From patchwork Thu Dec 3 10:33:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 57626 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3410790lbb; Thu, 3 Dec 2015 02:34:03 -0800 (PST) X-Received: by 10.140.84.40 with SMTP id k37mr10054132qgd.33.1449138843503; Thu, 03 Dec 2015 02:34:03 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u65si2557672qka.90.2015.12.03.02.34.02; Thu, 03 Dec 2015 02:34:03 -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 BE88D62C6A; Thu, 3 Dec 2015 10:34:02 +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 6A83162BF8; Thu, 3 Dec 2015 10:33:58 +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 B8EF262C0E; Thu, 3 Dec 2015 10:33:47 +0000 (UTC) Received: from mail-io0-f179.google.com (mail-io0-f179.google.com [209.85.223.179]) by lists.linaro.org (Postfix) with ESMTPS id 9069462BF4 for ; Thu, 3 Dec 2015 10:33:46 +0000 (UTC) Received: by iofh3 with SMTP id h3so76445283iof.3 for ; Thu, 03 Dec 2015 02:33:46 -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; bh=9sZM5/0RnAau46VFmCbYDNCqQ0stgASlz0r0Qdc/O2E=; b=QnQYbZfGXwWHTPKarO4JPKh6q0Hj2TOdpajRjxSljhQnmcCe3aAxblDom0fgI6erfb FpbceNh8CZybm/CTanUODZKX8JJadtd97M/QBDNztZfpGumeVCSDWQV+IDHvT3rWwfDG sP6JvmWUzPLzj+Se9OUvjGk+nOFQmQgsEh4fmzqXVF1CW7cU500F7pnpu8gWZLjgFqQJ ceaF9PQg4Giq7qn/D9CNtGuJsFCnZEIWj49rE0bvOCMCi8ocXQhsWtMrDahxpyqBnuYW tdpTWIzYBGjn4uXJJthU2tGAbndNVcb8AdrPbKSjWr254CCyTauOaQITjm5RTyWaCy8n 7a9A== 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; bh=9sZM5/0RnAau46VFmCbYDNCqQ0stgASlz0r0Qdc/O2E=; b=c8S3oveA645tBfItvzQ7Biw+3jSjNZGnfSFEnxYoVU3v5NM+CU2Ak4iWxfKYWKZlyQ TKzTdA/akngEYBwBTExk7TTLHhOwVfKbidCMYsNU6vB1xNet1na7ke/nQu0m/w0uT0oA ztVML4QWuCu4crEOqMA/SZ7KXdo10pQ6EoJnETtcSRHzi1VQog2JPs9PRpScbvzp10rT uPy73Oox9nk9r6+0BhOF8dVmHEJ6+ajTFbSNKfaRwFu293Juj77k3Qbc85dvuCEUEpAJ zH1ilS9TmNMkOZu3SiBo5JvQTkW5hKnCe8Uf+rgv+F28RNeEGmhdnXJmR+FS9mqIfywo Jg1w== X-Gm-Message-State: ALoCoQnY+2vHxdrEwjQrR18j3hjRo/QzajBVYe17QcPTZorFuJrIVDHCNBjNK+3xfMzDr/1kIOAC X-Received: by 10.107.1.196 with SMTP id 187mr9407503iob.167.1449138826086; Thu, 03 Dec 2015 02:33:46 -0800 (PST) Received: from bala-Vostro-2520.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id ht2sm2719744igb.22.2015.12.03.02.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Dec 2015 02:33:45 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 3 Dec 2015 16:03:36 +0530 Message-Id: <1449138816-7870-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: Classification patch Subject: [lng-odp] [API-NEXT/PATCH] validation: classification: adds Test case for ODP_PMR_DIP_ADDR 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" fixes: https://bugs.linaro.org/show_bug.cgi?id=1830 Signed-off-by: Balasubramanian Manoharan --- .../classification/odp_classification_common.c | 4 +- .../classification/odp_classification_test_pmr.c | 85 ++++++++++++++++++++++ 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index e2999ad..b9611ca 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -235,10 +235,10 @@ odp_packet_t create_packet(odp_pool_t pool, bool vlan, /* ipv4 */ ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); - parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask); + parse_ipv4_string(CLS_DEFAULT_DADDR, &addr, &mask); ip->dst_addr = odp_cpu_to_be_32(addr); - parse_ipv4_string(CLS_DEFAULT_DADDR, &addr, &mask); + parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask); ip->src_addr = odp_cpu_to_be_32(addr); ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN; if (flag_udp) diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c index 3f49d4c..03a2e1f 100644 --- a/test/validation/classification/odp_classification_test_pmr.c +++ b/test/validation/classification/odp_classification_test_pmr.c @@ -533,11 +533,96 @@ static void classification_test_pmr_term_ipproto(void) odp_pktio_close(pktio); } +static void classification_test_pmr_term_daddr(void) +{ + odp_packet_t pkt; + uint32_t seqno; + int retval; + odp_pktio_t pktio; + odp_queue_t queue; + odp_queue_t retqueue; + odp_queue_t defqueue; + odp_pmr_t pmr; + odp_cos_t cos; + uint32_t addr; + uint32_t mask; + char cosname[ODP_QUEUE_NAME_LEN]; + char queuename[ODP_QUEUE_NAME_LEN]; + odp_pmr_match_t match; + odph_ipv4hdr_t *ip; + const char *dst_addr = "10.0.0.99/32"; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + + 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(pmr != ODP_PMR_INVAL); + + sprintf(cosname, "daddr"); + cos = odp_cos_create(cosname); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + sprintf(queuename, "%s", "daddr"); + + queue = queue_create(queuename, true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + retval = odp_cos_queue_set(cos, queue); + CU_ASSERT(retval == 0); + + retval = odp_pktio_pmr_cos(pmr, pktio, cos); + CU_ASSERT(retval == 0); + + /* packet with dst ip address matching PMR rule to be + received in the CoS queue*/ + pkt = create_packet(pool_default, false, &seq, false); + ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); + ip->dst_addr = odp_cpu_to_be_32(addr); + ip->chksum = odph_ipv4_csum_update(pkt); + + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + enqueue_pktio_interface(pkt, pktio); + + 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 == queue); + odp_packet_free(pkt); + + /* Other packets delivered to default queue */ + pkt = create_packet(pool_default, false, &seq, false); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + enqueue_pktio_interface(pkt, pktio); + + 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); + + odp_cos_destroy(cos); + odp_pmr_destroy(pmr); + odp_packet_free(pkt); + destroy_inq(pktio); + odp_queue_destroy(queue); + odp_pktio_close(pktio); +} + odp_testinfo_t classification_suite_pmr[] = { ODP_TEST_INFO(classification_test_pmr_term_tcp_dport), ODP_TEST_INFO(classification_test_pmr_term_tcp_sport), ODP_TEST_INFO(classification_test_pmr_term_udp_dport), ODP_TEST_INFO(classification_test_pmr_term_udp_sport), ODP_TEST_INFO(classification_test_pmr_term_ipproto), + ODP_TEST_INFO(classification_test_pmr_term_daddr), ODP_TEST_INFO_NULL, };