From patchwork Fri Jan 22 12:07:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 60134 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp628180lbb; Fri, 22 Jan 2016 04:09:08 -0800 (PST) X-Received: by 10.50.117.33 with SMTP id kb1mr3273769igb.89.1453464548732; Fri, 22 Jan 2016 04:09:08 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 7si11782302ioa.202.2016.01.22.04.09.08; Fri, 22 Jan 2016 04:09:08 -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 085BD617E5; Fri, 22 Jan 2016 12:09:08 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=imr8m9e1; 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 4B30E617EA; Fri, 22 Jan 2016 12:07:29 +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 2BF87617E6; Fri, 22 Jan 2016 12:07:16 +0000 (UTC) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com [209.85.217.177]) by lists.linaro.org (Postfix) with ESMTPS id 8DDF0616C2 for ; Fri, 22 Jan 2016 12:07:12 +0000 (UTC) Received: by mail-lb0-f177.google.com with SMTP id cl12so39907788lbc.1 for ; Fri, 22 Jan 2016 04:07:12 -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=AtQIzzT2ltDCzl4iX5jiOtE32SutlJC1UQl9oCof4VQ=; b=imr8m9e1UEdF3OKcUSqDzyw5VzboJBQxjKSTUf1lRKTNsmpX0MSTMUT6NH7xuiIo1a hOJAmkFp0LpzmOouMOCvVFZTy8EpaeoTI23g0oqzKMRmCuM5LGkEqBBDMNXdMlBzAYBc gG/zquX3UbVv7bhcF8ZrkhmjCkq7GihibANjY= 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=AtQIzzT2ltDCzl4iX5jiOtE32SutlJC1UQl9oCof4VQ=; b=ge5eFlKqORln6Vu8qIcG9T5ti9sSOARYtJRCkRJvPUex5F0zR+EH2ZkrujzXoQWMM/ ObWrq7wS9U9rLJv66k0BT7XdBfgmw81Zo+VOJ5qwVQ2y0Q8plGLFBYP9wyqZu6A8U+Ql V+K/WJvYwaxFZR1RWEP2tBzxvnkoUzJAgETcJr/nv2SQ16PjuB/PRRXjOEahcTNxk3du HI5NoVTywtzTcnFz+ddzHnadG16S+Z/uUxzqqnjChZN3wwRSl6OzDaifzqDovo35/Yfc paiUSWG/icdFxFf8RYRmJX0RjUWEu/oIR+mUcG/GsfqqV+eU3wLDuUX4v9T7b5j0tzlL IaAg== X-Gm-Message-State: AG10YOQZGnsvI5lgfv4HncnWxaXHsesxLniwOgupBb/0fW2syuW6mjhVZbFLRVUDWCFRL6GT4zU= X-Received: by 10.112.12.2 with SMTP id u2mr1082100lbb.145.1453464431181; Fri, 22 Jan 2016 04:07:11 -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 wj2sm828569lbb.5.2016.01.22.04.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jan 2016 04:07:10 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 22 Jan 2016 15:07:01 +0300 Message-Id: <1453464424-28454-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453464424-28454-1-git-send-email-maxim.uvarov@linaro.org> References: <1453464424-28454-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv6 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 | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index ed5159b..6baeba4 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,21 @@ 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); + memset(&pktio_entry->s.stats, 0, sizeof(odp_pktio_stats_t)); + 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 +869,29 @@ 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) + 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 +901,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,