/* spinlock for crypto device callbacks */
static rte_spinlock_t rte_cryptodev_cb_lock = RTE_SPINLOCK_INITIALIZER;
-
/**
* The user application callback description.
*
rte_crypto_aead_algorithm_strings[] = {
[RTE_CRYPTO_AEAD_AES_CCM] = "aes-ccm",
[RTE_CRYPTO_AEAD_AES_GCM] = "aes-gcm",
+ [RTE_CRYPTO_AEAD_CHACHA20_POLY1305] = "chacha20-poly1305"
};
/**
}
return NULL;
-
}
static int
mz = rte_memzone_reserve(mz_name,
sizeof(struct rte_cryptodev_data),
socket_id, 0);
- } else
+ CDEV_LOG_DEBUG("PRIMARY:reserved memzone for %s (%p)",
+ mz_name, mz);
+ } else {
mz = rte_memzone_lookup(mz_name);
+ CDEV_LOG_DEBUG("SECONDARY:looked up memzone for %s (%p)",
+ mz_name, mz);
+ }
if (mz == NULL)
return -ENOMEM;
RTE_ASSERT(*data == mz->addr);
*data = NULL;
- if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+ CDEV_LOG_DEBUG("PRIMARY:free memzone of %s (%p)",
+ mz_name, mz);
return rte_memzone_free(mz);
+ } else {
+ CDEV_LOG_DEBUG("SECONDARY:don't free memzone of %s (%p)",
+ mz_name, mz);
+ }
return 0;
}
cryptodev->data->dev_id = dev_id;
cryptodev->data->socket_id = socket_id;
cryptodev->data->dev_started = 0;
+ CDEV_LOG_DEBUG("PRIMARY:init data");
}
+ CDEV_LOG_DEBUG("Data for %s: dev_id %d, socket %d, started %d",
+ cryptodev->data->name,
+ cryptodev->data->dev_id,
+ cryptodev->data->socket_id,
+ cryptodev->data->dev_started);
+
/* init user callbacks */
TAILQ_INIT(&(cryptodev->link_intr_cbs));
return 0;
}
+int
+rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id)
+{
+ struct rte_cryptodev *dev;
+
+ if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
+ return -EINVAL;
+ }
+
+ dev = &rte_crypto_devices[dev_id];
+ if (queue_pair_id >= dev->data->nb_queue_pairs) {
+ CDEV_LOG_ERR("Invalid queue_pair_id=%d", queue_pair_id);
+ return -EINVAL;
+ }
+ void **qps = dev->data->queue_pairs;
+
+ if (qps[queue_pair_id]) {
+ CDEV_LOG_DEBUG("qp %d on dev %d is initialised",
+ queue_pair_id, dev_id);
+ return 1;
+ }
+
+ CDEV_LOG_DEBUG("qp %d on dev %d is not initialised",
+ queue_pair_id, dev_id);
+
+ return 0;
+}
+
int
rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
(*dev->dev_ops->stats_reset)(dev);
}
-
void
rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info)
{
dev_info->device = dev->device;
}
-
int
rte_cryptodev_callback_register(uint8_t dev_id,
enum rte_cryptodev_event_type event,
rte_spinlock_unlock(&rte_cryptodev_cb_lock);
}
-
int
rte_cryptodev_sym_session_init(uint8_t dev_id,
struct rte_cryptodev_sym_session *sess,
dev = rte_cryptodev_pmd_get_dev(dev_id);
- if (sess == NULL || xforms == NULL || dev == NULL)
+ if (sess == NULL || xforms == NULL || dev == NULL || mp == NULL)
return -EINVAL;
if (mp->elt_size < sess_priv_sz)
sess->user_data_sz;
}
+static uint8_t
+rte_cryptodev_sym_is_valid_session_pool(struct rte_mempool *mp)
+{
+ struct rte_cryptodev_sym_session_pool_private_data *pool_priv;
+
+ if (!mp)
+ return 0;
+
+ pool_priv = rte_mempool_get_priv(mp);
+
+ if (!pool_priv || mp->private_data_size < sizeof(*pool_priv) ||
+ pool_priv->nb_drivers != nb_drivers ||
+ mp->elt_size <
+ rte_cryptodev_sym_get_header_session_size()
+ + pool_priv->user_data_sz)
+ return 0;
+
+ return 1;
+}
+
struct rte_cryptodev_sym_session *
rte_cryptodev_sym_session_create(struct rte_mempool *mp)
{
struct rte_cryptodev_sym_session *sess;
struct rte_cryptodev_sym_session_pool_private_data *pool_priv;
- if (!mp) {
+ if (!rte_cryptodev_sym_is_valid_session_pool(mp)) {
CDEV_LOG_ERR("Invalid mempool\n");
return NULL;
}
pool_priv = rte_mempool_get_priv(mp);
- if (!pool_priv || mp->private_data_size < sizeof(*pool_priv)) {
- CDEV_LOG_ERR("Invalid mempool\n");
- return NULL;
- }
-
/* Allocate a session structure from the session pool */
if (rte_mempool_get(mp, (void **)&sess)) {
CDEV_LOG_ERR("couldn't get object from session mempool");
rte_cryptodev_asym_session_create(struct rte_mempool *mp)
{
struct rte_cryptodev_asym_session *sess;
+ unsigned int session_size =
+ rte_cryptodev_asym_get_header_session_size();
+
+ if (!mp) {
+ CDEV_LOG_ERR("invalid mempool\n");
+ return NULL;
+ }
+
+ /* Verify if provided mempool can hold elements big enough. */
+ if (mp->elt_size < session_size) {
+ CDEV_LOG_ERR(
+ "mempool elements too small to hold session objects");
+ return NULL;
+ }
/* Allocate a session structure from the session pool */
if (rte_mempool_get(mp, (void **)&sess)) {
/* Clear device session pointer.
* Include the flag indicating presence of private data
*/
- memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t));
+ memset(sess, 0, session_size);
rte_cryptodev_trace_asym_session_create(mp, sess);
return sess;
return dev->dev_ops->sym_cpu_process(dev, sess, ofs, vec);
}
+int
+rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id)
+{
+ struct rte_cryptodev *dev;
+ int32_t size = sizeof(struct rte_crypto_raw_dp_ctx);
+ int32_t priv_size;
+
+ if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+ return -EINVAL;
+
+ dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+ if (*dev->dev_ops->sym_get_raw_dp_ctx_size == NULL ||
+ !(dev->feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)) {
+ return -ENOTSUP;
+ }
+
+ priv_size = (*dev->dev_ops->sym_get_raw_dp_ctx_size)(dev);
+ if (priv_size < 0)
+ return -ENOTSUP;
+
+ return RTE_ALIGN_CEIL((size + priv_size), 8);
+}
+
+int
+rte_cryptodev_configure_raw_dp_ctx(uint8_t dev_id, uint16_t qp_id,
+ struct rte_crypto_raw_dp_ctx *ctx,
+ enum rte_crypto_op_sess_type sess_type,
+ union rte_cryptodev_session_ctx session_ctx,
+ uint8_t is_update)
+{
+ struct rte_cryptodev *dev;
+
+ if (!rte_cryptodev_get_qp_status(dev_id, qp_id))
+ return -EINVAL;
+
+ dev = rte_cryptodev_pmd_get_dev(dev_id);
+ if (!(dev->feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)
+ || dev->dev_ops->sym_configure_raw_dp_ctx == NULL)
+ return -ENOTSUP;
+
+ return (*dev->dev_ops->sym_configure_raw_dp_ctx)(dev, qp_id, ctx,
+ sess_type, session_ctx, is_update);
+}
+
+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,
+ void **user_data, int *enqueue_status)
+{
+ return (*ctx->enqueue_burst)(ctx->qp_data, ctx->drv_ctx_data, vec,
+ ofs, user_data, enqueue_status);
+}
+
+int
+rte_cryptodev_raw_enqueue_done(struct rte_crypto_raw_dp_ctx *ctx,
+ uint32_t n)
+{
+ return (*ctx->enqueue_done)(ctx->qp_data, ctx->drv_ctx_data, n);
+}
+
+uint32_t
+rte_cryptodev_raw_dequeue_burst(struct rte_crypto_raw_dp_ctx *ctx,
+ rte_cryptodev_raw_get_dequeue_count_t get_dequeue_count,
+ rte_cryptodev_raw_post_dequeue_t post_dequeue,
+ void **out_user_data, uint8_t is_user_data_array,
+ uint32_t *n_success_jobs, int *status)
+{
+ return (*ctx->dequeue_burst)(ctx->qp_data, ctx->drv_ctx_data,
+ get_dequeue_count, post_dequeue, out_user_data,
+ is_user_data_array, n_success_jobs, status);
+}
+
+int
+rte_cryptodev_raw_dequeue_done(struct rte_crypto_raw_dp_ctx *ctx,
+ uint32_t n)
+{
+ return (*ctx->dequeue_done)(ctx->qp_data, ctx->drv_ctx_data, n);
+}
+
/** Initialise rte_crypto_op mempool element */
static void
rte_crypto_op_init(struct rte_mempool *mempool,