1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2019 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 {
53 /* Structure for the Port database resource information. */
54 struct ulp_interface_info {
55 enum bnxt_ulp_intf_type type;
60 struct ulp_phy_port_info {
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;
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];
81 * Initialize the port database. Memory is allocated in this
82 * call and assigned to the port database.
84 * ulp_ctxt [in] Ptr to ulp context
86 * Returns 0 on success or negative number on failure.
88 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
91 * Deinitialize the port database. Memory is deallocated in
94 * ulp_ctxt [in] Ptr to ulp context
96 * Returns 0 on success.
98 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
101 * Update the port database.This api is called when the port
102 * details are available during the startup.
104 * ulp_ctxt [in] Ptr to ulp context
105 * bp [in]. ptr to the device function.
107 * Returns 0 on success or negative number on failure.
109 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
110 struct rte_eth_dev *eth_dev);
113 * Api to get the ulp ifindex for a given device port.
115 * ulp_ctxt [in] Ptr to ulp context
116 * port_id [in].device port id
117 * ifindex [out] ulp ifindex
119 * Returns 0 on success or negative number on failure.
122 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
123 uint32_t port_id, uint32_t *ifindex);
126 * Api to get the function id for a given ulp ifindex.
128 * ulp_ctxt [in] Ptr to ulp context
129 * ifindex [in] ulp ifindex
130 * func_id [out] the function id of the given ifindex.
132 * Returns 0 on success or negative number on failure.
135 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
136 uint32_t ifindex, uint32_t fid_type,
140 * Api to get the svif for a given ulp ifindex.
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.
147 * Returns 0 on success or negative number on failure.
150 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
151 uint32_t ifindex, uint32_t dir, uint16_t *svif);
154 * Api to get the spif for a given ulp ifindex.
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.
161 * Returns 0 on success or negative number on failure.
164 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
165 uint32_t ifindex, uint32_t dir, uint16_t *spif);
169 * Api to get the parif for a given ulp ifindex.
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.
176 * Returns 0 on success or negative number on failure.
179 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
180 uint32_t ifindex, uint32_t dir, uint16_t *parif);
183 * Api to get the vnic id for a given ulp ifindex.
185 * ulp_ctxt [in] Ptr to ulp context
186 * ifindex [in] ulp ifindex
187 * vnic [out] the vnic of the given ifindex.
189 * Returns 0 on success or negative number on failure.
192 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
193 uint32_t ifindex, uint32_t vnic_type,
197 * Api to get the vport id for a given ulp ifindex.
199 * ulp_ctxt [in] Ptr to ulp context
200 * ifindex [in] ulp ifindex
201 * vport [out] the port of the given ifindex.
203 * Returns 0 on success or negative number on failure.
206 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
207 uint32_t ifindex, uint16_t *vport);
210 * Api to get the vport for a given physical port.
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
216 * Returns 0 on success or negative number on failure.
219 ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt,
224 * Api to get the svif for a given physical port.
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
230 * Returns 0 on success or negative number on failure.
233 ulp_port_db_phy_port_svif_get(struct bnxt_ulp_context *ulp_ctxt,
238 * Api to get the port type for a given ulp ifindex.
240 * ulp_ctxt [in] Ptr to ulp context
241 * ifindex [in] ulp ifindex
245 enum bnxt_ulp_intf_type
246 ulp_port_db_port_type_get(struct bnxt_ulp_context *ulp_ctxt,
250 * Api to get the ulp ifindex for a given function id.
252 * ulp_ctxt [in] Ptr to ulp context
253 * func_id [in].device func id
254 * ifindex [out] ulp ifindex
256 * Returns 0 on success or negative number on failure.
259 ulp_port_db_dev_func_id_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
260 uint32_t func_id, uint32_t *ifindex);
263 * Api to get the function id for a given port id.
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.
269 * Returns 0 on success or negative number on failure.
272 ulp_port_db_port_func_id_get(struct bnxt_ulp_context *ulp_ctxt,
273 uint16_t port_id, uint16_t *func_id);
275 #endif /* _ULP_PORT_DB_H_ */