DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] eventdev/crypto: restore opaque field between dequeue and enqueue
@ 2024-06-04 16:08 Ganapati Kundapura
  2024-06-04 16:18 ` [PATCH v2] " Ganapati Kundapura
  0 siblings, 1 reply; 11+ messages in thread
From: Ganapati Kundapura @ 2024-06-04 16:08 UTC (permalink / raw)
  To: dev

For session-less crypto operations, event info is contained in
crypto op metadata for each event which is restored in event
from the crypto op metadata response info.

For session based crypto operations, crypto op contains per session
based event info in crypto op metadata. If any PMD passes any
implementaion specific data in ev::impl_opaque on each event,
it's not getting restored.

This patch stores ev::impl_opaque in mbuf's dynamic field before
enqueueing to cryptodev and restores ev::impl_opaque from
mbuf's dynamic field after dequeueing crypto op from cryptodev
for session based crypto operations.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index db1c7f3..91a30ca 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -138,6 +138,27 @@ static struct event_crypto_adapter **event_crypto_adapter;
 	} \
 } while (0)
 
+#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
+/** Device-specific metadata field type */
+typedef uint8_t eca_dynfield_t;
+/** Dynamic mbuf field for device-specific metadata */
+int eca_dynfield_offset = -1;
+
+static int
+eca_dynfield_register(void)
+{
+	static const struct rte_mbuf_dynfield eca_dynfield_desc = {
+		.name = ECA_DYNFIELD_NAME,
+		.size = sizeof(eca_dynfield_t),
+		.align = alignof(eca_dynfield_t),
+		.flags = 0,
+	};
+
+	eca_dynfield_offset =
+		rte_mbuf_dynfield_register(&eca_dynfield_desc);
+	return eca_dynfield_offset;
+}
+
 static inline int
 eca_valid_id(uint8_t id)
 {
@@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
+
+		/** ev::impl_opaque field passed on from eventdev PMD could
+		 *  have different value per event.
+		 *  For session-based crypto operations retain ev::impl_opaque
+		 *  into mbuf dynfield and restore it back after copying event
+		 *  information from session event metadata.
+		 *  For session-less, each crypto operation carries event
+		 *  metadata and retains ev::impl_opaque information to be
+		 *  passed back to eventdev PMD.
+		 */
+		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = crypto_op->sym->m_src;
+
+			*RTE_MBUF_DYNFIELD(mbuf,
+					eca_dynfield_offset,
+					eca_dynfield_t *) = ev[i].impl_opaque;
+		}
+
 		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
 		if (m_data == NULL) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
@@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 
 		rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
 		ev->event_ptr = ops[i];
+
+		/** restore ev::impl_opaque from mbuf dyn field
+		 *  for session based crypto operation.
+		 *  For session-less, each crypto operations carries event
+		 *  metadata and retains ev::impl_opaque information to be
+		 *  passed back to eventdev PMD.
+		 */
+		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = ops[i]->sym->m_src;
+
+			ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
+							eca_dynfield_offset,
+							eca_dynfield_t *);
+		}
+
 		ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
 		if (adapter->implicit_release_disabled)
 			ev->op = RTE_EVENT_OP_FORWARD;
@@ -895,6 +949,16 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
 	}
 
 	adapter->implicit_release_disabled = (uint8_t)impl_rel;
+
+	/* Register for mbuf dyn field to store/restore ev::impl_opaque */
+	eca_dynfield_offset = eca_dynfield_register();
+	if (eca_dynfield_offset  < 0) {
+		RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
+		eca_circular_buffer_free(&adapter->ebuf);
+		rte_free(adapter);
+		return -EINVAL;
+	}
+
 	adapter->service_inited = 1;
 
 	return ret;
-- 
2.6.4


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

* [PATCH v2] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-04 16:08 [PATCH v1] eventdev/crypto: restore opaque field between dequeue and enqueue Ganapati Kundapura
@ 2024-06-04 16:18 ` Ganapati Kundapura
  2024-06-06  8:27   ` Jerin Jacob
  2024-06-06 11:46   ` [PATCH v3] " Ganapati Kundapura
  0 siblings, 2 replies; 11+ messages in thread
From: Ganapati Kundapura @ 2024-06-04 16:18 UTC (permalink / raw)
  To: dev, jerinj, abhinandan.gujjar; +Cc: jay.jayatheerthan, s.v.naga.harish.k

For session-less crypto operations, event info is contained in
crypto op metadata for each event which is restored in event
from the crypto op metadata response info.

For session based crypto operations, crypto op contains per session
based event info in crypto op metadata. If any PMD passes any
implementation specific data in ev::impl_opaque on each event,
it's not getting restored.

This patch stores ev::impl_opaque in mbuf's dynamic field before
enqueueing to cryptodev and restores ev::impl_opaque from
mbuf's dynamic field after dequeueing crypto op from cryptodev
for session based crypto operations.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

---
v2:
* Fixed TYPO_SPELLING warning in commit header

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index db1c7f3..91a30ca 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -138,6 +138,27 @@ static struct event_crypto_adapter **event_crypto_adapter;
 	} \
 } while (0)
 
+#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
+/** Device-specific metadata field type */
+typedef uint8_t eca_dynfield_t;
+/** Dynamic mbuf field for device-specific metadata */
+int eca_dynfield_offset = -1;
+
+static int
+eca_dynfield_register(void)
+{
+	static const struct rte_mbuf_dynfield eca_dynfield_desc = {
+		.name = ECA_DYNFIELD_NAME,
+		.size = sizeof(eca_dynfield_t),
+		.align = alignof(eca_dynfield_t),
+		.flags = 0,
+	};
+
+	eca_dynfield_offset =
+		rte_mbuf_dynfield_register(&eca_dynfield_desc);
+	return eca_dynfield_offset;
+}
+
 static inline int
 eca_valid_id(uint8_t id)
 {
@@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
+
+		/** ev::impl_opaque field passed on from eventdev PMD could
+		 *  have different value per event.
+		 *  For session-based crypto operations retain ev::impl_opaque
+		 *  into mbuf dynfield and restore it back after copying event
+		 *  information from session event metadata.
+		 *  For session-less, each crypto operation carries event
+		 *  metadata and retains ev::impl_opaque information to be
+		 *  passed back to eventdev PMD.
+		 */
+		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = crypto_op->sym->m_src;
+
+			*RTE_MBUF_DYNFIELD(mbuf,
+					eca_dynfield_offset,
+					eca_dynfield_t *) = ev[i].impl_opaque;
+		}
+
 		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
 		if (m_data == NULL) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
@@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 
 		rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
 		ev->event_ptr = ops[i];
+
+		/** restore ev::impl_opaque from mbuf dyn field
+		 *  for session based crypto operation.
+		 *  For session-less, each crypto operations carries event
+		 *  metadata and retains ev::impl_opaque information to be
+		 *  passed back to eventdev PMD.
+		 */
+		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = ops[i]->sym->m_src;
+
+			ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
+							eca_dynfield_offset,
+							eca_dynfield_t *);
+		}
+
 		ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
 		if (adapter->implicit_release_disabled)
 			ev->op = RTE_EVENT_OP_FORWARD;
