DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/13] port: added port statistics
@ 2015-03-30 10:28 Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 01/13] port: added structures for port stats Maciej Gajdzica
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

Added statistics for every type of port. By default all port statistics
are disabled, user must activate them in config file.

This patchset depends on two patchsets:
port: added ethdev_writer_nodrop and ring_writer_nodrop ports
port: added frag_ipv6 and ras_ipv6 ports

Maciej Gajdzica (13):
  port: added structures for port stats
  port: added port_ethdev_reader stats
  port: added port_ethdev_writer stats
  port: added port_ethdev_writer_nodrop stats
  port: added port_frag stats
  port: added port_ras stats
  port: added port_ring_reader stats
  port: added port_ring_writer stats
  port: added port_ring_writer_nodrop stats
  port: added port_sched_reader stats
  port: added port_sched_writer stats
  port: added port_source stats
  port: added port_sink stats

 config/common_bsdapp                   |   12 ++++
 config/common_linuxapp                 |   12 ++++
 lib/librte_port/rte_port.h             |   60 ++++++++++++++--
 lib/librte_port/rte_port_ethdev.c      |  113 +++++++++++++++++++++++++++++-
 lib/librte_port/rte_port_frag.c        |   36 ++++++++++
 lib/librte_port/rte_port_ras.c         |   38 ++++++++++
 lib/librte_port/rte_port_ring.c        |  118 +++++++++++++++++++++++++++++++-
 lib/librte_port/rte_port_sched.c       |   96 ++++++++++++++++++++++++--
 lib/librte_port/rte_port_source_sink.c |   98 ++++++++++++++++++++++++--
 9 files changed, 566 insertions(+), 17 deletions(-)

-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 01/13] port: added structures for port stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 02/13] port: added port_ethdev_reader stats Maciej Gajdzica
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 lib/librte_port/rte_port.h |   60 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 55 insertions(+), 5 deletions(-)

diff --git a/lib/librte_port/rte_port.h b/lib/librte_port/rte_port.h
index d84e5a1..ab433e5 100644
--- a/lib/librte_port/rte_port.h
+++ b/lib/librte_port/rte_port.h
@@ -81,6 +81,12 @@ extern "C" {
 Cannot be changed. */
 #define RTE_PORT_IN_BURST_SIZE_MAX                         64
 
+/** Input port statistics */
+struct rte_port_in_stats {
+	uint64_t n_pkts_in;
+	uint64_t n_pkts_drop;
+};
+
 /**
  * Input port create
  *
@@ -120,17 +126,42 @@ typedef int (*rte_port_in_op_rx)(
 	struct rte_mbuf **pkts,
 	uint32_t n_pkts);
 
+/**
+ * Input port stats get
+ *
+ * @param port
+ *   Handle to output port instance
+ * @param stats
+ *   Handle to port_in stats struct to copy data
+ * @param clear
+ *   Flag indicating that stats should be cleared after read
+ *
+ * @return
+ *   Error code or 0 on success.
+ */
+typedef int (*rte_port_in_op_stats_read)(
+		void *port,
+		struct rte_port_in_stats *stats,
+		int clear);
+
 /** Input port interface defining the input port operation */
 struct rte_port_in_ops {
 	rte_port_in_op_create f_create; /**< Create */
 	rte_port_in_op_free f_free;     /**< Free */
 	rte_port_in_op_rx f_rx;         /**< Packet RX (packet burst) */
+	rte_port_in_op_stats_read f_stats;	/**< Stats */
 };
 
 /*
  * Port OUT
  *
  */
+/** Output port statistics */
+struct rte_port_out_stats {
+	uint64_t n_pkts_in;
+	uint64_t n_pkts_drop;
+};
+
 /**
  * Output port create
  *
@@ -197,13 +228,32 @@ typedef int (*rte_port_out_op_tx_bulk)(
  */
 typedef int (*rte_port_out_op_flush)(void *port);
 
+/**
+ * Output port stats read
+ *
+ * @param port
+ *   Handle to output port instance
+ * @param stats
+ *   Handle to port_out stats struct to copy data
+ * @param clear
+ *   Flag indicating that stats should be cleared after read
+ *
+ * @return
+ *   Error code or 0 on success.
+ */
+typedef int (*rte_port_out_op_stats_read)(
+		void *port,
+		struct rte_port_out_stats *stats,
+		int clear);
+
 /** Output port interface defining the output port operation */
 struct rte_port_out_ops {
-	rte_port_out_op_create f_create;   /**< Create */
-	rte_port_out_op_free f_free;       /**< Free */
-	rte_port_out_op_tx f_tx;           /**< Packet TX (single packet) */
-	rte_port_out_op_tx_bulk f_tx_bulk; /**< Packet TX (packet burst) */
-	rte_port_out_op_flush f_flush;     /**< Flush */
+	rte_port_out_op_create f_create;		/**< Create */
+	rte_port_out_op_free f_free;			/**< Free */
+	rte_port_out_op_tx f_tx;				/**< Packet TX (single packet) */
+	rte_port_out_op_tx_bulk f_tx_bulk;		/**< Packet TX (packet burst) */
+	rte_port_out_op_flush f_flush;			/**< Flush */
+	rte_port_out_op_stats_read f_stats;     /**< Stats */
 };
 
 #ifdef __cplusplus
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 02/13] port: added port_ethdev_reader stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 01/13] port: added structures for port stats Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 03/13] port: added port_ethdev_writer stats Maciej Gajdzica
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp              |    1 +
 config/common_linuxapp            |    1 +
 lib/librte_port/rte_port_ethdev.c |   37 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 8ff4dc2..823e295 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -382,6 +382,7 @@ CONFIG_RTE_LIBRTE_REORDER=y
 # Compile librte_port
 #
 CONFIG_RTE_LIBRTE_PORT=y
+CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 09a58ac..0c3b4e2 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -389,6 +389,7 @@ CONFIG_RTE_LIBRTE_REORDER=y
 # Compile librte_port
 #
 CONFIG_RTE_LIBRTE_PORT=y
+CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_ethdev.c b/lib/librte_port/rte_port_ethdev.c
index 1f77cb5..05bc077 100644
--- a/lib/librte_port/rte_port_ethdev.c
+++ b/lib/librte_port/rte_port_ethdev.c
@@ -42,7 +42,23 @@
 /*
  * Port ETHDEV Reader
  */
+#ifdef RTE_PORT_ETHDEV_READER_STATS_COLLECT
+
+#define RTE_PORT_ETHDEV_READER_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_ETHDEV_READER_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_ETHDEV_READER_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_ETHDEV_READER_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_ethdev_reader {
+	struct rte_port_in_stats stats;
+
 	uint16_t queue_id;
 	uint8_t port_id;
 };
@@ -80,8 +96,11 @@ rte_port_ethdev_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 {
 	struct rte_port_ethdev_reader *p =
 		(struct rte_port_ethdev_reader *) port;
+	uint16_t rx_pkt_cnt;
 
-	return rte_eth_rx_burst(p->port_id, p->queue_id, pkts, n_pkts);
+	rx_pkt_cnt = rte_eth_rx_burst(p->port_id, p->queue_id, pkts, n_pkts);
+	RTE_PORT_ETHDEV_READER_STATS_PKTS_IN_ADD(p, rx_pkt_cnt);
+	return rx_pkt_cnt;
 }
 
 static int
@@ -97,6 +116,21 @@ rte_port_ethdev_reader_free(void *port)
 	return 0;
 }
 
+static int rte_port_ethdev_reader_stats_read(void *port,
+		struct rte_port_in_stats * stats, int clear)
+{
+	struct rte_port_ethdev_reader *p =
+			(struct rte_port_ethdev_reader *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Port ETHDEV Writer
  */
@@ -516,6 +550,7 @@ struct rte_port_in_ops rte_port_ethdev_reader_ops = {
 	.f_create = rte_port_ethdev_reader_create,
 	.f_free = rte_port_ethdev_reader_free,
 	.f_rx = rte_port_ethdev_reader_rx,
+	.f_stats = rte_port_ethdev_reader_stats_read,
 };
 
 struct rte_port_out_ops rte_port_ethdev_writer_ops = {
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 03/13] port: added port_ethdev_writer stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 01/13] port: added structures for port stats Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 02/13] port: added port_ethdev_reader stats Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 04/13] port: added port_ethdev_writer_nodrop stats Maciej Gajdzica
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp              |    1 +
 config/common_linuxapp            |    1 +
 lib/librte_port/rte_port_ethdev.c |   38 +++++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 823e295..d62e6d9 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -383,6 +383,7 @@ CONFIG_RTE_LIBRTE_REORDER=y
 #
 CONFIG_RTE_LIBRTE_PORT=y
 CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
+CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0c3b4e2..41a00a5 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -390,6 +390,7 @@ CONFIG_RTE_LIBRTE_REORDER=y
 #
 CONFIG_RTE_LIBRTE_PORT=y
 CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
+CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_ethdev.c b/lib/librte_port/rte_port_ethdev.c
index 05bc077..e9e549a 100644
--- a/lib/librte_port/rte_port_ethdev.c
+++ b/lib/librte_port/rte_port_ethdev.c
@@ -136,7 +136,23 @@ static int rte_port_ethdev_reader_stats_read(void *port,
  */
 #define RTE_PORT_ETHDEV_WRITER_APPROACH                  1
 
+#ifdef RTE_PORT_ETHDEV_WRITER_STATS_COLLECT
+
+#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_ethdev_writer {
+	struct rte_port_out_stats stats;
+
 	struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];
 	uint32_t tx_burst_sz;
 	uint16_t tx_buf_count;
@@ -187,6 +203,7 @@ send_burst(struct rte_port_ethdev_writer *p)
 	nb_tx = rte_eth_tx_burst(p->port_id, p->queue_id,
 			 p->tx_buf, p->tx_buf_count);
 
+	RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx);
 	for ( ; nb_tx < p->tx_buf_count; nb_tx++)
 		rte_pktmbuf_free(p->tx_buf[nb_tx]);
 
