DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2 00/13] port: added port statistics
@ 2015-04-30 12:07 Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 01/13] port: added structures for port stats Michal Jastrzebski
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

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

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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 01/13] port: added structures for port stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-05-18 10:47   ` Thomas Monjalon
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 02/13] port: added port_ethdev_reader stats Michal Jastrzebski
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added common data structures for port statistics.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 02/13] port: added port_ethdev_reader stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 01/13] port: added structures for port stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-05-18 10:53   ` Thomas Monjalon
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 03/13] port: added port_ethdev_writer stats Michal Jastrzebski
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for ethdev reader port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 c2374c0..db73c9c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -383,6 +383,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 0078dc9..a8719a6 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -390,6 +390,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] 17+ messages in thread

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

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for ethdev writer port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 db73c9c..337ce31 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
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index a8719a6..2e0856f 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
 
 #
 # 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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 04/13] port: added port_ethdev_writer_nodrop stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (2 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 03/13] port: added port_ethdev_writer stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 05/13] port: added port_frag stats Michal Jastrzebski
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for ethdev writer nodrop port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 337ce31..89da648 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -385,6 +385,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 2e0856f..630d163 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -392,6 +392,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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 05/13] port: added port_frag stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (3 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 04/13] port: added port_ethdev_writer_nodrop stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 06/13] port: added port_ras stats Michal Jastrzebski
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for IPv4 and IPv6 fragmentation ports.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 89da648..f3b8459 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -386,6 +386,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 630d163..3ac2e66 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -393,6 +393,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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 06/13] port: added port_ras stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (4 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 05/13] port: added port_frag stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 07/13] port: added port_ring_reader stats Michal Jastrzebski
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for IPv4 and IPv6 reassembly ports.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 f3b8459..e7a19d4 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -387,6 +387,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 3ac2e66..ff9898f 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -394,6 +394,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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 07/13] port: added port_ring_reader stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (5 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 06/13] port: added port_ras stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 08/13] port: added port_ring_writer stats Michal Jastrzebski
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for ring reader port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 e7a19d4..47165f9 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -388,6 +388,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 ff9898f..a6da86c 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -395,6 +395,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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 08/13] port: added port_ring_writer stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (6 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 07/13] port: added port_ring_reader stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 09/13] port: added port_ring_writer_nodrop stats Michal Jastrzebski
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for port writer port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 47165f9..3d250ae 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -389,6 +389,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 a6da86c..770a1f0 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -396,6 +396,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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 09/13] port: added port_ring_writer_nodrop stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (7 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 08/13] port: added port_ring_writer stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 10/13] port: added port_sched_reader stats Michal Jastrzebski
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for ring writer nodrop port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 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 3d250ae..8ddd84a 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -390,6 +390,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 770a1f0..593fe79 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -397,6 +397,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] 17+ messages in thread

* [dpdk-dev] [PATCH v2 10/13] port: added port_sched_reader stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (8 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 09/13] port: added port_ring_writer_nodrop stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 11/13] port: added port_sched_writer stats Michal Jastrzebski
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for sched reader port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 config/common_bsdapp             |    1 +
 config/common_linuxapp           |    1 +
 lib/librte_port/rte_port_sched.c |   39 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 8ddd84a..eb2d479 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -391,6 +391,7 @@ 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
+CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 593fe79..abeb703 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -398,6 +398,7 @@ 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
+CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_sched.c b/lib/librte_port/rte_port_sched.c
index 2107f4c..f1cb435 100644
--- a/lib/librte_port/rte_port_sched.c
+++ b/lib/librte_port/rte_port_sched.c
@@ -40,7 +40,23 @@
 /*
  * Reader
  */
+#ifdef RTE_PORT_SCHED_READER_STATS_COLLECT
+
+#define RTE_PORT_SCHED_READER_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_SCHED_READER_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_SCHED_READER_PKTS_IN_ADD(port, val)
+#define RTE_PORT_SCHED_READER_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_sched_reader {
+	struct rte_port_in_stats stats;
+
 	struct rte_sched_port *sched;
 };
 