@@ -895,6 +949,16 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
 	}
 
 	adapter->implicit_release_disabled = (uint8_t)impl_rel;
+
+	/* Register for mbuf dyn field to store/restore ev::impl_opaque */
+	eca_dynfield_offset = eca_dynfield_register();
+	if (eca_dynfield_offset  < 0) {
+		RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
+		eca_circular_buffer_free(&adapter->ebuf);
+		rte_free(adapter);
+		return -EINVAL;
+	}
+
 	adapter->service_inited = 1;
 
 	return ret;
-- 
2.6.4


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

* Re: [PATCH v2] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-04 16:18 ` [PATCH v2] " Ganapati Kundapura
@ 2024-06-06  8:27   ` Jerin Jacob
  2024-06-06 10:02     ` Jerin Jacob
  2024-06-06 11:46   ` [PATCH v3] " Ganapati Kundapura
  1 sibling, 1 reply; 11+ messages in thread
From: Jerin Jacob @ 2024-06-06  8:27 UTC (permalink / raw)
  To: Ganapati Kundapura
  Cc: dev, jerinj, abhinandan.gujjar, jay.jayatheerthan, s.v.naga.harish.k

On Tue, Jun 4, 2024 at 9:49 PM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> For session-less crypto operations, event info is contained in
> crypto op metadata for each event which is restored in event
> from the crypto op metadata response info.
>
> For session based crypto operations, crypto op contains per session
> based event info in crypto op metadata. If any PMD passes any
> implementation specific data in ev::impl_opaque on each event,
> it's not getting restored.
>
> This patch stores ev::impl_opaque in mbuf's dynamic field before
> enqueueing to cryptodev and restores ev::impl_opaque from
> mbuf's dynamic field after dequeueing crypto op from cryptodev
> for session based crypto operations.


Is n't Fix ? If so, please share the Fixes: tag, I will update on apply.


>
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
>
> ---
> v2:
> * Fixed TYPO_SPELLING warning in commit header
>
> diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
> index db1c7f3..91a30ca 100644
> --- a/lib/eventdev/rte_event_crypto_adapter.c
> +++ b/lib/eventdev/rte_event_crypto_adapter.c
> @@ -138,6 +138,27 @@ static struct event_crypto_adapter **event_crypto_adapter;
>         } \
>  } while (0)
>
> +#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
> +/** Device-specific metadata field type */
> +typedef uint8_t eca_dynfield_t;
> +/** Dynamic mbuf field for device-specific metadata */
> +int eca_dynfield_offset = -1;
> +
> +static int
> +eca_dynfield_register(void)
> +{
> +       static const struct rte_mbuf_dynfield eca_dynfield_desc = {
> +               .name = ECA_DYNFIELD_NAME,
> +               .size = sizeof(eca_dynfield_t),
> +               .align = alignof(eca_dynfield_t),
> +               .flags = 0,
> +       };
> +
> +       eca_dynfield_offset =
> +               rte_mbuf_dynfield_register(&eca_dynfield_desc);
> +       return eca_dynfield_offset;
> +}
> +
>  static inline int
>  eca_valid_id(uint8_t id)
>  {
> @@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
>                 crypto_op = ev[i].event_ptr;
>                 if (crypto_op == NULL)
>                         continue;
> +
> +               /** ev::impl_opaque field passed on from eventdev PMD could
> +                *  have different value per event.
> +                *  For session-based crypto operations retain ev::impl_opaque
> +                *  into mbuf dynfield and restore it back after copying event
> +                *  information from session event metadata.
> +                *  For session-less, each crypto operation carries event
> +                *  metadata and retains ev::impl_opaque information to be
> +                *  passed back to eventdev PMD.
> +                */
> +               if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +                       struct rte_mbuf *mbuf = crypto_op->sym->m_src;
> +
> +                       *RTE_MBUF_DYNFIELD(mbuf,
> +                                       eca_dynfield_offset,
> +                                       eca_dynfield_t *) = ev[i].impl_opaque;
> +               }
> +
>                 m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
>                 if (m_data == NULL) {
>                         rte_pktmbuf_free(crypto_op->sym->m_src);
> @@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
>
>                 rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
>                 ev->event_ptr = ops[i];
> +
> +               /** restore ev::impl_opaque from mbuf dyn field
> +                *  for session based crypto operation.
> +                *  For session-less, each crypto operations carries event
> +                *  metadata and retains ev::impl_opaque information to be
> +                *  passed back to eventdev PMD.
> +                */
> +               if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +                       struct rte_mbuf *mbuf = ops[i]->sym->m_src;
> +
> +                       ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
> +                                                       eca_dynfield_offset,
> +                                                       eca_dynfield_t *);
> +               }
> +
>                 ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
>                 if (adapter->implicit_release_disabled)
>                         ev->op = RTE_EVENT_OP_FORWARD;
> @@ -895,6 +949,16 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
>         }
>
>         adapter->implicit_release_disabled = (uint8_t)impl_rel;
> +
> +       /* Register for mbuf dyn field to store/restore ev::impl_opaque */
> +       eca_dynfield_offset = eca_dynfield_register();
> +       if (eca_dynfield_offset  < 0) {
> +               RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
> +               eca_circular_buffer_free(&adapter->ebuf);
> +               rte_free(adapter);
> +               return -EINVAL;
> +       }
> +
>         adapter->service_inited = 1;
>
>         return ret;
> --
> 2.6.4
>

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

