From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 51EB8A052F; Thu, 30 Jan 2020 00:31:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 28EB61BFEA; Thu, 30 Jan 2020 00:31:20 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id B1DFF1BFE1 for ; Thu, 30 Jan 2020 00:31:17 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2020 15:31:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,379,1574150400"; d="scan'208";a="229773742" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by orsmga003.jf.intel.com with ESMTP; 29 Jan 2020 15:31:16 -0800 Received: from orsmsx161.amr.corp.intel.com (10.22.240.84) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Jan 2020 15:31:15 -0800 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX161.amr.corp.intel.com (10.22.240.84) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Jan 2020 15:31:15 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.177) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Jan 2020 15:31:15 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IUyEBcV0J8UJjlEw2XLDA5SMVS0zSVCasDb7ZPEfLhiXeKY5rA06N/TJL4dLN3YuxD5q1aUhfopO7vIfA7oJwmWcKnw9QFuHQn6ykE3NefU/GcRaT7EboUFE5ps6qp6L/0qEM5zTNYwGuwZSp98q0P6IEa8c8flg0kpe8VomL+klnbxQK7hNRgwBMSWztWIbFkEbQoWCen+9/R96splFroiGIMu8PHa6qXBEQhZbsbRhdSUmN8vlDXVpwUr1jk0mLgw93YqdS6jwFznU++2p4h5inb+J4ctw0B8DPHYgaYWvyY+5Jk9VeZv6ZlLk5rzr02Zd38oXaPgYLwEXF+cvhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z2Z4sbA/47zKA5efJRYz8lFolQH1c7DzaYvLBpyEIHE=; b=GNNRQfKpaI1NMMrKjQnYxnh8dPGtytu4e8Lk7gzrrnHwWCt5Eou4uGyGT6SREk1CA9U7VPDE5kTi04NpidYSMSJ8jMLeJPUkcjhp5phefJJQjCGqGFMlnNjCwd3u/RVVJFnQmEQByeCU8bJUZALpTeVgPO4rxnD5Fh17s4ObLGSIXk+2ldIf9J1qwBzZdsKrgVVR/BlzQ0Jx3eaw8SmiovdVjzZXZWGiLOxIhxDMpGpRRPdLk89duYBrhVQCH4AoHdS1tKjMgRmaeTX08ZgTaxTVKeEQxDO8h2hOTHkS4MN5Ma2o2x8XOfWGwRZNHcJlHtke/Bjc2FDCDMiM6BRKjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z2Z4sbA/47zKA5efJRYz8lFolQH1c7DzaYvLBpyEIHE=; b=VO0YrtB2i2n5X+0mCXG4vR/2AMXgOzQrYHooL68aqv6RoBxQWlqQsh8Uig3LWUYCz6oh9tpmLtzLxwgynk/0/cbKmXsCHNMPhOdHbqEHdKIT+fXSPZluHmxbGHFHcr7kH2Jhf5mA8DfL2TMxJkwk0PPZcZ59pD/0rMWWBJpxcNw= Received: from SN6PR11MB2558.namprd11.prod.outlook.com (52.135.94.19) by SN6PR11MB2813.namprd11.prod.outlook.com (52.135.96.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.24; Wed, 29 Jan 2020 23:31:13 +0000 Received: from SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386]) by SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386%7]) with mapi id 15.20.2665.027; Wed, 29 Jan 2020 23:31:13 +0000 From: "Ananyev, Konstantin" To: Anoob Joseph , Akhil Goyal , "Nicolau, Radu" , Thomas Monjalon CC: Lukasz Bartosik , Jerin Jacob , Narayana Prasad , Ankur Dwivedi , Archana Muniganti , Tejasree Kondoj , Vamsi Attunuru , "dev@dpdk.org" Thread-Topic: [PATCH v2 09/12] examples/ipsec-secgw: add eventmode to ipsec-secgw Thread-Index: AQHVz5gZn6bh5pDpb0+eIC4h2LPsT6gCUFNw Date: Wed, 29 Jan 2020 23:31:12 +0000 Message-ID: References: <1575808249-31135-1-git-send-email-anoobj@marvell.com> <1579527918-360-1-git-send-email-anoobj@marvell.com> <1579527918-360-10-git-send-email-anoobj@marvell.com> In-Reply-To: <1579527918-360-10-git-send-email-anoobj@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmYwMDQ1OTAtMWZmNy00YWMzLThhMzUtZWFmMWZjY2U0MTE2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMFJ3K2ozRHVHOU1iNzJkZzRNdkpCWm8xd3BJRjdFQ0hQSXlQNGpqTGlrNktDdWVGYUdnVFN3SlFDN3BoNU1TZSJ9 dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 x-ctpclassification: CTP_NT authentication-results: spf=none (sender IP is ) smtp.mailfrom=konstantin.ananyev@intel.com; x-originating-ip: [192.198.151.187] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f283c370-8c95-4869-d20f-08d7a513542c x-ms-traffictypediagnostic: SN6PR11MB2813: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:317; x-forefront-prvs: 02973C87BC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(199004)(189003)(30864003)(71200400001)(186003)(2906002)(86362001)(4326008)(110136005)(52536014)(26005)(33656002)(6506007)(7416002)(9686003)(7696005)(498600001)(54906003)(66556008)(66476007)(64756008)(66446008)(66946007)(76116006)(8676002)(8936002)(5660300002)(55016002)(81156014)(81166006)(579004); DIR:OUT; SFP:1102; SCL:1; SRVR:SN6PR11MB2813; H:SN6PR11MB2558.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: V41vHZC6H4FmsgzQXzAekhGsFkPvkTPpuajWJbtBiqlYsjbm72BE3BFZKId0LdEN7FTIxgxjH37Vb3i01RXAH/e8mo7+w4VOEhbaaQL1XxBodhO3aPT3Lquf9sf92jCG8xlxsPeAPPdHsB+bwki66bmwxYNKmw2ujSdOzjXEGcstXFMt0sG+3Lz4WzIXqjwsKWnDdJsdNQDHL54zTgpG9DzT+EL+st+ruwz9EfR5D24VlKo61arwgKGpQO8/u5qOfB9fN6nhW0KLhZC1itW6yGA2s3kjpNaxMNkiiazI/rrHdvBJgjGuH9OWvejjLln6r1amdjigohbAyQU4anRokh2ktiJth0IJRgM/DVOq22NiWxUMmwTq3/3ZDCTbNAhOvZBJUBy8DIL3KXrYQPo+DZc6WELQOZfgvXYbBn3+tnmumdo06x8MSiu+FqDQFcU8 x-ms-exchange-antispam-messagedata: NTW4Gwjk1TmEGMT4kuDXblnCoSlDt8+MVSsdI9Xsj1gL0aCbcRSkvYCJ4JMKswh7kaD9Xf3o0QxVsBSWTgXwh7YikuDjtRaqZSIbozNPrh9iBjACZb5c633tDsaoov+yE5xgVXrUSvZf6vvCZ/cMuQ== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f283c370-8c95-4869-d20f-08d7a513542c X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2020 23:31:12.9410 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7bDAaUBA26c8xPgcEcTNe9J90Q2ZQZhEZTVbQM+QYkTpVO2Y3r4zg9iPHaZuHTxv/sZzHiZPEs83S8SIfJGS8Eq2I1/IuIOnEBb4DiR7lRE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2813 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 09/12] examples/ipsec-secgw: add eventmode to ipsec-secgw X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > Add eventmode support to ipsec-secgw. With the aid of event helper > configure and use the eventmode capabilities. >=20 > Signed-off-by: Anoob Joseph > Signed-off-by: Lukasz Bartosik > --- > examples/ipsec-secgw/event_helper.c | 4 +- > examples/ipsec-secgw/event_helper.h | 14 ++ > examples/ipsec-secgw/ipsec-secgw.c | 341 ++++++++++++++++++++++++++++++= +++++- > examples/ipsec-secgw/ipsec.h | 11 ++ > examples/ipsec-secgw/sa.c | 11 -- > 5 files changed, 365 insertions(+), 16 deletions(-) >=20 > diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/e= vent_helper.c > index 9719ab4..54a98c9 100644 > --- a/examples/ipsec-secgw/event_helper.c > +++ b/examples/ipsec-secgw/event_helper.c > @@ -966,6 +966,8 @@ eh_find_worker(uint32_t lcore_id, struct eh_conf *con= f, > else > curr_conf.cap.burst =3D EH_RX_TYPE_NON_BURST; >=20 > + curr_conf.cap.ipsec_mode =3D conf->ipsec_mode; > + > /* Parse the passed list and see if we have matching capabilities */ >=20 > /* Initialize the pointer used to traverse the list */ > @@ -1625,7 +1627,7 @@ eh_launch_worker(struct eh_conf *conf, struct eh_ap= p_worker_params *app_wrkr, > } >=20 > /* Get eventmode conf */ > - em_conf =3D (struct eventmode_conf *)(conf->mode_params); > + em_conf =3D conf->mode_params; >=20 > /* Get core ID */ > lcore_id =3D rte_lcore_id(); > diff --git a/examples/ipsec-secgw/event_helper.h b/examples/ipsec-secgw/e= vent_helper.h > index 15a7bd6..cf5d346 100644 > --- a/examples/ipsec-secgw/event_helper.h > +++ b/examples/ipsec-secgw/event_helper.h > @@ -74,6 +74,14 @@ enum eh_tx_types { > EH_TX_TYPE_NO_INTERNAL_PORT > }; >=20 > +/** > + * Event mode ipsec mode types > + */ > +enum eh_ipsec_mode_types { > + EH_IPSEC_MODE_TYPE_APP =3D 0, > + EH_IPSEC_MODE_TYPE_DRIVER > +}; > + > /* Event dev params */ > struct eventdev_params { > uint8_t eventdev_id; > @@ -183,6 +191,10 @@ struct eh_conf { > */ > void *mode_params; > /**< Mode specific parameters */ > + > + /** Application specific params */ > + enum eh_ipsec_mode_types ipsec_mode; > + /**< Mode of ipsec run */ > }; >=20 > /* Workers registered by the application */ > @@ -194,6 +206,8 @@ struct eh_app_worker_params { > /**< Specify status of rx type burst */ > uint64_t tx_internal_port : 1; > /**< Specify whether tx internal port is available */ > + uint64_t ipsec_mode : 1; > + /**< Specify ipsec processing level */ > }; > uint64_t u64; > } cap; > diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ip= sec-secgw.c > index d5e8fe5..f1cc3fb 100644 > --- a/examples/ipsec-secgw/ipsec-secgw.c > +++ b/examples/ipsec-secgw/ipsec-secgw.c > @@ -2,6 +2,7 @@ > * Copyright(c) 2016 Intel Corporation > */ >=20 > +#include > #include > #include > #include > @@ -14,6 +15,7 @@ > #include > #include > #include > +#include > #include >=20 > #include > @@ -41,12 +43,17 @@ > #include > #include > #include > +#include > +#include > #include > #include >=20 > +#include "event_helper.h" > #include "ipsec.h" > #include "parser.h" >=20 > +volatile bool force_quit; > + > #define RTE_LOGTYPE_IPSEC RTE_LOGTYPE_USER1 >=20 > #define MAX_JUMBO_PKT_LEN 9600 > @@ -133,12 +140,20 @@ struct flow_info flow_info_tbl[RTE_MAX_ETHPORTS]; > #define CMD_LINE_OPT_CONFIG "config" > #define CMD_LINE_OPT_SINGLE_SA "single-sa" > #define CMD_LINE_OPT_CRYPTODEV_MASK "cryptodev_mask" > +#define CMD_LINE_OPT_TRANSFER_MODE "transfer-mode" > +#define CMD_LINE_OPT_SCHEDULE_TYPE "schedule-type" > #define CMD_LINE_OPT_RX_OFFLOAD "rxoffload" > #define CMD_LINE_OPT_TX_OFFLOAD "txoffload" > #define CMD_LINE_OPT_REASSEMBLE "reassemble" > #define CMD_LINE_OPT_MTU "mtu" > #define CMD_LINE_OPT_FRAG_TTL "frag-ttl" >=20 > +#define CMD_LINE_ARG_EVENT "event" > +#define CMD_LINE_ARG_POLL "poll" > +#define CMD_LINE_ARG_ORDERED "ordered" > +#define CMD_LINE_ARG_ATOMIC "atomic" > +#define CMD_LINE_ARG_PARALLEL "parallel" > + > enum { > /* long options mapped to a short option */ >=20 > @@ -149,6 +164,8 @@ enum { > CMD_LINE_OPT_CONFIG_NUM, > CMD_LINE_OPT_SINGLE_SA_NUM, > CMD_LINE_OPT_CRYPTODEV_MASK_NUM, > + CMD_LINE_OPT_TRANSFER_MODE_NUM, > + CMD_LINE_OPT_SCHEDULE_TYPE_NUM, > CMD_LINE_OPT_RX_OFFLOAD_NUM, > CMD_LINE_OPT_TX_OFFLOAD_NUM, > CMD_LINE_OPT_REASSEMBLE_NUM, > @@ -160,6 +177,8 @@ static const struct option lgopts[] =3D { > {CMD_LINE_OPT_CONFIG, 1, 0, CMD_LINE_OPT_CONFIG_NUM}, > {CMD_LINE_OPT_SINGLE_SA, 1, 0, CMD_LINE_OPT_SINGLE_SA_NUM}, > {CMD_LINE_OPT_CRYPTODEV_MASK, 1, 0, CMD_LINE_OPT_CRYPTODEV_MASK_NUM}, > + {CMD_LINE_OPT_TRANSFER_MODE, 1, 0, CMD_LINE_OPT_TRANSFER_MODE_NUM}, > + {CMD_LINE_OPT_SCHEDULE_TYPE, 1, 0, CMD_LINE_OPT_SCHEDULE_TYPE_NUM}, > {CMD_LINE_OPT_RX_OFFLOAD, 1, 0, CMD_LINE_OPT_RX_OFFLOAD_NUM}, > {CMD_LINE_OPT_TX_OFFLOAD, 1, 0, CMD_LINE_OPT_TX_OFFLOAD_NUM}, > {CMD_LINE_OPT_REASSEMBLE, 1, 0, CMD_LINE_OPT_REASSEMBLE_NUM}, > @@ -177,6 +196,7 @@ static int32_t numa_on =3D 1; /**< NUMA is enabled by= default. */ > static uint32_t nb_lcores; > static uint32_t single_sa; > static uint32_t single_sa_idx; > +static uint32_t schedule_type; >=20 > /* > * RX/TX HW offload capabilities to enable/use on ethernet ports. > @@ -1185,7 +1205,7 @@ main_loop(__attribute__((unused)) void *dummy) > } >=20 > static int32_t > -check_params(void) > +check_params(struct eh_conf *eh_conf) > { > uint8_t lcore; > uint16_t portid; > @@ -1220,6 +1240,14 @@ check_params(void) > return -1; > } > } > + > + if (eh_conf->mode =3D=3D EH_PKT_TRANSFER_MODE_POLL) { > + if (schedule_type) { > + printf("error: option --schedule-type applies only to event mode\n"); > + return -1; > + } > + } As a nit - might be better to keep check_params() intact, and put this new check above into a separate function? check_eh_conf() or so? Another thing it seems a bit clumsy construction to have global var (schedu= ler_type) just to figure out was particular option present on command line or not. Probably simler way to avoid it - set initially em_conf->ext_params.sched_t= ype to some invalid value (-1 or so). Then after parse args you can check did its = value change or not. As alternative thought: wouldn't it be better to unite both --transfer-mod= e and --schedule-type options into one? Then possible values for this unite option would be: "poll" "event" (expands to "event-ordered") "event-ordered" "event-atomic" "event-parallel" And this situation you are checking above simply wouldn't be possible. Again probably would be easier/simpler for users. > + > return 0; > } >=20 > @@ -1277,6 +1305,8 @@ print_usage(const char *prgname) > " --config (port,queue,lcore)[,(port,queue,lcore)]" > " [--single-sa SAIDX]" > " [--cryptodev_mask MASK]" > + " [--transfer-mode MODE]" > + " [--schedule-type TYPE]" > " [--" CMD_LINE_OPT_RX_OFFLOAD " RX_OFFLOAD_MASK]" > " [--" CMD_LINE_OPT_TX_OFFLOAD " TX_OFFLOAD_MASK]" > " [--" CMD_LINE_OPT_REASSEMBLE " REASSEMBLE_TABLE_SIZE]" > @@ -1298,6 +1328,14 @@ print_usage(const char *prgname) > " bypassing the SP\n" > " --cryptodev_mask MASK: Hexadecimal bitmask of the crypto\n" > " devices to configure\n" > + " --transfer-mode MODE\n" > + " \"poll\" : Packet transfer via polling (default)\n" > + " \"event\" : Packet transfer via event device\n" > + " --schedule-type TYPE queue schedule type, used only when\n" > + " transfer mode is set to event\n" > + " \"ordered\" : Ordered (default)\n" > + " \"atomic\" : Atomic\n" > + " \"parallel\" : Parallel\n" > " --" CMD_LINE_OPT_RX_OFFLOAD > ": bitmask of the RX HW offload capabilities to enable/use\n" > " (DEV_RX_OFFLOAD_*)\n" > @@ -1432,8 +1470,45 @@ print_app_sa_prm(const struct app_sa_prm *prm) > printf("Frag TTL: %" PRIu64 " ns\n", frag_ttl_ns); > } >=20 > +static int > +parse_transfer_mode(struct eh_conf *conf, const char *optarg) > +{ > + if (!strcmp(CMD_LINE_ARG_POLL, optarg)) > + conf->mode =3D EH_PKT_TRANSFER_MODE_POLL; > + else if (!strcmp(CMD_LINE_ARG_EVENT, optarg)) > + conf->mode =3D EH_PKT_TRANSFER_MODE_EVENT; > + else { > + printf("Unsupported packet transfer mode\n"); > + return -EINVAL; > + } > + > + return 0; > +} > + > +static int > +parse_schedule_type(struct eh_conf *conf, const char *optarg) > +{ > + struct eventmode_conf *em_conf =3D NULL; > + > + /* Get eventmode conf */ > + em_conf =3D conf->mode_params; > + > + if (!strcmp(CMD_LINE_ARG_ORDERED, optarg)) > + em_conf->ext_params.sched_type =3D RTE_SCHED_TYPE_ORDERED; > + else if (!strcmp(CMD_LINE_ARG_ATOMIC, optarg)) > + em_conf->ext_params.sched_type =3D RTE_SCHED_TYPE_ATOMIC; > + else if (!strcmp(CMD_LINE_ARG_PARALLEL, optarg)) > + em_conf->ext_params.sched_type =3D RTE_SCHED_TYPE_PARALLEL; > + else { > + printf("Unsupported queue schedule type\n"); > + return -EINVAL; > + } > + > + return 0; > +} > + > static int32_t > -parse_args(int32_t argc, char **argv) > +parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) > { > int opt; > int64_t ret; > @@ -1522,6 +1597,7 @@ parse_args(int32_t argc, char **argv) > /* else */ > single_sa =3D 1; > single_sa_idx =3D ret; > + eh_conf->ipsec_mode =3D EH_IPSEC_MODE_TYPE_DRIVER; > printf("Configured with single SA index %u\n", > single_sa_idx); > break; > @@ -1536,6 +1612,26 @@ parse_args(int32_t argc, char **argv) > /* else */ > enabled_cryptodev_mask =3D ret; > break; > + > + case CMD_LINE_OPT_TRANSFER_MODE_NUM: > + ret =3D parse_transfer_mode(eh_conf, optarg); > + if (ret < 0) { > + printf("Invalid packet transfer mode\n"); > + print_usage(prgname); > + return -1; > + } > + break; > + > + case CMD_LINE_OPT_SCHEDULE_TYPE_NUM: > + ret =3D parse_schedule_type(eh_conf, optarg); > + if (ret < 0) { > + printf("Invalid queue schedule type\n"); > + print_usage(prgname); > + return -1; > + } > + schedule_type =3D 1; > + break; > + > case CMD_LINE_OPT_RX_OFFLOAD_NUM: > ret =3D parse_mask(optarg, &dev_rx_offload); > if (ret !=3D 0) { > @@ -2450,16 +2546,176 @@ create_default_ipsec_flow(uint16_t port_id, uint= 64_t rx_offloads) > port_id); > } >=20 Wouldn't it be more natural to have these 2 functions below (eh_conf_init(), eh_conf_uninit()) defined inside event_helper.c? > +static struct eh_conf * > +eh_conf_init(void) > +{ > + struct eventmode_conf *em_conf =3D NULL; > + struct eh_conf *conf =3D NULL; > + unsigned int eth_core_id; > + uint32_t nb_bytes; > + void *mem =3D NULL; > + > + /* Allocate memory for config */ > + conf =3D calloc(1, sizeof(struct eh_conf)); > + if (conf =3D=3D NULL) { > + printf("Failed to allocate memory for eventmode helper conf"); > + goto err; > + } > + > + /* Set default conf */ > + > + /* Packet transfer mode: poll */ > + conf->mode =3D EH_PKT_TRANSFER_MODE_POLL; > + conf->ipsec_mode =3D EH_IPSEC_MODE_TYPE_APP; > + > + /* Keep all ethernet ports enabled by default */ > + conf->eth_portmask =3D -1; > + > + /* Allocate memory for event mode params */ > + conf->mode_params =3D calloc(1, sizeof(struct eventmode_conf)); > + if (conf->mode_params =3D=3D NULL) { > + printf("Failed to allocate memory for event mode params"); > + goto err; > + } > + > + /* Get eventmode conf */ > + em_conf =3D conf->mode_params; > + > + /* Allocate and initialize bitmap for eth cores */ > + nb_bytes =3D rte_bitmap_get_memory_footprint(RTE_MAX_LCORE); > + if (!nb_bytes) { > + printf("Failed to get bitmap footprint"); > + goto err; > + } > + > + mem =3D rte_zmalloc("event-helper-ethcore-bitmap", nb_bytes, > + RTE_CACHE_LINE_SIZE); > + if (!mem) { > + printf("Failed to allocate memory for eth cores bitmap\n"); > + goto err; > + } > + > + em_conf->eth_core_mask =3D rte_bitmap_init(RTE_MAX_LCORE, mem, nb_bytes= ); > + if (!em_conf->eth_core_mask) { > + printf("Failed to initialize bitmap"); > + goto err; > + } > + > + /* Schedule type: ordered */ > + em_conf->ext_params.sched_type =3D RTE_SCHED_TYPE_ORDERED; > + > + /* Set two cores as eth cores for Rx & Tx */ > + > + /* Use first core other than master core as Rx core */ > + eth_core_id =3D rte_get_next_lcore(0, /* curr core */ > + 1, /* skip master core */ > + 0 /* wrap */); > + > + rte_bitmap_set(em_conf->eth_core_mask, eth_core_id); > + > + /* Use next core as Tx core */ > + eth_core_id =3D rte_get_next_lcore(eth_core_id, /* curr core */ > + 1, /* skip master core */ > + 0 /* wrap */); > + > + rte_bitmap_set(em_conf->eth_core_mask, eth_core_id); > + > + return conf; > +err: > + rte_free(mem); > + free(em_conf); > + free(conf); > + return NULL; > +} > + > +static void > +eh_conf_uninit(struct eh_conf *conf) > +{ > + struct eventmode_conf *em_conf =3D NULL; > + > + /* Get eventmode conf */ > + em_conf =3D conf->mode_params; > + > + /* Free evenmode configuration memory */ > + rte_free(em_conf->eth_core_mask); > + free(em_conf); > + free(conf); > +} > + > +static void > +signal_handler(int signum) > +{ > + if (signum =3D=3D SIGINT || signum =3D=3D SIGTERM) { > + printf("\n\nSignal %d received, preparing to exit...\n", > + signum); > + force_quit =3D true; > + } > +} > + > +static void > +inline_sessions_free(struct sa_ctx *sa_ctx) > +{ > + struct rte_ipsec_session *ips; > + struct ipsec_sa *sa; > + int32_t i, ret; > + > + for (i =3D 0; i < IPSEC_SA_MAX_ENTRIES; i++) { > + > + sa =3D &sa_ctx->sa[i]; > + if (!sa->spi) > + continue; > + > + ips =3D ipsec_get_primary_session(sa); > + if (ips->type !=3D RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL && > + ips->type !=3D RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) > + continue; > + > + ret =3D rte_security_session_destroy( > + rte_eth_dev_get_sec_ctx(sa->portid), > + ips->security.ses); > + if (ret) > + RTE_LOG(ERR, IPSEC, "Failed to destroy security " > + "session type %d, spi %d\n", > + ips->type, sa->spi); > + } > +} > + > +static void > +ev_mode_sess_verify(struct sa_ctx *sa_ctx) > +{ > + struct rte_ipsec_session *ips; > + struct ipsec_sa *sa; > + int32_t i; > + > + if (!sa_ctx) > + return; > + > + for (i =3D 0; i < IPSEC_SA_MAX_ENTRIES; i++) { > + > + sa =3D &sa_ctx->sa[i]; > + if (!sa->spi) > + continue; > + > + ips =3D ipsec_get_primary_session(sa); > + if (ips->type !=3D RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) > + rte_exit(EXIT_FAILURE, "Event mode supports only " > + "inline protocol sessions\n"); As I understand at that moment inline sessions already created on devices? For consistency wouldn't it be better to do this check at parsing cfg file, or straight after it?=20 > + } > + > +} > + > int32_t > main(int32_t argc, char **argv) > { > int32_t ret; > uint32_t lcore_id; > + uint32_t cdev_id; > uint32_t i; > uint8_t socket_id; > uint16_t portid; > uint64_t req_rx_offloads[RTE_MAX_ETHPORTS]; > uint64_t req_tx_offloads[RTE_MAX_ETHPORTS]; > + struct eh_conf *eh_conf =3D NULL; > size_t sess_sz; >=20 > /* init EAL */ > @@ -2469,8 +2725,17 @@ main(int32_t argc, char **argv) > argc -=3D ret; > argv +=3D ret; >=20 > + force_quit =3D false; > + signal(SIGINT, signal_handler); > + signal(SIGTERM, signal_handler); > + > + /* initialize event helper configuration */ > + eh_conf =3D eh_conf_init(); > + if (eh_conf =3D=3D NULL) > + rte_exit(EXIT_FAILURE, "Failed to init event helper config"); > + > /* parse application arguments (after the EAL ones) */ > - ret =3D parse_args(argc, argv); > + ret =3D parse_args(argc, argv, eh_conf); > if (ret < 0) > rte_exit(EXIT_FAILURE, "Invalid parameters\n"); >=20 > @@ -2487,7 +2752,7 @@ main(int32_t argc, char **argv) > rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n", > unprotected_port_mask); >=20 > - if (check_params() < 0) > + if (check_params(eh_conf) < 0) > rte_exit(EXIT_FAILURE, "check_params failed\n"); >=20 > ret =3D init_lcore_rx_queues(); > @@ -2529,6 +2794,18 @@ main(int32_t argc, char **argv) >=20 > cryptodevs_init(); >=20 > + /* > + * Set the enabled port mask in helper config for use by helper > + * sub-system. This will be used while initializing devices using > + * helper sub-system. > + */ > + eh_conf->eth_portmask =3D enabled_port_mask; > + > + /* Initialize eventmode components */ > + ret =3D eh_devs_init(eh_conf); > + if (ret < 0) > + rte_exit(EXIT_FAILURE, "eh_devs_init failed, err=3D%d\n", ret); > + > /* start ports */ > RTE_ETH_FOREACH_DEV(portid) { > if ((enabled_port_mask & (1 << portid)) =3D=3D 0) > @@ -2576,6 +2853,18 @@ main(int32_t argc, char **argv) > sp4_init(&socket_ctx[socket_id], socket_id); > sp6_init(&socket_ctx[socket_id], socket_id); > rt_init(&socket_ctx[socket_id], socket_id); > + > + /* > + * Event mode currently supports only inline protocol > + * sessions. If there are other types of sessions > + * configured then exit with error. > + */ > + if (eh_conf->mode =3D=3D EH_PKT_TRANSFER_MODE_EVENT) { > + ev_mode_sess_verify( > + socket_ctx[socket_id].sa_in); > + ev_mode_sess_verify( > + socket_ctx[socket_id].sa_out); > + } > } > } >=20 > @@ -2583,10 +2872,54 @@ main(int32_t argc, char **argv) > =09 > /* launch per-lcore init on every lcore */ > rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER); > + > RTE_LCORE_FOREACH_SLAVE(lcore_id) { > if (rte_eal_wait_lcore(lcore_id) < 0) > return -1; > } >=20 > + /* Uninitialize eventmode components */ > + ret =3D eh_devs_uninit(eh_conf); > + if (ret < 0) > + rte_exit(EXIT_FAILURE, "eh_devs_uninit failed, err=3D%d\n", ret); > + > + /* Free eventmode configuration memory */ > + eh_conf_uninit(eh_conf); > + > + /* Destroy inline inbound and outbound sessions */ > + for (i =3D 0; i < NB_SOCKETS && i < rte_socket_count(); i++) { > + socket_id =3D rte_socket_id_by_idx(i); > + inline_sessions_free(socket_ctx[socket_id].sa_in); That causes a crash on 2 socket system with the config that uses lcores only from the first socket. > + inline_sessions_free(socket_ctx[socket_id].sa_out); > + } > + > + for (cdev_id =3D 0; cdev_id < rte_cryptodev_count(); cdev_id++) { > + printf("Closing cryptodev %d...", cdev_id); > + rte_cryptodev_stop(cdev_id); > + rte_cryptodev_close(cdev_id); > + printf(" Done\n"); > + } > + > + RTE_ETH_FOREACH_DEV(portid) { > + if ((enabled_port_mask & (1 << portid)) =3D=3D 0) > + continue; > + > + printf("Closing port %d...", portid); > + if (flow_info_tbl[portid].rx_def_flow) { > + struct rte_flow_error err; > + > + ret =3D rte_flow_destroy(portid, > + flow_info_tbl[portid].rx_def_flow, &err); > + if (ret) > + RTE_LOG(ERR, IPSEC, "Failed to destroy flow " > + " for port %u, err msg: %s\n", portid, > + err.message); > + } > + rte_eth_dev_stop(portid); > + rte_eth_dev_close(portid); > + printf(" Done\n"); > + } > + printf("Bye...\n"); > + > return 0; > } > diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h > index 28ff07d..0539aec 100644 > --- a/examples/ipsec-secgw/ipsec.h > +++ b/examples/ipsec-secgw/ipsec.h > @@ -153,6 +153,17 @@ struct ipsec_sa { > struct rte_security_session_conf sess_conf; > } __rte_cache_aligned; >=20 > +struct sa_ctx { > + void *satbl; /* pointer to array of rte_ipsec_sa objects*/ > + struct ipsec_sa sa[IPSEC_SA_MAX_ENTRIES]; > + union { > + struct { > + struct rte_crypto_sym_xform a; > + struct rte_crypto_sym_xform b; > + }; > + } xf[IPSEC_SA_MAX_ENTRIES]; > +}; > + > struct ipsec_mbuf_metadata { > struct ipsec_sa *sa; > struct rte_crypto_op cop; > diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c > index c75a5a1..2ec3e17 100644 > --- a/examples/ipsec-secgw/sa.c > +++ b/examples/ipsec-secgw/sa.c > @@ -781,17 +781,6 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inb= ound) > printf("\n"); > } >=20 > -struct sa_ctx { > - void *satbl; /* pointer to array of rte_ipsec_sa objects*/ > - struct ipsec_sa sa[IPSEC_SA_MAX_ENTRIES]; > - union { > - struct { > - struct rte_crypto_sym_xform a; > - struct rte_crypto_sym_xform b; > - }; > - } xf[IPSEC_SA_MAX_ENTRIES]; > -}; > - > static struct sa_ctx * > sa_create(const char *name, int32_t socket_id) > { > -- > 2.7.4