From patchwork Fri Aug 14 11:03:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52431 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 3239E2031F for ; Fri, 14 Aug 2015 11:07:05 +0000 (UTC) Received: by labd1 with SMTP id d1sf26760364lab.0 for ; Fri, 14 Aug 2015 04:07:04 -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=8s57fpVhrtC257hLdFUpbY0tj9wa93yYy7IhHje647s=; b=iPODRyQHWj+nJeem57AQeSdRuaaUN1ff8DERHMNoY5mPptGiBJiGDvXNRINPvGl9j7 bNEGevRgEQ5VF942MynZ6r9up3cW1CkR9Zb5cytNJaY7ZgGyfQEkv6e0XBwaLco61HRR 5ZXRsx92oC4njI7MckMw1dcFzMYYfUH2bkMZM+xVQV0OqcfDHaHZ/AxphGoo6CYFXuaA DFlXvdMYB4L89+183ijPHhAV88eRZ95bzpwuz6AxpT77VQZ4ItRllIaSeilm9nhLTozF cLpkUCmulxAzyB6xMFSoq0AjVNOQdRKrR5jZh5MU8TuEEOKnXHjLikHai+RCv5fmfsVR zyvw== X-Gm-Message-State: ALoCoQk6Lrkwf8pW4yco77oDiJoZVuFeHmv8WcBymf+s5Br0BbEKhiD4oaWMRdHVUsw0GtwlUQoz X-Received: by 10.180.82.101 with SMTP id h5mr803615wiy.1.1439550424119; Fri, 14 Aug 2015 04:07:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.110 with SMTP id v14ls354662lal.19.gmail; Fri, 14 Aug 2015 04:07:03 -0700 (PDT) X-Received: by 10.112.180.98 with SMTP id dn2mr19333340lbc.0.1439550423626; Fri, 14 Aug 2015 04:07:03 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id gf10si5745410lbc.82.2015.08.14.04.07.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2015 04:07:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lagz9 with SMTP id z9so41784796lag.3 for ; Fri, 14 Aug 2015 04:07:03 -0700 (PDT) X-Received: by 10.112.126.101 with SMTP id mx5mr43562370lbb.35.1439550423468; Fri, 14 Aug 2015 04:07:03 -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 l6csp1533131lba; Fri, 14 Aug 2015 04:07:02 -0700 (PDT) X-Received: by 10.50.43.131 with SMTP id w3mr2171164igl.8.1439550422255; Fri, 14 Aug 2015 04:07:02 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f186si3533855ioe.187.2015.08.14.04.07.01; Fri, 14 Aug 2015 04:07:02 -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 2D65661EB3; Fri, 14 Aug 2015 11:07:01 +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 3CED761EE6; Fri, 14 Aug 2015 11:04:30 +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 E26D761EE8; Fri, 14 Aug 2015 11:04:21 +0000 (UTC) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by lists.linaro.org (Postfix) with ESMTPS id 7036861E5A for ; Fri, 14 Aug 2015 11:03:25 +0000 (UTC) Received: by wicja10 with SMTP id ja10so14602870wic.1 for ; Fri, 14 Aug 2015 04:03:24 -0700 (PDT) X-Received: by 10.180.182.112 with SMTP id ed16mr5609654wic.19.1439550204725; Fri, 14 Aug 2015 04:03:24 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id c11sm2538630wib.1.2015.08.14.04.03.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Aug 2015 04:03:23 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 14 Aug 2015 14:03:03 +0300 Message-Id: <1439550184-28383-7-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439550184-28383-1-git-send-email-maxim.uvarov@linaro.org> References: <1439550184-28383-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 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.42 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 | 114 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index ebe34fa..4222463 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -626,6 +626,119 @@ 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]); + odp_errno_zero(); + ret = odp_queue_enq_multi(outq, tx_ev, 10); + CU_ASSERT(ret == -1); + CU_ASSERT(odp_errno() == EPERM); + + /* start first and queue 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 +835,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 };