@@ -220,6 +237,7 @@ rte_port_ethdev_writer_tx_bulk(void *port,
 		uint64_t n_pkts = __builtin_popcountll(pkts_mask);
 		uint32_t i;
 
+		RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, n_pkts);
 		for (i = 0; i < n_pkts; i++) {
 			struct rte_mbuf *pkt = pkts[i];
 
@@ -234,6 +252,7 @@ rte_port_ethdev_writer_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[p->tx_buf_count++] = pkt;
+			RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, 1);
 			if (p->tx_buf_count >= p->tx_burst_sz)
 				send_burst(p);
 			pkts_mask &= ~pkt_mask;
@@ -264,9 +283,11 @@ rte_port_ethdev_writer_tx_bulk(void *port,
 		if (tx_buf_count)
 			send_burst(p);
 
+		RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, n_pkts);
 		n_pkts_ok = rte_eth_tx_burst(p->port_id, p->queue_id, pkts,
 			n_pkts);
 
+		RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - n_pkts_ok);
 		for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) {
 			struct rte_mbuf *pkt = pkts[n_pkts_ok];
 
@@ -279,6 +300,7 @@ rte_port_ethdev_writer_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[tx_buf_count++] = pkt;
+			RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, 1);
 			pkts_mask &= ~pkt_mask;
 		}
 
@@ -322,6 +344,21 @@ rte_port_ethdev_writer_free(void *port)
 	return 0;
 }
 
+static int rte_port_ethdev_writer_stats_read(void *port,
+		struct rte_port_out_stats *stats, int clear)
+{
+	struct rte_port_ethdev_writer *p =
+		(struct rte_port_ethdev_writer *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Port ETHDEV Writer Nodrop
  */
@@ -559,6 +596,7 @@ struct rte_port_out_ops rte_port_ethdev_writer_ops = {
 	.f_tx = rte_port_ethdev_writer_tx,
 	.f_tx_bulk = rte_port_ethdev_writer_tx_bulk,
 	.f_flush = rte_port_ethdev_writer_flush,
+	.f_stats = rte_port_ethdev_writer_stats_read,
 };
 
 struct rte_port_out_ops rte_port_ethdev_writer_nodrop_ops = {
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 04/13] port: added port_ethdev_writer_nodrop stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (2 preceding siblings ...)
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 03/13] port: added port_ethdev_writer stats Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 05/13] port: added port_frag stats Maciej Gajdzica
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp              |    1 +
 config/common_linuxapp            |    1 +
 lib/librte_port/rte_port_ethdev.c |   38 +++++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index d62e6d9..ed01d2d 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -384,6 +384,7 @@ CONFIG_RTE_LIBRTE_REORDER=y
 CONFIG_RTE_LIBRTE_PORT=y
 CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
+CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 41a00a5..6a7c5ac 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -391,6 +391,7 @@ CONFIG_RTE_LIBRTE_REORDER=y
 CONFIG_RTE_LIBRTE_PORT=y
 CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
+CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_ethdev.c b/lib/librte_port/rte_port_ethdev.c
index e9e549a..7a0c14e 100644
--- a/lib/librte_port/rte_port_ethdev.c
+++ b/lib/librte_port/rte_port_ethdev.c
@@ -364,7 +364,23 @@ static int rte_port_ethdev_writer_stats_read(void *port,
  */
 #define RTE_PORT_ETHDEV_WRITER_NODROP_APPROACH                  1
 
+#ifdef RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT
+
+#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_ethdev_writer_nodrop {
+	struct rte_port_out_stats stats;
+
 	struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];
 	uint32_t tx_burst_sz;
 	uint16_t tx_buf_count;
@@ -437,6 +453,7 @@ send_burst_nodrop(struct rte_port_ethdev_writer_nodrop *p)
 	}
 
 	/* We didn't send the packets in maximum allowed attempts */
+	RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx);
 	for ( ; nb_tx < p->tx_buf_count; nb_tx++)
 		rte_pktmbuf_free(p->tx_buf[nb_tx]);
 
@@ -450,6 +467,7 @@ rte_port_ethdev_writer_nodrop_tx(void *port, struct rte_mbuf *pkt)
 		(struct rte_port_ethdev_writer_nodrop *) port;
 
 	p->tx_buf[p->tx_buf_count++] = pkt;
+	RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);
 	if (p->tx_buf_count >= p->tx_burst_sz)
 		send_burst_nodrop(p);
 
@@ -470,6 +488,7 @@ rte_port_ethdev_writer_nodrop_tx_bulk(void *port,
 		uint64_t n_pkts = __builtin_popcountll(pkts_mask);
 		uint32_t i;
 
+		RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts);
 		for (i = 0; i < n_pkts; i++) {
 			struct rte_mbuf *pkt = pkts[i];
 
@@ -484,6 +503,7 @@ rte_port_ethdev_writer_nodrop_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[p->tx_buf_count++] = pkt;
+			RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);
 			if (p->tx_buf_count >= p->tx_burst_sz)
 				send_burst_nodrop(p);
 			pkts_mask &= ~pkt_mask;
