1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2018 Broadcom
8 #include <rte_malloc.h>
13 #include "bnxt_ring.h"
14 #include "hsi_struct_def_dpdk.h"
20 static 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->def_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;
48 B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
51 void bnxt_free_int(struct bnxt *bp)
55 if (bp->irq_tbl == NULL)
61 rte_intr_callback_unregister(&bp->pdev->intr_handle,
66 rte_free((void *)bp->irq_tbl);
71 void bnxt_disable_int(struct bnxt *bp)
73 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
75 /* Only the default completion ring */
76 if (cpr != NULL && cpr->cp_db.doorbell != NULL)
80 void bnxt_enable_int(struct bnxt *bp)
82 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
84 /* Only the default completion ring */
85 if (cpr != NULL && cpr->cp_db.doorbell != NULL)
89 int bnxt_setup_int(struct bnxt *bp)
92 const int len = sizeof(bp->irq_tbl[0].name);
95 /* DPDK host only supports 1 MSI-X vector */
97 bp->irq_tbl = rte_calloc("bnxt_irq_tbl", total_vecs,
98 sizeof(struct bnxt_irq), 0);
100 for (i = 0; i < total_vecs; i++) {
101 bp->irq_tbl[i].vector = i;
102 snprintf(bp->irq_tbl[i].name, len,
103 "%s-%d", bp->eth_dev->device->name, i);
104 bp->irq_tbl[i].handler = bnxt_int_handler;
113 PMD_DRV_LOG(ERR, "bnxt_irq_tbl setup failed\n");
117 int bnxt_request_int(struct bnxt *bp)
121 struct bnxt_irq *irq = bp->irq_tbl;
123 rte_intr_callback_register(&bp->pdev->intr_handle, irq->handler,
124 (void *)bp->eth_dev);