From patchwork Wed Feb 3 17:45:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 61115 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp445321lbl; Wed, 3 Feb 2016 09:57:15 -0800 (PST) X-Received: by 10.140.99.5 with SMTP id p5mr3180889qge.76.1454522235265; Wed, 03 Feb 2016 09:57:15 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p62si4795857qkl.67.2016.02.03.09.57.14; Wed, 03 Feb 2016 09:57:15 -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 CC0F261073; Wed, 3 Feb 2016 17:57:14 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=UIimBDKC; 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 6107961781; Wed, 3 Feb 2016 17:51:24 +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 7D8C4617E5; Wed, 3 Feb 2016 17:51:08 +0000 (UTC) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by lists.linaro.org (Postfix) with ESMTPS id 18A91617F0 for ; Wed, 3 Feb 2016 17:46:12 +0000 (UTC) Received: by mail-pa0-f45.google.com with SMTP id ho8so16880040pac.2 for ; Wed, 03 Feb 2016 09:46:12 -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=UIimBDKCTLBayX6Qxo9QNwy23CgWYDncyweoR5Vj4/rUkA/Q0sRqdT5U40zJPO+QO4 xwuuzQm/ateIm6kO8e0felcTgLOS02H5PcnVtK911rJUq10scijDi6Q4SHfDlZDKMqYj pGrK5a83lO8Y6ijGQtp5cQ0SSat1CgepwCDq4= 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=RbWd0AdZy7888skI0uiwU1iYFyvQB4nqCJDtIIZ9T6Xljs4N4o35L5xc0Dl9V2WImW gc2CHxM79F+Vk69vusXihl+XUzHc+PfVsAcBrS0QZWyZ1nzZDU+ygtTYmALL4THNJ+3t tucdzmLu3CADxPkQGyhQacruVGV8BTYFFYsPCFnlTl5t9t+VE7CevP6nBWgNjENfLxKF kd2VTVMLySQNZZNWK1+IELS7LfeUSd5wx7JNQFP4uc4Ow+dV59d777WN0bQwFl/tJHsB JwtGhAqc1ly2cBYv0/r428uuJkuJQWBtpnLKAWwEtVhdSLbw84MVPzu4MKBuXlpMik8R D/cQ== X-Gm-Message-State: AG10YOTdCEGdk5iGk3JV+l236wJWSvXk/QFGv+9AG/UvPTKTxLgcXF5PDpPjkNU2uFipm4FsMqg= X-Received: by 10.67.24.33 with SMTP id if1mr4093450pad.137.1454521571423; Wed, 03 Feb 2016 09:46:11 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id d65sm11237089pfb.74.2016.02.03.09.46.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Feb 2016 09:46:10 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Wed, 3 Feb 2016 23:15:49 +0530 Message-Id: <1454521550-21579-4-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454521550-21579-1-git-send-email-bala.manoharan@linaro.org> References: <1454521550-21579-1-git-send-email-bala.manoharan@linaro.org> X-Topics: Classification patch Subject: [lng-odp] [API-NEXT PATCHv5 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);