From patchwork Thu Dec 3 10:46:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 57632 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3415974lbb; Thu, 3 Dec 2015 02:47:12 -0800 (PST) X-Received: by 10.55.72.143 with SMTP id v137mr9754825qka.73.1449139632634; Thu, 03 Dec 2015 02:47:12 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f31si6428605qga.43.2015.12.03.02.47.12; Thu, 03 Dec 2015 02:47:12 -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.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 3DDE362C8E; Thu, 3 Dec 2015 10:47:12 +0000 (UTC) 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_H2,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 5109462C0E; Thu, 3 Dec 2015 10:46:57 +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 03AF362C6B; Thu, 3 Dec 2015 10:46:53 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by lists.linaro.org (Postfix) with ESMTPS id 3E02A62BF3 for ; Thu, 3 Dec 2015 10:46:23 +0000 (UTC) Received: by pfdd184 with SMTP id d184so7253592pfd.3 for ; Thu, 03 Dec 2015 02:46:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rOU2sVHR/WUiKEzFniMpYyVf+gIXJ427Hmny3JLiogk=; b=Q5Ke+9aM7st04eqCk5bHJJhhRhNAAXsdCfTLKmGjWT/t6nRfUXC0ZwaDdhX1B9RtTx IbS7pM5HzT5e93UabC4UeeB/zOmk33SQynikIavY6jOzO9fbKw8nvVOcIeyILQ1MUu8q gOyXgHzyjYsMkb8vhYAocTIB6CZ7FLRCh74H0qmua8pR66zH+tMm8aF/3wSQ1CzKWac3 flByruhPcnOqMXLb9Uf5Rz4N4d+/sQIchO+di+DcFPJPAjkYoU12mgUs4wrRnmLpimnI w8PZ+N/7R2PxZvtYPiPlLn4NR9I7kk/SXLoluqluMwU0NPAiv3MzTBIEfKkSpEtXLyUU KuGA== 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=rOU2sVHR/WUiKEzFniMpYyVf+gIXJ427Hmny3JLiogk=; b=Wy3uiNr/rSenb+YFdtGwesGjBgqDcY5n33GmGiK7TxokYfZXIaVA+pQA1r70Ep8L28 vKztbi/QLtFG26yOJmrfWELoYPMQTJo2NauKmBJbUChy6ruxj/pl+KeqwXAJwG+NDPEY J6VJIWxpHS+casMR2cpNLUGs8eiXtoFCNETbzWPpL93O7NS4WgbeQLZupoequjngI4A8 UFVfYZeVM1tr9JVo7UKZT4jU1HZ8tBGkCCAvdd0eIHc5+Mk5yM1c1qneaNR+O8/UcZMm EDBTNcieDC1O8gKbdVmBRA+cjgxHJjG80BQptypnM/KypaLbIdvFDsUKX2HNkVPg9+yH ihUQ== X-Gm-Message-State: ALoCoQntt3RVSw6O/dBqfm7Jxbm4xjZ0b6LF4JIU1KMr9/Sw8zHWq1IOrIG1unAFfY3u4028dPZ7 X-Received: by 10.98.11.133 with SMTP id 5mr12085149pfl.26.1449139582527; Thu, 03 Dec 2015 02:46:22 -0800 (PST) Received: from bala-Vostro-2520.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id 68sm9908068pfq.37.2015.12.03.02.46.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Dec 2015 02:46:22 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 3 Dec 2015 16:16:05 +0530 Message-Id: <1449139566-1196-3-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449139566-1196-1-git-send-email-bala.manoharan@linaro.org> References: <1449139566-1196-1-git-send-email-bala.manoharan@linaro.org> X-Topics: Classification patch Subject: [lng-odp] [API-NEXT/PATCHv4 3/4] validation: classification: add odp_cls_cos_pool_set() 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" Assigns a packet pool to CoS using odp_cls_cos_pool_set() api. Signed-off-by: Balasubramanian Manoharan --- .../classification/odp_classification_test_pmr.c | 279 +++++++++++++++++---- .../classification/odp_classification_tests.c | 139 ++++++++++ .../classification/odp_classification_testsuites.h | 4 +- 3 files changed, 379 insertions(+), 43 deletions(-) diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c index 3f49d4c..2fa524d 100644 --- a/test/validation/classification/odp_classification_test_pmr.c +++ b/test/validation/classification/odp_classification_test_pmr.c @@ -12,7 +12,7 @@ #include #include -static odp_pool_t pool_default; +static odp_pool_t pkt_pool; /** sequence number of IP packets */ odp_atomic_u32_t seq; @@ -27,8 +27,8 @@ int classification_suite_pmr_init(void) param.pkt.num = SHM_PKT_NUM_BUFS; param.type = ODP_POOL_PACKET; - pool_default = odp_pool_create("classification_pmr_pool", ¶m); - if (ODP_POOL_INVALID == pool_default) { + pkt_pool = odp_pool_create("classification_pmr_pool", ¶m); + if (ODP_POOL_INVALID == pkt_pool) { fprintf(stderr, "Packet pool creation failed.\n"); return -1; } @@ -43,7 +43,7 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type) odp_pktio_param_t pktio_param; int ret; - if (pool_default == ODP_POOL_INVALID) + if (pkt_pool == ODP_POOL_INVALID) return ODP_PKTIO_INVALID; odp_pktio_param_init(&pktio_param); @@ -52,9 +52,9 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type) else pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; - pktio = odp_pktio_open("loop", pool_default, &pktio_param); + pktio = odp_pktio_open("loop", pkt_pool, &pktio_param); if (pktio == ODP_PKTIO_INVALID) { - ret = odp_pool_destroy(pool_default); + ret = odp_pool_destroy(pkt_pool); if (ret) fprintf(stderr, "unable to destroy pool.\n"); return ODP_PKTIO_INVALID; @@ -69,7 +69,7 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type) return pktio; } -odp_queue_t create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype) +int create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype) { odp_queue_param_t qparam; odp_queue_t inq_def; @@ -92,17 +92,62 @@ odp_queue_t create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype) CU_ASSERT(inq_def != ODP_QUEUE_INVALID); if (0 > odp_pktio_inq_setdef(pktio, inq_def)) - return ODP_QUEUE_INVALID; + return -1; + + return 0; +} + +void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos, + odp_queue_t *queue, odp_pool_t *pool) +{ + odp_pool_param_t pool_param; + odp_pool_t default_pool; + odp_cos_t default_cos; + odp_queue_t default_queue; + int retval; + char cosname[ODP_COS_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; + char queuename[ODP_QUEUE_NAME_LEN]; + + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "DefaultPool"); + + default_pool = odp_pool_create(poolname, &pool_param); + CU_ASSERT(default_pool != ODP_POOL_INVALID); + + sprintf(queuename, "DefaultQueue"); + default_queue = queue_create(queuename, true); + CU_ASSERT(default_queue != ODP_QUEUE_INVALID); - return inq_def; + sprintf(cosname, "DefaultCos"); + default_cos = odp_cos_create(cosname); + CU_ASSERT(default_cos != ODP_COS_INVALID); + + retval = odp_cos_queue_set(default_cos, default_queue); + CU_ASSERT(retval == 0); + + retval = odp_cls_cos_pool_set(default_cos, default_pool); + CU_ASSERT(retval == 0); + + retval = odp_pktio_default_cos_set(pktio, default_cos); + CU_ASSERT(retval == 0); + + *cos = default_cos; + *queue = default_queue; + *pool = default_pool; + return; } int classification_suite_pmr_term(void) { int retcode = 0; - if (0 != odp_pool_destroy(pool_default)) { - fprintf(stderr, "pool_default destroy failed.\n"); + if (0 != odp_pool_destroy(pkt_pool)) { + fprintf(stderr, "pkt_pool destroy failed.\n"); retcode = -1; } @@ -120,11 +165,18 @@ static void classification_test_pmr_term_tcp_dport(void) odp_pktio_t pktio; odp_queue_t queue; odp_queue_t retqueue; - odp_queue_t defqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_t recvpool; odp_pmr_t pmr; odp_cos_t cos; - char cosname[ODP_QUEUE_NAME_LEN]; + char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; + odp_pool_param_t pool_param; + odp_pool_t pool; + odp_pool_t pool_recv; odp_pmr_match_t match; val = CLS_DEFAULT_DPORT; @@ -133,8 +185,8 @@ static void classification_test_pmr_term_tcp_dport(void) pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); CU_ASSERT(pktio != ODP_PKTIO_INVALID); - defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); - CU_ASSERT(defqueue != ODP_QUEUE_INVALID); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); match.term = ODP_PMR_TCP_DPORT; match.val = &val; @@ -153,13 +205,28 @@ static void classification_test_pmr_term_tcp_dport(void) queue = queue_create(queuename, true); CU_ASSERT(queue != ODP_QUEUE_INVALID); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "tcp_dport1"); + + pool = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos, pool); + CU_ASSERT(retval == 0); + retval = odp_cos_queue_set(cos, queue); CU_ASSERT(retval == 0); retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); - pkt = create_packet(pool_default, false, &seq, false); + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, false); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -170,13 +237,15 @@ static void classification_test_pmr_term_tcp_dport(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); + pool_recv = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_recv); CU_ASSERT(retqueue == queue); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); odp_packet_free(pkt); /* Other packets are delivered to default queue */ - pkt = create_packet(pool_default, false, &seq, false); + pkt = create_packet(pkt_pool, false, &seq, false); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -188,13 +257,19 @@ static void classification_test_pmr_term_tcp_dport(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); - CU_ASSERT(retqueue == defqueue); + CU_ASSERT(retqueue == default_queue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); odp_packet_free(pkt); odp_cos_destroy(cos); + odp_cos_destroy(default_cos); odp_pmr_destroy(pmr); destroy_inq(pktio); odp_queue_destroy(queue); + odp_queue_destroy(default_queue); + odp_pool_destroy(pool); + odp_pool_destroy(default_pool); odp_pktio_close(pktio); } @@ -209,10 +284,16 @@ static void classification_test_pmr_term_tcp_sport(void) odp_pktio_t pktio; odp_queue_t queue; odp_queue_t retqueue; - odp_queue_t defqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_param_t pool_param; + odp_pool_t pool; + odp_pool_t recvpool; odp_pmr_t pmr; odp_cos_t cos; - char cosname[ODP_QUEUE_NAME_LEN]; + char cosname[ODP_COS_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; odp_pmr_match_t match; @@ -221,7 +302,8 @@ static void classification_test_pmr_term_tcp_sport(void) seqno = 0; pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); - defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); match.term = ODP_PMR_TCP_SPORT; match.val = &val; @@ -240,13 +322,28 @@ static void classification_test_pmr_term_tcp_sport(void) queue = queue_create(queuename, true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "tcp_sport"); + + pool = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos, pool); + CU_ASSERT(retval == 0); + retval = odp_cos_queue_set(cos, queue); CU_ASSERT(retval == 0); retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); - pkt = create_packet(pool_default, false, &seq, false); + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, false); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -259,9 +356,11 @@ static void classification_test_pmr_term_tcp_sport(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); CU_ASSERT(retqueue == queue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); odp_packet_free(pkt); - pkt = create_packet(pool_default, false, &seq, false); + pkt = create_packet(pkt_pool, false, &seq, false); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -273,13 +372,19 @@ static void classification_test_pmr_term_tcp_sport(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); - CU_ASSERT(retqueue == defqueue); + CU_ASSERT(retqueue == default_queue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); odp_packet_free(pkt); odp_cos_destroy(cos); + odp_cos_destroy(default_cos); odp_pmr_destroy(pmr); destroy_inq(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); odp_queue_destroy(queue); + odp_queue_destroy(default_queue); odp_pktio_close(pktio); } @@ -292,12 +397,18 @@ static void classification_test_pmr_term_udp_dport(void) uint16_t mask; int retval; odp_pktio_t pktio; + odp_pool_t pool; + odp_pool_t recvpool; odp_queue_t queue; odp_queue_t retqueue; - odp_queue_t defqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_param_t pool_param; odp_pmr_t pmr; odp_cos_t cos; - char cosname[ODP_QUEUE_NAME_LEN]; + char cosname[ODP_COS_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; odp_pmr_match_t match; @@ -306,7 +417,8 @@ static void classification_test_pmr_term_udp_dport(void) seqno = 0; pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); - defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); match.term = ODP_PMR_UDP_DPORT; match.val = &val; @@ -328,10 +440,25 @@ static void classification_test_pmr_term_udp_dport(void) retval = odp_cos_queue_set(cos, queue); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "udp_dport"); + + pool = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos, pool); + CU_ASSERT(retval == 0); + retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); - pkt = create_packet(pool_default, false, &seq, true); + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, true); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -344,10 +471,12 @@ static void classification_test_pmr_term_udp_dport(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); CU_ASSERT(retqueue == queue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); odp_packet_free(pkt); /* Other packets received in default queue */ - pkt = create_packet(pool_default, false, &seq, true); + pkt = create_packet(pkt_pool, false, &seq, true); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -359,13 +488,19 @@ static void classification_test_pmr_term_udp_dport(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); - CU_ASSERT(retqueue == defqueue); + CU_ASSERT(retqueue == default_queue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); odp_packet_free(pkt); odp_cos_destroy(cos); + odp_cos_destroy(default_cos); odp_pmr_destroy(pmr); destroy_inq(pktio); odp_queue_destroy(queue); + odp_queue_destroy(default_queue); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); odp_pktio_close(pktio); } @@ -380,10 +515,16 @@ static void classification_test_pmr_term_udp_sport(void) odp_pktio_t pktio; odp_queue_t queue; odp_queue_t retqueue; - odp_queue_t defqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_param_t pool_param; + odp_pool_t pool; + odp_pool_t recvpool; odp_pmr_t pmr; odp_cos_t cos; - char cosname[ODP_QUEUE_NAME_LEN]; + char cosname[ODP_COS_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; odp_pmr_match_t match; @@ -392,7 +533,8 @@ static void classification_test_pmr_term_udp_sport(void) seqno = 0; pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); - defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); match.term = ODP_PMR_UDP_SPORT; match.val = &val; @@ -414,10 +556,25 @@ static void classification_test_pmr_term_udp_sport(void) retval = odp_cos_queue_set(cos, queue); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "udp_sport"); + + pool = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos, pool); + CU_ASSERT(retval == 0); + retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); - pkt = create_packet(pool_default, false, &seq, true); + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, true); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -430,9 +587,11 @@ static void classification_test_pmr_term_udp_sport(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); CU_ASSERT(retqueue == queue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); odp_packet_free(pkt); - pkt = create_packet(pool_default, false, &seq, true); + pkt = create_packet(pkt_pool, false, &seq, true); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -444,13 +603,19 @@ static void classification_test_pmr_term_udp_sport(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); - CU_ASSERT(retqueue == defqueue); + CU_ASSERT(retqueue == default_queue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); odp_packet_free(pkt); odp_cos_destroy(cos); + odp_cos_destroy(default_cos); odp_pmr_destroy(pmr); destroy_inq(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); odp_queue_destroy(queue); + odp_queue_destroy(default_queue); odp_pktio_close(pktio); } @@ -464,10 +629,16 @@ static void classification_test_pmr_term_ipproto(void) odp_pktio_t pktio; odp_queue_t queue; odp_queue_t retqueue; - odp_queue_t defqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_t pool; + odp_pool_t recvpool; odp_pmr_t pmr; odp_cos_t cos; - char cosname[ODP_QUEUE_NAME_LEN]; + odp_pool_param_t pool_param; + char cosname[ODP_COS_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; odp_pmr_match_t match; @@ -476,7 +647,8 @@ static void classification_test_pmr_term_ipproto(void) seqno = 0; pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); - defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); match.term = ODP_PMR_IPPROTO; match.val = &val; @@ -498,10 +670,25 @@ static void classification_test_pmr_term_ipproto(void) retval = odp_cos_queue_set(cos, queue); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "ipproto"); + + pool = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos, pool); + CU_ASSERT(retval == 0); + retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); - pkt = create_packet(pool_default, false, &seq, true); + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, true); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -510,11 +697,13 @@ static void classification_test_pmr_term_ipproto(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); CU_ASSERT(retqueue == queue); odp_packet_free(pkt); /* Other packets delivered to default queue */ - pkt = create_packet(pool_default, false, &seq, false); + pkt = create_packet(pkt_pool, false, &seq, false); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -523,13 +712,19 @@ static void classification_test_pmr_term_ipproto(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); - CU_ASSERT(retqueue == defqueue); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); + CU_ASSERT(retqueue == default_queue); odp_cos_destroy(cos); + odp_cos_destroy(default_cos); odp_pmr_destroy(pmr); odp_packet_free(pkt); destroy_inq(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); odp_queue_destroy(queue); + odp_queue_destroy(default_queue); odp_pktio_close(pktio); } diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index 3944d94..b64d841 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -14,6 +14,7 @@ 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; @@ -73,6 +74,9 @@ int classification_suite_init(void) for (i = 0; i < CLS_ENTRIES; i++) queue_list[i] = ODP_QUEUE_INVALID; + for (i = 0; i < CLS_ENTRIES; i++) + pool_list[i] = ODP_POOL_INVALID; + odp_atomic_init_u32(&seq, 0); ret = odp_pktio_start(pktio_loop); @@ -113,6 +117,9 @@ int classification_suite_term(void) for (i = 0; i < CLS_ENTRIES; i++) odp_queue_destroy(queue_list[i]); + for (i = 0; i < CLS_ENTRIES; i++) + odp_pool_destroy(pool_list[i]); + return retcode; } @@ -129,7 +136,9 @@ void configure_cls_pmr_chain(void) int retval; char cosname[ODP_QUEUE_NAME_LEN]; odp_queue_param_t qparam; + odp_pool_param_t pool_param; char queuename[ODP_QUEUE_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; uint32_t addr; uint32_t mask; odp_pmr_match_t match; @@ -150,10 +159,25 @@ void configure_cls_pmr_chain(void) &qparam); CU_ASSERT_FATAL(queue_list[CLS_PMR_CHAIN_SRC] != ODP_QUEUE_INVALID); + + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "SrcPool"); + + pool_list[CLS_PMR_CHAIN_SRC] = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool_list[CLS_PMR_CHAIN_SRC] != ODP_POOL_INVALID); + retval = odp_cos_queue_set(cos_list[CLS_PMR_CHAIN_SRC], queue_list[CLS_PMR_CHAIN_SRC]); CU_ASSERT(retval == 0); + retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_CHAIN_SRC], + pool_list[CLS_PMR_CHAIN_SRC]); + CU_ASSERT(retval == 0); + sprintf(cosname, "DstCos"); cos_list[CLS_PMR_CHAIN_DST] = odp_cos_create(cosname); CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_DST] != ODP_COS_INVALID); @@ -173,6 +197,20 @@ void configure_cls_pmr_chain(void) queue_list[CLS_PMR_CHAIN_DST]); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "%s", "DstPool"); + + pool_list[CLS_PMR_CHAIN_DST] = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool_list[CLS_PMR_CHAIN_DST] != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_CHAIN_DST], + pool_list[CLS_PMR_CHAIN_DST]); + CU_ASSERT(retval == 0); + parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask); match.term = ODP_PMR_SIP_ADDR; match.val = &addr; @@ -206,6 +244,7 @@ void test_cls_pmr_chain(void) odph_ipv4hdr_t *ip; odph_udphdr_t *udp; odp_queue_t queue; + odp_pool_t pool; uint32_t addr = 0; uint32_t mask; uint32_t seqno = 0; @@ -229,6 +268,8 @@ void test_cls_pmr_chain(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(queue == queue_list[CLS_PMR_CHAIN_DST]); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + pool = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_list[CLS_PMR_CHAIN_DST]); odp_packet_free(pkt); pkt = create_packet(pool_default, false, &seq, true); @@ -246,6 +287,8 @@ void test_cls_pmr_chain(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(queue == queue_list[CLS_PMR_CHAIN_SRC]); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + pool = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_list[CLS_PMR_CHAIN_SRC]); odp_packet_free(pkt); } @@ -253,8 +296,10 @@ void configure_pktio_default_cos(void) { int retval; odp_queue_param_t qparam; + odp_pool_param_t pool_param; char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; sprintf(cosname, "DefaultCoS"); cos_list[CLS_DEFAULT] = odp_cos_create(cosname); @@ -273,6 +318,20 @@ void configure_pktio_default_cos(void) queue_list[CLS_DEFAULT]); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "DefaultPool"); + + pool_list[CLS_DEFAULT] = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool_list[CLS_DEFAULT] != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos_list[CLS_DEFAULT], + pool_list[CLS_DEFAULT]); + CU_ASSERT(retval == 0); + retval = odp_pktio_default_cos_set(pktio_loop, cos_list[CLS_DEFAULT]); CU_ASSERT(retval == 0); } @@ -282,6 +341,7 @@ void test_pktio_default_cos(void) odp_packet_t pkt; odp_queue_t queue; uint32_t seqno = 0; + odp_pool_t pool; /* create a default packet */ pkt = create_packet(pool_default, false, &seq, true); seqno = cls_pkt_get_seq(pkt); @@ -294,6 +354,8 @@ void test_pktio_default_cos(void) /* Default packet should be received in default queue */ CU_ASSERT(queue == queue_list[CLS_DEFAULT]); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + pool = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_list[CLS_DEFAULT]); odp_packet_free(pkt); } @@ -302,8 +364,10 @@ void configure_pktio_error_cos(void) { int retval; odp_queue_param_t qparam; + odp_pool_param_t pool_param; char queuename[ODP_QUEUE_NAME_LEN]; char cosname[ODP_COS_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_LOWEST; @@ -323,6 +387,20 @@ void configure_pktio_error_cos(void) retval = odp_cos_queue_set(cos_list[CLS_ERROR], queue_list[CLS_ERROR]); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "ErrorPool"); + + pool_list[CLS_ERROR] = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool_list[CLS_ERROR] != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos_list[CLS_ERROR], + pool_list[CLS_ERROR]); + CU_ASSERT(retval == 0); + retval = odp_pktio_error_cos_set(pktio_loop, cos_list[CLS_ERROR]); CU_ASSERT(retval == 0); } @@ -331,6 +409,7 @@ void test_pktio_error_cos(void) { odp_queue_t queue; odp_packet_t pkt; + odp_pool_t pool; /*Create an error packet */ pkt = create_packet(pool_default, false, &seq, true); @@ -345,6 +424,8 @@ void test_pktio_error_cos(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); /* Error packet should be received in error queue */ CU_ASSERT(queue == queue_list[CLS_ERROR]); + pool = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_list[CLS_ERROR]); odp_packet_free(pkt); } @@ -382,12 +463,22 @@ void configure_cos_with_l2_priority(void) uint8_t num_qos = CLS_L2_QOS_MAX; odp_cos_t cos_tbl[CLS_L2_QOS_MAX]; odp_queue_t queue_tbl[CLS_L2_QOS_MAX]; + odp_pool_t pool; uint8_t qos_tbl[CLS_L2_QOS_MAX]; char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; int retval; int i; odp_queue_param_t qparam; + odp_pool_param_t pool_param; + + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + /** Initialize scalar variable qos_tbl **/ for (i = 0; i < CLS_L2_QOS_MAX; i++) @@ -409,8 +500,17 @@ void configure_cos_with_l2_priority(void) &qparam); CU_ASSERT_FATAL(queue_tbl[i] != ODP_QUEUE_INVALID); queue_list[CLS_L2_QOS_0 + i] = queue_tbl[i]; + retval = odp_cos_queue_set(cos_tbl[i], queue_tbl[i]); CU_ASSERT(retval == 0); + + sprintf(poolname, "%s_%d", "L2_Pool", i); + pool = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + pool_list[CLS_L2_QOS_0 + i] = pool; + retval = odp_cls_cos_pool_set(cos_tbl[i], pool); + CU_ASSERT(retval == 0); + qos_tbl[i] = i; } /* count 'i' is passed instead of num_qos to handle the rare scenario @@ -425,6 +525,7 @@ void test_cos_with_l2_priority(void) odph_ethhdr_t *ethhdr; odph_vlanhdr_t *vlan; odp_queue_t queue; + odp_pool_t pool; uint32_t seqno = 0; uint8_t i; @@ -439,6 +540,8 @@ void test_cos_with_l2_priority(void) pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(queue == queue_list[CLS_L2_QOS_0 + i]); + pool = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_list[CLS_L2_QOS_0 + i]); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); odp_packet_free(pkt); } @@ -453,6 +556,8 @@ void configure_pmr_cos(void) odp_queue_param_t qparam; char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; + odp_pool_param_t pool_param; val = CLS_PMR_SPORT; mask = 0xffff; @@ -483,6 +588,19 @@ void configure_pmr_cos(void) queue_list[CLS_PMR]); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "PMR_Pool"); + + pool_list[CLS_PMR] = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool_list[CLS_PMR] != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos_list[CLS_PMR], pool_list[CLS_PMR]); + CU_ASSERT(retval == 0); + retval = odp_pktio_pmr_cos(pmr_list[CLS_PMR], pktio_loop, cos_list[CLS_PMR]); CU_ASSERT(retval == 0); @@ -493,6 +611,7 @@ void test_pmr_cos(void) odp_packet_t pkt; odph_udphdr_t *udp; odp_queue_t queue; + odp_pool_t pool; uint32_t seqno = 0; pkt = create_packet(pool_default, false, &seq, true); @@ -504,6 +623,8 @@ void test_pmr_cos(void) pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(queue == queue_list[CLS_PMR]); + pool = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_list[CLS_PMR]); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); odp_packet_free(pkt); } @@ -518,6 +639,8 @@ void configure_pktio_pmr_match_set_cos(void) odp_queue_param_t qparam; char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; + char poolname[ODP_POOL_NAME_LEN]; + odp_pool_param_t pool_param; uint32_t addr = 0; uint32_t mask; @@ -557,6 +680,19 @@ void configure_pktio_pmr_match_set_cos(void) queue_list[CLS_PMR_SET]); CU_ASSERT(retval == 0); + odp_pool_param_init(&pool_param); + pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; + pool_param.pkt.len = SHM_PKT_BUF_SIZE; + pool_param.pkt.num = SHM_PKT_NUM_BUFS; + pool_param.type = ODP_POOL_PACKET; + sprintf(poolname, "cos_pmr_set_pool"); + + pool_list[CLS_PMR_SET] = odp_pool_create(poolname, &pool_param); + CU_ASSERT_FATAL(pool_list[CLS_PMR_SET] != ODP_POOL_INVALID); + retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_SET], + pool_list[CLS_PMR_SET]); + CU_ASSERT(retval == 0); + retval = odp_pktio_pmr_match_set_cos(pmr_set, pktio_loop, cos_list[CLS_PMR_SET]); CU_ASSERT(retval == 0); @@ -569,6 +705,7 @@ void test_pktio_pmr_match_set_cos(void) odph_ipv4hdr_t *ip; odph_udphdr_t *udp; odp_packet_t pkt; + odp_pool_t pool; odp_queue_t queue; uint32_t seqno = 0; @@ -588,6 +725,8 @@ void test_pktio_pmr_match_set_cos(void) pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS); CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(queue == queue_list[CLS_PMR_SET]); + pool = odp_packet_pool(pkt); + CU_ASSERT(pool == pool_list[CLS_PMR_SET]); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); odp_packet_free(pkt); } diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index 7d27d95..a09067c 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -25,7 +25,9 @@ odp_packet_t create_packet(odp_pool_t pool, bool vlan, 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_queue_t create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype); +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); int parse_ipv4_string(const char *ipaddress, uint32_t *addr, uint32_t *mask); void enqueue_pktio_interface(odp_packet_t pkt, odp_pktio_t pktio); odp_packet_t receive_packet(odp_queue_t *queue, uint64_t ns);