get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 54225,
    "url": "http://patches.dpdk.org/api/patches/54225/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1559583160-13944-2-git-send-email-anoobj@marvell.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": "<1559583160-13944-2-git-send-email-anoobj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1559583160-13944-2-git-send-email-anoobj@marvell.com",
    "date": "2019-06-03T17:32:01",
    "name": "[01/39] examples/l2fwd-event: create copy of l2fwd",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "5b427791c4725c4f254926379b2eaeaf4b6f6b25",
    "submitter": {
        "id": 1205,
        "url": "http://patches.dpdk.org/api/people/1205/?format=api",
        "name": "Anoob Joseph",
        "email": "anoobj@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patches.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1559583160-13944-2-git-send-email-anoobj@marvell.com/mbox/",
    "series": [
        {
            "id": 4868,
            "url": "http://patches.dpdk.org/api/series/4868/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4868",
            "date": "2019-06-03T17:32:00",
            "name": "adding eventmode helper library",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/4868/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/54225/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/54225/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id E4FC41B9A3;\n\tMon,  3 Jun 2019 19:33:27 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n\t[67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 54CF91B9A2\n\tfor <dev@dpdk.org>; Mon,  3 Jun 2019 19:33:27 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n\tby mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id\n\tx53HKacl027621; Mon, 3 Jun 2019 10:33:26 -0700",
            "from sc-exch03.marvell.com ([199.233.58.183])\n\tby mx0b-0016f401.pphosted.com with ESMTP id 2sw79pr6m4-6\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); \n\tMon, 03 Jun 2019 10:33:26 -0700",
            "from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com\n\t(10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3;\n\tMon, 3 Jun 2019 10:33:23 -0700",
            "from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com\n\t(10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend\n\tTransport; Mon, 3 Jun 2019 10:33:23 -0700",
            "from ajoseph83.caveonetworks.com.com (unknown [10.29.45.56])\n\tby maili.marvell.com (Postfix) with ESMTP id 62FA43F7040;\n\tMon,  3 Jun 2019 10:33:18 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n\th=from : to : cc :\n\tsubject : date : message-id : in-reply-to : references : mime-version\n\t: content-transfer-encoding : content-type; s=pfpt0818;\n\tbh=Ov3HfbFbR0j+qBcVrZK7qs24GPU9Og9qO05f5/yoBZU=;\n\tb=d+u4C2ZiHHPClAE2QlsC4rrBWjKFOGqfBHVMV0r6gAQ4LF498R8wMaeyXhAfz9bHRA72\n\tJOm1BYbYKmFNun38hxDjbKAqG9kYu1wWlH90izvyF64v8Q5rjjnA2mJqgdCd7pyJIr3E\n\t64mx8sp9prmG0TQ4pb0tnlieek2rFQTyjNeryljKjPOOnRZ8MLFPoJPLXU4gYP7cC/LS\n\tEH+uXkGJk+TF4310KlkZUoFdzNl/OBlvZFeW7L/uHUEf9rYkyZsRsza+UOIvBQtp1xVB\n\tYxVNdKEEd+UZMUONil5W0KLkyK1QEyy3lpoEyKWofFWlPTtUfa3+gNFpNwa0pm8M6UOA\n\t4g== ",
        "From": "Anoob Joseph <anoobj@marvell.com>",
        "To": "Jerin Jacob <jerinj@marvell.com>, Nikhil Rao <nikhil.rao@intel.com>,\n\t\"Erik Gabriel Carrillo\" <erik.g.carrillo@intel.com>, Abhinandan Gujjar\n\t<abhinandan.gujjar@intel.com>,\n\tBruce Richardson <bruce.richardson@intel.com>,\n\tPablo de Lara <pablo.de.lara.guarch@intel.com>",
        "CC": "Anoob Joseph <anoobj@marvell.com>, Narayana Prasad <pathreya@marvell.com>,\n\t<dev@dpdk.org>, Lukasz Bartosik <lbartosik@marvell.com>, Pavan Nikhilesh\n\t<pbhagavatula@marvell.com>, Hemant Agrawal <hemant.agrawal@nxp.com>,\n\t\"Nipun  Gupta\" <nipun.gupta@nxp.com>, Harry van Haaren\n\t<harry.van.haaren@intel.com>, =?utf-8?q?Mattias_R=C3=B6nnblom?=\n\t<mattias.ronnblom@ericsson.com>,  Liang Ma <liang.j.ma@intel.com>",
        "Date": "Mon, 3 Jun 2019 23:02:01 +0530",
        "Message-ID": "<1559583160-13944-2-git-send-email-anoobj@marvell.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1559583160-13944-1-git-send-email-anoobj@marvell.com>",
        "References": "<1559583160-13944-1-git-send-email-anoobj@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:, ,\n\tdefinitions=2019-06-03_13:, , signatures=0",
        "Subject": "[dpdk-dev] [PATCH 01/39] examples/l2fwd-event: create copy of l2fwd",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Creating a copy of l2fwd for event additions.\n\nSigned-off-by: Anoob Joseph <anoobj@marvell.com>\nSigned-off-by: Lukasz Bartosik <lbartosik@marvell.com>\n---\n examples/Makefile                |   1 +\n examples/l2fwd-event/Makefile    |  55 +++\n examples/l2fwd-event/main.c      | 752 +++++++++++++++++++++++++++++++++++++++\n examples/l2fwd-event/meson.build |  11 +\n 4 files changed, 819 insertions(+)\n create mode 100644 examples/l2fwd-event/Makefile\n create mode 100644 examples/l2fwd-event/main.c\n create mode 100644 examples/l2fwd-event/meson.build",
    "diff": "diff --git a/examples/Makefile b/examples/Makefile\nindex 7562424..aa718ef 100644\n--- a/examples/Makefile\n+++ b/examples/Makefile\n@@ -38,6 +38,7 @@ ifneq ($(PQOS_INSTALL_PATH),)\n DIRS-y += l2fwd-cat\n endif\n DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto\n+DIRS-$(CONFIG_RTE_LIBRTE_EVENTDEV) += l2fwd-event\n DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats\n DIRS-y += l2fwd-keepalive\n DIRS-y += l2fwd-keepalive/ka-agent\ndiff --git a/examples/l2fwd-event/Makefile b/examples/l2fwd-event/Makefile\nnew file mode 100644\nindex 0000000..398f7a1\n--- /dev/null\n+++ b/examples/l2fwd-event/Makefile\n@@ -0,0 +1,55 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2010-2014 Intel Corporation\n+\n+# binary name\n+APP = l2fwd-event\n+\n+# all source are stored in SRCS-y\n+SRCS-y := main.c\n+\n+# Build using pkg-config variables if possible\n+$(shell pkg-config --exists libdpdk)\n+ifeq ($(.SHELLSTATUS),0)\n+\n+all: shared\n+.PHONY: shared static\n+shared: build/$(APP)-shared\n+\tln -sf $(APP)-shared build/$(APP)\n+static: build/$(APP)-static\n+\tln -sf $(APP)-static build/$(APP)\n+\n+PC_FILE := $(shell pkg-config --path libdpdk)\n+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)\n+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)\n+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)\n+\n+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build\n+\t$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)\n+\n+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build\n+\t$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)\n+\n+build:\n+\t@mkdir -p $@\n+\n+.PHONY: clean\n+clean:\n+\trm -f build/$(APP) build/$(APP)-static build/$(APP)-shared\n+\trmdir --ignore-fail-on-non-empty build\n+\n+else # Build using legacy build system\n+\n+ifeq ($(RTE_SDK),)\n+$(error \"Please define RTE_SDK environment variable\")\n+endif\n+\n+# Default target, can be overridden by command line or environment\n+RTE_TARGET ?= x86_64-native-linuxapp-gcc\n+\n+include $(RTE_SDK)/mk/rte.vars.mk\n+\n+CFLAGS += -O3\n+CFLAGS += $(WERROR_FLAGS)\n+\n+include $(RTE_SDK)/mk/rte.extapp.mk\n+endif\ndiff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c\nnew file mode 100644\nindex 0000000..ef51dea\n--- /dev/null\n+++ b/examples/l2fwd-event/main.c\n@@ -0,0 +1,752 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2016 Intel Corporation\n+ * Copyright (C) 2019 Marvell International Ltd.\n+ */\n+\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <stdint.h>\n+#include <inttypes.h>\n+#include <sys/types.h>\n+#include <sys/queue.h>\n+#include <netinet/in.h>\n+#include <setjmp.h>\n+#include <stdarg.h>\n+#include <ctype.h>\n+#include <errno.h>\n+#include <getopt.h>\n+#include <signal.h>\n+#include <stdbool.h>\n+\n+#include <rte_common.h>\n+#include <rte_log.h>\n+#include <rte_malloc.h>\n+#include <rte_memory.h>\n+#include <rte_memcpy.h>\n+#include <rte_eal.h>\n+#include <rte_launch.h>\n+#include <rte_atomic.h>\n+#include <rte_cycles.h>\n+#include <rte_prefetch.h>\n+#include <rte_lcore.h>\n+#include <rte_per_lcore.h>\n+#include <rte_branch_prediction.h>\n+#include <rte_interrupts.h>\n+#include <rte_random.h>\n+#include <rte_debug.h>\n+#include <rte_ether.h>\n+#include <rte_ethdev.h>\n+#include <rte_mempool.h>\n+#include <rte_mbuf.h>\n+\n+static volatile bool force_quit;\n+\n+/* MAC updating enabled by default */\n+static int mac_updating = 1;\n+\n+#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1\n+\n+#define MAX_PKT_BURST 32\n+#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */\n+#define MEMPOOL_CACHE_SIZE 256\n+\n+/*\n+ * Configurable number of RX/TX ring descriptors\n+ */\n+#define RTE_TEST_RX_DESC_DEFAULT 1024\n+#define RTE_TEST_TX_DESC_DEFAULT 1024\n+static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;\n+static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;\n+\n+/* ethernet addresses of ports */\n+static struct rte_ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS];\n+\n+/* mask of enabled ports */\n+static uint32_t l2fwd_enabled_port_mask;\n+\n+/* list of enabled ports */\n+static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS];\n+\n+static unsigned int l2fwd_rx_queue_per_lcore = 1;\n+\n+#define MAX_RX_QUEUE_PER_LCORE 16\n+#define MAX_TX_QUEUE_PER_PORT 16\n+struct lcore_queue_conf {\n+\tunsigned int n_rx_port;\n+\tunsigned int rx_port_list[MAX_RX_QUEUE_PER_LCORE];\n+} __rte_cache_aligned;\n+struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];\n+\n+static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS];\n+\n+static struct rte_eth_conf port_conf = {\n+\t.rxmode = {\n+\t\t.split_hdr_size = 0,\n+\t},\n+\t.txmode = {\n+\t\t.mq_mode = ETH_MQ_TX_NONE,\n+\t},\n+};\n+\n+struct rte_mempool *l2fwd_pktmbuf_pool;\n+\n+/* Per-port statistics struct */\n+struct l2fwd_port_statistics {\n+\tuint64_t tx;\n+\tuint64_t rx;\n+\tuint64_t dropped;\n+} __rte_cache_aligned;\n+struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];\n+\n+#define MAX_TIMER_PERIOD 86400 /* 1 day max */\n+/* A tsc-based timer responsible for triggering statistics printout */\n+static uint64_t timer_period = 10; /* default period is 10 seconds */\n+\n+/* Print out statistics on packets dropped */\n+static void\n+print_stats(void)\n+{\n+\tuint64_t total_packets_dropped, total_packets_tx, total_packets_rx;\n+\tunsigned int portid;\n+\n+\ttotal_packets_dropped = 0;\n+\ttotal_packets_tx = 0;\n+\ttotal_packets_rx = 0;\n+\n+\tconst char clr[] = { 27, '[', '2', 'J', '\\0' };\n+\tconst char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\\0' };\n+\n+\t\t/* Clear screen and move to top left */\n+\tprintf(\"%s%s\", clr, topLeft);\n+\n+\tprintf(\"\\nPort statistics ====================================\");\n+\n+\tfor (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {\n+\t\t/* skip disabled ports */\n+\t\tif ((l2fwd_enabled_port_mask & (1 << portid)) == 0)\n+\t\t\tcontinue;\n+\t\tprintf(\"\\nStatistics for port %u ------------------------------\"\n+\t\t\t   \"\\nPackets sent: %24\"PRIu64\n+\t\t\t   \"\\nPackets received: %20\"PRIu64\n+\t\t\t   \"\\nPackets dropped: %21\"PRIu64,\n+\t\t\t   portid,\n+\t\t\t   port_statistics[portid].tx,\n+\t\t\t   port_statistics[portid].rx,\n+\t\t\t   port_statistics[portid].dropped);\n+\n+\t\ttotal_packets_dropped += port_statistics[portid].dropped;\n+\t\ttotal_packets_tx += port_statistics[portid].tx;\n+\t\ttotal_packets_rx += port_statistics[portid].rx;\n+\t}\n+\tprintf(\"\\nAggregate statistics ===============================\"\n+\t\t   \"\\nTotal packets sent: %18\"PRIu64\n+\t\t   \"\\nTotal packets received: %14\"PRIu64\n+\t\t   \"\\nTotal packets dropped: %15\"PRIu64,\n+\t\t   total_packets_tx,\n+\t\t   total_packets_rx,\n+\t\t   total_packets_dropped);\n+\tprintf(\"\\n====================================================\\n\");\n+}\n+\n+static void\n+l2fwd_mac_updating(struct rte_mbuf *m, unsigned int dest_portid)\n+{\n+\tstruct rte_ether_hdr *eth;\n+\tvoid *tmp;\n+\n+\teth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);\n+\n+\t/* 02:00:00:00:00:xx */\n+\ttmp = &eth->d_addr.addr_bytes[0];\n+\t*((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dest_portid << 40);\n+\n+\t/* src addr */\n+\trte_ether_addr_copy(&l2fwd_ports_eth_addr[dest_portid], &eth->s_addr);\n+}\n+\n+static void\n+l2fwd_simple_forward(struct rte_mbuf *m, unsigned int portid)\n+{\n+\tunsigned int dst_port;\n+\tint sent;\n+\tstruct rte_eth_dev_tx_buffer *buffer;\n+\n+\tdst_port = l2fwd_dst_ports[portid];\n+\n+\tif (mac_updating)\n+\t\tl2fwd_mac_updating(m, dst_port);\n+\n+\tbuffer = tx_buffer[dst_port];\n+\tsent = rte_eth_tx_buffer(dst_port, 0, buffer, m);\n+\tif (sent)\n+\t\tport_statistics[dst_port].tx += sent;\n+}\n+\n+/* main processing loop */\n+static void\n+l2fwd_main_loop(void)\n+{\n+\tstruct rte_mbuf *pkts_burst[MAX_PKT_BURST];\n+\tstruct rte_mbuf *m;\n+\tint sent;\n+\tunsigned int lcore_id;\n+\tuint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc;\n+\tunsigned int i, j, portid, nb_rx;\n+\tstruct lcore_queue_conf *qconf;\n+\tconst uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1)\n+\t\t\t/ US_PER_S * BURST_TX_DRAIN_US;\n+\tstruct rte_eth_dev_tx_buffer *buffer;\n+\n+\tprev_tsc = 0;\n+\ttimer_tsc = 0;\n+\n+\tlcore_id = rte_lcore_id();\n+\tqconf = &lcore_queue_conf[lcore_id];\n+\n+\tif (qconf->n_rx_port == 0) {\n+\t\tRTE_LOG(INFO, L2FWD, \"lcore %u has nothing to do\\n\", lcore_id);\n+\t\treturn;\n+\t}\n+\n+\tRTE_LOG(INFO, L2FWD, \"entering main loop on lcore %u\\n\", lcore_id);\n+\n+\tfor (i = 0; i < qconf->n_rx_port; i++) {\n+\n+\t\tportid = qconf->rx_port_list[i];\n+\t\tRTE_LOG(INFO, L2FWD, \" -- lcoreid=%u portid=%u\\n\", lcore_id,\n+\t\t\tportid);\n+\n+\t}\n+\n+\twhile (!force_quit) {\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\tfor (i = 0; i < qconf->n_rx_port; i++) {\n+\n+\t\t\t\tportid =\n+\t\t\t\t\tl2fwd_dst_ports[qconf->rx_port_list[i]];\n+\t\t\t\tbuffer = tx_buffer[portid];\n+\n+\t\t\t\tsent = rte_eth_tx_buffer_flush(portid, 0,\n+\t\t\t\t\t\t\t       buffer);\n+\t\t\t\tif (sent)\n+\t\t\t\t\tport_statistics[portid].tx += sent;\n+\n+\t\t\t}\n+\n+\t\t\t/* if timer is enabled */\n+\t\t\tif (timer_period > 0) {\n+\n+\t\t\t\t/* advance the timer */\n+\t\t\t\ttimer_tsc += diff_tsc;\n+\n+\t\t\t\t/* if timer has reached its timeout */\n+\t\t\t\tif (unlikely(timer_tsc >= timer_period)) {\n+\n+\t\t\t\t\t/* do this only on master core */\n+\t\t\t\t\tif (lcore_id ==\n+\t\t\t\t\t    rte_get_master_lcore()) {\n+\t\t\t\t\t\tprint_stats();\n+\t\t\t\t\t\t/* reset the timer */\n+\t\t\t\t\t\ttimer_tsc = 0;\n+\t\t\t\t\t}\n+\t\t\t\t}\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_port; i++) {\n+\n+\t\t\tportid = qconf->rx_port_list[i];\n+\t\t\tnb_rx = rte_eth_rx_burst(portid, 0,\n+\t\t\t\t\t\t pkts_burst, MAX_PKT_BURST);\n+\n+\t\t\tport_statistics[portid].rx += nb_rx;\n+\n+\t\t\tfor (j = 0; j < nb_rx; j++) {\n+\t\t\t\tm = pkts_burst[j];\n+\t\t\t\trte_prefetch0(rte_pktmbuf_mtod(m, void *));\n+\t\t\t\tl2fwd_simple_forward(m, portid);\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+static int\n+l2fwd_launch_one_lcore(__attribute__((unused)) void *dummy)\n+{\n+\tl2fwd_main_loop();\n+\treturn 0;\n+}\n+\n+/* display usage */\n+static void\n+l2fwd_usage(const char *prgname)\n+{\n+\tprintf(\"%s [EAL options] -- -p PORTMASK [-q NQ]\\n\"\n+\t       \"  -p PORTMASK: hexadecimal bitmask of ports to configure\\n\"\n+\t       \"  -q NQ: number of queue (=ports) per lcore (default is 1)\\n\"\n+\t\t   \"  -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\\n\"\n+\t\t   \"  --[no-]mac-updating: Enable or disable MAC addresses updating (enabled by default)\\n\"\n+\t\t   \"      When enabled:\\n\"\n+\t\t   \"       - The source MAC address is replaced by the TX port MAC address\\n\"\n+\t\t   \"       - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\\n\",\n+\t       prgname);\n+}\n+\n+static int\n+l2fwd_parse_portmask(const char *portmask)\n+{\n+\tchar *end = NULL;\n+\tunsigned long pm;\n+\n+\t/* parse hexadecimal string */\n+\tpm = strtoul(portmask, &end, 16);\n+\tif ((portmask[0] == '\\0') || (end == NULL) || (*end != '\\0'))\n+\t\treturn -1;\n+\n+\tif (pm == 0)\n+\t\treturn -1;\n+\n+\treturn pm;\n+}\n+\n+static unsigned int\n+l2fwd_parse_nqueue(const char *q_arg)\n+{\n+\tchar *end = NULL;\n+\tunsigned long n;\n+\n+\t/* parse hexadecimal string */\n+\tn = strtoul(q_arg, &end, 10);\n+\tif ((q_arg[0] == '\\0') || (end == NULL) || (*end != '\\0'))\n+\t\treturn 0;\n+\tif (n == 0)\n+\t\treturn 0;\n+\tif (n >= MAX_RX_QUEUE_PER_LCORE)\n+\t\treturn 0;\n+\n+\treturn n;\n+}\n+\n+static int\n+l2fwd_parse_timer_period(const char *q_arg)\n+{\n+\tchar *end = NULL;\n+\tint n;\n+\n+\t/* parse number string */\n+\tn = strtol(q_arg, &end, 10);\n+\tif ((q_arg[0] == '\\0') || (end == NULL) || (*end != '\\0'))\n+\t\treturn -1;\n+\tif (n >= MAX_TIMER_PERIOD)\n+\t\treturn -1;\n+\n+\treturn n;\n+}\n+\n+static const char short_options[] =\n+\t\"p:\"  /* portmask */\n+\t\"q:\"  /* number of queues */\n+\t\"T:\"  /* timer period */\n+\t;\n+\n+#define CMD_LINE_OPT_MAC_UPDATING \"mac-updating\"\n+#define CMD_LINE_OPT_NO_MAC_UPDATING \"no-mac-updating\"\n+\n+enum {\n+\t/* long options mapped to a short option */\n+\n+\t/* first long only option value must be >= 256, so that we won't\n+\t * conflict with short options\n+\t */\n+\tCMD_LINE_OPT_MIN_NUM = 256,\n+};\n+\n+static const struct option lgopts[] = {\n+\t{ CMD_LINE_OPT_MAC_UPDATING, no_argument, &mac_updating, 1},\n+\t{ CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, &mac_updating, 0},\n+\t{NULL, 0, 0, 0}\n+};\n+\n+/* Parse the argument given in the command line of the application */\n+static int\n+l2fwd_parse_args(int argc, char **argv)\n+{\n+\tint opt, ret, timer_secs;\n+\tchar **argvopt;\n+\tint option_index;\n+\tchar *prgname = argv[0];\n+\n+\targvopt = argv;\n+\n+\twhile ((opt = getopt_long(argc, argvopt, short_options,\n+\t\t\t\t  lgopts, &option_index)) != EOF) {\n+\n+\t\tswitch (opt) {\n+\t\t/* portmask */\n+\t\tcase 'p':\n+\t\t\tl2fwd_enabled_port_mask = l2fwd_parse_portmask(optarg);\n+\t\t\tif (l2fwd_enabled_port_mask == 0) {\n+\t\t\t\tprintf(\"invalid portmask\\n\");\n+\t\t\t\tl2fwd_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\t/* nqueue */\n+\t\tcase 'q':\n+\t\t\tl2fwd_rx_queue_per_lcore = l2fwd_parse_nqueue(optarg);\n+\t\t\tif (l2fwd_rx_queue_per_lcore == 0) {\n+\t\t\t\tprintf(\"invalid queue number\\n\");\n+\t\t\t\tl2fwd_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\t/* timer period */\n+\t\tcase 'T':\n+\t\t\ttimer_secs = l2fwd_parse_timer_period(optarg);\n+\t\t\tif (timer_secs < 0) {\n+\t\t\t\tprintf(\"invalid timer period\\n\");\n+\t\t\t\tl2fwd_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\ttimer_period = timer_secs;\n+\t\t\tbreak;\n+\n+\t\t/* long options */\n+\t\tcase 0:\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tl2fwd_usage(prgname);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tif (optind >= 0)\n+\t\targv[optind-1] = prgname;\n+\n+\tret = optind-1;\n+\toptind = 1; /* reset getopt lib */\n+\treturn ret;\n+}\n+\n+/* Check the link status of all ports in up to 9s, and print them finally */\n+static void\n+check_all_ports_link_status(uint32_t port_mask)\n+{\n+#define CHECK_INTERVAL 100 /* 100ms */\n+#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */\n+\tuint16_t portid;\n+\tuint8_t count, all_ports_up, print_flag = 0;\n+\tstruct rte_eth_link link;\n+\n+\tprintf(\"\\nChecking link status\");\n+\tfflush(stdout);\n+\tfor (count = 0; count <= MAX_CHECK_TIME; count++) {\n+\t\tif (force_quit)\n+\t\t\treturn;\n+\t\tall_ports_up = 1;\n+\t\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\t\tif (force_quit)\n+\t\t\t\treturn;\n+\t\t\tif ((port_mask & (1 << portid)) == 0)\n+\t\t\t\tcontinue;\n+\t\t\tmemset(&link, 0, sizeof(link));\n+\t\t\trte_eth_link_get_nowait(portid, &link);\n+\t\t\t/* print link status if flag set */\n+\t\t\tif (print_flag == 1) {\n+\t\t\t\tif (link.link_status)\n+\t\t\t\t\tprintf(\n+\t\t\t\t\t\"Port%d Link Up. Speed %u Mbps - %s\\n\",\n+\t\t\t\t\t\tportid, link.link_speed,\n+\t\t\t\t(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?\n+\t\t\t\t\t(\"full-duplex\") : (\"half-duplex\\n\"));\n+\t\t\t\telse\n+\t\t\t\t\tprintf(\"Port %d Link Down\\n\", portid);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\t/* clear all_ports_up flag if any link down */\n+\t\t\tif (link.link_status == ETH_LINK_DOWN) {\n+\t\t\t\tall_ports_up = 0;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t\t/* after finally printing all link status, get out */\n+\t\tif (print_flag == 1)\n+\t\t\tbreak;\n+\n+\t\tif (all_ports_up == 0) {\n+\t\t\tprintf(\".\");\n+\t\t\tfflush(stdout);\n+\t\t\trte_delay_ms(CHECK_INTERVAL);\n+\t\t}\n+\n+\t\t/* set the print_flag if all ports up or timeout */\n+\t\tif (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {\n+\t\t\tprint_flag = 1;\n+\t\t\tprintf(\"done\\n\");\n+\t\t}\n+\t}\n+}\n+\n+static void\n+signal_handler(int signum)\n+{\n+\tif (signum == SIGINT || signum == SIGTERM) {\n+\t\tprintf(\"\\n\\nSignal %d received, preparing to exit...\\n\",\n+\t\t\t\tsignum);\n+\t\tforce_quit = true;\n+\t}\n+}\n+\n+int\n+main(int argc, char **argv)\n+{\n+\tstruct lcore_queue_conf *qconf;\n+\tint ret;\n+\tuint16_t nb_ports;\n+\tuint16_t nb_ports_available = 0;\n+\tuint16_t portid, last_port;\n+\tunsigned int lcore_id, rx_lcore_id;\n+\tunsigned int nb_ports_in_mask = 0;\n+\tunsigned int nb_lcores = 0;\n+\tunsigned int nb_mbufs;\n+\n+\t/* init EAL */\n+\tret = rte_eal_init(argc, argv);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"Invalid EAL arguments\\n\");\n+\targc -= ret;\n+\targv += ret;\n+\n+\tforce_quit = false;\n+\tsignal(SIGINT, signal_handler);\n+\tsignal(SIGTERM, signal_handler);\n+\n+\t/* parse application arguments (after the EAL ones) */\n+\tret = l2fwd_parse_args(argc, argv);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"Invalid L2FWD arguments\\n\");\n+\n+\tprintf(\"MAC updating %s\\n\", mac_updating ? \"enabled\" : \"disabled\");\n+\n+\t/* convert to number of cycles */\n+\ttimer_period *= rte_get_timer_hz();\n+\n+\tnb_ports = rte_eth_dev_count_avail();\n+\tif (nb_ports == 0)\n+\t\trte_exit(EXIT_FAILURE, \"No Ethernet ports - bye\\n\");\n+\n+\t/* check port mask to possible port mask */\n+\tif (l2fwd_enabled_port_mask & ~((1 << nb_ports) - 1))\n+\t\trte_exit(EXIT_FAILURE, \"Invalid portmask; possible (0x%x)\\n\",\n+\t\t\t(1 << nb_ports) - 1);\n+\n+\t/* reset l2fwd_dst_ports */\n+\tfor (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)\n+\t\tl2fwd_dst_ports[portid] = 0;\n+\tlast_port = 0;\n+\n+\t/*\n+\t * Each logical core is assigned a dedicated TX queue on each port.\n+\t */\n+\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\t/* skip ports that are not enabled */\n+\t\tif ((l2fwd_enabled_port_mask & (1 << portid)) == 0)\n+\t\t\tcontinue;\n+\n+\t\tif (nb_ports_in_mask % 2) {\n+\t\t\tl2fwd_dst_ports[portid] = last_port;\n+\t\t\tl2fwd_dst_ports[last_port] = portid;\n+\t\t} else\n+\t\t\tlast_port = portid;\n+\n+\t\tnb_ports_in_mask++;\n+\t}\n+\tif (nb_ports_in_mask % 2) {\n+\t\tprintf(\"Notice: odd number of ports in portmask.\\n\");\n+\t\tl2fwd_dst_ports[last_port] = last_port;\n+\t}\n+\n+\trx_lcore_id = 0;\n+\tqconf = NULL;\n+\n+\t/* Initialize the port/queue configuration of each logical core */\n+\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\t/* skip ports that are not enabled */\n+\t\tif ((l2fwd_enabled_port_mask & (1 << portid)) == 0)\n+\t\t\tcontinue;\n+\n+\t\t/* get the lcore_id for this port */\n+\t\twhile (rte_lcore_is_enabled(rx_lcore_id) == 0 ||\n+\t\t       lcore_queue_conf[rx_lcore_id].n_rx_port ==\n+\t\t       l2fwd_rx_queue_per_lcore) {\n+\t\t\trx_lcore_id++;\n+\t\t\tif (rx_lcore_id >= RTE_MAX_LCORE)\n+\t\t\t\trte_exit(EXIT_FAILURE, \"Not enough cores\\n\");\n+\t\t}\n+\n+\t\tif (qconf != &lcore_queue_conf[rx_lcore_id]) {\n+\t\t\t/* Assigned a new logical core in the loop above. */\n+\t\t\tqconf = &lcore_queue_conf[rx_lcore_id];\n+\t\t\tnb_lcores++;\n+\t\t}\n+\n+\t\tqconf->rx_port_list[qconf->n_rx_port] = portid;\n+\t\tqconf->n_rx_port++;\n+\t\tprintf(\"Lcore %u: RX port %u\\n\", rx_lcore_id, portid);\n+\t}\n+\n+\tnb_mbufs = RTE_MAX(nb_ports * (nb_rxd + nb_txd + MAX_PKT_BURST +\n+\t\tnb_lcores * MEMPOOL_CACHE_SIZE), 8192U);\n+\n+\t/* create the mbuf pool */\n+\tl2fwd_pktmbuf_pool = rte_pktmbuf_pool_create(\"mbuf_pool\", nb_mbufs,\n+\t\tMEMPOOL_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE,\n+\t\trte_socket_id());\n+\tif (l2fwd_pktmbuf_pool == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Cannot init mbuf pool\\n\");\n+\n+\t/* Initialise each port */\n+\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\tstruct rte_eth_rxconf rxq_conf;\n+\t\tstruct rte_eth_txconf txq_conf;\n+\t\tstruct rte_eth_conf local_port_conf = port_conf;\n+\t\tstruct rte_eth_dev_info dev_info;\n+\n+\t\t/* skip ports that are not enabled */\n+\t\tif ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {\n+\t\t\tprintf(\"Skipping disabled port %u\\n\", portid);\n+\t\t\tcontinue;\n+\t\t}\n+\t\tnb_ports_available++;\n+\n+\t\t/* init port */\n+\t\tprintf(\"Initializing port %u... \", portid);\n+\t\tfflush(stdout);\n+\t\trte_eth_dev_info_get(portid, &dev_info);\n+\t\tif (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)\n+\t\t\tlocal_port_conf.txmode.offloads |=\n+\t\t\t\tDEV_TX_OFFLOAD_MBUF_FAST_FREE;\n+\t\tret = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"Cannot configure device: err=%d, port=%u\\n\",\n+\t\t\t\t  ret, portid);\n+\n+\t\tret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,\n+\t\t\t\t\t\t       &nb_txd);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t \"Cannot adjust number of descriptors: err=%d, port=%u\\n\",\n+\t\t\t\t ret, portid);\n+\n+\t\trte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);\n+\n+\t\t/* init one RX queue */\n+\t\tfflush(stdout);\n+\t\trxq_conf = dev_info.default_rxconf;\n+\t\trxq_conf.offloads = local_port_conf.rxmode.offloads;\n+\t\tret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,\n+\t\t\t\t\t     rte_eth_dev_socket_id(portid),\n+\t\t\t\t\t     &rxq_conf,\n+\t\t\t\t\t     l2fwd_pktmbuf_pool);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"rte_eth_rx_queue_setup:err=%d, port=%u\\n\",\n+\t\t\t\t  ret, portid);\n+\n+\t\t/* init one TX queue on each port */\n+\t\tfflush(stdout);\n+\t\ttxq_conf = dev_info.default_txconf;\n+\t\ttxq_conf.offloads = local_port_conf.txmode.offloads;\n+\t\tret = rte_eth_tx_queue_setup(portid, 0, nb_txd,\n+\t\t\t\trte_eth_dev_socket_id(portid),\n+\t\t\t\t&txq_conf);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"rte_eth_tx_queue_setup:err=%d, port=%u\\n\",\n+\t\t\t\tret, portid);\n+\n+\t\t/* Initialize TX buffers */\n+\t\ttx_buffer[portid] = rte_zmalloc_socket(\"tx_buffer\",\n+\t\t\t\tRTE_ETH_TX_BUFFER_SIZE(MAX_PKT_BURST), 0,\n+\t\t\t\trte_eth_dev_socket_id(portid));\n+\t\tif (tx_buffer[portid] == NULL)\n+\t\t\trte_exit(EXIT_FAILURE, \"Cannot allocate buffer for tx on port %u\\n\",\n+\t\t\t\t\tportid);\n+\n+\t\trte_eth_tx_buffer_init(tx_buffer[portid], MAX_PKT_BURST);\n+\n+\t\tret = rte_eth_tx_buffer_set_err_callback(tx_buffer[portid],\n+\t\t\t\trte_eth_tx_buffer_count_callback,\n+\t\t\t\t&port_statistics[portid].dropped);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"Cannot set error callback for tx buffer on port %u\\n\",\n+\t\t\t\t portid);\n+\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=%u\\n\",\n+\t\t\t\t  ret, portid);\n+\n+\t\tprintf(\"done:\\n\");\n+\n+\t\trte_eth_promiscuous_enable(portid);\n+\n+\t\tprintf(\"Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\\n\\n\",\n+\t\t\t\tportid,\n+\t\t\t\tl2fwd_ports_eth_addr[portid].addr_bytes[0],\n+\t\t\t\tl2fwd_ports_eth_addr[portid].addr_bytes[1],\n+\t\t\t\tl2fwd_ports_eth_addr[portid].addr_bytes[2],\n+\t\t\t\tl2fwd_ports_eth_addr[portid].addr_bytes[3],\n+\t\t\t\tl2fwd_ports_eth_addr[portid].addr_bytes[4],\n+\t\t\t\tl2fwd_ports_eth_addr[portid].addr_bytes[5]);\n+\n+\t\t/* initialize port stats */\n+\t\tmemset(&port_statistics, 0, sizeof(port_statistics));\n+\t}\n+\n+\tif (!nb_ports_available) {\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"All available ports are disabled. Please set portmask.\\n\");\n+\t}\n+\n+\tcheck_all_ports_link_status(l2fwd_enabled_port_mask);\n+\n+\tret = 0;\n+\t/* launch per-lcore init on every lcore */\n+\trte_eal_mp_remote_launch(l2fwd_launch_one_lcore, NULL, CALL_MASTER);\n+\tRTE_LCORE_FOREACH_SLAVE(lcore_id) {\n+\t\tif (rte_eal_wait_lcore(lcore_id) < 0) {\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\tif ((l2fwd_enabled_port_mask & (1 << portid)) == 0)\n+\t\t\tcontinue;\n+\t\tprintf(\"Closing port %d...\", portid);\n+\t\trte_eth_dev_stop(portid);\n+\t\trte_eth_dev_close(portid);\n+\t\tprintf(\" Done\\n\");\n+\t}\n+\tprintf(\"Bye...\\n\");\n+\n+\treturn ret;\n+}\ndiff --git a/examples/l2fwd-event/meson.build b/examples/l2fwd-event/meson.build\nnew file mode 100644\nindex 0000000..c34e11e\n--- /dev/null\n+++ b/examples/l2fwd-event/meson.build\n@@ -0,0 +1,11 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2017 Intel Corporation\n+\n+# meson file, for building this example as part of a main DPDK build.\n+#\n+# To build this example as a standalone application with an already-installed\n+# DPDK instance, use 'make'\n+\n+sources = files(\n+\t'main.c'\n+)\n",
    "prefixes": [
        "01/39"
    ]
}