1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
7 * This header file defines the Portability structures and APIs for
14 #include <rte_config.h>
15 #include <rte_spinlock.h>
17 #include <rte_byteorder.h>
21 * DPDK/Driver specific log level for the BNXT Eth driver.
23 extern int bnxt_logtype_driver;
27 struct tfp_spinlock_parms {
31 #define TFP_DRV_LOG_RAW(level, fmt, args...) \
32 rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \
35 #define TFP_DRV_LOG(level, fmt, args...) \
36 TFP_DRV_LOG_RAW(level, fmt, ## args)
41 * TruFlow Portability API Header File
45 * send message parameter definition
47 struct tfp_send_msg_parms {
49 * [in] mailbox, specifying the Mailbox to send the command on.
53 * [in] tlv_subtype, specifies the tlv_type.
57 * [in] tlv_subtype, specifies the tlv_subtype.
61 * [out] size, number specifying the request size of the data in bytes
65 * [in] data, pointer to the data to be sent within the HWRM command
69 * [out] size, number specifying the response size of the data in bytes
73 * [out] data, pointer to the data to be sent within the HWRM command
79 * calloc parameter definition
81 struct tfp_calloc_parms {
83 * [in] nitems, number specifying number of items to allocate.
87 * [in] size, number specifying the size of each memory item
88 * requested. Size is in bytes.
92 * [in] alignment, number indicates byte alignment required. 0
93 * - don't care, 16 - 16 byte alignment, 4K - 4K alignment etc
97 * [out] mem_va, pointer to the allocated memory.
101 * [out] mem_pa, physical address of the allocated memory.
109 * @ref tfp_send_direct
115 * @ref tfp_spinlock_init
116 * @ref tfp_spinlock_lock
117 * @ref tfp_spinlock_unlock
122 * Provides communication capability from the TruFlow API layer to
123 * the TruFlow firmware. The portability layer internally provides
124 * the transport to the firmware.
126 * [in] session, pointer to session handle
127 * [in] parms, parameter structure
131 * -1 - Global error like not supported
132 * -EINVAL - Parameter Error
134 int tfp_send_msg_direct(struct bnxt *bp,
135 struct tfp_send_msg_parms *parms);
138 * Sends OEM command message to Chimp
140 * [in] session, pointer to session handle
141 * [in] max_flows, max number of flows requested
145 * -1 - Global error like not supported
146 * -EINVAL - Parameter Error
149 tfp_msg_hwrm_oem_cmd(struct tf *tfp,
153 * Allocates zeroed memory from the heap.
155 * NOTE: Also performs virt2phy address conversion by default thus is
156 * can be expensive to invoke.
158 * [in] parms, parameter structure
162 * -ENOMEM - No memory available
163 * -EINVAL - Parameter error
165 int tfp_calloc(struct tfp_calloc_parms *parms);
166 void tfp_memcpy(void *dest, void *src, size_t n);
167 void tfp_free(void *addr);
169 void tfp_spinlock_init(struct tfp_spinlock_parms *slock);
170 void tfp_spinlock_lock(struct tfp_spinlock_parms *slock);
171 void tfp_spinlock_unlock(struct tfp_spinlock_parms *slock);
174 * Lookup of the FID in the platform specific structure.
177 * Pointer to session handle
180 * Pointer to the fw_fid
184 * -EINVAL - Parameter error
186 int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
190 * @ref tfp_cpu_to_le_16
191 * @ref tfp_le_to_cpu_16
192 * @ref tfp_cpu_to_le_32
193 * @ref tfp_le_to_cpu_32
194 * @ref tfp_cpu_to_le_64
195 * @ref tfp_le_to_cpu_64
196 * @ref tfp_cpu_to_be_16
197 * @ref tfp_be_to_cpu_16
198 * @ref tfp_cpu_to_be_32
199 * @ref tfp_be_to_cpu_32
200 * @ref tfp_cpu_to_be_64
201 * @ref tfp_be_to_cpu_64
204 #define tfp_cpu_to_le_16(val) rte_cpu_to_le_16(val)
205 #define tfp_le_to_cpu_16(val) rte_le_to_cpu_16(val)
206 #define tfp_cpu_to_le_32(val) rte_cpu_to_le_32(val)
207 #define tfp_le_to_cpu_32(val) rte_le_to_cpu_32(val)
208 #define tfp_cpu_to_le_64(val) rte_cpu_to_le_64(val)
209 #define tfp_le_to_cpu_64(val) rte_le_to_cpu_64(val)
210 #define tfp_cpu_to_be_16(val) rte_cpu_to_be_16(val)
211 #define tfp_be_to_cpu_16(val) rte_be_to_cpu_16(val)
212 #define tfp_cpu_to_be_32(val) rte_cpu_to_be_32(val)
213 #define tfp_be_to_cpu_32(val) rte_be_to_cpu_32(val)
214 #define tfp_cpu_to_be_64(val) rte_cpu_to_be_64(val)
215 #define tfp_be_to_cpu_64(val) rte_be_to_cpu_64(val)
216 #define tfp_bswap_16(val) rte_bswap16(val)
217 #define tfp_bswap_32(val) rte_bswap32(val)
218 #define tfp_bswap_64(val) rte_bswap64(val)
221 * Get the PF associated with the fw communications channel.
224 * Pointer to session handle
227 * Pointer to the pf id
234 int tfp_get_pf(struct tf *tfp, uint16_t *pf);