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
14 enum bnxt_ulp_svif_type {
15 BNXT_ULP_DRV_FUNC_SVIF = 0,
16 BNXT_ULP_VF_FUNC_SVIF,
17 BNXT_ULP_PHY_PORT_SVIF
20 enum bnxt_ulp_spif_type {
21 BNXT_ULP_DRV_FUNC_SPIF = 0,
22 BNXT_ULP_VF_FUNC_SPIF,
23 BNXT_ULP_PHY_PORT_SPIF
26 enum bnxt_ulp_parif_type {
27 BNXT_ULP_DRV_FUNC_PARIF = 0,
28 BNXT_ULP_VF_FUNC_PARIF,
29 BNXT_ULP_PHY_PORT_PARIF
32 enum bnxt_ulp_vnic_type {
33 BNXT_ULP_DRV_FUNC_VNIC = 0,
37 enum bnxt_ulp_fid_type {
38 BNXT_ULP_DRV_FUNC_FID,
42 struct ulp_func_if_info {
52 /* Structure for the Port database resource information. */
53 struct ulp_interface_info {
54 enum bnxt_ulp_intf_type type;
59 struct ulp_phy_port_info {
67 /* Structure for the Port database */
68 struct bnxt_ulp_port_db {
69 struct ulp_interface_info *ulp_intf_list;
70 uint32_t ulp_intf_list_size;
72 /* dpdk device external port list */
73 uint16_t dev_port_list[RTE_MAX_ETHPORTS];
74 struct ulp_phy_port_info *phy_port_list;
75 uint16_t phy_port_cnt;
76 struct ulp_func_if_info ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC];
80 * Initialize the port database. Memory is allocated in this
81 * call and assigned to the port database.
83 * ulp_ctxt [in] Ptr to ulp context
85 * Returns 0 on success or negative number on failure.
87 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
90 * Deinitialize the port database. Memory is deallocated in
93 * ulp_ctxt [in] Ptr to ulp context
95 * Returns 0 on success.
97 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
100 * Update the port database.This api is called when the port
101 * details are available during the startup.
103 * ulp_ctxt [in] Ptr to ulp context
104 * bp [in]. ptr to the device function.
106 * Returns 0 on success or negative number on failure.
108 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
109 struct rte_eth_dev *eth_dev);
112 * Api to get the ulp ifindex for a given device port.
114 * ulp_ctxt [in] Ptr to ulp context
115 * port_id [in].device port id
116 * ifindex [out] ulp ifindex
118 * Returns 0 on success or negative number on failure.
121 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
122 uint32_t port_id, uint32_t *ifindex);
125 * Api to get the function id for a given ulp ifindex.
127 * ulp_ctxt [in] Ptr to ulp context
128 * ifindex [in] ulp ifindex
129 * func_id [out] the function id of the given ifindex.
131 * Returns 0 on success or negative number on failure.
134 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
135 uint32_t ifindex, uint32_t fid_type,
139 * Api to get the svif for a given ulp ifindex.
141 * ulp_ctxt [in] Ptr to ulp context
142 * ifindex [in] ulp ifindex
143 * dir [in] the direction for the flow.
144 * svif [out] the svif of the given ifindex.
146 * Returns 0 on success or negative number on failure.
149 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
150 uint32_t ifindex, uint32_t dir, uint16_t *svif);
153 * Api to get the spif for a given ulp ifindex.
155 * ulp_ctxt [in] Ptr to ulp context
156 * ifindex [in] ulp ifindex
157 * dir [in] the direction for the flow.
158 * spif [out] the spif of the given ifindex.
160 * Returns 0 on success or negative number on failure.
163 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
164 uint32_t ifindex, uint32_t dir, uint16_t *spif);
168 * Api to get the parif for a given ulp ifindex.
170 * ulp_ctxt [in] Ptr to ulp context
171 * ifindex [in] ulp ifindex
172 * dir [in] the direction for the flow.
173 * parif [out] the parif of the given ifindex.
175 * Returns 0 on success or negative number on failure.
178 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
179 uint32_t ifindex, uint32_t dir, uint16_t *parif);
182 * Api to get the vnic id for a given ulp ifindex.
184 * ulp_ctxt [in] Ptr to ulp context
185 * ifindex [in] ulp ifindex
186 * vnic [out] the vnic of the given ifindex.
188 * Returns 0 on success or negative number on failure.
191 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
192 uint32_t ifindex, uint32_t vnic_type,
196 * Api to get the vport id for a given ulp ifindex.
198 * ulp_ctxt [in] Ptr to ulp context
199 * ifindex [in] ulp ifindex
200 * vport [out] the port of the given ifindex.
202 * Returns 0 on success or negative number on failure.
205 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
206 uint32_t ifindex, uint16_t *vport);
209 * Api to get the vport for a given physical port.
211 * ulp_ctxt [in] Ptr to ulp context
212 * phy_port [in] physical port index
213 * out_port [out] the port of the given physical index
215 * Returns 0 on success or negative number on failure.
218 ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt,
223 * Api to get the port type for a given ulp ifindex.
225 * ulp_ctxt [in] Ptr to ulp context
226 * ifindex [in] ulp ifindex
230 enum bnxt_ulp_intf_type
231 ulp_port_db_port_type_get(struct bnxt_ulp_context *ulp_ctxt,
235 * Api to get the ulp ifindex for a given function id.
237 * ulp_ctxt [in] Ptr to ulp context
238 * func_id [in].device func id
239 * ifindex [out] ulp ifindex
241 * Returns 0 on success or negative number on failure.
244 ulp_port_db_dev_func_id_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
245 uint32_t func_id, uint32_t *ifindex);
247 #endif /* _ULP_PORT_DB_H_ */