1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2018 Broadcom
8 #include <rte_cycles.h>
9 #include <rte_malloc.h>
13 #include "bnxt_ring.h"
14 #include "hsi_struct_def_dpdk.h"
20 void bnxt_int_handler(void *param)
22 struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;
23 struct bnxt *bp = eth_dev->data->dev_private;
24 struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
25 struct cmpl_base *cmp;
32 raw_cons = cpr->cp_raw_cons;
34 if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell)
37 cons = RING_CMP(cpr->cp_ring_struct, raw_cons);
38 cmp = &cpr->cp_desc_ring[cons];
40 if (!CMP_VALID(cmp, raw_cons, cpr->cp_ring_struct))
43 bnxt_event_hwrm_resp_handler(bp, cmp);
44 raw_cons = NEXT_RAW_CMP(raw_cons);
47 cpr->cp_raw_cons = raw_cons;
51 B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
54 int bnxt_free_int(struct bnxt *bp)
56 struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle;
57 struct bnxt_irq *irq = bp->irq_tbl;
67 * Callback deregistration will fail with rc -EAGAIN if the
68 * callback is currently active. Retry every 50 ms until
69 * successful or 500 ms has elapsed.
72 rc = rte_intr_callback_unregister(intr_handle,
80 } while (count++ < 10);
83 PMD_DRV_LOG(ERR, "irq cb unregister failed rc: %d\n",
89 rte_free(bp->irq_tbl);
95 void bnxt_disable_int(struct bnxt *bp)
97 struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
99 if (BNXT_NUM_ASYNC_CPR(bp) == 0)
102 if (!cpr || !cpr->cp_db.doorbell)
105 /* Only the default completion ring */
112 void bnxt_enable_int(struct bnxt *bp)
114 struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
116 if (BNXT_NUM_ASYNC_CPR(bp) == 0)
119 if (!cpr || !cpr->cp_db.doorbell)
122 /* Only the default completion ring */
129 int bnxt_setup_int(struct bnxt *bp)
132 const int len = sizeof(bp->irq_tbl[0].name);
135 /* DPDK host only supports 1 MSI-X vector */
137 bp->irq_tbl = rte_calloc("bnxt_irq_tbl", total_vecs,
138 sizeof(struct bnxt_irq), 0);
140 for (i = 0; i < total_vecs; i++) {
141 bp->irq_tbl[i].vector = i;
142 snprintf(bp->irq_tbl[i].name, len,
143 "%s-%d", bp->eth_dev->device->name, i);
144 bp->irq_tbl[i].handler = bnxt_int_handler;
147 PMD_DRV_LOG(ERR, "bnxt_irq_tbl setup failed\n");
154 int bnxt_request_int(struct bnxt *bp)
156 struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle;
157 struct bnxt_irq *irq = bp->irq_tbl;
163 if (!irq->requested) {
164 rc = rte_intr_callback_register(intr_handle,