* Re: [PATCH v2] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-06  8:27   ` Jerin Jacob
@ 2024-06-06 10:02     ` Jerin Jacob
  2024-06-06 11:47       ` Kundapura, Ganapati
  0 siblings, 1 reply; 11+ messages in thread
From: Jerin Jacob @ 2024-06-06 10:02 UTC (permalink / raw)
  To: Ganapati Kundapura
  Cc: dev, jerinj, abhinandan.gujjar, jay.jayatheerthan, s.v.naga.harish.k

On Thu, Jun 6, 2024 at 1:57 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Tue, Jun 4, 2024 at 9:49 PM Ganapati Kundapura
> <ganapati.kundapura@intel.com> wrote:
> >
> > For session-less crypto operations, event info is contained in
> > crypto op metadata for each event which is restored in event
> > from the crypto op metadata response info.
> >
> > For session based crypto operations, crypto op contains per session
> > based event info in crypto op metadata. If any PMD passes any
> > implementation specific data in ev::impl_opaque on each event,
> > it's not getting restored.
> >
> > This patch stores ev::impl_opaque in mbuf's dynamic field before
> > enqueueing to cryptodev and restores ev::impl_opaque from
> > mbuf's dynamic field after dequeueing crypto op from cryptodev
> > for session based crypto operations.
>
>
> Is n't Fix ? If so, please share the Fixes: tag, I will update on apply.

Also waiting for review and ack from @Gujjar, Abhinandan S
>
>
> >
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> >
> > ---
> > v2:
> > * Fixed TYPO_SPELLING warning in commit header
> >
> > diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
> > index db1c7f3..91a30ca 100644
> > --- a/lib/eventdev/rte_event_crypto_adapter.c
> > +++ b/lib/eventdev/rte_event_crypto_adapter.c
> > @@ -138,6 +138,27 @@ static struct event_crypto_adapter **event_crypto_adapter;
> >         } \
> >  } while (0)
> >
> > +#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
> > +/** Device-specific metadata field type */
> > +typedef uint8_t eca_dynfield_t;
> > +/** Dynamic mbuf field for device-specific metadata */
> > +int eca_dynfield_offset = -1;
> > +
> > +static int
> > +eca_dynfield_register(void)
> > +{
> > +       static const struct rte_mbuf_dynfield eca_dynfield_desc = {
> > +               .name = ECA_DYNFIELD_NAME,
> > +               .size = sizeof(eca_dynfield_t),
> > +               .align = alignof(eca_dynfield_t),
> > +               .flags = 0,
> > +       };
> > +
> > +       eca_dynfield_offset =
> > +               rte_mbuf_dynfield_register(&eca_dynfield_desc);
> > +       return eca_dynfield_offset;
> > +}
> > +
> >  static inline int
> >  eca_valid_id(uint8_t id)
> >  {
> > @@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
> >                 crypto_op = ev[i].event_ptr;
> >                 if (crypto_op == NULL)
> >                         continue;
> > +
> > +               /** ev::impl_opaque field passed on from eventdev PMD could
> > +                *  have different value per event.
> > +                *  For session-based crypto operations retain ev::impl_opaque
> > +                *  into mbuf dynfield and restore it back after copying event
> > +                *  information from session event metadata.
> > +                *  For session-less, each crypto operation carries event
> > +                *  metadata and retains ev::impl_opaque information to be
> > +                *  passed back to eventdev PMD.
> > +                */
> > +               if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> > +                       struct rte_mbuf *mbuf = crypto_op->sym->m_src;
> > +
> > +                       *RTE_MBUF_DYNFIELD(mbuf,
> > +                                       eca_dynfield_offset,
> > +                                       eca_dynfield_t *) = ev[i].impl_opaque;
> > +               }
> > +
> >                 m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
> >                 if (m_data == NULL) {
> >                         rte_pktmbuf_free(crypto_op->sym->m_src);
> > @@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
> >
> >                 rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
> >                 ev->event_ptr = ops[i];
> > +
> > +               /** restore ev::impl_opaque from mbuf dyn field
> > +                *  for session based crypto operation.
> > +                *  For session-less, each crypto operations carries event
> > +                *  metadata and retains ev::impl_opaque information to be
> > +                *  passed back to eventdev PMD.
> > +                */
> > +               if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> > +                       struct rte_mbuf *mbuf = ops[i]->sym->m_src;
> > +
> > +                       ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
> > +                                                       eca_dynfield_offset,
> > +                                                       eca_dynfield_t *);
> > +               }
> > +
> >                 ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
> >                 if (adapter->implicit_release_disabled)
> >                         ev->op = RTE_EVENT_OP_FORWARD;
> > @@ -895,6 +949,16 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
> >         }
> >
> >         adapter->implicit_release_disabled = (uint8_t)impl_rel;
> > +
> > +       /* Register for mbuf dyn field to store/restore ev::impl_opaque */
> > +       eca_dynfield_offset = eca_dynfield_register();
> > +       if (eca_dynfield_offset  < 0) {
> > +               RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
> > +               eca_circular_buffer_free(&adapter->ebuf);
> > +               rte_free(adapter);
> > +               return -EINVAL;
> > +       }
> > +
> >         adapter->service_inited = 1;
> >
> >         return ret;
> > --
> > 2.6.4
> >

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

* [PATCH v3] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-04 16:18 ` [PATCH v2] " Ganapati Kundapura
  2024-06-06  8:27   ` Jerin Jacob
@ 2024-06-06 11:46   ` Ganapati Kundapura
  2024-06-06 12:17     ` Gujjar, Abhinandan S
  2024-06-06 13:35     ` [PATCH v4] " Ganapati Kundapura
  1 sibling, 2 replies; 11+ messages in thread
From: Ganapati Kundapura @ 2024-06-06 11:46 UTC (permalink / raw)
  To: dev, jerinj, abhinandan.gujjar; +Cc: jay.jayatheerthan, s.v.naga.harish.k

For session-less crypto operations, event info is contained in
crypto op metadata for each event which is restored in event
from the crypto op metadata response info.

For session based crypto operations, crypto op contains per session
based event info in crypto op metadata. If any PMD passes any
implementation specific data in ev::impl_opaque on each event,
it's not getting restored.

This patch stores ev::impl_opaque in mbuf's dynamic field before
enqueueing to cryptodev and restores ev::impl_opaque from
mbuf's dynamic field after dequeueing crypto op from cryptodev
for session based crypto operations.

Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

---
v3:
* Added Fixes tag

v2:
* Fixed TYPO_SPELLING warning in commit header

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index db1c7f3..91a30ca 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -138,6 +138,27 @@ static struct event_crypto_adapter **event_crypto_adapter;
 	} \
 } while (0)
 
+#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
+/** Device-specific metadata field type */
+typedef uint8_t eca_dynfield_t;
+/** Dynamic mbuf field for device-specific metadata */
+int eca_dynfield_offset = -1;
+
+static int
+eca_dynfield_register(void)
+{
+	static const struct rte_mbuf_dynfield eca_dynfield_desc = {
+		.name = ECA_DYNFIELD_NAME,
+		.size = sizeof(eca_dynfield_t),
+		.align = alignof(eca_dynfield_t),
+		.flags = 0,
+	};
+
+	eca_dynfield_offset =
+		rte_mbuf_dynfield_register(&eca_dynfield_desc);
+	return eca_dynfield_offset;
+}
+
 static inline int
 eca_valid_id(uint8_t id)
 {
@@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
+
+		/** ev::impl_opaque field passed on from eventdev PMD could
+		 *  have different value per event.
+		 *  For session-based crypto operations retain ev::impl_opaque
+		 *  into mbuf dynfield and restore it back after copying event
+		 *  information from session event metadata.
+		 *  For session-less, each crypto operation carries event
+		 *  metadata and retains ev::impl_opaque information to be
+		 *  passed back to eventdev PMD.
+		 */
+		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = crypto_op->sym->m_src;
+
+			*RTE_MBUF_DYNFIELD(mbuf,
+					eca_dynfield_offset,
+					eca_dynfield_t *) = ev[i].impl_opaque;
+		}
+
 		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
 		if (m_data == NULL) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
@@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 
 		rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
 		ev->event_ptr = ops[i];
+
+		/** restore ev::impl_opaque from mbuf dyn field
+		 *  for session based crypto operation.
+		 *  For session-less, each crypto operations carries event
+		 *  metadata and retains ev::impl_opaque information to be
+		 *  passed back to eventdev PMD.
+		 */
+		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = ops[i]->sym->m_src;
+
+			ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
+							eca_dynfield_offset,
+							eca_dynfield_t *);
+		}
+
 		ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
 		if (adapter->implicit_release_disabled)
 			ev->op = RTE_EVENT_OP_FORWARD;