@@ -515,6 +535,7 @@ rte_port_ethdev_writer_nodrop_tx_bulk(void *port,
 		if (tx_buf_count)
 			send_burst_nodrop(p);
 
+		RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts);
 		n_pkts_ok = rte_eth_tx_burst(p->port_id, p->queue_id, pkts,
 			n_pkts);
 
@@ -537,6 +558,7 @@ rte_port_ethdev_writer_nodrop_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[tx_buf_count++] = pkt;
+			RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);
 			pkts_mask &= ~pkt_mask;
 		}
 
@@ -580,6 +602,21 @@ rte_port_ethdev_writer_nodrop_free(void *port)
 	return 0;
 }
 
+static int rte_port_ethdev_writer_nodrop_stats_read(void *port,
+		struct rte_port_out_stats *stats, int clear)
+{
+	struct rte_port_ethdev_writer_nodrop *p =
+		(struct rte_port_ethdev_writer_nodrop *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Summary of port operations
  */
@@ -605,4 +642,5 @@ struct rte_port_out_ops rte_port_ethdev_writer_nodrop_ops = {
 	.f_tx = rte_port_ethdev_writer_nodrop_tx,
 	.f_tx_bulk = rte_port_ethdev_writer_nodrop_tx_bulk,
 	.f_flush = rte_port_ethdev_writer_nodrop_flush,
+	.f_stats = rte_port_ethdev_writer_nodrop_stats_read,
 };
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 05/13] port: added port_frag stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (3 preceding siblings ...)
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 04/13] port: added port_ethdev_writer_nodrop stats Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 06/13] port: added port_ras stats Maciej Gajdzica
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp            |    1 +
 config/common_linuxapp          |    1 +
 lib/librte_port/rte_port_frag.c |   36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index ed01d2d..523b9e9 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -385,6 +385,7 @@ CONFIG_RTE_LIBRTE_PORT=y
 CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 6a7c5ac..e4baf41 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -392,6 +392,7 @@ CONFIG_RTE_LIBRTE_PORT=y
 CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_frag.c b/lib/librte_port/rte_port_frag.c
