DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] af_packet: add byte counters
@ 2016-05-25 21:03 Rich Lane
  2016-05-26 14:47 ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Lane @ 2016-05-25 21:03 UTC (permalink / raw)
  To: dev; +Cc: John W. Linville

Signed-off-by: Rich Lane <rich.lane@bigswitch.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 20 +++++++++++++++++++-
 1 file changed, 19 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 f17bd7e..2d7f344 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -78,6 +78,7 @@ struct pkt_rx_queue {
 
 	volatile unsigned long rx_pkts;
 	volatile unsigned long err_pkts;
+	volatile unsigned long rx_bytes;
 };
 
 struct pkt_tx_queue {
@@ -90,6 +91,7 @@ struct pkt_tx_queue {
 
 	volatile unsigned long tx_pkts;
 	volatile unsigned long err_pkts;
+	volatile unsigned long tx_bytes;
 };
 
 struct pmd_internals {
@@ -131,6 +133,7 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	uint8_t *pbuf;
 	struct pkt_rx_queue *pkt_q = queue;
 	uint16_t num_rx = 0;
+	unsigned long num_rx_bytes = 0;
 	unsigned int framecount, framenum;
 
 	if (unlikely(nb_pkts == 0))
@@ -167,9 +170,11 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		/* account for the receive frame */
 		bufs[i] = mbuf;
 		num_rx++;
+		num_rx_bytes += mbuf->pkt_len;
 	}
 	pkt_q->framenum = framenum;
 	pkt_q->rx_pkts += num_rx;
+	pkt_q->rx_bytes += num_rx_bytes;
 	return num_rx;
 }
 
@@ -186,6 +191,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	struct pollfd pfd;
 	struct pkt_tx_queue *pkt_q = queue;
 	uint16_t num_tx = 0;
+	unsigned long num_tx_bytes = 0;
 	int i;
 
 	if (unlikely(nb_pkts == 0))
@@ -219,6 +225,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		ppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;
 
 		num_tx++;
+		num_tx_bytes += mbuf->pkt_len;
 		rte_pktmbuf_free(mbuf);
 	}
 
@@ -229,6 +236,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	pkt_q->framenum = framenum;
 	pkt_q->tx_pkts += num_tx;
 	pkt_q->err_pkts += nb_pkts - num_tx;
+	pkt_q->tx_bytes += num_tx_bytes;
 	return num_tx;
 }
 
@@ -287,13 +295,16 @@ 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;
 	const struct pmd_internals *internal = dev->data->dev_private;
 
 	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;
 		rx_total += igb_stats->q_ipackets[i];
+		rx_bytes_total += igb_stats->q_ibytes[i];
 	}
 
 	imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
@@ -301,13 +312,17 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
 	for (i = 0; i < imax; i++) {
 		igb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;
 		igb_stats->q_errors[i] = internal->tx_queue[i].err_pkts;
+		igb_stats->q_obytes[i] = internal->tx_queue[i].tx_bytes;
 		tx_total += igb_stats->q_opackets[i];
 		tx_err_total += igb_stats->q_errors[i];
+		tx_bytes_total += igb_stats->q_obytes[i];
 	}
 
 	igb_stats->ipackets = rx_total;
+	igb_stats->ibytes = rx_bytes_total;
 	igb_stats->opackets = tx_total;
 	igb_stats->oerrors = tx_err_total;
+	igb_stats->obytes = tx_bytes_total;
 }
 
 static void
@@ -316,12 +331,15 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	unsigned i;
 	struct pmd_internals *internal = dev->data->dev_private;
 
-	for (i = 0; i < internal->nb_queues; i++)
+	for (i = 0; i < internal->nb_queues; i++) {
 		internal->rx_queue[i].rx_pkts = 0;
+		internal->rx_queue[i].rx_bytes = 0;
+	}
 
 	for (i = 0; i < internal->nb_queues; i++) {
 		internal->tx_queue[i].tx_pkts = 0;
 		internal->tx_queue[i].err_pkts = 0;
+		internal->tx_queue[i].tx_bytes = 0;
 	}
 }
 
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH] af_packet: add byte counters
  2016-05-25 21:03 [dpdk-dev] [PATCH] af_packet: add byte counters Rich Lane
