From patchwork Thu Aug 13 11:45:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52386 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id B99972031F for ; Thu, 13 Aug 2015 11:48:59 +0000 (UTC) Received: by labth1 with SMTP id th1sf16013690lab.2 for ; Thu, 13 Aug 2015 04:48:58 -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=PNI25T4n5dYqTVv/MVmgbv4wQMVBvDFDlt84rKP+GlI=; b=cVp2du5yB8hyaINfW+zo1MlQTK7QXDeXUieuacG/UqEqmdxfj73QjM02J7t6jYr8xw 7UZkpovcMsToH2+prTrC6JbA32aPczQ4hyqaTEfkSkKiCRNX4GLEGqEmVhXRGhJwkhT5 pJxIfyErhaYSluaoh2Fznvd4PSYKmDTfsIHCD9nrwj+p+c+YVZvEbz6TrPOkNkH26sPJ vjl0hkvSfP1wiIkZKa5aTmmKkvkzZVAsiwQNTrRp39GEb+YgBbksds9fTKqYJkzGZY/b F5JTYvBkg9WIjjs+8EaQlkYB69v21lhgSwCHQlqI1o3UveoueItRh8+B+Y75m0MIHHs4 4NBg== X-Gm-Message-State: ALoCoQla+12HJi/QEpEH/yGAzxwqsgXmmQTVph5DSVHoWa3CawSu5c+7Ng3dcRd8YsLmeyzD5Pil X-Received: by 10.180.205.198 with SMTP id li6mr875876wic.5.1439466538309; Thu, 13 Aug 2015 04:48:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.33 with SMTP id ld1ls169154lac.6.gmail; Thu, 13 Aug 2015 04:48:58 -0700 (PDT) X-Received: by 10.152.22.4 with SMTP id z4mr35794114lae.81.1439466538016; Thu, 13 Aug 2015 04:48:58 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id sb1si2023431lbb.33.2015.08.13.04.48.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2015 04:48:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lagz9 with SMTP id z9so24585788lag.3 for ; Thu, 13 Aug 2015 04:48:57 -0700 (PDT) X-Received: by 10.152.44.196 with SMTP id g4mr17642335lam.56.1439466537451; Thu, 13 Aug 2015 04:48:57 -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.7.198 with SMTP id l6csp888410lba; Thu, 13 Aug 2015 04:48:56 -0700 (PDT) X-Received: by 10.140.234.10 with SMTP id f10mr39334355qhc.3.1439466535926; Thu, 13 Aug 2015 04:48:55 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h17si3272056qge.102.2015.08.13.04.48.55; Thu, 13 Aug 2015 04:48:55 -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 05FA661D65; Thu, 13 Aug 2015 11:48:55 +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 E569B61FE5; Thu, 13 Aug 2015 11:46:20 +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 79CD861D14; Thu, 13 Aug 2015 11:46:15 +0000 (UTC) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by lists.linaro.org (Postfix) with ESMTPS id BD9B361CE0 for ; Thu, 13 Aug 2015 11:45:48 +0000 (UTC) Received: by wicne3 with SMTP id ne3so255694843wic.1 for ; Thu, 13 Aug 2015 04:45:48 -0700 (PDT) X-Received: by 10.194.221.4 with SMTP id qa4mr80564064wjc.145.1439466348028; Thu, 13 Aug 2015 04:45:48 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id ma4sm2972054wjb.38.2015.08.13.04.45.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Aug 2015 04:45:47 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 13 Aug 2015 14:45:33 +0300 Message-Id: <1439466334-16497-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439466334-16497-1-git-send-email-maxim.uvarov@linaro.org> References: <1439466334-16497-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 5/6] 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.45 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 | 112 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index ebe34fa..f8a8981 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -626,6 +626,117 @@ void pktio_test_inq(void) CU_ASSERT(odp_pktio_close(pktio) == 0); } +static uint32_t pktio_pkt_validate(odp_packet_t pkt) +{ + size_t off; + 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 -1; + + off += ODPH_UDPHDR_LEN; + if (odp_packet_copydata_out(pkt, off, sizeof(head), &head) != 0) + return -1; + + if (head.magic != TEST_SEQ_MAGIC) + return -1; + + if (odp_packet_len(pkt) == packet_len) { + off = packet_len - sizeof(tail); + if (odp_packet_copydata_out(pkt, off, sizeof(tail), &tail) != 0) + return -1; + } + + return 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*/ + odp_pktio_stop(pktio[0]); + ret = odp_queue_enq_multi(outq, tx_ev, 10); + CU_ASSERT(ret == 0); + + /* start first and queue 10 packets */ + odp_pktio_start(pktio[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; + } + /* stop second and check that packets did not arrive */ + if (num_ifaces == 1) + odp_pktio_stop(pktio[0]); + else + odp_pktio_stop(pktio[1]); + 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_validate(pkt)) + pkts++; + } + odp_event_free(ev); + } + } + if (pkts) + CU_FAIL("pktio stopped, received unexpected events"); + + /* start second and get packets */ + if (num_ifaces == 1) + odp_pktio_start(pktio[0]); + else + odp_pktio_start(pktio[1]); + 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_validate(pkt)) + 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 +833,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 };