index c4c05dc..c42b182 100644
--- a/lib/librte_port/rte_port_frag.c
+++ b/lib/librte_port/rte_port_frag.c
@@ -41,6 +41,20 @@
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
+#ifdef RTE_PORT_RING_READER_FRAG_STATS_COLLECT
+
+#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 typedef int32_t
 		(*frag_op)(struct rte_mbuf *pkt_in,
 			struct rte_mbuf **pkts_out,
@@ -50,6 +64,8 @@ typedef int32_t
 			struct rte_mempool *pool_indirect);
 
 struct rte_port_ring_reader_frag {
+	struct rte_port_in_stats stats;
+
 	/* Input parameters */
 	struct rte_ring *ring;
 	uint32_t mtu;
@@ -171,6 +187,7 @@ rte_port_ring_reader_frag_rx(void *port,
 		if (p->n_pkts == 0) {
 			p->n_pkts = rte_ring_sc_dequeue_burst(p->ring,
 				(void **) p->pkts, RTE_PORT_IN_BURST_SIZE_MAX);
+			RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD(p, p->n_pkts);
 			if (p->n_pkts == 0)
 				return n_pkts_out;
 			p->pos_pkts = 0;
@@ -203,6 +220,7 @@ rte_port_ring_reader_frag_rx(void *port,
 
 		if (status < 0) {
 			rte_pktmbuf_free(pkt);
+			RTE_PORT_RING_READER_FRAG_STATS_PKTS_DROP_ADD(p, 1);
 			continue;
 		}
 
@@ -252,6 +270,22 @@ rte_port_ring_reader_frag_free(void *port)
 	return 0;
 }
 
+static int
+rte_port_frag_reader_stats_read(void *port,
+		struct rte_port_in_stats *stats, int clear)
+{
+	struct rte_port_ring_reader_frag *p =
+		(struct rte_port_ring_reader_frag *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Summary of port operations
  */
@@ -259,10 +293,12 @@ struct rte_port_in_ops rte_port_ring_reader_ipv4_frag_ops = {
 	.f_create = rte_port_ring_reader_ipv4_frag_create,
 	.f_free = rte_port_ring_reader_frag_free,
 	.f_rx = rte_port_ring_reader_frag_rx,
+	.f_stats = rte_port_frag_reader_stats_read,
 };
 
 struct rte_port_in_ops rte_port_ring_reader_ipv6_frag_ops = {
 	.f_create = rte_port_ring_reader_ipv6_frag_create,
 	.f_free = rte_port_ring_reader_frag_free,
 	.f_rx = rte_port_ring_reader_frag_rx,
+	.f_stats = rte_port_frag_reader_stats_read,
 };
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 06/13] port: added port_ras stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (4 preceding siblings ...)
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 05/13] port: added port_frag stats Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 07/13] port: added port_ring_reader stats Maciej Gajdzica
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp           |    1 +
 config/common_linuxapp         |    1 +
 lib/librte_port/rte_port_ras.c |   38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 523b9e9..0e73ce6 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -386,6 +386,7 @@ CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index e4baf41..cef8be0 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -393,6 +393,7 @@ CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c
index 5eb627a..d7aaf6c 100644
--- a/lib/librte_port/rte_port_ras.c
+++ b/lib/librte_port/rte_port_ras.c
@@ -51,6 +51,20 @@
 #define RTE_PORT_RAS_N_ENTRIES (RTE_PORT_RAS_N_BUCKETS * RTE_PORT_RAS_N_ENTRIES_PER_BUCKET)
 #endif
 
+#ifdef RTE_PORT_RING_WRITER_RAS_STATS_COLLECT
+
+#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_ring_writer_ras;
 
 typedef void (*ras_op)(
@@ -63,6 +77,8 @@ static void
 process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt);
 
 struct rte_port_ring_writer_ras {
+	struct rte_port_out_stats stats;
+
 	struct rte_mbuf *tx_buf[RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_ring *ring;
 	uint32_t tx_burst_sz;
@@ -153,6 +169,7 @@ send_burst(struct rte_port_ring_writer_ras *p)
 	nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf,
 			p->tx_buf_count);
 
+	RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx);
 	for ( ; nb_tx < p->tx_buf_count; nb_tx++)
 		rte_pktmbuf_free(p->tx_buf[nb_tx]);
 
@@ -225,6 +242,7 @@ rte_port_ring_writer_ras_tx(void *port, struct rte_mbuf *pkt)
 	struct rte_port_ring_writer_ras *p =
 			(struct rte_port_ring_writer_ras *) port;
 
+	RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(p, 1);
 	p->f_ras(p, pkt);
 	if (p->tx_buf_count >= p->tx_burst_sz)
 		send_burst(p);
@@ -247,6 +265,7 @@ rte_port_ring_writer_ras_tx_bulk(void *port,
 		for (i = 0; i < n_pkts; i++) {
 			struct rte_mbuf *pkt = pkts[i];
 
+			RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(p, 1);
 			p->f_ras(p, pkt);
 			if (p->tx_buf_count >= p->tx_burst_sz)
 				send_burst(p);
@@ -257,6 +276,7 @@ rte_port_ring_writer_ras_tx_bulk(void *port,
 			uint64_t pkt_mask = 1LLU << pkt_index;
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
+			RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(p, 1);
 			p->f_ras(p, pkt);
 			if (p->tx_buf_count >= p->tx_burst_sz)
 				send_burst(p);
@@ -298,6 +318,22 @@ rte_port_ring_writer_ras_free(void *port)
 	return 0;
 }
 
+static int
+rte_port_ras_writer_stats_read(void *port,
+		struct rte_port_out_stats *stats, int clear)
+{
+	struct rte_port_ring_writer_ras *p =
+		(struct rte_port_ring_writer_ras *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Summary of port operations
  */
@@ -307,6 +343,7 @@ struct rte_port_out_ops rte_port_ring_writer_ipv4_ras_ops = {
 	.f_tx = rte_port_ring_writer_ras_tx,
 	.f_tx_bulk = rte_port_ring_writer_ras_tx_bulk,
 	.f_flush = rte_port_ring_writer_ras_flush,
+	.f_stats = rte_port_ras_writer_stats_read,
 };
 
 struct rte_port_out_ops rte_port_ring_writer_ipv6_ras_ops = {
@@ -315,4 +352,5 @@ struct rte_port_out_ops rte_port_ring_writer_ipv6_ras_ops = {
 	.f_tx = rte_port_ring_writer_ras_tx,
 	.f_tx_bulk = rte_port_ring_writer_ras_tx_bulk,
 	.f_flush = rte_port_ring_writer_ras_flush,
+	.f_stats = rte_port_ras_writer_stats_read,
 };
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 07/13] port: added port_ring_reader stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (5 preceding siblings ...)
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 06/13] port: added port_ras stats Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 08/13] port: added port_ring_writer stats Maciej Gajdzica
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp            |    1 +
 config/common_linuxapp          |    1 +
 lib/librte_port/rte_port_ring.c |   39 ++++++++++++++++++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 0e73ce6..b51095c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -387,6 +387,7 @@ CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_READER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index cef8be0..d84d2cf 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -394,6 +394,7 @@ CONFIG_RTE_PORT_ETHDEV_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_READER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c
index 371bb1e..6c5b514 100644
--- a/lib/librte_port/rte_port_ring.c
+++ b/lib/librte_port/rte_port_ring.c
@@ -42,7 +42,23 @@
 /*
  * Port RING Reader
  */
+#ifdef RTE_PORT_RING_READER_STATS_COLLECT
+
+#define RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_RING_READER_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_RING_READER_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_ring_reader {
+	struct rte_port_in_stats stats;
+
 	struct rte_ring *ring;
 };
 
@@ -77,8 +93,12 @@ static int
 rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 {
 	struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;
+	uint32_t nb_rx;
+
+	nb_rx = rte_ring_sc_dequeue_burst(p->ring, (void **) pkts, n_pkts);
+	RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx);
 
-	return rte_ring_sc_dequeue_burst(p->ring, (void **) pkts, n_pkts);
+	return nb_rx;
 }
 
 static int
@@ -94,6 +114,22 @@ rte_port_ring_reader_free(void *port)
 	return 0;
 }
 
+static int
+rte_port_ring_reader_stats_read(void *port,
+		struct rte_port_in_stats *stats, int clear)
+{
+	struct rte_port_ring_reader *p =
+		(struct rte_port_ring_reader *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Port RING Writer
  */
@@ -503,6 +539,7 @@ struct rte_port_in_ops rte_port_ring_reader_ops = {
 	.f_create = rte_port_ring_reader_create,
 	.f_free = rte_port_ring_reader_free,
 	.f_rx = rte_port_ring_reader_rx,
+	.f_stats = rte_port_ring_reader_stats_read,
 };
 
 struct rte_port_out_ops rte_port_ring_writer_ops = {
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 08/13] port: added port_ring_writer stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (6 preceding siblings ...)
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 07/13] port: added port_ring_reader stats Maciej Gajdzica
@ 2015-03-30 10:28 ` Maciej Gajdzica
  2015-03-30 10:29 ` [dpdk-dev] [PATCH 09/13] port: added port_ring_writer_nodrop stats Maciej Gajdzica
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:28 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp            |    1 +
 config/common_linuxapp          |    1 +
 lib/librte_port/rte_port_ring.c |   40 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index b51095c..94930ed 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -388,6 +388,7 @@ CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_WRITER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index d84d2cf..3127de5 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -395,6 +395,7 @@ CONFIG_RTE_PORT_ETHDEV_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_WRITER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c
index 6c5b514..6d03093 100644
--- a/lib/librte_port/rte_port_ring.c
+++ b/lib/librte_port/rte_port_ring.c
@@ -135,7 +135,23 @@ rte_port_ring_reader_stats_read(void *port,
  */
 #define RTE_PORT_RING_WRITER_APPROACH                  1
 
+#ifdef RTE_PORT_RING_WRITER_STATS_COLLECT
+
+#define RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_ring_writer {
+	struct rte_port_out_stats stats;
+
 	struct rte_mbuf *tx_buf[RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_ring *ring;
 	uint32_t tx_burst_sz;
@@ -183,6 +199,7 @@ send_burst(struct rte_port_ring_writer *p)
 	nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf,
 			p->tx_buf_count);
 
+	RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx);
 	for ( ; nb_tx < p->tx_buf_count; nb_tx++)
 		rte_pktmbuf_free(p->tx_buf[nb_tx]);
 
@@ -195,6 +212,7 @@ rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt)
 	struct rte_port_ring_writer *p = (struct rte_port_ring_writer *) port;
 
 	p->tx_buf[p->tx_buf_count++] = pkt;
+	RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1);
 	if (p->tx_buf_count >= p->tx_burst_sz)
 		send_burst(p);
 
