From patchwork Tue Apr 5 13:20:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 65071 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp461513lbc; Tue, 5 Apr 2016 06:21:24 -0700 (PDT) X-Received: by 10.107.134.84 with SMTP id i81mr18197864iod.99.1459862484346; Tue, 05 Apr 2016 06:21:24 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k9si12682567igg.39.2016.04.05.06.21.23; Tue, 05 Apr 2016 06:21:24 -0700 (PDT) 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; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id C442E61958; Tue, 5 Apr 2016 13:21:23 +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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 2F8CF61895; Tue, 5 Apr 2016 13:20:53 +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 DD9B66181B; Tue, 5 Apr 2016 13:20:44 +0000 (UTC) Received: from demumfd001.nsn-inter.net (demumfd001.nsn-inter.net [93.183.12.32]) by lists.linaro.org (Postfix) with ESMTPS id AC69261817 for ; Tue, 5 Apr 2016 13:20:43 +0000 (UTC) Received: from demuprx017.emea.nsn-intra.net ([10.150.129.56]) by demumfd001.nsn-inter.net (8.15.2/8.15.2) with ESMTPS id u35DKgkH005129 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Apr 2016 13:20:42 GMT Received: from 10.144.19.15 ([10.144.104.112]) by demuprx017.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id u35DKfpZ003126 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Tue, 5 Apr 2016 15:20:42 +0200 From: Matias Elo To: lng-odp@lists.linaro.org Date: Tue, 5 Apr 2016 16:20:41 +0300 Message-Id: <1459862441-28467-2-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459862441-28467-1-git-send-email-matias.elo@nokia.com> References: <1459862441-28467-1-git-send-email-matias.elo@nokia.com> X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 2082 X-purgate-ID: 151667::1459862442-00001B3D-DFBB5C90/0/0 X-Topics: patch Subject: [lng-odp] [PATCH 2/2] linux-generic: dpdk: 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" Copied pktio statistics implementation from odp-dpdk branch. Signed-off-by: Matias Elo --- platform/linux-generic/pktio/dpdk.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 57625dc..4318a9f 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -580,6 +580,8 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, odp_ticketlock_init(&pkt_dpdk->tx_lock[i]); } + rte_eth_stats_reset(pkt_dpdk->port_id); + return 0; } @@ -905,6 +907,41 @@ static int dpdk_link_status(pktio_entry_t *pktio_entry) return link.link_status; } +static void stats_convert(const struct rte_eth_stats *rte_stats, + odp_pktio_stats_t *stats) +{ + stats->in_octets = rte_stats->ibytes; + stats->in_ucast_pkts = 0; + stats->in_discards = rte_stats->imissed; + stats->in_errors = rte_stats->ierrors; + stats->in_unknown_protos = 0; + stats->out_octets = rte_stats->obytes; + stats->out_ucast_pkts = 0; + stats->out_discards = 0; + stats->out_errors = rte_stats->oerrors; +} + +static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) +{ + int ret; + struct rte_eth_stats rte_stats; + + ret = rte_eth_stats_get(pktio_entry->s.pkt_dpdk.port_id, &rte_stats); + + if (ret == 0) { + stats_convert(&rte_stats, stats); + return 0; + } else { + return (ret > 0) ? -ret : ret; + } +} + +static int dpdk_stats_reset(pktio_entry_t *pktio_entry) +{ + rte_eth_stats_reset(pktio_entry->s.pkt_dpdk.port_id); + return 0; +} + const pktio_if_ops_t dpdk_pktio_ops = { .name = "dpdk", .init_global = odp_dpdk_pktio_init_global, @@ -914,6 +951,8 @@ const pktio_if_ops_t dpdk_pktio_ops = { .close = dpdk_close, .start = dpdk_start, .stop = dpdk_stop, + .stats = dpdk_stats, + .stats_reset = dpdk_stats_reset, .recv_queue = dpdk_recv_queue, .send_queue = dpdk_send_queue, .link_status = dpdk_link_status,