From patchwork Wed Feb 3 17:15:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 61111 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp435252lbl; Wed, 3 Feb 2016 09:37:54 -0800 (PST) X-Received: by 10.55.82.214 with SMTP id g205mr3149090qkb.72.1454521073903; Wed, 03 Feb 2016 09:37:53 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 7si6379814qhm.17.2016.02.03.09.37.53; Wed, 03 Feb 2016 09:37:53 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 649D7618DC; Wed, 3 Feb 2016 17:37:53 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=cPQhZeGk; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 9F806617A6; Wed, 3 Feb 2016 17:21:33 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id AE51D617A6; Wed, 3 Feb 2016 17:21:22 +0000 (UTC) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by lists.linaro.org (Postfix) with ESMTPS id 52312617D7 for ; Wed, 3 Feb 2016 17:15:56 +0000 (UTC) Received: by mail-pa0-f49.google.com with SMTP id ho8so16487451pac.2 for ; Wed, 03 Feb 2016 09:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iJPnMdJtD0zlpi5SMzxNfyE/2VQlZiKdesUVD/IINfg=; b=cPQhZeGkiYcFIy/jZGEVc6+J5n03+h3qULafPYE0DGpabZBXsjT3A2rrb1NTaRo9Pk R35jioYfRRUckM0InHei6dzwSCfMPClQBKdDZD26PwtpjRcEFWog4O8ERS3/EFAEI4s6 PwA5Jf/etfhNc5/m56+/ep8RtlOCvRJr20cWU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iJPnMdJtD0zlpi5SMzxNfyE/2VQlZiKdesUVD/IINfg=; b=Sb/cy1DXMIr8idMYXaBytnhnwJxzsisiq7Um014J44Yc2MYYnJZtFu8deuBzIb9dF4 ZYLW/fkoXQX7puwtVyOlJbKVLV8FdZqkGLXOUouAaHOA1QP4YR+jZzZe+sI3YTZykuMV R75LNM2Cx8wNKi8DDODtRi8m88u/+yBVpKFPQm2ajytR+XT/qA8l03EiNBzxgbmrSsr9 DD6GdvlgHpa5gazy7nXP7R1ZqbcginIBTv/vxpy5QNQm/AzsqfOOiJlPyqrrHdD0fVJ7 irSaNxTaRcBk+yD3RmFmIFZo7XUFIDzwXzz5bvotr4OmYS5hLLVWQyQtLIn9cdVlmaa4 v+IQ== X-Gm-Message-State: AG10YOQF+BrjhPNgbcUGHS1QVqec2ZQP9VXgJjpYw2/yE6g1Jd2YWDUSX/erKdnwfq2G7m4Uf6M= X-Received: by 10.66.227.133 with SMTP id sa5mr3969428pac.36.1454519755603; Wed, 03 Feb 2016 09:15:55 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id g81sm11226137pfj.1.2016.02.03.09.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Feb 2016 09:15:54 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Wed, 3 Feb 2016 22:45:26 +0530 Message-Id: <1454519727-31240-4-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454519727-31240-1-git-send-email-bala.manoharan@linaro.org> References: <1454519727-31240-1-git-send-email-bala.manoharan@linaro.org> X-Topics: Classification patch Subject: [lng-odp] [API-NEXT PATCHv4 3/4] validation: classification: adds validation suite for pmr create api X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Adds validation suite for packet match rule create functions. Signed-off-by: Balasubramanian Manoharan --- test/validation/classification/classification.h | 1 - .../classification/odp_classification_basic.c | 141 +++++++----- .../classification/odp_classification_common.c | 26 +++ .../classification/odp_classification_test_pmr.c | 240 ++++++++------------- .../classification/odp_classification_tests.c | 87 ++++---- .../classification/odp_classification_testsuites.h | 4 +- 6 files changed, 245 insertions(+), 254 deletions(-) diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h index 5508af7..c987cca 100644 --- a/test/validation/classification/classification.h +++ b/test/validation/classification/classification.h @@ -59,7 +59,6 @@ void classification_test_create_cos(void); void classification_test_destroy_cos(void); void classification_test_create_pmr_match(void); -void classification_test_destroy_pmr(void); void classification_test_cos_set_queue(void); void classification_test_cos_set_pool(void); void classification_test_cos_set_drop(void); diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c index 81077b6..1336955 100644 --- a/test/validation/classification/odp_classification_basic.c +++ b/test/validation/classification/odp_classification_basic.c @@ -74,28 +74,40 @@ void classification_test_create_pmr_match(void) odp_pmr_t pmr; uint16_t val; uint16_t mask; + int retval; odp_pmr_match_t match; + odp_cos_t default_cos; + odp_cos_t cos; + odp_queue_t default_queue; + odp_queue_t queue; + odp_pool_t default_pool; + odp_pool_t pool; + odp_pool_t pkt_pool; + odp_cls_cos_param_t cls_param; + odp_pktio_t pktio; - val = 1024; - mask = 0xffff; - match.term = find_first_supported_l3_pmr(); - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); + pkt_pool = pool_create("pkt_pool"); + CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID); - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL)); - odp_pmr_destroy(pmr); -} + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); -void classification_test_destroy_pmr(void) -{ - odp_pmr_t pmr; - uint16_t val; - uint16_t mask; - int retval; - odp_pmr_match_t match; + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + + queue = queue_create("pmr_match", true); + CU_ASSERT(queue != ODP_QUEUE_INVALID); + + pool = pool_create("pmr_match"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + 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("pmr_match", &cls_param); + CU_ASSERT(cos != ODP_COS_INVALID); val = 1024; mask = 0xffff; @@ -104,12 +116,25 @@ void classification_test_destroy_pmr(void) match.mask = &mask; match.val_sz = sizeof(val); - pmr = odp_pmr_create(&match); - retval = odp_pmr_destroy(pmr); + pmr = odp_cls_pmr_create(&match, 1, default_cos, cos); + CU_ASSERT(pmr != ODP_PMR_INVAL); + CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL)); + /* destroy the created PMR */ + retval = odp_cls_pmr_destroy(pmr); CU_ASSERT(retval == 0); - retval = odp_pmr_destroy(ODP_PMR_INVAL); - retval = odp_pmr_destroy(ODP_PMR_INVAL); + + /* destroy an INVALID PMR */ + retval = odp_cls_pmr_destroy(ODP_PMR_INVAL); CU_ASSERT(retval < 0); + + odp_queue_destroy(queue); + odp_pool_destroy(pool); + odp_pool_destroy(pkt_pool); + odp_cos_destroy(cos); + odp_queue_destroy(default_queue); + odp_pool_destroy(default_pool); + odp_cos_destroy(default_cos); + odp_pktio_close(pktio); } void classification_test_cos_set_queue(void) @@ -224,39 +249,44 @@ void classification_test_cos_set_drop(void) void classification_test_pmr_match_set_create(void) { - odp_pmr_set_t pmr_set; + odp_pmr_t pmr_set; int retval; odp_pmr_match_t pmr_terms[PMR_SET_NUM]; + odp_cos_t default_cos; + odp_cos_t cos; + odp_queue_t default_queue; + odp_queue_t queue; + odp_pool_t default_pool; + odp_pool_t pool; + odp_pool_t pkt_pool; + odp_cls_cos_param_t cls_param; + odp_pktio_t pktio; uint16_t val = 1024; uint16_t mask = 0xffff; int i; - for (i = 0; i < PMR_SET_NUM; i++) { - pmr_terms[i].term = ODP_PMR_TCP_DPORT; - pmr_terms[i].val = &val; - pmr_terms[i].mask = &mask; - pmr_terms[i].val_sz = sizeof(val); - } - retval = odp_pmr_match_set_create(PMR_SET_NUM, pmr_terms, &pmr_set); - CU_ASSERT(retval > 0); - CU_ASSERT(odp_pmr_set_to_u64(pmr_set) != - odp_pmr_set_to_u64(ODP_PMR_SET_INVAL)); + pkt_pool = pool_create("pkt_pool"); + CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID); - retval = odp_pmr_match_set_destroy(pmr_set); - CU_ASSERT(retval == 0); -} + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); -void classification_test_pmr_match_set_destroy(void) -{ - odp_pmr_set_t pmr_set; - int retval; - odp_pmr_match_t pmr_terms[PMR_SET_NUM]; - uint16_t val = 1024; - uint16_t mask = 0xffff; - int i; + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); - retval = odp_pmr_match_set_destroy(ODP_PMR_SET_INVAL); - CU_ASSERT(retval < 0); + queue = queue_create("pmr_match", true); + CU_ASSERT(queue != ODP_QUEUE_INVALID); + + pool = pool_create("pmr_match"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + 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("pmr_match", &cls_param); + CU_ASSERT(cos != ODP_COS_INVALID); for (i = 0; i < PMR_SET_NUM; i++) { pmr_terms[i].term = ODP_PMR_TCP_DPORT; @@ -265,22 +295,31 @@ void classification_test_pmr_match_set_destroy(void) pmr_terms[i].val_sz = sizeof(val); } - retval = odp_pmr_match_set_create(PMR_SET_NUM, pmr_terms, &pmr_set); - CU_ASSERT(retval > 0); + pmr_set = odp_cls_pmr_create(pmr_terms, PMR_SET_NUM, + default_cos, cos); + CU_ASSERT(odp_pmr_to_u64(pmr_set) != + odp_pmr_to_u64(ODP_PMR_INVAL)); - retval = odp_pmr_match_set_destroy(pmr_set); + retval = odp_cls_pmr_destroy(pmr_set); CU_ASSERT(retval == 0); + + odp_queue_destroy(queue); + odp_pool_destroy(pool); + odp_pool_destroy(pkt_pool); + odp_cos_destroy(cos); + odp_queue_destroy(default_queue); + odp_pool_destroy(default_pool); + odp_cos_destroy(default_cos); + odp_pktio_close(pktio); } odp_testinfo_t classification_suite_basic[] = { ODP_TEST_INFO(classification_test_create_cos), ODP_TEST_INFO(classification_test_destroy_cos), ODP_TEST_INFO(classification_test_create_pmr_match), - ODP_TEST_INFO(classification_test_destroy_pmr), ODP_TEST_INFO(classification_test_cos_set_queue), ODP_TEST_INFO(classification_test_cos_set_drop), ODP_TEST_INFO(classification_test_cos_set_pool), ODP_TEST_INFO(classification_test_pmr_match_set_create), - ODP_TEST_INFO(classification_test_pmr_match_set_destroy), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index 54ce594..d18953d 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -17,6 +17,32 @@ 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 pktio; + odp_pktio_param_t pktio_param; + int ret; + + if (pool == ODP_POOL_INVALID) + return ODP_PKTIO_INVALID; + + odp_pktio_param_init(&pktio_param); + if (q_type == ODP_QUEUE_TYPE_PLAIN) + pktio_param.in_mode = ODP_PKTIN_MODE_QUEUE; + else + pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; + + pktio = odp_pktio_open("loop", pool, &pktio_param); + if (pktio == ODP_PKTIO_INVALID) { + ret = odp_pool_destroy(pool); + if (ret) + fprintf(stderr, "unable to destroy pool.\n"); + return ODP_PKTIO_INVALID; + } + + return pktio; +} + int destroy_inq(odp_pktio_t pktio) { odp_queue_t inq; diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c index 5f516a7..a00f496 100644 --- a/test/validation/classification/odp_classification_test_pmr.c +++ b/test/validation/classification/odp_classification_test_pmr.c @@ -29,33 +29,6 @@ int classification_suite_pmr_init(void) return 0; } -odp_pktio_t create_pktio(odp_queue_type_t q_type) -{ - odp_pktio_t pktio; - odp_pktio_param_t pktio_param; - int ret; - - if (pkt_pool == ODP_POOL_INVALID) - return ODP_PKTIO_INVALID; - - odp_pktio_param_init(&pktio_param); - - if (q_type == ODP_QUEUE_TYPE_PLAIN) - pktio_param.in_mode = ODP_PKTIN_MODE_QUEUE; - else - pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; - - pktio = odp_pktio_open("loop", pkt_pool, &pktio_param); - if (pktio == ODP_PKTIO_INVALID) { - ret = odp_pool_destroy(pkt_pool); - if (ret) - fprintf(stderr, "unable to destroy pool.\n"); - return ODP_PKTIO_INVALID; - } - - return pktio; -} - int create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype ODP_UNUSED) { odp_queue_param_t qparam; @@ -161,7 +134,7 @@ void classification_test_pmr_term_tcp_dport(void) mask = 0xffff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -169,15 +142,6 @@ void classification_test_pmr_term_tcp_dport(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_TCP_DPORT; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - - queue = queue_create("tcp_dport1", true); CU_ASSERT(queue != ODP_QUEUE_INVALID); @@ -193,8 +157,13 @@ void classification_test_pmr_term_tcp_dport(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_TCP_DPORT; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 1, default_cos, cos); + CU_ASSERT(pmr != ODP_PMR_INVAL); pkt = create_packet(pkt_pool, false, &seq, false); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); @@ -242,7 +211,7 @@ void classification_test_pmr_term_tcp_dport(void) odp_packet_free(pkt); odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); destroy_inq(pktio); odp_queue_destroy(queue); odp_queue_destroy(default_queue); @@ -278,7 +247,7 @@ void classification_test_pmr_term_tcp_sport(void) mask = 0xffff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -286,14 +255,6 @@ void classification_test_pmr_term_tcp_sport(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_TCP_SPORT; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("tcp_sport", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -309,8 +270,13 @@ void classification_test_pmr_term_tcp_sport(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_TCP_SPORT; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 1, default_cos, cos); + CU_ASSERT(pmr != ODP_PMR_INVAL); pkt = create_packet(pkt_pool, false, &seq, false); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); @@ -356,7 +322,7 @@ void classification_test_pmr_term_tcp_sport(void) odp_packet_free(pkt); odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); destroy_inq(pktio); odp_pool_destroy(default_pool); odp_pool_destroy(pool); @@ -392,7 +358,7 @@ void classification_test_pmr_term_udp_dport(void) mask = 0xffff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -400,14 +366,6 @@ void classification_test_pmr_term_udp_dport(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_UDP_DPORT; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("udp_dport", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -423,8 +381,13 @@ void classification_test_pmr_term_udp_dport(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_UDP_DPORT; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 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); @@ -471,7 +434,7 @@ void classification_test_pmr_term_udp_dport(void) odp_packet_free(pkt); odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); destroy_inq(pktio); odp_queue_destroy(queue); odp_queue_destroy(default_queue); @@ -507,7 +470,7 @@ void classification_test_pmr_term_udp_sport(void) mask = 0xffff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -515,14 +478,6 @@ void classification_test_pmr_term_udp_sport(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_UDP_SPORT; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("udp_sport", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -538,8 +493,13 @@ void classification_test_pmr_term_udp_sport(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_UDP_SPORT; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 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); @@ -585,7 +545,7 @@ void classification_test_pmr_term_udp_sport(void) odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); destroy_inq(pktio); odp_pool_destroy(default_pool); odp_pool_destroy(pool); @@ -620,7 +580,7 @@ void classification_test_pmr_term_ipproto(void) mask = 0xff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -628,14 +588,6 @@ void classification_test_pmr_term_ipproto(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_IPPROTO; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("ipproto", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -651,8 +603,13 @@ void classification_test_pmr_term_ipproto(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_IPPROTO; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 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); @@ -692,7 +649,7 @@ void classification_test_pmr_term_ipproto(void) odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); odp_packet_free(pkt); destroy_inq(pktio); odp_pool_destroy(default_pool); @@ -728,7 +685,7 @@ void classification_test_pmr_term_dmac(void) mask = 0xffffffffffff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -736,14 +693,6 @@ void classification_test_pmr_term_dmac(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_DMAC; - match.val = &val; - match.mask = &mask; - match.val_sz = ODPH_ETHADDR_LEN; - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("dmac", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -759,8 +708,13 @@ void classification_test_pmr_term_dmac(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_DMAC; + match.val = &val; + match.mask = &mask; + match.val_sz = ODPH_ETHADDR_LEN; + + pmr = odp_cls_pmr_create(&match, 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); @@ -796,7 +750,7 @@ void classification_test_pmr_term_dmac(void) odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); odp_packet_free(pkt); destroy_inq(pktio); odp_pool_destroy(default_pool); @@ -833,7 +787,7 @@ void classification_test_pmr_term_packet_len(void) mask = 0xff00; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -841,14 +795,6 @@ void classification_test_pmr_term_packet_len(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_LEN; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("packet_len", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -864,8 +810,13 @@ void classification_test_pmr_term_packet_len(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_LEN; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 1, default_cos, cos); + CU_ASSERT(pmr != ODP_PMR_INVAL); /* create packet of payload length 1024 */ pkt = create_packet_len(pkt_pool, false, &seq, true, 1024); @@ -906,7 +857,7 @@ void classification_test_pmr_term_packet_len(void) odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); odp_packet_free(pkt); destroy_inq(pktio); odp_pool_destroy(default_pool); @@ -943,7 +894,7 @@ static void classification_test_pmr_pool_set(void) mask = 0xff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -951,14 +902,6 @@ static void classification_test_pmr_pool_set(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_IPPROTO; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("ipproto1", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -981,8 +924,13 @@ static void classification_test_pmr_pool_set(void) retval = odp_cls_cos_pool_set(cos, pool_new); CU_ASSERT(retval == 0); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_IPPROTO; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 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); @@ -1004,7 +952,7 @@ static void classification_test_pmr_pool_set(void) odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); destroy_inq(pktio); odp_pool_destroy(default_pool); odp_pool_destroy(pool); @@ -1041,7 +989,7 @@ static void classification_test_pmr_queue_set(void) mask = 0xff; seqno = 0; - pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); @@ -1049,14 +997,6 @@ static void classification_test_pmr_queue_set(void) configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - match.term = ODP_PMR_IPPROTO; - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr = odp_pmr_create(&match); - CU_ASSERT(pmr != ODP_PMR_INVAL); - queue = queue_create("ipproto1", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -1079,8 +1019,13 @@ static void classification_test_pmr_queue_set(void) retval = odp_cos_queue_set(cos, queue_new); CU_ASSERT(retval == 0); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + match.term = ODP_PMR_IPPROTO; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&match, 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); @@ -1102,7 +1047,7 @@ static void classification_test_pmr_queue_set(void) odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); destroy_inq(pktio); odp_pool_destroy(default_pool); odp_pool_destroy(pool); @@ -1135,22 +1080,13 @@ 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); + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); configure_default_cos(pktio, &default_cos, &default_queue, &default_pool); - parse_ipv4_string(dst_addr, &addr, &mask); - match.term = ODP_PMR_DIP_ADDR; - match.val = &addr; - match.mask = &mask; - match.val_sz = sizeof(addr); - - pmr = odp_pmr_create(&match); - CU_ASSERT_FATAL(pmr != ODP_PMR_INVAL); - queue = queue_create("daddr", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); @@ -1166,8 +1102,14 @@ static void classification_test_pmr_term_daddr(void) cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr, pktio, cos); - CU_ASSERT(retval == 0); + parse_ipv4_string(dst_addr, &addr, &mask); + match.term = ODP_PMR_DIP_ADDR; + match.val = &addr; + match.mask = &mask; + match.val_sz = sizeof(addr); + + pmr = odp_cls_pmr_create(&match, 1, default_cos, cos); + CU_ASSERT_FATAL(pmr != ODP_PMR_INVAL); /* packet with dst ip address matching PMR rule to be received in the CoS queue*/ @@ -1207,7 +1149,7 @@ static void classification_test_pmr_term_daddr(void) odp_cos_destroy(cos); odp_cos_destroy(default_cos); - odp_pmr_destroy(pmr); + odp_cls_pmr_destroy(pmr); odp_packet_free(pkt); destroy_inq(pktio); odp_pool_destroy(default_pool); diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index a194259..f04e910 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -16,7 +16,6 @@ static odp_cos_t cos_list[CLS_ENTRIES]; static odp_pmr_t pmr_list[CLS_ENTRIES]; static odp_queue_t queue_list[CLS_ENTRIES]; static odp_pool_t pool_list[CLS_ENTRIES]; -static odp_pmr_set_t pmr_set; static odp_pool_t pool_default; static odp_pktio_t pktio_loop; @@ -107,7 +106,7 @@ int classification_suite_term(void) odp_cos_destroy(cos_list[i]); for (i = 0; i < CLS_ENTRIES; i++) - odp_pmr_destroy(pmr_list[i]); + odp_cls_pmr_destroy(pmr_list[i]); for (i = 0; i < CLS_ENTRIES; i++) odp_queue_destroy(queue_list[i]); @@ -128,7 +127,6 @@ void configure_cls_pmr_chain(void) uint16_t val; uint16_t maskport; - int retval; char cosname[ODP_QUEUE_NAME_LEN]; odp_queue_param_t qparam; odp_cls_cos_param_t cls_param; @@ -191,7 +189,9 @@ void configure_cls_pmr_chain(void) match.val = &addr; match.mask = &mask; match.val_sz = sizeof(addr); - pmr_list[CLS_PMR_CHAIN_SRC] = odp_pmr_create(&match); + pmr_list[CLS_PMR_CHAIN_SRC] = + odp_cls_pmr_create(&match, 1, cos_list[CLS_DEFAULT], + cos_list[CLS_PMR_CHAIN_SRC]); CU_ASSERT_FATAL(pmr_list[CLS_PMR_CHAIN_SRC] != ODP_PMR_INVAL); val = CLS_PMR_CHAIN_PORT; @@ -200,17 +200,10 @@ void configure_cls_pmr_chain(void) match.val = &val; match.mask = &maskport; match.val_sz = sizeof(val); - pmr_list[CLS_PMR_CHAIN_DST] = odp_pmr_create(&match); + pmr_list[CLS_PMR_CHAIN_DST] = + odp_cls_pmr_create(&match, 1, cos_list[CLS_PMR_CHAIN_SRC], + cos_list[CLS_PMR_CHAIN_DST]); CU_ASSERT_FATAL(pmr_list[CLS_PMR_CHAIN_DST] != ODP_PMR_INVAL); - - retval = odp_pktio_pmr_cos(pmr_list[CLS_PMR_CHAIN_SRC], pktio_loop, - cos_list[CLS_PMR_CHAIN_SRC]); - CU_ASSERT(retval == 0); - - retval = odp_cos_pmr_cos(pmr_list[CLS_PMR_CHAIN_DST], - cos_list[CLS_PMR_CHAIN_SRC], - cos_list[CLS_PMR_CHAIN_DST]); - CU_ASSERT(retval == 0); } void test_cls_pmr_chain(void) @@ -501,7 +494,6 @@ void configure_pmr_cos(void) { uint16_t val; uint16_t mask; - int retval; odp_pmr_match_t match; odp_queue_param_t qparam; odp_cls_cos_param_t cls_param; @@ -509,16 +501,6 @@ void configure_pmr_cos(void) char queuename[ODP_QUEUE_NAME_LEN]; char poolname[ODP_POOL_NAME_LEN]; - val = CLS_PMR_PORT; - mask = 0xffff; - match.term = find_first_supported_l3_pmr(); - match.val = &val; - match.mask = &mask; - match.val_sz = sizeof(val); - - pmr_list[CLS_PMR] = odp_pmr_create(&match); - CU_ASSERT_FATAL(pmr_list[CLS_PMR] != ODP_PMR_INVAL); - odp_queue_param_init(&qparam); qparam.type = ODP_QUEUE_TYPE_SCHED; qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; @@ -541,9 +523,16 @@ void configure_pmr_cos(void) cos_list[CLS_PMR] = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos_list[CLS_PMR] != ODP_COS_INVALID); - retval = odp_pktio_pmr_cos(pmr_list[CLS_PMR], pktio_loop, - cos_list[CLS_PMR]); - CU_ASSERT(retval == 0); + val = CLS_PMR_PORT; + mask = 0xffff; + match.term = find_first_supported_l3_pmr(); + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr_list[CLS_PMR] = odp_cls_pmr_create(&match, 1, cos_list[CLS_DEFAULT], + cos_list[CLS_PMR]); + CU_ASSERT_FATAL(pmr_list[CLS_PMR] != ODP_PMR_INVAL); } void test_pmr_cos(void) @@ -568,9 +557,8 @@ void test_pmr_cos(void) odp_packet_free(pkt); } -void configure_pktio_pmr_match_set_cos(void) +void configure_pktio_pmr_composite(void) { - int retval; odp_pmr_match_t pmr_terms[2]; uint16_t val; uint16_t maskport; @@ -583,23 +571,6 @@ void configure_pktio_pmr_match_set_cos(void) uint32_t addr = 0; uint32_t mask; - parse_ipv4_string(CLS_PMR_SET_SADDR, &addr, &mask); - pmr_terms[0].term = ODP_PMR_SIP_ADDR; - pmr_terms[0].val = &addr; - pmr_terms[0].mask = &mask; - pmr_terms[0].val_sz = sizeof(addr); - - - val = CLS_PMR_SET_PORT; - maskport = 0xffff; - pmr_terms[1].term = find_first_supported_l3_pmr(); - pmr_terms[1].val = &val; - pmr_terms[1].mask = &maskport; - pmr_terms[1].val_sz = sizeof(val); - - retval = odp_pmr_match_set_create(num_terms, pmr_terms, &pmr_set); - CU_ASSERT(retval > 0); - odp_queue_param_init(&qparam); qparam.type = ODP_QUEUE_TYPE_SCHED; qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; @@ -622,9 +593,23 @@ void configure_pktio_pmr_match_set_cos(void) cos_list[CLS_PMR_SET] = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos_list[CLS_PMR_SET] != ODP_COS_INVALID); - retval = odp_pktio_pmr_match_set_cos(pmr_set, pktio_loop, - cos_list[CLS_PMR_SET]); - CU_ASSERT(retval == 0); + parse_ipv4_string(CLS_PMR_SET_SADDR, &addr, &mask); + pmr_terms[0].term = ODP_PMR_SIP_ADDR; + pmr_terms[0].val = &addr; + pmr_terms[0].mask = &mask; + pmr_terms[0].val_sz = sizeof(addr); + + val = CLS_PMR_SET_PORT; + maskport = 0xffff; + pmr_terms[1].term = find_first_supported_l3_pmr(); + pmr_terms[1].val = &val; + pmr_terms[1].mask = &maskport; + pmr_terms[1].val_sz = sizeof(val); + + pmr_list[CLS_PMR_SET] = odp_cls_pmr_create(pmr_terms, num_terms, + cos_list[CLS_DEFAULT], + cos_list[CLS_PMR_SET]); + CU_ASSERT_FATAL(pmr_list[CLS_PMR_SET] != ODP_PMR_INVAL); } void test_pktio_pmr_match_set_cos(void) @@ -690,7 +675,7 @@ void classification_test_pktio_configure(void) if (TEST_PMR) configure_pmr_cos(); if (TEST_PMR_SET) - configure_pktio_pmr_match_set_cos(); + configure_pktio_pmr_composite(); } void classification_test_pktio_test(void) diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index 19d5ae2..851f0a3 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -27,7 +27,7 @@ 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_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool); int create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype); void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos, odp_queue_t *queue, odp_pool_t *pool); @@ -46,7 +46,7 @@ void configure_cos_with_l2_priority(void); void test_cos_with_l2_priority(void); void configure_pmr_cos(void); void test_pmr_cos(void); -void configure_pktio_pmr_match_set_cos(void); +void configure_pktio_pmr_composite(void); void test_pktio_pmr_match_set_cos(void); int destroy_inq(odp_pktio_t pktio); odp_pmr_term_t find_first_supported_l3_pmr(void);