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