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