From patchwork Tue Mar 1 19:56:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 63344 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2018189lbc; Tue, 1 Mar 2016 11:57:40 -0800 (PST) X-Received: by 10.140.23.139 with SMTP id 11mr28510881qgp.62.1456862260140; Tue, 01 Mar 2016 11:57:40 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f17si32372572qki.116.2016.03.01.11.57.39; Tue, 01 Mar 2016 11:57:40 -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 Received: by lists.linaro.org (Postfix, from userid 109) id 964E262FAC; Tue, 1 Mar 2016 19:57:39 +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_H3, RCVD_IN_MSPIKE_WL, 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 73EE562F1E; Tue, 1 Mar 2016 19:57:11 +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 F2A28615D1; Tue, 1 Mar 2016 19:57:04 +0000 (UTC) Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by lists.linaro.org (Postfix) with ESMTPS id CBB4461B05 for ; Tue, 1 Mar 2016 19:57:02 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id m82so137258683oif.1 for ; Tue, 01 Mar 2016 11:57:02 -0800 (PST) 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=cq0W+QgMWgXlx24gJROnvE+xgm13K5lWRb2zDDRa01s=; b=SPmjMU3AItVdVkNPXRdprFgXJP/57U6ZS/44/he9U5xzHhg/BbOo/jPyaJVxxoqe9t t5XAeu1Va/c7D0S1xv6Q0/PGUuDY8jxjp2X7EqhpT9B73CjUw1oykR8/kSFmFs4EOAAq Hg/5rLU4kiQObhaHa8aLHX92YAAijPPlH9U/KaZw0b316VmwoDM3x+sqAU12PxhKandT pVSVg9CP8CGryQBubNlUeXCeXiFzcm9EpWHpeRKnCygP7fGauCKRty/OUtS7+hfmD85q +vO2w+cZpTZDeLnoZ7zhurYg3WyVN1mB+3bci9pGAIXL0EWZYl0natteyREFXNsKzqJR yLLA== X-Gm-Message-State: AD7BkJKzVh3MoXBn5Vl3ulcrfriPiCnK8+mBJ+eTdcThPpLW0Zfw9u1OAFGA0nhIgLe3FJXCJGI= X-Received: by 10.202.91.196 with SMTP id p187mr17150857oib.39.1456862222302; Tue, 01 Mar 2016 11:57:02 -0800 (PST) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id bi2sm23064932obb.24.2016.03.01.11.57.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 11:57:01 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 1 Mar 2016 13:56:57 -0600 Message-Id: <1456862218-26220-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456862218-26220-1-git-send-email-bill.fischofer@linaro.org> References: <1456862218-26220-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 2/3] validation: tm: miscellaneous cleanup and fixes for tm cunit tests 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" Add missing odp_pktin/out_queue_config() calls for interfaces and streamline link status processing to enable the TM Cunit test to run properly with the latest PktIO changes. Signed-off-by: Bill Fischofer --- test/validation/traffic_mngr/traffic_mngr.c | 59 +++++++++++++++++++---------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/test/validation/traffic_mngr/traffic_mngr.c b/test/validation/traffic_mngr/traffic_mngr.c index f8084b8..1e34ad8 100644 --- a/test/validation/traffic_mngr/traffic_mngr.c +++ b/test/validation/traffic_mngr/traffic_mngr.c @@ -287,14 +287,31 @@ static odp_bool_t approx_eq64(uint64_t val, uint64_t correct) return false; } +static int 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); + } + + return ret; +} + static int open_pktios(void) { odp_pktio_param_t pktio_param; odp_pool_param_t pool_param; odp_pktio_t pktio; odp_pool_t pkt_pool; - odp_time_t start_time, duration; - uint64_t duration_ns; uint32_t iface; char pool_name[ODP_POOL_NAME_LEN]; int rc, ret; @@ -323,6 +340,10 @@ static int open_pktios(void) if (pktio == ODP_PKTIO_INVALID) pktio = odp_pktio_lookup(iface_name[iface]); + /* Set defaults for PktIn and PktOut queues */ + odp_pktin_queue_config(pktio, NULL); + odp_pktout_queue_config(pktio, NULL); + pktios[iface] = pktio; if (pktio == ODP_PKTIO_INVALID) { printf("%s odp_pktio_open() failed\n", __func__); @@ -362,38 +383,38 @@ static int open_pktios(void) xmt_pktout = pktouts[0]; rcv_pktin = pktins[1]; ret = odp_pktio_start(pktios[1]); - if (ret != 0) + if (ret != 0) { + printf("%s odp_pktio_start() failed\n", __func__); return -1; + } } else { xmt_pktout = pktouts[0]; rcv_pktin = pktins[0]; } ret = odp_pktio_start(pktios[0]); - if (ret != 0) + if (ret != 0) { + printf("%s odp_pktio_start() failed\n", __func__); return -1; + } /* Now wait until the link or links are up. */ - start_time = odp_time_local(); - while (odp_pktio_link_status(pktios[0]) != 1) { - duration = odp_time_diff(odp_time_local(), start_time); - duration_ns = odp_time_to_ns(duration); - if (ODP_TIME_SEC_IN_NS <= duration_ns) - return -1; - - busy_wait(10000); + rc = wait_linkup(pktios[0]); + if (rc != 1) { + printf("%s link %" PRIu64 " not up\n", __func__, + odp_pktio_to_u64(pktios[0])); + return -1; } if (num_ifaces < 2) return 0; - while (odp_pktio_link_status(pktios[1]) != 1) { - duration = odp_time_diff(odp_time_local(), start_time); - duration_ns = odp_time_to_ns(duration); - if (ODP_TIME_SEC_IN_NS <= duration_ns) - return -1; - - busy_wait(10000); + /* Wait for 2nd link to be up */ + rc = wait_linkup(pktios[1]); + if (rc != 1) { + printf("%s link %" PRIu64 " not up\n", __func__, + odp_pktio_to_u64(pktios[0])); + return -1; } return 0;