All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] table: added table statistics
@ 2015-03-30 11:42 Maciej Gajdzica
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

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

Maciej Gajdzica (10):
  table: added structure for storing table stats
  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                    |    9 ++++++
 config/common_linuxapp                  |    9 ++++++
 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, 401 insertions(+), 1 deletion(-)

-- 
1.7.9.5

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

* [PATCH 01/10] table: added structure for storing table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 02/10] table: added acl " Maciej Gajdzica
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 lib/librte_table/rte_table.h |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/librte_table/rte_table.h b/lib/librte_table/rte_table.h
index d57bc33..9860b7b 100644
--- a/lib/librte_table/rte_table.h
+++ b/lib/librte_table/rte_table.h
@@ -58,6 +58,12 @@ extern "C" {
 #include <rte_mbuf.h>
 #include <rte_port.h>
 
+/** Lookup table statistics */
+struct rte_table_stats {
+	uint64_t n_pkts_in;
+	uint64_t n_pkts_lookup_miss;
+};
+
 /**
  * Lookup table create
  *
@@ -186,6 +192,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 */
@@ -193,6 +217,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 related	[flat|nested] 12+ messages in thread

* [PATCH 02/10] table: added acl table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  2015-03-30 11:42   ` [PATCH 01/10] table: added structure for storing table stats Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 03/10] table: added array " Maciej Gajdzica
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp             |    1 +
 config/common_linuxapp           |    1 +
 lib/librte_table/rte_table_acl.c |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 4c32f43..20aa745 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -399,6 +399,7 @@ CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 # Compile librte_table
 #
 CONFIG_RTE_LIBRTE_TABLE=y
+CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 6a5aa87..7d70229 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -406,6 +406,7 @@ CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 # Compile librte_table
 #
 CONFIG_RTE_LIBRTE_TABLE=y
+CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_acl.c b/lib/librte_table/rte_table_acl.c
index 4416311..194316d 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_ACL_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 related	[flat|nested] 12+ messages in thread

* [PATCH 03/10] table: added array table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  2015-03-30 11:42   ` [PATCH 01/10] table: added structure for storing table stats Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 02/10] table: added acl " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 04/10] table: added hash_ext " Maciej Gajdzica
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp               |    1 +
 config/common_linuxapp             |    1 +
 lib/librte_table/rte_table_array.c |   34 +++++++++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 20aa745..1aba0d5 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -400,6 +400,7 @@ CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 #
 CONFIG_RTE_LIBRTE_TABLE=y
 CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
+CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 7d70229..b4ad91b 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -407,6 +407,7 @@ CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 #
 CONFIG_RTE_LIBRTE_TABLE=y
 CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
+CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_array.c b/lib/librte_table/rte_table_array.c
index c031070..3f25fa6 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_ARRAY_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 related	[flat|nested] 12+ messages in thread

* [PATCH 04/10] table: added hash_ext table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 03/10] table: added array " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 05/10] table: added hash_key16 " Maciej Gajdzica
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp                  |    1 +
 config/common_linuxapp                |    1 +
 lib/librte_table/rte_table_hash_ext.c |   44 +++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 1aba0d5..7f35d53 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -401,6 +401,7 @@ CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 CONFIG_RTE_LIBRTE_TABLE=y
 CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index b4ad91b..8e192bc 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -408,6 +408,7 @@ CONFIG_RTE_PORT_SINK_STATS_COLLECT=n
 CONFIG_RTE_LIBRTE_TABLE=y
 CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_hash_ext.c b/lib/librte_table/rte_table_hash_ext.c
index 66e416b..d9ff97b 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_HASH_EXT_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 related	[flat|nested] 12+ messages in thread

* [PATCH 05/10] table: added hash_key16 table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 04/10] table: added hash_ext " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 06/10] table: added hash_key32 " Maciej Gajdzica
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp                    |    1 +
 config/common_linuxapp                  |    1 +
 lib/librte_table/rte_table_hash_key16.c |   41 +++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 7f35d53..2f92f69 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -402,6 +402,7 @@ CONFIG_RTE_LIBRTE_TABLE=y
 CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 8e192bc..918bbaf 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -409,6 +409,7 @@ CONFIG_RTE_LIBRTE_TABLE=y
 CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_hash_key16.c b/lib/librte_table/rte_table_hash_key16.c
