From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by dpdk.org (Postfix) with ESMTP id 058B15B2E for ; Wed, 19 Sep 2018 17:01:52 +0200 (CEST) Received: by mail-lf1-f52.google.com with SMTP id x20-v6so5438997lfg.2 for ; Wed, 19 Sep 2018 08:01:52 -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=J/Mpxh0iAbquGER4dyKuSlIWsF8x+BHd1AY1KimlB6M=; b=BnCB7MtSnxJB81IrU7jQsYwZTYfXiPVqEyZnGt9cmjX8hUXDaHhdcgs+AHYM7dNWpL niK1RW6p+g3sDCuM4q/EeO0kU3RCO3wwq1vNaXvD5EkmKZtw44sqvsYCluynWZooBnv+ QF+vCg+YhvC6Z9TWWX1DYlvr/vLbGdM2xti2vhxwOBSsbQNkApbc23l80WGZj157SpQI eWeHByFtJQ1tfQHjdxwua08Ey8n8pt4YSA6Uhjl6xQuFJQiF+D11FUKDKE/b6KzUFs1g QglhdXF/FHGRvYwimUne3ImBY0UY0a8zPQa9Sv163pl6DSYxPkxFfximnGbkD9pSDHxk r28A== 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=J/Mpxh0iAbquGER4dyKuSlIWsF8x+BHd1AY1KimlB6M=; b=LL6I2ad0s7Iv0dQ/9IjchvixW0U8O5JV3Zf/hf7VjGgKBir9NbmzOP5tPJ1Hb0uNvf TGnmTU52EYIhq5f0GTsODpl+uOgOhfvA2LTwa4na+EZZdttEpx5Mv3Utaf31NCtkb8hW 4onD1F08Trx6mLfHMUQesFlwb86e6S0kMEkgnebsyGoUxxvlz/ikz4o9HYQJKePXFmul sBcSx0iOmiOWnZDvIA0kEPra8VkZc/6KjTcIf4jxmqb0yv/IEeel8zgXoZGhAdg3CvJg C4Qdq89Z41yYktg8M5dtuFle9pqt8crUpwQm40YyfzoTHcAdLgu2ywER1FtfE5EGeRjV vteQ== X-Gm-Message-State: APzg51AefcDJlriV3Pj3iEMu+MidL5isKAdMoS0v6B7kLCns6MbFTNyn aZKDdpoE5J3xLBe+IZ+iQU+6zFE90Nw= X-Google-Smtp-Source: ANB0VdY/agRWXs1R+Z8fzXYjoAGaujgia7CtYr8MI6GhxJHrHkW9j48CzI77uTrlSGD1+BwHcmzdkg== X-Received: by 2002:a19:9601:: with SMTP id y1-v6mr23896763lfd.91.1537369307396; Wed, 19 Sep 2018 08:01:47 -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 z3-v6sm1107711lfj.89.2018.09.19.08.01.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Sep 2018 08:01:45 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, zr@semihalf.com, tdu@semihalf.com, nadavh@marvell.com, Natalie Samsonov Date: Wed, 19 Sep 2018 17:01:34 +0200 Message-Id: <1537369294-17099-9-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537369294-17099-1-git-send-email-amo@semihalf.com> References: <1535720386-18775-1-git-send-email-amo@semihalf.com> <1537369294-17099-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v4 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, 19 Sep 2018 15:01:53 -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 3ea1dba..40c33cd 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -720,23 +720,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, @@ -752,6 +777,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 1a78a41..eeea31a 100644 --- a/drivers/net/mvneta/mvneta_ethdev.h +++ b/drivers/net/mvneta/mvneta_ethdev.h @@ -67,6 +67,7 @@ struct mvneta_priv { uint16_t nb_rx_queues; uint64_t rate_max; + struct rte_eth_stats prev_stats; }; /** Current log type. */ -- 2.7.4