@@ -214,6 +232,7 @@ rte_port_ring_writer_tx_bulk(void *port,
 		uint64_t n_pkts = __builtin_popcountll(pkts_mask);
 		uint32_t i;
 
+		RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, n_pkts);
 		for (i = 0; i < n_pkts; i++) {
 			struct rte_mbuf *pkt = pkts[i];
 
@@ -228,6 +247,7 @@ rte_port_ring_writer_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[p->tx_buf_count++] = pkt;
+			RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1);
 			if (p->tx_buf_count >= p->tx_burst_sz)
 				send_burst(p);
 			pkts_mask &= ~pkt_mask;
@@ -259,8 +279,10 @@ rte_port_ring_writer_tx_bulk(void *port,
 		if (tx_buf_count)
 			send_burst(p);
 
+		RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, n_pkts);
 		n_pkts_ok = rte_ring_sp_enqueue_burst(p->ring, (void **)pkts, n_pkts);
 
+		RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - n_pkts_ok);
 		for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) {
 			struct rte_mbuf *pkt = pkts[n_pkts_ok];
 
@@ -273,6 +295,7 @@ rte_port_ring_writer_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[tx_buf_count++] = pkt;
+			RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1);
 			pkts_mask &= ~pkt_mask;
 		}
 
@@ -315,6 +338,22 @@ rte_port_ring_writer_free(void *port)
 	return 0;
 }
 
