* [dpdk-dev] [PATCH v4 01/13] port: added structures for port stats and config option
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-18 11:03 ` Gajdzica, MaciejX T
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 02/13] port: added port_ethdev_reader stats Michal Jastrzebski
` (24 subsequent siblings)
25 siblings, 1 reply; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added common data structures for port statistics. Added config option to
enable stats collecting.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
config/common_bsdapp | 1 +
config/common_linuxapp | 1 +
lib/librte_port/rte_port.h | 60 ++++++++++++++++++++++++++++++++++++++++----
3 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/config/common_bsdapp b/config/common_bsdapp
index c2374c0..1d26956 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
+RTE_PORT_STATS_COLLECT=n
#
# Compile librte_table
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..5105b25 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
+RTE_PORT_STATS_COLLECT=n
#
# Compile librte_table
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] 30+ messages in thread
* Re: [dpdk-dev] [PATCH v4 01/13] port: added structures for port stats and config option
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 01/13] port: added structures for port stats and config option Michal Jastrzebski
@ 2015-06-18 11:03 ` Gajdzica, MaciejX T
0 siblings, 0 replies; 30+ messages in thread
From: Gajdzica, MaciejX T @ 2015-06-18 11:03 UTC (permalink / raw)
To: Jastrzebski, MichalX K, dev
Self NACK - missing CONFIG_ prefix in config file defines. The same issue is present in table stats patchset.
Will resend new version today.
> -----Original Message-----
> From: Jastrzebski, MichalX K
> Sent: Monday, June 08, 2015 5:00 PM
> To: dev@dpdk.org
> Cc: Gajdzica, MaciejX T
> Subject: [PATCH v4 01/13] port: added structures for port stats and config
> option
[...]
>
> diff --git a/config/common_bsdapp b/config/common_bsdapp index
> c2374c0..1d26956 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
> +RTE_PORT_STATS_COLLECT=n
>
> #
> # Compile librte_table
> diff --git a/config/common_linuxapp b/config/common_linuxapp index
> 0078dc9..5105b25 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
> +RTE_PORT_STATS_COLLECT=n
[...]
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 02/13] port: added port_ethdev_reader stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 01/13] port: added structures for port stats and config option Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 03/13] port: added port_ethdev_writer stats Michal Jastrzebski
` (23 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 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>
---
lib/librte_port/rte_port_ethdev.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/lib/librte_port/rte_port_ethdev.c b/lib/librte_port/rte_port_ethdev.c
index 39ed72d..da1af08 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_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
*/
@@ -422,6 +456,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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 03/13] port: added port_ethdev_writer stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 01/13] port: added structures for port stats and config option Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 02/13] port: added port_ethdev_reader stats Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 04/13] port: added port_ethdev_writer_nodrop stats Michal Jastrzebski
` (22 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 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>
---
lib/librte_port/rte_port_ethdev.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/lib/librte_port/rte_port_ethdev.c b/lib/librte_port/rte_port_ethdev.c
index da1af08..b5b39f8 100644
--- a/lib/librte_port/rte_port_ethdev.c
+++ b/lib/librte_port/rte_port_ethdev.c
@@ -134,7 +134,23 @@ static int rte_port_ethdev_reader_stats_read(void *port,
/*
* Port ETHDEV Writer
*/
+#ifdef RTE_PORT_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;
@@ -185,6 +201,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]);
@@ -198,6 +215,7 @@ rte_port_ethdev_writer_tx(void *port, struct rte_mbuf *pkt)
(struct rte_port_ethdev_writer *) port;
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);
@@ -223,9 +241,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];
@@ -238,6 +258,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;
}
@@ -275,6 +296,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
*/
@@ -465,6 +501,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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 04/13] port: added port_ethdev_writer_nodrop stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (2 preceding siblings ...)
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 03/13] port: added port_ethdev_writer stats Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 05/13] port: added port_frag stats Michal Jastrzebski
` (21 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 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>
---
lib/librte_port/rte_port_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/lib/librte_port/rte_port_ethdev.c b/lib/librte_port/rte_port_ethdev.c
index b5b39f8..cee1b33 100644
--- a/lib/librte_port/rte_port_ethdev.c
+++ b/lib/librte_port/rte_port_ethdev.c
@@ -314,7 +314,23 @@ static int rte_port_ethdev_writer_stats_read(void *port,
/*
* Port ETHDEV Writer Nodrop
*/
+#ifdef RTE_PORT_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;
@@ -387,6 +403,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]);
@@ -400,6 +417,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);
@@ -426,6 +444,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);
@@ -448,6 +467,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;
}
@@ -485,6 +505,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
*/
@@ -510,4 +545,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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 05/13] port: added port_frag stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (3 preceding siblings ...)
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 04/13] port: added port_ethdev_writer_nodrop stats Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 06/13] port: added port_ras stats Michal Jastrzebski
` (20 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 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>
---
lib/librte_port/rte_port_frag.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/lib/librte_port/rte_port_frag.c b/lib/librte_port/rte_port_frag.c
index c4c05dc..3720d5d 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_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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 06/13] port: added port_ras stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (4 preceding siblings ...)
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 05/13] port: added port_frag stats Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 07/13] port: added port_ring_reader stats Michal Jastrzebski
` (19 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 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>
---
lib/librte_port/rte_port_ras.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c
index 5eb627a..2c1822a 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_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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 07/13] port: added port_ring_reader stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (5 preceding siblings ...)
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 06/13] port: added port_ras stats Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 08/13] port: added port_ring_writer stats Michal Jastrzebski
` (18 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 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>
---
lib/librte_port/rte_port_ring.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c
index 89b9641..091b052 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_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;
- return rte_ring_sc_dequeue_burst(p->ring, (void **) pkts, n_pkts);
+ 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 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
*/
@@ -410,6 +446,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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 08/13] port: added port_ring_writer stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (6 preceding siblings ...)
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 07/13] port: added port_ring_reader stats Michal Jastrzebski
@ 2015-06-08 14:59 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 09/13] port: added port_ring_writer_nodrop stats Michal Jastrzebski
` (17 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 14:59 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>
---
lib/librte_port/rte_port_ring.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c
index 091b052..ff58009 100644
--- a/lib/librte_port/rte_port_ring.c
+++ b/lib/librte_port/rte_port_ring.c
@@ -133,7 +133,23 @@ rte_port_ring_reader_stats_read(void *port,
/*
* Port RING Writer
*/
+#ifdef RTE_PORT_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;
@@ -181,6 +197,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]);
@@ -193,6 +210,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);
@@ -219,8 +237,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];
@@ -233,6 +253,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;
}
@@ -269,6 +290,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
*/
@@ -455,6 +492,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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 09/13] port: added port_ring_writer_nodrop stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (7 preceding siblings ...)
2015-06-08 14:59 ` [dpdk-dev] [PATCH v4 08/13] port: added port_ring_writer stats Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 10/13] port: added port_sched_reader stats Michal Jastrzebski
` (16 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 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>
---
lib/librte_port/rte_port_ring.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c
index ff58009..9461c05 100644
--- a/lib/librte_port/rte_port_ring.c
+++ b/lib/librte_port/rte_port_ring.c
@@ -309,7 +309,23 @@ rte_port_ring_writer_stats_read(void *port,
/*
* Port RING Writer Nodrop
*/
+#ifdef RTE_PORT_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;
@@ -379,6 +395,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]);
@@ -392,6 +409,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);
@@ -418,6 +436,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)
@@ -439,6 +458,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;
}
@@ -476,6 +496,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
*/
@@ -501,4 +537,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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 10/13] port: added port_sched_reader stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (8 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 09/13] port: added port_ring_writer_nodrop stats Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 11/13] port: added port_sched_writer stats Michal Jastrzebski
` (15 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 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>
---
lib/librte_port/rte_port_sched.c | 39 +++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/lib/librte_port/rte_port_sched.c b/lib/librte_port/rte_port_sched.c
index 2107f4c..a82e4fa 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_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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 11/13] port: added port_sched_writer stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (9 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 10/13] port: added port_sched_reader stats Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 12/13] port: added port_source stats Michal Jastrzebski
` (14 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 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>
---
lib/librte_port/rte_port_sched.c | 57 ++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 5 deletions(-)
diff --git a/lib/librte_port/rte_port_sched.c b/lib/librte_port/rte_port_sched.c
index a82e4fa..c5ff8ab 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_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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 12/13] port: added port_source stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (10 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 11/13] port: added port_sched_writer stats Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 13/13] port: added port_sink stats Michal Jastrzebski
` (13 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 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>
---
lib/librte_port/rte_port_source_sink.c | 35 ++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/lib/librte_port/rte_port_source_sink.c b/lib/librte_port/rte_port_source_sink.c
index b9a25bb..234ab18 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_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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 13/13] port: added port_sink stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (11 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 12/13] port: added port_source stats Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 00/10] table: added table statistics Michal Jastrzebski
` (12 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 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>
---
lib/librte_port/rte_port_source_sink.c | 63 ++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 4 deletions(-)
diff --git a/lib/librte_port/rte_port_source_sink.c b/lib/librte_port/rte_port_source_sink.c
index 234ab18..0a70228 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_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] 30+ messages in thread
* [dpdk-dev] [PATCH v4 00/10] table: added table statistics
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (12 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 13/13] port: added port_sink stats Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 19:05 ` Dumitrescu, Cristian
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 01/10] table: added structure for storing table stats and config option Michal Jastrzebski
` (11 subsequent siblings)
25 siblings, 1 reply; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for every type of table. By default all table statistics
are disabled, user must activate them in config file.
Changes in v2:
- added missing signoffs
Changes in v3:
- removed new config options to enable/disable stats
- using RTE_LOG_LEVEL instead
Changes in v4:
- created single config option for all table statistics
Maciej Gajdzica (10):
table: added structure for storing table stats and config option
table: added acl table stats
table: added array table stats
table: added hash_ext table stats
table: added hash_key16 table stats
table: added hash_key32 table stats
table: added hash_key8 table stats
table: added hash_lru table stats
table: added lpm_ipv6 table stats
table: added lpm table stats
config/common_bsdapp | 1 +
config/common_linuxapp | 1 +
lib/librte_table/rte_table.h | 25 +++++++++++++++
lib/librte_table/rte_table_acl.c | 35 +++++++++++++++++++++
lib/librte_table/rte_table_array.c | 34 +++++++++++++++++++-
lib/librte_table/rte_table_hash_ext.c | 44 ++++++++++++++++++++++++++
lib/librte_table/rte_table_hash_key16.c | 41 ++++++++++++++++++++++++
lib/librte_table/rte_table_hash_key32.c | 41 ++++++++++++++++++++++++
lib/librte_table/rte_table_hash_key8.c | 52 +++++++++++++++++++++++++++++++
lib/librte_table/rte_table_hash_lru.c | 44 ++++++++++++++++++++++++++
lib/librte_table/rte_table_lpm.c | 34 ++++++++++++++++++++
lib/librte_table/rte_table_lpm_ipv6.c | 34 ++++++++++++++++++++
12 files changed, 385 insertions(+), 1 deletion(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 01/10] table: added structure for storing table stats and config option
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (13 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 00/10] table: added table statistics Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 02/10] table: added acl table stats Michal Jastrzebski
` (10 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added common structure for table statistics. Added config option to
enable table stats collecting.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
config/common_bsdapp | 1 +
config/common_linuxapp | 1 +
lib/librte_table/rte_table.h | 25 +++++++++++++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/config/common_bsdapp b/config/common_bsdapp
index 1d26956..68d5110 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -389,6 +389,7 @@ RTE_PORT_STATS_COLLECT=n
# Compile librte_table
#
CONFIG_RTE_LIBRTE_TABLE=y
+RTE_TABLE_STATS_COLLECT=n
#
# Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 5105b25..7e9b7fa 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -396,6 +396,7 @@ RTE_PORT_STATS_COLLECT=n
# Compile librte_table
#
CONFIG_RTE_LIBRTE_TABLE=y
+RTE_TABLE_STATS_COLLECT=n
#
# Compile librte_pipeline
diff --git a/lib/librte_table/rte_table.h b/lib/librte_table/rte_table.h
index 6e51fe6..1732fbf 100644
--- a/lib/librte_table/rte_table.h
+++ b/lib/librte_table/rte_table.h
@@ -59,6 +59,12 @@ extern "C" {
struct rte_mbuf;
+/** Lookup table statistics */
+struct rte_table_stats {
+ uint64_t n_pkts_in;
+ uint64_t n_pkts_lookup_miss;
+};
+
/**
* Lookup table create
*
@@ -187,6 +193,24 @@ typedef int (*rte_table_op_lookup)(
uint64_t *lookup_hit_mask,
void **entries);
+/**
+ * Lookup table stats read
+ *
+ * @param port
+ * Handle to lookup table instance
+ * @param stats
+ * Handle to table 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_table_op_stats_read)(
+ void *table,
+ struct rte_table_stats *stats,
+ int clear);
+
/** Lookup table interface defining the lookup table operation */
struct rte_table_ops {
rte_table_op_create f_create; /**< Create */
@@ -194,6 +218,7 @@ struct rte_table_ops {
rte_table_op_entry_add f_add; /**< Entry add */
rte_table_op_entry_delete f_delete; /**< Entry delete */
rte_table_op_lookup f_lookup; /**< Lookup */
+ rte_table_op_stats_read f_stats; /**< Stats */
};
#ifdef __cplusplus
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 02/10] table: added acl table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (14 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 01/10] table: added structure for storing table stats and config option Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 03/10] table: added array " Michal Jastrzebski
` (9 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for ACL table.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_acl.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/lib/librte_table/rte_table_acl.c b/lib/librte_table/rte_table_acl.c
index 4416311..f02de3e 100644
--- a/lib/librte_table/rte_table_acl.c
+++ b/lib/librte_table/rte_table_acl.c
@@ -43,7 +43,23 @@
#include "rte_table_acl.h"
#include <rte_ether.h>
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_ACL_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_ACL_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct rte_table_acl {
+ struct rte_table_stats stats;
+
/* Low-level ACL table */
char name[2][RTE_ACL_NAMESIZE];
struct rte_acl_param acl_params; /* for creating low level acl table */
@@ -441,6 +457,9 @@ rte_table_acl_lookup(
uint64_t pkts_out_mask;
uint32_t n_pkts, i, j;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_ACL_STATS_PKTS_IN_ADD(acl, n_pkts_in);
+
/* Input conversion */
for (i = 0, j = 0; i < (uint32_t)(RTE_PORT_IN_BURST_SIZE_MAX -
__builtin_clzll(pkts_mask)); i++) {
@@ -478,6 +497,21 @@ rte_table_acl_lookup(
}
*lookup_hit_mask = pkts_out_mask;
+ RTE_TABLE_ACL_STATS_PKTS_LOOKUP_MISS(acl, n_pkts_in - __builtin_popcountll(pkts_out_mask));
+
+ return 0;
+}
+
+static int
+rte_table_acl_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_acl *acl = (struct rte_table_acl *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &acl->stats, sizeof(acl->stats));
+
+ if (clear)
+ memset(&acl->stats, 0, sizeof(acl->stats));
return 0;
}
@@ -488,4 +522,5 @@ struct rte_table_ops rte_table_acl_ops = {
.f_add = rte_table_acl_entry_add,
.f_delete = rte_table_acl_entry_delete,
.f_lookup = rte_table_acl_lookup,
+ .f_stats = rte_table_acl_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 03/10] table: added array table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (15 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 02/10] table: added acl table stats Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 04/10] table: added hash_ext " Michal Jastrzebski
` (8 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for array table.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_array.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/lib/librte_table/rte_table_array.c b/lib/librte_table/rte_table_array.c
index c031070..d75cc25 100644
--- a/lib/librte_table/rte_table_array.c
+++ b/lib/librte_table/rte_table_array.c
@@ -42,7 +42,23 @@
#include "rte_table_array.h"
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_ARRAY_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_ARRAY_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct rte_table_array {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t entry_size;
uint32_t n_entries;
@@ -164,7 +180,8 @@ rte_table_array_lookup(
void **entries)
{
struct rte_table_array *t = (struct rte_table_array *) table;
-
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(t, n_pkts_in);
*lookup_hit_mask = pkts_mask;
if ((pkts_mask & (pkts_mask + 1)) == 0) {
@@ -196,10 +213,25 @@ rte_table_array_lookup(
return 0;
}
+static int
+rte_table_array_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_array *array = (struct rte_table_array *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &array->stats, sizeof(array->stats));
+
+ if (clear)
+ memset(&array->stats, 0, sizeof(array->stats));
+
+ return 0;
+}
+
struct rte_table_ops rte_table_array_ops = {
.f_create = rte_table_array_create,
.f_free = rte_table_array_free,
.f_add = rte_table_array_entry_add,
.f_delete = NULL,
.f_lookup = rte_table_array_lookup,
+ .f_stats = rte_table_array_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 04/10] table: added hash_ext table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (16 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 03/10] table: added array " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 05/10] table: added hash_key16 " Michal Jastrzebski
` (7 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for hash ext table.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_hash_ext.c | 44 +++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/librte_table/rte_table_hash_ext.c b/lib/librte_table/rte_table_hash_ext.c
index 66e416b..3c12273 100644
--- a/lib/librte_table/rte_table_hash_ext.c
+++ b/lib/librte_table/rte_table_hash_ext.c
@@ -74,6 +74,20 @@ do \
(bucket)->next = (bucket2)->next; \
while (0)
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct grinder {
struct bucket *bkt;
uint64_t sig;
@@ -82,6 +96,8 @@ struct grinder {
};
struct rte_table_hash {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t key_size;
uint32_t entry_size;
@@ -440,6 +456,9 @@ static int rte_table_hash_ext_lookup_unoptimized(
struct rte_table_hash *t = (struct rte_table_hash *) table;
uint64_t pkts_mask_out = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(t, n_pkts_in);
+
for ( ; pkts_mask; ) {
struct bucket *bkt0, *bkt;
struct rte_mbuf *pkt;
@@ -484,6 +503,7 @@ static int rte_table_hash_ext_lookup_unoptimized(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
}
@@ -861,6 +881,9 @@ static int rte_table_hash_ext_lookup(
uint64_t pkts_mask_out = 0, pkts_mask_match_many = 0;
int status = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(t, n_pkts_in);
+
/* Cannot run the pipeline with less than 7 packets */
if (__builtin_popcountll(pkts_mask) < 7)
return rte_table_hash_ext_lookup_unoptimized(table, pkts,
@@ -973,6 +996,7 @@ static int rte_table_hash_ext_lookup(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return status;
}
@@ -990,6 +1014,9 @@ static int rte_table_hash_ext_lookup_dosig(
uint64_t pkts_mask_out = 0, pkts_mask_match_many = 0;
int status = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(t, n_pkts_in);
+
/* Cannot run the pipeline with less than 7 packets */
if (__builtin_popcountll(pkts_mask) < 7)
return rte_table_hash_ext_lookup_unoptimized(table, pkts,
@@ -1102,15 +1129,31 @@ static int rte_table_hash_ext_lookup_dosig(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return status;
}
+static int
+rte_table_hash_ext_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_hash *t = (struct rte_table_hash *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &t->stats, sizeof(t->stats));
+
+ if (clear)
+ memset(&t->stats, 0, sizeof(t->stats));
+
+ return 0;
+}
+
struct rte_table_ops rte_table_hash_ext_ops = {
.f_create = rte_table_hash_ext_create,
.f_free = rte_table_hash_ext_free,
.f_add = rte_table_hash_ext_entry_add,
.f_delete = rte_table_hash_ext_entry_delete,
.f_lookup = rte_table_hash_ext_lookup,
+ .f_stats = rte_table_hash_ext_stats_read,
};
struct rte_table_ops rte_table_hash_ext_dosig_ops = {
@@ -1119,4 +1162,5 @@ struct rte_table_ops rte_table_hash_ext_dosig_ops = {
.f_add = rte_table_hash_ext_entry_add,
.f_delete = rte_table_hash_ext_entry_delete,
.f_lookup = rte_table_hash_ext_lookup_dosig,
+ .f_stats = rte_table_hash_ext_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 05/10] table: added hash_key16 table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (17 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 04/10] table: added hash_ext " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 06/10] table: added hash_key32 " Michal Jastrzebski
` (6 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for hash key16 table.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_hash_key16.c | 41 +++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/lib/librte_table/rte_table_hash_key16.c b/lib/librte_table/rte_table_hash_key16.c
index f87ea0e..b936323 100644
--- a/lib/librte_table/rte_table_hash_key16.c
+++ b/lib/librte_table/rte_table_hash_key16.c
@@ -46,6 +46,20 @@
#define RTE_BUCKET_ENTRY_VALID 0x1LLU
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_HASH_KEY16_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_HASH_KEY16_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_HASH_KEY16_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_HASH_KEY16_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct rte_bucket_4_16 {
/* Cache line 0 */
uint64_t signature[4 + 1];
@@ -61,6 +75,8 @@ struct rte_bucket_4_16 {
};
struct rte_table_hash {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t n_buckets;
uint32_t n_entries_per_bucket;
@@ -831,6 +847,9 @@ rte_table_hash_lookup_key16_lru(
uint32_t pkt11_index, pkt20_index, pkt21_index;
uint64_t pkts_mask_out = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY16_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -845,6 +864,7 @@ rte_table_hash_lookup_key16_lru(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY16_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
}
@@ -934,6 +954,7 @@ rte_table_hash_lookup_key16_lru(
bucket20, bucket21, pkts_mask_out, entries, f);
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY16_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key16_lru() */
@@ -954,6 +975,9 @@ rte_table_hash_lookup_key16_ext(
struct rte_bucket_4_16 *buckets[RTE_PORT_IN_BURST_SIZE_MAX];
uint64_t *keys[RTE_PORT_IN_BURST_SIZE_MAX];
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY16_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -1080,15 +1104,31 @@ grind_next_buckets:
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY16_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key16_ext() */
+static int
+rte_table_hash_key16_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_hash *t = (struct rte_table_hash *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &t->stats, sizeof(t->stats));
+
+ if (clear)
+ memset(&t->stats, 0, sizeof(t->stats));
+
+ return 0;
+}
+
struct rte_table_ops rte_table_hash_key16_lru_ops = {
.f_create = rte_table_hash_create_key16_lru,
.f_free = rte_table_hash_free_key16_lru,
.f_add = rte_table_hash_entry_add_key16_lru,
.f_delete = rte_table_hash_entry_delete_key16_lru,
.f_lookup = rte_table_hash_lookup_key16_lru,
+ .f_stats = rte_table_hash_key16_stats_read,
};
struct rte_table_ops rte_table_hash_key16_ext_ops = {
@@ -1097,4 +1137,5 @@ struct rte_table_ops rte_table_hash_key16_ext_ops = {
.f_add = rte_table_hash_entry_add_key16_ext,
.f_delete = rte_table_hash_entry_delete_key16_ext,
.f_lookup = rte_table_hash_lookup_key16_ext,
+ .f_stats = rte_table_hash_key16_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 06/10] table: added hash_key32 table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (18 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 05/10] table: added hash_key16 " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 07/10] table: added hash_key8 " Michal Jastrzebski
` (5 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for hash key32 table.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_hash_key32.c | 41 +++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/lib/librte_table/rte_table_hash_key32.c b/lib/librte_table/rte_table_hash_key32.c
index 6790594..c230629 100644
--- a/lib/librte_table/rte_table_hash_key32.c
+++ b/lib/librte_table/rte_table_hash_key32.c
@@ -46,6 +46,20 @@
#define RTE_BUCKET_ENTRY_VALID 0x1LLU
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_HASH_KEY32_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_HASH_KEY32_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_HASH_KEY32_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_HASH_KEY32_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct rte_bucket_4_32 {
/* Cache line 0 */
uint64_t signature[4 + 1];
@@ -61,6 +75,8 @@ struct rte_bucket_4_32 {
};
struct rte_table_hash {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t n_buckets;
uint32_t n_entries_per_bucket;
@@ -850,6 +866,9 @@ rte_table_hash_lookup_key32_lru(
uint32_t pkt11_index, pkt20_index, pkt21_index;
uint64_t pkts_mask_out = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY32_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -864,6 +883,7 @@ rte_table_hash_lookup_key32_lru(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY32_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
}
@@ -954,6 +974,7 @@ rte_table_hash_lookup_key32_lru(
mbuf20, mbuf21, bucket20, bucket21, pkts_mask_out, entries, f);
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY32_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key32_lru() */
@@ -974,6 +995,9 @@ rte_table_hash_lookup_key32_ext(
struct rte_bucket_4_32 *buckets[RTE_PORT_IN_BURST_SIZE_MAX];
uint64_t *keys[RTE_PORT_IN_BURST_SIZE_MAX];
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY32_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -1100,15 +1124,31 @@ grind_next_buckets:
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY32_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key32_ext() */
+static int
+rte_table_hash_key32_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_hash *t = (struct rte_table_hash *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &t->stats, sizeof(t->stats));
+
+ if (clear)
+ memset(&t->stats, 0, sizeof(t->stats));
+
+ return 0;
+}
+
struct rte_table_ops rte_table_hash_key32_lru_ops = {
.f_create = rte_table_hash_create_key32_lru,
.f_free = rte_table_hash_free_key32_lru,
.f_add = rte_table_hash_entry_add_key32_lru,
.f_delete = rte_table_hash_entry_delete_key32_lru,
.f_lookup = rte_table_hash_lookup_key32_lru,
+ .f_stats = rte_table_hash_key32_stats_read,
};
struct rte_table_ops rte_table_hash_key32_ext_ops = {
@@ -1117,4 +1157,5 @@ struct rte_table_ops rte_table_hash_key32_ext_ops = {
.f_add = rte_table_hash_entry_add_key32_ext,
.f_delete = rte_table_hash_entry_delete_key32_ext,
.f_lookup = rte_table_hash_lookup_key32_ext,
+ .f_stats =rte_table_hash_key32_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 07/10] table: added hash_key8 table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (19 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 06/10] table: added hash_key32 " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 08/10] table: added hash_lru " Michal Jastrzebski
` (4 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for hash key8 table.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_hash_key8.c | 52 ++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/lib/librte_table/rte_table_hash_key8.c b/lib/librte_table/rte_table_hash_key8.c
index 6803eb2..374e3e3 100644
--- a/lib/librte_table/rte_table_hash_key8.c
+++ b/lib/librte_table/rte_table_hash_key8.c
@@ -44,6 +44,20 @@
#define RTE_TABLE_HASH_KEY_SIZE 8
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_HASH_KEY8_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_HASH_KEY8_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct rte_bucket_4_8 {
/* Cache line 0 */
uint64_t signature;
@@ -58,6 +72,8 @@ struct rte_bucket_4_8 {
};
struct rte_table_hash {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t n_buckets;
uint32_t n_entries_per_bucket;
@@ -846,6 +862,9 @@ rte_table_hash_lookup_key8_lru(
pkt11_index, pkt20_index, pkt21_index;
uint64_t pkts_mask_out = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -860,6 +879,7 @@ rte_table_hash_lookup_key8_lru(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
}
@@ -949,6 +969,7 @@ rte_table_hash_lookup_key8_lru(
bucket20, bucket21, pkts_mask_out, entries, f);
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key8_lru() */
@@ -967,6 +988,9 @@ rte_table_hash_lookup_key8_lru_dosig(
uint32_t pkt11_index, pkt20_index, pkt21_index;
uint64_t pkts_mask_out = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -981,6 +1005,7 @@ rte_table_hash_lookup_key8_lru_dosig(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
}
@@ -1070,6 +1095,7 @@ rte_table_hash_lookup_key8_lru_dosig(
bucket20, bucket21, pkts_mask_out, entries, f);
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key8_lru_dosig() */
@@ -1090,6 +1116,9 @@ rte_table_hash_lookup_key8_ext(
struct rte_bucket_4_8 *buckets[RTE_PORT_IN_BURST_SIZE_MAX];
uint64_t *keys[RTE_PORT_IN_BURST_SIZE_MAX];
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -1216,6 +1245,7 @@ grind_next_buckets:
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key8_ext() */
@@ -1236,6 +1266,9 @@ rte_table_hash_lookup_key8_ext_dosig(
struct rte_bucket_4_8 *buckets[RTE_PORT_IN_BURST_SIZE_MAX];
uint64_t *keys[RTE_PORT_IN_BURST_SIZE_MAX];
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_IN_ADD(f, n_pkts_in);
+
/* Cannot run the pipeline with less than 5 packets */
if (__builtin_popcountll(pkts_mask) < 5) {
for ( ; pkts_mask; ) {
@@ -1362,15 +1395,31 @@ grind_next_buckets:
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
} /* rte_table_hash_lookup_key8_dosig_ext() */
+static int
+rte_table_hash_key8_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_hash *t = (struct rte_table_hash *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &t->stats, sizeof(t->stats));
+
+ if (clear)
+ memset(&t->stats, 0, sizeof(t->stats));
+
+ return 0;
+}
+
struct rte_table_ops rte_table_hash_key8_lru_ops = {
.f_create = rte_table_hash_create_key8_lru,
.f_free = rte_table_hash_free_key8_lru,
.f_add = rte_table_hash_entry_add_key8_lru,
.f_delete = rte_table_hash_entry_delete_key8_lru,
.f_lookup = rte_table_hash_lookup_key8_lru,
+ .f_stats = rte_table_hash_key8_stats_read,
};
struct rte_table_ops rte_table_hash_key8_lru_dosig_ops = {
@@ -1379,6 +1428,7 @@ struct rte_table_ops rte_table_hash_key8_lru_dosig_ops = {
.f_add = rte_table_hash_entry_add_key8_lru,
.f_delete = rte_table_hash_entry_delete_key8_lru,
.f_lookup = rte_table_hash_lookup_key8_lru_dosig,
+ .f_stats = rte_table_hash_key8_stats_read,
};
struct rte_table_ops rte_table_hash_key8_ext_ops = {
@@ -1387,6 +1437,7 @@ struct rte_table_ops rte_table_hash_key8_ext_ops = {
.f_add = rte_table_hash_entry_add_key8_ext,
.f_delete = rte_table_hash_entry_delete_key8_ext,
.f_lookup = rte_table_hash_lookup_key8_ext,
+ .f_stats = rte_table_hash_key8_stats_read,
};
struct rte_table_ops rte_table_hash_key8_ext_dosig_ops = {
@@ -1395,4 +1446,5 @@ struct rte_table_ops rte_table_hash_key8_ext_dosig_ops = {
.f_add = rte_table_hash_entry_add_key8_ext,
.f_delete = rte_table_hash_entry_delete_key8_ext,
.f_lookup = rte_table_hash_lookup_key8_ext_dosig,
+ .f_stats = rte_table_hash_key8_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 08/10] table: added hash_lru table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (20 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 07/10] table: added hash_key8 " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 09/10] table: added lpm_ipv6 " Michal Jastrzebski
` (3 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added statistics for hash_lru table.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_hash_lru.c | 44 +++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/librte_table/rte_table_hash_lru.c b/lib/librte_table/rte_table_hash_lru.c
index c9a8afd..c4b6079 100644
--- a/lib/librte_table/rte_table_hash_lru.c
+++ b/lib/librte_table/rte_table_hash_lru.c
@@ -45,6 +45,20 @@
#define KEYS_PER_BUCKET 4
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_HASH_LRU_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_HASH_LRU_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct bucket {
union {
struct bucket *next;
@@ -63,6 +77,8 @@ struct grinder {
};
struct rte_table_hash {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t key_size;
uint32_t entry_size;
@@ -368,6 +384,9 @@ static int rte_table_hash_lru_lookup_unoptimized(
struct rte_table_hash *t = (struct rte_table_hash *) table;
uint64_t pkts_mask_out = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(t, n_pkts_in);
+
for ( ; pkts_mask; ) {
struct bucket *bkt;
struct rte_mbuf *pkt;
@@ -412,6 +431,7 @@ static int rte_table_hash_lru_lookup_unoptimized(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_LRU_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return 0;
}
@@ -804,6 +824,9 @@ static int rte_table_hash_lru_lookup(
uint64_t pkts_mask_out = 0, pkts_mask_match_many = 0;
int status = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(t, n_pkts_in);
+
/* Cannot run the pipeline with less than 7 packets */
if (__builtin_popcountll(pkts_mask) < 7)
return rte_table_hash_lru_lookup_unoptimized(table, pkts,
@@ -916,6 +939,7 @@ static int rte_table_hash_lru_lookup(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_LRU_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return status;
}
@@ -933,6 +957,9 @@ static int rte_table_hash_lru_lookup_dosig(
uint64_t pkts_mask_out = 0, pkts_mask_match_many = 0;
int status = 0;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(t, n_pkts_in);
+
/* Cannot run the pipeline with less than 7 packets */
if (__builtin_popcountll(pkts_mask) < 7)
return rte_table_hash_lru_lookup_unoptimized(table, pkts,
@@ -1045,15 +1072,31 @@ static int rte_table_hash_lru_lookup_dosig(
}
*lookup_hit_mask = pkts_mask_out;
+ RTE_TABLE_HASH_LRU_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(pkts_mask_out));
return status;
}
+static int
+rte_table_hash_lru_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_hash *t = (struct rte_table_hash *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &t->stats, sizeof(t->stats));
+
+ if (clear)
+ memset(&t->stats, 0, sizeof(t->stats));
+
+ return 0;
+}
+
struct rte_table_ops rte_table_hash_lru_ops = {
.f_create = rte_table_hash_lru_create,
.f_free = rte_table_hash_lru_free,
.f_add = rte_table_hash_lru_entry_add,
.f_delete = rte_table_hash_lru_entry_delete,
.f_lookup = rte_table_hash_lru_lookup,
+ .f_stats = rte_table_hash_lru_stats_read,
};
struct rte_table_ops rte_table_hash_lru_dosig_ops = {
@@ -1062,4 +1105,5 @@ struct rte_table_ops rte_table_hash_lru_dosig_ops = {
.f_add = rte_table_hash_lru_entry_add,
.f_delete = rte_table_hash_lru_entry_delete,
.f_lookup = rte_table_hash_lru_lookup_dosig,
+ .f_stats = rte_table_hash_lru_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 09/10] table: added lpm_ipv6 table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (21 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 08/10] table: added hash_lru " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 10/10] table: added lpm " Michal Jastrzebski
` (2 subsequent siblings)
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added lpm ipv6 table statistics.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_lpm_ipv6.c | 34 +++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/librte_table/rte_table_lpm_ipv6.c b/lib/librte_table/rte_table_lpm_ipv6.c
index ce4ddc0..ce7fa02 100644
--- a/lib/librte_table/rte_table_lpm_ipv6.c
+++ b/lib/librte_table/rte_table_lpm_ipv6.c
@@ -46,7 +46,23 @@
#define RTE_TABLE_LPM_MAX_NEXT_HOPS 256
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_LPM_IPV6_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_LPM_IPV6_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_LPM_IPV6_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_LPM_IPV6_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct rte_table_lpm_ipv6 {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t entry_size;
uint32_t entry_unique_size;
@@ -327,6 +343,9 @@ rte_table_lpm_ipv6_lookup(
uint64_t pkts_out_mask = 0;
uint32_t i;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_LPM_IPV6_STATS_PKTS_IN_ADD(lpm, n_pkts_in);
+
pkts_out_mask = 0;
for (i = 0; i < (uint32_t)(RTE_PORT_IN_BURST_SIZE_MAX -
__builtin_clzll(pkts_mask)); i++) {
@@ -349,6 +368,20 @@ rte_table_lpm_ipv6_lookup(
}
*lookup_hit_mask = pkts_out_mask;
+ RTE_TABLE_LPM_IPV6_STATS_PKTS_LOOKUP_MISS(lpm, n_pkts_in - __builtin_popcountll(pkts_out_mask));
+ return 0;
+}
+
+static int
+rte_table_lpm_ipv6_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_lpm_ipv6 *t = (struct rte_table_lpm_ipv6 *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &t->stats, sizeof(t->stats));
+
+ if (clear)
+ memset(&t->stats, 0, sizeof(t->stats));
return 0;
}
@@ -359,4 +392,5 @@ struct rte_table_ops rte_table_lpm_ipv6_ops = {
.f_add = rte_table_lpm_ipv6_entry_add,
.f_delete = rte_table_lpm_ipv6_entry_delete,
.f_lookup = rte_table_lpm_ipv6_lookup,
+ .f_stats = rte_table_lpm_ipv6_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 10/10] table: added lpm table stats
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (22 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 09/10] table: added lpm_ipv6 " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 1/1] pipeline: add statistics for librte_pipeline ports and tables Michal Jastrzebski
2015-06-08 19:04 ` [dpdk-dev] [PATCH v4 00/13] port: added port statistics Dumitrescu, Cristian
25 siblings, 0 replies; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Added lpm table statistics.
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
lib/librte_table/rte_table_lpm.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/librte_table/rte_table_lpm.c b/lib/librte_table/rte_table_lpm.c
index 64c684d..300e680 100644
--- a/lib/librte_table/rte_table_lpm.c
+++ b/lib/librte_table/rte_table_lpm.c
@@ -46,7 +46,23 @@
#define RTE_TABLE_LPM_MAX_NEXT_HOPS 256
+#ifdef RTE_TABLE_STATS_COLLECT
+
+#define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
+ table->stats.n_pkts_in += val
+#define RTE_TABLE_LPM_STATS_PKTS_LOOKUP_MISS(table, val) \
+ table->stats.n_pkts_lookup_miss += val
+
+#else
+
+#define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val)
+#define RTE_TABLE_LPM_STATS_PKTS_LOOKUP_MISS(table, val)
+
+#endif
+
struct rte_table_lpm {
+ struct rte_table_stats stats;
+
/* Input parameters */
uint32_t entry_size;
uint32_t entry_unique_size;
@@ -313,6 +329,9 @@ rte_table_lpm_lookup(
uint64_t pkts_out_mask = 0;
uint32_t i;
+ __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
+ RTE_TABLE_LPM_STATS_PKTS_IN_ADD(lpm, n_pkts_in);
+
pkts_out_mask = 0;
for (i = 0; i < (uint32_t)(RTE_PORT_IN_BURST_SIZE_MAX -
__builtin_clzll(pkts_mask)); i++) {
@@ -335,6 +354,20 @@ rte_table_lpm_lookup(
}
*lookup_hit_mask = pkts_out_mask;
+ RTE_TABLE_LPM_STATS_PKTS_LOOKUP_MISS(lpm, n_pkts_in - __builtin_popcountll(pkts_out_mask));
+ return 0;
+}
+
+static int
+rte_table_lpm_stats_read(void *table, struct rte_table_stats *stats, int clear)
+{
+ struct rte_table_lpm *t = (struct rte_table_lpm *) table;
+
+ if (stats != NULL)
+ memcpy(stats, &t->stats, sizeof(t->stats));
+
+ if (clear)
+ memset(&t->stats, 0, sizeof(t->stats));
return 0;
}
@@ -345,4 +378,5 @@ struct rte_table_ops rte_table_lpm_ops = {
.f_add = rte_table_lpm_entry_add,
.f_delete = rte_table_lpm_entry_delete,
.f_lookup = rte_table_lpm_lookup,
+ .f_stats = rte_table_lpm_stats_read,
};
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [dpdk-dev] [PATCH v4 1/1] pipeline: add statistics for librte_pipeline ports and tables
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (23 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 10/10] table: added lpm " Michal Jastrzebski
@ 2015-06-08 15:00 ` Michal Jastrzebski
2015-06-08 19:07 ` Dumitrescu, Cristian
2015-06-08 19:04 ` [dpdk-dev] [PATCH v4 00/13] port: added port statistics Dumitrescu, Cristian
25 siblings, 1 reply; 30+ messages in thread
From: Michal Jastrzebski @ 2015-06-08 15:00 UTC (permalink / raw)
To: dev
From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
This patch adds statistics collection for librte_pipeline.
Those statistics ale disabled by default during build time.
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
---
config/common_bsdapp | 1 +
config/common_linuxapp | 1 +
lib/librte_pipeline/rte_pipeline.c | 185 +++++++++++++++++++++++++++++++++---
lib/librte_pipeline/rte_pipeline.h | 98 +++++++++++++++++++
4 files changed, 274 insertions(+), 11 deletions(-)
diff --git a/config/common_bsdapp b/config/common_bsdapp
index 68d5110..4c20fe0 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -395,6 +395,7 @@ RTE_TABLE_STATS_COLLECT=n
# Compile librte_pipeline
#
CONFIG_RTE_LIBRTE_PIPELINE=y
+RTE_PIPELINE_STATS_COLLECT=n
#
# Compile librte_kni
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 7e9b7fa..ca93abc 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -402,6 +402,7 @@ RTE_TABLE_STATS_COLLECT=n
# Compile librte_pipeline
#
CONFIG_RTE_LIBRTE_PIPELINE=y
+RTE_PIPELINE_STATS_COLLECT=y
#
# Compile librte_kni
diff --git a/lib/librte_pipeline/rte_pipeline.c b/lib/librte_pipeline/rte_pipeline.c
index 36d92c9..69bf003 100644
--- a/lib/librte_pipeline/rte_pipeline.c
+++ b/lib/librte_pipeline/rte_pipeline.c
@@ -48,6 +48,17 @@
#define RTE_TABLE_INVALID UINT32_MAX
+#ifdef RTE_PIPELINE_STATS_COLLECT
+#define RTE_PIPELINE_STATS_ADD(counter, val) \
+ ({ (counter) += (val); })
+
+#define RTE_PIPELINE_STATS_ADD_M(counter, mask) \
+ ({ (counter) += __builtin_popcountll(mask); })
+#else
+#define RTE_PIPELINE_STATS_ADD(counter, val)
+#define RTE_PIPELINE_STATS_ADD_M(counter, mask)
+#endif
+
struct rte_port_in {
/* Input parameters */
struct rte_port_in_ops ops;
@@ -63,6 +74,8 @@ struct rte_port_in {
/* List of enabled ports */
struct rte_port_in *next;
+
+ uint64_t n_pkts_dropped_by_ah;
};
struct rte_port_out {
@@ -74,6 +87,8 @@ struct rte_port_out {
/* Handle to low-level port */
void *h_port;
+
+ uint64_t n_pkts_dropped_by_ah;
};
struct rte_table {
@@ -90,6 +105,12 @@ struct rte_table {
/* Handle to the low-level table object */
void *h_table;
+
+ /* Stats for this table. */
+ uint64_t n_pkts_dropped_by_lkp_hit_ah;
+ uint64_t n_pkts_dropped_by_lkp_miss_ah;
+ uint64_t n_pkts_dropped_lkp_hit;
+ uint64_t n_pkts_dropped_lkp_miss;
};
#define RTE_PIPELINE_MAX_NAME_SZ 124
@@ -1040,6 +1061,8 @@ rte_pipeline_action_handler_port_bulk(struct rte_pipeline *p,
port_out->f_action_bulk(p->pkts, &pkts_mask, port_out->arg_ah);
p->action_mask0[RTE_PIPELINE_ACTION_DROP] |= pkts_mask ^ mask;
+ RTE_PIPELINE_STATS_ADD_M(port_out->n_pkts_dropped_by_ah,
+ pkts_mask ^ mask);
}
/* Output port TX */
@@ -1071,6 +1094,9 @@ rte_pipeline_action_handler_port(struct rte_pipeline *p, uint64_t pkts_mask)
p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=
(pkt_mask ^ 1LLU) << i;
+ RTE_PIPELINE_STATS_ADD(port_out->n_pkts_dropped_by_ah,
+ pkt_mask ^ 1LLU);
+
/* Output port TX */
if (pkt_mask != 0)
port_out->ops.f_tx(port_out->h_port,
@@ -1104,6 +1130,9 @@ rte_pipeline_action_handler_port(struct rte_pipeline *p, uint64_t pkts_mask)
p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=
(pkt_mask ^ 1LLU) << i;
+ RTE_PIPELINE_STATS_ADD(port_out->n_pkts_dropped_by_ah,
+ pkt_mask ^ 1LLU);
+
/* Output port TX */
if (pkt_mask != 0)
port_out->ops.f_tx(port_out->h_port,
@@ -1140,6 +1169,9 @@ rte_pipeline_action_handler_port_meta(struct rte_pipeline *p,
p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=
(pkt_mask ^ 1LLU) << i;
+ RTE_PIPELINE_STATS_ADD(port_out->n_pkts_dropped_by_ah,
+ pkt_mask ^ 1ULL);
+
/* Output port TX */
if (pkt_mask != 0)
port_out->ops.f_tx(port_out->h_port,
@@ -1174,6 +1206,9 @@ rte_pipeline_action_handler_port_meta(struct rte_pipeline *p,
p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=
(pkt_mask ^ 1LLU) << i;
+ RTE_PIPELINE_STATS_ADD(port_out->n_pkts_dropped_by_ah,
+ pkt_mask ^ 1ULL);
+
/* Output port TX */
if (pkt_mask != 0)
port_out->ops.f_tx(port_out->h_port,
@@ -1232,10 +1267,10 @@ rte_pipeline_run(struct rte_pipeline *p)
if (port_in->f_action != NULL) {
uint64_t mask = pkts_mask;
- port_in->f_action(p->pkts, n_pkts, &pkts_mask,
- port_in->arg_ah);
- p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=
- pkts_mask ^ mask;
+ port_in->f_action(p->pkts, n_pkts, &pkts_mask, port_in->arg_ah);
+ mask ^= pkts_mask;
+ p->action_mask0[RTE_PIPELINE_ACTION_DROP] |= mask;
+ RTE_PIPELINE_STATS_ADD_M(port_in->n_pkts_dropped_by_ah, mask);
}
/* Table */
@@ -1261,9 +1296,10 @@ rte_pipeline_run(struct rte_pipeline *p)
table->f_action_miss(p->pkts,
&lookup_miss_mask,
default_entry, table->arg_ah);
- p->action_mask0[
- RTE_PIPELINE_ACTION_DROP] |=
- lookup_miss_mask ^ mask;
+ mask ^= lookup_miss_mask;
+ p->action_mask0[RTE_PIPELINE_ACTION_DROP] |= mask;
+ RTE_PIPELINE_STATS_ADD_M(
+ table->n_pkts_dropped_by_lkp_miss_ah, mask);
}
/* Table reserved actions */
@@ -1277,6 +1313,10 @@ rte_pipeline_run(struct rte_pipeline *p)
uint32_t pos = default_entry->action;
p->action_mask0[pos] = lookup_miss_mask;
+ if (pos == RTE_PIPELINE_ACTION_DROP) {
+ RTE_PIPELINE_STATS_ADD_M(table->n_pkts_dropped_lkp_miss,
+ lookup_miss_mask);
+ }
}
}
@@ -1289,9 +1329,10 @@ rte_pipeline_run(struct rte_pipeline *p)
table->f_action_hit(p->pkts,
&lookup_hit_mask,
p->entries, table->arg_ah);
- p->action_mask0[
- RTE_PIPELINE_ACTION_DROP] |=
- lookup_hit_mask ^ mask;
+ mask ^= lookup_hit_mask;
+ p->action_mask0[RTE_PIPELINE_ACTION_DROP] |= mask;
+ RTE_PIPELINE_STATS_ADD_M(
+ table->n_pkts_dropped_by_lkp_hit_ah, mask);
}
/* Table reserved actions */
@@ -1308,6 +1349,9 @@ rte_pipeline_run(struct rte_pipeline *p)
p->action_mask0[RTE_PIPELINE_ACTION_TABLE] |=
p->action_mask1[
RTE_PIPELINE_ACTION_TABLE];
+
+ RTE_PIPELINE_STATS_ADD_M(table->n_pkts_dropped_lkp_hit,
+ p->action_mask1[RTE_PIPELINE_ACTION_DROP]);
}
/* Prepare for next iteration */
@@ -1370,9 +1414,128 @@ rte_pipeline_port_out_packet_insert(struct rte_pipeline *p,
if (pkt_mask != 0) /* Output port TX */
port_out->ops.f_tx(port_out->h_port, pkt);
- else
+ else {
rte_pktmbuf_free(pkt);
+ RTE_PIPELINE_STATS_ADD(port_out->n_pkts_dropped_by_ah, 1);
+ }
+ }
+
+ return 0;
+}
+
+int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t port_id,
+ struct rte_pipeline_port_in_stats *stats, int clear)
+{
+ struct rte_port_in *port;
+ int retval;
+
+ if (p == NULL) {
+ RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ if (port_id >= p->num_ports_in) {
+ RTE_LOG(ERR, PIPELINE,
+ "%s: port IN ID %u is out of range\n",
+ __func__, port_id);
+ return -EINVAL;
+ }
+
+ port = &p->ports_in[port_id];
+
+ if (port->ops.f_stats != NULL) {
+ retval = port->ops.f_stats(port->h_port, &stats->stats, clear);
+ if (retval)
+ return retval;
+ } else if (stats != NULL)
+ memset(&stats->stats, 0, sizeof(stats->stats));
+
+ if (stats != NULL)
+ stats->n_pkts_dropped_by_ah = port->n_pkts_dropped_by_ah;
+
+ if (clear != 0)
+ port->n_pkts_dropped_by_ah = 0;
+
+ return 0;
+}
+
+int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t port_id,
+ struct rte_pipeline_port_out_stats *stats, int clear)
+{
+ struct rte_port_out *port;
+ int retval;
+
+ if (p == NULL) {
+ RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ if (port_id >= p->num_ports_out) {
+ RTE_LOG(ERR, PIPELINE,
+ "%s: port OUT ID %u is out of range\n", __func__, port_id);
+ return -EINVAL;
+ }
+
+ port = &p->ports_out[port_id];
+ if (port->ops.f_stats != NULL) {
+ retval = port->ops.f_stats(port->h_port, &stats->stats, clear);
+ if (retval != 0)
+ return retval;
+ } else if (stats != NULL)
+ memset(&stats->stats, 0, sizeof(stats->stats));
+
+ if (stats != NULL)
+ stats->n_pkts_dropped_by_ah = port->n_pkts_dropped_by_ah;
+
+ if (clear != 0)
+ port->n_pkts_dropped_by_ah = 0;
+
+ return 0;
+}
+
+int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table_id,
+ struct rte_pipeline_table_stats *stats, int clear)
+{
+ struct rte_table *table;
+ int retval;
+
+ if (p == NULL) {
+ RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ if (table_id >= p->num_tables) {
+ RTE_LOG(ERR, PIPELINE,
+ "%s: table %u is out of range\n", __func__, table_id);
+ return -EINVAL;
+ }
+
+ table = &p->tables[table_id];
+ if (table->ops.f_stats != NULL) {
+ retval = table->ops.f_stats(table->h_table, &stats->stats, clear);
+ if (retval != 0)
+ return retval;
+ } else if (stats != NULL)
+ memset(&stats->stats, 0, sizeof(stats->stats));
+
+ if (stats != NULL) {
+ stats->n_pkts_dropped_by_lkp_hit_ah =
+ table->n_pkts_dropped_by_lkp_hit_ah;
+ stats->n_pkts_dropped_by_lkp_miss_ah =
+ table->n_pkts_dropped_by_lkp_miss_ah;
+ stats->n_pkts_dropped_lkp_hit = table->n_pkts_dropped_lkp_hit;
+ stats->n_pkts_dropped_lkp_miss = table->n_pkts_dropped_lkp_miss;
+ }
+
+ if (clear != 0) {
+ table->n_pkts_dropped_by_lkp_hit_ah = 0;
+ table->n_pkts_dropped_by_lkp_miss_ah = 0;
+ table->n_pkts_dropped_lkp_hit = 0;
+ table->n_pkts_dropped_lkp_miss = 0;
}
return 0;
}
+
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index 145fc06..59e0710 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -112,6 +112,45 @@ struct rte_pipeline_params {
uint32_t offset_port_id;
};
+/** Pipeline port in stats. */
+struct rte_pipeline_port_in_stats {
+ /** Port in stats. */
+ struct rte_port_in_stats stats;
+
+ /** Number of packets dropped by action handler. */
+ uint64_t n_pkts_dropped_by_ah;
+
+};
+
+/** Pipeline port out stats. */
+struct rte_pipeline_port_out_stats {
+ /** Port out stats. */
+ struct rte_port_out_stats stats;
+
+ /** Number of packets dropped by action handler. */
+ uint64_t n_pkts_dropped_by_ah;
+};
+
+/** Pipeline table stats. */
+struct rte_pipeline_table_stats {
+ /** Table stats. */
+ struct rte_table_stats stats;
+
+ /** Number of packets dropped by lookup hit action handler. */
+ uint64_t n_pkts_dropped_by_lkp_hit_ah;
+
+ /** Number of packets dropped by lookup miss action handler. */
+ uint64_t n_pkts_dropped_by_lkp_miss_ah;
+
+ /** Number of packets dropped by pipeline in behalf of this table based on
+ * on action specified in table entry. */
+ uint64_t n_pkts_dropped_lkp_hit;
+
+ /** Number of packets dropped by pipeline in behalf of this table based on
+ * on action specified in table entry. */
+ uint64_t n_pkts_dropped_lkp_miss;
+};
+
/**
* Pipeline create
*
@@ -426,6 +465,26 @@ int rte_pipeline_table_entry_delete(struct rte_pipeline *p,
int *key_found,
struct rte_pipeline_table_entry *entry);
+/**
+ * Read pipeline table stats.
+ *
+ * This function reads table statistics identified by *table_id* of given
+ * pipeline *p*.
+ *
+ * @param p
+ * Handle to pipeline instance.
+ * @param table_id
+ * Port ID what stats will be returned.
+ * @param stats
+ * Statistics buffer.
+ * @param clear
+ * If not 0 clear stats after reading.
+ * @return
+ * 0 on success, error code otherwise
+ */
+int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table_id,
+ struct rte_pipeline_table_stats *stats, int clear);
+
/*
* Port IN
*
@@ -540,6 +599,26 @@ int rte_pipeline_port_in_enable(struct rte_pipeline *p,
int rte_pipeline_port_in_disable(struct rte_pipeline *p,
uint32_t port_id);
+/**
+ * Read pipeline port in stats.
+ *
+ * This function reads port in statistics identified by *port_id* of given
+ * pipeline *p*.
+ *
+ * @param p
+ * Handle to pipeline instance.
+ * @param port_id
+ * Port ID what stats will be returned.
+ * @param stats
+ * Statistics buffer.
+ * @param clear
+ * If not 0 clear stats after reading.
+ * @return
+ * 0 on success, error code otherwise
+ */
+int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t port_id,
+ struct rte_pipeline_port_in_stats *stats, int clear);
+
/*
* Port OUT
*
@@ -658,6 +737,25 @@ int rte_pipeline_port_out_packet_insert(struct rte_pipeline *p,
uint32_t port_id,
struct rte_mbuf *pkt);
+/**
+ * Read pipeline port out stats.
+ *
+ * This function reads port out statistics identified by *port_id* of given
+ * pipeline *p*.
+ *
+ * @param p
+ * Handle to pipeline instance.
+ * @param port_id
+ * Port ID what stats will be returned.
+ * @param stats
+ * Statistics buffer.
+ * @param clear
+ * If not 0 clear stats after reading.
+ * @return
+ * 0 on success, error code otherwise
+ */
+int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t port_id,
+ struct rte_pipeline_port_out_stats *stats, int clear);
#ifdef __cplusplus
}
#endif
--
1.7.9.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [dpdk-dev] [PATCH v4 00/13] port: added port statistics
2015-06-08 14:59 [dpdk-dev] [PATCH v4 00/13] port: added port statistics Michal Jastrzebski
` (24 preceding siblings ...)
2015-06-08 15:00 ` [dpdk-dev] [PATCH v4 1/1] pipeline: add statistics for librte_pipeline ports and tables Michal Jastrzebski
@ 2015-06-08 19:04 ` Dumitrescu, Cristian
25 siblings, 0 replies; 30+ messages in thread
From: Dumitrescu, Cristian @ 2015-06-08 19:04 UTC (permalink / raw)
To: Jastrzebski, MichalX K, dev
> Added statistics for every type of port. By default all port statistics
> are disabled, user must activate them in config file.
>
>
> Changes in v4:
> - created single config option for all port statistics
>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
^ permalink raw reply [flat|nested] 30+ messages in thread