@@ -76,8 +92,12 @@ static int
 rte_port_sched_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 {
 	struct rte_port_sched_reader *p = (struct rte_port_sched_reader *) port;
+	uint32_t nb_rx;
 
-	return rte_sched_port_dequeue(p->sched, pkts, n_pkts);
+	nb_rx = rte_sched_port_dequeue(p->sched, pkts, n_pkts);
+	RTE_PORT_SCHED_READER_PKTS_IN_ADD(p, nb_rx);
+
+	return nb_rx;
 }
 
 static int
@@ -93,6 +113,22 @@ rte_port_sched_reader_free(void *port)
 	return 0;
 }
 
+static int
+rte_port_sched_reader_stats_read(void *port,
+		struct rte_port_in_stats *stats, int clear)
+{
+	struct rte_port_sched_reader *p =
+		(struct rte_port_sched_reader *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Writer
  */
@@ -228,6 +264,7 @@ struct rte_port_in_ops rte_port_sched_reader_ops = {
 	.f_create = rte_port_sched_reader_create,
 	.f_free = rte_port_sched_reader_free,
 	.f_rx = rte_port_sched_reader_rx,
+	.f_stats = rte_port_sched_reader_stats_read,
 };
 
 struct rte_port_out_ops rte_port_sched_writer_ops = {
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH v2 11/13] port: added port_sched_writer stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (9 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 10/13] port: added port_sched_reader stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 12/13] port: added port_source stats Michal Jastrzebski
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for sched writer port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 config/common_bsdapp             |    1 +
 config/common_linuxapp           |    1 +
 lib/librte_port/rte_port_sched.c |   57 ++++++++++++++++++++++++++++++++++----
 3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index eb2d479..06c788c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -392,6 +392,7 @@ 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
 CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
+CONFIG_RTE_PORT_SCHED_WRITER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index abeb703..819edea 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -399,6 +399,7 @@ 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
 CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
+CONFIG_RTE_PORT_SCHED_WRITER_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_sched.c b/lib/librte_port/rte_port_sched.c
index f1cb435..93d7930 100644
--- a/lib/librte_port/rte_port_sched.c
+++ b/lib/librte_port/rte_port_sched.c
@@ -132,7 +132,23 @@ rte_port_sched_reader_stats_read(void *port,
 /*
  * Writer
  */
+#ifdef RTE_PORT_SCHED_WRITER_STATS_COLLECT
+
+#define RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_sched_writer {
+	struct rte_port_out_stats stats;
+
 	struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_sched_port *sched;
 	uint32_t tx_burst_sz;
@@ -180,8 +196,12 @@ rte_port_sched_writer_tx(void *port, struct rte_mbuf *pkt)
 	struct rte_port_sched_writer *p = (struct rte_port_sched_writer *) port;
 
 	p->tx_buf[p->tx_buf_count++] = pkt;
+	RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(p, 1);
 	if (p->tx_buf_count >= p->tx_burst_sz) {
-		rte_sched_port_enqueue(p->sched, p->tx_buf, p->tx_buf_count);
+		__rte_unused uint32_t nb_tx;
+
+		nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf, p->tx_buf_count);
+		RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx);
 		p->tx_buf_count = 0;
 	}
 
@@ -200,15 +220,18 @@ rte_port_sched_writer_tx_bulk(void *port,
 			((pkts_mask & bsz_mask) ^ bsz_mask);
 
 	if (expr == 0) {
+		__rte_unused uint32_t nb_tx;
 		uint64_t n_pkts = __builtin_popcountll(pkts_mask);
 
 		if (tx_buf_count) {
-			rte_sched_port_enqueue(p->sched, p->tx_buf,
+			nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf,
 				tx_buf_count);
+			RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, tx_buf_count - nb_tx);
 			p->tx_buf_count = 0;
 		}
 
-		rte_sched_port_enqueue(p->sched, pkts, n_pkts);
+		nb_tx = rte_sched_port_enqueue(p->sched, pkts, n_pkts);
+		RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - nb_tx);
 	} else {
 		for ( ; pkts_mask; ) {
 			uint32_t pkt_index = __builtin_ctzll(pkts_mask);
@@ -216,13 +239,17 @@ rte_port_sched_writer_tx_bulk(void *port,
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
 			p->tx_buf[tx_buf_count++] = pkt;
+			RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(p, 1);
 			pkts_mask &= ~pkt_mask;
 		}
 		p->tx_buf_count = tx_buf_count;
 
 		if (tx_buf_count >= p->tx_burst_sz) {
-			rte_sched_port_enqueue(p->sched, p->tx_buf,
+			__rte_unused uint32_t nb_tx;
+
+			nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf,
 				tx_buf_count);
+			RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, tx_buf_count - nb_tx);
 			p->tx_buf_count = 0;
 		}
 	}
