From patchwork Wed Dec 23 09:33:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 58970 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3745650lbb; Wed, 23 Dec 2015 01:33:21 -0800 (PST) X-Received: by 10.107.169.225 with SMTP id f94mr29768411ioj.154.1450863201130; Wed, 23 Dec 2015 01:33:21 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 141si13355772iof.88.2015.12.23.01.33.20; Wed, 23 Dec 2015 01:33:21 -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 1BB01617DB; Wed, 23 Dec 2015 09:33:20 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=ek0UKECY; 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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BL_SPAMCOP_NET, 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 8955E617B3; Wed, 23 Dec 2015 09:33:14 +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 83A37617C2; Wed, 23 Dec 2015 09:33:12 +0000 (UTC) Received: from mail-pf0-f170.google.com (mail-pf0-f170.google.com [209.85.192.170]) by lists.linaro.org (Postfix) with ESMTPS id 8356561791 for ; Wed, 23 Dec 2015 09:33:10 +0000 (UTC) Received: by mail-pf0-f170.google.com with SMTP id u7so74049481pfb.1 for ; Wed, 23 Dec 2015 01:33:10 -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; bh=mucUE0DOysDu+OV0rlfwOnLH/j8fQYmBR7h4EK2u7Ks=; b=ek0UKECYtwRTXBaMwrqXOgHfxFAZgw3Ue07xOi3YitJy1KmbZ8Lk1t06o0R0zs5J4j X8S5Fnh3hCfd3zu/2eskjo1C45usksoSPvWLFvNZcNGadJ+BPHpxJMRQgleXft+GdJ8q gUK8kteRMi6RY33k2yiPeJdL7GelBolABmtac= 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=mucUE0DOysDu+OV0rlfwOnLH/j8fQYmBR7h4EK2u7Ks=; b=OYm3r1qoHYXBiGsCT40zp829RKEHSOBrOlQwSqY+AjnuRZ3rBTzKhXZxxkT87HJshl pY0KEvfAnCH1LSfBqN7PKOTx3QtXCZDOK+feVNH6SHY0Oi1FSCvx+yMfx9ZoD5s1+ZLL kPWjCoczbz1jA+vdTruxpRhpfdW3g+oL2o6qFyma3XEnwrrc20OWvE4ogmZqrbpjjdlO jkWHD9wSvRnPomnzrII6NagVOQBltL/Ym9kjd81wYh4UiZuf/EWNj61C0lTVOhyO+A31 3X98XvZsBrboPhyzgl2EjmW8zCpKeebJcB3P66ky6JrTQ3z18Ho6zoSPISw6D1urjqJL b+1Q== X-Gm-Message-State: ALoCoQmu1KvFNhFtaAOU5FPkK4jCXP4iCrWCPj/0GesS/7h81aVPXRA0hZF9hovgVriytDpU+BZMC66FdS+OUSrVrwAK67UKcw== X-Received: by 10.98.89.210 with SMTP id k79mr21417740pfj.45.1450863189721; Wed, 23 Dec 2015 01:33:09 -0800 (PST) Received: from bala-Vostro-2520.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id r90sm46575561pfi.80.2015.12.23.01.33.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Dec 2015 01:33:09 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Wed, 23 Dec 2015 15:03:02 +0530 Message-Id: <1450863182-28787-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/PATCHv2] 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 --- v2: rebase to HEAD .../classification/odp_classification_common.c | 4 +- .../classification/odp_classification_test_pmr.c | 99 ++++++++++++++++++++++ 2 files changed, 101 insertions(+), 2 deletions(-) diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index afcea45..68c4b5a 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -251,10 +251,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 5a13e13..3bd8e40 100644 --- a/test/validation/classification/odp_classification_test_pmr.c +++ b/test/validation/classification/odp_classification_test_pmr.c @@ -833,6 +833,104 @@ static void classification_test_pmr_queue_set(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 default_queue; + odp_pool_t pool; + odp_pool_t default_pool; + odp_pmr_t pmr; + odp_cos_t cos; + odp_cos_t default_cos; + uint32_t addr; + uint32_t mask; + char cosname[ODP_QUEUE_NAME_LEN]; + odp_pmr_match_t match; + odp_cls_cos_param_t cls_param; + odph_ipv4hdr_t *ip; + const char *dst_addr = "10.0.0.99/32"; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + 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_pmr_create(&match); + CU_ASSERT_FATAL(pmr != ODP_PMR_INVAL); + + queue = queue_create("daddr", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("daddr"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + sprintf(cosname, "daddr"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + retval = odp_pktio_pmr_cos(pmr, pktio, cos); + CU_ASSERT(retval == 0); + + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + + /* packet with dst ip address matching PMR rule to be + received in the CoS queue*/ + pkt = create_packet(pkt_pool, 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_FATAL(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(pkt_pool, 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_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + 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); +} + odp_testinfo_t classification_suite_pmr[] = { ODP_TEST_INFO(classification_test_pmr_term_tcp_dport), ODP_TEST_INFO(classification_test_pmr_term_tcp_sport), @@ -841,5 +939,6 @@ odp_testinfo_t classification_suite_pmr[] = { ODP_TEST_INFO(classification_test_pmr_term_ipproto), ODP_TEST_INFO(classification_test_pmr_pool_set), ODP_TEST_INFO(classification_test_pmr_queue_set), + ODP_TEST_INFO(classification_test_pmr_term_daddr), ODP_TEST_INFO_NULL, };