From patchwork Thu Dec 21 17:00:23 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: 122587 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1152662qgn; Thu, 21 Dec 2017 09:05:13 -0800 (PST) X-Google-Smtp-Source: ACJfBovwDJZqwdtGpN+e9R1yhTJphbFiEp1iZ//s+qJ3WSMQbIeywzZGn/7MKqaohqiCRn9dvNFY X-Received: by 10.55.74.144 with SMTP id x138mr14420606qka.239.1513875913783; Thu, 21 Dec 2017 09:05:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513875913; cv=none; d=google.com; s=arc-20160816; b=sn4KrEYbDIevi+75alppIuCBmrclalEfsedqzVWPH/NfC0v/OIOnYUa+qx/BVhn9+R D06TGuV3pGrQR2dhhMS8Xk7iF+RXVj08pTSvOGzuMTQJVMpbnWfJBnJBb4DltjHQc3df ylDiyQ6hpsgPpSvmGQMbXPwsELUGv0oFYUJErudW58CaEpbMtErZ4fdRFGK8ynHc+X7A NNROp8O/nkftcPNBw919V1me9dlGe5/+njIwq05yk2wFFRzg+NY7WCENkwNMMAT7XOJv RiG3vY0yEyTIEQQYyG4NpeMKEMV4i2YrZHJiT+ImGO1SuXRi+t6/EQgPw6PxhMZvSXDX XX+Q== 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=rENIsCSpEY3ptaIoACcvlVl23r7f1eDIaBdY2259PWs=; b=x4pTFm5g89FiL09PEGTCbIE5QCHkv0LaAISR3o9kWMOJupLOOaiY1ohWr5nVOcAT99 a6FJDx1NrCBm6ZnaehNoRK75RZUkuHRh9qMMeVaJB47hrsR/pe8bHbK5k2PknxNdAF4d VVX4s9Z/VOOvgNdKcsUpuujBYyhTe1IcMNlby7KoXW/bD2W2ftpmFbFzQhrz66lKKc3K f2mZ4FRJhIRYY+MYdf74DlujpQMTiYGhatcmLbdcei6xr8ZNMYFx1u14OKX55vJ0XiuP OUqlpYNpE9igzeGo4jQk1/tEq5AA0+4+jM7kJvUNoNBXWAC5K7gs69/wVTyjm4mGbklz YWNw== 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 j126si3546148qkd.53.2017.12.21.09.05.13; Thu, 21 Dec 2017 09:05:13 -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 645576171E; Thu, 21 Dec 2017 17:05:13 +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 74E7860C31; Thu, 21 Dec 2017 17:02:09 +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 E6A5E6096B; Thu, 21 Dec 2017 17:01:56 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 0706E60997 for ; Thu, 21 Dec 2017 17:00:36 +0000 (UTC) Received: from mxback12j.mail.yandex.net (mxback12j.mail.yandex.net [IPv6:2a02:6b8:0:1619::87]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 29127510280E for ; Thu, 21 Dec 2017 20:00:34 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback12j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id t9fOaDfKhg-0YNiseFH; Thu, 21 Dec 2017 20:00:34 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id x1tp8yxdAP-0X7mnxmo; Thu, 21 Dec 2017 20:00:33 +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 20:00:23 +0300 Message-Id: <1513875625-25260-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513875625-25260-1-git-send-email-odpbot@yandex.ru> References: <1513875625-25260-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 359 Subject: [lng-odp] [PATCH CATERPILLAR v2 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: d90db23824f481750cb9bfe1de16df25e2b1767a **/ 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_*/