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>
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 * Sends OEM command message to Chimp
176 * [in] session, pointer to session handle
177 * [in] max_flows, max number of flows requested
181 * -1 - Global error like not supported
182 * -EINVAL - Parameter Error
185 tfp_msg_hwrm_oem_cmd(struct tf *tfp,
189 * Allocates zero'ed memory from the heap.
191 * NOTE: Also performs virt2phy address conversion by default thus is
192 * can be expensive to invoke.
194 * [in] parms, parameter structure
198 * -ENOMEM - No memory available
199 * -EINVAL - Parameter error
201 int tfp_calloc(struct tfp_calloc_parms *parms);
202 void tfp_memcpy(void *dest, void *src, size_t n);
203 void tfp_free(void *addr);
205 void tfp_spinlock_init(struct tfp_spinlock_parms *slock);
206 void tfp_spinlock_lock(struct tfp_spinlock_parms *slock);
207 void tfp_spinlock_unlock(struct tfp_spinlock_parms *slock);
210 * Lookup of the FID in the platform specific structure.
213 * Pointer to session handle
216 * Pointer to the fw_fid
220 * -EINVAL - Parameter error
222 int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
226 * @ref tfp_cpu_to_le_16
227 * @ref tfp_le_to_cpu_16
228 * @ref tfp_cpu_to_le_32
229 * @ref tfp_le_to_cpu_32
230 * @ref tfp_cpu_to_le_64
231 * @ref tfp_le_to_cpu_64
232 * @ref tfp_cpu_to_be_16
233 * @ref tfp_be_to_cpu_16
234 * @ref tfp_cpu_to_be_32
235 * @ref tfp_be_to_cpu_32
236 * @ref tfp_cpu_to_be_64
237 * @ref tfp_be_to_cpu_64
240 #define tfp_cpu_to_le_16(val) rte_cpu_to_le_16(val)
241 #define tfp_le_to_cpu_16(val) rte_le_to_cpu_16(val)
242 #define tfp_cpu_to_le_32(val) rte_cpu_to_le_32(val)
243 #define tfp_le_to_cpu_32(val) rte_le_to_cpu_32(val)
244 #define tfp_cpu_to_le_64(val) rte_cpu_to_le_64(val)
245 #define tfp_le_to_cpu_64(val) rte_le_to_cpu_64(val)
246 #define tfp_cpu_to_be_16(val) rte_cpu_to_be_16(val)
247 #define tfp_be_to_cpu_16(val) rte_be_to_cpu_16(val)
248 #define tfp_cpu_to_be_32(val) rte_cpu_to_be_32(val)
249 #define tfp_be_to_cpu_32(val) rte_be_to_cpu_32(val)
250 #define tfp_cpu_to_be_64(val) rte_cpu_to_be_64(val)
251 #define tfp_be_to_cpu_64(val) rte_be_to_cpu_64(val)
252 #define tfp_bswap_16(val) rte_bswap16(val)
253 #define tfp_bswap_32(val) rte_bswap32(val)
254 #define tfp_bswap_64(val) rte_bswap64(val)
257 * Lookup of the FID in the platform specific structure.
260 * Pointer to session handle
263 * Pointer to the fw_fid
267 * -EINVAL - Parameter error
269 int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
272 * Get the PF associated with the fw communications channel.
275 * Pointer to session handle
278 * Pointer to the pf id
285 int tfp_get_pf(struct tf *tfp, uint16_t *pf);