1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2021 Broadcom
6 #ifndef _ULP_PORT_DB_H_
7 #define _ULP_PORT_DB_H_
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
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
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
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
33 enum bnxt_ulp_vnic_type {
34 BNXT_ULP_DRV_FUNC_VNIC = 0,
38 enum bnxt_ulp_fid_type {
39 BNXT_ULP_DRV_FUNC_FID,
43 struct ulp_func_if_info {
49 uint8_t func_mac[RTE_ETHER_ADDR_LEN];
50 uint16_t func_parent_vnic;
51 uint8_t func_parent_mac[RTE_ETHER_ADDR_LEN];
56 /* Structure for the Port database resource information. */
57 struct ulp_interface_info {
58 enum bnxt_ulp_intf_type type;
63 struct ulp_phy_port_info {
71 /* Structure for the Port database */
72 struct bnxt_ulp_port_db {
73 struct ulp_interface_info *ulp_intf_list;
74 uint32_t ulp_intf_list_size;
76 /* dpdk device external port list */
77 uint16_t dev_port_list[RTE_MAX_ETHPORTS];
78 struct ulp_phy_port_info *phy_port_list;
79 uint16_t phy_port_cnt;
80 struct ulp_func_if_info ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC];
84 * Initialize the port database. Memory is allocated in this
85 * call and assigned to the port database.
87 * ulp_ctxt [in] Ptr to ulp context
89 * Returns 0 on success or negative number on failure.
91 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
94 * Deinitialize the port database. Memory is deallocated in
97 * ulp_ctxt [in] Ptr to ulp context
99 * Returns 0 on success.
101 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
104 * Update the port database.This api is called when the port
105 * details are available during the startup.
107 * ulp_ctxt [in] Ptr to ulp context
108 * bp [in]. ptr to the device function.
110 * Returns 0 on success or negative number on failure.
112 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
113 struct rte_eth_dev *eth_dev);
116 * Api to get the ulp ifindex for a given device port.
118 * ulp_ctxt [in] Ptr to ulp context
119 * port_id [in].device port id
120 * ifindex [out] ulp ifindex
122 * Returns 0 on success or negative number on failure.
125 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
126 uint32_t port_id, uint32_t *ifindex);
129 * Api to get the function id for a given ulp ifindex.
131 * ulp_ctxt [in] Ptr to ulp context
132 * ifindex [in] ulp ifindex
133 * func_id [out] the function id of the given ifindex.
135 * Returns 0 on success or negative number on failure.
138 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
139 uint32_t ifindex, uint32_t fid_type,
143 * Api to get the svif for a given ulp ifindex.
145 * ulp_ctxt [in] Ptr to ulp context
146 * ifindex [in] ulp ifindex
147 * dir [in] the direction for the flow.
148 * svif [out] the svif of the given ifindex.
150 * Returns 0 on success or negative number on failure.
153 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
154 uint32_t ifindex, uint32_t dir, uint16_t *svif);
157 * Api to get the spif for a given ulp ifindex.
159 * ulp_ctxt [in] Ptr to ulp context
160 * ifindex [in] ulp ifindex
161 * dir [in] the direction for the flow.
162 * spif [out] the spif of the given ifindex.
164 * Returns 0 on success or negative number on failure.
167 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
168 uint32_t ifindex, uint32_t dir, uint16_t *spif);
172 * Api to get the parif for a given ulp ifindex.
174 * ulp_ctxt [in] Ptr to ulp context
175 * ifindex [in] ulp ifindex
176 * dir [in] the direction for the flow.
177 * parif [out] the parif of the given ifindex.
179 * Returns 0 on success or negative number on failure.
182 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
183 uint32_t ifindex, uint32_t dir, uint16_t *parif);
186 * Api to get the vnic id for a given ulp ifindex.
188 * ulp_ctxt [in] Ptr to ulp context
189 * ifindex [in] ulp ifindex
190 * vnic [out] the vnic of the given ifindex.
192 * Returns 0 on success or negative number on failure.
195 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
196 uint32_t ifindex, uint32_t vnic_type,
200 * Api to get the vport id for a given ulp ifindex.
202 * ulp_ctxt [in] Ptr to ulp context
203 * ifindex [in] ulp ifindex
204 * vport [out] the port of the given ifindex.
206 * Returns 0 on success or negative number on failure.
209 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
210 uint32_t ifindex, uint16_t *vport);
213 * Api to get the vport for a given physical port.
215 * ulp_ctxt [in] Ptr to ulp context
216 * phy_port [in] physical port index
217 * out_port [out] the port of the given physical index
219 * Returns 0 on success or negative number on failure.
222 ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt,
227 * Api to get the svif for a given physical port.
229 * ulp_ctxt [in] Ptr to ulp context
230 * phy_port [in] physical port index
231 * svif [out] the svif of the given physical index
233 * Returns 0 on success or negative number on failure.
236 ulp_port_db_phy_port_svif_get(struct bnxt_ulp_context *ulp_ctxt,
241 * Api to get the port type for a given ulp ifindex.
243 * ulp_ctxt [in] Ptr to ulp context
244 * ifindex [in] ulp ifindex
248 enum bnxt_ulp_intf_type
249 ulp_port_db_port_type_get(struct bnxt_ulp_context *ulp_ctxt,
253 * Api to get the ulp ifindex for a given function id.
255 * ulp_ctxt [in] Ptr to ulp context
256 * func_id [in].device func id
257 * ifindex [out] ulp ifindex
259 * Returns 0 on success or negative number on failure.
262 ulp_port_db_dev_func_id_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
263 uint32_t func_id, uint32_t *ifindex);
266 * Api to get the function id for a given port id.
268 * ulp_ctxt [in] Ptr to ulp context
269 * port_id [in] dpdk port id
270 * func_id [out] the function id of the given ifindex.
272 * Returns 0 on success or negative number on failure.
275 ulp_port_db_port_func_id_get(struct bnxt_ulp_context *ulp_ctxt,
276 uint16_t port_id, uint16_t *func_id);
279 * Api to get the parent mac address for a given port id.
281 * ulp_ctxt [in] Ptr to ulp context
282 * port_id [in].device port id
283 * mac_addr [out] mac address
285 * Returns 0 on success or negative number on failure.
288 ulp_port_db_parent_mac_addr_get(struct bnxt_ulp_context *ulp_ctxt,
289 uint32_t port_id, uint8_t **mac_addr);
290 #endif /* _ULP_PORT_DB_H_ */