From patchwork Mon Feb 29 20:53:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 63259 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1464373lbc; Mon, 29 Feb 2016 12:54:06 -0800 (PST) X-Received: by 10.55.195.16 with SMTP id a16mr21996879qkj.36.1456779246565; Mon, 29 Feb 2016 12:54:06 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n31si27487011qge.54.2016.02.29.12.54.06; Mon, 29 Feb 2016 12:54:06 -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 2E91161B17; Mon, 29 Feb 2016 20:54:06 +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_H2, 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 1B48861CD3; Mon, 29 Feb 2016 20:53:22 +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 23EB961C6E; Mon, 29 Feb 2016 20:53:14 +0000 (UTC) Received: from mail-ob0-f175.google.com (mail-ob0-f175.google.com [209.85.214.175]) by lists.linaro.org (Postfix) with ESMTPS id D21E761B17 for ; Mon, 29 Feb 2016 20:53:11 +0000 (UTC) Received: by mail-ob0-f175.google.com with SMTP id fz5so15088480obc.0 for ; Mon, 29 Feb 2016 12:53:11 -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=e6FKnuXtNQIbGUf0WAZPw92+VKIo6bwg0Eoy2jSgKXYcPe0Aor3Et62fdV9HByBnyF 93cJrku6E0F2ilS6ts+D3iJ+17YNo0GlfJkCS+sWOEOnlYObQJ8j5pqmuyBLZlvE5hol SqrsNxUhnhhT8i4YgU4ciclNVEGvGXqG2F5scIeDW9qNurElZNix9xAMfe4v2YI3AV2h agRYZz0N+3GA1SPI6lBv/qsn6d18SPvHhjS1THOgAkgqS1FHKNJngC/HqlOxz1LNNKX1 izOXvad0ytNL7sJXIfyBM8rHk7EzLFCLp67VWKwl7Ic8CAnB5TjpZBx+Z3cpxb67SHts ey/g== X-Gm-Message-State: AD7BkJK7kZX0nGJJPWZz9sWm2p5HOjVvq7245Xc65XQWRX5ULoKa1MYhchJ7EFjxwsIzcBVzPUk= X-Received: by 10.182.241.2 with SMTP id we2mr14297820obc.20.1456779191410; Mon, 29 Feb 2016 12:53:11 -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 v136sm19222721oif.15.2016.02.29.12.53.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 12:53:10 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 29 Feb 2016 14:53:07 -0600 Message-Id: <1456779187-32336-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456779187-32336-1-git-send-email-bill.fischofer@linaro.org> References: <1456779187-32336-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 3/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;