DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 2/2] app/test: add a case to verify lpm tlb8 recycle
@ 2016-08-01  7:03 Wei Dai
  2016-08-02 15:50 ` Bruce Richardson
  2016-08-03  7:03 ` [dpdk-dev] [PATCH v3 2/3] " Wei Dai
  0 siblings, 2 replies; 5+ messages in thread
From: Wei Dai @ 2016-08-01  7:03 UTC (permalink / raw)
  To: dev; +Cc: Wei Dai

As a bug-fix for lpm tlb8 recycle is introduced,
add a test case to verify tlb8 group is correctly
freed when it only includes a rule with depth=24.

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 app/test/test_lpm.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 80 insertions(+), 1 deletion(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index b6ad2eb..e053f99 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -68,6 +68,7 @@ static int32_t test14(void);
 static int32_t test15(void);
 static int32_t test16(void);
 static int32_t test17(void);
+static int32_t test18(void);
 
 rte_lpm_test tests[] = {
 /* Test Cases */
@@ -89,6 +90,7 @@ rte_lpm_test tests[] = {
 	test15,
 	test16,
 	test17,
+	test18
 };
 
 #define NUM_LPM_TESTS (sizeof(tests)/sizeof(tests[0]))
@@ -1218,6 +1220,83 @@ test17(void)
 }
 
 /*
+ * Test for recycle of tlb8
+ *  - step 1: add a rule with depth=28 (> 24)
+ *  - step 2: add a rule with same 24-bit prefix and depth=23 (< 24)
+ *  - step 3: delete the first rule
+ *  - step 4: check tlb8 is freed
+ *  - step 5: add a rule same as the first one (depth=28)
+ *  - step 6: check same tlb8 is allocated
+ *  - step 7: add a rule with same 24-bit prefix and depth=24
+ *  - step 8: delete the rule (depth=28) added in step 5
+ *  - step 9: check tlb8 is freed
+ *  - step 10: add a rule with same 24-bit prefix and depth = 28
+ *  - setp 11: check same tlb8 is allocated again
+ */
+int32_t
+test18(void)
+{
+#define group_idx next_hop
+	struct rte_lpm *lpm = NULL;
+	struct rte_lpm_config config;
+	uint32_t ip, next_hop;
+	uint8_t depth;
+	uint32_t tbl8_group_index;
+
+	config.max_rules = MAX_RULES;
+	config.number_tbl8s = NUMBER_TBL8S;
+	config.flags = 0;
+
+	lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
+	TEST_LPM_ASSERT(lpm != NULL);
+
+	ip = IPv4(192, 168, 100, 100);
+	depth = 28;
+	next_hop = 1;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	tbl8_group_index = lpm->tbl8[ip>>8].group_idx;
+
+	depth = 23;
+	next_hop = 2;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+
+	depth = 28;
+	rte_lpm_delete(lpm, ip, depth);
+
+	TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
+
+	next_hop = 3;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl8[ip>>8].group_idx);
+
+	depth = 24;
+	next_hop = 4;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+
+	depth = 28;
+	rte_lpm_delete(lpm, ip, depth);
+
+	TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
+
+	next_hop = 5;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl8[ip>>8].group_idx);
+
+	rte_lpm_free(lpm);
+#undef group_idx
+	return PASS;
+}
+
+
+/*
  * Do all unit tests.
  */
 
@@ -1230,7 +1309,7 @@ test_lpm(void)
 	for (i = 0; i < NUM_LPM_TESTS; i++) {
 		status = tests[i]();
 		if (status < 0) {
-			printf("ERROR: LPM Test %s: FAIL\n", RTE_STR(tests[i]));
+			printf("ERROR: LPM Test %u: FAIL\n", i);
 			global_status = status;
 		}
 	}
-- 
2.5.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] app/test: add a case to verify lpm tlb8 recycle
  2016-08-01  7:03 [dpdk-dev] [PATCH 2/2] app/test: add a case to verify lpm tlb8 recycle Wei Dai
@ 2016-08-02 15:50 ` Bruce Richardson
  2016-08-03  7:03 ` [dpdk-dev] [PATCH v3 2/3] " Wei Dai
  1 sibling, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2016-08-02 15:50 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev

