87de3bcbc69ccd839aaf1d1de30720016cd9fb5f
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_port_db.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2019 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _ULP_PORT_DB_H_
7 #define _ULP_PORT_DB_H_
8
9 #include "bnxt_ulp.h"
10
11 #define BNXT_PORT_DB_MAX_INTF_LIST              256
12
13 /* Structure for the Port database resource information. */
14 struct ulp_interface_info {
15         enum bnxt_ulp_intf_type type;
16         uint16_t                func_id;
17         uint16_t                func_svif;
18         uint16_t                func_spif;
19         uint16_t                func_parif;
20         uint16_t                default_vnic;
21         uint16_t                phy_port_id;
22 };
23
24 struct ulp_phy_port_info {
25         uint16_t        port_svif;
26         uint16_t        port_spif;
27         uint16_t        port_parif;
28         uint16_t        port_vport;
29 };
30
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;
35
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];
39 };
40
41 /*
42  * Initialize the port database. Memory is allocated in this
43  * call and assigned to the port database.
44  *
45  * ulp_ctxt [in] Ptr to ulp context
46  *
47  * Returns 0 on success or negative number on failure.
48  */
49 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt);
50
51 /*
52  * Deinitialize the port database. Memory is deallocated in
53  * this call.
54  *
55  * ulp_ctxt [in] Ptr to ulp context
56  *
57  * Returns 0 on success.
58  */
59 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
60
61 /*
62  * Update the port database.This api is called when the port
63  * details are available during the startup.
64  *
65  * ulp_ctxt [in] Ptr to ulp context
66  * bp [in]. ptr to the device function.
67  *
68  * Returns 0 on success or negative number on failure.
69  */
70 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
71                                          struct rte_eth_dev *eth_dev);
72
73 /*
74  * Api to get the ulp ifindex for a given device port.
75  *
76  * ulp_ctxt [in] Ptr to ulp context
77  * port_id [in].device port id
78  * ifindex [out] ulp ifindex
79  *
80  * Returns 0 on success or negative number on failure.
81  */
82 int32_t
83 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
84                                   uint32_t port_id, uint32_t *ifindex);
85
86 /*
87  * Api to get the function id for a given ulp ifindex.
88  *
89  * ulp_ctxt [in] Ptr to ulp context
90  * ifindex [in] ulp ifindex
91  * func_id [out] the function id of the given ifindex.
92  *
93  * Returns 0 on success or negative number on failure.
94  */
95 int32_t
96 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
97                             uint32_t ifindex, uint16_t *func_id);
98
99 /*
100  * Api to get the svif for a given ulp ifindex.
101  *
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.
106  *
107  * Returns 0 on success or negative number on failure.
108  */
109 int32_t
110 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
111                      uint32_t ifindex, uint32_t dir, uint16_t *svif);
112
113 /*
114  * Api to get the spif for a given ulp ifindex.
115  *
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.
120  *
121  * Returns 0 on success or negative number on failure.
122  */
123 int32_t
124 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
125                      uint32_t ifindex, uint32_t dir, uint16_t *spif);
126
127
128 /*
129  * Api to get the parif for a given ulp ifindex.
130  *
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.
135  *
136  * Returns 0 on success or negative number on failure.
137  */
138 int32_t
139 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
140                       uint32_t ifindex, uint32_t dir, uint16_t *parif);
141
142 /*
143  * Api to get the vnic id for a given ulp ifindex.
144  *
145  * ulp_ctxt [in] Ptr to ulp context
146  * ifindex [in] ulp ifindex
147  * vnic [out] the vnic of the given ifindex.
148  *
149  * Returns 0 on success or negative number on failure.
150  */
151 int32_t
152 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
153                              uint32_t ifindex, uint16_t *vnic);
154
155 /*
156  * Api to get the vport id for a given ulp ifindex.
157  *
158  * ulp_ctxt [in] Ptr to ulp context
159  * ifindex [in] ulp ifindex
160  * vport [out] the port of the given ifindex.
161  *
162  * Returns 0 on success or negative number on failure.
163  */
164 int32_t
165 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
166                       uint32_t ifindex, uint16_t *vport);
167
168 #endif /* _ULP_PORT_DB_H_ */