+static int
+rte_port_ring_writer_stats_read(void *port,
+		struct rte_port_out_stats *stats, int clear)
+{
+	struct rte_port_ring_writer *p =
+		(struct rte_port_ring_writer *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Port RING Writer Nodrop
  */
@@ -548,6 +587,7 @@ struct rte_port_out_ops rte_port_ring_writer_ops = {
 	.f_tx = rte_port_ring_writer_tx,
 	.f_tx_bulk = rte_port_ring_writer_tx_bulk,
 	.f_flush = rte_port_ring_writer_flush,
+	.f_stats = rte_port_ring_writer_stats_read,
 };
 
 struct rte_port_out_ops rte_port_ring_writer_nodrop_ops = {
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH 09/13] port: added port_ring_writer_nodrop stats
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (7 preceding siblings ...)
  2015-03-30 10:28 ` [dpdk-dev] [PATCH 08/13] port: added port_ring_writer stats Maciej Gajdzica
@ 2015-03-30 10:29 ` Maciej Gajdzica
  2015-03-30 11:57 ` [dpdk-dev] [PATCH 00/13] port: added port statistics Dumitrescu, Cristian
  2015-03-30 16:45 ` Stephen Hemminger
  10 siblings, 0 replies; 13+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 10:29 UTC (permalink / raw)
  To: dev

---
 config/common_bsdapp            |    1 +
 config/common_linuxapp          |    1 +
 lib/librte_port/rte_port_ring.c |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 94930ed..4a06da6 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -389,6 +389,7 @@ CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_WRITER_NODROP_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 3127de5..26e2d22 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -396,6 +396,7 @@ CONFIG_RTE_PORT_RING_READER_FRAG_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_RAS_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_STATS_COLLECT=n
+CONFIG_RTE_PORT_RING_WRITER_NODROP_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c
index 6d03093..b263662 100644
--- a/lib/librte_port/rte_port_ring.c
+++ b/lib/librte_port/rte_port_ring.c
@@ -359,7 +359,23 @@ rte_port_ring_writer_stats_read(void *port,
  */
 #define RTE_PORT_RING_WRITER_NODROP_APPROACH                  1
 
+#ifdef RTE_PORT_RING_WRITER_NODROP_STATS_COLLECT
+
+#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_ring_writer_nodrop {
+	struct rte_port_out_stats stats;
+
 	struct rte_mbuf *tx_buf[RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_ring *ring;
 	uint32_t tx_burst_sz;
@@ -429,6 +445,7 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)
 	}
 
 	/* We didn't send the packets in maximum allowed attempts */
+	RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx);
 	for ( ; nb_tx < p->tx_buf_count; nb_tx++)
 		rte_pktmbuf_free(p->tx_buf[nb_tx]);
 
@@ -442,6 +459,7 @@ rte_port_ring_writer_nodrop_tx(void *port, struct rte_mbuf *pkt)
 			(struct rte_port_ring_writer_nodrop *) port;
 
 	p->tx_buf[p->tx_buf_count++] = pkt;
+	RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);
 	if (p->tx_buf_count >= p->tx_burst_sz)
 		send_burst_nodrop(p);
 
@@ -462,6 +480,7 @@ rte_port_ring_writer_nodrop_tx_bulk(void *port,
 		uint64_t n_pkts = __builtin_popcountll(pkts_mask);
 		uint32_t i;
 
+		RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts);
 		for (i = 0; i < n_pkts; i++) {
 			struct rte_mbuf *pkt = pkts[i];
 
@@ -476,6 +495,7 @@ rte_port_ring_writer_nodrop_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[p->tx_buf_count++] = pkt;
+			RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);
 			if (p->tx_buf_count >= p->tx_burst_sz)
 				send_burst_nodrop(p);
 			pkts_mask &= ~pkt_mask;
@@ -507,6 +527,7 @@ rte_port_ring_writer_nodrop_tx_bulk(void *port,
 		if (tx_buf_count)
 			send_burst_nodrop(p);
 
+		RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts);
 		n_pkts_ok = rte_ring_sp_enqueue_burst(p->ring, (void **)pkts, n_pkts);
 
 		if (n_pkts_ok >= n_pkts)
@@ -528,6 +549,7 @@ rte_port_ring_writer_nodrop_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[tx_buf_count++] = pkt;
+			RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);
 			pkts_mask &= ~pkt_mask;
 		}
 
@@ -571,6 +593,22 @@ rte_port_ring_writer_nodrop_free(void *port)
 	return 0;
 }
 
