From patchwork Tue Oct 20 06:48:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 55274 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id C2EEC22EA2 for ; Tue, 20 Oct 2015 06:49:28 +0000 (UTC) Received: by wikv3 with SMTP id v3sf5504415wik.1 for ; Mon, 19 Oct 2015 23:49:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=oN/D8ePsIBLJzwM3fKq3k/2Z93BKj77qhmci55n+bD0=; b=EBmpdlcXv4+ZOPTswgdSsC0duXi8u6HB/69BIp8IHU+hoGMOj4V52LXVDWuitijADv g54KqZxRrXHKhKgKBDmggWOT6SVXQu8lqrP7FbSLCTVEubjim4mSD1En6WI6PmaUfTCG TzMjXtM3w1wnRCKNd+ThnBmRINQFR1xRp9zJTFJnM+1/6AS56BktrYlljVrFB74hpIDc spckYFT90CEKb2yKZwi32eFrk9bIdpusMbPBF8IVXXXwZAFZSK30jAwTSRJk3bJL4tJ8 qN1rYbSYZXU23QnhIqaeJ7VWd6d4EOtEPLnR3NoyXcSEXc1h6dBXdZLoM04EHHG72SVV Z5xw== X-Gm-Message-State: ALoCoQl5YoL8LH/BUZEd+zdDcfFGXaZs0HsXGRUEHgXt4nHgMJRu1fk7fZmNUh/HJz1kBPSK/FYh X-Received: by 10.112.54.197 with SMTP id l5mr259463lbp.21.1445323768055; Mon, 19 Oct 2015 23:49:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.27.206 with SMTP id b197ls27057lfb.26.gmail; Mon, 19 Oct 2015 23:49:27 -0700 (PDT) X-Received: by 10.112.142.9 with SMTP id rs9mr728592lbb.39.1445323767912; Mon, 19 Oct 2015 23:49:27 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id r199si1122609lfe.160.2015.10.19.23.49.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 23:49:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbec13 with SMTP id ec13so5395884lbb.0 for ; Mon, 19 Oct 2015 23:49:27 -0700 (PDT) X-Received: by 10.112.168.228 with SMTP id zz4mr767570lbb.73.1445323767650; Mon, 19 Oct 2015 23:49:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1891103lbq; Mon, 19 Oct 2015 23:49:26 -0700 (PDT) X-Received: by 10.107.8.30 with SMTP id 30mr1717111ioi.125.1445323766730; Mon, 19 Oct 2015 23:49:26 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id o19si1554077igs.94.2015.10.19.23.49.25; Mon, 19 Oct 2015 23:49:26 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id 7D81E61D66; Tue, 20 Oct 2015 06:49:25 +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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 4A76561D3C; Tue, 20 Oct 2015 06:49:18 +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 9A81561D4E; Tue, 20 Oct 2015 06:49:16 +0000 (UTC) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by lists.linaro.org (Postfix) with ESMTPS id 43109619AB for ; Tue, 20 Oct 2015 06:49:15 +0000 (UTC) Received: by padhk11 with SMTP id hk11so12032542pad.1 for ; Mon, 19 Oct 2015 23:49:14 -0700 (PDT) X-Received: by 10.68.219.133 with SMTP id po5mr2052221pbc.135.1445323754505; Mon, 19 Oct 2015 23:49:14 -0700 (PDT) Received: from localhost.localdomain ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id so4sm1697554pbc.72.2015.10.19.23.49.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Oct 2015 23:49:13 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Tue, 20 Oct 2015 12:18:57 +0530 Message-Id: <1445323737-16831-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: structural code change X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bala.manoharan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The following minor code modifications are implemented in this patch * Move destoy_inq() function to common file * TCP header length calculated from packet * Redundant pool lookup function removed Signed-off-by: Balasubramanian Manoharan --- .../classification/odp_classification_common.c | 41 +++++++++++++++++-- .../classification/odp_classification_test_pmr.c | 46 +++------------------- .../classification/odp_classification_tests.c | 31 ++------------- .../classification/odp_classification_testsuites.h | 2 +- 4 files changed, 47 insertions(+), 73 deletions(-) diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index b975dfb..ba3ade4 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -17,12 +17,40 @@ typedef struct cls_test_packet { uint32be_t seq; } cls_test_packet_t; +int destroy_inq(odp_pktio_t pktio) +{ + odp_queue_t inq; + odp_event_t ev; + + inq = odp_pktio_inq_getdef(pktio); + + if (inq == ODP_QUEUE_INVALID) { + CU_FAIL("attempting to destroy invalid inq"); + return -1; + } + + if (0 > odp_pktio_inq_remdef(pktio)) + return -1; + + while (1) { + ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); + + if (ev != ODP_EVENT_INVALID) + odp_event_free(ev); + else + break; + } + + return odp_queue_destroy(inq); +} + int cls_pkt_set_seq(odp_packet_t pkt) { static uint32_t seq; cls_test_packet_t data; uint32_t offset; odph_ipv4hdr_t *ip; + odph_tcphdr_t *tcp; int status; data.magic = DATA_MAGIC; @@ -35,9 +63,11 @@ int cls_pkt_set_seq(odp_packet_t pkt) if (ip->proto == ODPH_IPPROTO_UDP) status = odp_packet_copydata_in(pkt, offset + ODPH_UDPHDR_LEN, sizeof(data), &data); - else - status = odp_packet_copydata_in(pkt, offset + ODPH_TCPHDR_LEN, + else { + tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL); + status = odp_packet_copydata_in(pkt, offset + tcp->hl * 4, sizeof(data), &data); + } return status; } @@ -47,6 +77,7 @@ uint32_t cls_pkt_get_seq(odp_packet_t pkt) uint32_t offset; cls_test_packet_t data; odph_ipv4hdr_t *ip; + odph_tcphdr_t *tcp; ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); offset = odp_packet_l4_offset(pkt); @@ -57,9 +88,11 @@ uint32_t cls_pkt_get_seq(odp_packet_t pkt) if (ip->proto == ODPH_IPPROTO_UDP) odp_packet_copydata_out(pkt, offset + ODPH_UDPHDR_LEN, sizeof(data), &data); - else - odp_packet_copydata_out(pkt, offset + ODPH_TCPHDR_LEN, + else { + tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL); + odp_packet_copydata_out(pkt, offset + tcp->hl * 4, sizeof(data), &data); + } if (data.magic == DATA_MAGIC) return data.seq; diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c index e794bda..4bfe0cb 100644 --- a/test/validation/classification/odp_classification_test_pmr.c +++ b/test/validation/classification/odp_classification_test_pmr.c @@ -17,36 +17,8 @@ static odp_pool_t pool_default; /** sequence number of IP packets */ odp_atomic_u32_t seq; -static int destroy_inq(odp_pktio_t pktio) -{ - odp_queue_t inq; - odp_event_t ev; - - inq = odp_pktio_inq_getdef(pktio); - - if (inq == ODP_QUEUE_INVALID) { - CU_FAIL("attempting to destroy invalid inq"); - return -1; - } - - if (0 > odp_pktio_inq_remdef(pktio)) - return -1; - - while (1) { - ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); - - if (ev != ODP_EVENT_INVALID) - odp_buffer_free(odp_buffer_from_event(ev)); - else - break; - } - - return odp_queue_destroy(inq); -} - int classification_suite_pmr_init(void) { - odp_pool_t pool; odp_pool_param_t param; odp_pool_param_init(¶m); @@ -55,16 +27,12 @@ int classification_suite_pmr_init(void) param.pkt.num = SHM_PKT_NUM_BUFS; param.type = ODP_POOL_PACKET; - pool = odp_pool_create("classification_pmr_pool", ¶m); - if (ODP_POOL_INVALID == pool) { + pool_default = odp_pool_create("classification_pmr_pool", ¶m); + if (ODP_POOL_INVALID == pool_default) { fprintf(stderr, "Packet pool creation failed.\n"); return -1; } - pool_default = odp_pool_lookup("classification_pmr_pool"); - if (pool_default == ODP_POOL_INVALID) - return -1; - odp_atomic_init_u32(&seq, 0); return 0; } @@ -73,11 +41,9 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type) { odp_pktio_t pktio; odp_pktio_param_t pktio_param; - odp_pool_t pool; int ret; - pool = odp_pool_lookup("classification_pmr_pool"); - if (pool == ODP_POOL_INVALID) + if (pool_default == ODP_POOL_INVALID) return ODP_PKTIO_INVALID; odp_pktio_param_init(&pktio_param); @@ -86,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, &pktio_param); + pktio = odp_pktio_open("loop", pool_default, &pktio_param); if (pktio == ODP_PKTIO_INVALID) { - ret = odp_pool_destroy(pool); + ret = odp_pool_destroy(pool_default); if (ret) fprintf(stderr, "unable to destroy pool.\n"); return ODP_PKTIO_INVALID; @@ -477,7 +443,6 @@ static void classification_test_pmr_term_udp_sport(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC); CU_ASSERT(pkt != ODP_PACKET_INVALID); - CU_ASSERT(cls_pkt_get_seq(pkt) != TEST_SEQ_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); CU_ASSERT(retqueue == defqueue); odp_packet_free(pkt); @@ -557,7 +522,6 @@ static void classification_test_pmr_term_ipproto(void) pkt = receive_packet(&retqueue, ODP_TIME_SEC); CU_ASSERT(pkt != ODP_PACKET_INVALID); - CU_ASSERT(cls_pkt_get_seq(pkt) != TEST_SEQ_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); CU_ASSERT(retqueue == defqueue); diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index fe55419..62e67d1 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -22,33 +22,6 @@ static odp_pktio_t pktio_loop; /** sequence number of IP packets */ odp_atomic_u32_t seq; -static int destroy_inq(odp_pktio_t pktio) -{ - odp_queue_t inq; - odp_event_t ev; - - inq = odp_pktio_inq_getdef(pktio); - - if (inq == ODP_QUEUE_INVALID) { - CU_FAIL("attempting to destroy invalid inq"); - return -1; - } - - if (0 > odp_pktio_inq_remdef(pktio)) - return -1; - - while (1) { - ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); - - if (ev != ODP_EVENT_INVALID) - odp_event_free(ev); - else - break; - } - - return odp_queue_destroy(inq); -} - int classification_suite_init(void) { odp_pool_param_t param; @@ -358,9 +331,12 @@ void test_pktio_error_cos(void) { odp_queue_t queue; odp_packet_t pkt; + uint32_t seqno = 0; /*Create an error packet */ pkt = create_packet(pool_default, false, &seq, true); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); /* Incorrect IpV4 version */ @@ -370,6 +346,7 @@ void test_pktio_error_cos(void) pkt = receive_packet(&queue, ODP_TIME_SEC); CU_ASSERT(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); /* Error packet should be received in error queue */ CU_ASSERT(queue == queue_list[CLS_ERROR]); odp_packet_free(pkt); diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index 33547a7..a7a8baa 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -43,6 +43,6 @@ void configure_pmr_cos(void); 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); #endif /* ODP_BUFFER_TESTSUITES_H_ */