From patchwork Fri Dec 22 11:00:15 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: 122644 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2101517qgn; Fri, 22 Dec 2017 03:08:41 -0800 (PST) X-Google-Smtp-Source: ACJfBou5Lo0d53iYVHYbHbwLWVeu9vk4Pc2xINcc5EuLLpnIc//Tm7TfkdPwTw/pdIJurPAl5EKk X-Received: by 10.55.185.132 with SMTP id j126mr18877971qkf.275.1513940921437; Fri, 22 Dec 2017 03:08:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513940921; cv=none; d=google.com; s=arc-20160816; b=W9ZIR7naNN2KDeMoKIllNCErqDppWFnKvIIYookPUIZB+Kk1l8ot4zE6E/OUmbV2oW 83tQrgtwkxyrIajQupCDPUQeubO413ht6Cp3m2nUB+yvRmTupkC8Yli3X+z688qGKR4C 2pU9mfNX00KOvR+Qg5V41+4oCTsWRl11u4qdjyiwzdu4VadIcA0yDWKZUBnVQ+YW4LwY ZzRlVm8qa3sPLf2i2gp9TbDoMkAPkFywZFQf7FxAciq4wzrutLW7tQ4qLpw9s67NDSX+ GlRtiItlDb0F0fxGmo2FCK1W/8w5wYC1NlO2OlX1jf0NAewZqFWT8hGqLJX4IIG4At9D XOaQ== 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=6mUfz7kUZ0z1olsbnPE3rMI2BrjCA7n8OebdLBder9E=; b=oUjDpvltcYIMbb8HA1KqN/s67kgHJvQJRqNb30sDHgw8tSIIxJvNmwTTjKvs7l7HR8 LC8TxKKXRAfjWlNhdu6K6A48C4rtDOQcxgZOong3AbdthbW/yWf9MLJNI7rYdj6Ob4Qq a60o8NffHSoB0rzzGwVZZQID4k39/uQYOusZidmytQIAUlqQMPS9ddJuvqv4txQppDfP Fdnc1kl8nVWCSIeVadYxd9YngheoS2onctQPK6bI9WZmAFRlrDDUKnwUpPdHor2u2TxC 5WLwh/B21nQ1CPos4ya0I5q6pT5mIU5aoKffvQZcLoHTrmnBsMCvF4LCameKzDPiUewB egQA== 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 y126si320744qkc.333.2017.12.22.03.08.41; Fri, 22 Dec 2017 03:08:41 -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 195EE61767; Fri, 22 Dec 2017 11:08:41 +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 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 C9EC46171A; Fri, 22 Dec 2017 11:01:43 +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 9330161508; Fri, 22 Dec 2017 11:01:33 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id 37CBE6150D for ; Fri, 22 Dec 2017 11:00:21 +0000 (UTC) Received: from mxback7o.mail.yandex.net (mxback7o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::21]) by forward106j.mail.yandex.net (Yandex) with ESMTP id C6C091804103 for ; Fri, 22 Dec 2017 14:00:19 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback7o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id toVc4Oj8PC-0JtqaNb6; Fri, 22 Dec 2017 14:00:19 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id EWw1bAbGHJ-0J5S3D0Q; Fri, 22 Dec 2017 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: Fri, 22 Dec 2017 14:00:15 +0300 Message-Id: <1513940417-8765-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513940417-8765-1-git-send-email-odpbot@yandex.ru> References: <1513940417-8765-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 359 Subject: [lng-odp] [PATCH CATERPILLAR v3 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: 236ad276c55ab617e42fb2b92f40afdb8c4bb1ee **/ 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_*/