xref: /dpdk/app/test/test_table_combined.c (revision e1a06e391ba74f9c4d46a6ecef6d8ee084f4229e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation
3  */
4 
5 #ifndef RTE_EXEC_ENV_WINDOWS
6 
7 #include <string.h>
8 #include "test_table_combined.h"
9 #include "test_table.h"
10 #include <rte_table_lpm_ipv6.h>
11 
12 #define MAX_TEST_KEYS 128
13 #define N_PACKETS 50
14 
15 enum check_table_result {
16 	CHECK_TABLE_OK,
17 	CHECK_TABLE_PORT_CONFIG,
18 	CHECK_TABLE_PORT_ENABLE,
19 	CHECK_TABLE_TABLE_CONFIG,
20 	CHECK_TABLE_ENTRY_ADD,
21 	CHECK_TABLE_DEFAULT_ENTRY_ADD,
22 	CHECK_TABLE_CONNECT,
23 	CHECK_TABLE_MANAGE_ERROR,
24 	CHECK_TABLE_CONSISTENCY,
25 	CHECK_TABLE_NO_TRAFFIC,
26 	CHECK_TABLE_INVALID_PARAMETER,
27 };
28 
29 struct table_packets {
30 	uint32_t hit_packet[MAX_TEST_KEYS];
31 	uint32_t miss_packet[MAX_TEST_KEYS];
32 	uint32_t n_hit_packets;
33 	uint32_t n_miss_packets;
34 };
35 
36 combined_table_test table_tests_combined[] = {
37 	test_table_lpm_combined,
38 	test_table_lpm_ipv6_combined,
39 	test_table_hash8lru,
40 	test_table_hash8ext,
41 	test_table_hash16lru,
42 	test_table_hash16ext,
43 	test_table_hash32lru,
44 	test_table_hash32ext,
45 	test_table_hash_cuckoo_combined,
46 };
47 
48 unsigned n_table_tests_combined = RTE_DIM(table_tests_combined);
49 
50 /* Generic port tester function */
51 static int
52 test_table_type(struct rte_table_ops *table_ops, void *table_args,
53 	void *key, struct table_packets *table_packets,
54 	struct manage_ops *manage_ops, unsigned n_ops)
55 {
56 	uint32_t ring_in_id, table_id, ring_out_id, ring_out_2_id;
57 	unsigned i;
58 
59 	RTE_SET_USED(manage_ops);
60 	RTE_SET_USED(n_ops);
61 	/* Create pipeline */
62 	struct rte_pipeline_params pipeline_params = {
63 		.name = "pipeline",
64 		.socket_id = 0,
65 	};
66 
67 	struct rte_pipeline *pipeline = rte_pipeline_create(&pipeline_params);
68 
69 	/* Create input ring */
70 	struct rte_port_ring_reader_params ring_params_rx = {
71 		.ring = RING_RX,
72 	};
73 
74 	struct rte_port_ring_writer_params ring_params_tx = {
75 		.ring = RING_RX,
76 		.tx_burst_sz = RTE_PORT_IN_BURST_SIZE_MAX,
77 	};
78 
79 	struct rte_pipeline_port_in_params ring_in_params = {
80 		.ops = &rte_port_ring_reader_ops,
81 		.arg_create = (void *)&ring_params_rx,
82 		.f_action = NULL,
83 		.burst_size = RTE_PORT_IN_BURST_SIZE_MAX,
84 	};
85 
86 	if (rte_pipeline_port_in_create(pipeline, &ring_in_params,
87 		&ring_in_id) != 0) {
88 		rte_pipeline_free(pipeline);
89 		return -CHECK_TABLE_PORT_CONFIG;
90 	}
91 
92 	/* Create table */
93 	struct rte_pipeline_table_params table_params = {
94 		.ops = table_ops,
95 		.arg_create = table_args,
96 		.f_action_hit = NULL,
97 		.f_action_miss = NULL,
98 		.arg_ah = NULL,
99 		.action_data_size = 0,
100 	};
101 
102 	if (rte_pipeline_table_create(pipeline, &table_params,
103 		&table_id) != 0) {
104 		rte_pipeline_free(pipeline);
105 		return -CHECK_TABLE_TABLE_CONFIG;
106 	}
107 
108 	/* Create output ports */
109 	ring_params_tx.ring = RING_TX;
110 
111 	struct rte_pipeline_port_out_params ring_out_params = {
112 		.ops = &rte_port_ring_writer_ops,
113 		.arg_create = (void *)&ring_params_tx,
114 		.f_action = NULL,
115 	};
116 
117 	if (rte_pipeline_port_out_create(pipeline, &ring_out_params,
118 		&ring_out_id) != 0) {
119 		rte_pipeline_free(pipeline);
120 		return -CHECK_TABLE_PORT_CONFIG;
121 	}
122 
123 	ring_params_tx.ring = RING_TX_2;
124 
125 	if (rte_pipeline_port_out_create(pipeline, &ring_out_params,
126 		&ring_out_2_id) != 0) {
127 		rte_pipeline_free(pipeline);
128 		return -CHECK_TABLE_PORT_CONFIG;
129 	}
130 
131 	/* Add entry to the table */
132 	struct rte_pipeline_table_entry default_entry = {
133 		.action = RTE_PIPELINE_ACTION_DROP,
134 		{.table_id = ring_out_id},
135 	};
136 
137 	struct rte_pipeline_table_entry table_entry = {
138 		.action = RTE_PIPELINE_ACTION_PORT,
139 		{.table_id = ring_out_id},
140 	};
141 
142 	struct rte_pipeline_table_entry *default_entry_ptr, *entry_ptr;
143 
144 	int key_found;
145 
146 	if (rte_pipeline_table_default_entry_add(pipeline, table_id,
147 		&default_entry, &default_entry_ptr) != 0) {
148 		rte_pipeline_free(pipeline);
149 		return -CHECK_TABLE_DEFAULT_ENTRY_ADD;
150 	}
151 
152 	if (rte_pipeline_table_entry_add(pipeline, table_id,
153 		key ? key : &table_entry, &table_entry, &key_found,
154 			&entry_ptr) != 0) {
155 		rte_pipeline_free(pipeline);
156 		return -CHECK_TABLE_ENTRY_ADD;
157 	}
158 
159 	/* Create connections and check consistency */
160 	if (rte_pipeline_port_in_connect_to_table(pipeline, ring_in_id,
161 		table_id) != 0) {
162 		rte_pipeline_free(pipeline);
163 		return -CHECK_TABLE_CONNECT;
164 	}
165 
166 	if (rte_pipeline_port_in_enable(pipeline, ring_in_id) != 0) {
167 		rte_pipeline_free(pipeline);
168 		return -CHECK_TABLE_PORT_ENABLE;
169 	}
170 
171 	if (rte_pipeline_check(pipeline) != 0) {
172 		rte_pipeline_free(pipeline);
173 		return -CHECK_TABLE_CONSISTENCY;
174 	}
175 
176 
177 
178 	/* Flow test - All hits */
179 	if (table_packets->n_hit_packets) {
180 		for (i = 0; i < table_packets->n_hit_packets; i++)
181 			RING_ENQUEUE(RING_RX, table_packets->hit_packet[i]);
182 
183 		RUN_PIPELINE(pipeline);
184 
185 		VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets,
186 				table_packets->n_hit_packets);
187 	}
188 
189 	/* Flow test - All misses */
190 	if (table_packets->n_miss_packets) {
191 		for (i = 0; i < table_packets->n_miss_packets; i++)
192 			RING_ENQUEUE(RING_RX, table_packets->miss_packet[i]);
193 
194 		RUN_PIPELINE(pipeline);
195 
196 		VERIFY_TRAFFIC(RING_TX, table_packets->n_miss_packets, 0);
197 	}
198 
199 	/* Flow test - Half hits, half misses */
200 	if (table_packets->n_hit_packets && table_packets->n_miss_packets) {
201 		for (i = 0; i < (table_packets->n_hit_packets) / 2; i++)
202 			RING_ENQUEUE(RING_RX, table_packets->hit_packet[i]);
203 
204 		for (i = 0; i < (table_packets->n_miss_packets) / 2; i++)
205 			RING_ENQUEUE(RING_RX, table_packets->miss_packet[i]);
206 
207 		RUN_PIPELINE(pipeline);
208 		VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets,
209 			table_packets->n_hit_packets / 2);
210 	}
211 
212 	/* Flow test - Single packet */
213 	if (table_packets->n_hit_packets) {
214 		RING_ENQUEUE(RING_RX, table_packets->hit_packet[0]);
215 		RUN_PIPELINE(pipeline);
216 		VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets, 1);
217 	}
218 	if (table_packets->n_miss_packets) {
219 		RING_ENQUEUE(RING_RX, table_packets->miss_packet[0]);
220 		RUN_PIPELINE(pipeline);
221 		VERIFY_TRAFFIC(RING_TX, table_packets->n_miss_packets, 0);
222 	}
223 
224 
225 	/* Change table entry action */
226 	printf("Change entry action\n");
227 	table_entry.table_id = ring_out_2_id;
228 
229 	if (rte_pipeline_table_default_entry_add(pipeline, table_id,
230 		&default_entry, &default_entry_ptr) != 0) {
231 		rte_pipeline_free(pipeline);
232 		return -CHECK_TABLE_ENTRY_ADD;
233 	}
234 
235 	if (rte_pipeline_table_entry_add(pipeline, table_id,
236 		key ? key : &table_entry, &table_entry, &key_found,
237 			&entry_ptr) != 0) {
238 		rte_pipeline_free(pipeline);
239 		return -CHECK_TABLE_ENTRY_ADD;
240 	}
241 
242 	/* Check that traffic destination has changed */
243 	if (table_packets->n_hit_packets) {
244 		for (i = 0; i < table_packets->n_hit_packets; i++)
245 			RING_ENQUEUE(RING_RX, table_packets->hit_packet[i]);
246 
247 		RUN_PIPELINE(pipeline);
248 		VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets, 0);
249 		VERIFY_TRAFFIC(RING_TX_2, table_packets->n_hit_packets,
250 			table_packets->n_hit_packets);
251 	}
252 
253 	printf("delete entry\n");
254 	/* Delete table entry */
255 	rte_pipeline_table_entry_delete(pipeline, table_id,
256 		key ? key : &table_entry, &key_found, NULL);
257 
258 	rte_pipeline_free(pipeline);
259 
260 	return 0;
261 }
262 
263 /* Table tests */
264 int
265 test_table_stub_combined(void)
266 {
267 	int status, i;
268 	struct table_packets table_packets;
269 
270 	printf("--------------\n");
271 	printf("RUNNING TEST - %s\n", __func__);
272 	printf("--------------\n");
273 	for (i = 0; i < N_PACKETS; i++)
274 		table_packets.hit_packet[i] = i;
275 
276 	table_packets.n_hit_packets = N_PACKETS;
277 	table_packets.n_miss_packets = 0;
278 
279 	status = test_table_type(&rte_table_stub_ops, NULL, NULL,
280 		&table_packets, NULL, 1);
281 	VERIFY(status, CHECK_TABLE_OK);
282 
283 	return 0;
284 }
285 
286 int
287 test_table_lpm_combined(void)
288 {
289 	int status, i;
290 
291 	/* Traffic flow */
292 	struct rte_table_lpm_params lpm_params = {
293 		.name = "LPM",
294 		.n_rules = 1 << 16,
295 		.number_tbl8s = 1 << 8,
296 		.flags = 0,
297 		.entry_unique_size = 8,
298 		.offset = APP_METADATA_OFFSET(0),
299 	};
300 
301 	struct rte_table_lpm_key lpm_key = {
302 		.ip = 0xadadadad,
303 		.depth = 16,
304 	};
305 
306 	struct table_packets table_packets;
307 
308 	printf("--------------\n");
309 	printf("RUNNING TEST - %s\n", __func__);
310 	printf("--------------\n");
311 
312 	for (i = 0; i < N_PACKETS; i++)
313 		table_packets.hit_packet[i] = 0xadadadad;
314 
315 	for (i = 0; i < N_PACKETS; i++)
316 		table_packets.miss_packet[i] = 0xfefefefe;
317 
318 	table_packets.n_hit_packets = N_PACKETS;
319 	table_packets.n_miss_packets = N_PACKETS;
320 
321 	status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
322 		(void *)&lpm_key, &table_packets, NULL, 0);
323 	VERIFY(status, CHECK_TABLE_OK);
324 
325 	/* Invalid parameters */
326 	lpm_params.n_rules = 0;
327 
328 	status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
329 		(void *)&lpm_key, &table_packets, NULL, 0);
330 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
331 
332 	lpm_params.n_rules = 1 << 24;
333 	lpm_key.depth = 0;
334 
335 	status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
336 		(void *)&lpm_key, &table_packets, NULL, 0);
337 	VERIFY(status, CHECK_TABLE_ENTRY_ADD);
338 
339 	lpm_key.depth = 33;
340 
341 	status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
342 		(void *)&lpm_key, &table_packets, NULL, 0);
343 	VERIFY(status, CHECK_TABLE_ENTRY_ADD);
344 
345 	return 0;
346 }
347 
348 int
349 test_table_lpm_ipv6_combined(void)
350 {
351 	int status, i;
352 
353 	/* Traffic flow */
354 	struct rte_table_lpm_ipv6_params lpm_ipv6_params = {
355 		.name = "LPM",
356 		.n_rules = 1 << 16,
357 		.number_tbl8s = 1 << 13,
358 		.entry_unique_size = 8,
359 		.offset = APP_METADATA_OFFSET(32),
360 	};
361 
362 	struct rte_table_lpm_ipv6_key lpm_ipv6_key = {
363 		.depth = 16,
364 	};
365 	memset(&lpm_ipv6_key.ip, 0xad, 16);
366 
367 	struct table_packets table_packets;
368 
369 	printf("--------------\n");
370 	printf("RUNNING TEST - %s\n", __func__);
371 	printf("--------------\n");
372 	for (i = 0; i < N_PACKETS; i++)
373 		table_packets.hit_packet[i] = 0xadadadad;
374 
375 	for (i = 0; i < N_PACKETS; i++)
376 		table_packets.miss_packet[i] = 0xadadadab;
377 
378 	table_packets.n_hit_packets = N_PACKETS;
379 	table_packets.n_miss_packets = N_PACKETS;
380 
381 	status = test_table_type(&rte_table_lpm_ipv6_ops,
382 		(void *)&lpm_ipv6_params,
383 		(void *)&lpm_ipv6_key, &table_packets, NULL, 0);
384 	VERIFY(status, CHECK_TABLE_OK);
385 
386 	/* Invalid parameters */
387 	lpm_ipv6_params.n_rules = 0;
388 
389 	status = test_table_type(&rte_table_lpm_ipv6_ops,
390 		(void *)&lpm_ipv6_params,
391 		(void *)&lpm_ipv6_key, &table_packets, NULL, 0);
392 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
393 
394 	lpm_ipv6_params.n_rules = 1 << 24;
395 	lpm_ipv6_key.depth = 0;
396 
397 	status = test_table_type(&rte_table_lpm_ipv6_ops,
398 		(void *)&lpm_ipv6_params,
399 		(void *)&lpm_ipv6_key, &table_packets, NULL, 0);
400 	VERIFY(status, CHECK_TABLE_ENTRY_ADD);
401 
402 	lpm_ipv6_key.depth = 129;
403 	status = test_table_type(&rte_table_lpm_ipv6_ops,
404 		(void *)&lpm_ipv6_params,
405 		(void *)&lpm_ipv6_key, &table_packets, NULL, 0);
406 	VERIFY(status, CHECK_TABLE_ENTRY_ADD);
407 
408 	return 0;
409 }
410 
411 int
412 test_table_hash8lru(void)
413 {
414 	int status, i;
415 
416 	/* Traffic flow */
417 	struct rte_table_hash_params key8lru_params = {
418 		.name = "TABLE",
419 		.key_size = 8,
420 		.key_offset = APP_METADATA_OFFSET(32),
421 		.key_mask = NULL,
422 		.n_keys = 1 << 16,
423 		.n_buckets = 1 << 16,
424 		.f_hash = pipeline_test_hash,
425 		.seed = 0,
426 	};
427 
428 	uint8_t key8lru[8];
429 	uint32_t *k8lru = (uint32_t *) key8lru;
430 
431 	memset(key8lru, 0, sizeof(key8lru));
432 	k8lru[0] = 0xadadadad;
433 
434 	struct table_packets table_packets;
435 
436 	printf("--------------\n");
437 	printf("RUNNING TEST - %s\n", __func__);
438 	printf("--------------\n");
439 	for (i = 0; i < 50; i++)
440 		table_packets.hit_packet[i] = 0xadadadad;
441 
442 	for (i = 0; i < 50; i++)
443 		table_packets.miss_packet[i] = 0xfefefefe;
444 
445 	table_packets.n_hit_packets = 50;
446 	table_packets.n_miss_packets = 50;
447 
448 	status = test_table_type(&rte_table_hash_key8_lru_ops,
449 		(void *)&key8lru_params, (void *)key8lru, &table_packets,
450 			NULL, 0);
451 	VERIFY(status, CHECK_TABLE_OK);
452 
453 	/* Invalid parameters */
454 	key8lru_params.n_keys = 0;
455 
456 	status = test_table_type(&rte_table_hash_key8_lru_ops,
457 		(void *)&key8lru_params, (void *)key8lru, &table_packets,
458 			NULL, 0);
459 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
460 
461 	key8lru_params.n_keys = 1<<16;
462 	key8lru_params.f_hash = NULL;
463 
464 	status = test_table_type(&rte_table_hash_key8_lru_ops,
465 		(void *)&key8lru_params, (void *)key8lru, &table_packets,
466 			NULL, 0);
467 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
468 
469 	return 0;
470 }
471 
472 int
473 test_table_hash16lru(void)
474 {
475 	int status, i;
476 
477 	/* Traffic flow */
478 	struct rte_table_hash_params key16lru_params = {
479 		.name = "TABLE",
480 		.key_size = 16,
481 		.key_offset = APP_METADATA_OFFSET(32),
482 		.key_mask = NULL,
483 		.n_keys = 1 << 16,
484 		.n_buckets = 1 << 16,
485 		.f_hash = pipeline_test_hash,
486 		.seed = 0,
487 	};
488 
489 	uint8_t key16lru[16];
490 	uint32_t *k16lru = (uint32_t *) key16lru;
491 
492 	memset(key16lru, 0, sizeof(key16lru));
493 	k16lru[0] = 0xadadadad;
494 
495 	struct table_packets table_packets;
496 
497 	printf("--------------\n");
498 	printf("RUNNING TEST - %s\n", __func__);
499 	printf("--------------\n");
500 	for (i = 0; i < 50; i++)
501 		table_packets.hit_packet[i] = 0xadadadad;
502 
503 	for (i = 0; i < 50; i++)
504 		table_packets.miss_packet[i] = 0xfefefefe;
505 
506 	table_packets.n_hit_packets = 50;
507 	table_packets.n_miss_packets = 50;
508 
509 	status = test_table_type(&rte_table_hash_key16_lru_ops,
510 		(void *)&key16lru_params, (void *)key16lru, &table_packets,
511 			NULL, 0);
512 	VERIFY(status, CHECK_TABLE_OK);
513 
514 	/* Invalid parameters */
515 	key16lru_params.n_keys = 0;
516 
517 	status = test_table_type(&rte_table_hash_key16_lru_ops,
518 		(void *)&key16lru_params, (void *)key16lru, &table_packets,
519 			NULL, 0);
520 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
521 
522 	key16lru_params.n_keys = 1<<16;
523 	key16lru_params.f_hash = NULL;
524 
525 	status = test_table_type(&rte_table_hash_key16_lru_ops,
526 		(void *)&key16lru_params, (void *)key16lru, &table_packets,
527 			NULL, 0);
528 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
529 
530 	return 0;
531 }
532 
533 int
534 test_table_hash32lru(void)
535 {
536 	int status, i;
537 
538 	/* Traffic flow */
539 	struct rte_table_hash_params key32lru_params = {
540 		.name = "TABLE",
541 		.key_size = 32,
542 		.key_offset = APP_METADATA_OFFSET(32),
543 		.key_mask = NULL,
544 		.n_keys = 1 << 16,
545 		.n_buckets = 1 << 16,
546 		.f_hash = pipeline_test_hash,
547 		.seed = 0,
548 	};
549 
550 	uint8_t key32lru[32];
551 	uint32_t *k32lru = (uint32_t *) key32lru;
552 
553 	memset(key32lru, 0, sizeof(key32lru));
554 	k32lru[0] = 0xadadadad;
555 
556 	struct table_packets table_packets;
557 
558 	printf("--------------\n");
559 	printf("RUNNING TEST - %s\n", __func__);
560 	printf("--------------\n");
561 	for (i = 0; i < 50; i++)
562 		table_packets.hit_packet[i] = 0xadadadad;
563 
564 	for (i = 0; i < 50; i++)
565 		table_packets.miss_packet[i] = 0xbdadadad;
566 
567 	table_packets.n_hit_packets = 50;
568 	table_packets.n_miss_packets = 50;
569 
570 	status = test_table_type(&rte_table_hash_key32_lru_ops,
571 		(void *)&key32lru_params, (void *)key32lru, &table_packets,
572 		NULL, 0);
573 	VERIFY(status, CHECK_TABLE_OK);
574 
575 	/* Invalid parameters */
576 	key32lru_params.n_keys = 0;
577 
578 	status = test_table_type(&rte_table_hash_key32_lru_ops,
579 		(void *)&key32lru_params, (void *)key32lru, &table_packets,
580 		NULL, 0);
581 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
582 
583 	key32lru_params.n_keys = 1<<16;
584 	key32lru_params.f_hash = NULL;
585 
586 	status = test_table_type(&rte_table_hash_key32_lru_ops,
587 		(void *)&key32lru_params, (void *)key32lru, &table_packets,
588 		NULL, 0);
589 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
590 
591 	return 0;
592 }
593 
594 int
595 test_table_hash8ext(void)
596 {
597 	int status, i;
598 
599 	/* Traffic flow */
600 	struct rte_table_hash_params key8ext_params = {
601 		.name = "TABLE",
602 		.key_size = 8,
603 		.key_offset = APP_METADATA_OFFSET(32),
604 		.key_mask = NULL,
605 		.n_keys = 1 << 16,
606 		.n_buckets = 1 << 16,
607 		.f_hash = pipeline_test_hash,
608 		.seed = 0,
609 	};
610 
611 	uint8_t key8ext[8];
612 	uint32_t *k8ext = (uint32_t *) key8ext;
613 
614 	memset(key8ext, 0, sizeof(key8ext));
615 	k8ext[0] = 0xadadadad;
616 
617 	struct table_packets table_packets;
618 
619 	printf("--------------\n");
620 	printf("RUNNING TEST - %s\n", __func__);
621 	printf("--------------\n");
622 	for (i = 0; i < 50; i++)
623 		table_packets.hit_packet[i] = 0xadadadad;
624 
625 	for (i = 0; i < 50; i++)
626 		table_packets.miss_packet[i] = 0xbdadadad;
627 
628 	table_packets.n_hit_packets = 50;
629 	table_packets.n_miss_packets = 50;
630 
631 	status = test_table_type(&rte_table_hash_key8_ext_ops,
632 		(void *)&key8ext_params, (void *)key8ext, &table_packets,
633 		NULL, 0);
634 	VERIFY(status, CHECK_TABLE_OK);
635 
636 	/* Invalid parameters */
637 	key8ext_params.n_keys = 0;
638 
639 	status = test_table_type(&rte_table_hash_key8_ext_ops,
640 		(void *)&key8ext_params, (void *)key8ext, &table_packets,
641 		NULL, 0);
642 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
643 
644 	key8ext_params.n_keys = 1<<16;
645 	key8ext_params.f_hash = NULL;
646 
647 	status = test_table_type(&rte_table_hash_key8_ext_ops,
648 		(void *)&key8ext_params, (void *)key8ext, &table_packets,
649 		NULL, 0);
650 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
651 
652 	return 0;
653 }
654 
655 int
656 test_table_hash16ext(void)
657 {
658 	int status, i;
659 
660 	/* Traffic flow */
661 	struct rte_table_hash_params key16ext_params = {
662 		.name = "TABLE",
663 		.key_size = 16,
664 		.key_offset = APP_METADATA_OFFSET(32),
665 		.key_mask = NULL,
666 		.n_keys = 1 << 16,
667 		.n_buckets = 1 << 16,
668 		.f_hash = pipeline_test_hash,
669 		.seed = 0,
670 	};
671 
672 	uint8_t key16ext[16];
673 	uint32_t *k16ext = (uint32_t *) key16ext;
674 
675 	memset(key16ext, 0, sizeof(key16ext));
676 	k16ext[0] = 0xadadadad;
677 
678 	struct table_packets table_packets;
679 
680 	printf("--------------\n");
681 	printf("RUNNING TEST - %s\n", __func__);
682 	printf("--------------\n");
683 	for (i = 0; i < 50; i++)
684 		table_packets.hit_packet[i] = 0xadadadad;
685 
686 	for (i = 0; i < 50; i++)
687 		table_packets.miss_packet[i] = 0xbdadadad;
688 
689 	table_packets.n_hit_packets = 50;
690 	table_packets.n_miss_packets = 50;
691 
692 	status = test_table_type(&rte_table_hash_key16_ext_ops,
693 		(void *)&key16ext_params, (void *)key16ext, &table_packets,
694 		NULL, 0);
695 	VERIFY(status, CHECK_TABLE_OK);
696 
697 	/* Invalid parameters */
698 	key16ext_params.n_keys = 0;
699 
700 	status = test_table_type(&rte_table_hash_key16_ext_ops,
701 		(void *)&key16ext_params, (void *)key16ext, &table_packets,
702 		NULL, 0);
703 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
704 
705 	key16ext_params.n_keys = 1<<16;
706 	key16ext_params.f_hash = NULL;
707 
708 	status = test_table_type(&rte_table_hash_key16_ext_ops,
709 		(void *)&key16ext_params, (void *)key16ext, &table_packets,
710 		NULL, 0);
711 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
712 
713 	return 0;
714 }
715 
716 int
717 test_table_hash32ext(void)
718 {
719 	int status, i;
720 
721 	/* Traffic flow */
722 	struct rte_table_hash_params key32ext_params = {
723 		.name = "TABLE",
724 		.key_size = 32,
725 		.key_offset = APP_METADATA_OFFSET(32),
726 		.key_mask = NULL,
727 		.n_keys = 1 << 16,
728 		.n_buckets = 1 << 16,
729 		.f_hash = pipeline_test_hash,
730 		.seed = 0,
731 	};
732 
733 	uint8_t key32ext[32];
734 	uint32_t *k32ext = (uint32_t *) key32ext;
735 
736 	memset(key32ext, 0, sizeof(key32ext));
737 	k32ext[0] = 0xadadadad;
738 
739 	struct table_packets table_packets;
740 
741 	printf("--------------\n");
742 	printf("RUNNING TEST - %s\n", __func__);
743 	printf("--------------\n");
744 	for (i = 0; i < 50; i++)
745 		table_packets.hit_packet[i] = 0xadadadad;
746 
747 	for (i = 0; i < 50; i++)
748 		table_packets.miss_packet[i] = 0xbdadadad;
749 
750 	table_packets.n_hit_packets = 50;
751 	table_packets.n_miss_packets = 50;
752 
753 	status = test_table_type(&rte_table_hash_key32_ext_ops,
754 		(void *)&key32ext_params, (void *)key32ext, &table_packets,
755 		NULL, 0);
756 	VERIFY(status, CHECK_TABLE_OK);
757 
758 	/* Invalid parameters */
759 	key32ext_params.n_keys = 0;
760 
761 	status = test_table_type(&rte_table_hash_key32_ext_ops,
762 		(void *)&key32ext_params, (void *)key32ext, &table_packets,
763 		NULL, 0);
764 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
765 
766 	key32ext_params.n_keys = 1<<16;
767 	key32ext_params.f_hash = NULL;
768 
769 	status = test_table_type(&rte_table_hash_key32_ext_ops,
770 		(void *)&key32ext_params, (void *)key32ext, &table_packets,
771 		NULL, 0);
772 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
773 
774 	return 0;
775 }
776 
777 int
778 test_table_hash_cuckoo_combined(void)
779 {
780 	int status, i;
781 
782 	/* Traffic flow */
783 	struct rte_table_hash_cuckoo_params cuckoo_params = {
784 		.name = "TABLE",
785 		.key_size = 32,
786 		.key_offset = APP_METADATA_OFFSET(32),
787 		.key_mask = NULL,
788 		.n_keys = 1 << 16,
789 		.n_buckets = 1 << 16,
790 		.f_hash = pipeline_test_hash_cuckoo,
791 		.seed = 0,
792 	};
793 
794 	uint8_t key_cuckoo[32];
795 	uint32_t *kcuckoo = (uint32_t *) key_cuckoo;
796 
797 	memset(key_cuckoo, 0, sizeof(key_cuckoo));
798 	kcuckoo[0] = 0xadadadad;
799 
800 	struct table_packets table_packets;
801 
802 	printf("--------------\n");
803 	printf("RUNNING TEST - %s\n", __func__);
804 	printf("--------------\n");
805 	for (i = 0; i < 50; i++)
806 		table_packets.hit_packet[i] = 0xadadadad;
807 
808 	for (i = 0; i < 50; i++)
809 		table_packets.miss_packet[i] = 0xbdadadad;
810 
811 	table_packets.n_hit_packets = 50;
812 	table_packets.n_miss_packets = 50;
813 
814 	status = test_table_type(&rte_table_hash_cuckoo_ops,
815 		(void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
816 		NULL, 0);
817 	VERIFY(status, CHECK_TABLE_OK);
818 
819 	/* Invalid parameters */
820 	cuckoo_params.key_size = 0;
821 
822 	status = test_table_type(&rte_table_hash_cuckoo_ops,
823 		(void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
824 		NULL, 0);
825 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
826 
827 	cuckoo_params.key_size = 32;
828 	cuckoo_params.n_keys = 0;
829 
830 	status = test_table_type(&rte_table_hash_cuckoo_ops,
831 		(void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
832 		NULL, 0);
833 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
834 
835 	cuckoo_params.n_keys = 1<<16;
836 	cuckoo_params.f_hash = NULL;
837 
838 	status = test_table_type(&rte_table_hash_cuckoo_ops,
839 		(void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
840 		NULL, 0);
841 	VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
842 
843 	return 0;
844 }
845 
846 #endif /* !RTE_EXEC_ENV_WINDOWS */
847