From patchwork Tue Jan 26 16:00:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 60471 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2049049lbb; Tue, 26 Jan 2016 08:04:24 -0800 (PST) X-Received: by 10.140.101.70 with SMTP id t64mr28681965qge.61.1453824264142; Tue, 26 Jan 2016 08:04:24 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p47si1994629qge.79.2016.01.26.08.04.23; Tue, 26 Jan 2016 08:04:24 -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 AD58E61764; Tue, 26 Jan 2016 16:04:23 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=ImS1m3Uq; 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 6CD826176B; Tue, 26 Jan 2016 16:01:28 +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 A31B861709; Tue, 26 Jan 2016 16:00:55 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by lists.linaro.org (Postfix) with ESMTPS id EACE361690 for ; Tue, 26 Jan 2016 16:00:50 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id c192so107864763lfe.2 for ; Tue, 26 Jan 2016 08:00:50 -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=ngVqJx2bUucn076PQeN8zOiu0G/YblEeoF97gZYTS48=; b=ImS1m3UqpQUW+OU59zkp0Gm6Z8WNnj7hA5YtknppkZ5557Avg1uV4XiaXsuPwg/Pm0 b6HAbrEvDT1jLJrg4DyFq9i3jxfKnkRX7NNFI4QBFad6WPa0pZ9Qb8uFPdn1XEdtInnK vmDiYzDeJwA2eccKBmj6rqvmYp6sOM6Fz4EBI= 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=ngVqJx2bUucn076PQeN8zOiu0G/YblEeoF97gZYTS48=; b=Z4H7oGnMmI/U0sZTavR/kfQcBKu5nW/TgCchrHqVDRWkX8rT9/Sqpd+iT+5+6lLFOn NjPv6QNVoCT+eMEPc6KQzBkrKFKMnaGeOxiqgob6z1ivFW3RJJdODEKF2v5VFMUpGz0K fo1gFhprMU/qedpdXcLNXx4B7uniFkwKuDEXnnENGtJ9KjbUj0JzgsdMr7V2ioeFOaFv yIziLAZdcTRqr09/f+DBZes2Y2LFZXLNuqZVAFxUcIsRWbpoWpFwdGj7dX45MULjR+9E gb5Y2yVRA6JKKMKujEb+xyxER8mkZl4lmL/cXCWKF1vWSiDvA9X7s71mGamEekbmv2v0 Xr9g== X-Gm-Message-State: AG10YOR/VRJAkrgVx16AbfWlbgqNPYte91LWJWy72u1W2wSl52hbti2aH1Z3LVR5Sqka1bskzDM= X-Received: by 10.25.212.11 with SMTP id l11mr8991946lfg.118.1453824049670; Tue, 26 Jan 2016 08:00:49 -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 f186sm254394lfd.26.2016.01.26.08.00.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jan 2016 08:00:49 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 26 Jan 2016 19:00:39 +0300 Message-Id: <1453824042-29478-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453824042-29478-1-git-send-email-maxim.uvarov@linaro.org> References: <1453824042-29478-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv8 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 2a14861..16898ec 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -35,6 +35,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) { @@ -255,6 +257,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; @@ -345,6 +348,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: @@ -773,6 +790,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, @@ -782,6 +824,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,