diff mbox series

[v1,3/3] validation: classification: add test case for classifier enable boolean

Message ID 1502730005-8444-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v1,1/3] linux-generic: pktio: update classifier enable boolean | expand

Commit Message

Github ODP bot Aug. 14, 2017, 5 p.m. UTC
From: Balasubramanian Manoharan <bala.manoharan@linaro.org>


updates test suite to enable classifier in odp_pktin_queue_param_t config
adds test case for classifier enable boolean

Fixes https://bugs.linaro.org/show_bug.cgi?id=3177

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 126 (muvarov:monarch_lts)
 ** https://github.com/Linaro/odp/pull/126
 ** Patch: https://github.com/Linaro/odp/pull/126.patch
 ** Base sha: 759b6d5da6617af244765983d0b8bfbb26f41890
 ** Merge commit sha: 2c095e7e4fe1c0fc39b552b84d2374988f5920ca
 **/
 test/validation/classification/classification.h    |   1 +
 .../classification/odp_classification_basic.c      |   4 +-
 .../classification/odp_classification_common.c     |   5 +-
 .../classification/odp_classification_test_pmr.c   | 118 +++++++++++++++++++--
 .../classification/odp_classification_tests.c      |   2 +
 .../classification/odp_classification_testsuites.h |   3 +-
 6 files changed, 119 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h
index d73c8216..629484d0 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -77,6 +77,7 @@  void classification_test_pmr_term_udp_sport(void);
 void classification_test_pmr_term_ipproto(void);
 void classification_test_pmr_term_dmac(void);
 void classification_test_pmr_term_packet_len(void);
+void classification_test_pktin_classifier_flag(void);
 
 /* test arrays: */
 extern odp_testinfo_t classification_suite_basic[];
diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c
index 372377d8..9e83fc3d 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -89,7 +89,7 @@  void classification_test_create_pmr_match(void)
 	pkt_pool = pool_create("pkt_pool");
 	CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
 	configure_default_cos(pktio, &default_cos,
@@ -273,7 +273,7 @@  void classification_test_pmr_composite_create(void)
 	pkt_pool = pool_create("pkt_pool");
 	CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
 	configure_default_cos(pktio, &default_cos,
diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c
index 7a42ac74..e0012cdc 100644
--- a/test/validation/classification/odp_classification_common.c
+++ b/test/validation/classification/odp_classification_common.c
@@ -17,7 +17,8 @@  typedef struct cls_test_packet {
 	odp_u32be_t seq;
 } cls_test_packet_t;
 
-odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool)
+odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool,
+			 odp_bool_t cls_enable)
 {
 	odp_pktio_t pktio;
 	odp_pktio_param_t pktio_param;
@@ -43,6 +44,8 @@  odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool)
 
 	odp_pktin_queue_param_init(&pktin_param);
 	pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+	pktin_param.classifier_enable = cls_enable;
+	pktin_param.hash_enable = false;
 
 	if (odp_pktin_queue_config(pktio, &pktin_param)) {
 		fprintf(stderr, "pktin queue config failed.\n");
diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c
index 7c7d07ea..c9c0fe39 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -85,6 +85,102 @@  int classification_suite_pmr_term(void)
 	return retcode;
 }
 
