net/bnxt: aggregate ULP parser arguments
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_template_struct.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2019 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _ULP_TEMPLATE_STRUCT_H_
7 #define _ULP_TEMPLATE_STRUCT_H_
8
9 #include <stdint.h>
10 #include "rte_ether.h"
11 #include "rte_icmp.h"
12 #include "rte_ip.h"
13 #include "rte_tcp.h"
14 #include "rte_udp.h"
15 #include "rte_esp.h"
16 #include "rte_sctp.h"
17 #include "rte_flow.h"
18 #include "tf_core.h"
19
20 /* Number of fields for each protocol */
21 #define BNXT_ULP_PROTO_HDR_SVIF_NUM     1
22 #define BNXT_ULP_PROTO_HDR_ETH_NUM      3
23 #define BNXT_ULP_PROTO_HDR_S_VLAN_NUM   3
24 #define BNXT_ULP_PROTO_HDR_VLAN_NUM     6
25 #define BNXT_ULP_PROTO_HDR_IPV4_NUM     10
26 #define BNXT_ULP_PROTO_HDR_IPV6_NUM     6
27 #define BNXT_ULP_PROTO_HDR_UDP_NUM      4
28 #define BNXT_ULP_PROTO_HDR_TCP_NUM      9
29 #define BNXT_ULP_PROTO_HDR_VXLAN_NUM    4
30 #define BNXT_ULP_PROTO_HDR_MAX          128
31
32 struct ulp_rte_hdr_bitmap {
33         uint64_t        bits;
34 };
35
36 /* Structure to store the protocol fields */
37 #define RTE_PARSER_FLOW_HDR_FIELD_SIZE          16
38 struct ulp_rte_hdr_field {
39         uint8_t         spec[RTE_PARSER_FLOW_HDR_FIELD_SIZE];
40         uint8_t         mask[RTE_PARSER_FLOW_HDR_FIELD_SIZE];
41         uint32_t        size;
42 };
43
44 struct ulp_rte_act_bitmap {
45         uint64_t        bits;
46 };
47
48 /* Structure to hold the action property details. */
49 struct ulp_rte_act_prop {
50         uint8_t act_details[BNXT_ULP_ACT_PROP_IDX_LAST];
51 };
52
53 /* Structure to be used for passing all the parser functions */
54 struct ulp_rte_parser_params {
55         struct ulp_rte_hdr_bitmap       hdr_bitmap;
56         struct ulp_rte_hdr_field        hdr_field[BNXT_ULP_PROTO_HDR_MAX];
57         uint32_t                        field_idx;
58         uint32_t                        vlan_idx;
59         struct ulp_rte_act_bitmap       act_bitmap;
60         struct ulp_rte_act_prop         act_prop;
61         uint32_t                        dir;
62 };
63
64 /* Flow Parser Header Information Structure */
65 struct bnxt_ulp_rte_hdr_info {
66         enum bnxt_ulp_hdr_type                                  hdr_type;
67         /* Flow Parser Protocol Header Function Prototype */
68         int (*proto_hdr_func)(const struct rte_flow_item        *item_list,
69                               struct ulp_rte_parser_params      *params);
70 };
71
72 /* Flow Parser Header Information Structure Array defined in template source*/
73 extern struct bnxt_ulp_rte_hdr_info     ulp_hdr_info[];
74
75 struct bnxt_ulp_matcher_field_info {
76         enum bnxt_ulp_fmf_mask  mask_opcode;
77         enum bnxt_ulp_fmf_spec  spec_opcode;
78 };
79
80 /* Flow Parser Action Information Structure */
81 struct bnxt_ulp_rte_act_info {
82         enum bnxt_ulp_act_type                                  act_type;
83         /* Flow Parser Protocol Action Function Prototype */
84         int32_t (*proto_act_func)
85                 (const struct rte_flow_action   *action_item,
86                  struct ulp_rte_parser_params   *params);
87 };
88
89 /* Flow Parser Action Information Structure Array defined in template source*/
90 extern struct bnxt_ulp_rte_act_info     ulp_act_info[];
91
92 /* Flow Matcher structures */
93 struct bnxt_ulp_header_match_info {
94         struct ulp_rte_hdr_bitmap               hdr_bitmap;
95         uint32_t                                start_idx;
96         uint32_t                                num_entries;
97         uint32_t                                class_tmpl_id;
98         uint32_t                                act_vnic;
99 };
100
101 /* Flow Matcher templates Structure Array defined in template source*/
102 extern struct bnxt_ulp_header_match_info  ulp_ingress_hdr_match_list[];
103 extern struct bnxt_ulp_header_match_info  ulp_egress_hdr_match_list[];
104
105 /* Flow field match Information Structure Array defined in template source*/
106 extern struct bnxt_ulp_matcher_field_info       ulp_field_match[];
107
108 /* Flow Matcher Action structures */
109 struct bnxt_ulp_action_match_info {
110         struct ulp_rte_act_bitmap               act_bitmap;
111         uint32_t                                act_tmpl_id;
112 };
113
114 /* Flow Matcher templates Structure Array defined in template source */
115 extern struct bnxt_ulp_action_match_info  ulp_ingress_act_match_list[];
116 extern struct bnxt_ulp_action_match_info  ulp_egress_act_match_list[];
117
118 /* Device specific parameters */
119 struct bnxt_ulp_device_params {
120         uint8_t                         description[16];
121         uint32_t                        global_fid_enable;
122         enum bnxt_ulp_byte_order        byte_order;
123         uint8_t                         encap_byte_swap;
124         uint32_t                        lfid_entries;
125         uint32_t                        lfid_entry_size;
126         uint64_t                        gfid_entries;
127         uint32_t                        gfid_entry_size;
128         uint64_t                        num_flows;
129         uint32_t                        num_resources_per_flow;
130 };
131
132 /* Flow Mapper */
133 struct bnxt_ulp_mapper_tbl_list_info {
134         uint32_t        device_name;
135         uint32_t        start_tbl_idx;
136         uint32_t        num_tbls;
137 };
138
139 struct bnxt_ulp_mapper_class_tbl_info {
140         enum bnxt_ulp_resource_func     resource_func;
141         uint32_t        table_type;
142         uint8_t         direction;
143         uint8_t         mem;
144         uint32_t        priority;
145         uint8_t         srch_b4_alloc;
146         uint32_t        critical_resource;
147
148         /* Information for accessing the ulp_key_field_list */
149         uint32_t        key_start_idx;
150         uint16_t        key_bit_size;
151         uint16_t        key_num_fields;
152         /* Size of the blob that holds the key */
153         uint16_t        blob_key_bit_size;
154
155         /* Information for accessing the ulp_class_result_field_list */
156         uint32_t        result_start_idx;
157         uint16_t        result_bit_size;
158         uint16_t        result_num_fields;
159
160         /* Information for accessing the ulp_ident_list */
161         uint32_t        ident_start_idx;
162         uint16_t        ident_nums;
163
164         uint8_t         mark_enable;
165         enum bnxt_ulp_regfile_index     regfile_wr_idx;
166 };
167
168 struct bnxt_ulp_mapper_act_tbl_info {
169         enum bnxt_ulp_resource_func     resource_func;
170         enum tf_tbl_type table_type;
171         uint8_t         direction;
172         uint8_t         srch_b4_alloc;
173         uint32_t        result_start_idx;
174         uint16_t        result_bit_size;
175         uint16_t        encap_num_fields;
176         uint16_t        result_num_fields;
177
178         enum bnxt_ulp_regfile_index     regfile_wr_idx;
179 };
180
181 struct bnxt_ulp_mapper_class_key_field_info {
182         uint8_t                 name[64];
183         enum bnxt_ulp_mask_opc  mask_opcode;
184         enum bnxt_ulp_spec_opc  spec_opcode;
185         uint16_t                field_bit_size;
186         uint8_t                 mask_operand[16];
187         uint8_t                 spec_operand[16];
188 };
189
190 struct bnxt_ulp_mapper_result_field_info {
191         uint8_t                         name[64];
192         enum bnxt_ulp_result_opc        result_opcode;
193         uint16_t                        field_bit_size;
194         uint8_t                         result_operand[16];
195 };
196
197 struct bnxt_ulp_mapper_ident_info {
198         uint8_t         name[64];
199         uint32_t        resource_func;
200
201         uint16_t        ident_type;
202         uint16_t        ident_bit_size;
203         uint16_t        ident_bit_pos;
204         enum bnxt_ulp_regfile_index     regfile_wr_idx;
205 };
206
207 /*
208  * Flow Mapper Static Data Externs:
209  * Access to the below static data should be done through access functions and
210  * directly throughout the code.
211  */
212
213 /*
214  * The ulp_device_params is indexed by the dev_id.
215  * This table maintains the device specific parameters.
216  */
217 extern struct bnxt_ulp_device_params ulp_device_params[];
218
219 /*
220  * The ulp_class_tmpl_list and ulp_act_tmpl_list are indexed by the dev_id
221  * and template id (either class or action) returned by the matcher.
222  * The result provides the start index and number of entries in the connected
223  * ulp_class_tbl_list/ulp_act_tbl_list.
224  */
225 extern struct bnxt_ulp_mapper_tbl_list_info     ulp_class_tmpl_list[];
226 extern struct bnxt_ulp_mapper_tbl_list_info     ulp_act_tmpl_list[];
227
228 /*
229  * The ulp_class_tbl_list and ulp_act_tbl_list are indexed based on the results
230  * of the template lists.  Each entry describes the high level details of the
231  * table entry to include the start index and number of instructions in the
232  * field lists.
233  */
234 extern struct bnxt_ulp_mapper_class_tbl_info    ulp_class_tbl_list[];
235 extern struct bnxt_ulp_mapper_act_tbl_info      ulp_act_tbl_list[];
236
237 /*
238  * The ulp_class_result_field_list provides the instructions for creating result
239  * records such as tcam/em results.
240  */
241 extern struct bnxt_ulp_mapper_result_field_info ulp_class_result_field_list[];
242
243 /*
244  * The ulp_data_field_list provides the instructions for creating an action
245  * record.  It uses the same structure as the result list, but is only used for
246  * actions.
247  */
248 extern
249 struct bnxt_ulp_mapper_result_field_info ulp_act_result_field_list[];
250
251 /*
252  * The ulp_act_prop_map_table provides the mapping to index and size of action
253  * tcam and em tables.
254  */
255 extern
256 struct bnxt_ulp_mapper_class_key_field_info     ulp_class_key_field_list[];
257
258 /*
259  * The ulp_ident_list provides the instructions for creating identifiers such
260  * as profile ids.
261  */
262 extern struct bnxt_ulp_mapper_ident_info        ulp_ident_list[];
263
264 /*
265  * The ulp_act_prop_map_table provides the mapping to index and size of action
266  * properties.
267  */
268 extern uint32_t ulp_act_prop_map_table[];
269
270 #endif /* _ULP_TEMPLATE_STRUCT_H_ */