get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 9620,
    "url": "http://patches.dpdk.org/api/patches/9620/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1450739573-5915-1-git-send-email-rkerur@gmail.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": "<1450739573-5915-1-git-send-email-rkerur@gmail.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1450739573-5915-1-git-send-email-rkerur@gmail.com",
    "date": "2015-12-21T23:12:53",
    "name": "[dpdk-dev,v1] Modify and modularize l3fwd code",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "88b2a7f85f93c6b3ae82fd70fa5b416e331aa253",
    "submitter": {
        "id": 134,
        "url": "http://patches.dpdk.org/api/people/134/?format=api",
        "name": "Ravi Kerur",
        "email": "rkerur@gmail.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1450739573-5915-1-git-send-email-rkerur@gmail.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/9620/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/9620/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 8FA28593A;\n\tTue, 22 Dec 2015 00:13:10 +0100 (CET)",
            "from mail-pa0-f48.google.com (mail-pa0-f48.google.com\n\t[209.85.220.48]) by dpdk.org (Postfix) with ESMTP id 93A92593A\n\tfor <dev@dpdk.org>; Tue, 22 Dec 2015 00:13:07 +0100 (CET)",
            "by mail-pa0-f48.google.com with SMTP id cy9so24383452pac.0\n\tfor <dev@dpdk.org>; Mon, 21 Dec 2015 15:13:07 -0800 (PST)",
            "from user-PC.hsd1.ca.comcast.net\n\t(c-24-130-109-45.hsd1.ca.comcast.net. [24.130.109.45])\n\tby smtp.gmail.com with ESMTPSA id\n\t2sm36825101pfl.56.2015.12.21.15.13.05\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tMon, 21 Dec 2015 15:13:06 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=VfhCy2eLpbYJWh8DJ2puvgLpI0XaIL4Rdg1HtWYrpIg=;\n\tb=RXphbVc+wat4yBydtA3+v1QUaxacGzMsb0YKqSIeaMP/VYUcyv2lEFTng2hVaq3bU4\n\tLHP75lBbgeI83XuqgM4Je9C2aOZEsIi2d6qGK+D0k6Awzu7vn9ynEMwxsjwOGzmiXuga\n\t0WYXiPCBobPfo2bLuGxHN+YS3WpbqhUnLo6IWIS3TZNc/o62F6bQyVd9NJcidvqm9xIy\n\tGMBxNOIU8p/ifzkh5176HtIkvH0FXu1q2fdIXdgothJ44Vaxw+3rUqAXpLvpRq/+r++m\n\t+6Pjb1MgDLSkjTwPVXmXqyyIqH48naKfXEnbb+F1TJIkSX7QX3qe7vWx3TRaM8sKmm0v\n\tAjIg==",
        "X-Received": "by 10.66.190.98 with SMTP id gp2mr30945430pac.64.1450739586864; \n\tMon, 21 Dec 2015 15:13:06 -0800 (PST)",
        "From": "Ravi Kerur <rkerur@gmail.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 21 Dec 2015 15:12:53 -0800",
        "Message-Id": "<1450739573-5915-1-git-send-email-rkerur@gmail.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1450739511-5868-1-git-send-email-rkerur@gmail.com>",
        "References": "<1450739511-5868-1-git-send-email-rkerur@gmail.com>",
        "Subject": "[dpdk-dev] [PATCH v1] Modify and modularize l3fwd code",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <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": "v1:\n\t> Rebase to latest code base for DPDK team review.\n\nIntel team's (Konstantin, Bruce and Declan) review comments\n\nv4<-v3:\n        > Fix code review comments from Konstantin\n        > Move buffer optimization code into l3fwd_lpm_sse.h\n          and l3fwd_em_sse.h for LPM and EM respectively\n        > Add compile time __SSE4_1__ for header file inclusion\n        > Tested with CONFIG_RTE_MACHINE=default for non\n          __SSE4_1__ compilation and build\n        > Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04\n\nv3<-v2:\n        > Fix code review comments from Bruce\n        > Fix multiple static definitions\n        > Move local #defines to C files, common #defines\n                to H file.\n        > Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em\n        > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm\n        > Pass additional parameter to send_single_packet\n        > Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04\n\nv2<-v1:\n        > Fix errors in GCC 5.1\n        > Restore \"static inline\" functions, rearrange\n                functions to take \"static inline\" into account\n        > Duplicate main_loop for LPM and EM\n\nv1:\n        > Split main.c into following 3 files\n                > main.c, (parsing, buffer alloc, and other utilities)\n                > l3fwd_lpm.c, (Longest Prefix Match functions)\n                > l3fwd_em.c, (Exact Match f.e. Hash functions)\n                > l3fwd.h, (Common defines and prototypes)\n\n        > Select LPM or EM based on run time selection f.e.\n                > l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match)\n                > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)\n\n        > Options \"E\" and \"L\" are mutualy-exclusive.\n\n        > Use function pointers during initialiation of relevant\n                data structures.\n\n        > Remove unwanted #ifdefs in the code with exception to\n                > DO_RFC_1812_CHECKS\n                > RTE_MACHINE_CPUFLAG_SSE4_2\n\n        > Compiled for\n                > i686-native-linuxapp-gcc\n                > x86_64-native-linuxapp-gcc\n                > x86_x32-native-linuxapp-gcc\n                > x86_64-native-bsdapp-gcc\n\n        > Tested on\n                > Ubuntu 14.04 (GCC 4.8.4)\n                > FreeBSD 10.0 (GCC 4.8)\n                > I217 and I218 respectively.\n\nSigned-off-by: Ravi Kerur <rkerur@gmail.com>\n---\n examples/l3fwd/Makefile        |    9 +-\n examples/l3fwd/l3fwd.h         |  209 ++++\n examples/l3fwd/l3fwd_em.c      |  773 ++++++++++++++\n examples/l3fwd/l3fwd_em_sse.h  |  479 +++++++++\n examples/l3fwd/l3fwd_lpm.c     |  414 ++++++++\n examples/l3fwd/l3fwd_lpm_sse.h |  610 +++++++++++\n examples/l3fwd/main.c          | 2202 ++++------------------------------------\n 7 files changed, 2694 insertions(+), 2002 deletions(-)\n create mode 100644 examples/l3fwd/l3fwd.h\n create mode 100644 examples/l3fwd/l3fwd_em.c\n create mode 100644 examples/l3fwd/l3fwd_em_sse.h\n create mode 100644 examples/l3fwd/l3fwd_lpm.c\n create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h",
    "diff": "diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile\nindex 68de8fc..94a2282 100644\n--- a/examples/l3fwd/Makefile\n+++ b/examples/l3fwd/Makefile\n@@ -42,15 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk\n APP = l3fwd\n \n # all source are stored in SRCS-y\n-SRCS-y := main.c\n+SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c\n \n+CFLAGS += -I$(SRCDIR)\n CFLAGS += -O3 $(USER_FLAGS)\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/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h\nnew file mode 100644\nindex 0000000..50e40fe\n--- /dev/null\n+++ b/examples/l3fwd/l3fwd.h\n@@ -0,0 +1,209 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2015 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+#ifndef __L3_FWD_H__\n+#define __L3_FWD_H__\n+\n+#define DO_RFC_1812_CHECKS\n+\n+#define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1\n+\n+#define MAX_PKT_BURST     32\n+#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */\n+\n+#define MAX_RX_QUEUE_PER_LCORE 16\n+\n+/*\n+ * Try to avoid TX buffering if we have at least MAX_TX_BURST packets to send.\n+ */\n+#define\tMAX_TX_BURST\t  (MAX_PKT_BURST / 2)\n+\n+#define NB_SOCKETS        8\n+\n+/* Configure how many packets ahead to prefetch, when reading packets */\n+#define PREFETCH_OFFSET\t  3\n+\n+/* Hash parameters. */\n+#ifdef RTE_ARCH_X86_64\n+/* default to 4 million hash entries (approx) */\n+#define L3FWD_HASH_ENTRIES\t\t(1024*1024*4)\n+#else\n+/* 32-bit has less address-space for hugepage memory, limit to 1M entries */\n+#define L3FWD_HASH_ENTRIES\t\t(1024*1024*1)\n+#endif\n+#define HASH_ENTRY_NUMBER_DEFAULT\t4\n+\n+struct mbuf_table {\n+\tuint16_t len;\n+\tstruct rte_mbuf *m_table[MAX_PKT_BURST];\n+};\n+\n+struct lcore_rx_queue {\n+\tuint8_t port_id;\n+\tuint8_t queue_id;\n+} __rte_cache_aligned;\n+\n+struct lcore_conf {\n+\tuint16_t n_rx_queue;\n+\tstruct lcore_rx_queue rx_queue_list[MAX_RX_QUEUE_PER_LCORE];\n+\tuint16_t tx_queue_id[RTE_MAX_ETHPORTS];\n+\tstruct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS];\n+\tvoid *ipv4_lookup_struct;\n+\tvoid *ipv6_lookup_struct;\n+} __rte_cache_aligned;\n+\n+/* ethernet addresses of ports */\n+extern uint64_t dest_eth_addr[RTE_MAX_ETHPORTS];\n+extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];\n+\n+/* mask of enabled ports */\n+extern uint32_t enabled_port_mask;\n+\n+/* Used only in exact match mode. */\n+extern int ipv6; /**< ipv6 is false by default. */\n+extern uint32_t hash_entry_number;\n+\n+extern __m128i val_eth[RTE_MAX_ETHPORTS];\n+\n+extern struct lcore_conf lcore_conf[RTE_MAX_LCORE];\n+\n+/* Send burst of packets on an output interface */\n+static inline int\n+send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port)\n+{\n+\tstruct rte_mbuf **m_table;\n+\tint ret;\n+\tuint16_t queueid;\n+\n+\tqueueid = qconf->tx_queue_id[port];\n+\tm_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;\n+\n+\tret = rte_eth_tx_burst(port, queueid, m_table, n);\n+\tif (unlikely(ret < n)) {\n+\t\tdo {\n+\t\t\trte_pktmbuf_free(m_table[ret]);\n+\t\t} while (++ret < n);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* Enqueue a single packet, and send burst if queue is filled */\n+static inline int\n+send_single_packet(struct lcore_conf *qconf,\n+\t\tstruct rte_mbuf *m, uint8_t port)\n+{\n+\tuint16_t len;\n+\n+\tlen = qconf->tx_mbufs[port].len;\n+\tqconf->tx_mbufs[port].m_table[len] = m;\n+\tlen++;\n+\n+\t/* enough pkts to be sent */\n+\tif (unlikely(len == MAX_PKT_BURST)) {\n+\t\tsend_burst(qconf, MAX_PKT_BURST, port);\n+\t\tlen = 0;\n+\t}\n+\n+\tqconf->tx_mbufs[port].len = len;\n+\treturn 0;\n+}\n+\n+#ifdef DO_RFC_1812_CHECKS\n+static inline int\n+is_valid_ipv4_pkt(struct ipv4_hdr *pkt, uint32_t link_len)\n+{\n+\t/* From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2 */\n+\t/*\n+\t * 1. The packet length reported by the Link Layer must be large\n+\t * enough to hold the minimum length legal IP datagram (20 bytes).\n+\t */\n+\tif (link_len < sizeof(struct ipv4_hdr))\n+\t\treturn -1;\n+\n+\t/* 2. The IP checksum must be correct. */\n+\t/* this is checked in H/W */\n+\n+\t/*\n+\t * 3. The IP version number must be 4. If the version number is not 4\n+\t * then the packet may be another version of IP, such as IPng or\n+\t * ST-II.\n+\t */\n+\tif (((pkt->version_ihl) >> 4) != 4)\n+\t\treturn -3;\n+\t/*\n+\t * 4. The IP header length field must be large enough to hold the\n+\t * minimum length legal IP datagram (20 bytes = 5 words).\n+\t */\n+\tif ((pkt->version_ihl & 0xf) < 5)\n+\t\treturn -4;\n+\n+\t/*\n+\t * 5. The IP total length field must be large enough to hold the IP\n+\t * datagram header, whose length is specified in the IP header length\n+\t * field.\n+\t */\n+\tif (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct ipv4_hdr))\n+\t\treturn -5;\n+\n+\treturn 0;\n+}\n+#endif /* DO_RFC_1812_CHECKS */\n+\n+/* Function pointers for LPM or EM functionality. */\n+void\n+setup_lpm(const int socketid);\n+\n+void\n+setup_hash(const int socketid);\n+\n+int\n+em_main_loop(__attribute__((unused)) void *dummy);\n+\n+int\n+lpm_main_loop(__attribute__((unused)) void *dummy);\n+\n+/* Return ipv4/ipv6 fwd lookup struct for LPM or EM. */\n+void *\n+em_get_ipv4_l3fwd_lookup_struct(const int socketid);\n+\n+void *\n+em_get_ipv6_l3fwd_lookup_struct(const int socketid);\n+\n+void *\n+lpm_get_ipv4_l3fwd_lookup_struct(const int socketid);\n+\n+void *\n+lpm_get_ipv6_l3fwd_lookup_struct(const int socketid);\n+\n+#endif  /* __L3_FWD_H__ */\ndiff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c\nnew file mode 100644\nindex 0000000..e8f4fee\n--- /dev/null\n+++ b/examples/l3fwd/l3fwd_em.c\n@@ -0,0 +1,773 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2015 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 <stdio.h>\n+#include <stdlib.h>\n+#include <stdint.h>\n+#include <inttypes.h>\n+#include <sys/types.h>\n+#include <string.h>\n+#include <sys/queue.h>\n+#include <stdarg.h>\n+#include <errno.h>\n+#include <getopt.h>\n+\n+#include <rte_debug.h>\n+#include <rte_ether.h>\n+#include <rte_ethdev.h>\n+#include <rte_ring.h>\n+#include <rte_mempool.h>\n+#include <rte_cycles.h>\n+#include <rte_mbuf.h>\n+#include <rte_ip.h>\n+#include <rte_tcp.h>\n+#include <rte_udp.h>\n+#include <rte_hash.h>\n+\n+#include \"l3fwd.h\"\n+\n+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n+#include <rte_hash_crc.h>\n+#define DEFAULT_HASH_FUNC       rte_hash_crc\n+#else\n+#include <rte_jhash.h>\n+#define DEFAULT_HASH_FUNC       rte_jhash\n+#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n+\n+#define IPV6_ADDR_LEN 16\n+\n+struct ipv4_5tuple {\n+\tuint32_t ip_dst;\n+\tuint32_t ip_src;\n+\tuint16_t port_dst;\n+\tuint16_t port_src;\n+\tuint8_t  proto;\n+} __attribute__((__packed__));\n+\n+union ipv4_5tuple_host {\n+\tstruct {\n+\t\tuint8_t  pad0;\n+\t\tuint8_t  proto;\n+\t\tuint16_t pad1;\n+\t\tuint32_t ip_src;\n+\t\tuint32_t ip_dst;\n+\t\tuint16_t port_src;\n+\t\tuint16_t port_dst;\n+\t};\n+\t__m128i xmm;\n+};\n+\n+#define XMM_NUM_IN_IPV6_5TUPLE 3\n+\n+struct ipv6_5tuple {\n+\tuint8_t  ip_dst[IPV6_ADDR_LEN];\n+\tuint8_t  ip_src[IPV6_ADDR_LEN];\n+\tuint16_t port_dst;\n+\tuint16_t port_src;\n+\tuint8_t  proto;\n+} __attribute__((__packed__));\n+\n+union ipv6_5tuple_host {\n+\tstruct {\n+\t\tuint16_t pad0;\n+\t\tuint8_t  proto;\n+\t\tuint8_t  pad1;\n+\t\tuint8_t  ip_src[IPV6_ADDR_LEN];\n+\t\tuint8_t  ip_dst[IPV6_ADDR_LEN];\n+\t\tuint16_t port_src;\n+\t\tuint16_t port_dst;\n+\t\tuint64_t reserve;\n+\t};\n+\t__m128i xmm[XMM_NUM_IN_IPV6_5TUPLE];\n+};\n+\n+struct ipv4_l3fwd_em_route {\n+\tstruct ipv4_5tuple key;\n+\tuint8_t if_out;\n+};\n+\n+struct ipv6_l3fwd_em_route {\n+\tstruct ipv6_5tuple key;\n+\tuint8_t if_out;\n+};\n+\n+static struct ipv4_l3fwd_em_route ipv4_l3fwd_em_route_array[] = {\n+\t{{IPv4(101, 0, 0, 0), IPv4(100, 10, 0, 1),  101, 11, IPPROTO_TCP}, 0},\n+\t{{IPv4(201, 0, 0, 0), IPv4(200, 20, 0, 1),  102, 12, IPPROTO_TCP}, 1},\n+\t{{IPv4(111, 0, 0, 0), IPv4(100, 30, 0, 1),  101, 11, IPPROTO_TCP}, 2},\n+\t{{IPv4(211, 0, 0, 0), IPv4(200, 40, 0, 1),  102, 12, IPPROTO_TCP}, 3},\n+};\n+\n+static struct ipv6_l3fwd_em_route ipv6_l3fwd_em_route_array[] = {\n+\t{{\n+\t{0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n+\t{0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n+\t101, 11, IPPROTO_TCP}, 0},\n+\n+\t{{\n+\t{0xfe, 0x90, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n+\t{0xfe, 0x90, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n+\t102, 12, IPPROTO_TCP}, 1},\n+\n+\t{{\n+\t{0xfe, 0xa0, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n+\t{0xfe, 0xa0, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n+\t101, 11, IPPROTO_TCP}, 2},\n+\n+\t{{\n+\t{0xfe, 0xb0, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n+\t{0xfe, 0xb0, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n+\t102, 12, IPPROTO_TCP}, 3},\n+};\n+\n+struct rte_hash *ipv4_l3fwd_em_lookup_struct[NB_SOCKETS];\n+struct rte_hash *ipv6_l3fwd_em_lookup_struct[NB_SOCKETS];\n+\n+static inline uint32_t\n+ipv4_hash_crc(const void *data, __rte_unused uint32_t data_len,\n+\t\tuint32_t init_val)\n+{\n+\tconst union ipv4_5tuple_host *k;\n+\tuint32_t t;\n+\tconst uint32_t *p;\n+\n+\tk = data;\n+\tt = k->proto;\n+\tp = (const uint32_t *)&k->port_src;\n+\n+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n+\tinit_val = rte_hash_crc_4byte(t, init_val);\n+\tinit_val = rte_hash_crc_4byte(k->ip_src, init_val);\n+\tinit_val = rte_hash_crc_4byte(k->ip_dst, init_val);\n+\tinit_val = rte_hash_crc_4byte(*p, init_val);\n+#else /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n+\tinit_val = rte_jhash_1word(t, init_val);\n+\tinit_val = rte_jhash_1word(k->ip_src, init_val);\n+\tinit_val = rte_jhash_1word(k->ip_dst, init_val);\n+\tinit_val = rte_jhash_1word(*p, init_val);\n+#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n+\n+\treturn init_val;\n+}\n+\n+static inline uint32_t\n+ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,\n+\t\tuint32_t init_val)\n+{\n+\tconst union ipv6_5tuple_host *k;\n+\tuint32_t t;\n+\tconst uint32_t *p;\n+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n+\tconst uint32_t  *ip_src0, *ip_src1, *ip_src2, *ip_src3;\n+\tconst uint32_t  *ip_dst0, *ip_dst1, *ip_dst2, *ip_dst3;\n+#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n+\n+\tk = data;\n+\tt = k->proto;\n+\tp = (const uint32_t *)&k->port_src;\n+\n+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n+\tip_src0 = (const uint32_t *) k->ip_src;\n+\tip_src1 = (const uint32_t *)(k->ip_src+4);\n+\tip_src2 = (const uint32_t *)(k->ip_src+8);\n+\tip_src3 = (const uint32_t *)(k->ip_src+12);\n+\tip_dst0 = (const uint32_t *) k->ip_dst;\n+\tip_dst1 = (const uint32_t *)(k->ip_dst+4);\n+\tip_dst2 = (const uint32_t *)(k->ip_dst+8);\n+\tip_dst3 = (const uint32_t *)(k->ip_dst+12);\n+\tinit_val = rte_hash_crc_4byte(t, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_src0, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_src1, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_src2, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_src3, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_dst0, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_dst1, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_dst2, init_val);\n+\tinit_val = rte_hash_crc_4byte(*ip_dst3, init_val);\n+\tinit_val = rte_hash_crc_4byte(*p, init_val);\n+#else /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n+\tinit_val = rte_jhash_1word(t, init_val);\n+\tinit_val = rte_jhash(k->ip_src,\n+\t\t\tsizeof(uint8_t) * IPV6_ADDR_LEN, init_val);\n+\tinit_val = rte_jhash(k->ip_dst,\n+\t\t\tsizeof(uint8_t) * IPV6_ADDR_LEN, init_val);\n+\tinit_val = rte_jhash_1word(*p, init_val);\n+#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n+\treturn init_val;\n+}\n+\n+#define IPV4_L3FWD_EM_NUM_ROUTES \\\n+\t(sizeof(ipv4_l3fwd_em_route_array) / sizeof(ipv4_l3fwd_em_route_array[0]))\n+\n+#define IPV6_L3FWD_EM_NUM_ROUTES \\\n+\t(sizeof(ipv6_l3fwd_em_route_array) / sizeof(ipv6_l3fwd_em_route_array[0]))\n+\n+static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned;\n+static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned;\n+\n+static __m128i mask0;\n+static __m128i mask1;\n+static __m128i mask2;\n+\n+static inline uint8_t\n+em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct)\n+{\n+\tint ret = 0;\n+\tunion ipv4_5tuple_host key;\n+\tstruct rte_hash *ipv4_l3fwd_lookup_struct =\n+\t\t(struct rte_hash *)lookup_struct;\n+\n+\tipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live);\n+\t__m128i data = _mm_loadu_si128((__m128i *)(ipv4_hdr));\n+\n+\t/*\n+\t * Get 5 tuple: dst port, src port, dst IP address,\n+\t * src IP address and protocol.\n+\t */\n+\tkey.xmm = _mm_and_si128(data, mask0);\n+\n+\t/* Find destination port */\n+\tret = rte_hash_lookup(ipv4_l3fwd_lookup_struct, (const void *)&key);\n+\treturn (uint8_t)((ret < 0) ? portid : ipv4_l3fwd_out_if[ret]);\n+}\n+\n+static inline uint8_t\n+em_get_ipv6_dst_port(void *ipv6_hdr,  uint8_t portid, void *lookup_struct)\n+{\n+\tint ret = 0;\n+\tunion ipv6_5tuple_host key;\n+\tstruct rte_hash *ipv6_l3fwd_lookup_struct =\n+\t\t(struct rte_hash *)lookup_struct;\n+\n+\tipv6_hdr = (uint8_t *)ipv6_hdr + offsetof(struct ipv6_hdr, payload_len);\n+\t__m128i data0 =\n+\t\t_mm_loadu_si128((__m128i *)(ipv6_hdr));\n+\t__m128i data1 =\n+\t\t_mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+\n+\t\t\t\t\tsizeof(__m128i)));\n+\t__m128i data2 =\n+\t\t_mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+\n+\t\t\t\t\tsizeof(__m128i)+sizeof(__m128i)));\n+\n+\t/* Get part of 5 tuple: src IP address lower 96 bits and protocol */\n+\tkey.xmm[0] = _mm_and_si128(data0, mask1);\n+\n+\t/*\n+\t * Get part of 5 tuple: dst IP address lower 96 bits\n+\t * and src IP address higher 32 bits.\n+\t */\n+\tkey.xmm[1] = data1;\n+\n+\t/*\n+\t * Get part of 5 tuple: dst port and src port\n+\t * and dst IP address higher 32 bits.\n+\t */\n+\tkey.xmm[2] = _mm_and_si128(data2, mask2);\n+\n+\t/* Find destination port */\n+\tret = rte_hash_lookup(ipv6_l3fwd_lookup_struct, (const void *)&key);\n+\treturn (uint8_t)((ret < 0) ? portid : ipv6_l3fwd_out_if[ret]);\n+}\n+\n+static inline __attribute__((always_inline)) void\n+l3fwd_em_simple_forward(struct rte_mbuf *m, uint8_t portid,\n+\t\tstruct lcore_conf *qconf)\n+{\n+\tstruct ether_hdr *eth_hdr;\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tuint8_t dst_port;\n+\n+\teth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);\n+\n+\tif (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {\n+\t\t/* Handle IPv4 headers.*/\n+\t\tipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,\n+\t\t\t\t\t\t   sizeof(struct ether_hdr));\n+\n+#ifdef DO_RFC_1812_CHECKS\n+\t\t/* Check to make sure the packet is valid (RFC1812) */\n+\t\tif (is_valid_ipv4_pkt(ipv4_hdr, m->pkt_len) < 0) {\n+\t\t\trte_pktmbuf_free(m);\n+\t\t\treturn;\n+\t\t}\n+#endif\n+\t\t dst_port = em_get_ipv4_dst_port(ipv4_hdr, portid,\n+\t\t\t\t\t\tqconf->ipv4_lookup_struct);\n+\n+\t\tif (dst_port >= RTE_MAX_ETHPORTS ||\n+\t\t\t(enabled_port_mask & 1 << dst_port) == 0)\n+\t\t\tdst_port = portid;\n+\n+#ifdef DO_RFC_1812_CHECKS\n+\t\t/* Update time to live and header checksum */\n+\t\t--(ipv4_hdr->time_to_live);\n+\t\t++(ipv4_hdr->hdr_checksum);\n+#endif\n+\t\t/* dst addr */\n+\t\t*(uint64_t *)&eth_hdr->d_addr = dest_eth_addr[dst_port];\n+\n+\t\t/* src addr */\n+\t\tether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);\n+\n+\t\tsend_single_packet(qconf, m, dst_port);\n+\t} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {\n+\t\t/* Handle IPv6 headers.*/\n+\t\tstruct ipv6_hdr *ipv6_hdr;\n+\n+\t\tipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,\n+\t\t\t\t\t\t   sizeof(struct ether_hdr));\n+\n+\t\tdst_port = em_get_ipv6_dst_port(ipv6_hdr, portid,\n+\t\t\t\t\tqconf->ipv6_lookup_struct);\n+\n+\t\tif (dst_port >= RTE_MAX_ETHPORTS ||\n+\t\t\t(enabled_port_mask & 1 << dst_port) == 0)\n+\t\t\tdst_port = portid;\n+\n+\t\t/* dst addr */\n+\t\t*(uint64_t *)&eth_hdr->d_addr = dest_eth_addr[dst_port];\n+\n+\t\t/* src addr */\n+\t\tether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);\n+\n+\t\tsend_single_packet(qconf, m, dst_port);\n+\t} else {\n+\t\t/* Free the mbuf that contains non-IPV4/IPV6 packet */\n+\t\trte_pktmbuf_free(m);\n+\t}\n+}\n+\n+/*\n+ * Include header file if SSE4_1 is enabled for\n+ * buffer optimization i.e. ENABLE_MULTI_BUFFER_OPTIMIZE=1.\n+ */\n+#if defined(__SSE4_1__)\n+#include \"l3fwd_em_sse.h\"\n+#endif\n+\n+/*\n+ * Buffer non-optimized handling of packets, invoked\n+ * from main_loop.\n+ */\n+static inline void\n+l3fwd_em_no_opt_send_packets(int nb_rx, struct rte_mbuf **pkts_burst,\n+\t\t\tuint8_t portid, struct lcore_conf *qconf)\n+{\n+\tint32_t j;\n+\n+\t/* Prefetch first packets */\n+\tfor (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++)\n+\t\trte_prefetch0(rte_pktmbuf_mtod(pkts_burst[j], void *));\n+\n+\t/*\n+\t * Prefetch and forward already prefetched\n+\t * packets.\n+\t */\n+\tfor (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {\n+\t\trte_prefetch0(rte_pktmbuf_mtod(pkts_burst[\n+\t\t\t\tj + PREFETCH_OFFSET], void *));\n+\t\tl3fwd_em_simple_forward(pkts_burst[j], portid, qconf);\n+\t}\n+\n+\t/* Forward remaining prefetched packets */\n+\tfor (; j < nb_rx; j++)\n+\t\tl3fwd_em_simple_forward(pkts_burst[j], portid, qconf);\n+}\n+\n+static void\n+convert_ipv4_5tuple(struct ipv4_5tuple *key1,\n+\t\tunion ipv4_5tuple_host *key2)\n+{\n+\tkey2->ip_dst = rte_cpu_to_be_32(key1->ip_dst);\n+\tkey2->ip_src = rte_cpu_to_be_32(key1->ip_src);\n+\tkey2->port_dst = rte_cpu_to_be_16(key1->port_dst);\n+\tkey2->port_src = rte_cpu_to_be_16(key1->port_src);\n+\tkey2->proto = key1->proto;\n+\tkey2->pad0 = 0;\n+\tkey2->pad1 = 0;\n+}\n+\n+static void\n+convert_ipv6_5tuple(struct ipv6_5tuple *key1,\n+\t\tunion ipv6_5tuple_host *key2)\n+{\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < 16; i++) {\n+\t\tkey2->ip_dst[i] = key1->ip_dst[i];\n+\t\tkey2->ip_src[i] = key1->ip_src[i];\n+\t}\n+\tkey2->port_dst = rte_cpu_to_be_16(key1->port_dst);\n+\tkey2->port_src = rte_cpu_to_be_16(key1->port_src);\n+\tkey2->proto = key1->proto;\n+\tkey2->pad0 = 0;\n+\tkey2->pad1 = 0;\n+\tkey2->reserve = 0;\n+}\n+\n+#define BYTE_VALUE_MAX 256\n+#define ALL_32_BITS 0xffffffff\n+#define BIT_8_TO_15 0x0000ff00\n+static inline void\n+populate_ipv4_few_flow_into_table(const struct rte_hash *h)\n+{\n+\tuint32_t i;\n+\tint32_t ret;\n+\n+\tmask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS,\n+\t\t\t\tALL_32_BITS, BIT_8_TO_15);\n+\n+\tfor (i = 0; i < IPV4_L3FWD_EM_NUM_ROUTES; i++) {\n+\t\tstruct ipv4_l3fwd_em_route  entry;\n+\t\tunion ipv4_5tuple_host newkey;\n+\n+\t\tentry = ipv4_l3fwd_em_route_array[i];\n+\t\tconvert_ipv4_5tuple(&entry.key, &newkey);\n+\t\tret = rte_hash_add_key(h, (void *) &newkey);\n+\t\tif (ret < 0) {\n+\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %\" PRIu32\n+\t\t\t\t\" to the l3fwd hash.\\n\", i);\n+\t\t}\n+\t\tipv4_l3fwd_out_if[ret] = entry.if_out;\n+\t}\n+\tprintf(\"Hash: Adding 0x%\" PRIx64 \" keys\\n\", IPV4_L3FWD_EM_NUM_ROUTES);\n+}\n+\n+#define BIT_16_TO_23 0x00ff0000\n+static inline void\n+populate_ipv6_few_flow_into_table(const struct rte_hash *h)\n+{\n+\tuint32_t i;\n+\tint32_t ret;\n+\n+\tmask1 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS,\n+\t\t\t\tALL_32_BITS, BIT_16_TO_23);\n+\n+\tmask2 = _mm_set_epi32(0, 0, ALL_32_BITS, ALL_32_BITS);\n+\n+\tfor (i = 0; i < IPV6_L3FWD_EM_NUM_ROUTES; i++) {\n+\t\tstruct ipv6_l3fwd_em_route entry;\n+\t\tunion ipv6_5tuple_host newkey;\n+\n+\t\tentry = ipv6_l3fwd_em_route_array[i];\n+\t\tconvert_ipv6_5tuple(&entry.key, &newkey);\n+\t\tret = rte_hash_add_key(h, (void *) &newkey);\n+\t\tif (ret < 0) {\n+\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %\" PRIu32\n+\t\t\t\t\" to the l3fwd hash.\\n\", i);\n+\t\t}\n+\t\tipv6_l3fwd_out_if[ret] = entry.if_out;\n+\t}\n+\tprintf(\"Hash: Adding 0x%\" PRIx64 \"keys\\n\", IPV6_L3FWD_EM_NUM_ROUTES);\n+}\n+\n+#define NUMBER_PORT_USED 4\n+static inline void\n+populate_ipv4_many_flow_into_table(const struct rte_hash *h,\n+\t\tunsigned int nr_flow)\n+{\n+\tunsigned i;\n+\n+\tmask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS,\n+\t\t\t\tALL_32_BITS, BIT_8_TO_15);\n+\n+\tfor (i = 0; i < nr_flow; i++) {\n+\t\tstruct ipv4_l3fwd_em_route entry;\n+\t\tunion ipv4_5tuple_host newkey;\n+\n+\t\tuint8_t a = (uint8_t)\n+\t\t\t((i/NUMBER_PORT_USED)%BYTE_VALUE_MAX);\n+\t\tuint8_t b = (uint8_t)\n+\t\t\t(((i/NUMBER_PORT_USED)/BYTE_VALUE_MAX)%BYTE_VALUE_MAX);\n+\t\tuint8_t c = (uint8_t)\n+\t\t\t((i/NUMBER_PORT_USED)/(BYTE_VALUE_MAX*BYTE_VALUE_MAX));\n+\n+\t\t/* Create the ipv4 exact match flow */\n+\t\tmemset(&entry, 0, sizeof(entry));\n+\t\tswitch (i & (NUMBER_PORT_USED - 1)) {\n+\t\tcase 0:\n+\t\t\tentry = ipv4_l3fwd_em_route_array[0];\n+\t\t\tentry.key.ip_dst = IPv4(101, c, b, a);\n+\t\t\tbreak;\n+\t\tcase 1:\n+\t\t\tentry = ipv4_l3fwd_em_route_array[1];\n+\t\t\tentry.key.ip_dst = IPv4(201, c, b, a);\n+\t\t\tbreak;\n+\t\tcase 2:\n+\t\t\tentry = ipv4_l3fwd_em_route_array[2];\n+\t\t\tentry.key.ip_dst = IPv4(111, c, b, a);\n+\t\t\tbreak;\n+\t\tcase 3:\n+\t\t\tentry = ipv4_l3fwd_em_route_array[3];\n+\t\t\tentry.key.ip_dst = IPv4(211, c, b, a);\n+\t\t\tbreak;\n+\t\t};\n+\t\tconvert_ipv4_5tuple(&entry.key, &newkey);\n+\t\tint32_t ret = rte_hash_add_key(h, (void *) &newkey);\n+\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %u\\n\", i);\n+\n+\t\tipv4_l3fwd_out_if[ret] = (uint8_t) entry.if_out;\n+\n+\t}\n+\tprintf(\"Hash: Adding 0x%x keys\\n\", nr_flow);\n+}\n+\n+static inline void\n+populate_ipv6_many_flow_into_table(const struct rte_hash *h,\n+\t\tunsigned int nr_flow)\n+{\n+\tunsigned i;\n+\n+\tmask1 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS,\n+\t\t\t\tALL_32_BITS, BIT_16_TO_23);\n+\tmask2 = _mm_set_epi32(0, 0, ALL_32_BITS, ALL_32_BITS);\n+\n+\tfor (i = 0; i < nr_flow; i++) {\n+\t\tstruct ipv6_l3fwd_em_route entry;\n+\t\tunion ipv6_5tuple_host newkey;\n+\n+\t\tuint8_t a = (uint8_t)\n+\t\t\t((i/NUMBER_PORT_USED)%BYTE_VALUE_MAX);\n+\t\tuint8_t b = (uint8_t)\n+\t\t\t(((i/NUMBER_PORT_USED)/BYTE_VALUE_MAX)%BYTE_VALUE_MAX);\n+\t\tuint8_t c = (uint8_t)\n+\t\t\t((i/NUMBER_PORT_USED)/(BYTE_VALUE_MAX*BYTE_VALUE_MAX));\n+\n+\t\t/* Create the ipv6 exact match flow */\n+\t\tmemset(&entry, 0, sizeof(entry));\n+\t\tswitch (i & (NUMBER_PORT_USED - 1)) {\n+\t\tcase 0:\n+\t\t\tentry = ipv6_l3fwd_em_route_array[0];\n+\t\t\tbreak;\n+\t\tcase 1:\n+\t\t\tentry = ipv6_l3fwd_em_route_array[1];\n+\t\t\tbreak;\n+\t\tcase 2:\n+\t\t\tentry = ipv6_l3fwd_em_route_array[2];\n+\t\t\tbreak;\n+\t\tcase 3:\n+\t\t\tentry = ipv6_l3fwd_em_route_array[3];\n+\t\t\tbreak;\n+\t\t};\n+\t\tentry.key.ip_dst[13] = c;\n+\t\tentry.key.ip_dst[14] = b;\n+\t\tentry.key.ip_dst[15] = a;\n+\t\tconvert_ipv6_5tuple(&entry.key, &newkey);\n+\t\tint32_t ret = rte_hash_add_key(h, (void *) &newkey);\n+\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %u\\n\", i);\n+\n+\t\tipv6_l3fwd_out_if[ret] = (uint8_t) entry.if_out;\n+\n+\t}\n+\tprintf(\"Hash: Adding 0x%x keys\\n\", nr_flow);\n+}\n+\n+int\n+em_main_loop(__attribute__((unused)) void *dummy)\n+{\n+\tstruct rte_mbuf *pkts_burst[MAX_PKT_BURST];\n+\tunsigned lcore_id;\n+\tuint64_t prev_tsc, diff_tsc, cur_tsc;\n+\tint i, nb_rx;\n+\tuint8_t portid, queueid;\n+\tstruct lcore_conf *qconf;\n+\tconst uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /\n+\t\tUS_PER_S * BURST_TX_DRAIN_US;\n+\n+\tprev_tsc = 0;\n+\n+\tlcore_id = rte_lcore_id();\n+\tqconf = &lcore_conf[lcore_id];\n+\n+\tif (qconf->n_rx_queue == 0) {\n+\t\tRTE_LOG(INFO, L3FWD, \"lcore %u has nothing to do\\n\", lcore_id);\n+\t\treturn 0;\n+\t}\n+\n+\tRTE_LOG(INFO, L3FWD, \"entering main loop on lcore %u\\n\", lcore_id);\n+\n+\tfor (i = 0; i < qconf->n_rx_queue; i++) {\n+\n+\t\tportid = qconf->rx_queue_list[i].port_id;\n+\t\tqueueid = qconf->rx_queue_list[i].queue_id;\n+\t\tRTE_LOG(INFO, L3FWD,\n+\t\t\t\" -- lcoreid=%u portid=%hhu rxqueueid=%hhu\\n\",\n+\t\t\tlcore_id, portid, queueid);\n+\t}\n+\n+\twhile (1) {\n+\n+\t\tcur_tsc = rte_rdtsc();\n+\n+\t\t/*\n+\t\t * TX burst queue drain\n+\t\t */\n+\t\tdiff_tsc = cur_tsc - prev_tsc;\n+\t\tif (unlikely(diff_tsc > drain_tsc)) {\n+\n+\t\t\t/*\n+\t\t\t * This could be optimized (use queueid instead of\n+\t\t\t * portid), but it is not called so often\n+\t\t\t */\n+\t\t\tfor (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {\n+\t\t\t\tif (qconf->tx_mbufs[portid].len == 0)\n+\t\t\t\t\tcontinue;\n+\t\t\t\tsend_burst(qconf,\n+\t\t\t\t\tqconf->tx_mbufs[portid].len,\n+\t\t\t\t\tportid);\n+\t\t\t\tqconf->tx_mbufs[portid].len = 0;\n+\t\t\t}\n+\n+\t\t\tprev_tsc = cur_tsc;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Read packet from RX queues\n+\t\t */\n+\t\tfor (i = 0; i < qconf->n_rx_queue; ++i) {\n+\t\t\tportid = qconf->rx_queue_list[i].port_id;\n+\t\t\tqueueid = qconf->rx_queue_list[i].queue_id;\n+\t\t\tnb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,\n+\t\t\t\tMAX_PKT_BURST);\n+\t\t\tif (nb_rx == 0)\n+\t\t\t\tcontinue;\n+\n+\t\t\t/*\n+\t\t\t * For SSE4_1 use ENABLE_MULTI_BUFFER_OPTIMIZE=1\n+\t\t\t * code.\n+\t\t\t */\n+#if defined(__SSE4_1__)\n+\t\t\tl3fwd_em_send_packets(nb_rx, pkts_burst,\n+\t\t\t\t\t\t\tportid, qconf);\n+#else\n+\t\t\tl3fwd_em_no_opt_send_packets(nb_rx, pkts_burst,\n+\t\t\t\t\t\t\tportid, qconf);\n+#endif /* __SSE_4_1__ */\n+\t\t}\n+\t}\n+}\n+\n+/*\n+ * Initialize exact match (hash) parameters.\n+ */\n+void\n+setup_hash(const int socketid)\n+{\n+\tstruct rte_hash_parameters ipv4_l3fwd_hash_params = {\n+\t\t.name = NULL,\n+\t\t.entries = L3FWD_HASH_ENTRIES,\n+\t\t.key_len = sizeof(union ipv4_5tuple_host),\n+\t\t.hash_func = ipv4_hash_crc,\n+\t\t.hash_func_init_val = 0,\n+\t};\n+\n+\tstruct rte_hash_parameters ipv6_l3fwd_hash_params = {\n+\t\t.name = NULL,\n+\t\t.entries = L3FWD_HASH_ENTRIES,\n+\t\t.key_len = sizeof(union ipv6_5tuple_host),\n+\t\t.hash_func = ipv6_hash_crc,\n+\t\t.hash_func_init_val = 0,\n+\t};\n+\n+\tchar s[64];\n+\n+\t/* create ipv4 hash */\n+\tsnprintf(s, sizeof(s), \"ipv4_l3fwd_hash_%d\", socketid);\n+\tipv4_l3fwd_hash_params.name = s;\n+\tipv4_l3fwd_hash_params.socket_id = socketid;\n+\tipv4_l3fwd_em_lookup_struct[socketid] =\n+\t\trte_hash_create(&ipv4_l3fwd_hash_params);\n+\tif (ipv4_l3fwd_em_lookup_struct[socketid] == NULL)\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"Unable to create the l3fwd hash on socket %d\\n\",\n+\t\t\tsocketid);\n+\n+\t/* create ipv6 hash */\n+\tsnprintf(s, sizeof(s), \"ipv6_l3fwd_hash_%d\", socketid);\n+\tipv6_l3fwd_hash_params.name = s;\n+\tipv6_l3fwd_hash_params.socket_id = socketid;\n+\tipv6_l3fwd_em_lookup_struct[socketid] =\n+\t\trte_hash_create(&ipv6_l3fwd_hash_params);\n+\tif (ipv6_l3fwd_em_lookup_struct[socketid] == NULL)\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"Unable to create the l3fwd hash on socket %d\\n\",\n+\t\t\tsocketid);\n+\n+\tif (hash_entry_number != HASH_ENTRY_NUMBER_DEFAULT) {\n+\t\t/* For testing hash matching with a large number of flows we\n+\t\t * generate millions of IP 5-tuples with an incremented dst\n+\t\t * address to initialize the hash table. */\n+\t\tif (ipv6 == 0) {\n+\t\t\t/* populate the ipv4 hash */\n+\t\t\tpopulate_ipv4_many_flow_into_table(\n+\t\t\t\tipv4_l3fwd_em_lookup_struct[socketid],\n+\t\t\t\thash_entry_number);\n+\t\t} else {\n+\t\t\t/* populate the ipv6 hash */\n+\t\t\tpopulate_ipv6_many_flow_into_table(\n+\t\t\t\tipv6_l3fwd_em_lookup_struct[socketid],\n+\t\t\t\thash_entry_number);\n+\t\t}\n+\t} else {\n+\t\t/*\n+\t\t * Use data in ipv4/ipv6 l3fwd lookup table\n+\t\t * directly to initialize the hash table.\n+\t\t */\n+\t\tif (ipv6 == 0) {\n+\t\t\t/* populate the ipv4 hash */\n+\t\t\tpopulate_ipv4_few_flow_into_table(\n+\t\t\t\tipv4_l3fwd_em_lookup_struct[socketid]);\n+\t\t} else {\n+\t\t\t/* populate the ipv6 hash */\n+\t\t\tpopulate_ipv6_few_flow_into_table(\n+\t\t\t\tipv6_l3fwd_em_lookup_struct[socketid]);\n+\t\t}\n+\t}\n+}\n+\n+/* Return ipv4/ipv6 em fwd lookup struct. */\n+void *\n+em_get_ipv4_l3fwd_lookup_struct(const int socketid)\n+{\n+\treturn ipv4_l3fwd_em_lookup_struct[socketid];\n+}\n+\n+void *\n+em_get_ipv6_l3fwd_lookup_struct(const int socketid)\n+{\n+\treturn ipv6_l3fwd_em_lookup_struct[socketid];\n+}\ndiff --git a/examples/l3fwd/l3fwd_em_sse.h b/examples/l3fwd/l3fwd_em_sse.h\nnew file mode 100644\nindex 0000000..5287671\n--- /dev/null\n+++ b/examples/l3fwd/l3fwd_em_sse.h\n@@ -0,0 +1,479 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2015 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+#ifndef __L3FWD_EM_SSE_H__\n+#define __L3FWD_EM_SSE_H__\n+\n+#define MASK_ALL_PKTS   0xff\n+#define EXCLUDE_1ST_PKT 0xfe\n+#define EXCLUDE_2ND_PKT 0xfd\n+#define EXCLUDE_3RD_PKT 0xfb\n+#define EXCLUDE_4TH_PKT 0xf7\n+#define EXCLUDE_5TH_PKT 0xef\n+#define EXCLUDE_6TH_PKT 0xdf\n+#define EXCLUDE_7TH_PKT 0xbf\n+#define EXCLUDE_8TH_PKT 0x7f\n+\n+static inline void\n+simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid,\n+\t\t\tstruct lcore_conf *qconf)\n+{\n+\tstruct ether_hdr *eth_hdr[8];\n+\tstruct ipv4_hdr *ipv4_hdr[8];\n+\tuint8_t dst_port[8];\n+\tint32_t ret[8];\n+\tunion ipv4_5tuple_host key[8];\n+\t__m128i data[8];\n+\n+\teth_hdr[0] = rte_pktmbuf_mtod(m[0], struct ether_hdr *);\n+\teth_hdr[1] = rte_pktmbuf_mtod(m[1], struct ether_hdr *);\n+\teth_hdr[2] = rte_pktmbuf_mtod(m[2], struct ether_hdr *);\n+\teth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);\n+\teth_hdr[4] = rte_pktmbuf_mtod(m[4], struct ether_hdr *);\n+\teth_hdr[5] = rte_pktmbuf_mtod(m[5], struct ether_hdr *);\n+\teth_hdr[6] = rte_pktmbuf_mtod(m[6], struct ether_hdr *);\n+\teth_hdr[7] = rte_pktmbuf_mtod(m[7], struct ether_hdr *);\n+\n+\t/* Handle IPv4 headers.*/\n+\tipv4_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\n+#ifdef DO_RFC_1812_CHECKS\n+\t/* Check to make sure the packet is valid (RFC1812) */\n+\tuint8_t valid_mask = MASK_ALL_PKTS;\n+\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[0], m[0]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[0]);\n+\t\tvalid_mask &= EXCLUDE_1ST_PKT;\n+\t}\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[1], m[1]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[1]);\n+\t\tvalid_mask &= EXCLUDE_2ND_PKT;\n+\t}\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[2], m[2]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[2]);\n+\t\tvalid_mask &= EXCLUDE_3RD_PKT;\n+\t}\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[3], m[3]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[3]);\n+\t\tvalid_mask &= EXCLUDE_4TH_PKT;\n+\t}\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[4], m[4]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[4]);\n+\t\tvalid_mask &= EXCLUDE_5TH_PKT;\n+\t}\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[5], m[5]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[5]);\n+\t\tvalid_mask &= EXCLUDE_6TH_PKT;\n+\t}\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[6], m[6]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[6]);\n+\t\tvalid_mask &= EXCLUDE_7TH_PKT;\n+\t}\n+\tif (is_valid_ipv4_pkt(ipv4_hdr[7], m[7]->pkt_len) < 0) {\n+\t\trte_pktmbuf_free(m[7]);\n+\t\tvalid_mask &= EXCLUDE_8TH_PKT;\n+\t}\n+\tif (unlikely(valid_mask != MASK_ALL_PKTS)) {\n+\t\tif (valid_mask == 0) {\n+\t\t\treturn;\n+\t\t} else {\n+\t\t\tuint8_t i = 0;\n+\n+\t\t\tfor (i = 0; i < 8; i++) {\n+\t\t\t\tif ((0x1 << i) & valid_mask) {\n+\t\t\t\t\tl3fwd_em_simple_forward(m[i],\n+\t\t\t\t\t\t\tportid, qconf);\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\treturn;\n+\t\t}\n+\t}\n+#endif /* End of #ifdef DO_RFC_1812_CHECKS */\n+\n+\tdata[0] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[0], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[1] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[1], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[2] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[2], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[3] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[3], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[4] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[4], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[5] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[5], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[6] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[6], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[7] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[7], __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n+\n+\tkey[0].xmm = _mm_and_si128(data[0], mask0);\n+\tkey[1].xmm = _mm_and_si128(data[1], mask0);\n+\tkey[2].xmm = _mm_and_si128(data[2], mask0);\n+\tkey[3].xmm = _mm_and_si128(data[3], mask0);\n+\tkey[4].xmm = _mm_and_si128(data[4], mask0);\n+\tkey[5].xmm = _mm_and_si128(data[5], mask0);\n+\tkey[6].xmm = _mm_and_si128(data[6], mask0);\n+\tkey[7].xmm = _mm_and_si128(data[7], mask0);\n+\n+\tconst void *key_array[8] = {&key[0], &key[1], &key[2], &key[3],\n+\t\t\t\t&key[4], &key[5], &key[6], &key[7]};\n+\n+\trte_hash_lookup_multi(qconf->ipv4_lookup_struct, &key_array[0], 8, ret);\n+\tdst_port[0] = (uint8_t) ((ret[0] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[0]]);\n+\tdst_port[1] = (uint8_t) ((ret[1] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[1]]);\n+\tdst_port[2] = (uint8_t) ((ret[2] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[2]]);\n+\tdst_port[3] = (uint8_t) ((ret[3] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[3]]);\n+\tdst_port[4] = (uint8_t) ((ret[4] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[4]]);\n+\tdst_port[5] = (uint8_t) ((ret[5] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[5]]);\n+\tdst_port[6] = (uint8_t) ((ret[6] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[6]]);\n+\tdst_port[7] = (uint8_t) ((ret[7] < 0) ?\n+\t\t\tportid : ipv4_l3fwd_out_if[ret[7]]);\n+\n+\tif (dst_port[0] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[0]) == 0)\n+\t\tdst_port[0] = portid;\n+\n+\tif (dst_port[1] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[1]) == 0)\n+\t\tdst_port[1] = portid;\n+\n+\tif (dst_port[2] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[2]) == 0)\n+\t\tdst_port[2] = portid;\n+\n+\tif (dst_port[3] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[3]) == 0)\n+\t\tdst_port[3] = portid;\n+\n+\tif (dst_port[4] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[4]) == 0)\n+\t\tdst_port[4] = portid;\n+\n+\tif (dst_port[5] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[5]) == 0)\n+\t\tdst_port[5] = portid;\n+\n+\tif (dst_port[6] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[6]) == 0)\n+\t\tdst_port[6] = portid;\n+\n+\tif (dst_port[7] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[7]) == 0)\n+\t\tdst_port[7] = portid;\n+\n+#ifdef DO_RFC_1812_CHECKS\n+\t/* Update time to live and header checksum */\n+\t--(ipv4_hdr[0]->time_to_live);\n+\t--(ipv4_hdr[1]->time_to_live);\n+\t--(ipv4_hdr[2]->time_to_live);\n+\t--(ipv4_hdr[3]->time_to_live);\n+\t++(ipv4_hdr[0]->hdr_checksum);\n+\t++(ipv4_hdr[1]->hdr_checksum);\n+\t++(ipv4_hdr[2]->hdr_checksum);\n+\t++(ipv4_hdr[3]->hdr_checksum);\n+\t--(ipv4_hdr[4]->time_to_live);\n+\t--(ipv4_hdr[5]->time_to_live);\n+\t--(ipv4_hdr[6]->time_to_live);\n+\t--(ipv4_hdr[7]->time_to_live);\n+\t++(ipv4_hdr[4]->hdr_checksum);\n+\t++(ipv4_hdr[5]->hdr_checksum);\n+\t++(ipv4_hdr[6]->hdr_checksum);\n+\t++(ipv4_hdr[7]->hdr_checksum);\n+#endif\n+\n+\t/* dst addr */\n+\t*(uint64_t *)&eth_hdr[0]->d_addr = dest_eth_addr[dst_port[0]];\n+\t*(uint64_t *)&eth_hdr[1]->d_addr = dest_eth_addr[dst_port[1]];\n+\t*(uint64_t *)&eth_hdr[2]->d_addr = dest_eth_addr[dst_port[2]];\n+\t*(uint64_t *)&eth_hdr[3]->d_addr = dest_eth_addr[dst_port[3]];\n+\t*(uint64_t *)&eth_hdr[4]->d_addr = dest_eth_addr[dst_port[4]];\n+\t*(uint64_t *)&eth_hdr[5]->d_addr = dest_eth_addr[dst_port[5]];\n+\t*(uint64_t *)&eth_hdr[6]->d_addr = dest_eth_addr[dst_port[6]];\n+\t*(uint64_t *)&eth_hdr[7]->d_addr = dest_eth_addr[dst_port[7]];\n+\n+\t/* src addr */\n+\tether_addr_copy(&ports_eth_addr[dst_port[0]], &eth_hdr[0]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[1]], &eth_hdr[1]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[2]], &eth_hdr[2]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[3]], &eth_hdr[3]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[4]], &eth_hdr[4]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[5]], &eth_hdr[5]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[6]], &eth_hdr[6]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[7]], &eth_hdr[7]->s_addr);\n+\n+\tsend_single_packet(qconf, m[0], (uint8_t)dst_port[0]);\n+\tsend_single_packet(qconf, m[1], (uint8_t)dst_port[1]);\n+\tsend_single_packet(qconf, m[2], (uint8_t)dst_port[2]);\n+\tsend_single_packet(qconf, m[3], (uint8_t)dst_port[3]);\n+\tsend_single_packet(qconf, m[4], (uint8_t)dst_port[4]);\n+\tsend_single_packet(qconf, m[5], (uint8_t)dst_port[5]);\n+\tsend_single_packet(qconf, m[6], (uint8_t)dst_port[6]);\n+\tsend_single_packet(qconf, m[7], (uint8_t)dst_port[7]);\n+}\n+\n+static inline void\n+get_ipv6_5tuple(struct rte_mbuf *m0, __m128i mask0,\n+\t\t__m128i mask1, union ipv6_5tuple_host *key)\n+{\n+\t__m128i tmpdata0 = _mm_loadu_si128(\n+\t\t\trte_pktmbuf_mtod_offset(m0, __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv6_hdr, payload_len)));\n+\n+\t__m128i tmpdata1 = _mm_loadu_si128(\n+\t\t\trte_pktmbuf_mtod_offset(m0, __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv6_hdr, payload_len) +\n+\t\t\t\tsizeof(__m128i)));\n+\n+\t__m128i tmpdata2 = _mm_loadu_si128(\n+\t\t\trte_pktmbuf_mtod_offset(m0, __m128i *,\n+\t\t\t\tsizeof(struct ether_hdr) +\n+\t\t\t\toffsetof(struct ipv6_hdr, payload_len) +\n+\t\t\t\tsizeof(__m128i) + sizeof(__m128i)));\n+\n+\tkey->xmm[0] = _mm_and_si128(tmpdata0, mask0);\n+\tkey->xmm[1] = tmpdata1;\n+\tkey->xmm[2] = _mm_and_si128(tmpdata2, mask1);\n+}\n+\n+static inline void\n+simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid,\n+\t\t\tstruct lcore_conf *qconf)\n+{\n+\tstruct ether_hdr *eth_hdr[8];\n+\t__attribute__((unused)) struct ipv6_hdr *ipv6_hdr[8];\n+\tuint8_t dst_port[8];\n+\tint32_t ret[8];\n+\tunion ipv6_5tuple_host key[8];\n+\n+\teth_hdr[0] = rte_pktmbuf_mtod(m[0], struct ether_hdr *);\n+\teth_hdr[1] = rte_pktmbuf_mtod(m[1], struct ether_hdr *);\n+\teth_hdr[2] = rte_pktmbuf_mtod(m[2], struct ether_hdr *);\n+\teth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);\n+\teth_hdr[4] = rte_pktmbuf_mtod(m[4], struct ether_hdr *);\n+\teth_hdr[5] = rte_pktmbuf_mtod(m[5], struct ether_hdr *);\n+\teth_hdr[6] = rte_pktmbuf_mtod(m[6], struct ether_hdr *);\n+\teth_hdr[7] = rte_pktmbuf_mtod(m[7], struct ether_hdr *);\n+\n+\t/* Handle IPv6 headers.*/\n+\tipv6_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\n+\tget_ipv6_5tuple(m[0], mask1, mask2, &key[0]);\n+\tget_ipv6_5tuple(m[1], mask1, mask2, &key[1]);\n+\tget_ipv6_5tuple(m[2], mask1, mask2, &key[2]);\n+\tget_ipv6_5tuple(m[3], mask1, mask2, &key[3]);\n+\tget_ipv6_5tuple(m[4], mask1, mask2, &key[4]);\n+\tget_ipv6_5tuple(m[5], mask1, mask2, &key[5]);\n+\tget_ipv6_5tuple(m[6], mask1, mask2, &key[6]);\n+\tget_ipv6_5tuple(m[7], mask1, mask2, &key[7]);\n+\n+\tconst void *key_array[8] = {&key[0], &key[1], &key[2], &key[3],\n+\t\t\t\t&key[4], &key[5], &key[6], &key[7]};\n+\n+\trte_hash_lookup_multi(qconf->ipv6_lookup_struct, &key_array[0], 8, ret);\n+\tdst_port[0] = (uint8_t) ((ret[0] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[0]]);\n+\tdst_port[1] = (uint8_t) ((ret[1] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[1]]);\n+\tdst_port[2] = (uint8_t) ((ret[2] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[2]]);\n+\tdst_port[3] = (uint8_t) ((ret[3] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[3]]);\n+\tdst_port[4] = (uint8_t) ((ret[4] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[4]]);\n+\tdst_port[5] = (uint8_t) ((ret[5] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[5]]);\n+\tdst_port[6] = (uint8_t) ((ret[6] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[6]]);\n+\tdst_port[7] = (uint8_t) ((ret[7] < 0) ?\n+\t\tportid : ipv6_l3fwd_out_if[ret[7]]);\n+\n+\tif (dst_port[0] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[0]) == 0)\n+\t\tdst_port[0] = portid;\n+\n+\tif (dst_port[1] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[1]) == 0)\n+\t\tdst_port[1] = portid;\n+\n+\tif (dst_port[2] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[2]) == 0)\n+\t\tdst_port[2] = portid;\n+\n+\tif (dst_port[3] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[3]) == 0)\n+\t\tdst_port[3] = portid;\n+\n+\tif (dst_port[4] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[4]) == 0)\n+\t\tdst_port[4] = portid;\n+\n+\tif (dst_port[5] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[5]) == 0)\n+\t\tdst_port[5] = portid;\n+\n+\tif (dst_port[6] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[6]) == 0)\n+\t\tdst_port[6] = portid;\n+\n+\tif (dst_port[7] >= RTE_MAX_ETHPORTS ||\n+\t\t(enabled_port_mask & 1 << dst_port[7]) == 0)\n+\t\tdst_port[7] = portid;\n+\n+\t/* dst addr */\n+\t*(uint64_t *)&eth_hdr[0]->d_addr = dest_eth_addr[dst_port[0]];\n+\t*(uint64_t *)&eth_hdr[1]->d_addr = dest_eth_addr[dst_port[1]];\n+\t*(uint64_t *)&eth_hdr[2]->d_addr = dest_eth_addr[dst_port[2]];\n+\t*(uint64_t *)&eth_hdr[3]->d_addr = dest_eth_addr[dst_port[3]];\n+\t*(uint64_t *)&eth_hdr[4]->d_addr = dest_eth_addr[dst_port[4]];\n+\t*(uint64_t *)&eth_hdr[5]->d_addr = dest_eth_addr[dst_port[5]];\n+\t*(uint64_t *)&eth_hdr[6]->d_addr = dest_eth_addr[dst_port[6]];\n+\t*(uint64_t *)&eth_hdr[7]->d_addr = dest_eth_addr[dst_port[7]];\n+\n+\t/* src addr */\n+\tether_addr_copy(&ports_eth_addr[dst_port[0]], &eth_hdr[0]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[1]], &eth_hdr[1]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[2]], &eth_hdr[2]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[3]], &eth_hdr[3]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[4]], &eth_hdr[4]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[5]], &eth_hdr[5]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[6]], &eth_hdr[6]->s_addr);\n+\tether_addr_copy(&ports_eth_addr[dst_port[7]], &eth_hdr[7]->s_addr);\n+\n+\tsend_single_packet(qconf, m[0], (uint8_t)dst_port[0]);\n+\tsend_single_packet(qconf, m[1], (uint8_t)dst_port[1]);\n+\tsend_single_packet(qconf, m[2], (uint8_t)dst_port[2]);\n+\tsend_single_packet(qconf, m[3], (uint8_t)dst_port[3]);\n+\tsend_single_packet(qconf, m[4], (uint8_t)dst_port[4]);\n+\tsend_single_packet(qconf, m[5], (uint8_t)dst_port[5]);\n+\tsend_single_packet(qconf, m[6], (uint8_t)dst_port[6]);\n+\tsend_single_packet(qconf, m[7], (uint8_t)dst_port[7]);\n+}\n+\n+/*\n+ * Buffer optimized handling of packets, invoked\n+ * from main_loop.\n+ */\n+static inline void\n+l3fwd_em_send_packets(int nb_rx, struct rte_mbuf **pkts_burst,\n+\t\t\tuint8_t portid, struct lcore_conf *qconf)\n+{\n+\tint32_t j;\n+\n+\t/*\n+\t * Send nb_rx - nb_rx%8 packets\n+\t * in groups of 8.\n+\t */\n+\tint32_t n = RTE_ALIGN_FLOOR(nb_rx, 8);\n+\n+\tfor (j = 0; j < n; j += 8) {\n+\n+\t\tuint32_t pkt_type =\n+\t\t\tpkts_burst[j]->packet_type &\n+\t\t\tpkts_burst[j+1]->packet_type &\n+\t\t\tpkts_burst[j+2]->packet_type &\n+\t\t\tpkts_burst[j+3]->packet_type &\n+\t\t\tpkts_burst[j+4]->packet_type &\n+\t\t\tpkts_burst[j+5]->packet_type &\n+\t\t\tpkts_burst[j+6]->packet_type &\n+\t\t\tpkts_burst[j+7]->packet_type;\n+\n+\t\tif (pkt_type & RTE_PTYPE_L3_IPV4) {\n+\t\t\tsimple_ipv4_fwd_8pkts(\n+\t\t\t\t&pkts_burst[j], portid, qconf);\n+\t\t} else if (pkt_type & RTE_PTYPE_L3_IPV6) {\n+\t\t\tsimple_ipv6_fwd_8pkts(&pkts_burst[j],\n+\t\t\t\t\t\tportid, qconf);\n+\t\t} else {\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j], portid, qconf);\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j+1], portid, qconf);\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j+2], portid, qconf);\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j+3], portid, qconf);\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j+4], portid, qconf);\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j+5], portid, qconf);\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j+6], portid, qconf);\n+\t\t\tl3fwd_em_simple_forward(pkts_burst[j+7], portid, qconf);\n+\t\t}\n+\t}\n+\tfor (; j < nb_rx ; j++)\n+\t\tl3fwd_em_simple_forward(pkts_burst[j], portid, qconf);\n+}\n+\n+#endif /* __L3FWD_EM_SSE_H__ */\ndiff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c\nnew file mode 100644\nindex 0000000..feffc21\n--- /dev/null\n+++ b/examples/l3fwd/l3fwd_lpm.c\n@@ -0,0 +1,414 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2015 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 <stdio.h>\n+#include <stdlib.h>\n+#include <stdint.h>\n+#include <inttypes.h>\n+#include <sys/types.h>\n+#include <string.h>\n+#include <sys/queue.h>\n+#include <stdarg.h>\n+#include <errno.h>\n+#include <getopt.h>\n+\n+#include <rte_debug.h>\n+#include <rte_ether.h>\n+#include <rte_ethdev.h>\n+#include <rte_ring.h>\n+#include <rte_mempool.h>\n+#include <rte_cycles.h>\n+#include <rte_mbuf.h>\n+#include <rte_ip.h>\n+#include <rte_tcp.h>\n+#include <rte_udp.h>\n+#include <rte_lpm.h>\n+#include <rte_lpm6.h>\n+\n+#include \"l3fwd.h\"\n+\n+struct ipv4_l3fwd_lpm_route {\n+\tuint32_t ip;\n+\tuint8_t  depth;\n+\tuint8_t  if_out;\n+};\n+\n+struct ipv6_l3fwd_lpm_route {\n+\tuint8_t ip[16];\n+\tuint8_t  depth;\n+\tuint8_t  if_out;\n+};\n+\n+static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = {\n+\t{IPv4(1, 1, 1, 0), 24, 0},\n+\t{IPv4(2, 1, 1, 0), 24, 1},\n+\t{IPv4(3, 1, 1, 0), 24, 2},\n+\t{IPv4(4, 1, 1, 0), 24, 3},\n+\t{IPv4(5, 1, 1, 0), 24, 4},\n+\t{IPv4(6, 1, 1, 0), 24, 5},\n+\t{IPv4(7, 1, 1, 0), 24, 6},\n+\t{IPv4(8, 1, 1, 0), 24, 7},\n+};\n+\n+static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = {\n+\t{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 0},\n+\t{{2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 1},\n+\t{{3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 2},\n+\t{{4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 3},\n+\t{{5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 4},\n+\t{{6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 5},\n+\t{{7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 6},\n+\t{{8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 7},\n+};\n+\n+#define IPV4_L3FWD_LPM_NUM_ROUTES \\\n+\t(sizeof(ipv4_l3fwd_lpm_route_array) / sizeof(ipv4_l3fwd_lpm_route_array[0]))\n+#define IPV6_L3FWD_LPM_NUM_ROUTES \\\n+\t(sizeof(ipv6_l3fwd_lpm_route_array) / sizeof(ipv6_l3fwd_lpm_route_array[0]))\n+\n+#define IPV4_L3FWD_LPM_MAX_RULES         1024\n+#define IPV6_L3FWD_LPM_MAX_RULES         1024\n+#define IPV6_L3FWD_LPM_NUMBER_TBL8S (1 << 16)\n+\n+/* Used to mark destination port as 'invalid'. */\n+#define\tBAD_PORT\t((uint16_t)-1)\n+\n+#define FWDSTEP\t4\n+\n+/* replace first 12B of the ethernet header. */\n+#define\tMASK_ETH\t0x3f\n+\n+struct rte_lpm *ipv4_l3fwd_lpm_lookup_struct[NB_SOCKETS];\n+struct rte_lpm6 *ipv6_l3fwd_lpm_lookup_struct[NB_SOCKETS];\n+\n+static inline uint8_t\n+lpm_get_ipv4_dst_port(void *ipv4_hdr,  uint8_t portid, void *lookup_struct)\n+{\n+\tuint8_t next_hop;\n+\tstruct rte_lpm *ipv4_l3fwd_lookup_struct =\n+\t\t(struct rte_lpm *)lookup_struct;\n+\n+\treturn (uint8_t) ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct,\n+\t\trte_be_to_cpu_32(((struct ipv4_hdr *)ipv4_hdr)->dst_addr),\n+\t\t&next_hop) == 0) ? next_hop : portid);\n+}\n+\n+static inline uint8_t\n+lpm_get_ipv6_dst_port(void *ipv6_hdr,  uint8_t portid, void *lookup_struct)\n+{\n+\tuint8_t next_hop;\n+\tstruct rte_lpm6 *ipv6_l3fwd_lookup_struct =\n+\t\t(struct rte_lpm6 *)lookup_struct;\n+\n+\treturn (uint8_t) ((rte_lpm6_lookup(ipv6_l3fwd_lookup_struct,\n+\t\t\t((struct ipv6_hdr *)ipv6_hdr)->dst_addr,\n+\t\t\t&next_hop) == 0) ?  next_hop : portid);\n+}\n+\n+static inline __attribute__((always_inline)) void\n+l3fwd_lpm_simple_forward(struct rte_mbuf *m, uint8_t portid,\n+\t\tstruct lcore_conf *qconf)\n+{\n+\tstruct ether_hdr *eth_hdr;\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tuint8_t dst_port;\n+\n+\teth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);\n+\n+\tif (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {\n+\t\t/* Handle IPv4 headers.*/\n+\t\tipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,\n+\t\t\t\t\t\t   sizeof(struct ether_hdr));\n+\n+#ifdef DO_RFC_1812_CHECKS\n+\t\t/* Check to make sure the packet is valid (RFC1812) */\n+\t\tif (is_valid_ipv4_pkt(ipv4_hdr, m->pkt_len) < 0) {\n+\t\t\trte_pktmbuf_free(m);\n+\t\t\treturn;\n+\t\t}\n+#endif\n+\t\t dst_port = lpm_get_ipv4_dst_port(ipv4_hdr, portid,\n+\t\t\t\t\t\tqconf->ipv4_lookup_struct);\n+\n+\t\tif (dst_port >= RTE_MAX_ETHPORTS ||\n+\t\t\t(enabled_port_mask & 1 << dst_port) == 0)\n+\t\t\tdst_port = portid;\n+\n+#ifdef DO_RFC_1812_CHECKS\n+\t\t/* Update time to live and header checksum */\n+\t\t--(ipv4_hdr->time_to_live);\n+\t\t++(ipv4_hdr->hdr_checksum);\n+#endif\n+\t\t/* dst addr */\n+\t\t*(uint64_t *)&eth_hdr->d_addr = dest_eth_addr[dst_port];\n+\n+\t\t/* src addr */\n+\t\tether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);\n+\n+\t\tsend_single_packet(qconf, m, dst_port);\n+\t} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {\n+\t\t/* Handle IPv6 headers.*/\n+\t\tstruct ipv6_hdr *ipv6_hdr;\n+\n+\t\tipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,\n+\t\t\t\t\t\t   sizeof(struct ether_hdr));\n+\n+\t\tdst_port = lpm_get_ipv6_dst_port(ipv6_hdr, portid,\n+\t\t\t\t\tqconf->ipv6_lookup_struct);\n+\n+\t\tif (dst_port >= RTE_MAX_ETHPORTS ||\n+\t\t\t(enabled_port_mask & 1 << dst_port) == 0)\n+\t\t\tdst_port = portid;\n+\n+\t\t/* dst addr */\n+\t\t*(uint64_t *)&eth_hdr->d_addr = dest_eth_addr[dst_port];\n+\n+\t\t/* src addr */\n+\t\tether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);\n+\n+\t\tsend_single_packet(qconf, m, dst_port);\n+\t} else {\n+\t\t/* Free the mbuf that contains non-IPV4/IPV6 packet */\n+\t\trte_pktmbuf_free(m);\n+\t}\n+}\n+\n+/*\n+ * Include header file if SSE4_1 is enabled for\n+ * buffer optimization i.e. ENABLE_MULTI_BUFFER_OPTIMIZE=1.\n+ */\n+#if defined(__SSE4_1__)\n+#include \"l3fwd_lpm_sse.h\"\n+#endif\n+\n+static inline void\n+l3fwd_lpm_no_opt_send_packets(int nb_rx, struct rte_mbuf **pkts_burst,\n+\t\t\t\tuint8_t portid, struct lcore_conf *qconf)\n+{\n+\tint32_t j;\n+\n+\t/* Prefetch first packets */\n+\tfor (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++)\n+\t\trte_prefetch0(rte_pktmbuf_mtod(pkts_burst[j], void *));\n+\n+\t/* Prefetch and forward already prefetched packets. */\n+\tfor (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {\n+\t\trte_prefetch0(rte_pktmbuf_mtod(pkts_burst[\n+\t\t\t\tj + PREFETCH_OFFSET], void *));\n+\t\tl3fwd_lpm_simple_forward(pkts_burst[j], portid, qconf);\n+\t}\n+\n+\t/* Forward remaining prefetched packets */\n+\tfor (; j < nb_rx; j++)\n+\t\tl3fwd_lpm_simple_forward(pkts_burst[j], portid, qconf);\n+}\n+\n+/* main processing loop */\n+int\n+lpm_main_loop(__attribute__((unused)) void *dummy)\n+{\n+\tstruct rte_mbuf *pkts_burst[MAX_PKT_BURST];\n+\tunsigned lcore_id;\n+\tuint64_t prev_tsc, diff_tsc, cur_tsc;\n+\tint i, nb_rx;\n+\tuint8_t portid, queueid;\n+\tstruct lcore_conf *qconf;\n+\tconst uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /\n+\t\tUS_PER_S * BURST_TX_DRAIN_US;\n+\n+\tprev_tsc = 0;\n+\n+\tlcore_id = rte_lcore_id();\n+\tqconf = &lcore_conf[lcore_id];\n+\n+\tif (qconf->n_rx_queue == 0) {\n+\t\tRTE_LOG(INFO, L3FWD, \"lcore %u has nothing to do\\n\", lcore_id);\n+\t\treturn 0;\n+\t}\n+\n+\tRTE_LOG(INFO, L3FWD, \"entering main loop on lcore %u\\n\", lcore_id);\n+\n+\tfor (i = 0; i < qconf->n_rx_queue; i++) {\n+\n+\t\tportid = qconf->rx_queue_list[i].port_id;\n+\t\tqueueid = qconf->rx_queue_list[i].queue_id;\n+\t\tRTE_LOG(INFO, L3FWD,\n+\t\t\t\" -- lcoreid=%u portid=%hhu rxqueueid=%hhu\\n\",\n+\t\t\tlcore_id, portid, queueid);\n+\t}\n+\n+\twhile (1) {\n+\n+\t\tcur_tsc = rte_rdtsc();\n+\n+\t\t/*\n+\t\t * TX burst queue drain\n+\t\t */\n+\t\tdiff_tsc = cur_tsc - prev_tsc;\n+\t\tif (unlikely(diff_tsc > drain_tsc)) {\n+\n+\t\t\t/*\n+\t\t\t * This could be optimized (use queueid instead of\n+\t\t\t * portid), but it is not called so often\n+\t\t\t */\n+\t\t\tfor (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {\n+\t\t\t\tif (qconf->tx_mbufs[portid].len == 0)\n+\t\t\t\t\tcontinue;\n+\t\t\t\tsend_burst(qconf,\n+\t\t\t\t\tqconf->tx_mbufs[portid].len,\n+\t\t\t\t\tportid);\n+\t\t\t\tqconf->tx_mbufs[portid].len = 0;\n+\t\t\t}\n+\n+\t\t\tprev_tsc = cur_tsc;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Read packet from RX queues\n+\t\t */\n+\t\tfor (i = 0; i < qconf->n_rx_queue; ++i) {\n+\t\t\tportid = qconf->rx_queue_list[i].port_id;\n+\t\t\tqueueid = qconf->rx_queue_list[i].queue_id;\n+\t\t\tnb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,\n+\t\t\t\tMAX_PKT_BURST);\n+\t\t\tif (nb_rx == 0)\n+\t\t\t\tcontinue;\n+\n+\t\t\t/*\n+\t\t\t * For SSE4_1 use ENABLE_MULTI_BUFFER_OPTIMIZE=1\n+\t\t\t * code.\n+\t\t\t */\n+#if defined(__SSE4_1__)\n+\t\t\tl3fwd_lpm_send_packets(nb_rx, pkts_burst,\n+\t\t\t\t\t\tportid, qconf);\n+#else\n+\t\t\tl3fwd_lpm_no_opt_send_packets(nb_rx, pkts_burst,\n+\t\t\t\t\t\t\tportid, qconf);\n+#endif /* __SSE_4_1__ */\n+\t\t}\n+\t}\n+}\n+\n+void\n+setup_lpm(const int socketid)\n+{\n+\tstruct rte_lpm6_config config;\n+\tunsigned i;\n+\tint ret;\n+\tchar s[64];\n+\n+\t/* create the LPM table */\n+\tsnprintf(s, sizeof(s), \"IPV4_L3FWD_LPM_%d\", socketid);\n+\tipv4_l3fwd_lpm_lookup_struct[socketid] = rte_lpm_create(s, socketid,\n+\t\t\t\tIPV4_L3FWD_LPM_MAX_RULES, 0);\n+\tif (ipv4_l3fwd_lpm_lookup_struct[socketid] == NULL)\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"Unable to create the l3fwd LPM table on socket %d\\n\",\n+\t\t\tsocketid);\n+\n+\t/* populate the LPM table */\n+\tfor (i = 0; i < IPV4_L3FWD_LPM_NUM_ROUTES; i++) {\n+\n+\t\t/* skip unused ports */\n+\t\tif ((1 << ipv4_l3fwd_lpm_route_array[i].if_out &\n+\t\t\t\tenabled_port_mask) == 0)\n+\t\t\tcontinue;\n+\n+\t\tret = rte_lpm_add(ipv4_l3fwd_lpm_lookup_struct[socketid],\n+\t\t\tipv4_l3fwd_lpm_route_array[i].ip,\n+\t\t\tipv4_l3fwd_lpm_route_array[i].depth,\n+\t\t\tipv4_l3fwd_lpm_route_array[i].if_out);\n+\n+\t\tif (ret < 0) {\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Unable to add entry %u to the l3fwd LPM table on socket %d\\n\",\n+\t\t\t\ti, socketid);\n+\t\t}\n+\n+\t\tprintf(\"LPM: Adding route 0x%08x / %d (%d)\\n\",\n+\t\t\t(unsigned)ipv4_l3fwd_lpm_route_array[i].ip,\n+\t\t\tipv4_l3fwd_lpm_route_array[i].depth,\n+\t\t\tipv4_l3fwd_lpm_route_array[i].if_out);\n+\t}\n+\n+\t/* create the LPM6 table */\n+\tsnprintf(s, sizeof(s), \"IPV6_L3FWD_LPM_%d\", socketid);\n+\n+\tconfig.max_rules = IPV6_L3FWD_LPM_MAX_RULES;\n+\tconfig.number_tbl8s = IPV6_L3FWD_LPM_NUMBER_TBL8S;\n+\tconfig.flags = 0;\n+\tipv6_l3fwd_lpm_lookup_struct[socketid] = rte_lpm6_create(s, socketid,\n+\t\t\t\t&config);\n+\tif (ipv6_l3fwd_lpm_lookup_struct[socketid] == NULL)\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"Unable to create the l3fwd LPM table on socket %d\\n\",\n+\t\t\tsocketid);\n+\n+\t/* populate the LPM table */\n+\tfor (i = 0; i < IPV6_L3FWD_LPM_NUM_ROUTES; i++) {\n+\n+\t\t/* skip unused ports */\n+\t\tif ((1 << ipv6_l3fwd_lpm_route_array[i].if_out &\n+\t\t\t\tenabled_port_mask) == 0)\n+\t\t\tcontinue;\n+\n+\t\tret = rte_lpm6_add(ipv6_l3fwd_lpm_lookup_struct[socketid],\n+\t\t\tipv6_l3fwd_lpm_route_array[i].ip,\n+\t\t\tipv6_l3fwd_lpm_route_array[i].depth,\n+\t\t\tipv6_l3fwd_lpm_route_array[i].if_out);\n+\n+\t\tif (ret < 0) {\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Unable to add entry %u to the l3fwd LPM table on socket %d\\n\",\n+\t\t\t\ti, socketid);\n+\t\t}\n+\n+\t\tprintf(\"LPM: Adding route %s / %d (%d)\\n\",\n+\t\t\t\"IPV6\",\n+\t\t\tipv6_l3fwd_lpm_route_array[i].depth,\n+\t\t\tipv6_l3fwd_lpm_route_array[i].if_out);\n+\t}\n+}\n+\n+/* Return ipv4/ipv6 lpm fwd lookup struct. */\n+void *\n+lpm_get_ipv4_l3fwd_lookup_struct(const int socketid)\n+{\n+\treturn ipv4_l3fwd_lpm_lookup_struct[socketid];\n+}\n+\n+void *\n+lpm_get_ipv6_l3fwd_lookup_struct(const int socketid)\n+{\n+\treturn ipv6_l3fwd_lpm_lookup_struct[socketid];\n+}\ndiff --git a/examples/l3fwd/l3fwd_lpm_sse.h b/examples/l3fwd/l3fwd_lpm_sse.h\nnew file mode 100644\nindex 0000000..9e9b797\n--- /dev/null\n+++ b/examples/l3fwd/l3fwd_lpm_sse.h\n@@ -0,0 +1,610 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2015 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+#ifndef __L3FWD_LPM_SSE_H__\n+#define __L3FWD_LPM_SSE_H__\n+\n+static inline __attribute__((always_inline)) void\n+send_packetsx4(struct lcore_conf *qconf, uint8_t port,\n+\tstruct rte_mbuf *m[], uint32_t num)\n+{\n+\tuint32_t len, j, n;\n+\n+\tlen = qconf->tx_mbufs[port].len;\n+\n+\t/*\n+\t * If TX buffer for that queue is empty, and we have enough packets,\n+\t * then send them straightway.\n+\t */\n+\tif (num >= MAX_TX_BURST && len == 0) {\n+\t\tn = rte_eth_tx_burst(port, qconf->tx_queue_id[port], m, num);\n+\t\tif (unlikely(n < num)) {\n+\t\t\tdo {\n+\t\t\t\trte_pktmbuf_free(m[n]);\n+\t\t\t} while (++n < num);\n+\t\t}\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * Put packets into TX buffer for that queue.\n+\t */\n+\n+\tn = len + num;\n+\tn = (n > MAX_PKT_BURST) ? MAX_PKT_BURST - len : num;\n+\n+\tj = 0;\n+\tswitch (n % FWDSTEP) {\n+\twhile (j < n) {\n+\tcase 0:\n+\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n+\t\tj++;\n+\tcase 3:\n+\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n+\t\tj++;\n+\tcase 2:\n+\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n+\t\tj++;\n+\tcase 1:\n+\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n+\t\tj++;\n+\t}\n+\t}\n+\n+\tlen += n;\n+\n+\t/* enough pkts to be sent */\n+\tif (unlikely(len == MAX_PKT_BURST)) {\n+\n+\t\tsend_burst(qconf, MAX_PKT_BURST, port);\n+\n+\t\t/* copy rest of the packets into the TX buffer. */\n+\t\tlen = num - n;\n+\t\tj = 0;\n+\t\tswitch (len % FWDSTEP) {\n+\t\twhile (j < len) {\n+\t\tcase 0:\n+\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n+\t\t\tj++;\n+\t\tcase 3:\n+\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n+\t\t\tj++;\n+\t\tcase 2:\n+\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n+\t\t\tj++;\n+\t\tcase 1:\n+\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n+\t\t\tj++;\n+\t\t}\n+\t\t}\n+\t}\n+\n+\tqconf->tx_mbufs[port].len = len;\n+}\n+\n+#ifdef DO_RFC_1812_CHECKS\n+\n+#define\tIPV4_MIN_VER_IHL\t0x45\n+#define\tIPV4_MAX_VER_IHL\t0x4f\n+#define\tIPV4_MAX_VER_IHL_DIFF\t(IPV4_MAX_VER_IHL - IPV4_MIN_VER_IHL)\n+\n+/* Minimum value of IPV4 total length (20B) in network byte order. */\n+#define\tIPV4_MIN_LEN_BE\t(sizeof(struct ipv4_hdr) << 8)\n+\n+/*\n+ * From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2:\n+ * - The IP version number must be 4.\n+ * - The IP header length field must be large enough to hold the\n+ *    minimum length legal IP datagram (20 bytes = 5 words).\n+ * - The IP total length field must be large enough to hold the IP\n+ *   datagram header, whose length is specified in the IP header length\n+ *   field.\n+ * If we encounter invalid IPV4 packet, then set destination port for it\n+ * to BAD_PORT value.\n+ */\n+static inline __attribute__((always_inline)) void\n+rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)\n+{\n+\tuint8_t ihl;\n+\n+\tif (RTE_ETH_IS_IPV4_HDR(ptype)) {\n+\t\tihl = ipv4_hdr->version_ihl - IPV4_MIN_VER_IHL;\n+\n+\t\tipv4_hdr->time_to_live--;\n+\t\tipv4_hdr->hdr_checksum++;\n+\n+\t\tif (ihl > IPV4_MAX_VER_IHL_DIFF ||\n+\t\t\t\t((uint8_t)ipv4_hdr->total_length == 0 &&\n+\t\t\t\tipv4_hdr->total_length < IPV4_MIN_LEN_BE)) {\n+\t\t\tdp[0] = BAD_PORT;\n+\t\t}\n+\t}\n+}\n+\n+#else\n+#define\trfc1812_process(mb, dp)\tdo { } while (0)\n+#endif /* DO_RFC_1812_CHECKS */\n+\n+static inline __attribute__((always_inline)) uint16_t\n+get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt,\n+\tuint32_t dst_ipv4, uint8_t portid)\n+{\n+\tuint8_t next_hop;\n+\tstruct ipv6_hdr *ipv6_hdr;\n+\tstruct ether_hdr *eth_hdr;\n+\n+\tif (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {\n+\t\tif (rte_lpm_lookup(qconf->ipv4_lookup_struct, dst_ipv4,\n+\t\t\t\t&next_hop) != 0)\n+\t\t\tnext_hop = portid;\n+\t} else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {\n+\t\teth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);\n+\t\tipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1);\n+\t\tif (rte_lpm6_lookup(qconf->ipv6_lookup_struct,\n+\t\t\t\tipv6_hdr->dst_addr, &next_hop) != 0)\n+\t\t\tnext_hop = portid;\n+\t} else {\n+\t\tnext_hop = portid;\n+\t}\n+\n+\treturn next_hop;\n+}\n+\n+static inline void\n+process_packet(struct lcore_conf *qconf, struct rte_mbuf *pkt,\n+\tuint16_t *dst_port, uint8_t portid)\n+{\n+\tstruct ether_hdr *eth_hdr;\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tuint32_t dst_ipv4;\n+\tuint16_t dp;\n+\t__m128i te, ve;\n+\n+\teth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);\n+\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n+\n+\tdst_ipv4 = ipv4_hdr->dst_addr;\n+\tdst_ipv4 = rte_be_to_cpu_32(dst_ipv4);\n+\tdp = get_dst_port(qconf, pkt, dst_ipv4, portid);\n+\n+\tte = _mm_loadu_si128((__m128i *)eth_hdr);\n+\tve = val_eth[dp];\n+\n+\tdst_port[0] = dp;\n+\trfc1812_process(ipv4_hdr, dst_port, pkt->packet_type);\n+\n+\tte =  _mm_blend_epi16(te, ve, MASK_ETH);\n+\t_mm_storeu_si128((__m128i *)eth_hdr, te);\n+}\n+\n+/*\n+ * Read packet_type and destination IPV4 addresses from 4 mbufs.\n+ */\n+static inline void\n+processx4_step1(struct rte_mbuf *pkt[FWDSTEP],\n+\t\t__m128i *dip,\n+\t\tuint32_t *ipv4_flag)\n+{\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tstruct ether_hdr *eth_hdr;\n+\tuint32_t x0, x1, x2, x3;\n+\n+\teth_hdr = rte_pktmbuf_mtod(pkt[0], struct ether_hdr *);\n+\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n+\tx0 = ipv4_hdr->dst_addr;\n+\tipv4_flag[0] = pkt[0]->packet_type & RTE_PTYPE_L3_IPV4;\n+\n+\teth_hdr = rte_pktmbuf_mtod(pkt[1], struct ether_hdr *);\n+\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n+\tx1 = ipv4_hdr->dst_addr;\n+\tipv4_flag[0] &= pkt[1]->packet_type;\n+\n+\teth_hdr = rte_pktmbuf_mtod(pkt[2], struct ether_hdr *);\n+\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n+\tx2 = ipv4_hdr->dst_addr;\n+\tipv4_flag[0] &= pkt[2]->packet_type;\n+\n+\teth_hdr = rte_pktmbuf_mtod(pkt[3], struct ether_hdr *);\n+\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n+\tx3 = ipv4_hdr->dst_addr;\n+\tipv4_flag[0] &= pkt[3]->packet_type;\n+\n+\tdip[0] = _mm_set_epi32(x3, x2, x1, x0);\n+}\n+\n+/*\n+ * Lookup into LPM for destination port.\n+ * If lookup fails, use incoming port (portid) as destination port.\n+ */\n+static inline void\n+processx4_step2(const struct lcore_conf *qconf,\n+\t\t__m128i dip,\n+\t\tuint32_t ipv4_flag,\n+\t\tuint8_t portid,\n+\t\tstruct rte_mbuf *pkt[FWDSTEP],\n+\t\tuint16_t dprt[FWDSTEP])\n+{\n+\trte_xmm_t dst;\n+\tconst  __m128i bswap_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11,\n+\t\t\t\t\t\t4, 5, 6, 7, 0, 1, 2, 3);\n+\n+\t/* Byte swap 4 IPV4 addresses. */\n+\tdip = _mm_shuffle_epi8(dip, bswap_mask);\n+\n+\t/* if all 4 packets are IPV4. */\n+\tif (likely(ipv4_flag)) {\n+\t\trte_lpm_lookupx4(qconf->ipv4_lookup_struct, dip, dprt, portid);\n+\t} else {\n+\t\tdst.x = dip;\n+\t\tdprt[0] = get_dst_port(qconf, pkt[0], dst.u32[0], portid);\n+\t\tdprt[1] = get_dst_port(qconf, pkt[1], dst.u32[1], portid);\n+\t\tdprt[2] = get_dst_port(qconf, pkt[2], dst.u32[2], portid);\n+\t\tdprt[3] = get_dst_port(qconf, pkt[3], dst.u32[3], portid);\n+\t}\n+}\n+\n+/*\n+ * Update source and destination MAC addresses in the ethernet header.\n+ * Perform RFC1812 checks and updates for IPV4 packets.\n+ */\n+static inline void\n+processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP])\n+{\n+\t__m128i te[FWDSTEP];\n+\t__m128i ve[FWDSTEP];\n+\t__m128i *p[FWDSTEP];\n+\n+\tp[0] = rte_pktmbuf_mtod(pkt[0], __m128i *);\n+\tp[1] = rte_pktmbuf_mtod(pkt[1], __m128i *);\n+\tp[2] = rte_pktmbuf_mtod(pkt[2], __m128i *);\n+\tp[3] = rte_pktmbuf_mtod(pkt[3], __m128i *);\n+\n+\tve[0] = val_eth[dst_port[0]];\n+\tte[0] = _mm_loadu_si128(p[0]);\n+\n+\tve[1] = val_eth[dst_port[1]];\n+\tte[1] = _mm_loadu_si128(p[1]);\n+\n+\tve[2] = val_eth[dst_port[2]];\n+\tte[2] = _mm_loadu_si128(p[2]);\n+\n+\tve[3] = val_eth[dst_port[3]];\n+\tte[3] = _mm_loadu_si128(p[3]);\n+\n+\t/* Update first 12 bytes, keep rest bytes intact. */\n+\tte[0] =  _mm_blend_epi16(te[0], ve[0], MASK_ETH);\n+\tte[1] =  _mm_blend_epi16(te[1], ve[1], MASK_ETH);\n+\tte[2] =  _mm_blend_epi16(te[2], ve[2], MASK_ETH);\n+\tte[3] =  _mm_blend_epi16(te[3], ve[3], MASK_ETH);\n+\n+\t_mm_storeu_si128(p[0], te[0]);\n+\t_mm_storeu_si128(p[1], te[1]);\n+\t_mm_storeu_si128(p[2], te[2]);\n+\t_mm_storeu_si128(p[3], te[3]);\n+\n+\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[0] + 1),\n+\t\t&dst_port[0], pkt[0]->packet_type);\n+\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[1] + 1),\n+\t\t&dst_port[1], pkt[1]->packet_type);\n+\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[2] + 1),\n+\t\t&dst_port[2], pkt[2]->packet_type);\n+\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[3] + 1),\n+\t\t&dst_port[3], pkt[3]->packet_type);\n+}\n+\n+/*\n+ * We group consecutive packets with the same destionation port into one burst.\n+ * To avoid extra latency this is done together with some other packet\n+ * processing, but after we made a final decision about packet's destination.\n+ * To do this we maintain:\n+ * pnum - array of number of consecutive packets with the same dest port for\n+ * each packet in the input burst.\n+ * lp - pointer to the last updated element in the pnum.\n+ * dlp - dest port value lp corresponds to.\n+ */\n+\n+#define\tGRPSZ\t(1 << FWDSTEP)\n+#define\tGRPMSK\t(GRPSZ - 1)\n+\n+#define GROUP_PORT_STEP(dlp, dcp, lp, pn, idx)\tdo { \\\n+\tif (likely((dlp) == (dcp)[(idx)])) {         \\\n+\t\t(lp)[0]++;                           \\\n+\t} else {                                     \\\n+\t\t(dlp) = (dcp)[idx];                  \\\n+\t\t(lp) = (pn) + (idx);                 \\\n+\t\t(lp)[0] = 1;                         \\\n+\t}                                            \\\n+} while (0)\n+\n+/*\n+ * Group consecutive packets with the same destination port in bursts of 4.\n+ * Suppose we have array of destionation ports:\n+ * dst_port[] = {a, b, c, d,, e, ... }\n+ * dp1 should contain: <a, b, c, d>, dp2: <b, c, d, e>.\n+ * We doing 4 comparisions at once and the result is 4 bit mask.\n+ * This mask is used as an index into prebuild array of pnum values.\n+ */\n+static inline uint16_t *\n+port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, __m128i dp1, __m128i dp2)\n+{\n+\tstatic const struct {\n+\t\tuint64_t pnum; /* prebuild 4 values for pnum[]. */\n+\t\tint32_t  idx;  /* index for new last updated elemnet. */\n+\t\tuint16_t lpv;  /* add value to the last updated element. */\n+\t} gptbl[GRPSZ] = {\n+\t{\n+\t\t/* 0: a != b, b != c, c != d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000100010001),\n+\t\t.idx = 4,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 1: a == b, b != c, c != d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000100010002),\n+\t\t.idx = 4,\n+\t\t.lpv = 1,\n+\t},\n+\t{\n+\t\t/* 2: a != b, b == c, c != d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000100020001),\n+\t\t.idx = 4,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 3: a == b, b == c, c != d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000100020003),\n+\t\t.idx = 4,\n+\t\t.lpv = 2,\n+\t},\n+\t{\n+\t\t/* 4: a != b, b != c, c == d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000200010001),\n+\t\t.idx = 4,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 5: a == b, b != c, c == d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000200010002),\n+\t\t.idx = 4,\n+\t\t.lpv = 1,\n+\t},\n+\t{\n+\t\t/* 6: a != b, b == c, c == d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000200030001),\n+\t\t.idx = 4,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 7: a == b, b == c, c == d, d != e */\n+\t\t.pnum = UINT64_C(0x0001000200030004),\n+\t\t.idx = 4,\n+\t\t.lpv = 3,\n+\t},\n+\t{\n+\t\t/* 8: a != b, b != c, c != d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000100010001),\n+\t\t.idx = 3,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 9: a == b, b != c, c != d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000100010002),\n+\t\t.idx = 3,\n+\t\t.lpv = 1,\n+\t},\n+\t{\n+\t\t/* 0xa: a != b, b == c, c != d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000100020001),\n+\t\t.idx = 3,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 0xb: a == b, b == c, c != d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000100020003),\n+\t\t.idx = 3,\n+\t\t.lpv = 2,\n+\t},\n+\t{\n+\t\t/* 0xc: a != b, b != c, c == d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000300010001),\n+\t\t.idx = 2,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 0xd: a == b, b != c, c == d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000300010002),\n+\t\t.idx = 2,\n+\t\t.lpv = 1,\n+\t},\n+\t{\n+\t\t/* 0xe: a != b, b == c, c == d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000300040001),\n+\t\t.idx = 1,\n+\t\t.lpv = 0,\n+\t},\n+\t{\n+\t\t/* 0xf: a == b, b == c, c == d, d == e */\n+\t\t.pnum = UINT64_C(0x0002000300040005),\n+\t\t.idx = 0,\n+\t\t.lpv = 4,\n+\t},\n+\t};\n+\n+\tunion {\n+\t\tuint16_t u16[FWDSTEP + 1];\n+\t\tuint64_t u64;\n+\t} *pnum = (void *)pn;\n+\n+\tint32_t v;\n+\n+\tdp1 = _mm_cmpeq_epi16(dp1, dp2);\n+\tdp1 = _mm_unpacklo_epi16(dp1, dp1);\n+\tv = _mm_movemask_ps((__m128)dp1);\n+\n+\t/* update last port counter. */\n+\tlp[0] += gptbl[v].lpv;\n+\n+\t/* if dest port value has changed. */\n+\tif (v != GRPMSK) {\n+\t\tlp = pnum->u16 + gptbl[v].idx;\n+\t\tlp[0] = 1;\n+\t\tpnum->u64 = gptbl[v].pnum;\n+\t}\n+\n+\treturn lp;\n+}\n+\n+/*\n+ * Buffer optimized handling of packets, invoked\n+ * from main_loop.\n+ */\n+static inline void\n+l3fwd_lpm_send_packets(int nb_rx, struct rte_mbuf **pkts_burst,\n+\t\t\tuint8_t portid, struct lcore_conf *qconf)\n+{\n+\tint32_t j, k;\n+\tuint16_t dlp;\n+\tuint16_t *lp;\n+\tuint16_t dst_port[MAX_PKT_BURST];\n+\t__m128i dip[MAX_PKT_BURST / FWDSTEP];\n+\tuint32_t ipv4_flag[MAX_PKT_BURST / FWDSTEP];\n+\tuint16_t pnum[MAX_PKT_BURST + 1];\n+\n+\tk = RTE_ALIGN_FLOOR(nb_rx, FWDSTEP);\n+\tfor (j = 0; j != k; j += FWDSTEP) {\n+\t\tprocessx4_step1(&pkts_burst[j],\n+\t\t\t&dip[j / FWDSTEP],\n+\t\t\t&ipv4_flag[j / FWDSTEP]);\n+\t}\n+\n+\tk = RTE_ALIGN_FLOOR(nb_rx, FWDSTEP);\n+\tfor (j = 0; j != k; j += FWDSTEP) {\n+\t\tprocessx4_step2(qconf, dip[j / FWDSTEP],\n+\t\t\tipv4_flag[j / FWDSTEP], portid,\n+\t\t\t&pkts_burst[j], &dst_port[j]);\n+\t}\n+\n+\t/*\n+\t * Finish packet processing and group consecutive\n+\t * packets with the same destination port.\n+\t */\n+\tk = RTE_ALIGN_FLOOR(nb_rx, FWDSTEP);\n+\tif (k != 0) {\n+\t\t__m128i dp1, dp2;\n+\n+\t\tlp = pnum;\n+\t\tlp[0] = 1;\n+\n+\t\tprocessx4_step3(pkts_burst, dst_port);\n+\n+\t\t/* dp1: <d[0], d[1], d[2], d[3], ... > */\n+\t\tdp1 = _mm_loadu_si128((__m128i *)dst_port);\n+\n+\t\tfor (j = FWDSTEP; j != k; j += FWDSTEP) {\n+\t\t\tprocessx4_step3(&pkts_burst[j], &dst_port[j]);\n+\n+\t\t\t/*\n+\t\t\t * dp2:\n+\t\t\t * <d[j-3], d[j-2], d[j-1], d[j], ... >\n+\t\t\t */\n+\t\t\tdp2 = _mm_loadu_si128((__m128i *)\n+\t\t\t\t\t&dst_port[j - FWDSTEP + 1]);\n+\t\t\tlp  = port_groupx4(&pnum[j - FWDSTEP], lp, dp1, dp2);\n+\n+\t\t\t/*\n+\t\t\t * dp1:\n+\t\t\t * <d[j], d[j+1], d[j+2], d[j+3], ... >\n+\t\t\t */\n+\t\t\tdp1 = _mm_srli_si128(dp2, (FWDSTEP - 1) *\n+\t\t\t\t\t\tsizeof(dst_port[0]));\n+\t\t}\n+\n+\t\t/*\n+\t\t * dp2: <d[j-3], d[j-2], d[j-1], d[j-1], ... >\n+\t\t */\n+\t\tdp2 = _mm_shufflelo_epi16(dp1, 0xf9);\n+\t\tlp  = port_groupx4(&pnum[j - FWDSTEP], lp, dp1, dp2);\n+\n+\t\t/*\n+\t\t * remove values added by the last repeated\n+\t\t * dst port.\n+\t\t */\n+\t\tlp[0]--;\n+\t\tdlp = dst_port[j - 1];\n+\t} else {\n+\t\t/* set dlp and lp to the never used values. */\n+\t\tdlp = BAD_PORT - 1;\n+\t\tlp = pnum + MAX_PKT_BURST;\n+\t}\n+\n+\t/* Process up to last 3 packets one by one. */\n+\tswitch (nb_rx % FWDSTEP) {\n+\tcase 3:\n+\t\tprocess_packet(qconf, pkts_burst[j], dst_port + j, portid);\n+\t\tGROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);\n+\t\tj++;\n+\tcase 2:\n+\t\tprocess_packet(qconf, pkts_burst[j], dst_port + j, portid);\n+\t\tGROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);\n+\t\tj++;\n+\tcase 1:\n+\t\tprocess_packet(qconf, pkts_burst[j], dst_port + j, portid);\n+\t\tGROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);\n+\t\tj++;\n+\t}\n+\n+\t/*\n+\t * Send packets out, through destination port.\n+\t * Consecuteve pacekts with the same destination port\n+\t * are already grouped together.\n+\t * If destination port for the packet equals BAD_PORT,\n+\t * then free the packet without sending it out.\n+\t */\n+\tfor (j = 0; j < nb_rx; j += k) {\n+\n+\t\tint32_t m;\n+\t\tuint16_t pn;\n+\n+\t\tpn = dst_port[j];\n+\t\tk = pnum[j];\n+\n+\t\tif (likely(pn != BAD_PORT)) {\n+\t\t\tsend_packetsx4(qconf, pn, pkts_burst + j, k);\n+\t\t} else {\n+\t\t\tfor (m = j; m != j + k; m++)\n+\t\t\t\trte_pktmbuf_free(pkts_burst[m]);\n+\t\t}\n+\t}\n+}\n+\n+#endif /* __L3FWD_LPM_SSE_H__ */\ndiff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c\nindex 5b0c2dd..729104f 100644\n--- a/examples/l3fwd/main.c\n+++ b/examples/l3fwd/main.c\n@@ -71,129 +71,54 @@\n #include <rte_tcp.h>\n #include <rte_udp.h>\n #include <rte_string_fns.h>\n+#include <rte_cpuflags.h>\n \n #include <cmdline_parse.h>\n #include <cmdline_parse_etheraddr.h>\n \n-#define APP_LOOKUP_EXACT_MATCH          0\n-#define APP_LOOKUP_LPM                  1\n-#define DO_RFC_1812_CHECKS\n-\n-#ifndef APP_LOOKUP_METHOD\n-#define APP_LOOKUP_METHOD             APP_LOOKUP_LPM\n-#endif\n-\n-/*\n- *  When set to zero, simple forwaring path is eanbled.\n- *  When set to one, optimized forwarding path is enabled.\n- *  Note that LPM optimisation path uses SSE4.1 instructions.\n- */\n-#if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && !defined(__SSE4_1__))\n-#define ENABLE_MULTI_BUFFER_OPTIMIZE\t0\n-#else\n-#define ENABLE_MULTI_BUFFER_OPTIMIZE\t1\n-#endif\n-\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-#include <rte_hash.h>\n-#elif (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-#include <rte_lpm.h>\n-#include <rte_lpm6.h>\n-#else\n-#error \"APP_LOOKUP_METHOD set to incorrect value\"\n-#endif\n-\n-#ifndef IPv6_BYTES\n-#define IPv6_BYTES_FMT \"%02x%02x:%02x%02x:%02x%02x:%02x%02x:\"\\\n-                       \"%02x%02x:%02x%02x:%02x%02x:%02x%02x\"\n-#define IPv6_BYTES(addr) \\\n-\taddr[0],  addr[1], addr[2],  addr[3], \\\n-\taddr[4],  addr[5], addr[6],  addr[7], \\\n-\taddr[8],  addr[9], addr[10], addr[11],\\\n-\taddr[12], addr[13],addr[14], addr[15]\n-#endif\n-\n-\n-#define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1\n-\n-#define MAX_JUMBO_PKT_LEN  9600\n-\n-#define IPV6_ADDR_LEN 16\n-\n-#define MEMPOOL_CACHE_SIZE 256\n+#include \"l3fwd.h\"\n \n /*\n- * This expression is used to calculate the number of mbufs needed depending on user input, taking\n- *  into account memory for rx and tx hardware rings, cache per lcore and mtable per port per lcore.\n- *  RTE_MAX is used to ensure that NB_MBUF never goes below a minimum value of 8192\n+ * Configurable number of RX/TX ring descriptors\n  */\n+#define RTE_TEST_RX_DESC_DEFAULT 128\n+#define RTE_TEST_TX_DESC_DEFAULT 512\n \n-#define NB_MBUF RTE_MAX\t(\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\t\t\t(nb_ports*nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT +\t\t\t\t\t\t\t\\\n-\t\t\t\tnb_ports*nb_lcores*MAX_PKT_BURST +\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\t\t\tnb_ports*n_tx_queue*RTE_TEST_TX_DESC_DEFAULT +\t\t\t\t\t\t\t\t\\\n-\t\t\t\tnb_lcores*MEMPOOL_CACHE_SIZE),\t\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\t\t\t(unsigned)8192)\n+#define MAX_TX_QUEUE_PER_PORT RTE_MAX_ETHPORTS\n+#define MAX_RX_QUEUE_PER_PORT 128\n \n-#define MAX_PKT_BURST     32\n-#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */\n+#define MAX_LCORE_PARAMS 1024\n \n-/*\n- * Try to avoid TX buffering if we have at least MAX_TX_BURST packets to send.\n- */\n-#define\tMAX_TX_BURST\t(MAX_PKT_BURST / 2)\n+/* Static global variables used within this file. */\n+static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;\n+static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;\n \n-#define NB_SOCKETS 8\n+/**< Ports set in promiscuous mode off by default. */\n+static int promiscuous_on;\n \n-/* Configure how many packets ahead to prefetch, when reading packets */\n-#define PREFETCH_OFFSET\t3\n+/* Select Longest-Prefix or Exact match. */\n+static int l3fwd_lpm_on;\n+static int l3fwd_em_on;\n \n-/* Used to mark destination port as 'invalid'. */\n-#define\tBAD_PORT\t((uint16_t)-1)\n+static int numa_on = 1; /**< NUMA is enabled by default. */\n \n-#define FWDSTEP\t4\n-\n-/*\n- * Configurable number of RX/TX ring descriptors\n- */\n-#define RTE_TEST_RX_DESC_DEFAULT 128\n-#define RTE_TEST_TX_DESC_DEFAULT 512\n-static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;\n-static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;\n+/* Global variables. */\n \n /* ethernet addresses of ports */\n-static uint64_t dest_eth_addr[RTE_MAX_ETHPORTS];\n-static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];\n-\n-static __m128i val_eth[RTE_MAX_ETHPORTS];\n+uint64_t dest_eth_addr[RTE_MAX_ETHPORTS];\n+struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];\n \n-/* replace first 12B of the ethernet header. */\n-#define\tMASK_ETH\t0x3f\n+__m128i val_eth[RTE_MAX_ETHPORTS];\n \n /* mask of enabled ports */\n-static uint32_t enabled_port_mask = 0;\n-static int promiscuous_on = 0; /**< Ports set in promiscuous mode off by default. */\n-static int numa_on = 1; /**< NUMA is enabled by default. */\n+uint32_t enabled_port_mask;\n \n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-static int ipv6 = 0; /**< ipv6 is false by default. */\n-#endif\n+/* Used only in exact match mode. */\n+int ipv6; /**< ipv6 is false by default. */\n+uint32_t hash_entry_number = HASH_ENTRY_NUMBER_DEFAULT;\n \n-struct mbuf_table {\n-\tuint16_t len;\n-\tstruct rte_mbuf *m_table[MAX_PKT_BURST];\n-};\n+struct lcore_conf lcore_conf[RTE_MAX_LCORE];\n \n-struct lcore_rx_queue {\n-\tuint8_t port_id;\n-\tuint8_t queue_id;\n-} __rte_cache_aligned;\n-\n-#define MAX_RX_QUEUE_PER_LCORE 16\n-#define MAX_TX_QUEUE_PER_PORT RTE_MAX_ETHPORTS\n-#define MAX_RX_QUEUE_PER_PORT 128\n-\n-#define MAX_LCORE_PARAMS 1024\n struct lcore_params {\n \tuint8_t port_id;\n \tuint8_t queue_id;\n@@ -241,1546 +166,43 @@ static struct rte_eth_conf port_conf = {\n \n static struct rte_mempool * pktmbuf_pool[NB_SOCKETS];\n \n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-\n-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n-#include <rte_hash_crc.h>\n-#define DEFAULT_HASH_FUNC       rte_hash_crc\n-#else\n-#include <rte_jhash.h>\n-#define DEFAULT_HASH_FUNC       rte_jhash\n-#endif\n-\n-struct ipv4_5tuple {\n-        uint32_t ip_dst;\n-        uint32_t ip_src;\n-        uint16_t port_dst;\n-        uint16_t port_src;\n-        uint8_t  proto;\n-} __attribute__((__packed__));\n-\n-union ipv4_5tuple_host {\n-\tstruct {\n-\t\tuint8_t  pad0;\n-\t\tuint8_t  proto;\n-\t\tuint16_t pad1;\n-\t\tuint32_t ip_src;\n-\t\tuint32_t ip_dst;\n-\t\tuint16_t port_src;\n-\t\tuint16_t port_dst;\n-\t};\n-\t__m128i xmm;\n-};\n-\n-#define XMM_NUM_IN_IPV6_5TUPLE 3\n-\n-struct ipv6_5tuple {\n-        uint8_t  ip_dst[IPV6_ADDR_LEN];\n-        uint8_t  ip_src[IPV6_ADDR_LEN];\n-        uint16_t port_dst;\n-        uint16_t port_src;\n-        uint8_t  proto;\n-} __attribute__((__packed__));\n-\n-union ipv6_5tuple_host {\n-\tstruct {\n-\t\tuint16_t pad0;\n-\t\tuint8_t  proto;\n-\t\tuint8_t  pad1;\n-\t\tuint8_t  ip_src[IPV6_ADDR_LEN];\n-\t\tuint8_t  ip_dst[IPV6_ADDR_LEN];\n-\t\tuint16_t port_src;\n-\t\tuint16_t port_dst;\n-\t\tuint64_t reserve;\n-\t};\n-\t__m128i xmm[XMM_NUM_IN_IPV6_5TUPLE];\n-};\n-\n-struct ipv4_l3fwd_route {\n-\tstruct ipv4_5tuple key;\n-\tuint8_t if_out;\n-};\n-\n-struct ipv6_l3fwd_route {\n-\tstruct ipv6_5tuple key;\n-\tuint8_t if_out;\n-};\n-\n-static struct ipv4_l3fwd_route ipv4_l3fwd_route_array[] = {\n-\t{{IPv4(101,0,0,0), IPv4(100,10,0,1),  101, 11, IPPROTO_TCP}, 0},\n-\t{{IPv4(201,0,0,0), IPv4(200,20,0,1),  102, 12, IPPROTO_TCP}, 1},\n-\t{{IPv4(111,0,0,0), IPv4(100,30,0,1),  101, 11, IPPROTO_TCP}, 2},\n-\t{{IPv4(211,0,0,0), IPv4(200,40,0,1),  102, 12, IPPROTO_TCP}, 3},\n-};\n-\n-static struct ipv6_l3fwd_route ipv6_l3fwd_route_array[] = {\n-\t{{\n-\t{0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n-\t{0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n-\t101, 11, IPPROTO_TCP}, 0},\n-\n-\t{{\n-\t{0xfe, 0x90, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n-\t{0xfe, 0x90, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n-\t102, 12, IPPROTO_TCP}, 1},\n-\n-\t{{\n-\t{0xfe, 0xa0, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n-\t{0xfe, 0xa0, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n-\t101, 11, IPPROTO_TCP}, 2},\n-\n-\t{{\n-\t{0xfe, 0xb0, 0, 0, 0, 0, 0, 0, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0, 0, 0},\n-\t{0xfe, 0xb0, 0, 0, 0, 0, 0, 0, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05},\n-\t102, 12, IPPROTO_TCP}, 3},\n-};\n-\n-typedef struct rte_hash lookup_struct_t;\n-static lookup_struct_t *ipv4_l3fwd_lookup_struct[NB_SOCKETS];\n-static lookup_struct_t *ipv6_l3fwd_lookup_struct[NB_SOCKETS];\n-\n-#ifdef RTE_ARCH_X86_64\n-/* default to 4 million hash entries (approx) */\n-#define L3FWD_HASH_ENTRIES\t\t1024*1024*4\n-#else\n-/* 32-bit has less address-space for hugepage memory, limit to 1M entries */\n-#define L3FWD_HASH_ENTRIES\t\t1024*1024*1\n-#endif\n-#define HASH_ENTRY_NUMBER_DEFAULT\t4\n-\n-static uint32_t hash_entry_number = HASH_ENTRY_NUMBER_DEFAULT;\n-\n-static inline uint32_t\n-ipv4_hash_crc(const void *data, __rte_unused uint32_t data_len,\n-\tuint32_t init_val)\n-{\n-\tconst union ipv4_5tuple_host *k;\n-\tuint32_t t;\n-\tconst uint32_t *p;\n-\n-\tk = data;\n-\tt = k->proto;\n-\tp = (const uint32_t *)&k->port_src;\n-\n-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n-\tinit_val = rte_hash_crc_4byte(t, init_val);\n-\tinit_val = rte_hash_crc_4byte(k->ip_src, init_val);\n-\tinit_val = rte_hash_crc_4byte(k->ip_dst, init_val);\n-\tinit_val = rte_hash_crc_4byte(*p, init_val);\n-#else /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n-\tinit_val = rte_jhash_1word(t, init_val);\n-\tinit_val = rte_jhash_1word(k->ip_src, init_val);\n-\tinit_val = rte_jhash_1word(k->ip_dst, init_val);\n-\tinit_val = rte_jhash_1word(*p, init_val);\n-#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n-\treturn (init_val);\n-}\n-\n-static inline uint32_t\n-ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len, uint32_t init_val)\n-{\n-\tconst union ipv6_5tuple_host *k;\n-\tuint32_t t;\n-\tconst uint32_t *p;\n-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n-\tconst uint32_t  *ip_src0, *ip_src1, *ip_src2, *ip_src3;\n-\tconst uint32_t  *ip_dst0, *ip_dst1, *ip_dst2, *ip_dst3;\n-#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n-\n-\tk = data;\n-\tt = k->proto;\n-\tp = (const uint32_t *)&k->port_src;\n-\n-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n-\tip_src0 = (const uint32_t *) k->ip_src;\n-\tip_src1 = (const uint32_t *)(k->ip_src+4);\n-\tip_src2 = (const uint32_t *)(k->ip_src+8);\n-\tip_src3 = (const uint32_t *)(k->ip_src+12);\n-\tip_dst0 = (const uint32_t *) k->ip_dst;\n-\tip_dst1 = (const uint32_t *)(k->ip_dst+4);\n-\tip_dst2 = (const uint32_t *)(k->ip_dst+8);\n-\tip_dst3 = (const uint32_t *)(k->ip_dst+12);\n-\tinit_val = rte_hash_crc_4byte(t, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_src0, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_src1, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_src2, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_src3, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_dst0, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_dst1, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_dst2, init_val);\n-\tinit_val = rte_hash_crc_4byte(*ip_dst3, init_val);\n-\tinit_val = rte_hash_crc_4byte(*p, init_val);\n-#else /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n-\tinit_val = rte_jhash_1word(t, init_val);\n-\tinit_val = rte_jhash(k->ip_src, sizeof(uint8_t) * IPV6_ADDR_LEN, init_val);\n-\tinit_val = rte_jhash(k->ip_dst, sizeof(uint8_t) * IPV6_ADDR_LEN, init_val);\n-\tinit_val = rte_jhash_1word(*p, init_val);\n-#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */\n-\treturn (init_val);\n-}\n-\n-#define IPV4_L3FWD_NUM_ROUTES \\\n-\t(sizeof(ipv4_l3fwd_route_array) / sizeof(ipv4_l3fwd_route_array[0]))\n-\n-#define IPV6_L3FWD_NUM_ROUTES \\\n-\t(sizeof(ipv6_l3fwd_route_array) / sizeof(ipv6_l3fwd_route_array[0]))\n-\n-static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned;\n-static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned;\n-\n-#endif\n-\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-struct ipv4_l3fwd_route {\n-\tuint32_t ip;\n-\tuint8_t  depth;\n-\tuint8_t  if_out;\n+struct l3fwd_lkp_mode {\n+\tvoid  (*setup)(int);\n+\tint   (*main_loop)(void *);\n+\tvoid* (*get_ipv4_lookup_struct)(int);\n+\tvoid* (*get_ipv6_lookup_struct)(int);\n };\n \n-struct ipv6_l3fwd_route {\n-\tuint8_t ip[16];\n-\tuint8_t  depth;\n-\tuint8_t  if_out;\n-};\n+static struct l3fwd_lkp_mode l3fwd_lkp;\n \n-static struct ipv4_l3fwd_route ipv4_l3fwd_route_array[] = {\n-\t{IPv4(1,1,1,0), 24, 0},\n-\t{IPv4(2,1,1,0), 24, 1},\n-\t{IPv4(3,1,1,0), 24, 2},\n-\t{IPv4(4,1,1,0), 24, 3},\n-\t{IPv4(5,1,1,0), 24, 4},\n-\t{IPv4(6,1,1,0), 24, 5},\n-\t{IPv4(7,1,1,0), 24, 6},\n-\t{IPv4(8,1,1,0), 24, 7},\n+static struct l3fwd_lkp_mode l3fwd_em_lkp = {\n+\t.setup                  = setup_hash,\n+\t.main_loop              = em_main_loop,\n+\t.get_ipv4_lookup_struct = em_get_ipv4_l3fwd_lookup_struct,\n+\t.get_ipv6_lookup_struct = em_get_ipv6_l3fwd_lookup_struct,\n };\n \n-static struct ipv6_l3fwd_route ipv6_l3fwd_route_array[] = {\n-\t{{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 0},\n-\t{{2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 1},\n-\t{{3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 2},\n-\t{{4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 3},\n-\t{{5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 4},\n-\t{{6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 5},\n-\t{{7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 6},\n-\t{{8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 48, 7},\n+static struct l3fwd_lkp_mode l3fwd_lpm_lkp = {\n+\t.setup                  = setup_lpm,\n+\t.main_loop              = lpm_main_loop,\n+\t.get_ipv4_lookup_struct = lpm_get_ipv4_l3fwd_lookup_struct,\n+\t.get_ipv6_lookup_struct = lpm_get_ipv6_l3fwd_lookup_struct,\n };\n \n-#define IPV4_L3FWD_NUM_ROUTES \\\n-\t(sizeof(ipv4_l3fwd_route_array) / sizeof(ipv4_l3fwd_route_array[0]))\n-#define IPV6_L3FWD_NUM_ROUTES \\\n-\t(sizeof(ipv6_l3fwd_route_array) / sizeof(ipv6_l3fwd_route_array[0]))\n-\n-#define IPV4_L3FWD_LPM_MAX_RULES         1024\n-#define IPV6_L3FWD_LPM_MAX_RULES         1024\n-#define IPV6_L3FWD_LPM_NUMBER_TBL8S (1 << 16)\n-\n-typedef struct rte_lpm lookup_struct_t;\n-typedef struct rte_lpm6 lookup6_struct_t;\n-static lookup_struct_t *ipv4_l3fwd_lookup_struct[NB_SOCKETS];\n-static lookup6_struct_t *ipv6_l3fwd_lookup_struct[NB_SOCKETS];\n-#endif\n-\n-struct lcore_conf {\n-\tuint16_t n_rx_queue;\n-\tstruct lcore_rx_queue rx_queue_list[MAX_RX_QUEUE_PER_LCORE];\n-\tuint16_t tx_queue_id[RTE_MAX_ETHPORTS];\n-\tstruct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS];\n-\tlookup_struct_t * ipv4_lookup_struct;\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-\tlookup6_struct_t * ipv6_lookup_struct;\n-#else\n-\tlookup_struct_t * ipv6_lookup_struct;\n-#endif\n-} __rte_cache_aligned;\n-\n-static struct lcore_conf lcore_conf[RTE_MAX_LCORE];\n-\n-/* Send burst of packets on an output interface */\n-static inline int\n-send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port)\n-{\n-\tstruct rte_mbuf **m_table;\n-\tint ret;\n-\tuint16_t queueid;\n-\n-\tqueueid = qconf->tx_queue_id[port];\n-\tm_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;\n-\n-\tret = rte_eth_tx_burst(port, queueid, m_table, n);\n-\tif (unlikely(ret < n)) {\n-\t\tdo {\n-\t\t\trte_pktmbuf_free(m_table[ret]);\n-\t\t} while (++ret < n);\n-\t}\n-\n-\treturn 0;\n-}\n-\n-/* Enqueue a single packet, and send burst if queue is filled */\n-static inline int\n-send_single_packet(struct rte_mbuf *m, uint8_t port)\n-{\n-\tuint32_t lcore_id;\n-\tuint16_t len;\n-\tstruct lcore_conf *qconf;\n-\n-\tlcore_id = rte_lcore_id();\n-\n-\tqconf = &lcore_conf[lcore_id];\n-\tlen = qconf->tx_mbufs[port].len;\n-\tqconf->tx_mbufs[port].m_table[len] = m;\n-\tlen++;\n-\n-\t/* enough pkts to be sent */\n-\tif (unlikely(len == MAX_PKT_BURST)) {\n-\t\tsend_burst(qconf, MAX_PKT_BURST, port);\n-\t\tlen = 0;\n-\t}\n-\n-\tqconf->tx_mbufs[port].len = len;\n-\treturn 0;\n-}\n-\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-static inline __attribute__((always_inline)) void\n-send_packetsx4(struct lcore_conf *qconf, uint8_t port,\n-\tstruct rte_mbuf *m[], uint32_t num)\n-{\n-\tuint32_t len, j, n;\n-\n-\tlen = qconf->tx_mbufs[port].len;\n-\n-\t/*\n-\t * If TX buffer for that queue is empty, and we have enough packets,\n-\t * then send them straightway.\n-\t */\n-\tif (num >= MAX_TX_BURST && len == 0) {\n-\t\tn = rte_eth_tx_burst(port, qconf->tx_queue_id[port], m, num);\n-\t\tif (unlikely(n < num)) {\n-\t\t\tdo {\n-\t\t\t\trte_pktmbuf_free(m[n]);\n-\t\t\t} while (++n < num);\n-\t\t}\n-\t\treturn;\n-\t}\n-\n-\t/*\n-\t * Put packets into TX buffer for that queue.\n-\t */\n-\n-\tn = len + num;\n-\tn = (n > MAX_PKT_BURST) ? MAX_PKT_BURST - len : num;\n-\n-\tj = 0;\n-\tswitch (n % FWDSTEP) {\n-\twhile (j < n) {\n-\tcase 0:\n-\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n-\t\tj++;\n-\tcase 3:\n-\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n-\t\tj++;\n-\tcase 2:\n-\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n-\t\tj++;\n-\tcase 1:\n-\t\tqconf->tx_mbufs[port].m_table[len + j] = m[j];\n-\t\tj++;\n-\t}\n-\t}\n-\n-\tlen += n;\n-\n-\t/* enough pkts to be sent */\n-\tif (unlikely(len == MAX_PKT_BURST)) {\n-\n-\t\tsend_burst(qconf, MAX_PKT_BURST, port);\n-\n-\t\t/* copy rest of the packets into the TX buffer. */\n-\t\tlen = num - n;\n-\t\tj = 0;\n-\t\tswitch (len % FWDSTEP) {\n-\t\twhile (j < len) {\n-\t\tcase 0:\n-\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n-\t\t\tj++;\n-\t\tcase 3:\n-\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n-\t\t\tj++;\n-\t\tcase 2:\n-\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n-\t\t\tj++;\n-\t\tcase 1:\n-\t\t\tqconf->tx_mbufs[port].m_table[j] = m[n + j];\n-\t\t\tj++;\n-\t\t}\n-\t\t}\n-\t}\n-\n-\tqconf->tx_mbufs[port].len = len;\n-}\n-#endif /* APP_LOOKUP_LPM */\n-\n-#ifdef DO_RFC_1812_CHECKS\n-static inline int\n-is_valid_ipv4_pkt(struct ipv4_hdr *pkt, uint32_t link_len)\n-{\n-\t/* From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2 */\n-\t/*\n-\t * 1. The packet length reported by the Link Layer must be large\n-\t * enough to hold the minimum length legal IP datagram (20 bytes).\n-\t */\n-\tif (link_len < sizeof(struct ipv4_hdr))\n-\t\treturn -1;\n-\n-\t/* 2. The IP checksum must be correct. */\n-\t/* this is checked in H/W */\n-\n-\t/*\n-\t * 3. The IP version number must be 4. If the version number is not 4\n-\t * then the packet may be another version of IP, such as IPng or\n-\t * ST-II.\n-\t */\n-\tif (((pkt->version_ihl) >> 4) != 4)\n-\t\treturn -3;\n-\t/*\n-\t * 4. The IP header length field must be large enough to hold the\n-\t * minimum length legal IP datagram (20 bytes = 5 words).\n-\t */\n-\tif ((pkt->version_ihl & 0xf) < 5)\n-\t\treturn -4;\n-\n-\t/*\n-\t * 5. The IP total length field must be large enough to hold the IP\n-\t * datagram header, whose length is specified in the IP header length\n-\t * field.\n-\t */\n-\tif (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct ipv4_hdr))\n-\t\treturn -5;\n-\n-\treturn 0;\n-}\n-#endif\n-\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-\n-static __m128i mask0;\n-static __m128i mask1;\n-static __m128i mask2;\n-static inline uint8_t\n-get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, lookup_struct_t * ipv4_l3fwd_lookup_struct)\n-{\n-\tint ret = 0;\n-\tunion ipv4_5tuple_host key;\n-\n-\tipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live);\n-\t__m128i data = _mm_loadu_si128((__m128i*)(ipv4_hdr));\n-\t/* Get 5 tuple: dst port, src port, dst IP address, src IP address and protocol */\n-\tkey.xmm = _mm_and_si128(data, mask0);\n-\t/* Find destination port */\n-\tret = rte_hash_lookup(ipv4_l3fwd_lookup_struct, (const void *)&key);\n-\treturn (uint8_t)((ret < 0)? portid : ipv4_l3fwd_out_if[ret]);\n-}\n-\n-static inline uint8_t\n-get_ipv6_dst_port(void *ipv6_hdr,  uint8_t portid, lookup_struct_t * ipv6_l3fwd_lookup_struct)\n-{\n-\tint ret = 0;\n-\tunion ipv6_5tuple_host key;\n-\n-\tipv6_hdr = (uint8_t *)ipv6_hdr + offsetof(struct ipv6_hdr, payload_len);\n-\t__m128i data0 = _mm_loadu_si128((__m128i*)(ipv6_hdr));\n-\t__m128i data1 = _mm_loadu_si128((__m128i*)(((uint8_t*)ipv6_hdr)+sizeof(__m128i)));\n-\t__m128i data2 = _mm_loadu_si128((__m128i*)(((uint8_t*)ipv6_hdr)+sizeof(__m128i)+sizeof(__m128i)));\n-\t/* Get part of 5 tuple: src IP address lower 96 bits and protocol */\n-\tkey.xmm[0] = _mm_and_si128(data0, mask1);\n-\t/* Get part of 5 tuple: dst IP address lower 96 bits and src IP address higher 32 bits */\n-\tkey.xmm[1] = data1;\n-\t/* Get part of 5 tuple: dst port and src port and dst IP address higher 32 bits */\n-\tkey.xmm[2] = _mm_and_si128(data2, mask2);\n-\n-\t/* Find destination port */\n-\tret = rte_hash_lookup(ipv6_l3fwd_lookup_struct, (const void *)&key);\n-\treturn (uint8_t)((ret < 0)? portid : ipv6_l3fwd_out_if[ret]);\n-}\n-#endif\n-\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-\n-static inline uint8_t\n-get_ipv4_dst_port(void *ipv4_hdr,  uint8_t portid, lookup_struct_t * ipv4_l3fwd_lookup_struct)\n-{\n-\tuint8_t next_hop;\n-\n-\treturn (uint8_t) ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct,\n-\t\trte_be_to_cpu_32(((struct ipv4_hdr *)ipv4_hdr)->dst_addr),\n-\t\t&next_hop) == 0) ? next_hop : portid);\n-}\n-\n-static inline uint8_t\n-get_ipv6_dst_port(void *ipv6_hdr,  uint8_t portid, lookup6_struct_t * ipv6_l3fwd_lookup_struct)\n-{\n-\tuint8_t next_hop;\n-\treturn (uint8_t) ((rte_lpm6_lookup(ipv6_l3fwd_lookup_struct,\n-\t\t\t((struct ipv6_hdr*)ipv6_hdr)->dst_addr, &next_hop) == 0)?\n-\t\t\tnext_hop : portid);\n-}\n-#endif\n-\n-static inline void l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,\n-\tstruct lcore_conf *qconf)  __attribute__((unused));\n-\n-#if ((APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH) && \\\n-\t(ENABLE_MULTI_BUFFER_OPTIMIZE == 1))\n-\n-#define MASK_ALL_PKTS    0xff\n-#define EXCLUDE_1ST_PKT 0xfe\n-#define EXCLUDE_2ND_PKT 0xfd\n-#define EXCLUDE_3RD_PKT 0xfb\n-#define EXCLUDE_4TH_PKT 0xf7\n-#define EXCLUDE_5TH_PKT 0xef\n-#define EXCLUDE_6TH_PKT 0xdf\n-#define EXCLUDE_7TH_PKT 0xbf\n-#define EXCLUDE_8TH_PKT 0x7f\n-\n-static inline void\n-simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid, struct lcore_conf *qconf)\n-{\n-\tstruct ether_hdr *eth_hdr[8];\n-\tstruct ipv4_hdr *ipv4_hdr[8];\n-\tuint8_t dst_port[8];\n-\tint32_t ret[8];\n-\tunion ipv4_5tuple_host key[8];\n-\t__m128i data[8];\n-\n-\teth_hdr[0] = rte_pktmbuf_mtod(m[0], struct ether_hdr *);\n-\teth_hdr[1] = rte_pktmbuf_mtod(m[1], struct ether_hdr *);\n-\teth_hdr[2] = rte_pktmbuf_mtod(m[2], struct ether_hdr *);\n-\teth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);\n-\teth_hdr[4] = rte_pktmbuf_mtod(m[4], struct ether_hdr *);\n-\teth_hdr[5] = rte_pktmbuf_mtod(m[5], struct ether_hdr *);\n-\teth_hdr[6] = rte_pktmbuf_mtod(m[6], struct ether_hdr *);\n-\teth_hdr[7] = rte_pktmbuf_mtod(m[7], struct ether_hdr *);\n-\n-\t/* Handle IPv4 headers.*/\n-\tipv4_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv4_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv4_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv4_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv4_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv4_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv4_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv4_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct ipv4_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\n-#ifdef DO_RFC_1812_CHECKS\n-\t/* Check to make sure the packet is valid (RFC1812) */\n-\tuint8_t valid_mask = MASK_ALL_PKTS;\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[0], m[0]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[0]);\n-\t\tvalid_mask &= EXCLUDE_1ST_PKT;\n-\t}\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[1], m[1]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[1]);\n-\t\tvalid_mask &= EXCLUDE_2ND_PKT;\n-\t}\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[2], m[2]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[2]);\n-\t\tvalid_mask &= EXCLUDE_3RD_PKT;\n-\t}\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[3], m[3]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[3]);\n-\t\tvalid_mask &= EXCLUDE_4TH_PKT;\n-\t}\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[4], m[4]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[4]);\n-\t\tvalid_mask &= EXCLUDE_5TH_PKT;\n-\t}\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[5], m[5]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[5]);\n-\t\tvalid_mask &= EXCLUDE_6TH_PKT;\n-\t}\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[6], m[6]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[6]);\n-\t\tvalid_mask &= EXCLUDE_7TH_PKT;\n-\t}\n-\tif (is_valid_ipv4_pkt(ipv4_hdr[7], m[7]->pkt_len) < 0) {\n-\t\trte_pktmbuf_free(m[7]);\n-\t\tvalid_mask &= EXCLUDE_8TH_PKT;\n-\t}\n-\tif (unlikely(valid_mask != MASK_ALL_PKTS)) {\n-\t\tif (valid_mask == 0){\n-\t\t\treturn;\n-\t\t} else {\n-\t\t\tuint8_t i = 0;\n-\t\t\tfor (i = 0; i < 8; i++) {\n-\t\t\t\tif ((0x1 << i) & valid_mask) {\n-\t\t\t\t\tl3fwd_simple_forward(m[i], portid, qconf);\n-\t\t\t\t}\n-\t\t\t}\n-\t\t\treturn;\n-\t\t}\n-\t}\n-#endif // End of #ifdef DO_RFC_1812_CHECKS\n-\n-\tdata[0] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[0], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[1] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[1], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[2] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[2], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[3] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[3], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[4] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[4], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[5] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[5], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[6] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[6], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[7] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[7], __m128i *,\n-\t\t\t\t\tsizeof(struct ether_hdr) +\n-\t\t\t\t\toffsetof(struct ipv4_hdr, time_to_live)));\n-\n-\tkey[0].xmm = _mm_and_si128(data[0], mask0);\n-\tkey[1].xmm = _mm_and_si128(data[1], mask0);\n-\tkey[2].xmm = _mm_and_si128(data[2], mask0);\n-\tkey[3].xmm = _mm_and_si128(data[3], mask0);\n-\tkey[4].xmm = _mm_and_si128(data[4], mask0);\n-\tkey[5].xmm = _mm_and_si128(data[5], mask0);\n-\tkey[6].xmm = _mm_and_si128(data[6], mask0);\n-\tkey[7].xmm = _mm_and_si128(data[7], mask0);\n-\n-\tconst void *key_array[8] = {&key[0], &key[1], &key[2], &key[3],\n-\t\t\t\t&key[4], &key[5], &key[6], &key[7]};\n-\n-\trte_hash_lookup_multi(qconf->ipv4_lookup_struct, &key_array[0], 8, ret);\n-\tdst_port[0] = (uint8_t) ((ret[0] < 0) ? portid : ipv4_l3fwd_out_if[ret[0]]);\n-\tdst_port[1] = (uint8_t) ((ret[1] < 0) ? portid : ipv4_l3fwd_out_if[ret[1]]);\n-\tdst_port[2] = (uint8_t) ((ret[2] < 0) ? portid : ipv4_l3fwd_out_if[ret[2]]);\n-\tdst_port[3] = (uint8_t) ((ret[3] < 0) ? portid : ipv4_l3fwd_out_if[ret[3]]);\n-\tdst_port[4] = (uint8_t) ((ret[4] < 0) ? portid : ipv4_l3fwd_out_if[ret[4]]);\n-\tdst_port[5] = (uint8_t) ((ret[5] < 0) ? portid : ipv4_l3fwd_out_if[ret[5]]);\n-\tdst_port[6] = (uint8_t) ((ret[6] < 0) ? portid : ipv4_l3fwd_out_if[ret[6]]);\n-\tdst_port[7] = (uint8_t) ((ret[7] < 0) ? portid : ipv4_l3fwd_out_if[ret[7]]);\n-\n-\tif (dst_port[0] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[0]) == 0)\n-\t\tdst_port[0] = portid;\n-\tif (dst_port[1] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[1]) == 0)\n-\t\tdst_port[1] = portid;\n-\tif (dst_port[2] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[2]) == 0)\n-\t\tdst_port[2] = portid;\n-\tif (dst_port[3] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[3]) == 0)\n-\t\tdst_port[3] = portid;\n-\tif (dst_port[4] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[4]) == 0)\n-\t\tdst_port[4] = portid;\n-\tif (dst_port[5] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[5]) == 0)\n-\t\tdst_port[5] = portid;\n-\tif (dst_port[6] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[6]) == 0)\n-\t\tdst_port[6] = portid;\n-\tif (dst_port[7] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[7]) == 0)\n-\t\tdst_port[7] = portid;\n-\n-#ifdef DO_RFC_1812_CHECKS\n-\t/* Update time to live and header checksum */\n-\t--(ipv4_hdr[0]->time_to_live);\n-\t--(ipv4_hdr[1]->time_to_live);\n-\t--(ipv4_hdr[2]->time_to_live);\n-\t--(ipv4_hdr[3]->time_to_live);\n-\t++(ipv4_hdr[0]->hdr_checksum);\n-\t++(ipv4_hdr[1]->hdr_checksum);\n-\t++(ipv4_hdr[2]->hdr_checksum);\n-\t++(ipv4_hdr[3]->hdr_checksum);\n-\t--(ipv4_hdr[4]->time_to_live);\n-\t--(ipv4_hdr[5]->time_to_live);\n-\t--(ipv4_hdr[6]->time_to_live);\n-\t--(ipv4_hdr[7]->time_to_live);\n-\t++(ipv4_hdr[4]->hdr_checksum);\n-\t++(ipv4_hdr[5]->hdr_checksum);\n-\t++(ipv4_hdr[6]->hdr_checksum);\n-\t++(ipv4_hdr[7]->hdr_checksum);\n-#endif\n-\n-\t/* dst addr */\n-\t*(uint64_t *)&eth_hdr[0]->d_addr = dest_eth_addr[dst_port[0]];\n-\t*(uint64_t *)&eth_hdr[1]->d_addr = dest_eth_addr[dst_port[1]];\n-\t*(uint64_t *)&eth_hdr[2]->d_addr = dest_eth_addr[dst_port[2]];\n-\t*(uint64_t *)&eth_hdr[3]->d_addr = dest_eth_addr[dst_port[3]];\n-\t*(uint64_t *)&eth_hdr[4]->d_addr = dest_eth_addr[dst_port[4]];\n-\t*(uint64_t *)&eth_hdr[5]->d_addr = dest_eth_addr[dst_port[5]];\n-\t*(uint64_t *)&eth_hdr[6]->d_addr = dest_eth_addr[dst_port[6]];\n-\t*(uint64_t *)&eth_hdr[7]->d_addr = dest_eth_addr[dst_port[7]];\n-\n-\t/* src addr */\n-\tether_addr_copy(&ports_eth_addr[dst_port[0]], &eth_hdr[0]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[1]], &eth_hdr[1]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[2]], &eth_hdr[2]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[3]], &eth_hdr[3]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[4]], &eth_hdr[4]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[5]], &eth_hdr[5]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[6]], &eth_hdr[6]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[7]], &eth_hdr[7]->s_addr);\n-\n-\tsend_single_packet(m[0], (uint8_t)dst_port[0]);\n-\tsend_single_packet(m[1], (uint8_t)dst_port[1]);\n-\tsend_single_packet(m[2], (uint8_t)dst_port[2]);\n-\tsend_single_packet(m[3], (uint8_t)dst_port[3]);\n-\tsend_single_packet(m[4], (uint8_t)dst_port[4]);\n-\tsend_single_packet(m[5], (uint8_t)dst_port[5]);\n-\tsend_single_packet(m[6], (uint8_t)dst_port[6]);\n-\tsend_single_packet(m[7], (uint8_t)dst_port[7]);\n-\n-}\n-\n-static inline void get_ipv6_5tuple(struct rte_mbuf* m0, __m128i mask0, __m128i mask1,\n-\t\t\t\t union ipv6_5tuple_host * key)\n-{\n-        __m128i tmpdata0 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)));\n-        __m128i tmpdata1 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len) + sizeof(__m128i)));\n-        __m128i tmpdata2 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len) + sizeof(__m128i) + sizeof(__m128i)));\n-        key->xmm[0] = _mm_and_si128(tmpdata0, mask0);\n-        key->xmm[1] = tmpdata1;\n-        key->xmm[2] = _mm_and_si128(tmpdata2, mask1);\n-\treturn;\n-}\n-\n-static inline void\n-simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid, struct lcore_conf *qconf)\n-{\n-\tstruct ether_hdr *eth_hdr[8];\n-\t__attribute__((unused)) struct ipv6_hdr *ipv6_hdr[8];\n-\tuint8_t dst_port[8];\n-\tint32_t ret[8];\n-\tunion ipv6_5tuple_host key[8];\n-\n-\teth_hdr[0] = rte_pktmbuf_mtod(m[0], struct ether_hdr *);\n-\teth_hdr[1] = rte_pktmbuf_mtod(m[1], struct ether_hdr *);\n-\teth_hdr[2] = rte_pktmbuf_mtod(m[2], struct ether_hdr *);\n-\teth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);\n-\teth_hdr[4] = rte_pktmbuf_mtod(m[4], struct ether_hdr *);\n-\teth_hdr[5] = rte_pktmbuf_mtod(m[5], struct ether_hdr *);\n-\teth_hdr[6] = rte_pktmbuf_mtod(m[6], struct ether_hdr *);\n-\teth_hdr[7] = rte_pktmbuf_mtod(m[7], struct ether_hdr *);\n-\n-\t/* Handle IPv6 headers.*/\n-\tipv6_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv6_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv6_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv6_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv6_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv6_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv6_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\tipv6_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct ipv6_hdr *,\n-\t\t\t\t\t      sizeof(struct ether_hdr));\n-\n-\tget_ipv6_5tuple(m[0], mask1, mask2, &key[0]);\n-\tget_ipv6_5tuple(m[1], mask1, mask2, &key[1]);\n-\tget_ipv6_5tuple(m[2], mask1, mask2, &key[2]);\n-\tget_ipv6_5tuple(m[3], mask1, mask2, &key[3]);\n-\tget_ipv6_5tuple(m[4], mask1, mask2, &key[4]);\n-\tget_ipv6_5tuple(m[5], mask1, mask2, &key[5]);\n-\tget_ipv6_5tuple(m[6], mask1, mask2, &key[6]);\n-\tget_ipv6_5tuple(m[7], mask1, mask2, &key[7]);\n-\n-\tconst void *key_array[8] = {&key[0], &key[1], &key[2], &key[3],\n-\t\t\t\t&key[4], &key[5], &key[6], &key[7]};\n-\n-\trte_hash_lookup_multi(qconf->ipv6_lookup_struct, &key_array[0], 8, ret);\n-\tdst_port[0] = (uint8_t) ((ret[0] < 0) ? portid:ipv6_l3fwd_out_if[ret[0]]);\n-\tdst_port[1] = (uint8_t) ((ret[1] < 0) ? portid:ipv6_l3fwd_out_if[ret[1]]);\n-\tdst_port[2] = (uint8_t) ((ret[2] < 0) ? portid:ipv6_l3fwd_out_if[ret[2]]);\n-\tdst_port[3] = (uint8_t) ((ret[3] < 0) ? portid:ipv6_l3fwd_out_if[ret[3]]);\n-\tdst_port[4] = (uint8_t) ((ret[4] < 0) ? portid:ipv6_l3fwd_out_if[ret[4]]);\n-\tdst_port[5] = (uint8_t) ((ret[5] < 0) ? portid:ipv6_l3fwd_out_if[ret[5]]);\n-\tdst_port[6] = (uint8_t) ((ret[6] < 0) ? portid:ipv6_l3fwd_out_if[ret[6]]);\n-\tdst_port[7] = (uint8_t) ((ret[7] < 0) ? portid:ipv6_l3fwd_out_if[ret[7]]);\n-\n-\tif (dst_port[0] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[0]) == 0)\n-\t\tdst_port[0] = portid;\n-\tif (dst_port[1] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[1]) == 0)\n-\t\tdst_port[1] = portid;\n-\tif (dst_port[2] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[2]) == 0)\n-\t\tdst_port[2] = portid;\n-\tif (dst_port[3] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[3]) == 0)\n-\t\tdst_port[3] = portid;\n-\tif (dst_port[4] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[4]) == 0)\n-\t\tdst_port[4] = portid;\n-\tif (dst_port[5] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[5]) == 0)\n-\t\tdst_port[5] = portid;\n-\tif (dst_port[6] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[6]) == 0)\n-\t\tdst_port[6] = portid;\n-\tif (dst_port[7] >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port[7]) == 0)\n-\t\tdst_port[7] = portid;\n-\n-\t/* dst addr */\n-\t*(uint64_t *)&eth_hdr[0]->d_addr = dest_eth_addr[dst_port[0]];\n-\t*(uint64_t *)&eth_hdr[1]->d_addr = dest_eth_addr[dst_port[1]];\n-\t*(uint64_t *)&eth_hdr[2]->d_addr = dest_eth_addr[dst_port[2]];\n-\t*(uint64_t *)&eth_hdr[3]->d_addr = dest_eth_addr[dst_port[3]];\n-\t*(uint64_t *)&eth_hdr[4]->d_addr = dest_eth_addr[dst_port[4]];\n-\t*(uint64_t *)&eth_hdr[5]->d_addr = dest_eth_addr[dst_port[5]];\n-\t*(uint64_t *)&eth_hdr[6]->d_addr = dest_eth_addr[dst_port[6]];\n-\t*(uint64_t *)&eth_hdr[7]->d_addr = dest_eth_addr[dst_port[7]];\n-\n-\t/* src addr */\n-\tether_addr_copy(&ports_eth_addr[dst_port[0]], &eth_hdr[0]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[1]], &eth_hdr[1]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[2]], &eth_hdr[2]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[3]], &eth_hdr[3]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[4]], &eth_hdr[4]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[5]], &eth_hdr[5]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[6]], &eth_hdr[6]->s_addr);\n-\tether_addr_copy(&ports_eth_addr[dst_port[7]], &eth_hdr[7]->s_addr);\n-\n-\tsend_single_packet(m[0], (uint8_t)dst_port[0]);\n-\tsend_single_packet(m[1], (uint8_t)dst_port[1]);\n-\tsend_single_packet(m[2], (uint8_t)dst_port[2]);\n-\tsend_single_packet(m[3], (uint8_t)dst_port[3]);\n-\tsend_single_packet(m[4], (uint8_t)dst_port[4]);\n-\tsend_single_packet(m[5], (uint8_t)dst_port[5]);\n-\tsend_single_packet(m[6], (uint8_t)dst_port[6]);\n-\tsend_single_packet(m[7], (uint8_t)dst_port[7]);\n-\n-}\n-#endif /* APP_LOOKUP_METHOD */\n-\n-static inline __attribute__((always_inline)) void\n-l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qconf)\n-{\n-\tstruct ether_hdr *eth_hdr;\n-\tstruct ipv4_hdr *ipv4_hdr;\n-\tuint8_t dst_port;\n-\n-\teth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);\n-\n-\tif (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {\n-\t\t/* Handle IPv4 headers.*/\n-\t\tipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,\n-\t\t\t\t\t\t   sizeof(struct ether_hdr));\n-\n-#ifdef DO_RFC_1812_CHECKS\n-\t\t/* Check to make sure the packet is valid (RFC1812) */\n-\t\tif (is_valid_ipv4_pkt(ipv4_hdr, m->pkt_len) < 0) {\n-\t\t\trte_pktmbuf_free(m);\n-\t\t\treturn;\n-\t\t}\n-#endif\n-\n-\t\t dst_port = get_ipv4_dst_port(ipv4_hdr, portid,\n-\t\t\tqconf->ipv4_lookup_struct);\n-\t\tif (dst_port >= RTE_MAX_ETHPORTS ||\n-\t\t\t\t(enabled_port_mask & 1 << dst_port) == 0)\n-\t\t\tdst_port = portid;\n-\n-#ifdef DO_RFC_1812_CHECKS\n-\t\t/* Update time to live and header checksum */\n-\t\t--(ipv4_hdr->time_to_live);\n-\t\t++(ipv4_hdr->hdr_checksum);\n-#endif\n-\t\t/* dst addr */\n-\t\t*(uint64_t *)&eth_hdr->d_addr = dest_eth_addr[dst_port];\n-\n-\t\t/* src addr */\n-\t\tether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);\n-\n-\t\tsend_single_packet(m, dst_port);\n-\t} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {\n-\t\t/* Handle IPv6 headers.*/\n-\t\tstruct ipv6_hdr *ipv6_hdr;\n-\n-\t\tipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,\n-\t\t\t\t\t\t   sizeof(struct ether_hdr));\n-\n-\t\tdst_port = get_ipv6_dst_port(ipv6_hdr, portid, qconf->ipv6_lookup_struct);\n-\n-\t\tif (dst_port >= RTE_MAX_ETHPORTS || (enabled_port_mask & 1 << dst_port) == 0)\n-\t\t\tdst_port = portid;\n-\n-\t\t/* dst addr */\n-\t\t*(uint64_t *)&eth_hdr->d_addr = dest_eth_addr[dst_port];\n-\n-\t\t/* src addr */\n-\t\tether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);\n-\n-\t\tsend_single_packet(m, dst_port);\n-\t} else\n-\t\t/* Free the mbuf that contains non-IPV4/IPV6 packet */\n-\t\trte_pktmbuf_free(m);\n-}\n-\n-#if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && \\\n-\t(ENABLE_MULTI_BUFFER_OPTIMIZE == 1))\n-#ifdef DO_RFC_1812_CHECKS\n-\n-#define\tIPV4_MIN_VER_IHL\t0x45\n-#define\tIPV4_MAX_VER_IHL\t0x4f\n-#define\tIPV4_MAX_VER_IHL_DIFF\t(IPV4_MAX_VER_IHL - IPV4_MIN_VER_IHL)\n-\n-/* Minimum value of IPV4 total length (20B) in network byte order. */\n-#define\tIPV4_MIN_LEN_BE\t(sizeof(struct ipv4_hdr) << 8)\n-\n-/*\n- * From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2:\n- * - The IP version number must be 4.\n- * - The IP header length field must be large enough to hold the\n- *    minimum length legal IP datagram (20 bytes = 5 words).\n- * - The IP total length field must be large enough to hold the IP\n- *   datagram header, whose length is specified in the IP header length\n- *   field.\n- * If we encounter invalid IPV4 packet, then set destination port for it\n- * to BAD_PORT value.\n- */\n-static inline __attribute__((always_inline)) void\n-rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)\n-{\n-\tuint8_t ihl;\n-\n-\tif (RTE_ETH_IS_IPV4_HDR(ptype)) {\n-\t\tihl = ipv4_hdr->version_ihl - IPV4_MIN_VER_IHL;\n-\n-\t\tipv4_hdr->time_to_live--;\n-\t\tipv4_hdr->hdr_checksum++;\n-\n-\t\tif (ihl > IPV4_MAX_VER_IHL_DIFF ||\n-\t\t\t\t((uint8_t)ipv4_hdr->total_length == 0 &&\n-\t\t\t\tipv4_hdr->total_length < IPV4_MIN_LEN_BE)) {\n-\t\t\tdp[0] = BAD_PORT;\n-\t\t}\n-\t}\n-}\n-\n-#else\n-#define\trfc1812_process(mb, dp)\tdo { } while (0)\n-#endif /* DO_RFC_1812_CHECKS */\n-#endif /* APP_LOOKUP_LPM && ENABLE_MULTI_BUFFER_OPTIMIZE */\n-\n-\n-#if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && \\\n-\t(ENABLE_MULTI_BUFFER_OPTIMIZE == 1))\n-\n-static inline __attribute__((always_inline)) uint16_t\n-get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt,\n-\tuint32_t dst_ipv4, uint8_t portid)\n-{\n-\tuint8_t next_hop;\n-\tstruct ipv6_hdr *ipv6_hdr;\n-\tstruct ether_hdr *eth_hdr;\n-\n-\tif (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {\n-\t\tif (rte_lpm_lookup(qconf->ipv4_lookup_struct, dst_ipv4,\n-\t\t\t\t&next_hop) != 0)\n-\t\t\tnext_hop = portid;\n-\t} else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {\n-\t\teth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);\n-\t\tipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1);\n-\t\tif (rte_lpm6_lookup(qconf->ipv6_lookup_struct,\n-\t\t\t\tipv6_hdr->dst_addr, &next_hop) != 0)\n-\t\t\tnext_hop = portid;\n-\t} else {\n-\t\tnext_hop = portid;\n-\t}\n-\n-\treturn next_hop;\n-}\n-\n-static inline void\n-process_packet(struct lcore_conf *qconf, struct rte_mbuf *pkt,\n-\tuint16_t *dst_port, uint8_t portid)\n-{\n-\tstruct ether_hdr *eth_hdr;\n-\tstruct ipv4_hdr *ipv4_hdr;\n-\tuint32_t dst_ipv4;\n-\tuint16_t dp;\n-\t__m128i te, ve;\n-\n-\teth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);\n-\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n-\n-\tdst_ipv4 = ipv4_hdr->dst_addr;\n-\tdst_ipv4 = rte_be_to_cpu_32(dst_ipv4);\n-\tdp = get_dst_port(qconf, pkt, dst_ipv4, portid);\n-\n-\tte = _mm_loadu_si128((__m128i *)eth_hdr);\n-\tve = val_eth[dp];\n-\n-\tdst_port[0] = dp;\n-\trfc1812_process(ipv4_hdr, dst_port, pkt->packet_type);\n-\n-\tte =  _mm_blend_epi16(te, ve, MASK_ETH);\n-\t_mm_storeu_si128((__m128i *)eth_hdr, te);\n-}\n-\n-/*\n- * Read packet_type and destination IPV4 addresses from 4 mbufs.\n- */\n-static inline void\n-processx4_step1(struct rte_mbuf *pkt[FWDSTEP],\n-\t\t__m128i *dip,\n-\t\tuint32_t *ipv4_flag)\n-{\n-\tstruct ipv4_hdr *ipv4_hdr;\n-\tstruct ether_hdr *eth_hdr;\n-\tuint32_t x0, x1, x2, x3;\n-\n-\teth_hdr = rte_pktmbuf_mtod(pkt[0], struct ether_hdr *);\n-\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n-\tx0 = ipv4_hdr->dst_addr;\n-\tipv4_flag[0] = pkt[0]->packet_type & RTE_PTYPE_L3_IPV4;\n-\n-\teth_hdr = rte_pktmbuf_mtod(pkt[1], struct ether_hdr *);\n-\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n-\tx1 = ipv4_hdr->dst_addr;\n-\tipv4_flag[0] &= pkt[1]->packet_type;\n-\n-\teth_hdr = rte_pktmbuf_mtod(pkt[2], struct ether_hdr *);\n-\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n-\tx2 = ipv4_hdr->dst_addr;\n-\tipv4_flag[0] &= pkt[2]->packet_type;\n-\n-\teth_hdr = rte_pktmbuf_mtod(pkt[3], struct ether_hdr *);\n-\tipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);\n-\tx3 = ipv4_hdr->dst_addr;\n-\tipv4_flag[0] &= pkt[3]->packet_type;\n-\n-\tdip[0] = _mm_set_epi32(x3, x2, x1, x0);\n-}\n-\n-/*\n- * Lookup into LPM for destination port.\n- * If lookup fails, use incoming port (portid) as destination port.\n- */\n-static inline void\n-processx4_step2(const struct lcore_conf *qconf,\n-\t\t__m128i dip,\n-\t\tuint32_t ipv4_flag,\n-\t\tuint8_t portid,\n-\t\tstruct rte_mbuf *pkt[FWDSTEP],\n-\t\tuint16_t dprt[FWDSTEP])\n-{\n-\trte_xmm_t dst;\n-\tconst  __m128i bswap_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11,\n-\t\t\t\t\t\t4, 5, 6, 7, 0, 1, 2, 3);\n-\n-\t/* Byte swap 4 IPV4 addresses. */\n-\tdip = _mm_shuffle_epi8(dip, bswap_mask);\n-\n-\t/* if all 4 packets are IPV4. */\n-\tif (likely(ipv4_flag)) {\n-\t\trte_lpm_lookupx4(qconf->ipv4_lookup_struct, dip, dprt, portid);\n-\t} else {\n-\t\tdst.x = dip;\n-\t\tdprt[0] = get_dst_port(qconf, pkt[0], dst.u32[0], portid);\n-\t\tdprt[1] = get_dst_port(qconf, pkt[1], dst.u32[1], portid);\n-\t\tdprt[2] = get_dst_port(qconf, pkt[2], dst.u32[2], portid);\n-\t\tdprt[3] = get_dst_port(qconf, pkt[3], dst.u32[3], portid);\n-\t}\n-}\n-\n /*\n- * Update source and destination MAC addresses in the ethernet header.\n- * Perform RFC1812 checks and updates for IPV4 packets.\n+ * Setup lookup methods for forwarding.\n+ * Currently exact-match and longest-prefix-match\n+ * are supported ones.\n  */\n-static inline void\n-processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP])\n+static void\n+setup_l3fwd_lookup_tables(void)\n {\n-\t__m128i te[FWDSTEP];\n-\t__m128i ve[FWDSTEP];\n-\t__m128i *p[FWDSTEP];\n-\n-\tp[0] = rte_pktmbuf_mtod(pkt[0], __m128i *);\n-\tp[1] = rte_pktmbuf_mtod(pkt[1], __m128i *);\n-\tp[2] = rte_pktmbuf_mtod(pkt[2], __m128i *);\n-\tp[3] = rte_pktmbuf_mtod(pkt[3], __m128i *);\n-\n-\tve[0] = val_eth[dst_port[0]];\n-\tte[0] = _mm_loadu_si128(p[0]);\n-\n-\tve[1] = val_eth[dst_port[1]];\n-\tte[1] = _mm_loadu_si128(p[1]);\n-\n-\tve[2] = val_eth[dst_port[2]];\n-\tte[2] = _mm_loadu_si128(p[2]);\n-\n-\tve[3] = val_eth[dst_port[3]];\n-\tte[3] = _mm_loadu_si128(p[3]);\n-\n-\t/* Update first 12 bytes, keep rest bytes intact. */\n-\tte[0] =  _mm_blend_epi16(te[0], ve[0], MASK_ETH);\n-\tte[1] =  _mm_blend_epi16(te[1], ve[1], MASK_ETH);\n-\tte[2] =  _mm_blend_epi16(te[2], ve[2], MASK_ETH);\n-\tte[3] =  _mm_blend_epi16(te[3], ve[3], MASK_ETH);\n-\n-\t_mm_storeu_si128(p[0], te[0]);\n-\t_mm_storeu_si128(p[1], te[1]);\n-\t_mm_storeu_si128(p[2], te[2]);\n-\t_mm_storeu_si128(p[3], te[3]);\n-\n-\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[0] + 1),\n-\t\t&dst_port[0], pkt[0]->packet_type);\n-\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[1] + 1),\n-\t\t&dst_port[1], pkt[1]->packet_type);\n-\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[2] + 1),\n-\t\t&dst_port[2], pkt[2]->packet_type);\n-\trfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[3] + 1),\n-\t\t&dst_port[3], pkt[3]->packet_type);\n-}\n-\n-/*\n- * We group consecutive packets with the same destionation port into one burst.\n- * To avoid extra latency this is done together with some other packet\n- * processing, but after we made a final decision about packet's destination.\n- * To do this we maintain:\n- * pnum - array of number of consecutive packets with the same dest port for\n- * each packet in the input burst.\n- * lp - pointer to the last updated element in the pnum.\n- * dlp - dest port value lp corresponds to.\n- */\n-\n-#define\tGRPSZ\t(1 << FWDSTEP)\n-#define\tGRPMSK\t(GRPSZ - 1)\n-\n-#define GROUP_PORT_STEP(dlp, dcp, lp, pn, idx)\tdo { \\\n-\tif (likely((dlp) == (dcp)[(idx)])) {         \\\n-\t\t(lp)[0]++;                           \\\n-\t} else {                                     \\\n-\t\t(dlp) = (dcp)[idx];                  \\\n-\t\t(lp) = (pn) + (idx);                 \\\n-\t\t(lp)[0] = 1;                         \\\n-\t}                                            \\\n-} while (0)\n-\n-/*\n- * Group consecutive packets with the same destination port in bursts of 4.\n- * Suppose we have array of destionation ports:\n- * dst_port[] = {a, b, c, d,, e, ... }\n- * dp1 should contain: <a, b, c, d>, dp2: <b, c, d, e>.\n- * We doing 4 comparisions at once and the result is 4 bit mask.\n- * This mask is used as an index into prebuild array of pnum values.\n- */\n-static inline uint16_t *\n-port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, __m128i dp1, __m128i dp2)\n-{\n-\tstatic const struct {\n-\t\tuint64_t pnum; /* prebuild 4 values for pnum[]. */\n-\t\tint32_t  idx;  /* index for new last updated elemnet. */\n-\t\tuint16_t lpv;  /* add value to the last updated element. */\n-\t} gptbl[GRPSZ] = {\n-\t{\n-\t\t/* 0: a != b, b != c, c != d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000100010001),\n-\t\t.idx = 4,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 1: a == b, b != c, c != d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000100010002),\n-\t\t.idx = 4,\n-\t\t.lpv = 1,\n-\t},\n-\t{\n-\t\t/* 2: a != b, b == c, c != d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000100020001),\n-\t\t.idx = 4,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 3: a == b, b == c, c != d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000100020003),\n-\t\t.idx = 4,\n-\t\t.lpv = 2,\n-\t},\n-\t{\n-\t\t/* 4: a != b, b != c, c == d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000200010001),\n-\t\t.idx = 4,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 5: a == b, b != c, c == d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000200010002),\n-\t\t.idx = 4,\n-\t\t.lpv = 1,\n-\t},\n-\t{\n-\t\t/* 6: a != b, b == c, c == d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000200030001),\n-\t\t.idx = 4,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 7: a == b, b == c, c == d, d != e */\n-\t\t.pnum = UINT64_C(0x0001000200030004),\n-\t\t.idx = 4,\n-\t\t.lpv = 3,\n-\t},\n-\t{\n-\t\t/* 8: a != b, b != c, c != d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000100010001),\n-\t\t.idx = 3,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 9: a == b, b != c, c != d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000100010002),\n-\t\t.idx = 3,\n-\t\t.lpv = 1,\n-\t},\n-\t{\n-\t\t/* 0xa: a != b, b == c, c != d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000100020001),\n-\t\t.idx = 3,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 0xb: a == b, b == c, c != d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000100020003),\n-\t\t.idx = 3,\n-\t\t.lpv = 2,\n-\t},\n-\t{\n-\t\t/* 0xc: a != b, b != c, c == d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000300010001),\n-\t\t.idx = 2,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 0xd: a == b, b != c, c == d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000300010002),\n-\t\t.idx = 2,\n-\t\t.lpv = 1,\n-\t},\n-\t{\n-\t\t/* 0xe: a != b, b == c, c == d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000300040001),\n-\t\t.idx = 1,\n-\t\t.lpv = 0,\n-\t},\n-\t{\n-\t\t/* 0xf: a == b, b == c, c == d, d == e */\n-\t\t.pnum = UINT64_C(0x0002000300040005),\n-\t\t.idx = 0,\n-\t\t.lpv = 4,\n-\t},\n-\t};\n-\n-\tunion {\n-\t\tuint16_t u16[FWDSTEP + 1];\n-\t\tuint64_t u64;\n-\t} *pnum = (void *)pn;\n-\n-\tint32_t v;\n-\n-\tdp1 = _mm_cmpeq_epi16(dp1, dp2);\n-\tdp1 = _mm_unpacklo_epi16(dp1, dp1);\n-\tv = _mm_movemask_ps((__m128)dp1);\n-\n-\t/* update last port counter. */\n-\tlp[0] += gptbl[v].lpv;\n-\n-\t/* if dest port value has changed. */\n-\tif (v != GRPMSK) {\n-\t\tlp = pnum->u16 + gptbl[v].idx;\n-\t\tlp[0] = 1;\n-\t\tpnum->u64 = gptbl[v].pnum;\n-\t}\n-\n-\treturn lp;\n-}\n-\n-#endif /* APP_LOOKUP_METHOD */\n-\n-/* main processing loop */\n-static int\n-main_loop(__attribute__((unused)) void *dummy)\n-{\n-\tstruct rte_mbuf *pkts_burst[MAX_PKT_BURST];\n-\tunsigned lcore_id;\n-\tuint64_t prev_tsc, diff_tsc, cur_tsc;\n-\tint i, j, nb_rx;\n-\tuint8_t portid, queueid;\n-\tstruct lcore_conf *qconf;\n-\tconst uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /\n-\t\tUS_PER_S * BURST_TX_DRAIN_US;\n-\n-#if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && \\\n-\t(ENABLE_MULTI_BUFFER_OPTIMIZE == 1))\n-\tint32_t k;\n-\tuint16_t dlp;\n-\tuint16_t *lp;\n-\tuint16_t dst_port[MAX_PKT_BURST];\n-\t__m128i dip[MAX_PKT_BURST / FWDSTEP];\n-\tuint32_t ipv4_flag[MAX_PKT_BURST / FWDSTEP];\n-\tuint16_t pnum[MAX_PKT_BURST + 1];\n-#endif\n-\n-\tprev_tsc = 0;\n-\n-\tlcore_id = rte_lcore_id();\n-\tqconf = &lcore_conf[lcore_id];\n-\n-\tif (qconf->n_rx_queue == 0) {\n-\t\tRTE_LOG(INFO, L3FWD, \"lcore %u has nothing to do\\n\", lcore_id);\n-\t\treturn 0;\n-\t}\n-\n-\tRTE_LOG(INFO, L3FWD, \"entering main loop on lcore %u\\n\", lcore_id);\n-\n-\tfor (i = 0; i < qconf->n_rx_queue; i++) {\n-\n-\t\tportid = qconf->rx_queue_list[i].port_id;\n-\t\tqueueid = qconf->rx_queue_list[i].queue_id;\n-\t\tRTE_LOG(INFO, L3FWD, \" -- lcoreid=%u portid=%hhu rxqueueid=%hhu\\n\", lcore_id,\n-\t\t\tportid, queueid);\n-\t}\n-\n-\twhile (1) {\n-\n-\t\tcur_tsc = rte_rdtsc();\n-\n-\t\t/*\n-\t\t * TX burst queue drain\n-\t\t */\n-\t\tdiff_tsc = cur_tsc - prev_tsc;\n-\t\tif (unlikely(diff_tsc > drain_tsc)) {\n-\n-\t\t\t/*\n-\t\t\t * This could be optimized (use queueid instead of\n-\t\t\t * portid), but it is not called so often\n-\t\t\t */\n-\t\t\tfor (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {\n-\t\t\t\tif (qconf->tx_mbufs[portid].len == 0)\n-\t\t\t\t\tcontinue;\n-\t\t\t\tsend_burst(qconf,\n-\t\t\t\t\tqconf->tx_mbufs[portid].len,\n-\t\t\t\t\tportid);\n-\t\t\t\tqconf->tx_mbufs[portid].len = 0;\n-\t\t\t}\n-\n-\t\t\tprev_tsc = cur_tsc;\n-\t\t}\n-\n-\t\t/*\n-\t\t * Read packet from RX queues\n-\t\t */\n-\t\tfor (i = 0; i < qconf->n_rx_queue; ++i) {\n-\t\t\tportid = qconf->rx_queue_list[i].port_id;\n-\t\t\tqueueid = qconf->rx_queue_list[i].queue_id;\n-\t\t\tnb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,\n-\t\t\t\tMAX_PKT_BURST);\n-\t\t\tif (nb_rx == 0)\n-\t\t\t\tcontinue;\n-\n-#if (ENABLE_MULTI_BUFFER_OPTIMIZE == 1)\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-\t\t\t{\n-\t\t\t\t/*\n-\t\t\t\t * Send nb_rx - nb_rx%8 packets\n-\t\t\t\t * in groups of 8.\n-\t\t\t\t */\n-\t\t\t\tint32_t n = RTE_ALIGN_FLOOR(nb_rx, 8);\n-\t\t\t\tfor (j = 0; j < n; j += 8) {\n-\t\t\t\t\tuint32_t pkt_type =\n-\t\t\t\t\t\tpkts_burst[j]->packet_type &\n-\t\t\t\t\t\tpkts_burst[j+1]->packet_type &\n-\t\t\t\t\t\tpkts_burst[j+2]->packet_type &\n-\t\t\t\t\t\tpkts_burst[j+3]->packet_type &\n-\t\t\t\t\t\tpkts_burst[j+4]->packet_type &\n-\t\t\t\t\t\tpkts_burst[j+5]->packet_type &\n-\t\t\t\t\t\tpkts_burst[j+6]->packet_type &\n-\t\t\t\t\t\tpkts_burst[j+7]->packet_type;\n-\t\t\t\t\tif (pkt_type & RTE_PTYPE_L3_IPV4) {\n-\t\t\t\t\t\tsimple_ipv4_fwd_8pkts(\n-\t\t\t\t\t\t&pkts_burst[j], portid, qconf);\n-\t\t\t\t\t} else if (pkt_type &\n-\t\t\t\t\t\tRTE_PTYPE_L3_IPV6) {\n-\t\t\t\t\t\tsimple_ipv6_fwd_8pkts(&pkts_burst[j],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t} else {\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j+1],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j+2],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j+3],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j+4],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j+5],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j+6],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j+7],\n-\t\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t\t}\n-\t\t\t\t}\n-\t\t\t\tfor (; j < nb_rx ; j++) {\n-\t\t\t\t\tl3fwd_simple_forward(pkts_burst[j],\n-\t\t\t\t\t\t\t\tportid, qconf);\n-\t\t\t\t}\n-\t\t\t}\n-#elif (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-\n-\t\t\tk = RTE_ALIGN_FLOOR(nb_rx, FWDSTEP);\n-\t\t\tfor (j = 0; j != k; j += FWDSTEP) {\n-\t\t\t\tprocessx4_step1(&pkts_burst[j],\n-\t\t\t\t\t&dip[j / FWDSTEP],\n-\t\t\t\t\t&ipv4_flag[j / FWDSTEP]);\n-\t\t\t}\n-\n-\t\t\tk = RTE_ALIGN_FLOOR(nb_rx, FWDSTEP);\n-\t\t\tfor (j = 0; j != k; j += FWDSTEP) {\n-\t\t\t\tprocessx4_step2(qconf, dip[j / FWDSTEP],\n-\t\t\t\t\tipv4_flag[j / FWDSTEP], portid,\n-\t\t\t\t\t&pkts_burst[j], &dst_port[j]);\n-\t\t\t}\n-\n-\t\t\t/*\n-\t\t\t * Finish packet processing and group consecutive\n-\t\t\t * packets with the same destination port.\n-\t\t\t */\n-\t\t\tk = RTE_ALIGN_FLOOR(nb_rx, FWDSTEP);\n-\t\t\tif (k != 0) {\n-\t\t\t\t__m128i dp1, dp2;\n-\n-\t\t\t\tlp = pnum;\n-\t\t\t\tlp[0] = 1;\n-\n-\t\t\t\tprocessx4_step3(pkts_burst, dst_port);\n-\n-\t\t\t\t/* dp1: <d[0], d[1], d[2], d[3], ... > */\n-\t\t\t\tdp1 = _mm_loadu_si128((__m128i *)dst_port);\n-\n-\t\t\t\tfor (j = FWDSTEP; j != k; j += FWDSTEP) {\n-\t\t\t\t\tprocessx4_step3(&pkts_burst[j],\n-\t\t\t\t\t\t&dst_port[j]);\n-\n-\t\t\t\t\t/*\n-\t\t\t\t\t * dp2:\n-\t\t\t\t\t * <d[j-3], d[j-2], d[j-1], d[j], ... >\n-\t\t\t\t\t */\n-\t\t\t\t\tdp2 = _mm_loadu_si128((__m128i *)\n-\t\t\t\t\t\t&dst_port[j - FWDSTEP + 1]);\n-\t\t\t\t\tlp  = port_groupx4(&pnum[j - FWDSTEP],\n-\t\t\t\t\t\tlp, dp1, dp2);\n-\n-\t\t\t\t\t/*\n-\t\t\t\t\t * dp1:\n-\t\t\t\t\t * <d[j], d[j+1], d[j+2], d[j+3], ... >\n-\t\t\t\t\t */\n-\t\t\t\t\tdp1 = _mm_srli_si128(dp2,\n-\t\t\t\t\t\t(FWDSTEP - 1) *\n-\t\t\t\t\t\tsizeof(dst_port[0]));\n-\t\t\t\t}\n-\n-\t\t\t\t/*\n-\t\t\t\t * dp2: <d[j-3], d[j-2], d[j-1], d[j-1], ... >\n-\t\t\t\t */\n-\t\t\t\tdp2 = _mm_shufflelo_epi16(dp1, 0xf9);\n-\t\t\t\tlp  = port_groupx4(&pnum[j - FWDSTEP], lp,\n-\t\t\t\t\tdp1, dp2);\n-\n-\t\t\t\t/*\n-\t\t\t\t * remove values added by the last repeated\n-\t\t\t\t * dst port.\n-\t\t\t\t */\n-\t\t\t\tlp[0]--;\n-\t\t\t\tdlp = dst_port[j - 1];\n-\t\t\t} else {\n-\t\t\t\t/* set dlp and lp to the never used values. */\n-\t\t\t\tdlp = BAD_PORT - 1;\n-\t\t\t\tlp = pnum + MAX_PKT_BURST;\n-\t\t\t}\n-\n-\t\t\t/* Process up to last 3 packets one by one. */\n-\t\t\tswitch (nb_rx % FWDSTEP) {\n-\t\t\tcase 3:\n-\t\t\t\tprocess_packet(qconf, pkts_burst[j],\n-\t\t\t\t\tdst_port + j, portid);\n-\t\t\t\tGROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);\n-\t\t\t\tj++;\n-\t\t\tcase 2:\n-\t\t\t\tprocess_packet(qconf, pkts_burst[j],\n-\t\t\t\t\tdst_port + j, portid);\n-\t\t\t\tGROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);\n-\t\t\t\tj++;\n-\t\t\tcase 1:\n-\t\t\t\tprocess_packet(qconf, pkts_burst[j],\n-\t\t\t\t\tdst_port + j, portid);\n-\t\t\t\tGROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);\n-\t\t\t\tj++;\n-\t\t\t}\n-\n-\t\t\t/*\n-\t\t\t * Send packets out, through destination port.\n-\t\t\t * Consecuteve pacekts with the same destination port\n-\t\t\t * are already grouped together.\n-\t\t\t * If destination port for the packet equals BAD_PORT,\n-\t\t\t * then free the packet without sending it out.\n-\t\t\t */\n-\t\t\tfor (j = 0; j < nb_rx; j += k) {\n-\n-\t\t\t\tint32_t m;\n-\t\t\t\tuint16_t pn;\n-\n-\t\t\t\tpn = dst_port[j];\n-\t\t\t\tk = pnum[j];\n-\n-\t\t\t\tif (likely(pn != BAD_PORT)) {\n-\t\t\t\t\tsend_packetsx4(qconf, pn,\n-\t\t\t\t\t\tpkts_burst + j, k);\n-\t\t\t\t} else {\n-\t\t\t\t\tfor (m = j; m != j + k; m++)\n-\t\t\t\t\t\trte_pktmbuf_free(pkts_burst[m]);\n-\t\t\t\t}\n-\t\t\t}\n-\n-#endif /* APP_LOOKUP_METHOD */\n-#else /* ENABLE_MULTI_BUFFER_OPTIMIZE == 0 */\n-\n-\t\t\t/* Prefetch first packets */\n-\t\t\tfor (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++) {\n-\t\t\t\trte_prefetch0(rte_pktmbuf_mtod(\n-\t\t\t\t\t\tpkts_burst[j], void *));\n-\t\t\t}\n-\n-\t\t\t/* Prefetch and forward already prefetched packets */\n-\t\t\tfor (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {\n-\t\t\t\trte_prefetch0(rte_pktmbuf_mtod(pkts_burst[\n-\t\t\t\t\t\tj + PREFETCH_OFFSET], void *));\n-\t\t\t\tl3fwd_simple_forward(pkts_burst[j], portid,\n-\t\t\t\t\tqconf);\n-\t\t\t}\n-\n-\t\t\t/* Forward remaining prefetched packets */\n-\t\t\tfor (; j < nb_rx; j++) {\n-\t\t\t\tl3fwd_simple_forward(pkts_burst[j], portid,\n-\t\t\t\t\tqconf);\n-\t\t\t}\n-#endif /* ENABLE_MULTI_BUFFER_OPTIMIZE */\n-\n-\t\t}\n-\t}\n+\t/* Setup HASH lookup functions. */\n+\tif (l3fwd_em_on)\n+\t\tl3fwd_lkp = l3fwd_em_lkp;\n+\t/* Setup LPM lookup functions. */\n+\telse\n+\t\tl3fwd_lkp = l3fwd_lpm_lkp;\n }\n \n static int\n@@ -1837,7 +259,8 @@ get_port_n_rx_queues(const uint8_t port)\n \tuint16_t i;\n \n \tfor (i = 0; i < nb_lcore_params; ++i) {\n-\t\tif (lcore_params[i].port_id == port && lcore_params[i].queue_id > queue)\n+\t\tif (lcore_params[i].port_id == port &&\n+\t\t\tlcore_params[i].queue_id > queue)\n \t\t\tqueue = lcore_params[i].queue_id;\n \t}\n \treturn (uint8_t)(++queue);\n@@ -1876,6 +299,8 @@ print_usage(const char *prgname)\n \t\t\"  [--enable-jumbo [--max-pkt-len PKTLEN]]\\n\"\n \t\t\"  -p PORTMASK: hexadecimal bitmask of ports to configure\\n\"\n \t\t\"  -P : enable promiscuous mode\\n\"\n+\t\t\"  -E : enable exact match\\n\"\n+\t\t\"  -L : enable longest prefix match\\n\"\n \t\t\"  --config (port,queue,lcore): rx queues configuration\\n\"\n \t\t\"  --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X\\n\"\n \t\t\"  --no-numa: optional, disable numa awareness\\n\"\n@@ -1886,7 +311,8 @@ print_usage(const char *prgname)\n \t\tprgname);\n }\n \n-static int parse_max_pkt_len(const char *pktlen)\n+static int\n+parse_max_pkt_len(const char *pktlen)\n {\n \tchar *end = NULL;\n \tunsigned long len;\n@@ -1919,7 +345,6 @@ parse_portmask(const char *portmask)\n \treturn pm;\n }\n \n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n static int\n parse_hash_entry_number(const char *hash_entry_num)\n {\n@@ -1935,7 +360,6 @@ parse_hash_entry_number(const char *hash_entry_num)\n \n \treturn hash_en;\n }\n-#endif\n \n static int\n parse_config(const char *q_arg)\n@@ -1979,9 +403,12 @@ parse_config(const char *q_arg)\n \t\t\t\tnb_lcore_params);\n \t\t\treturn -1;\n \t\t}\n-\t\tlcore_params_array[nb_lcore_params].port_id = (uint8_t)int_fld[FLD_PORT];\n-\t\tlcore_params_array[nb_lcore_params].queue_id = (uint8_t)int_fld[FLD_QUEUE];\n-\t\tlcore_params_array[nb_lcore_params].lcore_id = (uint8_t)int_fld[FLD_LCORE];\n+\t\tlcore_params_array[nb_lcore_params].port_id =\n+\t\t\t(uint8_t)int_fld[FLD_PORT];\n+\t\tlcore_params_array[nb_lcore_params].queue_id =\n+\t\t\t(uint8_t)int_fld[FLD_QUEUE];\n+\t\tlcore_params_array[nb_lcore_params].lcore_id =\n+\t\t\t(uint8_t)int_fld[FLD_LCORE];\n \t\t++nb_lcore_params;\n \t}\n \tlcore_params = lcore_params_array;\n@@ -2016,6 +443,9 @@ parse_eth_dest(const char *optarg)\n \t*(uint64_t *)(val_eth + portid) = dest_eth_addr[portid];\n }\n \n+#define MAX_JUMBO_PKT_LEN  9600\n+#define MEMPOOL_CACHE_SIZE 256\n+\n #define CMD_LINE_OPT_CONFIG \"config\"\n #define CMD_LINE_OPT_ETH_DEST \"eth-dest\"\n #define CMD_LINE_OPT_NO_NUMA \"no-numa\"\n@@ -2023,6 +453,20 @@ parse_eth_dest(const char *optarg)\n #define CMD_LINE_OPT_ENABLE_JUMBO \"enable-jumbo\"\n #define CMD_LINE_OPT_HASH_ENTRY_NUM \"hash-entry-num\"\n \n+/*\n+ * This expression is used to calculate the number of mbufs needed\n+ * depending on user input, taking  into account memory for rx and\n+ * tx hardware rings, cache per lcore and mtable per port per lcore.\n+ * RTE_MAX is used to ensure that NB_MBUF never goes below a minimum\n+ * value of 8192\n+ */\n+#define NB_MBUF RTE_MAX(\t\\\n+\t(nb_ports*nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT +\t\\\n+\tnb_ports*nb_lcores*MAX_PKT_BURST +\t\t\t\\\n+\tnb_ports*n_tx_queue*RTE_TEST_TX_DESC_DEFAULT +\t\t\\\n+\tnb_lcores*MEMPOOL_CACHE_SIZE),\t\t\t\t\\\n+\t(unsigned)8192)\n+\n /* Parse the argument given in the command line of the application */\n static int\n parse_args(int argc, char **argv)\n@@ -2043,7 +487,24 @@ parse_args(int argc, char **argv)\n \n \targvopt = argv;\n \n-\twhile ((opt = getopt_long(argc, argvopt, \"p:P\",\n+\t/* Error or normal output strings. */\n+\tconst char *str1 = \"L3FWD: Invalid portmask\";\n+\tconst char *str2 = \"L3FWD: Promiscuous mode selected\";\n+\tconst char *str3 = \"L3FWD: Exact match selected\";\n+\tconst char *str4 = \"L3FWD: Longest-prefix match selected\";\n+\tconst char *str5 = \"L3FWD: Invalid config\";\n+\tconst char *str6 = \"L3FWD: NUMA is disabled\";\n+\tconst char *str7 = \"L3FWD: IPV6 is specified\";\n+\tconst char *str8 =\n+\t\t\"L3FWD: Jumbo frame is enabled - disabling simple TX path\";\n+\tconst char *str9 = \"L3FWD: Invalid packet length\";\n+\tconst char *str10 = \"L3FWD: Set jumbo frame max packet len to \";\n+\tconst char *str11 = \"L3FWD: Invalid hash entry number\";\n+\tconst char *str12 =\n+\t\t\"L3FWD: LPM and EM are mutually exclusive, select only one\";\n+\tconst char *str13 = \"L3FWD: LPM or EM none selected, default LPM on\";\n+\n+\twhile ((opt = getopt_long(argc, argvopt, \"p:PLE\",\n \t\t\t\tlgopts, &option_index)) != EOF) {\n \n \t\tswitch (opt) {\n@@ -2051,80 +512,102 @@ parse_args(int argc, char **argv)\n \t\tcase 'p':\n \t\t\tenabled_port_mask = parse_portmask(optarg);\n \t\t\tif (enabled_port_mask == 0) {\n-\t\t\t\tprintf(\"invalid portmask\\n\");\n+\t\t\t\tprintf(\"%s\\n\", str1);\n \t\t\t\tprint_usage(prgname);\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t\tbreak;\n \t\tcase 'P':\n-\t\t\tprintf(\"Promiscuous mode selected\\n\");\n+\t\t\tprintf(\"%s\\n\", str2);\n \t\t\tpromiscuous_on = 1;\n \t\t\tbreak;\n \n+\t\tcase 'E':\n+\t\t\tprintf(\"%s\\n\", str3);\n+\t\t\tl3fwd_em_on = 1;\n+\t\t\tbreak;\n+\n+\t\tcase 'L':\n+\t\t\tprintf(\"%s\\n\", str4);\n+\t\t\tl3fwd_lpm_on = 1;\n+\t\t\tbreak;\n+\n \t\t/* long options */\n \t\tcase 0:\n-\t\t\tif (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_CONFIG,\n-\t\t\t\tsizeof (CMD_LINE_OPT_CONFIG))) {\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\t\tCMD_LINE_OPT_CONFIG,\n+\t\t\t\t\tsizeof(CMD_LINE_OPT_CONFIG))) {\n+\n \t\t\t\tret = parse_config(optarg);\n \t\t\t\tif (ret) {\n-\t\t\t\t\tprintf(\"invalid config\\n\");\n+\t\t\t\t\tprintf(\"%s\\n\", str5);\n \t\t\t\t\tprint_usage(prgname);\n \t\t\t\t\treturn -1;\n \t\t\t\t}\n \t\t\t}\n \n-\t\t\tif (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_ETH_DEST,\n-\t\t\t\tsizeof(CMD_LINE_OPT_ETH_DEST))) {\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\t\tCMD_LINE_OPT_ETH_DEST,\n+\t\t\t\t\tsizeof(CMD_LINE_OPT_ETH_DEST))) {\n \t\t\t\t\tparse_eth_dest(optarg);\n \t\t\t}\n \n-\t\t\tif (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_NO_NUMA,\n-\t\t\t\tsizeof(CMD_LINE_OPT_NO_NUMA))) {\n-\t\t\t\tprintf(\"numa is disabled \\n\");\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\t\tCMD_LINE_OPT_NO_NUMA,\n+\t\t\t\t\tsizeof(CMD_LINE_OPT_NO_NUMA))) {\n+\t\t\t\tprintf(\"%s\\n\", str6);\n \t\t\t\tnuma_on = 0;\n \t\t\t}\n \n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-\t\t\tif (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_IPV6,\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\tCMD_LINE_OPT_IPV6,\n \t\t\t\tsizeof(CMD_LINE_OPT_IPV6))) {\n-\t\t\t\tprintf(\"ipv6 is specified \\n\");\n+\t\t\t\tprintf(\"%sn\", str7);\n \t\t\t\tipv6 = 1;\n \t\t\t}\n-#endif\n \n-\t\t\tif (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_ENABLE_JUMBO,\n-\t\t\t\tsizeof (CMD_LINE_OPT_ENABLE_JUMBO))) {\n-\t\t\t\tstruct option lenopts = {\"max-pkt-len\", required_argument, 0, 0};\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\t\tCMD_LINE_OPT_ENABLE_JUMBO,\n+\t\t\t\t\tsizeof(CMD_LINE_OPT_ENABLE_JUMBO))) {\n+\t\t\t\tstruct option lenopts = {\n+\t\t\t\t\t\"max-pkt-len\", required_argument, 0, 0\n+\t\t\t\t};\n \n-\t\t\t\tprintf(\"jumbo frame is enabled - disabling simple TX path\\n\");\n+\t\t\t\tprintf(\"%s\\n\", str8);\n \t\t\t\tport_conf.rxmode.jumbo_frame = 1;\n \n-\t\t\t\t/* if no max-pkt-len set, use the default value ETHER_MAX_LEN */\n-\t\t\t\tif (0 == getopt_long(argc, argvopt, \"\", &lenopts, &option_index)) {\n+\t\t\t\t/*\n+\t\t\t\t * if no max-pkt-len set, use the default\n+\t\t\t\t * value ETHER_MAX_LEN.\n+\t\t\t\t */\n+\t\t\t\tif (0 == getopt_long(argc, argvopt, \"\",\n+\t\t\t\t\t\t&lenopts, &option_index)) {\n \t\t\t\t\tret = parse_max_pkt_len(optarg);\n-\t\t\t\t\tif ((ret < 64) || (ret > MAX_JUMBO_PKT_LEN)){\n-\t\t\t\t\t\tprintf(\"invalid packet length\\n\");\n+\t\t\t\t\tif ((ret < 64) ||\n+\t\t\t\t\t\t(ret > MAX_JUMBO_PKT_LEN)) {\n+\t\t\t\t\t\tprintf(\"%s\\n\", str9);\n \t\t\t\t\t\tprint_usage(prgname);\n \t\t\t\t\t\treturn -1;\n \t\t\t\t\t}\n \t\t\t\t\tport_conf.rxmode.max_rx_pkt_len = ret;\n \t\t\t\t}\n-\t\t\t\tprintf(\"set jumbo frame max packet length to %u\\n\",\n-\t\t\t\t\t\t(unsigned int)port_conf.rxmode.max_rx_pkt_len);\n+\t\t\t\tprintf(\"%s %u\\n\", str10,\n+\t\t\t\t(unsigned int)port_conf.rxmode.max_rx_pkt_len);\n \t\t\t}\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-\t\t\tif (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_HASH_ENTRY_NUM,\n+\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\tCMD_LINE_OPT_HASH_ENTRY_NUM,\n \t\t\t\tsizeof(CMD_LINE_OPT_HASH_ENTRY_NUM))) {\n+\n \t\t\t\tret = parse_hash_entry_number(optarg);\n \t\t\t\tif ((ret > 0) && (ret <= L3FWD_HASH_ENTRIES)) {\n \t\t\t\t\thash_entry_number = ret;\n \t\t\t\t} else {\n-\t\t\t\t\tprintf(\"invalid hash entry number\\n\");\n+\t\t\t\t\tprintf(\"%s\\n\", str11);\n \t\t\t\t\tprint_usage(prgname);\n \t\t\t\t\treturn -1;\n \t\t\t\t}\n \t\t\t}\n-#endif\n \t\t\tbreak;\n \n \t\tdefault:\n@@ -2133,6 +616,31 @@ parse_args(int argc, char **argv)\n \t\t}\n \t}\n \n+\t/* If both LPM and EM are selected, return error. */\n+\tif (l3fwd_lpm_on && l3fwd_em_on) {\n+\t\tprintf(\"%s\\n\", str12);\n+\t\treturn -1;\n+\t}\n+\n+\t/*\n+\t * Nothing is selected, pick longest-prefix match\n+\t * as default match.\n+\t */\n+\tif (!l3fwd_lpm_on && !l3fwd_em_on) {\n+\t\tl3fwd_lpm_on = 1;\n+\t\tprintf(\"%s\\n\", str13);\n+\t}\n+\n+\t/*\n+\t * ipv6 and hash flags are valid only for\n+\t * exact macth, reset them to default for\n+\t * longest-prefix match.\n+\t */\n+\tif (l3fwd_lpm_on) {\n+\t\tipv6 = 0;\n+\t\thash_entry_number = HASH_ENTRY_NUMBER_DEFAULT;\n+\t}\n+\n \tif (optind >= 0)\n \t\targv[optind-1] = prgname;\n \n@@ -2149,315 +657,6 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr)\n \tprintf(\"%s%s\", name, buf);\n }\n \n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)\n-\n-static void convert_ipv4_5tuple(struct ipv4_5tuple* key1,\n-\t\tunion ipv4_5tuple_host* key2)\n-{\n-\tkey2->ip_dst = rte_cpu_to_be_32(key1->ip_dst);\n-\tkey2->ip_src = rte_cpu_to_be_32(key1->ip_src);\n-\tkey2->port_dst = rte_cpu_to_be_16(key1->port_dst);\n-\tkey2->port_src = rte_cpu_to_be_16(key1->port_src);\n-\tkey2->proto = key1->proto;\n-\tkey2->pad0 = 0;\n-\tkey2->pad1 = 0;\n-\treturn;\n-}\n-\n-static void convert_ipv6_5tuple(struct ipv6_5tuple* key1,\n-                union ipv6_5tuple_host* key2)\n-{\n-\tuint32_t i;\n-\tfor (i = 0; i < 16; i++)\n-\t{\n-\t\tkey2->ip_dst[i] = key1->ip_dst[i];\n-\t\tkey2->ip_src[i] = key1->ip_src[i];\n-\t}\n-\tkey2->port_dst = rte_cpu_to_be_16(key1->port_dst);\n-\tkey2->port_src = rte_cpu_to_be_16(key1->port_src);\n-\tkey2->proto = key1->proto;\n-\tkey2->pad0 = 0;\n-\tkey2->pad1 = 0;\n-\tkey2->reserve = 0;\n-\treturn;\n-}\n-\n-#define BYTE_VALUE_MAX 256\n-#define ALL_32_BITS 0xffffffff\n-#define BIT_8_TO_15 0x0000ff00\n-static inline void\n-populate_ipv4_few_flow_into_table(const struct rte_hash* h)\n-{\n-\tuint32_t i;\n-\tint32_t ret;\n-\tuint32_t array_len = sizeof(ipv4_l3fwd_route_array)/sizeof(ipv4_l3fwd_route_array[0]);\n-\n-\tmask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, ALL_32_BITS, BIT_8_TO_15);\n-\tfor (i = 0; i < array_len; i++) {\n-\t\tstruct ipv4_l3fwd_route  entry;\n-\t\tunion ipv4_5tuple_host newkey;\n-\t\tentry = ipv4_l3fwd_route_array[i];\n-\t\tconvert_ipv4_5tuple(&entry.key, &newkey);\n-\t\tret = rte_hash_add_key (h,(void *) &newkey);\n-\t\tif (ret < 0) {\n-\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %\" PRIu32\n-\t\t\t\t\" to the l3fwd hash.\\n\", i);\n-\t\t}\n-\t\tipv4_l3fwd_out_if[ret] = entry.if_out;\n-\t}\n-\tprintf(\"Hash: Adding 0x%\" PRIx32 \" keys\\n\", array_len);\n-}\n-\n-#define BIT_16_TO_23 0x00ff0000\n-static inline void\n-populate_ipv6_few_flow_into_table(const struct rte_hash* h)\n-{\n-\tuint32_t i;\n-\tint32_t ret;\n-\tuint32_t array_len = sizeof(ipv6_l3fwd_route_array)/sizeof(ipv6_l3fwd_route_array[0]);\n-\n-\tmask1 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, ALL_32_BITS, BIT_16_TO_23);\n-\tmask2 = _mm_set_epi32(0, 0, ALL_32_BITS, ALL_32_BITS);\n-\tfor (i = 0; i < array_len; i++) {\n-\t\tstruct ipv6_l3fwd_route entry;\n-\t\tunion ipv6_5tuple_host newkey;\n-\t\tentry = ipv6_l3fwd_route_array[i];\n-\t\tconvert_ipv6_5tuple(&entry.key, &newkey);\n-\t\tret = rte_hash_add_key (h, (void *) &newkey);\n-\t\tif (ret < 0) {\n-\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %\" PRIu32\n-\t\t\t\t\" to the l3fwd hash.\\n\", i);\n-\t\t}\n-\t\tipv6_l3fwd_out_if[ret] = entry.if_out;\n-\t}\n-\tprintf(\"Hash: Adding 0x%\" PRIx32 \"keys\\n\", array_len);\n-}\n-\n-#define NUMBER_PORT_USED 4\n-static inline void\n-populate_ipv4_many_flow_into_table(const struct rte_hash* h,\n-                unsigned int nr_flow)\n-{\n-\tunsigned i;\n-\tmask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, ALL_32_BITS, BIT_8_TO_15);\n-\tfor (i = 0; i < nr_flow; i++) {\n-\t\tstruct ipv4_l3fwd_route entry;\n-\t\tunion ipv4_5tuple_host newkey;\n-\t\tuint8_t a = (uint8_t) ((i/NUMBER_PORT_USED)%BYTE_VALUE_MAX);\n-\t\tuint8_t b = (uint8_t) (((i/NUMBER_PORT_USED)/BYTE_VALUE_MAX)%BYTE_VALUE_MAX);\n-\t\tuint8_t c = (uint8_t) ((i/NUMBER_PORT_USED)/(BYTE_VALUE_MAX*BYTE_VALUE_MAX));\n-\t\t/* Create the ipv4 exact match flow */\n-\t\tmemset(&entry, 0, sizeof(entry));\n-\t\tswitch (i & (NUMBER_PORT_USED -1)) {\n-\t\tcase 0:\n-\t\t\tentry = ipv4_l3fwd_route_array[0];\n-\t\t\tentry.key.ip_dst = IPv4(101,c,b,a);\n-\t\t\tbreak;\n-\t\tcase 1:\n-\t\t\tentry = ipv4_l3fwd_route_array[1];\n-\t\t\tentry.key.ip_dst = IPv4(201,c,b,a);\n-\t\t\tbreak;\n-\t\tcase 2:\n-\t\t\tentry = ipv4_l3fwd_route_array[2];\n-\t\t\tentry.key.ip_dst = IPv4(111,c,b,a);\n-\t\t\tbreak;\n-\t\tcase 3:\n-\t\t\tentry = ipv4_l3fwd_route_array[3];\n-\t\t\tentry.key.ip_dst = IPv4(211,c,b,a);\n-\t\t\tbreak;\n-\t\t};\n-\t\tconvert_ipv4_5tuple(&entry.key, &newkey);\n-\t\tint32_t ret = rte_hash_add_key(h,(void *) &newkey);\n-\t\tif (ret < 0) {\n-\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %u\\n\", i);\n-\t\t}\n-\t\tipv4_l3fwd_out_if[ret] = (uint8_t) entry.if_out;\n-\n-\t}\n-\tprintf(\"Hash: Adding 0x%x keys\\n\", nr_flow);\n-}\n-\n-static inline void\n-populate_ipv6_many_flow_into_table(const struct rte_hash* h,\n-                unsigned int nr_flow)\n-{\n-\tunsigned i;\n-\tmask1 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, ALL_32_BITS, BIT_16_TO_23);\n-\tmask2 = _mm_set_epi32(0, 0, ALL_32_BITS, ALL_32_BITS);\n-\tfor (i = 0; i < nr_flow; i++) {\n-\t\tstruct ipv6_l3fwd_route entry;\n-\t\tunion ipv6_5tuple_host newkey;\n-\t\tuint8_t a = (uint8_t) ((i/NUMBER_PORT_USED)%BYTE_VALUE_MAX);\n-\t\tuint8_t b = (uint8_t) (((i/NUMBER_PORT_USED)/BYTE_VALUE_MAX)%BYTE_VALUE_MAX);\n-\t\tuint8_t c = (uint8_t) ((i/NUMBER_PORT_USED)/(BYTE_VALUE_MAX*BYTE_VALUE_MAX));\n-\t\t/* Create the ipv6 exact match flow */\n-\t\tmemset(&entry, 0, sizeof(entry));\n-\t\tswitch (i & (NUMBER_PORT_USED - 1)) {\n-\t\tcase 0: entry = ipv6_l3fwd_route_array[0]; break;\n-\t\tcase 1: entry = ipv6_l3fwd_route_array[1]; break;\n-\t\tcase 2: entry = ipv6_l3fwd_route_array[2]; break;\n-\t\tcase 3: entry = ipv6_l3fwd_route_array[3]; break;\n-\t\t};\n-\t\tentry.key.ip_dst[13] = c;\n-\t\tentry.key.ip_dst[14] = b;\n-\t\tentry.key.ip_dst[15] = a;\n-\t\tconvert_ipv6_5tuple(&entry.key, &newkey);\n-\t\tint32_t ret = rte_hash_add_key(h,(void *) &newkey);\n-\t\tif (ret < 0) {\n-\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %u\\n\", i);\n-\t\t}\n-\t\tipv6_l3fwd_out_if[ret] = (uint8_t) entry.if_out;\n-\n-\t}\n-\tprintf(\"Hash: Adding 0x%x keys\\n\", nr_flow);\n-}\n-\n-static void\n-setup_hash(int socketid)\n-{\n-    struct rte_hash_parameters ipv4_l3fwd_hash_params = {\n-        .name = NULL,\n-        .entries = L3FWD_HASH_ENTRIES,\n-        .key_len = sizeof(union ipv4_5tuple_host),\n-        .hash_func = ipv4_hash_crc,\n-        .hash_func_init_val = 0,\n-    };\n-\n-    struct rte_hash_parameters ipv6_l3fwd_hash_params = {\n-        .name = NULL,\n-        .entries = L3FWD_HASH_ENTRIES,\n-        .key_len = sizeof(union ipv6_5tuple_host),\n-        .hash_func = ipv6_hash_crc,\n-        .hash_func_init_val = 0,\n-    };\n-\n-    char s[64];\n-\n-\t/* create ipv4 hash */\n-\tsnprintf(s, sizeof(s), \"ipv4_l3fwd_hash_%d\", socketid);\n-\tipv4_l3fwd_hash_params.name = s;\n-\tipv4_l3fwd_hash_params.socket_id = socketid;\n-\tipv4_l3fwd_lookup_struct[socketid] = rte_hash_create(&ipv4_l3fwd_hash_params);\n-\tif (ipv4_l3fwd_lookup_struct[socketid] == NULL)\n-\t\trte_exit(EXIT_FAILURE, \"Unable to create the l3fwd hash on \"\n-\t\t\t\t\"socket %d\\n\", socketid);\n-\n-\t/* create ipv6 hash */\n-\tsnprintf(s, sizeof(s), \"ipv6_l3fwd_hash_%d\", socketid);\n-\tipv6_l3fwd_hash_params.name = s;\n-\tipv6_l3fwd_hash_params.socket_id = socketid;\n-\tipv6_l3fwd_lookup_struct[socketid] = rte_hash_create(&ipv6_l3fwd_hash_params);\n-\tif (ipv6_l3fwd_lookup_struct[socketid] == NULL)\n-\t\trte_exit(EXIT_FAILURE, \"Unable to create the l3fwd hash on \"\n-\t\t\t\t\"socket %d\\n\", socketid);\n-\n-\tif (hash_entry_number != HASH_ENTRY_NUMBER_DEFAULT) {\n-\t\t/* For testing hash matching with a large number of flows we\n-\t\t * generate millions of IP 5-tuples with an incremented dst\n-\t\t * address to initialize the hash table. */\n-\t\tif (ipv6 == 0) {\n-\t\t\t/* populate the ipv4 hash */\n-\t\t\tpopulate_ipv4_many_flow_into_table(\n-\t\t\t\tipv4_l3fwd_lookup_struct[socketid], hash_entry_number);\n-\t\t} else {\n-\t\t\t/* populate the ipv6 hash */\n-\t\t\tpopulate_ipv6_many_flow_into_table(\n-\t\t\t\tipv6_l3fwd_lookup_struct[socketid], hash_entry_number);\n-\t\t}\n-\t} else {\n-\t\t/* Use data in ipv4/ipv6 l3fwd lookup table directly to initialize the hash table */\n-\t\tif (ipv6 == 0) {\n-\t\t\t/* populate the ipv4 hash */\n-\t\t\tpopulate_ipv4_few_flow_into_table(ipv4_l3fwd_lookup_struct[socketid]);\n-\t\t} else {\n-\t\t\t/* populate the ipv6 hash */\n-\t\t\tpopulate_ipv6_few_flow_into_table(ipv6_l3fwd_lookup_struct[socketid]);\n-\t\t}\n-\t}\n-}\n-#endif\n-\n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-static void\n-setup_lpm(int socketid)\n-{\n-\tstruct rte_lpm6_config config;\n-\tunsigned i;\n-\tint ret;\n-\tchar s[64];\n-\n-\t/* create the LPM table */\n-\tsnprintf(s, sizeof(s), \"IPV4_L3FWD_LPM_%d\", socketid);\n-\tipv4_l3fwd_lookup_struct[socketid] = rte_lpm_create(s, socketid,\n-\t\t\t\tIPV4_L3FWD_LPM_MAX_RULES, 0);\n-\tif (ipv4_l3fwd_lookup_struct[socketid] == NULL)\n-\t\trte_exit(EXIT_FAILURE, \"Unable to create the l3fwd LPM table\"\n-\t\t\t\t\" on socket %d\\n\", socketid);\n-\n-\t/* populate the LPM table */\n-\tfor (i = 0; i < IPV4_L3FWD_NUM_ROUTES; i++) {\n-\n-\t\t/* skip unused ports */\n-\t\tif ((1 << ipv4_l3fwd_route_array[i].if_out &\n-\t\t\t\tenabled_port_mask) == 0)\n-\t\t\tcontinue;\n-\n-\t\tret = rte_lpm_add(ipv4_l3fwd_lookup_struct[socketid],\n-\t\t\tipv4_l3fwd_route_array[i].ip,\n-\t\t\tipv4_l3fwd_route_array[i].depth,\n-\t\t\tipv4_l3fwd_route_array[i].if_out);\n-\n-\t\tif (ret < 0) {\n-\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %u to the \"\n-\t\t\t\t\"l3fwd LPM table on socket %d\\n\",\n-\t\t\t\ti, socketid);\n-\t\t}\n-\n-\t\tprintf(\"LPM: Adding route 0x%08x / %d (%d)\\n\",\n-\t\t\t(unsigned)ipv4_l3fwd_route_array[i].ip,\n-\t\t\tipv4_l3fwd_route_array[i].depth,\n-\t\t\tipv4_l3fwd_route_array[i].if_out);\n-\t}\n-\n-\t/* create the LPM6 table */\n-\tsnprintf(s, sizeof(s), \"IPV6_L3FWD_LPM_%d\", socketid);\n-\n-\tconfig.max_rules = IPV6_L3FWD_LPM_MAX_RULES;\n-\tconfig.number_tbl8s = IPV6_L3FWD_LPM_NUMBER_TBL8S;\n-\tconfig.flags = 0;\n-\tipv6_l3fwd_lookup_struct[socketid] = rte_lpm6_create(s, socketid,\n-\t\t\t\t&config);\n-\tif (ipv6_l3fwd_lookup_struct[socketid] == NULL)\n-\t\trte_exit(EXIT_FAILURE, \"Unable to create the l3fwd LPM table\"\n-\t\t\t\t\" on socket %d\\n\", socketid);\n-\n-\t/* populate the LPM table */\n-\tfor (i = 0; i < IPV6_L3FWD_NUM_ROUTES; i++) {\n-\n-\t\t/* skip unused ports */\n-\t\tif ((1 << ipv6_l3fwd_route_array[i].if_out &\n-\t\t\t\tenabled_port_mask) == 0)\n-\t\t\tcontinue;\n-\n-\t\tret = rte_lpm6_add(ipv6_l3fwd_lookup_struct[socketid],\n-\t\t\tipv6_l3fwd_route_array[i].ip,\n-\t\t\tipv6_l3fwd_route_array[i].depth,\n-\t\t\tipv6_l3fwd_route_array[i].if_out);\n-\n-\t\tif (ret < 0) {\n-\t\t\trte_exit(EXIT_FAILURE, \"Unable to add entry %u to the \"\n-\t\t\t\t\"l3fwd LPM table on socket %d\\n\",\n-\t\t\t\ti, socketid);\n-\t\t}\n-\n-\t\tprintf(\"LPM: Adding route %s / %d (%d)\\n\",\n-\t\t\t\"IPV6\",\n-\t\t\tipv6_l3fwd_route_array[i].depth,\n-\t\t\tipv6_l3fwd_route_array[i].if_out);\n-\t}\n-}\n-#endif\n-\n static int\n init_mem(unsigned nb_mbuf)\n {\n@@ -2476,9 +675,11 @@ init_mem(unsigned nb_mbuf)\n \t\t\tsocketid = 0;\n \n \t\tif (socketid >= NB_SOCKETS) {\n-\t\t\trte_exit(EXIT_FAILURE, \"Socket %d of lcore %u is out of range %d\\n\",\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Socket %d of lcore %u is out of range %d\\n\",\n \t\t\t\tsocketid, lcore_id, NB_SOCKETS);\n \t\t}\n+\n \t\tif (pktmbuf_pool[socketid] == NULL) {\n \t\t\tsnprintf(s, sizeof(s), \"mbuf_pool_%d\", socketid);\n \t\t\tpktmbuf_pool[socketid] =\n@@ -2487,19 +688,20 @@ init_mem(unsigned nb_mbuf)\n \t\t\t\t\tRTE_MBUF_DEFAULT_BUF_SIZE, socketid);\n \t\t\tif (pktmbuf_pool[socketid] == NULL)\n \t\t\t\trte_exit(EXIT_FAILURE,\n-\t\t\t\t\t\t\"Cannot init mbuf pool on socket %d\\n\", socketid);\n+\t\t\t\t\t\"Cannot init mbuf pool on socket %d\\n\",\n+\t\t\t\t\tsocketid);\n \t\t\telse\n-\t\t\t\tprintf(\"Allocated mbuf pool on socket %d\\n\", socketid);\n+\t\t\t\tprintf(\"Allocated mbuf pool on socket %d\\n\",\n+\t\t\t\t\tsocketid);\n \n-#if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)\n-\t\t\tsetup_lpm(socketid);\n-#else\n-\t\t\tsetup_hash(socketid);\n-#endif\n+\t\t\t/* Setup either LPM or EM(f.e Hash).  */\n+\t\t\tl3fwd_lkp.setup(socketid);\n \t\t}\n \t\tqconf = &lcore_conf[lcore_id];\n-\t\tqconf->ipv4_lookup_struct = ipv4_l3fwd_lookup_struct[socketid];\n-\t\tqconf->ipv6_lookup_struct = ipv6_l3fwd_lookup_struct[socketid];\n+\t\tqconf->ipv4_lookup_struct =\n+\t\t\tl3fwd_lkp.get_ipv4_lookup_struct(socketid);\n+\t\tqconf->ipv6_lookup_struct =\n+\t\t\tl3fwd_lkp.get_ipv6_lookup_struct(socketid);\n \t}\n \treturn 0;\n }\n@@ -2581,7 +783,8 @@ main(int argc, char **argv)\n \n \t/* pre-init dst MACs for all ports to 02:00:00:00:00:xx */\n \tfor (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {\n-\t\tdest_eth_addr[portid] = ETHER_LOCAL_ADMIN_ADDR + ((uint64_t)portid << 40);\n+\t\tdest_eth_addr[portid] =\n+\t\t\tETHER_LOCAL_ADMIN_ADDR + ((uint64_t)portid << 40);\n \t\t*(uint64_t *)(val_eth + portid) = dest_eth_addr[portid];\n \t}\n \n@@ -2606,6 +809,9 @@ main(int argc, char **argv)\n \n \tnb_lcores = rte_lcore_count();\n \n+\t/* Setup function pointers for lookup method. */\n+\tsetup_l3fwd_lookup_tables();\n+\n \t/* initialize all ports */\n \tfor (portid = 0; portid < nb_ports; portid++) {\n \t\t/* skip ports that are not enabled */\n@@ -2627,7 +833,8 @@ main(int argc, char **argv)\n \t\tret = rte_eth_dev_configure(portid, nb_rx_queue,\n \t\t\t\t\t(uint16_t)n_tx_queue, &port_conf);\n \t\tif (ret < 0)\n-\t\t\trte_exit(EXIT_FAILURE, \"Cannot configure device: err=%d, port=%d\\n\",\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Cannot configure device: err=%d, port=%d\\n\",\n \t\t\t\tret, portid);\n \n \t\trte_eth_macaddr_get(portid, &ports_eth_addr[portid]);\n@@ -2655,7 +862,8 @@ main(int argc, char **argv)\n \t\t\t\tcontinue;\n \n \t\t\tif (numa_on)\n-\t\t\t\tsocketid = (uint8_t)rte_lcore_to_socket_id(lcore_id);\n+\t\t\t\tsocketid =\n+\t\t\t\t(uint8_t)rte_lcore_to_socket_id(lcore_id);\n \t\t\telse\n \t\t\t\tsocketid = 0;\n \n@@ -2669,7 +877,8 @@ main(int argc, char **argv)\n \t\t\tret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,\n \t\t\t\t\t\t     socketid, txconf);\n \t\t\tif (ret < 0)\n-\t\t\t\trte_exit(EXIT_FAILURE, \"rte_eth_tx_queue_setup: err=%d, \"\n+\t\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\t\"rte_eth_tx_queue_setup: err=%d, \"\n \t\t\t\t\t\"port=%d\\n\", ret, portid);\n \n \t\t\tqconf = &lcore_conf[lcore_id];\n@@ -2691,7 +900,8 @@ main(int argc, char **argv)\n \t\t\tqueueid = qconf->rx_queue_list[queue].queue_id;\n \n \t\t\tif (numa_on)\n-\t\t\t\tsocketid = (uint8_t)rte_lcore_to_socket_id(lcore_id);\n+\t\t\t\tsocketid =\n+\t\t\t\t(uint8_t)rte_lcore_to_socket_id(lcore_id);\n \t\t\telse\n \t\t\t\tsocketid = 0;\n \n@@ -2703,8 +913,9 @@ main(int argc, char **argv)\n \t\t\t\t\tNULL,\n \t\t\t\t\tpktmbuf_pool[socketid]);\n \t\t\tif (ret < 0)\n-\t\t\t\trte_exit(EXIT_FAILURE, \"rte_eth_rx_queue_setup: err=%d,\"\n-\t\t\t\t\t\t\"port=%d\\n\", ret, portid);\n+\t\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"rte_eth_rx_queue_setup: err=%d, port=%d\\n\",\n+\t\t\t\tret, portid);\n \t\t}\n \t}\n \n@@ -2718,7 +929,8 @@ main(int argc, char **argv)\n \t\t/* Start device */\n \t\tret = rte_eth_dev_start(portid);\n \t\tif (ret < 0)\n-\t\t\trte_exit(EXIT_FAILURE, \"rte_eth_dev_start: err=%d, port=%d\\n\",\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"rte_eth_dev_start: err=%d, port=%d\\n\",\n \t\t\t\tret, portid);\n \n \t\t/*\n@@ -2734,7 +946,7 @@ main(int argc, char **argv)\n \tcheck_all_ports_link_status((uint8_t)nb_ports, enabled_port_mask);\n \n \t/* launch per-lcore init on every lcore */\n-\trte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);\n+\trte_eal_mp_remote_launch(l3fwd_lkp.main_loop, NULL, CALL_MASTER);\n \tRTE_LCORE_FOREACH_SLAVE(lcore_id) {\n \t\tif (rte_eal_wait_lcore(lcore_id) < 0)\n \t\t\treturn -1;\n",
    "prefixes": [
        "dpdk-dev",
        "v1"
    ]
}