1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 2019 Marvell International Ltd.
5 #include <rte_bus_pci.h>
6 #include <rte_common.h>
7 #include <rte_crypto.h>
8 #include <rte_cryptodev.h>
9 #include <rte_cryptodev_pmd.h>
11 #include <rte_errno.h>
12 #include <rte_mempool.h>
15 #include "otx2_common.h"
16 #include "otx2_cryptodev.h"
17 #include "otx2_cryptodev_ops.h"
19 /* CPT common headers */
20 #include "cpt_common.h"
21 #include "cpt_pmd_logs.h"
25 static struct rte_pci_id pci_id_cpt_table[] = {
27 RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
28 PCI_DEVID_OCTEONTX2_RVU_CPT_VF)
37 otx2_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
38 struct rte_pci_device *pci_dev)
40 struct rte_cryptodev_pmd_init_params init_params = {
42 .socket_id = rte_socket_id(),
43 .private_data_size = sizeof(struct otx2_cpt_vf)
45 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
46 struct rte_cryptodev *dev;
49 rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
51 dev = rte_cryptodev_pmd_create(name, &pci_dev->device, &init_params);
57 dev->dev_ops = &otx2_cpt_ops;
59 dev->driver_id = otx2_cryptodev_driver_id;
61 dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
62 RTE_CRYPTODEV_FF_HW_ACCELERATED;
67 CPT_LOG_ERR("Could not create device (vendor_id: 0x%x device_id: 0x%x)",
68 pci_dev->id.vendor_id, pci_dev->id.device_id);
73 otx2_cpt_pci_remove(struct rte_pci_device *pci_dev)
75 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
76 struct rte_cryptodev *dev;
81 rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
83 dev = rte_cryptodev_pmd_get_named_dev(name);
87 return rte_cryptodev_pmd_destroy(dev);
90 static struct rte_pci_driver otx2_cryptodev_pmd = {
91 .id_table = pci_id_cpt_table,
92 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
93 .probe = otx2_cpt_pci_probe,
94 .remove = otx2_cpt_pci_remove,
97 static struct cryptodev_driver otx2_cryptodev_drv;
99 RTE_INIT(otx2_cpt_init_log);
100 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX2_PMD, otx2_cryptodev_pmd);
101 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX2_PMD, pci_id_cpt_table);
102 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx2_cryptodev_drv, otx2_cryptodev_pmd.driver,
103 otx2_cryptodev_driver_id);
105 RTE_INIT(otx2_cpt_init_log)
108 otx2_cpt_logtype = rte_log_register("pmd.crypto.octeontx2");
109 if (otx2_cpt_logtype >= 0)
110 rte_log_set_level(otx2_cpt_logtype, RTE_LOG_NOTICE);