net/bnxt: support GRE flows
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_rte_parser.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2021 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _ULP_RTE_PARSER_H_
7 #define _ULP_RTE_PARSER_H_
8
9 #include <rte_log.h>
10 #include <rte_flow.h>
11 #include <rte_flow_driver.h>
12 #include "ulp_template_db_enum.h"
13 #include "ulp_template_struct.h"
14 #include "ulp_mapper.h"
15 #include "bnxt_tf_common.h"
16
17 /* defines to be used in the tunnel header parsing */
18 #define BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS        2
19 #define BNXT_ULP_ENCAP_IPV4_ID_PROTO            6
20 #define BNXT_ULP_ENCAP_IPV4_DEST_IP             4
21 #define BNXT_ULP_ENCAP_IPV4_SIZE                12
22 #define BNXT_ULP_ENCAP_IPV6_VTC_FLOW            4
23 #define BNXT_ULP_ENCAP_IPV6_PROTO_TTL           2
24 #define BNXT_ULP_ENCAP_IPV6_DO                  2
25 #define BNXT_ULP_ENCAP_IPV6_SIZE                24
26 #define BNXT_ULP_ENCAP_UDP_SIZE                 4
27 #define BNXT_ULP_INVALID_SVIF_VAL               -1U
28
29 #define BNXT_ULP_GET_IPV6_VER(vtcf)             \
30                         (((vtcf) & BNXT_ULP_PARSER_IPV6_VER_MASK) >> 28)
31 #define BNXT_ULP_GET_IPV6_TC(vtcf)              \
32                         (((vtcf) & BNXT_ULP_PARSER_IPV6_TC) >> 20)
33 #define BNXT_ULP_GET_IPV6_FLOWLABEL(vtcf)       \
34                         ((vtcf) & BNXT_ULP_PARSER_IPV6_FLOW_LABEL)
35 #define BNXT_ULP_PARSER_IPV6_VER_MASK           0xf0000000
36 #define BNXT_ULP_PARSER_IPV6_TC                 0x0ff00000
37 #define BNXT_ULP_PARSER_IPV6_FLOW_LABEL         0x000fffff
38
39 void
40 bnxt_ulp_init_mapper_params(struct bnxt_ulp_mapper_create_parms *mapper_cparms,
41                             struct ulp_rte_parser_params *params,
42                             enum bnxt_ulp_fdb_type flow_type);
43
44 /* Function to handle the parsing of the RTE port id. */
45 int32_t
46 ulp_rte_parser_implicit_match_port_process(struct ulp_rte_parser_params *param);
47
48 /* Function to handle the implicit action port id */
49 int32_t
50 ulp_rte_parser_implicit_act_port_process(struct ulp_rte_parser_params *params);
51
52 /*
53  * Function to handle the parsing of RTE Flows and placing
54  * the RTE flow items into the ulp structures.
55  */
56 int32_t
57 bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[],
58                               struct ulp_rte_parser_params *params);
59
60 /*
61  * Function to handle the parsing of RTE Flows and placing
62  * the RTE flow actions into the ulp structures.
63  */
64 int32_t
65 bnxt_ulp_rte_parser_act_parse(const struct rte_flow_action actions[],
66                               struct ulp_rte_parser_params *params);
67
68 /*
69  * Function to handle the post processing of the parsing details
70  */
71 int32_t
72 bnxt_ulp_rte_parser_post_process(struct ulp_rte_parser_params *params);
73
74 /* Function to handle the parsing of RTE Flow item PF Header. */
75 int32_t
76 ulp_rte_pf_hdr_handler(const struct rte_flow_item *item,
77                        struct ulp_rte_parser_params *params);
78
79 /* Function to handle the parsing of RTE Flow item VF Header. */
80 int32_t
81 ulp_rte_vf_hdr_handler(const struct rte_flow_item *item,
82                        struct ulp_rte_parser_params *params);
83
84 /* Function to handle the parsing of RTE Flow item port id Header. */
85 int32_t
86 ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item,
87                             struct ulp_rte_parser_params *params);
88
89 /* Function to handle the parsing of RTE Flow item port Header. */
90 int32_t
91 ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item,
92                              struct ulp_rte_parser_params *params);
93
94 /* Function to handle the RTE item Ethernet Header. */
95 int32_t
96 ulp_rte_eth_hdr_handler(const struct rte_flow_item *item,
97                         struct ulp_rte_parser_params *params);
98
99 /* Function to handle the parsing of RTE Flow item Vlan Header. */
100 int32_t
101 ulp_rte_vlan_hdr_handler(const struct rte_flow_item *item,
102                          struct ulp_rte_parser_params *params);
103
104 /* Function to handle the parsing of RTE Flow item IPV4 Header. */
105 int32_t
106 ulp_rte_ipv4_hdr_handler(const struct rte_flow_item *item,
107                          struct ulp_rte_parser_params *params);
108
109 /* Function to handle the parsing of RTE Flow item IPV6 Header. */
110 int32_t
111 ulp_rte_ipv6_hdr_handler(const struct rte_flow_item *item,
112                          struct ulp_rte_parser_params *params);
113
114 /* Function to handle the parsing of RTE Flow item UDP Header. */
115 int32_t
116 ulp_rte_udp_hdr_handler(const struct rte_flow_item *item,
117                         struct ulp_rte_parser_params *params);
118
119 /* Function to handle the parsing of RTE Flow item TCP Header. */
120 int32_t
121 ulp_rte_tcp_hdr_handler(const struct rte_flow_item *item,
122                         struct ulp_rte_parser_params *params);
123
124 /* Function to handle the parsing of RTE Flow item Vxlan Header. */
125 int32_t
126 ulp_rte_vxlan_hdr_handler(const struct rte_flow_item *item,
127                           struct ulp_rte_parser_params *params);
128
129 /* Function to handle the parsing of RTE Flow item GRE Header. */
130 int32_t
131 ulp_rte_gre_hdr_handler(const struct rte_flow_item *item,
132                         struct ulp_rte_parser_params *params);
133
134 int32_t
135 ulp_rte_item_any_handler(const struct rte_flow_item *item __rte_unused,
136                          struct ulp_rte_parser_params *params __rte_unused);
137
138 /* Function to handle the parsing of RTE Flow item void Header. */
139 int32_t
140 ulp_rte_void_hdr_handler(const struct rte_flow_item *item,
141                          struct ulp_rte_parser_params *params);
142
143 /* Function to handle the parsing of RTE Flow action void Header. */
144 int32_t
145 ulp_rte_void_act_handler(const struct rte_flow_action *action_item,
146                          struct ulp_rte_parser_params *params);
147
148 /* Function to handle the parsing of RTE Flow action RSS Header. */
149 int32_t
150 ulp_rte_rss_act_handler(const struct rte_flow_action *action_item,
151                         struct ulp_rte_parser_params *params);
152
153 /* Function to handle the parsing of RTE Flow action Mark Header. */
154 int32_t
155 ulp_rte_mark_act_handler(const struct rte_flow_action *action_item,
156                          struct ulp_rte_parser_params *params);
157
158 /* Function to handle the parsing of RTE Flow action vxlan_encap Header. */
159 int32_t
160 ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item,
161                                 struct ulp_rte_parser_params *params);
162
163 /* Function to handle the parsing of RTE Flow action vxlan_encap Header. */
164 int32_t
165 ulp_rte_vxlan_decap_act_handler(const struct rte_flow_action *action_item,
166                                 struct ulp_rte_parser_params *params);
167
168 /* Function to handle the parsing of RTE Flow action drop Header. */
169 int32_t
170 ulp_rte_drop_act_handler(const struct rte_flow_action *action_item,
171                          struct ulp_rte_parser_params *params);
172
173 /* Function to handle the parsing of RTE Flow action count. */
174 int32_t
175 ulp_rte_count_act_handler(const struct rte_flow_action *action_item,
176                           struct ulp_rte_parser_params *params);
177
178 /* Function to handle the parsing of RTE Flow action PF. */
179 int32_t
180 ulp_rte_pf_act_handler(const struct rte_flow_action *action_item,
181                        struct ulp_rte_parser_params *params);
182
183 /* Function to handle the parsing of RTE Flow action VF. */
184 int32_t
185 ulp_rte_vf_act_handler(const struct rte_flow_action *action_item,
186                        struct ulp_rte_parser_params *params);
187
188 /* Function to handle the parsing of RTE Flow action port_id. */
189 int32_t
190 ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item,
191                             struct ulp_rte_parser_params *params);
192
193 /* Function to handle the parsing of RTE Flow action phy_port. */
194 int32_t
195 ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item,
196                              struct ulp_rte_parser_params *params);
197
198 /* Function to handle the parsing of RTE Flow action pop vlan. */
199 int32_t
200 ulp_rte_of_pop_vlan_act_handler(const struct rte_flow_action *action_item,
201                                 struct ulp_rte_parser_params *params);
202
203 /* Function to handle the parsing of RTE Flow action push vlan. */
204 int32_t
205 ulp_rte_of_push_vlan_act_handler(const struct rte_flow_action *action_item,
206                                  struct ulp_rte_parser_params *params);
207
208 /* Function to handle the parsing of RTE Flow action set vlan id. */
209 int32_t
210 ulp_rte_of_set_vlan_vid_act_handler(const struct rte_flow_action *action_item,
211                                     struct ulp_rte_parser_params *params);
212
213 /* Function to handle the parsing of RTE Flow action set vlan pcp. */
214 int32_t
215 ulp_rte_of_set_vlan_pcp_act_handler(const struct rte_flow_action *action_item,
216                                     struct ulp_rte_parser_params *params);
217
218 /* Function to handle the parsing of RTE Flow action set ipv4 src.*/
219 int32_t
220 ulp_rte_set_ipv4_src_act_handler(const struct rte_flow_action *action_item,
221                                  struct ulp_rte_parser_params *params);
222
223 /* Function to handle the parsing of RTE Flow action set ipv4 dst.*/
224 int32_t
225 ulp_rte_set_ipv4_dst_act_handler(const struct rte_flow_action *action_item,
226                                  struct ulp_rte_parser_params *params);
227
228 /* Function to handle the parsing of RTE Flow action set tp src.*/
229 int32_t
230 ulp_rte_set_tp_src_act_handler(const struct rte_flow_action *action_item,
231                                struct ulp_rte_parser_params *params);
232
233 /* Function to handle the parsing of RTE Flow action set tp dst.*/
234 int32_t
235 ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item,
236                                struct ulp_rte_parser_params *params);
237
238 /* Function to handle the parsing of RTE Flow action dec ttl.*/
239 int32_t
240 ulp_rte_dec_ttl_act_handler(const struct rte_flow_action *action_item,
241                             struct ulp_rte_parser_params *params);
242
243 /* Function to handle the parsing of RTE Flow action JUMP .*/
244 int32_t
245 ulp_rte_jump_act_handler(const struct rte_flow_action *action_item,
246                          struct ulp_rte_parser_params *params);
247
248 #endif /* _ULP_RTE_PARSER_H_ */