From patchwork Wed Aug 19 13:19:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52548 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 36C2A22DB1 for ; Wed, 19 Aug 2015 13:21:27 +0000 (UTC) Received: by lbcue2 with SMTP id ue2sf1492948lbc.1 for ; Wed, 19 Aug 2015 06:21: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=j7UtJqOZDfmGIFIETFqkkNyYeWT4DkYklo2IVbdetjA=; b=gECQOOzbRWTdjiqIY1CKgBqA+VZmm74QLgNiePXLeHcPhc9X34N0592Ou/zcBPmp/8 bUSyJ0r/NRflSJQPskTKm+XKUSPTA70R0j/Cbruu31Gywzc0IKZ2GN06IeH3nOfkZMeX y1+uzfkvm9sLZa9MYhTIEoUjMCjkayRQJwk9rCJdy6jc9+V8dbfSMMCFrIXswAKyGdmD /BeDttiVg9e8xTKLpJUz3Uz7+0uA2hg03CsVZvLYDqUtMjiOI2IABM3/63l1mUNL05Y0 pJh3ehWU/rwJ5IespCAKF4xvaBDDfoxb3nuGmKWG/4IKy9Q+FQfzZ9HC+qKZagBGv9WH eElQ== X-Gm-Message-State: ALoCoQmtd4Y6TL/DIcNe1OMp+2mWGfRBIrzGiAppxfh0EI00wbzrDyyhTraBqZMW0Y1vji8V2/9Q X-Received: by 10.180.75.49 with SMTP id z17mr7735086wiv.7.1439990486147; Wed, 19 Aug 2015 06:21:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.135 with SMTP id rk7ls23278lac.96.gmail; Wed, 19 Aug 2015 06:21:26 -0700 (PDT) X-Received: by 10.112.210.6 with SMTP id mq6mr11199778lbc.83.1439990485976; Wed, 19 Aug 2015 06:21:25 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id nq2si505311lbc.42.2015.08.19.06.21.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 06:21:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by laba3 with SMTP id a3so2874206lab.1 for ; Wed, 19 Aug 2015 06:21:25 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr11115619laf.112.1439990485685; Wed, 19 Aug 2015 06:21:25 -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 yc8csp371102lbb; Wed, 19 Aug 2015 06:21:24 -0700 (PDT) X-Received: by 10.140.102.136 with SMTP id w8mr22372093qge.25.1439990484154; Wed, 19 Aug 2015 06:21:24 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id o49si1031281qge.47.2015.08.19.06.21.22; Wed, 19 Aug 2015 06:21: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 703B661F6E; Wed, 19 Aug 2015 13:21:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id C33D861FAB; Wed, 19 Aug 2015 13:19:54 +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 BBA3461F69; Wed, 19 Aug 2015 13:19:45 +0000 (UTC) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by lists.linaro.org (Postfix) with ESMTPS id 5052461F75 for ; Wed, 19 Aug 2015 13:19:23 +0000 (UTC) Received: by wicne3 with SMTP id ne3so120543859wic.0 for ; Wed, 19 Aug 2015 06:19:22 -0700 (PDT) X-Received: by 10.194.172.233 with SMTP id bf9mr23731229wjc.107.1439990362560; Wed, 19 Aug 2015 06:19:22 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id h9sm1039322wjx.20.2015.08.19.06.19.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 06:19:22 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 19 Aug 2015 16:19:00 +0300 Message-Id: <1439990341-12037-7-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439990341-12037-1-git-send-email-maxim.uvarov@linaro.org> References: <1439990341-12037-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 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.49 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 | 119 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index ebe34fa..d43c25e 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -109,6 +109,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; @@ -626,6 +629,121 @@ 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]); + + /* stop and check that we can not transmit*/ + ret = odp_pktio_stop(pktio[0]); + CU_ASSERT(ret == 0); + odp_errno_zero(); + ret = odp_queue_enq_multi(outq, tx_ev, 10); + CU_ASSERT(ret == -1); + + /* 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]; @@ -722,6 +840,7 @@ CU_TestInfo pktio_suite[] = { {"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 };