1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 2019 Marvell International Ltd.
5 #include "otx2_common.h"
6 #include "otx2_cryptodev.h"
7 #include "otx2_cryptodev_hw_access.h"
9 #include "cpt_pmd_logs.h"
12 otx2_cpt_lf_err_intr_handler(void *param)
14 uintptr_t base = (uintptr_t)param;
18 lf_id = (base >> 12) & 0xFF;
20 intr = otx2_read64(base + OTX2_CPT_LF_MISC_INT);
24 CPT_LOG_ERR("LF %d MISC_INT: 0x%" PRIx64 "", lf_id, intr);
27 otx2_write64(intr, base + OTX2_CPT_LF_MISC_INT);
31 otx2_cpt_lf_err_intr_unregister(const struct rte_cryptodev *dev,
32 uint16_t msix_off, uintptr_t base)
34 struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
35 struct rte_intr_handle *handle = &pci_dev->intr_handle;
37 /* Disable error interrupts */
38 otx2_write64(~0ull, base + OTX2_CPT_LF_MISC_INT_ENA_W1C);
40 otx2_unregister_irq(handle, otx2_cpt_lf_err_intr_handler, (void *)base,
45 otx2_cpt_err_intr_unregister(const struct rte_cryptodev *dev)
47 struct otx2_cpt_vf *vf = dev->data->dev_private;
51 for (i = 0; i < vf->nb_queues; i++) {
52 base = OTX2_CPT_LF_BAR2(vf, i);
53 otx2_cpt_lf_err_intr_unregister(dev, vf->lf_msixoff[i], base);
56 vf->err_intr_registered = 0;
60 otx2_cpt_lf_err_intr_register(const struct rte_cryptodev *dev,
61 uint16_t msix_off, uintptr_t base)
63 struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
64 struct rte_intr_handle *handle = &pci_dev->intr_handle;
67 /* Disable error interrupts */
68 otx2_write64(~0ull, base + OTX2_CPT_LF_MISC_INT_ENA_W1C);
70 /* Register error interrupt handler */
71 ret = otx2_register_irq(handle, otx2_cpt_lf_err_intr_handler,
72 (void *)base, msix_off);
76 /* Enable error interrupts */
77 otx2_write64(~0ull, base + OTX2_CPT_LF_MISC_INT_ENA_W1S);
83 otx2_cpt_err_intr_register(const struct rte_cryptodev *dev)
85 struct otx2_cpt_vf *vf = dev->data->dev_private;
89 for (i = 0; i < vf->nb_queues; i++) {
90 if (vf->lf_msixoff[i] == MSIX_VECTOR_INVALID) {
91 CPT_LOG_ERR("Invalid CPT LF MSI-X offset: 0x%x",
97 for (i = 0; i < vf->nb_queues; i++) {
98 base = OTX2_CPT_LF_BAR2(vf, i);
99 ret = otx2_cpt_lf_err_intr_register(dev, vf->lf_msixoff[i],
102 goto intr_unregister;
105 vf->err_intr_registered = 1;
109 /* Unregister the ones already registered */
110 for (j = 0; j < i; j++) {
111 base = OTX2_CPT_LF_BAR2(vf, j);
112 otx2_cpt_lf_err_intr_unregister(dev, vf->lf_msixoff[j], base);
116 * Failed to register error interrupt. Not returning error as this would
117 * prevent application from enabling larger number of devs.
119 * This failure is a known issue because otx2_dev_init() initializes
120 * interrupts based on static values from ATF, and the actual number
121 * of interrupts needed (which is based on LFs) can be determined only
122 * after otx2_dev_init() sets up interrupts which includes mbox