From patchwork Wed Dec 30 13:13:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 59077 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2840010lbb; Wed, 30 Dec 2015 05:14:24 -0800 (PST) X-Received: by 10.55.71.146 with SMTP id u140mr82486761qka.14.1451481264655; Wed, 30 Dec 2015 05:14:24 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s105si75461227qgs.72.2015.12.30.05.14.24; Wed, 30 Dec 2015 05:14:24 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1F8C0616E3; Wed, 30 Dec 2015 13:14:24 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=dbND9ebE; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 AE6FE61797; Wed, 30 Dec 2015 13:13:40 +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 6DF7061795; Wed, 30 Dec 2015 13:13:36 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 57DD161794 for ; Wed, 30 Dec 2015 13:13:35 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id c192so49783199lfe.2 for ; Wed, 30 Dec 2015 05:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lxZa/R7p+VXPzbfH/qgGMdTNnRj/grLmtFnu3sIos28=; b=dbND9ebE4TFmN8oegTRw7yRNV20+zovGrNGzrxkseGXH+BZejz9k5IKbJpyl/J/S9q PN8m0Km2wyE7RtN4UANXhmmctuys1HZFAQUZzjs2xIo37vLfpFpDvN/2HYj8zQYrna11 +nlg6anRfApxu+hthyv/1bJm0xK+c6ZzhIAzA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lxZa/R7p+VXPzbfH/qgGMdTNnRj/grLmtFnu3sIos28=; b=TFhEYIu0FdhYfY4+7i7kM9lv+9NkIgBM4c0aE8RJWAlgWGIu8SpIE9kHLzJoHhaJQH NbwV1L6vHjN6OYOcJ3CLQ7/ah/Wm98pmAa9qYbmS18YvXNTtMqgZNGSMXtP5vfvzI7hb TpdIciMOhaKvQ1eG8JIvCuUBTTNEqXUC/SFZACHzGr94VJ1JjTsxeWqhP2d46itaGe/b yAWWntDVJ3SEL+hwMbKyVQnTNuWFrE1mN/5qK7jK8hppUYNkDao+9HLgJEtunrMfma5R WXPQYesRii3QKJiY8VG46kbSc8w4sTsKz+FolExGHb3MgxZJbbRk09RX544CA5/6dbi5 zK3A== X-Gm-Message-State: ALoCoQmwLXkvw7Hr0Ol21jYToi9ufcNJKaVBrbyAMcYWZrvvOY1ReQlZ322v2g1cycJuTemsWcWp4Y+X3evCn/DtQr7/EfR46A== X-Received: by 10.25.134.130 with SMTP id i124mr16385127lfd.63.1451481214234; Wed, 30 Dec 2015 05:13:34 -0800 (PST) Received: from localhost.localdomain (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.gmail.com with ESMTPSA id b74sm6568598lfb.32.2015.12.30.05.13.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Dec 2015 05:13:33 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 30 Dec 2015 16:13:25 +0300 Message-Id: <1451481205-20606-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451481205-20606-1-git-send-email-maxim.uvarov@linaro.org> References: <1451481205-20606-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 2/2] validation: test odp_pktio_link_status() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" Signed-off-by: Maxim Uvarov --- test/validation/pktio/pktio.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index e473a1d..4beb681 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -74,6 +74,29 @@ pkt_segmented_e pool_segmentation = PKT_POOL_UNSEGMENTED; odp_pool_t pool[MAX_NUM_IFACES] = {ODP_POOL_INVALID, ODP_POOL_INVALID}; +static inline void _pktio_wait_linkup(odp_pktio_t pktio) +{ + /* wait 1 second for link up */ + uint64_t wait_ns = (10 * ODP_TIME_MSEC_IN_NS); + int wait_num = 100; + int i; + int ret = -1; + + for (i = 0; i < wait_num; i++) { + ret = odp_pktio_link_status(pktio); + if (ret < 0 || ret == 1) + break; + /* link is down, call status again after delay */ + odp_time_wait_ns(wait_ns); + } + + if (ret != -1) { + /* assert only if link state supported and + * it's down. */ + CU_ASSERT_FATAL(ret == 1); + } +} + static void set_pool_len(odp_pool_param_t *params) { switch (pool_segmentation) { @@ -514,6 +537,8 @@ static void test_txrx(odp_pktio_input_mode_t in_mode, int num_pkts) ret = odp_pktio_start(io->id); CU_ASSERT(ret == 0); + + _pktio_wait_linkup(io->id); } /* if we have two interfaces then send through one and receive on @@ -757,6 +782,8 @@ void pktio_test_start_stop(void) ret = odp_pktio_start(pktio[0]); CU_ASSERT(ret < 0); + _pktio_wait_linkup(pktio[0]); + /* Test Rx on a stopped interface. Only works if there are 2 */ if (num_ifaces > 1) { for (alloc = 0; alloc < 1000; alloc++) { @@ -804,6 +831,8 @@ void pktio_test_start_stop(void) ret = odp_pktio_start(pktio[1]); CU_ASSERT(ret == 0); + _pktio_wait_linkup(pktio[1]); + /* flush packets with magic number in pipes */ for (i = 0; i < 1000; i++) { ev = odp_schedule(NULL, wait); @@ -915,6 +944,8 @@ void pktio_test_send_failure(void) ret = odp_pktio_start(pktio_tx); CU_ASSERT_FATAL(ret == 0); + _pktio_wait_linkup(pktio_tx); + /* configure the pool so that we can generate test packets larger * than the interface MTU */ memset(&pool_params, 0, sizeof(pool_params)); @@ -930,6 +961,8 @@ void pktio_test_send_failure(void) ODP_PKTOUT_MODE_SEND); ret = odp_pktio_start(pktio_rx); CU_ASSERT_FATAL(ret == 0); + + _pktio_wait_linkup(pktio_rx); } else { pktio_rx = pktio_tx; } @@ -1052,6 +1085,8 @@ void pktio_test_recv_on_wonly(void) ret = odp_pktio_start(pktio); CU_ASSERT_FATAL(ret == 0); + _pktio_wait_linkup(pktio); + ret = odp_pktio_recv(pktio, &pkt, 1); CU_ASSERT(ret < 0); @@ -1082,6 +1117,8 @@ void pktio_test_send_on_ronly(void) ret = odp_pktio_start(pktio); CU_ASSERT_FATAL(ret == 0); + _pktio_wait_linkup(pktio); + pkt = odp_packet_alloc(default_pkt_pool, packet_len); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID)