xref: /dpdk/app/test/test_security_inline_proto_vectors.h (revision 0151b80786ebbc62f0ead73bd4708665228a093d)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2022 Marvell.
3  */
4 #ifndef _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
5 #define _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
6 
7 #include "test_cryptodev_security_ipsec.h"
8 
9 uint8_t dummy_ipv4_eth_hdr[] = {
10 		/* ETH */
11 		0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
12 		0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00,
13 };
14 uint8_t dummy_ipv6_eth_hdr[] = {
15 		/* ETH */
16 		0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
17 		0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd,
18 };
19 
20 #define MAX_FRAG_LEN		 IPSEC_TEXT_MAX_LEN
21 #define MAX_FRAGS		 6
22 #define MAX_PKT_LEN		 (MAX_FRAG_LEN * MAX_FRAGS)
23 
24 struct ip_reassembly_test_packet {
25 	uint32_t len;
26 	uint32_t l4_offset;
27 	uint8_t data[MAX_PKT_LEN];
28 };
29 
30 struct reassembly_vector {
31 	/* input/output text in struct ipsec_test_data are not used */
32 	struct ipsec_test_data *sa_data;
33 	struct ip_reassembly_test_packet *full_pkt;
34 	struct ip_reassembly_test_packet *frags[MAX_FRAGS];
35 	uint16_t nb_frags;
36 	bool burst;
37 };
38 
39 struct ip_pkt_vector {
40 	/* input/output text in struct ipsec_test_data are not used */
41 	struct ipsec_test_data *sa_data;
42 	struct ip_reassembly_test_packet *full_pkt;
43 	bool burst;
44 };
45 
46 struct sa_expiry_vector {
47 	struct ipsec_session_data *sa_data;
48 	enum rte_eth_event_ipsec_subtype event;
49 	bool notify_event;
50 };
51 
52 /* The source file includes below test vectors */
53 /* IPv6:
54  *
55  *	1) pkt_ipv6_udp_p1
56  *		pkt_ipv6_udp_p1_f1
57  *		pkt_ipv6_udp_p1_f2
58  *
59  *	2) pkt_ipv6_udp_p2
60  *		pkt_ipv6_udp_p2_f1
61  *		pkt_ipv6_udp_p2_f2
62  *		pkt_ipv6_udp_p2_f3
63  *		pkt_ipv6_udp_p2_f4
64  *
65  *	3) pkt_ipv6_udp_p3
66  *		pkt_ipv6_udp_p3_f1
67  *		pkt_ipv6_udp_p3_f2
68  *		pkt_ipv6_udp_p3_f3
69  *		pkt_ipv6_udp_p3_f4
70  *		pkt_ipv6_udp_p3_f5
71  */
72 
73 /* IPv4:
74  *
75  *	1) pkt_ipv4_udp_p1
76  *		pkt_ipv4_udp_p1_f1
77  *		pkt_ipv4_udp_p1_f2
78  *
79  *	2) pkt_ipv4_udp_p2
80  *		pkt_ipv4_udp_p2_f1
81  *		pkt_ipv4_udp_p2_f2
82  *		pkt_ipv4_udp_p2_f3
83  *		pkt_ipv4_udp_p2_f4
84  *
85  *	3) pkt_ipv4_udp_p3
86  *		pkt_ipv4_udp_p3_f1
87  *		pkt_ipv4_udp_p3_f2
88  *		pkt_ipv4_udp_p3_f3
89  *		pkt_ipv4_udp_p3_f4
90  *		pkt_ipv4_udp_p3_f5
91  */
92 
93 struct ip_reassembly_test_packet pkt_ipv6_udp_p1 = {
94 	.len = 1500,
95 	.l4_offset = 40,
96 	.data = {
97 		/* IP */
98 		0x60, 0x00, 0x00, 0x00, 0x05, 0xb4, 0x11, 0x40,
99 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
101 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
102 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
103 
104 		/* UDP */
105 		0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
106 	},
107 };
108 
109 struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f1 = {
110 	.len = 1384,
111 	.l4_offset = 48,
112 	.data = {
113 		/* IP */
114 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
115 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
117 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
118 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
119 		0x11, 0x00, 0x00, 0x01, 0x5c, 0x92, 0xac, 0xf1,
120 
121 		/* UDP */
122 		0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
123 	},
124 };
125 
126 struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f2 = {
127 	.len = 172,
128 	.l4_offset = 48,
129 	.data = {
130 		/* IP */
131 		0x60, 0x00, 0x00, 0x00, 0x00, 0x84, 0x2c, 0x40,
132 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
133 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
134 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
135 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
136 		0x11, 0x00, 0x05, 0x38, 0x5c, 0x92, 0xac, 0xf1,
137 	},
138 };
139 
140 struct ip_reassembly_test_packet pkt_ipv6_udp_p2 = {
141 	.len = 4482,
142 	.l4_offset = 40,
143 	.data = {
144 		/* IP */
145 		0x60, 0x00, 0x00, 0x00, 0x11, 0x5a, 0x11, 0x40,
146 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
148 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
150 
151 		/* UDP */
152 		0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
153 	},
154 };
155 
156 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f1 = {
157 	.len = 1384,
158 	.l4_offset = 48,
159 	.data = {
160 		/* IP */
161 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
162 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
163 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
164 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
166 		0x11, 0x00, 0x00, 0x01, 0x64, 0x6c, 0x68, 0x9f,
167 
168 		/* UDP */
169 		0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
170 	},
171 };
172 
173 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f2 = {
174 	.len = 1384,
175 	.l4_offset = 48,
176 	.data = {
177 		/* IP */
178 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
179 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
181 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
182 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
183 		0x11, 0x00, 0x05, 0x39, 0x64, 0x6c, 0x68, 0x9f,
184 	},
185 };
186 
187 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f3 = {
188 	.len = 1384,
189 	.l4_offset = 48,
190 	.data = {
191 		/* IP */
192 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
193 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
194 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
195 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
197 		0x11, 0x00, 0x0a, 0x71, 0x64, 0x6c, 0x68, 0x9f,
198 	},
199 };
200 
201 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f4 = {
202 	.len = 482,
203 	.l4_offset = 48,
204 	.data = {
205 		/* IP */
206 		0x60, 0x00, 0x00, 0x00, 0x01, 0xba, 0x2c, 0x40,
207 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
209 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
211 		0x11, 0x00, 0x0f, 0xa8, 0x64, 0x6c, 0x68, 0x9f,
212 	},
213 };
214 
215 struct ip_reassembly_test_packet pkt_ipv6_udp_p3 = {
216 	.len = 5782,
217 	.l4_offset = 40,
218 	.data = {
219 		/* IP */
220 		0x60, 0x00, 0x00, 0x00, 0x16, 0x6e, 0x2c, 0x40,
221 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
222 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
223 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
224 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
225 
226 		/* UDP */
227 		0x08, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
228 	},
229 };
230 
231 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f1 = {
232 	.len = 1384,
233 	.l4_offset = 48,
234 	.data = {
235 		/* IP */
236 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
237 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
238 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
239 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
241 		0x11, 0x00, 0x00, 0x01, 0x65, 0xcf, 0x5a, 0xae,
242 
243 		/* UDP */
244 		0x80, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
245 	},
246 };
247 
248 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f2 = {
249 	.len = 1384,
250 	.l4_offset = 48,
251 	.data = {
252 		/* IP */
253 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
254 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
256 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
258 		0x11, 0x00, 0x05, 0x39, 0x65, 0xcf, 0x5a, 0xae,
259 	},
260 };
261 
262 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f3 = {
263 	.len = 1384,
264 	.l4_offset = 48,
265 	.data = {
266 		/* IP */
267 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
268 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
270 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
271 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
272 		0x11, 0x00, 0x0a, 0x71, 0x65, 0xcf, 0x5a, 0xae,
273 	},
274 };
275 
276 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f4 = {
277 	.len = 1384,
278 	.l4_offset = 48,
279 	.data = {
280 		/* IP */
281 		0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
282 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
283 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
284 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
286 		0x11, 0x00, 0x0f, 0xa9, 0x65, 0xcf, 0x5a, 0xae,
287 	},
288 };
289 
290 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f5 = {
291 	.len = 446,
292 	.l4_offset = 48,
293 	.data = {
294 		/* IP */
295 		0x60, 0x00, 0x00, 0x00, 0x01, 0x96, 0x2c, 0x40,
296 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 		0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
298 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 		0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
300 		0x11, 0x00, 0x14, 0xe0, 0x65, 0xcf, 0x5a, 0xae,
301 	},
302 };
303 
304 struct ip_reassembly_test_packet pkt_ipv4_udp = {
305 	.len = 1200,
306 	.l4_offset = 20,
307 	.data = {
308 		/* IP */
309 		0x45, 0x00, 0x04, 0xb0, 0x00, 0x01, 0x00, 0x00,
310 		0x40, 0x11, 0x66, 0x0d, 0x0d, 0x00, 0x00, 0x02,
311 		0x02, 0x00, 0x00, 0x02,
312 
313 		/* UDP */
314 		0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
315 	},
316 };
317 
318 struct ip_reassembly_test_packet pkt_ipv4_udp_p1 = {
319 	.len = 1500,
320 	.l4_offset = 20,
321 	.data = {
322 		/* IP */
323 		0x45, 0x00, 0x05, 0xdc, 0x00, 0x01, 0x00, 0x00,
324 		0x40, 0x11, 0x66, 0x0d, 0x0d, 0x00, 0x00, 0x02,
325 		0x02, 0x00, 0x00, 0x02,
326 
327 		/* UDP */
328 		0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
329 	},
330 };
331 
332 struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f1 = {
333 	.len = 1420,
334 	.l4_offset = 20,
335 	.data = {
336 		/* IP */
337 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x01, 0x20, 0x00,
338 		0x40, 0x11, 0x46, 0x5d, 0x0d, 0x00, 0x00, 0x02,
339 		0x02, 0x00, 0x00, 0x02,
340 
341 		/* UDP */
342 		0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
343 	},
344 };
345 
346 struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f2 = {
347 	.len = 100,
348 	.l4_offset = 20,
349 	.data = {
350 		/* IP */
351 		0x45, 0x00, 0x00, 0x64, 0x00, 0x01, 0x00, 0xaf,
352 		0x40, 0x11, 0x6a, 0xd6, 0x0d, 0x00, 0x00, 0x02,
353 		0x02, 0x00, 0x00, 0x02,
354 	},
355 };
356 
357 struct ip_reassembly_test_packet pkt_ipv4_udp_p2 = {
358 	.len = 4482,
359 	.l4_offset = 20,
360 	.data = {
361 		/* IP */
362 		0x45, 0x00, 0x11, 0x82, 0x00, 0x02, 0x00, 0x00,
363 		0x40, 0x11, 0x5a, 0x66, 0x0d, 0x00, 0x00, 0x02,
364 		0x02, 0x00, 0x00, 0x02,
365 
366 		/* UDP */
367 		0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
368 	},
369 };
370 
371 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f1 = {
372 	.len = 1420,
373 	.l4_offset = 20,
374 	.data = {
375 		/* IP */
376 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0x00,
377 		0x40, 0x11, 0x46, 0x5c, 0x0d, 0x00, 0x00, 0x02,
378 		0x02, 0x00, 0x00, 0x02,
379 
380 		/* UDP */
381 		0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
382 	},
383 };
384 
385 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f2 = {
386 	.len = 1420,
387 	.l4_offset = 20,
388 	.data = {
389 		/* IP */
390 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0xaf,
391 		0x40, 0x11, 0x45, 0xad, 0x0d, 0x00, 0x00, 0x02,
392 		0x02, 0x00, 0x00, 0x02,
393 	},
394 };
395 
396 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f3 = {
397 	.len = 1420,
398 	.l4_offset = 20,
399 	.data = {
400 		/* IP */
401 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x21, 0x5e,
402 		0x40, 0x11, 0x44, 0xfe, 0x0d, 0x00, 0x00, 0x02,
403 		0x02, 0x00, 0x00, 0x02,
404 	},
405 };
406 
407 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f4 = {
408 	.len = 282,
409 	.l4_offset = 20,
410 	.data = {
411 		/* IP */
412 		0x45, 0x00, 0x01, 0x1a, 0x00, 0x02, 0x02, 0x0d,
413 		0x40, 0x11, 0x68, 0xc1, 0x0d, 0x00, 0x00, 0x02,
414 		0x02, 0x00, 0x00, 0x02,
415 	},
416 };
417 
418 struct ip_reassembly_test_packet pkt_ipv4_udp_p3 = {
419 	.len = 5782,
420 	.l4_offset = 20,
421 	.data = {
422 		/* IP */
423 		0x45, 0x00, 0x16, 0x96, 0x00, 0x03, 0x00, 0x00,
424 		0x40, 0x11, 0x55, 0x51, 0x0d, 0x00, 0x00, 0x02,
425 		0x02, 0x00, 0x00, 0x02,
426 
427 		/* UDP */
428 		0x08, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
429 	},
430 };
431 
432 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f1 = {
433 	.len = 1420,
434 	.l4_offset = 20,
435 	.data = {
436 		/* IP */
437 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0x00,
438 		0x40, 0x11, 0x46, 0x5b, 0x0d, 0x00, 0x00, 0x02,
439 		0x02, 0x00, 0x00, 0x02,
440 
441 		/* UDP */
442 		0x80, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
443 	},
444 };
445 
446 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f2 = {
447 	.len = 1420,
448 	.l4_offset = 20,
449 	.data = {
450 		/* IP */
451 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0xaf,
452 		0x40, 0x11, 0x45, 0xac, 0x0d, 0x00, 0x00, 0x02,
453 		0x02, 0x00, 0x00, 0x02,
454 	},
455 };
456 
457 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f3 = {
458 	.len = 1420,
459 	.l4_offset = 20,
460 	.data = {
461 		/* IP */
462 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x21, 0x5e,
463 		0x40, 0x11, 0x44, 0xfd, 0x0d, 0x00, 0x00, 0x02,
464 		0x02, 0x00, 0x00, 0x02,
465 	},
466 };
467 
468 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f4 = {
469 	.len = 1420,
470 	.l4_offset = 20,
471 	.data = {
472 		/* IP */
473 		0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x22, 0x0d,
474 		0x40, 0x11, 0x44, 0x4e, 0x0d, 0x00, 0x00, 0x02,
475 		0x02, 0x00, 0x00, 0x02,
476 	},
477 };
478 
479 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f5 = {
480 	.len = 182,
481 	.l4_offset = 20,
482 	.data = {
483 		/* IP */
484 		0x45, 0x00, 0x00, 0xb6, 0x00, 0x03, 0x02, 0xbc,
485 		0x40, 0x11, 0x68, 0x75, 0x0d, 0x00, 0x00, 0x02,
486 		0x02, 0x00, 0x00, 0x02,
487 	},
488 };
489 
490 static inline void
491 test_vector_payload_populate(struct ip_reassembly_test_packet *pkt,
492 			     bool first_frag, uint16_t extra_data, uint16_t extra_data_sum)
493 {
494 	bool is_ipv6 = ((pkt->data[0] >> 4) == 0x6);
495 	uint32_t i = pkt->l4_offset;
496 	uint16_t len, off;
497 	size_t ext_len = 0;
498 	int proto;
499 
500 	/**
501 	 * For non-fragmented packets and first frag, skip 8 bytes from
502 	 * l4_offset for UDP header.
503 	 */
504 	if (first_frag)
505 		i += 8;
506 
507 	/* Fixup header and checksum */
508 	if (extra_data || extra_data_sum) {
509 		if (is_ipv6) {
510 			struct rte_ipv6_hdr *hdr = (struct rte_ipv6_hdr *)pkt->data;
511 			struct rte_ipv6_fragment_ext *frag_ext;
512 			uint8_t *p = pkt->data;
513 			uint16_t old_off;
514 
515 			len = rte_be_to_cpu_16(hdr->payload_len) + extra_data;
516 			hdr->payload_len = rte_cpu_to_be_16(len);
517 
518 			/* Find frag extension header to add to frag offset */
519 			if (extra_data_sum) {
520 				proto = hdr->proto;
521 				p += sizeof(struct rte_ipv6_hdr);
522 				while (proto != IPPROTO_FRAGMENT) {
523 					proto = rte_ipv6_get_next_ext(p, proto, &ext_len);
524 					if (proto < 0)
525 						break;
526 					p += ext_len;
527 				}
528 				/* Found fragment header, update the frag offset */
529 				if (proto == IPPROTO_FRAGMENT) {
530 					frag_ext = (struct rte_ipv6_fragment_ext *)p;
531 					old_off = rte_be_to_cpu_16(frag_ext->frag_data);
532 					off = old_off & 0xFFF8;
533 					off += extra_data_sum;
534 					frag_ext->frag_data = rte_cpu_to_be_16(off |
535 									       (old_off & 0x7));
536 				}
537 			}
538 		} else {
539 			struct rte_ipv4_hdr *hdr = (struct rte_ipv4_hdr *)pkt->data;
540 			uint16_t old_off = rte_be_to_cpu_16(hdr->fragment_offset);
541 
542 			len = rte_be_to_cpu_16(hdr->total_length) + extra_data;
543 			off = old_off & 0x1FFF;
544 			off += (extra_data_sum >> 3);
545 
546 			hdr->total_length = rte_cpu_to_be_16(len);
547 			hdr->fragment_offset = rte_cpu_to_be_16(off | (old_off & 0xe000));
548 			hdr->hdr_checksum = 0;
549 			hdr->hdr_checksum = rte_ipv4_cksum(hdr);
550 		}
551 		pkt->len += extra_data;
552 	}
553 
554 	for (; i < pkt->len; i++)
555 		pkt->data[i] = 0x58;
556 }
557 
558 struct ipsec_test_data conf_aes_128_gcm = {
559 	.key = {
560 		.data = {
561 			0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
562 			0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
563 		},
564 	},
565 
566 	.salt = {
567 		.data = {
568 			0xca, 0xfe, 0xba, 0xbe
569 		},
570 		.len = 4,
571 	},
572 
573 	.iv = {
574 		.data = {
575 			0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
576 		},
577 	},
578 
579 	.ipsec_xform = {
580 		.spi = 0xa5f8,
581 		.salt = 0xbebafeca,
582 		.options.esn = 0,
583 		.options.udp_encap = 0,
584 		.options.copy_dscp = 0,
585 		.options.copy_flabel = 0,
586 		.options.copy_df = 0,
587 		.options.dec_ttl = 0,
588 		.options.ecn = 0,
589 		.options.stats = 0,
590 		.options.tunnel_hdr_verify = 0,
591 		.options.ip_csum_enable = 0,
592 		.options.l4_csum_enable = 0,
593 		.options.ip_reassembly_en = 1,
594 		.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
595 		.proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
596 		.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
597 		.tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
598 		.replay_win_sz = 0,
599 	},
600 
601 	.aead = true,
602 
603 	.xform = {
604 		.aead = {
605 			.next = NULL,
606 			.type = RTE_CRYPTO_SYM_XFORM_AEAD,
607 			.aead = {
608 				.op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
609 				.algo = RTE_CRYPTO_AEAD_AES_GCM,
610 				.key.length = 16,
611 				.iv.length = 12,
612 				.iv.offset = 0,
613 				.digest_length = 16,
614 				.aad_length = 12,
615 			},
616 		},
617 	},
618 };
619 
620 struct ipsec_test_data conf_aes_128_gcm_v6_tunnel = {
621 	.key = {
622 		.data = {
623 			0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
624 			0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
625 		},
626 	},
627 
628 	.salt = {
629 		.data = {
630 			0xca, 0xfe, 0xba, 0xbe
631 		},
632 		.len = 4,
633 	},
634 
635 	.iv = {
636 		.data = {
637 			0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
638 		},
639 	},
640 
641 	.ipsec_xform = {
642 		.spi = 0xa5f8,
643 		.salt = 0xbebafeca,
644 		.options.esn = 0,
645 		.options.udp_encap = 0,
646 		.options.copy_dscp = 0,
647 		.options.copy_flabel = 0,
648 		.options.copy_df = 0,
649 		.options.dec_ttl = 0,
650 		.options.ecn = 0,
651 		.options.stats = 0,
652 		.options.tunnel_hdr_verify = 0,
653 		.options.ip_csum_enable = 0,
654 		.options.l4_csum_enable = 0,
655 		.options.ip_reassembly_en = 1,
656 		.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
657 		.proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
658 		.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
659 		.tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
660 		.replay_win_sz = 0,
661 	},
662 
663 	.aead = true,
664 
665 	.xform = {
666 		.aead = {
667 			.next = NULL,
668 			.type = RTE_CRYPTO_SYM_XFORM_AEAD,
669 			.aead = {
670 				.op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
671 				.algo = RTE_CRYPTO_AEAD_AES_GCM,
672 				.key.length = 16,
673 				.iv.length = 12,
674 				.iv.offset = 0,
675 				.digest_length = 16,
676 				.aad_length = 12,
677 			},
678 		},
679 	},
680 };
681 
682 const struct ip_pkt_vector ipv4_vector = {
683 	.sa_data = &conf_aes_128_gcm,
684 	.full_pkt = &pkt_ipv4_udp,
685 	.burst = false,
686 };
687 
688 const struct reassembly_vector ipv4_2frag_vector = {
689 	.sa_data = &conf_aes_128_gcm,
690 	.full_pkt = &pkt_ipv4_udp_p1,
691 	.frags[0] = &pkt_ipv4_udp_p1_f1,
692 	.frags[1] = &pkt_ipv4_udp_p1_f2,
693 	.nb_frags = 2,
694 	.burst = false,
695 };
696 
697 const struct reassembly_vector ipv6_2frag_vector = {
698 	.sa_data = &conf_aes_128_gcm_v6_tunnel,
699 	.full_pkt = &pkt_ipv6_udp_p1,
700 	.frags[0] = &pkt_ipv6_udp_p1_f1,
701 	.frags[1] = &pkt_ipv6_udp_p1_f2,
702 	.nb_frags = 2,
703 	.burst = false,
704 };
705 
706 const struct reassembly_vector ipv4_4frag_vector = {
707 	.sa_data = &conf_aes_128_gcm,
708 	.full_pkt = &pkt_ipv4_udp_p2,
709 	.frags[0] = &pkt_ipv4_udp_p2_f1,
710 	.frags[1] = &pkt_ipv4_udp_p2_f2,
711 	.frags[2] = &pkt_ipv4_udp_p2_f3,
712 	.frags[3] = &pkt_ipv4_udp_p2_f4,
713 	.nb_frags = 4,
714 	.burst = false,
715 };
716 
717 const struct reassembly_vector ipv6_4frag_vector = {
718 	.sa_data = &conf_aes_128_gcm_v6_tunnel,
719 	.full_pkt = &pkt_ipv6_udp_p2,
720 	.frags[0] = &pkt_ipv6_udp_p2_f1,
721 	.frags[1] = &pkt_ipv6_udp_p2_f2,
722 	.frags[2] = &pkt_ipv6_udp_p2_f3,
723 	.frags[3] = &pkt_ipv6_udp_p2_f4,
724 	.nb_frags = 4,
725 	.burst = false,
726 };
727 const struct reassembly_vector ipv4_5frag_vector = {
728 	.sa_data = &conf_aes_128_gcm,
729 	.full_pkt = &pkt_ipv4_udp_p3,
730 	.frags[0] = &pkt_ipv4_udp_p3_f1,
731 	.frags[1] = &pkt_ipv4_udp_p3_f2,
732 	.frags[2] = &pkt_ipv4_udp_p3_f3,
733 	.frags[3] = &pkt_ipv4_udp_p3_f4,
734 	.frags[4] = &pkt_ipv4_udp_p3_f5,
735 	.nb_frags = 5,
736 	.burst = false,
737 };
738 const struct reassembly_vector ipv6_5frag_vector = {
739 	.sa_data = &conf_aes_128_gcm_v6_tunnel,
740 	.full_pkt = &pkt_ipv6_udp_p3,
741 	.frags[0] = &pkt_ipv6_udp_p3_f1,
742 	.frags[1] = &pkt_ipv6_udp_p3_f2,
743 	.frags[2] = &pkt_ipv6_udp_p3_f3,
744 	.frags[3] = &pkt_ipv6_udp_p3_f4,
745 	.frags[4] = &pkt_ipv6_udp_p3_f5,
746 	.nb_frags = 5,
747 	.burst = false,
748 };
749 /* Negative test cases. */
750 const struct reassembly_vector ipv4_incomplete_vector = {
751 	.sa_data = &conf_aes_128_gcm,
752 	.full_pkt = &pkt_ipv4_udp_p2,
753 	.frags[0] = &pkt_ipv4_udp_p2_f1,
754 	.frags[1] = &pkt_ipv4_udp_p2_f2,
755 	.nb_frags = 2,
756 	.burst = false,
757 };
758 const struct reassembly_vector ipv4_overlap_vector = {
759 	.sa_data = &conf_aes_128_gcm,
760 	.full_pkt = &pkt_ipv4_udp_p1,
761 	.frags[0] = &pkt_ipv4_udp_p1_f1,
762 	.frags[1] = &pkt_ipv4_udp_p1_f1, /* Overlap */
763 	.frags[2] = &pkt_ipv4_udp_p1_f2,
764 	.nb_frags = 3,
765 	.burst = false,
766 };
767 const struct reassembly_vector ipv4_out_of_order_vector = {
768 	.sa_data = &conf_aes_128_gcm,
769 	.full_pkt = &pkt_ipv4_udp_p2,
770 	.frags[0] = &pkt_ipv4_udp_p2_f1,
771 	.frags[1] = &pkt_ipv4_udp_p2_f3,
772 	.frags[2] = &pkt_ipv4_udp_p2_f4,
773 	.frags[3] = &pkt_ipv4_udp_p2_f2, /* out of order */
774 	.nb_frags = 4,
775 	.burst = false,
776 };
777 const struct reassembly_vector ipv4_4frag_burst_vector = {
778 	.sa_data = &conf_aes_128_gcm,
779 	.full_pkt = &pkt_ipv4_udp_p2,
780 	.frags[0] = &pkt_ipv4_udp_p2_f1,
781 	.frags[1] = &pkt_ipv4_udp_p2_f2,
782 	.frags[2] = &pkt_ipv4_udp_p2_f3,
783 	.frags[3] = &pkt_ipv4_udp_p2_f4,
784 	.nb_frags = 4,
785 	.burst = true,
786 };
787 
788 #endif
789