index ee5f639..4dd4774 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_HASH_KEY16_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;
@@ -832,6 +848,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; ) {
@@ -846,6 +865,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;
 	}
 
@@ -935,6 +955,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() */
 
@@ -955,6 +976,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; ) {
@@ -1081,15 +1105,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 = {
@@ -1098,4 +1138,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 related	[flat|nested] 12+ messages in thread

* [PATCH 06/10] table: added hash_key32 table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 05/10] table: added hash_key16 " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 07/10] table: added hash_key8 " Maciej Gajdzica
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp                    |    1 +
 config/common_linuxapp                  |    1 +
 lib/librte_table/rte_table_hash_key32.c |   41 +++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 2f92f69..a77e422 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -403,6 +403,7 @@ CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 918bbaf..dfe60aa 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -410,6 +410,7 @@ CONFIG_RTE_TABLE_ACL_STATS_COLLECT=n
 CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_hash_key32.c b/lib/librte_table/rte_table_hash_key32.c
index da0ce6a..56e0512 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_HASH_KEY32_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;
@@ -851,6 +867,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; ) {
@@ -865,6 +884,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;
 	}
 
@@ -955,6 +975,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() */
 
@@ -975,6 +996,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; ) {
@@ -1101,15 +1125,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 = {
@@ -1118,4 +1158,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 related	[flat|nested] 12+ messages in thread

* [PATCH 07/10] table: added hash_key8 table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 06/10] table: added hash_key32 " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 08/10] table: added hash_lru " Maciej Gajdzica
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp                   |    1 +
 config/common_linuxapp                 |    1 +
 lib/librte_table/rte_table_hash_key8.c |   52 ++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index a77e422..7708b1c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -404,6 +404,7 @@ CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index dfe60aa..e5debf9 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -411,6 +411,7 @@ CONFIG_RTE_TABLE_ARRAY_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_hash_key8.c b/lib/librte_table/rte_table_hash_key8.c
index 443ca7d..ded1670 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_HASH_KEY8_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;
@@ -847,6 +863,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; ) {
@@ -861,6 +880,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;
 	}
 
@@ -950,6 +970,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() */
 
@@ -968,6 +989,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; ) {
@@ -982,6 +1006,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;
 	}
 
@@ -1071,6 +1096,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() */
 
