return 0;
}
-void qat_dev_info_get(struct rte_cryptodev *dev,
+void qat_sym_dev_info_get(struct rte_cryptodev *dev,
struct rte_cryptodev_info *info)
{
- struct qat_pmd_private *internals = dev->data->dev_private;
+ struct qat_sym_dev_private *internals = dev->data->dev_private;
const struct qat_qp_hw_data *sym_hw_qps =
- qp_gen_config[internals->qat_dev_gen]
+ qp_gen_config[internals->qat_dev->qat_dev_gen]
.qp_hw_data[QAT_SERVICE_SYMMETRIC];
PMD_INIT_FUNC_TRACE();
qat_qps_per_service(sym_hw_qps, QAT_SERVICE_SYMMETRIC);
info->feature_flags = dev->feature_flags;
info->capabilities = internals->qat_dev_capabilities;
- info->sym.max_nb_sessions = internals->max_nb_sessions;
+ info->sym.max_nb_sessions = RTE_QAT_PMD_MAX_NB_SESSIONS;
info->driver_id = cryptodev_qat_driver_id;
info->pci_dev = RTE_DEV_TO_PCI(dev->device);
}
{
return &qat_pci_devices[dev_id];
}
+
static struct qat_pci_device *
qat_pci_get_named_dev(const char *name)
{
char name[QAT_DEV_NAME_MAX_LEN];
rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
-
+ snprintf(name+strlen(name), QAT_DEV_NAME_MAX_LEN-strlen(name), "_qat");
if (qat_pci_get_named_dev(name) != NULL) {
PMD_DRV_LOG(ERR, "QAT device with name %s already allocated!",
name);
qat_dev = qat_pci_get_dev(qat_dev_id);
snprintf(qat_dev->name, QAT_DEV_NAME_MAX_LEN, "%s", name);
+ qat_dev->qat_dev_id = qat_dev_id;
qat_dev->pci_dev = pci_dev;
switch (qat_dev->pci_dev->id.device_id) {
case 0x0443:
qat_nb_pci_devices++;
- PMD_DRV_LOG(DEBUG, "QAT device %d allocated, total QATs %d",
- qat_dev_id, qat_nb_pci_devices);
+ PMD_DRV_LOG(DEBUG, "QAT device %d allocated, name %s, total QATs %d",
+ qat_dev->qat_dev_id, qat_dev->name, qat_nb_pci_devices);
return qat_dev;
}
return -EINVAL;
rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+ snprintf(name+strlen(name), QAT_DEV_NAME_MAX_LEN-strlen(name), "_qat");
qat_dev = qat_pci_get_named_dev(name);
if (qat_dev != NULL) {
* - config data
* - runtime data
*/
+struct qat_sym_dev_private;
struct qat_pci_device {
- /* data used by all services */
+ /* Data used by all services */
char name[QAT_DEV_NAME_MAX_LEN];
/**< Name of qat pci device */
+ uint8_t qat_dev_id;
+ /**< Device instance for this qat pci device */
struct rte_pci_device *pci_dev;
/**< PCI information. */
enum qat_device_gen qat_dev_gen;
/**< QAT device generation */
rte_spinlock_t arb_csr_lock;
- /* protects accesses to the arbiter CSR */
+ /**< lock to protect accesses to the arbiter CSR */
__extension__
uint8_t attached : 1;
/**< Flag indicating the device is attached */
- /* data relating to symmetric crypto service */
- struct qat_pmd_private *sym_dev;
+ /* Data relating to symmetric crypto service */
+ struct qat_sym_dev_private *sym_dev;
/**< link back to cryptodev private data */
- unsigned int max_nb_sym_queue_pairs;
- /**< Max number of queue pairs supported by device */
- /* data relating to compression service */
+ /* Data relating to compression service */
- /* data relating to asymmetric crypto service */
+ /* Data relating to asymmetric crypto service */
};
* there can be one of these on each qat_pci_device (VF),
* in future there may also be private data structures for other services.
*/
-struct qat_pmd_private {
- unsigned int max_nb_queue_pairs;
- /**< Max number of queue pairs supported by device */
- unsigned int max_nb_sessions;
- /**< Max number of sessions supported by device */
- enum qat_device_gen qat_dev_gen;
- /**< QAT device generation */
- const struct rte_cryptodev_capabilities *qat_dev_capabilities;
- /* QAT device capabilities */
- struct rte_pci_device *pci_dev;
- /**< PCI information. */
- uint8_t dev_id;
- /**< Device ID for this instance */
+struct qat_sym_dev_private {
struct qat_pci_device *qat_dev;
/**< The qat pci device hosting the service */
+ uint8_t sym_dev_id;
+ /**< Device instance for this rte_cryptodev */
+ const struct rte_cryptodev_capabilities *qat_dev_capabilities;
+ /* QAT device symmetric crypto capabilities */
};
struct qat_gen_hw_data {
int qat_dev_start(struct rte_cryptodev *dev);
void qat_dev_stop(struct rte_cryptodev *dev);
int qat_dev_close(struct rte_cryptodev *dev);
-void qat_dev_info_get(struct rte_cryptodev *dev,
+void qat_sym_dev_info_get(struct rte_cryptodev *dev,
struct rte_cryptodev_info *info);
struct qat_pci_device *
static int qat_qp_check_queue_alignment(uint64_t phys_addr,
uint32_t queue_size_bytes);
static void qat_queue_delete(struct qat_queue *queue);
-static int qat_queue_create(struct qat_pmd_private *qat_dev,
+static int qat_queue_create(struct qat_pci_device *qat_dev,
struct qat_queue *queue, struct qat_qp_config *, uint8_t dir);
static int adf_verify_queue_size(uint32_t msg_size, uint32_t msg_num,
uint32_t *queue_size_for_csr);
socket_id, RTE_MEMZONE_IOVA_CONTIG, queue_size);
}
-int qat_qp_setup(struct qat_pmd_private *qat_dev,
+int qat_qp_setup(struct qat_pci_device *qat_dev,
struct qat_qp **qp_addr,
uint16_t queue_pair_id,
struct qat_qp_config *qat_qp_conf)
char op_cookie_pool_name[RTE_RING_NAMESIZE];
uint32_t i;
- PMD_DRV_LOG(DEBUG, "Setup qp %u on device %d gen %d",
- queue_pair_id, qat_dev->dev_id, qat_dev->qat_dev_gen);
+ PMD_DRV_LOG(DEBUG, "Setup qp %u on qat pci device %d gen %d",
+ queue_pair_id, qat_dev->qat_dev_id, qat_dev->qat_dev_gen);
if ((qat_qp_conf->nb_descriptors > ADF_MAX_DESC) ||
(qat_qp_conf->nb_descriptors < ADF_MIN_DESC)) {
adf_configure_queues(qp);
adf_queue_arb_enable(&qp->tx_q, qp->mmap_bar_addr);
- snprintf(op_cookie_pool_name, RTE_RING_NAMESIZE, "%s_%s_qp_op_%d_%hu",
- pci_dev->driver->driver.name, qat_qp_conf->service_str,
- qat_dev->dev_id, queue_pair_id);
+ snprintf(op_cookie_pool_name, RTE_RING_NAMESIZE,
+ "%s%d_cookies_%s_qp%hu",
+ pci_dev->driver->driver.name, qat_dev->qat_dev_id,
+ qat_qp_conf->service_str, queue_pair_id);
+ PMD_DRV_LOG(DEBUG, "cookiepool: %s", op_cookie_pool_name);
qp->op_cookie_pool = rte_mempool_lookup(op_cookie_pool_name);
if (qp->op_cookie_pool == NULL)
qp->op_cookie_pool = rte_mempool_create(op_cookie_pool_name,
}
PMD_DRV_LOG(DEBUG, "Free qp on qat_pci device %d",
- qp->qat_dev->dev_id);
+ qp->qat_dev->qat_dev_id);
/* Don't free memory if there are still responses to be processed */
if (qp->inflights16 == 0) {
}
static int
-qat_queue_create(struct qat_pmd_private *qat_dev, struct qat_queue *queue,
+qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue,
struct qat_qp_config *qp_conf, uint8_t dir)
{
uint64_t queue_base;
* Allocate a memzone for the queue - create a unique name.
*/
snprintf(queue->memz_name, sizeof(queue->memz_name),
- "%s_%s_%s_%d_%d_%d",
- pci_dev->driver->driver.name, qp_conf->service_str,
- "qp_mem", qat_dev->dev_id,
+ "%s_%d_%s_%s_%d_%d",
+ pci_dev->driver->driver.name, qat_dev->qat_dev_id,
+ qp_conf->service_str, "qp_mem",
queue->hw_bundle_number, queue->hw_queue_number);
qp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes,
qp_conf->socket_id);
enum qat_device_gen qat_dev_gen;
build_request_t build_request;
process_response_t process_response;
- struct qat_pmd_private *qat_dev;
+ struct qat_pci_device *qat_dev;
/**< qat device this qp is on */
} __rte_cache_aligned;
qat_qp_release(struct qat_qp **qp_addr);
int
-qat_qp_setup(struct qat_pmd_private *qat_dev,
+qat_qp_setup(struct qat_pci_device *qat_dev,
struct qat_qp **qp_addr, uint16_t queue_pair_id,
struct qat_qp_config *qat_qp_conf);
return qat_enqueue_op_burst(qp, (void **)ops, nb_ops);
}
-int
+static int
qat_sym_process_response(void **op, uint8_t *resp,
__rte_unused void *op_cookie,
__rte_unused enum qat_device_gen qat_dev_gen)
iv_length);
}
-
-int
+static int
qat_sym_build_request(void *in_op, uint8_t *out_msg,
void *op_cookie, enum qat_device_gen qat_dev_gen)
{
struct qat_qp **qp_addr =
(struct qat_qp **)&(dev->data->queue_pairs[qp_id]);
- struct qat_pmd_private *qat_private = dev->data->dev_private;
+ struct qat_sym_dev_private *qat_private = dev->data->dev_private;
const struct qat_qp_hw_data *sym_hw_qps =
- qp_gen_config[qat_private->qat_dev_gen]
+ qp_gen_config[qat_private->qat_dev->qat_dev_gen]
.qp_hw_data[QAT_SERVICE_SYMMETRIC];
const struct qat_qp_hw_data *qp_hw_data = sym_hw_qps + qp_id;
qat_qp_conf.socket_id = socket_id;
qat_qp_conf.service_str = "sym";
- ret = qat_qp_setup(qat_private, qp_addr, qp_id, &qat_qp_conf);
+ ret = qat_qp_setup(qat_private->qat_dev, qp_addr, qp_id, &qat_qp_conf);
if (ret != 0)
return ret;
phys_addr_t qat_sgl_dst_phys_addr;
};
-int
-qat_sym_build_request(void *in_op, uint8_t *out_msg,
- void *op_cookie, enum qat_device_gen qat_dev_gen);
-
-int
-qat_sym_process_response(void **op, uint8_t *resp,
- __rte_unused void *op_cookie, enum qat_device_gen qat_dev_gen);
-
void qat_sym_stats_get(struct rte_cryptodev *dev,
struct rte_cryptodev_stats *stats);
void qat_sym_stats_reset(struct rte_cryptodev *dev);
static int
qat_is_cipher_alg_supported(enum rte_crypto_cipher_algorithm algo,
- struct qat_pmd_private *internals)
+ struct qat_sym_dev_private *internals)
{
int i = 0;
const struct rte_cryptodev_capabilities *capability;
static int
qat_is_auth_alg_supported(enum rte_crypto_auth_algorithm algo,
- struct qat_pmd_private *internals)
+ struct qat_sym_dev_private *internals)
{
int i = 0;
const struct rte_cryptodev_capabilities *capability;
struct rte_crypto_sym_xform *xform,
struct qat_sym_session *session)
{
- struct qat_pmd_private *internals = dev->data->dev_private;
+ struct qat_sym_dev_private *internals = dev->data->dev_private;
struct rte_crypto_cipher_xform *cipher_xform = NULL;
int ret;
struct qat_sym_session *session)
{
struct rte_crypto_auth_xform *auth_xform = qat_get_auth_xform(xform);
- struct qat_pmd_private *internals = dev->data->dev_private;
+ struct qat_sym_dev_private *internals = dev->data->dev_private;
uint8_t *key_data = auth_xform->key.data;
uint8_t key_length = auth_xform->key.length;
.dev_start = qat_dev_start,
.dev_stop = qat_dev_stop,
.dev_close = qat_dev_close,
- .dev_infos_get = qat_dev_info_get,
+ .dev_infos_get = qat_sym_dev_info_get,
.stats_get = qat_sym_stats_get,
.stats_reset = qat_sym_stats_reset,
struct rte_cryptodev_pmd_init_params init_params = {
.name = "",
.socket_id = qat_pci_dev->pci_dev->device.numa_node,
- .private_data_size = sizeof(struct qat_pmd_private),
+ .private_data_size = sizeof(struct qat_sym_dev_private),
.max_nb_sessions = RTE_QAT_PMD_MAX_NB_SESSIONS
};
char name[RTE_CRYPTODEV_NAME_MAX_LEN];
struct rte_cryptodev *cryptodev;
- struct qat_pmd_private *internals;
+ struct qat_sym_dev_private *internals;
snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN, "%s_%s",
qat_pci_dev->name, "sym");
internals->qat_dev = qat_pci_dev;
qat_pci_dev->sym_dev = internals;
- internals->max_nb_sessions = init_params.max_nb_sessions;
- internals->pci_dev = RTE_DEV_TO_PCI(cryptodev->device);
- internals->dev_id = cryptodev->data->dev_id;
- switch (internals->pci_dev->id.device_id) {
- case 0x0443:
- internals->qat_dev_gen = QAT_GEN1;
+ internals->sym_dev_id = cryptodev->data->dev_id;
+ switch (qat_pci_dev->qat_dev_gen) {
+ case QAT_GEN1:
internals->qat_dev_capabilities = qat_gen1_sym_capabilities;
break;
- case 0x37c9:
- case 0x19e3:
- case 0x6f55:
- internals->qat_dev_gen = QAT_GEN2;
+ case QAT_GEN2:
internals->qat_dev_capabilities = qat_gen2_sym_capabilities;
break;
default:
- PMD_DRV_LOG(ERR,
- "Invalid dev_id, can't determine capabilities");
+ internals->qat_dev_capabilities = qat_gen2_sym_capabilities;
+ PMD_DRV_LOG(DEBUG,
+ "QAT gen %d capabilities unknown, default to GEN2",
+ qat_pci_dev->qat_dev_gen);
break;
}
- return 0;
+ PMD_DRV_LOG(DEBUG, "Created QAT SYM device %s as cryptodev instance %d",
+ name, internals->sym_dev_id);
+ return 0;
}
static int
return 0;
/* free crypto device */
- cryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->dev_id);
+ cryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->sym_dev_id);
rte_cryptodev_pmd_destroy(cryptodev);
qat_pci_dev->sym_dev = NULL;