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
13 /* Structure for the Port database resource information. */
14 struct ulp_interface_info {
15 enum bnxt_ulp_intf_type type;
20 uint16_t default_vnic;
24 struct ulp_phy_port_info {
31 /* Structure for the Port database */
32 struct bnxt_ulp_port_db {
33 struct ulp_interface_info *ulp_intf_list;
34 uint32_t ulp_intf_list_size;
36 /* dpdk device external port list */
37 uint16_t dev_port_list[RTE_MAX_ETHPORTS];
38 struct ulp_phy_port_info phy_port_list[RTE_MAX_ETHPORTS];
42 * Initialize the port database. Memory is allocated in this
43 * call and assigned to the port database.
45 * ulp_ctxt [in] Ptr to ulp context
47 * Returns 0 on success or negative number on failure.
49 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt);
52 * Deinitialize the port database. Memory is deallocated in
55 * ulp_ctxt [in] Ptr to ulp context
57 * Returns 0 on success.
59 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
62 * Update the port database.This api is called when the port
63 * details are available during the startup.
65 * ulp_ctxt [in] Ptr to ulp context
66 * bp [in]. ptr to the device function.
68 * Returns 0 on success or negative number on failure.
70 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
71 struct rte_eth_dev *eth_dev);
74 * Api to get the ulp ifindex for a given device port.
76 * ulp_ctxt [in] Ptr to ulp context
77 * port_id [in].device port id
78 * ifindex [out] ulp ifindex
80 * Returns 0 on success or negative number on failure.
83 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
84 uint32_t port_id, uint32_t *ifindex);
87 * Api to get the function id for a given ulp ifindex.
89 * ulp_ctxt [in] Ptr to ulp context
90 * ifindex [in] ulp ifindex
91 * func_id [out] the function id of the given ifindex.
93 * Returns 0 on success or negative number on failure.
96 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
97 uint32_t ifindex, uint16_t *func_id);
100 * Api to get the svif for a given ulp ifindex.
102 * ulp_ctxt [in] Ptr to ulp context
103 * ifindex [in] ulp ifindex
104 * dir [in] the direction for the flow.
105 * svif [out] the svif of the given ifindex.
107 * Returns 0 on success or negative number on failure.
110 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
111 uint32_t ifindex, uint32_t dir, uint16_t *svif);
114 * Api to get the spif for a given ulp ifindex.
116 * ulp_ctxt [in] Ptr to ulp context
117 * ifindex [in] ulp ifindex
118 * dir [in] the direction for the flow.
119 * spif [out] the spif of the given ifindex.
121 * Returns 0 on success or negative number on failure.
124 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
125 uint32_t ifindex, uint32_t dir, uint16_t *spif);
129 * Api to get the parif for a given ulp ifindex.
131 * ulp_ctxt [in] Ptr to ulp context
132 * ifindex [in] ulp ifindex
133 * dir [in] the direction for the flow.
134 * parif [out] the parif of the given ifindex.
136 * Returns 0 on success or negative number on failure.
139 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
140 uint32_t ifindex, uint32_t dir, uint16_t *parif);
143 * Api to get the vnic id for a given ulp ifindex.
145 * ulp_ctxt [in] Ptr to ulp context
146 * ifindex [in] ulp ifindex
147 * vnic [out] the vnic of the given ifindex.
149 * Returns 0 on success or negative number on failure.
152 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
153 uint32_t ifindex, uint16_t *vnic);
156 * Api to get the vport id for a given ulp ifindex.
158 * ulp_ctxt [in] Ptr to ulp context
159 * ifindex [in] ulp ifindex
160 * vport [out] the port of the given ifindex.
162 * Returns 0 on success or negative number on failure.
165 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
166 uint32_t ifindex, uint16_t *vport);
168 #endif /* _ULP_PORT_DB_H_ */