From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8B141695C for ; Thu, 23 Mar 2017 15:38:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490279881; x=1521815881; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=MlGOOAFqggNziJlCEMinYHrxYWnGdsotDQh7NwEXH50=; b=RJoFBF6iGvDg18Zy1/mHbVq6mAjNsDsjrysJU48YF6MWAH8c+3lq+vm6 cyJ4L+G/p3jS3tvWt5DB9tZuCAFCKg==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Mar 2017 07:38:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,210,1486454400"; d="scan'208";a="80255679" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by fmsmga006.fm.intel.com with ESMTP; 23 Mar 2017 07:37:59 -0700 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.112]) by irsmsx105.ger.corp.intel.com ([169.254.7.195]) with mapi id 14.03.0248.002; Thu, 23 Mar 2017 14:37:58 +0000 From: "Trahe, Fiona" To: "akhil.goyal@nxp.com" , "dev@dpdk.org" CC: "Gonzalez Monroy, Sergio" , "Doherty, Declan" , "De Lara Guarch, Pablo" , "hemant.agrawal@nxp.com" , "Trahe, Fiona" Thread-Topic: [PATCH v2 1/2] cryptodev: add api for attach-detach session with queue pair Thread-Index: AQHSo6yHlAHTYokxrEGuosNh3HI8SaGie+Cw Date: Thu, 23 Mar 2017 14:37:58 +0000 Message-ID: <348A99DA5F5B7549AA880327E580B435891AB5C7@IRSMSX101.ger.corp.intel.com> References: <20170317084510.2120-1-akhil.goyal@nxp.com> <20170323080648.7149-1-akhil.goyal@nxp.com> In-Reply-To: <20170323080648.7149-1-akhil.goyal@nxp.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2I2Y2E3YTktMTZiMy00ZjI1LWJjZDgtYTgzZmEwZGFhMjIxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkRlVUs4SDZTdmZXSGJnREVzRVgxWStWUms5b0JSZmRzWWJUZnROcGNUOW89In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 1/2] cryptodev: add api for attach-detach session with queue pair 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, 23 Mar 2017 14:38:02 -0000 Hi Akhil > -----Original Message----- > From: akhil.goyal@nxp.com [mailto:akhil.goyal@nxp.com] > Sent: Thursday, March 23, 2017 8:07 AM > To: dev@dpdk.org > Cc: Gonzalez Monroy, Sergio ; Doherty, > Declan ; De Lara Guarch, Pablo > ; Trahe, Fiona ; > hemant.agrawal@nxp.com; Akhil Goyal > Subject: [PATCH v2 1/2] cryptodev: add api for attach-detach session with > queue pair >=20 > From: Akhil Goyal >=20 > HW based crypto drivers may only support limited number of > sessions per queue pair. This requires support for attaching > sessions to specific queue pair. New APIs are introduced to > attach/detach a session with/from a particular queue pair. > These are optional APIs. >=20 > Application can call attach API after creating a session > and can call detach API before deleting a session. >=20 > Application needs to check if max_nb_sessions_per_qp > 0, > then it should call the attach API. >=20 > max_nb_sessions_per_qp =3D 0 means infinite sessions per qp >=20 > Signed-off-by: Akhil Goyal > --- > lib/librte_cryptodev/rte_cryptodev.c | 47 > ++++++++++++++++++++++++++ > lib/librte_cryptodev/rte_cryptodev.h | 34 +++++++++++++++++++ > lib/librte_cryptodev/rte_cryptodev_pmd.h | 29 ++++++++++++++++ > lib/librte_cryptodev/rte_cryptodev_version.map | 2 ++ > 4 files changed, 112 insertions(+) >=20 > diff --git a/lib/librte_cryptodev/rte_cryptodev.c > b/lib/librte_cryptodev/rte_cryptodev.c > index 0ac23ed..eb72f03 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.c > +++ b/lib/librte_cryptodev/rte_cryptodev.c > @@ -1393,6 +1393,53 @@ rte_cryptodev_sym_session_create(uint8_t > dev_id, > return sess; > } >=20 > +int > +rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id, > + struct rte_cryptodev_sym_session *sess) > +{ > + struct rte_cryptodev *dev; > + > + if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) { > + CDEV_LOG_ERR("Invalid dev_id=3D%d", sess->dev_id); > + return -EINVAL; > + } > + > + dev =3D &rte_crypto_devices[sess->dev_id]; > + > + /* The API is optional, not returning error if driver do not suuport */ > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0); > + if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) { > + CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with > session", > + sess->dev_id, qp_id); > + return -EPERM; > + } > + > + return 0; > +} > + > +int > +rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id, > + struct rte_cryptodev_sym_session *sess) > +{ > + struct rte_cryptodev *dev; > + > + if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) { > + CDEV_LOG_ERR("Invalid dev_id=3D%d", sess->dev_id); > + return -EINVAL; > + } > + > + dev =3D &rte_crypto_devices[sess->dev_id]; > + > + /* The API is optional, not returning error if driver do not suuport */ > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, > 0); > + if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) { > + CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from > session", > + sess->dev_id, qp_id); > + return -EPERM; > + } > + > + return 0; > +} > struct rte_cryptodev_sym_session * > rte_cryptodev_sym_session_free(uint8_t dev_id, > struct rte_cryptodev_sym_session *sess) > diff --git a/lib/librte_cryptodev/rte_cryptodev.h > b/lib/librte_cryptodev/rte_cryptodev.h > index d61a43e..05e5b4e 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.h > +++ b/lib/librte_cryptodev/rte_cryptodev.h > @@ -332,6 +332,10 @@ struct rte_cryptodev_info { > struct { > unsigned max_nb_sessions; > /**< Maximum number of sessions supported by device. */ > + unsigned max_nb_sessions_per_qp; > + /**< Maximum number of sessions per queue pair. > + * Default 0 for infinite sessions > + */ > } sym; > }; >=20 > @@ -915,6 +919,36 @@ extern struct rte_cryptodev_sym_session * > rte_cryptodev_sym_session_free(uint8_t dev_id, > struct rte_cryptodev_sym_session *session); >=20 > +/** > + * Attach queue pair with sym session. > + * > + * @param qp_id Queue pair to which session will be attached. > + * @param session Session pointer previously allocated by > + * *rte_cryptodev_sym_session_create*. > + * > + * @return > + * - On success, zero. > + * - On failure, a negative value. > + */ > +extern int > +rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id, > + struct rte_cryptodev_sym_session *session); > + Just a nit - is there a reason why these 2 fns have extern label? I see several other fns in same file which also have this, though not=20 needed, so maybe just a cut-and-paste? > +/** > + * Detach queue pair with sym session. > + * > + * @param qp_id Queue pair to which session is attached. > + * @param session Session pointer previously allocated by > + * *rte_cryptodev_sym_session_create*. > + * > + * @return > + * - On success, zero. > + * - On failure, a negative value. > + */ > +extern int > +rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id, > + struct rte_cryptodev_sym_session *session); > + >=20 > #ifdef __cplusplus > } > diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h > b/lib/librte_cryptodev/rte_cryptodev_pmd.h > index 1a417e2..df92817 100644 > --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h > +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h > @@ -381,6 +381,31 @@ typedef void * > (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev, > typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev, > void *session_private); >=20 > +/** > + * Optional API for drivers to attach sessions with queue pair. > + * @param dev Crypto device pointer > + * @param qp_id queue pair id for attaching session > + * @param priv_sess Pointer to cryptodev's private session structu= re > + * @return > + * - Return 0 on success > + */ > +typedef int (*cryptodev_sym_queue_pair_attach_session_t)( > + struct rte_cryptodev *dev, > + uint16_t qp_id, > + void *session_private); > + > +/** > + * Optional API for drivers to detach sessions from queue pair. > + * @param dev Crypto device pointer > + * @param qp_id queue pair id for detaching session > + * @param priv_sess Pointer to cryptodev's private session structu= re > + * @return > + * - Return 0 on success > + */ > +typedef int (*cryptodev_sym_queue_pair_detach_session_t)( > + struct rte_cryptodev *dev, > + uint16_t qp_id, > + void *session_private); >=20 > /** Crypto device operations function pointer table */ > struct rte_cryptodev_ops { > @@ -415,6 +440,10 @@ struct rte_cryptodev_ops { > /**< Configure a Crypto session. */ > cryptodev_sym_free_session_t session_clear; > /**< Clear a Crypto sessions private data. */ > + cryptodev_sym_queue_pair_attach_session_t qp_attach_session; > + /**< Attach queue pair with session. */ > + cryptodev_sym_queue_pair_attach_session_t qp_detach_session; > + /**< Detach queue pair from session. */ > }; >=20 Another nit. It would be more correct for comments to say Attach session to queue pair /= Detach session from queue pair. Apart from those nits Acked-by: Fiona Trahe >=20 > diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map > b/lib/librte_cryptodev/rte_cryptodev_version.map > index 831a15c..9ac510e 100644 > --- a/lib/librte_cryptodev/rte_cryptodev_version.map > +++ b/lib/librte_cryptodev/rte_cryptodev_version.map > @@ -70,5 +70,7 @@ DPDK_17.05 { >=20 > rte_cryptodev_get_auth_algo_enum; > rte_cryptodev_get_cipher_algo_enum; > + rte_cryptodev_queue_pair_attach_sym_session; > + rte_cryptodev_queue_pair_detach_sym_session; >=20 > } DPDK_17.02; > -- > 2.9.3