b1419a34cff10e62d2a14fd747720353b5e548b6
[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         struct ulp_func_if_info         ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC];
75 };
76
77 /*
78  * Initialize the port database. Memory is allocated in this
79  * call and assigned to the port database.
80  *
81  * ulp_ctxt [in] Ptr to ulp context
82  *
83  * Returns 0 on success or negative number on failure.
84  */
85 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt);
86
87 /*
88  * Deinitialize the port database. Memory is deallocated in
89  * this call.
90  *
91  * ulp_ctxt [in] Ptr to ulp context
92  *
93  * Returns 0 on success.
94  */
95 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
96
97 /*
98  * Update the port database.This api is called when the port
99  * details are available during the startup.
100  *
101  * ulp_ctxt [in] Ptr to ulp context
102  * bp [in]. ptr to the device function.
103  *
104  * Returns 0 on success or negative number on failure.
105  */
106 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
107                                          struct rte_eth_dev *eth_dev);
108
109 /*
110  * Api to get the ulp ifindex for a given device port.
111  *
112  * ulp_ctxt [in] Ptr to ulp context
113  * port_id [in].device port id
114  * ifindex [out] ulp ifindex
115  *
116  * Returns 0 on success or negative number on failure.
117  */
118 int32_t
119 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
120                                   uint32_t port_id, uint32_t *ifindex);
121
122 /*
123  * Api to get the function id for a given ulp ifindex.
124  *
125  * ulp_ctxt [in] Ptr to ulp context
126  * ifindex [in] ulp ifindex
127  * func_id [out] the function id of the given ifindex.
128  *
129  * Returns 0 on success or negative number on failure.
130  */
131 int32_t
132 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
133                             uint32_t ifindex, uint32_t fid_type,
134                             uint16_t *func_id);
135
136 /*
137  * Api to get the svif for a given ulp ifindex.
138  *
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.
143  *
144  * Returns 0 on success or negative number on failure.
145  */
146 int32_t
147 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
148                      uint32_t ifindex, uint32_t dir, uint16_t *svif);
149
150 /*
151  * Api to get the spif for a given ulp ifindex.
152  *
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.
157  *
158  * Returns 0 on success or negative number on failure.
159  */
160 int32_t
161 ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
162                      uint32_t ifindex, uint32_t dir, uint16_t *spif);
163
164
165 /*
166  * Api to get the parif for a given ulp ifindex.
167  *
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.
172  *
173  * Returns 0 on success or negative number on failure.
174  */
175 int32_t
176 ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
177                       uint32_t ifindex, uint32_t dir, uint16_t *parif);
178
179 /*
180  * Api to get the vnic id for a given ulp ifindex.
181  *
182  * ulp_ctxt [in] Ptr to ulp context
183  * ifindex [in] ulp ifindex
184  * vnic [out] the vnic of the given ifindex.
185  *
186  * Returns 0 on success or negative number on failure.
187  */
188 int32_t
189 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
190                              uint32_t ifindex, uint32_t vnic_type,
191                              uint16_t *vnic);
192
193 /*
194  * Api to get the vport id for a given ulp ifindex.
195  *
196  * ulp_ctxt [in] Ptr to ulp context
197  * ifindex [in] ulp ifindex
198  * vport [out] the port of the given ifindex.
199  *
200  * Returns 0 on success or negative number on failure.
201  */
202 int32_t
203 ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
204                       uint32_t ifindex, uint16_t *vport);
205
206 #endif /* _ULP_PORT_DB_H_ */