604c4385a2b41a2708af377b0db8f628ee0831d7
[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                port_svif;
19         uint16_t                default_vnic;
20         uint8_t                 mac_addr[RTE_ETHER_ADDR_LEN];
21         /* back pointer to the bnxt driver, it is null for rep ports */
22         struct bnxt             *bp;
23 };
24
25 /* Structure for the Port database */
26 struct bnxt_ulp_port_db {
27         struct ulp_interface_info       *ulp_intf_list;
28         uint32_t                        ulp_intf_list_size;
29
30         /* dpdk device external port list */
31         uint16_t                        dev_port_list[RTE_MAX_ETHPORTS];
32 };
33
34 /*
35  * Initialize the port database. Memory is allocated in this
36  * call and assigned to the port database.
37  *
38  * ulp_ctxt [in] Ptr to ulp context
39  *
40  * Returns 0 on success or negative number on failure.
41  */
42 int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt);
43
44 /*
45  * Deinitialize the port database. Memory is deallocated in
46  * this call.
47  *
48  * ulp_ctxt [in] Ptr to ulp context
49  *
50  * Returns 0 on success.
51  */
52 int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
53
54 /*
55  * Update the port database.This api is called when the port
56  * details are available during the startup.
57  *
58  * ulp_ctxt [in] Ptr to ulp context
59  * bp [in]. ptr to the device function.
60  *
61  * Returns 0 on success or negative number on failure.
62  */
63 int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
64                                          struct rte_eth_dev *eth_dev);
65
66 /*
67  * Api to get the ulp ifindex for a given device port.
68  *
69  * ulp_ctxt [in] Ptr to ulp context
70  * port_id [in].device port id
71  * ifindex [out] ulp ifindex
72  *
73  * Returns 0 on success or negative number on failure.
74  */
75 int32_t
76 ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
77                                   uint32_t port_id,
78                                   uint32_t *ifindex);
79
80 /*
81  * Api to get the function id for a given ulp ifindex.
82  *
83  * ulp_ctxt [in] Ptr to ulp context
84  * ifindex [in] ulp ifindex
85  * func_id [out] the function id of the given ifindex.
86  *
87  * Returns 0 on success or negative number on failure.
88  */
89 int32_t
90 ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
91                             uint32_t ifindex,
92                             uint16_t *func_id);
93
94 /*
95  * Api to get the svid for a given ulp ifindex.
96  *
97  * ulp_ctxt [in] Ptr to ulp context
98  * ifindex [in] ulp ifindex
99  * dir [in] the direction for the flow.
100  * svif [out] the svif of the given ifindex.
101  *
102  * Returns 0 on success or negative number on failure.
103  */
104 int32_t
105 ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
106                      uint32_t ifindex,
107                      uint32_t dir,
108                      uint16_t *svif);
109
110 /*
111  * Api to get the vnic id for a given ulp ifindex.
112  *
113  * ulp_ctxt [in] Ptr to ulp context
114  * ifindex [in] ulp ifindex
115  * vnic [out] the vnic of the given ifindex.
116  *
117  * Returns 0 on success or negative number on failure.
118  */
119 int32_t
120 ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
121                              uint32_t ifindex,
122                              uint16_t *vnic);
123
124 #endif /* _ULP_PORT_DB_H_ */