* [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair
@ 2017-03-17 8:45 akhil.goyal
2017-03-17 8:45 ` [dpdk-dev] [PATCH 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: akhil.goyal @ 2017-03-17 8:45 UTC (permalink / raw)
To: dev
Cc: sergio.gonzalez.monroy, declan.doherty, pablo.de.lara.guarch,
fiona.trahe, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
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.
Application can call attach API after creating a session
and can call detach API before deleting a session.
Application needs to check if max_nb_sessions_per_qp > 0,
then it should call the attach API.
max_nb_sessions_per_qp = 0 means infinite sessions per qp
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
lib/librte_cryptodev/rte_cryptodev.c | 41 ++++++++++++++++++++++++++
lib/librte_cryptodev/rte_cryptodev.h | 27 +++++++++++++++++
lib/librte_cryptodev/rte_cryptodev_pmd.h | 29 ++++++++++++++++++
lib/librte_cryptodev/rte_cryptodev_version.map | 2 ++
4 files changed, 99 insertions(+)
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 0ac23ed..f1eabd0 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1393,6 +1393,47 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
return sess;
}
+void
+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=%d", sess->dev_id);
+ return;
+ }
+
+ dev = &rte_crypto_devices[sess->dev_id];
+
+ RTE_FUNC_PTR_OR_RET(*dev->dev_ops->qp_attach_session);
+ 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;
+ }
+}
+
+void
+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=%d", sess->dev_id);
+ return;
+ }
+
+ dev = &rte_crypto_devices[sess->dev_id];
+
+ RTE_FUNC_PTR_OR_RET(*dev->dev_ops->qp_detach_session);
+ 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;
+ }
+}
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..b322bea 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -332,6 +332,9 @@ 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;
};
@@ -915,6 +918,30 @@ extern struct rte_cryptodev_sym_session *
rte_cryptodev_sym_session_free(uint8_t dev_id,
struct rte_cryptodev_sym_session *session);
+/**
+ * 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*.
+ *
+ */
+extern void
+rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+ struct rte_cryptodev_sym_session *session);
+
+/**
+ * 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*.
+ *
+ */
+extern void
+rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+ struct rte_cryptodev_sym_session *session);
+
#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);
+/**
+ * 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 structure
+ * @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 structure
+ * @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);
/** 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. */
};
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 {
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;
} DPDK_17.02;
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 2/2] examples/ipsec-secgw: attach session-qp
2017-03-17 8:45 [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair akhil.goyal
@ 2017-03-17 8:45 ` akhil.goyal
2017-03-20 16:26 ` [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair Trahe, Fiona
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 " akhil.goyal
2 siblings, 0 replies; 15+ messages in thread
From: akhil.goyal @ 2017-03-17 8:45 UTC (permalink / raw)
To: dev
Cc: sergio.gonzalez.monroy, declan.doherty, pablo.de.lara.guarch,
fiona.trahe, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
adding support for attaching session to queue pairs.
This is required as underlying crypto driver may only
support limited number of sessions per queue pair
if max_nb_sessions_per_qp > 0, session should be
attached to a particular qp.
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
examples/ipsec-secgw/ipsec.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 144f0aa..817ff07 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -47,6 +47,7 @@
static inline int
create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
{
+ struct rte_cryptodev_info cdev_info;
unsigned long cdev_id_qp = 0;
int32_t ret;
struct cdev_key key = { 0 };
@@ -73,6 +74,11 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
sa->crypto_session = rte_cryptodev_sym_session_create(
ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
+ rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
+ if (cdev_info.sym.max_nb_sessions_per_qp > 0)
+ rte_cryptodev_queue_pair_attach_sym_session(
+ ipsec_ctx->tbl[cdev_id_qp].qp,
+ sa->crypto_session);
sa->cdev_id_qp = cdev_id_qp;
return 0;
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair
2017-03-17 8:45 [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair akhil.goyal
2017-03-17 8:45 ` [dpdk-dev] [PATCH 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
@ 2017-03-20 16:26 ` Trahe, Fiona
2017-03-21 5:31 ` Akhil Goyal
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 " akhil.goyal
2 siblings, 1 reply; 15+ messages in thread
From: Trahe, Fiona @ 2017-03-20 16:26 UTC (permalink / raw)
To: akhil.goyal, dev
Cc: Gonzalez Monroy, Sergio, Doherty, Declan, De Lara Guarch, Pablo,
Trahe, Fiona
Hi Akhil,
> -----Original Message-----
> From: akhil.goyal@nxp.com [mailto:akhil.goyal@nxp.com]
> Sent: Friday, March 17, 2017 8:45 AM
> To: dev@dpdk.org
> Cc: Gonzalez Monroy, Sergio <sergio.gonzalez.monroy@intel.com>; Doherty,
> Declan <declan.doherty@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Trahe, Fiona <fiona.trahe@intel.com>;
> Akhil Goyal <akhil.goyal@nxp.com>
> Subject: [PATCH 1/2] cryptodev: add api for attach-detach session with queue
> pair
>
> From: Akhil Goyal <akhil.goyal@nxp.com>
>
> 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.
>
> Application can call attach API after creating a session
> and can call detach API before deleting a session.
>
> Application needs to check if max_nb_sessions_per_qp > 0,
> then it should call the attach API.
>
> max_nb_sessions_per_qp = 0 means infinite sessions per qp
>
> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> ---
> lib/librte_cryptodev/rte_cryptodev.c | 41
> ++++++++++++++++++++++++++
> lib/librte_cryptodev/rte_cryptodev.h | 27 +++++++++++++++++
> lib/librte_cryptodev/rte_cryptodev_pmd.h | 29 ++++++++++++++++++
> lib/librte_cryptodev/rte_cryptodev_version.map | 2 ++
> 4 files changed, 99 insertions(+)
>
> diff --git a/lib/librte_cryptodev/rte_cryptodev.c
> b/lib/librte_cryptodev/rte_cryptodev.c
> index 0ac23ed..f1eabd0 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.c
> +++ b/lib/librte_cryptodev/rte_cryptodev.c
> @@ -1393,6 +1393,47 @@ rte_cryptodev_sym_session_create(uint8_t
> dev_id,
> return sess;
> }
>
> +void
> +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=%d", sess->dev_id);
> + return;
> + }
> +
> + dev = &rte_crypto_devices[sess->dev_id];
> +
> + RTE_FUNC_PTR_OR_RET(*dev->dev_ops->qp_attach_session);
> + 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;
> + }
> +}
Wouldn't it be better if this returned an error if e.g. the qp already has max num sessions attached?
> +
> +void
> +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=%d", sess->dev_id);
> + return;
> + }
> +
> + dev = &rte_crypto_devices[sess->dev_id];
> +
> + RTE_FUNC_PTR_OR_RET(*dev->dev_ops->qp_detach_session);
> + 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;
> + }
> +}
> 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..b322bea 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.h
> +++ b/lib/librte_cryptodev/rte_cryptodev.h
> @@ -332,6 +332,9 @@ 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;
> };
>
> @@ -915,6 +918,30 @@ extern struct rte_cryptodev_sym_session *
> rte_cryptodev_sym_session_free(uint8_t dev_id,
> struct rte_cryptodev_sym_session *session);
>
> +/**
> + * 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*.
> + *
> + */
> +extern void
> +rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
> + struct rte_cryptodev_sym_session *session);
> +
> +/**
> + * 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*.
> + *
> + */
> +extern void
> +rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
> + struct rte_cryptodev_sym_session *session);
> +
>
> #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);
>
> +/**
> + * 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 structure
> + * @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 structure
> + * @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);
>
> /** 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. */
> };
>
>
> 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 {
>
> 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;
>
> } DPDK_17.02;
> --
> 2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair
2017-03-20 16:26 ` [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair Trahe, Fiona
@ 2017-03-21 5:31 ` Akhil Goyal
0 siblings, 0 replies; 15+ messages in thread
From: Akhil Goyal @ 2017-03-21 5:31 UTC (permalink / raw)
To: Trahe, Fiona, dev
Cc: Gonzalez Monroy, Sergio, Doherty, Declan, De Lara Guarch, Pablo,
hemant.agrawal
On 3/20/2017 9:56 PM, Trahe, Fiona wrote:
> Hi Akhil,
>
>> -----Original Message-----
>> From: akhil.goyal@nxp.com [mailto:akhil.goyal@nxp.com]
>> Sent: Friday, March 17, 2017 8:45 AM
>> To: dev@dpdk.org
>> Cc: Gonzalez Monroy, Sergio <sergio.gonzalez.monroy@intel.com>; Doherty,
>> Declan <declan.doherty@intel.com>; De Lara Guarch, Pablo
>> <pablo.de.lara.guarch@intel.com>; Trahe, Fiona <fiona.trahe@intel.com>;
>> Akhil Goyal <akhil.goyal@nxp.com>
>> Subject: [PATCH 1/2] cryptodev: add api for attach-detach session with queue
>> pair
>>
>> From: Akhil Goyal <akhil.goyal@nxp.com>
>>
>> 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.
>>
>> Application can call attach API after creating a session
>> and can call detach API before deleting a session.
>>
>> Application needs to check if max_nb_sessions_per_qp > 0,
>> then it should call the attach API.
>>
>> max_nb_sessions_per_qp = 0 means infinite sessions per qp
>>
>> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
>> ---
>> lib/librte_cryptodev/rte_cryptodev.c | 41
>> ++++++++++++++++++++++++++
>> lib/librte_cryptodev/rte_cryptodev.h | 27 +++++++++++++++++
>> lib/librte_cryptodev/rte_cryptodev_pmd.h | 29 ++++++++++++++++++
>> lib/librte_cryptodev/rte_cryptodev_version.map | 2 ++
>> 4 files changed, 99 insertions(+)
>>
>> diff --git a/lib/librte_cryptodev/rte_cryptodev.c
>> b/lib/librte_cryptodev/rte_cryptodev.c
>> index 0ac23ed..f1eabd0 100644
>> --- a/lib/librte_cryptodev/rte_cryptodev.c
>> +++ b/lib/librte_cryptodev/rte_cryptodev.c
>> @@ -1393,6 +1393,47 @@ rte_cryptodev_sym_session_create(uint8_t
>> dev_id,
>> return sess;
>> }
>>
>> +void
>> +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=%d", sess->dev_id);
>> + return;
>> + }
>> +
>> + dev = &rte_crypto_devices[sess->dev_id];
>> +
>> + RTE_FUNC_PTR_OR_RET(*dev->dev_ops->qp_attach_session);
>> + 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;
>> + }
>> +}
>
>
> Wouldn't it be better if this returned an error if e.g. the qp already has max num sessions attached?
ok.. I would correct this.
Regards,
Akhil
>
>
>
>> +
>> +void
>> +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=%d", sess->dev_id);
>> + return;
>> + }
>> +
>> + dev = &rte_crypto_devices[sess->dev_id];
>> +
>> + RTE_FUNC_PTR_OR_RET(*dev->dev_ops->qp_detach_session);
>> + 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;
>> + }
>> +}
>> 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..b322bea 100644
>> --- a/lib/librte_cryptodev/rte_cryptodev.h
>> +++ b/lib/librte_cryptodev/rte_cryptodev.h
>> @@ -332,6 +332,9 @@ 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;
>> };
>>
>> @@ -915,6 +918,30 @@ extern struct rte_cryptodev_sym_session *
>> rte_cryptodev_sym_session_free(uint8_t dev_id,
>> struct rte_cryptodev_sym_session *session);
>>
>> +/**
>> + * 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*.
>> + *
>> + */
>> +extern void
>> +rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
>> + struct rte_cryptodev_sym_session *session);
>> +
>> +/**
>> + * 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*.
>> + *
>> + */
>> +extern void
>> +rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
>> + struct rte_cryptodev_sym_session *session);
>> +
>>
>> #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);
>>
>> +/**
>> + * 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 structure
>> + * @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 structure
>> + * @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);
>>
>> /** 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. */
>> };
>>
>>
>> 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 {
>>
>> 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;
>>
>> } DPDK_17.02;
>> --
>> 2.9.3
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] cryptodev: add api for attach-detach session with queue pair
2017-03-17 8:45 [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair akhil.goyal
2017-03-17 8:45 ` [dpdk-dev] [PATCH 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
2017-03-20 16:26 ` [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair Trahe, Fiona
@ 2017-03-23 8:06 ` akhil.goyal
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
` (2 more replies)
2 siblings, 3 replies; 15+ messages in thread
From: akhil.goyal @ 2017-03-23 8:06 UTC (permalink / raw)
To: dev
Cc: sergio.gonzalez.monroy, declan.doherty, pablo.de.lara.guarch,
fiona.trahe, hemant.agrawal, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
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.
Application can call attach API after creating a session
and can call detach API before deleting a session.
Application needs to check if max_nb_sessions_per_qp > 0,
then it should call the attach API.
max_nb_sessions_per_qp = 0 means infinite sessions per qp
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
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(+)
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;
}
+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=%d", sess->dev_id);
+ return -EINVAL;
+ }
+
+ dev = &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=%d", sess->dev_id);
+ return -EINVAL;
+ }
+
+ dev = &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;
};
@@ -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);
+/**
+ * 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);
+
+/**
+ * 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);
+
#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);
+/**
+ * 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 structure
+ * @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 structure
+ * @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);
/** 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. */
};
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 {
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;
} DPDK_17.02;
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 " akhil.goyal
@ 2017-03-23 8:06 ` akhil.goyal
2017-03-23 10:30 ` Sergio Gonzalez Monroy
2017-03-23 14:37 ` [dpdk-dev] [PATCH v2 1/2] cryptodev: add api for attach-detach session with queue pair Trahe, Fiona
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 " akhil.goyal
2 siblings, 1 reply; 15+ messages in thread
From: akhil.goyal @ 2017-03-23 8:06 UTC (permalink / raw)
To: dev
Cc: sergio.gonzalez.monroy, declan.doherty, pablo.de.lara.guarch,
fiona.trahe, hemant.agrawal, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
adding support for attaching session to queue pairs.
This is required as underlying crypto driver may only
support limited number of sessions per queue pair
if max_nb_sessions_per_qp > 0, session should be
attached to a particular qp.
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
examples/ipsec-secgw/ipsec.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 144f0aa..b35b30f 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -47,6 +47,7 @@
static inline int
create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
{
+ struct rte_cryptodev_info cdev_info;
unsigned long cdev_id_qp = 0;
int32_t ret;
struct cdev_key key = { 0 };
@@ -73,6 +74,17 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
sa->crypto_session = rte_cryptodev_sym_session_create(
ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
+ rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
+ if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
+ ret = rte_cryptodev_queue_pair_attach_sym_session(
+ ipsec_ctx->tbl[cdev_id_qp].qp,
+ sa->crypto_session);
+ if (ret < 0) {
+ RTE_LOG(ERR, IPSEC, "Session cannot be attached"
+ " to qp %u ", ipsec_ctx->tbl[cdev_id_qp].qp);
+ return -1;
+ }
+ }
sa->cdev_id_qp = cdev_id_qp;
return 0;
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
@ 2017-03-23 10:30 ` Sergio Gonzalez Monroy
2017-03-23 10:38 ` Akhil Goyal
0 siblings, 1 reply; 15+ messages in thread
From: Sergio Gonzalez Monroy @ 2017-03-23 10:30 UTC (permalink / raw)
To: akhil.goyal, dev
Cc: declan.doherty, pablo.de.lara.guarch, fiona.trahe, hemant.agrawal
That was simpler than I thought.
For some reason I understood that the device will support thousands of
queues and single session per queue which would have needed more app
changes.
On 23/03/2017 08:06, akhil.goyal@nxp.com wrote:
> From: Akhil Goyal <akhil.goyal@nxp.com>
>
> adding support for attaching session to queue pairs.
> This is required as underlying crypto driver may only
> support limited number of sessions per queue pair
> if max_nb_sessions_per_qp > 0, session should be
> attached to a particular qp.
>
> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> ---
> examples/ipsec-secgw/ipsec.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
> index 144f0aa..b35b30f 100644
> --- a/examples/ipsec-secgw/ipsec.c
> +++ b/examples/ipsec-secgw/ipsec.c
> @@ -47,6 +47,7 @@
> static inline int
> create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
> {
> + struct rte_cryptodev_info cdev_info;
> unsigned long cdev_id_qp = 0;
> int32_t ret;
> struct cdev_key key = { 0 };
> @@ -73,6 +74,17 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
> sa->crypto_session = rte_cryptodev_sym_session_create(
> ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
>
> + rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
> + if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
> + ret = rte_cryptodev_queue_pair_attach_sym_session(
> + ipsec_ctx->tbl[cdev_id_qp].qp,
> + sa->crypto_session);
> + if (ret < 0) {
> + RTE_LOG(ERR, IPSEC, "Session cannot be attached"
> + " to qp %u ", ipsec_ctx->tbl[cdev_id_qp].qp);
Guideline is to keep error strings in single line to facilitate grep.
Other than that:
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
> + return -1;
> + }
> + }
> sa->cdev_id_qp = cdev_id_qp;
>
> return 0;
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp
2017-03-23 10:30 ` Sergio Gonzalez Monroy
@ 2017-03-23 10:38 ` Akhil Goyal
2017-03-23 10:43 ` Sergio Gonzalez Monroy
0 siblings, 1 reply; 15+ messages in thread
From: Akhil Goyal @ 2017-03-23 10:38 UTC (permalink / raw)
To: Sergio Gonzalez Monroy, dev
Cc: declan.doherty, pablo.de.lara.guarch, fiona.trahe, hemant.agrawal
On 3/23/2017 4:00 PM, Sergio Gonzalez Monroy wrote:
> That was simpler than I thought.
>
> For some reason I understood that the device will support thousands of
> queues and single session per queue which would have needed more app
> changes.
>
> On 23/03/2017 08:06, akhil.goyal@nxp.com wrote:
>> From: Akhil Goyal <akhil.goyal@nxp.com>
>>
>> adding support for attaching session to queue pairs.
>> This is required as underlying crypto driver may only
>> support limited number of sessions per queue pair
>> if max_nb_sessions_per_qp > 0, session should be
>> attached to a particular qp.
>>
>> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
>> ---
>> examples/ipsec-secgw/ipsec.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
>> index 144f0aa..b35b30f 100644
>> --- a/examples/ipsec-secgw/ipsec.c
>> +++ b/examples/ipsec-secgw/ipsec.c
>> @@ -47,6 +47,7 @@
>> static inline int
>> create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct
>> ipsec_sa *sa)
>> {
>> + struct rte_cryptodev_info cdev_info;
>> unsigned long cdev_id_qp = 0;
>> int32_t ret;
>> struct cdev_key key = { 0 };
>> @@ -73,6 +74,17 @@ create_session(struct ipsec_ctx *ipsec_ctx
>> __rte_unused, struct ipsec_sa *sa)
>> sa->crypto_session = rte_cryptodev_sym_session_create(
>> ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
>> + rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
>> + if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
>> + ret = rte_cryptodev_queue_pair_attach_sym_session(
>> + ipsec_ctx->tbl[cdev_id_qp].qp,
>> + sa->crypto_session);
>> + if (ret < 0) {
>> + RTE_LOG(ERR, IPSEC, "Session cannot be attached"
>> + " to qp %u ", ipsec_ctx->tbl[cdev_id_qp].qp);
>
> Guideline is to keep error strings in single line to facilitate grep.
> Other than that:
>
> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
>
>> + return -1;
>> + }
>> + }
>> sa->cdev_id_qp = cdev_id_qp;
>> return 0;
>
>
>
Hi Sergio,
Similar error string is mentioned above my change also in the same
function. I deliberately did that as per the error strings in the file.
Thanks,
Akhil
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp
2017-03-23 10:38 ` Akhil Goyal
@ 2017-03-23 10:43 ` Sergio Gonzalez Monroy
2017-03-23 12:18 ` Akhil Goyal
0 siblings, 1 reply; 15+ messages in thread
From: Sergio Gonzalez Monroy @ 2017-03-23 10:43 UTC (permalink / raw)
To: Akhil Goyal, dev
Cc: declan.doherty, pablo.de.lara.guarch, fiona.trahe, hemant.agrawal
On 23/03/2017 10:38, Akhil Goyal wrote:
> On 3/23/2017 4:00 PM, Sergio Gonzalez Monroy wrote:
>> That was simpler than I thought.
>>
>> For some reason I understood that the device will support thousands of
>> queues and single session per queue which would have needed more app
>> changes.
>>
>> On 23/03/2017 08:06, akhil.goyal@nxp.com wrote:
>>> From: Akhil Goyal <akhil.goyal@nxp.com>
>>>
>>> adding support for attaching session to queue pairs.
>>> This is required as underlying crypto driver may only
>>> support limited number of sessions per queue pair
>>> if max_nb_sessions_per_qp > 0, session should be
>>> attached to a particular qp.
>>>
>>> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
>>> ---
>>> examples/ipsec-secgw/ipsec.c | 12 ++++++++++++
>>> 1 file changed, 12 insertions(+)
>>>
>>> diff --git a/examples/ipsec-secgw/ipsec.c
>>> b/examples/ipsec-secgw/ipsec.c
>>> index 144f0aa..b35b30f 100644
>>> --- a/examples/ipsec-secgw/ipsec.c
>>> +++ b/examples/ipsec-secgw/ipsec.c
>>> @@ -47,6 +47,7 @@
>>> static inline int
>>> create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct
>>> ipsec_sa *sa)
>>> {
>>> + struct rte_cryptodev_info cdev_info;
>>> unsigned long cdev_id_qp = 0;
>>> int32_t ret;
>>> struct cdev_key key = { 0 };
>>> @@ -73,6 +74,17 @@ create_session(struct ipsec_ctx *ipsec_ctx
>>> __rte_unused, struct ipsec_sa *sa)
>>> sa->crypto_session = rte_cryptodev_sym_session_create(
>>> ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
>>> + rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
>>> + if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
>>> + ret = rte_cryptodev_queue_pair_attach_sym_session(
>>> + ipsec_ctx->tbl[cdev_id_qp].qp,
>>> + sa->crypto_session);
>>> + if (ret < 0) {
>>> + RTE_LOG(ERR, IPSEC, "Session cannot be attached"
>>> + " to qp %u ", ipsec_ctx->tbl[cdev_id_qp].qp);
>>
>> Guideline is to keep error strings in single line to facilitate grep.
>> Other than that:
>>
>> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
>>
>>> + return -1;
>>> + }
>>> + }
>>> sa->cdev_id_qp = cdev_id_qp;
>>> return 0;
>>
>>
>>
> Hi Sergio,
>
> Similar error string is mentioned above my change also in the same
> function. I deliberately did that as per the error strings in the file.
>
> Thanks,
> Akhil
>
That means that we need to update those strings too, but new code should
try to keep error string in single line.
Thanks,
Sergio
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp
2017-03-23 10:43 ` Sergio Gonzalez Monroy
@ 2017-03-23 12:18 ` Akhil Goyal
0 siblings, 0 replies; 15+ messages in thread
From: Akhil Goyal @ 2017-03-23 12:18 UTC (permalink / raw)
To: Sergio Gonzalez Monroy, dev
Cc: declan.doherty, pablo.de.lara.guarch, fiona.trahe, hemant.agrawal
On 3/23/2017 4:13 PM, Sergio Gonzalez Monroy wrote:
> On 23/03/2017 10:38, Akhil Goyal wrote:
>> On 3/23/2017 4:00 PM, Sergio Gonzalez Monroy wrote:
>>> That was simpler than I thought.
>>>
>>> For some reason I understood that the device will support thousands of
>>> queues and single session per queue which would have needed more app
>>> changes.
>>>
>>> On 23/03/2017 08:06, akhil.goyal@nxp.com wrote:
>>>> From: Akhil Goyal <akhil.goyal@nxp.com>
>>>>
>>>> adding support for attaching session to queue pairs.
>>>> This is required as underlying crypto driver may only
>>>> support limited number of sessions per queue pair
>>>> if max_nb_sessions_per_qp > 0, session should be
>>>> attached to a particular qp.
>>>>
>>>> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
>>>> ---
>>>> examples/ipsec-secgw/ipsec.c | 12 ++++++++++++
>>>> 1 file changed, 12 insertions(+)
>>>>
>>>> diff --git a/examples/ipsec-secgw/ipsec.c
>>>> b/examples/ipsec-secgw/ipsec.c
>>>> index 144f0aa..b35b30f 100644
>>>> --- a/examples/ipsec-secgw/ipsec.c
>>>> +++ b/examples/ipsec-secgw/ipsec.c
>>>> @@ -47,6 +47,7 @@
>>>> static inline int
>>>> create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct
>>>> ipsec_sa *sa)
>>>> {
>>>> + struct rte_cryptodev_info cdev_info;
>>>> unsigned long cdev_id_qp = 0;
>>>> int32_t ret;
>>>> struct cdev_key key = { 0 };
>>>> @@ -73,6 +74,17 @@ create_session(struct ipsec_ctx *ipsec_ctx
>>>> __rte_unused, struct ipsec_sa *sa)
>>>> sa->crypto_session = rte_cryptodev_sym_session_create(
>>>> ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
>>>> + rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
>>>> + if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
>>>> + ret = rte_cryptodev_queue_pair_attach_sym_session(
>>>> + ipsec_ctx->tbl[cdev_id_qp].qp,
>>>> + sa->crypto_session);
>>>> + if (ret < 0) {
>>>> + RTE_LOG(ERR, IPSEC, "Session cannot be attached"
>>>> + " to qp %u ", ipsec_ctx->tbl[cdev_id_qp].qp);
>>>
>>> Guideline is to keep error strings in single line to facilitate grep.
>>> Other than that:
>>>
>>> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
>>>
>>>> + return -1;
>>>> + }
>>>> + }
>>>> sa->cdev_id_qp = cdev_id_qp;
>>>> return 0;
>>>
>>>
>>>
>> Hi Sergio,
>>
>> Similar error string is mentioned above my change also in the same
>> function. I deliberately did that as per the error strings in the file.
>>
>> Thanks,
>> Akhil
>>
>
> That means that we need to update those strings too, but new code should
> try to keep error string in single line.
>
> Thanks,
> Sergio
>
Ok I would correct the string. Will send the v3 with this change only if
there is no more comments from Fiona.
Thanks,
Akhil
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] cryptodev: add api for attach-detach session with queue pair
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 " akhil.goyal
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
@ 2017-03-23 14:37 ` Trahe, Fiona
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 " akhil.goyal
2 siblings, 0 replies; 15+ messages in thread
From: Trahe, Fiona @ 2017-03-23 14:37 UTC (permalink / raw)
To: akhil.goyal, dev
Cc: Gonzalez Monroy, Sergio, Doherty, Declan, De Lara Guarch, Pablo,
hemant.agrawal, Trahe, Fiona
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 <sergio.gonzalez.monroy@intel.com>; Doherty,
> Declan <declan.doherty@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Trahe, Fiona <fiona.trahe@intel.com>;
> hemant.agrawal@nxp.com; Akhil Goyal <akhil.goyal@nxp.com>
> Subject: [PATCH v2 1/2] cryptodev: add api for attach-detach session with
> queue pair
>
> From: Akhil Goyal <akhil.goyal@nxp.com>
>
> 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.
>
> Application can call attach API after creating a session
> and can call detach API before deleting a session.
>
> Application needs to check if max_nb_sessions_per_qp > 0,
> then it should call the attach API.
>
> max_nb_sessions_per_qp = 0 means infinite sessions per qp
>
> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> ---
> 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(+)
>
> 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;
> }
>
> +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=%d", sess->dev_id);
> + return -EINVAL;
> + }
> +
> + dev = &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=%d", sess->dev_id);
> + return -EINVAL;
> + }
> +
> + dev = &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;
> };
>
> @@ -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);
>
> +/**
> + * 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
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);
> +
>
> #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);
>
> +/**
> + * 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 structure
> + * @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 structure
> + * @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);
>
> /** 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. */
> };
>
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 <fiona.trahe@intel.com>
>
> 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 {
>
> 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;
>
> } DPDK_17.02;
> --
> 2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v3 1/2] cryptodev: add api for attach-detach session with queue pair
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 " akhil.goyal
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
2017-03-23 14:37 ` [dpdk-dev] [PATCH v2 1/2] cryptodev: add api for attach-detach session with queue pair Trahe, Fiona
@ 2017-03-24 9:29 ` akhil.goyal
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
2017-03-28 12:58 ` [dpdk-dev] [PATCH v3 1/2] cryptodev: add api for attach-detach session with queue pair De Lara Guarch, Pablo
2 siblings, 2 replies; 15+ messages in thread
From: akhil.goyal @ 2017-03-24 9:29 UTC (permalink / raw)
To: dev
Cc: sergio.gonzalez.monroy, declan.doherty, pablo.de.lara.guarch,
fiona.trahe, hemant.agrawal, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
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.
Application can call attach API after creating a session
and can call detach API before deleting a session.
Application needs to check if max_nb_sessions_per_qp > 0,
then it should call the attach API.
max_nb_sessions_per_qp = 0 means infinite sessions per qp
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
---
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(+)
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;
}
+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=%d", sess->dev_id);
+ return -EINVAL;
+ }
+
+ dev = &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=%d", sess->dev_id);
+ return -EINVAL;
+ }
+
+ dev = &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..f9f3f9e 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;
};
@@ -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);
+/**
+ * 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.
+ */
+int
+rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+ struct rte_cryptodev_sym_session *session);
+
+/**
+ * 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.
+ */
+int
+rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+ struct rte_cryptodev_sym_session *session);
+
#ifdef __cplusplus
}
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 1a417e2..0a4ded0 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);
+/**
+ * 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 structure
+ * @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 structure
+ * @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);
/** 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 session to queue pair. */
+ cryptodev_sym_queue_pair_attach_session_t qp_detach_session;
+ /**< Detach session from queue pair. */
};
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 {
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;
} DPDK_17.02;
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: attach session-qp
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 " akhil.goyal
@ 2017-03-24 9:29 ` akhil.goyal
2017-03-28 12:58 ` De Lara Guarch, Pablo
2017-03-28 12:58 ` [dpdk-dev] [PATCH v3 1/2] cryptodev: add api for attach-detach session with queue pair De Lara Guarch, Pablo
1 sibling, 1 reply; 15+ messages in thread
From: akhil.goyal @ 2017-03-24 9:29 UTC (permalink / raw)
To: dev
Cc: sergio.gonzalez.monroy, declan.doherty, pablo.de.lara.guarch,
fiona.trahe, hemant.agrawal, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
adding support for attaching session to queue pairs.
This is required as underlying crypto driver may only
support limited number of sessions per queue pair
if max_nb_sessions_per_qp > 0, session should be
attached to a particular qp.
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
examples/ipsec-secgw/ipsec.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 144f0aa..edca5f0 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -47,6 +47,7 @@
static inline int
create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
{
+ struct rte_cryptodev_info cdev_info;
unsigned long cdev_id_qp = 0;
int32_t ret;
struct cdev_key key = { 0 };
@@ -73,6 +74,18 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
sa->crypto_session = rte_cryptodev_sym_session_create(
ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
+ rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
+ if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
+ ret = rte_cryptodev_queue_pair_attach_sym_session(
+ ipsec_ctx->tbl[cdev_id_qp].qp,
+ sa->crypto_session);
+ if (ret < 0) {
+ RTE_LOG(ERR, IPSEC,
+ "Session cannot be attached to qp %u ",
+ ipsec_ctx->tbl[cdev_id_qp].qp);
+ return -1;
+ }
+ }
sa->cdev_id_qp = cdev_id_qp;
return 0;
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v3 1/2] cryptodev: add api for attach-detach session with queue pair
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 " akhil.goyal
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
@ 2017-03-28 12:58 ` De Lara Guarch, Pablo
1 sibling, 0 replies; 15+ messages in thread
From: De Lara Guarch, Pablo @ 2017-03-28 12:58 UTC (permalink / raw)
To: akhil.goyal, dev
Cc: Gonzalez Monroy, Sergio, Doherty, Declan, Trahe, Fiona, hemant.agrawal
> -----Original Message-----
> From: akhil.goyal@nxp.com [mailto:akhil.goyal@nxp.com]
> Sent: Friday, March 24, 2017 9:29 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 v3 1/2] cryptodev: add api for attach-detach session with
> queue pair
>
> From: Akhil Goyal <akhil.goyal@nxp.com>
>
> 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.
>
> Application can call attach API after creating a session
> and can call detach API before deleting a session.
>
> Application needs to check if max_nb_sessions_per_qp > 0,
> then it should call the attach API.
>
> max_nb_sessions_per_qp = 0 means infinite sessions per qp
>
> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Applied to dpdk-next-crypto.
Thanks,
Pablo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: attach session-qp
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
@ 2017-03-28 12:58 ` De Lara Guarch, Pablo
0 siblings, 0 replies; 15+ messages in thread
From: De Lara Guarch, Pablo @ 2017-03-28 12:58 UTC (permalink / raw)
To: akhil.goyal, dev
Cc: Gonzalez Monroy, Sergio, Doherty, Declan, Trahe, Fiona, hemant.agrawal
> -----Original Message-----
> From: akhil.goyal@nxp.com [mailto:akhil.goyal@nxp.com]
> Sent: Friday, March 24, 2017 9:29 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 v3 2/2] examples/ipsec-secgw: attach session-qp
>
> From: Akhil Goyal <akhil.goyal@nxp.com>
>
> adding support for attaching session to queue pairs.
> This is required as underlying crypto driver may only
> support limited number of sessions per queue pair
> if max_nb_sessions_per_qp > 0, session should be
> attached to a particular qp.
>
> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Applied to dpdk-next-crypto.
Thanks,
Pablo
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-03-28 12:59 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 8:45 [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair akhil.goyal
2017-03-17 8:45 ` [dpdk-dev] [PATCH 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
2017-03-20 16:26 ` [dpdk-dev] [PATCH 1/2] cryptodev: add api for attach-detach session with queue pair Trahe, Fiona
2017-03-21 5:31 ` Akhil Goyal
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 " akhil.goyal
2017-03-23 8:06 ` [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
2017-03-23 10:30 ` Sergio Gonzalez Monroy
2017-03-23 10:38 ` Akhil Goyal
2017-03-23 10:43 ` Sergio Gonzalez Monroy
2017-03-23 12:18 ` Akhil Goyal
2017-03-23 14:37 ` [dpdk-dev] [PATCH v2 1/2] cryptodev: add api for attach-detach session with queue pair Trahe, Fiona
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 " akhil.goyal
2017-03-24 9:29 ` [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: attach session-qp akhil.goyal
2017-03-28 12:58 ` De Lara Guarch, Pablo
2017-03-28 12:58 ` [dpdk-dev] [PATCH v3 1/2] cryptodev: add api for attach-detach session with queue pair De Lara Guarch, Pablo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).