On Mon, Aug 01, 2016 at 03:03:44PM +0800, Wei Dai wrote:
> As a bug-fix for lpm tlb8 recycle is introduced,
> add a test case to verify tlb8 group is correctly
> freed when it only includes a rule with depth=24.
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] app/test: add a case to verify lpm tlb8 recycle
  2016-08-01  7:03 [dpdk-dev] [PATCH 2/2] app/test: add a case to verify lpm tlb8 recycle Wei Dai
  2016-08-02 15:50 ` Bruce Richardson
@ 2016-08-03  7:03 ` Wei Dai
  2016-08-08  6:40   ` [dpdk-dev] [PATCH v4 " Wei Dai
  1 sibling, 1 reply; 5+ messages in thread
From: Wei Dai @ 2016-08-03  7:03 UTC (permalink / raw)
  To: dev; +Cc: Wei Dai

As a bug-fix for lpm tlb8 recycle is introduced,
add a test case to verify tlb8 group is correctly
freed when it only includes a rule with depth=24.

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 app/test/test_lpm.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index b6ad2eb..ad12846 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -68,6 +68,7 @@ static int32_t test14(void);
 static int32_t test15(void);
 static int32_t test16(void);
 static int32_t test17(void);
+static int32_t test18(void);
 
 rte_lpm_test tests[] = {
 /* Test Cases */
@@ -89,6 +90,7 @@ rte_lpm_test tests[] = {
 	test15,
 	test16,
 	test17,
+	test18
 };
 
 #define NUM_LPM_TESTS (sizeof(tests)/sizeof(tests[0]))
@@ -1218,6 +1220,82 @@ test17(void)
 }
 
 /*
+ * Test for recycle of tlb8
+ *  - step 1: add a rule with depth=28 (> 24)
+ *  - step 2: add a rule with same 24-bit prefix and depth=23 (< 24)
+ *  - step 3: delete the first rule
+ *  - step 4: check tlb8 is freed
+ *  - step 5: add a rule same as the first one (depth=28)
+ *  - step 6: check same tlb8 is allocated
+ *  - step 7: add a rule with same 24-bit prefix and depth=24
+ *  - step 8: delete the rule (depth=28) added in step 5
+ *  - step 9: check tlb8 is freed
+ *  - step 10: add a rule with same 24-bit prefix and depth = 28
+ *  - setp 11: check same tlb8 is allocated again
+ */
+int32_t
+test18(void)
+{
+#define group_idx next_hop
+	struct rte_lpm *lpm = NULL;
+	struct rte_lpm_config config;
+	uint32_t ip, next_hop;
+	uint8_t depth;
+	uint32_t tbl8_group_index;
+
+	config.max_rules = MAX_RULES;
+	config.number_tbl8s = NUMBER_TBL8S;
+	config.flags = 0;
+
+	lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
+	TEST_LPM_ASSERT(lpm != NULL);
+
+	ip = IPv4(192, 168, 100, 100);
+	depth = 28;
+	next_hop = 1;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	tbl8_group_index = lpm->tbl8[ip>>8].group_idx;
+
+	depth = 23;
+	next_hop = 2;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+
+	depth = 28;
+	rte_lpm_delete(lpm, ip, depth);
+
+	TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
+
+	next_hop = 3;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl8[ip>>8].group_idx);
+
+	depth = 24;
+	next_hop = 4;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+
+	depth = 28;
+	rte_lpm_delete(lpm, ip, depth);
+
+	TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
+
+	next_hop = 5;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl8[ip>>8].group_idx);
+
+	rte_lpm_free(lpm);
+#undef group_idx
+	return PASS;
+}
+
+/*
  * Do all unit tests.
  */
 
@@ -1230,7 +1308,7 @@ test_lpm(void)
 	for (i = 0; i < NUM_LPM_TESTS; i++) {
 		status = tests[i]();
 		if (status < 0) {
-			printf("ERROR: LPM Test %s: FAIL\n", RTE_STR(tests[i]));
+			printf("ERROR: LPM Test %u: FAIL\n", i);
 			global_status = status;
 		}
 	}
-- 
2.5.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v4 2/3] app/test: add a case to verify lpm tlb8 recycle
  2016-08-03  7:03 ` [dpdk-dev] [PATCH v3 2/3] " Wei Dai
