1 /* SPDX-License-Identifier: BSD-3-Clause
2 * see the individual elements.
3 * Copyright(c) 2019-2020 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 tf *tfp,
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(container_of(tfp,
57 * Sends preformatted TruFlow msg to the TruFlow Firmware using
58 * the Truflow tunnel HWRM message type.
60 * Returns success or failure code.
63 tfp_send_msg_tunneled(struct tf *tfp,
64 struct tfp_send_msg_parms *parms)
67 uint8_t use_kong_mb = 1;
72 if (parms->mailbox == TF_CHIMP_MB)
75 rc = bnxt_hwrm_tf_message_tunneled(container_of(tfp,
91 * Allocates zero'ed memory from the heap.
93 * Returns success or failure code.
96 tfp_calloc(struct tfp_calloc_parms *parms)
101 parms->mem_va = rte_zmalloc("tf",
102 (parms->nitems * parms->size),
104 if (parms->mem_va == NULL) {
105 TFP_DRV_LOG(ERR, "Allocate failed mem_va\n");
109 parms->mem_pa = (void *)((uintptr_t)rte_mem_virt2iova(parms->mem_va));
110 if (parms->mem_pa == (void *)((uintptr_t)RTE_BAD_IOVA)) {
111 TFP_DRV_LOG(ERR, "Allocate failed mem_pa\n");
119 * Frees the memory space pointed to by the provided pointer. The
120 * pointer must have been returned from the tfp_calloc().
129 * Copies n bytes from src memory to dest memory. The memory areas
133 tfp_memcpy(void *dest, void *src, size_t n)
135 rte_memcpy(dest, src, n);
139 * Used to initialize portable spin lock
142 tfp_spinlock_init(struct tfp_spinlock_parms *parms)
144 rte_spinlock_init(&parms->slock);
148 * Used to lock portable spin lock
151 tfp_spinlock_lock(struct tfp_spinlock_parms *parms)
153 rte_spinlock_lock(&parms->slock);
157 * Used to unlock portable spin lock
160 tfp_spinlock_unlock(struct tfp_spinlock_parms *parms)
162 rte_spinlock_unlock(&parms->slock);
166 tfp_get_fid(struct tf *tfp, uint16_t *fw_fid)
168 struct bnxt *bp = NULL;
170 if (tfp == NULL || fw_fid == NULL)
173 bp = container_of(tfp, struct bnxt, tfp);
177 *fw_fid = bp->fw_fid;