DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] add drop statistic for af_packet
@ 2019-11-25 13:41 Vadim
  2019-11-26 14:28 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Vadim @ 2019-11-25 13:41 UTC (permalink / raw)
  To: linville; +Cc: dev, 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..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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] add drop statistic for af_packet
  2019-11-25 13:41 [dpdk-dev] [PATCH] add drop statistic for af_packet Vadim
@ 2019-11-26 14:28 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2019-11-26 14:28 UTC (permalink / raw)
  To: Vadim, linville; +Cc: dev

Hi Vadim,

On 11/25/2019 1:41 PM, Vadim wrote:
> ---
>  drivers/net/af_packet/rte_eth_af_packet.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

Please include your sign off, and add some description in the commit log.

> 
> 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;

This will work but since the PMD is implementing 'TPACKET_V2', this may be
confusing, what about using 'struct tpacket_stats'?

>  
>  	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;
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-26 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 13:41 [dpdk-dev] [PATCH] add drop statistic for af_packet Vadim
2019-11-26 14:28 ` Ferruh Yigit

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).