xref: /dpdk/drivers/net/bnxt/tf_ulp/ulp_port_db.h (revision 68a03efeed657e6e05f281479b33b51102797e15)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2021 Broadcom
3  * All rights reserved.
4  */
5 
6 #ifndef _ULP_PORT_DB_H_
7 #define _ULP_PORT_DB_H_
8 
9 #include "bnxt_ulp.h"
10 
11 #define BNXT_PORT_DB_MAX_INTF_LIST		256
12 #define BNXT_PORT_DB_MAX_FUNC			2048
13 #define BNXT_ULP_FREE_PARIF_BASE		11
14 
15 enum bnxt_ulp_svif_type {
16 	BNXT_ULP_DRV_FUNC_SVIF = 0,
17 	BNXT_ULP_VF_FUNC_SVIF,
18 	BNXT_ULP_PHY_PORT_SVIF
19 };
20 
21 enum bnxt_ulp_spif_type {
22 	BNXT_ULP_DRV_FUNC_SPIF = 0,
23 	BNXT_ULP_VF_FUNC_SPIF,
24 	BNXT_ULP_PHY_PORT_SPIF
25 };
26 
27 enum bnxt_ulp_parif_type {
28 	BNXT_ULP_DRV_FUNC_PARIF = 0,
29 	BNXT_ULP_VF_FUNC_PARIF,
30 	BNXT_ULP_PHY_PORT_PARIF
31 };
32 
33 enum bnxt_ulp_vnic_type {
34 	BNXT_ULP_DRV_FUNC_VNIC = 0,
35 	BNXT_ULP_VF_FUNC_VNIC
36 };
37 
38 enum bnxt_ulp_fid_type {
39 	BNXT_ULP_DRV_FUNC_FID,
40 	BNXT_ULP_VF_FUNC_FID
41 };
42 
43 struct ulp_func_if_info {
44 	uint16_t		func_valid;
45 	uint16_t		func_svif;
46 	uint16_t		func_spif;
47 	uint16_t		func_parif;
48 	uint16_t		func_vnic;
49 	uint16_t		phy_port_id;
50 	uint16_t		ifindex;
51 };
52 
53 /* Structure for the Port database resource information. */
54 struct ulp_interface_info {
55 	enum bnxt_ulp_intf_type	type;
56 	uint16_t		drv_func_id;
57 	uint16_t		vf_func_id;
58 };
59 
60 struct ulp_phy_port_info {
61 	uint16_t	port_valid;
62 	uint16_t	port_svif;
63 	uint16_t	port_spif;
64 	uint16_t	port_parif;
65 	uint16_t	port_vport;
66 };
67 
68 /* Structure for the Port database */
69 struct bnxt_ulp_port_db {
70 	struct ulp_interface_info	*ulp_intf_list;
71 	uint32_t			ulp_intf_list_size;
72 
73 	/* dpdk device external port list */
74 	uint16_t			dev_port_list[RTE_MAX_ETHPORTS];
75 	struct ulp_phy_port_info	*phy_port_list;
76 	uint16_t			phy_port_cnt;
77 	struct ulp_func_if_info		ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC];
78 };
79 
80 /*
81  * Initialize the port database. Memory is allocated in this
82  * call and assigned to the port database.
83  *
84  * ulp_ctxt [in] Ptr to ulp context
85  *
86  * Returns 0 on success or negative number on failure.
87  */
88 int32_t	ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
89 
90 /*
91  * Deinitialize the port database. Memory is deallocated in
92  * this call.
93  *
94  * ulp_ctxt [in] Ptr to ulp context
95  *
96  * Returns 0 on success.
97  */
98 int32_t	ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
99 
100 /*
101  * Update the port database.This api is called when the port
102  * details are available during the startup.
103  *
104  * ulp_ctxt [in] Ptr to ulp context
105  * bp [in]. ptr to the device function.
106  *
107  * Returns 0 on success or negative number on failure.
108  */
109 int32_t	ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
110 					 struct rte_eth_dev *eth_dev);
111 
112 /*
113  * Api to get the ulp ifindex for a given device port.
114  *
115  * ulp_ctxt [in] Ptr to ulp context
116  * port_id [in].device port id
117  * ifindex [out] ulp ifindex
118  *
119  * Returns 0 on success or negative number on failure.
120  */
121 int32_t
122 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
123 				  uint32_t port_id, uint32_t *ifindex);
124 
125 /*
126  * Api to get the function id for a given ulp ifindex.
127  *
128  * ulp_ctxt [in] Ptr to ulp context
129  * ifindex [in] ulp ifindex
130  * func_id [out] the function id of the given ifindex.
131  *
132  * Returns 0 on success or negative number on failure.
133  */
134 int32_t
135 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
136 			    uint32_t ifindex, uint32_t fid_type,
137 			    uint16_t *func_id);
138 
139 /*
140  * Api to get the svif for a given ulp ifindex.
141  *
142  * ulp_ctxt [in] Ptr to ulp context
143  * ifindex [in] ulp ifindex
144  * dir [in] the direction for the flow.
145  * svif [out] the svif of the given ifindex.
146  *
147  * Returns 0 on success or negative number on failure.
148  */
149 int32_t
150 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
151 		     uint32_t ifindex, uint32_t dir, uint16_t *svif);
152 
153 /*
154  * Api to get the spif for a given ulp ifindex.
155  *
156  * ulp_ctxt [in] Ptr to ulp context
157  * ifindex [in] ulp ifindex
158  * dir [in] the direction for the flow.
159  * spif [out] the spif of the given ifindex.
160  *
161  * Returns 0 on success or negative number on failure.
162  */
163 int32_t
164 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
165 		     uint32_t ifindex, uint32_t dir, uint16_t *spif);
166 
167 
168 /*
169  * Api to get the parif for a given ulp ifindex.
170  *
171  * ulp_ctxt [in] Ptr to ulp context
172  * ifindex [in] ulp ifindex
173  * dir [in] the direction for the flow.
174  * parif [out] the parif of the given ifindex.
175  *
176  * Returns 0 on success or negative number on failure.
177  */
178 int32_t
179 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
180 		      uint32_t ifindex, uint32_t dir, uint16_t *parif);
181 
182 /*
183  * Api to get the vnic id for a given ulp ifindex.
184  *
185  * ulp_ctxt [in] Ptr to ulp context
186  * ifindex [in] ulp ifindex
187  * vnic [out] the vnic of the given ifindex.
188  *
189  * Returns 0 on success or negative number on failure.
190  */
191 int32_t
192 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
193 			     uint32_t ifindex, uint32_t vnic_type,
194 			     uint16_t *vnic);
195 
196 /*
197  * Api to get the vport id for a given ulp ifindex.
198  *
199  * ulp_ctxt [in] Ptr to ulp context
200  * ifindex [in] ulp ifindex
201  * vport [out] the port of the given ifindex.
202  *
203  * Returns 0 on success or negative number on failure.
204  */
205 int32_t
206 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
207 		      uint32_t ifindex,	uint16_t *vport);
208 
209 /*
210  * Api to get the vport for a given physical port.
211  *
212  * ulp_ctxt [in] Ptr to ulp context
213  * phy_port [in] physical port index
214  * out_port [out] the port of the given physical index
215  *
216  * Returns 0 on success or negative number on failure.
217  */
218 int32_t
219 ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt,
220 			       uint32_t phy_port,
221 			       uint16_t *out_port);
222 
223 /*
224  * Api to get the svif for a given physical port.
225  *
226  * ulp_ctxt [in] Ptr to ulp context
227  * phy_port [in] physical port index
228  * svif [out] the svif of the given physical index
229  *
230  * Returns 0 on success or negative number on failure.
231  */
232 int32_t
233 ulp_port_db_phy_port_svif_get(struct bnxt_ulp_context *ulp_ctxt,
234 			      uint32_t phy_port,
235 			      uint16_t *svif);
236 
237 /*
238  * Api to get the port type for a given ulp ifindex.
239  *
240  * ulp_ctxt [in] Ptr to ulp context
241  * ifindex [in] ulp ifindex
242  *
243  * Returns port type.
244  */
245 enum bnxt_ulp_intf_type
246 ulp_port_db_port_type_get(struct bnxt_ulp_context *ulp_ctxt,
247 			  uint32_t ifindex);
248 
249 /*
250  * Api to get the ulp ifindex for a given function id.
251  *
252  * ulp_ctxt [in] Ptr to ulp context
253  * func_id [in].device func id
254  * ifindex [out] ulp ifindex
255  *
256  * Returns 0 on success or negative number on failure.
257  */
258 int32_t
259 ulp_port_db_dev_func_id_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
260 				     uint32_t func_id, uint32_t *ifindex);
261 
262 /*
263  * Api to get the function id for a given port id.
264  *
265  * ulp_ctxt [in] Ptr to ulp context
266  * port_id [in] dpdk port id
267  * func_id [out] the function id of the given ifindex.
268  *
269  * Returns 0 on success or negative number on failure.
270  */
271 int32_t
272 ulp_port_db_port_func_id_get(struct bnxt_ulp_context *ulp_ctxt,
273 			     uint16_t port_id, uint16_t *func_id);
274 
275 #endif /* _ULP_PORT_DB_H_ */
276