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->def_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;
49 B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
52 int bnxt_free_int(struct bnxt *bp)
54 struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle;
55 struct bnxt_irq *irq = bp->irq_tbl;
65 * Callback deregistration will fail with rc -EAGAIN if the
66 * callback is currently active. Retry every 50 ms until
67 * successful or 500 ms has elapsed.
70 rc = rte_intr_callback_unregister(intr_handle,
78 } while (count++ < 10);
81 PMD_DRV_LOG(ERR, "irq cb unregister failed rc: %d\n",
87 rte_free(bp->irq_tbl);
93 void bnxt_disable_int(struct bnxt *bp)
95 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
97 /* Only the default completion ring */
98 if (cpr != NULL && cpr->cp_db.doorbell != NULL)
102 void bnxt_enable_int(struct bnxt *bp)
104 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
106 /* Only the default completion ring */
107 if (cpr != NULL && cpr->cp_db.doorbell != NULL)
111 int bnxt_setup_int(struct bnxt *bp)
114 const int len = sizeof(bp->irq_tbl[0].name);
117 /* DPDK host only supports 1 MSI-X vector */
119 bp->irq_tbl = rte_calloc("bnxt_irq_tbl", total_vecs,
120 sizeof(struct bnxt_irq), 0);
122 for (i = 0; i < total_vecs; i++) {
123 bp->irq_tbl[i].vector = i;
124 snprintf(bp->irq_tbl[i].name, len,
125 "%s-%d", bp->eth_dev->device->name, i);
126 bp->irq_tbl[i].handler = bnxt_int_handler;
135 PMD_DRV_LOG(ERR, "bnxt_irq_tbl setup failed\n");
139 int bnxt_request_int(struct bnxt *bp)
141 struct rte_intr_handle *intr_handle = &bp->pdev->intr_handle;
142 struct bnxt_irq *irq = bp->irq_tbl;
148 if (!irq->requested) {
149 rc = rte_intr_callback_register(intr_handle,