From patchwork Tue Jan 2 11:00:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123123 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8827500qgn; Tue, 2 Jan 2018 03:03:54 -0800 (PST) X-Google-Smtp-Source: ACJfBotlMbSQIETncIknvx2Lx7DyME5ZeGLTMn/LjzUqmQA5RlajtSgohOlJhJnqEFA62gGfMAt8 X-Received: by 10.55.77.150 with SMTP id a144mr24999953qkb.273.1514891034223; Tue, 02 Jan 2018 03:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514891034; cv=none; d=google.com; s=arc-20160816; b=wPlBbKW1tN+W2lwgKGTvEzJ4q3GWYwPyFmgqeoLSQrFluBS5Afn3BO11R+sG7+AmBx Cdwhk59RUsLTMPHjXPGtMKd/0dzHnpXnzaJcbyYjsa35VMBAH00B00HVoOGgScdefP8E fl3Buuhn4ifGYk278HQ9xYZcdkk4lY+z0ijxWgYTQVJUhJdqMBeiFRvoffRStWLH/hgl MblXRorKa8vcrg1HamEkWGCojjUVkndARNd9ePQB5gwNU51p1ZW8zno4jdATI8EhIBn1 Ir8QGwnoRRSUheeO1qaUUG+mocyn2RCT8OmGJ+wVnw4QGVCp8WoV71vOfxuq9LhUsXZO 1i0Q== 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=ivzdujF45lSOS4nq6RLIwW9Ze6oQapuDaMRYv4SYZ2o=; b=NvX4kHhmI3WNMp4G/4sEK/bQo4wKfRe0ltqEndCWmecgjFtROt1yJs7xujfmtluOsR OWXnNLRzryWBUGdYpprRvfrwhwUyr0+TbJbMEQWoQTmFvDd+ebJ0m38YNA/QNnb8UMOY ynCA8LsvWJI9lqww5GhgCWAoYzlp/4sSc5FYrSPEohjCBgAZOng3ezmm+lGePw84qWtL aDqRTG259MOIpjeMMVKCD9lYHFy/wA1gPLiBG3cq1gbwlnZxEn0J0vlMfGIlzmUbJ5nJ bgmMPQznz5x0aJnoE6SGGHVTcGdl3ac2imhTfauhiYJLRzJCQhqEsdU1sRmzFtTM6t3Z ma+w== 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 u63si1010783qkc.53.2018.01.02.03.03.54; Tue, 02 Jan 2018 03:03:54 -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 EBE6B6152B; Tue, 2 Jan 2018 11:03:53 +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_H3,RCVD_IN_MSPIKE_WL,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 3E44E608E7; Tue, 2 Jan 2018 11:00:44 +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 DFC7C6084A; Tue, 2 Jan 2018 11:00:27 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id 155A16084A for ; Tue, 2 Jan 2018 11:00:21 +0000 (UTC) Received: from mxback11j.mail.yandex.net (mxback11j.mail.yandex.net [IPv6:2a02:6b8:0:1619::84]) by forward105j.mail.yandex.net (Yandex) with ESMTP id D57B118296B for ; Tue, 2 Jan 2018 14:00:19 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback11j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id QIm6gJ2Kn1-0JuuPNSk; Tue, 02 Jan 2018 14:00:19 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id il3rylQ92N-0JLKaCFK; Tue, 02 Jan 2018 14:00:19 +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: Tue, 2 Jan 2018 14:00:10 +0300 Message-Id: <1514890812-4276-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514890812-4276-1-git-send-email-odpbot@yandex.ru> References: <1514890812-4276-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 359 Subject: [lng-odp] [PATCH CATERPILLAR v5 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: bbbe6c0ef65c16f6d7d327712f177fbf6740e96f ** Merge commit sha: 7766a11fc4f83aeb2d92df6ea192304b21572529 **/ 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_*/