From patchwork Fri Jan 22 12:45:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 60145 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp649853lbb; Fri, 22 Jan 2016 04:46:39 -0800 (PST) X-Received: by 10.50.137.40 with SMTP id qf8mr3435067igb.8.1453466799873; Fri, 22 Jan 2016 04:46:39 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s67si11969740ioi.154.2016.01.22.04.46.38; Fri, 22 Jan 2016 04:46:39 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BB41B617AA; Fri, 22 Jan 2016 12:46:37 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=XY9lsGHF; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 4A7A2617E4; Fri, 22 Jan 2016 12:46:01 +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 D911A617D0; Fri, 22 Jan 2016 12:45:54 +0000 (UTC) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by lists.linaro.org (Postfix) with ESMTPS id 3B1FB617D0 for ; Fri, 22 Jan 2016 12:45:53 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id c192so46185610lfe.2 for ; Fri, 22 Jan 2016 04:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t0PwgllrMIud4eDLNwL8anAIj7NZc+267NGAigXtUGA=; b=XY9lsGHFhf7AWoO8Jp/mVnkZEMDoBrLyyTzLDv5k0qZrzBz2EtkCqsVFpCkjhdXcnu xZI8DmXaSd2KzB9tZH6FnP53pgLanR2M7fyHdXULCHNn4wTqwb2PPvWxmjD6lSMmnN1N s6Obdfkoxz86Y6OmC3SQ7pA0KHcMwzrZQeD5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t0PwgllrMIud4eDLNwL8anAIj7NZc+267NGAigXtUGA=; b=cWpIRS8RTX8kbb79Ju6JUPAgZJoJT4na3hq3vr/BXh3GelUSR47WVX9JgJq55pxuzi myVMN+lvZTa/RbLQIrkOstmsBccKODukOmXqzHjGYpSf+g85fwVwpCSYHcvBBIi3+An7 aLW4kMO8BcIS7Idvull/dpXtEjCqMX6KWKR3Awe7ju3D+nHYTDwFm5S3HH8bMW88qXI+ rHnDI0CnAP/Mo1eE6nziwQ6ZDAjmt3ILdHijl+Xhu5VrknOpdJgRF54HMnqeEaHdqe3z 2SbWUiLHfra8KKy7GEzU4pdI7G7U5N35gyjNJIL3YSQSZNsml7ecX7aKT5MEaaFpZylP e6Vg== X-Gm-Message-State: AG10YOTfHjkh61xZauZgSdTugRVEe2TtJ0Ouw6XaKYrE0QQ49Zw8IepZh3Z98P6fcb7vB9wpjNc= X-Received: by 10.25.161.6 with SMTP id k6mr1144403lfe.17.1453466752227; Fri, 22 Jan 2016 04:45:52 -0800 (PST) Received: from localhost.localdomain (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.gmail.com with ESMTPSA id l67sm880998lfi.2.2016.01.22.04.45.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jan 2016 04:45:51 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 22 Jan 2016 15:45:37 +0300 Message-Id: <1453466740-11943-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453466740-11943-1-git-send-email-maxim.uvarov@linaro.org> References: <1453466740-11943-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv7 2/5] linux-generic: netmap: implement pktio statistics 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Maxim Uvarov --- platform/linux-generic/pktio/netmap.c | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index ed5159b..a3c7a53 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -37,6 +37,8 @@ #define NM_WAIT_TIMEOUT 5 /* netmap_wait_for_link() timeout in seconds */ #define NM_INJECT_RETRIES 10 +static int netmap_stats_reset(pktio_entry_t *pktio_entry); + static int netmap_do_ioctl(pktio_entry_t *pktio_entry, unsigned long cmd, int subcmd) { @@ -348,6 +350,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, struct nm_desc *desc; struct netmap_ring *ring; odp_pktin_hash_proto_t hash_proto; + odp_pktio_stats_t cur_stats; if (getenv("ODP_PKTIO_DISABLE_NETMAP")) return -1; @@ -438,6 +441,20 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, odp_ticketlock_init(&pkt_nm->tx_desc_ring[i].s.lock); } + /* netmap uses only ethtool to get statistics counters */ + err = ethtool_stats_get_fd(pktio_entry->s.pkt_nm.sockfd, + pktio_entry->s.name, + &cur_stats); + if (err) { + ODP_ERR("netmap pktio %s does not support statistics counters\n", + pktio_entry->s.name); + pktio_entry->s.stats_type = STATS_UNSUPPORTED; + } else { + pktio_entry->s.stats_type = STATS_ETHTOOL; + } + + (void)netmap_stats_reset(pktio_entry); + return 0; error: @@ -851,6 +868,31 @@ static int netmap_pktout_queues(pktio_entry_t *pktio_entry, return num_queues; } +static int netmap_stats(pktio_entry_t *pktio_entry, + odp_pktio_stats_t *stats) +{ + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { + memset(stats, 0, sizeof(*stats)); + return 0; + } + + return sock_stats_fd(pktio_entry, + stats, + pktio_entry->s.pkt_nm.sockfd); +} + +static int netmap_stats_reset(pktio_entry_t *pktio_entry) +{ + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { + memset(&pktio_entry->s.stats, 0, + sizeof(odp_pktio_stats_t)); + return 0; + } + + return sock_stats_reset_fd(pktio_entry, + pktio_entry->s.pkt_nm.sockfd); +} + const pktio_if_ops_t netmap_pktio_ops = { .name = "netmap", .init = NULL, @@ -860,6 +902,8 @@ const pktio_if_ops_t netmap_pktio_ops = { .start = netmap_start, .stop = netmap_stop, .link_status = netmap_link_status, + .stats = netmap_stats, + .stats_reset = netmap_stats_reset, .recv = netmap_recv, .send = netmap_send, .mtu_get = netmap_mtu_get,