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 D61D84CE4 for ; Tue, 28 Aug 2018 17:10:40 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id q127-v6so1709965ljq.11 for ; Tue, 28 Aug 2018 08:10:40 -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=MFAUMnOSE8ET2cxLBny6eq6oRHV3pKYsfxNXFCfBI+A=; b=0L3NXOXndB8GTSegvP3JI6asNIQ2ySfY2BdDwxkF2xwcPyAPsS8Nk8tc67fd3ZWiPQ VGzauF6SsR6GEqpkZMUCPx3qQe57HNe2pzV9MdhRJ3Uc1xoauHMwrOYjUKo/e2R7SsfS Jg/RvJHe2NPkARmTA1yEQ5il8Tm2rmU9uKVAP/GB5WsSm5nig5LDg2NeoZSEVx/AclwL Yds4rXwd4PNxJOmtinlYrOxEreAzSl9lMAITEJKQPTznCSzm8V78XqpieL+b/BaOk/zZ 3Qs9ClqMpMEfUvdwVYcF7kvKdw0t3UaHFdmgvESSjVwGmzcTkDrh9ydTUUBq5tQwSPR7 Ohzw== 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=MFAUMnOSE8ET2cxLBny6eq6oRHV3pKYsfxNXFCfBI+A=; b=WP5IIs1Wa1ht4qBDXwhg3jywvY38XmlGRMsq3YZakKanschmpx5BkEtTNfIqr+TNoN 6LHb6yHoQh8iY8233DpViz8GeztDmd+yWL+Y7yQc8IHZydWu7PlA1L0MRXQZ3SLDwwOi dlRfE5mp14JJyVL35QenufarrxElY+AsN9pCFARm/kUge7bsid8DwJkXWvZ6NF1wqkz4 GgOCXm+TgkYIyaHOdEDA5pPIqFOrjR51KbHYsCUwweDlhpg5Txf5UYD+oPNrpcoN9dja 55Wmbmj5tmJrOrC904t0820yYWZashSDw7OFDkq6Aah4zXWGPsHQtur4ZUvS5xu3MFKH T4eQ== X-Gm-Message-State: APzg51Dcd1OpRqhyTTggbn7b5h5UMKB/UGjmk8U+ZdVfghO6FZK97wpO 1JwpvOtmIX42YpgjSTQ9q2EXUtHVdNM= X-Google-Smtp-Source: ANB0VdYzqgiUuZnNwcM9e8Gb/GuyTezrIlh4K6ST/zCEqnXkWDcT6GLZukDG7DZ8ZpmtoS+WqyDOzQ== X-Received: by 2002:a2e:1bd7:: with SMTP id c84-v6mr1600249ljf.0.1535469040388; Tue, 28 Aug 2018 08:10:40 -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 p28-v6sm260685ljp.90.2018.08.28.08.10.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 08:10:39 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: nsamsono@marvell.com Date: Tue, 28 Aug 2018 17:10:29 +0200 Message-Id: <1535469030-18647-8-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535469030-18647-1-git-send-email-amo@semihalf.com> References: <1535469030-18647-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH 7/8] net/mvneta: add support for basic stats 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: Tue, 28 Aug 2018 15:10:41 -0000 From: Yelena Krivosheev Add support for getting of basic statistics for the driver. Signed-off-by: Yelena Krivosheev Signed-off-by: Natalie Samsonov --- drivers/net/mvneta/mvneta_ethdev.c | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c index f19d2ea..9bff6c3 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -1678,6 +1678,52 @@ mvneta_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) return 0; } +/** + * DPDK callback to get device statistics. + * + * @param dev + * Pointer to Ethernet device structure. + * @param stats + * Stats structure output buffer. + * + * @return + * 0 on success, negative error value otherwise. + */ +static int +mvneta_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct mvneta_priv *priv = dev->data->dev_private; + struct neta_ppio_statistics ppio_stats; + unsigned int ret; + + if (!priv->ppio) + return -EPERM; + + ret = neta_ppio_get_statistics(priv->ppio, &ppio_stats); + if (unlikely(ret)) { + MVNETA_LOG(ERR, "Failed to update port statistics\n"); + return ret; + } + + stats->ipackets += ppio_stats.rx_packets + + ppio_stats.rx_broadcast_packets + + ppio_stats.rx_multicast_packets; + 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; + stats->imissed += ppio_stats.rx_discard + + ppio_stats.rx_overrun; + + stats->ierrors = ppio_stats.rx_packets_err + + ppio_stats.rx_errors + + ppio_stats.rx_crc_error; + stats->oerrors = ppio_stats.tx_errors; + + return 0; +} + static const struct eth_dev_ops mvneta_ops = { .dev_configure = mvneta_dev_configure, .dev_start = mvneta_dev_start, @@ -1692,6 +1738,7 @@ static const struct eth_dev_ops mvneta_ops = { .mac_addr_add = mvneta_mac_addr_add, .mac_addr_set = mvneta_mac_addr_set, .mtu_set = mvneta_mtu_set, + .stats_get = mvneta_stats_get, .dev_infos_get = mvneta_dev_infos_get, .dev_supported_ptypes_get = mvneta_dev_supported_ptypes_get, .rxq_info_get = mvneta_rxq_info_get, -- 2.7.4