1 /* SPDX-License-Identifier: BSD-3-Clause
2 * see the individual elements.
3 * Copyright(c) 2019-2021 Broadcom
7 #include <rte_memcpy.h>
8 #include <rte_byteorder.h>
9 #include <rte_config.h>
11 #include <rte_ethdev.h>
12 #include <rte_lcore.h>
14 #include <rte_errno.h>
15 #include <rte_malloc.h>
16 #include <rte_spinlock.h>
21 #include "bnxt_hwrm.h"
22 #include "tf_msg_common.h"
25 * Sends TruFlow msg to the TruFlow Firmware using
26 * a message specific HWRM message type.
28 * Returns success or failure code.
31 tfp_send_msg_direct(struct bnxt *bp,
32 struct tfp_send_msg_parms *parms)
35 uint8_t use_kong_mb = 1;
40 if (parms->mailbox == TF_CHIMP_MB)
43 rc = bnxt_hwrm_tf_message_direct(bp,
55 * Allocates zeroed memory from the heap.
57 * Returns success or failure code.
60 tfp_calloc(struct tfp_calloc_parms *parms)
65 parms->mem_va = rte_zmalloc("tf",
66 (parms->nitems * parms->size),
68 if (parms->mem_va == NULL) {
69 TFP_DRV_LOG(ERR, "Allocate failed mem_va\n");
73 parms->mem_pa = (void *)((uintptr_t)rte_mem_virt2iova(parms->mem_va));
74 if (parms->mem_pa == (void *)((uintptr_t)RTE_BAD_IOVA)) {
75 TFP_DRV_LOG(ERR, "Allocate failed mem_pa\n");
83 * Frees the memory space pointed to by the provided pointer. The
84 * pointer must have been returned from the tfp_calloc().
93 * Copies n bytes from src memory to dest memory. The memory areas
97 tfp_memcpy(void *dest, void *src, size_t n)
99 rte_memcpy(dest, src, n);
103 * Used to initialize portable spin lock
106 tfp_spinlock_init(struct tfp_spinlock_parms *parms)
108 rte_spinlock_init(&parms->slock);
112 * Used to lock portable spin lock
115 tfp_spinlock_lock(struct tfp_spinlock_parms *parms)
117 rte_spinlock_lock(&parms->slock);
121 * Used to unlock portable spin lock
124 tfp_spinlock_unlock(struct tfp_spinlock_parms *parms)
126 rte_spinlock_unlock(&parms->slock);
130 tfp_get_fid(struct tf *tfp, uint16_t *fw_fid)
132 struct bnxt *bp = NULL;
134 if (tfp == NULL || fw_fid == NULL)
137 bp = (struct bnxt *)tfp->bp;
141 *fw_fid = bp->fw_fid;
147 tfp_get_pf(struct tf *tfp, uint16_t *pf)
149 struct bnxt *bp = NULL;
151 if (tfp == NULL || pf == NULL)
154 bp = (struct bnxt *)tfp->bp;
155 if (BNXT_VF(bp) && bp->parent) {
156 *pf = bp->parent->fid - 1;
158 } else if (BNXT_PF(bp)) {
159 *pf = bp->fw_fid - 1;