+void classification_test_pktin_classifier_flag(void)
+{
+	odp_packet_t pkt;
+	odph_tcphdr_t *tcp;
+	uint32_t seqno;
+	uint16_t val;
+	uint16_t mask;
+	int retval;
+	odp_pktio_t pktio;
+	odp_queue_t queue;
+	odp_queue_t retqueue;
+	odp_queue_t default_queue;
+	odp_cos_t default_cos;
+	odp_pool_t default_pool;
+	odp_pmr_t pmr;
+	odp_cos_t cos;
+	char cosname[ODP_COS_NAME_LEN];
+	odp_cls_cos_param_t cls_param;
+	odp_pool_t pool;
+	odp_pool_t pool_recv;
+	odp_pmr_param_t pmr_param;
+	odph_ethhdr_t *eth;
+
+	val = CLS_DEFAULT_DPORT;
+	mask = 0xffff;
+	seqno = 0;
+
+	/* classifier is disabled in pktin queue configuration */
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, false);
+	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
+	retval = start_pktio(pktio);
+	CU_ASSERT(retval == 0);
+
+	configure_default_cos(pktio, &default_cos,
+			      &default_queue, &default_pool);
+
+	queue = queue_create("tcp_dport1", true);
+	CU_ASSERT(queue != ODP_QUEUE_INVALID);
+
+	pool = pool_create("tcp_dport1");
+	CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+	sprintf(cosname, "tcp_dport");
+	odp_cls_cos_param_init(&cls_param);
+	cls_param.pool = pool;
+	cls_param.queue = queue;
+	cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+	cos = odp_cls_cos_create(cosname, &cls_param);
+	CU_ASSERT(cos != ODP_COS_INVALID);
+
+	odp_cls_pmr_param_init(&pmr_param);
+	pmr_param.term = ODP_PMR_TCP_DPORT;
+	pmr_param.match.value = &val;
+	pmr_param.match.mask = &mask;
+	pmr_param.val_sz = sizeof(val);
+
+	pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
+	CU_ASSERT(pmr != ODP_PMR_INVAL);
+
+	pkt = create_packet(pkt_pool, false, &seq, true);
+	CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+	seqno = cls_pkt_get_seq(pkt);
+	CU_ASSERT(seqno != TEST_SEQ_INVALID);
+	eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
+	odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN);
+	odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN);
+
+	tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);
+	tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
+
+	enqueue_pktio_interface(pkt, pktio);
+
+	/* since classifier flag is disabled in pktin queue configuration
+	packet will not be delivered in classifier queues */
+	pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS);
+	CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+	pool_recv = odp_packet_pool(pkt);
+	/* since classifier is disabled packet should not be received in
+	pool and queue configured with classifier */
+	CU_ASSERT(pool != pool_recv);
+	CU_ASSERT(retqueue != queue);
+	CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
+
+	odp_packet_free(pkt);
+	odp_cos_destroy(cos);
+	odp_cos_destroy(default_cos);
+	odp_cls_pmr_destroy(pmr);
+	stop_pktio(pktio);
+	odp_queue_destroy(queue);
+	odp_queue_destroy(default_queue);
+	odp_pool_destroy(pool);
+	odp_pool_destroy(default_pool);
+	odp_pktio_close(pktio);
+}
+
 void classification_test_pmr_term_tcp_dport(void)
 {
 	odp_packet_t pkt;
@@ -113,7 +209,7 @@  void classification_test_pmr_term_tcp_dport(void)
 	mask = 0xffff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -227,7 +323,7 @@  void classification_test_pmr_term_tcp_sport(void)
 	mask = 0xffff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -339,7 +435,7 @@  void classification_test_pmr_term_udp_dport(void)
 	mask = 0xffff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -452,7 +548,7 @@  void classification_test_pmr_term_udp_sport(void)
 	mask = 0xffff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -563,7 +659,7 @@  void classification_test_pmr_term_ipproto(void)
 	mask = 0xff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -669,7 +765,7 @@  void classification_test_pmr_term_dmac(void)
 	mask = 0xffffffffffff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -772,7 +868,7 @@  void classification_test_pmr_term_packet_len(void)
 	mask = 0xff00;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -880,7 +976,7 @@  static void classification_test_pmr_pool_set(void)
 	mask = 0xff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -976,7 +1072,7 @@  static void classification_test_pmr_queue_set(void)
 	mask = 0xff;
 	seqno = 0;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
@@ -1068,7 +1164,8 @@  static void classification_test_pmr_term_daddr(void)
 	const char *dst_addr = "10.0.0.99/32";
 	odph_ethhdr_t *eth;
 
-	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool);
+	pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true);
+	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 	retval = start_pktio(pktio);
 	CU_ASSERT(retval == 0);
 
@@ -1159,5 +1256,6 @@  odp_testinfo_t classification_suite_pmr[] = {
 	ODP_TEST_INFO(classification_test_pmr_queue_set),
 	ODP_TEST_INFO(classification_test_pmr_term_daddr),
 	ODP_TEST_INFO(classification_test_pmr_term_packet_len),
+	ODP_TEST_INFO(classification_test_pktin_classifier_flag),
 	ODP_TEST_INFO_NULL,
 };
diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c
index ed45518b..85f422dc 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -49,6 +49,8 @@  int classification_suite_init(void)
 
 	odp_pktin_queue_param_init(&pktin_param);
 	pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+	pktin_param.classifier_enable = true;
+	pktin_param.hash_enable = false;
 
 	if (odp_pktin_queue_config(pktio_loop, &pktin_param)) {
 		fprintf(stderr, "pktin queue config failed.\n");
diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h
index aea3de1b..1f3e084b 100644
--- a/test/validation/classification/odp_classification_testsuites.h
+++ b/test/validation/classification/odp_classification_testsuites.h
@@ -28,7 +28,8 @@  odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
 			       uint16_t len);
 int cls_pkt_set_seq(odp_packet_t pkt);
 uint32_t cls_pkt_get_seq(odp_packet_t pkt);
-odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool);
+odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool,
+			 odp_bool_t cls_enable);
 void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos,
 			   odp_queue_t *queue, odp_pool_t *pool);
 int parse_ipv4_string(const char *ipaddress, uint32_t *addr, uint32_t *mask);