get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 66107,
    "url": "http://patches.dpdk.org/api/patches/66107/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1582820317-7333-11-git-send-email-lbartosik@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": "<1582820317-7333-11-git-send-email-lbartosik@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1582820317-7333-11-git-send-email-lbartosik@marvell.com",
    "date": "2020-02-27T16:18:32",
    "name": "[v5,10/15] examples/ipsec-secgw: add eventmode to ipsec-secgw",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "c07a101dbb1d89dc019150e5301bb6811551c4e7",
    "submitter": {
        "id": 1305,
        "url": "http://patches.dpdk.org/api/people/1305/?format=api",
        "name": "Lukas Bartosik [C]",
        "email": "lbartosik@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/1582820317-7333-11-git-send-email-lbartosik@marvell.com/mbox/",
    "series": [
        {
            "id": 8713,
            "url": "http://patches.dpdk.org/api/series/8713/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8713",
            "date": "2020-02-27T16:18:22",
            "name": "add eventmode to ipsec-secgw",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/8713/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/66107/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/66107/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 4FC19A055F;\n\tThu, 27 Feb 2020 17:20:52 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B6CFA1C024;\n\tThu, 27 Feb 2020 17:19:18 +0100 (CET)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 0BD731C01F\n for <dev@dpdk.org>; Thu, 27 Feb 2020 17:19:14 +0100 (CET)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n 01RFttcm011386; Thu, 27 Feb 2020 08:19:14 -0800",
            "from sc-exch04.marvell.com ([199.233.58.184])\n by mx0a-0016f401.pphosted.com with ESMTP id 2ydcm19hb9-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Thu, 27 Feb 2020 08:19:14 -0800",
            "from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com\n (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 27 Feb\n 2020 08:19:12 -0800",
            "from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com\n (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Thu, 27 Feb 2020 08:19:12 -0800",
            "from luke.marvell.com (unknown [10.95.130.81])\n by maili.marvell.com (Postfix) with ESMTP id B23A13F703F;\n Thu, 27 Feb 2020 08:19:09 -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-type; s=pfpt0818; bh=juaDo11IUX09LA29St0jNjkXpA1qgVe8G5ofpTGXnH0=;\n b=X+GLlfNt+Uz2mTrOjM1HQMkee4oVd3LAxWwQQt9QxQ7UQVELkIo5TbHc0XocS8EPK5ro\n wKJT8lP6wWeBSHU57UtmvvjGFnOfZKev1pU4Z/HJdmHbUPx5GWzrBGPuaWPHvD3fXhpb\n 8UHqdAgTEa56eJYmpqs7Lk9UDLGTc5U9sCVMtLdQCw1fbl3jadHo+IBD+NuPeIVZvj5q\n Z5sPlK9rtmtZeGMAqZIjkggnYz+4FbAHVlePrwo6FQPcrVTeknAQHMPavL9ZMVrT1V6X\n T1XrrV5vFhkAK/iRRsDJ9vwdp8DR1kGJ1cf3isUNOUdB3OLBDrAcDi2TzEX/hkjRdw88 eA==",
        "From": "Lukasz Bartosik <lbartosik@marvell.com>",
        "To": "Akhil Goyal <akhil.goyal@nxp.com>, Radu Nicolau <radu.nicolau@intel.com>,\n Thomas Monjalon <thomas@monjalon.net>",
        "CC": "Jerin Jacob <jerinj@marvell.com>, Narayana Prasad <pathreya@marvell.com>,\n Ankur Dwivedi <adwivedi@marvell.com>, Anoob Joseph <anoobj@marvell.com>,\n Archana Muniganti <marchana@marvell.com>, Tejasree Kondoj\n <ktejasree@marvell.com>, Vamsi Attunuru <vattunuru@marvell.com>,\n \"Konstantin Ananyev\" <konstantin.ananyev@intel.com>, <dev@dpdk.org>",
        "Date": "Thu, 27 Feb 2020 17:18:32 +0100",
        "Message-ID": "<1582820317-7333-11-git-send-email-lbartosik@marvell.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1582820317-7333-1-git-send-email-lbartosik@marvell.com>",
        "References": "<1582185727-6749-1-git-send-email-lbartosik@marvell.com>\n <1582820317-7333-1-git-send-email-lbartosik@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572\n definitions=2020-02-27_05:2020-02-26,\n 2020-02-27 signatures=0",
        "Subject": "[dpdk-dev] [PATCH v5 10/15] 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": "Add eventmode support to ipsec-secgw. With the aid of event helper\nconfigure and use the eventmode capabilities.\n\nSigned-off-by: Anoob Joseph <anoobj@marvell.com>\nSigned-off-by: Lukasz Bartosik <lbartosik@marvell.com>\n---\n examples/ipsec-secgw/event_helper.c |   3 +\n examples/ipsec-secgw/event_helper.h |  14 ++\n examples/ipsec-secgw/ipsec-secgw.c  | 301 +++++++++++++++++++++++++++++++++++-\n examples/ipsec-secgw/ipsec.h        |  24 +++\n examples/ipsec-secgw/sa.c           |  21 +--\n examples/ipsec-secgw/sad.h          |   5 -\n 6 files changed, 340 insertions(+), 28 deletions(-)",
    "diff": "diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/event_helper.c\nindex 0854fc2..076f1f2 100644\n--- a/examples/ipsec-secgw/event_helper.c\n+++ b/examples/ipsec-secgw/event_helper.c\n@@ -960,6 +960,8 @@ 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+\n \t/* Parse the passed list and see if we have matching capabilities */\n \n \t/* Initialize the pointer used to traverse the list */\n@@ -1400,6 +1402,7 @@ eh_conf_init(void)\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 \n \t/* Keep all ethernet ports enabled by default */\n \tconf->eth_portmask = -1;\ndiff --git a/examples/ipsec-secgw/event_helper.h b/examples/ipsec-secgw/event_helper.h\nindex e17cab1..b65b343 100644\n--- a/examples/ipsec-secgw/event_helper.h\n+++ b/examples/ipsec-secgw/event_helper.h\n@@ -73,6 +73,14 @@ 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 /* Event dev params */\n struct eventdev_params {\n \tuint8_t eventdev_id;\n@@ -182,6 +190,10 @@ 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 };\n \n /* Workers registered by the application */\n@@ -193,6 +205,8 @@ 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};\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 e1ee7c3..0f692d7 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,9 +15,11 @@\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+#include <rte_bitmap.h>\n #include <rte_byteorder.h>\n #include <rte_log.h>\n #include <rte_eal.h>\n@@ -41,13 +44,17 @@\n #include <rte_jhash.h>\n #include <rte_cryptodev.h>\n #include <rte_security.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 #include \"sad.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@@ -134,12 +141,20 @@ 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\"event-schedule-type\"\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_EVENT\t\"event\"\n+#define CMD_LINE_ARG_POLL\t\"poll\"\n+#define CMD_LINE_ARG_ORDERED\t\"ordered\"\n+#define CMD_LINE_ARG_ATOMIC\t\"atomic\"\n+#define CMD_LINE_ARG_PARALLEL\t\"parallel\"\n+\n enum {\n \t/* long options mapped to a short option */\n \n@@ -150,6 +165,8 @@ 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_TX_OFFLOAD_NUM,\n \tCMD_LINE_OPT_REASSEMBLE_NUM,\n@@ -161,6 +178,8 @@ 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_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@@ -1199,13 +1218,19 @@ main_loop(__attribute__((unused)) void *dummy)\n }\n \n static int32_t\n-check_params(void)\n+check_poll_mode_params(struct eh_conf *eh_conf)\n {\n \tuint8_t lcore;\n \tuint16_t portid;\n \tuint16_t i;\n \tint32_t socket_id;\n \n+\tif (!eh_conf)\n+\t\treturn -EINVAL;\n+\n+\tif (eh_conf->mode != EH_PKT_TRANSFER_MODE_POLL)\n+\t\treturn 0;\n+\n \tif (lcore_params == NULL) {\n \t\tprintf(\"Error: No port/queue/core mappings\\n\");\n \t\treturn -1;\n@@ -1292,6 +1317,8 @@ 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\" [--event-schedule-type TYPE]\"\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@@ -1310,11 +1337,24 @@ print_usage(const char *prgname)\n \t\t\"  -c specifies inbound SAD cache size,\\n\"\n \t\t\"     zero value disables the cache (default value: 128)\\n\"\n \t\t\"  -f CONFIG_FILE: Configuration file\\n\"\n-\t\t\"  --config (port,queue,lcore): Rx queue configuration\\n\"\n+\t\t\"  --config (port,queue,lcore): Rx queue configuration. In poll\\n\"\n+\t\t\"                               mode determines which queues from\\n\"\n+\t\t\"                               which ports are mapped to which cores.\\n\"\n+\t\t\"                               In event mode this option is not used\\n\"\n+\t\t\"                               as packets are dynamically scheduled\\n\"\n+\t\t\"                               to cores by HW.\\n\"\n \t\t\"  --single-sa SAIDX: Use single SA index for outbound traffic,\\n\"\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\"               \\\"poll\\\"  : Packet transfer via polling (default)\\n\"\n+\t\t\"               \\\"event\\\" : Packet transfer via event device\\n\"\n+\t\t\"  --event-schedule-type TYPE queue schedule type, used only when\\n\"\n+\t\t\"                             transfer mode is set to event\\n\"\n+\t\t\"               \\\"ordered\\\"  : Ordered (default)\\n\"\n+\t\t\"               \\\"atomic\\\"   : Atomic\\n\"\n+\t\t\"               \\\"parallel\\\" : Parallel\\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@@ -1449,8 +1489,45 @@ print_app_sa_prm(const struct app_sa_prm *prm)\n \tprintf(\"Frag TTL: %\" PRIu64 \" ns\\n\", frag_ttl_ns);\n }\n \n+static int\n+parse_transfer_mode(struct eh_conf *conf, const char *optarg)\n+{\n+\tif (!strcmp(CMD_LINE_ARG_POLL, optarg))\n+\t\tconf->mode = EH_PKT_TRANSFER_MODE_POLL;\n+\telse if (!strcmp(CMD_LINE_ARG_EVENT, optarg))\n+\t\tconf->mode = EH_PKT_TRANSFER_MODE_EVENT;\n+\telse {\n+\t\tprintf(\"Unsupported packet transfer mode\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\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+\n+\t/* Get eventmode conf */\n+\tem_conf = conf->mode_params;\n+\n+\tif (!strcmp(CMD_LINE_ARG_ORDERED, optarg))\n+\t\tem_conf->ext_params.sched_type = RTE_SCHED_TYPE_ORDERED;\n+\telse if (!strcmp(CMD_LINE_ARG_ATOMIC, optarg))\n+\t\tem_conf->ext_params.sched_type = RTE_SCHED_TYPE_ATOMIC;\n+\telse if (!strcmp(CMD_LINE_ARG_PARALLEL, optarg))\n+\t\tem_conf->ext_params.sched_type = RTE_SCHED_TYPE_PARALLEL;\n+\telse {\n+\t\tprintf(\"Unsupported queue schedule type\\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)\n+parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf)\n {\n \tint opt;\n \tint64_t ret;\n@@ -1548,6 +1625,7 @@ parse_args(int32_t argc, char **argv)\n \t\t\t/* else */\n \t\t\tsingle_sa = 1;\n \t\t\tsingle_sa_idx = ret;\n+\t\t\teh_conf->ipsec_mode = EH_IPSEC_MODE_TYPE_DRIVER;\n \t\t\tprintf(\"Configured with single SA index %u\\n\",\n \t\t\t\t\tsingle_sa_idx);\n \t\t\tbreak;\n@@ -1562,6 +1640,25 @@ 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_RX_OFFLOAD_NUM:\n \t\t\tret = parse_mask(optarg, &dev_rx_offload);\n \t\t\tif (ret != 0) {\n@@ -2476,16 +2573,141 @@ create_default_ipsec_flow(uint16_t port_id, uint64_t rx_offloads)\n \t\tport_id);\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+static void\n+ev_mode_sess_verify(struct ipsec_sa *sa, int nb_sa)\n+{\n+\tstruct rte_ipsec_session *ips;\n+\tint32_t i;\n+\n+\tif (!sa || !nb_sa)\n+\t\treturn;\n+\n+\tfor (i = 0; i < nb_sa; i++) {\n+\t\tips = ipsec_get_primary_session(&sa[i]);\n+\t\tif (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL)\n+\t\t\trte_exit(EXIT_FAILURE, \"Event mode supports only \"\n+\t\t\t\t \"inline protocol sessions\\n\");\n+\t}\n+\n+}\n+\n+static int32_t\n+check_event_mode_params(struct eh_conf *eh_conf)\n+{\n+\tstruct eventmode_conf *em_conf = NULL;\n+\tstruct lcore_params *params;\n+\tuint16_t portid;\n+\n+\tif (!eh_conf || !eh_conf->mode_params)\n+\t\treturn -EINVAL;\n+\n+\t/* Get eventmode conf */\n+\tem_conf = eh_conf->mode_params;\n+\n+\tif (eh_conf->mode == EH_PKT_TRANSFER_MODE_POLL &&\n+\t    em_conf->ext_params.sched_type != SCHED_TYPE_NOT_SET) {\n+\t\tprintf(\"error: option --event-schedule-type applies only to \"\n+\t\t       \"event mode\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (eh_conf->mode != EH_PKT_TRANSFER_MODE_EVENT)\n+\t\treturn 0;\n+\n+\t/* Set schedule type to ORDERED if it wasn't explicitly set by user */\n+\tif (em_conf->ext_params.sched_type == SCHED_TYPE_NOT_SET)\n+\t\tem_conf->ext_params.sched_type = RTE_SCHED_TYPE_ORDERED;\n+\n+\t/*\n+\t * Event mode currently supports only inline protocol sessions.\n+\t * If there are other types of sessions configured then exit with\n+\t * error.\n+\t */\n+\tev_mode_sess_verify(sa_in, nb_sa_in);\n+\tev_mode_sess_verify(sa_out, nb_sa_out);\n+\n+\n+\t/* Option --config does not apply to event mode */\n+\tif (nb_lcore_params > 0) {\n+\t\tprintf(\"error: option --config applies only to poll mode\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/*\n+\t * In order to use the same port_init routine for both poll and event\n+\t * modes initialize lcore_params with one queue for each eth port\n+\t */\n+\tlcore_params = lcore_params_array;\n+\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\tif ((enabled_port_mask & (1 << portid)) == 0)\n+\t\t\tcontinue;\n+\n+\t\tparams = &lcore_params[nb_lcore_params++];\n+\t\tparams->port_id = portid;\n+\t\tparams->queue_id = 0;\n+\t\tparams->lcore_id = 0;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void\n+inline_sessions_free(struct sa_ctx *sa_ctx)\n+{\n+\tstruct rte_ipsec_session *ips;\n+\tstruct ipsec_sa *sa;\n+\tint32_t ret;\n+\tuint32_t i;\n+\n+\tif (!sa_ctx)\n+\t\treturn;\n+\n+\tfor (i = 0; i < sa_ctx->nb_sa; i++) {\n+\n+\t\tsa = &sa_ctx->sa[i];\n+\t\tif (!sa->spi)\n+\t\t\tcontinue;\n+\n+\t\tips = ipsec_get_primary_session(sa);\n+\t\tif (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL &&\n+\t\t    ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)\n+\t\t\tcontinue;\n+\n+\t\tif (!rte_eth_dev_is_valid_port(sa->portid))\n+\t\t\tcontinue;\n+\n+\t\tret = rte_security_session_destroy(\n+\t\t\t\trte_eth_dev_get_sec_ctx(sa->portid),\n+\t\t\t\tips->security.ses);\n+\t\tif (ret)\n+\t\t\tRTE_LOG(ERR, IPSEC, \"Failed to destroy security \"\n+\t\t\t\t\t    \"session type %d, spi %d\\n\",\n+\t\t\t\t\t    ips->type, sa->spi);\n+\t}\n+}\n+\n int32_t\n main(int32_t argc, char **argv)\n {\n \tint32_t ret;\n \tuint32_t lcore_id;\n+\tuint32_t cdev_id;\n \tuint32_t i;\n \tuint8_t socket_id;\n \tuint16_t portid;\n \tuint64_t req_rx_offloads[RTE_MAX_ETHPORTS];\n \tuint64_t req_tx_offloads[RTE_MAX_ETHPORTS];\n+\tstruct eh_conf *eh_conf = NULL;\n \tsize_t sess_sz;\n \n \t/* init EAL */\n@@ -2495,8 +2717,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@@ -2513,8 +2744,11 @@ main(int32_t argc, char **argv)\n \t\trte_exit(EXIT_FAILURE, \"Invalid unprotected portmask 0x%x\\n\",\n \t\t\t\tunprotected_port_mask);\n \n-\tif (check_params() < 0)\n-\t\trte_exit(EXIT_FAILURE, \"check_params failed\\n\");\n+\tif (check_poll_mode_params(eh_conf) < 0)\n+\t\trte_exit(EXIT_FAILURE, \"check_poll_mode_params failed\\n\");\n+\n+\tif (check_event_mode_params(eh_conf) < 0)\n+\t\trte_exit(EXIT_FAILURE, \"check_event_mode_params failed\\n\");\n \n \tret = init_lcore_rx_queues();\n \tif (ret < 0)\n@@ -2555,6 +2789,18 @@ main(int32_t argc, char **argv)\n \n \tcryptodevs_init();\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 initializing 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/* start ports */\n \tRTE_ETH_FOREACH_DEV(portid) {\n \t\tif ((enabled_port_mask & (1 << portid)) == 0)\n@@ -2614,5 +2860,48 @@ main(int32_t argc, char **argv)\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+\t/* Destroy inline inbound and outbound sessions */\n+\tfor (i = 0; i < NB_SOCKETS && i < rte_socket_count(); i++) {\n+\t\tsocket_id = rte_socket_id_by_idx(i);\n+\t\tinline_sessions_free(socket_ctx[socket_id].sa_in);\n+\t\tinline_sessions_free(socket_ctx[socket_id].sa_out);\n+\t}\n+\n+\tfor (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {\n+\t\tprintf(\"Closing cryptodev %d...\", cdev_id);\n+\t\trte_cryptodev_stop(cdev_id);\n+\t\trte_cryptodev_close(cdev_id);\n+\t\tprintf(\" Done\\n\");\n+\t}\n+\n+\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\tif ((enabled_port_mask & (1 << portid)) == 0)\n+\t\t\tcontinue;\n+\n+\t\tprintf(\"Closing port %d...\", portid);\n+\t\tif (flow_info_tbl[portid].rx_def_flow) {\n+\t\t\tstruct rte_flow_error err;\n+\n+\t\t\tret = rte_flow_destroy(portid,\n+\t\t\t\tflow_info_tbl[portid].rx_def_flow, &err);\n+\t\t\tif (ret)\n+\t\t\t\tRTE_LOG(ERR, IPSEC, \"Failed to destroy flow \"\n+\t\t\t\t\t\" for port %u, err msg: %s\\n\", portid,\n+\t\t\t\t\terr.message);\n+\t\t}\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 8f5d382..ec3d60b 100644\n--- a/examples/ipsec-secgw/ipsec.h\n+++ b/examples/ipsec-secgw/ipsec.h\n@@ -159,6 +159,24 @@ struct ipsec_sa {\n \tstruct rte_security_session_conf sess_conf;\n } __rte_cache_aligned;\n \n+struct ipsec_xf {\n+\tstruct rte_crypto_sym_xform a;\n+\tstruct rte_crypto_sym_xform b;\n+};\n+\n+struct ipsec_sad {\n+\tstruct rte_ipsec_sad *sad_v4;\n+\tstruct rte_ipsec_sad *sad_v6;\n+};\n+\n+struct sa_ctx {\n+\tvoid *satbl; /* pointer to array of rte_ipsec_sa objects*/\n+\tstruct ipsec_sad sad;\n+\tstruct ipsec_xf *xf;\n+\tuint32_t nb_sa;\n+\tstruct ipsec_sa sa[];\n+};\n+\n struct ipsec_mbuf_metadata {\n \tstruct ipsec_sa *sa;\n \tstruct rte_crypto_op cop;\n@@ -253,6 +271,12 @@ struct ipsec_traffic {\n \tstruct traffic_type ip6;\n };\n \n+extern struct ipsec_sa *sa_out;\n+extern uint32_t nb_sa_out;\n+\n+extern struct ipsec_sa *sa_in;\n+extern uint32_t nb_sa_in;\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/sa.c b/examples/ipsec-secgw/sa.c\nindex 4822d6b..0eb52d1 100644\n--- a/examples/ipsec-secgw/sa.c\n+++ b/examples/ipsec-secgw/sa.c\n@@ -135,14 +135,14 @@ const struct supported_aead_algo aead_algos[] = {\n \n #define SA_INIT_NB\t128\n \n-static struct ipsec_sa *sa_out;\n+struct ipsec_sa *sa_out;\n+uint32_t nb_sa_out;\n static uint32_t sa_out_sz;\n-static uint32_t nb_sa_out;\n static struct ipsec_sa_cnt sa_out_cnt;\n \n-static struct ipsec_sa *sa_in;\n+struct ipsec_sa *sa_in;\n+uint32_t nb_sa_in;\n static uint32_t sa_in_sz;\n-static uint32_t nb_sa_in;\n static struct ipsec_sa_cnt sa_in_cnt;\n \n static const struct supported_cipher_algo *\n@@ -826,19 +826,6 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound)\n \tprintf(\"\\n\");\n }\n \n-struct ipsec_xf {\n-\tstruct rte_crypto_sym_xform a;\n-\tstruct rte_crypto_sym_xform b;\n-};\n-\n-struct sa_ctx {\n-\tvoid *satbl; /* pointer to array of rte_ipsec_sa objects*/\n-\tstruct ipsec_sad sad;\n-\tstruct ipsec_xf *xf;\n-\tuint32_t nb_sa;\n-\tstruct ipsec_sa sa[];\n-};\n-\n static struct sa_ctx *\n sa_create(const char *name, int32_t socket_id, uint32_t nb_sa)\n {\ndiff --git a/examples/ipsec-secgw/sad.h b/examples/ipsec-secgw/sad.h\nindex 55712ba..473aaa9 100644\n--- a/examples/ipsec-secgw/sad.h\n+++ b/examples/ipsec-secgw/sad.h\n@@ -18,11 +18,6 @@ struct ipsec_sad_cache {\n \n RTE_DECLARE_PER_LCORE(struct ipsec_sad_cache, sad_cache);\n \n-struct ipsec_sad {\n-\tstruct rte_ipsec_sad *sad_v4;\n-\tstruct rte_ipsec_sad *sad_v6;\n-};\n-\n int ipsec_sad_create(const char *name, struct ipsec_sad *sad,\n \tint socket_id, struct ipsec_sa_cnt *sa_cnt);\n \n",
    "prefixes": [
        "v5",
        "10/15"
    ]
}