xref: /dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h (revision ba57777d)
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		-1UL
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 enum bnxt_ulp_prsr_action {
40 	ULP_PRSR_ACT_DEFAULT = 0,
41 	ULP_PRSR_ACT_MATCH_IGNORE = 1,
42 	ULP_PRSR_ACT_MASK_IGNORE = 2,
43 	ULP_PRSR_ACT_SPEC_IGNORE = 4
44 };
45 
46 void
47 bnxt_ulp_init_mapper_params(struct bnxt_ulp_mapper_create_parms *mapper_cparms,
48 			    struct ulp_rte_parser_params *params,
49 			    enum bnxt_ulp_fdb_type flow_type);
50 
51 /* Function to handle the parsing of the RTE port id. */
52 int32_t
53 ulp_rte_parser_implicit_match_port_process(struct ulp_rte_parser_params *param);
54 
55 /* Function to handle the implicit action port id */
56 int32_t
57 ulp_rte_parser_implicit_act_port_process(struct ulp_rte_parser_params *params);
58 
59 /*
60  * Function to handle the parsing of RTE Flows and placing
61  * the RTE flow items into the ulp structures.
62  */
63 int32_t
64 bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[],
65 			      struct ulp_rte_parser_params *params);
66 
67 /*
68  * Function to handle the parsing of RTE Flows and placing
69  * the RTE flow actions into the ulp structures.
70  */
71 int32_t
72 bnxt_ulp_rte_parser_act_parse(const struct rte_flow_action actions[],
73 			      struct ulp_rte_parser_params *params);
74 
75 /*
76  * Function to handle the post processing of the parsing details
77  */
78 int32_t
79 bnxt_ulp_rte_parser_post_process(struct ulp_rte_parser_params *params);
80 
81 /* Function to handle the parsing of RTE Flow item PF Header. */
82 int32_t
83 ulp_rte_pf_hdr_handler(const struct rte_flow_item *item,
84 		       struct ulp_rte_parser_params *params);
85 
86 /* Function to handle the parsing of RTE Flow item VF Header. */
87 int32_t
88 ulp_rte_vf_hdr_handler(const struct rte_flow_item *item,
89 		       struct ulp_rte_parser_params *params);
90 
91 /* Function to handle the parsing of RTE Flow item port id Header. */
92 int32_t
93 ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item,
94 			    struct ulp_rte_parser_params *params);
95 
96 /* Function to handle the parsing of RTE Flow item port Header. */
97 int32_t
98 ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item,
99 			     struct ulp_rte_parser_params *params);
100 
101 /* Function to handle the RTE item Ethernet Header. */
102 int32_t
103 ulp_rte_eth_hdr_handler(const struct rte_flow_item *item,
104 			struct ulp_rte_parser_params *params);
105 
106 /* Function to handle the parsing of RTE Flow item Vlan Header. */
107 int32_t
108 ulp_rte_vlan_hdr_handler(const struct rte_flow_item *item,
109 			 struct ulp_rte_parser_params *params);
110 
111 /* Function to handle the parsing of RTE Flow item IPV4 Header. */
112 int32_t
113 ulp_rte_ipv4_hdr_handler(const struct rte_flow_item *item,
114 			 struct ulp_rte_parser_params *params);
115 
116 /* Function to handle the parsing of RTE Flow item IPV6 Header. */
117 int32_t
118 ulp_rte_ipv6_hdr_handler(const struct rte_flow_item *item,
119 			 struct ulp_rte_parser_params *params);
120 
121 /* Function to handle the parsing of RTE Flow item UDP Header. */
122 int32_t
123 ulp_rte_udp_hdr_handler(const struct rte_flow_item *item,
124 			struct ulp_rte_parser_params *params);
125 
126 /* Function to handle the parsing of RTE Flow item TCP Header. */
127 int32_t
128 ulp_rte_tcp_hdr_handler(const struct rte_flow_item *item,
129 			struct ulp_rte_parser_params *params);
130 
131 /* Function to handle the parsing of RTE Flow item Vxlan Header. */
132 int32_t
133 ulp_rte_vxlan_hdr_handler(const struct rte_flow_item *item,
134 			  struct ulp_rte_parser_params *params);
135 
136 /* Function to handle the parsing of RTE Flow item GRE Header. */
137 int32_t
138 ulp_rte_gre_hdr_handler(const struct rte_flow_item *item,
139 			struct ulp_rte_parser_params *params);
140 
141 int32_t
142 ulp_rte_item_any_handler(const struct rte_flow_item *item __rte_unused,
143 			 struct ulp_rte_parser_params *params __rte_unused);
144 
145 /* Function to handle the parsing of RTE Flow item ICMP Header. */
146 int32_t
147 ulp_rte_icmp_hdr_handler(const struct rte_flow_item *item,
148 			 struct ulp_rte_parser_params *params);
149 
150 /* Function to handle the parsing of RTE Flow item ICMP6 Header. */
151 int32_t
152 ulp_rte_icmp6_hdr_handler(const struct rte_flow_item *item,
153 			  struct ulp_rte_parser_params *params);
154 
155 /* Function to handle the parsing of RTE Flow item void Header. */
156 int32_t
157 ulp_rte_void_hdr_handler(const struct rte_flow_item *item,
158 			 struct ulp_rte_parser_params *params);
159 
160 /* Function to handle the parsing of RTE Flow action void Header. */
161 int32_t
162 ulp_rte_void_act_handler(const struct rte_flow_action *action_item,
163 			 struct ulp_rte_parser_params *params);
164 
165 /* Function to handle the parsing of RTE Flow action RSS Header. */
166 int32_t
167 ulp_rte_rss_act_handler(const struct rte_flow_action *action_item,
168 			struct ulp_rte_parser_params *params);
169 
170 /* Function to handle the parsing of RTE Flow action Mark Header. */
171 int32_t
172 ulp_rte_mark_act_handler(const struct rte_flow_action *action_item,
173 			 struct ulp_rte_parser_params *params);
174 
175 /* Function to handle the parsing of RTE Flow action vxlan_encap Header. */
176 int32_t
177 ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item,
178 				struct ulp_rte_parser_params *params);
179 
180 /* Function to handle the parsing of RTE Flow action vxlan_encap Header. */
181 int32_t
182 ulp_rte_vxlan_decap_act_handler(const struct rte_flow_action *action_item,
183 				struct ulp_rte_parser_params *params);
184 
185 /* Function to handle the parsing of RTE Flow action drop Header. */
186 int32_t
187 ulp_rte_drop_act_handler(const struct rte_flow_action *action_item,
188 			 struct ulp_rte_parser_params *params);
189 
190 /* Function to handle the parsing of RTE Flow action count. */
191 int32_t
192 ulp_rte_count_act_handler(const struct rte_flow_action *action_item,
193 			  struct ulp_rte_parser_params *params);
194 
195 /* Function to handle the parsing of RTE Flow action PF. */
196 int32_t
197 ulp_rte_pf_act_handler(const struct rte_flow_action *action_item,
198 		       struct ulp_rte_parser_params *params);
199 
200 /* Function to handle the parsing of RTE Flow action VF. */
201 int32_t
202 ulp_rte_vf_act_handler(const struct rte_flow_action *action_item,
203 		       struct ulp_rte_parser_params *params);
204 
205 /* Function to handle the parsing of RTE Flow action port_id. */
206 int32_t
207 ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item,
208 			    struct ulp_rte_parser_params *params);
209 
210 /* Function to handle the parsing of RTE Flow action phy_port. */
211 int32_t
212 ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item,
213 			     struct ulp_rte_parser_params *params);
214 
215 /* Function to handle the parsing of RTE Flow action pop vlan. */
216 int32_t
217 ulp_rte_of_pop_vlan_act_handler(const struct rte_flow_action *action_item,
218 				struct ulp_rte_parser_params *params);
219 
220 /* Function to handle the parsing of RTE Flow action push vlan. */
221 int32_t
222 ulp_rte_of_push_vlan_act_handler(const struct rte_flow_action *action_item,
223 				 struct ulp_rte_parser_params *params);
224 
225 /* Function to handle the parsing of RTE Flow action set vlan id. */
226 int32_t
227 ulp_rte_of_set_vlan_vid_act_handler(const struct rte_flow_action *action_item,
228 				    struct ulp_rte_parser_params *params);
229 
230 /* Function to handle the parsing of RTE Flow action set vlan pcp. */
231 int32_t
232 ulp_rte_of_set_vlan_pcp_act_handler(const struct rte_flow_action *action_item,
233 				    struct ulp_rte_parser_params *params);
234 
235 /* Function to handle the parsing of RTE Flow action set ipv4 src.*/
236 int32_t
237 ulp_rte_set_ipv4_src_act_handler(const struct rte_flow_action *action_item,
238 				 struct ulp_rte_parser_params *params);
239 
240 /* Function to handle the parsing of RTE Flow action set ipv4 dst.*/
241 int32_t
242 ulp_rte_set_ipv4_dst_act_handler(const struct rte_flow_action *action_item,
243 				 struct ulp_rte_parser_params *params);
244 
245 /* Function to handle the parsing of RTE Flow action set tp src.*/
246 int32_t
247 ulp_rte_set_tp_src_act_handler(const struct rte_flow_action *action_item,
248 			       struct ulp_rte_parser_params *params);
249 
250 /* Function to handle the parsing of RTE Flow action set tp dst.*/
251 int32_t
252 ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item,
253 			       struct ulp_rte_parser_params *params);
254 
255 /* Function to handle the parsing of RTE Flow action dec ttl.*/
256 int32_t
257 ulp_rte_dec_ttl_act_handler(const struct rte_flow_action *action_item,
258 			    struct ulp_rte_parser_params *params);
259 
260 /* Function to handle the parsing of RTE Flow action JUMP .*/
261 int32_t
262 ulp_rte_jump_act_handler(const struct rte_flow_action *action_item,
263 			 struct ulp_rte_parser_params *params);
264 
265 int32_t
266 ulp_rte_sample_act_handler(const struct rte_flow_action *action_item,
267 			   struct ulp_rte_parser_params *params);
268 
269 int32_t
270 ulp_rte_shared_act_handler(const struct rte_flow_action *action_item,
271 			   struct ulp_rte_parser_params *params);
272 
273 #endif /* _ULP_RTE_PARSER_H_ */
274