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