* [dpdk-dev] [dpdk-dev, v1, 2/3] cryptodev: add support to set session private data
@ 2018-04-04 6:34 Abhinandan Gujjar
2018-04-13 18:55 ` De Lara Guarch, Pablo
0 siblings, 1 reply; 2+ messages in thread
From: Abhinandan Gujjar @ 2018-04-04 6:34 UTC (permalink / raw)
To: pablo.de.lara.guarch, declan.doherty, jerin.jacob,
hemant.agrawal, akhil.goyal, dev
Cc: narender.vangati, abhinandan.gujjar, nikhil.rao
The application may want to store private data along with the
rte_cryptodev that is transparent to the rte_cryptodev layer.
For e.g., If an eventdev based application is submitting a
rte_cryptodev_sym_session operation and wants to indicate event
information required to construct a new event that will be
enqueued to eventdev after completion of the rte_cryptodev_sym_session
operation. This patch provides a mechanism for the application
to associate this information with the rte_cryptodev_sym_session session.
The application can set the private data using
rte_cryptodev_sym_session_set_private_data() and retrieve it using
rte_cryptodev_sym_session_get_private_data().
Signed-off-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
Signed-off-by: Nikhil Rao <nikhil.rao@intel.com>
---
lib/librte_cryptodev/rte_cryptodev.c | 43 +++++++++++++++++++++++---
lib/librte_cryptodev/rte_cryptodev.h | 32 +++++++++++++++++++
lib/librte_cryptodev/rte_cryptodev_version.map | 7 +++++
3 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 8745b6b..5275111 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1099,8 +1099,10 @@ struct rte_cryptodev_sym_session *
return NULL;
}
- /* Clear device session pointer */
- memset(sess, 0, (sizeof(void *) * nb_drivers));
+ /* Clear device session pointer.
+ * Include the flag indicating presence of private data
+ */
+ memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t));
return sess;
}
@@ -1204,9 +1206,10 @@ struct rte_cryptodev_sym_session *
{
/*
* Header contains pointers to the private data
- * of all registered drivers
+ * of all registered drivers, and a flag which
+ * indicates presence of private data
*/
- return (sizeof(void *) * nb_drivers);
+ return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t));
}
unsigned int
@@ -1238,6 +1241,38 @@ struct rte_cryptodev_sym_session *
}
+int
+rte_cryptodev_sym_session_set_private_data(
+ struct rte_cryptodev_sym_session *sess,
+ void *data,
+ uint16_t size)
+{
+ uint16_t off_set = sizeof(void *) * nb_drivers;
+ uint8_t *private_data_present = (uint8_t *)sess + off_set;
+
+ if (sess == NULL)
+ return -EINVAL;
+
+ *private_data_present = 1;
+ off_set += sizeof(uint8_t);
+ rte_memcpy((uint8_t *)sess + off_set, data, size);
+ return 0;
+}
+
+void *
+rte_cryptodev_sym_session_get_private_data(
+ struct rte_cryptodev_sym_session *sess)
+{
+ uint16_t off_set = sizeof(void *) * nb_drivers;
+ uint8_t *private_data_present = (uint8_t *)sess + off_set;
+
+ if (sess == NULL || !*private_data_present)
+ return NULL;
+
+ off_set += sizeof(uint8_t);
+ return (uint8_t *)sess + off_set;
+}
+
/** Initialise rte_crypto_op mempool element */
static void
rte_crypto_op_init(struct rte_mempool *mempool,
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index c8fa689..a75b3da 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -1037,6 +1037,38 @@ struct rte_cryptodev_sym_session *
*/
const char *rte_cryptodev_driver_name_get(uint8_t driver_id);
+/**
+ * Set private data for a session.
+ *
+ * @param sess Session pointer allocated by
+ * *rte_cryptodev_sym_session_create*.
+ * @param data Pointer to the private data.
+ * @param size Size of the private data.
+ *
+ * @return
+ * - On success, zero.
+ * - On failure, a negative value.
+ */
+int
+rte_cryptodev_sym_session_set_private_data(
+ struct rte_cryptodev_sym_session *sess,
+ void *data,
+ uint16_t size);
+
+/**
+ * Get private data of a session.
+ *
+ * @param sess Session pointer allocated by
+ * *rte_cryptodev_sym_session_create*.
+ *
+ * @return
+ * - On success return pointer to private data.
+ * - On failure returns NULL.
+ */
+void *
+rte_cryptodev_sym_session_get_private_data(
+ struct rte_cryptodev_sym_session *sess);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index eb47308..c3a3fda 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -85,3 +85,10 @@ DPDK_17.11 {
rte_cryptodev_pmd_parse_input_args;
} DPDK_17.08;
+
+DPDK_18.05 {
+ global:
+
+ rte_cryptodev_sym_session_set_private_data;
+ rte_cryptodev_sym_session_get_private_data;
+} DPDK_17.11;
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [dpdk-dev, v1, 2/3] cryptodev: add support to set session private data
2018-04-04 6:34 [dpdk-dev] [dpdk-dev, v1, 2/3] cryptodev: add support to set session private data Abhinandan Gujjar
@ 2018-04-13 18:55 ` De Lara Guarch, Pablo
0 siblings, 0 replies; 2+ messages in thread
From: De Lara Guarch, Pablo @ 2018-04-13 18:55 UTC (permalink / raw)
To: Gujjar, Abhinandan S, Doherty, Declan, jerin.jacob,
hemant.agrawal, akhil.goyal, dev
Cc: Vangati, Narender, Rao, Nikhil
Hi Abhinandan,
> -----Original Message-----
> From: Gujjar, Abhinandan S
> Sent: Wednesday, April 4, 2018 7:34 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>; jerin.jacob@caviumnetworks.com;
> hemant.agrawal@nxp.com; akhil.goyal@nxp.com; dev@dpdk.org
> Cc: Vangati, Narender <narender.vangati@intel.com>; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Rao, Nikhil <nikhil.rao@intel.com>
> Subject: [dpdk-dev,v1,2/3] cryptodev: add support to set session private data
>
Generally, it is better to directly use "support" in the title, and not "add support".
Maybe better write: "cryptodev: support session private data setting"
...
> diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map
> b/lib/librte_cryptodev/rte_cryptodev_version.map
> index eb47308..c3a3fda 100644
> --- a/lib/librte_cryptodev/rte_cryptodev_version.map
> +++ b/lib/librte_cryptodev/rte_cryptodev_version.map
> @@ -85,3 +85,10 @@ DPDK_17.11 {
> rte_cryptodev_pmd_parse_input_args;
>
> } DPDK_17.08;
> +
> +DPDK_18.05 {
> + global:
> +
> + rte_cryptodev_sym_session_set_private_data;
> + rte_cryptodev_sym_session_get_private_data;
This list has to be in alphabetical order.
Rest looks good to me, so:
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Lastly, since Akhil has acked the patch, you can add his and my ack in v2.
Thanks,
Pablo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-13 18:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04 6:34 [dpdk-dev] [dpdk-dev, v1, 2/3] cryptodev: add support to set session private data Abhinandan Gujjar
2018-04-13 18:55 ` De Lara Guarch, Pablo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).