f9e5e2ba68c3f3f7093eed99782aef64fdab4782
[dpdk.git] / drivers / net / bnxt / tf_ulp / bnxt_ulp.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _BNXT_ULP_H_
7 #define _BNXT_ULP_H_
8
9 #include <inttypes.h>
10 #include <stdbool.h>
11 #include <sys/queue.h>
12
13 #include "rte_ethdev.h"
14
15 #include "ulp_template_db_enum.h"
16
17 /* defines for the ulp_flags */
18 #define BNXT_ULP_VF_REP_ENABLED         0x1
19 #define ULP_VF_REP_IS_ENABLED(flag)     ((flag) & BNXT_ULP_VF_REP_ENABLED)
20
21 struct bnxt_ulp_data {
22         uint32_t                        tbl_scope_id;
23         struct bnxt_ulp_mark_tbl        *mark_tbl;
24         uint32_t                        dev_id; /* Hardware device id */
25         uint32_t                        ref_cnt;
26         struct bnxt_ulp_flow_db         *flow_db;
27         void                            *mapper_data;
28         struct bnxt_ulp_port_db         *port_db;
29         struct bnxt_ulp_fc_info         *fc_info;
30         uint32_t                        ulp_flags;
31         uint32_t                        port_to_app_flow_id;
32         uint32_t                        app_to_port_flow_id;
33         uint32_t                        tx_cfa_action;
34 };
35
36 struct bnxt_ulp_context {
37         struct bnxt_ulp_data    *cfg_data;
38         /* TBD The tfp should be removed once tf_attach is implemented. */
39         struct tf               *g_tfp;
40 };
41
42 struct bnxt_ulp_pci_info {
43         uint32_t        domain;
44         uint8_t         bus;
45 };
46
47 struct bnxt_ulp_session_state {
48         STAILQ_ENTRY(bnxt_ulp_session_state)    next;
49         bool                                    bnxt_ulp_init;
50         pthread_mutex_t                         bnxt_ulp_mutex;
51         struct bnxt_ulp_pci_info                pci_info;
52         struct bnxt_ulp_data                    *cfg_data;
53         /* TBD The tfp should be removed once tf_attach is implemented. */
54         struct tf                               *g_tfp;
55         uint32_t                                session_opened;
56 };
57
58 /* ULP flow id structure */
59 struct rte_tf_flow {
60         uint32_t        flow_id;
61 };
62
63 struct ulp_tlv_param {
64         enum bnxt_ulp_df_param_type type;
65         uint32_t length;
66         uint8_t value[16];
67 };
68
69 /*
70  * Allow the deletion of context only for the bnxt device that
71  * created the session
72  * TBD - The implementation of the function should change to
73  * using the reference count once tf_session_attach functionality
74  * is fixed.
75  */
76 bool
77 ulp_ctx_deinit_allowed(void *bp);
78
79 /* Function to set the device id of the hardware. */
80 int32_t
81 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);
82
83 /* Function to get the device id of the hardware. */
84 int32_t
85 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);
86
87 /* Function to set the table scope id of the EEM table. */
88 int32_t
89 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
90                                 uint32_t tbl_scope_id);
91
92 /* Function to get the table scope id of the EEM table. */
93 int32_t
94 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
95                                 uint32_t *tbl_scope_id);
96
97 /* Function to set the tfp session details in the ulp context. */
98 int32_t
99 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
100
101 /* Function to get the tfp session details from ulp context. */
102 struct tf *
103 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp);
104
105 /* Get the device table entry based on the device id. */
106 struct bnxt_ulp_device_params *
107 bnxt_ulp_device_params_get(uint32_t dev_id);
108
109 int32_t
110 bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
111                                struct bnxt_ulp_mark_tbl *mark_tbl);
112
113 struct bnxt_ulp_mark_tbl *
114 bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
115
116 /* Function to set the flow database to the ulp context. */
117 int32_t
118 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
119                                 struct bnxt_ulp_flow_db *flow_db);
120
121 /* Function to get the flow database from the ulp context. */
122 struct bnxt_ulp_flow_db *
123 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx);
124
125 /* Function to get the ulp context from eth device. */
126 struct bnxt_ulp_context *
127 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
128
129 /* Function to add the ulp mapper data to the ulp context */
130 int32_t
131 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
132                                     void *mapper_data);
133
134 /* Function to get the ulp mapper data from the ulp context */
135 void *
136 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
137
138 /* Function to set the port database to the ulp context. */
139 int32_t
140 bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx,
141                                 struct bnxt_ulp_port_db *port_db);
142
143 /* Function to get the port database from the ulp context. */
144 struct bnxt_ulp_port_db *
145 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx);
146
147 /* Function to create default flows. */
148 int32_t
149 ulp_default_flow_create(struct rte_eth_dev *eth_dev,
150                         struct ulp_tlv_param *param_list,
151                         uint32_t ulp_class_tid,
152                         uint32_t *flow_id);
153
154 /* Function to destroy default flows. */
155 int32_t
156 ulp_default_flow_destroy(struct rte_eth_dev *eth_dev,
157                          uint32_t flow_id);
158
159 int
160 bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
161                       struct rte_flow_error *error);
162
163 int32_t
164 bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx,
165                                 struct bnxt_ulp_fc_info *ulp_fc_info);
166
167 struct bnxt_ulp_fc_info *
168 bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx);
169
170 int32_t
171 bnxt_ulp_cntxt_ptr2_ulp_flags_get(struct bnxt_ulp_context *ulp_ctx,
172                                   uint32_t *flags);
173
174 #endif /* _BNXT_ULP_H_ */