From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id C10153977 for ; Wed, 3 Oct 2018 09:22:28 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id o14-v6so4133127ljj.2 for ; Wed, 03 Oct 2018 00:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZnwV6/aiEULTPJmZtFA50sMQPp36Bln0Xo62SV9W4So=; b=X3ivL/3aiKYn0+3gk0PfZwXfPLNu4V6EwsCLVSDorxR+xFfibKlozjqyUg1u52MFnk HXjpPAilGEemq+Za0yx79KVmem7KiQ+xNGCEAGTJEB4L3fEUldtE1Abmh+O+Hzcxn1pH bmPJHCmHLIvCC7jSuqaC071I0oyvyy6L9Q+904ZlZXDBHXQdqZ+tQSDtpxSHL7OYb7lI PG7M8Ec/1KFO9mPyfuDq32R7IzJ58dGHHNCwZzmH4JofpOguZYPU9ADUK4AWUF9fjE52 Xn/o/auKsb6Eqrz+hxXMuTgMgQvjgFKfQfSOCmD0cS8/YzsxG7IK2KK6D69Bd14s/20J D2ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZnwV6/aiEULTPJmZtFA50sMQPp36Bln0Xo62SV9W4So=; b=ck/bqpBzk0xwaWFs7eZiILSC2+96h3sbyD6JVzWyjuHemmXauHAofUf1YGaiJ1NoTa 15wxktMDfy19Dc7/vub1HiXHCWRaJrVL8Md4yjbssdQ2l70q9R/c3kXagzLuj4ZnXfOr VhNmF2vr0c4zkiaJydmYW7a7eOF4nuR63FgM1bzPteHlsDgCkC1oAVMQbtSZHYfTat8o xUSCtwiYl6+9flNrwCXEbp+Op2ZtslSYMqiBlpPpxIWE7sJV3Tdu/FXbewT0xDTZ8vLn WGtmgAK533INKOF5hLcqeK66OFYiC7GWpF25yaJLpcYRDazSa9Y5kLMExZQvF0GBfcBW C7EA== X-Gm-Message-State: ABuFfoieYJdXouZLGM75LmJztu3D/sX3GsdvtYc3pIPtzCyzzi7ZeWZc Y8SDO2wIEhoMsp9IwBpTfLGB3S3eMAFPkg== X-Google-Smtp-Source: ACcGV63j8oFXPIAz+Ho0A/vubXNu8AUMscq5V+wAZ96vl3qGcMdMZ6in5zquY6CrWLS1RI4sb1V8Ww== X-Received: by 2002:a2e:5c89:: with SMTP id q131-v6mr142148ljb.119.1538551348191; Wed, 03 Oct 2018 00:22:28 -0700 (PDT) Received: from amok.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.googlemail.com with ESMTPSA id f73-v6sm123659lfl.80.2018.10.03.00.22.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Oct 2018 00:22:27 -0700 (PDT) From: Andrzej Ostruszka X-Google-Original-From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, nadavh@marvell.com, zr@semihalf.com, tdu@semihalf.com, Natalie Samsonov Date: Wed, 3 Oct 2018 09:22:16 +0200 Message-Id: <1538551336-19259-9-git-send-email-andrzej.ostruszka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538551336-19259-1-git-send-email-andrzej.ostruszka@gmail.com> References: <1538385970-21260-1-git-send-email-andrzej.ostruszka@gmail.com> <1538551336-19259-1-git-send-email-andrzej.ostruszka@gmail.com> Subject: [dpdk-dev] [PATCH v7 8/8] net/mvneta: add reset statistics callback X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Oct 2018 07:22:29 -0000 From: Natalie Samsonov Add support for resetting of driver statistics. Signed-off-by: Natalie Samsonov --- drivers/net/mvneta/mvneta_ethdev.c | 40 +++++++++++++++++++++++++++++++------- drivers/net/mvneta/mvneta_ethdev.h | 1 + 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c index d004bfd..f7071bc 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -695,23 +695,48 @@ mvneta_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->ipackets += ppio_stats.rx_packets + ppio_stats.rx_broadcast_packets + - ppio_stats.rx_multicast_packets; + ppio_stats.rx_multicast_packets - + priv->prev_stats.ipackets; stats->opackets += ppio_stats.tx_packets + ppio_stats.tx_broadcast_packets + - ppio_stats.tx_multicast_packets; - stats->ibytes += ppio_stats.rx_bytes; - stats->obytes += ppio_stats.tx_bytes; + ppio_stats.tx_multicast_packets - + priv->prev_stats.opackets; + stats->ibytes += ppio_stats.rx_bytes - priv->prev_stats.ibytes; + stats->obytes += ppio_stats.tx_bytes - priv->prev_stats.obytes; stats->imissed += ppio_stats.rx_discard + - ppio_stats.rx_overrun; + ppio_stats.rx_overrun - + priv->prev_stats.imissed; stats->ierrors = ppio_stats.rx_packets_err + ppio_stats.rx_errors + - ppio_stats.rx_crc_error; - stats->oerrors = ppio_stats.tx_errors; + ppio_stats.rx_crc_error - + priv->prev_stats.ierrors; + stats->oerrors = ppio_stats.tx_errors - priv->prev_stats.oerrors; return 0; } +/** + * DPDK callback to clear device statistics. + * + * @param dev + * Pointer to Ethernet device structure. + */ +static void +mvneta_stats_reset(struct rte_eth_dev *dev) +{ + struct mvneta_priv *priv = dev->data->dev_private; + unsigned int ret; + + if (!priv->ppio) + return; + + ret = mvneta_stats_get(dev, &priv->prev_stats); + if (unlikely(ret)) + RTE_LOG(ERR, PMD, "Failed to reset port statistics"); +} + + static const struct eth_dev_ops mvneta_ops = { .dev_configure = mvneta_dev_configure, .dev_start = mvneta_dev_start, @@ -727,6 +752,7 @@ static const struct eth_dev_ops mvneta_ops = { .mac_addr_set = mvneta_mac_addr_set, .mtu_set = mvneta_mtu_set, .stats_get = mvneta_stats_get, + .stats_reset = mvneta_stats_reset, .dev_infos_get = mvneta_dev_infos_get, .dev_supported_ptypes_get = mvneta_dev_supported_ptypes_get, .rxq_info_get = mvneta_rxq_info_get, diff --git a/drivers/net/mvneta/mvneta_ethdev.h b/drivers/net/mvneta/mvneta_ethdev.h index 836a5e9..101b0a8 100644 --- a/drivers/net/mvneta/mvneta_ethdev.h +++ b/drivers/net/mvneta/mvneta_ethdev.h @@ -66,6 +66,7 @@ struct mvneta_priv { struct neta_ppio_params ppio_params; uint64_t rate_max; + struct rte_eth_stats prev_stats; }; /** Current log type. */ -- 2.7.4