1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2018 Broadcom
8 #include <rte_cycles.h>
9 #include <rte_malloc.h>
14 #include "bnxt_ring.h"
15 #include "hsi_struct_def_dpdk.h"
21 static void bnxt_int_handler(void *param)
23 struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;
24 struct bnxt *bp = eth_dev->data->dev_private;
25 struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
26 struct cmpl_base *cmp;
33 raw_cons = cpr->cp_raw_cons;
35 if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell)
38 cons = RING_CMP(cpr->cp_ring_struct, raw_cons);
39 cmp = &cpr->cp_desc_ring[cons];
41 if (!CMP_VALID(cmp, raw_cons, cpr->cp_ring_struct))
44 bnxt_event_hwrm_resp_handler(bp, cmp);
45 raw_cons = NEXT_RAW_CMP(raw_cons);
48 cpr->cp_raw_cons = raw_cons;
52 B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
55 int bnxt_free_int(struct bnxt *bp)
57 struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle;
58 struct bnxt_irq *irq = bp->irq_tbl;
68 * Callback deregistration will fail with rc -EAGAIN if the
69 * callback is currently active. Retry every 50 ms until
70 * successful or 500 ms has elapsed.
73 rc = rte_intr_callback_unregister(intr_handle,
81 } while (count++ < 10);
84 PMD_DRV_LOG(ERR, "irq cb unregister failed rc: %d\n",
90 rte_free(bp->irq_tbl);
96 void bnxt_disable_int(struct bnxt *bp)
98 struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
100 if (BNXT_NUM_ASYNC_CPR(bp) == 0)
103 if (!cpr || !cpr->cp_db.doorbell)
106 /* Only the default completion ring */
113 void bnxt_enable_int(struct bnxt *bp)
115 struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
117 if (BNXT_NUM_ASYNC_CPR(bp) == 0)
120 if (!cpr || !cpr->cp_db.doorbell)
123 /* Only the default completion ring */
130 int bnxt_setup_int(struct bnxt *bp)
133 const int len = sizeof(bp->irq_tbl[0].name);
136 /* DPDK host only supports 1 MSI-X vector */
138 bp->irq_tbl = rte_calloc("bnxt_irq_tbl", total_vecs,
139 sizeof(struct bnxt_irq), 0);
141 for (i = 0; i < total_vecs; i++) {
142 bp->irq_tbl[i].vector = i;
143 snprintf(bp->irq_tbl[i].name, len,
144 "%s-%d", bp->eth_dev->device->name, i);
145 bp->irq_tbl[i].handler = bnxt_int_handler;
148 PMD_DRV_LOG(ERR, "bnxt_irq_tbl setup failed\n");
155 int bnxt_request_int(struct bnxt *bp)
157 struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle;
158 struct bnxt_irq *irq = bp->irq_tbl;
164 if (!irq->requested) {
165 rc = rte_intr_callback_register(intr_handle,