From patchwork Wed Aug 26 15:49:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52737 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 30F3522E9E for ; Wed, 26 Aug 2015 15:53:27 +0000 (UTC) Received: by wicul11 with SMTP id ul11sf7555434wic.1 for ; Wed, 26 Aug 2015 08:53:26 -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:in-reply-to:references: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=T7YKOqynLT5XSCaqqLUedrtvAVl/69L/VnVk9zLdW+g=; b=Cw3Wec1k1HjKd4bT3CvmRf6n4bsYlq7fs4CuhzLy1d/OAUmSP9WHlECHNjRAzl18NT DUGB3svixxcpHyTR4LvF1A40EfYU9az1Bnnl3k61GyLPllOpz05ln/2V0c9ibgUyWA6y iw5Uzpy/m6qxdtWK+pCjQY2WOQGugSHrRMgDh/CydYjQAjjijSIPfUJMmPDJi9A5+lgE GgIQRl/gxnlLZfn8PK54txzjSOTSF9Q+sjU4DpSuEGBhQBRDaeAB62vAkIYHPX91ERjW AbrnyUA5i5+4qgxk1lyaSNFuCdS2xmOyTFqW59Q4RmBpBliRD7mTgbyTPCLqxQ1MOyDi bQWA== X-Gm-Message-State: ALoCoQk80CrRJB2aX/Zt4YOdnwaoz5HEzXNUOV7Fo27ntLUeUYV7jnAdkio/8werMa4iY0vT28av X-Received: by 10.112.189.105 with SMTP id gh9mr10336455lbc.16.1440604406488; Wed, 26 Aug 2015 08:53:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.197 with SMTP id ks5ls784995lac.64.gmail; Wed, 26 Aug 2015 08:53:26 -0700 (PDT) X-Received: by 10.152.36.226 with SMTP id t2mr31595965laj.6.1440604406324; Wed, 26 Aug 2015 08:53:26 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id q7si19058790laq.23.2015.08.26.08.53.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 08:53:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by laba3 with SMTP id a3so122469880lab.1 for ; Wed, 26 Aug 2015 08:53:26 -0700 (PDT) X-Received: by 10.152.28.193 with SMTP id d1mr31161780lah.72.1440604406193; Wed, 26 Aug 2015 08:53:26 -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.162.200 with SMTP id yc8csp4011534lbb; Wed, 26 Aug 2015 08:53:24 -0700 (PDT) X-Received: by 10.50.142.98 with SMTP id rv2mr4479089igb.41.1440604404134; Wed, 26 Aug 2015 08:53:24 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id cj4si3714804igc.57.2015.08.26.08.53.22; Wed, 26 Aug 2015 08:53:24 -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 D750B6207F; Wed, 26 Aug 2015 15:53:21 +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_H2, 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 E6AFE6207E; Wed, 26 Aug 2015 15:50:13 +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 C14D562092; Wed, 26 Aug 2015 15:50:11 +0000 (UTC) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by lists.linaro.org (Postfix) with ESMTPS id 1BD106207E for ; Wed, 26 Aug 2015 15:49:20 +0000 (UTC) Received: by lbbsx3 with SMTP id sx3so122573691lbb.0 for ; Wed, 26 Aug 2015 08:49:18 -0700 (PDT) X-Received: by 10.152.21.231 with SMTP id y7mr28183313lae.63.1440604158733; Wed, 26 Aug 2015 08:49:18 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id w3sm6870916lag.13.2015.08.26.08.49.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 08:49:18 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 26 Aug 2015 18:49:06 +0300 Message-Id: <1440604147-24703-7-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440604147-24703-1-git-send-email-maxim.uvarov@linaro.org> References: <1440604147-24703-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv5 6/7] validation: test odp_pktio_start and odp_pktio_stop 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: maxim.uvarov@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.215.46 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 Signed-off-by: Maxim Uvarov --- test/validation/pktio/pktio.c | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 33a672a..874e28e 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -134,6 +134,9 @@ static uint32_t pktio_pkt_seq(odp_packet_t pkt) pkt_head_t head; pkt_tail_t tail; + if (pkt == ODP_PACKET_INVALID) + return -1; + off = odp_packet_l4_offset(pkt); if (off == ODP_PACKET_OFFSET_INVALID) return TEST_SEQ_INVALID; @@ -653,6 +656,117 @@ void pktio_test_inq(void) CU_ASSERT(odp_pktio_close(pktio) == 0); } +static void pktio_test_start_stop(void) +{ + odp_pktio_t pktio[MAX_NUM_IFACES]; + odp_packet_t pkt; + odp_event_t tx_ev[1000]; + odp_event_t ev; + int i, pkts, ret, alloc = 0; + odp_queue_t outq; + + for (i = 0; i < num_ifaces; i++) { + pktio[i] = create_pktio(iface_name[i], ODP_QUEUE_TYPE_SCHED, 0); + CU_ASSERT(pktio[i] != ODP_PKTIO_INVALID); + create_inq(pktio[i], ODP_QUEUE_TYPE_SCHED); + } + + for (alloc = 0; alloc < 1000; alloc++) { + pkt = odp_packet_alloc(default_pkt_pool, packet_len); + if (pkt == ODP_PACKET_INVALID) + break; + pktio_init_packet(pkt); + tx_ev[alloc] = odp_packet_to_event(pkt); + } + + outq = odp_pktio_outq_getdef(pktio[0]); + + ret = odp_pktio_stop(pktio[0]); + CU_ASSERT(ret == 0); + + /* start first and queue packets */ + ret = odp_pktio_start(pktio[0]); + CU_ASSERT(ret == 0); + /* stop second and send packets*/ + if (num_ifaces > 1) { + ret = odp_pktio_stop(pktio[1]); + CU_ASSERT(ret == 0); + } + for (pkts = 0; pkts != alloc; ) { + ret = odp_queue_enq_multi(outq, &tx_ev[pkts], alloc - pkts); + if (ret < 0) { + CU_FAIL("unable to enqueue packet\n"); + break; + } + pkts += ret; + } + /* check that packets did not arrive */ + for (i = 0, pkts = 0; i < 1000; i++) { + ev = odp_schedule(NULL, ODP_TIME_MSEC); + if (ev != ODP_EVENT_INVALID) { + if (odp_event_type(ev) == ODP_EVENT_PACKET) { + if (pktio_pkt_seq(pkt) != TEST_SEQ_INVALID) + pkts++; + } + odp_event_free(ev); + } + } + if (pkts) + CU_FAIL("pktio stopped, received unexpected events"); + + /* start both, send and get packets */ + /* 0 already started */ + if (num_ifaces > 1) { + ret = odp_pktio_start(pktio[1]); + CU_ASSERT(ret == 0); + } + + /* flush packets with magic number in pipes */ + for (i = 0; i < 1000; i++) { + ev = odp_schedule(NULL, ODP_TIME_MSEC); + if (ev != ODP_EVENT_INVALID) + odp_event_free(ev); + } + + /* alloc */ + for (alloc = 0; alloc < 1000; alloc++) { + pkt = odp_packet_alloc(default_pkt_pool, packet_len); + if (pkt == ODP_PACKET_INVALID) + break; + pktio_init_packet(pkt); + tx_ev[alloc] = odp_packet_to_event(pkt); + } + + /* send */ + for (pkts = 0; pkts != alloc; ) { + ret = odp_queue_enq_multi(outq, &tx_ev[pkts], alloc - pkts); + if (ret < 0) { + CU_FAIL("unable to enqueue packet\n"); + break; + } + pkts += ret; + } + + /* get */ + for (i = 0, pkts = 0; i < 1000; i++) { + ev = odp_schedule(NULL, ODP_TIME_MSEC); + if (ev != ODP_EVENT_INVALID) { + if (odp_event_type(ev) == ODP_EVENT_PACKET) { + pkt = odp_packet_from_event(ev); + if (pktio_pkt_seq(pkt) != TEST_SEQ_INVALID) + pkts++; + } + odp_event_free(ev); + } + } + CU_ASSERT(pkts == alloc); + + for (i = 0; i < num_ifaces; i++) { + destroy_inq(pktio[i]); + CU_ASSERT(odp_pktio_close(pktio[i]) == 0); + } +} + static int create_pool(const char *iface, int num) { char pool_name[ODP_POOL_NAME_LEN]; @@ -762,6 +876,7 @@ CU_TestInfo pktio_suite_unsegmented[] = { {"pktio promisc mode", pktio_test_promisc}, {"pktio mac", pktio_test_mac}, {"pktio inq_remdef", pktio_test_inq_remdef}, + {"pktio start stop", pktio_test_start_stop}, CU_TEST_INFO_NULL };