From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id ADA701B902 for ; Thu, 10 Jan 2019 15:50:45 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2019 06:50:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,461,1539673200"; d="scan'208";a="126595110" Received: from silpixa00398673.ir.intel.com (HELO silpixa00398673.ger.corp.intel.com) ([10.237.223.54]) by orsmga001.jf.intel.com with ESMTP; 10 Jan 2019 06:50:43 -0800 From: Fan Zhang To: dev@dpdk.org Cc: akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com, fiona.trahe@intel.com Date: Thu, 10 Jan 2019 14:50:20 +0000 Message-Id: <20190110145022.42883-11-roy.fan.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190110145022.42883-1-roy.fan.zhang@intel.com> References: <20190109225609.20590-1-roy.fan.zhang@intel.com> <20190110145022.42883-1-roy.fan.zhang@intel.com> Subject: [dpdk-dev] [PATCH v5 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: Thu, 10 Jan 2019 14:50:46 -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/cryptodev_lib.rst | 4 + doc/guides/prog_guide/img/cryptodev_sym_sess.svg | 172 ++++++++++++----------- lib/librte_cryptodev/rte_cryptodev.c | 11 +- lib/librte_cryptodev/rte_cryptodev.h | 5 +- 4 files changed, 107 insertions(+), 85 deletions(-) diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst index f68fb72d3..74a930b6d 100644 --- a/doc/guides/prog_guide/cryptodev_lib.rst +++ b/doc/guides/prog_guide/cryptodev_lib.rst @@ -327,6 +327,10 @@ the set API to set the user data and retrieve it using get API. void * rte_cryptodev_sym_session_get_user_data( struct rte_cryptodev_sym_session *sess); +Please note the ``size`` passed to set API cannot be bigger than the predefined +``user_data_sz`` when creating the session header mempool, otherwise the +function will return error. Also when ``user_data_sz`` was defined as ``0`` when +creating the session header mempool, the get API will always return ``NULL``. For session-less mode, the private user data information can be placed along with the ``struct rte_crypto_op``. The ``rte_crypto_op::private_data_offset`` indicates the 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 cc22a1878..232cd1aa8 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