@@ -895,6 +949,16 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
 	}
 
 	adapter->implicit_release_disabled = (uint8_t)impl_rel;
+
+	/* Register for mbuf dyn field to store/restore ev::impl_opaque */
+	eca_dynfield_offset = eca_dynfield_register();
+	if (eca_dynfield_offset  < 0) {
+		RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
+		eca_circular_buffer_free(&adapter->ebuf);
+		rte_free(adapter);
+		return -EINVAL;
+	}
+
 	adapter->service_inited = 1;
 
 	return ret;
-- 
2.6.4


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

* RE: [PATCH v2] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-06 10:02     ` Jerin Jacob
@ 2024-06-06 11:47       ` Kundapura, Ganapati
  0 siblings, 0 replies; 11+ messages in thread
From: Kundapura, Ganapati @ 2024-06-06 11:47 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: dev, jerinj, Gujjar, Abhinandan S, Jayatheerthan, Jay,
	Naga Harish K, S V

Hi Jerin,

> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Thursday, June 6, 2024 3:33 PM
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Cc: dev@dpdk.org; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: Re: [PATCH v2] eventdev/crypto: restore opaque field between
> dequeue and enqueue
> 
> On Thu, Jun 6, 2024 at 1:57 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> >
> > On Tue, Jun 4, 2024 at 9:49 PM Ganapati Kundapura
> > <ganapati.kundapura@intel.com> wrote:
> > >
> > > For session-less crypto operations, event info is contained in
> > > crypto op metadata for each event which is restored in event from
> > > the crypto op metadata response info.
> > >
> > > For session based crypto operations, crypto op contains per session
> > > based event info in crypto op metadata. If any PMD passes any
> > > implementation specific data in ev::impl_opaque on each event, it's
> > > not getting restored.
> > >
> > > This patch stores ev::impl_opaque in mbuf's dynamic field before
> > > enqueueing to cryptodev and restores ev::impl_opaque from mbuf's
> > > dynamic field after dequeueing crypto op from cryptodev for session
> > > based crypto operations.
> >
> >
> > Is n't Fix ? If so, please share the Fixes: tag, I will update on apply.
Posted V3 patch with Fixes tag
> 
> Also waiting for review and ack from @Gujjar, Abhinandan S
> >
> >
> > >
> > > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > >
> > > ---
> > > v2:
> > > * Fixed TYPO_SPELLING warning in commit header
> > >
> > > diff --git a/lib/eventdev/rte_event_crypto_adapter.c
> > > b/lib/eventdev/rte_event_crypto_adapter.c
> > > index db1c7f3..91a30ca 100644
> > > --- a/lib/eventdev/rte_event_crypto_adapter.c
> > > +++ b/lib/eventdev/rte_event_crypto_adapter.c
> > > @@ -138,6 +138,27 @@ static struct event_crypto_adapter
> **event_crypto_adapter;
> > >         } \
> > >  } while (0)
> > >
> > > +#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
> > > +/** Device-specific metadata field type */ typedef uint8_t
> > > +eca_dynfield_t;
> > > +/** Dynamic mbuf field for device-specific metadata */ int
> > > +eca_dynfield_offset = -1;
> > > +
> > > +static int
> > > +eca_dynfield_register(void)
> > > +{
> > > +       static const struct rte_mbuf_dynfield eca_dynfield_desc = {
> > > +               .name = ECA_DYNFIELD_NAME,
> > > +               .size = sizeof(eca_dynfield_t),
> > > +               .align = alignof(eca_dynfield_t),
> > > +               .flags = 0,
> > > +       };
> > > +
> > > +       eca_dynfield_offset =
> > > +               rte_mbuf_dynfield_register(&eca_dynfield_desc);
> > > +       return eca_dynfield_offset;
> > > +}
> > > +
> > >  static inline int
> > >  eca_valid_id(uint8_t id)
> > >  {
> > > @@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct
> event_crypto_adapter *adapter, struct rte_event *ev,
> > >                 crypto_op = ev[i].event_ptr;
> > >                 if (crypto_op == NULL)
> > >                         continue;
> > > +
> > > +               /** ev::impl_opaque field passed on from eventdev PMD could
> > > +                *  have different value per event.
> > > +                *  For session-based crypto operations retain ev::impl_opaque
> > > +                *  into mbuf dynfield and restore it back after copying event
> > > +                *  information from session event metadata.
> > > +                *  For session-less, each crypto operation carries event
> > > +                *  metadata and retains ev::impl_opaque information to be
> > > +                *  passed back to eventdev PMD.
> > > +                */
> > > +               if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> > > +                       struct rte_mbuf *mbuf =
> > > + crypto_op->sym->m_src;
> > > +
> > > +                       *RTE_MBUF_DYNFIELD(mbuf,
> > > +                                       eca_dynfield_offset,
> > > +                                       eca_dynfield_t *) = ev[i].impl_opaque;
> > > +               }
> > > +
> > >                 m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
> > >                 if (m_data == NULL) {
> > >                         rte_pktmbuf_free(crypto_op->sym->m_src);
> > > @@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct
> > > event_crypto_adapter *adapter,
> > >
> > >                 rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
> > >                 ev->event_ptr = ops[i];
> > > +
> > > +               /** restore ev::impl_opaque from mbuf dyn field
> > > +                *  for session based crypto operation.
> > > +                *  For session-less, each crypto operations carries event
> > > +                *  metadata and retains ev::impl_opaque information to be
> > > +                *  passed back to eventdev PMD.
> > > +                */
> > > +               if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> > > +                       struct rte_mbuf *mbuf = ops[i]->sym->m_src;
> > > +
> > > +                       ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
> > > +                                                       eca_dynfield_offset,
> > > +                                                       eca_dynfield_t *);
> > > +               }
> > > +
> > >                 ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
> > >                 if (adapter->implicit_release_disabled)
> > >                         ev->op = RTE_EVENT_OP_FORWARD; @@ -895,6
> > > +949,16 @@ eca_init_service(struct event_crypto_adapter *adapter,
> uint8_t id)
> > >         }
> > >
> > >         adapter->implicit_release_disabled = (uint8_t)impl_rel;
> > > +
> > > +       /* Register for mbuf dyn field to store/restore ev::impl_opaque */
> > > +       eca_dynfield_offset = eca_dynfield_register();
> > > +       if (eca_dynfield_offset  < 0) {
> > > +               RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
> > > +               eca_circular_buffer_free(&adapter->ebuf);
> > > +               rte_free(adapter);
> > > +               return -EINVAL;
> > > +       }
> > > +
> > >         adapter->service_inited = 1;
> > >
> > >         return ret;
> > > --
> > > 2.6.4
> > >

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

* RE: [PATCH v3] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-06 11:46   ` [PATCH v3] " Ganapati Kundapura
@ 2024-06-06 12:17     ` Gujjar, Abhinandan S
  2024-06-06 13:37       ` Kundapura, Ganapati
  2024-06-06 13:35     ` [PATCH v4] " Ganapati Kundapura
  1 sibling, 1 reply; 11+ messages in thread
