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 = (struct bnxt *)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)
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 switch (CMP_TYPE(cmp)) {
44 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
45 /* Handle any async event */
46 bnxt_handle_async_event(bp, cmp);
48 case CMPL_BASE_TYPE_HWRM_FWD_REQ:
49 /* Handle HWRM forwarded responses */
50 bnxt_handle_fwd_req(bp, cmp);
53 /* Ignore any other events */
54 if (cmp->type & rte_cpu_to_le_16(0x01)) {
55 if (!CMP_VALID(cmp, raw_cons,
60 "Ignoring %02x completion\n", CMP_TYPE(cmp));
63 raw_cons = NEXT_RAW_CMP(raw_cons);
67 cpr->cp_raw_cons = raw_cons;
68 B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
71 void bnxt_free_int(struct bnxt *bp)
78 rte_intr_disable(&bp->pdev->intr_handle);
79 rte_intr_callback_unregister(&bp->pdev->intr_handle,
84 rte_free((void *)bp->irq_tbl);
89 void bnxt_disable_int(struct bnxt *bp)
91 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
93 /* Only the default completion ring */
94 if (cpr != NULL && cpr->cp_doorbell != NULL)
98 void bnxt_enable_int(struct bnxt *bp)
100 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
105 int bnxt_setup_int(struct bnxt *bp)
108 const int len = sizeof(bp->irq_tbl[0].name);
111 /* DPDK host only supports 1 MSI-X vector */
113 bp->irq_tbl = rte_calloc("bnxt_irq_tbl", total_vecs,
114 sizeof(struct bnxt_irq), 0);
116 for (i = 0; i < total_vecs; i++) {
117 bp->irq_tbl[i].vector = i;
118 snprintf(bp->irq_tbl[i].name, len,
119 "%s-%d", bp->eth_dev->device->name, i);
120 bp->irq_tbl[i].handler = bnxt_int_handler;
129 PMD_DRV_LOG(ERR, "bnxt_irq_tbl setup failed\n");
133 int bnxt_request_int(struct bnxt *bp)
137 struct bnxt_irq *irq = bp->irq_tbl;
139 rte_intr_callback_register(&bp->pdev->intr_handle, irq->handler,
140 (void *)bp->eth_dev);
141 rte_intr_enable(&bp->pdev->intr_handle);