15129044dSC.J. Collier/*-
25129044dSC.J. Collier *   BSD LICENSE
35129044dSC.J. Collier *
43d9b7210SChristian Ehrhardt *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
55129044dSC.J. Collier *   All rights reserved.
65129044dSC.J. Collier *
75129044dSC.J. Collier *   Redistribution and use in source and binary forms, with or without
85129044dSC.J. Collier *   modification, are permitted provided that the following conditions
95129044dSC.J. Collier *   are met:
105129044dSC.J. Collier *
115129044dSC.J. Collier *     * Redistributions of source code must retain the above copyright
125129044dSC.J. Collier *       notice, this list of conditions and the following disclaimer.
135129044dSC.J. Collier *     * Redistributions in binary form must reproduce the above copyright
145129044dSC.J. Collier *       notice, this list of conditions and the following disclaimer in
155129044dSC.J. Collier *       the documentation and/or other materials provided with the
165129044dSC.J. Collier *       distribution.
175129044dSC.J. Collier *     * Neither the name of Intel Corporation nor the names of its
185129044dSC.J. Collier *       contributors may be used to endorse or promote products derived
195129044dSC.J. Collier *       from this software without specific prior written permission.
205129044dSC.J. Collier *
215129044dSC.J. Collier *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
225129044dSC.J. Collier *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
235129044dSC.J. Collier *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
245129044dSC.J. Collier *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
255129044dSC.J. Collier *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
265129044dSC.J. Collier *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
275129044dSC.J. Collier *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
285129044dSC.J. Collier *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
295129044dSC.J. Collier *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
305129044dSC.J. Collier *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
315129044dSC.J. Collier *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
325129044dSC.J. Collier */
335129044dSC.J. Collier
345129044dSC.J. Collier#include <string.h>
355129044dSC.J. Collier#include <rte_byteorder.h>
365129044dSC.J. Collier#include <rte_table_lpm_ipv6.h>
375129044dSC.J. Collier#include <rte_lru.h>
385129044dSC.J. Collier#include <rte_cycles.h>
395129044dSC.J. Collier#include "test_table_tables.h"
405129044dSC.J. Collier#include "test_table.h"
415129044dSC.J. Collier
425129044dSC.J. Colliertable_test table_tests[] = {
435129044dSC.J. Collier	test_table_stub,
445129044dSC.J. Collier	test_table_array,
455129044dSC.J. Collier	test_table_lpm,
465129044dSC.J. Collier	test_table_lpm_ipv6,
475129044dSC.J. Collier	test_table_hash_lru,
485129044dSC.J. Collier	test_table_hash_ext,
493d9b7210SChristian Ehrhardt	test_table_hash_cuckoo,
505129044dSC.J. Collier};
515129044dSC.J. Collier
525129044dSC.J. Collier#define PREPARE_PACKET(mbuf, value) do {				\
535129044dSC.J. Collier	uint32_t *k32, *signature;					\
545129044dSC.J. Collier	uint8_t *key;							\
555129044dSC.J. Collier	mbuf = rte_pktmbuf_alloc(pool);					\
565129044dSC.J. Collier	signature = RTE_MBUF_METADATA_UINT32_PTR(mbuf,			\
575129044dSC.J. Collier			APP_METADATA_OFFSET(0));			\
585129044dSC.J. Collier	key = RTE_MBUF_METADATA_UINT8_PTR(mbuf,			\
595129044dSC.J. Collier			APP_METADATA_OFFSET(32));			\
605129044dSC.J. Collier	memset(key, 0, 32);						\
615129044dSC.J. Collier	k32 = (uint32_t *) key;						\
625129044dSC.J. Collier	k32[0] = (value);						\
635129044dSC.J. Collier	*signature = pipeline_test_hash(key, 0, 0);			\
645129044dSC.J. Collier} while (0)
655129044dSC.J. Collier
665129044dSC.J. Collierunsigned n_table_tests = RTE_DIM(table_tests);
675129044dSC.J. Collier
685129044dSC.J. Collier/* Function prototypes */
695129044dSC.J. Collierstatic int
705129044dSC.J. Colliertest_table_hash_lru_generic(struct rte_table_ops *ops);
715129044dSC.J. Collierstatic int
725129044dSC.J. Colliertest_table_hash_ext_generic(struct rte_table_ops *ops);
735129044dSC.J. Collier
745129044dSC.J. Collierstruct rte_bucket_4_8 {
755129044dSC.J. Collier	/* Cache line 0 */
765129044dSC.J. Collier	uint64_t signature;
775129044dSC.J. Collier	uint64_t lru_list;
785129044dSC.J. Collier	struct rte_bucket_4_8 *next;
795129044dSC.J. Collier	uint64_t next_valid;
805129044dSC.J. Collier	uint64_t key[4];
815129044dSC.J. Collier	/* Cache line 1 */
825129044dSC.J. Collier	uint8_t data[0];
835129044dSC.J. Collier};
845129044dSC.J. Collier
855129044dSC.J. Collier#if RTE_TABLE_HASH_LRU_STRATEGY == 3
865129044dSC.J. Collieruint64_t shuffles = 0xfffffffdfffbfff9ULL;
875129044dSC.J. Collier#else
885129044dSC.J. Collieruint64_t shuffles = 0x0003000200010000ULL;
895129044dSC.J. Collier#endif
905129044dSC.J. Collier
915129044dSC.J. Collierstatic int test_lru_update(void)
925129044dSC.J. Collier{
935129044dSC.J. Collier	struct rte_bucket_4_8 b;
945129044dSC.J. Collier	struct rte_bucket_4_8 *bucket;
955129044dSC.J. Collier	uint32_t i;
965129044dSC.J. Collier	uint64_t pos;
975129044dSC.J. Collier	uint64_t iterations;
985129044dSC.J. Collier	uint64_t j;
995129044dSC.J. Collier	int poss;
1005129044dSC.J. Collier
1015129044dSC.J. Collier	printf("---------------------------\n");
1025129044dSC.J. Collier	printf("Testing lru_update macro...\n");
1035129044dSC.J. Collier	printf("---------------------------\n");
1045129044dSC.J. Collier	bucket = &b;
1055129044dSC.J. Collier	iterations = 10;
1065129044dSC.J. Collier#if RTE_TABLE_HASH_LRU_STRATEGY == 3
1075129044dSC.J. Collier	bucket->lru_list = 0xFFFFFFFFFFFFFFFFULL;
1085129044dSC.J. Collier#else
1095129044dSC.J. Collier	bucket->lru_list = 0x0000000100020003ULL;
1105129044dSC.J. Collier#endif
1115129044dSC.J. Collier	poss = 0;
1125129044dSC.J. Collier	for (j = 0; j < iterations; j++)
1135129044dSC.J. Collier		for (i = 0; i < 9; i++) {
1145129044dSC.J. Collier			uint32_t idx = i >> 1;
1155129044dSC.J. Collier			lru_update(bucket, idx);
1165129044dSC.J. Collier			pos = lru_pos(bucket);
1175129044dSC.J. Collier			poss += pos;
1185129044dSC.J. Collier			printf("%s: %d lru_list=%016"PRIx64", upd=%d, "
1195129044dSC.J. Collier				"pos=%"PRIx64"\n",
1205129044dSC.J. Collier				__func__, i, bucket->lru_list, i>>1, pos);
1215129044dSC.J. Collier		}
1225129044dSC.J. Collier
1235129044dSC.J. Collier	if (bucket->lru_list != shuffles) {
1245129044dSC.J. Collier		printf("%s: ERROR: %d lru_list=%016"PRIx64", expected %016"
1255129044dSC.J. Collier			PRIx64"\n",
1265129044dSC.J. Collier			__func__, i, bucket->lru_list, shuffles);
1275129044dSC.J. Collier		return -1;
1285129044dSC.J. Collier	}
1295129044dSC.J. Collier	printf("%s: output checksum of results =%d\n",
1305129044dSC.J. Collier		__func__, poss);
1315129044dSC.J. Collier#if 0
1325129044dSC.J. Collier	if (poss != 126) {
1335129044dSC.J. Collier		printf("%s: ERROR output checksum of results =%d expected %d\n",
1345129044dSC.J. Collier			__func__, poss, 126);
1355129044dSC.J. Collier		return -1;
1365129044dSC.J. Collier	}
1375129044dSC.J. Collier#endif
1385129044dSC.J. Collier
1395129044dSC.J. Collier	fflush(stdout);
1405129044dSC.J. Collier
1415129044dSC.J. Collier	uint64_t sc_start = rte_rdtsc();
1425129044dSC.J. Collier	iterations = 100000000;
1435129044dSC.J. Collier	poss = 0;
1445129044dSC.J. Collier	for (j = 0; j < iterations; j++) {
1455129044dSC.J. Collier		for (i = 0; i < 4; i++) {
1465129044dSC.J. Collier			lru_update(bucket, i);
1475129044dSC.J. Collier			pos |= bucket->lru_list;
1485129044dSC.J. Collier		}
1495129044dSC.J. Collier	}
1505129044dSC.J. Collier	uint64_t sc_end = rte_rdtsc();
1515129044dSC.J. Collier
1525129044dSC.J. Collier	printf("%s: output checksum of results =%llu\n",
1535129044dSC.J. Collier		__func__, (long long unsigned int)pos);
1545129044dSC.J. Collier	printf("%s: start=%016"PRIx64", end=%016"PRIx64"\n",
1555129044dSC.J. Collier		__func__, sc_start, sc_end);
1565129044dSC.J. Collier	printf("\nlru_update: %lu cycles per loop iteration.\n\n",
1575129044dSC.J. Collier		(long unsigned int)((sc_end-sc_start)/(iterations*4)));
1585129044dSC.J. Collier
1595129044dSC.J. Collier	return 0;
1605129044dSC.J. Collier}
1615129044dSC.J. Collier
1625129044dSC.J. Collier/* Table tests */
1635129044dSC.J. Collierint
1645129044dSC.J. Colliertest_table_stub(void)
1655129044dSC.J. Collier{
1665129044dSC.J. Collier	int i;
1675129044dSC.J. Collier	uint64_t expected_mask = 0, result_mask;
1685129044dSC.J. Collier	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
1695129044dSC.J. Collier	void *table;
1705129044dSC.J. Collier	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
1715129044dSC.J. Collier
1725129044dSC.J. Collier	/* Create */
1735129044dSC.J. Collier	table = rte_table_stub_ops.f_create(NULL, 0, 1);
1745129044dSC.J. Collier	if (table == NULL)
1755129044dSC.J. Collier		return -1;
1765129044dSC.J. Collier
1775129044dSC.J. Collier	/* Traffic flow */
1785129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
1795129044dSC.J. Collier		if (i % 2 == 0)
1805129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadad);
1815129044dSC.J. Collier		else
1825129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadab);
1835129044dSC.J. Collier
1845129044dSC.J. Collier	expected_mask = 0;
1855129044dSC.J. Collier	rte_table_stub_ops.f_lookup(table, mbufs, -1,
1865129044dSC.J. Collier		&result_mask, (void **)entries);
1875129044dSC.J. Collier	if (result_mask != expected_mask)
1885129044dSC.J. Collier		return -2;
1895129044dSC.J. Collier
1905129044dSC.J. Collier	/* Free resources */
1915129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
1925129044dSC.J. Collier		rte_pktmbuf_free(mbufs[i]);
1935129044dSC.J. Collier
1945129044dSC.J. Collier	return 0;
1955129044dSC.J. Collier}
1965129044dSC.J. Collier
1975129044dSC.J. Collierint
1985129044dSC.J. Colliertest_table_array(void)
1995129044dSC.J. Collier{
2005129044dSC.J. Collier	int status, i;
2015129044dSC.J. Collier	uint64_t result_mask;
2025129044dSC.J. Collier	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
2035129044dSC.J. Collier	void *table;
2045129044dSC.J. Collier	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
2055129044dSC.J. Collier	char entry1, entry2;
2065129044dSC.J. Collier	void *entry_ptr;
2075129044dSC.J. Collier	int key_found;
2085129044dSC.J. Collier
2095129044dSC.J. Collier	/* Initialize params and create tables */
2105129044dSC.J. Collier	struct rte_table_array_params array_params = {
2115129044dSC.J. Collier		.n_entries = 7,
2125129044dSC.J. Collier		.offset = APP_METADATA_OFFSET(1)
2135129044dSC.J. Collier	};
2145129044dSC.J. Collier
2155129044dSC.J. Collier	table = rte_table_array_ops.f_create(NULL, 0, 1);
2165129044dSC.J. Collier	if (table != NULL)
2175129044dSC.J. Collier		return -1;
2185129044dSC.J. Collier
2195129044dSC.J. Collier	array_params.n_entries = 0;
2205129044dSC.J. Collier
2215129044dSC.J. Collier	table = rte_table_array_ops.f_create(&array_params, 0, 1);
2225129044dSC.J. Collier	if (table != NULL)
2235129044dSC.J. Collier		return -2;
2245129044dSC.J. Collier
2255129044dSC.J. Collier	array_params.n_entries = 7;
2265129044dSC.J. Collier
2275129044dSC.J. Collier	table = rte_table_array_ops.f_create(&array_params, 0, 1);
2285129044dSC.J. Collier	if (table != NULL)
2295129044dSC.J. Collier		return -3;
2305129044dSC.J. Collier
2315129044dSC.J. Collier	array_params.n_entries = 1 << 24;
2325129044dSC.J. Collier	array_params.offset = APP_METADATA_OFFSET(1);
2335129044dSC.J. Collier
2345129044dSC.J. Collier	table = rte_table_array_ops.f_create(&array_params, 0, 1);
2355129044dSC.J. Collier	if (table == NULL)
2365129044dSC.J. Collier		return -4;
2375129044dSC.J. Collier
2385129044dSC.J. Collier	array_params.offset = APP_METADATA_OFFSET(32);
2395129044dSC.J. Collier
2405129044dSC.J. Collier	table = rte_table_array_ops.f_create(&array_params, 0, 1);
2415129044dSC.J. Collier	if (table == NULL)
2425129044dSC.J. Collier		return -5;
2435129044dSC.J. Collier
2445129044dSC.J. Collier	/* Free */
2455129044dSC.J. Collier	status = rte_table_array_ops.f_free(table);
2465129044dSC.J. Collier	if (status < 0)
2475129044dSC.J. Collier		return -6;
2485129044dSC.J. Collier
2495129044dSC.J. Collier	status = rte_table_array_ops.f_free(NULL);
2505129044dSC.J. Collier	if (status == 0)
2515129044dSC.J. Collier		return -7;
2525129044dSC.J. Collier
2535129044dSC.J. Collier	/* Add */
2545129044dSC.J. Collier	struct rte_table_array_key array_key_1 = {
2555129044dSC.J. Collier		.pos = 10,
2565129044dSC.J. Collier	};
2575129044dSC.J. Collier	struct rte_table_array_key array_key_2 = {
2585129044dSC.J. Collier		.pos = 20,
2595129044dSC.J. Collier	};
2605129044dSC.J. Collier	entry1 = 'A';
2615129044dSC.J. Collier	entry2 = 'B';
2625129044dSC.J. Collier
2635129044dSC.J. Collier	table = rte_table_array_ops.f_create(&array_params, 0, 1);
2645129044dSC.J. Collier	if (table == NULL)
2655129044dSC.J. Collier		return -8;
2665129044dSC.J. Collier
2675129044dSC.J. Collier	status = rte_table_array_ops.f_add(NULL, (void *) &array_key_1, &entry1,
2685129044dSC.J. Collier		&key_found, &entry_ptr);
2695129044dSC.J. Collier	if (status == 0)
2705129044dSC.J. Collier		return -9;
2715129044dSC.J. Collier
2725129044dSC.J. Collier	status = rte_table_array_ops.f_add(table, (void *) &array_key_1, NULL,
2735129044dSC.J. Collier		&key_found, &entry_ptr);
2745129044dSC.J. Collier	if (status == 0)
2755129044dSC.J. Collier		return -10;
2765129044dSC.J. Collier
2775129044dSC.J. Collier	status = rte_table_array_ops.f_add(table, (void *) &array_key_1,
2785129044dSC.J. Collier		&entry1, &key_found, &entry_ptr);
2795129044dSC.J. Collier	if (status != 0)
2805129044dSC.J. Collier		return -11;
2815129044dSC.J. Collier
2825129044dSC.J. Collier	/* Traffic flow */
2835129044dSC.J. Collier	status = rte_table_array_ops.f_add(table, (void *) &array_key_2,
2845129044dSC.J. Collier		&entry2, &key_found, &entry_ptr);
2855129044dSC.J. Collier	if (status != 0)
2865129044dSC.J. Collier		return -12;
2875129044dSC.J. Collier
2885129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
2895129044dSC.J. Collier		if (i % 2 == 0)
2905129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 10);
2915129044dSC.J. Collier		else
2925129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 20);
2935129044dSC.J. Collier
2945129044dSC.J. Collier	rte_table_array_ops.f_lookup(table, mbufs, -1,
2955129044dSC.J. Collier		&result_mask, (void **)entries);
2965129044dSC.J. Collier
2975129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
2985129044dSC.J. Collier		if (i % 2 == 0 && *entries[i] != 'A')
2995129044dSC.J. Collier			return -13;
3005129044dSC.J. Collier		else
3015129044dSC.J. Collier			if (i % 2 == 1 && *entries[i] != 'B')
3025129044dSC.J. Collier				return -13;
3035129044dSC.J. Collier
3045129044dSC.J. Collier	/* Free resources */
3055129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
3065129044dSC.J. Collier		rte_pktmbuf_free(mbufs[i]);
3075129044dSC.J. Collier
3085129044dSC.J. Collier	status = rte_table_array_ops.f_free(table);
3095129044dSC.J. Collier
3105129044dSC.J. Collier	return 0;
3115129044dSC.J. Collier}
3125129044dSC.J. Collier
3135129044dSC.J. Collierint
3145129044dSC.J. Colliertest_table_lpm(void)
3155129044dSC.J. Collier{
3165129044dSC.J. Collier	int status, i;
3175129044dSC.J. Collier	uint64_t expected_mask = 0, result_mask;
3185129044dSC.J. Collier	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
3195129044dSC.J. Collier	void *table;
3205129044dSC.J. Collier	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
3215129044dSC.J. Collier	char entry;
3225129044dSC.J. Collier	void *entry_ptr;
3235129044dSC.J. Collier	int key_found;
3245129044dSC.J. Collier	uint32_t entry_size = 1;
3255129044dSC.J. Collier
3265129044dSC.J. Collier	/* Initialize params and create tables */
3275129044dSC.J. Collier	struct rte_table_lpm_params lpm_params = {
3285129044dSC.J. Collier		.name = "LPM",
3295129044dSC.J. Collier		.n_rules = 1 << 24,
3305129044dSC.J. Collier		.number_tbl8s = 1 << 8,
3315129044dSC.J. Collier		.flags = 0,
3325129044dSC.J. Collier		.entry_unique_size = entry_size,
3335129044dSC.J. Collier		.offset = APP_METADATA_OFFSET(1)
3345129044dSC.J. Collier	};
3355129044dSC.J. Collier
3365129044dSC.J. Collier	table = rte_table_lpm_ops.f_create(NULL, 0, entry_size);
3375129044dSC.J. Collier	if (table != NULL)
3385129044dSC.J. Collier		return -1;
3395129044dSC.J. Collier
3405129044dSC.J. Collier	lpm_params.name = NULL;
3415129044dSC.J. Collier
3425129044dSC.J. Collier	table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
3435129044dSC.J. Collier	if (table != NULL)
3445129044dSC.J. Collier		return -2;
3455129044dSC.J. Collier
3465129044dSC.J. Collier	lpm_params.name = "LPM";
3475129044dSC.J. Collier	lpm_params.n_rules = 0;
3485129044dSC.J. Collier
3495129044dSC.J. Collier	table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
3505129044dSC.J. Collier	if (table != NULL)
3515129044dSC.J. Collier		return -3;
3525129044dSC.J. Collier
3535129044dSC.J. Collier	lpm_params.n_rules = 1 << 24;
3545129044dSC.J. Collier	lpm_params.offset = APP_METADATA_OFFSET(32);
3555129044dSC.J. Collier	lpm_params.entry_unique_size = 0;
3565129044dSC.J. Collier
3575129044dSC.J. Collier	table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
3585129044dSC.J. Collier	if (table != NULL)
3595129044dSC.J. Collier		return -4;
3605129044dSC.J. Collier
3615129044dSC.J. Collier	lpm_params.entry_unique_size = entry_size + 1;
3625129044dSC.J. Collier
3635129044dSC.J. Collier	table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
3645129044dSC.J. Collier	if (table != NULL)
3655129044dSC.J. Collier		return -5;
3665129044dSC.J. Collier
3675129044dSC.J. Collier	lpm_params.entry_unique_size = entry_size;
3685129044dSC.J. Collier
3695129044dSC.J. Collier	table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
3705129044dSC.J. Collier	if (table == NULL)
3715129044dSC.J. Collier		return -6;
3725129044dSC.J. Collier
3735129044dSC.J. Collier	/* Free */
3745129044dSC.J. Collier	status = rte_table_lpm_ops.f_free(table);
3755129044dSC.J. Collier	if (status < 0)
3765129044dSC.J. Collier		return -7;
3775129044dSC.J. Collier
3785129044dSC.J. Collier	status = rte_table_lpm_ops.f_free(NULL);
3795129044dSC.J. Collier	if (status == 0)
3805129044dSC.J. Collier		return -8;
3815129044dSC.J. Collier
3825129044dSC.J. Collier	/* Add */
3835129044dSC.J. Collier	struct rte_table_lpm_key lpm_key;
3845129044dSC.J. Collier	lpm_key.ip = 0xadadadad;
3855129044dSC.J. Collier
3865129044dSC.J. Collier	table = rte_table_lpm_ops.f_create(&lpm_params, 0, 1);
3875129044dSC.J. Collier	if (table == NULL)
3885129044dSC.J. Collier		return -9;
3895129044dSC.J. Collier
3905129044dSC.J. Collier	status = rte_table_lpm_ops.f_add(NULL, &lpm_key, &entry, &key_found,
3915129044dSC.J. Collier		&entry_ptr);
3925129044dSC.J. Collier	if (status == 0)
3935129044dSC.J. Collier		return -10;
3945129044dSC.J. Collier
3955129044dSC.J. Collier	status = rte_table_lpm_ops.f_add(table, NULL, &entry, &key_found,
3965129044dSC.J. Collier		&entry_ptr);
3975129044dSC.J. Collier	if (status == 0)
3985129044dSC.J. Collier		return -11;
3995129044dSC.J. Collier
4005129044dSC.J. Collier	status = rte_table_lpm_ops.f_add(table, &lpm_key, NULL, &key_found,
4015129044dSC.J. Collier		&entry_ptr);
4025129044dSC.J. Collier	if (status == 0)
4035129044dSC.J. Collier		return -12;
4045129044dSC.J. Collier
4055129044dSC.J. Collier	lpm_key.depth = 0;
4065129044dSC.J. Collier	status = rte_table_lpm_ops.f_add(table, &lpm_key, &entry, &key_found,
4075129044dSC.J. Collier		&entry_ptr);
4085129044dSC.J. Collier	if (status == 0)
4095129044dSC.J. Collier		return -13;
4105129044dSC.J. Collier
4115129044dSC.J. Collier	lpm_key.depth = 33;
4125129044dSC.J. Collier	status = rte_table_lpm_ops.f_add(table, &lpm_key, &entry, &key_found,
4135129044dSC.J. Collier		&entry_ptr);
4145129044dSC.J. Collier	if (status == 0)
4155129044dSC.J. Collier		return -14;
4165129044dSC.J. Collier
4175129044dSC.J. Collier	lpm_key.depth = 16;
4185129044dSC.J. Collier	status = rte_table_lpm_ops.f_add(table, &lpm_key, &entry, &key_found,
4195129044dSC.J. Collier		&entry_ptr);
4205129044dSC.J. Collier	if (status != 0)
4215129044dSC.J. Collier		return -15;
4225129044dSC.J. Collier
4235129044dSC.J. Collier	/* Delete */
4245129044dSC.J. Collier	status = rte_table_lpm_ops.f_delete(NULL, &lpm_key, &key_found, NULL);
4255129044dSC.J. Collier	if (status == 0)
4265129044dSC.J. Collier		return -16;
4275129044dSC.J. Collier
4285129044dSC.J. Collier	status = rte_table_lpm_ops.f_delete(table, NULL, &key_found, NULL);
4295129044dSC.J. Collier	if (status == 0)
4305129044dSC.J. Collier		return -17;
4315129044dSC.J. Collier
4325129044dSC.J. Collier	lpm_key.depth = 0;
4335129044dSC.J. Collier	status = rte_table_lpm_ops.f_delete(table, &lpm_key, &key_found, NULL);
4345129044dSC.J. Collier	if (status == 0)
4355129044dSC.J. Collier		return -18;
4365129044dSC.J. Collier
4375129044dSC.J. Collier	lpm_key.depth = 33;
4385129044dSC.J. Collier	status = rte_table_lpm_ops.f_delete(table, &lpm_key, &key_found, NULL);
4395129044dSC.J. Collier	if (status == 0)
4405129044dSC.J. Collier		return -19;
4415129044dSC.J. Collier
4425129044dSC.J. Collier	lpm_key.depth = 16;
4435129044dSC.J. Collier	status = rte_table_lpm_ops.f_delete(table, &lpm_key, &key_found, NULL);
4445129044dSC.J. Collier	if (status != 0)
4455129044dSC.J. Collier		return -20;
4465129044dSC.J. Collier
4475129044dSC.J. Collier	status = rte_table_lpm_ops.f_delete(table, &lpm_key, &key_found, NULL);
4485129044dSC.J. Collier	if (status != 0)
4495129044dSC.J. Collier		return -21;
4505129044dSC.J. Collier
4515129044dSC.J. Collier	/* Traffic flow */
4525129044dSC.J. Collier	entry = 'A';
4535129044dSC.J. Collier	status = rte_table_lpm_ops.f_add(table, &lpm_key, &entry, &key_found,
4545129044dSC.J. Collier		&entry_ptr);
4555129044dSC.J. Collier	if (status < 0)
4565129044dSC.J. Collier		return -22;
4575129044dSC.J. Collier
4585129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
4595129044dSC.J. Collier		if (i % 2 == 0) {
4605129044dSC.J. Collier			expected_mask |= (uint64_t)1 << i;
4615129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadad);
4625129044dSC.J. Collier		} else
4635129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadab);
4645129044dSC.J. Collier
4655129044dSC.J. Collier	rte_table_lpm_ops.f_lookup(table, mbufs, -1,
4665129044dSC.J. Collier		&result_mask, (void **)entries);
4675129044dSC.J. Collier	if (result_mask != expected_mask)
4685129044dSC.J. Collier		return -23;
4695129044dSC.J. Collier
4705129044dSC.J. Collier	/* Free resources */
4715129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
4725129044dSC.J. Collier		rte_pktmbuf_free(mbufs[i]);
4735129044dSC.J. Collier
4745129044dSC.J. Collier	status = rte_table_lpm_ops.f_free(table);
4755129044dSC.J. Collier
4765129044dSC.J. Collier	return 0;
4775129044dSC.J. Collier}
4785129044dSC.J. Collier
4795129044dSC.J. Collierint
4805129044dSC.J. Colliertest_table_lpm_ipv6(void)
4815129044dSC.J. Collier{
4825129044dSC.J. Collier	int status, i;
4835129044dSC.J. Collier	uint64_t expected_mask = 0, result_mask;
4845129044dSC.J. Collier	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
4855129044dSC.J. Collier	void *table;
4865129044dSC.J. Collier	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
4875129044dSC.J. Collier	char entry;
4885129044dSC.J. Collier	void *entry_ptr;
4895129044dSC.J. Collier	int key_found;
4905129044dSC.J. Collier	uint32_t entry_size = 1;
4915129044dSC.J. Collier
4925129044dSC.J. Collier	/* Initialize params and create tables */
4935129044dSC.J. Collier	struct rte_table_lpm_ipv6_params lpm_params = {
4945129044dSC.J. Collier		.name = "LPM",
4955129044dSC.J. Collier		.n_rules = 1 << 24,
4965129044dSC.J. Collier		.number_tbl8s = 1 << 21,
4975129044dSC.J. Collier		.entry_unique_size = entry_size,
4985129044dSC.J. Collier		.offset = APP_METADATA_OFFSET(32)
4995129044dSC.J. Collier	};
5005129044dSC.J. Collier
5015129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(NULL, 0, entry_size);
5025129044dSC.J. Collier	if (table != NULL)
5035129044dSC.J. Collier		return -1;
5045129044dSC.J. Collier
5055129044dSC.J. Collier	lpm_params.name = NULL;
5065129044dSC.J. Collier
5075129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
5085129044dSC.J. Collier	if (table != NULL)
5095129044dSC.J. Collier		return -2;
5105129044dSC.J. Collier
5115129044dSC.J. Collier	lpm_params.name = "LPM";
5125129044dSC.J. Collier	lpm_params.n_rules = 0;
5135129044dSC.J. Collier
5145129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
5155129044dSC.J. Collier	if (table != NULL)
5165129044dSC.J. Collier		return -3;
5175129044dSC.J. Collier
5185129044dSC.J. Collier	lpm_params.n_rules = 1 << 24;
5195129044dSC.J. Collier	lpm_params.number_tbl8s = 0;
5205129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
5215129044dSC.J. Collier	if (table != NULL)
5225129044dSC.J. Collier		return -4;
5235129044dSC.J. Collier
5245129044dSC.J. Collier	lpm_params.number_tbl8s = 1 << 21;
5255129044dSC.J. Collier	lpm_params.entry_unique_size = 0;
5265129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
5275129044dSC.J. Collier	if (table != NULL)
5285129044dSC.J. Collier		return -5;
5295129044dSC.J. Collier
5305129044dSC.J. Collier	lpm_params.entry_unique_size = entry_size + 1;
5315129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
5325129044dSC.J. Collier	if (table != NULL)
5335129044dSC.J. Collier		return -6;
5345129044dSC.J. Collier
5355129044dSC.J. Collier	lpm_params.entry_unique_size = entry_size;
5365129044dSC.J. Collier	lpm_params.offset = APP_METADATA_OFFSET(32);
5375129044dSC.J. Collier
5385129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
5395129044dSC.J. Collier	if (table == NULL)
5405129044dSC.J. Collier		return -7;
5415129044dSC.J. Collier
5425129044dSC.J. Collier	/* Free */
5435129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_free(table);
5445129044dSC.J. Collier	if (status < 0)
5455129044dSC.J. Collier		return -8;
5465129044dSC.J. Collier
5475129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_free(NULL);
5485129044dSC.J. Collier	if (status == 0)
5495129044dSC.J. Collier		return -9;
5505129044dSC.J. Collier
5515129044dSC.J. Collier	/* Add */
5525129044dSC.J. Collier	struct rte_table_lpm_ipv6_key lpm_key;
5535129044dSC.J. Collier
5545129044dSC.J. Collier	lpm_key.ip[0] = 0xad;
5555129044dSC.J. Collier	lpm_key.ip[1] = 0xad;
5565129044dSC.J. Collier	lpm_key.ip[2] = 0xad;
5575129044dSC.J. Collier	lpm_key.ip[3] = 0xad;
5585129044dSC.J. Collier
5595129044dSC.J. Collier	table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
5605129044dSC.J. Collier	if (table == NULL)
5615129044dSC.J. Collier		return -10;
5625129044dSC.J. Collier
5635129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_add(NULL, &lpm_key, &entry,
5645129044dSC.J. Collier		&key_found, &entry_ptr);
5655129044dSC.J. Collier	if (status == 0)
5665129044dSC.J. Collier		return -11;
5675129044dSC.J. Collier
5685129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_add(table, NULL, &entry, &key_found,
5695129044dSC.J. Collier		&entry_ptr);
5705129044dSC.J. Collier	if (status == 0)
5715129044dSC.J. Collier		return -12;
5725129044dSC.J. Collier
5735129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_add(table, &lpm_key, NULL, &key_found,
5745129044dSC.J. Collier		&entry_ptr);
5755129044dSC.J. Collier	if (status == 0)
5765129044dSC.J. Collier		return -13;
5775129044dSC.J. Collier
5785129044dSC.J. Collier	lpm_key.depth = 0;
5795129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_add(table, &lpm_key, &entry,
5805129044dSC.J. Collier		&key_found, &entry_ptr);
5815129044dSC.J. Collier	if (status == 0)
5825129044dSC.J. Collier		return -14;
5835129044dSC.J. Collier
5845129044dSC.J. Collier	lpm_key.depth = 129;
5855129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_add(table, &lpm_key, &entry,
5865129044dSC.J. Collier		&key_found, &entry_ptr);
5875129044dSC.J. Collier	if (status == 0)
5885129044dSC.J. Collier		return -15;
5895129044dSC.J. Collier
5905129044dSC.J. Collier	lpm_key.depth = 16;
5915129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_add(table, &lpm_key, &entry,
5925129044dSC.J. Collier		&key_found, &entry_ptr);
5935129044dSC.J. Collier	if (status != 0)
5945129044dSC.J. Collier		return -16;
5955129044dSC.J. Collier
5965129044dSC.J. Collier	/* Delete */
5975129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_delete(NULL, &lpm_key, &key_found,
5985129044dSC.J. Collier		NULL);
5995129044dSC.J. Collier	if (status == 0)
6005129044dSC.J. Collier		return -17;
6015129044dSC.J. Collier
6025129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_delete(table, NULL, &key_found, NULL);
6035129044dSC.J. Collier	if (status == 0)
6045129044dSC.J. Collier		return -18;
6055129044dSC.J. Collier
6065129044dSC.J. Collier	lpm_key.depth = 0;
6075129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_delete(table, &lpm_key, &key_found,
6085129044dSC.J. Collier		NULL);
6095129044dSC.J. Collier	if (status == 0)
6105129044dSC.J. Collier		return -19;
6115129044dSC.J. Collier
6125129044dSC.J. Collier	lpm_key.depth = 129;
6135129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_delete(table, &lpm_key, &key_found,
6145129044dSC.J. Collier		NULL);
6155129044dSC.J. Collier	if (status == 0)
6165129044dSC.J. Collier		return -20;
6175129044dSC.J. Collier
6185129044dSC.J. Collier	lpm_key.depth = 16;
6195129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_delete(table, &lpm_key, &key_found,
6205129044dSC.J. Collier		NULL);
6215129044dSC.J. Collier	if (status != 0)
6225129044dSC.J. Collier		return -21;
6235129044dSC.J. Collier
6245129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_delete(table, &lpm_key, &key_found,
6255129044dSC.J. Collier		NULL);
6265129044dSC.J. Collier	if (status != 0)
6275129044dSC.J. Collier		return -22;
6285129044dSC.J. Collier
6295129044dSC.J. Collier	/* Traffic flow */
6305129044dSC.J. Collier	entry = 'A';
6315129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_add(table, &lpm_key, &entry,
6325129044dSC.J. Collier		&key_found, &entry_ptr);
6335129044dSC.J. Collier	if (status < 0)
6345129044dSC.J. Collier		return -23;
6355129044dSC.J. Collier
6365129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
6375129044dSC.J. Collier		if (i % 2 == 0) {
6385129044dSC.J. Collier			expected_mask |= (uint64_t)1 << i;
6395129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadad);
6405129044dSC.J. Collier		} else
6415129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadab);
6425129044dSC.J. Collier
6435129044dSC.J. Collier	rte_table_lpm_ipv6_ops.f_lookup(table, mbufs, -1,
6445129044dSC.J. Collier		&result_mask, (void **)entries);
6455129044dSC.J. Collier	if (result_mask != expected_mask)
6465129044dSC.J. Collier		return -24;
6475129044dSC.J. Collier
6485129044dSC.J. Collier	/* Free resources */
6495129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
6505129044dSC.J. Collier		rte_pktmbuf_free(mbufs[i]);
6515129044dSC.J. Collier
6525129044dSC.J. Collier	status = rte_table_lpm_ipv6_ops.f_free(table);
6535129044dSC.J. Collier
6545129044dSC.J. Collier	return 0;
6555129044dSC.J. Collier}
6565129044dSC.J. Collier
6575129044dSC.J. Collierstatic int
6585129044dSC.J. Colliertest_table_hash_lru_generic(struct rte_table_ops *ops)
6595129044dSC.J. Collier{
6605129044dSC.J. Collier	int status, i;
6615129044dSC.J. Collier	uint64_t expected_mask = 0, result_mask;
6625129044dSC.J. Collier	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
6635129044dSC.J. Collier	void *table;
6645129044dSC.J. Collier	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
6655129044dSC.J. Collier	char entry;
6665129044dSC.J. Collier	void *entry_ptr;
6675129044dSC.J. Collier	int key_found;
6685129044dSC.J. Collier
6695129044dSC.J. Collier	/* Initialize params and create tables */
6705129044dSC.J. Collier	struct rte_table_hash_key8_lru_params hash_params = {
6715129044dSC.J. Collier		.n_entries = 1 << 10,
6725129044dSC.J. Collier		.f_hash = pipeline_test_hash,
6735129044dSC.J. Collier		.seed = 0,
6745129044dSC.J. Collier		.signature_offset = APP_METADATA_OFFSET(1),
6755129044dSC.J. Collier		.key_offset = APP_METADATA_OFFSET(32),
6765129044dSC.J. Collier		.key_mask = NULL,
6775129044dSC.J. Collier	};
6785129044dSC.J. Collier
6795129044dSC.J. Collier	hash_params.n_entries = 0;
6805129044dSC.J. Collier
6815129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
6825129044dSC.J. Collier	if (table != NULL)
6835129044dSC.J. Collier		return -1;
6845129044dSC.J. Collier
6855129044dSC.J. Collier	hash_params.n_entries = 1 << 10;
6865129044dSC.J. Collier	hash_params.signature_offset = APP_METADATA_OFFSET(1);
6875129044dSC.J. Collier
6885129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
6895129044dSC.J. Collier	if (table == NULL)
6905129044dSC.J. Collier		return -2;
6915129044dSC.J. Collier
6925129044dSC.J. Collier	hash_params.signature_offset = APP_METADATA_OFFSET(0);
6935129044dSC.J. Collier	hash_params.key_offset = APP_METADATA_OFFSET(1);
6945129044dSC.J. Collier
6955129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
6965129044dSC.J. Collier	if (table == NULL)
6975129044dSC.J. Collier		return -3;
6985129044dSC.J. Collier
6995129044dSC.J. Collier	hash_params.key_offset = APP_METADATA_OFFSET(32);
7005129044dSC.J. Collier	hash_params.f_hash = NULL;
7015129044dSC.J. Collier
7025129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
7035129044dSC.J. Collier	if (table != NULL)
7045129044dSC.J. Collier		return -4;
7055129044dSC.J. Collier
7065129044dSC.J. Collier	hash_params.f_hash = pipeline_test_hash;
7075129044dSC.J. Collier
7085129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
7095129044dSC.J. Collier	if (table == NULL)
7105129044dSC.J. Collier		return -5;
7115129044dSC.J. Collier
7125129044dSC.J. Collier	/* Free */
7135129044dSC.J. Collier	status = ops->f_free(table);
7145129044dSC.J. Collier	if (status < 0)
7155129044dSC.J. Collier		return -6;
7165129044dSC.J. Collier
7175129044dSC.J. Collier	status = ops->f_free(NULL);
7185129044dSC.J. Collier	if (status == 0)
7195129044dSC.J. Collier		return -7;
7205129044dSC.J. Collier
7215129044dSC.J. Collier	/* Add */
7225129044dSC.J. Collier	uint8_t key[32];
7235129044dSC.J. Collier	uint32_t *k32 = (uint32_t *) &key;
7245129044dSC.J. Collier
7255129044dSC.J. Collier	memset(key, 0, 32);
7265129044dSC.J. Collier	k32[0] = rte_be_to_cpu_32(0xadadadad);
7275129044dSC.J. Collier
7285129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
7295129044dSC.J. Collier	if (table == NULL)
7305129044dSC.J. Collier		return -8;
7315129044dSC.J. Collier
7325129044dSC.J. Collier	entry = 'A';
7335129044dSC.J. Collier	status = ops->f_add(table, &key, &entry, &key_found, &entry_ptr);
7345129044dSC.J. Collier	if (status != 0)
7355129044dSC.J. Collier		return -9;
7365129044dSC.J. Collier
7375129044dSC.J. Collier	/* Delete */
7385129044dSC.J. Collier	status = ops->f_delete(table, &key, &key_found, NULL);
7395129044dSC.J. Collier	if (status != 0)
7405129044dSC.J. Collier		return -10;
7415129044dSC.J. Collier
7425129044dSC.J. Collier	status = ops->f_delete(table, &key, &key_found, NULL);
7435129044dSC.J. Collier	if (status != 0)
7445129044dSC.J. Collier		return -11;
7455129044dSC.J. Collier
7465129044dSC.J. Collier	/* Traffic flow */
7475129044dSC.J. Collier	entry = 'A';
7485129044dSC.J. Collier	status = ops->f_add(table, &key, &entry, &key_found, &entry_ptr);
7495129044dSC.J. Collier	if (status < 0)
7505129044dSC.J. Collier		return -12;
7515129044dSC.J. Collier
7525129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
7535129044dSC.J. Collier		if (i % 2 == 0) {
7545129044dSC.J. Collier			expected_mask |= (uint64_t)1 << i;
7555129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadad);
7565129044dSC.J. Collier		} else
7575129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadab);
7585129044dSC.J. Collier
7595129044dSC.J. Collier	ops->f_lookup(table, mbufs, -1, &result_mask, (void **)entries);
7605129044dSC.J. Collier	if (result_mask != expected_mask)
7615129044dSC.J. Collier		return -13;
7625129044dSC.J. Collier
7635129044dSC.J. Collier	/* Free resources */
7645129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
7655129044dSC.J. Collier		rte_pktmbuf_free(mbufs[i]);
7665129044dSC.J. Collier
7675129044dSC.J. Collier	status = ops->f_free(table);
7685129044dSC.J. Collier
7695129044dSC.J. Collier	return 0;
7705129044dSC.J. Collier}
7715129044dSC.J. Collier
7725129044dSC.J. Collierstatic int
7735129044dSC.J. Colliertest_table_hash_ext_generic(struct rte_table_ops *ops)
7745129044dSC.J. Collier{
7755129044dSC.J. Collier	int status, i;
7765129044dSC.J. Collier	uint64_t expected_mask = 0, result_mask;
7775129044dSC.J. Collier	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
7785129044dSC.J. Collier	void *table;
7795129044dSC.J. Collier	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
7805129044dSC.J. Collier	char entry;
7815129044dSC.J. Collier	int key_found;
7825129044dSC.J. Collier	void *entry_ptr;
7835129044dSC.J. Collier
7845129044dSC.J. Collier	/* Initialize params and create tables */
7855129044dSC.J. Collier	struct rte_table_hash_key8_ext_params hash_params = {
7865129044dSC.J. Collier		.n_entries = 1 << 10,
7875129044dSC.J. Collier		.n_entries_ext = 1 << 4,
7885129044dSC.J. Collier		.f_hash = pipeline_test_hash,
7895129044dSC.J. Collier		.seed = 0,
7905129044dSC.J. Collier		.signature_offset = APP_METADATA_OFFSET(1),
7915129044dSC.J. Collier		.key_offset = APP_METADATA_OFFSET(32),
7925129044dSC.J. Collier		.key_mask = NULL,
7935129044dSC.J. Collier	};
7945129044dSC.J. Collier
7955129044dSC.J. Collier	hash_params.n_entries = 0;
7965129044dSC.J. Collier
7975129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
7985129044dSC.J. Collier	if (table != NULL)
7995129044dSC.J. Collier		return -1;
8005129044dSC.J. Collier
8015129044dSC.J. Collier	hash_params.n_entries = 1 << 10;
8025129044dSC.J. Collier	hash_params.n_entries_ext = 0;
8035129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
8045129044dSC.J. Collier	if (table != NULL)
8055129044dSC.J. Collier		return -2;
8065129044dSC.J. Collier
8075129044dSC.J. Collier	hash_params.n_entries_ext = 1 << 4;
8085129044dSC.J. Collier	hash_params.signature_offset = APP_METADATA_OFFSET(1);
8095129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
8105129044dSC.J. Collier	if (table == NULL)
8115129044dSC.J. Collier		return -2;
8125129044dSC.J. Collier
8135129044dSC.J. Collier	hash_params.signature_offset = APP_METADATA_OFFSET(0);
8145129044dSC.J. Collier	hash_params.key_offset = APP_METADATA_OFFSET(1);
8155129044dSC.J. Collier
8165129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
8175129044dSC.J. Collier	if (table == NULL)
8185129044dSC.J. Collier		return -3;
8195129044dSC.J. Collier
8205129044dSC.J. Collier	hash_params.key_offset = APP_METADATA_OFFSET(32);
8215129044dSC.J. Collier	hash_params.f_hash = NULL;
8225129044dSC.J. Collier
8235129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
8245129044dSC.J. Collier	if (table != NULL)
8255129044dSC.J. Collier		return -4;
8265129044dSC.J. Collier
8275129044dSC.J. Collier	hash_params.f_hash = pipeline_test_hash;
8285129044dSC.J. Collier
8295129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
8305129044dSC.J. Collier	if (table == NULL)
8315129044dSC.J. Collier		return -5;
8325129044dSC.J. Collier
8335129044dSC.J. Collier	/* Free */
8345129044dSC.J. Collier	status = ops->f_free(table);
8355129044dSC.J. Collier	if (status < 0)
8365129044dSC.J. Collier		return -6;
8375129044dSC.J. Collier
8385129044dSC.J. Collier	status = ops->f_free(NULL);
8395129044dSC.J. Collier	if (status == 0)
8405129044dSC.J. Collier		return -7;
8415129044dSC.J. Collier
8425129044dSC.J. Collier	/* Add */
8435129044dSC.J. Collier	uint8_t key[32];
8445129044dSC.J. Collier	uint32_t *k32 = (uint32_t *) &key;
8455129044dSC.J. Collier
8465129044dSC.J. Collier	memset(key, 0, 32);
8475129044dSC.J. Collier	k32[0] = rte_be_to_cpu_32(0xadadadad);
8485129044dSC.J. Collier
8495129044dSC.J. Collier	table = ops->f_create(&hash_params, 0, 1);
8505129044dSC.J. Collier	if (table == NULL)
8515129044dSC.J. Collier		return -8;
8525129044dSC.J. Collier
8535129044dSC.J. Collier	entry = 'A';
8545129044dSC.J. Collier	status = ops->f_add(table, &key, &entry, &key_found, &entry_ptr);
8555129044dSC.J. Collier	if (status != 0)
8565129044dSC.J. Collier		return -9;
8575129044dSC.J. Collier
8585129044dSC.J. Collier	/* Delete */
8595129044dSC.J. Collier	status = ops->f_delete(table, &key, &key_found, NULL);
8605129044dSC.J. Collier	if (status != 0)
8615129044dSC.J. Collier		return -10;
8625129044dSC.J. Collier
8635129044dSC.J. Collier	status = ops->f_delete(table, &key, &key_found, NULL);
8645129044dSC.J. Collier	if (status != 0)
8655129044dSC.J. Collier		return -11;
8665129044dSC.J. Collier
8675129044dSC.J. Collier	/* Traffic flow */
8685129044dSC.J. Collier	entry = 'A';
8695129044dSC.J. Collier	status = ops->f_add(table, &key, &entry, &key_found, &entry_ptr);
8705129044dSC.J. Collier	if (status < 0)
8715129044dSC.J. Collier		return -12;
8725129044dSC.J. Collier
8735129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
8745129044dSC.J. Collier		if (i % 2 == 0) {
8755129044dSC.J. Collier			expected_mask |= (uint64_t)1 << i;
8765129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadad);
8775129044dSC.J. Collier		} else
8785129044dSC.J. Collier			PREPARE_PACKET(mbufs[i], 0xadadadab);
8795129044dSC.J. Collier
8805129044dSC.J. Collier	ops->f_lookup(table, mbufs, -1, &result_mask, (void **)entries);
8815129044dSC.J. Collier	if (result_mask != expected_mask)
8825129044dSC.J. Collier		return -13;
8835129044dSC.J. Collier
8845129044dSC.J. Collier	/* Free resources */
8855129044dSC.J. Collier	for (i = 0; i < RTE_PORT_IN_BURST_SIZE_MAX; i++)
8865129044dSC.J. Collier		rte_pktmbuf_free(mbufs[i]);
8875129044dSC.J. Collier
8885129044dSC.J. Collier	status = ops->f_free(table);
8895129044dSC.J. Collier
8905129044dSC.J. Collier	return 0;
8915129044dSC.J. Collier}
8925129044dSC.J. Collier
8935129044dSC.J. Collierint
8945129044dSC.J. Colliertest_table_hash_lru(void)
8955129044dSC.J. Collier{
8965129044dSC.J. Collier	int status;
8975129044dSC.J. Collier
8985129044dSC.J. Collier	status = test_table_hash_lru_generic(&rte_table_hash_key8_lru_ops);
8995129044dSC.J. Collier	if (status < 0)
9005129044dSC.J. Collier		return status;
9015129044dSC.J. Collier
9025129044dSC.J. Collier	status = test_table_hash_lru_generic(
9035129044dSC.J. Collier		&rte_table_hash_key8_lru_dosig_ops);
9045129044dSC.J. Collier	if (status < 0)
9055129044dSC.J. Collier		return status;
9065129044dSC.J. Collier
9075129044dSC.J. Collier	status = test_table_hash_lru_generic(&rte_table_hash_key16_lru_ops);
9085129044dSC.J. Collier	if (status < 0)
9095129044dSC.J. Collier		return status;
9105129044dSC.J. Collier
9115129044dSC.J. Collier	status = test_table_hash_lru_generic(&rte_table_hash_key32_lru_ops);
9125129044dSC.J. Collier	if (status < 0)
9135129044dSC.J. Collier		return status;
9145129044dSC.J. Collier
9155129044dSC.J. Collier	status = test_lru_update();
9165129044dSC.J. Collier	if (status < 0)
9175129044dSC.J. Collier		return status;
9185129044dSC.J. Collier
9195129044dSC.J. Collier	return 0;
9205129044dSC.J. Collier}
9215129044dSC.J. Collier
9225129044dSC.J. Collierint
9235129044dSC.J. Colliertest_table_hash_ext(void)
9245129044dSC.J. Collier{
9255129044dSC.J. Collier	int status;
9265129044dSC.J. Collier
9275129044dSC.J. Collier	status = test_table_hash_ext_generic(&rte_table_hash_key8_ext_ops);
9285129044dSC.J. Collier	if (status < 0)
9295129044dSC.J. Collier		return status;
9305129044dSC.J. Collier
9315129044dSC.J. Collier	status = test_table_hash_ext_generic