From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0053.outbound.protection.outlook.com [104.47.37.53]) by dpdk.org (Postfix) with ESMTP id 4F7CD8E6E for ; Thu, 19 Apr 2018 14:16:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CkLWOX6SvRnkRVTyaGqP4R4z4uuim4HdZi5VBbbsWrY=; b=LjwrBvLzHl7Z8SDFBy5zuTK7PNH2rCwBGRWCck1IoszrhxJph66MhwsU89ff5fj2pc8iayUn4n4tLLxDUeVwmlo0GqbARGJn2xDWUzO3d1rOjYqyH1IRCCOE+7AhYWR+jiLlzsLSmfbrRAkEIecPg/m/KCR8bmx68mitpb1+/PU= Received: from CY4PR0701MB3634.namprd07.prod.outlook.com (52.132.101.164) by CY4PR0701MB3746.namprd07.prod.outlook.com (52.132.102.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Thu, 19 Apr 2018 12:16:57 +0000 Received: from CY4PR0701MB3634.namprd07.prod.outlook.com ([fe80::70e9:85be:bc6f:72f]) by CY4PR0701MB3634.namprd07.prod.outlook.com ([fe80::70e9:85be:bc6f:72f%13]) with mapi id 15.20.0696.013; Thu, 19 Apr 2018 12:16:56 +0000 From: "Verma, Shally" To: Abhinandan Gujjar , "pablo.de.lara.guarch@intel.com" , "declan.doherty@intel.com" , "Jacob, Jerin" , "hemant.agrawal@nxp.com" , "akhil.goyal@nxp.com" , "dev@dpdk.org" CC: "narender.vangati@intel.com" , "nikhil.rao@intel.com" Thread-Topic: [dpdk-dev] [v2, 2/3] cryptodev: support session private data setting Thread-Index: AQHT1U/SgQXoxcFIu0WmLNe7G57KpKQH8zAA Date: Thu, 19 Apr 2018 12:16:55 +0000 Message-ID: References: <1523861696-103397-1-git-send-email-abhinandan.gujjar@intel.com> <1523861696-103397-2-git-send-email-abhinandan.gujjar@intel.com> In-Reply-To: <1523861696-103397-2-git-send-email-abhinandan.gujjar@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=cavium.com; x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY4PR0701MB3746; 7:I7t+HXu6j5NIL0ETyN9rEFNdSQg2R2q9C2DECHAE3/01mIxL0qpv0/U9nBIW8B7pnXaXgoEJrZXXpPGToGK+ZxOiuodUoCJMJh2d8BmxS7Z+AEjK+oar99lTyonlw9eJl/3k1DlW7TXfqdKpG4f+c8HaiuMn5OI1D2aF90KLt2pZvNdYukByVPDLExCHQWKGBd0GLKFzt+uk9ccLx3azRdlZ/GPDPWVwR2dSgvEI6gOteb9Emtpb9y+htvbx44Va x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10009020)(396003)(39380400002)(346002)(376002)(366004)(39860400002)(13464003)(6116002)(86362001)(229853002)(33656002)(305945005)(3280700002)(316002)(2900100001)(2906002)(5250100002)(66066001)(2501003)(3660700001)(9686003)(8936002)(486006)(74316002)(11346002)(55016002)(446003)(476003)(6246003)(53936002)(6506007)(59450400001)(76176011)(55236004)(26005)(7736002)(478600001)(186003)(102836004)(72206003)(7696005)(2201001)(8656006)(5660300001)(3846002)(6436002)(81166006)(54906003)(110136005)(4326008)(25786009)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3746; H:CY4PR0701MB3634.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; MLV:sfv; x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR0701MB3746; x-ms-traffictypediagnostic: CY4PR0701MB3746: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231232)(944501327)(52105095)(10201501046)(93006095)(93001095)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:CY4PR0701MB3746; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0701MB3746; x-forefront-prvs: 0647963F84 x-microsoft-antispam-message-info: 0YoYpkXuFWZySB5cR26Wm7HSTZ0UExakj1afupOEg1dL+RfNfeDaF0T78K4yHdWp7EauxLZFOdqa+dHS9gZL3uG8mVYJTcmvbQ7NhFQfgfnsME4sRjrcXe8ZJCIU4um/gamxXgaOZqaJcCEOPNLcHwxvk8xTY/7/gsSeM6E/ybYvD3erkIhoDVMrAblWraL+ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b60758c2-6d69-4bc5-5a88-08d5a5ef716c X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: b60758c2-6d69-4bc5-5a88-08d5a5ef716c X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2018 12:16:55.9923 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3746 Subject: Re: [dpdk-dev] [v2, 2/3] cryptodev: support session private data setting 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: , X-List-Received-Date: Thu, 19 Apr 2018 12:16:59 -0000 >-----Original Message----- >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Abhinandan Gujjar >Sent: 16 April 2018 12:25 >To: pablo.de.lara.guarch@intel.com; declan.doherty@intel.com; Jacob, Jerin= ; >hemant.agrawal@nxp.com; akhil.goyal@nxp.com; dev@dpdk.org >Cc: narender.vangati@intel.com; abhinandan.gujjar@intel.com; nikhil.rao@in= tel.com >Subject: [dpdk-dev] [v2, 2/3] cryptodev: support session private data sett= ing > >The application may want to store private data along with the >rte_cryptodev that is transparent to the rte_cryptodev layer. >For e.g., If an eventdev based application is submitting a >rte_cryptodev_sym_session operation and wants to indicate event >information required to construct a new event that will be >enqueued to eventdev after completion of the rte_cryptodev_sym_session >operation. This patch provides a mechanism for the application >to associate this information with the rte_cryptodev_sym_session session. >The application can set the private data using >rte_cryptodev_sym_session_set_private_data() and retrieve it using >rte_cryptodev_sym_session_get_private_data(). > >Signed-off-by: Abhinandan Gujjar >Signed-off-by: Nikhil Rao >Acked-by: Pablo de Lara >--- > lib/librte_cryptodev/rte_cryptodev.c | 43 +++++++++++++++++++++= ++--- > lib/librte_cryptodev/rte_cryptodev.h | 32 +++++++++++++++++++ > lib/librte_cryptodev/rte_cryptodev_version.map | 7 +++++ > 3 files changed, 78 insertions(+), 4 deletions(-) > >diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/r= te_cryptodev.c >index 8745b6b..2a95a35 100644 >--- a/lib/librte_cryptodev/rte_cryptodev.c >+++ b/lib/librte_cryptodev/rte_cryptodev.c >@@ -1099,8 +1099,10 @@ struct rte_cryptodev_sym_session * > return NULL; > } > >- /* Clear device session pointer */ >- memset(sess, 0, (sizeof(void *) * nb_drivers)); >+ /* Clear device session pointer. >+ * Include the flag indicating presence of private data >+ */ >+ memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t)); > > return sess; > } >@@ -1204,9 +1206,10 @@ struct rte_cryptodev_sym_session * > { > /* > * Header contains pointers to the private data >- * of all registered drivers >+ * of all registered drivers, and a flag which >+ * indicates presence of private data > */ >- return (sizeof(void *) * nb_drivers); >+ return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t)); > } > > unsigned int >@@ -1238,6 +1241,38 @@ struct rte_cryptodev_sym_session * > > } > >+int __rte_experimental >+rte_cryptodev_sym_session_set_private_data( >+ struct rte_cryptodev_sym_session *sess, >+ void *data, >+ uint16_t size) >+{ >+ uint16_t off_set =3D sizeof(void *) * nb_drivers; >+ uint8_t *private_data_present =3D (uint8_t *)sess + off_set; [Shally] I was going through this in context of crypto event adapter and r= ealize probably it is safer to set priv_data_size after (sess =3D=3D NULL) = check. Same is applicable in get_private_data(). >+ >+ if (sess =3D=3D NULL) >+ return -EINVAL; >+ >+ *private_data_present =3D 1; >+ off_set +=3D sizeof(uint8_t); >+ rte_memcpy((uint8_t *)sess + off_set, data, size); >+ return 0; >+} >+ >+void * __rte_experimental >+rte_cryptodev_sym_session_get_private_data( >+ struct rte_cryptodev_sym_session *sess) >+{ >+ uint16_t off_set =3D sizeof(void *) * nb_drivers; >+ uint8_t *private_data_present =3D (uint8_t *)sess + off_set; >+ >+ if (sess =3D=3D NULL || !*private_data_present) >+ return NULL; >+ >+ off_set +=3D sizeof(uint8_t); >+ return (uint8_t *)sess + off_set; >+} >+ > /** Initialise rte_crypto_op mempool element */ > static void > rte_crypto_op_init(struct rte_mempool *mempool, >diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/r= te_cryptodev.h >index c8fa689..261a359 100644 >--- a/lib/librte_cryptodev/rte_cryptodev.h >+++ b/lib/librte_cryptodev/rte_cryptodev.h >@@ -1037,6 +1037,38 @@ struct rte_cryptodev_sym_session * > */ > const char *rte_cryptodev_driver_name_get(uint8_t driver_id); > >+/** >+ * Set private data for a session. >+ * >+ * @param sess Session pointer allocated by >+ * *rte_cryptodev_sym_session_create*. >+ * @param data Pointer to the private data. >+ * @param size Size of the private data. >+ * >+ * @return >+ * - On success, zero. >+ * - On failure, a negative value. >+ */ >+int __rte_experimental >+rte_cryptodev_sym_session_set_private_data( >+ struct rte_cryptodev_sym_session *sess, >+ void *data, >+ uint16_t size); >+ >+/** >+ * Get private data of a session. >+ * >+ * @param sess Session pointer allocated by >+ * *rte_cryptodev_sym_session_create*. >+ * >+ * @return >+ * - On success return pointer to private data. >+ * - On failure returns NULL. >+ */ >+void * __rte_experimental >+rte_cryptodev_sym_session_get_private_data( >+ struct rte_cryptodev_sym_session *sess); >+ > #ifdef __cplusplus > } > #endif >diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_c= ryptodev/rte_cryptodev_version.map >index eb47308..560e464 100644 >--- a/lib/librte_cryptodev/rte_cryptodev_version.map >+++ b/lib/librte_cryptodev/rte_cryptodev_version.map >@@ -85,3 +85,10 @@ DPDK_17.11 { > rte_cryptodev_pmd_parse_input_args; > > } DPDK_17.08; >+ >+EXPERIMENTAL { >+ global: >+ >+ rte_cryptodev_sym_session_get_private_data; >+ rte_cryptodev_sym_session_set_private_data; >+} DPDK_17.11; >-- >1.9.1