+static int
+rte_port_ring_writer_nodrop_stats_read(void *port,
+		struct rte_port_out_stats *stats, int clear)
+{
+	struct rte_port_ring_writer_nodrop *p =
+		(struct rte_port_ring_writer_nodrop *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Summary of port operations
  */
@@ -596,4 +634,5 @@ struct rte_port_out_ops rte_port_ring_writer_nodrop_ops = {
 	.f_tx = rte_port_ring_writer_nodrop_tx,
 	.f_tx_bulk = rte_port_ring_writer_nodrop_tx_bulk,
 	.f_flush = rte_port_ring_writer_nodrop_flush,
+	.f_stats = rte_port_ring_writer_nodrop_stats_read,
 };
-- 
1.7.9.5

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

* Re: [dpdk-dev] [PATCH 00/13] port: added port statistics
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (8 preceding siblings ...)
  2015-03-30 10:29 ` [dpdk-dev] [PATCH 09/13] port: added port_ring_writer_nodrop stats Maciej Gajdzica
@ 2015-03-30 11:57 ` Dumitrescu, Cristian
  2015-03-30 16:45 ` Stephen Hemminger
  10 siblings, 0 replies; 13+ messages in thread
From: Dumitrescu, Cristian @ 2015-03-30 11:57 UTC (permalink / raw)
  To: Gajdzica, MaciejX T, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Maciej Gajdzica
> Sent: Monday, March 30, 2015 11:29 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 00/13] port: added port statistics
> 
> Added statistics for every type of port. By default all port statistics
> are disabled, user must activate them in config file.
> 
> This patchset depends on two patchsets:
> port: added ethdev_writer_nodrop and ring_writer_nodrop ports
> port: added frag_ipv6 and ras_ipv6 ports
> 
> Maciej Gajdzica (13):
>   port: added structures for port stats
>   port: added port_ethdev_reader stats
>   port: added port_ethdev_writer stats
>   port: added port_ethdev_writer_nodrop stats
>   port: added port_frag stats
>   port: added port_ras stats
>   port: added port_ring_reader stats
>   port: added port_ring_writer stats
>   port: added port_ring_writer_nodrop stats
>   port: added port_sched_reader stats
>   port: added port_sched_writer stats
>   port: added port_source stats
>   port: added port_sink stats
> 
>  config/common_bsdapp                   |   12 ++++
>  config/common_linuxapp                 |   12 ++++
>  lib/librte_port/rte_port.h             |   60 ++++++++++++++--
>  lib/librte_port/rte_port_ethdev.c      |  113
> +++++++++++++++++++++++++++++-
>  lib/librte_port/rte_port_frag.c        |   36 ++++++++++
>  lib/librte_port/rte_port_ras.c         |   38 ++++++++++
>  lib/librte_port/rte_port_ring.c        |  118
> +++++++++++++++++++++++++++++++-
>  lib/librte_port/rte_port_sched.c       |   96 ++++++++++++++++++++++++--
>  lib/librte_port/rte_port_source_sink.c |   98
> ++++++++++++++++++++++++--
>  9 files changed, 566 insertions(+), 17 deletions(-)
> 
> --
> 1.7.9.5

Acked by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

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

* Re: [dpdk-dev] [PATCH 00/13] port: added port statistics
  2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
                   ` (9 preceding siblings ...)
  2015-03-30 11:57 ` [dpdk-dev] [PATCH 00/13] port: added port statistics Dumitrescu, Cristian
@ 2015-03-30 16:45 ` Stephen Hemminger
  2015-03-30 20:27   ` David Marchand
  10 siblings, 1 reply; 13+ messages in thread
From: Stephen Hemminger @ 2015-03-30 16:45 UTC (permalink / raw)
  To: Maciej Gajdzica; +Cc: dev

On Mon, 30 Mar 2015 12:28:51 +0200
Maciej Gajdzica <maciejx.t.gajdzica@intel.com> wrote:

> Added statistics for every type of port. By default all port statistics
> are disabled, user must activate them in config file.

Can we stop with the config file option for everything nonsense.
I know that it makes sense for demos and special case testing, but
config options just increase the testing space and also make life
more difficult for distributions.

Unless there is a reason that these statistics should never be
used, why aren't they always present. If you say they hurt performance,
then do something about it (like using per-core statistics).

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

* Re: [dpdk-dev] [PATCH 00/13] port: added port statistics
  2015-03-30 16:45 ` Stephen Hemminger
@ 2015-03-30 20:27   ` David Marchand
  0 siblings, 0 replies; 13+ messages in thread
From: David Marchand @ 2015-03-30 20:27 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Mon, Mar 30, 2015 at 6:45 PM, Stephen Hemminger <
stephen@networkplumber.org> wrote:

> On Mon, 30 Mar 2015 12:28:51 +0200
> Maciej Gajdzica <maciejx.t.gajdzica@intel.com> wrote:
>
> > Added statistics for every type of port. By default all port statistics
> > are disabled, user must activate them in config file.
>
> Can we stop with the config file option for everything nonsense.
> I know that it makes sense for demos and special case testing, but
> config options just increase the testing space and also make life
> more difficult for distributions.
>
> Unless there is a reason that these statistics should never be
> used, why aren't they always present. If you say they hurt performance,
> then do something about it (like using per-core statistics).
>

+1

-- 
David Marchand

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

end of thread, other threads:[~2015-03-30 20:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30 10:28 [dpdk-dev] [PATCH 00/13] port: added port statistics Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 01/13] port: added structures for port stats Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 02/13] port: added port_ethdev_reader stats Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 03/13] port: added port_ethdev_writer stats Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 04/13] port: added port_ethdev_writer_nodrop stats Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 05/13] port: added port_frag stats Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 06/13] port: added port_ras stats Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 07/13] port: added port_ring_reader stats Maciej Gajdzica
2015-03-30 10:28 ` [dpdk-dev] [PATCH 08/13] port: added port_ring_writer stats Maciej Gajdzica
2015-03-30 10:29 ` [dpdk-dev] [PATCH 09/13] port: added port_ring_writer_nodrop stats Maciej Gajdzica
2015-03-30 11:57 ` [dpdk-dev] [PATCH 00/13] port: added port statistics Dumitrescu, Cristian
2015-03-30 16:45 ` Stephen Hemminger
2015-03-30 20:27   ` David Marchand

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