From patchwork Thu Dec 21 16:00:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 122581 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1084177qgn; Thu, 21 Dec 2017 08:08:50 -0800 (PST) X-Google-Smtp-Source: ACJfBov7NEvfB/YGSW0S9NZemCneGU1s6JaaCuUACecIpCqBReww0vJLQDz75KPlXS49Wfc0o4WC X-Received: by 10.237.56.197 with SMTP id k63mr15141913qte.308.1513872530093; Thu, 21 Dec 2017 08:08:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513872530; cv=none; d=google.com; s=arc-20160816; b=sNo847DRJFO8Xm5/Uz+yo6izsSDhloXjNVdOvrNQvq6O1e+y38FuPcc/5uRlM6HPYR WDKCefjXLqW1nY9MZQ0/u/4Hd1wpCNxJ61/KwdZqnjKZVSQ4WBeTceDv8DV0KbsghR8/ ifHQe5amKoHud+EoBEhXG3GjtbA7gFzPDJIUWYGww1qTOfmRXtZuwWt5qS7MPTcxtxIF NmKxbgVDrwfoCrSdwNhemwM1S6ad9Y0LKqWg5CCCZ8LWCacTfvYLi3xvz8KA2cxSLBmW HRZflTPfn/wxEb5jJbJ0Z8NZfpl1k/4zKt/emUwfzGF2Cyj2chMKbjfdu72+fm+L8bY8 K7PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=p1iokmfRcr6FtjZ8F5e032K6H/xXnKL59PM0iK1I/Tc=; b=MlJneCM0R/Mmh4ZyHQelZQ9H8q6WvlIWYQwMcF4uIlX3HC+7TKl4jJzwqDU4D9CE+e lIqHK5LIa+dYnTz+b8EvO2b/HAbGGyCrVJae5f0C8O2Pspenxg64CD0K2NAUvuOn4369 H2PDwG8WEvp7gPM1rvNaUN6et8Td7age0tr8nZzg61ykOXWjIYnDuXx3608Q5C6tXgoq NEgSs6xPTnfFyJn8+KTo+j0WjRheNEaXVk7vtQiuH5DLqU9HaQspuPu0CRltDmqSl/vS ARuRMb2FP86uQVNzBrqiF2WaY2cUPXPz1C6UtW5uAMSRgISTcg3sLOFPsdG2I4eaLDY4 2V2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id r32si472086qta.346.2017.12.21.08.08.49; Thu, 21 Dec 2017 08:08:50 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id B7D6261759; Thu, 21 Dec 2017 16:08:49 +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,FREEMAIL_FROM, 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 06FD06151C; Thu, 21 Dec 2017 16:01:45 +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 D699161514; Thu, 21 Dec 2017 16:01:17 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 5A4E060C4C for ; Thu, 21 Dec 2017 16:00:20 +0000 (UTC) Received: from mxback1j.mail.yandex.net (mxback1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10a]) by forward100p.mail.yandex.net (Yandex) with ESMTP id C6325510229B for ; Thu, 21 Dec 2017 19:00:18 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id mXWdCPEjlX-0IvmWjus; Thu, 21 Dec 2017 19:00:18 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bLqbqs0pBY-0IP0dSWu; Thu, 21 Dec 2017 19:00:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 21 Dec 2017 19:00:14 +0300 Message-Id: <1513872016-2819-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513872016-2819-1-git-send-email-odpbot@yandex.ru> References: <1513872016-2819-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 359 Subject: [lng-odp] [PATCH CATERPILLAR v1 2/4] linux-gen: extend ethtool helper functions 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Mykyta Iziumtsev Add helper function to query RX/TX queue lengths on network interface to facilitate upcoming native and mediated device drivers. Signed-off-by: Mykyta Iziumtsev --- /** Email created from pull request 359 (MykytaI:caterpillar_mdev_auxiliary) ** https://github.com/Linaro/odp/pull/359 ** Patch: https://github.com/Linaro/odp/pull/359.patch ** Base sha: 63fd88635cc10caaa02fdccd3f52c9494487bdd2 ** Merge commit sha: 0e9885d54ac547d0bdf599d65b6fe32de445adb7 **/ platform/linux-generic/pktio/ethtool.c | 19 +++++++++++++++++-- platform/linux-generic/pktio/ethtool.h | 27 +++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/pktio/ethtool.c b/platform/linux-generic/pktio/ethtool.c index b71666a32..119ad75a4 100644 --- a/platform/linux-generic/pktio/ethtool.c +++ b/platform/linux-generic/pktio/ethtool.c @@ -159,12 +159,27 @@ static int ethtool_stats(int fd, struct ifreq *ifr, odp_pktio_stats_t *stats) return 0; } -int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats) +int ethtool_stats_get_fd(int fd, const char *netif_name, + odp_pktio_stats_t *stats) { struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", netif_name); return ethtool_stats(fd, &ifr, stats); } + +int ethtool_ringparam_get_fd(int fd, const char *netif_name, + struct ethtool_ringparam *param) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", netif_name); + + param->cmd = ETHTOOL_GRINGPARAM; + ifr.ifr_data = (void *)param; + + return ioctl(fd, SIOCETHTOOL, &ifr); +} diff --git a/platform/linux-generic/pktio/ethtool.h b/platform/linux-generic/pktio/ethtool.h index c5a811238..c330c2e31 100644 --- a/platform/linux-generic/pktio/ethtool.h +++ b/platform/linux-generic/pktio/ethtool.h @@ -7,9 +7,32 @@ #ifndef ODP_PKTIO_ETHTOOL_H_ #define ODP_PKTIO_ETHTOOL_H_ +#include + +/** + * Get statistics for a network interface + * + * @param fd Arbitrary socket file descriptor + * @param netif_name Network interface name + * @param stats[out] Output buffer for counters + * + * @retval 0 on success + * @retval != 0 on failure + */ +int ethtool_stats_get_fd(int fd, const char *netif_name, + odp_pktio_stats_t *stats); + /** - * Get ethtool statistics of a packet socket + * Get RX/TX queue parameters for a network interface + * + * @param fd Arbitrary socket file descriptor + * @param netif_name Network interface name + * @param param[out] Output buffer for parameters + * + * @retval 0 on success + * @retval != 0 on failure */ -int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats); +int ethtool_ringparam_get_fd(int fd, const char *netif_name, + struct ethtool_ringparam *param); #endif /*ODP_PKTIO_ETHTOOL_H_*/