From patchwork Mon Dec 28 16:40:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 59025 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1806723lbb; Mon, 28 Dec 2015 08:41:42 -0800 (PST) X-Received: by 10.140.134.198 with SMTP id 189mr76938732qhg.58.1451320902285; Mon, 28 Dec 2015 08:41:42 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y206si65406777qka.77.2015.12.28.08.41.42; Mon, 28 Dec 2015 08:41:42 -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 ACF8C616F6; Mon, 28 Dec 2015 16:41:41 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=VE3BvQZL; 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 BD3D6616FC; Mon, 28 Dec 2015 16:40:32 +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 CE9A7616F4; Mon, 28 Dec 2015 16:40:22 +0000 (UTC) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by lists.linaro.org (Postfix) with ESMTPS id 614A9616ED for ; Mon, 28 Dec 2015 16:40:21 +0000 (UTC) Received: by mail-lb0-f173.google.com with SMTP id bc4so93353914lbc.2 for ; Mon, 28 Dec 2015 08:40:21 -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=ZYI9no3aDYSBWZpFYK4IYsdw48u3xe4lJV2O00tKRgE=; b=VE3BvQZLH46t37LhrGP+c/mIgH0PwvhKJI477D/Z49JH0KOkuQ2QZBtQ3740Ze/rGc m850nw57/ZPdb81AxShorNDfrzNdqsPds+GqngzaqqAFP7d5CuUUAgsVjRBt4up2Jax2 pLTMC9CdMfvHrWgek9CAolskHHYHCOw4aT/DM= 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=ZYI9no3aDYSBWZpFYK4IYsdw48u3xe4lJV2O00tKRgE=; b=khrZ+3CeEAhYPz7cJJPRuMZCNuqBkV4J2Ss3TbDiR1nb7cTEoSrBgmvLgW2crnFEac kF/x/Jzn+irrYPp9NOHl4ZdESsbsvMjnzs8FF/G6FOMvOaf6RhK6+PPUcNwahwx+54Zi JSBGS/L1jBFiGjcK2fyxND3uutdAGmSdChNWQgZTnfDIxk29GdXmslgnVlszNVHMLCdW 5I0EOR6bIs3ncr6sPmwwkrRcq1lGiUdsiYJ0olX1Wc2oo790lQX0W7Vibm0qFT2oUeOT 0BIvF54liQbHEbST1dOmKgbWUZLemokAZIN0Fl8fPZwJGvGPwF+PqeQSXvZaFIwL++U4 9KXg== X-Gm-Message-State: ALoCoQlJvntBXu95IdjlPWEaPTMYkov6PlknLW0J/sEXQpqDjBPciSyeGC1MnliNuVRWRjetzJ0ffAjiHlW/+DJFAKuDcxRqRg== X-Received: by 10.112.200.40 with SMTP id jp8mr19830408lbc.104.1451320820261; Mon, 28 Dec 2015 08:40:20 -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 kz5sm9252745lbc.7.2015.12.28.08.40.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Dec 2015 08:40:19 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 28 Dec 2015 19:40:11 +0300 Message-Id: <1451320813-9428-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451320813-9428-1-git-send-email-maxim.uvarov@linaro.org> References: <1451320813-9428-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 2/4] helper: define odph_pktio_wailt_linkup() helper to wait link up 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" Define pktio helper to wait link up after odp_pktio_start(). Signed-off-by: Maxim Uvarov --- helper/Makefile.am | 1 + helper/include/odp/helper/pktio.h | 65 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 helper/include/odp/helper/pktio.h diff --git a/helper/Makefile.am b/helper/Makefile.am index 1906ae2..c01f43a 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -18,6 +18,7 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/strong_types.h\ $(srcdir)/include/odp/helper/tcp.h\ $(srcdir)/include/odp/helper/table.h\ + $(srcdir)/include/odp/helper/pktio.h\ $(srcdir)/include/odp/helper/udp.h noinst_HEADERS = \ diff --git a/helper/include/odp/helper/pktio.h b/helper/include/odp/helper/pktio.h new file mode 100644 index 0000000..18e6f94 --- /dev/null +++ b/helper/include/odp/helper/pktio.h @@ -0,0 +1,65 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP pktio helper API + * + */ + +#ifndef ODPH_PKTIO_H_ +#define ODPH_PKTIO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** time to wait after odp_pktio_start() to bring link up. + * It's is hardware dependent value, here we will have some common + * value. + */ +#define _ODPH_PKTIO_LINK_UP_TIME (50 * ODP_TIME_MSEC_IN_NS) + +/** Number of odp_pktio_link_status() calls in time interval. */ +#define _ODPH_PKTIO_LINK_TRIES 5 + +/** + * Wait for pktio link up. + * + * After odp_pktio_link_start(pktio) some platforms need small delay + * to bring up corresponding pktio link. + * + * @param pktio Packet IO handle. + * + * @retval 1 link is up + * @retval 0 link is down + * @retval <0 on failure +*/ +static inline int odph_pktio_wait_linkup(odp_pktio_t pktio) +{ + uint64_t wait_ns = _ODPH_PKTIO_LINK_UP_TIME / _ODPH_PKTIO_LINK_TRIES; + int i; + int ret = -1; + + for (i = 0; i < _ODPH_PKTIO_LINK_TRIES; i++) { + ret = odp_pktio_link_status(pktio); + if (ret < 0 || ret == 1) + return ret; + /* link is down, call status again after delay */ + odp_time_wait_ns(wait_ns); + } + return ret; +} + +#ifdef __cplusplus +} +#endif + +#endif