@@ -1091,6 +1117,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; ) {
@@ -1217,6 +1246,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() */
 
@@ -1237,6 +1267,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; ) {
@@ -1363,15 +1396,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 = {
@@ -1380,6 +1429,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 = {
@@ -1388,6 +1438,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 = {
@@ -1396,4 +1447,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 related	[flat|nested] 12+ messages in thread

* [PATCH 08/10] table: added hash_lru table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (6 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 07/10] table: added hash_key8 " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 09/10] table: added lpm_ipv6 " Maciej Gajdzica
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp                  |    1 +
 config/common_linuxapp                |    1 +
 lib/librte_table/rte_table_hash_lru.c |   44 +++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 7708b1c..8206d22 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -405,6 +405,7 @@ CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_LRU_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index e5debf9..c607077 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -412,6 +412,7 @@ CONFIG_RTE_TABLE_HASH_EXT_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
+CONFIG_RTE_TABLE_HASH_LRU_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_hash_lru.c b/lib/librte_table/rte_table_hash_lru.c
index c9a8afd..2f2156c 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_HASH_LRU_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 related	[flat|nested] 12+ messages in thread

* [PATCH 09/10] table: added lpm_ipv6 table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (7 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 08/10] table: added hash_lru " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:42   ` [PATCH 10/10] table: added lpm " Maciej Gajdzica
  2015-03-30 11:59   ` [PATCH 00/10] table: added table statistics Dumitrescu, Cristian
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp                  |    1 +
 config/common_linuxapp                |    1 +
 lib/librte_table/rte_table_lpm_ipv6.c |   34 +++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 8206d22..08b2b4a 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -406,6 +406,7 @@ CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_LRU_STATS_COLLECT=n
+CONFIG_RTE_TABLE_LPM_IPV6_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index c607077..fde934d 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -413,6 +413,7 @@ CONFIG_RTE_TABLE_HASH_KEY16_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_LRU_STATS_COLLECT=n
+CONFIG_RTE_TABLE_LPM_IPV6_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_lpm_ipv6.c b/lib/librte_table/rte_table_lpm_ipv6.c
index ce4ddc0..11534a9 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_LPM_IPV6_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 related	[flat|nested] 12+ messages in thread

* [PATCH 10/10] table: added lpm table stats
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (8 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 09/10] table: added lpm_ipv6 " Maciej Gajdzica
@ 2015-03-30 11:42   ` Maciej Gajdzica
  2015-03-30 11:59   ` [PATCH 00/10] table: added table statistics Dumitrescu, Cristian
  10 siblings, 0 replies; 12+ messages in thread
From: Maciej Gajdzica @ 2015-03-30 11:42 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

---
 config/common_bsdapp             |    1 +
 config/common_linuxapp           |    1 +
 lib/librte_table/rte_table_lpm.c |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 08b2b4a..829591c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -407,6 +407,7 @@ CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_LRU_STATS_COLLECT=n
 CONFIG_RTE_TABLE_LPM_IPV6_STATS_COLLECT=n
+CONFIG_RTE_TABLE_LPM_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/config/common_linuxapp b/config/common_linuxapp
index fde934d..891b5da 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -414,6 +414,7 @@ CONFIG_RTE_TABLE_HASH_KEY32_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_KEY8_STATS_COLLECT=n
 CONFIG_RTE_TABLE_HASH_LRU_STATS_COLLECT=n
 CONFIG_RTE_TABLE_LPM_IPV6_STATS_COLLECT=n
+CONFIG_RTE_TABLE_LPM_STATS_COLLECT=n
 
 #
 # Compile librte_pipeline
diff --git a/lib/librte_table/rte_table_lpm.c b/lib/librte_table/rte_table_lpm.c
index 64c684d..7d8f670 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_LPM_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 related	[flat|nested] 12+ messages in thread

* Re: [PATCH 00/10] table: added table statistics
       [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (9 preceding siblings ...)
  2015-03-30 11:42   ` [PATCH 10/10] table: added lpm " Maciej Gajdzica
@ 2015-03-30 11:59   ` Dumitrescu, Cristian
  10 siblings, 0 replies; 12+ messages in thread
From: Dumitrescu, Cristian @ 2015-03-30 11:59 UTC (permalink / raw)
  To: Gajdzica, MaciejX T, dev-VfR2kkLFssw



> -----Original Message-----
> From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Maciej Gajdzica
> Sent: Monday, March 30, 2015 12:42 PM
> To: dev-VfR2kkLFssw@public.gmane.org
> Subject: [dpdk-dev] [PATCH 00/10] table: added table statistics
> 
> Added statistics for every type of table. By default all table statistics
> are disabled, user must activate them in config file.
> 
> Maciej Gajdzica (10):
>   table: added structure for storing table stats
>   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                    |    9 ++++++
>  config/common_linuxapp                  |    9 ++++++
>  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, 401 insertions(+), 1 deletion(-)
> 
> --
> 1.7.9.5

Acked by: Cristian Dumitrescu <cristian.dumitrescu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30 11:42 [PATCH 00/10] table: added table statistics Maciej Gajdzica
     [not found] ` <1427715737-29252-1-git-send-email-maciejx.t.gajdzica-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-30 11:42   ` [PATCH 01/10] table: added structure for storing table stats Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 02/10] table: added acl " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 03/10] table: added array " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 04/10] table: added hash_ext " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 05/10] table: added hash_key16 " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 06/10] table: added hash_key32 " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 07/10] table: added hash_key8 " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 08/10] table: added hash_lru " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 09/10] table: added lpm_ipv6 " Maciej Gajdzica
2015-03-30 11:42   ` [PATCH 10/10] table: added lpm " Maciej Gajdzica
2015-03-30 11:59   ` [PATCH 00/10] table: added table statistics Dumitrescu, Cristian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.