1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 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>
20 * DPDK/Driver specific log level for the BNXT Eth driver.
22 extern int bnxt_logtype_driver;
26 struct tfp_spinlock_parms {
30 #define TFP_DRV_LOG_RAW(level, fmt, args...) \
31 rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \
34 #define TFP_DRV_LOG(level, fmt, args...) \
35 TFP_DRV_LOG_RAW(level, fmt, ## args)
40 * TrueFlow Portability API Header File
44 * send message parameter definition
46 struct tfp_send_msg_parms {
48 * [in] mailbox, specifying the Mailbox to send the command on.
52 * [in] tlv_subtype, specifies the tlv_type.
56 * [in] tlv_subtype, specifies the tlv_subtype.
60 * [out] tf_resp_code, response code from the internal tlv
61 * message. Only supported on tunneled messages.
63 uint32_t tf_resp_code;
65 * [out] size, number specifying the request size of the data in bytes
69 * [in] data, pointer to the data to be sent within the HWRM command
73 * [out] size, number specifying the response size of the data in bytes
77 * [out] data, pointer to the data to be sent within the HWRM command
83 * calloc parameter definition
85 struct tfp_calloc_parms {
87 * [in] nitems, number specifying number of items to allocate.
91 * [in] size, number specifying the size of each memory item
92 * requested. Size is in bytes.
96 * [in] alignment, number indicates byte alignment required. 0
97 * - don't care, 16 - 16 byte alignment, 4K - 4K alignment etc
101 * [out] mem_va, pointer to the allocated memory.
105 * [out] mem_pa, physical address of the allocated memory.
113 * @ref tfp_send_direct
114 * @ref tfp_send_msg_tunneled
120 * @ref tfp_spinlock_init
121 * @ref tfp_spinlock_lock
122 * @ref tfp_spinlock_unlock
127 * Provides communication capability from the TrueFlow API layer to
128 * the TrueFlow firmware. The portability layer internally provides
129 * the transport to the firmware.
131 * [in] session, pointer to session handle
132 * [in] parms, parameter structure
136 * -1 - Global error like not supported
137 * -EINVAL - Parameter Error
139 int tfp_send_msg_direct(struct tf *tfp,
140 struct tfp_send_msg_parms *parms);
143 * Provides communication capability from the TrueFlow API layer to
144 * the TrueFlow firmware. The portability layer internally provides
145 * the transport to the firmware.
147 * [in] session, pointer to session handle
148 * [in] parms, parameter structure
152 * -1 - Global error like not supported
153 * -EINVAL - Parameter Error
155 int tfp_send_msg_tunneled(struct tf *tfp,
156 struct tfp_send_msg_parms *parms);
159 * Sends OEM command message to Chimp
161 * [in] session, pointer to session handle
162 * [in] max_flows, max number of flows requested
166 * -1 - Global error like not supported
167 * -EINVAL - Parameter Error
170 tfp_msg_hwrm_oem_cmd(struct tf *tfp,
174 * Allocates zero'ed memory from the heap.
176 * NOTE: Also performs virt2phy address conversion by default thus is
177 * can be expensive to invoke.
179 * [in] parms, parameter structure
183 * -ENOMEM - No memory available
184 * -EINVAL - Parameter error
186 int tfp_calloc(struct tfp_calloc_parms *parms);
187 void tfp_memcpy(void *dest, void *src, size_t n);
188 void tfp_free(void *addr);
190 void tfp_spinlock_init(struct tfp_spinlock_parms *slock);
191 void tfp_spinlock_lock(struct tfp_spinlock_parms *slock);
192 void tfp_spinlock_unlock(struct tfp_spinlock_parms *slock);
195 * Lookup of the FID in the platform specific structure.
198 * Pointer to session handle
201 * Pointer to the fw_fid
205 * -EINVAL - Parameter error
207 int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
211 * @ref tfp_cpu_to_le_16
212 * @ref tfp_le_to_cpu_16
213 * @ref tfp_cpu_to_le_32
214 * @ref tfp_le_to_cpu_32
215 * @ref tfp_cpu_to_le_64
216 * @ref tfp_le_to_cpu_64
217 * @ref tfp_cpu_to_be_16
218 * @ref tfp_be_to_cpu_16
219 * @ref tfp_cpu_to_be_32
220 * @ref tfp_be_to_cpu_32
221 * @ref tfp_cpu_to_be_64
222 * @ref tfp_be_to_cpu_64
225 #define tfp_cpu_to_le_16(val) rte_cpu_to_le_16(val)
226 #define tfp_le_to_cpu_16(val) rte_le_to_cpu_16(val)
227 #define tfp_cpu_to_le_32(val) rte_cpu_to_le_32(val)
228 #define tfp_le_to_cpu_32(val) rte_le_to_cpu_32(val)
229 #define tfp_cpu_to_le_64(val) rte_cpu_to_le_64(val)
230 #define tfp_le_to_cpu_64(val) rte_le_to_cpu_64(val)
231 #define tfp_cpu_to_be_16(val) rte_cpu_to_be_16(val)
232 #define tfp_be_to_cpu_16(val) rte_be_to_cpu_16(val)
233 #define tfp_cpu_to_be_32(val) rte_cpu_to_be_32(val)
234 #define tfp_be_to_cpu_32(val) rte_be_to_cpu_32(val)
235 #define tfp_cpu_to_be_64(val) rte_cpu_to_be_64(val)
236 #define tfp_be_to_cpu_64(val) rte_be_to_cpu_64(val)
237 #define tfp_bswap_16(val) rte_bswap16(val)
238 #define tfp_bswap_32(val) rte_bswap32(val)
239 #define tfp_bswap_64(val) rte_bswap64(val)
242 * Lookup of the FID in the platform specific structure.
245 * Pointer to session handle
248 * Pointer to the fw_fid
252 * -EINVAL - Parameter error
254 int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);