From: Vadim Podovinnikov <podovinnikov@protei.ru>
To: linville@tuxdriver.com
Cc: dev@dpdk.org, Vadim Podovinnikov <podovinnikov@protei.ru>
Subject: [dpdk-dev] [PATCH v4] add drop statistic for af_packet
Date: Fri, 29 Nov 2019 17:59:25 +0300 [thread overview]
Message-ID: <20191129145925.26628-1-podovinnikov@protei.ru> (raw)
In-Reply-To: <cf03b5bc-3cf2-795f-8107-ba8de273dfe0@intel.com>
Signed-off-by: Vadim Podovinnikov <podovinnikov@protei.ru>
---
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
next prev parent reply other threads:[~2019-11-29 14:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191125180325.2E2284C9D@dpdk.org>
2019-11-26 14:32 ` [dpdk-dev] [PATCH v2] " Vadim
2019-11-26 14:45 ` Ferruh Yigit
2019-11-26 15:47 ` [dpdk-dev] [PATCH v3] " Vadim Podovinnikov
2019-11-28 15:03 ` Ferruh Yigit
2019-11-29 14:59 ` Vadim Podovinnikov [this message]
2019-12-02 9:40 ` [dpdk-dev] [PATCH v4] " Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191129145925.26628-1-podovinnikov@protei.ru \
--to=podovinnikov@protei.ru \
--cc=dev@dpdk.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).