@ 2016-05-26 14:47 ` Ferruh Yigit
  2016-05-26 15:01   ` John W. Linville
  2016-05-26 16:59   ` Rich Lane
  0 siblings, 2 replies; 5+ messages in thread
From: Ferruh Yigit @ 2016-05-26 14:47 UTC (permalink / raw)
  To: Rich Lane, dev; +Cc: John W. Linville

On 5/25/2016 10:03 PM, Rich Lane wrote:
> Signed-off-by: Rich Lane <rich.lane@bigswitch.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>


While testing this, independent from patch applied or not , I am getting
following assertion after random time:

testpmd> PANIC in rte_mbuf_raw_alloc():
line 1111       assert "rte_mbuf_refcnt_read(m) == 0" failed

I may be doing something wrong, do you observe this Rich?

Thanks,
ferruh

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

* Re: [dpdk-dev] [PATCH] af_packet: add byte counters
  2016-05-26 14:47 ` Ferruh Yigit
@ 2016-05-26 15:01   ` John W. Linville
  2016-06-09 16:03     ` Bruce Richardson
  2016-05-26 16:59   ` Rich Lane
  1 sibling, 1 reply; 5+ messages in thread
From: John W. Linville @ 2016-05-26 15:01 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: Rich Lane, dev

On Thu, May 26, 2016 at 03:47:59PM +0100, Ferruh Yigit wrote:
> On 5/25/2016 10:03 PM, Rich Lane wrote:
> > Signed-off-by: Rich Lane <rich.lane@bigswitch.com>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Acked-by: John W. Linville <linville@tuxdriver.com>

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

* Re: [dpdk-dev] [PATCH] af_packet: add byte counters
  2016-05-26 14:47 ` Ferruh Yigit
  2016-05-26 15:01   ` John W. Linville
@ 2016-05-26 16:59   ` Rich Lane
  1 sibling, 0 replies; 5+ messages in thread
From: Rich Lane @ 2016-05-26 16:59 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev, John W. Linville

On Thu, May 26, 2016 at 7:47 AM, Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 5/25/2016 10:03 PM, Rich Lane wrote:
> > Signed-off-by: Rich Lane <rich.lane@bigswitch.com>
>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
>
> While testing this, independent from patch applied or not , I am getting
> following assertion after random time:
>
> testpmd> PANIC in rte_mbuf_raw_alloc():
> line 1111       assert "rte_mbuf_refcnt_read(m) == 0" failed
>
> I may be doing something wrong, do you observe this Rich?
>

No, I don't see that assertion failure in testpmd or my application.

Thanks for the review!

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

* Re: [dpdk-dev] [PATCH] af_packet: add byte counters
  2016-05-26 15:01   ` John W. Linville
@ 2016-06-09 16:03     ` Bruce Richardson
  0 siblings, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2016-06-09 16:03 UTC (permalink / raw)
  To: John W. Linville; +Cc: Ferruh Yigit, Rich Lane, dev

On Thu, May 26, 2016 at 11:01:57AM -0400, John W. Linville wrote:
> On Thu, May 26, 2016 at 03:47:59PM +0100, Ferruh Yigit wrote:
> > On 5/25/2016 10:03 PM, Rich Lane wrote:
> > > Signed-off-by: Rich Lane <rich.lane@bigswitch.com>
> > 
> > Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> 
> Acked-by: John W. Linville <linville@tuxdriver.com>
> 
Applied to dpdk-next-net/rel_16_07

/Bruce

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

end of thread, other threads:[~2016-06-09 16:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-25 21:03 [dpdk-dev] [PATCH] af_packet: add byte counters Rich Lane
2016-05-26 14:47 ` Ferruh Yigit
2016-05-26 15:01   ` John W. Linville
2016-06-09 16:03     ` Bruce Richardson
2016-05-26 16:59   ` Rich Lane

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