ip_frag: add IPv4 options fragment
[dpdk.git] / app / test / test_lpm.c
index 258b2f6..bceb9ae 100644 (file)
@@ -2,6 +2,18 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include "test.h"
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+static int
+test_lpm(void)
+{
+       printf("lpm not supported on Windows, skipping test\n");
+       return TEST_SKIPPED;
+}
+
+#else
+
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -10,7 +22,6 @@
 #include <rte_lpm.h>
 #include <rte_malloc.h>
 
-#include "test.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -179,7 +190,7 @@ test3(void)
        status = rte_lpm_add(NULL, ip, depth, next_hop);
        TEST_LPM_ASSERT(status < 0);
 
-       /*Create vaild lpm to use in rest of test. */
+       /*Create valid lpm to use in rest of test. */
        lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
        TEST_LPM_ASSERT(lpm != NULL);
 
@@ -217,7 +228,7 @@ test4(void)
        status = rte_lpm_delete(NULL, ip, depth);
        TEST_LPM_ASSERT(status < 0);
 
-       /*Create vaild lpm to use in rest of test. */
+       /*Create valid lpm to use in rest of test. */
        lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
        TEST_LPM_ASSERT(lpm != NULL);
 
@@ -255,7 +266,7 @@ test5(void)
        status = rte_lpm_lookup(NULL, ip, &next_hop_return);
        TEST_LPM_ASSERT(status < 0);
 
-       /*Create vaild lpm to use in rest of test. */
+       /*Create valid lpm to use in rest of test. */
        lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
        TEST_LPM_ASSERT(lpm != NULL);
 
@@ -993,7 +1004,7 @@ test13(void)
 }
 
 /*
- * Fore TBL8 extension exhaustion. Add 256 rules that require a tbl8 extension.
+ * For TBL8 extension exhaustion. Add 512 rules that require a tbl8 extension.
  * No more tbl8 extensions will be allowed. Now add one more rule that required
  * a tbl8 extension and get fail.
  * */
@@ -1008,28 +1019,37 @@ test14(void)
        struct rte_lpm_config config;
 
        config.max_rules = 256 * 32;
-       config.number_tbl8s = NUMBER_TBL8S;
+       config.number_tbl8s = 512;
        config.flags = 0;
-       uint32_t ip, next_hop_add, next_hop_return;
+       uint32_t ip, next_hop_base, next_hop_return;
        uint8_t depth;
        int32_t status = 0;
+       xmm_t ipx4;
+       uint32_t hop[4];
 
        /* Add enough space for 256 rules for every depth */
        lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
        TEST_LPM_ASSERT(lpm != NULL);
 
        depth = 32;
-       next_hop_add = 100;
+       next_hop_base = 100;
        ip = RTE_IPV4(0, 0, 0, 0);
 
        /* Add 256 rules that require a tbl8 extension */
-       for (; ip <= RTE_IPV4(0, 0, 255, 0); ip += 256) {
-               status = rte_lpm_add(lpm, ip, depth, next_hop_add);
+       for (; ip <= RTE_IPV4(0, 1, 255, 0); ip += 256) {
+               status = rte_lpm_add(lpm, ip, depth, next_hop_base + ip);
                TEST_LPM_ASSERT(status == 0);
 
                status = rte_lpm_lookup(lpm, ip, &next_hop_return);
                TEST_LPM_ASSERT((status == 0) &&
-                               (next_hop_return == next_hop_add));
+                               (next_hop_return == next_hop_base + ip));
+
+               ipx4 = vect_set_epi32(ip + 3, ip + 2, ip + 1, ip);
+               rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX);
+               TEST_LPM_ASSERT(hop[0] == next_hop_base + ip);
+               TEST_LPM_ASSERT(hop[1] == UINT32_MAX);
+               TEST_LPM_ASSERT(hop[2] == UINT32_MAX);
+               TEST_LPM_ASSERT(hop[3] == UINT32_MAX);
        }
 
        /* All tbl8 extensions have been used above. Try to add one more and
@@ -1037,7 +1057,7 @@ test14(void)
        ip = RTE_IPV4(1, 0, 0, 0);
        depth = 32;
 
-       status = rte_lpm_add(lpm, ip, depth, next_hop_add);
+       status = rte_lpm_add(lpm, ip, depth, next_hop_base + ip);
        TEST_LPM_ASSERT(status < 0);
 
        rte_lpm_free(lpm);
@@ -1575,4 +1595,6 @@ test_lpm(void)
        return global_status;
 }
 
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
 REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);