From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 6A40C1B5BA for ; Wed, 9 Jan 2019 23:56:35 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 14:56:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,459,1539673200"; d="scan'208,217";a="265885217" Received: from silpixa00398673.ir.intel.com (HELO silpixa00398673.ger.corp.intel.com) ([10.237.223.54]) by orsmga004.jf.intel.com with ESMTP; 09 Jan 2019 14:56:29 -0800 From: Fan Zhang To: dev@dpdk.org Cc: akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com, fiona.trahe@intel.com Date: Wed, 9 Jan 2019 22:56:07 +0000 Message-Id: <20190109225609.20590-11-roy.fan.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109225609.20590-1-roy.fan.zhang@intel.com> References: <20181221135550.80745-1-roy.fan.zhang@intel.com> <20190109225609.20590-1-roy.fan.zhang@intel.com> Subject: [dpdk-dev] [PATCH v4 10/12] cryptodev: add user data size to symmetric session 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: Wed, 09 Jan 2019 22:56:35 -0000 This patch adds a user_data_sz field to cryptodev symmetric session. The field is used to check if reading or writing the session's user data field is eligible. Signed-off-by: Fan Zhang Acked-by: Fiona Trahe --- doc/guides/prog_guide/img/cryptodev_sym_sess.svg | 172 ++++++++++++----------- lib/librte_cryptodev/rte_cryptodev.c | 11 +- lib/librte_cryptodev/rte_cryptodev.h | 5 +- 3 files changed, 103 insertions(+), 85 deletions(-) diff --git a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg index 5c843f736..20059cc0f 100644 --- a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg +++ b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg @@ -37,7 +37,7 @@ showgrid="false" inkscape:zoom="1.7495789" inkscape:cx="208.74719" - inkscape:cy="216.52777" + inkscape:cy="170.80248" inkscape:window-x="0" inkscape:window-y="27" inkscape:window-maximized="1" @@ -150,7 +150,7 @@ id="filter_2">Rounded Rectangle.12Crypto Symmetric SessionRounded Rectangle.13Private Session Data + id="desc29">Private Session Data + id="text4129" + y="80.842018" + x="27.862804" + style="font-style:normal;font-weight:normal;font-size:30.00008965px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000226" + xml:space="preserve"> - +} session_data[]; +uint16_t user_data_sz; +user_data nb_drivers; + s.user_data_sz = pool_priv->user_data_sz; if ((rte_cryptodev_sym_get_existing_header_session_size(&s) > obj_size) || (s.nb_drivers <= dev->driver_id) || @@ -1307,7 +1308,8 @@ rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts, static unsigned int rte_cryptodev_sym_session_data_size(struct rte_cryptodev_sym_session *sess) { - return (sizeof(sess->sess_data[0]) * sess->nb_drivers); + return (sizeof(sess->sess_data[0]) * sess->nb_drivers) + + sess->user_data_sz; } struct rte_cryptodev_sym_session * @@ -1335,7 +1337,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp) } sess->nb_drivers = pool_priv->nb_drivers; - + sess->user_data_sz = pool_priv->user_data_sz; /* Clear device session pointer. * Include the flag indicating presence of user data @@ -1538,6 +1540,9 @@ rte_cryptodev_sym_session_set_user_data( if (sess == NULL) return -EINVAL; + if (sess->user_data_sz < size) + return -ENOMEM; + rte_memcpy(sess->sess_data + sess->nb_drivers, data, size); return 0; } @@ -1546,7 +1551,7 @@ void * __rte_experimental rte_cryptodev_sym_session_get_user_data( struct rte_cryptodev_sym_session *sess) { - if (sess == NULL) + if (sess == NULL || sess->user_data_sz == 0) return NULL; return (void *)(sess->sess_data + sess->nb_drivers); diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 81b7fd1aa..4ca7425c6 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -959,6 +959,8 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, struct rte_cryptodev_sym_session { uint16_t nb_drivers; /**< number of elements in sess_data array */ + uint16_t user_data_sz; + /**< session user data will be placed after sess_data */ __extension__ struct { void *data; } sess_data[0]; @@ -1132,7 +1134,8 @@ rte_cryptodev_asym_session_clear(uint8_t dev_id, struct rte_cryptodev_asym_session *sess); /** - * Get the size of the header session, for all registered drivers. + * Get the size of the header session, for all registered drivers excluding + * the user data size. * * @return * Size of the symmetric eader session. -- 2.13.6