From patchwork Tue Jan 12 18:11:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 59634 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2893101lbb; Tue, 12 Jan 2016 10:12:40 -0800 (PST) X-Received: by 10.140.97.5 with SMTP id l5mr171734497qge.84.1452622360076; Tue, 12 Jan 2016 10:12:40 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x143si48347999qka.122.2016.01.12.10.12.39; Tue, 12 Jan 2016 10:12:40 -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 9D91C6173A; Tue, 12 Jan 2016 18:12:39 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=OWZ4DW+z; 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 7AF716172D; Tue, 12 Jan 2016 18:12:08 +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 9913B616F8; Tue, 12 Jan 2016 18:12:00 +0000 (UTC) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by lists.linaro.org (Postfix) with ESMTPS id D54FF616ED for ; Tue, 12 Jan 2016 18:11:58 +0000 (UTC) Received: by mail-lf0-f47.google.com with SMTP id m198so92530498lfm.0 for ; Tue, 12 Jan 2016 10:11:58 -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=rOB1PXi9YIW3w1URwbt8pF7oxH50v4zcGrQxv2j1Ap0=; b=OWZ4DW+z4g7GKPL2NJpj9AI9iKDIMfxmC66tPk5SlABQibnp9/7HO+9LsrN0s8q69q 1V5x/JFXeDeHiACuu2CtufUvyfc1HahoGOEp3sJbtr7H27ANkfn8aungsvx9WxU9ahQD vzy5tABWBCmialWibu4dREt0ydN0OaQZqqkA0= 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=rOB1PXi9YIW3w1URwbt8pF7oxH50v4zcGrQxv2j1Ap0=; b=emFVXOq/M4GKIfls5vs6ktq9WJPb4UKUhiiBRXk59tVf1VxJwxmuRkgvavw+/PSC0F VsfgQn1wNoGGp7Ya4oL9uArX3699cQntDvkX8pjo9TQlrbsB6MfobjMpLe5/mS3SO1AU 8AqC0hg2t/oM10P/kPv5buhItUUX1NFnbAyZnidi4Ke3KbBQ/Vhe2Z/jh7j4MQ/f+tLq ye5+HgdE/9Wo1bfaz0TkFNtlEbyIlZn27h5jiac+yu9KY5LJysCb5PqDh0e4rJzfIWil s6I98hrppCZxIzmAQkxRSNmqac10t0oQkqh9Gw6GhfSHtGdSbDlJr0nhWLzRIXOcLdrU oHQg== X-Gm-Message-State: ALoCoQmuM1dQuZad930kNZNhXojtC/WoQvWDkF8ZbmQtQjLgWyxL+miRA0pQuEIcawjc/h/msnvzJCXT+EiLKkqOeXmRkZ39YA== X-Received: by 10.25.23.85 with SMTP id n82mr19864574lfi.164.1452622317808; Tue, 12 Jan 2016 10:11:57 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id o9sm3340536lfe.15.2016.01.12.10.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Jan 2016 10:11:57 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Tue, 12 Jan 2016 20:11:43 +0200 Message-Id: <1452622307-18379-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452622307-18379-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1452622307-18379-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 1/5] validation: cls: adopt for supported l3 PMR 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" The classification tests should use supported l3 PMR where it's not important. For validating concrete PMRs the separate test exists. Signed-off-by: Ivan Khoronzhuk --- test/validation/classification/classification.h | 6 +-- .../classification/odp_classification_basic.c | 4 +- .../classification/odp_classification_common.c | 52 ++++++++++++++++++++++ .../classification/odp_classification_tests.c | 25 +++++------ .../classification/odp_classification_testsuites.h | 2 + 5 files changed, 69 insertions(+), 20 deletions(-) diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h index a186339..f363812 100644 --- a/test/validation/classification/classification.h +++ b/test/validation/classification/classification.h @@ -29,18 +29,18 @@ #define CLS_PMR_CHAIN_SRC 2 #define CLS_PMR_CHAIN_DST 3 #define CLS_PMR_CHAIN_SADDR "10.0.0.5/32" -#define CLS_PMR_CHAIN_SPORT 3000 +#define CLS_PMR_CHAIN_PORT 3000 /* Config values for PMR */ #define TEST_PMR 1 #define CLS_PMR 4 -#define CLS_PMR_SPORT 4000 +#define CLS_PMR_PORT 4000 /* Config values for PMR SET */ #define TEST_PMR_SET 1 #define CLS_PMR_SET 5 #define CLS_PMR_SET_SADDR "10.0.0.6/32" -#define CLS_PMR_SET_SPORT 5000 +#define CLS_PMR_SET_PORT 5000 /* Config values for CoS L2 Priority */ #define TEST_L2_QOS 1 diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c index f0b7a42..81077b6 100644 --- a/test/validation/classification/odp_classification_basic.c +++ b/test/validation/classification/odp_classification_basic.c @@ -78,7 +78,7 @@ void classification_test_create_pmr_match(void) val = 1024; mask = 0xffff; - match.term = ODP_PMR_TCP_SPORT; + match.term = find_first_supported_l3_pmr(); match.val = &val; match.mask = &mask; match.val_sz = sizeof(val); @@ -99,7 +99,7 @@ void classification_test_destroy_pmr(void) val = 1024; mask = 0xffff; - match.term = ODP_PMR_TCP_SPORT; + match.term = find_first_supported_l3_pmr(); match.val = &val; match.mask = &mask; match.val_sz = sizeof(val); diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index afcea45..b1c1750 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -299,3 +299,55 @@ odp_packet_t create_packet(odp_pool_t pool, bool vlan, return pkt; } + +odp_pmr_term_e find_first_supported_l3_pmr(void) +{ + odp_pmr_term_e term; + unsigned long long cap; + + /* choose supported PMR */ + cap = odp_pmr_terms_cap(); + if (cap & (1 << ODP_PMR_UDP_SPORT)) + term = ODP_PMR_UDP_SPORT; + else if (cap & (1 << ODP_PMR_UDP_DPORT)) + term = ODP_PMR_UDP_DPORT; + else if (cap & (1 << ODP_PMR_TCP_SPORT)) + term = ODP_PMR_TCP_SPORT; + else if (cap & (1 << ODP_PMR_TCP_DPORT)) + term = ODP_PMR_TCP_DPORT; + else + CU_FAIL("Implementations doesn't support any TCP/UDP PMR"); + + return term; +} + +int set_first_supported_pmr_port(odp_packet_t pkt, uint16_t port) +{ + odph_udphdr_t *udp; + odph_tcphdr_t *tcp; + odp_pmr_term_e term; + + udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL); + tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL); + port = odp_cpu_to_be_16(port); + term = find_first_supported_l3_pmr(); + switch (term) { + case ODP_PMR_UDP_SPORT: + udp->src_port = port; + break; + case ODP_PMR_UDP_DPORT: + udp->dst_port = port; + break; + case ODP_PMR_TCP_DPORT: + tcp->dst_port = port; + break; + case ODP_PMR_TCP_SPORT: + tcp->src_port = port; + break; + default: + CU_FAIL("Unsupported L3 term"); + return -1; + } + + return 0; +} diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index e11c3d8..a118728 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -10,6 +10,7 @@ #include #include #include +#include static odp_cos_t cos_list[CLS_ENTRIES]; static odp_pmr_t pmr_list[CLS_ENTRIES]; @@ -195,9 +196,9 @@ void configure_cls_pmr_chain(void) pmr_list[CLS_PMR_CHAIN_SRC] = odp_pmr_create(&match); CU_ASSERT_FATAL(pmr_list[CLS_PMR_CHAIN_SRC] != ODP_PMR_INVAL); - val = CLS_PMR_CHAIN_SPORT; + val = CLS_PMR_CHAIN_PORT; maskport = 0xffff; - match.term = ODP_PMR_UDP_SPORT; + match.term = find_first_supported_l3_pmr(); match.val = &val; match.mask = &maskport; match.val_sz = sizeof(val); @@ -218,7 +219,6 @@ void test_cls_pmr_chain(void) { odp_packet_t pkt; odph_ipv4hdr_t *ip; - odph_udphdr_t *udp; odp_queue_t queue; odp_pool_t pool; uint32_t addr = 0; @@ -236,8 +236,7 @@ void test_cls_pmr_chain(void) ip->chksum = 0; ip->chksum = odph_ipv4_csum_update(pkt); - udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL); - udp->src_port = odp_cpu_to_be_16(CLS_PMR_CHAIN_SPORT); + set_first_supported_pmr_port(pkt, CLS_PMR_CHAIN_PORT); enqueue_pktio_interface(pkt, pktio_loop); @@ -513,9 +512,9 @@ void configure_pmr_cos(void) char queuename[ODP_QUEUE_NAME_LEN]; char poolname[ODP_POOL_NAME_LEN]; - val = CLS_PMR_SPORT; + val = CLS_PMR_PORT; mask = 0xffff; - match.term = ODP_PMR_UDP_SPORT; + match.term = find_first_supported_l3_pmr(); match.val = &val; match.mask = &mask; match.val_sz = sizeof(val); @@ -554,7 +553,6 @@ void configure_pmr_cos(void) 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; @@ -563,8 +561,7 @@ void test_pmr_cos(void) CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); - udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL); - udp->src_port = odp_cpu_to_be_16(CLS_PMR_SPORT); + set_first_supported_pmr_port(pkt, CLS_PMR_PORT); enqueue_pktio_interface(pkt, pktio_loop); pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); @@ -597,9 +594,9 @@ void configure_pktio_pmr_match_set_cos(void) pmr_terms[0].val_sz = sizeof(addr); - val = CLS_PMR_SET_SPORT; + val = CLS_PMR_SET_PORT; maskport = 0xffff; - pmr_terms[1].term = ODP_PMR_UDP_SPORT; + 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); @@ -640,7 +637,6 @@ void test_pktio_pmr_match_set_cos(void) uint32_t addr = 0; uint32_t mask; odph_ipv4hdr_t *ip; - odph_udphdr_t *udp; odp_packet_t pkt; odp_pool_t pool; odp_queue_t queue; @@ -657,8 +653,7 @@ void test_pktio_pmr_match_set_cos(void) ip->chksum = 0; ip->chksum = odph_ipv4_csum_update(pkt); - udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL); - udp->src_port = odp_cpu_to_be_16(CLS_PMR_SET_SPORT); + set_first_supported_pmr_port(pkt, CLS_PMR_SET_PORT); enqueue_pktio_interface(pkt, pktio_loop); pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index 02828e1..ee33009 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -46,5 +46,7 @@ void test_pmr_cos(void); void configure_pktio_pmr_match_set_cos(void); void test_pktio_pmr_match_set_cos(void); int destroy_inq(odp_pktio_t pktio); +odp_pmr_term_e find_first_supported_l3_pmr(void); +int set_first_supported_pmr_port(odp_packet_t pkt, uint16_t port); #endif /* ODP_BUFFER_TESTSUITES_H_ */