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 7B10CA056A; Fri, 6 Mar 2020 11:02:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 46E871C0D7; Fri, 6 Mar 2020 11:00:13 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id CED691C0B3 for ; Fri, 6 Mar 2020 11:00:05 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 026A02R0010304; Fri, 6 Mar 2020 02:00:05 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=CybYD+dZi5/8H9/Q3reh1xRVLzRoVpbwICVs2Mzj4W0=; b=LcH6OR1XRlGIPAtn46xrZfd11KKjmwFCyjnP1H4gCdqwjFcw5l0bjCsxk3GYkjs+UjtE VqT7oHJk/2okYAoB/EY1/tH6klUNgDYQ9i5xaRVXhM1CqkkXnI/rljBrEAR9oH7Hf3NR QvEeca7otf3yT14K0Juoq48ZpczhzzofwS22+jL+scZ71ZJCDTRbPGyf3lcpBSjba+JH 0Pm+DGZz0NCQJQ8JWVJf5m0Ztpmp5TtMtwmNvSHQlSmPYXzqL3E6Shyg58HFWNF4xFtK Luc0Qv8XatDwRnHKTh6GHDL4QDMON5IyMAEK4sRGdzhnPN+9b33M/uQwyxEU3x6u7wlJ QA== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2yhn0yc5p8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 06 Mar 2020 02:00:05 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 6 Mar 2020 02:00:02 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 6 Mar 2020 02:00:02 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 6 Mar 2020 02:00:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XGoRIVfWj4JJcj0ZQyECby7LDzmuxzqiWSmBBU3gR68rXlFOMkd3nFJRViRrQI2abhsak3M50+eAD+eiGu2Ch9lHQP0JqmmpjWuZoOPDJIGUQpdC0B4QRKKD/c73Ne7zHrEX9vGsrmtLHlVLpSHV9WBtwiCITffJ2CtvqezNj2d3AD21UDjepIW/85jnUSWKdhQBgexIHcTtjihYQ+e6G16iiDX1uos5a6+c7WzGlBS5IjgZzO9RAU4CPrTLBSjDqrtLimaVVO8nDM0c/XG3Px43YwcRmWSKnNJNhMktKMlY8Ke4LCbgiemGqRBxqaTjn34OsEhwlwsFnjtJR1Royw== 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=CybYD+dZi5/8H9/Q3reh1xRVLzRoVpbwICVs2Mzj4W0=; b=bduYsb77xAz826kLEtpFZX+FC40u2lN1+vkh/kfgtLgjh/bAgCev4R42AtZSp1Isy4RtrXqc61U+L+AALZ5tOCvUr+ECYniOz6MNm05jnR1S5bPK7510rzHeN4ruLgaOcCy3l1GZIae4A62VF53zR+mYGtgOqDeed1OVj6iYeQpghv7ru4vN4wl5rjVBe+vjaIM4drp7mBa/3gspLDwX9Y8XZAxa+21MEfYxrs4OrRLqdfyhmphF1LqMHysKjOz5RcRyvbYl2a/De1Yb76zkQp2VF9iMnehkicKaMnlt7Mne1YCybAwmp1a9fqh5PsXN6usEkPn5G7/CsErLRs3WWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CybYD+dZi5/8H9/Q3reh1xRVLzRoVpbwICVs2Mzj4W0=; b=S4FtUhSURQbnyiru8GMO66ZycBEh4LC2hHt+0Wbp0C8UdGQ8MieEFE1HAAnxv9nJtAqFOBr85QHueoK2lfkxrWPRdWWlSK8jxmCQfLQh5BfDTjndhNHnhbZ8ZRTXOd7HtjnPlV3RtJnOW1d5jispPaSR682IG/2cvRN6DyzC6Lw= Received: from MN2PR18MB2877.namprd18.prod.outlook.com (2603:10b6:208:3b::26) by MN2PR18MB2447.namprd18.prod.outlook.com (2603:10b6:208:100::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Fri, 6 Mar 2020 10:00:00 +0000 Received: from MN2PR18MB2877.namprd18.prod.outlook.com ([fe80::648f:e7fa:f95e:191b]) by MN2PR18MB2877.namprd18.prod.outlook.com ([fe80::648f:e7fa:f95e:191b%2]) with mapi id 15.20.2793.013; Fri, 6 Mar 2020 10:00:00 +0000 From: Anoob Joseph To: Praveen Shetty , "dev@dpdk.org" , "declan.doherty@intel.com" , "bernard.iremonger@intel.com" , "konstantin.ananyev@intel.com" Thread-Topic: [dpdk-dev] [PATCH v1] examples/ipsec-secgw: load/unload esp-ah DDP file Thread-Index: AQHV85bptWBTyWSm+Eyfk6Ra/QhC96g7SUxg Date: Fri, 6 Mar 2020 09:59:59 +0000 Message-ID: References: <20200306055609.11734-1-praveen.shetty@intel.com> In-Reply-To: <20200306055609.11734-1-praveen.shetty@intel.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [14.140.231.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ef539ee6-01cd-4233-82f4-08d7c1b5221f x-ms-traffictypediagnostic: MN2PR18MB2447: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:206; x-forefront-prvs: 0334223192 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(346002)(396003)(376002)(366004)(199004)(189003)(66946007)(2906002)(9686003)(55236004)(110136005)(33656002)(55016002)(86362001)(64756008)(26005)(66446008)(66556008)(76116006)(66476007)(186003)(81166006)(316002)(81156014)(71200400001)(478600001)(8936002)(7696005)(52536014)(6506007)(53546011)(5660300002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2447; H:MN2PR18MB2877.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PJQa09SZ9yGe1/zCJn8AmUWB1kq9SD+ko/IQDxN7Lmz4nuOQgW8xb6GGWTQuzTpwAUBZIlCDP08XIJdfB43c2oapHNwexhLnyByyAizbkOmsqzJ64ZOG9H+VlP9+AgU4+RNAPGK5zxRIFMdCqnbEgAb9Vk89Wv/tf71ozhVjWPBICeG5RUzpMDFz2QNZPCDYtTCylAIyBCTbkQn4NGnp1hNbDqohi0yVnZ6wMRhDsZn+uMB9TdO8ZnPkrMvR8hnCYeF9vuWiXP6G0AsTMqodk+27hge0Kp+cQYsiH/Mc9Mskez6qLG67sy8h7YdQqHOmwpmlV/s3SB5nppJP4ODRcQWMjYO3lNxYbSahcdbGoQaIag0FIMpVS2xgiM+7nSrZEhgR26ej1ilPr+Iem/lEW6na9CRA5M7SpdpZVu81kiBc2yvZWwFlkDESxO/Vf/CK x-ms-exchange-antispam-messagedata: 8k1nZijTVYld/zIsfj4nbnJ4Mf4YfDi4JNvRj4W6K6TgUgX6lKk4KZ5GZwaOrAoQU33yUGjygLeLw+gSA8+YEjCYFDHF1+adE1t7yXxPzW2xqRjtuEOBUmvTKSke3JvKKqn22J0p0ipe2/RMQFcnbw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: ef539ee6-01cd-4233-82f4-08d7c1b5221f X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Mar 2020 10:00:00.0097 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: tEXrNe5prqcNosv4bwcFRSz+0I4f68cdEqz43IhvsezGi43eWl5Oo+LfcK7u+fT4SHp/y6lmTD2x+qsCFzzjYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2447 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-03-06_02:2020-03-05, 2020-03-06 signatures=0 Subject: Re: [dpdk-dev] [PATCH v1] examples/ipsec-secgw: load/unload esp-ah DDP file 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" Hi Praveen, Please see inline. Thanks, Anoob > -----Original Message----- > From: dev On Behalf Of Praveen Shetty > Sent: Friday, March 6, 2020 11:26 AM > To: dev@dpdk.org; declan.doherty@intel.com; > bernard.iremonger@intel.com; konstantin.ananyev@intel.com > Subject: [dpdk-dev] [PATCH v1] examples/ipsec-secgw: load/unload esp-ah > DDP file >=20 > Modified Secuirty gateway application to support load/unload esp-ah ddp > package on i40e NIC from ipsec-secgw application. >=20 > Signed-off-by: Praveen Shetty > --- > examples/ipsec-secgw/ipsec-secgw.c | 67 +++++++++++- > examples/ipsec-secgw/ipsec.c | 158 > +++++++++++++++++++++++++++++ > examples/ipsec-secgw/ipsec.h | 6 +- > 3 files changed, 228 insertions(+), 3 deletions(-) >=20 > diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec- > secgw/ipsec-secgw.c > index 4799bc90c..214b8a625 100644 > --- a/examples/ipsec-secgw/ipsec-secgw.c > +++ b/examples/ipsec-secgw/ipsec-secgw.c > @@ -198,7 +198,10 @@ struct app_sa_prm app_sa_prm =3D { > .cache_sz =3D SA_CACHE_SZ > }; > static const char *cfgfile; > - > +static const char *ddp_file; > +static const char *ddp_bkp_file; > +static uint16_t fdir_portid; > +static int16_t ddp_unload_flag; > struct lcore_rx_queue { > uint16_t port_id; > uint8_t queue_id; > @@ -1286,6 +1289,8 @@ print_usage(const char *prgname) > " [-e]" > " [-a]" > " [-c]" > + " [-L (portid,ddp_file_path,ddp_backup_file_path)]" > + " [-U (portid,ddp_backup_file_path)]" [Anoob] This is applicable only to i40e NIC, right? Probably mention that. =20 > " -f CONFIG_FILE" > " --config (port,queue,lcore)[,(port,queue,lcore)]" > " [--single-sa SAIDX]" > @@ -1307,6 +1312,8 @@ print_usage(const char *prgname) > " -a enables SA SQN atomic behaviour\n" > " -c specifies inbound SAD cache size,\n" > " zero value disables the cache (default value: 128)\n" > + " -L To load ddp profile on NIC\n" > + " -U To unload ddp profile from NIC\n" > " -f CONFIG_FILE: Configuration file\n" > " --config (port,queue,lcore): Rx queue configuration\n" > " --single-sa SAIDX: Use single SA index for outbound > traffic,\n" > @@ -1379,6 +1386,33 @@ parse_decimal(const char *str) > return num; > } >=20 > +static int32_t > +parse_ddp_load_args(char *str) > +{ > + int16_t num_args =3D 0; > + char *file_fld[3]; > + num_args =3D rte_strsplit(str, strlen(str), file_fld, 3, ','); > + if (num_args !=3D 3) > + return -1; > + fdir_portid =3D atoi(file_fld[0]); > + ddp_file =3D file_fld[1]; > + ddp_bkp_file =3D file_fld[2]; > + return 0; > +} > + > +static int32_t > +parse_ddp_unload_args(char *str) > +{ > + int16_t num_args =3D 0; > + char *file_fld[2]; > + num_args =3D rte_strsplit(str, strlen(str), file_fld, 2, ','); > + if (num_args !=3D 2) > + return -1; > + fdir_portid =3D atoi(file_fld[0]); > + ddp_bkp_file =3D file_fld[1]; > + return 0; > +} > + > static int32_t > parse_config(const char *q_arg) > { > @@ -1459,7 +1493,7 @@ parse_args(int32_t argc, char **argv) >=20 > argvopt =3D argv; >=20 > - while ((opt =3D getopt_long(argc, argvopt, "aelp:Pu:f:j:w:c:", > + while ((opt =3D getopt_long(argc, argvopt, "aelp:Pu:L:U:f:j:w:c:", > lgopts, &option_index)) !=3D EOF) { >=20 > switch (opt) { > @@ -1483,6 +1517,25 @@ parse_args(int32_t argc, char **argv) > return -1; > } > break; > + case 'L': > + printf("Loading ddp package selected\n"); > + ret =3D parse_ddp_load_args(optarg); > + if (ret < 0) { > + printf("Invalid ddp load args: %s\n", optarg); > + print_usage(prgname); > + return -1; > + } > + break; > + case 'U': > + printf("Unloading ddp package selected\n"); > + ret =3D parse_ddp_unload_args(optarg); > + if (ret < 0) { > + printf("Invalid ddp unload args: %s\n", > optarg); > + print_usage(prgname); > + return -1; > + } > + ddp_unload_flag =3D 1; > + break; > case 'f': > if (f_present =3D=3D 1) { > printf("\"-f\" option present more than " > @@ -2505,6 +2558,16 @@ main(int32_t argc, char **argv) > sa_check_offloads(portid, &req_rx_offloads, > &req_tx_offloads); > port_init(portid, req_rx_offloads, req_tx_offloads); > } [Anoob] Following checks are not valid for non i40e PMDs, right? Is there a= capability we can check before doing the below? =20 > + if (ddp_file !=3D NULL && ddp_bkp_file !=3D NULL) { > + ret =3D load_ddp_esp_package(fdir_portid, ddp_file, > ddp_bkp_file); > + if (ret < 0) > + printf("loading ddp package failed\n"); > + } > + if (ddp_unload_flag && ddp_bkp_file !=3D NULL) { > + ret =3D unload_ddp_esp_package(fdir_portid, ddp_bkp_file); > + if (ret < 0) > + printf("unloading ddp package failed\n"); > + } >=20 > cryptodevs_init(); >=20 > diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c > index 6e8120702..3840a0848 100644 > --- a/examples/ipsec-secgw/ipsec.c > +++ b/examples/ipsec-secgw/ipsec.c > @@ -4,6 +4,9 @@ > #include > #include > #include > +#include > +#include > +#include >=20 > #include > #include > @@ -14,6 +17,9 @@ > #include > #include > #include > +#ifdef RTE_LIBRTE_I40E_PMD > +#include > +#endif >=20 > #include "ipsec.h" > #include "esp.h" > @@ -155,6 +161,158 @@ create_lookaside_session(struct ipsec_ctx > *ipsec_ctx, struct ipsec_sa *sa, > return 0; > } >=20 > +static int > +close_file(uint8_t *buf) > +{ > + if (buf) { > + free((void *)buf); > + return 0; > + } > + > + return -1; > +} > + > +static uint8_t * > +open_file(const char *file_path, uint32_t *size) { > + int fd =3D open(file_path, O_RDONLY); > + off_t pkg_size; > + uint8_t *buf =3D NULL; > + int ret =3D 0; > + struct stat st_buf; > + > + if (size) > + *size =3D 0; > + > + if (fd =3D=3D -1) { > + printf("%s: Failed to open %s\n", __func__, file_path); > + return buf; > + } > + > + if ((fstat(fd, &st_buf) !=3D 0) || (!S_ISREG(st_buf.st_mode))) { > + close(fd); > + printf("%s: File operations failed\n", __func__); > + return buf; > + } > + > + pkg_size =3D st_buf.st_size; > + if (pkg_size < 0) { > + close(fd); > + printf("%s: File operations failed\n", __func__); > + return buf; > + } > + > + buf =3D (uint8_t *)malloc(pkg_size); [Anoob] The cast is not required. > + if (!buf) { > + close(fd); > + printf("%s: Failed to malloc memory\n", __func__); > + return buf; > + } > + > + ret =3D read(fd, buf, pkg_size); > + if (ret < 0) { > + close(fd); > + printf("%s: File read operation failed\n", __func__); > + close_file(buf); [Anoob] close_file() just frees the buffer and returns 0 is the buffer is n= ot NULL, and returns -1 if NULL. Do we need a separate function just for th= at? Also, the return value of close_file is ignored in all cases. =20 > + return NULL; > + } > + > + if (size) > + *size =3D pkg_size; > + > + close(fd); > + > + return buf; > +} > + > +static int > +save_file(const char *file_path, uint8_t *buf, uint32_t size) { > + FILE *fh =3D fopen(file_path, "wb"); > + > + if (fh =3D=3D NULL) { > + printf("%s: Failed to open %s\n", __func__, file_path); > + return -1; > + } > + > + if (fwrite(buf, 1, size, fh) !=3D size) { > + fclose(fh); > + printf("%s: File write operation failed\n", __func__); > + return -1; > + } > + > + fclose(fh); > + > + return 0; > +} > + > +/* Load dynamic device personalization profile */ int > +load_ddp_esp_package(uint16_t fdir_portid, const char *ddp_file, > + const char *ddp_bkp_file) > +{ > + uint8_t *buff; > + uint32_t size; > + int ret =3D -ENOTSUP; > + > + buff =3D open_file(ddp_file, &size); > + if (!buff) > + return -1; > + > +#ifdef RTE_LIBRTE_I40E_PMD > + ret =3D rte_pmd_i40e_process_ddp_package(fdir_portid, > + buff, size, > + > RTE_PMD_I40E_PKG_OP_WR_ADD); #endif > + [Anoob] Rather than calling PMD specific functions from all applications, i= t might be better to introduce the same via 'devargs' to the PMD. > + if (ret =3D=3D -EEXIST) > + printf("Profile has already existed.\n"); > + else if (ret < 0) { [Anoob] When i40e is not enabled (using RTE_LIBRTE_I40E_PMD), the error mes= sage would be "Failed to load profile", though the right reason is feature = being not supported. =20 > + printf("Failed to load profile.\n"); > + close_file(buff); > + return -1; > + } else > + printf("loading ddp profile success\n"); > + if (ddp_bkp_file !=3D NULL) > + save_file(ddp_bkp_file, buff, size); > + > + close_file(buff); > + return 0; > +} > + > +/* Unload dynamic device personalization profile */ int > +unload_ddp_esp_package(uint16_t fdir_portid, const char *ddp_bkp_file) > +{ > + > + uint8_t *buff; > + uint32_t size; > + int ret =3D -ENOTSUP; > + > + buff =3D open_file(ddp_bkp_file, &size); > + if (!buff) > + return -1; > + > +#ifdef RTE_LIBRTE_I40E_PMD > + ret =3D rte_pmd_i40e_process_ddp_package(fdir_portid, > + buff, size, > + > RTE_PMD_I40E_PKG_OP_WR_DEL); #endif > + > + if (ret =3D=3D -EACCES) { > + printf("Profile does not exist.\n"); > + close_file(buff); > + return -1; > + } else if (ret < 0) { > + printf("Failed to delete profile.\n"); > + close_file(buff); > + return -1; > + } else > + printf("ddp profile deleted successfully\n"); > + close_file(buff); > + return 0; > +} > + [Anoob] All the above functions are just about loading the ddp package. May= be we can move all that into a new file. =20 > int > create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, > struct rte_ipsec_session *ips) > diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h > index 4f2fd6184..73eec47ab 100644 > --- a/examples/ipsec-secgw/ipsec.h > +++ b/examples/ipsec-secgw/ipsec.h > @@ -383,5 +383,9 @@ create_lookaside_session(struct ipsec_ctx > *ipsec_ctx, struct ipsec_sa *sa, int create_inline_session(struct socke= t_ctx > *skt_ctx, struct ipsec_sa *sa, > struct rte_ipsec_session *ips); > - > +int > +load_ddp_esp_package(uint16_t fdir_portid, const char *ddp_file, > + const char *ddp_bkp_file); > +int > +unload_ddp_esp_package(uint16_t fdir_portid, const char *ddp_bkp_file); > #endif /* __IPSEC_H__ */ > -- > 2.17.1