@@ -236,7 +263,10 @@ rte_port_sched_writer_flush(void *port)
 	struct rte_port_sched_writer *p = (struct rte_port_sched_writer *) port;
 
 	if (p->tx_buf_count) {
-		rte_sched_port_enqueue(p->sched, p->tx_buf, p->tx_buf_count);
+		__rte_unused uint32_t nb_tx;
+
+		nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf, p->tx_buf_count);
+		RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx);
 		p->tx_buf_count = 0;
 	}
 
@@ -257,6 +287,22 @@ rte_port_sched_writer_free(void *port)
 	return 0;
 }
 
+static int
+rte_port_sched_writer_stats_read(void *port,
+		struct rte_port_out_stats *stats, int clear)
+{
+	struct rte_port_sched_writer *p =
+		(struct rte_port_sched_writer *) 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
  */
@@ -273,4 +319,5 @@ struct rte_port_out_ops rte_port_sched_writer_ops = {
 	.f_tx = rte_port_sched_writer_tx,
 	.f_tx_bulk = rte_port_sched_writer_tx_bulk,
 	.f_flush = rte_port_sched_writer_flush,
+	.f_stats = rte_port_sched_writer_stats_read,
 };
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH v2 12/13] port: added port_source stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (10 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 11/13] port: added port_sched_writer stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 13/13] port: added port_sink stats Michal Jastrzebski
  2015-05-05 15:08 ` [dpdk-dev] [PATCH v2 00/13] port: added port statistics Dumitrescu, Cristian
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for source port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 config/common_bsdapp                   |    1 +
 config/common_linuxapp                 |    1 +
 lib/librte_port/rte_port_source_sink.c |   35 ++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 06c788c..7f2554c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -393,6 +393,7 @@ CONFIG_RTE_PORT_RING_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_WRITER_STATS_COLLECT=n
+CONFIG_RTE_PORT_SOURCE_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 819edea..f2d58b3 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -400,6 +400,7 @@ CONFIG_RTE_PORT_RING_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_RING_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_WRITER_STATS_COLLECT=n
+CONFIG_RTE_PORT_SOURCE_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_source_sink.c b/lib/librte_port/rte_port_source_sink.c
index b9a25bb..4f51ec7 100644
--- a/lib/librte_port/rte_port_source_sink.c
+++ b/lib/librte_port/rte_port_source_sink.c
@@ -42,7 +42,23 @@
 /*
  * Port SOURCE
  */
+#ifdef RTE_PORT_SOURCE_STATS_COLLECT
+
+#define RTE_PORT_SOURCE_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_SOURCE_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_SOURCE_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_SOURCE_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
 struct rte_port_source {
+	struct rte_port_in_stats stats;
+
 	struct rte_mempool *mempool;
 };
 
@@ -93,9 +109,27 @@ rte_port_source_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 	if (rte_mempool_get_bulk(p->mempool, (void **) pkts, n_pkts) != 0)
 		return 0;
 
+	RTE_PORT_SOURCE_STATS_PKTS_IN_ADD(p, n_pkts);
+
 	return n_pkts;
 }
 
+static int
+rte_port_source_stats_read(void *port,
+		struct rte_port_in_stats *stats, int clear)
+{
+	struct rte_port_source *p =
+		(struct rte_port_source *) port;
+
+	if (stats != NULL)
+		memcpy(stats, &p->stats, sizeof(p->stats));
+
+	if (clear)
+		memset(&p->stats, 0, sizeof(p->stats));
+
+	return 0;
+}
+
 /*
  * Port SINK
  */
@@ -147,6 +181,7 @@ struct rte_port_in_ops rte_port_source_ops = {
 	.f_create = rte_port_source_create,
 	.f_free = rte_port_source_free,
 	.f_rx = rte_port_source_rx,
+	.f_stats = rte_port_source_stats_read,
 };
 
 struct rte_port_out_ops rte_port_sink_ops = {
-- 
1.7.9.5

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

* [dpdk-dev] [PATCH v2 13/13] port: added port_sink stats
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (11 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 12/13] port: added port_source stats Michal Jastrzebski
@ 2015-04-30 12:07 ` Michal Jastrzebski
  2015-05-05 15:08 ` [dpdk-dev] [PATCH v2 00/13] port: added port statistics Dumitrescu, Cristian
  13 siblings, 0 replies; 17+ messages in thread
From: Michal Jastrzebski @ 2015-04-30 12:07 UTC (permalink / raw)
  To: dev

From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>

Added statistics for sink port.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 config/common_bsdapp                   |    1 +
 config/common_linuxapp                 |    1 +
 lib/librte_port/rte_port_source_sink.c |   63 ++++++++++++++++++++++++++++++--
 3 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 7f2554c..238d178 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -394,6 +394,7 @@ CONFIG_RTE_PORT_RING_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_SOURCE_STATS_COLLECT=n
+CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index f2d58b3..36a623d 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -401,6 +401,7 @@ CONFIG_RTE_PORT_RING_WRITER_NODROP_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_READER_STATS_COLLECT=n
 CONFIG_RTE_PORT_SCHED_WRITER_STATS_COLLECT=n
 CONFIG_RTE_PORT_SOURCE_STATS_COLLECT=n
+CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 
 #
 # Compile librte_table
diff --git a/lib/librte_port/rte_port_source_sink.c b/lib/librte_port/rte_port_source_sink.c
index 4f51ec7..508fcf6 100644
--- a/lib/librte_port/rte_port_source_sink.c
+++ b/lib/librte_port/rte_port_source_sink.c
@@ -133,28 +133,64 @@ rte_port_source_stats_read(void *port,
 /*
  * Port SINK
  */
+#ifdef RTE_PORT_SINK_STATS_COLLECT
+
+#define RTE_PORT_SINK_STATS_PKTS_IN_ADD(port, val) \
+	port->stats.n_pkts_in += val
+#define RTE_PORT_SINK_STATS_PKTS_DROP_ADD(port, val) \
+	port->stats.n_pkts_drop += val
+
+#else
+
+#define RTE_PORT_SINK_STATS_PKTS_IN_ADD(port, val)
+#define RTE_PORT_SINK_STATS_PKTS_DROP_ADD(port, val)
+
+#endif
+
+struct rte_port_sink {
+	struct rte_port_out_stats stats;
+};
+
 static void *
-rte_port_sink_create(__rte_unused void *params, __rte_unused int socket_id)
+rte_port_sink_create(__rte_unused void *params, int socket_id)
 {
-	return (void *) 1;
+	struct rte_port_sink *port;
+
+	/* Memory allocation */
+	port = rte_zmalloc_socket("PORT", sizeof(*port),
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (port == NULL) {
+		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		return NULL;
+	}
+
+	return port;
 }
 
 static int
-rte_port_sink_tx(__rte_unused void *port, struct rte_mbuf *pkt)
+rte_port_sink_tx(void *port, struct rte_mbuf *pkt)
 {
+	__rte_unused struct rte_port_sink *p = (struct rte_port_sink *) port;
+
+	RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1);
 	rte_pktmbuf_free(pkt);
+	RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, 1);
 
 	return 0;
 }
 
 static int
-rte_port_sink_tx_bulk(__rte_unused void *port, struct rte_mbuf **pkts,
+rte_port_sink_tx_bulk(void *port, struct rte_mbuf **pkts,
 	uint64_t pkts_mask)
 {
+	__rte_unused struct rte_port_sink *p = (struct rte_port_sink *) port;
+
 	if ((pkts_mask & (pkts_mask + 1)) == 0) {
 		uint64_t n_pkts = __builtin_popcountll(pkts_mask);
 		uint32_t i;
 
+		RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, n_pkts);
+		RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, n_pkts);
 		for (i = 0; i < n_pkts; i++) {
 			struct rte_mbuf *pkt = pkts[i];
 
@@ -166,6 +202,8 @@ rte_port_sink_tx_bulk(__rte_unused void *port, struct rte_mbuf **pkts,
 			uint64_t pkt_mask = 1LLU << pkt_index;
 			struct rte_mbuf *pkt = pkts[pkt_index];
 
+			RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1);
+			RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, 1);
 			rte_pktmbuf_free(pkt);
 			pkts_mask &= ~pkt_mask;
 		}
@@ -174,6 +212,22 @@ rte_port_sink_tx_bulk(__rte_unused void *port, struct rte_mbuf **pkts,
 	return 0;
 }
 
+static int
+rte_port_sink_stats_read(void *port, struct rte_port_out_stats *stats,
+		int clear)
+{
+	struct rte_port_sink *p =
+		(struct rte_port_sink *) 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
  */
@@ -190,4 +244,5 @@ struct rte_port_out_ops rte_port_sink_ops = {
 	.f_tx = rte_port_sink_tx,
 	.f_tx_bulk = rte_port_sink_tx_bulk,
 	.f_flush = NULL,
+	.f_stats = rte_port_sink_stats_read,
 };
-- 
1.7.9.5

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

* Re: [dpdk-dev] [PATCH v2 00/13] port: added port statistics
  2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
                   ` (12 preceding siblings ...)
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 13/13] port: added port_sink stats Michal Jastrzebski
@ 2015-05-05 15:08 ` Dumitrescu, Cristian
  13 siblings, 0 replies; 17+ messages in thread
From: Dumitrescu, Cristian @ 2015-05-05 15:08 UTC (permalink / raw)
  To: Jastrzebski, MichalX K, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal Jastrzebski
> Sent: Thursday, April 30, 2015 1:07 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2 00/13] port: added port statistics
> 
> From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
> 
> Added statistics for every type of port. By default all port statistics
> are disabled, user must activate them in config file.
> 
> 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] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v2 01/13] port: added structures for port stats
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 01/13] port: added structures for port stats Michal Jastrzebski
@ 2015-05-18 10:47   ` Thomas Monjalon
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2015-05-18 10:47 UTC (permalink / raw)
  To: Maciej Gajdzica; +Cc: dev

