get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 63650,
    "url": "http://patches.dpdk.org/api/patches/63650/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1575808249-31135-10-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": "<1575808249-31135-10-git-send-email-anoobj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1575808249-31135-10-git-send-email-anoobj@marvell.com",
    "date": "2019-12-08T12:30:44",
    "name": "[09/14] examples/ipsec-secgw: add eventmode to ipsec-secgw",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "181179650f8c451624e97fa3274fff777cccf0da",
    "submitter": {
        "id": 1205,
        "url": "http://patches.dpdk.org/api/people/1205/?format=api",
        "name": "Anoob Joseph",
        "email": "anoobj@marvell.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1575808249-31135-10-git-send-email-anoobj@marvell.com/mbox/",
    "series": [
        {
            "id": 7750,
            "url": "http://patches.dpdk.org/api/series/7750/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=7750",
            "date": "2019-12-08T12:30:35",
            "name": "add eventmode to ipsec-secgw",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/7750/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/63650/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/63650/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 7D005A04F1;\n\tSun,  8 Dec 2019 13:32:56 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id C3AA01BFBA;\n\tSun,  8 Dec 2019 13:32:07 +0100 (CET)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id BC5D81BFB6\n for <dev@dpdk.org>; Sun,  8 Dec 2019 13:32:05 +0100 (CET)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n xB8CVRXv019938; Sun, 8 Dec 2019 04:32:05 -0800",
            "from sc-exch01.marvell.com ([199.233.58.181])\n by mx0b-0016f401.pphosted.com with ESMTP id 2wrcfpte8s-2\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Sun, 08 Dec 2019 04:32:04 -0800",
            "from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 8 Dec\n 2019 04:32:03 -0800",
            "from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend\n Transport; Sun, 8 Dec 2019 04:32:03 -0800",
            "from ajoseph83.caveonetworks.com.com (unknown [10.29.45.60])\n by maili.marvell.com (Postfix) with ESMTP id B5DF73F703F;\n Sun,  8 Dec 2019 04:31:58 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0818;\n bh=akv0yhVbqBWmMqefBBFJw1lVlXXWqAapu3TfORK25dI=;\n b=wxRWwpXTVdpv+LWNVcaW+MEjdIyQ0N2gJIP/F30tYdlIGxdgc6RLNUz2SFyFHx0Lk9tl\n IKhY3AXghYihtHYwX6023JPDjfoSS7I6hZW3UAQm6JhWQUiW9PSilRpeaDECN5TObvnK\n SJLabXcApFyY+SzpCtzoUV7aZqSRt1XImDK3g/SaGSkM/CN4TZ4iK+62WFkIcpfhY7ZY\n +kWmzr8seZCXhc6iD5tHAh8iUgn45pZbD6aIZpzssAiUKEPcrRyKQg5dnBhstAEWHJXk\n OZRztgYuYWpIrGOysbDzSKGa/yI5wHad+RCk96SJCqfUwF9f4juqC2Fmg2mxeWD3V1y2 /A==",
        "From": "Anoob Joseph <anoobj@marvell.com>",
        "To": "Akhil Goyal <akhil.goyal@nxp.com>, Radu Nicolau <radu.nicolau@intel.com>,\n Thomas Monjalon <thomas@monjalon.net>",
        "CC": "Lukasz Bartosik <lbartosik@marvell.com>, Jerin Jacob <jerinj@marvell.com>,\n Narayana Prasad <pathreya@marvell.com>,\n Ankur Dwivedi <adwivedi@marvell.com>, Anoob Joseph <anoobj@marvell.com>,\n Archana Muniganti <marchana@marvell.com>,\n Tejasree Kondoj <ktejasree@marvell.com>, Vamsi Attunuru\n <vattunuru@marvell.com>,\n Konstantin Ananyev <konstantin.ananyev@intel.com>, <dev@dpdk.org>",
        "Date": "Sun, 8 Dec 2019 18:00:44 +0530",
        "Message-ID": "<1575808249-31135-10-git-send-email-anoobj@marvell.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1575808249-31135-1-git-send-email-anoobj@marvell.com>",
        "References": "<1575808249-31135-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:6.0.95,18.0.572\n definitions=2019-12-08_03:2019-12-05,2019-12-08 signatures=0",
        "Subject": "[dpdk-dev] [PATCH 09/14] examples/ipsec-secgw: add eventmode to\n\tipsec-secgw",
        "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 <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Lukasz Bartosik <lbartosik@marvell.com>\n\nAdd eventmode support to ipsec-secgw. This uses event helper to setup\nand use the eventmode capabilities. Add driver inbound worker.\n\nExample command:\n./ipsec-secgw -c 0x1 -w 0002:02:00.0,ipsec_in_max_spi=100 -w 0002:07:00.0\n -w 0002:0e:00.0 -w 0002:10:00.1 -- -P -p 0x3 -u 0x1\n --config \"(0,0,0),(1,0,0)\" -f a-aes-gcm-msa.cfg --transfer-mode 1\n --schedule-type 2 --process-mode drv --process-dir in\n\nSigned-off-by: Anoob Joseph <anoobj@marvell.com>\nSigned-off-by: Lukasz Bartosik <lbartosik@marvell.com>\n---\n examples/ipsec-secgw/Makefile       |   1 +\n examples/ipsec-secgw/event_helper.c |   3 +\n examples/ipsec-secgw/event_helper.h |  26 +++\n examples/ipsec-secgw/ipsec-secgw.c  | 344 +++++++++++++++++++++++++++++++++++-\n examples/ipsec-secgw/ipsec.h        |   7 +\n examples/ipsec-secgw/ipsec_worker.c | 180 +++++++++++++++++++\n examples/ipsec-secgw/meson.build    |   2 +-\n 7 files changed, 555 insertions(+), 8 deletions(-)\n create mode 100644 examples/ipsec-secgw/ipsec_worker.c",
    "diff": "diff --git a/examples/ipsec-secgw/Makefile b/examples/ipsec-secgw/Makefile\nindex 09e3c5a..f6fd94c 100644\n--- a/examples/ipsec-secgw/Makefile\n+++ b/examples/ipsec-secgw/Makefile\n@@ -15,6 +15,7 @@ SRCS-y += sa.c\n SRCS-y += rt.c\n SRCS-y += ipsec_process.c\n SRCS-y += ipsec-secgw.c\n+SRCS-y += ipsec_worker.c\n SRCS-y += event_helper.c\n \n CFLAGS += -gdwarf-2\ndiff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/event_helper.c\nindex 6549875..44f997d 100644\n--- a/examples/ipsec-secgw/event_helper.c\n+++ b/examples/ipsec-secgw/event_helper.c\n@@ -984,6 +984,9 @@ eh_find_worker(uint32_t lcore_id, struct eh_conf *conf,\n \telse\n \t\tcurr_conf.cap.burst = EH_RX_TYPE_NON_BURST;\n \n+\tcurr_conf.cap.ipsec_mode = conf->ipsec_mode;\n+\tcurr_conf.cap.ipsec_dir = conf->ipsec_dir;\n+\n \t/* Parse the passed list and see if we have matching capabilities */\n \n \t/* Initialize the pointer used to traverse the list */\ndiff --git a/examples/ipsec-secgw/event_helper.h b/examples/ipsec-secgw/event_helper.h\nindex 2895dfa..07849b0 100644\n--- a/examples/ipsec-secgw/event_helper.h\n+++ b/examples/ipsec-secgw/event_helper.h\n@@ -74,6 +74,22 @@ enum eh_tx_types {\n \tEH_TX_TYPE_NO_INTERNAL_PORT\n };\n \n+/**\n+ * Event mode ipsec mode types\n+ */\n+enum eh_ipsec_mode_types {\n+\tEH_IPSEC_MODE_TYPE_APP = 0,\n+\tEH_IPSEC_MODE_TYPE_DRIVER\n+};\n+\n+/**\n+ * Event mode ipsec direction types\n+ */\n+enum eh_ipsec_dir_types {\n+\tEH_IPSEC_DIR_TYPE_OUTBOUND = 0,\n+\tEH_IPSEC_DIR_TYPE_INBOUND,\n+};\n+\n /* Event dev params */\n struct eventdev_params {\n \tuint8_t eventdev_id;\n@@ -183,6 +199,12 @@ struct eh_conf {\n \t\t */\n \tvoid *mode_params;\n \t\t/**< Mode specific parameters */\n+\n+\t\t/** Application specific params */\n+\tenum eh_ipsec_mode_types ipsec_mode;\n+\t\t/**< Mode of ipsec run */\n+\tenum eh_ipsec_dir_types ipsec_dir;\n+\t\t/**< Direction of ipsec processing */\n };\n \n /* Workers registered by the application */\n@@ -194,6 +216,10 @@ struct eh_app_worker_params {\n \t\t\t/**< Specify status of rx type burst */\n \t\t\tuint64_t tx_internal_port : 1;\n \t\t\t/**< Specify whether tx internal port is available */\n+\t\t\tuint64_t ipsec_mode : 1;\n+\t\t\t/**< Specify ipsec processing level */\n+\t\t\tuint64_t ipsec_dir : 1;\n+\t\t\t/**< Specify direction of ipsec */\n \t\t};\n \t\tuint64_t u64;\n \t} cap;\ndiff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c\nindex 7506922..c5d95b9 100644\n--- a/examples/ipsec-secgw/ipsec-secgw.c\n+++ b/examples/ipsec-secgw/ipsec-secgw.c\n@@ -2,6 +2,7 @@\n  * Copyright(c) 2016 Intel Corporation\n  */\n \n+#include <stdbool.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <stdint.h>\n@@ -14,6 +15,7 @@\n #include <sys/queue.h>\n #include <stdarg.h>\n #include <errno.h>\n+#include <signal.h>\n #include <getopt.h>\n \n #include <rte_common.h>\n@@ -41,12 +43,17 @@\n #include <rte_jhash.h>\n #include <rte_cryptodev.h>\n #include <rte_security.h>\n+#include <rte_bitmap.h>\n+#include <rte_eventdev.h>\n #include <rte_ip.h>\n #include <rte_ip_frag.h>\n \n+#include \"event_helper.h\"\n #include \"ipsec.h\"\n #include \"parser.h\"\n \n+volatile bool force_quit;\n+\n #define RTE_LOGTYPE_IPSEC RTE_LOGTYPE_USER1\n \n #define MAX_JUMBO_PKT_LEN  9600\n@@ -133,12 +140,21 @@ struct flow_info flow_info_tbl[RTE_MAX_ETHPORTS];\n #define CMD_LINE_OPT_CONFIG\t\t\"config\"\n #define CMD_LINE_OPT_SINGLE_SA\t\t\"single-sa\"\n #define CMD_LINE_OPT_CRYPTODEV_MASK\t\"cryptodev_mask\"\n+#define CMD_LINE_OPT_TRANSFER_MODE\t\"transfer-mode\"\n+#define CMD_LINE_OPT_SCHEDULE_TYPE\t\"schedule-type\"\n+#define CMD_LINE_OPT_IPSEC_MODE\t\t\"process-mode\"\n+#define CMD_LINE_OPT_IPSEC_DIR\t\t\"process-dir\"\n #define CMD_LINE_OPT_RX_OFFLOAD\t\t\"rxoffload\"\n #define CMD_LINE_OPT_TX_OFFLOAD\t\t\"txoffload\"\n #define CMD_LINE_OPT_REASSEMBLE\t\t\"reassemble\"\n #define CMD_LINE_OPT_MTU\t\t\"mtu\"\n #define CMD_LINE_OPT_FRAG_TTL\t\t\"frag-ttl\"\n \n+#define CMD_LINE_ARG_APP \"app\"\n+#define CMD_LINE_ARG_DRV \"drv\"\n+#define CMD_LINE_ARG_INB \"in\"\n+#define CMD_LINE_ARG_OUT \"out\"\n+\n enum {\n \t/* long options mapped to a short option */\n \n@@ -149,7 +165,11 @@ enum {\n \tCMD_LINE_OPT_CONFIG_NUM,\n \tCMD_LINE_OPT_SINGLE_SA_NUM,\n \tCMD_LINE_OPT_CRYPTODEV_MASK_NUM,\n+\tCMD_LINE_OPT_TRANSFER_MODE_NUM,\n+\tCMD_LINE_OPT_SCHEDULE_TYPE_NUM,\n \tCMD_LINE_OPT_RX_OFFLOAD_NUM,\n+\tCMD_LINE_OPT_IPSEC_MODE_NUM,\n+\tCMD_LINE_OPT_IPSEC_DIR_NUM,\n \tCMD_LINE_OPT_TX_OFFLOAD_NUM,\n \tCMD_LINE_OPT_REASSEMBLE_NUM,\n \tCMD_LINE_OPT_MTU_NUM,\n@@ -160,6 +180,10 @@ static const struct option lgopts[] = {\n \t{CMD_LINE_OPT_CONFIG, 1, 0, CMD_LINE_OPT_CONFIG_NUM},\n \t{CMD_LINE_OPT_SINGLE_SA, 1, 0, CMD_LINE_OPT_SINGLE_SA_NUM},\n \t{CMD_LINE_OPT_CRYPTODEV_MASK, 1, 0, CMD_LINE_OPT_CRYPTODEV_MASK_NUM},\n+\t{CMD_LINE_OPT_TRANSFER_MODE, 1, 0, CMD_LINE_OPT_TRANSFER_MODE_NUM},\n+\t{CMD_LINE_OPT_SCHEDULE_TYPE, 1, 0, CMD_LINE_OPT_SCHEDULE_TYPE_NUM},\n+\t{CMD_LINE_OPT_IPSEC_MODE, 1, 0, CMD_LINE_OPT_IPSEC_MODE_NUM},\n+\t{CMD_LINE_OPT_IPSEC_DIR, 1, 0, CMD_LINE_OPT_IPSEC_DIR_NUM},\n \t{CMD_LINE_OPT_RX_OFFLOAD, 1, 0, CMD_LINE_OPT_RX_OFFLOAD_NUM},\n \t{CMD_LINE_OPT_TX_OFFLOAD, 1, 0, CMD_LINE_OPT_TX_OFFLOAD_NUM},\n \t{CMD_LINE_OPT_REASSEMBLE, 1, 0, CMD_LINE_OPT_REASSEMBLE_NUM},\n@@ -1094,8 +1118,8 @@ drain_outbound_crypto_queues(const struct lcore_conf *qconf,\n }\n \n /* main processing loop */\n-static int32_t\n-main_loop(__attribute__((unused)) void *dummy)\n+void\n+ipsec_poll_mode_worker(void)\n {\n \tstruct rte_mbuf *pkts[MAX_PKT_BURST];\n \tuint32_t lcore_id;\n@@ -1137,7 +1161,7 @@ main_loop(__attribute__((unused)) void *dummy)\n \tif (qconf->nb_rx_queue == 0) {\n \t\tRTE_LOG(DEBUG, IPSEC, \"lcore %u has nothing to do\\n\",\n \t\t\tlcore_id);\n-\t\treturn 0;\n+\t\treturn;\n \t}\n \n \tRTE_LOG(INFO, IPSEC, \"entering main loop on lcore %u\\n\", lcore_id);\n@@ -1150,7 +1174,7 @@ main_loop(__attribute__((unused)) void *dummy)\n \t\t\tlcore_id, portid, queueid);\n \t}\n \n-\twhile (1) {\n+\twhile (!force_quit) {\n \t\tcur_tsc = rte_rdtsc();\n \n \t\t/* TX queue buffer drain */\n@@ -1277,6 +1301,10 @@ print_usage(const char *prgname)\n \t\t\" --config (port,queue,lcore)[,(port,queue,lcore)]\"\n \t\t\" [--single-sa SAIDX]\"\n \t\t\" [--cryptodev_mask MASK]\"\n+\t\t\" [--transfer-mode MODE]\"\n+\t\t\" [--schedule-type TYPE]\"\n+\t\t\" [--process-mode MODE]\"\n+\t\t\" [--process-dir DIR]\"\n \t\t\" [--\" CMD_LINE_OPT_RX_OFFLOAD \" RX_OFFLOAD_MASK]\"\n \t\t\" [--\" CMD_LINE_OPT_TX_OFFLOAD \" TX_OFFLOAD_MASK]\"\n \t\t\" [--\" CMD_LINE_OPT_REASSEMBLE \" REASSEMBLE_TABLE_SIZE]\"\n@@ -1298,6 +1326,22 @@ print_usage(const char *prgname)\n \t\t\"                     bypassing the SP\\n\"\n \t\t\"  --cryptodev_mask MASK: Hexadecimal bitmask of the crypto\\n\"\n \t\t\"                         devices to configure\\n\"\n+\t\t\"  --transfer-mode MODE\\n\"\n+\t\t\"               0: Packet transfer via polling (default)\\n\"\n+\t\t\"               1: Packet transfer via eventdev\\n\"\n+\t\t\"  --schedule-type TYPE queue schedule type, used only when\\n\"\n+\t\t\"                       transfer mode is set to eventdev\\n\"\n+\t\t\"               0: Ordered (default)\\n\"\n+\t\t\"               1: Atomic\\n\"\n+\t\t\"               2: Parallel\\n\"\n+\t\t\"  --process-mode MODE processing mode, used only when\\n\"\n+\t\t\"                      transfer mode is set to eventdev\\n\"\n+\t\t\"               \\\"app\\\" : application mode (default)\\n\"\n+\t\t\"               \\\"drv\\\" : driver mode\\n\"\n+\t\t\"  --process-dir DIR processing direction, used only when\\n\"\n+\t\t\"                    transfer mode is set to eventdev\\n\"\n+\t\t\"               \\\"out\\\" : outbound (default)\\n\"\n+\t\t\"               \\\"in\\\"  : inbound\\n\"\n \t\t\"  --\" CMD_LINE_OPT_RX_OFFLOAD\n \t\t\": bitmask of the RX HW offload capabilities to enable/use\\n\"\n \t\t\"                         (DEV_RX_OFFLOAD_*)\\n\"\n@@ -1433,7 +1477,89 @@ print_app_sa_prm(const struct app_sa_prm *prm)\n }\n \n static int32_t\n-parse_args(int32_t argc, char **argv)\n+eh_parse_decimal(const char *str)\n+{\n+\tunsigned long num;\n+\tchar *end = NULL;\n+\n+\tnum = strtoul(str, &end, 10);\n+\tif ((str[0] == '\\0') || (end == NULL) || (*end != '\\0'))\n+\t\treturn -EINVAL;\n+\n+\treturn num;\n+}\n+\n+static int\n+parse_transfer_mode(struct eh_conf *conf, const char *optarg)\n+{\n+\tint32_t parsed_dec;\n+\n+\tparsed_dec = eh_parse_decimal(optarg);\n+\tif (parsed_dec != EH_PKT_TRANSFER_MODE_POLL &&\n+\t    parsed_dec != EH_PKT_TRANSFER_MODE_EVENT) {\n+\t\tprintf(\"Unsupported packet transfer mode\");\n+\t\treturn -EINVAL;\n+\t}\n+\tconf->mode = parsed_dec;\n+\treturn 0;\n+}\n+\n+static int\n+parse_schedule_type(struct eh_conf *conf, const char *optarg)\n+{\n+\tstruct eventmode_conf *em_conf = NULL;\n+\tint32_t parsed_dec;\n+\n+\tparsed_dec = eh_parse_decimal(optarg);\n+\tif (parsed_dec != RTE_SCHED_TYPE_ORDERED &&\n+\t    parsed_dec != RTE_SCHED_TYPE_ATOMIC &&\n+\t    parsed_dec != RTE_SCHED_TYPE_PARALLEL)\n+\t\treturn -EINVAL;\n+\n+\t/* Get eventmode conf */\n+\tem_conf = (struct eventmode_conf *)(conf->mode_params);\n+\n+\tem_conf->ext_params.sched_type = parsed_dec;\n+\n+\treturn 0;\n+}\n+\n+static int\n+parse_ipsec_mode(struct eh_conf *conf, const char *optarg)\n+{\n+\tif (!strncmp(CMD_LINE_ARG_APP, optarg, strlen(CMD_LINE_ARG_APP)) &&\n+\t    strlen(optarg) == strlen(CMD_LINE_ARG_APP))\n+\t\tconf->ipsec_mode = EH_IPSEC_MODE_TYPE_APP;\n+\telse if (!strncmp(CMD_LINE_ARG_DRV, optarg, strlen(CMD_LINE_ARG_DRV)) &&\n+\t\t strlen(optarg) == strlen(CMD_LINE_ARG_DRV))\n+\t\tconf->ipsec_mode = EH_IPSEC_MODE_TYPE_DRIVER;\n+\telse {\n+\t\tprintf(\"Unsupported ipsec mode\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+parse_ipsec_dir(struct eh_conf *conf, const char *optarg)\n+{\n+\tif (!strncmp(CMD_LINE_ARG_INB, optarg, strlen(CMD_LINE_ARG_INB)) &&\n+\t    strlen(optarg) == strlen(CMD_LINE_ARG_INB))\n+\t\tconf->ipsec_dir = EH_IPSEC_DIR_TYPE_INBOUND;\n+\telse if (!strncmp(CMD_LINE_ARG_OUT, optarg, strlen(CMD_LINE_ARG_OUT)) &&\n+\t\t strlen(optarg) == strlen(CMD_LINE_ARG_OUT))\n+\t\tconf->ipsec_dir = EH_IPSEC_DIR_TYPE_OUTBOUND;\n+\telse {\n+\t\tprintf(\"Unsupported ipsec direction\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int32_t\n+parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf)\n {\n \tint opt;\n \tint64_t ret;\n@@ -1536,6 +1662,43 @@ parse_args(int32_t argc, char **argv)\n \t\t\t/* else */\n \t\t\tenabled_cryptodev_mask = ret;\n \t\t\tbreak;\n+\n+\t\tcase CMD_LINE_OPT_TRANSFER_MODE_NUM:\n+\t\t\tret = parse_transfer_mode(eh_conf, optarg);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tprintf(\"Invalid packet transfer mode\\n\");\n+\t\t\t\tprint_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase CMD_LINE_OPT_SCHEDULE_TYPE_NUM:\n+\t\t\tret = parse_schedule_type(eh_conf, optarg);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tprintf(\"Invalid queue schedule type\\n\");\n+\t\t\t\tprint_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase CMD_LINE_OPT_IPSEC_MODE_NUM:\n+\t\t\tret = parse_ipsec_mode(eh_conf, optarg);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tprintf(\"Invalid ipsec mode\\n\");\n+\t\t\t\tprint_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase CMD_LINE_OPT_IPSEC_DIR_NUM:\n+\t\t\tret = parse_ipsec_dir(eh_conf, optarg);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tprintf(\"Invalid ipsec direction\\n\");\n+\t\t\t\tprint_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n \t\tcase CMD_LINE_OPT_RX_OFFLOAD_NUM:\n \t\t\tret = parse_mask(optarg, &dev_rx_offload);\n \t\t\tif (ret != 0) {\n@@ -2457,6 +2620,132 @@ create_default_ipsec_flow(uint16_t port_id, uint64_t rx_offloads)\n \treturn ret;\n }\n \n+static struct eh_conf *\n+eh_conf_init(void)\n+{\n+\tstruct eventmode_conf *em_conf = NULL;\n+\tstruct eh_conf *conf = NULL;\n+\tunsigned int eth_core_id;\n+\tuint32_t nb_bytes;\n+\tvoid *mem = NULL;\n+\n+\t/* Allocate memory for config */\n+\tconf = calloc(1, sizeof(struct eh_conf));\n+\tif (conf == NULL) {\n+\t\tprintf(\"Failed to allocate memory for eventmode helper conf\");\n+\t\tgoto err;\n+\t}\n+\n+\t/* Set default conf */\n+\n+\t/* Packet transfer mode: poll */\n+\tconf->mode = EH_PKT_TRANSFER_MODE_POLL;\n+\tconf->ipsec_mode = EH_IPSEC_MODE_TYPE_APP;\n+\tconf->ipsec_dir = EH_IPSEC_DIR_TYPE_OUTBOUND;\n+\n+\t/* Keep all ethernet ports enabled by default */\n+\tconf->eth_portmask = -1;\n+\n+\t/* Allocate memory for event mode params */\n+\tconf->mode_params =\n+\t\tcalloc(1, sizeof(struct eventmode_conf));\n+\tif (conf->mode_params == NULL) {\n+\t\tprintf(\"Failed to allocate memory for event mode params\");\n+\t\tgoto err;\n+\t}\n+\n+\t/* Get eventmode conf */\n+\tem_conf = (struct eventmode_conf *)(conf->mode_params);\n+\n+\t/* Allocate and initialize bitmap for eth cores */\n+\tnb_bytes = rte_bitmap_get_memory_footprint(RTE_MAX_LCORE);\n+\tif (!nb_bytes) {\n+\t\tprintf(\"Failed to get bitmap footprint\");\n+\t\tgoto err;\n+\t}\n+\n+\tmem = rte_zmalloc(\"event-helper-ethcore-bitmap\", nb_bytes,\n+\t\t\t  RTE_CACHE_LINE_SIZE);\n+\tif (!mem) {\n+\t\tprintf(\"Failed to allocate memory for eth cores bitmap\\n\");\n+\t\tgoto err;\n+\t}\n+\n+\tem_conf->eth_core_mask = rte_bitmap_init(RTE_MAX_LCORE, mem, nb_bytes);\n+\tif (!em_conf->eth_core_mask) {\n+\t\tprintf(\"Failed to initialize bitmap\");\n+\t\tgoto err;\n+\t}\n+\n+\t/* Schedule type: ordered */\n+\tem_conf->ext_params.sched_type = RTE_SCHED_TYPE_ORDERED;\n+\n+\t/* Set two cores as eth cores for Rx & Tx */\n+\n+\t/* Use first core other than master core as Rx core */\n+\teth_core_id = rte_get_next_lcore(0,\t/* curr core */\n+\t\t\t\t\t 1,\t/* skip master core */\n+\t\t\t\t\t 0\t/* wrap */);\n+\n+\trte_bitmap_set(em_conf->eth_core_mask, eth_core_id);\n+\n+\t/* Use next core as Tx core */\n+\teth_core_id = rte_get_next_lcore(eth_core_id,\t/* curr core */\n+\t\t\t\t\t 1,\t\t/* skip master core */\n+\t\t\t\t\t 0\t\t/* wrap */);\n+\n+\trte_bitmap_set(em_conf->eth_core_mask, eth_core_id);\n+\n+\treturn conf;\n+err:\n+\trte_free(mem);\n+\tfree(em_conf);\n+\tfree(conf);\n+\treturn NULL;\n+}\n+\n+static void\n+eh_conf_uninit(struct eh_conf *conf)\n+{\n+\tstruct eventmode_conf *em_conf = NULL;\n+\n+\t/* Get eventmode conf */\n+\tem_conf = (struct eventmode_conf *)(conf->mode_params);\n+\n+\t/* Free evenmode configuration memory */\n+\trte_free(em_conf->eth_core_mask);\n+\tfree(em_conf);\n+\tfree(conf);\n+}\n+\n+static void\n+signal_handler(int signum)\n+{\n+\tif (signum == SIGINT || signum == SIGTERM) {\n+\t\tuint16_t port_id;\n+\t\tprintf(\"\\n\\nSignal %d received, preparing to exit...\\n\",\n+\t\t\t\tsignum);\n+\t\tforce_quit = true;\n+\n+\t\t/* Destroy the default ipsec flow */\n+\t\tRTE_ETH_FOREACH_DEV(port_id) {\n+\t\t\tif ((enabled_port_mask & (1 << port_id)) == 0)\n+\t\t\t\tcontinue;\n+\t\t\tif (flow_info_tbl[port_id].rx_def_flow) {\n+\t\t\t\tstruct rte_flow_error err;\n+\t\t\t\tint ret;\n+\t\t\t\tret = rte_flow_destroy(port_id,\n+\t\t\t\t\tflow_info_tbl[port_id].rx_def_flow,\n+\t\t\t\t\t&err);\n+\t\t\t\tif (ret)\n+\t\t\t\t\tRTE_LOG(ERR, IPSEC,\n+\t\t\t\t\t\"Failed to destroy flow for port %u, \"\n+\t\t\t\t\t\"err msg: %s\\n\", port_id, err.message);\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n int32_t\n main(int32_t argc, char **argv)\n {\n@@ -2466,6 +2755,7 @@ main(int32_t argc, char **argv)\n \tuint8_t socket_id;\n \tuint16_t portid;\n \tuint64_t req_rx_offloads, req_tx_offloads;\n+\tstruct eh_conf *eh_conf = NULL;\n \tsize_t sess_sz;\n \n \t/* init EAL */\n@@ -2475,8 +2765,17 @@ main(int32_t argc, char **argv)\n \targc -= ret;\n \targv += ret;\n \n+\tforce_quit = false;\n+\tsignal(SIGINT, signal_handler);\n+\tsignal(SIGTERM, signal_handler);\n+\n+\t/* initialize event helper configuration */\n+\teh_conf = eh_conf_init();\n+\tif (eh_conf == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Failed to init event helper config\");\n+\n \t/* parse application arguments (after the EAL ones) */\n-\tret = parse_args(argc, argv);\n+\tret = parse_args(argc, argv, eh_conf);\n \tif (ret < 0)\n \t\trte_exit(EXIT_FAILURE, \"Invalid parameters\\n\");\n \n@@ -2592,12 +2891,43 @@ main(int32_t argc, char **argv)\n \n \tcheck_all_ports_link_status(enabled_port_mask);\n \n+\t/*\n+\t * Set the enabled port mask in helper config for use by helper\n+\t * sub-system. This will be used while intializing devices using\n+\t * helper sub-system.\n+\t */\n+\teh_conf->eth_portmask = enabled_port_mask;\n+\n+\t/* Initialize eventmode components */\n+\tret = eh_devs_init(eh_conf);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"eh_devs_init failed, err=%d\\n\", ret);\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(ipsec_launch_one_lcore, eh_conf, CALL_MASTER);\n+\n \tRTE_LCORE_FOREACH_SLAVE(lcore_id) {\n \t\tif (rte_eal_wait_lcore(lcore_id) < 0)\n \t\t\treturn -1;\n \t}\n \n+\t/* Uninitialize eventmode components */\n+\tret = eh_devs_uninit(eh_conf);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"eh_devs_uninit failed, err=%d\\n\", ret);\n+\n+\t/* Free eventmode configuration memory */\n+\teh_conf_uninit(eh_conf);\n+\n+\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\tif ((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 0;\n }\ndiff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h\nindex 28ff07d..0b9fc04 100644\n--- a/examples/ipsec-secgw/ipsec.h\n+++ b/examples/ipsec-secgw/ipsec.h\n@@ -247,6 +247,13 @@ struct ipsec_traffic {\n \tstruct traffic_type ip6;\n };\n \n+\n+void\n+ipsec_poll_mode_worker(void);\n+\n+int\n+ipsec_launch_one_lcore(void *args);\n+\n uint16_t\n ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n \t\tuint16_t nb_pkts, uint16_t len);\ndiff --git a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec-secgw/ipsec_worker.c\nnew file mode 100644\nindex 0000000..87c657b\n--- /dev/null\n+++ b/examples/ipsec-secgw/ipsec_worker.c\n@@ -0,0 +1,180 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2016 Intel Corporation\n+ * Copyright (C) 2019 Marvell International Ltd.\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 <stdbool.h>\n+\n+#include <rte_common.h>\n+#include <rte_log.h>\n+#include <rte_memcpy.h>\n+#include <rte_atomic.h>\n+#include <rte_cycles.h>\n+#include <rte_prefetch.h>\n+#include <rte_lcore.h>\n+#include <rte_branch_prediction.h>\n+#include <rte_event_eth_tx_adapter.h>\n+#include <rte_ether.h>\n+#include <rte_ethdev.h>\n+#include <rte_eventdev.h>\n+#include <rte_malloc.h>\n+#include <rte_mbuf.h>\n+\n+#include \"ipsec.h\"\n+#include \"event_helper.h\"\n+\n+extern volatile bool force_quit;\n+\n+static inline void\n+ipsec_event_pre_forward(struct rte_mbuf *m, unsigned int port_id)\n+{\n+\t/* Save the destination port in the mbuf */\n+\tm->port = port_id;\n+\n+\t/* Save eth queue for Tx */\n+\trte_event_eth_tx_adapter_txq_set(m, 0);\n+}\n+\n+/*\n+ * Event mode exposes various operating modes depending on the\n+ * capabilities of the event device and the operating mode\n+ * selected.\n+ */\n+\n+/* Workers registered */\n+#define IPSEC_EVENTMODE_WORKERS\t\t1\n+\n+/*\n+ * Event mode worker\n+ * Operating parameters : non-burst - Tx internal port - driver mode - inbound\n+ */\n+static void\n+ipsec_wrkr_non_burst_int_port_drvr_mode_inb(struct eh_event_link_info *links,\n+\t\tuint8_t nb_links)\n+{\n+\tunsigned int nb_rx = 0;\n+\tstruct rte_mbuf *pkt;\n+\tunsigned int port_id;\n+\tstruct rte_event ev;\n+\tuint32_t lcore_id;\n+\n+\t/* Check if we have links registered for this lcore */\n+\tif (nb_links == 0) {\n+\t\t/* No links registered - exit */\n+\t\tgoto exit;\n+\t}\n+\n+\t/* Get core ID */\n+\tlcore_id = rte_lcore_id();\n+\n+\tRTE_LOG(INFO, IPSEC,\n+\t\t\"Launching event mode worker (non-burst - Tx internal port - \"\n+\t\t\"driver mode - inbound) on lcore %d\\n\", lcore_id);\n+\n+\t/* We have valid links */\n+\n+\t/* Check if it's single link */\n+\tif (nb_links != 1) {\n+\t\tRTE_LOG(INFO, IPSEC,\n+\t\t\t\"Multiple links not supported. Using first link\\n\");\n+\t}\n+\n+\tRTE_LOG(INFO, IPSEC, \" -- lcoreid=%u event_port_id=%u\\n\", lcore_id,\n+\t\t\tlinks[0].event_port_id);\n+\twhile (!force_quit) {\n+\t\t/* Read packet from event queues */\n+\t\tnb_rx = rte_event_dequeue_burst(links[0].eventdev_id,\n+\t\t\t\tlinks[0].event_port_id,\n+\t\t\t\t&ev,\t/* events */\n+\t\t\t\t1,\t/* nb_events */\n+\t\t\t\t0\t/* timeout_ticks */);\n+\n+\t\tif (nb_rx == 0)\n+\t\t\tcontinue;\n+\n+\t\tport_id = ev.queue_id;\n+\t\tpkt = ev.mbuf;\n+\n+\t\trte_prefetch0(rte_pktmbuf_mtod(pkt, void *));\n+\n+\t\t/* Process packet */\n+\t\tipsec_event_pre_forward(pkt, port_id);\n+\n+\t\t/*\n+\t\t * Since tx internal port is available, events can be\n+\t\t * directly enqueued to the adapter and it would be\n+\t\t * internally submitted to the eth device.\n+\t\t */\n+\t\trte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,\n+\t\t\t\tlinks[0].event_port_id,\n+\t\t\t\t&ev,\t/* events */\n+\t\t\t\t1,\t/* nb_events */\n+\t\t\t\t0\t/* flags */);\n+\t}\n+\n+exit:\n+\treturn;\n+}\n+\n+static uint8_t\n+ipsec_eventmode_populate_wrkr_params(struct eh_app_worker_params *wrkrs)\n+{\n+\tstruct eh_app_worker_params *wrkr;\n+\tuint8_t nb_wrkr_param = 0;\n+\n+\t/* Save workers */\n+\twrkr = wrkrs;\n+\n+\t/* Non-burst - Tx internal port - driver mode - inbound */\n+\twrkr->cap.burst = EH_RX_TYPE_NON_BURST;\n+\twrkr->cap.tx_internal_port = EH_TX_TYPE_INTERNAL_PORT;\n+\twrkr->cap.ipsec_mode = EH_IPSEC_MODE_TYPE_DRIVER;\n+\twrkr->cap.ipsec_dir = EH_IPSEC_DIR_TYPE_INBOUND;\n+\twrkr->worker_thread = ipsec_wrkr_non_burst_int_port_drvr_mode_inb;\n+\n+\tnb_wrkr_param++;\n+\treturn nb_wrkr_param;\n+}\n+\n+static void\n+ipsec_eventmode_worker(struct eh_conf *conf)\n+{\n+\tstruct eh_app_worker_params ipsec_wrkr[IPSEC_EVENTMODE_WORKERS] = {\n+\t\t\t\t\t{{{0} }, NULL } };\n+\tuint8_t nb_wrkr_param;\n+\n+\t/* Populate l2fwd_wrkr params */\n+\tnb_wrkr_param = ipsec_eventmode_populate_wrkr_params(ipsec_wrkr);\n+\n+\t/*\n+\t * Launch correct worker after checking\n+\t * the event device's capabilities.\n+\t */\n+\teh_launch_worker(conf, ipsec_wrkr, nb_wrkr_param);\n+}\n+\n+int ipsec_launch_one_lcore(void *args)\n+{\n+\tstruct eh_conf *conf;\n+\n+\tconf = (struct eh_conf *)args;\n+\n+\tif (conf->mode == EH_PKT_TRANSFER_MODE_POLL) {\n+\t\t/* Run in poll mode */\n+\t\tipsec_poll_mode_worker();\n+\t} else if (conf->mode == EH_PKT_TRANSFER_MODE_EVENT) {\n+\t\t/* Run in event mode */\n+\t\tipsec_eventmode_worker(conf);\n+\t}\n+\treturn 0;\n+}\ndiff --git a/examples/ipsec-secgw/meson.build b/examples/ipsec-secgw/meson.build\nindex 20f4064..ab40ca5 100644\n--- a/examples/ipsec-secgw/meson.build\n+++ b/examples/ipsec-secgw/meson.build\n@@ -10,5 +10,5 @@ deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev']\n allow_experimental_apis = true\n sources = files(\n \t'esp.c', 'ipsec.c', 'ipsec_process.c', 'ipsec-secgw.c',\n-\t'parser.c', 'rt.c', 'sa.c', 'sp4.c', 'sp6.c', 'event_helper.c'\n+\t'parser.c', 'rt.c', 'sa.c', 'sp4.c', 'sp6.c', 'event_helper.c', 'ipsec_worker.c'\n )\n",
    "prefixes": [
        "09/14"
    ]
}