1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Cavium, Inc
6 #include <rte_bus_pci.h>
7 #include <rte_cryptodev.h>
8 #include <rte_malloc.h>
10 #include "cpt_pmd_logs.h"
12 #include "otx_cryptodev.h"
13 #include "otx_cryptodev_hw_access.h"
14 #include "otx_cryptodev_ops.h"
19 otx_cpt_alarm_cb(void *arg)
21 struct cpt_vf *cptvf = arg;
22 otx_cpt_poll_misc(cptvf);
23 rte_eal_alarm_set(CPT_INTR_POLL_INTERVAL_MS * 1000,
24 otx_cpt_alarm_cb, cptvf);
28 otx_cpt_periodic_alarm_start(void *arg)
30 return rte_eal_alarm_set(CPT_INTR_POLL_INTERVAL_MS * 1000,
31 otx_cpt_alarm_cb, arg);
35 otx_cpt_dev_create(struct rte_cryptodev *c_dev)
37 struct rte_pci_device *pdev = RTE_DEV_TO_PCI(c_dev->device);
38 struct cpt_vf *cptvf = NULL;
43 if (pdev->mem_resource[0].phys_addr == 0ULL)
46 /* for secondary processes, we don't initialise any further as primary
47 * has already done this work.
49 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
52 cptvf = rte_zmalloc_socket("otx_cryptodev_private_mem",
53 sizeof(struct cpt_vf), RTE_CACHE_LINE_SIZE,
57 CPT_LOG_ERR("Cannot allocate memory for device private data");
61 snprintf(dev_name, 32, "%02x:%02x.%x",
62 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
64 reg_base = pdev->mem_resource[0].addr;
66 CPT_LOG_ERR("Failed to map BAR0 of %s", dev_name);
71 ret = otx_cpt_hw_init(cptvf, pdev, reg_base, dev_name);
73 CPT_LOG_ERR("Failed to init cptvf %s", dev_name);
78 /* Start off timer for mailbox interrupts */
79 otx_cpt_periodic_alarm_start(cptvf);
81 c_dev->dev_ops = NULL;
83 c_dev->enqueue_burst = NULL;
84 c_dev->dequeue_burst = NULL;
86 c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
87 RTE_CRYPTODEV_FF_HW_ACCELERATED |
88 RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
89 RTE_CRYPTODEV_FF_IN_PLACE_SGL |
90 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
91 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
93 /* Save dev private data */
94 c_dev->data->dev_private = cptvf;
100 /* Free private data allocated */