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 struct ulp_func_if_info ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC];
78 * Initialize the port database. Memory is allocated in this
79 * call and assigned to the port database.
81 * ulp_ctxt [in] Ptr to ulp context
83 * Returns 0 on success or negative number on failure.
85 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
88 * Deinitialize the port database. Memory is deallocated in
91 * ulp_ctxt [in] Ptr to ulp context
93 * Returns 0 on success.
95 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
98 * Update the port database.This api is called when the port
99 * details are available during the startup.
101 * ulp_ctxt [in] Ptr to ulp context
102 * bp [in]. ptr to the device function.
104 * Returns 0 on success or negative number on failure.
106 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
107 struct rte_eth_dev *eth_dev);
110 * Api to get the ulp ifindex for a given device port.
112 * ulp_ctxt [in] Ptr to ulp context
113 * port_id [in].device port id
114 * ifindex [out] ulp ifindex
116 * Returns 0 on success or negative number on failure.
119 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
120 uint32_t port_id, uint32_t *ifindex);
123 * Api to get the function id for a given ulp ifindex.
125 * ulp_ctxt [in] Ptr to ulp context
126 * ifindex [in] ulp ifindex
127 * func_id [out] the function id of the given ifindex.
129 * Returns 0 on success or negative number on failure.
132 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
133 uint32_t ifindex, uint32_t fid_type,
137 * Api to get the svif for a given ulp ifindex.
139 * ulp_ctxt [in] Ptr to ulp context
140 * ifindex [in] ulp ifindex
141 * dir [in] the direction for the flow.
142 * svif [out] the svif of the given ifindex.
144 * Returns 0 on success or negative number on failure.
147 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
148 uint32_t ifindex, uint32_t dir, uint16_t *svif);
151 * Api to get the spif for a given ulp ifindex.
153 * ulp_ctxt [in] Ptr to ulp context
154 * ifindex [in] ulp ifindex
155 * dir [in] the direction for the flow.
156 * spif [out] the spif of the given ifindex.
158 * Returns 0 on success or negative number on failure.
161 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
162 uint32_t ifindex, uint32_t dir, uint16_t *spif);
166 * Api to get the parif for a given ulp ifindex.
168 * ulp_ctxt [in] Ptr to ulp context
169 * ifindex [in] ulp ifindex
170 * dir [in] the direction for the flow.
171 * parif [out] the parif of the given ifindex.
173 * Returns 0 on success or negative number on failure.
176 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
177 uint32_t ifindex, uint32_t dir, uint16_t *parif);
180 * Api to get the vnic id for a given ulp ifindex.
182 * ulp_ctxt [in] Ptr to ulp context
183 * ifindex [in] ulp ifindex
184 * vnic [out] the vnic of the given ifindex.
186 * Returns 0 on success or negative number on failure.
189 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
190 uint32_t ifindex, uint32_t vnic_type,
194 * Api to get the vport id for a given ulp ifindex.
196 * ulp_ctxt [in] Ptr to ulp context
197 * ifindex [in] ulp ifindex
198 * vport [out] the port of the given ifindex.
200 * Returns 0 on success or negative number on failure.
203 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
204 uint32_t ifindex, uint16_t *vport);
206 #endif /* _ULP_PORT_DB_H_ */