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 344B8A04B3; Mon, 23 Dec 2019 17:43:35 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 22ABB2BE3; Mon, 23 Dec 2019 17:43:34 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id A79302BA3 for ; Mon, 23 Dec 2019 17:43:31 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Dec 2019 08:43:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,348,1571727600"; d="scan'208";a="242261615" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 23 Dec 2019 08:43:30 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Dec 2019 08:43:30 -0800 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Dec 2019 08:43:29 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.172) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Dec 2019 08:43:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MPDPztg2V6si4UlvUWOORGnZ4rMjFAN8xTJ0igOqbQ/n/MZJfNH7dr7dqqKadbW4utmPlBgBuKmnq87FU5QY4BxuYvX4wS3+fpc/IUhKFXx4UFBIrKN6jwoVx2OdNgKcKPN+n4t6IC2fb1VqI4VuhYvmc4sdql3MAmzrm6V87sjAatTl2+kHOAWk8YB77GgBKat3totFOSasl5csqNQcfRScINAdlkRneKg6AApd4BZsxAU7cXx5DrBVcd6NPeK+OFseDASTVzfBrk6bFO3t3NsTXQvmReEgeM79Gms7HTro/fogzWIQM7rW3S+wUBUKzw9swA6xr9hCRJPmfUloDQ== 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=w+96Us//9O6kYz97Q++APatjLvW7UNYcwZt0SvxF25A=; b=SHURC/Qd1W7WGR4MgXZnrUDmUpkZP9qq3mZfxRJ+2msJy2rufoO4GRQDXaBhXUUoVvB77H/EKlV9rsZrdmrms/D/1Vn3Ks6zAEGWQQMG+yNjUz2nb7+rBt9Ma9DLZem3HfETBExqGcLrZQ2Wu9p6yCkv+iDDnGX72iQW6oQCN8rgo1Fu1FvZLVDra7MsmxXh+ooCVeSGN0JegQt96+PZtYCAxFji+DHObZzLin5qHjWPj++XmsYiawNeA8imTtG8icCbo9ZbyPGgdy/2okEuKAEz4qG033FX6C48vhNNKXaTiXFSSMaZlR8aBcgK/55xqw7AnNZcI0mkr5xgqUobOQ== 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=w+96Us//9O6kYz97Q++APatjLvW7UNYcwZt0SvxF25A=; b=sUuR6gI+sOH16LpYgmk4D6+UuArdgbX7dm3bwcDc7q7ZdOSK8O3sTZxSDO16PserTpaLYCrL8RKNlEaS6dVqL6YQKi0pPxUhn4FFNTQXki4GdK0DG4UopwauXnwXEsdt6CQLQ8ATmF/979fM8LjrXCT65Vxt4GnGym+ZVGgzsF4= Received: from SN6PR11MB2558.namprd11.prod.outlook.com (52.135.94.19) by SN6PR11MB2784.namprd11.prod.outlook.com (52.135.89.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.15; Mon, 23 Dec 2019 16:43: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.2559.017; Mon, 23 Dec 2019 16:43: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 09/14] examples/ipsec-secgw: add eventmode to ipsec-secgw Thread-Index: AQHVrcOQjf1Dol+ZoUa/RbcKkKjo2KfIALbg Date: Mon, 23 Dec 2019 16:43:13 +0000 Message-ID: References: <1575808249-31135-1-git-send-email-anoobj@marvell.com> <1575808249-31135-10-git-send-email-anoobj@marvell.com> In-Reply-To: <1575808249-31135-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2U3ZWE4N2MtNWJiOC00ZDAyLTg1MWYtYWYxM2U3YmE2OGFjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUlJZdmRoN0lSVkZqOEpqQit4NGVneHFjWlwvV1B4TElYOUdJaUhJd2FsaU8rYXd4ZXVJNzRPQmVkNkVjNjE2cFAifQ== 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.184] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7b30840f-93d9-4d04-1a86-08d787c73408 x-ms-traffictypediagnostic: SN6PR11MB2784: 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:281; x-forefront-prvs: 0260457E99 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(376002)(346002)(396003)(366004)(199004)(189003)(66946007)(30864003)(7696005)(71200400001)(8676002)(81166006)(64756008)(66476007)(478600001)(66446008)(81156014)(66556008)(76116006)(54906003)(5660300002)(4326008)(6506007)(55016002)(110136005)(33656002)(9686003)(186003)(2906002)(316002)(8936002)(86362001)(52536014)(26005)(7416002); DIR:OUT; SFP:1102; SCL:1; SRVR:SN6PR11MB2784; 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: SBL+trRKYJ036bSyUrp9rMPgdNzT7U4ZBF5N9jlYT2QXtYq6ITtYQyZvmU1Vmeq2mG8pzgCavOsV6pcV0PZ3sVD6+n/VfqE+eOeQdJ+uBXis+2yuYhIJMHftlmAEh7nHukcHw0I/BHM9Qcx2OuBKEKQMLYpj35oWM7bGz4Xv6sZWTcO4YjpkDRXREylNLL/dRBdqe2AflLNmYH6Rfjj8utPz3Q4nZT9ryOIHEgMrWsl99AO9aDEAQr4qHlTB2+lTMVQTlEcxqbyI7w6z/gqFoduL/g9j3ZkUAMD5qFuZ93cBG5AJQEE5BGzSgndFSZVnCtEku7dSS9TaojkiH8pM6F3Q63Seh9ny3BhDVJMZmm9MYoOMmuDXREP77C72UsXpBTIQ1G8nbr242JYRtUePhz6OpUnxtGr2VzFcAKPPVpSvchhg/EhIzZDZOgxknWJm Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7b30840f-93d9-4d04-1a86-08d787c73408 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Dec 2019 16:43:13.6043 (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: 3PHIh0czL7ymEC+3GPTpy3UHaZFR8ZFJGmOTQExod+iFyXd50w4HjHzl/gjk+PYZaJKxZxXIOlA1CpBgu/HJmlLgBvRb74+thmN8dKx+YIk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2784 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 09/14] 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" >=20 > Add eventmode support to ipsec-secgw. This uses event helper to setup > and use the eventmode capabilities. Add driver inbound worker. >=20 > Example command: > ./ipsec-secgw -c 0x1 -w 0002:02:00.0,ipsec_in_max_spi=3D100 -w 0002:07:00= .0 > -w 0002:0e:00.0 -w 0002:10:00.1 -- -P -p 0x3 -u 0x1 > --config "(0,0,0),(1,0,0)" -f a-aes-gcm-msa.cfg --transfer-mode 1 > --schedule-type 2 --process-mode drv --process-dir in >=20 > Signed-off-by: Anoob Joseph > Signed-off-by: Lukasz Bartosik > --- > examples/ipsec-secgw/Makefile | 1 + > examples/ipsec-secgw/event_helper.c | 3 + > examples/ipsec-secgw/event_helper.h | 26 +++ > examples/ipsec-secgw/ipsec-secgw.c | 344 ++++++++++++++++++++++++++++++= +++++- > examples/ipsec-secgw/ipsec.h | 7 + > examples/ipsec-secgw/ipsec_worker.c | 180 +++++++++++++++++++ > examples/ipsec-secgw/meson.build | 2 +- > 7 files changed, 555 insertions(+), 8 deletions(-) > create mode 100644 examples/ipsec-secgw/ipsec_worker.c >=20 > diff --git a/examples/ipsec-secgw/Makefile b/examples/ipsec-secgw/Makefil= e > index 09e3c5a..f6fd94c 100644 > --- a/examples/ipsec-secgw/Makefile > +++ b/examples/ipsec-secgw/Makefile > @@ -15,6 +15,7 @@ SRCS-y +=3D sa.c > SRCS-y +=3D rt.c > SRCS-y +=3D ipsec_process.c > SRCS-y +=3D ipsec-secgw.c > +SRCS-y +=3D ipsec_worker.c > SRCS-y +=3D event_helper.c >=20 > CFLAGS +=3D -gdwarf-2 > diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/e= vent_helper.c > index 6549875..44f997d 100644 > --- a/examples/ipsec-secgw/event_helper.c > +++ b/examples/ipsec-secgw/event_helper.c > @@ -984,6 +984,9 @@ 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; > + curr_conf.cap.ipsec_dir =3D conf->ipsec_dir; > + > /* Parse the passed list and see if we have matching capabilities */ >=20 > /* Initialize the pointer used to traverse the list */ > diff --git a/examples/ipsec-secgw/event_helper.h b/examples/ipsec-secgw/e= vent_helper.h > index 2895dfa..07849b0 100644 > --- a/examples/ipsec-secgw/event_helper.h > +++ b/examples/ipsec-secgw/event_helper.h > @@ -74,6 +74,22 @@ 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 mode ipsec direction types > + */ > +enum eh_ipsec_dir_types { > + EH_IPSEC_DIR_TYPE_OUTBOUND =3D 0, > + EH_IPSEC_DIR_TYPE_INBOUND, > +}; > + > /* Event dev params */ > struct eventdev_params { > uint8_t eventdev_id; > @@ -183,6 +199,12 @@ struct eh_conf { > */ > void *mode_params; > /**< Mode specific parameters */ > + > + /** Application specific params */ > + enum eh_ipsec_mode_types ipsec_mode; > + /**< Mode of ipsec run */ > + enum eh_ipsec_dir_types ipsec_dir; > + /**< Direction of ipsec processing */ > }; >=20 > /* Workers registered by the application */ > @@ -194,6 +216,10 @@ 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 ipsec_dir : 1; > + /**< Specify direction of ipsec */ > }; > uint64_t u64; > } cap; > diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ip= sec-secgw.c > index 7506922..c5d95b9 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,21 @@ 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_IPSEC_MODE "process-mode" > +#define CMD_LINE_OPT_IPSEC_DIR "process-dir" > #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_APP "app" > +#define CMD_LINE_ARG_DRV "drv" > +#define CMD_LINE_ARG_INB "in" > +#define CMD_LINE_ARG_OUT "out" > + > enum { > /* long options mapped to a short option */ >=20 > @@ -149,7 +165,11 @@ 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_IPSEC_MODE_NUM, > + CMD_LINE_OPT_IPSEC_DIR_NUM, > CMD_LINE_OPT_TX_OFFLOAD_NUM, > CMD_LINE_OPT_REASSEMBLE_NUM, > CMD_LINE_OPT_MTU_NUM, > @@ -160,6 +180,10 @@ 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_IPSEC_MODE, 1, 0, CMD_LINE_OPT_IPSEC_MODE_NUM}, > + {CMD_LINE_OPT_IPSEC_DIR, 1, 0, CMD_LINE_OPT_IPSEC_DIR_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}, > @@ -1094,8 +1118,8 @@ drain_outbound_crypto_queues(const struct lcore_con= f *qconf, > } >=20 > /* main processing loop */ > -static int32_t > -main_loop(__attribute__((unused)) void *dummy) > +void > +ipsec_poll_mode_worker(void) > { > struct rte_mbuf *pkts[MAX_PKT_BURST]; > uint32_t lcore_id; > @@ -1137,7 +1161,7 @@ main_loop(__attribute__((unused)) void *dummy) > if (qconf->nb_rx_queue =3D=3D 0) { > RTE_LOG(DEBUG, IPSEC, "lcore %u has nothing to do\n", > lcore_id); > - return 0; > + return; > } >=20 > RTE_LOG(INFO, IPSEC, "entering main loop on lcore %u\n", lcore_id); > @@ -1150,7 +1174,7 @@ main_loop(__attribute__((unused)) void *dummy) > lcore_id, portid, queueid); > } >=20 > - while (1) { > + while (!force_quit) { > cur_tsc =3D rte_rdtsc(); >=20 > /* TX queue buffer drain */ > @@ -1277,6 +1301,10 @@ print_usage(const char *prgname) > " --config (port,queue,lcore)[,(port,queue,lcore)]" > " [--single-sa SAIDX]" > " [--cryptodev_mask MASK]" > + " [--transfer-mode MODE]" > + " [--schedule-type TYPE]" > + " [--process-mode MODE]" > + " [--process-dir DIR]" > " [--" 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 +1326,22 @@ 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" > + " 0: Packet transfer via polling (default)\n" > + " 1: Packet transfer via eventdev\n" > + " --schedule-type TYPE queue schedule type, used only when\n" > + " transfer mode is set to eventdev\n" > + " 0: Ordered (default)\n" > + " 1: Atomic\n" > + " 2: Parallel\n" For last two, why not something huma-readable? I.E. =3D=3D --tranfer-mode=3D(poll|event) or so. Same for schedule-type. > + " --process-mode MODE processing mode, used only when\n" > + " transfer mode is set to eventdev\n" > + " \"app\" : application mode (default)\n" > + " \"drv\" : driver mode\n" > + " --process-dir DIR processing direction, used only when\n" > + " transfer mode is set to eventdev\n" > + " \"out\" : outbound (default)\n" > + " \"in\" : inbound\n" Hmm and why in eventdev mode it is not possible to handle both inbound and = outbound traffic? Where is the limitation: eventdev framework/PMD/ipsec-secgw? > " --" CMD_LINE_OPT_RX_OFFLOAD > ": bitmask of the RX HW offload capabilities to enable/use\n" > " (DEV_RX_OFFLOAD_*)\n" > @@ -1433,7 +1477,89 @@ print_app_sa_prm(const struct app_sa_prm *prm) > } >=20 > static int32_t > -parse_args(int32_t argc, char **argv) > +eh_parse_decimal(const char *str) > +{ > + unsigned long num; > + char *end =3D NULL; > + > + num =3D strtoul(str, &end, 10); > + if ((str[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0')) > + return -EINVAL; > + > + return num; > +} There already exists parse_decimal(), why to create a dup? > + > +static int > +parse_transfer_mode(struct eh_conf *conf, const char *optarg) > +{ > + int32_t parsed_dec; > + > + parsed_dec =3D eh_parse_decimal(optarg); > + if (parsed_dec !=3D EH_PKT_TRANSFER_MODE_POLL && > + parsed_dec !=3D EH_PKT_TRANSFER_MODE_EVENT) { > + printf("Unsupported packet transfer mode"); > + return -EINVAL; > + } > + conf->mode =3D parsed_dec; > + return 0; > +} > + > +static int > +parse_schedule_type(struct eh_conf *conf, const char *optarg) > +{ > + struct eventmode_conf *em_conf =3D NULL; > + int32_t parsed_dec; > + > + parsed_dec =3D eh_parse_decimal(optarg); > + if (parsed_dec !=3D RTE_SCHED_TYPE_ORDERED && > + parsed_dec !=3D RTE_SCHED_TYPE_ATOMIC && > + parsed_dec !=3D RTE_SCHED_TYPE_PARALLEL) > + return -EINVAL; > + > + /* Get eventmode conf */ > + em_conf =3D (struct eventmode_conf *)(conf->mode_params); > + > + em_conf->ext_params.sched_type =3D parsed_dec; > + > + return 0; > +} > + > +static int > +parse_ipsec_mode(struct eh_conf *conf, const char *optarg) > +{ > + if (!strncmp(CMD_LINE_ARG_APP, optarg, strlen(CMD_LINE_ARG_APP)) && > + strlen(optarg) =3D=3D strlen(CMD_LINE_ARG_APP)) Ugh, that's an ugly construction, why not just: if (strcmp(CMD_LINE_ARG_APP, optarg) =3D=3D 0) ? > + conf->ipsec_mode =3D EH_IPSEC_MODE_TYPE_APP; > + else if (!strncmp(CMD_LINE_ARG_DRV, optarg, strlen(CMD_LINE_ARG_DRV)) &= & > + strlen(optarg) =3D=3D strlen(CMD_LINE_ARG_DRV)) > + conf->ipsec_mode =3D EH_IPSEC_MODE_TYPE_DRIVER; > + else { > + printf("Unsupported ipsec mode\n"); > + return -EINVAL; > + } > + > + return 0; > +} > + > +static int > +parse_ipsec_dir(struct eh_conf *conf, const char *optarg) > +{ > + if (!strncmp(CMD_LINE_ARG_INB, optarg, strlen(CMD_LINE_ARG_INB)) && > + strlen(optarg) =3D=3D strlen(CMD_LINE_ARG_INB)) > + conf->ipsec_dir =3D EH_IPSEC_DIR_TYPE_INBOUND; > + else if (!strncmp(CMD_LINE_ARG_OUT, optarg, strlen(CMD_LINE_ARG_OUT)) &= & > + strlen(optarg) =3D=3D strlen(CMD_LINE_ARG_OUT)) > + conf->ipsec_dir =3D EH_IPSEC_DIR_TYPE_OUTBOUND; > + else { > + printf("Unsupported ipsec direction\n"); > + return -EINVAL; > + } > + > + return 0; > +} > + > +static int32_t > +parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) > { > int opt; > int64_t ret; > @@ -1536,6 +1662,43 @@ 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; > + } > + break; > + > + case CMD_LINE_OPT_IPSEC_MODE_NUM: > + ret =3D parse_ipsec_mode(eh_conf, optarg); > + if (ret < 0) { > + printf("Invalid ipsec mode\n"); > + print_usage(prgname); > + return -1; > + } > + break; > + > + case CMD_LINE_OPT_IPSEC_DIR_NUM: > + ret =3D parse_ipsec_dir(eh_conf, optarg); > + if (ret < 0) { > + printf("Invalid ipsec direction\n"); > + print_usage(prgname); > + return -1; > + } > + break; > + > case CMD_LINE_OPT_RX_OFFLOAD_NUM: > ret =3D parse_mask(optarg, &dev_rx_offload); > if (ret !=3D 0) { > @@ -2457,6 +2620,132 @@ create_default_ipsec_flow(uint16_t port_id, uint6= 4_t rx_offloads) > return ret; > } >=20 > +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; > + conf->ipsec_dir =3D EH_IPSEC_DIR_TYPE_OUTBOUND; > + > + /* 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 (struct eventmode_conf *)(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 (struct eventmode_conf *)(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) { > + uint16_t port_id; > + printf("\n\nSignal %d received, preparing to exit...\n", > + signum); > + force_quit =3D true; > + > + /* Destroy the default ipsec flow */ > + RTE_ETH_FOREACH_DEV(port_id) { > + if ((enabled_port_mask & (1 << port_id)) =3D=3D 0) > + continue; > + if (flow_info_tbl[port_id].rx_def_flow) { > + struct rte_flow_error err; > + int ret; As we are going to call dev_stop(), etc. at force_quit below, is there any reason to call rte_flow_destroy() here? Just curious. > + ret =3D rte_flow_destroy(port_id, > + flow_info_tbl[port_id].rx_def_flow, > + &err); > + if (ret) > + RTE_LOG(ERR, IPSEC, > + "Failed to destroy flow for port %u, " > + "err msg: %s\n", port_id, err.message); > + } > + } > + } > +} > + > int32_t > main(int32_t argc, char **argv) > { > @@ -2466,6 +2755,7 @@ main(int32_t argc, char **argv) > uint8_t socket_id; > uint16_t portid; > uint64_t req_rx_offloads, req_tx_offloads; > + struct eh_conf *eh_conf =3D NULL; > size_t sess_sz; >=20 > /* init EAL */ > @@ -2475,8 +2765,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 > @@ -2592,12 +2891,43 @@ main(int32_t argc, char **argv) >=20 > check_all_ports_link_status(enabled_port_mask); >=20 > + /* > + * Set the enabled port mask in helper config for use by helper > + * sub-system. This will be used while intializing 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); > + > /* launch per-lcore init on every lcore */ > - rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER); > + rte_eal_mp_remote_launch(ipsec_launch_one_lcore, eh_conf, 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); > + > + RTE_ETH_FOREACH_DEV(portid) { > + if ((enabled_port_mask & (1 << portid)) =3D=3D 0) > + continue; > + printf("Closing port %d...", portid); > + rte_eth_dev_stop(portid); > + rte_eth_dev_close(portid); > + printf(" Done\n"); > + } > + printf("Bye...\n"); > + > return 0; > }