1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
6 /* This header file defines the Portability structures and APIs for
13 #include <rte_spinlock.h>
17 struct tfp_spinlock_parms {
24 * TrueFlow Portability API Header File
27 /** send message parameter definition
29 struct tfp_send_msg_parms {
31 * [in] mailbox, specifying the Mailbox to send the command on.
35 * [in] tlv_subtype, specifies the tlv_type.
39 * [in] tlv_subtype, specifies the tlv_subtype.
43 * [out] tf_resp_code, response code from the internal tlv
44 * message. Only supported on tunneled messages.
46 uint32_t tf_resp_code;
48 * [out] size, number specifying the request size of the data in bytes
52 * [in] data, pointer to the data to be sent within the HWRM command
56 * [out] size, number specifying the response size of the data in bytes
60 * [out] data, pointer to the data to be sent within the HWRM command
65 /** calloc parameter definition
67 struct tfp_calloc_parms {
69 * [in] nitems, number specifying number of items to allocate.
73 * [in] size, number specifying the size of each memory item
74 * requested. Size is in bytes.
78 * [in] alignment, number indicates byte alignment required. 0
79 * - don't care, 16 - 16 byte alignment, 4K - 4K alignment etc
83 * [out] mem_va, pointer to the allocated memory.
87 * [out] mem_pa, physical address of the allocated memory.
95 * @ref tfp_send_direct
96 * @ref tfp_send_msg_tunneled
102 * @ref tfp_spinlock_init
103 * @ref tfp_spinlock_lock
104 * @ref tfp_spinlock_unlock
106 * @ref tfp_cpu_to_le_16
107 * @ref tfp_le_to_cpu_16
108 * @ref tfp_cpu_to_le_32
109 * @ref tfp_le_to_cpu_32
110 * @ref tfp_cpu_to_le_64
111 * @ref tfp_le_to_cpu_64
112 * @ref tfp_cpu_to_be_16
113 * @ref tfp_be_to_cpu_16
114 * @ref tfp_cpu_to_be_32
115 * @ref tfp_be_to_cpu_32
116 * @ref tfp_cpu_to_be_64
117 * @ref tfp_be_to_cpu_64
120 #define tfp_cpu_to_le_16(val) rte_cpu_to_le_16(val)
121 #define tfp_le_to_cpu_16(val) rte_le_to_cpu_16(val)
122 #define tfp_cpu_to_le_32(val) rte_cpu_to_le_32(val)
123 #define tfp_le_to_cpu_32(val) rte_le_to_cpu_32(val)
124 #define tfp_cpu_to_le_64(val) rte_cpu_to_le_64(val)
125 #define tfp_le_to_cpu_64(val) rte_le_to_cpu_64(val)
126 #define tfp_cpu_to_be_16(val) rte_cpu_to_be_16(val)
127 #define tfp_be_to_cpu_16(val) rte_be_to_cpu_16(val)
128 #define tfp_cpu_to_be_32(val) rte_cpu_to_be_32(val)
129 #define tfp_be_to_cpu_32(val) rte_be_to_cpu_32(val)
130 #define tfp_cpu_to_be_64(val) rte_cpu_to_be_64(val)
131 #define tfp_be_to_cpu_64(val) rte_be_to_cpu_64(val)
132 #define tfp_bswap_16(val) rte_bswap16(val)
133 #define tfp_bswap_32(val) rte_bswap32(val)
134 #define tfp_bswap_64(val) rte_bswap64(val)
137 * Provides communication capability from the TrueFlow API layer to
138 * the TrueFlow firmware. The portability layer internally provides
139 * the transport to the firmware.
141 * [in] session, pointer to session handle
142 * [in] parms, parameter structure
146 * -1 - Global error like not supported
147 * -EINVAL - Parameter Error
149 int tfp_send_msg_direct(struct tf *tfp,
150 struct tfp_send_msg_parms *parms);
153 * Provides communication capability from the TrueFlow API layer to
154 * the TrueFlow firmware. The portability layer internally provides
155 * the transport to the firmware.
157 * [in] session, pointer to session handle
158 * [in] parms, parameter structure
162 * -1 - Global error like not supported
163 * -EINVAL - Parameter Error
165 int tfp_send_msg_tunneled(struct tf *tfp,
166 struct tfp_send_msg_parms *parms);
169 * Allocates zero'ed memory from the heap.
171 * NOTE: Also performs virt2phy address conversion by default thus is
172 * can be expensive to invoke.
174 * [in] parms, parameter structure
178 * -ENOMEM - No memory available
179 * -EINVAL - Parameter error
181 int tfp_calloc(struct tfp_calloc_parms *parms);
183 void tfp_free(void *addr);
184 void tfp_memcpy(void *dest, void *src, size_t n);
185 void tfp_spinlock_init(struct tfp_spinlock_parms *slock);
186 void tfp_spinlock_lock(struct tfp_spinlock_parms *slock);
187 void tfp_spinlock_unlock(struct tfp_spinlock_parms *slock);