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;
}
{
/*
* 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
}
+int __rte_experimental
+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_experimental
+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,
*/
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_experimental
+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_experimental
+rte_cryptodev_sym_session_get_private_data(
+ struct rte_cryptodev_sym_session *sess);
+
#ifdef __cplusplus
}
#endif