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