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 {
51 /* Structure for the Port database resource information. */
52 struct ulp_interface_info {
53 enum bnxt_ulp_intf_type type;
58 struct ulp_phy_port_info {
66 /* Structure for the Port database */
67 struct bnxt_ulp_port_db {
68 struct ulp_interface_info *ulp_intf_list;
69 uint32_t ulp_intf_list_size;
71 /* dpdk device external port list */
72 uint16_t dev_port_list[RTE_MAX_ETHPORTS];
73 struct ulp_phy_port_info *phy_port_list;
74 uint16_t phy_port_cnt;
75 struct ulp_func_if_info ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC];
79 * Initialize the port database. Memory is allocated in this
80 * call and assigned to the port database.
82 * ulp_ctxt [in] Ptr to ulp context
84 * Returns 0 on success or negative number on failure.
86 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
89 * Deinitialize the port database. Memory is deallocated in
92 * ulp_ctxt [in] Ptr to ulp context
94 * Returns 0 on success.
96 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
99 * Update the port database.This api is called when the port
100 * details are available during the startup.
102 * ulp_ctxt [in] Ptr to ulp context
103 * bp [in]. ptr to the device function.
105 * Returns 0 on success or negative number on failure.
107 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
108 struct rte_eth_dev *eth_dev);
111 * Api to get the ulp ifindex for a given device port.
113 * ulp_ctxt [in] Ptr to ulp context
114 * port_id [in].device port id
115 * ifindex [out] ulp ifindex
117 * Returns 0 on success or negative number on failure.
120 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
121 uint32_t port_id, uint32_t *ifindex);
124 * Api to get the function id for a given ulp ifindex.
126 * ulp_ctxt [in] Ptr to ulp context
127 * ifindex [in] ulp ifindex
128 * func_id [out] the function id of the given ifindex.
130 * Returns 0 on success or negative number on failure.
133 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
134 uint32_t ifindex, uint32_t fid_type,
138 * Api to get the svif for a given ulp ifindex.
140 * ulp_ctxt [in] Ptr to ulp context
141 * ifindex [in] ulp ifindex
142 * dir [in] the direction for the flow.
143 * svif [out] the svif of the given ifindex.
145 * Returns 0 on success or negative number on failure.
148 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
149 uint32_t ifindex, uint32_t dir, uint16_t *svif);
152 * Api to get the spif for a given ulp ifindex.
154 * ulp_ctxt [in] Ptr to ulp context
155 * ifindex [in] ulp ifindex
156 * dir [in] the direction for the flow.
157 * spif [out] the spif of the given ifindex.
159 * Returns 0 on success or negative number on failure.
162 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
163 uint32_t ifindex, uint32_t dir, uint16_t *spif);
167 * Api to get the parif for a given ulp ifindex.
169 * ulp_ctxt [in] Ptr to ulp context
170 * ifindex [in] ulp ifindex
171 * dir [in] the direction for the flow.
172 * parif [out] the parif of the given ifindex.
174 * Returns 0 on success or negative number on failure.
177 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
178 uint32_t ifindex, uint32_t dir, uint16_t *parif);
181 * Api to get the vnic id for a given ulp ifindex.
183 * ulp_ctxt [in] Ptr to ulp context
184 * ifindex [in] ulp ifindex
185 * vnic [out] the vnic of the given ifindex.
187 * Returns 0 on success or negative number on failure.
190 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
191 uint32_t ifindex, uint32_t vnic_type,
195 * Api to get the vport id for a given ulp ifindex.
197 * ulp_ctxt [in] Ptr to ulp context
198 * ifindex [in] ulp ifindex
199 * vport [out] the port of the given ifindex.
201 * Returns 0 on success or negative number on failure.
204 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
205 uint32_t ifindex, uint16_t *vport);
208 * Api to get the vport for a given physical port.
210 * ulp_ctxt [in] Ptr to ulp context
211 * phy_port [in] physical port index
212 * out_port [out] the port of the given physical index
214 * Returns 0 on success or negative number on failure.
217 ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt,
221 #endif /* _ULP_PORT_DB_H_ */