From: Gujjar, Abhinandan S @ 2024-06-06 12:17 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj; +Cc: Jayatheerthan, Jay, Naga Harish K, S V

Hi Ganapati,

Few comments inline. Please update in the next patch and add Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>


> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Thursday, June 6, 2024 5:17 PM
> To: dev@dpdk.org; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v3] eventdev/crypto: restore opaque field between dequeue
> and enqueue
> 
> For session-less crypto operations, event info is contained in crypto op
> metadata for each event which is restored in event from the crypto op
> metadata response info.
> 
> For session based crypto operations, crypto op contains per session based
> event info in crypto op metadata. If any PMD passes any implementation
> specific data in ev::impl_opaque on each event, it's not getting restored.
> 
> This patch stores ev::impl_opaque in mbuf's dynamic field before
> enqueueing to cryptodev and restores ev::impl_opaque from mbuf's dynamic
> field after dequeueing crypto op from cryptodev for session based crypto
> operations.
> 
> Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> 
> ---
> v3:
> * Added Fixes tag
> 
> v2:
> * Fixed TYPO_SPELLING warning in commit header
> 
> diff --git a/lib/eventdev/rte_event_crypto_adapter.c
> b/lib/eventdev/rte_event_crypto_adapter.c
> index db1c7f3..91a30ca 100644
> --- a/lib/eventdev/rte_event_crypto_adapter.c
> +++ b/lib/eventdev/rte_event_crypto_adapter.c
> @@ -138,6 +138,27 @@ static struct event_crypto_adapter
> **event_crypto_adapter;
>  	} \
>  } while (0)
> 
> +#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
> +/** Device-specific metadata field type */ typedef uint8_t
> +eca_dynfield_t;
> +/** Dynamic mbuf field for device-specific metadata */ int
Offset of dynamic field, right?
I see comment and statement are on the same line, please check. 

> +eca_dynfield_offset = -1;
> +
> +static int
> +eca_dynfield_register(void)
> +{
> +	static const struct rte_mbuf_dynfield eca_dynfield_desc = {
> +		.name = ECA_DYNFIELD_NAME,
> +		.size = sizeof(eca_dynfield_t),
> +		.align = alignof(eca_dynfield_t),
> +		.flags = 0,
> +	};
> +
> +	eca_dynfield_offset =
> +		rte_mbuf_dynfield_register(&eca_dynfield_desc);
> +	return eca_dynfield_offset;
> +}
> +
>  static inline int
>  eca_valid_id(uint8_t id)
>  {
> @@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct event_crypto_adapter
> *adapter, struct rte_event *ev,
>  		crypto_op = ev[i].event_ptr;
>  		if (crypto_op == NULL)
>  			continue;
> +
> +		/** ev::impl_opaque field passed on from eventdev PMD
Replace ev::impl_opaque with "struct rte_event::impl_opaque " in commit message and code

> could
> +		 *  have different value per event.
> +		 *  For session-based crypto operations retain
> ev::impl_opaque
> +		 *  into mbuf dynfield and restore it back after copying event
> +		 *  information from session event metadata.
> +		 *  For session-less, each crypto operation carries event
> +		 *  metadata and retains ev::impl_opaque information to be
> +		 *  passed back to eventdev PMD.
> +		 */
> +		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> {
> +			struct rte_mbuf *mbuf = crypto_op->sym->m_src;
> +
> +			*RTE_MBUF_DYNFIELD(mbuf,
> +					eca_dynfield_offset,
> +					eca_dynfield_t *) =
> ev[i].impl_opaque;
> +		}
> +
>  		m_data =
> rte_cryptodev_session_event_mdata_get(crypto_op);
>  		if (m_data == NULL) {
>  			rte_pktmbuf_free(crypto_op->sym->m_src);
> @@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct
> event_crypto_adapter *adapter,
> 
>  		rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
>  		ev->event_ptr = ops[i];
> +
> +		/** restore ev::impl_opaque from mbuf dyn field
Replace dynfield -> "dynamic field" in the comments
> +		 *  for session based crypto operation.
> +		 *  For session-less, each crypto operations carries event
> +		 *  metadata and retains ev::impl_opaque information to be
> +		 *  passed back to eventdev PMD.
> +		 */
> +		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +			struct rte_mbuf *mbuf = ops[i]->sym->m_src;
> +
> +			ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
> +							eca_dynfield_offset,
> +							eca_dynfield_t *);
> +		}
> +
>  		ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
>  		if (adapter->implicit_release_disabled)
>  			ev->op = RTE_EVENT_OP_FORWARD;
> @@ -895,6 +949,16 @@ eca_init_service(struct event_crypto_adapter
> *adapter, uint8_t id)
>  	}
> 
>  	adapter->implicit_release_disabled = (uint8_t)impl_rel;
> +
> +	/* Register for mbuf dyn field to store/restore ev::impl_opaque */
> +	eca_dynfield_offset = eca_dynfield_register();
> +	if (eca_dynfield_offset  < 0) {
> +		RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
> +		eca_circular_buffer_free(&adapter->ebuf);
> +		rte_free(adapter);
> +		return -EINVAL;
> +	}
> +
>  	adapter->service_inited = 1;
> 
>  	return ret;
> --
> 2.6.4


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

* [PATCH v4] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-06 11:46   ` [PATCH v3] " Ganapati Kundapura
  2024-06-06 12:17     ` Gujjar, Abhinandan S
@ 2024-06-06 13:35     ` Ganapati Kundapura
  2024-06-06 13:48       ` [PATCH v5] " Ganapati Kundapura
  1 sibling, 1 reply; 11+ messages in thread
From: Ganapati Kundapura @ 2024-06-06 13:35 UTC (permalink / raw)
  To: dev, jerinj, abhinandan.gujjar; +Cc: jay.jayatheerthan, s.v.naga.harish.k

For session-less crypto operations, event info is contained in
crypto op metadata for each event which is restored in event
from the crypto op metadata response info.

For session based crypto operations, crypto op contains per session
based event info in crypto op metadata. If any PMD passes any
implementation specific data in "struct rte_event::impl_opaque"
on each event, it's not getting restored.

This patch stores "struct rte_event::impl_opaque" in mbuf dynamic
field before enqueueing to cryptodev and restores
"struct rte_event::impl_opaque" from mbuf dynamic field after
dequeueing crypto op from cryptodev for session based crypto operations.

Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")

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

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

---
v4:
* Replaced ev::impl_opaque with "struct rte_event::impl_opaque"
* Added Acked-by

v3:
* Added Fixes tag

v2:
* Fixed TYPO_SPELLING warning in commit header

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index db1c7f3..b2b54bb 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -138,6 +138,28 @@ static struct event_crypto_adapter **event_crypto_adapter;
 	} \
 } while (0)
 