@ 2016-08-08  6:40   ` Wei Dai
  2016-10-13 20:18     ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Dai @ 2016-08-08  6:40 UTC (permalink / raw)
  To: dev; +Cc: Wei Dai

As a bug-fix for lpm tlb8 recycle is introduced,
add a test case to verify tlb8 group is correctly
freed when it only includes a rule with depth=24.

Signed-off-by: Wei Dai <wei.dai@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test/test_lpm.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index b6ad2eb..ad12846 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -68,6 +68,7 @@ static int32_t test14(void);
 static int32_t test15(void);
 static int32_t test16(void);
 static int32_t test17(void);
+static int32_t test18(void);
 
 rte_lpm_test tests[] = {
 /* Test Cases */
@@ -89,6 +90,7 @@ rte_lpm_test tests[] = {
 	test15,
 	test16,
 	test17,
+	test18
 };
 
 #define NUM_LPM_TESTS (sizeof(tests)/sizeof(tests[0]))
@@ -1218,6 +1220,82 @@ test17(void)
 }
 
 /*
+ * Test for recycle of tlb8
+ *  - step 1: add a rule with depth=28 (> 24)
+ *  - step 2: add a rule with same 24-bit prefix and depth=23 (< 24)
+ *  - step 3: delete the first rule
+ *  - step 4: check tlb8 is freed
+ *  - step 5: add a rule same as the first one (depth=28)
+ *  - step 6: check same tlb8 is allocated
+ *  - step 7: add a rule with same 24-bit prefix and depth=24
+ *  - step 8: delete the rule (depth=28) added in step 5
+ *  - step 9: check tlb8 is freed
+ *  - step 10: add a rule with same 24-bit prefix and depth = 28
+ *  - setp 11: check same tlb8 is allocated again
+ */
+int32_t
+test18(void)
+{
+#define group_idx next_hop
+	struct rte_lpm *lpm = NULL;
+	struct rte_lpm_config config;
+	uint32_t ip, next_hop;
+	uint8_t depth;
+	uint32_t tbl8_group_index;
+
+	config.max_rules = MAX_RULES;
+	config.number_tbl8s = NUMBER_TBL8S;
+	config.flags = 0;
+
+	lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
+	TEST_LPM_ASSERT(lpm != NULL);
+
+	ip = IPv4(192, 168, 100, 100);
+	depth = 28;
+	next_hop = 1;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	tbl8_group_index = lpm->tbl8[ip>>8].group_idx;
+
+	depth = 23;
+	next_hop = 2;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+
+	depth = 28;
+	rte_lpm_delete(lpm, ip, depth);
+
+	TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
+
+	next_hop = 3;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl8[ip>>8].group_idx);
+
+	depth = 24;
+	next_hop = 4;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+
+	depth = 28;
+	rte_lpm_delete(lpm, ip, depth);
+
+	TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
+
+	next_hop = 5;
+	rte_lpm_add(lpm, ip, depth, next_hop);
+
+	TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
+	TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl8[ip>>8].group_idx);
+
+	rte_lpm_free(lpm);
+#undef group_idx
+	return PASS;
+}
+
+/*
  * Do all unit tests.
  */
 
@@ -1230,7 +1308,7 @@ test_lpm(void)
 	for (i = 0; i < NUM_LPM_TESTS; i++) {
 		status = tests[i]();
 		if (status < 0) {
-			printf("ERROR: LPM Test %s: FAIL\n", RTE_STR(tests[i]));
+			printf("ERROR: LPM Test %u: FAIL\n", i);
 			global_status = status;
 		}
 	}
-- 
2.5.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v4 2/3] app/test: add a case to verify lpm tlb8 recycle
  2016-08-08  6:40   ` [dpdk-dev] [PATCH v4 " Wei Dai
@ 2016-10-13 20:18     ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2016-10-13 20:18 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev

2016-08-08 14:40, Wei Dai:
> As a bug-fix for lpm tlb8 recycle is introduced,
> add a test case to verify tlb8 group is correctly
> freed when it only includes a rule with depth=24.
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Series applied with typo tlb/tbl fixed

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-10-13 20:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01  7:03 [dpdk-dev] [PATCH 2/2] app/test: add a case to verify lpm tlb8 recycle Wei Dai
2016-08-02 15:50 ` Bruce Richardson
2016-08-03  7:03 ` [dpdk-dev] [PATCH v3 2/3] " Wei Dai
2016-08-08  6:40   ` [dpdk-dev] [PATCH v4 " Wei Dai
2016-10-13 20:18     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).