| 1430 | } |
| 1431 | |
| 1432 | int |
| 1433 | rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, |
| 1434 | const struct rte_cryptodev_qp_conf *qp_conf, int socket_id) |
| 1435 | |
| 1436 | { |
| 1437 | struct rte_cryptodev *dev; |
| 1438 | |
| 1439 | if (!rte_cryptodev_is_valid_dev(dev_id)) { |
| 1440 | CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); |
| 1441 | return -EINVAL; |
| 1442 | } |
| 1443 | |
| 1444 | dev = &rte_crypto_devices[dev_id]; |
| 1445 | if (queue_pair_id >= dev->data->nb_queue_pairs) { |
| 1446 | CDEV_LOG_ERR("Invalid queue_pair_id=%d", queue_pair_id); |
| 1447 | return -EINVAL; |
| 1448 | } |
| 1449 | |
| 1450 | if (!qp_conf) { |
| 1451 | CDEV_LOG_ERR("qp_conf cannot be NULL"); |
| 1452 | return -EINVAL; |
| 1453 | } |
| 1454 | |
| 1455 | if (qp_conf->mp_session) { |
| 1456 | struct rte_cryptodev_sym_session_pool_private_data *pool_priv; |
| 1457 | |
| 1458 | pool_priv = rte_mempool_get_priv(qp_conf->mp_session); |
| 1459 | if (!pool_priv || qp_conf->mp_session->private_data_size < |
| 1460 | sizeof(*pool_priv)) { |
| 1461 | CDEV_LOG_ERR("Invalid mempool"); |
| 1462 | return -EINVAL; |
| 1463 | } |
| 1464 | |
| 1465 | if (!rte_cryptodev_sym_is_valid_session_pool(qp_conf->mp_session, |
| 1466 | rte_cryptodev_sym_get_private_session_size(dev_id))) { |
| 1467 | CDEV_LOG_ERR("Invalid mempool"); |
| 1468 | return -EINVAL; |
| 1469 | } |
| 1470 | } |
| 1471 | |
| 1472 | if (dev->data->dev_started) { |
| 1473 | CDEV_LOG_ERR( |
| 1474 | "device %d must be stopped to allow configuration", dev_id); |
| 1475 | return -EBUSY; |
| 1476 | } |
| 1477 | |
| 1478 | if (*dev->dev_ops->queue_pair_setup == NULL) |
| 1479 | return -ENOTSUP; |
| 1480 | |
| 1481 | rte_cryptodev_trace_queue_pair_setup(dev_id, queue_pair_id, qp_conf); |
| 1482 | return (*dev->dev_ops->queue_pair_setup)(dev, queue_pair_id, qp_conf, |
| 1483 | socket_id); |
| 1484 | } |
| 1485 | |
| 1486 | struct rte_cryptodev_cb * |
| 1487 | rte_cryptodev_add_enq_callback(uint8_t dev_id, |