+#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
+/* Device-specific metadata field type */
+typedef uint8_t eca_dynfield_t;
+
+/* mbuf dynamic field offset for device-specific metadata */
+int eca_dynfield_offset = -1;
+
+static int
+eca_dynfield_register(void)
+{
+	static const struct rte_mbuf_dynfield eca_dynfield_desc = {
+		.name = ECA_DYNFIELD_NAME,
+		.size = sizeof(eca_dynfield_t),
+		.align = alignof(eca_dynfield_t),
+		.flags = 0,
+	};
+
+	eca_dynfield_offset =
+		rte_mbuf_dynfield_register(&eca_dynfield_desc);
+	return eca_dynfield_offset;
+}
+
 static inline int
 eca_valid_id(uint8_t id)
 {
@@ -491,6 +513,25 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
+
+		/** "struct rte_event::impl_opaque" field passed on from
+		 *  eventdev PMD could have different value per event.
+		 *  For session-based crypto operations retain
+		 *  "struct rte_event::impl_opaque" into mbuf dynamic field and
+		 *  restore it back after copying event information from
+		 *  session event metadata.
+		 *  For session-less, each crypto operation carries event
+		 *  metadata and retains "struct rte_event:impl_opaque"
+		 *  information to be passed back to eventdev PMD.
+		 */
+		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = crypto_op->sym->m_src;
+
+			*RTE_MBUF_DYNFIELD(mbuf,
+					eca_dynfield_offset,
+					eca_dynfield_t *) = ev[i].impl_opaque;
+		}
+
 		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
 		if (m_data == NULL) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
@@ -657,6 +698,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 
 		rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
 		ev->event_ptr = ops[i];
+
+		/** Restore "struct rte_event::impl_opaque" from mbuf
+		 *  dynamic field for session based crypto operation.
+		 *  For session-less, each crypto operations carries event
+		 *  metadata and retains "struct rte_event::impl_opaque"
+		 *  information to be passed back to eventdev PMD.
+		 */
+		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = ops[i]->sym->m_src;
+
+			ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
+							eca_dynfield_offset,
+							eca_dynfield_t *);
+		}
+
 		ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
 		if (adapter->implicit_release_disabled)
 			ev->op = RTE_EVENT_OP_FORWARD;
@@ -895,6 +951,16 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
 	}
 
 	adapter->implicit_release_disabled = (uint8_t)impl_rel;
+
+	/* Register for mbuf dyn field to store/restore ev::impl_opaque */
+	eca_dynfield_offset = eca_dynfield_register();
+	if (eca_dynfield_offset  < 0) {
+		RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
+		eca_circular_buffer_free(&adapter->ebuf);
+		rte_free(adapter);
+		return -EINVAL;
+	}
+
 	adapter->service_inited = 1;
 
 	return ret;
-- 
2.6.4


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

* RE: [PATCH v3] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-06 12:17     ` Gujjar, Abhinandan S
@ 2024-06-06 13:37       ` Kundapura, Ganapati
  0 siblings, 0 replies; 11+ messages in thread
From: Kundapura, Ganapati @ 2024-06-06 13:37 UTC (permalink / raw)
  To: Gujjar, Abhinandan S, dev, jerinj; +Cc: Jayatheerthan, Jay, Naga Harish K, S V

Hi Abhi,

