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 14289A04DD; Tue, 26 Nov 2019 15:32:37 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7E6132B96; Tue, 26 Nov 2019 15:32:36 +0100 (CET) Received: from mail2.protei.ru (mail2.protei.ru [62.152.87.202]) by dpdk.org (Postfix) with ESMTP id CEB21CF3 for ; Tue, 26 Nov 2019 15:32:35 +0100 (CET) Received: from smtp.protei.ru (imap.protei.ru [10.0.0.6]) by mail2.protei.ru (Postfix) with ESMTP id E21494001D97; Tue, 26 Nov 2019 17:32:30 +0300 (MSK) Received: from localhost (unknown [127.0.0.1]) by smtp.protei.ru (Postfix) with ESMTP id D0A4B3F115; Tue, 26 Nov 2019 14:32:30 +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 CyrxKVyENbOV; Tue, 26 Nov 2019 17:32:30 +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 B513C3F114; Tue, 26 Nov 2019 17:32:30 +0300 (MSK) From: Vadim To: linville@tuxdriver.com Cc: dev@dpdk.org, Vadim Date: Tue, 26 Nov 2019 17:32:33 +0300 Message-Id: <20191126143233.19235-1-podovinnikov@protei.ru> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191125180325.2E2284C9D@dpdk.org> References: <20191125180325.2E2284C9D@dpdk.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] 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 --- drivers/net/af_packet/rte_eth_af_packet.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index f5806bf42..da54f82f7 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -327,8 +327,10 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { unsigned i, imax; unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0; - unsigned long rx_bytes_total = 0, tx_bytes_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_v3); + struct tpacket_stats_v3 st; imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS); @@ -337,6 +339,12 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) igb_stats->q_ibytes[i] = internal->rx_queue[i].rx_bytes; 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; } imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ? @@ -349,6 +357,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) tx_bytes_total += igb_stats->q_obytes[i]; } + igb_stats->imissed = rx_drop; igb_stats->ipackets = rx_total; igb_stats->ibytes = rx_bytes_total; igb_stats->opackets = tx_total; -- 2.24.0