2015-04-30 14:07, Michal Jastrzebski:
> From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
[...]
>  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 */
>  };

Please avoid changing alignment if not really necessary.
Here it seems you want to have some space between "f_stats;" and its comment.
So you should use spaces for alignment of the comments and not hard-tabs,
even less hard-tabs used as 4-char like here.

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

* Re: [dpdk-dev] [PATCH v2 02/13] port: added port_ethdev_reader stats
  2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 02/13] port: added port_ethdev_reader stats Michal Jastrzebski
@ 2015-05-18 10:53   ` Thomas Monjalon
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2015-05-18 10:53 UTC (permalink / raw)
  To: Maciej Gajdzica; +Cc: dev

2015-04-30 14:07, Michal Jastrzebski:
> From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
> 
> Added statistics for ethdev reader port.
> 
> Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
> ---
>  config/common_bsdapp              |    1 +
>  config/common_linuxapp            |    1 +
[...]
>  # Compile librte_port
>  #
>  CONFIG_RTE_LIBRTE_PORT=y
> +CONFIG_RTE_PORT_ETHDEV_READER_STATS_COLLECT=n

No, consider adding something to these files is forbidden.
We must remove compile-time options, not adding new ones.

CONFIG_RTE_LIBRTE_IP_FRAG_TBL_STAT and CONFIG_RTE_SCHED_COLLECT_STATS should
be removed.

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

end of thread, other threads:[~2015-05-18 12:29 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-30 12:07 [dpdk-dev] [PATCH v2 00/13] port: added port statistics Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 01/13] port: added structures for port stats Michal Jastrzebski
2015-05-18 10:47   ` Thomas Monjalon
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 02/13] port: added port_ethdev_reader stats Michal Jastrzebski
2015-05-18 10:53   ` Thomas Monjalon
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 03/13] port: added port_ethdev_writer stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 04/13] port: added port_ethdev_writer_nodrop stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 05/13] port: added port_frag stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 06/13] port: added port_ras stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 07/13] port: added port_ring_reader stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 08/13] port: added port_ring_writer stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 09/13] port: added port_ring_writer_nodrop stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 10/13] port: added port_sched_reader stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 11/13] port: added port_sched_writer stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 12/13] port: added port_source stats Michal Jastrzebski
2015-04-30 12:07 ` [dpdk-dev] [PATCH v2 13/13] port: added port_sink stats Michal Jastrzebski
2015-05-05 15:08 ` [dpdk-dev] [PATCH v2 00/13] port: added port statistics Dumitrescu, Cristian

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