From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 46E367D02 for ; Fri, 20 Apr 2018 14:20:34 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Apr 2018 05:20:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,301,1520924400"; d="scan'208";a="34861794" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by orsmga007.jf.intel.com with ESMTP; 20 Apr 2018 05:20:32 -0700 Received: from pgsmsx106.gar.corp.intel.com ([169.254.9.180]) by KMSMSX151.gar.corp.intel.com ([169.254.10.3]) with mapi id 14.03.0319.002; Fri, 20 Apr 2018 20:20:31 +0800 From: "Gujjar, Abhinandan S" To: "Verma, Shally" , "De Lara Guarch, Pablo" , "Doherty, Declan" , "Jacob, Jerin" , "hemant.agrawal@nxp.com" , "akhil.goyal@nxp.com" , "dev@dpdk.org" CC: "Vangati, Narender" , "Rao, Nikhil" Thread-Topic: [dpdk-dev] [v2, 2/3] cryptodev: support session private data setting Thread-Index: AQHT19hZa/vjtkCLxUmFpqR6n4Hrs6QJkfUQ Date: Fri, 20 Apr 2018 12:20:30 +0000 Message-ID: <5612CB344B05EE4F95FC5B729939F780706F0302@PGSMSX106.gar.corp.intel.com> References: <1523861696-103397-1-git-send-email-abhinandan.gujjar@intel.com> <1523861696-103397-2-git-send-email-abhinandan.gujjar@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTFiNmFmNjktNTU4NS00MWE3LTgzMzYtNGIzN2NmYWNjNTQyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InVEbW9YQkdMcmNvMFRudG96ZnNpTlFINDYzUGxBeExqUlIxNlAzTk53VFE9In0= dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [172.30.20.205] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: Fri, 20 Apr 2018 12:20:35 -0000 > -----Original Message----- > From: Verma, Shally [mailto:Shally.Verma@cavium.com] > Sent: Thursday, April 19, 2018 5:47 PM > To: Gujjar, Abhinandan S ; De Lara Guarch, P= ablo > ; Doherty, Declan > ; Jacob, Jerin > ; hemant.agrawal@nxp.com; > akhil.goyal@nxp.com; dev@dpdk.org > Cc: Vangati, Narender ; Rao, Nikhil > > Subject: RE: [dpdk-dev] [v2, 2/3] cryptodev: support session private data= setting >=20 >=20 >=20 > >-----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@intel.com > >Subject: [dpdk-dev] [v2, 2/3] cryptodev: support session private data > >setting > > > >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/rte_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; >=20 > [Shally] I was going through this in context of crypto event adapter and= realize > probably it is safer to set priv_data_size after (sess =3D=3D NULL) check= . > Same is applicable in get_private_data(). [Abhinandan] I guess you are pointing *private_data_present* which is calcu= lated prior, it will not be used if the sess is NULL. >=20 > >+ > >+ 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/rte_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_cryptodev/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