net/bnxt: fix build with gcc 10 default no-common
[dpdk.git] / drivers / net / bnxt / tf_core / tfp.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 /* This header file defines the Portability structures and APIs for
7  * TruFlow.
8  */
9
10 #ifndef _TFP_H_
11 #define _TFP_H_
12
13 #include <rte_spinlock.h>
14
15 /** Spinlock
16  */
17 struct tfp_spinlock_parms {
18         rte_spinlock_t slock;
19 };
20
21 /**
22  * @file
23  *
24  * TrueFlow Portability API Header File
25  */
26
27 /** send message parameter definition
28  */
29 struct tfp_send_msg_parms {
30         /**
31          * [in] mailbox, specifying the Mailbox to send the command on.
32          */
33         uint32_t  mailbox;
34         /**
35          * [in] tlv_subtype, specifies the tlv_type.
36          */
37         uint16_t  tf_type;
38         /**
39          * [in] tlv_subtype, specifies the tlv_subtype.
40          */
41         uint16_t  tf_subtype;
42         /**
43          * [out] tf_resp_code, response code from the internal tlv
44          *       message. Only supported on tunneled messages.
45          */
46         uint32_t tf_resp_code;
47         /**
48          * [out] size, number specifying the request size of the data in bytes
49          */
50         uint32_t req_size;
51         /**
52          * [in] data, pointer to the data to be sent within the HWRM command
53          */
54         uint32_t *req_data;
55         /**
56          * [out] size, number specifying the response size of the data in bytes
57          */
58         uint32_t resp_size;
59         /**
60          * [out] data, pointer to the data to be sent within the HWRM command
61          */
62         uint32_t *resp_data;
63 };
64
65 /** calloc parameter definition
66  */
67 struct tfp_calloc_parms {
68         /**
69          * [in] nitems, number specifying number of items to allocate.
70          */
71         size_t nitems;
72         /**
73          * [in] size, number specifying the size of each memory item
74          *      requested. Size is in bytes.
75          */
76         size_t size;
77         /**
78          * [in] alignment, number indicates byte alignment required. 0
79          *      - don't care, 16 - 16 byte alignment, 4K - 4K alignment etc
80          */
81         size_t alignment;
82         /**
83          * [out] mem_va, pointer to the allocated memory.
84          */
85         void *mem_va;
86         /**
87          * [out] mem_pa, physical address of the allocated memory.
88          */
89         void *mem_pa;
90 };
91
92 /**
93  * @page Portability
94  *
95  * @ref tfp_send_direct
96  * @ref tfp_send_msg_tunneled
97  *
98  * @ref tfp_calloc
99  * @ref tfp_free
100  * @ref tfp_memcpy
101  *
102  * @ref tfp_spinlock_init
103  * @ref tfp_spinlock_lock
104  * @ref tfp_spinlock_unlock
105  *
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
118  */
119
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)
135
136 /**
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.
140  *
141  * [in] session, pointer to session handle
142  * [in] parms, parameter structure
143  *
144  * Returns:
145  *   0              - Success
146  *   -1             - Global error like not supported
147  *   -EINVAL        - Parameter Error
148  */
149 int tfp_send_msg_direct(struct tf *tfp,
150                         struct tfp_send_msg_parms *parms);
151
152 /**
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.
156  *
157  * [in] session, pointer to session handle
158  * [in] parms, parameter structure
159  *
160  * Returns:
161  *   0              - Success
162  *   -1             - Global error like not supported
163  *   -EINVAL        - Parameter Error
164  */
165 int tfp_send_msg_tunneled(struct tf                 *tfp,
166                           struct tfp_send_msg_parms *parms);
167
168 /**
169  * Allocates zero'ed memory from the heap.
170  *
171  * NOTE: Also performs virt2phy address conversion by default thus is
172  * can be expensive to invoke.
173  *
174  * [in] parms, parameter structure
175  *
176  * Returns:
177  *   0              - Success
178  *   -ENOMEM        - No memory available
179  *   -EINVAL        - Parameter error
180  */
181 int tfp_calloc(struct tfp_calloc_parms *parms);
182
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);
188 #endif /* _TFP_H_ */