From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31A76A04E0; Fri, 29 Nov 2019 15:59:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6D3249E4; Fri, 29 Nov 2019 15:59:28 +0100 (CET) Received: from mail2.protei.ru (mail2.protei.ru [62.152.87.202]) by dpdk.org (Postfix) with ESMTP id 193B423D for ; Fri, 29 Nov 2019 15:59:27 +0100 (CET) Received: from smtp.protei.ru (imap.protei.ru [10.0.0.6]) by mail2.protei.ru (Postfix) with ESMTP id 9B4E54001D97; Fri, 29 Nov 2019 17:59:22 +0300 (MSK) Received: from localhost (unknown [127.0.0.1]) by smtp.protei.ru (Postfix) with ESMTP id 61D5A108BF6A; Fri, 29 Nov 2019 14:59:22 +0000 (UTC) Received: from smtp.protei.ru ([127.0.0.1]) by localhost (imap.protei.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fx70NrW4YChx; Fri, 29 Nov 2019 17:59:22 +0300 (MSK) Received: from localhost.localdomain (podovinnikov.protei [192.168.100.231]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.protei.ru (Postfix) with ESMTPSA id 41AA3108A9FD; Fri, 29 Nov 2019 17:59:22 +0300 (MSK) From: Vadim Podovinnikov To: linville@tuxdriver.com Cc: dev@dpdk.org, Vadim Podovinnikov Date: Fri, 29 Nov 2019 17:59:25 +0300 Message-Id: <20191129145925.26628-1-podovinnikov@protei.ru> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4] add drop statistic for af_packet 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Vadim Podovinnikov --- drivers/net/af_packet/rte_eth_af_packet.c | 33 +++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index eee0fbce2..2aa7c0fcc 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -52,6 +52,7 @@ struct pkt_rx_queue { volatile unsigned long rx_pkts; volatile unsigned long rx_bytes; + volatile unsigned long rx_drop; }; struct pkt_tx_queue { @@ -322,6 +323,25 @@ eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) return 0; } +static void +fill_eth_drop_stats(struct rte_eth_dev *dev) +{ + unsigned int i, imax; + struct pmd_internals *internal = dev->data->dev_private; + socklen_t sock_len = sizeof(struct tpacket_stats); + struct tpacket_stats st; + + imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? + internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS); + for (i = 0; i < imax; i++) { + memset(&st, 0, sock_len); + int rc = getsockopt(internal->rx_queue[i].sockfd, SOL_PACKET, + PACKET_STATISTICS, &st, &sock_len); + if (rc == 0) + internal->rx_queue[i].rx_drop += st.tp_drops; + } +} + static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { @@ -329,22 +349,18 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0; unsigned long rx_bytes_total = 0, tx_bytes_total = 0, rx_drop = 0; const struct pmd_internals *internal = dev->data->dev_private; - socklen_t sock_len = sizeof(struct tpacket_stats); - struct tpacket_stats st; + + fill_eth_drop_stats(dev); imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS); for (i = 0; i < imax; i++) { igb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts; igb_stats->q_ibytes[i] = internal->rx_queue[i].rx_bytes; + igb_stats->q_errors[i] = internal->rx_queue[i].rx_drop; rx_total += igb_stats->q_ipackets[i]; rx_bytes_total += igb_stats->q_ibytes[i]; - - memset(&st, 0, sock_len); - int rc = getsockopt(internal->rx_queue[i].sockfd, SOL_PACKET, - PACKET_STATISTICS, &st, &sock_len); - if (rc == 0) - rx_drop += st.tp_drops; + rx_drop += igb_stats->q_errors[i]; } imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? @@ -375,6 +391,7 @@ eth_stats_reset(struct rte_eth_dev *dev) for (i = 0; i < internal->nb_queues; i++) { internal->rx_queue[i].rx_pkts = 0; internal->rx_queue[i].rx_bytes = 0; + internal->rx_queue[i].rx_drop = 0; } for (i = 0; i < internal->nb_queues; i++) { -- 2.24.0