DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] Session crypto event metadata api
@ 2022-03-25 11:16 Volodymyr Fialko
  2022-03-25 11:16 ` [PATCH 1/2] security: introduce per session event metadata Volodymyr Fialko
                   ` (2 more replies)
  0 siblings, 3 replies; 69+ messages in thread
From: Volodymyr Fialko @ 2022-03-25 11:16 UTC (permalink / raw)
  To: dev; +Cc: jerinj, Volodymyr Fialko

Implement API to set/get crypto event meta data per security session.

Volodymyr Fialko (2):
  security: introduce per session event metadata
  crypto/cnxk: support for security session enqueue

 .../prog_guide/event_crypto_adapter.rst       |  4 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h      |  5 +++
 lib/security/rte_security.h                   | 43 +++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH 1/2] security: introduce per session event metadata
  2022-03-25 11:16 [PATCH 0/2] Session crypto event metadata api Volodymyr Fialko
@ 2022-03-25 11:16 ` Volodymyr Fialko
  2022-04-04  8:38   ` Gujjar, Abhinandan S
  2022-03-25 11:16 ` [PATCH 2/2] crypto/cnxk: support for security session enqueue Volodymyr Fialko
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
  2 siblings, 1 reply; 69+ messages in thread
From: Volodymyr Fialko @ 2022-03-25 11:16 UTC (permalink / raw)
  To: dev, Abhinandan Gujjar, Akhil Goyal
  Cc: jerinj, Volodymyr Fialko, Anoob Joseph

Implement API to set/get event data per security session.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 .../prog_guide/event_crypto_adapter.rst       |  4 +-
 lib/security/rte_security.h                   | 43 +++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/doc/guides/prog_guide/event_crypto_adapter.rst b/doc/guides/prog_guide/event_crypto_adapter.rst
index 4fb5c688e0..227b36b4b7 100644
--- a/doc/guides/prog_guide/event_crypto_adapter.rst
+++ b/doc/guides/prog_guide/event_crypto_adapter.rst
@@ -246,9 +246,9 @@ by ``rte_cryptodev_sym_session_get_user_data()`` API.  The
 RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA capability indicates
 whether HW or SW supports this feature.
 
-For security session, ``rte_security_session_set_private_data()`` API
+For security session, ``rte_security_session_set_event_mdata()`` API
 will be used to set request/response data. The same data will be obtained
-by ``rte_security_session_get_private_data()`` API.
+by ``rte_security_session_get_event_mdata()`` API.
 
 For session-less it is mandatory to place the request/response data with
 the ``rte_crypto_op``.
diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h
index b080d10c2c..29ec514504 100644
--- a/lib/security/rte_security.h
+++ b/lib/security/rte_security.h
@@ -526,6 +526,8 @@ struct rte_security_session {
 	/**< Private session material */
 	uint64_t opaque_data;
 	/**< Opaque user defined data */
+	void *event_mdata;
+	/**< Event request/response information */
 };
 
 /**
@@ -729,6 +731,47 @@ set_sec_session_private_data(struct rte_security_session *sess,
 	sess->sess_private_data = private_data;
 }
 
+/**
+ * Get event meta data attached to a security session.
+ *
+ * @param	sess		Session pointer allocated by
+ *				*rte_security_session_create*.
+ *
+ * @return
+ *  - On success return pointer to the event crypto meta data which is set
+ *    using *rte_security_session_set_event_mdata*
+ *  - On failure returns NULL.
+ */
+__rte_experimental
+static inline void *
+rte_security_session_get_event_mdata(const struct rte_security_session *sess)
+{
+	return sess->event_mdata;
+}
+
+/**
+ * Attach event crypto meta data to a security session.
+ *
+ * Application can allocate memory for *rte_event_crypto_metadata* and set the
+ * reference pointer using this API which the PMD can retrieve using
+ * *rte_security_session_get_event_mdata*
+ *
+ * The API should be used only in case session is used for event crypto
+ * adapter.
+ *
+ * @param	sess		Session pointer allocated by
+ *				*rte_security_session_create*.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ */
+__rte_experimental
+static inline void
+rte_security_session_set_event_mdata(struct rte_security_session *sess,
+				     void *ev_mdata)
+{
+	sess->event_mdata = ev_mdata;
+}
+
 /**
  * Attach a session to a crypto operation.
  * This API is needed only in case of RTE_SECURITY_SESS_CRYPTO_PROTO_OFFLOAD
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH 2/2] crypto/cnxk: support for security session enqueue
  2022-03-25 11:16 [PATCH 0/2] Session crypto event metadata api Volodymyr Fialko
  2022-03-25 11:16 ` [PATCH 1/2] security: introduce per session event metadata Volodymyr Fialko
@ 2022-03-25 11:16 ` Volodymyr Fialko
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
  2 siblings, 0 replies; 69+ messages in thread
From: Volodymyr Fialko @ 2022-03-25 11:16 UTC (permalink / raw)
  To: dev, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj
  Cc: jerinj, Volodymyr Fialko

Add support for enqueue security session to event crypto adapter. Event
metadata is used to store request/response information that is needed to
enqueue an event after the crypto operation completed.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
index 1c58254bef..857fe95e1c 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
@@ -7,6 +7,7 @@
 
 #include <rte_cryptodev.h>
 #include <rte_event_crypto_adapter.h>
+#include <rte_security.h>
 
 #include "roc_api.h"
 
@@ -142,6 +143,10 @@ cnxk_event_crypto_mdata_get(struct rte_crypto_op *op)
 		 op->private_data_offset)
 		ec_mdata = (union rte_event_crypto_metadata
 				    *)((uint8_t *)op + op->private_data_offset);
+	else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION &&
+		 op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
+		ec_mdata = rte_security_session_get_event_mdata(
+			op->sym->sec_session);
 	else
 		return NULL;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH 1/2] security: introduce per session event metadata
  2022-03-25 11:16 ` [PATCH 1/2] security: introduce per session event metadata Volodymyr Fialko
@ 2022-04-04  8:38   ` Gujjar, Abhinandan S
  2022-04-04  9:48     ` Akhil Goyal
  0 siblings, 1 reply; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-04-04  8:38 UTC (permalink / raw)
  To: Volodymyr Fialko, dev, Akhil Goyal; +Cc: jerinj, Anoob Joseph

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Volodymyr Fialko <vfialko@marvell.com>
> Sent: Friday, March 25, 2022 4:46 PM
> To: dev@dpdk.org; Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; Akhil
> Goyal <gakhil@marvell.com>
> Cc: jerinj@marvell.com; Volodymyr Fialko <vfialko@marvell.com>; Anoob
> Joseph <anoobj@marvell.com>
> Subject: [PATCH 1/2] security: introduce per session event metadata
> 
> Implement API to set/get event data per security session.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Acked-by: Akhil Goyal <gakhil@marvell.com>
> Acked-by: Anoob Joseph <anoobj@marvell.com>
> ---
>  .../prog_guide/event_crypto_adapter.rst       |  4 +-
>  lib/security/rte_security.h                   | 43 +++++++++++++++++++
>  2 files changed, 45 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/guides/prog_guide/event_crypto_adapter.rst
> b/doc/guides/prog_guide/event_crypto_adapter.rst
> index 4fb5c688e0..227b36b4b7 100644
> --- a/doc/guides/prog_guide/event_crypto_adapter.rst
> +++ b/doc/guides/prog_guide/event_crypto_adapter.rst
> @@ -246,9 +246,9 @@ by ``rte_cryptodev_sym_session_get_user_data()`` API.
> The  RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA capability
> indicates  whether HW or SW supports this feature.
> 
> -For security session, ``rte_security_session_set_private_data()`` API
> +For security session, ``rte_security_session_set_event_mdata()`` API
>  will be used to set request/response data. The same data will be obtained -by
> ``rte_security_session_get_private_data()`` API.
> +by ``rte_security_session_get_event_mdata()`` API.
> 
>  For session-less it is mandatory to place the request/response data with  the
> ``rte_crypto_op``.
> diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h index
> b080d10c2c..29ec514504 100644
> --- a/lib/security/rte_security.h
> +++ b/lib/security/rte_security.h
> @@ -526,6 +526,8 @@ struct rte_security_session {
>  	/**< Private session material */
>  	uint64_t opaque_data;
>  	/**< Opaque user defined data */
> +	void *event_mdata;
> +	/**< Event request/response information */
>  };
> 
>  /**
> @@ -729,6 +731,47 @@ set_sec_session_private_data(struct
> rte_security_session *sess,
>  	sess->sess_private_data = private_data;  }
> 
> +/**
> + * Get event meta data attached to a security session.
> + *
> + * @param	sess		Session pointer allocated by
> + *				*rte_security_session_create*.
> + *
> + * @return
> + *  - On success return pointer to the event crypto meta data which is set
> + *    using *rte_security_session_set_event_mdata*
> + *  - On failure returns NULL.
> + */
> +__rte_experimental
> +static inline void *
> +rte_security_session_get_event_mdata(const struct rte_security_session
> +*sess) {
> +	return sess->event_mdata;
> +}
> +
> +/**
> + * Attach event crypto meta data to a security session.
> + *
> + * Application can allocate memory for *rte_event_crypto_metadata* and
> +set the
> + * reference pointer using this API which the PMD can retrieve using
> + * *rte_security_session_get_event_mdata*
> + *
> + * The API should be used only in case session is used for event crypto
> + * adapter.
> + *
> + * @param	sess		Session pointer allocated by
> + *				*rte_security_session_create*.
> + * @param	ev_mdata	Pointer to the event crypto meta data
> + *				(aka *union rte_event_crypto_metadata*)
> + */
> +__rte_experimental
> +static inline void
> +rte_security_session_set_event_mdata(struct rte_security_session *sess,
> +				     void *ev_mdata)
> +{
> +	sess->event_mdata = ev_mdata;
> +}
> +
>  /**
>   * Attach a session to a crypto operation.
>   * This API is needed only in case of
> RTE_SECURITY_SESS_CRYPTO_PROTO_OFFLOAD
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH 1/2] security: introduce per session event metadata
  2022-04-04  8:38   ` Gujjar, Abhinandan S
@ 2022-04-04  9:48     ` Akhil Goyal
  2022-04-04 10:42       ` Gujjar, Abhinandan S
  0 siblings, 1 reply; 69+ messages in thread
From: Akhil Goyal @ 2022-04-04  9:48 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, Volodymyr Fialko, dev
  Cc: Jerin Jacob Kollanukkaran, Anoob Joseph

Hi Abhinandan,
> ----------------------------------------------------------------------
> Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
> 
This change would be an ABI breakage. So to avoid that, we are planning to
Propose a better solution compared to this patch.
We plan to add a new cryptodev op to set the event metadata. A single API
which can be used in all cases - sym/asym/security sessions.

As currently in case of sym crypto, userdata is being used for storing the event
Metadata and it is then dereferenced in the PMD which is wrong.
User data is meant only for user to use and PMD should not dereference it.

Hence a new cryptodev op can be used to set session event metadata
explicitly if event mode is enabled.

I will be sending the proposal soon. Would need your help in testing the
Intel usecases.

Regards,
Akhil
> > -----Original Message-----
> > From: Volodymyr Fialko <vfialko@marvell.com>
> > Sent: Friday, March 25, 2022 4:46 PM
> > To: dev@dpdk.org; Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>;
> Akhil
> > Goyal <gakhil@marvell.com>
> > Cc: jerinj@marvell.com; Volodymyr Fialko <vfialko@marvell.com>; Anoob
> > Joseph <anoobj@marvell.com>
> > Subject: [PATCH 1/2] security: introduce per session event metadata
> >
> > Implement API to set/get event data per security session.
> >
> > Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> > Acked-by: Akhil Goyal <gakhil@marvell.com>
> > Acked-by: Anoob Joseph <anoobj@marvell.com>
> > ---
> >  .../prog_guide/event_crypto_adapter.rst       |  4 +-
> >  lib/security/rte_security.h                   | 43 +++++++++++++++++++
> >  2 files changed, 45 insertions(+), 2 deletions(-)
> >
> > diff --git a/doc/guides/prog_guide/event_crypto_adapter.rst
> > b/doc/guides/prog_guide/event_crypto_adapter.rst
> > index 4fb5c688e0..227b36b4b7 100644
> > --- a/doc/guides/prog_guide/event_crypto_adapter.rst
> > +++ b/doc/guides/prog_guide/event_crypto_adapter.rst
> > @@ -246,9 +246,9 @@ by ``rte_cryptodev_sym_session_get_user_data()``
> API.
> > The  RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA capability
> > indicates  whether HW or SW supports this feature.
> >
> > -For security session, ``rte_security_session_set_private_data()`` API
> > +For security session, ``rte_security_session_set_event_mdata()`` API
> >  will be used to set request/response data. The same data will be obtained -by
> > ``rte_security_session_get_private_data()`` API.
> > +by ``rte_security_session_get_event_mdata()`` API.
> >
> >  For session-less it is mandatory to place the request/response data with  the
> > ``rte_crypto_op``.
> > diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h index
> > b080d10c2c..29ec514504 100644
> > --- a/lib/security/rte_security.h
> > +++ b/lib/security/rte_security.h
> > @@ -526,6 +526,8 @@ struct rte_security_session {
> >  	/**< Private session material */
> >  	uint64_t opaque_data;
> >  	/**< Opaque user defined data */
> > +	void *event_mdata;
> > +	/**< Event request/response information */
> >  };
> >
> >  /**
> > @@ -729,6 +731,47 @@ set_sec_session_private_data(struct
> > rte_security_session *sess,
> >  	sess->sess_private_data = private_data;  }
> >
> > +/**
> > + * Get event meta data attached to a security session.
> > + *
> > + * @param	sess		Session pointer allocated by
> > + *				*rte_security_session_create*.
> > + *
> > + * @return
> > + *  - On success return pointer to the event crypto meta data which is set
> > + *    using *rte_security_session_set_event_mdata*
> > + *  - On failure returns NULL.
> > + */
> > +__rte_experimental
> > +static inline void *
> > +rte_security_session_get_event_mdata(const struct rte_security_session
> > +*sess) {
> > +	return sess->event_mdata;
> > +}
> > +
> > +/**
> > + * Attach event crypto meta data to a security session.
> > + *
> > + * Application can allocate memory for *rte_event_crypto_metadata* and
> > +set the
> > + * reference pointer using this API which the PMD can retrieve using
> > + * *rte_security_session_get_event_mdata*
> > + *
> > + * The API should be used only in case session is used for event crypto
> > + * adapter.
> > + *
> > + * @param	sess		Session pointer allocated by
> > + *				*rte_security_session_create*.
> > + * @param	ev_mdata	Pointer to the event crypto meta data
> > + *				(aka *union rte_event_crypto_metadata*)
> > + */
> > +__rte_experimental
> > +static inline void
> > +rte_security_session_set_event_mdata(struct rte_security_session *sess,
> > +				     void *ev_mdata)
> > +{
> > +	sess->event_mdata = ev_mdata;
> > +}
> > +
> >  /**
> >   * Attach a session to a crypto operation.
> >   * This API is needed only in case of
> > RTE_SECURITY_SESS_CRYPTO_PROTO_OFFLOAD
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH 1/2] security: introduce per session event metadata
  2022-04-04  9:48     ` Akhil Goyal
@ 2022-04-04 10:42       ` Gujjar, Abhinandan S
  2022-04-13  7:13         ` Akhil Goyal
  0 siblings, 1 reply; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-04-04 10:42 UTC (permalink / raw)
  To: Akhil Goyal, Volodymyr Fialko, dev, Jayatheerthan, Jay, Vangati,
	Narender
  Cc: Jerin Jacob Kollanukkaran, Anoob Joseph

+ @Jayatheerthan, Jay & @Vangati, Narender

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Monday, April 4, 2022 3:19 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; Volodymyr Fialko
> <vfialko@marvell.com>; dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Anoob Joseph
> <anoobj@marvell.com>
> Subject: RE: [PATCH 1/2] security: introduce per session event metadata
> 
> Hi Abhinandan,
> > ----------------------------------------------------------------------
> > Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
> >
> This change would be an ABI breakage. So to avoid that, we are planning to
> Propose a better solution compared to this patch.
> We plan to add a new cryptodev op to set the event metadata. A single API
> which can be used in all cases - sym/asym/security sessions.
> 
> As currently in case of sym crypto, userdata is being used for storing the event
> Metadata and it is then dereferenced in the PMD which is wrong.
> User data is meant only for user to use and PMD should not dereference it.
> 
> Hence a new cryptodev op can be used to set session event metadata explicitly
> if event mode is enabled.
> 
> I will be sending the proposal soon. Would need your help in testing the Intel
> usecases.
> 
> Regards,
> Akhil
> > > -----Original Message-----
> > > From: Volodymyr Fialko <vfialko@marvell.com>
> > > Sent: Friday, March 25, 2022 4:46 PM
> > > To: dev@dpdk.org; Gujjar, Abhinandan S
> > > <abhinandan.gujjar@intel.com>;
> > Akhil
> > > Goyal <gakhil@marvell.com>
> > > Cc: jerinj@marvell.com; Volodymyr Fialko <vfialko@marvell.com>;
> > > Anoob Joseph <anoobj@marvell.com>
> > > Subject: [PATCH 1/2] security: introduce per session event metadata
> > >
> > > Implement API to set/get event data per security session.
> > >
> > > Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> > > Acked-by: Akhil Goyal <gakhil@marvell.com>
> > > Acked-by: Anoob Joseph <anoobj@marvell.com>
> > > ---
> > >  .../prog_guide/event_crypto_adapter.rst       |  4 +-
> > >  lib/security/rte_security.h                   | 43 +++++++++++++++++++
> > >  2 files changed, 45 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/doc/guides/prog_guide/event_crypto_adapter.rst
> > > b/doc/guides/prog_guide/event_crypto_adapter.rst
> > > index 4fb5c688e0..227b36b4b7 100644
> > > --- a/doc/guides/prog_guide/event_crypto_adapter.rst
> > > +++ b/doc/guides/prog_guide/event_crypto_adapter.rst
> > > @@ -246,9 +246,9 @@ by ``rte_cryptodev_sym_session_get_user_data()``
> > API.
> > > The  RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA
> capability
> > > indicates  whether HW or SW supports this feature.
> > >
> > > -For security session, ``rte_security_session_set_private_data()``
> > > API
> > > +For security session, ``rte_security_session_set_event_mdata()``
> > > +API
> > >  will be used to set request/response data. The same data will be
> > > obtained -by ``rte_security_session_get_private_data()`` API.
> > > +by ``rte_security_session_get_event_mdata()`` API.
> > >
> > >  For session-less it is mandatory to place the request/response data
> > > with  the ``rte_crypto_op``.
> > > diff --git a/lib/security/rte_security.h
> > > b/lib/security/rte_security.h index
> > > b080d10c2c..29ec514504 100644
> > > --- a/lib/security/rte_security.h
> > > +++ b/lib/security/rte_security.h
> > > @@ -526,6 +526,8 @@ struct rte_security_session {
> > >  	/**< Private session material */
> > >  	uint64_t opaque_data;
> > >  	/**< Opaque user defined data */
> > > +	void *event_mdata;
> > > +	/**< Event request/response information */
> > >  };
> > >
> > >  /**
> > > @@ -729,6 +731,47 @@ set_sec_session_private_data(struct
> > > rte_security_session *sess,
> > >  	sess->sess_private_data = private_data;  }
> > >
> > > +/**
> > > + * Get event meta data attached to a security session.
> > > + *
> > > + * @param	sess		Session pointer allocated by
> > > + *				*rte_security_session_create*.
> > > + *
> > > + * @return
> > > + *  - On success return pointer to the event crypto meta data which is set
> > > + *    using *rte_security_session_set_event_mdata*
> > > + *  - On failure returns NULL.
> > > + */
> > > +__rte_experimental
> > > +static inline void *
> > > +rte_security_session_get_event_mdata(const struct
> > > +rte_security_session
> > > +*sess) {
> > > +	return sess->event_mdata;
> > > +}
> > > +
> > > +/**
> > > + * Attach event crypto meta data to a security session.
> > > + *
> > > + * Application can allocate memory for *rte_event_crypto_metadata*
> > > +and set the
> > > + * reference pointer using this API which the PMD can retrieve
> > > +using
> > > + * *rte_security_session_get_event_mdata*
> > > + *
> > > + * The API should be used only in case session is used for event
> > > +crypto
> > > + * adapter.
> > > + *
> > > + * @param	sess		Session pointer allocated by
> > > + *				*rte_security_session_create*.
> > > + * @param	ev_mdata	Pointer to the event crypto meta data
> > > + *				(aka *union rte_event_crypto_metadata*)
> > > + */
> > > +__rte_experimental
> > > +static inline void
> > > +rte_security_session_set_event_mdata(struct rte_security_session *sess,
> > > +				     void *ev_mdata)
> > > +{
> > > +	sess->event_mdata = ev_mdata;
> > > +}
> > > +
> > >  /**
> > >   * Attach a session to a crypto operation.
> > >   * This API is needed only in case of
> > > RTE_SECURITY_SESS_CRYPTO_PROTO_OFFLOAD
> > > --
> > > 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH 1/2] security: introduce per session event metadata
  2022-04-04 10:42       ` Gujjar, Abhinandan S
@ 2022-04-13  7:13         ` Akhil Goyal
  2022-04-18 19:36           ` Akhil Goyal
  0 siblings, 1 reply; 69+ messages in thread
From: Akhil Goyal @ 2022-04-13  7:13 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, Volodymyr Fialko, dev, Jayatheerthan, Jay,
	Vangati, Narender
  Cc: Jerin Jacob Kollanukkaran, Anoob Joseph

Hi Abhinandan and others,
> + @Jayatheerthan, Jay & @Vangati, Narender
> 
> > This change would be an ABI breakage. So to avoid that, we are planning to
> > Propose a better solution compared to this patch.
> > We plan to add a new cryptodev op to set the event metadata. A single API
> > which can be used in all cases - sym/asym/security sessions.
> >
> > As currently in case of sym crypto, userdata is being used for storing the event
> > Metadata and it is then dereferenced in the PMD which is wrong.
> > User data is meant only for user to use and PMD should not dereference it.
> >
> > Hence a new cryptodev op can be used to set session event metadata explicitly
> > if event mode is enabled.
> >
> > I will be sending the proposal soon. Would need your help in testing the Intel
> > usecases.
> >

We may need to stick to the approach introduced in this patch only.
As if we propose, a new single API for all type of sessions, the driver would need to
Get the event metadata from the session private data. This is not possible with
Your use case which gets it inside the eventdev library for sw adapter case as it cannot
Get the session private data without knowing the cdev_id.

Hence, we will take this patch as is in next release for security sessions(as it is an ABI break)
And would also introduce a similar change for crypto sessions in next release.
This way we can get rid of using userdata which is wrong implementation.

Regards,
Akhil

^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 0/7] Add new cryptodev op for event metadata
  2022-03-25 11:16 [PATCH 0/2] Session crypto event metadata api Volodymyr Fialko
  2022-03-25 11:16 ` [PATCH 1/2] security: introduce per session event metadata Volodymyr Fialko
  2022-03-25 11:16 ` [PATCH 2/2] crypto/cnxk: support for security session enqueue Volodymyr Fialko
@ 2022-04-18 19:33 ` Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 1/7] cryptodev: add APIs to get/set " Akhil Goyal
                     ` (7 more replies)
  2 siblings, 8 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For using event crypto metadata, event metadata need to be set
in session. For this session user data was used for symmetric
crypto sessions and no support was present for asymmetric and
security sessions.
The use of userdata to store event metadata (which is dereferenced
in PMD) is not correct as it is meant for the application to use it.
Hence, a new API is created to set and get event crypto metadata which
is scalable to all sessions supported by the crypto PMD.
The application can use the set API to set event metadata and the
PMD may store that inside the session private data and PMD need not
use the get API as it would be internal to the PMD.
For the software event crypto adapter implementation, the eventdev
library can use the get API to get the event metadata stored inside
the session structure.
For Asymmetric sessions, a new field is added inside the session
struct which is internal to library.
For symmetric and security sessions, new field cannot be added as
it would be ABI break. Hence, session userdata is being used to
store that as it was used earlier. In next ABI break release this
would be fixed similar to asymmetric crypto case.

The patchset also add support for asymmetric crypto adapter
in the test applications and the crypto/cnxk implementation of
the new cryptodev op and corresponding changes in the eventdev lib.


changes in v2:
- v1 patchset only fixed security sessions and also caused ABI breakage.
This is fixed in v2.
- added new API for setting event metadata.
- added new cryptodev op which can handle all sessions

Akhil Goyal (5):
  crypto/octeontx: use new API for event metadata
  test/event: use new API to set event crypto metadata
  eventdev: use new API to get event crypto metadata
  test/event: add asymmetric cases for crypto adapter
  test-eventdev: support asym ops for crypto adapter

Volodymyr Fialko (2):
  cryptodev: add APIs to get/set event metadata
  crypto/cnxk: add event metadata set operation

 app/test-eventdev/evt_common.h              |   2 +
 app/test-eventdev/evt_options.c             |  17 +
 app/test-eventdev/evt_options.h             |   4 +
 app/test-eventdev/test_perf_atq.c           |  12 +-
 app/test-eventdev/test_perf_common.c        | 254 ++++++++--
 app/test-eventdev/test_perf_common.h        |  45 +-
 app/test-eventdev/test_perf_queue.c         |  12 +-
 app/test/test_event_crypto_adapter.c        | 503 +++++++++++++++++++-
 doc/guides/tools/testeventdev.rst           |   5 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c   | 144 +++++-
 drivers/crypto/cnxk/cn10k_ipsec.h           |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    | 138 +++++-
 drivers/crypto/cnxk/cn9k_ipsec.h            |   2 +
 drivers/crypto/cnxk/cnxk_ae.h               |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h    |  18 -
 drivers/crypto/cnxk/cnxk_se.h               |   2 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c |  20 +-
 lib/cryptodev/cryptodev_pmd.h               |  23 +
 lib/cryptodev/rte_cryptodev.c               |  52 ++
 lib/cryptodev/rte_cryptodev.h               |  34 ++
 lib/cryptodev/version.map                   |   4 +
 lib/eventdev/rte_event_crypto_adapter.c     |  55 +--
 22 files changed, 1162 insertions(+), 188 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 1/7] cryptodev: add APIs to get/set event metadata
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
@ 2022-04-18 19:33   ` Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

From: Volodymyr Fialko <vfialko@marvell.com>

Currently, crypto session userdata is used to set event crypto
metadata from the application and the driver is dereferencing it
in driver which is not correct. User data is meant to be opaque
to the driver.
To support this, new API is added to get and set event crypto
metadata. The new API, rte_cryptodev_set_session_event_mdata,
allows setting event metadata in session private data which is
filled inside PMD using a new cryptodev op. This operation
can be performed on any of the PMD supported sessions
(sym/asym/security).
For SW abstraction of event crypto adapter to be used by
eventdev library, a new field is added in asymmetric crypto
session for now and for symmetric case, current implementation
of using userdata is used. Symmetric cases cannot be fixed now,
as it will be ABI breakage which will be resolved in DPDK 22.11.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 lib/cryptodev/cryptodev_pmd.h | 23 ++++++++++++++++
 lib/cryptodev/rte_cryptodev.c | 52 +++++++++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.h | 34 +++++++++++++++++++++++
 lib/cryptodev/version.map     |  4 +++
 4 files changed, 113 insertions(+)

diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 2b1ce2da2d..f374b6c880 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -398,6 +398,25 @@ typedef int (*cryptodev_sym_configure_raw_dp_ctx_t)(
 	enum rte_crypto_op_sess_type sess_type,
 	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
 
+/**
+ * Typedef that the driver provided to set event crypto meta data.
+ *
+ * @param	dev		Crypto device pointer.
+ * @param	sess		Crypto or security session.
+ * @param	op_type		Operation type.
+ * @param	sess_type	Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ * @return
+ *   - On success return 0.
+ *   - On failure return negative integer.
+ */
+typedef int (*cryptodev_session_event_mdata_set_t)(
+	struct rte_cryptodev *dev, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata);
+
 /** Crypto device operations function pointer table */
 struct rte_cryptodev_ops {
 	cryptodev_configure_t dev_configure;	/**< Configure device. */
@@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
 			/**< Initialize raw data path context data. */
 		};
 	};
+	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
+	/**< Set a Crypto or Security session even meta data. */
 };
 
 
@@ -636,6 +657,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
 	/**< Size of private data used when creating mempool */
 	uint16_t user_data_sz;
 	/**< Session user data will be placed after sess_data */
+	void *event_mdata;
+	/**< Event crypto adapter metadata */
 	uint8_t padding[3];
 	uint8_t sess_private_data[0];
 };
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 3500a2d470..9ea64bc4f0 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2259,6 +2259,58 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t dev_id, uint16_t qp_id,
 			sess_type, session_ctx, is_update);
 }
 
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata)
+{
+	struct rte_cryptodev *dev;
+
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		goto skip_pmd_op;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (dev->dev_ops->session_ev_mdata_set == NULL)
+		goto skip_pmd_op;
+
+	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
+			sess_type, ev_mdata);
+
+skip_pmd_op:
+#define EVENT_CRYPTO_MDATA_SZ	16
+/**<
+ * sizeof(union rte_event_crypto_metadata). To be removed when event_mdata is
+ * added in rte_cryptodev_sym_session
+ */
+
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
+		return rte_cryptodev_sym_session_set_user_data(sess, ev_mdata,
+				EVENT_CRYPTO_MDATA_SZ);
+	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		((struct rte_cryptodev_asym_session *)sess)->event_mdata =
+						ev_mdata;
+		return 0;
+	} else
+		return -ENOTSUP;
+}
+
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return rte_cryptodev_sym_session_get_user_data(op->sym->session);
+	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return op->asym->session->event_mdata;
+	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
+			op->private_data_offset)
+		return ((uint8_t *)op + op->private_data_offset);
+	else
+		return NULL;
+}
+
 uint32_t
 rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx,
 	struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs,
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 45d33f4a50..b3ddc41ab1 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -1269,6 +1269,40 @@ __rte_experimental
 int
 rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
 
+/**
+ * Set session event meta data
+ *
+ * @param	dev_id		The device identifier.
+ * @param	sess            Crypto or security session.
+ * @param	op_type         Operation type.
+ * @param	sess_type       Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+__rte_experimental
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata);
+
+/**
+ * Get session event meta data (aka *union rte_event_crypto_metadata*)
+ *
+ * @param	op            pointer to *rte_crypto_op* structure.
+ *
+ * @return
+ *  - On success, pointer to event crypto metadata
+ *  - On failure, a negative value.
+ */
+__rte_experimental
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
+
 /**
  * Union of different crypto session types, including session-less xform
  * pointer.
diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map
index c7c5aefceb..b8a23a1791 100644
--- a/lib/cryptodev/version.map
+++ b/lib/cryptodev/version.map
@@ -105,6 +105,10 @@ EXPERIMENTAL {
 	rte_cryptodev_asym_session_pool_create;
 	rte_cryptodev_asym_session_set_user_data;
 	__rte_cryptodev_trace_asym_session_pool_create;
+
+	#added in 22.07
+	rte_cryptodev_session_event_mdata_get;
+	rte_cryptodev_session_event_mdata_set;
 };
 
 INTERNAL {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 2/7] crypto/cnxk: add event metadata set operation
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 1/7] cryptodev: add APIs to get/set " Akhil Goyal
@ 2022-04-18 19:33   ` Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

From: Volodymyr Fialko <vfialko@marvell.com>

Added cryptodev operation for setting event crypto
metadata for all supported sessions - sym/asym/security.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++---
 drivers/crypto/cnxk/cn10k_ipsec.h         |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 138 ++++++++++++++++++---
 drivers/crypto/cnxk/cn9k_ipsec.h          |   2 +
 drivers/crypto/cnxk/cnxk_ae.h             |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  18 ---
 drivers/crypto/cnxk/cnxk_se.h             |   2 +
 7 files changed, 255 insertions(+), 53 deletions(-)

diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
index c4d5d039ec..08a4df1474 100644
--- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
@@ -264,30 +264,136 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count + i;
 }
 
-uint16_t
-cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				      void *sess,
+				      enum rte_crypto_op_type op_type,
+				      enum rte_crypto_op_sess_type sess_type,
+				      void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
-	uint64_t lmt_base, lmt_arg;
-	struct cpt_inst_s *inst;
 	struct cnxk_cpt_qp *qp;
 	uint8_t cdev_id;
-	uint16_t lmt_id;
-	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	int16_t qp_id;
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn10k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn10k_ca_meta_info_extract(struct rte_crypto_op *op,
+			 struct cnxk_cpt_qp **qp, uint64_t *w2)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			*w2 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn10k_cryptodev_driver_id);
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata*)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			*w2 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	uint64_t lmt_base, lmt_arg, w2;
+	struct cpt_inst_s *inst;
+	struct cnxk_cpt_qp *qp;
+	uint16_t lmt_id;
+	int ret;
+
+	ret = cn10k_ca_meta_info_extract(op, &qp, &w2);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -316,9 +422,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst->w0.u64 = 0;
 	inst->res_addr = (uint64_t)&infl_req->res;
-	inst->w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
+	inst->w2.u64 = w2;
 	inst->w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -327,7 +431,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst->w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id;
@@ -592,4 +696,6 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set,
 };
diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h b/drivers/crypto/cnxk/cn10k_ipsec.h
index 647a71cdd5..1c1d904799 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec.h
@@ -20,6 +20,8 @@ struct cn10k_ipsec_sa {
 	uint16_t iv_offset;
 	uint8_t iv_length;
 	bool is_outbound;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 
 	/**
 	 * End of SW mutable area
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index d3d441cb24..987699f8d4 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -316,28 +316,134 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count;
 }
 
-uint16_t
-cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				     void *sess,
+				     enum rte_crypto_op_type op_type,
+				     enum rte_crypto_op_sess_type sess_type,
+				     void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
 	struct cnxk_cpt_qp *qp;
-	struct cpt_inst_s inst;
 	uint8_t cdev_id;
 	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn9k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn9k_ca_meta_info_extract(struct rte_crypto_op *op,
+			struct cnxk_cpt_qp **qp, struct cpt_inst_s *inst)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			inst->w2.u64 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn9k_cryptodev_driver_id);
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata*)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			inst->w2.u64 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	struct cnxk_cpt_qp *qp;
+	struct cpt_inst_s inst;
+	int ret;
+
+	ret = cn9k_ca_meta_info_extract(op, &qp, &inst);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -362,9 +468,6 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst.w0.u64 = 0;
 	inst.res_addr = (uint64_t)&infl_req->res;
-	inst.w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
 	inst.w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -373,7 +476,7 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst.w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	cn9k_cpt_inst_submit(&inst, qp->lmtline.lmt_base, qp->lmtline.io_addr);
@@ -613,4 +716,7 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set,
+
 };
diff --git a/drivers/crypto/cnxk/cn9k_ipsec.h b/drivers/crypto/cnxk/cn9k_ipsec.h
index f3acad561b..499dbc2782 100644
--- a/drivers/crypto/cnxk/cn9k_ipsec.h
+++ b/drivers/crypto/cnxk/cn9k_ipsec.h
@@ -42,6 +42,8 @@ struct cn9k_ipsec_sa {
 	struct cnxk_on_ipsec_ar ar;
 	/** Anti replay window size */
 	uint32_t replay_win_sz;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 };
 
 struct cn9k_sec_session {
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 01ccfcd334..10854c79c8 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -22,6 +22,8 @@ struct cnxk_ae_sess {
 	uint64_t *cnxk_fpm_iova;
 	struct roc_ae_ec_group **ec_grp;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 };
 
 static __rte_always_inline void
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
index ab0f00ee7c..7ece0214dc 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
@@ -125,24 +125,6 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
 			struct rte_cryptodev_asym_session *sess);
 void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
 
-static inline union rte_event_crypto_metadata *
-cnxk_event_crypto_mdata_get(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-			op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata
-				    *)((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 static __rte_always_inline void
 pending_queue_advance(uint64_t *index, const uint64_t mask)
 {
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index e988d57b94..b11c2bb3a2 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -33,6 +33,8 @@ struct cnxk_se_sess {
 	uint16_t auth_iv_offset;
 	uint32_t salt;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 	struct roc_se_ctx roc_se_ctx;
 } __rte_cache_aligned;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 3/7] crypto/octeontx: use new API for event metadata
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 1/7] cryptodev: add APIs to get/set " Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
@ 2022-04-18 19:33   ` Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata can be used
directly instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index ddb1266c3c..d5851d9987 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -684,24 +684,6 @@ submit_request_to_sso(struct ssows *ws, uintptr_t req,
 	ssovf_store_pair(add_work, req, ws->grps[rsp_info->queue_id]);
 }
 
-static inline union rte_event_crypto_metadata *
-get_event_crypto_mdata(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-							   op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata *)
-			((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 uint16_t __rte_hot
 otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 {
@@ -712,7 +694,7 @@ otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 	uint8_t op_type, cdev_id;
 	uint16_t qp_id;
 
-	ec_mdata = get_event_crypto_mdata(op);
+	ec_mdata = rte_cryptodev_session_event_mdata_get(op);
 	if (unlikely(ec_mdata == NULL)) {
 		rte_errno = EINVAL;
 		return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 4/7] test/event: use new API to set event crypto metadata
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
                     ` (2 preceding siblings ...)
  2022-04-18 19:33   ` [PATCH v2 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
@ 2022-04-18 19:33   ` Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 5/7] eventdev: use new API to get " Akhil Goyal
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

Used the new API rte_cryptodev_set_session_event_mdata to set
event crypto metadata from the applications (app/test and
app/test-eventdev) instead of using session userdata.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test-eventdev/test_perf_common.c |  8 ++++++--
 app/test/test_event_crypto_adapter.c | 12 ++++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9d1f4a4567..78dfaf4cab 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -835,8 +835,12 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 					return -ENOMEM;
 
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_sym_session_set_user_data(
-					crypto_sess, &m_data, sizeof(m_data));
+				rte_cryptodev_session_event_mdata_set(cdev_id,
+						crypto_sess,
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data);
+
 				p->ca.crypto_sess[flow_id] = crypto_sess;
 			}
 
diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 688520db4e..631011b1bd 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -227,8 +227,10 @@ test_op_forward_mode(uint8_t session_less)
 			m_data.request_info.queue_pair_id =
 				request_info.queue_pair_id;
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data);
 		}
 
 		rte_crypto_op_attach_sym_session(op, sess);
@@ -416,8 +418,10 @@ test_op_new_mode(uint8_t session_less)
 		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
 			/* Fill in private user data information */
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data);
 		}
 		ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess,
 				&cipher_xform, params.session_priv_mpool);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 5/7] eventdev: use new API to get event crypto metadata
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
                     ` (3 preceding siblings ...)
  2022-04-18 19:33   ` [PATCH v2 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
@ 2022-04-18 19:33   ` Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata is used
instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 lib/eventdev/rte_event_crypto_adapter.c | 55 ++++++-------------------
 1 file changed, 12 insertions(+), 43 deletions(-)

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index f624f50187..7c695176f4 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -457,43 +457,22 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
-		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					crypto_op->sym->session);
-			if (m_data == NULL) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
+		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
+		if (m_data == NULL) {
+			rte_pktmbuf_free(crypto_op->sym->m_src);
+			rte_crypto_op_free(crypto_op);
+			continue;
+		}
 
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else if (crypto_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				crypto_op->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)crypto_op +
-					crypto_op->private_data_offset);
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else {
+		cdev_id = m_data->request_info.cdev_id;
+		qp_id = m_data->request_info.queue_pair_id;
+		qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
+		if (!qp_info->qp_enabled) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
 			rte_crypto_op_free(crypto_op);
 			continue;
 		}
+		eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
 
 		if (eca_circular_buffer_batch_ready(&qp_info->cbuf)) {
 			ret = eca_circular_buffer_flush_to_cdev(&qp_info->cbuf,
@@ -636,17 +615,7 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 	for (i = 0; i < num; i++) {
 		struct rte_event *ev = &events[nb_ev++];
 
-		m_data = NULL;
-		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					ops[i]->sym->session);
-		} else if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				ops[i]->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)ops[i] +
-				  ops[i]->private_data_offset);
-		}
-
+		m_data = rte_cryptodev_session_event_mdata_get(ops[i]);
 		if (unlikely(m_data == NULL)) {
 			rte_pktmbuf_free(ops[i]->sym->m_src);
 			rte_crypto_op_free(ops[i]);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 6/7] test/event: add asymmetric cases for crypto adapter
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
                     ` (4 preceding siblings ...)
  2022-04-18 19:33   ` [PATCH v2 5/7] eventdev: use new API to get " Akhil Goyal
@ 2022-04-18 19:33   ` Akhil Goyal
  2022-04-18 19:33   ` [PATCH v2 7/7] test-eventdev: support asym ops " Akhil Goyal
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

Test app is updated to add cases for asymmetric crypto
sessions for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test/test_event_crypto_adapter.c | 491 ++++++++++++++++++++++++++-
 1 file changed, 485 insertions(+), 6 deletions(-)

diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 631011b1bd..dbc9268737 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -6,6 +6,7 @@
 #include "test.h"
 #include <string.h>
 #include <rte_common.h>
+#include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
@@ -67,12 +68,97 @@ static const uint8_t text_64B[] = {
 	0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
 	0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c
 };
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 struct event_crypto_adapter_test_params {
 	struct rte_mempool *mbuf_pool;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *asym_op_mpool;
 	struct rte_mempool *session_mpool;
 	struct rte_mempool *session_priv_mpool;
+	struct rte_mempool *asym_sess_mpool;
 	struct rte_cryptodev_config *config;
 	uint8_t crypto_event_port_id;
 	uint8_t internal_port_op_fwd;
@@ -134,11 +220,24 @@ send_recv_ev(struct rte_event *ev)
 		rte_pause();
 
 	op = recv_ev.event_ptr;
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(op->sym->m_src);
+		rte_pktmbuf_free(op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(op);
 
 	return TEST_SUCCESS;
@@ -348,6 +447,170 @@ test_session_with_op_forward_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_forward_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	struct rte_event ev;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op,
+		"Failed to allocate asymmetric crypto operation struct\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		/* Create Crypto session*/
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.request_info.cdev_id = request_info.cdev_id;
+			m_data.request_info.queue_pair_id =
+				request_info.queue_pair_id;
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data);
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.request_info.cdev_id = request_info.cdev_id;
+		m_data.request_info.queue_pair_id = request_info.queue_pair_id;
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+	/* Fill in event info and update event_ptr with rte_crypto_op */
+	memset(&ev, 0, sizeof(ev));
+	ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
+	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	ev.flow_id = 0xAABB;
+	ev.event_ptr = op;
+
+	ret = send_recv_ev(&ev);
+	TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
+				"crypto adapter\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+
+static int
+test_asym_sessionless_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(1);
+}
+
+static int
+test_asym_session_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID
+				), "Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(0);
+}
+
 static int
 send_op_recv_ev(struct rte_crypto_op *op)
 {
@@ -365,11 +628,24 @@ send_op_recv_ev(struct rte_crypto_op *op)
 		rte_pause();
 
 	recv_op = ev.event_ptr;
+	if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = recv_op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = recv_op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(recv_op->sym->m_src);
+		rte_pktmbuf_free(recv_op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(recv_op);
 
 	return TEST_SUCCESS;
@@ -505,6 +781,156 @@ test_session_with_op_new_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_new_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data);
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+
+	ret = send_op_recv_ev(op);
+	TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_asym_sessionless_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	/* start the event crypto adapter */
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(1);
+}
+
+static int
+test_asym_session_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(0);
+}
+
 static int
 configure_cryptodev(void)
 {
@@ -537,6 +963,19 @@ configure_cryptodev(void)
 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
 		return TEST_FAILED;
 	}
+	params.asym_op_mpool = rte_crypto_op_pool_create(
+			"EVENT_CRYPTO_ASYM_OP_POOL",
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+			NUM_MBUFS, MBUF_CACHE_SIZE,
+			(DEFAULT_NUM_XFORMS *
+			sizeof(struct rte_crypto_asym_xform)) +
+			sizeof(union rte_event_crypto_metadata),
+			rte_socket_id());
+	if (params.asym_op_mpool == NULL) {
+		RTE_LOG(ERR, USER1, "Can't create CRYPTO_ASYM_OP_POOL\n");
+		return TEST_FAILED;
+	}
+
 
 	/* Create a NULL crypto device */
 	nb_devs = rte_cryptodev_device_count_by_driver(
@@ -581,6 +1020,15 @@ configure_cryptodev(void)
 	TEST_ASSERT_NOT_NULL(params.session_priv_mpool,
 			"session mempool allocation failed\n");
 
+	params.asym_sess_mpool = rte_cryptodev_asym_session_pool_create(
+			"CRYPTO_AD_ASYM_SESS_MP",
+			MAX_NB_SESSIONS, 0,
+			sizeof(union rte_event_crypto_metadata),
+			SOCKET_ID_ANY);
+	TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
+			"asym session mempool allocation failed\n");
+
+
 	rte_cryptodev_info_get(TEST_CDEV_ID, &info);
 	conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	conf.socket_id = SOCKET_ID_ANY;
@@ -960,6 +1408,21 @@ crypto_teardown(void)
 		params.session_priv_mpool = NULL;
 	}
 
+	/* Free asym session mempool */
+	if (params.asym_sess_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count %u\n",
+		rte_mempool_avail_count(params.asym_sess_mpool));
+		rte_mempool_free(params.asym_sess_mpool);
+		params.asym_sess_mpool = NULL;
+	}
+	/* Free asym ops mempool */
+	if (params.asym_op_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL count %u\n",
+		rte_mempool_avail_count(params.asym_op_mpool));
+		rte_mempool_free(params.asym_op_mpool);
+		params.asym_op_mpool = NULL;
+	}
+
 	/* Free ops mempool */
 	if (params.op_mpool != NULL) {
 		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL count %u\n",
@@ -1016,6 +1479,22 @@ static struct unit_test_suite functional_testsuite = {
 				test_crypto_adapter_stop,
 				test_sessionless_with_op_new_mode),
 
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_new_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_new_mode),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v2 7/7] test-eventdev: support asym ops for crypto adapter
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
                     ` (5 preceding siblings ...)
  2022-04-18 19:33   ` [PATCH v2 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
@ 2022-04-18 19:33   ` Akhil Goyal
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:33 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

Test eventdev app is updated to add new option for asymmetric
crypto ops for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test-eventdev/evt_common.h       |   2 +
 app/test-eventdev/evt_options.c      |  17 ++
 app/test-eventdev/evt_options.h      |   4 +
 app/test-eventdev/test_perf_atq.c    |  12 +-
 app/test-eventdev/test_perf_common.c | 250 +++++++++++++++++++++++----
 app/test-eventdev/test_perf_common.h |  45 +++--
 app/test-eventdev/test_perf_queue.c  |  12 +-
 doc/guides/tools/testeventdev.rst    |   5 +
 8 files changed, 284 insertions(+), 63 deletions(-)

diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index 2f301a7e79..196eca8bd0 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -6,6 +6,7 @@
 #define _EVT_COMMON_
 
 #include <rte_common.h>
+#include <rte_crypto.h>
 #include <rte_debug.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_eventdev.h>
@@ -80,6 +81,7 @@ struct evt_options {
 	uint64_t optm_timer_tick_nsec;
 	enum evt_prod_type prod_type;
 	enum rte_event_crypto_adapter_mode crypto_adptr_mode;
+	enum rte_crypto_op_type crypto_op_type;
 };
 
 static inline bool
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index d3c704d2b3..8326734b64 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -38,6 +38,7 @@ evt_options_default(struct evt_options *opt)
 	opt->eth_queues = 1;
 	opt->vector_size = 64;
 	opt->vector_tmo_nsec = 100E3;
+	opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
 }
 
 typedef int (*option_parser_t)(struct evt_options *opt,
@@ -142,6 +143,18 @@ evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
 	return ret;
 }
 
+static int
+evt_parse_crypto_op_type(struct evt_options *opt, const char *arg)
+{
+	uint8_t op_type;
+	int ret;
+
+	ret = parser_read_uint8(&op_type, arg);
+	opt->crypto_op_type = op_type ? RTE_CRYPTO_OP_TYPE_ASYMMETRIC :
+					RTE_CRYPTO_OP_TYPE_SYMMETRIC;
+	return ret;
+}
+
 static int
 evt_parse_test_name(struct evt_options *opt, const char *arg)
 {
@@ -368,6 +381,8 @@ usage(char *program)
 		"\t--expiry_nsec      : event timer expiry ns.\n"
 		"\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
 		"\t                      1 for OP_FORWARD mode.\n"
+		"\t--crypto_op_type   : 0 for SYM ops (default) and\n"
+		"\t                     1 for ASYM ops.\n"
 		"\t--mbuf_sz          : packet mbuf size.\n"
 		"\t--max_pkt_sz       : max packet size.\n"
 		"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -442,6 +457,7 @@ static struct option lgopts[] = {
 	{ EVT_PROD_TIMERDEV,       0, 0, 0 },
 	{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
 	{ EVT_CRYPTO_ADPTR_MODE,   1, 0, 0 },
+	{ EVT_CRYPTO_OP_TYPE,	   1, 0, 0 },
 	{ EVT_NB_TIMERS,           1, 0, 0 },
 	{ EVT_NB_TIMER_ADPTRS,     1, 0, 0 },
 	{ EVT_TIMER_TICK_NSEC,     1, 0, 0 },
@@ -484,6 +500,7 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
 		{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
 		{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
 		{ EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
+		{ EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type},
 		{ EVT_NB_TIMERS, evt_parse_nb_timers},
 		{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
 		{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 2231c58801..f23fb8a511 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -38,6 +38,7 @@
 #define EVT_PROD_TIMERDEV        ("prod_type_timerdev")
 #define EVT_PROD_TIMERDEV_BURST  ("prod_type_timerdev_burst")
 #define EVT_CRYPTO_ADPTR_MODE	 ("crypto_adptr_mode")
+#define EVT_CRYPTO_OP_TYPE	 ("crypto_op_type")
 #define EVT_NB_TIMERS            ("nb_timers")
 #define EVT_NB_TIMER_ADPTRS      ("nb_timer_adptrs")
 #define EVT_TIMER_TICK_NSEC      ("timer_tick_nsec")
@@ -298,6 +299,9 @@ evt_dump_producer_type(struct evt_options *opt)
 			 "Event crypto adapter producers");
 		evt_dump("crypto adapter mode", "%s",
 			 opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+		evt_dump("crypto op type", "%s",
+			 (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) ?
+			 "SYMMETRIC" : "ASYMMETRIC");
 		evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
 		break;
 	}
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 67ff681666..6a2aa86fd2 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -53,11 +53,13 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 78dfaf4cab..bafc466d61 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -7,6 +7,89 @@
 #include "test_perf_common.h"
 
 #define NB_CRYPTODEV_DESCRIPTORS 128
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 int
 perf_test_result(struct evt_test *test, struct evt_options *opt)
@@ -277,12 +360,10 @@ perf_event_timer_producer_burst(void *arg)
 static inline void
 crypto_adapter_enq_op_new(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	struct test_perf *t = p->t;
 	const uint32_t nb_flows = t->nb_flows;
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
-	struct rte_crypto_sym_op *sym_op;
 	struct evt_options *opt = t->opt;
 	uint16_t qp_id = p->ca.cdev_qp_id;
 	uint8_t cdev_id = p->ca.cdev_id;
@@ -300,22 +381,39 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
 
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
-		       t->done == false)
+				t->done == false)
 			rte_pause();
 
 		count++;
@@ -325,7 +423,6 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 static inline void
 crypto_adapter_enq_op_fwd(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	const uint8_t dev_id = p->dev_id;
 	const uint8_t port = p->port_id;
 	struct test_perf *t = p->t;
@@ -333,7 +430,6 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
 	struct evt_options *opt = t->opt;
-	struct rte_crypto_sym_op *sym_op;
 	uint32_t flow_counter = 0;
 	struct rte_crypto_op *op;
 	struct rte_event ev;
@@ -354,19 +450,37 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
+
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		ev.event_ptr = op;
 
 		while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
@@ -729,6 +843,37 @@ cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
 	return sess;
 }
 
+static void *
+cryptodev_asym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform;
+	void *sess;
+
+	xform.next = NULL;
+	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform.xform_type;
+	capability = rte_cryptodev_asym_capability_get(p->ca.cdev_id, &cap_idx);
+	if (capability == NULL) {
+		evt_err("Device doesn't support MODEX. Test Skipped\n");
+		return NULL;
+	}
+
+	xform.modex.modulus.data = modex_test_case.modulus.data;
+	xform.modex.modulus.length = modex_test_case.modulus.len;
+	xform.modex.exponent.data = modex_test_case.exponent.data;
+	xform.modex.exponent.length = modex_test_case.exponent.len;
+
+	if (rte_cryptodev_asym_session_create(p->ca.cdev_id, &xform,
+			t->ca_asym_sess_pool, &sess)) {
+		evt_err("Failed to create asym session");
+		return NULL;
+	}
+
+	return sess;
+}
+
 int
 perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 				uint8_t stride, uint8_t nb_queues,
@@ -804,7 +949,6 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 
 		prod = 0;
 		for (; port < perf_nb_event_ports(opt); port++) {
-			struct rte_cryptodev_sym_session *crypto_sess;
 			union rte_event_crypto_metadata m_data;
 			struct prod_data *p = &t->prod[port];
 			uint32_t flow_id;
@@ -820,7 +964,7 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			p->ca.cdev_id = cdev_id;
 			p->ca.cdev_qp_id = qp_id;
 			p->ca.crypto_sess = rte_zmalloc_socket(
-				NULL, sizeof(crypto_sess) * t->nb_flows,
+				NULL, sizeof(void *) * t->nb_flows,
 				RTE_CACHE_LINE_SIZE, opt->socket_id);
 			p->t = t;
 
@@ -830,18 +974,36 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			m_data.response_info.queue_id = p->queue_id;
 
 			for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
-				crypto_sess = cryptodev_sym_sess_create(p, t);
-				if (crypto_sess == NULL)
-					return -ENOMEM;
-
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_session_event_mdata_set(cdev_id,
-						crypto_sess,
+				if (opt->crypto_op_type ==
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					struct rte_cryptodev_sym_session *sess;
+
+					sess = cryptodev_sym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
 						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 						RTE_CRYPTO_OP_WITH_SESSION,
 						&m_data);
+					p->ca.crypto_sess[flow_id] = sess;
+				} else {
+					void *sess;
 
-				p->ca.crypto_sess[flow_id] = crypto_sess;
+					sess = cryptodev_asym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
+						RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data);
+					p->ca.crypto_sess[flow_id] = sess;
+				}
 			}
 
 			conf.event_port_cfg |=
@@ -1123,14 +1285,24 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	t->ca_op_pool = rte_crypto_op_pool_create(
-		"crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
-		128, 0, rte_socket_id());
+		"crypto_op_pool", opt->crypto_op_type, opt->pool_sz,
+		128, sizeof(union rte_event_crypto_metadata),
+		rte_socket_id());
 	if (t->ca_op_pool == NULL) {
 		evt_err("Failed to create crypto op pool");
 		return -ENOMEM;
 	}
 
 	nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+	t->ca_asym_sess_pool = rte_cryptodev_asym_session_pool_create(
+		"ca_asym_sess_pool", nb_sessions, 0,
+		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+	if (t->ca_asym_sess_pool == NULL) {
+		evt_err("Failed to create sym session pool");
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
 		"ca_sess_pool", nb_sessions, 0, 0,
 		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
@@ -1217,6 +1389,7 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 
 	return ret;
 }
@@ -1258,6 +1431,7 @@ perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 }
 
 int
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index ea0907d61a..5651832cc9 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -40,7 +40,7 @@ struct worker_data {
 struct crypto_adptr_data {
 	uint8_t cdev_id;
 	uint16_t cdev_qp_id;
-	struct rte_cryptodev_sym_session **crypto_sess;
+	void **crypto_sess;
 };
 struct prod_data {
 	uint8_t dev_id;
@@ -70,6 +70,7 @@ struct test_perf {
 	struct rte_mempool *ca_op_pool;
 	struct rte_mempool *ca_sess_pool;
 	struct rte_mempool *ca_sess_priv_pool;
+	struct rte_mempool *ca_asym_sess_pool;
 } __rte_cache_aligned;
 
 struct perf_elt {
@@ -111,8 +112,6 @@ perf_process_last_stage(struct rte_mempool *const pool,
 		struct rte_event *const ev, struct worker_data *const w,
 		void *bufs[], int const buf_sz, uint8_t count)
 {
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -120,9 +119,19 @@ perf_process_last_stage(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)ev->event_ptr)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		struct rte_crypto_op *op = ev->event_ptr;
+
+		rte_free(op->asym->modex.result.data);
+		rte_crypto_op_free(op);
+	} else {
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		}
 	}
 	return count;
 }
@@ -135,8 +144,6 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	uint64_t latency;
 	struct perf_elt *const m = ev->event_ptr;
 
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -144,15 +151,23 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		latency = rte_get_timer_cycles() - m->timestamp;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)m)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		rte_free(((struct rte_crypto_op *)m)->asym->modex.result.data);
+		rte_crypto_op_free((struct rte_crypto_op *)m);
 	} else {
-		latency = rte_get_timer_cycles() - m->timestamp;
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			latency = rte_get_timer_cycles() - m->timestamp;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		} else {
+			latency = rte_get_timer_cycles() - m->timestamp;
+		}
+
+		w->latency += latency;
 	}
-
-	w->latency += latency;
 	return count;
 }
 
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index dcf6d82947..631a39f727 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -55,11 +55,13 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index f7d813226d..a8e02d57a4 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -157,6 +157,11 @@ The following are the application command-line options:
         Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
         OP_FORWARD mode.
 
+* ``--crypto_op_type``
+
+        Set crypto operation type. Use 0 for symmetric crypto ops (default)
+        and 1 for asymmetric crypto ops.
+
 * ``--mbuf_sz``
 
        Set packet mbuf size. Can be used to configure Jumbo Frames. Only
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH 1/2] security: introduce per session event metadata
  2022-04-13  7:13         ` Akhil Goyal
@ 2022-04-18 19:36           ` Akhil Goyal
  0 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-18 19:36 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, Volodymyr Fialko, dev, Jayatheerthan, Jay,
	Vangati, Narender
  Cc: Jerin Jacob Kollanukkaran, Anoob Joseph

Hi Abhinandan and others,
> We may need to stick to the approach introduced in this patch only.
> As if we propose, a new single API for all type of sessions, the driver would need
> to
> Get the event metadata from the session private data. This is not possible with
> Your use case which gets it inside the eventdev library for sw adapter case as it
> cannot
> Get the session private data without knowing the cdev_id.
> 
> Hence, we will take this patch as is in next release for security sessions(as it is an
> ABI break)
> And would also introduce a similar change for crypto sessions in next release.
> This way we can get rid of using userdata which is wrong implementation.

On another thought, we have posted a new patchset to use event crypto adapter.
Please review and provide feedback.

Thanks,
Akhil

^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 0/7] Add new cryptodev op for event metadata
  2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
                     ` (6 preceding siblings ...)
  2022-04-18 19:33   ` [PATCH v2 7/7] test-eventdev: support asym ops " Akhil Goyal
@ 2022-04-21 14:37   ` Akhil Goyal
  2022-04-21 14:37     ` [PATCH v3 1/7] cryptodev: add APIs to get/set " Akhil Goyal
                       ` (9 more replies)
  7 siblings, 10 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For using event crypto metadata, event metadata need to be set
in session. For this session user data was used for symmetric
crypto sessions and no support was present for asymmetric and
security sessions.
The use of userdata to store event metadata (which is dereferenced
in PMD) is not correct as it is meant for the application to use it.
Hence, a new API is created to set and get event crypto metadata which
is scalable to all sessions supported by the crypto PMD.
The application can use the set API to set event metadata and the
PMD may store that inside the session private data and PMD need not
use the get API as it would be internal to the PMD.
For the software event crypto adapter implementation, the eventdev
library can use the get API to get the event metadata stored inside
the session structure.
For Asymmetric sessions, a new field is added inside the session
struct which is internal to library.
For symmetric and security sessions, new field cannot be added as
it would be ABI break. Hence, session userdata is being used to
store that as it was used earlier. In next ABI break release this
would be fixed similar to asymmetric crypto case.

The patchset also add support for asymmetric crypto adapter
in the test applications and the crypto/cnxk implementation of
the new cryptodev op and corresponding changes in the eventdev lib.

Changes in v3:
- fix SW adapter case of memory allocation/free of mdata. mdata is
allocated in set API and freed in session clear/destroy.
- mark rte_cryptodev_session_event_mdata_get as internal API
as it is only needed for the app or the PMD.

changes in v2:
- v1 patchset only fixed security sessions and also caused ABI breakage.
This is fixed in v2.
- added new API for setting event metadata.
- added new cryptodev op which can handle all sessions


Akhil Goyal (5):
  crypto/octeontx: use new API for event metadata
  test/event: use new API to set event crypto metadata
  eventdev: use new API to get event crypto metadata
  test/event: add asymmetric cases for crypto adapter
  test-eventdev: support asym ops for crypto adapter

Volodymyr Fialko (2):
  cryptodev: add APIs to get/set event metadata
  crypto/cnxk: add event metadata set operation

 app/test-eventdev/evt_common.h              |   2 +
 app/test-eventdev/evt_options.c             |  17 +
 app/test-eventdev/evt_options.h             |   4 +
 app/test-eventdev/test_perf_atq.c           |  12 +-
 app/test-eventdev/test_perf_common.c        | 254 ++++++++--
 app/test-eventdev/test_perf_common.h        |  45 +-
 app/test-eventdev/test_perf_queue.c         |  12 +-
 app/test/test_event_crypto_adapter.c        | 503 +++++++++++++++++++-
 doc/guides/tools/testeventdev.rst           |   5 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c   | 144 +++++-
 drivers/crypto/cnxk/cn10k_ipsec.h           |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    | 138 +++++-
 drivers/crypto/cnxk/cn9k_ipsec.h            |   2 +
 drivers/crypto/cnxk/cnxk_ae.h               |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h    |  18 -
 drivers/crypto/cnxk/cnxk_se.h               |   2 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c |  20 +-
 lib/cryptodev/cryptodev_pmd.c               |  16 +
 lib/cryptodev/cryptodev_pmd.h               |  36 ++
 lib/cryptodev/rte_cryptodev.c               |  41 ++
 lib/cryptodev/rte_cryptodev.h               |  22 +
 lib/cryptodev/version.map                   |   4 +
 lib/eventdev/rte_event_crypto_adapter.c     |  55 +--
 23 files changed, 1168 insertions(+), 188 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
@ 2022-04-21 14:37     ` Akhil Goyal
  2022-04-27 15:38       ` Zhang, Roy Fan
  2022-04-28 14:42       ` Gujjar, Abhinandan S
  2022-04-21 14:37     ` [PATCH v3 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
                       ` (8 subsequent siblings)
  9 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

From: Volodymyr Fialko <vfialko@marvell.com>

Currently, crypto session userdata is used to set event crypto
metadata from the application and the driver is dereferencing it
in driver which is not correct. User data is meant to be opaque
to the driver.
To support this, new API is added to get and set event crypto
metadata. The new API, rte_cryptodev_set_session_event_mdata,
allows setting event metadata in session private data which is
filled inside PMD using a new cryptodev op. This operation
can be performed on any of the PMD supported sessions
(sym/asym/security).
For SW abstraction of event crypto adapter to be used by
eventdev library, a new field is added in asymmetric crypto
session for now and for symmetric case, current implementation
of using userdata is used. Symmetric cases cannot be fixed now,
as it will be ABI breakage which will be resolved in DPDK 22.11.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 lib/cryptodev/cryptodev_pmd.c | 16 ++++++++++++++
 lib/cryptodev/cryptodev_pmd.h | 36 ++++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.c | 41 +++++++++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.h | 22 +++++++++++++++++++
 lib/cryptodev/version.map     |  4 ++++
 5 files changed, 119 insertions(+)

diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
index 739a0b3f34..1903ade388 100644
--- a/lib/cryptodev/cryptodev_pmd.c
+++ b/lib/cryptodev/cryptodev_pmd.c
@@ -227,3 +227,19 @@ cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
 	fp_ops->qp.enq_cb = dev->enq_cbs;
 	fp_ops->qp.deq_cb = dev->deq_cbs;
 }
+
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return rte_cryptodev_sym_session_get_user_data(op->sym->session);
+	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return op->asym->session->event_mdata;
+	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
+			op->private_data_offset)
+		return ((uint8_t *)op + op->private_data_offset);
+	else
+		return NULL;
+}
diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 2b1ce2da2d..7969944b66 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -398,6 +398,25 @@ typedef int (*cryptodev_sym_configure_raw_dp_ctx_t)(
 	enum rte_crypto_op_sess_type sess_type,
 	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
 
+/**
+ * Typedef that the driver provided to set event crypto meta data.
+ *
+ * @param	dev		Crypto device pointer.
+ * @param	sess		Crypto or security session.
+ * @param	op_type		Operation type.
+ * @param	sess_type	Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ * @return
+ *   - On success return 0.
+ *   - On failure return negative integer.
+ */
+typedef int (*cryptodev_session_event_mdata_set_t)(
+	struct rte_cryptodev *dev, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata);
+
 /** Crypto device operations function pointer table */
 struct rte_cryptodev_ops {
 	cryptodev_configure_t dev_configure;	/**< Configure device. */
@@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
 			/**< Initialize raw data path context data. */
 		};
 	};
+	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
+	/**< Set a Crypto or Security session even meta data. */
 };
 
 
@@ -603,6 +624,19 @@ void
 cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
 		     const struct rte_cryptodev *dev);
 
+/**
+ * Get session event meta data (aka *union rte_event_crypto_metadata*)
+ *
+ * @param	op            pointer to *rte_crypto_op* structure.
+ *
+ * @return
+ *  - On success, pointer to event crypto metadata
+ *  - On failure, a negative value.
+ */
+__rte_internal
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
+
 static inline void *
 get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
 		uint8_t driver_id) {
@@ -636,6 +670,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
 	/**< Size of private data used when creating mempool */
 	uint16_t user_data_sz;
 	/**< Session user data will be placed after sess_data */
+	void *event_mdata;
+	/**< Event crypto adapter metadata */
 	uint8_t padding[3];
 	uint8_t sess_private_data[0];
 };
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 3500a2d470..a070cb2a00 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t dev_id, void *sess)
 
 	dev->dev_ops->asym_session_clear(dev, sess);
 
+	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata)
+		rte_free(((struct rte_cryptodev_asym_session *)sess)->event_mdata);
+
 	/* Return session to mempool */
 	sess_mp = rte_mempool_from_obj(sess);
 	rte_mempool_put(sess_mp, sess);
@@ -2259,6 +2262,44 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t dev_id, uint16_t qp_id,
 			sess_type, session_ctx, is_update);
 }
 
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata,
+	uint16_t size)
+{
+	struct rte_cryptodev *dev;
+
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		goto skip_pmd_op;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (dev->dev_ops->session_ev_mdata_set == NULL)
+		goto skip_pmd_op;
+
+	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
+			sess_type, ev_mdata);
+
+skip_pmd_op:
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
+		return rte_cryptodev_sym_session_set_user_data(sess, ev_mdata,
+				size);
+	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		struct rte_cryptodev_asym_session *s = sess;
+
+		if (s->event_mdata == NULL) {
+			s->event_mdata = rte_malloc(NULL, size, 0);
+			if (s->event_mdata == NULL)
+				return -ENOMEM;
+		}
+		rte_memcpy(s->event_mdata, ev_mdata, size);
+
+		return 0;
+	} else
+		return -ENOTSUP;
+}
+
 uint32_t
 rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx,
 	struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs,
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 45d33f4a50..2c2c2edeb7 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -1269,6 +1269,28 @@ __rte_experimental
 int
 rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
 
+/**
+ * Set session event meta data
+ *
+ * @param	dev_id		The device identifier.
+ * @param	sess            Crypto or security session.
+ * @param	op_type         Operation type.
+ * @param	sess_type       Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ * @param	size            Size of ev_mdata.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+__rte_experimental
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata, uint16_t size);
+
 /**
  * Union of different crypto session types, including session-less xform
  * pointer.
diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map
index c7c5aefceb..f0abfaa47d 100644
--- a/lib/cryptodev/version.map
+++ b/lib/cryptodev/version.map
@@ -105,6 +105,9 @@ EXPERIMENTAL {
 	rte_cryptodev_asym_session_pool_create;
 	rte_cryptodev_asym_session_set_user_data;
 	__rte_cryptodev_trace_asym_session_pool_create;
+
+	#added in 22.07
+	rte_cryptodev_session_event_mdata_set;
 };
 
 INTERNAL {
@@ -123,5 +126,6 @@ INTERNAL {
 	rte_cryptodev_pmd_parse_input_args;
 	rte_cryptodev_pmd_probing_finish;
 	rte_cryptodev_pmd_release_device;
+	rte_cryptodev_session_event_mdata_get;
 	rte_cryptodevs;
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 2/7] crypto/cnxk: add event metadata set operation
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
  2022-04-21 14:37     ` [PATCH v3 1/7] cryptodev: add APIs to get/set " Akhil Goyal
@ 2022-04-21 14:37     ` Akhil Goyal
  2022-04-27 15:38       ` Zhang, Roy Fan
  2022-05-01 13:17       ` Gujjar, Abhinandan S
  2022-04-21 14:37     ` [PATCH v3 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
                       ` (7 subsequent siblings)
  9 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

From: Volodymyr Fialko <vfialko@marvell.com>

Added cryptodev operation for setting event crypto
metadata for all supported sessions - sym/asym/security.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++---
 drivers/crypto/cnxk/cn10k_ipsec.h         |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 138 ++++++++++++++++++---
 drivers/crypto/cnxk/cn9k_ipsec.h          |   2 +
 drivers/crypto/cnxk/cnxk_ae.h             |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  18 ---
 drivers/crypto/cnxk/cnxk_se.h             |   2 +
 7 files changed, 255 insertions(+), 53 deletions(-)

diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
index c4d5d039ec..01aa0d6870 100644
--- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
@@ -264,30 +264,136 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count + i;
 }
 
-uint16_t
-cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				      void *sess,
+				      enum rte_crypto_op_type op_type,
+				      enum rte_crypto_op_sess_type sess_type,
+				      void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
-	uint64_t lmt_base, lmt_arg;
-	struct cpt_inst_s *inst;
 	struct cnxk_cpt_qp *qp;
 	uint8_t cdev_id;
-	uint16_t lmt_id;
-	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	int16_t qp_id;
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn10k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn10k_ca_meta_info_extract(struct rte_crypto_op *op,
+			 struct cnxk_cpt_qp **qp, uint64_t *w2)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			*w2 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn10k_cryptodev_driver_id);
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata *)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			*w2 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	uint64_t lmt_base, lmt_arg, w2;
+	struct cpt_inst_s *inst;
+	struct cnxk_cpt_qp *qp;
+	uint16_t lmt_id;
+	int ret;
+
+	ret = cn10k_ca_meta_info_extract(op, &qp, &w2);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -316,9 +422,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst->w0.u64 = 0;
 	inst->res_addr = (uint64_t)&infl_req->res;
-	inst->w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
+	inst->w2.u64 = w2;
 	inst->w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -327,7 +431,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst->w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id;
@@ -592,4 +696,6 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set,
 };
diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h b/drivers/crypto/cnxk/cn10k_ipsec.h
index 647a71cdd5..1c1d904799 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec.h
@@ -20,6 +20,8 @@ struct cn10k_ipsec_sa {
 	uint16_t iv_offset;
 	uint8_t iv_length;
 	bool is_outbound;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 
 	/**
 	 * End of SW mutable area
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index d3d441cb24..98fa97ef01 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -316,28 +316,134 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count;
 }
 
-uint16_t
-cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				     void *sess,
+				     enum rte_crypto_op_type op_type,
+				     enum rte_crypto_op_sess_type sess_type,
+				     void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
 	struct cnxk_cpt_qp *qp;
-	struct cpt_inst_s inst;
 	uint8_t cdev_id;
 	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn9k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn9k_ca_meta_info_extract(struct rte_crypto_op *op,
+			struct cnxk_cpt_qp **qp, struct cpt_inst_s *inst)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			inst->w2.u64 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn9k_cryptodev_driver_id);
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata *)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			inst->w2.u64 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	struct cnxk_cpt_qp *qp;
+	struct cpt_inst_s inst;
+	int ret;
+
+	ret = cn9k_ca_meta_info_extract(op, &qp, &inst);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -362,9 +468,6 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst.w0.u64 = 0;
 	inst.res_addr = (uint64_t)&infl_req->res;
-	inst.w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
 	inst.w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -373,7 +476,7 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst.w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	cn9k_cpt_inst_submit(&inst, qp->lmtline.lmt_base, qp->lmtline.io_addr);
@@ -613,4 +716,7 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set,
+
 };
diff --git a/drivers/crypto/cnxk/cn9k_ipsec.h b/drivers/crypto/cnxk/cn9k_ipsec.h
index f3acad561b..499dbc2782 100644
--- a/drivers/crypto/cnxk/cn9k_ipsec.h
+++ b/drivers/crypto/cnxk/cn9k_ipsec.h
@@ -42,6 +42,8 @@ struct cn9k_ipsec_sa {
 	struct cnxk_on_ipsec_ar ar;
 	/** Anti replay window size */
 	uint32_t replay_win_sz;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 };
 
 struct cn9k_sec_session {
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 01ccfcd334..10854c79c8 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -22,6 +22,8 @@ struct cnxk_ae_sess {
 	uint64_t *cnxk_fpm_iova;
 	struct roc_ae_ec_group **ec_grp;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 };
 
 static __rte_always_inline void
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
index ab0f00ee7c..7ece0214dc 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
@@ -125,24 +125,6 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
 			struct rte_cryptodev_asym_session *sess);
 void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
 
-static inline union rte_event_crypto_metadata *
-cnxk_event_crypto_mdata_get(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-			op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata
-				    *)((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 static __rte_always_inline void
 pending_queue_advance(uint64_t *index, const uint64_t mask)
 {
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index e988d57b94..b11c2bb3a2 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -33,6 +33,8 @@ struct cnxk_se_sess {
 	uint16_t auth_iv_offset;
 	uint32_t salt;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 	struct roc_se_ctx roc_se_ctx;
 } __rte_cache_aligned;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 3/7] crypto/octeontx: use new API for event metadata
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
  2022-04-21 14:37     ` [PATCH v3 1/7] cryptodev: add APIs to get/set " Akhil Goyal
  2022-04-21 14:37     ` [PATCH v3 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
@ 2022-04-21 14:37     ` Akhil Goyal
  2022-04-27 15:38       ` Zhang, Roy Fan
  2022-05-01 13:18       ` Gujjar, Abhinandan S
  2022-04-21 14:37     ` [PATCH v3 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
                       ` (6 subsequent siblings)
  9 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata can be used
directly instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index ddb1266c3c..d5851d9987 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -684,24 +684,6 @@ submit_request_to_sso(struct ssows *ws, uintptr_t req,
 	ssovf_store_pair(add_work, req, ws->grps[rsp_info->queue_id]);
 }
 
-static inline union rte_event_crypto_metadata *
-get_event_crypto_mdata(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-							   op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata *)
-			((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 uint16_t __rte_hot
 otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 {
@@ -712,7 +694,7 @@ otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 	uint8_t op_type, cdev_id;
 	uint16_t qp_id;
 
-	ec_mdata = get_event_crypto_mdata(op);
+	ec_mdata = rte_cryptodev_session_event_mdata_get(op);
 	if (unlikely(ec_mdata == NULL)) {
 		rte_errno = EINVAL;
 		return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 4/7] test/event: use new API to set event crypto metadata
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
                       ` (2 preceding siblings ...)
  2022-04-21 14:37     ` [PATCH v3 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
@ 2022-04-21 14:37     ` Akhil Goyal
  2022-04-27 15:39       ` Zhang, Roy Fan
  2022-04-28 14:47       ` Gujjar, Abhinandan S
  2022-04-21 14:37     ` [PATCH v3 5/7] eventdev: use new API to get " Akhil Goyal
                       ` (5 subsequent siblings)
  9 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

Used the new API rte_cryptodev_set_session_event_mdata to set
event crypto metadata from the applications (app/test and
app/test-eventdev) instead of using session userdata.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test-eventdev/test_perf_common.c |  8 ++++++--
 app/test/test_event_crypto_adapter.c | 12 ++++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9d1f4a4567..0378607cda 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -835,8 +835,12 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 					return -ENOMEM;
 
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_sym_session_set_user_data(
-					crypto_sess, &m_data, sizeof(m_data));
+				rte_cryptodev_session_event_mdata_set(cdev_id,
+						crypto_sess,
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data, sizeof(m_data));
+
 				p->ca.crypto_sess[flow_id] = crypto_sess;
 			}
 
diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 688520db4e..9904206735 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -227,8 +227,10 @@ test_op_forward_mode(uint8_t session_less)
 			m_data.request_info.queue_pair_id =
 				request_info.queue_pair_id;
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
 		}
 
 		rte_crypto_op_attach_sym_session(op, sess);
@@ -416,8 +418,10 @@ test_op_new_mode(uint8_t session_less)
 		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
 			/* Fill in private user data information */
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
 		}
 		ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess,
 				&cipher_xform, params.session_priv_mpool);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 5/7] eventdev: use new API to get event crypto metadata
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
                       ` (3 preceding siblings ...)
  2022-04-21 14:37     ` [PATCH v3 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
@ 2022-04-21 14:37     ` Akhil Goyal
  2022-04-27 15:39       ` Zhang, Roy Fan
  2022-04-28 15:08       ` Gujjar, Abhinandan S
  2022-04-21 14:37     ` [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
                       ` (4 subsequent siblings)
  9 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata is used
instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 lib/eventdev/rte_event_crypto_adapter.c | 55 ++++++-------------------
 1 file changed, 12 insertions(+), 43 deletions(-)

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index f624f50187..7c695176f4 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -457,43 +457,22 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
-		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					crypto_op->sym->session);
-			if (m_data == NULL) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
+		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
+		if (m_data == NULL) {
+			rte_pktmbuf_free(crypto_op->sym->m_src);
+			rte_crypto_op_free(crypto_op);
+			continue;
+		}
 
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else if (crypto_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				crypto_op->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)crypto_op +
-					crypto_op->private_data_offset);
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else {
+		cdev_id = m_data->request_info.cdev_id;
+		qp_id = m_data->request_info.queue_pair_id;
+		qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
+		if (!qp_info->qp_enabled) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
 			rte_crypto_op_free(crypto_op);
 			continue;
 		}
+		eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
 
 		if (eca_circular_buffer_batch_ready(&qp_info->cbuf)) {
 			ret = eca_circular_buffer_flush_to_cdev(&qp_info->cbuf,
@@ -636,17 +615,7 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 	for (i = 0; i < num; i++) {
 		struct rte_event *ev = &events[nb_ev++];
 
-		m_data = NULL;
-		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					ops[i]->sym->session);
-		} else if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				ops[i]->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)ops[i] +
-				  ops[i]->private_data_offset);
-		}
-
+		m_data = rte_cryptodev_session_event_mdata_get(ops[i]);
 		if (unlikely(m_data == NULL)) {
 			rte_pktmbuf_free(ops[i]->sym->m_src);
 			rte_crypto_op_free(ops[i]);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
                       ` (4 preceding siblings ...)
  2022-04-21 14:37     ` [PATCH v3 5/7] eventdev: use new API to get " Akhil Goyal
@ 2022-04-21 14:37     ` Akhil Goyal
  2022-04-27 15:39       ` Zhang, Roy Fan
  2022-04-28 15:14       ` Gujjar, Abhinandan S
  2022-04-21 14:37     ` [PATCH v3 7/7] test-eventdev: support asym ops " Akhil Goyal
                       ` (3 subsequent siblings)
  9 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

Test app is updated to add cases for asymmetric crypto
sessions for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test/test_event_crypto_adapter.c | 491 ++++++++++++++++++++++++++-
 1 file changed, 485 insertions(+), 6 deletions(-)

diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 9904206735..eecfc22057 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -6,6 +6,7 @@
 #include "test.h"
 #include <string.h>
 #include <rte_common.h>
+#include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
@@ -67,12 +68,97 @@ static const uint8_t text_64B[] = {
 	0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
 	0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c
 };
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 struct event_crypto_adapter_test_params {
 	struct rte_mempool *mbuf_pool;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *asym_op_mpool;
 	struct rte_mempool *session_mpool;
 	struct rte_mempool *session_priv_mpool;
+	struct rte_mempool *asym_sess_mpool;
 	struct rte_cryptodev_config *config;
 	uint8_t crypto_event_port_id;
 	uint8_t internal_port_op_fwd;
@@ -134,11 +220,24 @@ send_recv_ev(struct rte_event *ev)
 		rte_pause();
 
 	op = recv_ev.event_ptr;
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(op->sym->m_src);
+		rte_pktmbuf_free(op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(op);
 
 	return TEST_SUCCESS;
@@ -348,6 +447,170 @@ test_session_with_op_forward_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_forward_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	struct rte_event ev;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op,
+		"Failed to allocate asymmetric crypto operation struct\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		/* Create Crypto session*/
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.request_info.cdev_id = request_info.cdev_id;
+			m_data.request_info.queue_pair_id =
+				request_info.queue_pair_id;
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.request_info.cdev_id = request_info.cdev_id;
+		m_data.request_info.queue_pair_id = request_info.queue_pair_id;
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+	/* Fill in event info and update event_ptr with rte_crypto_op */
+	memset(&ev, 0, sizeof(ev));
+	ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
+	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	ev.flow_id = 0xAABB;
+	ev.event_ptr = op;
+
+	ret = send_recv_ev(&ev);
+	TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
+				"crypto adapter\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+
+static int
+test_asym_sessionless_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(1);
+}
+
+static int
+test_asym_session_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID
+				), "Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(0);
+}
+
 static int
 send_op_recv_ev(struct rte_crypto_op *op)
 {
@@ -365,11 +628,24 @@ send_op_recv_ev(struct rte_crypto_op *op)
 		rte_pause();
 
 	recv_op = ev.event_ptr;
+	if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = recv_op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = recv_op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(recv_op->sym->m_src);
+		rte_pktmbuf_free(recv_op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(recv_op);
 
 	return TEST_SUCCESS;
@@ -505,6 +781,156 @@ test_session_with_op_new_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_new_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+
+	ret = send_op_recv_ev(op);
+	TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_asym_sessionless_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	/* start the event crypto adapter */
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(1);
+}
+
+static int
+test_asym_session_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(0);
+}
+
 static int
 configure_cryptodev(void)
 {
@@ -537,6 +963,19 @@ configure_cryptodev(void)
 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
 		return TEST_FAILED;
 	}
+	params.asym_op_mpool = rte_crypto_op_pool_create(
+			"EVENT_CRYPTO_ASYM_OP_POOL",
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+			NUM_MBUFS, MBUF_CACHE_SIZE,
+			(DEFAULT_NUM_XFORMS *
+			sizeof(struct rte_crypto_asym_xform)) +
+			sizeof(union rte_event_crypto_metadata),
+			rte_socket_id());
+	if (params.asym_op_mpool == NULL) {
+		RTE_LOG(ERR, USER1, "Can't create CRYPTO_ASYM_OP_POOL\n");
+		return TEST_FAILED;
+	}
+
 
 	/* Create a NULL crypto device */
 	nb_devs = rte_cryptodev_device_count_by_driver(
@@ -581,6 +1020,15 @@ configure_cryptodev(void)
 	TEST_ASSERT_NOT_NULL(params.session_priv_mpool,
 			"session mempool allocation failed\n");
 
+	params.asym_sess_mpool = rte_cryptodev_asym_session_pool_create(
+			"CRYPTO_AD_ASYM_SESS_MP",
+			MAX_NB_SESSIONS, 0,
+			sizeof(union rte_event_crypto_metadata),
+			SOCKET_ID_ANY);
+	TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
+			"asym session mempool allocation failed\n");
+
+
 	rte_cryptodev_info_get(TEST_CDEV_ID, &info);
 	conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	conf.socket_id = SOCKET_ID_ANY;
@@ -960,6 +1408,21 @@ crypto_teardown(void)
 		params.session_priv_mpool = NULL;
 	}
 
+	/* Free asym session mempool */
+	if (params.asym_sess_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count %u\n",
+		rte_mempool_avail_count(params.asym_sess_mpool));
+		rte_mempool_free(params.asym_sess_mpool);
+		params.asym_sess_mpool = NULL;
+	}
+	/* Free asym ops mempool */
+	if (params.asym_op_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL count %u\n",
+		rte_mempool_avail_count(params.asym_op_mpool));
+		rte_mempool_free(params.asym_op_mpool);
+		params.asym_op_mpool = NULL;
+	}
+
 	/* Free ops mempool */
 	if (params.op_mpool != NULL) {
 		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL count %u\n",
@@ -1016,6 +1479,22 @@ static struct unit_test_suite functional_testsuite = {
 				test_crypto_adapter_stop,
 				test_sessionless_with_op_new_mode),
 
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_new_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_new_mode),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v3 7/7] test-eventdev: support asym ops for crypto adapter
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
                       ` (5 preceding siblings ...)
  2022-04-21 14:37     ` [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
@ 2022-04-21 14:37     ` Akhil Goyal
  2022-04-27 15:40       ` Zhang, Roy Fan
  2022-05-01 13:00       ` Gujjar, Abhinandan S
  2022-04-27 15:37     ` [PATCH v3 0/7] Add new cryptodev op for event metadata Zhang, Roy Fan
                       ` (2 subsequent siblings)
  9 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-04-21 14:37 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

Test eventdev app is updated to add new option for asymmetric
crypto ops for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test-eventdev/evt_common.h       |   2 +
 app/test-eventdev/evt_options.c      |  17 ++
 app/test-eventdev/evt_options.h      |   4 +
 app/test-eventdev/test_perf_atq.c    |  12 +-
 app/test-eventdev/test_perf_common.c | 250 +++++++++++++++++++++++----
 app/test-eventdev/test_perf_common.h |  45 +++--
 app/test-eventdev/test_perf_queue.c  |  12 +-
 doc/guides/tools/testeventdev.rst    |   5 +
 8 files changed, 284 insertions(+), 63 deletions(-)

diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index 2f301a7e79..196eca8bd0 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -6,6 +6,7 @@
 #define _EVT_COMMON_
 
 #include <rte_common.h>
+#include <rte_crypto.h>
 #include <rte_debug.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_eventdev.h>
@@ -80,6 +81,7 @@ struct evt_options {
 	uint64_t optm_timer_tick_nsec;
 	enum evt_prod_type prod_type;
 	enum rte_event_crypto_adapter_mode crypto_adptr_mode;
+	enum rte_crypto_op_type crypto_op_type;
 };
 
 static inline bool
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index d3c704d2b3..8326734b64 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -38,6 +38,7 @@ evt_options_default(struct evt_options *opt)
 	opt->eth_queues = 1;
 	opt->vector_size = 64;
 	opt->vector_tmo_nsec = 100E3;
+	opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
 }
 
 typedef int (*option_parser_t)(struct evt_options *opt,
@@ -142,6 +143,18 @@ evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
 	return ret;
 }
 
+static int
+evt_parse_crypto_op_type(struct evt_options *opt, const char *arg)
+{
+	uint8_t op_type;
+	int ret;
+
+	ret = parser_read_uint8(&op_type, arg);
+	opt->crypto_op_type = op_type ? RTE_CRYPTO_OP_TYPE_ASYMMETRIC :
+					RTE_CRYPTO_OP_TYPE_SYMMETRIC;
+	return ret;
+}
+
 static int
 evt_parse_test_name(struct evt_options *opt, const char *arg)
 {
@@ -368,6 +381,8 @@ usage(char *program)
 		"\t--expiry_nsec      : event timer expiry ns.\n"
 		"\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
 		"\t                      1 for OP_FORWARD mode.\n"
+		"\t--crypto_op_type   : 0 for SYM ops (default) and\n"
+		"\t                     1 for ASYM ops.\n"
 		"\t--mbuf_sz          : packet mbuf size.\n"
 		"\t--max_pkt_sz       : max packet size.\n"
 		"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -442,6 +457,7 @@ static struct option lgopts[] = {
 	{ EVT_PROD_TIMERDEV,       0, 0, 0 },
 	{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
 	{ EVT_CRYPTO_ADPTR_MODE,   1, 0, 0 },
+	{ EVT_CRYPTO_OP_TYPE,	   1, 0, 0 },
 	{ EVT_NB_TIMERS,           1, 0, 0 },
 	{ EVT_NB_TIMER_ADPTRS,     1, 0, 0 },
 	{ EVT_TIMER_TICK_NSEC,     1, 0, 0 },
@@ -484,6 +500,7 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
 		{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
 		{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
 		{ EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
+		{ EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type},
 		{ EVT_NB_TIMERS, evt_parse_nb_timers},
 		{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
 		{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 2231c58801..f23fb8a511 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -38,6 +38,7 @@
 #define EVT_PROD_TIMERDEV        ("prod_type_timerdev")
 #define EVT_PROD_TIMERDEV_BURST  ("prod_type_timerdev_burst")
 #define EVT_CRYPTO_ADPTR_MODE	 ("crypto_adptr_mode")
+#define EVT_CRYPTO_OP_TYPE	 ("crypto_op_type")
 #define EVT_NB_TIMERS            ("nb_timers")
 #define EVT_NB_TIMER_ADPTRS      ("nb_timer_adptrs")
 #define EVT_TIMER_TICK_NSEC      ("timer_tick_nsec")
@@ -298,6 +299,9 @@ evt_dump_producer_type(struct evt_options *opt)
 			 "Event crypto adapter producers");
 		evt_dump("crypto adapter mode", "%s",
 			 opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+		evt_dump("crypto op type", "%s",
+			 (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) ?
+			 "SYMMETRIC" : "ASYMMETRIC");
 		evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
 		break;
 	}
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 67ff681666..6a2aa86fd2 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -53,11 +53,13 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 0378607cda..f2da6fd74c 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -7,6 +7,89 @@
 #include "test_perf_common.h"
 
 #define NB_CRYPTODEV_DESCRIPTORS 128
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 int
 perf_test_result(struct evt_test *test, struct evt_options *opt)
@@ -277,12 +360,10 @@ perf_event_timer_producer_burst(void *arg)
 static inline void
 crypto_adapter_enq_op_new(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	struct test_perf *t = p->t;
 	const uint32_t nb_flows = t->nb_flows;
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
-	struct rte_crypto_sym_op *sym_op;
 	struct evt_options *opt = t->opt;
 	uint16_t qp_id = p->ca.cdev_qp_id;
 	uint8_t cdev_id = p->ca.cdev_id;
@@ -300,22 +381,39 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
 
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
-		       t->done == false)
+				t->done == false)
 			rte_pause();
 
 		count++;
@@ -325,7 +423,6 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 static inline void
 crypto_adapter_enq_op_fwd(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	const uint8_t dev_id = p->dev_id;
 	const uint8_t port = p->port_id;
 	struct test_perf *t = p->t;
@@ -333,7 +430,6 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
 	struct evt_options *opt = t->opt;
-	struct rte_crypto_sym_op *sym_op;
 	uint32_t flow_counter = 0;
 	struct rte_crypto_op *op;
 	struct rte_event ev;
@@ -354,19 +450,37 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
+
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		ev.event_ptr = op;
 
 		while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
@@ -729,6 +843,37 @@ cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
 	return sess;
 }
 
+static void *
+cryptodev_asym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform;
+	void *sess;
+
+	xform.next = NULL;
+	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform.xform_type;
+	capability = rte_cryptodev_asym_capability_get(p->ca.cdev_id, &cap_idx);
+	if (capability == NULL) {
+		evt_err("Device doesn't support MODEX. Test Skipped\n");
+		return NULL;
+	}
+
+	xform.modex.modulus.data = modex_test_case.modulus.data;
+	xform.modex.modulus.length = modex_test_case.modulus.len;
+	xform.modex.exponent.data = modex_test_case.exponent.data;
+	xform.modex.exponent.length = modex_test_case.exponent.len;
+
+	if (rte_cryptodev_asym_session_create(p->ca.cdev_id, &xform,
+			t->ca_asym_sess_pool, &sess)) {
+		evt_err("Failed to create asym session");
+		return NULL;
+	}
+
+	return sess;
+}
+
 int
 perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 				uint8_t stride, uint8_t nb_queues,
@@ -804,7 +949,6 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 
 		prod = 0;
 		for (; port < perf_nb_event_ports(opt); port++) {
-			struct rte_cryptodev_sym_session *crypto_sess;
 			union rte_event_crypto_metadata m_data;
 			struct prod_data *p = &t->prod[port];
 			uint32_t flow_id;
@@ -820,7 +964,7 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			p->ca.cdev_id = cdev_id;
 			p->ca.cdev_qp_id = qp_id;
 			p->ca.crypto_sess = rte_zmalloc_socket(
-				NULL, sizeof(crypto_sess) * t->nb_flows,
+				NULL, sizeof(void *) * t->nb_flows,
 				RTE_CACHE_LINE_SIZE, opt->socket_id);
 			p->t = t;
 
@@ -830,18 +974,36 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			m_data.response_info.queue_id = p->queue_id;
 
 			for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
-				crypto_sess = cryptodev_sym_sess_create(p, t);
-				if (crypto_sess == NULL)
-					return -ENOMEM;
-
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_session_event_mdata_set(cdev_id,
-						crypto_sess,
+				if (opt->crypto_op_type ==
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					struct rte_cryptodev_sym_session *sess;
+
+					sess = cryptodev_sym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
 						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 						RTE_CRYPTO_OP_WITH_SESSION,
 						&m_data, sizeof(m_data));
+					p->ca.crypto_sess[flow_id] = sess;
+				} else {
+					void *sess;
 
-				p->ca.crypto_sess[flow_id] = crypto_sess;
+					sess = cryptodev_asym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
+						RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data, sizeof(m_data));
+					p->ca.crypto_sess[flow_id] = sess;
+				}
 			}
 
 			conf.event_port_cfg |=
@@ -1123,14 +1285,24 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	t->ca_op_pool = rte_crypto_op_pool_create(
-		"crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
-		128, 0, rte_socket_id());
+		"crypto_op_pool", opt->crypto_op_type, opt->pool_sz,
+		128, sizeof(union rte_event_crypto_metadata),
+		rte_socket_id());
 	if (t->ca_op_pool == NULL) {
 		evt_err("Failed to create crypto op pool");
 		return -ENOMEM;
 	}
 
 	nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+	t->ca_asym_sess_pool = rte_cryptodev_asym_session_pool_create(
+		"ca_asym_sess_pool", nb_sessions, 0,
+		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+	if (t->ca_asym_sess_pool == NULL) {
+		evt_err("Failed to create sym session pool");
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
 		"ca_sess_pool", nb_sessions, 0, 0,
 		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
@@ -1217,6 +1389,7 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 
 	return ret;
 }
@@ -1258,6 +1431,7 @@ perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 }
 
 int
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index ea0907d61a..5651832cc9 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -40,7 +40,7 @@ struct worker_data {
 struct crypto_adptr_data {
 	uint8_t cdev_id;
 	uint16_t cdev_qp_id;
-	struct rte_cryptodev_sym_session **crypto_sess;
+	void **crypto_sess;
 };
 struct prod_data {
 	uint8_t dev_id;
@@ -70,6 +70,7 @@ struct test_perf {
 	struct rte_mempool *ca_op_pool;
 	struct rte_mempool *ca_sess_pool;
 	struct rte_mempool *ca_sess_priv_pool;
+	struct rte_mempool *ca_asym_sess_pool;
 } __rte_cache_aligned;
 
 struct perf_elt {
@@ -111,8 +112,6 @@ perf_process_last_stage(struct rte_mempool *const pool,
 		struct rte_event *const ev, struct worker_data *const w,
 		void *bufs[], int const buf_sz, uint8_t count)
 {
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -120,9 +119,19 @@ perf_process_last_stage(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)ev->event_ptr)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		struct rte_crypto_op *op = ev->event_ptr;
+
+		rte_free(op->asym->modex.result.data);
+		rte_crypto_op_free(op);
+	} else {
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		}
 	}
 	return count;
 }
@@ -135,8 +144,6 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	uint64_t latency;
 	struct perf_elt *const m = ev->event_ptr;
 
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -144,15 +151,23 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		latency = rte_get_timer_cycles() - m->timestamp;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)m)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		rte_free(((struct rte_crypto_op *)m)->asym->modex.result.data);
+		rte_crypto_op_free((struct rte_crypto_op *)m);
 	} else {
-		latency = rte_get_timer_cycles() - m->timestamp;
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			latency = rte_get_timer_cycles() - m->timestamp;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		} else {
+			latency = rte_get_timer_cycles() - m->timestamp;
+		}
+
+		w->latency += latency;
 	}
-
-	w->latency += latency;
 	return count;
 }
 
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index dcf6d82947..631a39f727 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -55,11 +55,13 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index f7d813226d..a8e02d57a4 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -157,6 +157,11 @@ The following are the application command-line options:
         Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
         OP_FORWARD mode.
 
+* ``--crypto_op_type``
+
+        Set crypto operation type. Use 0 for symmetric crypto ops (default)
+        and 1 for asymmetric crypto ops.
+
 * ``--mbuf_sz``
 
        Set packet mbuf size. Can be used to configure Jumbo Frames. Only
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 0/7] Add new cryptodev op for event metadata
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
                       ` (6 preceding siblings ...)
  2022-04-21 14:37     ` [PATCH v3 7/7] test-eventdev: support asym ops " Akhil Goyal
@ 2022-04-27 15:37     ` Zhang, Roy Fan
  2022-04-28 14:24     ` Gujjar, Abhinandan S
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
  9 siblings, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:37 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko



> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 0/7] Add new cryptodev op for event metadata
> 
> For using event crypto metadata, event metadata need to be set
> in session. For this session user data was used for symmetric
> crypto sessions and no support was present for asymmetric and
> security sessions.
> The use of userdata to store event metadata (which is dereferenced
> in PMD) is not correct as it is meant for the application to use it.
> Hence, a new API is created to set and get event crypto metadata which
> is scalable to all sessions supported by the crypto PMD.
> The application can use the set API to set event metadata and the
> PMD may store that inside the session private data and PMD need not
> use the get API as it would be internal to the PMD.
> For the software event crypto adapter implementation, the eventdev
> library can use the get API to get the event metadata stored inside
> the session structure.
> For Asymmetric sessions, a new field is added inside the session
> struct which is internal to library.
> For symmetric and security sessions, new field cannot be added as
> it would be ABI break. Hence, session userdata is being used to
> store that as it was used earlier. In next ABI break release this
> would be fixed similar to asymmetric crypto case.
> 
> The patchset also add support for asymmetric crypto adapter
> in the test applications and the crypto/cnxk implementation of
> the new cryptodev op and corresponding changes in the eventdev lib.
> 
> Changes in v3:
> - fix SW adapter case of memory allocation/free of mdata. mdata is
> allocated in set API and freed in session clear/destroy.
> - mark rte_cryptodev_session_event_mdata_get as internal API
> as it is only needed for the app or the PMD.
> 
> changes in v2:
> - v1 patchset only fixed security sessions and also caused ABI breakage.
> This is fixed in v2.
> - added new API for setting event metadata.
> - added new cryptodev op which can handle all sessions
> 
> 
> Akhil Goyal (5):
>   crypto/octeontx: use new API for event metadata
>   test/event: use new API to set event crypto metadata
>   eventdev: use new API to get event crypto metadata
>   test/event: add asymmetric cases for crypto adapter
>   test-eventdev: support asym ops for crypto adapter
> 
> Volodymyr Fialko (2):
>   cryptodev: add APIs to get/set event metadata
>   crypto/cnxk: add event metadata set operation
> 
>  app/test-eventdev/evt_common.h              |   2 +
>  app/test-eventdev/evt_options.c             |  17 +
>  app/test-eventdev/evt_options.h             |   4 +
>  app/test-eventdev/test_perf_atq.c           |  12 +-
>  app/test-eventdev/test_perf_common.c        | 254 ++++++++--
>  app/test-eventdev/test_perf_common.h        |  45 +-
>  app/test-eventdev/test_perf_queue.c         |  12 +-
>  app/test/test_event_crypto_adapter.c        | 503 +++++++++++++++++++-
>  doc/guides/tools/testeventdev.rst           |   5 +
>  drivers/crypto/cnxk/cn10k_cryptodev_ops.c   | 144 +++++-
>  drivers/crypto/cnxk/cn10k_ipsec.h           |   2 +
>  drivers/crypto/cnxk/cn9k_cryptodev_ops.c    | 138 +++++-
>  drivers/crypto/cnxk/cn9k_ipsec.h            |   2 +
>  drivers/crypto/cnxk/cnxk_ae.h               |   2 +
>  drivers/crypto/cnxk/cnxk_cryptodev_ops.h    |  18 -
>  drivers/crypto/cnxk/cnxk_se.h               |   2 +
>  drivers/crypto/octeontx/otx_cryptodev_ops.c |  20 +-
>  lib/cryptodev/cryptodev_pmd.c               |  16 +
>  lib/cryptodev/cryptodev_pmd.h               |  36 ++
>  lib/cryptodev/rte_cryptodev.c               |  41 ++
>  lib/cryptodev/rte_cryptodev.h               |  22 +
>  lib/cryptodev/version.map                   |   4 +
>  lib/eventdev/rte_event_crypto_adapter.c     |  55 +--
>  23 files changed, 1168 insertions(+), 188 deletions(-)
> 
> --
> 2.25.1
Series-acked-by: Fan Zhang <roy.fan.zhang@intel.com>


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
  2022-04-21 14:37     ` [PATCH v3 1/7] cryptodev: add APIs to get/set " Akhil Goyal
@ 2022-04-27 15:38       ` Zhang, Roy Fan
  2022-04-28 14:42       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:38 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
> 
> From: Volodymyr Fialko <vfialko@marvell.com>
> 
> Currently, crypto session userdata is used to set event crypto
> metadata from the application and the driver is dereferencing it
> in driver which is not correct. User data is meant to be opaque
> to the driver.
> To support this, new API is added to get and set event crypto
> metadata. The new API, rte_cryptodev_set_session_event_mdata,
> allows setting event metadata in session private data which is
> filled inside PMD using a new cryptodev op. This operation
> can be performed on any of the PMD supported sessions
> (sym/asym/security).
> For SW abstraction of event crypto adapter to be used by
> eventdev library, a new field is added in asymmetric crypto
> session for now and for symmetric case, current implementation
> of using userdata is used. Symmetric cases cannot be fixed now,
> as it will be ABI breakage which will be resolved in DPDK 22.11.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 2/7] crypto/cnxk: add event metadata set operation
  2022-04-21 14:37     ` [PATCH v3 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
@ 2022-04-27 15:38       ` Zhang, Roy Fan
  2022-05-01 13:17       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:38 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 2/7] crypto/cnxk: add event metadata set operation
> 
> From: Volodymyr Fialko <vfialko@marvell.com>
> 
> Added cryptodev operation for setting event crypto
> metadata for all supported sessions - sym/asym/security.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++-
> --
>  drivers/crypto/cnxk/cn10k_ipsec.h         |   2 +
>  drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 138 ++++++++++++++++++---
>  drivers/crypto/cnxk/cn9k_ipsec.h          |   2 +
>  drivers/crypto/cnxk/cnxk_ae.h             |   2 +
>  drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  18 ---
>  drivers/crypto/cnxk/cnxk_se.h             |   2 +
>  7 files changed, 255 insertions(+), 53 deletions(-)
> 
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 3/7] crypto/octeontx: use new API for event metadata
  2022-04-21 14:37     ` [PATCH v3 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
@ 2022-04-27 15:38       ` Zhang, Roy Fan
  2022-05-01 13:18       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:38 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 3/7] crypto/octeontx: use new API for event metadata
> 
> For getting event crypto metadata from crypto_op,
> the new API rte_cryptodev_get_session_event_mdata can be used
> directly instead of getting userdata inside PMD.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 4/7] test/event: use new API to set event crypto metadata
  2022-04-21 14:37     ` [PATCH v3 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
@ 2022-04-27 15:39       ` Zhang, Roy Fan
  2022-04-28 14:47       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:39 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 4/7] test/event: use new API to set event crypto
> metadata
> 
> Used the new API rte_cryptodev_set_session_event_mdata to set
> event crypto metadata from the applications (app/test and
> app/test-eventdev) instead of using session userdata.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 5/7] eventdev: use new API to get event crypto metadata
  2022-04-21 14:37     ` [PATCH v3 5/7] eventdev: use new API to get " Akhil Goyal
@ 2022-04-27 15:39       ` Zhang, Roy Fan
  2022-04-28 15:08       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:39 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 5/7] eventdev: use new API to get event crypto
> metadata
> 
> For getting event crypto metadata from crypto_op,
> the new API rte_cryptodev_get_session_event_mdata is used
> instead of getting userdata inside PMD.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
  2022-04-21 14:37     ` [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
@ 2022-04-27 15:39       ` Zhang, Roy Fan
  2022-04-28 15:14       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:39 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
> 
> Test app is updated to add cases for asymmetric crypto
> sessions for event crypto adapter.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 7/7] test-eventdev: support asym ops for crypto adapter
  2022-04-21 14:37     ` [PATCH v3 7/7] test-eventdev: support asym ops " Akhil Goyal
@ 2022-04-27 15:40       ` Zhang, Roy Fan
  2022-05-01 13:00       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Zhang, Roy Fan @ 2022-04-27 15:40 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Vangati, Narender, vfialko

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 3:37 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 7/7] test-eventdev: support asym ops for crypto adapter
> 
> Test eventdev app is updated to add new option for asymmetric
> crypto ops for event crypto adapter.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 0/7] Add new cryptodev op for event metadata
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
                       ` (7 preceding siblings ...)
  2022-04-27 15:37     ` [PATCH v3 0/7] Add new cryptodev op for event metadata Zhang, Roy Fan
@ 2022-04-28 14:24     ` Gujjar, Abhinandan S
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
  9 siblings, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-04-28 14:24 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 0/7] Add new cryptodev op for event metadata
> 
> For using event crypto metadata, event metadata need to be set in session. For
> this session user data was used for symmetric crypto sessions and no support
> was present for asymmetric and security sessions.
> The use of userdata to store event metadata (which is dereferenced in PMD) is
> not correct as it is meant for the application to use it.
> Hence, a new API is created to set and get event crypto metadata which is
> scalable to all sessions supported by the crypto PMD.
> The application can use the set API to set event metadata and the PMD may
> store that inside the session private data and PMD need not use the get API as
> it would be internal to the PMD.
> For the software event crypto adapter implementation, the eventdev library
> can use the get API to get the event metadata stored inside the session
> structure.
> For Asymmetric sessions, a new field is added inside the session struct which is
> internal to library.
> For symmetric and security sessions, new field cannot be added as it would be
> ABI break. Hence, session userdata is being used to store that as it was used
> earlier. In next ABI break release this would be fixed similar to asymmetric
> crypto case.
> 
> The patchset also add support for asymmetric crypto adapter in the test
> applications and the crypto/cnxk implementation of the new cryptodev op and
> corresponding changes in the eventdev lib.
> 
> Changes in v3:
> - fix SW adapter case of memory allocation/free of mdata. mdata is allocated in
> set API and freed in session clear/destroy.
> - mark rte_cryptodev_session_event_mdata_get as internal API as it is only
> needed for the app or the PMD.
> 
> changes in v2:
> - v1 patchset only fixed security sessions and also caused ABI breakage.
> This is fixed in v2.
> - added new API for setting event metadata.
> - added new cryptodev op which can handle all sessions
> 
> 
> Akhil Goyal (5):
>   crypto/octeontx: use new API for event metadata
>   test/event: use new API to set event crypto metadata
>   eventdev: use new API to get event crypto metadata
>   test/event: add asymmetric cases for crypto adapter
>   test-eventdev: support asym ops for crypto adapter
> 
> Volodymyr Fialko (2):
>   cryptodev: add APIs to get/set event metadata
>   crypto/cnxk: add event metadata set operation
> 
>  app/test-eventdev/evt_common.h              |   2 +
>  app/test-eventdev/evt_options.c             |  17 +
>  app/test-eventdev/evt_options.h             |   4 +
>  app/test-eventdev/test_perf_atq.c           |  12 +-
>  app/test-eventdev/test_perf_common.c        | 254 ++++++++--
>  app/test-eventdev/test_perf_common.h        |  45 +-
>  app/test-eventdev/test_perf_queue.c         |  12 +-
>  app/test/test_event_crypto_adapter.c        | 503 +++++++++++++++++++-
>  doc/guides/tools/testeventdev.rst           |   5 +
>  drivers/crypto/cnxk/cn10k_cryptodev_ops.c   | 144 +++++-
>  drivers/crypto/cnxk/cn10k_ipsec.h           |   2 +
>  drivers/crypto/cnxk/cn9k_cryptodev_ops.c    | 138 +++++-
>  drivers/crypto/cnxk/cn9k_ipsec.h            |   2 +
>  drivers/crypto/cnxk/cnxk_ae.h               |   2 +
>  drivers/crypto/cnxk/cnxk_cryptodev_ops.h    |  18 -
>  drivers/crypto/cnxk/cnxk_se.h               |   2 +
>  drivers/crypto/octeontx/otx_cryptodev_ops.c |  20 +-
>  lib/cryptodev/cryptodev_pmd.c               |  16 +
>  lib/cryptodev/cryptodev_pmd.h               |  36 ++
>  lib/cryptodev/rte_cryptodev.c               |  41 ++
>  lib/cryptodev/rte_cryptodev.h               |  22 +
>  lib/cryptodev/version.map                   |   4 +
>  lib/eventdev/rte_event_crypto_adapter.c     |  55 +--
>  23 files changed, 1168 insertions(+), 188 deletions(-)
> 
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
  2022-04-21 14:37     ` [PATCH v3 1/7] cryptodev: add APIs to get/set " Akhil Goyal
  2022-04-27 15:38       ` Zhang, Roy Fan
@ 2022-04-28 14:42       ` Gujjar, Abhinandan S
  2022-04-29 12:16         ` Akhil Goyal
  1 sibling, 1 reply; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-04-28 14:42 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko



> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
> 
> From: Volodymyr Fialko <vfialko@marvell.com>
> 
> Currently, crypto session userdata is used to set event crypto metadata from
> the application and the driver is dereferencing it in driver which is not correct.
> User data is meant to be opaque to the driver.
> To support this, new API is added to get and set event crypto metadata. The
> new API, rte_cryptodev_set_session_event_mdata,
> allows setting event metadata in session private data which is filled inside PMD
> using a new cryptodev op. This operation can be performed on any of the PMD
> supported sessions (sym/asym/security).
> For SW abstraction of event crypto adapter to be used by eventdev library, a
> new field is added in asymmetric crypto session for now and for symmetric
> case, current implementation of using userdata is used. Symmetric cases cannot
> be fixed now, as it will be ABI breakage which will be resolved in DPDK 22.11.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  lib/cryptodev/cryptodev_pmd.c | 16 ++++++++++++++
> lib/cryptodev/cryptodev_pmd.h | 36 ++++++++++++++++++++++++++++++
> lib/cryptodev/rte_cryptodev.c | 41 +++++++++++++++++++++++++++++++++++
>  lib/cryptodev/rte_cryptodev.h | 22 +++++++++++++++++++
>  lib/cryptodev/version.map     |  4 ++++
>  5 files changed, 119 insertions(+)
> 
> diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
> index 739a0b3f34..1903ade388 100644
> --- a/lib/cryptodev/cryptodev_pmd.c
> +++ b/lib/cryptodev/cryptodev_pmd.c
> @@ -227,3 +227,19 @@ cryptodev_fp_ops_set(struct rte_crypto_fp_ops
> *fp_ops,
>  	fp_ops->qp.enq_cb = dev->enq_cbs;
>  	fp_ops->qp.deq_cb = dev->deq_cbs;
>  }
> +
> +void *
> +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op) {
Null check for op?
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
> +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> +		return rte_cryptodev_sym_session_get_user_data(op->sym-
> >session);
> +	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
> +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> +		return op->asym->session->event_mdata;
> +	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> +			op->private_data_offset)
> +		return ((uint8_t *)op + op->private_data_offset);
> +	else
> +		return NULL;
> +}
> diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
> index 2b1ce2da2d..7969944b66 100644
> --- a/lib/cryptodev/cryptodev_pmd.h
> +++ b/lib/cryptodev/cryptodev_pmd.h
> @@ -398,6 +398,25 @@ typedef int
> (*cryptodev_sym_configure_raw_dp_ctx_t)(
>  	enum rte_crypto_op_sess_type sess_type,
>  	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
> 
> +/**
> + * Typedef that the driver provided to set event crypto meta data.
> + *
> + * @param	dev		Crypto device pointer.
> + * @param	sess		Crypto or security session.
> + * @param	op_type		Operation type.
> + * @param	sess_type	Session type.
> + * @param	ev_mdata	Pointer to the event crypto meta data
> + *				(aka *union rte_event_crypto_metadata*)
> + * @return
> + *   - On success return 0.
> + *   - On failure return negative integer.
> + */
> +typedef int (*cryptodev_session_event_mdata_set_t)(
> +	struct rte_cryptodev *dev, void *sess,
> +	enum rte_crypto_op_type op_type,
> +	enum rte_crypto_op_sess_type sess_type,
> +	void *ev_mdata);
> +
>  /** Crypto device operations function pointer table */  struct
> rte_cryptodev_ops {
>  	cryptodev_configure_t dev_configure;	/**< Configure device. */
> @@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
>  			/**< Initialize raw data path context data. */
>  		};
>  	};
> +	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
> +	/**< Set a Crypto or Security session even meta data. */
>  };
> 
> 
> @@ -603,6 +624,19 @@ void
>  cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
>  		     const struct rte_cryptodev *dev);
> 
> +/**
> + * Get session event meta data (aka *union rte_event_crypto_metadata*)
> + *
> + * @param	op            pointer to *rte_crypto_op* structure.
> + *
> + * @return
> + *  - On success, pointer to event crypto metadata
> + *  - On failure, a negative value.
> + */
> +__rte_internal
> +void *
> +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
> +
>  static inline void *
>  get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
>  		uint8_t driver_id) {
> @@ -636,6 +670,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
>  	/**< Size of private data used when creating mempool */
>  	uint16_t user_data_sz;
>  	/**< Session user data will be placed after sess_data */
> +	void *event_mdata;
> +	/**< Event crypto adapter metadata */
Add reference to rte_event_crypto_metadata for clarity?
>  	uint8_t padding[3];
>  	uint8_t sess_private_data[0];
>  };
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index
> 3500a2d470..a070cb2a00 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t dev_id,
> void *sess)
> 
>  	dev->dev_ops->asym_session_clear(dev, sess);
> 
> +	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata)
> +		rte_free(((struct rte_cryptodev_asym_session *)sess)-
> >event_mdata);
> +
Who allocates memory for event_mdata? If this done by application before calling
rte_cryptodev_session_event_mdata_set(), please document it.
>  	/* Return session to mempool */
>  	sess_mp = rte_mempool_from_obj(sess);
>  	rte_mempool_put(sess_mp, sess);
> @@ -2259,6 +2262,44 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t
> dev_id, uint16_t qp_id,
>  			sess_type, session_ctx, is_update);
>  }
> 
> +int
> +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
> +	enum rte_crypto_op_type op_type,
> +	enum rte_crypto_op_sess_type sess_type,
> +	void *ev_mdata,
> +	uint16_t size)
> +{
> +	struct rte_cryptodev *dev;
> +
> +	if (!rte_cryptodev_is_valid_dev(dev_id))
> +		goto skip_pmd_op;
> +
> +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> +	if (dev->dev_ops->session_ev_mdata_set == NULL)
> +		goto skip_pmd_op;
> +
> +	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
> +			sess_type, ev_mdata);
> +
> +skip_pmd_op:
> +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
> +		return rte_cryptodev_sym_session_set_user_data(sess,
> ev_mdata,
> +				size);
> +	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		struct rte_cryptodev_asym_session *s = sess;
Null check for sess?
> +
> +		if (s->event_mdata == NULL) {
> +			s->event_mdata = rte_malloc(NULL, size, 0);
> +			if (s->event_mdata == NULL)
> +				return -ENOMEM;
> +		}
> +		rte_memcpy(s->event_mdata, ev_mdata, size);
> +
> +		return 0;
> +	} else
> +		return -ENOTSUP;
> +}
> +
>  uint32_t
>  rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx,
>  	struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs, diff --
> git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index
> 45d33f4a50..2c2c2edeb7 100644
> --- a/lib/cryptodev/rte_cryptodev.h
> +++ b/lib/cryptodev/rte_cryptodev.h
> @@ -1269,6 +1269,28 @@ __rte_experimental  int
> rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
> 
> +/**
> + * Set session event meta data
> + *
> + * @param	dev_id		The device identifier.
> + * @param	sess            Crypto or security session.
> + * @param	op_type         Operation type.
> + * @param	sess_type       Session type.
> + * @param	ev_mdata	Pointer to the event crypto meta data
> + *				(aka *union rte_event_crypto_metadata*)
> + * @param	size            Size of ev_mdata.
> + *
> + * @return
> + *  - On success, zero.
> + *  - On failure, a negative value.
> + */
> +__rte_experimental
> +int
> +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
> +	enum rte_crypto_op_type op_type,
> +	enum rte_crypto_op_sess_type sess_type,
> +	void *ev_mdata, uint16_t size);
> +
>  /**
>   * Union of different crypto session types, including session-less xform
>   * pointer.
> diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index
> c7c5aefceb..f0abfaa47d 100644
> --- a/lib/cryptodev/version.map
> +++ b/lib/cryptodev/version.map
> @@ -105,6 +105,9 @@ EXPERIMENTAL {
>  	rte_cryptodev_asym_session_pool_create;
>  	rte_cryptodev_asym_session_set_user_data;
>  	__rte_cryptodev_trace_asym_session_pool_create;
> +
> +	#added in 22.07
> +	rte_cryptodev_session_event_mdata_set;
>  };
> 
>  INTERNAL {
> @@ -123,5 +126,6 @@ INTERNAL {
>  	rte_cryptodev_pmd_parse_input_args;
>  	rte_cryptodev_pmd_probing_finish;
>  	rte_cryptodev_pmd_release_device;
> +	rte_cryptodev_session_event_mdata_get;
>  	rte_cryptodevs;
>  };
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 4/7] test/event: use new API to set event crypto metadata
  2022-04-21 14:37     ` [PATCH v3 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
  2022-04-27 15:39       ` Zhang, Roy Fan
@ 2022-04-28 14:47       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-04-28 14:47 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 4/7] test/event: use new API to set event crypto metadata
> 
> Used the new API rte_cryptodev_set_session_event_mdata to set event crypto
> metadata from the applications (app/test and
> app/test-eventdev) instead of using session userdata.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  app/test-eventdev/test_perf_common.c |  8 ++++++--
> app/test/test_event_crypto_adapter.c | 12 ++++++++----
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> eventdev/test_perf_common.c
> index 9d1f4a4567..0378607cda 100644
> --- a/app/test-eventdev/test_perf_common.c
> +++ b/app/test-eventdev/test_perf_common.c
> @@ -835,8 +835,12 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
>  					return -ENOMEM;
> 
>  				m_data.response_info.flow_id = flow_id;
> -				rte_cryptodev_sym_session_set_user_data(
> -					crypto_sess, &m_data,
> sizeof(m_data));
> +
> 	rte_cryptodev_session_event_mdata_set(cdev_id,
> +						crypto_sess,
> +
> 	RTE_CRYPTO_OP_TYPE_SYMMETRIC,
> +
> 	RTE_CRYPTO_OP_WITH_SESSION,
> +						&m_data, sizeof(m_data));
> +
>  				p->ca.crypto_sess[flow_id] = crypto_sess;
>  			}
> 
> diff --git a/app/test/test_event_crypto_adapter.c
> b/app/test/test_event_crypto_adapter.c
> index 688520db4e..9904206735 100644
> --- a/app/test/test_event_crypto_adapter.c
> +++ b/app/test/test_event_crypto_adapter.c
> @@ -227,8 +227,10 @@ test_op_forward_mode(uint8_t session_less)
>  			m_data.request_info.queue_pair_id =
>  				request_info.queue_pair_id;
>  			m_data.response_info.event = response_info.event;
> -			rte_cryptodev_sym_session_set_user_data(sess,
> -						&m_data, sizeof(m_data));
> +
> 	rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
> +					sess,
> RTE_CRYPTO_OP_TYPE_SYMMETRIC,
> +					RTE_CRYPTO_OP_WITH_SESSION,
> +					&m_data, sizeof(m_data));
>  		}
> 
>  		rte_crypto_op_attach_sym_session(op, sess); @@ -416,8
> +418,10 @@ test_op_new_mode(uint8_t session_less)
>  		if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
>  			/* Fill in private user data information */
>  			m_data.response_info.event = response_info.event;
> -			rte_cryptodev_sym_session_set_user_data(sess,
> -						&m_data, sizeof(m_data));
> +
> 	rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
> +					sess,
> RTE_CRYPTO_OP_TYPE_SYMMETRIC,
> +					RTE_CRYPTO_OP_WITH_SESSION,
> +					&m_data, sizeof(m_data));
>  		}
>  		ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess,
>  				&cipher_xform, params.session_priv_mpool);
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 5/7] eventdev: use new API to get event crypto metadata
  2022-04-21 14:37     ` [PATCH v3 5/7] eventdev: use new API to get " Akhil Goyal
  2022-04-27 15:39       ` Zhang, Roy Fan
@ 2022-04-28 15:08       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-04-28 15:08 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 5/7] eventdev: use new API to get event crypto metadata
> 
> For getting event crypto metadata from crypto_op, the new API
> rte_cryptodev_get_session_event_mdata is used instead of getting userdata
> inside PMD.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  lib/eventdev/rte_event_crypto_adapter.c | 55 ++++++-------------------
>  1 file changed, 12 insertions(+), 43 deletions(-)
> 
> diff --git a/lib/eventdev/rte_event_crypto_adapter.c
> b/lib/eventdev/rte_event_crypto_adapter.c
> index f624f50187..7c695176f4 100644
> --- a/lib/eventdev/rte_event_crypto_adapter.c
> +++ b/lib/eventdev/rte_event_crypto_adapter.c
> @@ -457,43 +457,22 @@ eca_enq_to_cryptodev(struct event_crypto_adapter
> *adapter, struct rte_event *ev,
>  		crypto_op = ev[i].event_ptr;
>  		if (crypto_op == NULL)
>  			continue;
> -		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> -			m_data = rte_cryptodev_sym_session_get_user_data(
> -					crypto_op->sym->session);
> -			if (m_data == NULL) {
> -				rte_pktmbuf_free(crypto_op->sym->m_src);
> -				rte_crypto_op_free(crypto_op);
> -				continue;
> -			}
> +		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
> +		if (m_data == NULL) {
> +			rte_pktmbuf_free(crypto_op->sym->m_src);
> +			rte_crypto_op_free(crypto_op);
> +			continue;
> +		}
> 
> -			cdev_id = m_data->request_info.cdev_id;
> -			qp_id = m_data->request_info.queue_pair_id;
> -			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
> -			if (!qp_info->qp_enabled) {
> -				rte_pktmbuf_free(crypto_op->sym->m_src);
> -				rte_crypto_op_free(crypto_op);
> -				continue;
> -			}
> -			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
> -		} else if (crypto_op->sess_type ==
> RTE_CRYPTO_OP_SESSIONLESS &&
> -				crypto_op->private_data_offset) {
> -			m_data = (union rte_event_crypto_metadata *)
> -				 ((uint8_t *)crypto_op +
> -					crypto_op->private_data_offset);
> -			cdev_id = m_data->request_info.cdev_id;
> -			qp_id = m_data->request_info.queue_pair_id;
> -			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
> -			if (!qp_info->qp_enabled) {
> -				rte_pktmbuf_free(crypto_op->sym->m_src);
> -				rte_crypto_op_free(crypto_op);
> -				continue;
> -			}
> -			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
> -		} else {
> +		cdev_id = m_data->request_info.cdev_id;
> +		qp_id = m_data->request_info.queue_pair_id;
> +		qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
> +		if (!qp_info->qp_enabled) {
>  			rte_pktmbuf_free(crypto_op->sym->m_src);
>  			rte_crypto_op_free(crypto_op);
>  			continue;
>  		}
> +		eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
> 
>  		if (eca_circular_buffer_batch_ready(&qp_info->cbuf)) {
>  			ret = eca_circular_buffer_flush_to_cdev(&qp_info-
> >cbuf,
> @@ -636,17 +615,7 @@ eca_ops_enqueue_burst(struct event_crypto_adapter
> *adapter,
>  	for (i = 0; i < num; i++) {
>  		struct rte_event *ev = &events[nb_ev++];
> 
> -		m_data = NULL;
> -		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> -			m_data = rte_cryptodev_sym_session_get_user_data(
> -					ops[i]->sym->session);
> -		} else if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS
> &&
> -				ops[i]->private_data_offset) {
> -			m_data = (union rte_event_crypto_metadata *)
> -				 ((uint8_t *)ops[i] +
> -				  ops[i]->private_data_offset);
> -		}
> -
> +		m_data = rte_cryptodev_session_event_mdata_get(ops[i]);
>  		if (unlikely(m_data == NULL)) {
>  			rte_pktmbuf_free(ops[i]->sym->m_src);
>  			rte_crypto_op_free(ops[i]);
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
  2022-04-21 14:37     ` [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
  2022-04-27 15:39       ` Zhang, Roy Fan
@ 2022-04-28 15:14       ` Gujjar, Abhinandan S
  2022-04-29 12:23         ` Akhil Goyal
  1 sibling, 1 reply; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-04-28 15:14 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

This is failing with asym changes. Please look into this.

root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/test/dpdk-test
EAL: Detected CPU lcores: 96
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: VFIO support initialized
EAL: Probe PCI driver: net_ice (8086:1593) device: 0000:18:00.0 (socket 0)
ice_load_pkg_type(): Active package is: 1.3.26.0, ICE OS Default Package (single VLAN mode)
EAL: Probe PCI driver: net_ice (8086:1593) device: 0000:18:00.1 (socket 0)
ice_load_pkg_type(): Active package is: 1.3.26.0, ICE OS Default Package (single VLAN mode)
TELEMETRY: No legacy callbacks, legacy socket not created
APP: HPET is not enabled, using TSC as default timer
RTE>>event_crypto_adapter_autotest
 + ------------------------------------------------------- +
 + Test Suite : Event crypto adapter test suite
CRYPTODEV: Creating cryptodev crypto_null

CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue pairs: 8
CRYPTODEV: elt_size 0 is expanded to 208

CRYPTODEV: Could not set max private session size

EAL: Test assert configure_cryptodev line 1028 failed: asym session mempool allocation failed

EAL: Test assert testsuite_setup line 1361 failed: cryptodev initialization failed

 + ------------------------------------------------------- +
 + Test Suite Summary : Event crypto adapter test suite
 + ------------------------------------------------------- +
 + Tests Total :       11
 + Tests Skipped :      0
 + Tests Executed :     0
 + Tests Unsupported:   0
 + Tests Passed :       0
 + Tests Failed :      11
 + ------------------------------------------------------- +
Test Failed


> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
> 
> Test app is updated to add cases for asymmetric crypto sessions for event
> crypto adapter.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  app/test/test_event_crypto_adapter.c | 491 ++++++++++++++++++++++++++-
>  1 file changed, 485 insertions(+), 6 deletions(-)
> 
> diff --git a/app/test/test_event_crypto_adapter.c
> b/app/test/test_event_crypto_adapter.c
> index 9904206735..eecfc22057 100644
> --- a/app/test/test_event_crypto_adapter.c
> +++ b/app/test/test_event_crypto_adapter.c
> @@ -6,6 +6,7 @@
>  #include "test.h"
>  #include <string.h>
>  #include <rte_common.h>
> +#include <rte_malloc.h>
>  #include <rte_mempool.h>
>  #include <rte_mbuf.h>
>  #include <rte_cryptodev.h>
> @@ -67,12 +68,97 @@ static const uint8_t text_64B[] = {
>  	0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
>  	0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c  };
> +#define DATA_SIZE		512
> +struct modex_test_data {
> +	enum rte_crypto_asym_xform_type xform_type;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} base;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} exponent;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} modulus;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} reminder;
> +	uint16_t result_len;
> +};
> +
> +static struct
> +modex_test_data modex_test_case = {
> +	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
> +	.base = {
> +		.data = {
> +			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
> +			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
> +			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
> +		},
> +		.len = 20,
> +	},
> +	.exponent = {
> +		.data = {
> +			0x01, 0x00, 0x01
> +		},
> +		.len = 3,
> +	},
> +	.reminder = {
> +		.data = {
> +			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
> +			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
> +			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
> +			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
> +			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
> +			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
> +			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
> +			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
> +			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
> +			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
> +			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
> +			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
> +			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
> +			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
> +			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
> +			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
> +		},
> +		.len = 128,
> +	},
> +	.modulus = {
> +		.data = {
> +			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
> +			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
> +			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
> +			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
> +			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
> +			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
> +			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
> +			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
> +			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
> +			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
> +			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
> +			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
> +			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
> +			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
> +			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
> +			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
> +		},
> +		.len = 128,
> +	},
> +	.result_len = 128,
> +};
> 
>  struct event_crypto_adapter_test_params {
>  	struct rte_mempool *mbuf_pool;
>  	struct rte_mempool *op_mpool;
> +	struct rte_mempool *asym_op_mpool;
>  	struct rte_mempool *session_mpool;
>  	struct rte_mempool *session_priv_mpool;
> +	struct rte_mempool *asym_sess_mpool;
>  	struct rte_cryptodev_config *config;
>  	uint8_t crypto_event_port_id;
>  	uint8_t internal_port_op_fwd;
> @@ -134,11 +220,24 @@ send_recv_ev(struct rte_event *ev)
>  		rte_pause();
> 
>  	op = recv_ev.event_ptr;
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
>  #if PKT_TRACE
> -	struct rte_mbuf *m = op->sym->m_src;
> -	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
> +		struct rte_mbuf *m = op->sym->m_src;
> +		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
>  #endif
> -	rte_pktmbuf_free(op->sym->m_src);
> +		rte_pktmbuf_free(op->sym->m_src);
> +	} else {
> +		uint8_t *data_expected = NULL, *data_received = NULL;
> +		uint32_t data_size;
> +
> +		data_expected = modex_test_case.reminder.data;
> +		data_received = op->asym->modex.result.data;
> +		data_size = op->asym->modex.result.length;
> +		ret = memcmp(data_expected, data_received, data_size);
> +		TEST_ASSERT_EQUAL(ret, 0,
> +				"Data mismatch for asym crypto adapter\n");
> +		rte_free(op->asym->modex.result.data);
> +	}
>  	rte_crypto_op_free(op);
> 
>  	return TEST_SUCCESS;
> @@ -348,6 +447,170 @@ test_session_with_op_forward_mode(void)
>  	return TEST_SUCCESS;
>  }
> 
> +static int
> +test_asym_op_forward_mode(uint8_t session_less) {
> +	const struct rte_cryptodev_asymmetric_xform_capability *capability;
> +	struct rte_cryptodev_asym_capability_idx cap_idx;
> +	struct rte_crypto_asym_xform xform_tc;
> +	union rte_event_crypto_metadata m_data;
> +	struct rte_cryptodev_info dev_info;
> +	struct rte_crypto_asym_op *asym_op;
> +	struct rte_crypto_op *op;
> +	uint8_t input[4096] = {0};
> +	uint8_t *result = NULL;
> +	struct rte_event ev;
> +	void *sess = NULL;
> +	uint32_t cap;
> +	int ret;
> +
> +	memset(&m_data, 0, sizeof(m_data));
> +
> +	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
> +	if (session_less && !(dev_info.feature_flags &
> +				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support Asym sessionless ops. Test
> Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +	/* Setup Cipher Parameters */
> +	xform_tc.next = NULL;
> +	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
> +	cap_idx.type = xform_tc.xform_type;
> +	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID,
> +&cap_idx);
> +
> +	if (capability == NULL) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support MODEX. Test Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +
> +	op = rte_crypto_op_alloc(params.asym_op_mpool,
> +			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
> +	TEST_ASSERT_NOT_NULL(op,
> +		"Failed to allocate asymmetric crypto operation struct\n");
> +
> +	asym_op = op->asym;
> +
> +	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
> +	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
> +	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
> +	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
> +	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
> +	memcpy(input, modex_test_case.base.data,
> +		modex_test_case.base.len);
> +	asym_op->modex.base.data = input;
> +	asym_op->modex.base.length = modex_test_case.base.len;
> +	asym_op->modex.result.data = result;
> +	asym_op->modex.result.length = modex_test_case.result_len;
> +	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
> +			xform_tc.modex.modulus.length)) {
> +		RTE_LOG(INFO, USER1,
> +			"line %u FAILED: %s", __LINE__,
> +			"Invalid MODULUS length specified");
> +		return TEST_FAILED;
> +	}
> +
> +	if (!session_less) {
> +		/* Create Crypto session*/
> +		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
> +				&xform_tc, params.asym_sess_mpool, &sess);
> +		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
> +
> +		ret = rte_event_crypto_adapter_caps_get(evdev,
> TEST_CDEV_ID,
> +							&cap);
> +		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter
> capabilities\n");
> +
> +		if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
> +			/* Fill in private user data information */
> +			m_data.request_info.cdev_id = request_info.cdev_id;
> +			m_data.request_info.queue_pair_id =
> +				request_info.queue_pair_id;
> +			m_data.response_info.event = response_info.event;
> +
> 	rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
> +					sess,
> RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +					RTE_CRYPTO_OP_WITH_SESSION,
> +					&m_data, sizeof(m_data));
> +		}
> +
> +		rte_crypto_op_attach_asym_session(op, sess);
> +	} else {
> +		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
> +		asym_op->xform = &xform_tc;
> +		op->private_data_offset = (sizeof(struct rte_crypto_op) +
> +				sizeof(struct rte_crypto_asym_op) +
> +				DEFAULT_NUM_XFORMS *
> +				sizeof(struct rte_crypto_asym_xform));
> +		/* Fill in private data information */
> +		m_data.request_info.cdev_id = request_info.cdev_id;
> +		m_data.request_info.queue_pair_id =
> request_info.queue_pair_id;
> +		m_data.response_info.event = response_info.event;
> +		rte_memcpy((uint8_t *)op + op->private_data_offset,
> +				&m_data, sizeof(m_data));
> +	}
> +	/* Fill in event info and update event_ptr with rte_crypto_op */
> +	memset(&ev, 0, sizeof(ev));
> +	ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
> +	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> +	ev.flow_id = 0xAABB;
> +	ev.event_ptr = op;
> +
> +	ret = send_recv_ev(&ev);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
> +				"crypto adapter\n");
> +
> +	test_crypto_adapter_stats();
> +
> +	return TEST_SUCCESS;
> +}
> +
> +
> +static int
> +test_asym_sessionless_with_op_forward_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
> +			return TEST_SKIPPED;
> +	}
> +
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID),
> +				"Failed to start event crypto adapter");
> +
> +	return test_asym_op_forward_mode(1);
> +}
> +
> +static int
> +test_asym_session_with_op_forward_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
> +			return TEST_SKIPPED;
> +	}
> +
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID
> +				), "Failed to start event crypto adapter");
> +
> +	return test_asym_op_forward_mode(0);
> +}
> +
>  static int
>  send_op_recv_ev(struct rte_crypto_op *op)  { @@ -365,11 +628,24 @@
> send_op_recv_ev(struct rte_crypto_op *op)
>  		rte_pause();
> 
>  	recv_op = ev.event_ptr;
> +	if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
>  #if PKT_TRACE
> -	struct rte_mbuf *m = recv_op->sym->m_src;
> -	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
> +		struct rte_mbuf *m = recv_op->sym->m_src;
> +		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
>  #endif
> -	rte_pktmbuf_free(recv_op->sym->m_src);
> +		rte_pktmbuf_free(recv_op->sym->m_src);
> +	} else {
> +		uint8_t *data_expected = NULL, *data_received = NULL;
> +		uint32_t data_size;
> +
> +		data_expected = modex_test_case.reminder.data;
> +		data_received = op->asym->modex.result.data;
> +		data_size = op->asym->modex.result.length;
> +		ret = memcmp(data_expected, data_received, data_size);
> +		TEST_ASSERT_EQUAL(ret, 0,
> +				"Data mismatch for asym crypto adapter\n");
> +		rte_free(op->asym->modex.result.data);
> +	}
>  	rte_crypto_op_free(recv_op);
> 
>  	return TEST_SUCCESS;
> @@ -505,6 +781,156 @@ test_session_with_op_new_mode(void)
>  	return TEST_SUCCESS;
>  }
> 
> +static int
> +test_asym_op_new_mode(uint8_t session_less) {
> +	const struct rte_cryptodev_asymmetric_xform_capability *capability;
> +	struct rte_cryptodev_asym_capability_idx cap_idx;
> +	struct rte_crypto_asym_xform xform_tc;
> +	union rte_event_crypto_metadata m_data;
> +	struct rte_cryptodev_info dev_info;
> +	struct rte_crypto_asym_op *asym_op;
> +	struct rte_crypto_op *op;
> +	uint8_t input[4096] = {0};
> +	uint8_t *result = NULL;
> +	void *sess = NULL;
> +	uint32_t cap;
> +	int ret;
> +
> +	memset(&m_data, 0, sizeof(m_data));
> +
> +	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
> +	if (session_less && !(dev_info.feature_flags &
> +				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support Asym sessionless ops. Test
> Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +	/* Setup Cipher Parameters */
> +	xform_tc.next = NULL;
> +	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
> +	cap_idx.type = xform_tc.xform_type;
> +	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID,
> +&cap_idx);
> +
> +	if (capability == NULL) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support MODEX. Test Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +
> +	op = rte_crypto_op_alloc(params.asym_op_mpool,
> +			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
> +	TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n");
> +
> +	asym_op = op->asym;
> +
> +	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
> +	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
> +	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
> +	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
> +	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
> +	memcpy(input, modex_test_case.base.data,
> +		modex_test_case.base.len);
> +	asym_op->modex.base.data = input;
> +	asym_op->modex.base.length = modex_test_case.base.len;
> +	asym_op->modex.result.data = result;
> +	asym_op->modex.result.length = modex_test_case.result_len;
> +	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
> +			xform_tc.modex.modulus.length)) {
> +		RTE_LOG(INFO, USER1,
> +			"line %u FAILED: %s", __LINE__,
> +			"Invalid MODULUS length specified");
> +		return TEST_FAILED;
> +	}
> +
> +	if (!session_less) {
> +		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
> +				&xform_tc, params.asym_sess_mpool, &sess);
> +		TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
> +		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
> +
> +		ret = rte_event_crypto_adapter_caps_get(evdev,
> TEST_CDEV_ID,
> +							&cap);
> +		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter
> capabilities\n");
> +
> +		if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
> +			/* Fill in private user data information */
> +			m_data.response_info.event = response_info.event;
> +
> 	rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
> +					sess,
> RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +					RTE_CRYPTO_OP_WITH_SESSION,
> +					&m_data, sizeof(m_data));
> +		}
> +
> +		rte_crypto_op_attach_asym_session(op, sess);
> +	} else {
> +		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
> +		asym_op->xform = &xform_tc;
> +		op->private_data_offset = (sizeof(struct rte_crypto_op) +
> +				sizeof(struct rte_crypto_asym_op) +
> +				DEFAULT_NUM_XFORMS *
> +				sizeof(struct rte_crypto_asym_xform));
> +		/* Fill in private data information */
> +		m_data.response_info.event = response_info.event;
> +		rte_memcpy((uint8_t *)op + op->private_data_offset,
> +				&m_data, sizeof(m_data));
> +	}
> +
> +	ret = send_op_recv_ev(op);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
> +
> +	test_crypto_adapter_stats();
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
> +test_asym_sessionless_with_op_new_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +			return TEST_SKIPPED;
> +	}
> +
> +	/* start the event crypto adapter */
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID),
> +				"Failed to start event crypto adapter");
> +
> +	return test_asym_op_new_mode(1);
> +}
> +
> +static int
> +test_asym_session_with_op_new_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +			return TEST_SKIPPED;
> +	}
> +
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID),
> +				"Failed to start event crypto adapter");
> +
> +	return test_asym_op_new_mode(0);
> +}
> +
>  static int
>  configure_cryptodev(void)
>  {
> @@ -537,6 +963,19 @@ configure_cryptodev(void)
>  		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
>  		return TEST_FAILED;
>  	}
> +	params.asym_op_mpool = rte_crypto_op_pool_create(
> +			"EVENT_CRYPTO_ASYM_OP_POOL",
> +			RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +			NUM_MBUFS, MBUF_CACHE_SIZE,
> +			(DEFAULT_NUM_XFORMS *
> +			sizeof(struct rte_crypto_asym_xform)) +
> +			sizeof(union rte_event_crypto_metadata),
> +			rte_socket_id());
> +	if (params.asym_op_mpool == NULL) {
> +		RTE_LOG(ERR, USER1, "Can't create
> CRYPTO_ASYM_OP_POOL\n");
> +		return TEST_FAILED;
> +	}
> +
> 
>  	/* Create a NULL crypto device */
>  	nb_devs = rte_cryptodev_device_count_by_driver(
> @@ -581,6 +1020,15 @@ configure_cryptodev(void)
>  	TEST_ASSERT_NOT_NULL(params.session_priv_mpool,
>  			"session mempool allocation failed\n");
> 
> +	params.asym_sess_mpool = rte_cryptodev_asym_session_pool_create(
> +			"CRYPTO_AD_ASYM_SESS_MP",
> +			MAX_NB_SESSIONS, 0,
> +			sizeof(union rte_event_crypto_metadata),
> +			SOCKET_ID_ANY);
> +	TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
> +			"asym session mempool allocation failed\n");
> +
> +
>  	rte_cryptodev_info_get(TEST_CDEV_ID, &info);
>  	conf.nb_queue_pairs = info.max_nb_queue_pairs;
>  	conf.socket_id = SOCKET_ID_ANY;
> @@ -960,6 +1408,21 @@ crypto_teardown(void)
>  		params.session_priv_mpool = NULL;
>  	}
> 
> +	/* Free asym session mempool */
> +	if (params.asym_sess_mpool != NULL) {
> +		RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count
> %u\n",
> +		rte_mempool_avail_count(params.asym_sess_mpool));
> +		rte_mempool_free(params.asym_sess_mpool);
> +		params.asym_sess_mpool = NULL;
> +	}
> +	/* Free asym ops mempool */
> +	if (params.asym_op_mpool != NULL) {
> +		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL
> count %u\n",
> +		rte_mempool_avail_count(params.asym_op_mpool));
> +		rte_mempool_free(params.asym_op_mpool);
> +		params.asym_op_mpool = NULL;
> +	}
> +
>  	/* Free ops mempool */
>  	if (params.op_mpool != NULL) {
>  		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL
> count %u\n", @@ -1016,6 +1479,22 @@ static struct unit_test_suite
> functional_testsuite = {
>  				test_crypto_adapter_stop,
>  				test_sessionless_with_op_new_mode),
> 
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
> +				test_crypto_adapter_stop,
> +				test_asym_session_with_op_forward_mode),
> +
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
> +				test_crypto_adapter_stop,
> +
> 	test_asym_sessionless_with_op_forward_mode),
> +
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
> +				test_crypto_adapter_stop,
> +				test_asym_session_with_op_new_mode),
> +
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
> +				test_crypto_adapter_stop,
> +				test_asym_sessionless_with_op_new_mode),
> +
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
  2022-04-28 14:42       ` Gujjar, Abhinandan S
@ 2022-04-29 12:16         ` Akhil Goyal
  2022-05-01 12:24           ` Gujjar, Abhinandan S
  0 siblings, 1 reply; 69+ messages in thread
From: Akhil Goyal @ 2022-04-29 12:16 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, Jayatheerthan, Jay,
	Vangati, Narender, Volodymyr Fialko

Hi Abhinandan,

Please see inline.
> > +
> > +void *
> > +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op) {
> Null check for op?

Null check can be added, but this a datapath dpdk internal API.
We do not normally add checks in datapath.
If you insist, I can add, but before calling this API, PMD/lib would have already
checked for null op.

> > +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
> > +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> > +		return rte_cryptodev_sym_session_get_user_data(op->sym-
> > >session);
> > +	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
> > +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> > +		return op->asym->session->event_mdata;
> > +	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> > +			op->private_data_offset)
> > +		return ((uint8_t *)op + op->private_data_offset);
> > +	else
> > +		return NULL;
> > +}
> > diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
> > index 2b1ce2da2d..7969944b66 100644
> > --- a/lib/cryptodev/cryptodev_pmd.h
> > +++ b/lib/cryptodev/cryptodev_pmd.h
> > @@ -398,6 +398,25 @@ typedef int
> > (*cryptodev_sym_configure_raw_dp_ctx_t)(
> >  	enum rte_crypto_op_sess_type sess_type,
> >  	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
> >
> > +/**
> > + * Typedef that the driver provided to set event crypto meta data.
> > + *
> > + * @param	dev		Crypto device pointer.
> > + * @param	sess		Crypto or security session.
> > + * @param	op_type		Operation type.
> > + * @param	sess_type	Session type.
> > + * @param	ev_mdata	Pointer to the event crypto meta data
> > + *				(aka *union rte_event_crypto_metadata*)
> > + * @return
> > + *   - On success return 0.
> > + *   - On failure return negative integer.
> > + */
> > +typedef int (*cryptodev_session_event_mdata_set_t)(
> > +	struct rte_cryptodev *dev, void *sess,
> > +	enum rte_crypto_op_type op_type,
> > +	enum rte_crypto_op_sess_type sess_type,
> > +	void *ev_mdata);
> > +
> >  /** Crypto device operations function pointer table */  struct
> > rte_cryptodev_ops {
> >  	cryptodev_configure_t dev_configure;	/**< Configure device. */
> > @@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
> >  			/**< Initialize raw data path context data. */
> >  		};
> >  	};
> > +	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
> > +	/**< Set a Crypto or Security session even meta data. */
> >  };
> >
> >
> > @@ -603,6 +624,19 @@ void
> >  cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
> >  		     const struct rte_cryptodev *dev);
> >
> > +/**
> > + * Get session event meta data (aka *union rte_event_crypto_metadata*)
> > + *
> > + * @param	op            pointer to *rte_crypto_op* structure.
> > + *
> > + * @return
> > + *  - On success, pointer to event crypto metadata
> > + *  - On failure, a negative value.
> > + */
> > +__rte_internal
> > +void *
> > +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
> > +
> >  static inline void *
> >  get_sym_session_private_data(const struct rte_cryptodev_sym_session
> *sess,
> >  		uint8_t driver_id) {
> > @@ -636,6 +670,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
> >  	/**< Size of private data used when creating mempool */
> >  	uint16_t user_data_sz;
> >  	/**< Session user data will be placed after sess_data */
> > +	void *event_mdata;
> > +	/**< Event crypto adapter metadata */
> Add reference to rte_event_crypto_metadata for clarity?

Ok will add the comment.

> >  	uint8_t padding[3];
> >  	uint8_t sess_private_data[0];
> >  };
> > diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
> index
> > 3500a2d470..a070cb2a00 100644
> > --- a/lib/cryptodev/rte_cryptodev.c
> > +++ b/lib/cryptodev/rte_cryptodev.c
> > @@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t dev_id,
> > void *sess)
> >
> >  	dev->dev_ops->asym_session_clear(dev, sess);
> >
> > +	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata)
> > +		rte_free(((struct rte_cryptodev_asym_session *)sess)-
> > >event_mdata);
> > +
> Who allocates memory for event_mdata? If this done by application before
> calling
> rte_cryptodev_session_event_mdata_set(), please document it.

It is same as was done before this patch.
The rte_cryptodev_session_event_mdata_set is allocating and making the copy
as it was copied in userdata before. Hence, no update is required.

> >  	/* Return session to mempool */
> >  	sess_mp = rte_mempool_from_obj(sess);
> >  	rte_mempool_put(sess_mp, sess);
> > @@ -2259,6 +2262,44 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t
> > dev_id, uint16_t qp_id,
> >  			sess_type, session_ctx, is_update);
> >  }
> >
> > +int
> > +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
> > +	enum rte_crypto_op_type op_type,
> > +	enum rte_crypto_op_sess_type sess_type,
> > +	void *ev_mdata,
> > +	uint16_t size)
> > +{
> > +	struct rte_cryptodev *dev;
> > +
> > +	if (!rte_cryptodev_is_valid_dev(dev_id))
> > +		goto skip_pmd_op;
> > +
> > +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> > +	if (dev->dev_ops->session_ev_mdata_set == NULL)
> > +		goto skip_pmd_op;
> > +
> > +	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
> > +			sess_type, ev_mdata);
> > +
> > +skip_pmd_op:
> > +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
> > +		return rte_cryptodev_sym_session_set_user_data(sess,
> > ev_mdata,
> > +				size);
> > +	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> > +		struct rte_cryptodev_asym_session *s = sess;
> Null check for sess?

Again, it is a datapath, avoided extra checks.

> > +
> > +		if (s->event_mdata == NULL) {
> > +			s->event_mdata = rte_malloc(NULL, size, 0);
> > +			if (s->event_mdata == NULL)
> > +				return -ENOMEM;
> > +		}
> > +		rte_memcpy(s->event_mdata, ev_mdata, size);
> > +
> > +		return 0;
> > +	} else
> > +		return -ENOTSUP;
> > +}


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
  2022-04-28 15:14       ` Gujjar, Abhinandan S
@ 2022-04-29 12:23         ` Akhil Goyal
  2022-05-01 12:45           ` Gujjar, Abhinandan S
  0 siblings, 1 reply; 69+ messages in thread
From: Akhil Goyal @ 2022-04-29 12:23 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, Jayatheerthan, Jay,
	Vangati, Narender, Volodymyr Fialko

Hi Abhinandan,

> This is failing with asym changes. Please look into this.

Thanks for pointing this out. It is failing as null crypto does not support asym
And asym_session_create would need an op from driver which is NULL for null crypto

Please check if below change is working for you.

diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index eecfc22057..2ecc7e2cea 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -934,13 +934,16 @@ test_asym_session_with_op_new_mode(void)
 static int
 configure_cryptodev(void)
 {
+       const struct rte_cryptodev_capabilities *capability;
        struct rte_cryptodev_qp_conf qp_conf;
        struct rte_cryptodev_config conf;
        struct rte_cryptodev_info info;
        unsigned int session_size;
+       unsigned int i = 0;
        uint8_t nb_devs;
        int ret;

+
        params.mbuf_pool = rte_pktmbuf_pool_create(
                        "CRYPTO_ADAPTER_MBUFPOOL",
                        NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
@@ -963,19 +966,6 @@ configure_cryptodev(void)
                RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
                return TEST_FAILED;
        }
-       params.asym_op_mpool = rte_crypto_op_pool_create(
-                       "EVENT_CRYPTO_ASYM_OP_POOL",
-                       RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
-                       NUM_MBUFS, MBUF_CACHE_SIZE,
-                       (DEFAULT_NUM_XFORMS *
-                       sizeof(struct rte_crypto_asym_xform)) +
-                       sizeof(union rte_event_crypto_metadata),
-                       rte_socket_id());
-       if (params.asym_op_mpool == NULL) {
-               RTE_LOG(ERR, USER1, "Can't create CRYPTO_ASYM_OP_POOL\n");
-               return TEST_FAILED;
-       }
-

        /* Create a NULL crypto device */
        nb_devs = rte_cryptodev_device_count_by_driver(
@@ -1020,16 +1010,34 @@ configure_cryptodev(void)
        TEST_ASSERT_NOT_NULL(params.session_priv_mpool,
                        "session mempool allocation failed\n");

-       params.asym_sess_mpool = rte_cryptodev_asym_session_pool_create(
-                       "CRYPTO_AD_ASYM_SESS_MP",
-                       MAX_NB_SESSIONS, 0,
-                       sizeof(union rte_event_crypto_metadata),
-                       SOCKET_ID_ANY);
-       TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
-                       "asym session mempool allocation failed\n");
-
-
        rte_cryptodev_info_get(TEST_CDEV_ID, &info);
+
+       while ((capability = &info.capabilities[i++])->op !=
+                       RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+               if (capability->op == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+                       params.asym_op_mpool = rte_crypto_op_pool_create(
+                               "EVENT_CRYPTO_ASYM_OP_POOL",
+                               RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+                               NUM_MBUFS, MBUF_CACHE_SIZE,
+                               (DEFAULT_NUM_XFORMS *
+                               sizeof(struct rte_crypto_asym_xform)) +
+                               sizeof(union rte_event_crypto_metadata),
+                               rte_socket_id());
+                       TEST_ASSERT_NOT_NULL(params.asym_op_mpool,
+                                       "Can't create CRYPTO_ASYM_OP_POOL\n");
+
+                       params.asym_sess_mpool =
+                               rte_cryptodev_asym_session_pool_create(
+                                       "CRYPTO_AD_ASYM_SESS_MP",
+                                       MAX_NB_SESSIONS, 0,
+                                       sizeof(union rte_event_crypto_metadata),
+                                       SOCKET_ID_ANY);
+                       TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
+                               "asym session mempool allocation failed\n");
+                       break;
+               }
+       }
+
        conf.nb_queue_pairs = info.max_nb_queue_pairs;
        conf.socket_id = SOCKET_ID_ANY;
        conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;


> 
> root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/test/dpdk-
> test
> EAL: Detected CPU lcores: 96
> EAL: Detected NUMA nodes: 2
> EAL: Detected static linkage of DPDK
> EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> EAL: Selected IOVA mode 'PA'
> EAL: VFIO support initialized
> EAL: Probe PCI driver: net_ice (8086:1593) device: 0000:18:00.0 (socket 0)
> ice_load_pkg_type(): Active package is: 1.3.26.0, ICE OS Default Package (single
> VLAN mode)
> EAL: Probe PCI driver: net_ice (8086:1593) device: 0000:18:00.1 (socket 0)
> ice_load_pkg_type(): Active package is: 1.3.26.0, ICE OS Default Package (single
> VLAN mode)
> TELEMETRY: No legacy callbacks, legacy socket not created
> APP: HPET is not enabled, using TSC as default timer
> RTE>>event_crypto_adapter_autotest
>  + ------------------------------------------------------- +
>  + Test Suite : Event crypto adapter test suite
> CRYPTODEV: Creating cryptodev crypto_null
> 
> CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max
> queue pairs: 8
> CRYPTODEV: elt_size 0 is expanded to 208
> 
> CRYPTODEV: Could not set max private session size
> 
> EAL: Test assert configure_cryptodev line 1028 failed: asym session mempool
> allocation failed
> 
> EAL: Test assert testsuite_setup line 1361 failed: cryptodev initialization failed
> 
>  + ------------------------------------------------------- +
>  + Test Suite Summary : Event crypto adapter test suite
>  + ------------------------------------------------------- +
>  + Tests Total :       11
>  + Tests Skipped :      0
>  + Tests Executed :     0
>  + Tests Unsupported:   0
>  + Tests Passed :       0
>  + Tests Failed :      11
>  + ------------------------------------------------------- +
> Test Failed


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
  2022-04-29 12:16         ` Akhil Goyal
@ 2022-05-01 12:24           ` Gujjar, Abhinandan S
  2022-05-01 18:37             ` Akhil Goyal
  0 siblings, 1 reply; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-01 12:24 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, Jayatheerthan, Jay,
	Vangati, Narender, Volodymyr Fialko


> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Friday, April 29, 2022 5:47 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org
> Cc: Anoob Joseph <anoobj@marvell.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>;
> Vangati, Narender <narender.vangati@intel.com>; Volodymyr Fialko
> <vfialko@marvell.com>
> Subject: RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
> 
> Hi Abhinandan,
> 
> Please see inline.
> > > +
> > > +void *
> > > +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op) {
> > Null check for op?
> 
> Null check can be added, but this a datapath dpdk internal API.
> We do not normally add checks in datapath.
> If you insist, I can add, but before calling this API, PMD/lib would have already
> checked for null op.
It is ok for get API. It is better to add the check for set API as it exposed to user application.
Currently, the set API is validating dev_id. It is better to add a null check only for set API.
> 
> > > +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
> > > +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> > > +		return rte_cryptodev_sym_session_get_user_data(op->sym-
> > > >session);
> > > +	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
> > > +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> > > +		return op->asym->session->event_mdata;
> > > +	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> > > +			op->private_data_offset)
> > > +		return ((uint8_t *)op + op->private_data_offset);
> > > +	else
> > > +		return NULL;
> > > +}
> > > diff --git a/lib/cryptodev/cryptodev_pmd.h
> > > b/lib/cryptodev/cryptodev_pmd.h index 2b1ce2da2d..7969944b66 100644
> > > --- a/lib/cryptodev/cryptodev_pmd.h
> > > +++ b/lib/cryptodev/cryptodev_pmd.h
> > > @@ -398,6 +398,25 @@ typedef int
> > > (*cryptodev_sym_configure_raw_dp_ctx_t)(
> > >  	enum rte_crypto_op_sess_type sess_type,
> > >  	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
> > >
> > > +/**
> > > + * Typedef that the driver provided to set event crypto meta data.
> > > + *
> > > + * @param	dev		Crypto device pointer.
> > > + * @param	sess		Crypto or security session.
> > > + * @param	op_type		Operation type.
> > > + * @param	sess_type	Session type.
> > > + * @param	ev_mdata	Pointer to the event crypto meta data
> > > + *				(aka *union rte_event_crypto_metadata*)
> > > + * @return
> > > + *   - On success return 0.
> > > + *   - On failure return negative integer.
> > > + */
> > > +typedef int (*cryptodev_session_event_mdata_set_t)(
> > > +	struct rte_cryptodev *dev, void *sess,
> > > +	enum rte_crypto_op_type op_type,
> > > +	enum rte_crypto_op_sess_type sess_type,
> > > +	void *ev_mdata);
> > > +
> > >  /** Crypto device operations function pointer table */  struct
> > > rte_cryptodev_ops {
> > >  	cryptodev_configure_t dev_configure;	/**< Configure device. */
> > > @@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
> > >  			/**< Initialize raw data path context data. */
> > >  		};
> > >  	};
> > > +	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
> > > +	/**< Set a Crypto or Security session even meta data. */
> > >  };
> > >
> > >
> > > @@ -603,6 +624,19 @@ void
> > >  cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
> > >  		     const struct rte_cryptodev *dev);
> > >
> > > +/**
> > > + * Get session event meta data (aka *union
> > > +rte_event_crypto_metadata*)
> > > + *
> > > + * @param	op            pointer to *rte_crypto_op* structure.
> > > + *
> > > + * @return
> > > + *  - On success, pointer to event crypto metadata
> > > + *  - On failure, a negative value.
> > > + */
> > > +__rte_internal
> > > +void *
> > > +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
> > > +
> > >  static inline void *
> > >  get_sym_session_private_data(const struct rte_cryptodev_sym_session
> > *sess,
> > >  		uint8_t driver_id) {
> > > @@ -636,6 +670,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
> > >  	/**< Size of private data used when creating mempool */
> > >  	uint16_t user_data_sz;
> > >  	/**< Session user data will be placed after sess_data */
> > > +	void *event_mdata;
> > > +	/**< Event crypto adapter metadata */
> > Add reference to rte_event_crypto_metadata for clarity?
> 
> Ok will add the comment.
> 
> > >  	uint8_t padding[3];
> > >  	uint8_t sess_private_data[0];
> > >  };
> > > diff --git a/lib/cryptodev/rte_cryptodev.c
> > > b/lib/cryptodev/rte_cryptodev.c
> > index
> > > 3500a2d470..a070cb2a00 100644
> > > --- a/lib/cryptodev/rte_cryptodev.c
> > > +++ b/lib/cryptodev/rte_cryptodev.c
> > > @@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t
> > > dev_id, void *sess)
> > >
> > >  	dev->dev_ops->asym_session_clear(dev, sess);
> > >
> > > +	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata)
> > > +		rte_free(((struct rte_cryptodev_asym_session *)sess)-
> > > >event_mdata);
> > > +
> > Who allocates memory for event_mdata? If this done by application
> > before calling rte_cryptodev_session_event_mdata_set(), please
> > document it.
> 
> It is same as was done before this patch.
> The rte_cryptodev_session_event_mdata_set is allocating and making the copy
> as it was copied in userdata before. Hence, no update is required.
ok
> 
> > >  	/* Return session to mempool */
> > >  	sess_mp = rte_mempool_from_obj(sess);
> > >  	rte_mempool_put(sess_mp, sess);
> > > @@ -2259,6 +2262,44 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t
> > > dev_id, uint16_t qp_id,
> > >  			sess_type, session_ctx, is_update);  }
> > >
> > > +int
> > > +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
> > > +	enum rte_crypto_op_type op_type,
> > > +	enum rte_crypto_op_sess_type sess_type,
> > > +	void *ev_mdata,
> > > +	uint16_t size)
> > > +{
> > > +	struct rte_cryptodev *dev;
> > > +
> > > +	if (!rte_cryptodev_is_valid_dev(dev_id))
> > > +		goto skip_pmd_op;
> > > +
> > > +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> > > +	if (dev->dev_ops->session_ev_mdata_set == NULL)
> > > +		goto skip_pmd_op;
> > > +
> > > +	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
> > > +			sess_type, ev_mdata);
> > > +
> > > +skip_pmd_op:
> > > +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
> > > +		return rte_cryptodev_sym_session_set_user_data(sess,
> > > ev_mdata,
> > > +				size);
> > > +	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> > > +		struct rte_cryptodev_asym_session *s = sess;
> > Null check for sess?
> 
> Again, it is a datapath, avoided extra checks.
> 
> > > +
> > > +		if (s->event_mdata == NULL) {
> > > +			s->event_mdata = rte_malloc(NULL, size, 0);
> > > +			if (s->event_mdata == NULL)
> > > +				return -ENOMEM;
> > > +		}
> > > +		rte_memcpy(s->event_mdata, ev_mdata, size);
> > > +
> > > +		return 0;
> > > +	} else
> > > +		return -ENOTSUP;
> > > +}


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
  2022-04-29 12:23         ` Akhil Goyal
@ 2022-05-01 12:45           ` Gujjar, Abhinandan S
  2022-05-01 18:36             ` Akhil Goyal
  0 siblings, 1 reply; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-01 12:45 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, Jayatheerthan, Jay,
	Vangati, Narender, Volodymyr Fialko



> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Friday, April 29, 2022 5:53 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org
> Cc: Anoob Joseph <anoobj@marvell.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>;
> Vangati, Narender <narender.vangati@intel.com>; Volodymyr Fialko
> <vfialko@marvell.com>
> Subject: RE: [PATCH v3 6/7] test/event: add asymmetric cases for crypto
> adapter
> 
> Hi Abhinandan,
> 
> > This is failing with asym changes. Please look into this.
> 
> Thanks for pointing this out. It is failing as null crypto does not support asym
> And asym_session_create would need an op from driver which is NULL for null
> crypto
> 
> Please check if below change is working for you.
I could not apply this patch cleanly. I see that you are skipping the asym test for NULL PMD.
Can I use openssl or any open source PMD to test this feature? If yes, please provide the command line.
> 
> diff --git a/app/test/test_event_crypto_adapter.c
> b/app/test/test_event_crypto_adapter.c
> index eecfc22057..2ecc7e2cea 100644
> --- a/app/test/test_event_crypto_adapter.c
> +++ b/app/test/test_event_crypto_adapter.c
> @@ -934,13 +934,16 @@ test_asym_session_with_op_new_mode(void)
>  static int
>  configure_cryptodev(void)
>  {
> +       const struct rte_cryptodev_capabilities *capability;
>         struct rte_cryptodev_qp_conf qp_conf;
>         struct rte_cryptodev_config conf;
>         struct rte_cryptodev_info info;
>         unsigned int session_size;
> +       unsigned int i = 0;
>         uint8_t nb_devs;
>         int ret;
> 
> +
>         params.mbuf_pool = rte_pktmbuf_pool_create(
>                         "CRYPTO_ADAPTER_MBUFPOOL",
>                         NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE, @@ -963,19
> +966,6 @@ configure_cryptodev(void)
>                 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
>                 return TEST_FAILED;
>         }
> -       params.asym_op_mpool = rte_crypto_op_pool_create(
> -                       "EVENT_CRYPTO_ASYM_OP_POOL",
> -                       RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> -                       NUM_MBUFS, MBUF_CACHE_SIZE,
> -                       (DEFAULT_NUM_XFORMS *
> -                       sizeof(struct rte_crypto_asym_xform)) +
> -                       sizeof(union rte_event_crypto_metadata),
> -                       rte_socket_id());
> -       if (params.asym_op_mpool == NULL) {
> -               RTE_LOG(ERR, USER1, "Can't create CRYPTO_ASYM_OP_POOL\n");
> -               return TEST_FAILED;
> -       }
> -
> 
>         /* Create a NULL crypto device */
>         nb_devs = rte_cryptodev_device_count_by_driver(
> @@ -1020,16 +1010,34 @@ configure_cryptodev(void)
>         TEST_ASSERT_NOT_NULL(params.session_priv_mpool,
>                         "session mempool allocation failed\n");
> 
> -       params.asym_sess_mpool = rte_cryptodev_asym_session_pool_create(
> -                       "CRYPTO_AD_ASYM_SESS_MP",
> -                       MAX_NB_SESSIONS, 0,
> -                       sizeof(union rte_event_crypto_metadata),
> -                       SOCKET_ID_ANY);
> -       TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
> -                       "asym session mempool allocation failed\n");
> -
> -
>         rte_cryptodev_info_get(TEST_CDEV_ID, &info);
> +
> +       while ((capability = &info.capabilities[i++])->op !=
> +                       RTE_CRYPTO_OP_TYPE_UNDEFINED) {
> +               if (capability->op == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +                       params.asym_op_mpool = rte_crypto_op_pool_create(
> +                               "EVENT_CRYPTO_ASYM_OP_POOL",
> +                               RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +                               NUM_MBUFS, MBUF_CACHE_SIZE,
> +                               (DEFAULT_NUM_XFORMS *
> +                               sizeof(struct rte_crypto_asym_xform)) +
> +                               sizeof(union rte_event_crypto_metadata),
> +                               rte_socket_id());
> +                       TEST_ASSERT_NOT_NULL(params.asym_op_mpool,
> +                                       "Can't create
> + CRYPTO_ASYM_OP_POOL\n");
> +
> +                       params.asym_sess_mpool =
> +                               rte_cryptodev_asym_session_pool_create(
> +                                       "CRYPTO_AD_ASYM_SESS_MP",
> +                                       MAX_NB_SESSIONS, 0,
> +                                       sizeof(union rte_event_crypto_metadata),
> +                                       SOCKET_ID_ANY);
> +                       TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
> +                               "asym session mempool allocation failed\n");
> +                       break;
> +               }
> +       }
> +
>         conf.nb_queue_pairs = info.max_nb_queue_pairs;
>         conf.socket_id = SOCKET_ID_ANY;
>         conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> 
> 
> >
> > root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi#
> > ./app/test/dpdk- test
> > EAL: Detected CPU lcores: 96
> > EAL: Detected NUMA nodes: 2
> > EAL: Detected static linkage of DPDK
> > EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> > EAL: Selected IOVA mode 'PA'
> > EAL: VFIO support initialized
> > EAL: Probe PCI driver: net_ice (8086:1593) device: 0000:18:00.0
> > (socket 0)
> > ice_load_pkg_type(): Active package is: 1.3.26.0, ICE OS Default
> > Package (single VLAN mode)
> > EAL: Probe PCI driver: net_ice (8086:1593) device: 0000:18:00.1
> > (socket 0)
> > ice_load_pkg_type(): Active package is: 1.3.26.0, ICE OS Default
> > Package (single VLAN mode)
> > TELEMETRY: No legacy callbacks, legacy socket not created
> > APP: HPET is not enabled, using TSC as default timer
> > RTE>>event_crypto_adapter_autotest
> >  + ------------------------------------------------------- +  + Test
> > Suite : Event crypto adapter test suite
> > CRYPTODEV: Creating cryptodev crypto_null
> >
> > CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0,
> > max queue pairs: 8
> > CRYPTODEV: elt_size 0 is expanded to 208
> >
> > CRYPTODEV: Could not set max private session size
> >
> > EAL: Test assert configure_cryptodev line 1028 failed: asym session
> > mempool allocation failed
> >
> > EAL: Test assert testsuite_setup line 1361 failed: cryptodev
> > initialization failed
> >
> >  + ------------------------------------------------------- +  + Test
> > Suite Summary : Event crypto adapter test suite  +
> > ------------------------------------------------------- +
> >  + Tests Total :       11
> >  + Tests Skipped :      0
> >  + Tests Executed :     0
> >  + Tests Unsupported:   0
> >  + Tests Passed :       0
> >  + Tests Failed :      11
> >  + ------------------------------------------------------- + Test
> > Failed


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 7/7] test-eventdev: support asym ops for crypto adapter
  2022-04-21 14:37     ` [PATCH v3 7/7] test-eventdev: support asym ops " Akhil Goyal
  2022-04-27 15:40       ` Zhang, Roy Fan
@ 2022-05-01 13:00       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-01 13:00 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 7/7] test-eventdev: support asym ops for crypto adapter
> 
> Test eventdev app is updated to add new option for asymmetric crypto ops for
> event crypto adapter.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  app/test-eventdev/evt_common.h       |   2 +
>  app/test-eventdev/evt_options.c      |  17 ++
>  app/test-eventdev/evt_options.h      |   4 +
>  app/test-eventdev/test_perf_atq.c    |  12 +-
>  app/test-eventdev/test_perf_common.c | 250 +++++++++++++++++++++++----
> app/test-eventdev/test_perf_common.h |  45 +++--  app/test-
> eventdev/test_perf_queue.c  |  12 +-
>  doc/guides/tools/testeventdev.rst    |   5 +
>  8 files changed, 284 insertions(+), 63 deletions(-)
> 
> diff --git a/app/test-eventdev/evt_common.h b/app/test-
> eventdev/evt_common.h index 2f301a7e79..196eca8bd0 100644
> --- a/app/test-eventdev/evt_common.h
> +++ b/app/test-eventdev/evt_common.h
> @@ -6,6 +6,7 @@
>  #define _EVT_COMMON_
> 
>  #include <rte_common.h>
> +#include <rte_crypto.h>
>  #include <rte_debug.h>
>  #include <rte_event_crypto_adapter.h>
>  #include <rte_eventdev.h>
> @@ -80,6 +81,7 @@ struct evt_options {
>  	uint64_t optm_timer_tick_nsec;
>  	enum evt_prod_type prod_type;
>  	enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> +	enum rte_crypto_op_type crypto_op_type;
>  };
> 
>  static inline bool
> diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
> index d3c704d2b3..8326734b64 100644
> --- a/app/test-eventdev/evt_options.c
> +++ b/app/test-eventdev/evt_options.c
> @@ -38,6 +38,7 @@ evt_options_default(struct evt_options *opt)
>  	opt->eth_queues = 1;
>  	opt->vector_size = 64;
>  	opt->vector_tmo_nsec = 100E3;
> +	opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
>  }
> 
>  typedef int (*option_parser_t)(struct evt_options *opt, @@ -142,6 +143,18
> @@ evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
>  	return ret;
>  }
> 
> +static int
> +evt_parse_crypto_op_type(struct evt_options *opt, const char *arg) {
> +	uint8_t op_type;
> +	int ret;
> +
> +	ret = parser_read_uint8(&op_type, arg);
> +	opt->crypto_op_type = op_type ?
> RTE_CRYPTO_OP_TYPE_ASYMMETRIC :
> +					RTE_CRYPTO_OP_TYPE_SYMMETRIC;
> +	return ret;
> +}
> +
>  static int
>  evt_parse_test_name(struct evt_options *opt, const char *arg)  { @@ -368,6
> +381,8 @@ usage(char *program)
>  		"\t--expiry_nsec      : event timer expiry ns.\n"
>  		"\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
> and\n"
>  		"\t                      1 for OP_FORWARD mode.\n"
> +		"\t--crypto_op_type   : 0 for SYM ops (default) and\n"
> +		"\t                     1 for ASYM ops.\n"
>  		"\t--mbuf_sz          : packet mbuf size.\n"
>  		"\t--max_pkt_sz       : max packet size.\n"
>  		"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> @@ -442,6 +457,7 @@ static struct option lgopts[] = {
>  	{ EVT_PROD_TIMERDEV,       0, 0, 0 },
>  	{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
>  	{ EVT_CRYPTO_ADPTR_MODE,   1, 0, 0 },
> +	{ EVT_CRYPTO_OP_TYPE,	   1, 0, 0 },
>  	{ EVT_NB_TIMERS,           1, 0, 0 },
>  	{ EVT_NB_TIMER_ADPTRS,     1, 0, 0 },
>  	{ EVT_TIMER_TICK_NSEC,     1, 0, 0 },
> @@ -484,6 +500,7 @@ evt_opts_parse_long(int opt_idx, struct evt_options
> *opt)
>  		{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
>  		{ EVT_PROD_TIMERDEV_BURST,
> evt_parse_timer_prod_type_burst},
>  		{ EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
> +		{ EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type},
>  		{ EVT_NB_TIMERS, evt_parse_nb_timers},
>  		{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
>  		{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git
> a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h index
> 2231c58801..f23fb8a511 100644
> --- a/app/test-eventdev/evt_options.h
> +++ b/app/test-eventdev/evt_options.h
> @@ -38,6 +38,7 @@
>  #define EVT_PROD_TIMERDEV        ("prod_type_timerdev")
>  #define EVT_PROD_TIMERDEV_BURST  ("prod_type_timerdev_burst")
>  #define EVT_CRYPTO_ADPTR_MODE	 ("crypto_adptr_mode")
> +#define EVT_CRYPTO_OP_TYPE	 ("crypto_op_type")
>  #define EVT_NB_TIMERS            ("nb_timers")
>  #define EVT_NB_TIMER_ADPTRS      ("nb_timer_adptrs")
>  #define EVT_TIMER_TICK_NSEC      ("timer_tick_nsec")
> @@ -298,6 +299,9 @@ evt_dump_producer_type(struct evt_options *opt)
>  			 "Event crypto adapter producers");
>  		evt_dump("crypto adapter mode", "%s",
>  			 opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> +		evt_dump("crypto op type", "%s",
> +			 (opt->crypto_op_type ==
> RTE_CRYPTO_OP_TYPE_SYMMETRIC) ?
> +			 "SYMMETRIC" : "ASYMMETRIC");
>  		evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
>  		break;
>  	}
> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> eventdev/test_perf_atq.c
> index 67ff681666..6a2aa86fd2 100644
> --- a/app/test-eventdev/test_perf_atq.c
> +++ b/app/test-eventdev/test_perf_atq.c
> @@ -53,11 +53,13 @@ perf_atq_worker(void *arg, const int
> enable_fwd_latency)
>  			struct rte_crypto_op *op = ev.event_ptr;
> 
>  			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> -				if (op->sym->m_dst == NULL)
> -					ev.event_ptr = op->sym->m_src;
> -				else
> -					ev.event_ptr = op->sym->m_dst;
> -				rte_crypto_op_free(op);
> +				if (op->type ==
> RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +					if (op->sym->m_dst == NULL)
> +						ev.event_ptr = op->sym-
> >m_src;
> +					else
> +						ev.event_ptr = op->sym-
> >m_dst;
> +					rte_crypto_op_free(op);
> +				}
>  			} else {
>  				rte_crypto_op_free(op);
>  				continue;
> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> eventdev/test_perf_common.c
> index 0378607cda..f2da6fd74c 100644
> --- a/app/test-eventdev/test_perf_common.c
> +++ b/app/test-eventdev/test_perf_common.c
> @@ -7,6 +7,89 @@
>  #include "test_perf_common.h"
> 
>  #define NB_CRYPTODEV_DESCRIPTORS 128
> +#define DATA_SIZE		512
> +struct modex_test_data {
> +	enum rte_crypto_asym_xform_type xform_type;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} base;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} exponent;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} modulus;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} reminder;
> +	uint16_t result_len;
> +};
> +
> +static struct
> +modex_test_data modex_test_case = {
> +	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
> +	.base = {
> +		.data = {
> +			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
> +			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
> +			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
> +		},
> +		.len = 20,
> +	},
> +	.exponent = {
> +		.data = {
> +			0x01, 0x00, 0x01
> +		},
> +		.len = 3,
> +	},
> +	.reminder = {
> +		.data = {
> +			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
> +			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
> +			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
> +			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
> +			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
> +			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
> +			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
> +			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
> +			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
> +			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
> +			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
> +			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
> +			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
> +			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
> +			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
> +			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
> +		},
> +		.len = 128,
> +	},
> +	.modulus = {
> +		.data = {
> +			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
> +			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
> +			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
> +			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
> +			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
> +			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
> +			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
> +			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
> +			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
> +			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
> +			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
> +			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
> +			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
> +			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
> +			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
> +			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
> +		},
> +		.len = 128,
> +	},
> +	.result_len = 128,
> +};
> 
>  int
>  perf_test_result(struct evt_test *test, struct evt_options *opt) @@ -277,12
> +360,10 @@ perf_event_timer_producer_burst(void *arg)  static inline void
> crypto_adapter_enq_op_new(struct prod_data *p)  {
> -	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
>  	struct test_perf *t = p->t;
>  	const uint32_t nb_flows = t->nb_flows;
>  	const uint64_t nb_pkts = t->nb_pkts;
>  	struct rte_mempool *pool = t->pool;
> -	struct rte_crypto_sym_op *sym_op;
>  	struct evt_options *opt = t->opt;
>  	uint16_t qp_id = p->ca.cdev_qp_id;
>  	uint8_t cdev_id = p->ca.cdev_id;
> @@ -300,22 +381,39 @@ crypto_adapter_enq_op_new(struct prod_data *p)
>  	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> 
>  	while (count < nb_pkts && t->done == false) {
> -		m = rte_pktmbuf_alloc(pool);
> -		if (m == NULL)
> -			continue;
> +		if (opt->crypto_op_type ==
> RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +			struct rte_crypto_sym_op *sym_op;
> 
> -		rte_pktmbuf_append(m, len);
> -		op = rte_crypto_op_alloc(t->ca_op_pool,
> +			op = rte_crypto_op_alloc(t->ca_op_pool,
>  					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> -		sym_op = op->sym;
> -		sym_op->m_src = m;
> -		sym_op->cipher.data.offset = 0;
> -		sym_op->cipher.data.length = len;
> -		rte_crypto_op_attach_sym_session(
> -			op, crypto_sess[flow_counter++ % nb_flows]);
> +			m = rte_pktmbuf_alloc(pool);
> +			if (m == NULL)
> +				continue;
> 
> +			rte_pktmbuf_append(m, len);
> +			sym_op = op->sym;
> +			sym_op->m_src = m;
> +			sym_op->cipher.data.offset = 0;
> +			sym_op->cipher.data.length = len;
> +			rte_crypto_op_attach_sym_session(
> +				op, p->ca.crypto_sess[flow_counter++ %
> nb_flows]);
> +		} else {
> +			struct rte_crypto_asym_op *asym_op;
> +			uint8_t *result = rte_zmalloc(NULL,
> +					modex_test_case.result_len, 0);
> +
> +			op = rte_crypto_op_alloc(t->ca_op_pool,
> +
> RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
> +			asym_op = op->asym;
> +			asym_op->modex.base.data =
> modex_test_case.base.data;
> +			asym_op->modex.base.length =
> modex_test_case.base.len;
> +			asym_op->modex.result.data = result;
> +			asym_op->modex.result.length =
> modex_test_case.result_len;
> +			rte_crypto_op_attach_asym_session(
> +				op, p->ca.crypto_sess[flow_counter++ %
> nb_flows]);
> +		}
>  		while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) !=
> 1 &&
> -		       t->done == false)
> +				t->done == false)
>  			rte_pause();
> 
>  		count++;
> @@ -325,7 +423,6 @@ crypto_adapter_enq_op_new(struct prod_data *p)
> static inline void  crypto_adapter_enq_op_fwd(struct prod_data *p)  {
> -	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
>  	const uint8_t dev_id = p->dev_id;
>  	const uint8_t port = p->port_id;
>  	struct test_perf *t = p->t;
> @@ -333,7 +430,6 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
>  	const uint64_t nb_pkts = t->nb_pkts;
>  	struct rte_mempool *pool = t->pool;
>  	struct evt_options *opt = t->opt;
> -	struct rte_crypto_sym_op *sym_op;
>  	uint32_t flow_counter = 0;
>  	struct rte_crypto_op *op;
>  	struct rte_event ev;
> @@ -354,19 +450,37 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
>  	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> 
>  	while (count < nb_pkts && t->done == false) {
> -		m = rte_pktmbuf_alloc(pool);
> -		if (m == NULL)
> -			continue;
> +		if (opt->crypto_op_type ==
> RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +			struct rte_crypto_sym_op *sym_op;
> 
> -		rte_pktmbuf_append(m, len);
> -		op = rte_crypto_op_alloc(t->ca_op_pool,
> +			op = rte_crypto_op_alloc(t->ca_op_pool,
>  					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> -		sym_op = op->sym;
> -		sym_op->m_src = m;
> -		sym_op->cipher.data.offset = 0;
> -		sym_op->cipher.data.length = len;
> -		rte_crypto_op_attach_sym_session(
> -			op, crypto_sess[flow_counter++ % nb_flows]);
> +			m = rte_pktmbuf_alloc(pool);
> +			if (m == NULL)
> +				continue;
> +
> +			rte_pktmbuf_append(m, len);
> +			sym_op = op->sym;
> +			sym_op->m_src = m;
> +			sym_op->cipher.data.offset = 0;
> +			sym_op->cipher.data.length = len;
> +			rte_crypto_op_attach_sym_session(
> +				op, p->ca.crypto_sess[flow_counter++ %
> nb_flows]);
> +		} else {
> +			struct rte_crypto_asym_op *asym_op;
> +			uint8_t *result = rte_zmalloc(NULL,
> +					modex_test_case.result_len, 0);
> +
> +			op = rte_crypto_op_alloc(t->ca_op_pool,
> +
> RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
> +			asym_op = op->asym;
> +			asym_op->modex.base.data =
> modex_test_case.base.data;
> +			asym_op->modex.base.length =
> modex_test_case.base.len;
> +			asym_op->modex.result.data = result;
> +			asym_op->modex.result.length =
> modex_test_case.result_len;
> +			rte_crypto_op_attach_asym_session(
> +				op, p->ca.crypto_sess[flow_counter++ %
> nb_flows]);
> +		}
>  		ev.event_ptr = op;
> 
>  		while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev,
> 1) != 1 && @@ -729,6 +843,37 @@ cryptodev_sym_sess_create(struct
> prod_data *p, struct test_perf *t)
>  	return sess;
>  }
> 
> +static void *
> +cryptodev_asym_sess_create(struct prod_data *p, struct test_perf *t) {
> +	const struct rte_cryptodev_asymmetric_xform_capability *capability;
> +	struct rte_cryptodev_asym_capability_idx cap_idx;
> +	struct rte_crypto_asym_xform xform;
> +	void *sess;
> +
> +	xform.next = NULL;
> +	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
> +	cap_idx.type = xform.xform_type;
> +	capability = rte_cryptodev_asym_capability_get(p->ca.cdev_id,
> &cap_idx);
> +	if (capability == NULL) {
> +		evt_err("Device doesn't support MODEX. Test Skipped\n");
> +		return NULL;
> +	}
> +
> +	xform.modex.modulus.data = modex_test_case.modulus.data;
> +	xform.modex.modulus.length = modex_test_case.modulus.len;
> +	xform.modex.exponent.data = modex_test_case.exponent.data;
> +	xform.modex.exponent.length = modex_test_case.exponent.len;
> +
> +	if (rte_cryptodev_asym_session_create(p->ca.cdev_id, &xform,
> +			t->ca_asym_sess_pool, &sess)) {
> +		evt_err("Failed to create asym session");
> +		return NULL;
> +	}
> +
> +	return sess;
> +}
> +
>  int
>  perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>  				uint8_t stride, uint8_t nb_queues,
> @@ -804,7 +949,6 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
> 
>  		prod = 0;
>  		for (; port < perf_nb_event_ports(opt); port++) {
> -			struct rte_cryptodev_sym_session *crypto_sess;
>  			union rte_event_crypto_metadata m_data;
>  			struct prod_data *p = &t->prod[port];
>  			uint32_t flow_id;
> @@ -820,7 +964,7 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
>  			p->ca.cdev_id = cdev_id;
>  			p->ca.cdev_qp_id = qp_id;
>  			p->ca.crypto_sess = rte_zmalloc_socket(
> -				NULL, sizeof(crypto_sess) * t->nb_flows,
> +				NULL, sizeof(void *) * t->nb_flows,
>  				RTE_CACHE_LINE_SIZE, opt->socket_id);
>  			p->t = t;
> 
> @@ -830,18 +974,36 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
>  			m_data.response_info.queue_id = p->queue_id;
> 
>  			for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> -				crypto_sess = cryptodev_sym_sess_create(p, t);
> -				if (crypto_sess == NULL)
> -					return -ENOMEM;
> -
>  				m_data.response_info.flow_id = flow_id;
> -
> 	rte_cryptodev_session_event_mdata_set(cdev_id,
> -						crypto_sess,
> +				if (opt->crypto_op_type ==
> +
> 	RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +					struct rte_cryptodev_sym_session
> *sess;
> +
> +					sess = cryptodev_sym_sess_create(p,
> t);
> +					if (sess == NULL)
> +						return -ENOMEM;
> +
> +
> 	rte_cryptodev_session_event_mdata_set(
> +						cdev_id,
> +						sess,
> 
> 	RTE_CRYPTO_OP_TYPE_SYMMETRIC,
> 
> 	RTE_CRYPTO_OP_WITH_SESSION,
>  						&m_data, sizeof(m_data));
> +					p->ca.crypto_sess[flow_id] = sess;
> +				} else {
> +					void *sess;
> 
> -				p->ca.crypto_sess[flow_id] = crypto_sess;
> +					sess = cryptodev_asym_sess_create(p,
> t);
> +					if (sess == NULL)
> +						return -ENOMEM;
> +
> 	rte_cryptodev_session_event_mdata_set(
> +						cdev_id,
> +						sess,
> +
> 	RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +
> 	RTE_CRYPTO_OP_WITH_SESSION,
> +						&m_data, sizeof(m_data));
> +					p->ca.crypto_sess[flow_id] = sess;
> +				}
>  			}
> 
>  			conf.event_port_cfg |=
> @@ -1123,14 +1285,24 @@ perf_cryptodev_setup(struct evt_test *test, struct
> evt_options *opt)
>  	}
> 
>  	t->ca_op_pool = rte_crypto_op_pool_create(
> -		"crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >pool_sz,
> -		128, 0, rte_socket_id());
> +		"crypto_op_pool", opt->crypto_op_type, opt->pool_sz,
> +		128, sizeof(union rte_event_crypto_metadata),
> +		rte_socket_id());
>  	if (t->ca_op_pool == NULL) {
>  		evt_err("Failed to create crypto op pool");
>  		return -ENOMEM;
>  	}
> 
>  	nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> +	t->ca_asym_sess_pool = rte_cryptodev_asym_session_pool_create(
> +		"ca_asym_sess_pool", nb_sessions, 0,
> +		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> +	if (t->ca_asym_sess_pool == NULL) {
> +		evt_err("Failed to create sym session pool");
> +		ret = -ENOMEM;
> +		goto err;
> +	}
> +
>  	t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
>  		"ca_sess_pool", nb_sessions, 0, 0,
>  		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> @@ -1217,6 +1389,7 @@ perf_cryptodev_setup(struct evt_test *test, struct
> evt_options *opt)
>  	rte_mempool_free(t->ca_op_pool);
>  	rte_mempool_free(t->ca_sess_pool);
>  	rte_mempool_free(t->ca_sess_priv_pool);
> +	rte_mempool_free(t->ca_asym_sess_pool);
> 
>  	return ret;
>  }
> @@ -1258,6 +1431,7 @@ perf_cryptodev_destroy(struct evt_test *test, struct
> evt_options *opt)
>  	rte_mempool_free(t->ca_op_pool);
>  	rte_mempool_free(t->ca_sess_pool);
>  	rte_mempool_free(t->ca_sess_priv_pool);
> +	rte_mempool_free(t->ca_asym_sess_pool);
>  }
> 
>  int
> diff --git a/app/test-eventdev/test_perf_common.h b/app/test-
> eventdev/test_perf_common.h
> index ea0907d61a..5651832cc9 100644
> --- a/app/test-eventdev/test_perf_common.h
> +++ b/app/test-eventdev/test_perf_common.h
> @@ -40,7 +40,7 @@ struct worker_data {
>  struct crypto_adptr_data {
>  	uint8_t cdev_id;
>  	uint16_t cdev_qp_id;
> -	struct rte_cryptodev_sym_session **crypto_sess;
> +	void **crypto_sess;
>  };
>  struct prod_data {
>  	uint8_t dev_id;
> @@ -70,6 +70,7 @@ struct test_perf {
>  	struct rte_mempool *ca_op_pool;
>  	struct rte_mempool *ca_sess_pool;
>  	struct rte_mempool *ca_sess_priv_pool;
> +	struct rte_mempool *ca_asym_sess_pool;
>  } __rte_cache_aligned;
> 
>  struct perf_elt {
> @@ -111,8 +112,6 @@ perf_process_last_stage(struct rte_mempool *const
> pool,
>  		struct rte_event *const ev, struct worker_data *const w,
>  		void *bufs[], int const buf_sz, uint8_t count)  {
> -	bufs[count++] = ev->event_ptr;
> -
>  	/* release fence here ensures event_prt is
>  	 * stored before updating the number of
>  	 * processed packets for worker lcores @@ -120,9 +119,19 @@
> perf_process_last_stage(struct rte_mempool *const pool,
>  	rte_atomic_thread_fence(__ATOMIC_RELEASE);
>  	w->processed_pkts++;
> 
> -	if (unlikely(count == buf_sz)) {
> -		count = 0;
> -		rte_mempool_put_bulk(pool, bufs, buf_sz);
> +	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
> +			((struct rte_crypto_op *)ev->event_ptr)->type ==
> +				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		struct rte_crypto_op *op = ev->event_ptr;
> +
> +		rte_free(op->asym->modex.result.data);
> +		rte_crypto_op_free(op);
> +	} else {
> +		bufs[count++] = ev->event_ptr;
> +		if (unlikely(count == buf_sz)) {
> +			count = 0;
> +			rte_mempool_put_bulk(pool, bufs, buf_sz);
> +		}
>  	}
>  	return count;
>  }
> @@ -135,8 +144,6 @@ perf_process_last_stage_latency(struct rte_mempool
> *const pool,
>  	uint64_t latency;
>  	struct perf_elt *const m = ev->event_ptr;
> 
> -	bufs[count++] = ev->event_ptr;
> -
>  	/* release fence here ensures event_prt is
>  	 * stored before updating the number of
>  	 * processed packets for worker lcores @@ -144,15 +151,23 @@
> perf_process_last_stage_latency(struct rte_mempool *const pool,
>  	rte_atomic_thread_fence(__ATOMIC_RELEASE);
>  	w->processed_pkts++;
> 
> -	if (unlikely(count == buf_sz)) {
> -		count = 0;
> -		latency = rte_get_timer_cycles() - m->timestamp;
> -		rte_mempool_put_bulk(pool, bufs, buf_sz);
> +	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
> +			((struct rte_crypto_op *)m)->type ==
> +				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		rte_free(((struct rte_crypto_op *)m)->asym-
> >modex.result.data);
> +		rte_crypto_op_free((struct rte_crypto_op *)m);
>  	} else {
> -		latency = rte_get_timer_cycles() - m->timestamp;
> +		bufs[count++] = ev->event_ptr;
> +		if (unlikely(count == buf_sz)) {
> +			count = 0;
> +			latency = rte_get_timer_cycles() - m->timestamp;
> +			rte_mempool_put_bulk(pool, bufs, buf_sz);
> +		} else {
> +			latency = rte_get_timer_cycles() - m->timestamp;
> +		}
> +
> +		w->latency += latency;
>  	}
> -
> -	w->latency += latency;
>  	return count;
>  }
> 
> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> eventdev/test_perf_queue.c
> index dcf6d82947..631a39f727 100644
> --- a/app/test-eventdev/test_perf_queue.c
> +++ b/app/test-eventdev/test_perf_queue.c
> @@ -55,11 +55,13 @@ perf_queue_worker(void *arg, const int
> enable_fwd_latency)
>  			struct rte_crypto_op *op = ev.event_ptr;
> 
>  			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> -				if (op->sym->m_dst == NULL)
> -					ev.event_ptr = op->sym->m_src;
> -				else
> -					ev.event_ptr = op->sym->m_dst;
> -				rte_crypto_op_free(op);
> +				if (op->type ==
> RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +					if (op->sym->m_dst == NULL)
> +						ev.event_ptr = op->sym-
> >m_src;
> +					else
> +						ev.event_ptr = op->sym-
> >m_dst;
> +					rte_crypto_op_free(op);
> +				}
>  			} else {
>  				rte_crypto_op_free(op);
>  				continue;
> diff --git a/doc/guides/tools/testeventdev.rst
> b/doc/guides/tools/testeventdev.rst
> index f7d813226d..a8e02d57a4 100644
> --- a/doc/guides/tools/testeventdev.rst
> +++ b/doc/guides/tools/testeventdev.rst
> @@ -157,6 +157,11 @@ The following are the application command-line
> options:
>          Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
>          OP_FORWARD mode.
> 
> +* ``--crypto_op_type``
> +
> +        Set crypto operation type. Use 0 for symmetric crypto ops (default)
> +        and 1 for asymmetric crypto ops.
> +
>  * ``--mbuf_sz``
> 
>         Set packet mbuf size. Can be used to configure Jumbo Frames. Only
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 2/7] crypto/cnxk: add event metadata set operation
  2022-04-21 14:37     ` [PATCH v3 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
  2022-04-27 15:38       ` Zhang, Roy Fan
@ 2022-05-01 13:17       ` Gujjar, Abhinandan S
  2022-05-01 18:29         ` Akhil Goyal
  1 sibling, 1 reply; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-01 13:17 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

Minor comment below

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 2/7] crypto/cnxk: add event metadata set operation
> 
> From: Volodymyr Fialko <vfialko@marvell.com>
> 
> Added cryptodev operation for setting event crypto metadata for all supported
> sessions - sym/asym/security.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++---
>  drivers/crypto/cnxk/cn10k_ipsec.h         |   2 +
>  drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 138 ++++++++++++++++++---
>  drivers/crypto/cnxk/cn9k_ipsec.h          |   2 +
>  drivers/crypto/cnxk/cnxk_ae.h             |   2 +
>  drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  18 ---
>  drivers/crypto/cnxk/cnxk_se.h             |   2 +
>  7 files changed, 255 insertions(+), 53 deletions(-)
> 
> diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> index c4d5d039ec..01aa0d6870 100644
> --- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> +++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> @@ -264,30 +264,136 @@ cn10k_cpt_enqueue_burst(void *qptr, struct
> rte_crypto_op **ops, uint16_t nb_ops)
>  	return count + i;
>  }
> 
> -uint16_t
> -cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> *op)
> +static int
> +cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev
> __rte_unused,
> +				      void *sess,
> +				      enum rte_crypto_op_type op_type,
> +				      enum rte_crypto_op_sess_type sess_type,
> +				      void *mdata)
>  {
> -	union rte_event_crypto_metadata *ec_mdata;
> -	struct cpt_inflight_req *infl_req;
> +	union rte_event_crypto_metadata *ec_mdata = mdata;
>  	struct rte_event *rsp_info;
> -	uint64_t lmt_base, lmt_arg;
> -	struct cpt_inst_s *inst;
>  	struct cnxk_cpt_qp *qp;
>  	uint8_t cdev_id;
> -	uint16_t lmt_id;
> -	uint16_t qp_id;
> -	int ret;
> -
> -	ec_mdata = cnxk_event_crypto_mdata_get(op);
> -	if (!ec_mdata) {
> -		rte_errno = EINVAL;
> -		return 0;
> -	}
> +	int16_t qp_id;
> +	uint64_t w2;
> 
> +	/* Get queue pair */
>  	cdev_id = ec_mdata->request_info.cdev_id;
>  	qp_id = ec_mdata->request_info.queue_pair_id;
>  	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
> +
> +	/* Prepare w2 */
>  	rsp_info = &ec_mdata->response_info;
> +	w2 = CNXK_CPT_INST_W2(
> +		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> +		rsp_info->sched_type, rsp_info->queue_id, 0);
> +
> +	/* Set meta according to session type */
> +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn10k_sec_session *priv;
> +			struct cn10k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(sess);
> +			sa = &priv->sa;
> +			sa->qp = qp;
> +			sa->inst.w2 = w2;
> +		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				sess, cn10k_cryptodev_driver_id);
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
cnXX_ca_meta_info_extract() supports SESSIONLESS case. But no support here.
Is this expected?
> +			return -EINVAL;
> +	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess = sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static inline int
> +cn10k_ca_meta_info_extract(struct rte_crypto_op *op,
> +			 struct cnxk_cpt_qp **qp, uint64_t *w2) {
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn10k_sec_session *priv;
> +			struct cn10k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(op->sym-
> >sec_session);
> +			sa = &priv->sa;
> +			*qp = sa->qp;
> +			*w2 = sa->inst.w2;
> +		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				op->sym->session,
> cn10k_cryptodev_driver_id);
> +			*qp = priv->qp;
> +			*w2 = priv->cpt_inst_w2;
> +		} else {
> +			union rte_event_crypto_metadata *ec_mdata;
> +			struct rte_event *rsp_info;
> +			uint8_t cdev_id;
> +			uint16_t qp_id;
> +
> +			ec_mdata = (union rte_event_crypto_metadata *)
> +				((uint8_t *)op + op->private_data_offset);
> +			if (!ec_mdata)
> +				return -EINVAL;
> +			rsp_info = &ec_mdata->response_info;
> +			cdev_id = ec_mdata->request_info.cdev_id;
> +			qp_id = ec_mdata->request_info.queue_pair_id;
> +			*qp = rte_cryptodevs[cdev_id].data-
> >queue_pairs[qp_id];
> +			*w2 = CNXK_CPT_INST_W2(
> +				(RTE_EVENT_TYPE_CRYPTODEV << 28) |
> rsp_info->flow_id,
> +				rsp_info->sched_type, rsp_info->queue_id, 0);
> +		}
> +	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			asym_sess = op->asym->session;
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			*qp = priv->qp;
> +			*w2 = priv->cpt_inst_w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +uint16_t
> +cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> +*op) {
> +	struct cpt_inflight_req *infl_req;
> +	uint64_t lmt_base, lmt_arg, w2;
> +	struct cpt_inst_s *inst;
> +	struct cnxk_cpt_qp *qp;
> +	uint16_t lmt_id;
> +	int ret;
> +
> +	ret = cn10k_ca_meta_info_extract(op, &qp, &w2);
> +	if (unlikely(ret)) {
> +		rte_errno = EINVAL;
> +		return 0;
> +	}
> 
>  	if (unlikely(!qp->ca.enabled)) {
>  		rte_errno = EINVAL;
> @@ -316,9 +422,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  	infl_req->qp = qp;
>  	inst->w0.u64 = 0;
>  	inst->res_addr = (uint64_t)&infl_req->res;
> -	inst->w2.u64 = CNXK_CPT_INST_W2(
> -		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> -		rsp_info->sched_type, rsp_info->queue_id, 0);
> +	inst->w2.u64 = w2;
>  	inst->w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
> 
>  	if (roc_cpt_is_iq_full(&qp->lf)) {
> @@ -327,7 +431,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  		return 0;
>  	}
> 
> -	if (!rsp_info->sched_type)
> +	if (inst->w2.s.tt == RTE_SCHED_TYPE_ORDERED)
>  		roc_sso_hws_head_wait(tag_op);
> 
>  	lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id; @@ -592,4
> +696,6 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
>  	.asym_session_configure = cnxk_ae_session_cfg,
>  	.asym_session_clear = cnxk_ae_session_clear,
> 
> +	/* Event crypto ops */
> +	.session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set,
>  };
> diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h
> b/drivers/crypto/cnxk/cn10k_ipsec.h
> index 647a71cdd5..1c1d904799 100644
> --- a/drivers/crypto/cnxk/cn10k_ipsec.h
> +++ b/drivers/crypto/cnxk/cn10k_ipsec.h
> @@ -20,6 +20,8 @@ struct cn10k_ipsec_sa {
>  	uint16_t iv_offset;
>  	uint8_t iv_length;
>  	bool is_outbound;
> +	/** Queue pair */
> +	struct cnxk_cpt_qp *qp;
> 
>  	/**
>  	 * End of SW mutable area
> diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> index d3d441cb24..98fa97ef01 100644
> --- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> +++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> @@ -316,28 +316,134 @@ cn9k_cpt_enqueue_burst(void *qptr, struct
> rte_crypto_op **ops, uint16_t nb_ops)
>  	return count;
>  }
> 
> -uint16_t
> -cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> *op)
> +static int
> +cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev
> __rte_unused,
> +				     void *sess,
> +				     enum rte_crypto_op_type op_type,
> +				     enum rte_crypto_op_sess_type sess_type,
> +				     void *mdata)
>  {
> -	union rte_event_crypto_metadata *ec_mdata;
> -	struct cpt_inflight_req *infl_req;
> +	union rte_event_crypto_metadata *ec_mdata = mdata;
>  	struct rte_event *rsp_info;
>  	struct cnxk_cpt_qp *qp;
> -	struct cpt_inst_s inst;
>  	uint8_t cdev_id;
>  	uint16_t qp_id;
> -	int ret;
> -
> -	ec_mdata = cnxk_event_crypto_mdata_get(op);
> -	if (!ec_mdata) {
> -		rte_errno = EINVAL;
> -		return 0;
> -	}
> +	uint64_t w2;
> 
> +	/* Get queue pair */
>  	cdev_id = ec_mdata->request_info.cdev_id;
>  	qp_id = ec_mdata->request_info.queue_pair_id;
>  	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
> +
> +	/* Prepare w2 */
>  	rsp_info = &ec_mdata->response_info;
> +	w2 = CNXK_CPT_INST_W2(
> +		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> +		rsp_info->sched_type, rsp_info->queue_id, 0);
> +
> +	/* Set meta according to session type */
> +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn9k_sec_session *priv;
> +			struct cn9k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(sess);
> +			sa = &priv->sa;
> +			sa->qp = qp;
> +			sa->inst.w2 = w2;
> +		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				sess, cn9k_cryptodev_driver_id);
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
> +			return -EINVAL;
> +	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess = sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static inline int
> +cn9k_ca_meta_info_extract(struct rte_crypto_op *op,
> +			struct cnxk_cpt_qp **qp, struct cpt_inst_s *inst) {
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn9k_sec_session *priv;
> +			struct cn9k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(op->sym-
> >sec_session);
> +			sa = &priv->sa;
> +			*qp = sa->qp;
> +			inst->w2.u64 = sa->inst.w2;
> +		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				op->sym->session, cn9k_cryptodev_driver_id);
> +			*qp = priv->qp;
> +			inst->w2.u64 = priv->cpt_inst_w2;
> +		} else {
> +			union rte_event_crypto_metadata *ec_mdata;
> +			struct rte_event *rsp_info;
> +			uint8_t cdev_id;
> +			uint16_t qp_id;
> +
> +			ec_mdata = (union rte_event_crypto_metadata *)
> +				((uint8_t *)op + op->private_data_offset);
> +			if (!ec_mdata)
> +				return -EINVAL;
> +			rsp_info = &ec_mdata->response_info;
> +			cdev_id = ec_mdata->request_info.cdev_id;
> +			qp_id = ec_mdata->request_info.queue_pair_id;
> +			*qp = rte_cryptodevs[cdev_id].data-
> >queue_pairs[qp_id];
> +			inst->w2.u64 = CNXK_CPT_INST_W2(
> +				(RTE_EVENT_TYPE_CRYPTODEV << 28) |
> rsp_info->flow_id,
> +				rsp_info->sched_type, rsp_info->queue_id, 0);
> +		}
> +	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			asym_sess = op->asym->session;
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			*qp = priv->qp;
> +			inst->w2.u64 = priv->cpt_inst_w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +uint16_t
> +cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> +*op) {
> +	struct cpt_inflight_req *infl_req;
> +	struct cnxk_cpt_qp *qp;
> +	struct cpt_inst_s inst;
> +	int ret;
> +
> +	ret = cn9k_ca_meta_info_extract(op, &qp, &inst);
> +	if (unlikely(ret)) {
> +		rte_errno = EINVAL;
> +		return 0;
> +	}
> 
>  	if (unlikely(!qp->ca.enabled)) {
>  		rte_errno = EINVAL;
> @@ -362,9 +468,6 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  	infl_req->qp = qp;
>  	inst.w0.u64 = 0;
>  	inst.res_addr = (uint64_t)&infl_req->res;
> -	inst.w2.u64 = CNXK_CPT_INST_W2(
> -		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> -		rsp_info->sched_type, rsp_info->queue_id, 0);
>  	inst.w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
> 
>  	if (roc_cpt_is_iq_full(&qp->lf)) {
> @@ -373,7 +476,7 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  		return 0;
>  	}
> 
> -	if (!rsp_info->sched_type)
> +	if (inst.w2.s.tt == RTE_SCHED_TYPE_ORDERED)
>  		roc_sso_hws_head_wait(tag_op);
> 
>  	cn9k_cpt_inst_submit(&inst, qp->lmtline.lmt_base, qp-
> >lmtline.io_addr); @@ -613,4 +716,7 @@ struct rte_cryptodev_ops
> cn9k_cpt_ops = {
>  	.asym_session_configure = cnxk_ae_session_cfg,
>  	.asym_session_clear = cnxk_ae_session_clear,
> 
> +	/* Event crypto ops */
> +	.session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set,
> +
>  };
> diff --git a/drivers/crypto/cnxk/cn9k_ipsec.h
> b/drivers/crypto/cnxk/cn9k_ipsec.h
> index f3acad561b..499dbc2782 100644
> --- a/drivers/crypto/cnxk/cn9k_ipsec.h
> +++ b/drivers/crypto/cnxk/cn9k_ipsec.h
> @@ -42,6 +42,8 @@ struct cn9k_ipsec_sa {
>  	struct cnxk_on_ipsec_ar ar;
>  	/** Anti replay window size */
>  	uint32_t replay_win_sz;
> +	/** Queue pair */
> +	struct cnxk_cpt_qp *qp;
>  };
> 
>  struct cn9k_sec_session {
> diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
> index 01ccfcd334..10854c79c8 100644
> --- a/drivers/crypto/cnxk/cnxk_ae.h
> +++ b/drivers/crypto/cnxk/cnxk_ae.h
> @@ -22,6 +22,8 @@ struct cnxk_ae_sess {
>  	uint64_t *cnxk_fpm_iova;
>  	struct roc_ae_ec_group **ec_grp;
>  	uint64_t cpt_inst_w7;
> +	uint64_t cpt_inst_w2;
> +	struct cnxk_cpt_qp *qp;
>  };
> 
>  static __rte_always_inline void
> diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> index ab0f00ee7c..7ece0214dc 100644
> --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> @@ -125,24 +125,6 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
>  			struct rte_cryptodev_asym_session *sess);  void
> cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
> 
> -static inline union rte_event_crypto_metadata * -
> cnxk_event_crypto_mdata_get(struct rte_crypto_op *op) -{
> -	union rte_event_crypto_metadata *ec_mdata;
> -
> -	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> -		ec_mdata = rte_cryptodev_sym_session_get_user_data(
> -			op->sym->session);
> -	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> -		 op->private_data_offset)
> -		ec_mdata = (union rte_event_crypto_metadata
> -				    *)((uint8_t *)op + op->private_data_offset);
> -	else
> -		return NULL;
> -
> -	return ec_mdata;
> -}
> -
>  static __rte_always_inline void
>  pending_queue_advance(uint64_t *index, const uint64_t mask)  { diff --git
> a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index
> e988d57b94..b11c2bb3a2 100644
> --- a/drivers/crypto/cnxk/cnxk_se.h
> +++ b/drivers/crypto/cnxk/cnxk_se.h
> @@ -33,6 +33,8 @@ struct cnxk_se_sess {
>  	uint16_t auth_iv_offset;
>  	uint32_t salt;
>  	uint64_t cpt_inst_w7;
> +	uint64_t cpt_inst_w2;
> +	struct cnxk_cpt_qp *qp;
>  	struct roc_se_ctx roc_se_ctx;
>  } __rte_cache_aligned;
> 
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 3/7] crypto/octeontx: use new API for event metadata
  2022-04-21 14:37     ` [PATCH v3 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
  2022-04-27 15:38       ` Zhang, Roy Fan
@ 2022-05-01 13:18       ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-01 13:18 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, April 21, 2022 8:07 PM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v3 3/7] crypto/octeontx: use new API for event metadata
> 
> For getting event crypto metadata from crypto_op, the new API
> rte_cryptodev_get_session_event_mdata can be used directly instead of
> getting userdata inside PMD.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
>  drivers/crypto/octeontx/otx_cryptodev_ops.c | 20 +-------------------
>  1 file changed, 1 insertion(+), 19 deletions(-)
> 
> diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c
> b/drivers/crypto/octeontx/otx_cryptodev_ops.c
> index ddb1266c3c..d5851d9987 100644
> --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
> +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
> @@ -684,24 +684,6 @@ submit_request_to_sso(struct ssows *ws, uintptr_t
> req,
>  	ssovf_store_pair(add_work, req, ws->grps[rsp_info->queue_id]);  }
> 
> -static inline union rte_event_crypto_metadata * -
> get_event_crypto_mdata(struct rte_crypto_op *op) -{
> -	union rte_event_crypto_metadata *ec_mdata;
> -
> -	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> -		ec_mdata = rte_cryptodev_sym_session_get_user_data(
> -							   op->sym->session);
> -	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> -		 op->private_data_offset)
> -		ec_mdata = (union rte_event_crypto_metadata *)
> -			((uint8_t *)op + op->private_data_offset);
> -	else
> -		return NULL;
> -
> -	return ec_mdata;
> -}
> -
>  uint16_t __rte_hot
>  otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)  { @@ -
> 712,7 +694,7 @@ otx_crypto_adapter_enqueue(void *port, struct
> rte_crypto_op *op)
>  	uint8_t op_type, cdev_id;
>  	uint16_t qp_id;
> 
> -	ec_mdata = get_event_crypto_mdata(op);
> +	ec_mdata = rte_cryptodev_session_event_mdata_get(op);
>  	if (unlikely(ec_mdata == NULL)) {
>  		rte_errno = EINVAL;
>  		return 0;
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 2/7] crypto/cnxk: add event metadata set operation
  2022-05-01 13:17       ` Gujjar, Abhinandan S
@ 2022-05-01 18:29         ` Akhil Goyal
  0 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 18:29 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, Jayatheerthan, Jay,
	Vangati, Narender, Volodymyr Fialko

> > -uint16_t
> > -cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> > *op)
> > +static int
> > +cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev
> > __rte_unused,
> > +				      void *sess,
> > +				      enum rte_crypto_op_type op_type,
> > +				      enum rte_crypto_op_sess_type sess_type,
> > +				      void *mdata)
> >  {
> > -	union rte_event_crypto_metadata *ec_mdata;
> > -	struct cpt_inflight_req *infl_req;
> > +	union rte_event_crypto_metadata *ec_mdata = mdata;
> >  	struct rte_event *rsp_info;
> > -	uint64_t lmt_base, lmt_arg;
> > -	struct cpt_inst_s *inst;
> >  	struct cnxk_cpt_qp *qp;
> >  	uint8_t cdev_id;
> > -	uint16_t lmt_id;
> > -	uint16_t qp_id;
> > -	int ret;
> > -
> > -	ec_mdata = cnxk_event_crypto_mdata_get(op);
> > -	if (!ec_mdata) {
> > -		rte_errno = EINVAL;
> > -		return 0;
> > -	}
> > +	int16_t qp_id;
> > +	uint64_t w2;
> >
> > +	/* Get queue pair */
> >  	cdev_id = ec_mdata->request_info.cdev_id;
> >  	qp_id = ec_mdata->request_info.queue_pair_id;
> >  	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
> > +
> > +	/* Prepare w2 */
> >  	rsp_info = &ec_mdata->response_info;
> > +	w2 = CNXK_CPT_INST_W2(
> > +		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> > +		rsp_info->sched_type, rsp_info->queue_id, 0);
> > +
> > +	/* Set meta according to session type */
> > +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> > +		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> > +			struct cn10k_sec_session *priv;
> > +			struct cn10k_ipsec_sa *sa;
> > +
> > +			priv = get_sec_session_private_data(sess);
> > +			sa = &priv->sa;
> > +			sa->qp = qp;
> > +			sa->inst.w2 = w2;
> > +		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> > +			struct cnxk_se_sess *priv;
> > +
> > +			priv = get_sym_session_private_data(
> > +				sess, cn10k_cryptodev_driver_id);
> > +			priv->qp = qp;
> > +			priv->cpt_inst_w2 = w2;
> > +		} else
> cnXX_ca_meta_info_extract() supports SESSIONLESS case. But no support here.
> Is this expected?

This function is for setting the event metadata in session, but in case of sessionless
there are no sessions, so event metadata is extracted in a different way.
Hence this is correct.



^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter
  2022-05-01 12:45           ` Gujjar, Abhinandan S
@ 2022-05-01 18:36             ` Akhil Goyal
  0 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 18:36 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, Jayatheerthan, Jay,
	Vangati, Narender, Volodymyr Fialko

Hi Abhinandan,
> >
> > > This is failing with asym changes. Please look into this.
> >
> > Thanks for pointing this out. It is failing as null crypto does not support asym
> > And asym_session_create would need an op from driver which is NULL for null
> > crypto
> >
> > Please check if below change is working for you.
> I could not apply this patch cleanly. I see that you are skipping the asym test for
> NULL PMD.
> Can I use openssl or any open source PMD to test this feature? If yes, please
> provide the command line.

The patch is not skipping specifically null pmd.
It is not creating asym session and asym op mempools for devices which do not
Support asym sessions.

OpenSSL can be used as it support asym ops(vdev can be passed as command line arg),
But the test will not execute, as it would not support event crypto adapter.
This patch can be tested with PMD which support ASYM crypto adapter and no other
PMD support that as of now.

> >
> > diff --git a/app/test/test_event_crypto_adapter.c
> > b/app/test/test_event_crypto_adapter.c
> > index eecfc22057..2ecc7e2cea 100644
> > --- a/app/test/test_event_crypto_adapter.c
> > +++ b/app/test/test_event_crypto_adapter.c
> > @@ -934,13 +934,16 @@ test_asym_session_with_op_new_mode(void)
> >  static int
> >  configure_cryptodev(void)
> >  {
> > +       const struct rte_cryptodev_capabilities *capability;
> >         struct rte_cryptodev_qp_conf qp_conf;
> >         struct rte_cryptodev_config conf;
> >         struct rte_cryptodev_info info;
> >         unsigned int session_size;
> > +       unsigned int i = 0;
> >         uint8_t nb_devs;
> >         int ret;
> >
> > +
> >         params.mbuf_pool = rte_pktmbuf_pool_create(
> >                         "CRYPTO_ADAPTER_MBUFPOOL",
> >                         NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE, @@ -963,19
> > +966,6 @@ configure_cryptodev(void)
> >                 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
> >                 return TEST_FAILED;
> >         }
> > -       params.asym_op_mpool = rte_crypto_op_pool_create(
> > -                       "EVENT_CRYPTO_ASYM_OP_POOL",
> > -                       RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> > -                       NUM_MBUFS, MBUF_CACHE_SIZE,
> > -                       (DEFAULT_NUM_XFORMS *
> > -                       sizeof(struct rte_crypto_asym_xform)) +
> > -                       sizeof(union rte_event_crypto_metadata),
> > -                       rte_socket_id());
> > -       if (params.asym_op_mpool == NULL) {
> > -               RTE_LOG(ERR, USER1, "Can't create CRYPTO_ASYM_OP_POOL\n");
> > -               return TEST_FAILED;
> > -       }
> > -
> >
> >         /* Create a NULL crypto device */
> >         nb_devs = rte_cryptodev_device_count_by_driver(
> > @@ -1020,16 +1010,34 @@ configure_cryptodev(void)
> >         TEST_ASSERT_NOT_NULL(params.session_priv_mpool,
> >                         "session mempool allocation failed\n");
> >
> > -       params.asym_sess_mpool = rte_cryptodev_asym_session_pool_create(
> > -                       "CRYPTO_AD_ASYM_SESS_MP",
> > -                       MAX_NB_SESSIONS, 0,
> > -                       sizeof(union rte_event_crypto_metadata),
> > -                       SOCKET_ID_ANY);
> > -       TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
> > -                       "asym session mempool allocation failed\n");
> > -
> > -
> >         rte_cryptodev_info_get(TEST_CDEV_ID, &info);
> > +
> > +       while ((capability = &info.capabilities[i++])->op !=
> > +                       RTE_CRYPTO_OP_TYPE_UNDEFINED) {
> > +               if (capability->op == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> > +                       params.asym_op_mpool = rte_crypto_op_pool_create(
> > +                               "EVENT_CRYPTO_ASYM_OP_POOL",
> > +                               RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> > +                               NUM_MBUFS, MBUF_CACHE_SIZE,
> > +                               (DEFAULT_NUM_XFORMS *
> > +                               sizeof(struct rte_crypto_asym_xform)) +
> > +                               sizeof(union rte_event_crypto_metadata),
> > +                               rte_socket_id());
> > +                       TEST_ASSERT_NOT_NULL(params.asym_op_mpool,
> > +                                       "Can't create
> > + CRYPTO_ASYM_OP_POOL\n");
> > +
> > +                       params.asym_sess_mpool =
> > +                               rte_cryptodev_asym_session_pool_create(
> > +                                       "CRYPTO_AD_ASYM_SESS_MP",
> > +                                       MAX_NB_SESSIONS, 0,
> > +                                       sizeof(union rte_event_crypto_metadata),
> > +                                       SOCKET_ID_ANY);
> > +                       TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
> > +                               "asym session mempool allocation failed\n");
> > +                       break;
> > +               }
> > +       }
> > +
> >         conf.nb_queue_pairs = info.max_nb_queue_pairs;
> >         conf.socket_id = SOCKET_ID_ANY;
> >         conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> >
> >


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
  2022-05-01 12:24           ` Gujjar, Abhinandan S
@ 2022-05-01 18:37             ` Akhil Goyal
  0 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 18:37 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, Jayatheerthan, Jay,
	Vangati, Narender, Volodymyr Fialko

> > > > +
> > > > +void *
> > > > +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op) {
> > > Null check for op?
> >
> > Null check can be added, but this a datapath dpdk internal API.
> > We do not normally add checks in datapath.
> > If you insist, I can add, but before calling this API, PMD/lib would have already
> > checked for null op.
> It is ok for get API. It is better to add the check for set API as it exposed to user
> application.
> Currently, the set API is validating dev_id. It is better to add a null check only for
> set API.
Ok. Will do that.



^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 0/7] Add new cryptodev op for event metadata
  2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
                       ` (8 preceding siblings ...)
  2022-04-28 14:24     ` Gujjar, Abhinandan S
@ 2022-05-01 19:24     ` Akhil Goyal
  2022-05-01 19:24       ` [PATCH v4 1/7] cryptodev: add APIs to get/set " Akhil Goyal
                         ` (8 more replies)
  9 siblings, 9 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For using event crypto metadata, event metadata need to be set
in session. For this session user data was used for symmetric
crypto sessions and no support was present for asymmetric and
security sessions.
The use of userdata to store event metadata (which is dereferenced
in PMD) is not correct as it is meant for the application to use it.
Hence, a new API is created to set and get event crypto metadata which
is scalable to all sessions supported by the crypto PMD.
The application can use the set API to set event metadata and the
PMD may store that inside the session private data and PMD need not
use the get API as it would be internal to the PMD.
For the software event crypto adapter implementation, the eventdev
library can use the get API to get the event metadata stored inside
the session structure.
For Asymmetric sessions, a new field is added inside the session
struct which is internal to library.
For symmetric and security sessions, new field cannot be added as
it would be ABI break. Hence, session userdata is being used to
store that as it was used earlier. In next ABI break release this
would be fixed similar to asymmetric crypto case.

The patchset also add support for asymmetric crypto adapter
in the test applications and the crypto/cnxk implementation of
the new cryptodev op and corresponding changes in the eventdev lib.

Changes in v4:
- added null checks in set API
- updated check in session destroy
- updated API comments
- fixed test app failure reported by Abhinandan.
- moved event mdata after padding in asym session struct.

Changes in v3:
- fix SW adapter case of memory allocation/free of mdata. mdata is
allocated in set API and freed in session clear/destroy.
- mark rte_cryptodev_session_event_mdata_get as internal API
as it is only needed for the app or the PMD.

changes in v2:
- v1 patchset only fixed security sessions and also caused ABI breakage.
This is fixed in v2.
- added new API for setting event metadata.
- added new cryptodev op which can handle all sessions


Akhil Goyal (5):
  crypto/octeontx: use new API for event metadata
  test/event: use new API to set event crypto metadata
  eventdev: use new API to get event crypto metadata
  test/event: add asymmetric cases for crypto adapter
  test-eventdev: support asym ops for crypto adapter

Volodymyr Fialko (2):
  cryptodev: add APIs to get/set event metadata
  crypto/cnxk: add event metadata set operation

 app/test-eventdev/evt_common.h              |   2 +
 app/test-eventdev/evt_options.c             |  17 +
 app/test-eventdev/evt_options.h             |   4 +
 app/test-eventdev/test_perf_atq.c           |  12 +-
 app/test-eventdev/test_perf_common.c        | 254 ++++++++--
 app/test-eventdev/test_perf_common.h        |  45 +-
 app/test-eventdev/test_perf_queue.c         |  12 +-
 app/test/test_event_crypto_adapter.c        | 511 +++++++++++++++++++-
 doc/guides/tools/testeventdev.rst           |   5 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c   | 144 +++++-
 drivers/crypto/cnxk/cn10k_ipsec.h           |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    | 138 +++++-
 drivers/crypto/cnxk/cn9k_ipsec.h            |   2 +
 drivers/crypto/cnxk/cnxk_ae.h               |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h    |  18 -
 drivers/crypto/cnxk/cnxk_se.h               |   2 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c |  20 +-
 lib/cryptodev/cryptodev_pmd.c               |  16 +
 lib/cryptodev/cryptodev_pmd.h               |  36 ++
 lib/cryptodev/rte_cryptodev.c               |  44 ++
 lib/cryptodev/rte_cryptodev.h               |  22 +
 lib/cryptodev/version.map                   |   4 +
 lib/eventdev/rte_event_crypto_adapter.c     |  55 +--
 23 files changed, 1179 insertions(+), 188 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 1/7] cryptodev: add APIs to get/set event metadata
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
@ 2022-05-01 19:24       ` Akhil Goyal
  2022-05-02  9:01         ` Anoob Joseph
  2022-05-02 11:06         ` Gujjar, Abhinandan S
  2022-05-01 19:24       ` [PATCH v4 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
                         ` (7 subsequent siblings)
  8 siblings, 2 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang

From: Volodymyr Fialko <vfialko@marvell.com>

Currently, crypto session userdata is used to set event crypto
metadata from the application and the driver is dereferencing it
in driver which is not correct. User data is meant to be opaque
to the driver.
To support this, new API is added to get and set event crypto
metadata. The new API, rte_cryptodev_set_session_event_mdata,
allows setting event metadata in session private data which is
filled inside PMD using a new cryptodev op. This operation
can be performed on any of the PMD supported sessions
(sym/asym/security).
For SW abstraction of event crypto adapter to be used by
eventdev library, a new field is added in asymmetric crypto
session for now and for symmetric case, current implementation
of using userdata is used. Symmetric cases cannot be fixed now,
as it will be ABI breakage which will be resolved in DPDK 22.11.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 lib/cryptodev/cryptodev_pmd.c | 16 +++++++++++++
 lib/cryptodev/cryptodev_pmd.h | 36 ++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.c | 44 +++++++++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.h | 22 ++++++++++++++++++
 lib/cryptodev/version.map     |  4 ++++
 5 files changed, 122 insertions(+)

diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
index 739a0b3f34..1903ade388 100644
--- a/lib/cryptodev/cryptodev_pmd.c
+++ b/lib/cryptodev/cryptodev_pmd.c
@@ -227,3 +227,19 @@ cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
 	fp_ops->qp.enq_cb = dev->enq_cbs;
 	fp_ops->qp.deq_cb = dev->deq_cbs;
 }
+
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return rte_cryptodev_sym_session_get_user_data(op->sym->session);
+	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return op->asym->session->event_mdata;
+	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
+			op->private_data_offset)
+		return ((uint8_t *)op + op->private_data_offset);
+	else
+		return NULL;
+}
diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 2b1ce2da2d..7a7d3ee3f1 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -398,6 +398,25 @@ typedef int (*cryptodev_sym_configure_raw_dp_ctx_t)(
 	enum rte_crypto_op_sess_type sess_type,
 	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
 
+/**
+ * Typedef that the driver provided to set event crypto meta data.
+ *
+ * @param	dev		Crypto device pointer.
+ * @param	sess		Crypto or security session.
+ * @param	op_type		Operation type.
+ * @param	sess_type	Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ * @return
+ *   - On success return 0.
+ *   - On failure return negative integer.
+ */
+typedef int (*cryptodev_session_event_mdata_set_t)(
+	struct rte_cryptodev *dev, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata);
+
 /** Crypto device operations function pointer table */
 struct rte_cryptodev_ops {
 	cryptodev_configure_t dev_configure;	/**< Configure device. */
@@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
 			/**< Initialize raw data path context data. */
 		};
 	};
+	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
+	/**< Set a Crypto or Security session even meta data. */
 };
 
 
@@ -603,6 +624,19 @@ void
 cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
 		     const struct rte_cryptodev *dev);
 
+/**
+ * Get session event meta data (aka *union rte_event_crypto_metadata*)
+ *
+ * @param	op            pointer to *rte_crypto_op* structure.
+ *
+ * @return
+ *  - On success, pointer to event crypto metadata
+ *  - On failure, NULL.
+ */
+__rte_internal
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
+
 static inline void *
 get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
 		uint8_t driver_id) {
@@ -637,6 +671,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
 	uint16_t user_data_sz;
 	/**< Session user data will be placed after sess_data */
 	uint8_t padding[3];
+	void *event_mdata;
+	/**< Event metadata (aka *union rte_event_crypto_metadata*) */
 	uint8_t sess_private_data[0];
 };
 
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 3500a2d470..5ebc423afa 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t dev_id, void *sess)
 
 	dev->dev_ops->asym_session_clear(dev, sess);
 
+	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata != NULL)
+		rte_free(((struct rte_cryptodev_asym_session *)sess)->event_mdata);
+
 	/* Return session to mempool */
 	sess_mp = rte_mempool_from_obj(sess);
 	rte_mempool_put(sess_mp, sess);
@@ -2259,6 +2262,47 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t dev_id, uint16_t qp_id,
 			sess_type, session_ctx, is_update);
 }
 
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata,
+	uint16_t size)
+{
+	struct rte_cryptodev *dev;
+
+	if (sess == NULL || ev_mdata == NULL)
+		return -EINVAL;
+
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		goto skip_pmd_op;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (dev->dev_ops->session_ev_mdata_set == NULL)
+		goto skip_pmd_op;
+
+	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
+			sess_type, ev_mdata);
+
+skip_pmd_op:
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
+		return rte_cryptodev_sym_session_set_user_data(sess, ev_mdata,
+				size);
+	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		struct rte_cryptodev_asym_session *s = sess;
+
+		if (s->event_mdata == NULL) {
+			s->event_mdata = rte_malloc(NULL, size, 0);
+			if (s->event_mdata == NULL)
+				return -ENOMEM;
+		}
+		rte_memcpy(s->event_mdata, ev_mdata, size);
+
+		return 0;
+	} else
+		return -ENOTSUP;
+}
+
 uint32_t
 rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx,
 	struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs,
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 45d33f4a50..2c2c2edeb7 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -1269,6 +1269,28 @@ __rte_experimental
 int
 rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
 
+/**
+ * Set session event meta data
+ *
+ * @param	dev_id		The device identifier.
+ * @param	sess            Crypto or security session.
+ * @param	op_type         Operation type.
+ * @param	sess_type       Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ * @param	size            Size of ev_mdata.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+__rte_experimental
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata, uint16_t size);
+
 /**
  * Union of different crypto session types, including session-less xform
  * pointer.
diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map
index c7c5aefceb..f0abfaa47d 100644
--- a/lib/cryptodev/version.map
+++ b/lib/cryptodev/version.map
@@ -105,6 +105,9 @@ EXPERIMENTAL {
 	rte_cryptodev_asym_session_pool_create;
 	rte_cryptodev_asym_session_set_user_data;
 	__rte_cryptodev_trace_asym_session_pool_create;
+
+	#added in 22.07
+	rte_cryptodev_session_event_mdata_set;
 };
 
 INTERNAL {
@@ -123,5 +126,6 @@ INTERNAL {
 	rte_cryptodev_pmd_parse_input_args;
 	rte_cryptodev_pmd_probing_finish;
 	rte_cryptodev_pmd_release_device;
+	rte_cryptodev_session_event_mdata_get;
 	rte_cryptodevs;
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 2/7] crypto/cnxk: add event metadata set operation
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
  2022-05-01 19:24       ` [PATCH v4 1/7] cryptodev: add APIs to get/set " Akhil Goyal
@ 2022-05-01 19:24       ` Akhil Goyal
  2022-05-02 11:07         ` Gujjar, Abhinandan S
  2022-05-01 19:24       ` [PATCH v4 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
                         ` (6 subsequent siblings)
  8 siblings, 1 reply; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

From: Volodymyr Fialko <vfialko@marvell.com>

Added cryptodev operation for setting event crypto
metadata for all supported sessions - sym/asym/security.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++---
 drivers/crypto/cnxk/cn10k_ipsec.h         |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 138 ++++++++++++++++++---
 drivers/crypto/cnxk/cn9k_ipsec.h          |   2 +
 drivers/crypto/cnxk/cnxk_ae.h             |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  18 ---
 drivers/crypto/cnxk/cnxk_se.h             |   2 +
 7 files changed, 255 insertions(+), 53 deletions(-)

diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
index c4d5d039ec..01aa0d6870 100644
--- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
@@ -264,30 +264,136 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count + i;
 }
 
-uint16_t
-cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				      void *sess,
+				      enum rte_crypto_op_type op_type,
+				      enum rte_crypto_op_sess_type sess_type,
+				      void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
-	uint64_t lmt_base, lmt_arg;
-	struct cpt_inst_s *inst;
 	struct cnxk_cpt_qp *qp;
 	uint8_t cdev_id;
-	uint16_t lmt_id;
-	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	int16_t qp_id;
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn10k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn10k_ca_meta_info_extract(struct rte_crypto_op *op,
+			 struct cnxk_cpt_qp **qp, uint64_t *w2)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			*w2 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn10k_cryptodev_driver_id);
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata *)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			*w2 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	uint64_t lmt_base, lmt_arg, w2;
+	struct cpt_inst_s *inst;
+	struct cnxk_cpt_qp *qp;
+	uint16_t lmt_id;
+	int ret;
+
+	ret = cn10k_ca_meta_info_extract(op, &qp, &w2);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -316,9 +422,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst->w0.u64 = 0;
 	inst->res_addr = (uint64_t)&infl_req->res;
-	inst->w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
+	inst->w2.u64 = w2;
 	inst->w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -327,7 +431,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst->w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id;
@@ -592,4 +696,6 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set,
 };
diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h b/drivers/crypto/cnxk/cn10k_ipsec.h
index 647a71cdd5..1c1d904799 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec.h
@@ -20,6 +20,8 @@ struct cn10k_ipsec_sa {
 	uint16_t iv_offset;
 	uint8_t iv_length;
 	bool is_outbound;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 
 	/**
 	 * End of SW mutable area
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index d3d441cb24..98fa97ef01 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -316,28 +316,134 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count;
 }
 
-uint16_t
-cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				     void *sess,
+				     enum rte_crypto_op_type op_type,
+				     enum rte_crypto_op_sess_type sess_type,
+				     void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
 	struct cnxk_cpt_qp *qp;
-	struct cpt_inst_s inst;
 	uint8_t cdev_id;
 	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn9k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn9k_ca_meta_info_extract(struct rte_crypto_op *op,
+			struct cnxk_cpt_qp **qp, struct cpt_inst_s *inst)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			inst->w2.u64 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn9k_cryptodev_driver_id);
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata *)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			inst->w2.u64 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	struct cnxk_cpt_qp *qp;
+	struct cpt_inst_s inst;
+	int ret;
+
+	ret = cn9k_ca_meta_info_extract(op, &qp, &inst);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -362,9 +468,6 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst.w0.u64 = 0;
 	inst.res_addr = (uint64_t)&infl_req->res;
-	inst.w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
 	inst.w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -373,7 +476,7 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst.w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	cn9k_cpt_inst_submit(&inst, qp->lmtline.lmt_base, qp->lmtline.io_addr);
@@ -613,4 +716,7 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set,
+
 };
diff --git a/drivers/crypto/cnxk/cn9k_ipsec.h b/drivers/crypto/cnxk/cn9k_ipsec.h
index f3acad561b..499dbc2782 100644
--- a/drivers/crypto/cnxk/cn9k_ipsec.h
+++ b/drivers/crypto/cnxk/cn9k_ipsec.h
@@ -42,6 +42,8 @@ struct cn9k_ipsec_sa {
 	struct cnxk_on_ipsec_ar ar;
 	/** Anti replay window size */
 	uint32_t replay_win_sz;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 };
 
 struct cn9k_sec_session {
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 01ccfcd334..10854c79c8 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -22,6 +22,8 @@ struct cnxk_ae_sess {
 	uint64_t *cnxk_fpm_iova;
 	struct roc_ae_ec_group **ec_grp;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 };
 
 static __rte_always_inline void
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
index ab0f00ee7c..7ece0214dc 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
@@ -125,24 +125,6 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
 			struct rte_cryptodev_asym_session *sess);
 void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
 
-static inline union rte_event_crypto_metadata *
-cnxk_event_crypto_mdata_get(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-			op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata
-				    *)((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 static __rte_always_inline void
 pending_queue_advance(uint64_t *index, const uint64_t mask)
 {
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index ce7ca2eda9..a339b80a87 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -33,6 +33,8 @@ struct cnxk_se_sess {
 	uint16_t auth_iv_offset;
 	uint32_t salt;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 	struct roc_se_ctx roc_se_ctx;
 } __rte_cache_aligned;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 3/7] crypto/octeontx: use new API for event metadata
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
  2022-05-01 19:24       ` [PATCH v4 1/7] cryptodev: add APIs to get/set " Akhil Goyal
  2022-05-01 19:24       ` [PATCH v4 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
@ 2022-05-01 19:24       ` Akhil Goyal
  2022-05-01 19:24       ` [PATCH v4 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
                         ` (5 subsequent siblings)
  8 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata can be used
directly instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index ddb1266c3c..d5851d9987 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -684,24 +684,6 @@ submit_request_to_sso(struct ssows *ws, uintptr_t req,
 	ssovf_store_pair(add_work, req, ws->grps[rsp_info->queue_id]);
 }
 
-static inline union rte_event_crypto_metadata *
-get_event_crypto_mdata(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-							   op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata *)
-			((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 uint16_t __rte_hot
 otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 {
@@ -712,7 +694,7 @@ otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 	uint8_t op_type, cdev_id;
 	uint16_t qp_id;
 
-	ec_mdata = get_event_crypto_mdata(op);
+	ec_mdata = rte_cryptodev_session_event_mdata_get(op);
 	if (unlikely(ec_mdata == NULL)) {
 		rte_errno = EINVAL;
 		return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 4/7] test/event: use new API to set event crypto metadata
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
                         ` (2 preceding siblings ...)
  2022-05-01 19:24       ` [PATCH v4 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
@ 2022-05-01 19:24       ` Akhil Goyal
  2022-05-01 19:24       ` [PATCH v4 5/7] eventdev: use new API to get " Akhil Goyal
                         ` (4 subsequent siblings)
  8 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

Used the new API rte_cryptodev_set_session_event_mdata to set
event crypto metadata from the applications (app/test and
app/test-eventdev) instead of using session userdata.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
---
 app/test-eventdev/test_perf_common.c |  8 ++++++--
 app/test/test_event_crypto_adapter.c | 12 ++++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9d1f4a4567..0378607cda 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -835,8 +835,12 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 					return -ENOMEM;
 
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_sym_session_set_user_data(
-					crypto_sess, &m_data, sizeof(m_data));
+				rte_cryptodev_session_event_mdata_set(cdev_id,
+						crypto_sess,
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data, sizeof(m_data));
+
 				p->ca.crypto_sess[flow_id] = crypto_sess;
 			}
 
diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 688520db4e..9904206735 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -227,8 +227,10 @@ test_op_forward_mode(uint8_t session_less)
 			m_data.request_info.queue_pair_id =
 				request_info.queue_pair_id;
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
 		}
 
 		rte_crypto_op_attach_sym_session(op, sess);
@@ -416,8 +418,10 @@ test_op_new_mode(uint8_t session_less)
 		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
 			/* Fill in private user data information */
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
 		}
 		ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess,
 				&cipher_xform, params.session_priv_mpool);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 5/7] eventdev: use new API to get event crypto metadata
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
                         ` (3 preceding siblings ...)
  2022-05-01 19:24       ` [PATCH v4 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
@ 2022-05-01 19:24       ` Akhil Goyal
  2022-05-01 19:24       ` [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
                         ` (3 subsequent siblings)
  8 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata is used
instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
---
 lib/eventdev/rte_event_crypto_adapter.c | 55 ++++++-------------------
 1 file changed, 12 insertions(+), 43 deletions(-)

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index f624f50187..7c695176f4 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -457,43 +457,22 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
-		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					crypto_op->sym->session);
-			if (m_data == NULL) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
+		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
+		if (m_data == NULL) {
+			rte_pktmbuf_free(crypto_op->sym->m_src);
+			rte_crypto_op_free(crypto_op);
+			continue;
+		}
 
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else if (crypto_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				crypto_op->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)crypto_op +
-					crypto_op->private_data_offset);
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else {
+		cdev_id = m_data->request_info.cdev_id;
+		qp_id = m_data->request_info.queue_pair_id;
+		qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
+		if (!qp_info->qp_enabled) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
 			rte_crypto_op_free(crypto_op);
 			continue;
 		}
+		eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
 
 		if (eca_circular_buffer_batch_ready(&qp_info->cbuf)) {
 			ret = eca_circular_buffer_flush_to_cdev(&qp_info->cbuf,
@@ -636,17 +615,7 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 	for (i = 0; i < num; i++) {
 		struct rte_event *ev = &events[nb_ev++];
 
-		m_data = NULL;
-		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					ops[i]->sym->session);
-		} else if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				ops[i]->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)ops[i] +
-				  ops[i]->private_data_offset);
-		}
-
+		m_data = rte_cryptodev_session_event_mdata_get(ops[i]);
 		if (unlikely(m_data == NULL)) {
 			rte_pktmbuf_free(ops[i]->sym->m_src);
 			rte_crypto_op_free(ops[i]);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
                         ` (4 preceding siblings ...)
  2022-05-01 19:24       ` [PATCH v4 5/7] eventdev: use new API to get " Akhil Goyal
@ 2022-05-01 19:24       ` Akhil Goyal
  2022-05-02 11:08         ` Gujjar, Abhinandan S
  2022-05-01 19:24       ` [PATCH v4 7/7] test-eventdev: support asym ops " Akhil Goyal
                         ` (2 subsequent siblings)
  8 siblings, 1 reply; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang

Test app is updated to add cases for asymmetric crypto
sessions for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 app/test/test_event_crypto_adapter.c | 499 ++++++++++++++++++++++++++-
 1 file changed, 493 insertions(+), 6 deletions(-)

diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 9904206735..2ecc7e2cea 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -6,6 +6,7 @@
 #include "test.h"
 #include <string.h>
 #include <rte_common.h>
+#include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
@@ -67,12 +68,97 @@ static const uint8_t text_64B[] = {
 	0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
 	0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c
 };
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 struct event_crypto_adapter_test_params {
 	struct rte_mempool *mbuf_pool;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *asym_op_mpool;
 	struct rte_mempool *session_mpool;
 	struct rte_mempool *session_priv_mpool;
+	struct rte_mempool *asym_sess_mpool;
 	struct rte_cryptodev_config *config;
 	uint8_t crypto_event_port_id;
 	uint8_t internal_port_op_fwd;
@@ -134,11 +220,24 @@ send_recv_ev(struct rte_event *ev)
 		rte_pause();
 
 	op = recv_ev.event_ptr;
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(op->sym->m_src);
+		rte_pktmbuf_free(op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(op);
 
 	return TEST_SUCCESS;
@@ -348,6 +447,170 @@ test_session_with_op_forward_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_forward_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	struct rte_event ev;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op,
+		"Failed to allocate asymmetric crypto operation struct\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		/* Create Crypto session*/
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.request_info.cdev_id = request_info.cdev_id;
+			m_data.request_info.queue_pair_id =
+				request_info.queue_pair_id;
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.request_info.cdev_id = request_info.cdev_id;
+		m_data.request_info.queue_pair_id = request_info.queue_pair_id;
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+	/* Fill in event info and update event_ptr with rte_crypto_op */
+	memset(&ev, 0, sizeof(ev));
+	ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
+	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	ev.flow_id = 0xAABB;
+	ev.event_ptr = op;
+
+	ret = send_recv_ev(&ev);
+	TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
+				"crypto adapter\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+
+static int
+test_asym_sessionless_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(1);
+}
+
+static int
+test_asym_session_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID
+				), "Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(0);
+}
+
 static int
 send_op_recv_ev(struct rte_crypto_op *op)
 {
@@ -365,11 +628,24 @@ send_op_recv_ev(struct rte_crypto_op *op)
 		rte_pause();
 
 	recv_op = ev.event_ptr;
+	if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = recv_op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = recv_op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(recv_op->sym->m_src);
+		rte_pktmbuf_free(recv_op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(recv_op);
 
 	return TEST_SUCCESS;
@@ -505,16 +781,169 @@ test_session_with_op_new_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_new_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+
+	ret = send_op_recv_ev(op);
+	TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_asym_sessionless_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	/* start the event crypto adapter */
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(1);
+}
+
+static int
+test_asym_session_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(0);
+}
+
 static int
 configure_cryptodev(void)
 {
+	const struct rte_cryptodev_capabilities *capability;
 	struct rte_cryptodev_qp_conf qp_conf;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_info info;
 	unsigned int session_size;
+	unsigned int i = 0;
 	uint8_t nb_devs;
 	int ret;
 
+
 	params.mbuf_pool = rte_pktmbuf_pool_create(
 			"CRYPTO_ADAPTER_MBUFPOOL",
 			NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
@@ -582,6 +1011,33 @@ configure_cryptodev(void)
 			"session mempool allocation failed\n");
 
 	rte_cryptodev_info_get(TEST_CDEV_ID, &info);
+
+	while ((capability = &info.capabilities[i++])->op !=
+			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		if (capability->op == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+			params.asym_op_mpool = rte_crypto_op_pool_create(
+				"EVENT_CRYPTO_ASYM_OP_POOL",
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+				NUM_MBUFS, MBUF_CACHE_SIZE,
+				(DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform)) +
+				sizeof(union rte_event_crypto_metadata),
+				rte_socket_id());
+			TEST_ASSERT_NOT_NULL(params.asym_op_mpool,
+					"Can't create CRYPTO_ASYM_OP_POOL\n");
+
+			params.asym_sess_mpool =
+				rte_cryptodev_asym_session_pool_create(
+					"CRYPTO_AD_ASYM_SESS_MP",
+					MAX_NB_SESSIONS, 0,
+					sizeof(union rte_event_crypto_metadata),
+					SOCKET_ID_ANY);
+			TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
+				"asym session mempool allocation failed\n");
+			break;
+		}
+	}
+
 	conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	conf.socket_id = SOCKET_ID_ANY;
 	conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
@@ -960,6 +1416,21 @@ crypto_teardown(void)
 		params.session_priv_mpool = NULL;
 	}
 
+	/* Free asym session mempool */
+	if (params.asym_sess_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count %u\n",
+		rte_mempool_avail_count(params.asym_sess_mpool));
+		rte_mempool_free(params.asym_sess_mpool);
+		params.asym_sess_mpool = NULL;
+	}
+	/* Free asym ops mempool */
+	if (params.asym_op_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL count %u\n",
+		rte_mempool_avail_count(params.asym_op_mpool));
+		rte_mempool_free(params.asym_op_mpool);
+		params.asym_op_mpool = NULL;
+	}
+
 	/* Free ops mempool */
 	if (params.op_mpool != NULL) {
 		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL count %u\n",
@@ -1016,6 +1487,22 @@ static struct unit_test_suite functional_testsuite = {
 				test_crypto_adapter_stop,
 				test_sessionless_with_op_new_mode),
 
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_new_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_new_mode),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v4 7/7] test-eventdev: support asym ops for crypto adapter
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
                         ` (5 preceding siblings ...)
  2022-05-01 19:24       ` [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
@ 2022-05-01 19:24       ` Akhil Goyal
  2022-05-02 11:08       ` [PATCH v4 0/7] Add new cryptodev op for event metadata Gujjar, Abhinandan S
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
  8 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-01 19:24 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

Test eventdev app is updated to add new option for asymmetric
crypto ops for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
---
 app/test-eventdev/evt_common.h       |   2 +
 app/test-eventdev/evt_options.c      |  17 ++
 app/test-eventdev/evt_options.h      |   4 +
 app/test-eventdev/test_perf_atq.c    |  12 +-
 app/test-eventdev/test_perf_common.c | 250 +++++++++++++++++++++++----
 app/test-eventdev/test_perf_common.h |  45 +++--
 app/test-eventdev/test_perf_queue.c  |  12 +-
 doc/guides/tools/testeventdev.rst    |   5 +
 8 files changed, 284 insertions(+), 63 deletions(-)

diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index 2f301a7e79..196eca8bd0 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -6,6 +6,7 @@
 #define _EVT_COMMON_
 
 #include <rte_common.h>
+#include <rte_crypto.h>
 #include <rte_debug.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_eventdev.h>
@@ -80,6 +81,7 @@ struct evt_options {
 	uint64_t optm_timer_tick_nsec;
 	enum evt_prod_type prod_type;
 	enum rte_event_crypto_adapter_mode crypto_adptr_mode;
+	enum rte_crypto_op_type crypto_op_type;
 };
 
 static inline bool
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index d3c704d2b3..8326734b64 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -38,6 +38,7 @@ evt_options_default(struct evt_options *opt)
 	opt->eth_queues = 1;
 	opt->vector_size = 64;
 	opt->vector_tmo_nsec = 100E3;
+	opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
 }
 
 typedef int (*option_parser_t)(struct evt_options *opt,
@@ -142,6 +143,18 @@ evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
 	return ret;
 }
 
+static int
+evt_parse_crypto_op_type(struct evt_options *opt, const char *arg)
+{
+	uint8_t op_type;
+	int ret;
+
+	ret = parser_read_uint8(&op_type, arg);
+	opt->crypto_op_type = op_type ? RTE_CRYPTO_OP_TYPE_ASYMMETRIC :
+					RTE_CRYPTO_OP_TYPE_SYMMETRIC;
+	return ret;
+}
+
 static int
 evt_parse_test_name(struct evt_options *opt, const char *arg)
 {
@@ -368,6 +381,8 @@ usage(char *program)
 		"\t--expiry_nsec      : event timer expiry ns.\n"
 		"\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
 		"\t                      1 for OP_FORWARD mode.\n"
+		"\t--crypto_op_type   : 0 for SYM ops (default) and\n"
+		"\t                     1 for ASYM ops.\n"
 		"\t--mbuf_sz          : packet mbuf size.\n"
 		"\t--max_pkt_sz       : max packet size.\n"
 		"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -442,6 +457,7 @@ static struct option lgopts[] = {
 	{ EVT_PROD_TIMERDEV,       0, 0, 0 },
 	{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
 	{ EVT_CRYPTO_ADPTR_MODE,   1, 0, 0 },
+	{ EVT_CRYPTO_OP_TYPE,	   1, 0, 0 },
 	{ EVT_NB_TIMERS,           1, 0, 0 },
 	{ EVT_NB_TIMER_ADPTRS,     1, 0, 0 },
 	{ EVT_TIMER_TICK_NSEC,     1, 0, 0 },
@@ -484,6 +500,7 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
 		{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
 		{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
 		{ EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
+		{ EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type},
 		{ EVT_NB_TIMERS, evt_parse_nb_timers},
 		{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
 		{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 2231c58801..f23fb8a511 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -38,6 +38,7 @@
 #define EVT_PROD_TIMERDEV        ("prod_type_timerdev")
 #define EVT_PROD_TIMERDEV_BURST  ("prod_type_timerdev_burst")
 #define EVT_CRYPTO_ADPTR_MODE	 ("crypto_adptr_mode")
+#define EVT_CRYPTO_OP_TYPE	 ("crypto_op_type")
 #define EVT_NB_TIMERS            ("nb_timers")
 #define EVT_NB_TIMER_ADPTRS      ("nb_timer_adptrs")
 #define EVT_TIMER_TICK_NSEC      ("timer_tick_nsec")
@@ -298,6 +299,9 @@ evt_dump_producer_type(struct evt_options *opt)
 			 "Event crypto adapter producers");
 		evt_dump("crypto adapter mode", "%s",
 			 opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+		evt_dump("crypto op type", "%s",
+			 (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) ?
+			 "SYMMETRIC" : "ASYMMETRIC");
 		evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
 		break;
 	}
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 67ff681666..6a2aa86fd2 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -53,11 +53,13 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 0378607cda..f2da6fd74c 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -7,6 +7,89 @@
 #include "test_perf_common.h"
 
 #define NB_CRYPTODEV_DESCRIPTORS 128
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 int
 perf_test_result(struct evt_test *test, struct evt_options *opt)
@@ -277,12 +360,10 @@ perf_event_timer_producer_burst(void *arg)
 static inline void
 crypto_adapter_enq_op_new(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	struct test_perf *t = p->t;
 	const uint32_t nb_flows = t->nb_flows;
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
-	struct rte_crypto_sym_op *sym_op;
 	struct evt_options *opt = t->opt;
 	uint16_t qp_id = p->ca.cdev_qp_id;
 	uint8_t cdev_id = p->ca.cdev_id;
@@ -300,22 +381,39 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
 
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
-		       t->done == false)
+				t->done == false)
 			rte_pause();
 
 		count++;
@@ -325,7 +423,6 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 static inline void
 crypto_adapter_enq_op_fwd(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	const uint8_t dev_id = p->dev_id;
 	const uint8_t port = p->port_id;
 	struct test_perf *t = p->t;
@@ -333,7 +430,6 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
 	struct evt_options *opt = t->opt;
-	struct rte_crypto_sym_op *sym_op;
 	uint32_t flow_counter = 0;
 	struct rte_crypto_op *op;
 	struct rte_event ev;
@@ -354,19 +450,37 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
+
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		ev.event_ptr = op;
 
 		while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
@@ -729,6 +843,37 @@ cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
 	return sess;
 }
 
+static void *
+cryptodev_asym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform;
+	void *sess;
+
+	xform.next = NULL;
+	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform.xform_type;
+	capability = rte_cryptodev_asym_capability_get(p->ca.cdev_id, &cap_idx);
+	if (capability == NULL) {
+		evt_err("Device doesn't support MODEX. Test Skipped\n");
+		return NULL;
+	}
+
+	xform.modex.modulus.data = modex_test_case.modulus.data;
+	xform.modex.modulus.length = modex_test_case.modulus.len;
+	xform.modex.exponent.data = modex_test_case.exponent.data;
+	xform.modex.exponent.length = modex_test_case.exponent.len;
+
+	if (rte_cryptodev_asym_session_create(p->ca.cdev_id, &xform,
+			t->ca_asym_sess_pool, &sess)) {
+		evt_err("Failed to create asym session");
+		return NULL;
+	}
+
+	return sess;
+}
+
 int
 perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 				uint8_t stride, uint8_t nb_queues,
@@ -804,7 +949,6 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 
 		prod = 0;
 		for (; port < perf_nb_event_ports(opt); port++) {
-			struct rte_cryptodev_sym_session *crypto_sess;
 			union rte_event_crypto_metadata m_data;
 			struct prod_data *p = &t->prod[port];
 			uint32_t flow_id;
@@ -820,7 +964,7 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			p->ca.cdev_id = cdev_id;
 			p->ca.cdev_qp_id = qp_id;
 			p->ca.crypto_sess = rte_zmalloc_socket(
-				NULL, sizeof(crypto_sess) * t->nb_flows,
+				NULL, sizeof(void *) * t->nb_flows,
 				RTE_CACHE_LINE_SIZE, opt->socket_id);
 			p->t = t;
 
@@ -830,18 +974,36 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			m_data.response_info.queue_id = p->queue_id;
 
 			for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
-				crypto_sess = cryptodev_sym_sess_create(p, t);
-				if (crypto_sess == NULL)
-					return -ENOMEM;
-
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_session_event_mdata_set(cdev_id,
-						crypto_sess,
+				if (opt->crypto_op_type ==
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					struct rte_cryptodev_sym_session *sess;
+
+					sess = cryptodev_sym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
 						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 						RTE_CRYPTO_OP_WITH_SESSION,
 						&m_data, sizeof(m_data));
+					p->ca.crypto_sess[flow_id] = sess;
+				} else {
+					void *sess;
 
-				p->ca.crypto_sess[flow_id] = crypto_sess;
+					sess = cryptodev_asym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
+						RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data, sizeof(m_data));
+					p->ca.crypto_sess[flow_id] = sess;
+				}
 			}
 
 			conf.event_port_cfg |=
@@ -1123,14 +1285,24 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	t->ca_op_pool = rte_crypto_op_pool_create(
-		"crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
-		128, 0, rte_socket_id());
+		"crypto_op_pool", opt->crypto_op_type, opt->pool_sz,
+		128, sizeof(union rte_event_crypto_metadata),
+		rte_socket_id());
 	if (t->ca_op_pool == NULL) {
 		evt_err("Failed to create crypto op pool");
 		return -ENOMEM;
 	}
 
 	nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+	t->ca_asym_sess_pool = rte_cryptodev_asym_session_pool_create(
+		"ca_asym_sess_pool", nb_sessions, 0,
+		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+	if (t->ca_asym_sess_pool == NULL) {
+		evt_err("Failed to create sym session pool");
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
 		"ca_sess_pool", nb_sessions, 0, 0,
 		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
@@ -1217,6 +1389,7 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 
 	return ret;
 }
@@ -1258,6 +1431,7 @@ perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 }
 
 int
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index ea0907d61a..5651832cc9 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -40,7 +40,7 @@ struct worker_data {
 struct crypto_adptr_data {
 	uint8_t cdev_id;
 	uint16_t cdev_qp_id;
-	struct rte_cryptodev_sym_session **crypto_sess;
+	void **crypto_sess;
 };
 struct prod_data {
 	uint8_t dev_id;
@@ -70,6 +70,7 @@ struct test_perf {
 	struct rte_mempool *ca_op_pool;
 	struct rte_mempool *ca_sess_pool;
 	struct rte_mempool *ca_sess_priv_pool;
+	struct rte_mempool *ca_asym_sess_pool;
 } __rte_cache_aligned;
 
 struct perf_elt {
@@ -111,8 +112,6 @@ perf_process_last_stage(struct rte_mempool *const pool,
 		struct rte_event *const ev, struct worker_data *const w,
 		void *bufs[], int const buf_sz, uint8_t count)
 {
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -120,9 +119,19 @@ perf_process_last_stage(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)ev->event_ptr)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		struct rte_crypto_op *op = ev->event_ptr;
+
+		rte_free(op->asym->modex.result.data);
+		rte_crypto_op_free(op);
+	} else {
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		}
 	}
 	return count;
 }
@@ -135,8 +144,6 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	uint64_t latency;
 	struct perf_elt *const m = ev->event_ptr;
 
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -144,15 +151,23 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		latency = rte_get_timer_cycles() - m->timestamp;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)m)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		rte_free(((struct rte_crypto_op *)m)->asym->modex.result.data);
+		rte_crypto_op_free((struct rte_crypto_op *)m);
 	} else {
-		latency = rte_get_timer_cycles() - m->timestamp;
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			latency = rte_get_timer_cycles() - m->timestamp;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		} else {
+			latency = rte_get_timer_cycles() - m->timestamp;
+		}
+
+		w->latency += latency;
 	}
-
-	w->latency += latency;
 	return count;
 }
 
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index dcf6d82947..631a39f727 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -55,11 +55,13 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index f7d813226d..a8e02d57a4 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -157,6 +157,11 @@ The following are the application command-line options:
         Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
         OP_FORWARD mode.
 
+* ``--crypto_op_type``
+
+        Set crypto operation type. Use 0 for symmetric crypto ops (default)
+        and 1 for asymmetric crypto ops.
+
 * ``--mbuf_sz``
 
        Set packet mbuf size. Can be used to configure Jumbo Frames. Only
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v4 1/7] cryptodev: add APIs to get/set event metadata
  2022-05-01 19:24       ` [PATCH v4 1/7] cryptodev: add APIs to get/set " Akhil Goyal
@ 2022-05-02  9:01         ` Anoob Joseph
  2022-05-02 11:06         ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Anoob Joseph @ 2022-05-02  9:01 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: Jerin Jacob Kollanukkaran, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, Volodymyr Fialko, Akhil Goyal, Fan Zhang

Hi Akhil,

Minor nit inline. 

With that addressed,
Series Acked-by: Anoob Joseph <anoobj@marvell.com>

Thanks,
Anoob

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Monday, May 2, 2022 12:55 AM
> To: dev@dpdk.org
> Cc: Anoob Joseph <anoobj@marvell.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; abhinandan.gujjar@intel.com;
> jay.jayatheerthan@intel.com; narender.vangati@intel.com; Volodymyr
> Fialko <vfialko@marvell.com>; Akhil Goyal <gakhil@marvell.com>; Fan Zhang
> <roy.fan.zhang@intel.com>
> Subject: [PATCH v4 1/7] cryptodev: add APIs to get/set event metadata
> 
> From: Volodymyr Fialko <vfialko@marvell.com>
> 
> Currently, crypto session userdata is used to set event crypto metadata from
> the application and the driver is dereferencing it in driver which is not correct.
> User data is meant to be opaque to the driver.
> To support this, new API is added to get and set event crypto metadata. The
> new API, rte_cryptodev_set_session_event_mdata,
> allows setting event metadata in session private data which is filled inside
> PMD using a new cryptodev op. This operation can be performed on any of
> the PMD supported sessions (sym/asym/security).
> For SW abstraction of event crypto adapter to be used by eventdev library, a
> new field is added in asymmetric crypto session for now and for symmetric
> case, current implementation of using userdata is used. Symmetric cases
> cannot be fixed now, as it will be ABI breakage which will be resolved in DPDK
> 22.11.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  lib/cryptodev/cryptodev_pmd.c | 16 +++++++++++++
> lib/cryptodev/cryptodev_pmd.h | 36 ++++++++++++++++++++++++++++
> lib/cryptodev/rte_cryptodev.c | 44
> +++++++++++++++++++++++++++++++++++
>  lib/cryptodev/rte_cryptodev.h | 22 ++++++++++++++++++
>  lib/cryptodev/version.map     |  4 ++++
>  5 files changed, 122 insertions(+)
> 

[snip]
 
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
> index 3500a2d470..5ebc423afa 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t dev_id,
> void *sess)
> 
>  	dev->dev_ops->asym_session_clear(dev, sess);
> 
> +	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata !=
> NULL)
> +		rte_free(((struct rte_cryptodev_asym_session *)sess)-
> >event_mdata);
> +

[Anoob] rte_free would do a NULL check. So the other NULL check may not be required.


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v4 1/7] cryptodev: add APIs to get/set event metadata
  2022-05-01 19:24       ` [PATCH v4 1/7] cryptodev: add APIs to get/set " Akhil Goyal
  2022-05-02  9:01         ` Anoob Joseph
@ 2022-05-02 11:06         ` Gujjar, Abhinandan S
  1 sibling, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-02 11:06 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko,
	Zhang, Roy Fan

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Monday, May 2, 2022 12:55 AM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>; Zhang, Roy Fan <roy.fan.zhang@intel.com>
> Subject: [PATCH v4 1/7] cryptodev: add APIs to get/set event metadata
> 
> From: Volodymyr Fialko <vfialko@marvell.com>
> 
> Currently, crypto session userdata is used to set event crypto metadata from
> the application and the driver is dereferencing it in driver which is not correct.
> User data is meant to be opaque to the driver.
> To support this, new API is added to get and set event crypto metadata. The
> new API, rte_cryptodev_set_session_event_mdata,
> allows setting event metadata in session private data which is filled inside PMD
> using a new cryptodev op. This operation can be performed on any of the PMD
> supported sessions (sym/asym/security).
> For SW abstraction of event crypto adapter to be used by eventdev library, a
> new field is added in asymmetric crypto session for now and for symmetric
> case, current implementation of using userdata is used. Symmetric cases cannot
> be fixed now, as it will be ABI breakage which will be resolved in DPDK 22.11.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  lib/cryptodev/cryptodev_pmd.c | 16 +++++++++++++
> lib/cryptodev/cryptodev_pmd.h | 36 ++++++++++++++++++++++++++++
> lib/cryptodev/rte_cryptodev.c | 44 +++++++++++++++++++++++++++++++++++
>  lib/cryptodev/rte_cryptodev.h | 22 ++++++++++++++++++
>  lib/cryptodev/version.map     |  4 ++++
>  5 files changed, 122 insertions(+)
> 
> diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
> index 739a0b3f34..1903ade388 100644
> --- a/lib/cryptodev/cryptodev_pmd.c
> +++ b/lib/cryptodev/cryptodev_pmd.c
> @@ -227,3 +227,19 @@ cryptodev_fp_ops_set(struct rte_crypto_fp_ops
> *fp_ops,
>  	fp_ops->qp.enq_cb = dev->enq_cbs;
>  	fp_ops->qp.deq_cb = dev->deq_cbs;
>  }
> +
> +void *
> +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op) {
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
> +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> +		return rte_cryptodev_sym_session_get_user_data(op->sym-
> >session);
> +	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
> +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> +		return op->asym->session->event_mdata;
> +	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> +			op->private_data_offset)
> +		return ((uint8_t *)op + op->private_data_offset);
> +	else
> +		return NULL;
> +}
> diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
> index 2b1ce2da2d..7a7d3ee3f1 100644
> --- a/lib/cryptodev/cryptodev_pmd.h
> +++ b/lib/cryptodev/cryptodev_pmd.h
> @@ -398,6 +398,25 @@ typedef int
> (*cryptodev_sym_configure_raw_dp_ctx_t)(
>  	enum rte_crypto_op_sess_type sess_type,
>  	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
> 
> +/**
> + * Typedef that the driver provided to set event crypto meta data.
> + *
> + * @param	dev		Crypto device pointer.
> + * @param	sess		Crypto or security session.
> + * @param	op_type		Operation type.
> + * @param	sess_type	Session type.
> + * @param	ev_mdata	Pointer to the event crypto meta data
> + *				(aka *union rte_event_crypto_metadata*)
> + * @return
> + *   - On success return 0.
> + *   - On failure return negative integer.
> + */
> +typedef int (*cryptodev_session_event_mdata_set_t)(
> +	struct rte_cryptodev *dev, void *sess,
> +	enum rte_crypto_op_type op_type,
> +	enum rte_crypto_op_sess_type sess_type,
> +	void *ev_mdata);
> +
>  /** Crypto device operations function pointer table */  struct
> rte_cryptodev_ops {
>  	cryptodev_configure_t dev_configure;	/**< Configure device. */
> @@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
>  			/**< Initialize raw data path context data. */
>  		};
>  	};
> +	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
> +	/**< Set a Crypto or Security session even meta data. */
>  };
> 
> 
> @@ -603,6 +624,19 @@ void
>  cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
>  		     const struct rte_cryptodev *dev);
> 
> +/**
> + * Get session event meta data (aka *union rte_event_crypto_metadata*)
> + *
> + * @param	op            pointer to *rte_crypto_op* structure.
> + *
> + * @return
> + *  - On success, pointer to event crypto metadata
> + *  - On failure, NULL.
> + */
> +__rte_internal
> +void *
> +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
> +
>  static inline void *
>  get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
>  		uint8_t driver_id) {
> @@ -637,6 +671,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
>  	uint16_t user_data_sz;
>  	/**< Session user data will be placed after sess_data */
>  	uint8_t padding[3];
> +	void *event_mdata;
> +	/**< Event metadata (aka *union rte_event_crypto_metadata*) */
>  	uint8_t sess_private_data[0];
>  };
> 
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index
> 3500a2d470..5ebc423afa 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t dev_id,
> void *sess)
> 
>  	dev->dev_ops->asym_session_clear(dev, sess);
> 
> +	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata != NULL)
> +		rte_free(((struct rte_cryptodev_asym_session *)sess)-
> >event_mdata);
> +
>  	/* Return session to mempool */
>  	sess_mp = rte_mempool_from_obj(sess);
>  	rte_mempool_put(sess_mp, sess);
> @@ -2259,6 +2262,47 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t
> dev_id, uint16_t qp_id,
>  			sess_type, session_ctx, is_update);
>  }
> 
> +int
> +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
> +	enum rte_crypto_op_type op_type,
> +	enum rte_crypto_op_sess_type sess_type,
> +	void *ev_mdata,
> +	uint16_t size)
> +{
> +	struct rte_cryptodev *dev;
> +
> +	if (sess == NULL || ev_mdata == NULL)
> +		return -EINVAL;
> +
> +	if (!rte_cryptodev_is_valid_dev(dev_id))
> +		goto skip_pmd_op;
> +
> +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> +	if (dev->dev_ops->session_ev_mdata_set == NULL)
> +		goto skip_pmd_op;
> +
> +	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
> +			sess_type, ev_mdata);
> +
> +skip_pmd_op:
> +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
> +		return rte_cryptodev_sym_session_set_user_data(sess,
> ev_mdata,
> +				size);
> +	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		struct rte_cryptodev_asym_session *s = sess;
> +
> +		if (s->event_mdata == NULL) {
> +			s->event_mdata = rte_malloc(NULL, size, 0);
> +			if (s->event_mdata == NULL)
> +				return -ENOMEM;
> +		}
> +		rte_memcpy(s->event_mdata, ev_mdata, size);
> +
> +		return 0;
> +	} else
> +		return -ENOTSUP;
> +}
> +
>  uint32_t
>  rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx,
>  	struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs, diff --
> git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index
> 45d33f4a50..2c2c2edeb7 100644
> --- a/lib/cryptodev/rte_cryptodev.h
> +++ b/lib/cryptodev/rte_cryptodev.h
> @@ -1269,6 +1269,28 @@ __rte_experimental  int
> rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
> 
> +/**
> + * Set session event meta data
> + *
> + * @param	dev_id		The device identifier.
> + * @param	sess            Crypto or security session.
> + * @param	op_type         Operation type.
> + * @param	sess_type       Session type.
> + * @param	ev_mdata	Pointer to the event crypto meta data
> + *				(aka *union rte_event_crypto_metadata*)
> + * @param	size            Size of ev_mdata.
> + *
> + * @return
> + *  - On success, zero.
> + *  - On failure, a negative value.
> + */
> +__rte_experimental
> +int
> +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
> +	enum rte_crypto_op_type op_type,
> +	enum rte_crypto_op_sess_type sess_type,
> +	void *ev_mdata, uint16_t size);
> +
>  /**
>   * Union of different crypto session types, including session-less xform
>   * pointer.
> diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index
> c7c5aefceb..f0abfaa47d 100644
> --- a/lib/cryptodev/version.map
> +++ b/lib/cryptodev/version.map
> @@ -105,6 +105,9 @@ EXPERIMENTAL {
>  	rte_cryptodev_asym_session_pool_create;
>  	rte_cryptodev_asym_session_set_user_data;
>  	__rte_cryptodev_trace_asym_session_pool_create;
> +
> +	#added in 22.07
> +	rte_cryptodev_session_event_mdata_set;
>  };
> 
>  INTERNAL {
> @@ -123,5 +126,6 @@ INTERNAL {
>  	rte_cryptodev_pmd_parse_input_args;
>  	rte_cryptodev_pmd_probing_finish;
>  	rte_cryptodev_pmd_release_device;
> +	rte_cryptodev_session_event_mdata_get;
>  	rte_cryptodevs;
>  };
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v4 2/7] crypto/cnxk: add event metadata set operation
  2022-05-01 19:24       ` [PATCH v4 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
@ 2022-05-02 11:07         ` Gujjar, Abhinandan S
  0 siblings, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-02 11:07 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko,
	Zhang, Roy Fan

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Monday, May 2, 2022 12:55 AM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>; Zhang, Roy Fan <roy.fan.zhang@intel.com>; Gujjar,
> Abhinandan S <abhinandan.gujjar@intel.com>
> Subject: [PATCH v4 2/7] crypto/cnxk: add event metadata set operation
> 
> From: Volodymyr Fialko <vfialko@marvell.com>
> 
> Added cryptodev operation for setting event crypto metadata for all supported
> sessions - sym/asym/security.
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
> Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
> ---
>  drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++---
>  drivers/crypto/cnxk/cn10k_ipsec.h         |   2 +
>  drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 138 ++++++++++++++++++---
>  drivers/crypto/cnxk/cn9k_ipsec.h          |   2 +
>  drivers/crypto/cnxk/cnxk_ae.h             |   2 +
>  drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  18 ---
>  drivers/crypto/cnxk/cnxk_se.h             |   2 +
>  7 files changed, 255 insertions(+), 53 deletions(-)
> 
> diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> index c4d5d039ec..01aa0d6870 100644
> --- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> +++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
> @@ -264,30 +264,136 @@ cn10k_cpt_enqueue_burst(void *qptr, struct
> rte_crypto_op **ops, uint16_t nb_ops)
>  	return count + i;
>  }
> 
> -uint16_t
> -cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> *op)
> +static int
> +cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev
> __rte_unused,
> +				      void *sess,
> +				      enum rte_crypto_op_type op_type,
> +				      enum rte_crypto_op_sess_type sess_type,
> +				      void *mdata)
>  {
> -	union rte_event_crypto_metadata *ec_mdata;
> -	struct cpt_inflight_req *infl_req;
> +	union rte_event_crypto_metadata *ec_mdata = mdata;
>  	struct rte_event *rsp_info;
> -	uint64_t lmt_base, lmt_arg;
> -	struct cpt_inst_s *inst;
>  	struct cnxk_cpt_qp *qp;
>  	uint8_t cdev_id;
> -	uint16_t lmt_id;
> -	uint16_t qp_id;
> -	int ret;
> -
> -	ec_mdata = cnxk_event_crypto_mdata_get(op);
> -	if (!ec_mdata) {
> -		rte_errno = EINVAL;
> -		return 0;
> -	}
> +	int16_t qp_id;
> +	uint64_t w2;
> 
> +	/* Get queue pair */
>  	cdev_id = ec_mdata->request_info.cdev_id;
>  	qp_id = ec_mdata->request_info.queue_pair_id;
>  	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
> +
> +	/* Prepare w2 */
>  	rsp_info = &ec_mdata->response_info;
> +	w2 = CNXK_CPT_INST_W2(
> +		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> +		rsp_info->sched_type, rsp_info->queue_id, 0);
> +
> +	/* Set meta according to session type */
> +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn10k_sec_session *priv;
> +			struct cn10k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(sess);
> +			sa = &priv->sa;
> +			sa->qp = qp;
> +			sa->inst.w2 = w2;
> +		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				sess, cn10k_cryptodev_driver_id);
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
> +			return -EINVAL;
> +	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess = sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static inline int
> +cn10k_ca_meta_info_extract(struct rte_crypto_op *op,
> +			 struct cnxk_cpt_qp **qp, uint64_t *w2) {
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn10k_sec_session *priv;
> +			struct cn10k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(op->sym-
> >sec_session);
> +			sa = &priv->sa;
> +			*qp = sa->qp;
> +			*w2 = sa->inst.w2;
> +		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				op->sym->session,
> cn10k_cryptodev_driver_id);
> +			*qp = priv->qp;
> +			*w2 = priv->cpt_inst_w2;
> +		} else {
> +			union rte_event_crypto_metadata *ec_mdata;
> +			struct rte_event *rsp_info;
> +			uint8_t cdev_id;
> +			uint16_t qp_id;
> +
> +			ec_mdata = (union rte_event_crypto_metadata *)
> +				((uint8_t *)op + op->private_data_offset);
> +			if (!ec_mdata)
> +				return -EINVAL;
> +			rsp_info = &ec_mdata->response_info;
> +			cdev_id = ec_mdata->request_info.cdev_id;
> +			qp_id = ec_mdata->request_info.queue_pair_id;
> +			*qp = rte_cryptodevs[cdev_id].data-
> >queue_pairs[qp_id];
> +			*w2 = CNXK_CPT_INST_W2(
> +				(RTE_EVENT_TYPE_CRYPTODEV << 28) |
> rsp_info->flow_id,
> +				rsp_info->sched_type, rsp_info->queue_id, 0);
> +		}
> +	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			asym_sess = op->asym->session;
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			*qp = priv->qp;
> +			*w2 = priv->cpt_inst_w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +uint16_t
> +cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> +*op) {
> +	struct cpt_inflight_req *infl_req;
> +	uint64_t lmt_base, lmt_arg, w2;
> +	struct cpt_inst_s *inst;
> +	struct cnxk_cpt_qp *qp;
> +	uint16_t lmt_id;
> +	int ret;
> +
> +	ret = cn10k_ca_meta_info_extract(op, &qp, &w2);
> +	if (unlikely(ret)) {
> +		rte_errno = EINVAL;
> +		return 0;
> +	}
> 
>  	if (unlikely(!qp->ca.enabled)) {
>  		rte_errno = EINVAL;
> @@ -316,9 +422,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  	infl_req->qp = qp;
>  	inst->w0.u64 = 0;
>  	inst->res_addr = (uint64_t)&infl_req->res;
> -	inst->w2.u64 = CNXK_CPT_INST_W2(
> -		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> -		rsp_info->sched_type, rsp_info->queue_id, 0);
> +	inst->w2.u64 = w2;
>  	inst->w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
> 
>  	if (roc_cpt_is_iq_full(&qp->lf)) {
> @@ -327,7 +431,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  		return 0;
>  	}
> 
> -	if (!rsp_info->sched_type)
> +	if (inst->w2.s.tt == RTE_SCHED_TYPE_ORDERED)
>  		roc_sso_hws_head_wait(tag_op);
> 
>  	lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id; @@ -592,4
> +696,6 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
>  	.asym_session_configure = cnxk_ae_session_cfg,
>  	.asym_session_clear = cnxk_ae_session_clear,
> 
> +	/* Event crypto ops */
> +	.session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set,
>  };
> diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h
> b/drivers/crypto/cnxk/cn10k_ipsec.h
> index 647a71cdd5..1c1d904799 100644
> --- a/drivers/crypto/cnxk/cn10k_ipsec.h
> +++ b/drivers/crypto/cnxk/cn10k_ipsec.h
> @@ -20,6 +20,8 @@ struct cn10k_ipsec_sa {
>  	uint16_t iv_offset;
>  	uint8_t iv_length;
>  	bool is_outbound;
> +	/** Queue pair */
> +	struct cnxk_cpt_qp *qp;
> 
>  	/**
>  	 * End of SW mutable area
> diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> index d3d441cb24..98fa97ef01 100644
> --- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> +++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
> @@ -316,28 +316,134 @@ cn9k_cpt_enqueue_burst(void *qptr, struct
> rte_crypto_op **ops, uint16_t nb_ops)
>  	return count;
>  }
> 
> -uint16_t
> -cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> *op)
> +static int
> +cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev
> __rte_unused,
> +				     void *sess,
> +				     enum rte_crypto_op_type op_type,
> +				     enum rte_crypto_op_sess_type sess_type,
> +				     void *mdata)
>  {
> -	union rte_event_crypto_metadata *ec_mdata;
> -	struct cpt_inflight_req *infl_req;
> +	union rte_event_crypto_metadata *ec_mdata = mdata;
>  	struct rte_event *rsp_info;
>  	struct cnxk_cpt_qp *qp;
> -	struct cpt_inst_s inst;
>  	uint8_t cdev_id;
>  	uint16_t qp_id;
> -	int ret;
> -
> -	ec_mdata = cnxk_event_crypto_mdata_get(op);
> -	if (!ec_mdata) {
> -		rte_errno = EINVAL;
> -		return 0;
> -	}
> +	uint64_t w2;
> 
> +	/* Get queue pair */
>  	cdev_id = ec_mdata->request_info.cdev_id;
>  	qp_id = ec_mdata->request_info.queue_pair_id;
>  	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
> +
> +	/* Prepare w2 */
>  	rsp_info = &ec_mdata->response_info;
> +	w2 = CNXK_CPT_INST_W2(
> +		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> +		rsp_info->sched_type, rsp_info->queue_id, 0);
> +
> +	/* Set meta according to session type */
> +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn9k_sec_session *priv;
> +			struct cn9k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(sess);
> +			sa = &priv->sa;
> +			sa->qp = qp;
> +			sa->inst.w2 = w2;
> +		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				sess, cn9k_cryptodev_driver_id);
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
> +			return -EINVAL;
> +	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess = sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			priv->qp = qp;
> +			priv->cpt_inst_w2 = w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static inline int
> +cn9k_ca_meta_info_extract(struct rte_crypto_op *op,
> +			struct cnxk_cpt_qp **qp, struct cpt_inst_s *inst) {
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
> +			struct cn9k_sec_session *priv;
> +			struct cn9k_ipsec_sa *sa;
> +
> +			priv = get_sec_session_private_data(op->sym-
> >sec_session);
> +			sa = &priv->sa;
> +			*qp = sa->qp;
> +			inst->w2.u64 = sa->inst.w2;
> +		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct cnxk_se_sess *priv;
> +
> +			priv = get_sym_session_private_data(
> +				op->sym->session, cn9k_cryptodev_driver_id);
> +			*qp = priv->qp;
> +			inst->w2.u64 = priv->cpt_inst_w2;
> +		} else {
> +			union rte_event_crypto_metadata *ec_mdata;
> +			struct rte_event *rsp_info;
> +			uint8_t cdev_id;
> +			uint16_t qp_id;
> +
> +			ec_mdata = (union rte_event_crypto_metadata *)
> +				((uint8_t *)op + op->private_data_offset);
> +			if (!ec_mdata)
> +				return -EINVAL;
> +			rsp_info = &ec_mdata->response_info;
> +			cdev_id = ec_mdata->request_info.cdev_id;
> +			qp_id = ec_mdata->request_info.queue_pair_id;
> +			*qp = rte_cryptodevs[cdev_id].data-
> >queue_pairs[qp_id];
> +			inst->w2.u64 = CNXK_CPT_INST_W2(
> +				(RTE_EVENT_TYPE_CRYPTODEV << 28) |
> rsp_info->flow_id,
> +				rsp_info->sched_type, rsp_info->queue_id, 0);
> +		}
> +	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_cryptodev_asym_session *asym_sess;
> +			struct cnxk_ae_sess *priv;
> +
> +			asym_sess = op->asym->session;
> +			priv = (struct cnxk_ae_sess *)asym_sess-
> >sess_private_data;
> +			*qp = priv->qp;
> +			inst->w2.u64 = priv->cpt_inst_w2;
> +		} else
> +			return -EINVAL;
> +	} else
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +uint16_t
> +cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op
> +*op) {
> +	struct cpt_inflight_req *infl_req;
> +	struct cnxk_cpt_qp *qp;
> +	struct cpt_inst_s inst;
> +	int ret;
> +
> +	ret = cn9k_ca_meta_info_extract(op, &qp, &inst);
> +	if (unlikely(ret)) {
> +		rte_errno = EINVAL;
> +		return 0;
> +	}
> 
>  	if (unlikely(!qp->ca.enabled)) {
>  		rte_errno = EINVAL;
> @@ -362,9 +468,6 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  	infl_req->qp = qp;
>  	inst.w0.u64 = 0;
>  	inst.res_addr = (uint64_t)&infl_req->res;
> -	inst.w2.u64 = CNXK_CPT_INST_W2(
> -		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
> -		rsp_info->sched_type, rsp_info->queue_id, 0);
>  	inst.w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
> 
>  	if (roc_cpt_is_iq_full(&qp->lf)) {
> @@ -373,7 +476,7 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op,
> struct rte_crypto_op *op)
>  		return 0;
>  	}
> 
> -	if (!rsp_info->sched_type)
> +	if (inst.w2.s.tt == RTE_SCHED_TYPE_ORDERED)
>  		roc_sso_hws_head_wait(tag_op);
> 
>  	cn9k_cpt_inst_submit(&inst, qp->lmtline.lmt_base, qp-
> >lmtline.io_addr); @@ -613,4 +716,7 @@ struct rte_cryptodev_ops
> cn9k_cpt_ops = {
>  	.asym_session_configure = cnxk_ae_session_cfg,
>  	.asym_session_clear = cnxk_ae_session_clear,
> 
> +	/* Event crypto ops */
> +	.session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set,
> +
>  };
> diff --git a/drivers/crypto/cnxk/cn9k_ipsec.h
> b/drivers/crypto/cnxk/cn9k_ipsec.h
> index f3acad561b..499dbc2782 100644
> --- a/drivers/crypto/cnxk/cn9k_ipsec.h
> +++ b/drivers/crypto/cnxk/cn9k_ipsec.h
> @@ -42,6 +42,8 @@ struct cn9k_ipsec_sa {
>  	struct cnxk_on_ipsec_ar ar;
>  	/** Anti replay window size */
>  	uint32_t replay_win_sz;
> +	/** Queue pair */
> +	struct cnxk_cpt_qp *qp;
>  };
> 
>  struct cn9k_sec_session {
> diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
> index 01ccfcd334..10854c79c8 100644
> --- a/drivers/crypto/cnxk/cnxk_ae.h
> +++ b/drivers/crypto/cnxk/cnxk_ae.h
> @@ -22,6 +22,8 @@ struct cnxk_ae_sess {
>  	uint64_t *cnxk_fpm_iova;
>  	struct roc_ae_ec_group **ec_grp;
>  	uint64_t cpt_inst_w7;
> +	uint64_t cpt_inst_w2;
> +	struct cnxk_cpt_qp *qp;
>  };
> 
>  static __rte_always_inline void
> diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> index ab0f00ee7c..7ece0214dc 100644
> --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
> @@ -125,24 +125,6 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
>  			struct rte_cryptodev_asym_session *sess);  void
> cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
> 
> -static inline union rte_event_crypto_metadata * -
> cnxk_event_crypto_mdata_get(struct rte_crypto_op *op) -{
> -	union rte_event_crypto_metadata *ec_mdata;
> -
> -	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> -		ec_mdata = rte_cryptodev_sym_session_get_user_data(
> -			op->sym->session);
> -	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> -		 op->private_data_offset)
> -		ec_mdata = (union rte_event_crypto_metadata
> -				    *)((uint8_t *)op + op->private_data_offset);
> -	else
> -		return NULL;
> -
> -	return ec_mdata;
> -}
> -
>  static __rte_always_inline void
>  pending_queue_advance(uint64_t *index, const uint64_t mask)  { diff --git
> a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index
> ce7ca2eda9..a339b80a87 100644
> --- a/drivers/crypto/cnxk/cnxk_se.h
> +++ b/drivers/crypto/cnxk/cnxk_se.h
> @@ -33,6 +33,8 @@ struct cnxk_se_sess {
>  	uint16_t auth_iv_offset;
>  	uint32_t salt;
>  	uint64_t cpt_inst_w7;
> +	uint64_t cpt_inst_w2;
> +	struct cnxk_cpt_qp *qp;
>  	struct roc_se_ctx roc_se_ctx;
>  } __rte_cache_aligned;
> 
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v4 0/7] Add new cryptodev op for event metadata
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
                         ` (6 preceding siblings ...)
  2022-05-01 19:24       ` [PATCH v4 7/7] test-eventdev: support asym ops " Akhil Goyal
@ 2022-05-02 11:08       ` Gujjar, Abhinandan S
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
  8 siblings, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-02 11:08 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Monday, May 2, 2022 12:55 AM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v4 0/7] Add new cryptodev op for event metadata
> 
> For using event crypto metadata, event metadata need to be set in session. For
> this session user data was used for symmetric crypto sessions and no support
> was present for asymmetric and security sessions.
> The use of userdata to store event metadata (which is dereferenced in PMD) is
> not correct as it is meant for the application to use it.
> Hence, a new API is created to set and get event crypto metadata which is
> scalable to all sessions supported by the crypto PMD.
> The application can use the set API to set event metadata and the PMD may
> store that inside the session private data and PMD need not use the get API as
> it would be internal to the PMD.
> For the software event crypto adapter implementation, the eventdev library
> can use the get API to get the event metadata stored inside the session
> structure.
> For Asymmetric sessions, a new field is added inside the session struct which is
> internal to library.
> For symmetric and security sessions, new field cannot be added as it would be
> ABI break. Hence, session userdata is being used to store that as it was used
> earlier. In next ABI break release this would be fixed similar to asymmetric
> crypto case.
> 
> The patchset also add support for asymmetric crypto adapter in the test
> applications and the crypto/cnxk implementation of the new cryptodev op and
> corresponding changes in the eventdev lib.
> 
> Changes in v4:
> - added null checks in set API
> - updated check in session destroy
> - updated API comments
> - fixed test app failure reported by Abhinandan.
> - moved event mdata after padding in asym session struct.
> 
> Changes in v3:
> - fix SW adapter case of memory allocation/free of mdata. mdata is allocated in
> set API and freed in session clear/destroy.
> - mark rte_cryptodev_session_event_mdata_get as internal API as it is only
> needed for the app or the PMD.
> 
> changes in v2:
> - v1 patchset only fixed security sessions and also caused ABI breakage.
> This is fixed in v2.
> - added new API for setting event metadata.
> - added new cryptodev op which can handle all sessions
> 
> 
> Akhil Goyal (5):
>   crypto/octeontx: use new API for event metadata
>   test/event: use new API to set event crypto metadata
>   eventdev: use new API to get event crypto metadata
>   test/event: add asymmetric cases for crypto adapter
>   test-eventdev: support asym ops for crypto adapter
> 
> Volodymyr Fialko (2):
>   cryptodev: add APIs to get/set event metadata
>   crypto/cnxk: add event metadata set operation
> 
>  app/test-eventdev/evt_common.h              |   2 +
>  app/test-eventdev/evt_options.c             |  17 +
>  app/test-eventdev/evt_options.h             |   4 +
>  app/test-eventdev/test_perf_atq.c           |  12 +-
>  app/test-eventdev/test_perf_common.c        | 254 ++++++++--
>  app/test-eventdev/test_perf_common.h        |  45 +-
>  app/test-eventdev/test_perf_queue.c         |  12 +-
>  app/test/test_event_crypto_adapter.c        | 511 +++++++++++++++++++-
>  doc/guides/tools/testeventdev.rst           |   5 +
>  drivers/crypto/cnxk/cn10k_cryptodev_ops.c   | 144 +++++-
>  drivers/crypto/cnxk/cn10k_ipsec.h           |   2 +
>  drivers/crypto/cnxk/cn9k_cryptodev_ops.c    | 138 +++++-
>  drivers/crypto/cnxk/cn9k_ipsec.h            |   2 +
>  drivers/crypto/cnxk/cnxk_ae.h               |   2 +
>  drivers/crypto/cnxk/cnxk_cryptodev_ops.h    |  18 -
>  drivers/crypto/cnxk/cnxk_se.h               |   2 +
>  drivers/crypto/octeontx/otx_cryptodev_ops.c |  20 +-
>  lib/cryptodev/cryptodev_pmd.c               |  16 +
>  lib/cryptodev/cryptodev_pmd.h               |  36 ++
>  lib/cryptodev/rte_cryptodev.c               |  44 ++
>  lib/cryptodev/rte_cryptodev.h               |  22 +
>  lib/cryptodev/version.map                   |   4 +
>  lib/eventdev/rte_event_crypto_adapter.c     |  55 +--
>  23 files changed, 1179 insertions(+), 188 deletions(-)
> 
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter
  2022-05-01 19:24       ` [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
@ 2022-05-02 11:08         ` Gujjar, Abhinandan S
  0 siblings, 0 replies; 69+ messages in thread
From: Gujjar, Abhinandan S @ 2022-05-02 11:08 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: anoobj, jerinj, Jayatheerthan, Jay, Vangati, Narender, vfialko,
	Zhang, Roy Fan

Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Monday, May 2, 2022 12:55 AM
> To: dev@dpdk.org
> Cc: anoobj@marvell.com; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>; vfialko@marvell.com; Akhil Goyal
> <gakhil@marvell.com>; Zhang, Roy Fan <roy.fan.zhang@intel.com>
> Subject: [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter
> 
> Test app is updated to add cases for asymmetric crypto sessions for event
> crypto adapter.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  app/test/test_event_crypto_adapter.c | 499 ++++++++++++++++++++++++++-
>  1 file changed, 493 insertions(+), 6 deletions(-)
> 
> diff --git a/app/test/test_event_crypto_adapter.c
> b/app/test/test_event_crypto_adapter.c
> index 9904206735..2ecc7e2cea 100644
> --- a/app/test/test_event_crypto_adapter.c
> +++ b/app/test/test_event_crypto_adapter.c
> @@ -6,6 +6,7 @@
>  #include "test.h"
>  #include <string.h>
>  #include <rte_common.h>
> +#include <rte_malloc.h>
>  #include <rte_mempool.h>
>  #include <rte_mbuf.h>
>  #include <rte_cryptodev.h>
> @@ -67,12 +68,97 @@ static const uint8_t text_64B[] = {
>  	0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
>  	0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c  };
> +#define DATA_SIZE		512
> +struct modex_test_data {
> +	enum rte_crypto_asym_xform_type xform_type;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} base;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} exponent;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} modulus;
> +	struct {
> +		uint8_t data[DATA_SIZE];
> +		uint16_t len;
> +	} reminder;
> +	uint16_t result_len;
> +};
> +
> +static struct
> +modex_test_data modex_test_case = {
> +	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
> +	.base = {
> +		.data = {
> +			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
> +			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
> +			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
> +		},
> +		.len = 20,
> +	},
> +	.exponent = {
> +		.data = {
> +			0x01, 0x00, 0x01
> +		},
> +		.len = 3,
> +	},
> +	.reminder = {
> +		.data = {
> +			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
> +			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
> +			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
> +			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
> +			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
> +			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
> +			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
> +			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
> +			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
> +			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
> +			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
> +			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
> +			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
> +			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
> +			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
> +			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
> +		},
> +		.len = 128,
> +	},
> +	.modulus = {
> +		.data = {
> +			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
> +			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
> +			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
> +			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
> +			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
> +			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
> +			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
> +			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
> +			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
> +			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
> +			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
> +			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
> +			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
> +			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
> +			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
> +			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
> +		},
> +		.len = 128,
> +	},
> +	.result_len = 128,
> +};
> 
>  struct event_crypto_adapter_test_params {
>  	struct rte_mempool *mbuf_pool;
>  	struct rte_mempool *op_mpool;
> +	struct rte_mempool *asym_op_mpool;
>  	struct rte_mempool *session_mpool;
>  	struct rte_mempool *session_priv_mpool;
> +	struct rte_mempool *asym_sess_mpool;
>  	struct rte_cryptodev_config *config;
>  	uint8_t crypto_event_port_id;
>  	uint8_t internal_port_op_fwd;
> @@ -134,11 +220,24 @@ send_recv_ev(struct rte_event *ev)
>  		rte_pause();
> 
>  	op = recv_ev.event_ptr;
> +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
>  #if PKT_TRACE
> -	struct rte_mbuf *m = op->sym->m_src;
> -	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
> +		struct rte_mbuf *m = op->sym->m_src;
> +		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
>  #endif
> -	rte_pktmbuf_free(op->sym->m_src);
> +		rte_pktmbuf_free(op->sym->m_src);
> +	} else {
> +		uint8_t *data_expected = NULL, *data_received = NULL;
> +		uint32_t data_size;
> +
> +		data_expected = modex_test_case.reminder.data;
> +		data_received = op->asym->modex.result.data;
> +		data_size = op->asym->modex.result.length;
> +		ret = memcmp(data_expected, data_received, data_size);
> +		TEST_ASSERT_EQUAL(ret, 0,
> +				"Data mismatch for asym crypto adapter\n");
> +		rte_free(op->asym->modex.result.data);
> +	}
>  	rte_crypto_op_free(op);
> 
>  	return TEST_SUCCESS;
> @@ -348,6 +447,170 @@ test_session_with_op_forward_mode(void)
>  	return TEST_SUCCESS;
>  }
> 
> +static int
> +test_asym_op_forward_mode(uint8_t session_less) {
> +	const struct rte_cryptodev_asymmetric_xform_capability *capability;
> +	struct rte_cryptodev_asym_capability_idx cap_idx;
> +	struct rte_crypto_asym_xform xform_tc;
> +	union rte_event_crypto_metadata m_data;
> +	struct rte_cryptodev_info dev_info;
> +	struct rte_crypto_asym_op *asym_op;
> +	struct rte_crypto_op *op;
> +	uint8_t input[4096] = {0};
> +	uint8_t *result = NULL;
> +	struct rte_event ev;
> +	void *sess = NULL;
> +	uint32_t cap;
> +	int ret;
> +
> +	memset(&m_data, 0, sizeof(m_data));
> +
> +	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
> +	if (session_less && !(dev_info.feature_flags &
> +				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support Asym sessionless ops. Test
> Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +	/* Setup Cipher Parameters */
> +	xform_tc.next = NULL;
> +	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
> +	cap_idx.type = xform_tc.xform_type;
> +	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID,
> +&cap_idx);
> +
> +	if (capability == NULL) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support MODEX. Test Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +
> +	op = rte_crypto_op_alloc(params.asym_op_mpool,
> +			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
> +	TEST_ASSERT_NOT_NULL(op,
> +		"Failed to allocate asymmetric crypto operation struct\n");
> +
> +	asym_op = op->asym;
> +
> +	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
> +	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
> +	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
> +	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
> +	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
> +	memcpy(input, modex_test_case.base.data,
> +		modex_test_case.base.len);
> +	asym_op->modex.base.data = input;
> +	asym_op->modex.base.length = modex_test_case.base.len;
> +	asym_op->modex.result.data = result;
> +	asym_op->modex.result.length = modex_test_case.result_len;
> +	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
> +			xform_tc.modex.modulus.length)) {
> +		RTE_LOG(INFO, USER1,
> +			"line %u FAILED: %s", __LINE__,
> +			"Invalid MODULUS length specified");
> +		return TEST_FAILED;
> +	}
> +
> +	if (!session_less) {
> +		/* Create Crypto session*/
> +		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
> +				&xform_tc, params.asym_sess_mpool, &sess);
> +		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
> +
> +		ret = rte_event_crypto_adapter_caps_get(evdev,
> TEST_CDEV_ID,
> +							&cap);
> +		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter
> capabilities\n");
> +
> +		if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
> +			/* Fill in private user data information */
> +			m_data.request_info.cdev_id = request_info.cdev_id;
> +			m_data.request_info.queue_pair_id =
> +				request_info.queue_pair_id;
> +			m_data.response_info.event = response_info.event;
> +
> 	rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
> +					sess,
> RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +					RTE_CRYPTO_OP_WITH_SESSION,
> +					&m_data, sizeof(m_data));
> +		}
> +
> +		rte_crypto_op_attach_asym_session(op, sess);
> +	} else {
> +		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
> +		asym_op->xform = &xform_tc;
> +		op->private_data_offset = (sizeof(struct rte_crypto_op) +
> +				sizeof(struct rte_crypto_asym_op) +
> +				DEFAULT_NUM_XFORMS *
> +				sizeof(struct rte_crypto_asym_xform));
> +		/* Fill in private data information */
> +		m_data.request_info.cdev_id = request_info.cdev_id;
> +		m_data.request_info.queue_pair_id =
> request_info.queue_pair_id;
> +		m_data.response_info.event = response_info.event;
> +		rte_memcpy((uint8_t *)op + op->private_data_offset,
> +				&m_data, sizeof(m_data));
> +	}
> +	/* Fill in event info and update event_ptr with rte_crypto_op */
> +	memset(&ev, 0, sizeof(ev));
> +	ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
> +	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> +	ev.flow_id = 0xAABB;
> +	ev.event_ptr = op;
> +
> +	ret = send_recv_ev(&ev);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
> +				"crypto adapter\n");
> +
> +	test_crypto_adapter_stats();
> +
> +	return TEST_SUCCESS;
> +}
> +
> +
> +static int
> +test_asym_sessionless_with_op_forward_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
> +			return TEST_SKIPPED;
> +	}
> +
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID),
> +				"Failed to start event crypto adapter");
> +
> +	return test_asym_op_forward_mode(1);
> +}
> +
> +static int
> +test_asym_session_with_op_forward_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
> +			return TEST_SKIPPED;
> +	}
> +
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID
> +				), "Failed to start event crypto adapter");
> +
> +	return test_asym_op_forward_mode(0);
> +}
> +
>  static int
>  send_op_recv_ev(struct rte_crypto_op *op)  { @@ -365,11 +628,24 @@
> send_op_recv_ev(struct rte_crypto_op *op)
>  		rte_pause();
> 
>  	recv_op = ev.event_ptr;
> +	if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
>  #if PKT_TRACE
> -	struct rte_mbuf *m = recv_op->sym->m_src;
> -	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
> +		struct rte_mbuf *m = recv_op->sym->m_src;
> +		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
>  #endif
> -	rte_pktmbuf_free(recv_op->sym->m_src);
> +		rte_pktmbuf_free(recv_op->sym->m_src);
> +	} else {
> +		uint8_t *data_expected = NULL, *data_received = NULL;
> +		uint32_t data_size;
> +
> +		data_expected = modex_test_case.reminder.data;
> +		data_received = op->asym->modex.result.data;
> +		data_size = op->asym->modex.result.length;
> +		ret = memcmp(data_expected, data_received, data_size);
> +		TEST_ASSERT_EQUAL(ret, 0,
> +				"Data mismatch for asym crypto adapter\n");
> +		rte_free(op->asym->modex.result.data);
> +	}
>  	rte_crypto_op_free(recv_op);
> 
>  	return TEST_SUCCESS;
> @@ -505,16 +781,169 @@ test_session_with_op_new_mode(void)
>  	return TEST_SUCCESS;
>  }
> 
> +static int
> +test_asym_op_new_mode(uint8_t session_less) {
> +	const struct rte_cryptodev_asymmetric_xform_capability *capability;
> +	struct rte_cryptodev_asym_capability_idx cap_idx;
> +	struct rte_crypto_asym_xform xform_tc;
> +	union rte_event_crypto_metadata m_data;
> +	struct rte_cryptodev_info dev_info;
> +	struct rte_crypto_asym_op *asym_op;
> +	struct rte_crypto_op *op;
> +	uint8_t input[4096] = {0};
> +	uint8_t *result = NULL;
> +	void *sess = NULL;
> +	uint32_t cap;
> +	int ret;
> +
> +	memset(&m_data, 0, sizeof(m_data));
> +
> +	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
> +	if (session_less && !(dev_info.feature_flags &
> +				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support Asym sessionless ops. Test
> Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +	/* Setup Cipher Parameters */
> +	xform_tc.next = NULL;
> +	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
> +	cap_idx.type = xform_tc.xform_type;
> +	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID,
> +&cap_idx);
> +
> +	if (capability == NULL) {
> +		RTE_LOG(INFO, USER1,
> +			"Device doesn't support MODEX. Test Skipped\n");
> +		return TEST_SKIPPED;
> +	}
> +
> +	op = rte_crypto_op_alloc(params.asym_op_mpool,
> +			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
> +	TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n");
> +
> +	asym_op = op->asym;
> +
> +	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
> +	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
> +	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
> +	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
> +	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
> +	memcpy(input, modex_test_case.base.data,
> +		modex_test_case.base.len);
> +	asym_op->modex.base.data = input;
> +	asym_op->modex.base.length = modex_test_case.base.len;
> +	asym_op->modex.result.data = result;
> +	asym_op->modex.result.length = modex_test_case.result_len;
> +	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
> +			xform_tc.modex.modulus.length)) {
> +		RTE_LOG(INFO, USER1,
> +			"line %u FAILED: %s", __LINE__,
> +			"Invalid MODULUS length specified");
> +		return TEST_FAILED;
> +	}
> +
> +	if (!session_less) {
> +		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
> +				&xform_tc, params.asym_sess_mpool, &sess);
> +		TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
> +		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
> +
> +		ret = rte_event_crypto_adapter_caps_get(evdev,
> TEST_CDEV_ID,
> +							&cap);
> +		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter
> capabilities\n");
> +
> +		if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
> +			/* Fill in private user data information */
> +			m_data.response_info.event = response_info.event;
> +
> 	rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
> +					sess,
> RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +					RTE_CRYPTO_OP_WITH_SESSION,
> +					&m_data, sizeof(m_data));
> +		}
> +
> +		rte_crypto_op_attach_asym_session(op, sess);
> +	} else {
> +		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
> +		asym_op->xform = &xform_tc;
> +		op->private_data_offset = (sizeof(struct rte_crypto_op) +
> +				sizeof(struct rte_crypto_asym_op) +
> +				DEFAULT_NUM_XFORMS *
> +				sizeof(struct rte_crypto_asym_xform));
> +		/* Fill in private data information */
> +		m_data.response_info.event = response_info.event;
> +		rte_memcpy((uint8_t *)op + op->private_data_offset,
> +				&m_data, sizeof(m_data));
> +	}
> +
> +	ret = send_op_recv_ev(op);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
> +
> +	test_crypto_adapter_stats();
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
> +test_asym_sessionless_with_op_new_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +			return TEST_SKIPPED;
> +	}
> +
> +	/* start the event crypto adapter */
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID),
> +				"Failed to start event crypto adapter");
> +
> +	return test_asym_op_new_mode(1);
> +}
> +
> +static int
> +test_asym_session_with_op_new_mode(void)
> +{
> +	uint32_t cap;
> +	int ret;
> +
> +	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
> &cap);
> +	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
> +
> +	if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
> +	    !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +		map_adapter_service_core();
> +	else {
> +		if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
> +			return TEST_SKIPPED;
> +	}
> +
> +
> 	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTE
> R_ID),
> +				"Failed to start event crypto adapter");
> +
> +	return test_asym_op_new_mode(0);
> +}
> +
>  static int
>  configure_cryptodev(void)
>  {
> +	const struct rte_cryptodev_capabilities *capability;
>  	struct rte_cryptodev_qp_conf qp_conf;
>  	struct rte_cryptodev_config conf;
>  	struct rte_cryptodev_info info;
>  	unsigned int session_size;
> +	unsigned int i = 0;
>  	uint8_t nb_devs;
>  	int ret;
> 
> +
>  	params.mbuf_pool = rte_pktmbuf_pool_create(
>  			"CRYPTO_ADAPTER_MBUFPOOL",
>  			NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE, @@
> -582,6 +1011,33 @@ configure_cryptodev(void)
>  			"session mempool allocation failed\n");
> 
>  	rte_cryptodev_info_get(TEST_CDEV_ID, &info);
> +
> +	while ((capability = &info.capabilities[i++])->op !=
> +			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
> +		if (capability->op == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +			params.asym_op_mpool = rte_crypto_op_pool_create(
> +				"EVENT_CRYPTO_ASYM_OP_POOL",
> +				RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
> +				NUM_MBUFS, MBUF_CACHE_SIZE,
> +				(DEFAULT_NUM_XFORMS *
> +				sizeof(struct rte_crypto_asym_xform)) +
> +				sizeof(union rte_event_crypto_metadata),
> +				rte_socket_id());
> +			TEST_ASSERT_NOT_NULL(params.asym_op_mpool,
> +					"Can't create
> CRYPTO_ASYM_OP_POOL\n");
> +
> +			params.asym_sess_mpool =
> +				rte_cryptodev_asym_session_pool_create(
> +					"CRYPTO_AD_ASYM_SESS_MP",
> +					MAX_NB_SESSIONS, 0,
> +					sizeof(union
> rte_event_crypto_metadata),
> +					SOCKET_ID_ANY);
> +			TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
> +				"asym session mempool allocation failed\n");
> +			break;
> +		}
> +	}
> +
>  	conf.nb_queue_pairs = info.max_nb_queue_pairs;
>  	conf.socket_id = SOCKET_ID_ANY;
>  	conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY; @@ -960,6 +1416,21
> @@ crypto_teardown(void)
>  		params.session_priv_mpool = NULL;
>  	}
> 
> +	/* Free asym session mempool */
> +	if (params.asym_sess_mpool != NULL) {
> +		RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count
> %u\n",
> +		rte_mempool_avail_count(params.asym_sess_mpool));
> +		rte_mempool_free(params.asym_sess_mpool);
> +		params.asym_sess_mpool = NULL;
> +	}
> +	/* Free asym ops mempool */
> +	if (params.asym_op_mpool != NULL) {
> +		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL
> count %u\n",
> +		rte_mempool_avail_count(params.asym_op_mpool));
> +		rte_mempool_free(params.asym_op_mpool);
> +		params.asym_op_mpool = NULL;
> +	}
> +
>  	/* Free ops mempool */
>  	if (params.op_mpool != NULL) {
>  		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL
> count %u\n", @@ -1016,6 +1487,22 @@ static struct unit_test_suite
> functional_testsuite = {
>  				test_crypto_adapter_stop,
>  				test_sessionless_with_op_new_mode),
> 
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
> +				test_crypto_adapter_stop,
> +				test_asym_session_with_op_forward_mode),
> +
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
> +				test_crypto_adapter_stop,
> +
> 	test_asym_sessionless_with_op_forward_mode),
> +
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
> +				test_crypto_adapter_stop,
> +				test_asym_session_with_op_new_mode),
> +
> +		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
> +				test_crypto_adapter_stop,
> +				test_asym_sessionless_with_op_new_mode),
> +
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 0/7] Add new cryptodev op for event metadata
  2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
                         ` (7 preceding siblings ...)
  2022-05-02 11:08       ` [PATCH v4 0/7] Add new cryptodev op for event metadata Gujjar, Abhinandan S
@ 2022-05-12 12:45       ` Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 1/7] cryptodev: add APIs to get/set " Akhil Goyal
                           ` (7 more replies)
  8 siblings, 8 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal

For using event crypto metadata, event metadata need to be set
in session. For this session user data was used for symmetric
crypto sessions and no support was present for asymmetric and
security sessions.
The use of userdata to store event metadata (which is dereferenced
in PMD) is not correct as it is meant for the application to use it.
Hence, a new API is created to set and get event crypto metadata which
is scalable to all sessions supported by the crypto PMD.
The application can use the set API to set event metadata and the
PMD may store that inside the session private data and PMD need not
use the get API as it would be internal to the PMD.
For the software event crypto adapter implementation, the eventdev
library can use the get API to get the event metadata stored inside
the session structure.
For Asymmetric sessions, a new field is added inside the session
struct which is internal to library.
For symmetric and security sessions, new field cannot be added as
it would be ABI break. Hence, session userdata is being used to
store that as it was used earlier. In next ABI break release this
would be fixed similar to asymmetric crypto case.

The patchset also add support for asymmetric crypto adapter
in the test applications and the crypto/cnxk implementation of
the new cryptodev op and corresponding changes in the eventdev lib.

changes in v5:
removed extra check for freeing mdata

Changes in v4:
- added null checks in set API
- updated check in session destroy
- updated API comments
- fixed test app failure reported by Abhinandan.
- moved event mdata after padding in asym session struct.

Changes in v3:
- fix SW adapter case of memory allocation/free of mdata. mdata is
allocated in set API and freed in session clear/destroy.
- mark rte_cryptodev_session_event_mdata_get as internal API
as it is only needed for the app or the PMD.

changes in v2:
- v1 patchset only fixed security sessions and also caused ABI breakage.
This is fixed in v2.
- added new API for setting event metadata.
- added new cryptodev op which can handle all sessions


Akhil Goyal (5):
  crypto/octeontx: use new API for event metadata
  test/event: use new API to set event crypto metadata
  eventdev: use new API to get event crypto metadata
  test/event: add asymmetric cases for crypto adapter
  test-eventdev: support asym ops for crypto adapter

Volodymyr Fialko (2):
  cryptodev: add APIs to get/set event metadata
  crypto/cnxk: add event metadata set operation

 app/test-eventdev/evt_common.h              |   2 +
 app/test-eventdev/evt_options.c             |  17 +
 app/test-eventdev/evt_options.h             |   4 +
 app/test-eventdev/test_perf_atq.c           |  12 +-
 app/test-eventdev/test_perf_common.c        | 254 ++++++++--
 app/test-eventdev/test_perf_common.h        |  45 +-
 app/test-eventdev/test_perf_queue.c         |  12 +-
 app/test/test_event_crypto_adapter.c        | 511 +++++++++++++++++++-
 doc/guides/tools/testeventdev.rst           |   5 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c   | 144 +++++-
 drivers/crypto/cnxk/cn10k_ipsec.h           |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    | 138 +++++-
 drivers/crypto/cnxk/cn9k_ipsec.h            |   2 +
 drivers/crypto/cnxk/cnxk_ae.h               |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h    |  18 -
 drivers/crypto/cnxk/cnxk_se.h               |   2 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c |  20 +-
 lib/cryptodev/cryptodev_pmd.c               |  16 +
 lib/cryptodev/cryptodev_pmd.h               |  36 ++
 lib/cryptodev/rte_cryptodev.c               |  43 ++
 lib/cryptodev/rte_cryptodev.h               |  22 +
 lib/cryptodev/version.map                   |   4 +
 lib/eventdev/rte_event_crypto_adapter.c     |  55 +--
 23 files changed, 1178 insertions(+), 188 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 1/7] cryptodev: add APIs to get/set event metadata
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
@ 2022-05-12 12:45         ` Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
                           ` (6 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

From: Volodymyr Fialko <vfialko@marvell.com>

Currently, crypto session userdata is used to set event crypto
metadata from the application and the driver is dereferencing it
in driver which is not correct. User data is meant to be opaque
to the driver.
To support this, new API is added to get and set event crypto
metadata. The new API, rte_cryptodev_set_session_event_mdata,
allows setting event metadata in session private data which is
filled inside PMD using a new cryptodev op. This operation
can be performed on any of the PMD supported sessions
(sym/asym/security).
For SW abstraction of event crypto adapter to be used by
eventdev library, a new field is added in asymmetric crypto
session for now and for symmetric case, current implementation
of using userdata is used. Symmetric cases cannot be fixed now,
as it will be ABI breakage which will be resolved in DPDK 22.11.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 lib/cryptodev/cryptodev_pmd.c | 16 +++++++++++++
 lib/cryptodev/cryptodev_pmd.h | 36 +++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.c | 43 +++++++++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.h | 22 ++++++++++++++++++
 lib/cryptodev/version.map     |  4 ++++
 5 files changed, 121 insertions(+)

diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
index 739a0b3f34..1903ade388 100644
--- a/lib/cryptodev/cryptodev_pmd.c
+++ b/lib/cryptodev/cryptodev_pmd.c
@@ -227,3 +227,19 @@ cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
 	fp_ops->qp.enq_cb = dev->enq_cbs;
 	fp_ops->qp.deq_cb = dev->deq_cbs;
 }
+
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return rte_cryptodev_sym_session_get_user_data(op->sym->session);
+	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
+			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
+		return op->asym->session->event_mdata;
+	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
+			op->private_data_offset)
+		return ((uint8_t *)op + op->private_data_offset);
+	else
+		return NULL;
+}
diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 2b1ce2da2d..7a7d3ee3f1 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -398,6 +398,25 @@ typedef int (*cryptodev_sym_configure_raw_dp_ctx_t)(
 	enum rte_crypto_op_sess_type sess_type,
 	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
 
+/**
+ * Typedef that the driver provided to set event crypto meta data.
+ *
+ * @param	dev		Crypto device pointer.
+ * @param	sess		Crypto or security session.
+ * @param	op_type		Operation type.
+ * @param	sess_type	Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ * @return
+ *   - On success return 0.
+ *   - On failure return negative integer.
+ */
+typedef int (*cryptodev_session_event_mdata_set_t)(
+	struct rte_cryptodev *dev, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata);
+
 /** Crypto device operations function pointer table */
 struct rte_cryptodev_ops {
 	cryptodev_configure_t dev_configure;	/**< Configure device. */
@@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
 			/**< Initialize raw data path context data. */
 		};
 	};
+	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
+	/**< Set a Crypto or Security session even meta data. */
 };
 
 
@@ -603,6 +624,19 @@ void
 cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
 		     const struct rte_cryptodev *dev);
 
+/**
+ * Get session event meta data (aka *union rte_event_crypto_metadata*)
+ *
+ * @param	op            pointer to *rte_crypto_op* structure.
+ *
+ * @return
+ *  - On success, pointer to event crypto metadata
+ *  - On failure, NULL.
+ */
+__rte_internal
+void *
+rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
+
 static inline void *
 get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
 		uint8_t driver_id) {
@@ -637,6 +671,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
 	uint16_t user_data_sz;
 	/**< Session user data will be placed after sess_data */
 	uint8_t padding[3];
+	void *event_mdata;
+	/**< Event metadata (aka *union rte_event_crypto_metadata*) */
 	uint8_t sess_private_data[0];
 };
 
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 3500a2d470..e16e6802aa 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2051,6 +2051,8 @@ rte_cryptodev_asym_session_free(uint8_t dev_id, void *sess)
 
 	dev->dev_ops->asym_session_clear(dev, sess);
 
+	rte_free(((struct rte_cryptodev_asym_session *)sess)->event_mdata);
+
 	/* Return session to mempool */
 	sess_mp = rte_mempool_from_obj(sess);
 	rte_mempool_put(sess_mp, sess);
@@ -2259,6 +2261,47 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t dev_id, uint16_t qp_id,
 			sess_type, session_ctx, is_update);
 }
 
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata,
+	uint16_t size)
+{
+	struct rte_cryptodev *dev;
+
+	if (sess == NULL || ev_mdata == NULL)
+		return -EINVAL;
+
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		goto skip_pmd_op;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (dev->dev_ops->session_ev_mdata_set == NULL)
+		goto skip_pmd_op;
+
+	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
+			sess_type, ev_mdata);
+
+skip_pmd_op:
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
+		return rte_cryptodev_sym_session_set_user_data(sess, ev_mdata,
+				size);
+	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		struct rte_cryptodev_asym_session *s = sess;
+
+		if (s->event_mdata == NULL) {
+			s->event_mdata = rte_malloc(NULL, size, 0);
+			if (s->event_mdata == NULL)
+				return -ENOMEM;
+		}
+		rte_memcpy(s->event_mdata, ev_mdata, size);
+
+		return 0;
+	} else
+		return -ENOTSUP;
+}
+
 uint32_t
 rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx,
 	struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs,
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 45d33f4a50..2c2c2edeb7 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -1269,6 +1269,28 @@ __rte_experimental
 int
 rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
 
+/**
+ * Set session event meta data
+ *
+ * @param	dev_id		The device identifier.
+ * @param	sess            Crypto or security session.
+ * @param	op_type         Operation type.
+ * @param	sess_type       Session type.
+ * @param	ev_mdata	Pointer to the event crypto meta data
+ *				(aka *union rte_event_crypto_metadata*)
+ * @param	size            Size of ev_mdata.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+__rte_experimental
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+	enum rte_crypto_op_type op_type,
+	enum rte_crypto_op_sess_type sess_type,
+	void *ev_mdata, uint16_t size);
+
 /**
  * Union of different crypto session types, including session-less xform
  * pointer.
diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map
index c7c5aefceb..f0abfaa47d 100644
--- a/lib/cryptodev/version.map
+++ b/lib/cryptodev/version.map
@@ -105,6 +105,9 @@ EXPERIMENTAL {
 	rte_cryptodev_asym_session_pool_create;
 	rte_cryptodev_asym_session_set_user_data;
 	__rte_cryptodev_trace_asym_session_pool_create;
+
+	#added in 22.07
+	rte_cryptodev_session_event_mdata_set;
 };
 
 INTERNAL {
@@ -123,5 +126,6 @@ INTERNAL {
 	rte_cryptodev_pmd_parse_input_args;
 	rte_cryptodev_pmd_probing_finish;
 	rte_cryptodev_pmd_release_device;
+	rte_cryptodev_session_event_mdata_get;
 	rte_cryptodevs;
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 2/7] crypto/cnxk: add event metadata set operation
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 1/7] cryptodev: add APIs to get/set " Akhil Goyal
@ 2022-05-12 12:45         ` Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
                           ` (5 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

From: Volodymyr Fialko <vfialko@marvell.com>

Added cryptodev operation for setting event crypto
metadata for all supported sessions - sym/asym/security.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++---
 drivers/crypto/cnxk/cn10k_ipsec.h         |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 138 ++++++++++++++++++---
 drivers/crypto/cnxk/cn9k_ipsec.h          |   2 +
 drivers/crypto/cnxk/cnxk_ae.h             |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  18 ---
 drivers/crypto/cnxk/cnxk_se.h             |   2 +
 7 files changed, 255 insertions(+), 53 deletions(-)

diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
index c4d5d039ec..01aa0d6870 100644
--- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
@@ -264,30 +264,136 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count + i;
 }
 
-uint16_t
-cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				      void *sess,
+				      enum rte_crypto_op_type op_type,
+				      enum rte_crypto_op_sess_type sess_type,
+				      void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
-	uint64_t lmt_base, lmt_arg;
-	struct cpt_inst_s *inst;
 	struct cnxk_cpt_qp *qp;
 	uint8_t cdev_id;
-	uint16_t lmt_id;
-	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	int16_t qp_id;
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn10k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn10k_ca_meta_info_extract(struct rte_crypto_op *op,
+			 struct cnxk_cpt_qp **qp, uint64_t *w2)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn10k_sec_session *priv;
+			struct cn10k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			*w2 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn10k_cryptodev_driver_id);
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata *)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			*w2 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			*w2 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	uint64_t lmt_base, lmt_arg, w2;
+	struct cpt_inst_s *inst;
+	struct cnxk_cpt_qp *qp;
+	uint16_t lmt_id;
+	int ret;
+
+	ret = cn10k_ca_meta_info_extract(op, &qp, &w2);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -316,9 +422,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst->w0.u64 = 0;
 	inst->res_addr = (uint64_t)&infl_req->res;
-	inst->w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
+	inst->w2.u64 = w2;
 	inst->w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -327,7 +431,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst->w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id;
@@ -592,4 +696,6 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set,
 };
diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h b/drivers/crypto/cnxk/cn10k_ipsec.h
index 647a71cdd5..1c1d904799 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec.h
@@ -20,6 +20,8 @@ struct cn10k_ipsec_sa {
 	uint16_t iv_offset;
 	uint8_t iv_length;
 	bool is_outbound;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 
 	/**
 	 * End of SW mutable area
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index d3d441cb24..98fa97ef01 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -316,28 +316,134 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 	return count;
 }
 
-uint16_t
-cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+static int
+cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,
+				     void *sess,
+				     enum rte_crypto_op_type op_type,
+				     enum rte_crypto_op_sess_type sess_type,
+				     void *mdata)
 {
-	union rte_event_crypto_metadata *ec_mdata;
-	struct cpt_inflight_req *infl_req;
+	union rte_event_crypto_metadata *ec_mdata = mdata;
 	struct rte_event *rsp_info;
 	struct cnxk_cpt_qp *qp;
-	struct cpt_inst_s inst;
 	uint8_t cdev_id;
 	uint16_t qp_id;
-	int ret;
-
-	ec_mdata = cnxk_event_crypto_mdata_get(op);
-	if (!ec_mdata) {
-		rte_errno = EINVAL;
-		return 0;
-	}
+	uint64_t w2;
 
+	/* Get queue pair */
 	cdev_id = ec_mdata->request_info.cdev_id;
 	qp_id = ec_mdata->request_info.queue_pair_id;
 	qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+
+	/* Prepare w2 */
 	rsp_info = &ec_mdata->response_info;
+	w2 = CNXK_CPT_INST_W2(
+		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+		rsp_info->sched_type, rsp_info->queue_id, 0);
+
+	/* Set meta according to session type */
+	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(sess);
+			sa = &priv->sa;
+			sa->qp = qp;
+			sa->inst.w2 = w2;
+		} else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				sess, cn9k_cryptodev_driver_id);
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess = sess;
+			struct cnxk_ae_sess *priv;
+
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			priv->qp = qp;
+			priv->cpt_inst_w2 = w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int
+cn9k_ca_meta_info_extract(struct rte_crypto_op *op,
+			struct cnxk_cpt_qp **qp, struct cpt_inst_s *inst)
+{
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			struct cn9k_sec_session *priv;
+			struct cn9k_ipsec_sa *sa;
+
+			priv = get_sec_session_private_data(op->sym->sec_session);
+			sa = &priv->sa;
+			*qp = sa->qp;
+			inst->w2.u64 = sa->inst.w2;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct cnxk_se_sess *priv;
+
+			priv = get_sym_session_private_data(
+				op->sym->session, cn9k_cryptodev_driver_id);
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else {
+			union rte_event_crypto_metadata *ec_mdata;
+			struct rte_event *rsp_info;
+			uint8_t cdev_id;
+			uint16_t qp_id;
+
+			ec_mdata = (union rte_event_crypto_metadata *)
+				((uint8_t *)op + op->private_data_offset);
+			if (!ec_mdata)
+				return -EINVAL;
+			rsp_info = &ec_mdata->response_info;
+			cdev_id = ec_mdata->request_info.cdev_id;
+			qp_id = ec_mdata->request_info.queue_pair_id;
+			*qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id];
+			inst->w2.u64 = CNXK_CPT_INST_W2(
+				(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
+				rsp_info->sched_type, rsp_info->queue_id, 0);
+		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_cryptodev_asym_session *asym_sess;
+			struct cnxk_ae_sess *priv;
+
+			asym_sess = op->asym->session;
+			priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data;
+			*qp = priv->qp;
+			inst->w2.u64 = priv->cpt_inst_w2;
+		} else
+			return -EINVAL;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+uint16_t
+cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
+{
+	struct cpt_inflight_req *infl_req;
+	struct cnxk_cpt_qp *qp;
+	struct cpt_inst_s inst;
+	int ret;
+
+	ret = cn9k_ca_meta_info_extract(op, &qp, &inst);
+	if (unlikely(ret)) {
+		rte_errno = EINVAL;
+		return 0;
+	}
 
 	if (unlikely(!qp->ca.enabled)) {
 		rte_errno = EINVAL;
@@ -362,9 +468,6 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	infl_req->qp = qp;
 	inst.w0.u64 = 0;
 	inst.res_addr = (uint64_t)&infl_req->res;
-	inst.w2.u64 = CNXK_CPT_INST_W2(
-		(RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id,
-		rsp_info->sched_type, rsp_info->queue_id, 0);
 	inst.w3.u64 = CNXK_CPT_INST_W3(1, infl_req);
 
 	if (roc_cpt_is_iq_full(&qp->lf)) {
@@ -373,7 +476,7 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 		return 0;
 	}
 
-	if (!rsp_info->sched_type)
+	if (inst.w2.s.tt == RTE_SCHED_TYPE_ORDERED)
 		roc_sso_hws_head_wait(tag_op);
 
 	cn9k_cpt_inst_submit(&inst, qp->lmtline.lmt_base, qp->lmtline.io_addr);
@@ -613,4 +716,7 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 	.asym_session_configure = cnxk_ae_session_cfg,
 	.asym_session_clear = cnxk_ae_session_clear,
 
+	/* Event crypto ops */
+	.session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set,
+
 };
diff --git a/drivers/crypto/cnxk/cn9k_ipsec.h b/drivers/crypto/cnxk/cn9k_ipsec.h
index f3acad561b..499dbc2782 100644
--- a/drivers/crypto/cnxk/cn9k_ipsec.h
+++ b/drivers/crypto/cnxk/cn9k_ipsec.h
@@ -42,6 +42,8 @@ struct cn9k_ipsec_sa {
 	struct cnxk_on_ipsec_ar ar;
 	/** Anti replay window size */
 	uint32_t replay_win_sz;
+	/** Queue pair */
+	struct cnxk_cpt_qp *qp;
 };
 
 struct cn9k_sec_session {
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 01ccfcd334..10854c79c8 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -22,6 +22,8 @@ struct cnxk_ae_sess {
 	uint64_t *cnxk_fpm_iova;
 	struct roc_ae_ec_group **ec_grp;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 };
 
 static __rte_always_inline void
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
index ab0f00ee7c..7ece0214dc 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
@@ -125,24 +125,6 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
 			struct rte_cryptodev_asym_session *sess);
 void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
 
-static inline union rte_event_crypto_metadata *
-cnxk_event_crypto_mdata_get(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-			op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata
-				    *)((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 static __rte_always_inline void
 pending_queue_advance(uint64_t *index, const uint64_t mask)
 {
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index ce7ca2eda9..a339b80a87 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -33,6 +33,8 @@ struct cnxk_se_sess {
 	uint16_t auth_iv_offset;
 	uint32_t salt;
 	uint64_t cpt_inst_w7;
+	uint64_t cpt_inst_w2;
+	struct cnxk_cpt_qp *qp;
 	struct roc_se_ctx roc_se_ctx;
 } __rte_cache_aligned;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 3/7] crypto/octeontx: use new API for event metadata
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 1/7] cryptodev: add APIs to get/set " Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
@ 2022-05-12 12:45         ` Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
                           ` (4 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata can be used
directly instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index ddb1266c3c..d5851d9987 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -684,24 +684,6 @@ submit_request_to_sso(struct ssows *ws, uintptr_t req,
 	ssovf_store_pair(add_work, req, ws->grps[rsp_info->queue_id]);
 }
 
-static inline union rte_event_crypto_metadata *
-get_event_crypto_mdata(struct rte_crypto_op *op)
-{
-	union rte_event_crypto_metadata *ec_mdata;
-
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		ec_mdata = rte_cryptodev_sym_session_get_user_data(
-							   op->sym->session);
-	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-		 op->private_data_offset)
-		ec_mdata = (union rte_event_crypto_metadata *)
-			((uint8_t *)op + op->private_data_offset);
-	else
-		return NULL;
-
-	return ec_mdata;
-}
-
 uint16_t __rte_hot
 otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 {
@@ -712,7 +694,7 @@ otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op)
 	uint8_t op_type, cdev_id;
 	uint16_t qp_id;
 
-	ec_mdata = get_event_crypto_mdata(op);
+	ec_mdata = rte_cryptodev_session_event_mdata_get(op);
 	if (unlikely(ec_mdata == NULL)) {
 		rte_errno = EINVAL;
 		return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 4/7] test/event: use new API to set event crypto metadata
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
                           ` (2 preceding siblings ...)
  2022-05-12 12:45         ` [PATCH v5 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
@ 2022-05-12 12:45         ` Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 5/7] eventdev: use new API to get " Akhil Goyal
                           ` (3 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

Used the new API rte_cryptodev_set_session_event_mdata to set
event crypto metadata from the applications (app/test and
app/test-eventdev) instead of using session userdata.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 app/test-eventdev/test_perf_common.c |  8 ++++++--
 app/test/test_event_crypto_adapter.c | 12 ++++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9d1f4a4567..0378607cda 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -835,8 +835,12 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 					return -ENOMEM;
 
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_sym_session_set_user_data(
-					crypto_sess, &m_data, sizeof(m_data));
+				rte_cryptodev_session_event_mdata_set(cdev_id,
+						crypto_sess,
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data, sizeof(m_data));
+
 				p->ca.crypto_sess[flow_id] = crypto_sess;
 			}
 
diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 688520db4e..9904206735 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -227,8 +227,10 @@ test_op_forward_mode(uint8_t session_less)
 			m_data.request_info.queue_pair_id =
 				request_info.queue_pair_id;
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
 		}
 
 		rte_crypto_op_attach_sym_session(op, sess);
@@ -416,8 +418,10 @@ test_op_new_mode(uint8_t session_less)
 		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
 			/* Fill in private user data information */
 			m_data.response_info.event = response_info.event;
-			rte_cryptodev_sym_session_set_user_data(sess,
-						&m_data, sizeof(m_data));
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
 		}
 		ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess,
 				&cipher_xform, params.session_priv_mpool);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 5/7] eventdev: use new API to get event crypto metadata
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
                           ` (3 preceding siblings ...)
  2022-05-12 12:45         ` [PATCH v5 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
@ 2022-05-12 12:45         ` Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
                           ` (2 subsequent siblings)
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

For getting event crypto metadata from crypto_op,
the new API rte_cryptodev_get_session_event_mdata is used
instead of getting userdata inside PMD.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 lib/eventdev/rte_event_crypto_adapter.c | 55 ++++++-------------------
 1 file changed, 12 insertions(+), 43 deletions(-)

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index f624f50187..7c695176f4 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -457,43 +457,22 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
-		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					crypto_op->sym->session);
-			if (m_data == NULL) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
+		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
+		if (m_data == NULL) {
+			rte_pktmbuf_free(crypto_op->sym->m_src);
+			rte_crypto_op_free(crypto_op);
+			continue;
+		}
 
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else if (crypto_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				crypto_op->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)crypto_op +
-					crypto_op->private_data_offset);
-			cdev_id = m_data->request_info.cdev_id;
-			qp_id = m_data->request_info.queue_pair_id;
-			qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
-			if (!qp_info->qp_enabled) {
-				rte_pktmbuf_free(crypto_op->sym->m_src);
-				rte_crypto_op_free(crypto_op);
-				continue;
-			}
-			eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
-		} else {
+		cdev_id = m_data->request_info.cdev_id;
+		qp_id = m_data->request_info.queue_pair_id;
+		qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id];
+		if (!qp_info->qp_enabled) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
 			rte_crypto_op_free(crypto_op);
 			continue;
 		}
+		eca_circular_buffer_add(&qp_info->cbuf, crypto_op);
 
 		if (eca_circular_buffer_batch_ready(&qp_info->cbuf)) {
 			ret = eca_circular_buffer_flush_to_cdev(&qp_info->cbuf,
@@ -636,17 +615,7 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 	for (i = 0; i < num; i++) {
 		struct rte_event *ev = &events[nb_ev++];
 
-		m_data = NULL;
-		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-			m_data = rte_cryptodev_sym_session_get_user_data(
-					ops[i]->sym->session);
-		} else if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
-				ops[i]->private_data_offset) {
-			m_data = (union rte_event_crypto_metadata *)
-				 ((uint8_t *)ops[i] +
-				  ops[i]->private_data_offset);
-		}
-
+		m_data = rte_cryptodev_session_event_mdata_get(ops[i]);
 		if (unlikely(m_data == NULL)) {
 			rte_pktmbuf_free(ops[i]->sym->m_src);
 			rte_crypto_op_free(ops[i]);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 6/7] test/event: add asymmetric cases for crypto adapter
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
                           ` (4 preceding siblings ...)
  2022-05-12 12:45         ` [PATCH v5 5/7] eventdev: use new API to get " Akhil Goyal
@ 2022-05-12 12:45         ` Akhil Goyal
  2022-05-12 12:45         ` [PATCH v5 7/7] test-eventdev: support asym ops " Akhil Goyal
  2022-05-16 18:30         ` [PATCH v5 0/7] Add new cryptodev op for event metadata Akhil Goyal
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

Test app is updated to add cases for asymmetric crypto
sessions for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 app/test/test_event_crypto_adapter.c | 499 ++++++++++++++++++++++++++-
 1 file changed, 493 insertions(+), 6 deletions(-)

diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 9904206735..2ecc7e2cea 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -6,6 +6,7 @@
 #include "test.h"
 #include <string.h>
 #include <rte_common.h>
+#include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
@@ -67,12 +68,97 @@ static const uint8_t text_64B[] = {
 	0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
 	0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c
 };
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 struct event_crypto_adapter_test_params {
 	struct rte_mempool *mbuf_pool;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *asym_op_mpool;
 	struct rte_mempool *session_mpool;
 	struct rte_mempool *session_priv_mpool;
+	struct rte_mempool *asym_sess_mpool;
 	struct rte_cryptodev_config *config;
 	uint8_t crypto_event_port_id;
 	uint8_t internal_port_op_fwd;
@@ -134,11 +220,24 @@ send_recv_ev(struct rte_event *ev)
 		rte_pause();
 
 	op = recv_ev.event_ptr;
+	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(op->sym->m_src);
+		rte_pktmbuf_free(op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(op);
 
 	return TEST_SUCCESS;
@@ -348,6 +447,170 @@ test_session_with_op_forward_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_forward_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	struct rte_event ev;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op,
+		"Failed to allocate asymmetric crypto operation struct\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		/* Create Crypto session*/
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.request_info.cdev_id = request_info.cdev_id;
+			m_data.request_info.queue_pair_id =
+				request_info.queue_pair_id;
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.request_info.cdev_id = request_info.cdev_id;
+		m_data.request_info.queue_pair_id = request_info.queue_pair_id;
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+	/* Fill in event info and update event_ptr with rte_crypto_op */
+	memset(&ev, 0, sizeof(ev));
+	ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
+	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	ev.flow_id = 0xAABB;
+	ev.event_ptr = op;
+
+	ret = send_recv_ev(&ev);
+	TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
+				"crypto adapter\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+
+static int
+test_asym_sessionless_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(1);
+}
+
+static int
+test_asym_session_with_op_forward_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID
+				), "Failed to start event crypto adapter");
+
+	return test_asym_op_forward_mode(0);
+}
+
 static int
 send_op_recv_ev(struct rte_crypto_op *op)
 {
@@ -365,11 +628,24 @@ send_op_recv_ev(struct rte_crypto_op *op)
 		rte_pause();
 
 	recv_op = ev.event_ptr;
+	if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
 #if PKT_TRACE
-	struct rte_mbuf *m = recv_op->sym->m_src;
-	rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
+		struct rte_mbuf *m = recv_op->sym->m_src;
+		rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
 #endif
-	rte_pktmbuf_free(recv_op->sym->m_src);
+		rte_pktmbuf_free(recv_op->sym->m_src);
+	} else {
+		uint8_t *data_expected = NULL, *data_received = NULL;
+		uint32_t data_size;
+
+		data_expected = modex_test_case.reminder.data;
+		data_received = op->asym->modex.result.data;
+		data_size = op->asym->modex.result.length;
+		ret = memcmp(data_expected, data_received, data_size);
+		TEST_ASSERT_EQUAL(ret, 0,
+				"Data mismatch for asym crypto adapter\n");
+		rte_free(op->asym->modex.result.data);
+	}
 	rte_crypto_op_free(recv_op);
 
 	return TEST_SUCCESS;
@@ -505,16 +781,169 @@ test_session_with_op_new_mode(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_asym_op_new_mode(uint8_t session_less)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform_tc;
+	union rte_event_crypto_metadata m_data;
+	struct rte_cryptodev_info dev_info;
+	struct rte_crypto_asym_op *asym_op;
+	struct rte_crypto_op *op;
+	uint8_t input[4096] = {0};
+	uint8_t *result = NULL;
+	void *sess = NULL;
+	uint32_t cap;
+	int ret;
+
+	memset(&m_data, 0, sizeof(m_data));
+
+	rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
+	if (session_less && !(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support Asym sessionless ops. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+	/* Setup Cipher Parameters */
+	xform_tc.next = NULL;
+	xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform_tc.xform_type;
+	capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1,
+			"Device doesn't support MODEX. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	op = rte_crypto_op_alloc(params.asym_op_mpool,
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n");
+
+	asym_op = op->asym;
+
+	result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
+	xform_tc.modex.modulus.data = modex_test_case.modulus.data;
+	xform_tc.modex.modulus.length = modex_test_case.modulus.len;
+	xform_tc.modex.exponent.data = modex_test_case.exponent.data;
+	xform_tc.modex.exponent.length = modex_test_case.exponent.len;
+	memcpy(input, modex_test_case.base.data,
+		modex_test_case.base.len);
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = modex_test_case.base.len;
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = modex_test_case.result_len;
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+			xform_tc.modex.modulus.length)) {
+		RTE_LOG(INFO, USER1,
+			"line %u FAILED: %s", __LINE__,
+			"Invalid MODULUS length specified");
+		return TEST_FAILED;
+	}
+
+	if (!session_less) {
+		ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
+				&xform_tc, params.asym_sess_mpool, &sess);
+		TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
+		TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
+
+		ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
+							&cap);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
+			/* Fill in private user data information */
+			m_data.response_info.event = response_info.event;
+			rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
+					sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+					RTE_CRYPTO_OP_WITH_SESSION,
+					&m_data, sizeof(m_data));
+		}
+
+		rte_crypto_op_attach_asym_session(op, sess);
+	} else {
+		op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+		asym_op->xform = &xform_tc;
+		op->private_data_offset = (sizeof(struct rte_crypto_op) +
+				sizeof(struct rte_crypto_asym_op) +
+				DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform));
+		/* Fill in private data information */
+		m_data.response_info.event = response_info.event;
+		rte_memcpy((uint8_t *)op + op->private_data_offset,
+				&m_data, sizeof(m_data));
+	}
+
+	ret = send_op_recv_ev(op);
+	TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
+
+	test_crypto_adapter_stats();
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_asym_sessionless_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	/* start the event crypto adapter */
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(1);
+}
+
+static int
+test_asym_session_with_op_new_mode(void)
+{
+	uint32_t cap;
+	int ret;
+
+	ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
+
+	if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
+	    !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+		map_adapter_service_core();
+	else {
+		if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
+			return TEST_SKIPPED;
+	}
+
+	TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
+				"Failed to start event crypto adapter");
+
+	return test_asym_op_new_mode(0);
+}
+
 static int
 configure_cryptodev(void)
 {
+	const struct rte_cryptodev_capabilities *capability;
 	struct rte_cryptodev_qp_conf qp_conf;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_info info;
 	unsigned int session_size;
+	unsigned int i = 0;
 	uint8_t nb_devs;
 	int ret;
 
+
 	params.mbuf_pool = rte_pktmbuf_pool_create(
 			"CRYPTO_ADAPTER_MBUFPOOL",
 			NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
@@ -582,6 +1011,33 @@ configure_cryptodev(void)
 			"session mempool allocation failed\n");
 
 	rte_cryptodev_info_get(TEST_CDEV_ID, &info);
+
+	while ((capability = &info.capabilities[i++])->op !=
+			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		if (capability->op == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+			params.asym_op_mpool = rte_crypto_op_pool_create(
+				"EVENT_CRYPTO_ASYM_OP_POOL",
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+				NUM_MBUFS, MBUF_CACHE_SIZE,
+				(DEFAULT_NUM_XFORMS *
+				sizeof(struct rte_crypto_asym_xform)) +
+				sizeof(union rte_event_crypto_metadata),
+				rte_socket_id());
+			TEST_ASSERT_NOT_NULL(params.asym_op_mpool,
+					"Can't create CRYPTO_ASYM_OP_POOL\n");
+
+			params.asym_sess_mpool =
+				rte_cryptodev_asym_session_pool_create(
+					"CRYPTO_AD_ASYM_SESS_MP",
+					MAX_NB_SESSIONS, 0,
+					sizeof(union rte_event_crypto_metadata),
+					SOCKET_ID_ANY);
+			TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
+				"asym session mempool allocation failed\n");
+			break;
+		}
+	}
+
 	conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	conf.socket_id = SOCKET_ID_ANY;
 	conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
@@ -960,6 +1416,21 @@ crypto_teardown(void)
 		params.session_priv_mpool = NULL;
 	}
 
+	/* Free asym session mempool */
+	if (params.asym_sess_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count %u\n",
+		rte_mempool_avail_count(params.asym_sess_mpool));
+		rte_mempool_free(params.asym_sess_mpool);
+		params.asym_sess_mpool = NULL;
+	}
+	/* Free asym ops mempool */
+	if (params.asym_op_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL count %u\n",
+		rte_mempool_avail_count(params.asym_op_mpool));
+		rte_mempool_free(params.asym_op_mpool);
+		params.asym_op_mpool = NULL;
+	}
+
 	/* Free ops mempool */
 	if (params.op_mpool != NULL) {
 		RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL count %u\n",
@@ -1016,6 +1487,22 @@ static struct unit_test_suite functional_testsuite = {
 				test_crypto_adapter_stop,
 				test_sessionless_with_op_new_mode),
 
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_forward_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_session_with_op_new_mode),
+
+		TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
+				test_crypto_adapter_stop,
+				test_asym_sessionless_with_op_new_mode),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* [PATCH v5 7/7] test-eventdev: support asym ops for crypto adapter
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
                           ` (5 preceding siblings ...)
  2022-05-12 12:45         ` [PATCH v5 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
@ 2022-05-12 12:45         ` Akhil Goyal
  2022-05-16 18:30         ` [PATCH v5 0/7] Add new cryptodev op for event metadata Akhil Goyal
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-12 12:45 UTC (permalink / raw)
  To: dev
  Cc: anoobj, jerinj, abhinandan.gujjar, jay.jayatheerthan,
	narender.vangati, vfialko, Akhil Goyal, Fan Zhang,
	Abhinandan Gujjar

Test eventdev app is updated to add new option for asymmetric
crypto ops for event crypto adapter.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
---
 app/test-eventdev/evt_common.h       |   2 +
 app/test-eventdev/evt_options.c      |  17 ++
 app/test-eventdev/evt_options.h      |   4 +
 app/test-eventdev/test_perf_atq.c    |  12 +-
 app/test-eventdev/test_perf_common.c | 250 +++++++++++++++++++++++----
 app/test-eventdev/test_perf_common.h |  45 +++--
 app/test-eventdev/test_perf_queue.c  |  12 +-
 doc/guides/tools/testeventdev.rst    |   5 +
 8 files changed, 284 insertions(+), 63 deletions(-)

diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index 2f301a7e79..196eca8bd0 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -6,6 +6,7 @@
 #define _EVT_COMMON_
 
 #include <rte_common.h>
+#include <rte_crypto.h>
 #include <rte_debug.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_eventdev.h>
@@ -80,6 +81,7 @@ struct evt_options {
 	uint64_t optm_timer_tick_nsec;
 	enum evt_prod_type prod_type;
 	enum rte_event_crypto_adapter_mode crypto_adptr_mode;
+	enum rte_crypto_op_type crypto_op_type;
 };
 
 static inline bool
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index d3c704d2b3..8326734b64 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -38,6 +38,7 @@ evt_options_default(struct evt_options *opt)
 	opt->eth_queues = 1;
 	opt->vector_size = 64;
 	opt->vector_tmo_nsec = 100E3;
+	opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
 }
 
 typedef int (*option_parser_t)(struct evt_options *opt,
@@ -142,6 +143,18 @@ evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
 	return ret;
 }
 
+static int
+evt_parse_crypto_op_type(struct evt_options *opt, const char *arg)
+{
+	uint8_t op_type;
+	int ret;
+
+	ret = parser_read_uint8(&op_type, arg);
+	opt->crypto_op_type = op_type ? RTE_CRYPTO_OP_TYPE_ASYMMETRIC :
+					RTE_CRYPTO_OP_TYPE_SYMMETRIC;
+	return ret;
+}
+
 static int
 evt_parse_test_name(struct evt_options *opt, const char *arg)
 {
@@ -368,6 +381,8 @@ usage(char *program)
 		"\t--expiry_nsec      : event timer expiry ns.\n"
 		"\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
 		"\t                      1 for OP_FORWARD mode.\n"
+		"\t--crypto_op_type   : 0 for SYM ops (default) and\n"
+		"\t                     1 for ASYM ops.\n"
 		"\t--mbuf_sz          : packet mbuf size.\n"
 		"\t--max_pkt_sz       : max packet size.\n"
 		"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -442,6 +457,7 @@ static struct option lgopts[] = {
 	{ EVT_PROD_TIMERDEV,       0, 0, 0 },
 	{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
 	{ EVT_CRYPTO_ADPTR_MODE,   1, 0, 0 },
+	{ EVT_CRYPTO_OP_TYPE,	   1, 0, 0 },
 	{ EVT_NB_TIMERS,           1, 0, 0 },
 	{ EVT_NB_TIMER_ADPTRS,     1, 0, 0 },
 	{ EVT_TIMER_TICK_NSEC,     1, 0, 0 },
@@ -484,6 +500,7 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
 		{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
 		{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
 		{ EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
+		{ EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type},
 		{ EVT_NB_TIMERS, evt_parse_nb_timers},
 		{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
 		{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 2231c58801..f23fb8a511 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -38,6 +38,7 @@
 #define EVT_PROD_TIMERDEV        ("prod_type_timerdev")
 #define EVT_PROD_TIMERDEV_BURST  ("prod_type_timerdev_burst")
 #define EVT_CRYPTO_ADPTR_MODE	 ("crypto_adptr_mode")
+#define EVT_CRYPTO_OP_TYPE	 ("crypto_op_type")
 #define EVT_NB_TIMERS            ("nb_timers")
 #define EVT_NB_TIMER_ADPTRS      ("nb_timer_adptrs")
 #define EVT_TIMER_TICK_NSEC      ("timer_tick_nsec")
@@ -298,6 +299,9 @@ evt_dump_producer_type(struct evt_options *opt)
 			 "Event crypto adapter producers");
 		evt_dump("crypto adapter mode", "%s",
 			 opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+		evt_dump("crypto op type", "%s",
+			 (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) ?
+			 "SYMMETRIC" : "ASYMMETRIC");
 		evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
 		break;
 	}
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 67ff681666..6a2aa86fd2 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -53,11 +53,13 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 0378607cda..f2da6fd74c 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -7,6 +7,89 @@
 #include "test_perf_common.h"
 
 #define NB_CRYPTODEV_DESCRIPTORS 128
+#define DATA_SIZE		512
+struct modex_test_data {
+	enum rte_crypto_asym_xform_type xform_type;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} base;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} exponent;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} modulus;
+	struct {
+		uint8_t data[DATA_SIZE];
+		uint16_t len;
+	} reminder;
+	uint16_t result_len;
+};
+
+static struct
+modex_test_data modex_test_case = {
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20,
+	},
+	.exponent = {
+		.data = {
+			0x01, 0x00, 0x01
+		},
+		.len = 3,
+	},
+	.reminder = {
+		.data = {
+			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
+			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
+			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
+			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
+			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
+			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
+			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
+			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
+			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
+			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
+			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
+			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
+			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
+			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
+			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
+			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
+		},
+		.len = 128,
+	},
+	.modulus = {
+		.data = {
+			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
+			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
+			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
+			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
+			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
+			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
+			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
+			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
+			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
+			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
+			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
+			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
+			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
+			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
+			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
+			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
+		},
+		.len = 128,
+	},
+	.result_len = 128,
+};
 
 int
 perf_test_result(struct evt_test *test, struct evt_options *opt)
@@ -277,12 +360,10 @@ perf_event_timer_producer_burst(void *arg)
 static inline void
 crypto_adapter_enq_op_new(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	struct test_perf *t = p->t;
 	const uint32_t nb_flows = t->nb_flows;
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
-	struct rte_crypto_sym_op *sym_op;
 	struct evt_options *opt = t->opt;
 	uint16_t qp_id = p->ca.cdev_qp_id;
 	uint8_t cdev_id = p->ca.cdev_id;
@@ -300,22 +381,39 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
 
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
-		       t->done == false)
+				t->done == false)
 			rte_pause();
 
 		count++;
@@ -325,7 +423,6 @@ crypto_adapter_enq_op_new(struct prod_data *p)
 static inline void
 crypto_adapter_enq_op_fwd(struct prod_data *p)
 {
-	struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
 	const uint8_t dev_id = p->dev_id;
 	const uint8_t port = p->port_id;
 	struct test_perf *t = p->t;
@@ -333,7 +430,6 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	const uint64_t nb_pkts = t->nb_pkts;
 	struct rte_mempool *pool = t->pool;
 	struct evt_options *opt = t->opt;
-	struct rte_crypto_sym_op *sym_op;
 	uint32_t flow_counter = 0;
 	struct rte_crypto_op *op;
 	struct rte_event ev;
@@ -354,19 +450,37 @@ crypto_adapter_enq_op_fwd(struct prod_data *p)
 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
 
 	while (count < nb_pkts && t->done == false) {
-		m = rte_pktmbuf_alloc(pool);
-		if (m == NULL)
-			continue;
+		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct rte_crypto_sym_op *sym_op;
 
-		rte_pktmbuf_append(m, len);
-		op = rte_crypto_op_alloc(t->ca_op_pool,
+			op = rte_crypto_op_alloc(t->ca_op_pool,
 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-		sym_op = op->sym;
-		sym_op->m_src = m;
-		sym_op->cipher.data.offset = 0;
-		sym_op->cipher.data.length = len;
-		rte_crypto_op_attach_sym_session(
-			op, crypto_sess[flow_counter++ % nb_flows]);
+			m = rte_pktmbuf_alloc(pool);
+			if (m == NULL)
+				continue;
+
+			rte_pktmbuf_append(m, len);
+			sym_op = op->sym;
+			sym_op->m_src = m;
+			sym_op->cipher.data.offset = 0;
+			sym_op->cipher.data.length = len;
+			rte_crypto_op_attach_sym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		} else {
+			struct rte_crypto_asym_op *asym_op;
+			uint8_t *result = rte_zmalloc(NULL,
+					modex_test_case.result_len, 0);
+
+			op = rte_crypto_op_alloc(t->ca_op_pool,
+					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+			asym_op = op->asym;
+			asym_op->modex.base.data = modex_test_case.base.data;
+			asym_op->modex.base.length = modex_test_case.base.len;
+			asym_op->modex.result.data = result;
+			asym_op->modex.result.length = modex_test_case.result_len;
+			rte_crypto_op_attach_asym_session(
+				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
+		}
 		ev.event_ptr = op;
 
 		while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
@@ -729,6 +843,37 @@ cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
 	return sess;
 }
 
+static void *
+cryptodev_asym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	struct rte_crypto_asym_xform xform;
+	void *sess;
+
+	xform.next = NULL;
+	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap_idx.type = xform.xform_type;
+	capability = rte_cryptodev_asym_capability_get(p->ca.cdev_id, &cap_idx);
+	if (capability == NULL) {
+		evt_err("Device doesn't support MODEX. Test Skipped\n");
+		return NULL;
+	}
+
+	xform.modex.modulus.data = modex_test_case.modulus.data;
+	xform.modex.modulus.length = modex_test_case.modulus.len;
+	xform.modex.exponent.data = modex_test_case.exponent.data;
+	xform.modex.exponent.length = modex_test_case.exponent.len;
+
+	if (rte_cryptodev_asym_session_create(p->ca.cdev_id, &xform,
+			t->ca_asym_sess_pool, &sess)) {
+		evt_err("Failed to create asym session");
+		return NULL;
+	}
+
+	return sess;
+}
+
 int
 perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 				uint8_t stride, uint8_t nb_queues,
@@ -804,7 +949,6 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 
 		prod = 0;
 		for (; port < perf_nb_event_ports(opt); port++) {
-			struct rte_cryptodev_sym_session *crypto_sess;
 			union rte_event_crypto_metadata m_data;
 			struct prod_data *p = &t->prod[port];
 			uint32_t flow_id;
@@ -820,7 +964,7 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			p->ca.cdev_id = cdev_id;
 			p->ca.cdev_qp_id = qp_id;
 			p->ca.crypto_sess = rte_zmalloc_socket(
-				NULL, sizeof(crypto_sess) * t->nb_flows,
+				NULL, sizeof(void *) * t->nb_flows,
 				RTE_CACHE_LINE_SIZE, opt->socket_id);
 			p->t = t;
 
@@ -830,18 +974,36 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
 			m_data.response_info.queue_id = p->queue_id;
 
 			for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
-				crypto_sess = cryptodev_sym_sess_create(p, t);
-				if (crypto_sess == NULL)
-					return -ENOMEM;
-
 				m_data.response_info.flow_id = flow_id;
-				rte_cryptodev_session_event_mdata_set(cdev_id,
-						crypto_sess,
+				if (opt->crypto_op_type ==
+						RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					struct rte_cryptodev_sym_session *sess;
+
+					sess = cryptodev_sym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
 						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 						RTE_CRYPTO_OP_WITH_SESSION,
 						&m_data, sizeof(m_data));
+					p->ca.crypto_sess[flow_id] = sess;
+				} else {
+					void *sess;
 
-				p->ca.crypto_sess[flow_id] = crypto_sess;
+					sess = cryptodev_asym_sess_create(p, t);
+					if (sess == NULL)
+						return -ENOMEM;
+					rte_cryptodev_session_event_mdata_set(
+						cdev_id,
+						sess,
+						RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+						RTE_CRYPTO_OP_WITH_SESSION,
+						&m_data, sizeof(m_data));
+					p->ca.crypto_sess[flow_id] = sess;
+				}
 			}
 
 			conf.event_port_cfg |=
@@ -1123,14 +1285,24 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	t->ca_op_pool = rte_crypto_op_pool_create(
-		"crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
-		128, 0, rte_socket_id());
+		"crypto_op_pool", opt->crypto_op_type, opt->pool_sz,
+		128, sizeof(union rte_event_crypto_metadata),
+		rte_socket_id());
 	if (t->ca_op_pool == NULL) {
 		evt_err("Failed to create crypto op pool");
 		return -ENOMEM;
 	}
 
 	nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+	t->ca_asym_sess_pool = rte_cryptodev_asym_session_pool_create(
+		"ca_asym_sess_pool", nb_sessions, 0,
+		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+	if (t->ca_asym_sess_pool == NULL) {
+		evt_err("Failed to create sym session pool");
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
 		"ca_sess_pool", nb_sessions, 0, 0,
 		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
@@ -1217,6 +1389,7 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 
 	return ret;
 }
@@ -1258,6 +1431,7 @@ perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
 	rte_mempool_free(t->ca_op_pool);
 	rte_mempool_free(t->ca_sess_pool);
 	rte_mempool_free(t->ca_sess_priv_pool);
+	rte_mempool_free(t->ca_asym_sess_pool);
 }
 
 int
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index ea0907d61a..5651832cc9 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -40,7 +40,7 @@ struct worker_data {
 struct crypto_adptr_data {
 	uint8_t cdev_id;
 	uint16_t cdev_qp_id;
-	struct rte_cryptodev_sym_session **crypto_sess;
+	void **crypto_sess;
 };
 struct prod_data {
 	uint8_t dev_id;
@@ -70,6 +70,7 @@ struct test_perf {
 	struct rte_mempool *ca_op_pool;
 	struct rte_mempool *ca_sess_pool;
 	struct rte_mempool *ca_sess_priv_pool;
+	struct rte_mempool *ca_asym_sess_pool;
 } __rte_cache_aligned;
 
 struct perf_elt {
@@ -111,8 +112,6 @@ perf_process_last_stage(struct rte_mempool *const pool,
 		struct rte_event *const ev, struct worker_data *const w,
 		void *bufs[], int const buf_sz, uint8_t count)
 {
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -120,9 +119,19 @@ perf_process_last_stage(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)ev->event_ptr)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		struct rte_crypto_op *op = ev->event_ptr;
+
+		rte_free(op->asym->modex.result.data);
+		rte_crypto_op_free(op);
+	} else {
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		}
 	}
 	return count;
 }
@@ -135,8 +144,6 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	uint64_t latency;
 	struct perf_elt *const m = ev->event_ptr;
 
-	bufs[count++] = ev->event_ptr;
-
 	/* release fence here ensures event_prt is
 	 * stored before updating the number of
 	 * processed packets for worker lcores
@@ -144,15 +151,23 @@ perf_process_last_stage_latency(struct rte_mempool *const pool,
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 	w->processed_pkts++;
 
-	if (unlikely(count == buf_sz)) {
-		count = 0;
-		latency = rte_get_timer_cycles() - m->timestamp;
-		rte_mempool_put_bulk(pool, bufs, buf_sz);
+	if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV &&
+			((struct rte_crypto_op *)m)->type ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		rte_free(((struct rte_crypto_op *)m)->asym->modex.result.data);
+		rte_crypto_op_free((struct rte_crypto_op *)m);
 	} else {
-		latency = rte_get_timer_cycles() - m->timestamp;
+		bufs[count++] = ev->event_ptr;
+		if (unlikely(count == buf_sz)) {
+			count = 0;
+			latency = rte_get_timer_cycles() - m->timestamp;
+			rte_mempool_put_bulk(pool, bufs, buf_sz);
+		} else {
+			latency = rte_get_timer_cycles() - m->timestamp;
+		}
+
+		w->latency += latency;
 	}
-
-	w->latency += latency;
 	return count;
 }
 
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index dcf6d82947..631a39f727 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -55,11 +55,13 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
 			struct rte_crypto_op *op = ev.event_ptr;
 
 			if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-				if (op->sym->m_dst == NULL)
-					ev.event_ptr = op->sym->m_src;
-				else
-					ev.event_ptr = op->sym->m_dst;
-				rte_crypto_op_free(op);
+				if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+					if (op->sym->m_dst == NULL)
+						ev.event_ptr = op->sym->m_src;
+					else
+						ev.event_ptr = op->sym->m_dst;
+					rte_crypto_op_free(op);
+				}
 			} else {
 				rte_crypto_op_free(op);
 				continue;
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index f7d813226d..a8e02d57a4 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -157,6 +157,11 @@ The following are the application command-line options:
         Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
         OP_FORWARD mode.
 
+* ``--crypto_op_type``
+
+        Set crypto operation type. Use 0 for symmetric crypto ops (default)
+        and 1 for asymmetric crypto ops.
+
 * ``--mbuf_sz``
 
        Set packet mbuf size. Can be used to configure Jumbo Frames. Only
-- 
2.25.1


^ permalink raw reply	[flat|nested] 69+ messages in thread

* RE: [PATCH v5 0/7] Add new cryptodev op for event metadata
  2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
                           ` (6 preceding siblings ...)
  2022-05-12 12:45         ` [PATCH v5 7/7] test-eventdev: support asym ops " Akhil Goyal
@ 2022-05-16 18:30         ` Akhil Goyal
  7 siblings, 0 replies; 69+ messages in thread
From: Akhil Goyal @ 2022-05-16 18:30 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: Anoob Joseph, Jerin Jacob Kollanukkaran, abhinandan.gujjar,
	jay.jayatheerthan, narender.vangati, Volodymyr Fialko

> Subject: [PATCH v5 0/7] Add new cryptodev op for event metadata
> 
> For using event crypto metadata, event metadata need to be set
> in session. For this session user data was used for symmetric
> crypto sessions and no support was present for asymmetric and
> security sessions.
> The use of userdata to store event metadata (which is dereferenced
> in PMD) is not correct as it is meant for the application to use it.
> Hence, a new API is created to set and get event crypto metadata which
> is scalable to all sessions supported by the crypto PMD.
> The application can use the set API to set event metadata and the
> PMD may store that inside the session private data and PMD need not
> use the get API as it would be internal to the PMD.
> For the software event crypto adapter implementation, the eventdev
> library can use the get API to get the event metadata stored inside
> the session structure.
> For Asymmetric sessions, a new field is added inside the session
> struct which is internal to library.
> For symmetric and security sessions, new field cannot be added as
> it would be ABI break. Hence, session userdata is being used to
> store that as it was used earlier. In next ABI break release this
> would be fixed similar to asymmetric crypto case.
> 
> The patchset also add support for asymmetric crypto adapter
> in the test applications and the crypto/cnxk implementation of
> the new cryptodev op and corresponding changes in the eventdev lib.
> 
> changes in v5:
> removed extra check for freeing mdata

Series Applied to dpdk-next-crypto


^ permalink raw reply	[flat|nested] 69+ messages in thread

end of thread, other threads:[~2022-05-16 18:30 UTC | newest]

Thread overview: 69+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 11:16 [PATCH 0/2] Session crypto event metadata api Volodymyr Fialko
2022-03-25 11:16 ` [PATCH 1/2] security: introduce per session event metadata Volodymyr Fialko
2022-04-04  8:38   ` Gujjar, Abhinandan S
2022-04-04  9:48     ` Akhil Goyal
2022-04-04 10:42       ` Gujjar, Abhinandan S
2022-04-13  7:13         ` Akhil Goyal
2022-04-18 19:36           ` Akhil Goyal
2022-03-25 11:16 ` [PATCH 2/2] crypto/cnxk: support for security session enqueue Volodymyr Fialko
2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 5/7] eventdev: use new API to get " Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-04-27 15:38       ` Zhang, Roy Fan
2022-04-28 14:42       ` Gujjar, Abhinandan S
2022-04-29 12:16         ` Akhil Goyal
2022-05-01 12:24           ` Gujjar, Abhinandan S
2022-05-01 18:37             ` Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-04-27 15:38       ` Zhang, Roy Fan
2022-05-01 13:17       ` Gujjar, Abhinandan S
2022-05-01 18:29         ` Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-04-27 15:38       ` Zhang, Roy Fan
2022-05-01 13:18       ` Gujjar, Abhinandan S
2022-04-21 14:37     ` [PATCH v3 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-04-27 15:39       ` Zhang, Roy Fan
2022-04-28 14:47       ` Gujjar, Abhinandan S
2022-04-21 14:37     ` [PATCH v3 5/7] eventdev: use new API to get " Akhil Goyal
2022-04-27 15:39       ` Zhang, Roy Fan
2022-04-28 15:08       ` Gujjar, Abhinandan S
2022-04-21 14:37     ` [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-04-27 15:39       ` Zhang, Roy Fan
2022-04-28 15:14       ` Gujjar, Abhinandan S
2022-04-29 12:23         ` Akhil Goyal
2022-05-01 12:45           ` Gujjar, Abhinandan S
2022-05-01 18:36             ` Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-04-27 15:40       ` Zhang, Roy Fan
2022-05-01 13:00       ` Gujjar, Abhinandan S
2022-04-27 15:37     ` [PATCH v3 0/7] Add new cryptodev op for event metadata Zhang, Roy Fan
2022-04-28 14:24     ` Gujjar, Abhinandan S
2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-05-02  9:01         ` Anoob Joseph
2022-05-02 11:06         ` Gujjar, Abhinandan S
2022-05-01 19:24       ` [PATCH v4 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-05-02 11:07         ` Gujjar, Abhinandan S
2022-05-01 19:24       ` [PATCH v4 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 5/7] eventdev: use new API to get " Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-05-02 11:08         ` Gujjar, Abhinandan S
2022-05-01 19:24       ` [PATCH v4 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-05-02 11:08       ` [PATCH v4 0/7] Add new cryptodev op for event metadata Gujjar, Abhinandan S
2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 5/7] eventdev: use new API to get " Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-05-16 18:30         ` [PATCH v5 0/7] Add new cryptodev op for event metadata Akhil Goyal

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git