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] size, number specifying the request size of the data in bytes
64 * [in] data, pointer to the data to be sent within the HWRM command
68 * [out] size, number specifying the response size of the data in bytes
72 * [out] data, pointer to the data to be sent within the HWRM command
78 * calloc parameter definition
80 struct tfp_calloc_parms {
82 * [in] nitems, number specifying number of items to allocate.
86 * [in] size, number specifying the size of each memory item
87 * requested. Size is in bytes.
91 * [in] alignment, number indicates byte alignment required. 0
92 * - don't care, 16 - 16 byte alignment, 4K - 4K alignment etc
96 * [out] mem_va, pointer to the allocated memory.
100 * [out] mem_pa, physical address of the allocated memory.
108 * @ref tfp_send_direct
114 * @ref tfp_spinlock_init
115 * @ref tfp_spinlock_lock
116 * @ref tfp_spinlock_unlock
121 * Provides communication capability from the TrueFlow API layer to
122 * the TrueFlow firmware. The portability layer internally provides
123 * the transport to the firmware.
125 * [in] session, pointer to session handle
126 * [in] parms, parameter structure
130 * -1 - Global error like not supported
131 * -EINVAL - Parameter Error
133 int tfp_send_msg_direct(struct tf *tfp,
134 struct tfp_send_msg_parms *parms);
137 * Sends OEM command message to Chimp
139 * [in] session, pointer to session handle
140 * [in] max_flows, max number of flows requested
144 * -1 - Global error like not supported
145 * -EINVAL - Parameter Error
148 tfp_msg_hwrm_oem_cmd(struct tf *tfp,
152 * Allocates zero'ed memory from the heap.
154 * NOTE: Also performs virt2phy address conversion by default thus is
155 * can be expensive to invoke.
157 * [in] parms, parameter structure
161 * -ENOMEM - No memory available
162 * -EINVAL - Parameter error
164 int tfp_calloc(struct tfp_calloc_parms *parms);
165 void tfp_memcpy(void *dest, void *src, size_t n);
166 void tfp_free(void *addr);
168 void tfp_spinlock_init(struct tfp_spinlock_parms *slock);
169 void tfp_spinlock_lock(struct tfp_spinlock_parms *slock);
170 void tfp_spinlock_unlock(struct tfp_spinlock_parms *slock);
173 * Lookup of the FID in the platform specific structure.
176 * Pointer to session handle
179 * Pointer to the fw_fid
183 * -EINVAL - Parameter error
185 int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
189 * @ref tfp_cpu_to_le_16
190 * @ref tfp_le_to_cpu_16
191 * @ref tfp_cpu_to_le_32
192 * @ref tfp_le_to_cpu_32
193 * @ref tfp_cpu_to_le_64
194 * @ref tfp_le_to_cpu_64
195 * @ref tfp_cpu_to_be_16
196 * @ref tfp_be_to_cpu_16
197 * @ref tfp_cpu_to_be_32
198 * @ref tfp_be_to_cpu_32
199 * @ref tfp_cpu_to_be_64
200 * @ref tfp_be_to_cpu_64
203 #define tfp_cpu_to_le_16(val) rte_cpu_to_le_16(val)
204 #define tfp_le_to_cpu_16(val) rte_le_to_cpu_16(val)
205 #define tfp_cpu_to_le_32(val) rte_cpu_to_le_32(val)
206 #define tfp_le_to_cpu_32(val) rte_le_to_cpu_32(val)
207 #define tfp_cpu_to_le_64(val) rte_cpu_to_le_64(val)
208 #define tfp_le_to_cpu_64(val) rte_le_to_cpu_64(val)
209 #define tfp_cpu_to_be_16(val) rte_cpu_to_be_16(val)
210 #define tfp_be_to_cpu_16(val) rte_be_to_cpu_16(val)
211 #define tfp_cpu_to_be_32(val) rte_cpu_to_be_32(val)
212 #define tfp_be_to_cpu_32(val) rte_be_to_cpu_32(val)
213 #define tfp_cpu_to_be_64(val) rte_cpu_to_be_64(val)
214 #define tfp_be_to_cpu_64(val) rte_be_to_cpu_64(val)
215 #define tfp_bswap_16(val) rte_bswap16(val)
216 #define tfp_bswap_32(val) rte_bswap32(val)
217 #define tfp_bswap_64(val) rte_bswap64(val)
220 * Get the PF associated with the fw communications channel.
223 * Pointer to session handle
226 * Pointer to the pf id
233 int tfp_get_pf(struct tf *tfp, uint16_t *pf);