net/bnxt: remove VNIC and vport bits from template match
[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 #define BNXT_PORT_DB_MAX_FUNC                   2048
13
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
18 };
19
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
24 };
25
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
30 };
31
32 enum bnxt_ulp_vnic_type {
33         BNXT_ULP_DRV_FUNC_VNIC = 0,
34         BNXT_ULP_VF_FUNC_VNIC
35 };
36
37 enum bnxt_ulp_fid_type {
38         BNXT_ULP_DRV_FUNC_FID,
39         BNXT_ULP_VF_FUNC_FID
40 };
41
42 struct ulp_func_if_info {
43         uint16_t                func_valid;
44         uint16_t                func_svif;
45         uint16_t                func_spif;
46         uint16_t                func_parif;
47         uint16_t                func_vnic;
48         uint16_t                phy_port_id;
49 };
50
51 /* Structure for the Port database resource information. */
52 struct ulp_interface_info {
53         enum bnxt_ulp_intf_type type;
54         uint16_t                drv_func_id;
55         uint16_t                vf_func_id;
56 };
57
58 struct ulp_phy_port_info {
59         uint16_t        port_valid;
60         uint16_t        port_svif;
61         uint16_t        port_spif;
62         uint16_t        port_parif;
63         uint16_t        port_vport;
64 };
65
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;
70
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];
76 };
77
78 /*
79  * Initialize the port database. Memory is allocated in this
80  * call and assigned to the port database.
81  *
82  * ulp_ctxt [in] Ptr to ulp context
83  *
84  * Returns 0 on success or negative number on failure.
85  */
86 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
87
88 /*
89  * Deinitialize the port database. Memory is deallocated in
90  * this call.
91  *
92  * ulp_ctxt [in] Ptr to ulp context
93  *
94  * Returns 0 on success.
95  */
96 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
97
98 /*
99  * Update the port database.This api is called when the port
100  * details are available during the startup.
101  *
102  * ulp_ctxt [in] Ptr to ulp context
103  * bp [in]. ptr to the device function.
104  *
105  * Returns 0 on success or negative number on failure.
106  */
107 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
108                                          struct rte_eth_dev *eth_dev);
109
110 /*
111  * Api to get the ulp ifindex for a given device port.
112  *
113  * ulp_ctxt [in] Ptr to ulp context
114  * port_id [in].device port id
115  * ifindex [out] ulp ifindex
116  *
117  * Returns 0 on success or negative number on failure.
118  */
119 int32_t
120 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
121                                   uint32_t port_id, uint32_t *ifindex);
122
123 /*
124  * Api to get the function id for a given ulp ifindex.
125  *
126  * ulp_ctxt [in] Ptr to ulp context
127  * ifindex [in] ulp ifindex
128  * func_id [out] the function id of the given ifindex.
129  *
130  * Returns 0 on success or negative number on failure.
131  */
132 int32_t
133 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
134                             uint32_t ifindex, uint32_t fid_type,
135                             uint16_t *func_id);
136
137 /*
138  * Api to get the svif for a given ulp ifindex.
139  *
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.
144  *
145  * Returns 0 on success or negative number on failure.
146  */
147 int32_t
148 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
149                      uint32_t ifindex, uint32_t dir, uint16_t *svif);
150
151 /*
152  * Api to get the spif for a given ulp ifindex.
153  *
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.
158  *
159  * Returns 0 on success or negative number on failure.
160  */
161 int32_t
162 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
163                      uint32_t ifindex, uint32_t dir, uint16_t *spif);
164
165
166 /*
167  * Api to get the parif for a given ulp ifindex.
168  *
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.
173  *
174  * Returns 0 on success or negative number on failure.
175  */
176 int32_t
177 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
178                       uint32_t ifindex, uint32_t dir, uint16_t *parif);
179
180 /*
181  * Api to get the vnic id for a given ulp ifindex.
182  *
183  * ulp_ctxt [in] Ptr to ulp context
184  * ifindex [in] ulp ifindex
185  * vnic [out] the vnic of the given ifindex.
186  *
187  * Returns 0 on success or negative number on failure.
188  */
189 int32_t
190 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
191                              uint32_t ifindex, uint32_t vnic_type,
192                              uint16_t *vnic);
193
194 /*
195  * Api to get the vport id for a given ulp ifindex.
196  *
197  * ulp_ctxt [in] Ptr to ulp context
198  * ifindex [in] ulp ifindex
199  * vport [out] the port of the given ifindex.
200  *
201  * Returns 0 on success or negative number on failure.
202  */
203 int32_t
204 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
205                       uint32_t ifindex, uint16_t *vport);
206
207 /*
208  * Api to get the vport for a given physical port.
209  *
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
213  *
214  * Returns 0 on success or negative number on failure.
215  */
216 int32_t
217 ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt,
218                                uint32_t phy_port,
219                                uint16_t *out_port);
220
221 #endif /* _ULP_PORT_DB_H_ */