net/bnxt: add global config set and get functions
[dpdk.git] / drivers / net / bnxt / tf_core / tf_if_tbl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef TF_IF_TBL_TYPE_H_
7 #define TF_IF_TBL_TYPE_H_
8
9 #include "tf_core.h"
10 #include "stack.h"
11
12 /*
13  * This is the constant used to define invalid CFA
14  * types across all devices.
15  */
16 #define CFA_IF_TBL_TYPE_INVALID 65535
17
18 struct tf;
19
20 /**
21  * The IF Table module provides processing of Internal TF interface table types.
22  */
23
24 /**
25  * IF table configuration enumeration.
26  */
27 enum tf_if_tbl_cfg_type {
28         /**
29          * No configuration
30          */
31         TF_IF_TBL_CFG_NULL,
32         /**
33          * HCAPI 'controlled'
34          */
35         TF_IF_TBL_CFG,
36 };
37
38 /**
39  * IF table configuration structure, used by the Device to configure
40  * how an individual TF type is configured in regard to the HCAPI type.
41  */
42 struct tf_if_tbl_cfg {
43         /**
44          * IF table config controls how the DB for that element is
45          * processed.
46          */
47         enum tf_if_tbl_cfg_type cfg_type;
48
49         /**
50          * HCAPI Type for the element. Used for TF to HCAPI type
51          * conversion.
52          */
53         uint16_t hcapi_type;
54 };
55
56 /**
57  * Get HCAPI type parameters for a single element
58  */
59 struct tf_if_tbl_get_hcapi_parms {
60         /**
61          * [in] IF Tbl DB Handle
62          */
63         void *tbl_db;
64         /**
65          * [in] DB Index, indicates which DB entry to perform the
66          * action on.
67          */
68         uint16_t db_index;
69         /**
70          * [out] Pointer to the hcapi type for the specified db_index
71          */
72         uint16_t *hcapi_type;
73 };
74
75 /**
76  * Table configuration parameters
77  */
78 struct tf_if_tbl_cfg_parms {
79         /**
80          * Number of table types in each of the configuration arrays
81          */
82         uint16_t num_elements;
83         /**
84          * Table Type element configuration array
85          */
86         struct tf_if_tbl_cfg *cfg;
87         /**
88          * Shadow table type configuration array
89          */
90         struct tf_shadow_if_tbl_cfg *shadow_cfg;
91         /**
92          * Boolean controlling the request shadow copy.
93          */
94         bool shadow_copy;
95 };
96
97 /**
98  * IF Table set parameters
99  */
100 struct tf_if_tbl_set_parms {
101         /**
102          * [in] Receive or transmit direction
103          */
104         enum tf_dir dir;
105         /**
106          * [in] Type of object to set
107          */
108         enum tf_if_tbl_type type;
109         /**
110          * [in] Type of HCAPI
111          */
112         uint16_t hcapi_type;
113         /**
114          * [in] Entry data
115          */
116         uint32_t *data;
117         /**
118          * [in] Entry size
119          */
120         uint16_t data_sz_in_bytes;
121         /**
122          * [in] Entry index to write to
123          */
124         uint32_t idx;
125 };
126
127 /**
128  * IF Table get parameters
129  */
130 struct tf_if_tbl_get_parms {
131         /**
132          * [in] Receive or transmit direction
133          */
134         enum tf_dir dir;
135         /**
136          * [in] Type of object to get
137          */
138         enum tf_if_tbl_type type;
139         /**
140          * [in] Type of HCAPI
141          */
142         uint16_t hcapi_type;
143         /**
144          * [out] Entry data
145          */
146         uint32_t *data;
147         /**
148          * [out] Entry size
149          */
150         uint16_t data_sz_in_bytes;
151         /**
152          * [in] Entry index to read
153          */
154         uint32_t idx;
155 };
156
157 /**
158  * @page if tbl Table
159  *
160  * @ref tf_if_tbl_bind
161  *
162  * @ref tf_if_tbl_unbind
163  *
164  * @ref tf_tbl_set
165  *
166  * @ref tf_tbl_get
167  *
168  * @ref tf_tbl_restore
169  */
170 /**
171  * Initializes the Table module with the requested DBs. Must be
172  * invoked as the first thing before any of the access functions.
173  *
174  * [in] tfp
175  *   Pointer to TF handle, used for HCAPI communication
176  *
177  * [in] parms
178  *   Pointer to Table configuration parameters
179  *
180  * Returns
181  *   - (0) if successful.
182  *   - (-EINVAL) on failure.
183  */
184 int tf_if_tbl_bind(struct tf *tfp,
185                    struct tf_if_tbl_cfg_parms *parms);
186
187 /**
188  * Cleans up the private DBs and releases all the data.
189  *
190  * [in] tfp
191  *   Pointer to TF handle, used for HCAPI communication
192  *
193  * [in] parms
194  *   Pointer to parameters
195  *
196  * Returns
197  *   - (0) if successful.
198  *   - (-EINVAL) on failure.
199  */
200 int tf_if_tbl_unbind(struct tf *tfp);
201
202 /**
203  * Configures the requested element by sending a firmware request which
204  * then installs it into the device internal structures.
205  *
206  * [in] tfp
207  *   Pointer to TF handle, used for HCAPI communication
208  *
209  * [in] parms
210  *   Pointer to Interface Table set parameters
211  *
212  * Returns
213  *   - (0) if successful.
214  *   - (-EINVAL) on failure.
215  */
216 int tf_if_tbl_set(struct tf *tfp,
217                   struct tf_if_tbl_set_parms *parms);
218
219 /**
220  * Retrieves the requested element by sending a firmware request to get
221  * the element.
222  *
223  * [in] tfp
224  *   Pointer to TF handle, used for HCAPI communication
225  *
226  * [in] parms
227  *   Pointer to Table get parameters
228  *
229  * Returns
230  *   - (0) if successful.
231  *   - (-EINVAL) on failure.
232  */
233 int tf_if_tbl_get(struct tf *tfp,
234                   struct tf_if_tbl_get_parms *parms);
235
236 #endif /* TF_IF_TBL_TYPE_H */