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 A9989A04C2; Mon, 25 Nov 2019 19:01:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AA4BE5596; Mon, 25 Nov 2019 19:01:43 +0100 (CET) Received: from mail2.protei.ru (mail2.protei.ru [62.152.87.202]) by dpdk.org (Postfix) with ESMTP id 335B7A3 for ; Mon, 25 Nov 2019 14:41:07 +0100 (CET) Received: from smtp.protei.ru (imap.protei.ru [10.0.0.6]) by mail2.protei.ru (Postfix) with ESMTP id B068F4001D97; Mon, 25 Nov 2019 16:41:02 +0300 (MSK) Received: from localhost (unknown [127.0.0.1]) by smtp.protei.ru (Postfix) with ESMTP id 9A9E8108F782; Mon, 25 Nov 2019 13:41:02 +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 gSOWgvuQ5dZ9; Mon, 25 Nov 2019 16:41:02 +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 7B1F9108F781; Mon, 25 Nov 2019 16:41:02 +0300 (MSK) From: Vadim To: linville@tuxdriver.com Cc: dev@dpdk.org, Vadim Date: Mon, 25 Nov 2019 16:41:05 +0300 Message-Id: <20191125134105.17166-1-podovinnikov@protei.ru> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 25 Nov 2019 19:01:39 +0100 Subject: [dpdk-dev] [PATCH] 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" --- 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..eb1902170 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 (0 == rc) + 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