From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by dpdk.org (Postfix) with ESMTP id 6E1F05F3D for ; Fri, 31 Aug 2018 14:59:58 +0200 (CEST) Received: by mail-lj1-f174.google.com with SMTP id 203-v6so9970363ljj.13 for ; Fri, 31 Aug 2018 05:59:58 -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=HPCe8+dphDyJouj+9BBARh0KCivb/kPpAsWuO9/6rZs=; b=KKHRXNE8hcsjpQVk9/aqv8ChA8lk1tE6hMNJxT9kPTu9O55+uJ1MpURXn+cDS+wkge VQ5e35GZn/7JRtj/bPL7Jdk/9wwU/bHCZaS/5imLKwTDonC16j74CFjnu39l2X5PuFgP PrdS5AbQaLne+6EDbRa+TeL9xdjwE08cD20xLumalMQ/Fdnt6U5SkDT+mPcpMU+/lZXm w0Z6GQu9YTxpTraxp8XNFz4QixDC8qZJIr9wDQicKXeFctnWUjtcJiYI1P/v4dwqu5d2 cna5kklJ5HOonXeAeuMOrvhWITaA5OgUuzKSWgtnY3yGcb7zQdfgtqf/16bztB62fHh8 sIHg== 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=HPCe8+dphDyJouj+9BBARh0KCivb/kPpAsWuO9/6rZs=; b=CiXtS4XfxaPhomC9hOdOOehKVt7CaaNpTZwwNKjgB2RtFQrP2sy5oFMCARNhewJgED CtBAuhD9Q42M2S7b3zFW7Ov6pM2Hf+nH49YDdsx4tzJ2XTYIWdkfAZpyujirThn+Wde3 fJhkZ3ZI8FiYOkjS+9dKhsV2pr4budrMQyX03AL/dVNWJF901pBkSusHZS+8t8yZvLSO KHRupO5Jrovid3tepNFSSCE7WnVL6CQWHio/gvctDLUrW+rkRDb4JwJjUAb6ZSo/0fqQ 1kxpj92a1M6VfcFanQ6mUg7c1n3CKcbVeop9/8cXHJMER75kf9nbU3RgYmMOFYz9mk4f tXaw== X-Gm-Message-State: APzg51CN4sI16E0eimhC/wF18SL66FnwNkFIMyQ9IMWzs+WUaUHR5xFD o83cqDeV1ThUuaSlLh4a+29lTJ82v0Y= X-Google-Smtp-Source: ANB0VdbGpgFAfkYkGHeE//XrSDgNM2spoQZT3rz2QofVHMvDY1jZuLd25s0u82/y1XMzhSwfbB+1tQ== X-Received: by 2002:a2e:4782:: with SMTP id u124-v6mr11020708lja.40.1535720397991; Fri, 31 Aug 2018 05:59:57 -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 a66-v6sm1894220lfa.93.2018.08.31.05.59.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Aug 2018 05:59:57 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, zr@semihalf.com, tdu@semihalf.com, nsamsono@marvell.com Date: Fri, 31 Aug 2018 14:59:46 +0200 Message-Id: <1535720386-18775-9-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535720386-18775-1-git-send-email-amo@semihalf.com> References: <1535718368-15803-1-git-send-email-amo@semihalf.com> <1535720386-18775-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v3 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: Fri, 31 Aug 2018 12:59:58 -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 2bf2e2e..1bcfc68 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -1700,23 +1700,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, @@ -1732,6 +1757,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 a05566d..6aed170 100644 --- a/drivers/net/mvneta/mvneta_ethdev.h +++ b/drivers/net/mvneta/mvneta_ethdev.h @@ -77,6 +77,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