From patchwork Fri Dec 22 12: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: 122648 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2158066qgn; Fri, 22 Dec 2017 04:03:24 -0800 (PST) X-Google-Smtp-Source: ACJfBov28lSiDaLTTz2UZG9eoArvj8GAQbaYQSOAe2UfpSXznrxo3jxxLTekBRp9dpMetq2PSfG/ X-Received: by 10.55.107.129 with SMTP id g123mr3914344qkc.353.1513944204012; Fri, 22 Dec 2017 04:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513944204; cv=none; d=google.com; s=arc-20160816; b=XLRWhG2dA++XEFayhSyTpeK4LDNVWIO5OfpFbCqdZgz/IeTg+zZuLzsRTGpymN40kg iB0P1Fh0VKdM77c1F1eVNaI5WQihzMDay9kTo6Fsviyyl9AjZlce5iBwBu3Dj3WJLWTg t6HfrRsHKAmKOD/eSV/Sl9Bwpwxlain9BNVYtx9LiAi80DuRbWfZPq+aUXDCJbn+QZx+ UOHItF3bUkuWnv/6rk5xLa0JmkuI1a5i1iPSGj1VzaSSl2V8b8OK6bZ8QKgagU98ojtK JP8Ak0U4SKo7Z8CTjzMjmdu6ISGDeEyLGurFy4TVLmBgkPnIpOmR+2Ev2w0if74zi8OH xCsA== 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=SouCRCdSYFjpLNvDTCDvvGdRrj8FrGWY3vg7lXhvoAE=; b=SHtvgkHKl8UM6Xw9Wp0U1RI6MSqCwJnDs3ME/zWNAehlo3g3cK90/dsoxXxkhX8Yaz 2+XaqmDHjhHs4TfnFa5FXZh1rKfM/N7kc+pAMLmC/YnJjEcuZh8iUsIfKvfwHFYsOdVg JPqqQGsWZFSebgeNNGHR+LhYuUKOyxAolqmeWVdhtohb6Op0sMxB6MiuguiSBs6DGc/P A8e71ZGiW2XkU+aEMOqmGoyQDpU6Wwwc2P4VbBR5oH8tziVKxu7E6kIqnG91Njp292O2 1ReQe1x2hMEGwWKG1h29Yy0a/C4b1DJw7Gznu5dK74rO5BvkZ1Q9e68r9KmXn5NOTfAO R3hg== 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 f77si5265448qki.178.2017.12.22.04.03.23; Fri, 22 Dec 2017 04:03:23 -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 A558661522; Fri, 22 Dec 2017 12:03:23 +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 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 5C0EF616E5; Fri, 22 Dec 2017 12:01:53 +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 6707861721; Fri, 22 Dec 2017 12:01:43 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 133136151D for ; Fri, 22 Dec 2017 12:00:55 +0000 (UTC) Received: from mxback10g.mail.yandex.net (mxback10g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:171]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 9D53751052DD for ; Fri, 22 Dec 2017 15:00:53 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback10g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id bTYwK7UYWm-0rxemAQT; Fri, 22 Dec 2017 15:00:53 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 7oecpqL4w1-0lMqI8C2; Fri, 22 Dec 2017 15:00:47 +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: Fri, 22 Dec 2017 15:00:14 +0300 Message-Id: <1513944016-27700-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513944016-27700-1-git-send-email-odpbot@yandex.ru> References: <1513944016-27700-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 359 Subject: [lng-odp] [PATCH CATERPILLAR v4 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: 2db210ebd4f03f71560747c008ba0754bfbc16f0 **/ 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_*/