> -----Original Message-----
> From: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> Sent: Thursday, June 6, 2024 5:47 PM
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>; dev@dpdk.org;
> jerinj@marvell.com
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: RE: [PATCH v3] eventdev/crypto: restore opaque field between
> dequeue and enqueue
> 
> Hi Ganapati,
> 
> Few comments inline. Please update in the next patch and add Acked-by:
> Abhinandan Gujjar <abhinandan.gujjar@intel.com>
> 
Added Acked-by in v4
> 
> > -----Original Message-----
> > From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> > Sent: Thursday, June 6, 2024 5:17 PM
> > To: dev@dpdk.org; jerinj@marvell.com; Gujjar, Abhinandan S
> > <abhinandan.gujjar@intel.com>
> > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; Naga Harish K, S
> > V <s.v.naga.harish.k@intel.com>
> > Subject: [PATCH v3] eventdev/crypto: restore opaque field between
> > dequeue and enqueue
> >
> > For session-less crypto operations, event info is contained in crypto
> > op metadata for each event which is restored in event from the crypto
> > op metadata response info.
> >
> > For session based crypto operations, crypto op contains per session
> > based event info in crypto op metadata. If any PMD passes any
> > implementation specific data in ev::impl_opaque on each event, it's not
> getting restored.
> >
> > This patch stores ev::impl_opaque in mbuf's dynamic field before
> > enqueueing to cryptodev and restores ev::impl_opaque from mbuf's
> > dynamic field after dequeueing crypto op from cryptodev for session
> > based crypto operations.
> >
> > Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")
> >
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> >
> > ---
> > v3:
> > * Added Fixes tag
> >
> > v2:
> > * Fixed TYPO_SPELLING warning in commit header
> >
> > diff --git a/lib/eventdev/rte_event_crypto_adapter.c
> > b/lib/eventdev/rte_event_crypto_adapter.c
> > index db1c7f3..91a30ca 100644
> > --- a/lib/eventdev/rte_event_crypto_adapter.c
> > +++ b/lib/eventdev/rte_event_crypto_adapter.c
> > @@ -138,6 +138,27 @@ static struct event_crypto_adapter
> > **event_crypto_adapter;
> >  	} \
> >  } while (0)
> >
> > +#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
> > +/** Device-specific metadata field type */ typedef uint8_t
> > +eca_dynfield_t;
> > +/** Dynamic mbuf field for device-specific metadata */ int
> Offset of dynamic field, right?
> I see comment and statement are on the same line, please check.
Updated in V4
> 
> > +eca_dynfield_offset = -1;
> > +
> > +static int
> > +eca_dynfield_register(void)
> > +{
> > +	static const struct rte_mbuf_dynfield eca_dynfield_desc = {
> > +		.name = ECA_DYNFIELD_NAME,
> > +		.size = sizeof(eca_dynfield_t),
> > +		.align = alignof(eca_dynfield_t),
> > +		.flags = 0,
> > +	};
> > +
> > +	eca_dynfield_offset =
> > +		rte_mbuf_dynfield_register(&eca_dynfield_desc);
> > +	return eca_dynfield_offset;
> > +}
> > +
> >  static inline int
> >  eca_valid_id(uint8_t id)
> >  {
> > @@ -491,6 +512,24 @@ eca_enq_to_cryptodev(struct
> event_crypto_adapter
> > *adapter, struct rte_event *ev,
> >  		crypto_op = ev[i].event_ptr;
> >  		if (crypto_op == NULL)
> >  			continue;
> > +
> > +		/** ev::impl_opaque field passed on from eventdev PMD
> Replace ev::impl_opaque with "struct rte_event::impl_opaque " in commit
> message and code
> 
Updated in v4
> > could
> > +		 *  have different value per event.
> > +		 *  For session-based crypto operations retain
> > ev::impl_opaque
> > +		 *  into mbuf dynfield and restore it back after copying event
> > +		 *  information from session event metadata.
> > +		 *  For session-less, each crypto operation carries event
> > +		 *  metadata and retains ev::impl_opaque information to be
> > +		 *  passed back to eventdev PMD.
> > +		 */
> > +		if (crypto_op->sess_type ==
> RTE_CRYPTO_OP_WITH_SESSION)
> > {
> > +			struct rte_mbuf *mbuf = crypto_op->sym->m_src;
> > +
> > +			*RTE_MBUF_DYNFIELD(mbuf,
> > +					eca_dynfield_offset,
> > +					eca_dynfield_t *) =
> > ev[i].impl_opaque;
> > +		}
> > +
> >  		m_data =
> > rte_cryptodev_session_event_mdata_get(crypto_op);
> >  		if (m_data == NULL) {
> >  			rte_pktmbuf_free(crypto_op->sym->m_src);
> > @@ -657,6 +696,21 @@ eca_ops_enqueue_burst(struct
> event_crypto_adapter
> > *adapter,
> >
> >  		rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
> >  		ev->event_ptr = ops[i];
> > +
> > +		/** restore ev::impl_opaque from mbuf dyn field
> Replace dynfield -> "dynamic field" in the comments
Updated in v4
> > +		 *  for session based crypto operation.
> > +		 *  For session-less, each crypto operations carries event
> > +		 *  metadata and retains ev::impl_opaque information to be
> > +		 *  passed back to eventdev PMD.
> > +		 */
> > +		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> > +			struct rte_mbuf *mbuf = ops[i]->sym->m_src;
> > +
> > +			ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
> > +							eca_dynfield_offset,
> > +							eca_dynfield_t *);
> > +		}
> > +
> >  		ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
> >  		if (adapter->implicit_release_disabled)
> >  			ev->op = RTE_EVENT_OP_FORWARD;
> > @@ -895,6 +949,16 @@ eca_init_service(struct event_crypto_adapter
> > *adapter, uint8_t id)
> >  	}
> >
> >  	adapter->implicit_release_disabled = (uint8_t)impl_rel;
> > +
> > +	/* Register for mbuf dyn field to store/restore ev::impl_opaque */
> > +	eca_dynfield_offset = eca_dynfield_register();
> > +	if (eca_dynfield_offset  < 0) {
> > +		RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
> > +		eca_circular_buffer_free(&adapter->ebuf);
> > +		rte_free(adapter);
> > +		return -EINVAL;
> > +	}
> > +
> >  	adapter->service_inited = 1;
> >
> >  	return ret;
> > --
> > 2.6.4


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

* [PATCH v5] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-06 13:35     ` [PATCH v4] " Ganapati Kundapura
@ 2024-06-06 13:48       ` Ganapati Kundapura
  2024-06-07  8:20         ` Jerin Jacob
  0 siblings, 1 reply; 11+ messages in thread
From: Ganapati Kundapura @ 2024-06-06 13:48 UTC (permalink / raw)
  To: jerinjacobk, dev, abhinandan.gujjar; +Cc: jay.jayatheerthan

For session-less crypto operations, event info is contained in
crypto op metadata for each event which is restored in event
from the crypto op metadata response info.

For session based crypto operations, crypto op contains per session
based event info in crypto op metadata. If any PMD passes any
implementation specific data in "struct rte_event::impl_opaque"
on each event, it's not getting restored.

This patch stores "struct rte_event::impl_opaque" in mbuf dynamic
field before enqueueing to cryptodev and restores
"struct rte_event::impl_opaque" from mbuf dynamic field after
dequeueing crypto op from cryptodev for session based crypto operations.

Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")

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

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

---
v5:
* Replaced ev::impl_opaque with "struct rte_event::impl_opaque"
* in eca_init_service()

v4:
* Replaced ev::impl_opaque with "struct rte_event::impl_opaque"
* Added Acked-by

v3:
* Added Fixes tag

v2:
* Fixed TYPO_SPELLING warning in commit header

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index db1c7f3..939ca1c 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -138,6 +138,28 @@ static struct event_crypto_adapter **event_crypto_adapter;
 	} \
 } while (0)
 
+#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
+/* Device-specific metadata field type */
+typedef uint8_t eca_dynfield_t;
+
+/* mbuf dynamic field offset for device-specific metadata */
+int eca_dynfield_offset = -1;
+
+static int
+eca_dynfield_register(void)
+{
+	static const struct rte_mbuf_dynfield eca_dynfield_desc = {
+		.name = ECA_DYNFIELD_NAME,
+		.size = sizeof(eca_dynfield_t),
+		.align = alignof(eca_dynfield_t),
+		.flags = 0,
+	};
+
+	eca_dynfield_offset =
+		rte_mbuf_dynfield_register(&eca_dynfield_desc);
+	return eca_dynfield_offset;
+}
+
 static inline int
 eca_valid_id(uint8_t id)
 {
@@ -491,6 +513,25 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
 		crypto_op = ev[i].event_ptr;
 		if (crypto_op == NULL)
 			continue;
+
+		/** "struct rte_event::impl_opaque" field passed on from
+		 *  eventdev PMD could have different value per event.
+		 *  For session-based crypto operations retain
+		 *  "struct rte_event::impl_opaque" into mbuf dynamic field and
+		 *  restore it back after copying event information from
+		 *  session event metadata.
+		 *  For session-less, each crypto operation carries event
+		 *  metadata and retains "struct rte_event:impl_opaque"
+		 *  information to be passed back to eventdev PMD.
+		 */
+		if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = crypto_op->sym->m_src;
+
+			*RTE_MBUF_DYNFIELD(mbuf,
+					eca_dynfield_offset,
+					eca_dynfield_t *) = ev[i].impl_opaque;
+		}
+
 		m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
 		if (m_data == NULL) {
 			rte_pktmbuf_free(crypto_op->sym->m_src);
@@ -657,6 +698,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
 
 		rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
 		ev->event_ptr = ops[i];
+
+		/** Restore "struct rte_event::impl_opaque" from mbuf
+		 *  dynamic field for session based crypto operation.
+		 *  For session-less, each crypto operations carries event
+		 *  metadata and retains "struct rte_event::impl_opaque"
+		 *  information to be passed back to eventdev PMD.
+		 */
+		if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			struct rte_mbuf *mbuf = ops[i]->sym->m_src;
+
+			ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
+							eca_dynfield_offset,
+							eca_dynfield_t *);
+		}
+
 		ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
 		if (adapter->implicit_release_disabled)
 			ev->op = RTE_EVENT_OP_FORWARD;
@@ -895,6 +951,18 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
 	}
 
 	adapter->implicit_release_disabled = (uint8_t)impl_rel;
+
+	/** Register for mbuf dyn field to store/restore
+	 *  "struct rte_event::impl_opaque"
+	 */
+	eca_dynfield_offset = eca_dynfield_register();
+	if (eca_dynfield_offset  < 0) {
+		RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
+		eca_circular_buffer_free(&adapter->ebuf);
+		rte_free(adapter);
+		return -EINVAL;
+	}
+
 	adapter->service_inited = 1;
 
 	return ret;
-- 
2.6.4


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

* Re: [PATCH v5] eventdev/crypto: restore opaque field between dequeue and enqueue
  2024-06-06 13:48       ` [PATCH v5] " Ganapati Kundapura
@ 2024-06-07  8:20         ` Jerin Jacob
  0 siblings, 0 replies; 11+ messages in thread
From: Jerin Jacob @ 2024-06-07  8:20 UTC (permalink / raw)
  To: Ganapati Kundapura; +Cc: dev, abhinandan.gujjar, jay.jayatheerthan

On Thu, Jun 6, 2024 at 7:18 PM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> For session-less crypto operations, event info is contained in
> crypto op metadata for each event which is restored in event
> from the crypto op metadata response info.
>
> For session based crypto operations, crypto op contains per session
> based event info in crypto op metadata. If any PMD passes any
> implementation specific data in "struct rte_event::impl_opaque"
> on each event, it's not getting restored.
>
> This patch stores "struct rte_event::impl_opaque" in mbuf dynamic
> field before enqueueing to cryptodev and restores
> "struct rte_event::impl_opaque" from mbuf dynamic field after
> dequeueing crypto op from cryptodev for session based crypto operations.
>
> Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")
>
> Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
>
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Changed git commit to fix following issues[1] and applied to
dpdk-next-eventdev/for-main. Thanks



eventdev/crypto: fix opaque field handling

For session-less crypto operations, event info is contained in
crypto op metadata for each event which is restored in event
from the crypto op metadata response info.

For session based crypto operations, crypto op contains per session
based event info in crypto op metadata. If any PMD passes any
implementation specific data in "struct rte_event::impl_opaque"
on each event, it's not getting restored.

This patch stores "struct rte_event::impl_opaque" in mbuf dynamic
field before enqueueing to cryptodev and restores
struct rte_event::impl_opaque" from mbuf dynamic field after
dequeueing crypto op from cryptodev for session based crypto operations.

Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")
Cc: stable@dpdk.org

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>

[1]


Headline too long:
        eventdev/crypto: restore opaque field between dequeue and enqueue
Is it candidate for Cc: stable@dpdk.org backport?
        eventdev/crypto: restore opaque field between dequeue and enqueue
Wrong tag order:
        eventdev/crypto: restore opaque field between dequeue and
enqueue (Signed-off-by:)

Invalid patch(es) found - checked 1 patch
check-git-log failed


>
> ---
> v5:
> * Replaced ev::impl_opaque with "struct rte_event::impl_opaque"
> * in eca_init_service()
>
> v4:
> * Replaced ev::impl_opaque with "struct rte_event::impl_opaque"
> * Added Acked-by
>
> v3:
> * Added Fixes tag
>
> v2:
> * Fixed TYPO_SPELLING warning in commit header
>
> diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
> index db1c7f3..939ca1c 100644
> --- a/lib/eventdev/rte_event_crypto_adapter.c
> +++ b/lib/eventdev/rte_event_crypto_adapter.c
> @@ -138,6 +138,28 @@ static struct event_crypto_adapter **event_crypto_adapter;
>         } \
>  } while (0)
>
> +#define ECA_DYNFIELD_NAME "eca_ev_opaque_data"
> +/* Device-specific metadata field type */
> +typedef uint8_t eca_dynfield_t;
> +
> +/* mbuf dynamic field offset for device-specific metadata */
> +int eca_dynfield_offset = -1;
> +
> +static int
> +eca_dynfield_register(void)
> +{
> +       static const struct rte_mbuf_dynfield eca_dynfield_desc = {
> +               .name = ECA_DYNFIELD_NAME,
> +               .size = sizeof(eca_dynfield_t),
> +               .align = alignof(eca_dynfield_t),
> +               .flags = 0,
> +       };
> +
> +       eca_dynfield_offset =
> +               rte_mbuf_dynfield_register(&eca_dynfield_desc);
> +       return eca_dynfield_offset;
> +}
> +
>  static inline int
>  eca_valid_id(uint8_t id)
>  {
> @@ -491,6 +513,25 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev,
>                 crypto_op = ev[i].event_ptr;
>                 if (crypto_op == NULL)
>                         continue;
> +
> +               /** "struct rte_event::impl_opaque" field passed on from
> +                *  eventdev PMD could have different value per event.
> +                *  For session-based crypto operations retain
> +                *  "struct rte_event::impl_opaque" into mbuf dynamic field and
> +                *  restore it back after copying event information from
> +                *  session event metadata.
> +                *  For session-less, each crypto operation carries event
> +                *  metadata and retains "struct rte_event:impl_opaque"
> +                *  information to be passed back to eventdev PMD.
> +                */
> +               if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +                       struct rte_mbuf *mbuf = crypto_op->sym->m_src;
> +
> +                       *RTE_MBUF_DYNFIELD(mbuf,
> +                                       eca_dynfield_offset,
> +                                       eca_dynfield_t *) = ev[i].impl_opaque;
> +               }
> +
>                 m_data = rte_cryptodev_session_event_mdata_get(crypto_op);
>                 if (m_data == NULL) {
>                         rte_pktmbuf_free(crypto_op->sym->m_src);
> @@ -657,6 +698,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
>
>                 rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
>                 ev->event_ptr = ops[i];
> +
> +               /** Restore "struct rte_event::impl_opaque" from mbuf
> +                *  dynamic field for session based crypto operation.
> +                *  For session-less, each crypto operations carries event
> +                *  metadata and retains "struct rte_event::impl_opaque"
> +                *  information to be passed back to eventdev PMD.
> +                */
> +               if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
> +                       struct rte_mbuf *mbuf = ops[i]->sym->m_src;
> +
> +                       ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf,
> +                                                       eca_dynfield_offset,
> +                                                       eca_dynfield_t *);
> +               }
> +
>                 ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
>                 if (adapter->implicit_release_disabled)
>                         ev->op = RTE_EVENT_OP_FORWARD;
> @@ -895,6 +951,18 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id)
>         }
>
>         adapter->implicit_release_disabled = (uint8_t)impl_rel;
> +
> +       /** Register for mbuf dyn field to store/restore
> +        *  "struct rte_event::impl_opaque"
> +        */
> +       eca_dynfield_offset = eca_dynfield_register();
> +       if (eca_dynfield_offset  < 0) {
> +               RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field");
> +               eca_circular_buffer_free(&adapter->ebuf);
> +               rte_free(adapter);
> +               return -EINVAL;
> +       }
> +
>         adapter->service_inited = 1;
>
>         return ret;
> --
> 2.6.4
>

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

end of thread, other threads:[~2024-06-07  8:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04 16:08 [PATCH v1] eventdev/crypto: restore opaque field between dequeue and enqueue Ganapati Kundapura
2024-06-04 16:18 ` [PATCH v2] " Ganapati Kundapura
2024-06-06  8:27   ` Jerin Jacob
2024-06-06 10:02     ` Jerin Jacob
2024-06-06 11:47       ` Kundapura, Ganapati
2024-06-06 11:46   ` [PATCH v3] " Ganapati Kundapura
2024-06-06 12:17     ` Gujjar, Abhinandan S
2024-06-06 13:37       ` Kundapura, Ganapati
2024-06-06 13:35     ` [PATCH v4] " Ganapati Kundapura
2024-06-06 13:48       ` [PATCH v5] " Ganapati Kundapura
2024-06-07  8:20         ` Jerin Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).