DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] Keep-alive stats and doc fixes
@ 2016-01-20 15:53 Harry van Haaren
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 1/3] doc: fix keepalive sample app guide Harry van Haaren
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-01-20 15:53 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patchset contains:
1. Fix variable naming consistency in sample guide
2. Set last_seen time on core when it gets registered
3. An xstats implementation for last-seen and current core status

Harry van Haaren (3):
  doc: fix keepalive sample app guide
  eal: add keepalive core register timestamp
  keepalive: add rte_keepalive_xstats() and example

 doc/guides/rel_notes/release_2_3.rst            |  6 +++
 doc/guides/sample_app_ug/keep_alive.rst         | 30 +++++++++-----
 examples/l2fwd-keepalive/main.c                 | 22 ++++++++--
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 ++++
 lib/librte_eal/common/include/rte_keepalive.h   | 17 +++++++-
 lib/librte_eal/common/rte_keepalive.c           | 53 ++++++++++++++++++++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 ++++
 7 files changed, 127 insertions(+), 15 deletions(-)

-- 
2.5.0

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

* [dpdk-dev] [PATCH 1/3] doc: fix keepalive sample app guide
  2016-01-20 15:53 [dpdk-dev] [PATCH 0/3] Keep-alive stats and doc fixes Harry van Haaren
@ 2016-01-20 15:53 ` Harry van Haaren
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 2/3] eal: add keepalive core register timestamp Harry van Haaren
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-01-20 15:53 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch fixes some mismatches between the keepalive code
and the docs. Struct names, and descriptions are not in line
with the codebase.

Fixes: e64833f2273a ("examples/l2fwd-keepalive: add sample application")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/sample_app_ug/keep_alive.rst | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst
index 080811b..1478faf 100644
--- a/doc/guides/sample_app_ug/keep_alive.rst
+++ b/doc/guides/sample_app_ug/keep_alive.rst
@@ -1,6 +1,6 @@
 
 ..  BSD LICENSE
-    Copyright(c) 2015 Intel Corporation. All rights reserved.
+    Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -143,17 +143,17 @@ The Keep-Alive/'Liveliness' conceptual scheme:
 The following sections provide some explanation of the code aspects
 that are specific to the Keep Alive sample application.
 
-The heartbeat functionality is initialized with a struct
-rte_heartbeat and the callback function to invoke in the
+The keepalive functionality is initialized with a struct
+rte_keepalive and the callback function to invoke in the
 case of a timeout.
 
 .. code-block:: c
 
     rte_global_keepalive_info = rte_keepalive_create(&dead_core, NULL);
-    if (rte_global_hbeat_info == NULL)
+    if (rte_global_keepalive_info == NULL)
         rte_exit(EXIT_FAILURE, "keepalive_create() failed");
 
-The function that issues the pings hbeat_dispatch_pings()
+The function that issues the pings keepalive_dispatch_pings()
 is configured to run every check_period milliseconds.
 
 .. code-block:: c
@@ -162,7 +162,8 @@ is configured to run every check_period milliseconds.
             (check_period * rte_get_timer_hz()) / 1000,
             PERIODICAL,
             rte_lcore_id(),
-            &hbeat_dispatch_pings, rte_global_keepalive_info
+            &rte_keepalive_dispatch_pings,
+            rte_global_keepalive_info
             ) != 0 )
         rte_exit(EXIT_FAILURE, "Keepalive setup failure.\n");
 
@@ -173,7 +174,7 @@ functionality and the example random failures.
 
 .. code-block:: c
 
-    rte_keepalive_mark_alive(&rte_global_hbeat_info);
+    rte_keepalive_mark_alive(&rte_global_keepalive_info);
     cur_tsc = rte_rdtsc();
 
     /* Die randomly within 7 secs for demo purposes.. */
@@ -185,7 +186,7 @@ The rte_keepalive_mark_alive function simply sets the core state to alive.
 .. code-block:: c
 
     static inline void
-    rte_keepalive_mark_alive(struct rte_heartbeat *keepcfg)
+    rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
     {
-        keepcfg->state_flags[rte_lcore_id()] = 1;
+        keepcfg->state_flags[rte_lcore_id()] = ALIVE;
     }
-- 
2.5.0

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

* [dpdk-dev] [PATCH 2/3] eal: add keepalive core register timestamp
  2016-01-20 15:53 [dpdk-dev] [PATCH 0/3] Keep-alive stats and doc fixes Harry van Haaren
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 1/3] doc: fix keepalive sample app guide Harry van Haaren
@ 2016-01-20 15:53 ` Harry van Haaren
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 3/3] keepalive: add rte_keepalive_xstats() and example Harry van Haaren
  2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
  3 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-01-20 15:53 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch sets a timestamp on each lcore when it is registered
for keepalive. This causes the first values read by the monitor
to show time since the core was registered, instead of the delta
between 0 and the timestamp counter.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_eal/common/rte_keepalive.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index 736fd0f..5358322 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -38,6 +38,7 @@
 #include <rte_log.h>
 #include <rte_keepalive.h>
 #include <rte_malloc.h>
+#include <rte_cycles.h>
 
 static void
 print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
@@ -108,6 +109,8 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
-	if (id_core < RTE_KEEPALIVE_MAXCORES)
+	if (id_core < RTE_KEEPALIVE_MAXCORES) {
 		keepcfg->active_cores[id_core] = 1;
+		keepcfg->last_alive[id_core] = rte_rdtsc();
+	}
 }
-- 
2.5.0

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

* [dpdk-dev] [PATCH 3/3] keepalive: add rte_keepalive_xstats() and example
  2016-01-20 15:53 [dpdk-dev] [PATCH 0/3] Keep-alive stats and doc fixes Harry van Haaren
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 1/3] doc: fix keepalive sample app guide Harry van Haaren
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 2/3] eal: add keepalive core register timestamp Harry van Haaren
@ 2016-01-20 15:53 ` Harry van Haaren
  2016-01-21  9:57   ` Remy Horton
  2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
  3 siblings, 1 reply; 23+ messages in thread
From: Harry van Haaren @ 2016-01-20 15:53 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch adds a function that exposes keepalive statistics
re-using the existing rte_eth_xstats struct. The function provides
the client API the opportunity to read last-seen and status of
each core.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/rel_notes/release_2_3.rst            |  6 ++++
 doc/guides/sample_app_ug/keep_alive.rst         | 11 ++++++
 examples/l2fwd-keepalive/main.c                 | 22 ++++++++++--
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 ++++
 lib/librte_eal/common/include/rte_keepalive.h   | 17 ++++++++-
 lib/librte_eal/common/rte_keepalive.c           | 48 ++++++++++++++++++++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 ++++
 7 files changed, 113 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_3.rst b/doc/guides/rel_notes/release_2_3.rst
index 99de186..9e33aa2 100644
--- a/doc/guides/rel_notes/release_2_3.rst
+++ b/doc/guides/rel_notes/release_2_3.rst
@@ -4,6 +4,12 @@ DPDK Release 2.3
 New Features
 ------------
 
+* **Keep Alive xstats**
+
+  A function ``rte_keepalive_xstats()`` has been added to the
+  keepalive header, allowing the retrieval of keepalive statistics
+  such as last-alive-time and the status of each core registered
+  for monitoring. The API reflects that of the existing xstats API.
 
 Resolved Issues
 ---------------
diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst
index 1478faf..839e29c 100644
--- a/doc/guides/sample_app_ug/keep_alive.rst
+++ b/doc/guides/sample_app_ug/keep_alive.rst
@@ -190,3 +190,14 @@ The rte_keepalive_mark_alive function simply sets the core state to alive.
     {
         keepcfg->state_flags[rte_lcore_id()] = ALIVE;
     }
+
+Keepalive exposes its statistics using an API very similar to the xstats API.
+This allows client code to call the function and retrieve the current status
+of keepalive, providing information like last-alive time and status per-core
+that has keepalive enabled.
+
+.. code-block:: c
+
+    nstats = rte_keepalive_xstats(rte_global_keepalive_info, xstats, nstats);
+    for (i = 0; i < nstats; i++)
+        printf("%s : %lu\n", xstats[i].name, xstats[i].value);
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index f4d52f2..a8f2ba4 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -66,6 +66,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ring.h>
+#include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_timer.h>
@@ -139,7 +140,7 @@ struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
 /* A tsc-based timer responsible for triggering statistics printout */
 #define TIMER_MILLISECOND 1
 #define MAX_TIMER_PERIOD 86400 /* 1 day max */
-static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; /* 10 seconds */
+static int64_t timer_period = 1 * TIMER_MILLISECOND * 1000; /* 1 second */
 static int64_t check_period = 5; /* default check cycle is 5ms */
 
 /* Keepalive structure */
@@ -189,7 +190,22 @@ print_stats(__attribute__((unused)) struct rte_timer *ptr_timer,
 		   total_packets_tx,
 		   total_packets_rx,
 		   total_packets_dropped);
-	printf("\n====================================================\n");
+	printf("\nKeep Alive xstats ==================================\n");
+
+	/* Keepalive Xstats */
+	unsigned nstats = rte_keepalive_xstats(rte_global_keepalive_info, 0, 0);
+	struct rte_eth_xstats *xstats = rte_zmalloc( "RTE_KEEPALIVE_XSTATS",
+					sizeof( struct rte_eth_xstats) * nstats,
+					RTE_CACHE_LINE_SIZE);
+
+	nstats = rte_keepalive_xstats(rte_global_keepalive_info, xstats,
+				      nstats);
+	unsigned i;
+	for (i = 0; i < nstats; i++)
+		printf("%s\t%lu\n", xstats[i].name,
+				xstats[i].value);
+	printf("====================================================\n");
+	rte_free(xstats);
 }
 
 /* Send the burst of packets on an output interface */
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 9d7adf1..f5e16a7 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -135,3 +135,10 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+DPDK_2.3 {
+	global:
+
+	rte_keepalive_xstats;
+
+} DPDK_2.2;
diff --git a/lib/librte_eal/common/include/rte_keepalive.h b/lib/librte_eal/common/include/rte_keepalive.h
index 02472c0..352dd17 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,8 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif
 
+struct rte_eth_xstats;
+
 
 /**
  * Keepalive failure callback.
@@ -127,6 +129,19 @@ void rte_keepalive_dispatch_pings(void *ptr_timer, void *ptr_data);
 void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
 	const int id_core);
 
+/**
+ * Get statistics of the keepalive state. If xstats NULL or n is zero, the
+ * function returns the number of xstats available. If xstats is a pointer to
+ * array of size n, n items will be filled in, and then returned.
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ * @param *xstats
+ *   An array of rte_eth_xstats, or NULL.
+ * @param n
+ *   Size of the array of xstats being passed in
+ */
+int rte_keepalive_xstats(struct rte_keepalive *keepcfg,
+			 struct rte_eth_xstats *xstats, unsigned n);
 
 /**
  * Per-core keepalive check.
diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index 5358322..5952bac 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -39,6 +39,9 @@
 #include <rte_keepalive.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
+#include <rte_ethdev.h>
+
+#define RTE_KEEPALIVE_NSTATS 2
 
 static void
 print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
@@ -114,3 +117,46 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 		keepcfg->last_alive[id_core] = rte_rdtsc();
 	}
 }
+
+int
+rte_keepalive_xstats(struct rte_keepalive *ka, struct rte_eth_xstats *xstats,
+		     unsigned n)
+{
+	unsigned i, c, active = 0;
+	for (i = 0; i < RTE_KEEPALIVE_MAXCORES; i++) {
+		if (ka->active_cores[i])
+			active++;
+	}
+
+	const unsigned nstats = active * RTE_KEEPALIVE_NSTATS;
+
+	/* Indicate number of ka-xstats */
+	if (n < nstats)
+		return nstats;
+
+	if (xstats == NULL)
+		return nstats;
+
+	uint64_t tsc = rte_rdtsc();
+	i = 0;
+	for (c = 0; c < RTE_KEEPALIVE_MAXCORES; c++) {
+		if (ka->active_cores[c]) {
+			snprintf(xstats[i].name,
+					RTE_ETH_XSTATS_NAME_SIZE,
+					"%s%u%s", "keepalive_core",
+					c, "_last_time");
+			xstats[i].value = ((tsc - ka->last_alive[c])*1000) /
+				rte_get_tsc_hz();
+			i++;
+
+			snprintf(xstats[i].name,
+					RTE_ETH_XSTATS_NAME_SIZE,
+					"%s%u%s\t", "keepalive_core",
+					c, "_status");
+			xstats[i].value = (uint32_t)ka->state_flags[c];
+			i++;
+		}
+	}
+
+	return nstats;
+}
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index cbe175f..2979df3 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -138,3 +138,10 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+DPDK_2.3 {
+	global:
+
+	rte_keepalive_xstats;
+
+} DPDK_2.2;
-- 
2.5.0

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

* Re: [dpdk-dev] [PATCH 3/3] keepalive: add rte_keepalive_xstats() and example
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 3/3] keepalive: add rte_keepalive_xstats() and example Harry van Haaren
@ 2016-01-21  9:57   ` Remy Horton
  0 siblings, 0 replies; 23+ messages in thread
From: Remy Horton @ 2016-01-21  9:57 UTC (permalink / raw)
  To: dev

Morning,

On 20/01/2016 15:53, Harry van Haaren wrote:
> This patch adds a function that exposes keepalive statistics
> re-using the existing rte_eth_xstats struct. The function provides
> the client API the opportunity to read last-seen and status of
> each core.
>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
  ...
>   #include <rte_keepalive.h>
>   #include <rte_malloc.h>
>   #include <rte_cycles.h>
> +#include <rte_ethdev.h>
> +
> +#define RTE_KEEPALIVE_NSTATS 2

Tried building this and am getting the following error:

== Build lib/librte_eal/linuxapp/eal
   CC rte_keepalive.o
/local/rhorton/dpdk-test/lib/librte_eal/common/rte_keepalive.c:42:24: 
fatal error: rte_ethdev.h: No such file or directory
compilation terminated.

If I remember correctly, there are limitations on the libs using each 
others' header files..


..Remy

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

* [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes
  2016-01-20 15:53 [dpdk-dev] [PATCH 0/3] Keep-alive stats and doc fixes Harry van Haaren
                   ` (2 preceding siblings ...)
  2016-01-20 15:53 ` [dpdk-dev] [PATCH 3/3] keepalive: add rte_keepalive_xstats() and example Harry van Haaren
@ 2016-01-21 11:05 ` Harry van Haaren
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide Harry van Haaren
                     ` (4 more replies)
  3 siblings, 5 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-01-21 11:05 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patchset contains:
1. Fix variable naming consistency in sample guide
2. Set last_seen time on core when it gets registered
3. An xstats implementation for last-seen and current core status

v2:
-Refactor to remove rte_ethdev.h include

Harry van Haaren (3):
  doc: fix keepalive sample app guide
  eal: add keepalive core register timestamp
  keepalive: add rte_keepalive_xstats_get() and example

 doc/guides/rel_notes/release_2_3.rst            |  6 +++
 doc/guides/sample_app_ug/keep_alive.rst         | 30 +++++++++-----
 examples/l2fwd-keepalive/main.c                 | 23 +++++++++--
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 ++++
 lib/librte_eal/common/include/rte_keepalive.h   | 28 ++++++++++++-
 lib/librte_eal/common/rte_keepalive.c           | 52 ++++++++++++++++++++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 ++++
 7 files changed, 138 insertions(+), 15 deletions(-)

-- 
2.5.0

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

* [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide
  2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
@ 2016-01-21 11:05   ` Harry van Haaren
  2016-02-19 17:28     ` Mcnamara, John
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 2/3] eal: add keepalive core register timestamp Harry van Haaren
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Harry van Haaren @ 2016-01-21 11:05 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch fixes some mismatches between the keepalive code
and the docs. Struct names, and descriptions are not in line
with the codebase.

Fixes: e64833f2273a ("examples/l2fwd-keepalive: add sample application")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/sample_app_ug/keep_alive.rst | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst
index 080811b..1478faf 100644
--- a/doc/guides/sample_app_ug/keep_alive.rst
+++ b/doc/guides/sample_app_ug/keep_alive.rst
@@ -1,6 +1,6 @@
 
 ..  BSD LICENSE
-    Copyright(c) 2015 Intel Corporation. All rights reserved.
+    Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -143,17 +143,17 @@ The Keep-Alive/'Liveliness' conceptual scheme:
 The following sections provide some explanation of the code aspects
 that are specific to the Keep Alive sample application.
 
-The heartbeat functionality is initialized with a struct
-rte_heartbeat and the callback function to invoke in the
+The keepalive functionality is initialized with a struct
+rte_keepalive and the callback function to invoke in the
 case of a timeout.
 
 .. code-block:: c
 
     rte_global_keepalive_info = rte_keepalive_create(&dead_core, NULL);
-    if (rte_global_hbeat_info == NULL)
+    if (rte_global_keepalive_info == NULL)
         rte_exit(EXIT_FAILURE, "keepalive_create() failed");
 
-The function that issues the pings hbeat_dispatch_pings()
+The function that issues the pings keepalive_dispatch_pings()
 is configured to run every check_period milliseconds.
 
 .. code-block:: c
@@ -162,7 +162,8 @@ is configured to run every check_period milliseconds.
             (check_period * rte_get_timer_hz()) / 1000,
             PERIODICAL,
             rte_lcore_id(),
-            &hbeat_dispatch_pings, rte_global_keepalive_info
+            &rte_keepalive_dispatch_pings,
+            rte_global_keepalive_info
             ) != 0 )
         rte_exit(EXIT_FAILURE, "Keepalive setup failure.\n");
 
@@ -173,7 +174,7 @@ functionality and the example random failures.
 
 .. code-block:: c
 
-    rte_keepalive_mark_alive(&rte_global_hbeat_info);
+    rte_keepalive_mark_alive(&rte_global_keepalive_info);
     cur_tsc = rte_rdtsc();
 
     /* Die randomly within 7 secs for demo purposes.. */
@@ -185,7 +186,7 @@ The rte_keepalive_mark_alive function simply sets the core state to alive.
 .. code-block:: c
 
     static inline void
-    rte_keepalive_mark_alive(struct rte_heartbeat *keepcfg)
+    rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
     {
-        keepcfg->state_flags[rte_lcore_id()] = 1;
+        keepcfg->state_flags[rte_lcore_id()] = ALIVE;
     }
-- 
2.5.0

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

* [dpdk-dev] [PATCH v2 2/3] eal: add keepalive core register timestamp
  2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide Harry van Haaren
@ 2016-01-21 11:05   ` Harry van Haaren
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 3/3] keepalive: add rte_keepalive_xstats_get() and example Harry van Haaren
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-01-21 11:05 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch sets a timestamp on each lcore when it is registered
for keepalive. This causes the first values read by the monitor
to show time since the core was registered, instead of the delta
between 0 and the timestamp counter.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_eal/common/rte_keepalive.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index 736fd0f..5358322 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -38,6 +38,7 @@
 #include <rte_log.h>
 #include <rte_keepalive.h>
 #include <rte_malloc.h>
+#include <rte_cycles.h>
 
 static void
 print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
@@ -108,6 +109,8 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
-	if (id_core < RTE_KEEPALIVE_MAXCORES)
+	if (id_core < RTE_KEEPALIVE_MAXCORES) {
 		keepcfg->active_cores[id_core] = 1;
+		keepcfg->last_alive[id_core] = rte_rdtsc();
+	}
 }
-- 
2.5.0

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

* [dpdk-dev] [PATCH v2 3/3] keepalive: add rte_keepalive_xstats_get() and example
  2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide Harry van Haaren
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 2/3] eal: add keepalive core register timestamp Harry van Haaren
@ 2016-01-21 11:05   ` Harry van Haaren
  2016-01-21 12:12   ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Remy Horton
  2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
  4 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-01-21 11:05 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch adds a function that exposes keepalive statistics
using a rte_keepalive_xstats struct. The function provides
the client API the opportunity to read last-seen and status of
each core.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/rel_notes/release_2_3.rst            |  6 ++++
 doc/guides/sample_app_ug/keep_alive.rst         | 11 ++++++
 examples/l2fwd-keepalive/main.c                 | 23 ++++++++++--
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 ++++
 lib/librte_eal/common/include/rte_keepalive.h   | 28 ++++++++++++++-
 lib/librte_eal/common/rte_keepalive.c           | 47 ++++++++++++++++++++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 ++++
 7 files changed, 124 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_3.rst b/doc/guides/rel_notes/release_2_3.rst
index 99de186..c06e28c 100644
--- a/doc/guides/rel_notes/release_2_3.rst
+++ b/doc/guides/rel_notes/release_2_3.rst
@@ -4,6 +4,12 @@ DPDK Release 2.3
 New Features
 ------------
 
+* **Keep Alive xstats**
+
+  A function ``rte_keepalive_xstats_get()`` has been added to the
+  keepalive header, allowing the retrieval of keepalive statistics
+  such as last-alive-time and the status of each core registered
+  for monitoring. The API reflects that of the existing xstats API.
 
 Resolved Issues
 ---------------
diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst
index 1478faf..7c2d2a4 100644
--- a/doc/guides/sample_app_ug/keep_alive.rst
+++ b/doc/guides/sample_app_ug/keep_alive.rst
@@ -190,3 +190,14 @@ The rte_keepalive_mark_alive function simply sets the core state to alive.
     {
         keepcfg->state_flags[rte_lcore_id()] = ALIVE;
     }
+
+Keepalive exposes its statistics using an API very similar to the xstats API.
+This allows client code to call the function and retrieve the current status
+of keepalive, providing information like last-alive time and status per-core.
+
+.. code-block:: c
+
+    nstats = rte_keepalive_xstats_get(rte_global_keepalive_info, xstats,
+                                      nstats);
+    for (i = 0; i < nstats; i++)
+        printf("%s : %lu\n", xstats[i].name, xstats[i].value);
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index f4d52f2..34c6d62 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -66,6 +66,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ring.h>
+#include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_timer.h>
@@ -139,7 +140,7 @@ struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
 /* A tsc-based timer responsible for triggering statistics printout */
 #define TIMER_MILLISECOND 1
 #define MAX_TIMER_PERIOD 86400 /* 1 day max */
-static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; /* 10 seconds */
+static int64_t timer_period = 1 * TIMER_MILLISECOND * 1000; /* 1 second */
 static int64_t check_period = 5; /* default check cycle is 5ms */
 
 /* Keepalive structure */
@@ -189,7 +190,23 @@ print_stats(__attribute__((unused)) struct rte_timer *ptr_timer,
 		   total_packets_tx,
 		   total_packets_rx,
 		   total_packets_dropped);
-	printf("\n====================================================\n");
+	printf("\nKeep Alive xstats ==================================\n");
+
+	/* Keepalive Xstats */
+	unsigned nstats = rte_keepalive_xstats_get(rte_global_keepalive_info,
+						   0, 0);
+	struct rte_keepalive_xstats *xstats =
+		rte_zmalloc("RTE_KEEPALIVE_XSTATS",
+			    sizeof(struct rte_keepalive_xstats) * nstats,
+			    RTE_CACHE_LINE_SIZE);
+
+	nstats = rte_keepalive_xstats_get(rte_global_keepalive_info, xstats,
+				      nstats);
+	unsigned i;
+	for (i = 0; i < nstats; i++)
+		printf("%s\t%lu\n", xstats[i].name, xstats[i].value);
+	printf("====================================================\n");
+	rte_free(xstats);
 }
 
 /* Send the burst of packets on an output interface */
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 9d7adf1..ff1cbc7 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -135,3 +135,10 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+DPDK_2.3 {
+	global:
+
+	rte_keepalive_xstats_get;
+
+} DPDK_2.2;
diff --git a/lib/librte_eal/common/include/rte_keepalive.h b/lib/librte_eal/common/include/rte_keepalive.h
index 02472c0..f98b92c 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,19 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif
 
+#define RTE_KEEPALIVE_XSTATS_NAME_LEN 64
+
+/**
+ * Keepalive extended statistic structure
+ *
+ * This structure is used by rte_keepalive_xstats_get() to provide
+ * statistics that are not provided in the generic rte_eth_stats
+ * structure.
+ */
+struct rte_keepalive_xstats {
+	char name[RTE_KEEPALIVE_XSTATS_NAME_LEN];
+	uint64_t value;
+};
 
 /**
  * Keepalive failure callback.
@@ -127,6 +140,19 @@ void rte_keepalive_dispatch_pings(void *ptr_timer, void *ptr_data);
 void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
 	const int id_core);
 
+/**
+ * Get statistics of the keepalive state. If xstats NULL or n is zero, the
+ * function returns the number of xstats available. If xstats is a pointer to
+ * array of size n, n items will be filled in, and then returned.
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ * @param *xstats
+ *   An array of rte_eth_xstats, or NULL.
+ * @param n
+ *   Size of the array of xstats being passed in
+ */
+int rte_keepalive_xstats_get(struct rte_keepalive *keepcfg,
+			     struct rte_keepalive_xstats *xstats, unsigned n);
 
 /**
  * Per-core keepalive check.
diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index 5358322..ec0f986 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -40,6 +40,8 @@
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 
+#define RTE_KEEPALIVE_NSTATS 2
+
 static void
 print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
 {
@@ -114,3 +116,46 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 		keepcfg->last_alive[id_core] = rte_rdtsc();
 	}
 }
+
+int
+rte_keepalive_xstats_get(struct rte_keepalive *ka,
+			 struct rte_keepalive_xstats *xstats, unsigned n)
+{
+	unsigned i, c, active = 0;
+	for (i = 0; i < RTE_KEEPALIVE_MAXCORES; i++) {
+		if (ka->active_cores[i])
+			active++;
+	}
+
+	const unsigned nstats = active * RTE_KEEPALIVE_NSTATS;
+
+	/* Indicate number of ka-xstats */
+	if (n < nstats)
+		return nstats;
+
+	if (xstats == NULL)
+		return nstats;
+
+	uint64_t tsc = rte_rdtsc();
+	i = 0;
+	for (c = 0; c < RTE_KEEPALIVE_MAXCORES; c++) {
+		if (ka->active_cores[c]) {
+			snprintf(xstats[i].name,
+				 RTE_KEEPALIVE_XSTATS_NAME_LEN,
+				 "%s%u%s", "keepalive_core",
+				 c, "_last_time");
+			xstats[i].value = ((tsc - ka->last_alive[c])*1000) /
+				rte_get_tsc_hz();
+			i++;
+
+			snprintf(xstats[i].name,
+				 RTE_KEEPALIVE_XSTATS_NAME_LEN,
+				 "%s%u%s\t", "keepalive_core",
+				 c, "_status");
+			xstats[i].value = (uint32_t)ka->state_flags[c];
+			i++;
+		}
+	}
+
+	return nstats;
+}
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index cbe175f..088fc18 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -138,3 +138,10 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+DPDK_2.3 {
+	global:
+
+	rte_keepalive_xstats_get;
+
+} DPDK_2.2;
-- 
2.5.0

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

* Re: [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes
  2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
                     ` (2 preceding siblings ...)
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 3/3] keepalive: add rte_keepalive_xstats_get() and example Harry van Haaren
@ 2016-01-21 12:12   ` Remy Horton
  2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
  4 siblings, 0 replies; 23+ messages in thread
From: Remy Horton @ 2016-01-21 12:12 UTC (permalink / raw)
  To: dev



On 21/01/2016 11:05, Harry van Haaren wrote:
> This patchset contains:
> 1. Fix variable naming consistency in sample guide
> 2. Set last_seen time on core when it gets registered
> 3. An xstats implementation for last-seen and current core status
>
> v2:
> -Refactor to remove rte_ethdev.h include

Acked-by: Remy Horton <remy.horton@intel.com>

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

* Re: [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide
  2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide Harry van Haaren
@ 2016-02-19 17:28     ` Mcnamara, John
  0 siblings, 0 replies; 23+ messages in thread
From: Mcnamara, John @ 2016-02-19 17:28 UTC (permalink / raw)
  To: Van Haaren, Harry, Horton, Remy; +Cc: dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren
> Sent: Thursday, January 21, 2016 11:05 AM
> To: Horton, Remy <remy.horton@intel.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide
> 
> This patch fixes some mismatches between the keepalive code and the docs.
> Struct names, and descriptions are not in line with the codebase.
> 
> Fixes: e64833f2273a ("examples/l2fwd-keepalive: add sample application")
> 
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

Acked-by: John McNamara <john.mcnamara@intel.com>

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

* [dpdk-dev] [PATCH v3 0/3] Keepalive stats function and doc fixes
  2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
                     ` (3 preceding siblings ...)
  2016-01-21 12:12   ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Remy Horton
@ 2016-02-22 11:25   ` Harry van Haaren
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide Harry van Haaren
                       ` (4 more replies)
  4 siblings, 5 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-02-22 11:25 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patchset contains:
1. Fix variable naming consistency in sample guide
2. Set last_seen time on core when it gets registered
3. An xstats implementation for last-seen and current core status

v2:
-Refactor to remove rte_ethdev.h include

v3:
-Rebase to git

Harry van Haaren (3):
  doc: fix keepalive sample app guide
  eal: add keepalive core register timestamp
  keepalive: add rte_keepalive_xstats_get()

 doc/guides/rel_notes/release_16_04.rst          |  7 ++++
 doc/guides/sample_app_ug/keep_alive.rst         | 30 ++++++++++-----
 examples/l2fwd-keepalive/main.c                 | 22 +++++++++--
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_keepalive.h   | 31 ++++++++++++++-
 lib/librte_eal/common/rte_keepalive.c           | 51 ++++++++++++++++++++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 7 files changed, 128 insertions(+), 15 deletions(-)

-- 
2.5.0

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

* [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide
  2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
@ 2016-02-22 11:26     ` Harry van Haaren
  2016-02-22 16:54       ` Mcnamara, John
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 2/3] eal: add keepalive core register timestamp Harry van Haaren
                       ` (3 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Harry van Haaren @ 2016-02-22 11:26 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch fixes some mismatches between the keepalive code
and the docs. Struct names, and descriptions are not in line
with the codebase.

Fixes: e64833f2273a ("examples/l2fwd-keepalive: add sample application")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/sample_app_ug/keep_alive.rst | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst
index 080811b..1478faf 100644
--- a/doc/guides/sample_app_ug/keep_alive.rst
+++ b/doc/guides/sample_app_ug/keep_alive.rst
@@ -1,6 +1,6 @@
 
 ..  BSD LICENSE
-    Copyright(c) 2015 Intel Corporation. All rights reserved.
+    Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -143,17 +143,17 @@ The Keep-Alive/'Liveliness' conceptual scheme:
 The following sections provide some explanation of the code aspects
 that are specific to the Keep Alive sample application.
 
-The heartbeat functionality is initialized with a struct
-rte_heartbeat and the callback function to invoke in the
+The keepalive functionality is initialized with a struct
+rte_keepalive and the callback function to invoke in the
 case of a timeout.
 
 .. code-block:: c
 
     rte_global_keepalive_info = rte_keepalive_create(&dead_core, NULL);
-    if (rte_global_hbeat_info == NULL)
+    if (rte_global_keepalive_info == NULL)
         rte_exit(EXIT_FAILURE, "keepalive_create() failed");
 
-The function that issues the pings hbeat_dispatch_pings()
+The function that issues the pings keepalive_dispatch_pings()
 is configured to run every check_period milliseconds.
 
 .. code-block:: c
@@ -162,7 +162,8 @@ is configured to run every check_period milliseconds.
             (check_period * rte_get_timer_hz()) / 1000,
             PERIODICAL,
             rte_lcore_id(),
-            &hbeat_dispatch_pings, rte_global_keepalive_info
+            &rte_keepalive_dispatch_pings,
+            rte_global_keepalive_info
             ) != 0 )
         rte_exit(EXIT_FAILURE, "Keepalive setup failure.\n");
 
@@ -173,7 +174,7 @@ functionality and the example random failures.
 
 .. code-block:: c
 
-    rte_keepalive_mark_alive(&rte_global_hbeat_info);
+    rte_keepalive_mark_alive(&rte_global_keepalive_info);
     cur_tsc = rte_rdtsc();
 
     /* Die randomly within 7 secs for demo purposes.. */
@@ -185,7 +186,7 @@ The rte_keepalive_mark_alive function simply sets the core state to alive.
 .. code-block:: c
 
     static inline void
-    rte_keepalive_mark_alive(struct rte_heartbeat *keepcfg)
+    rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
     {
-        keepcfg->state_flags[rte_lcore_id()] = 1;
+        keepcfg->state_flags[rte_lcore_id()] = ALIVE;
     }
-- 
2.5.0

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

* [dpdk-dev] [PATCH v3 2/3] eal: add keepalive core register timestamp
  2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide Harry van Haaren
@ 2016-02-22 11:26     ` Harry van Haaren
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 3/3] keepalive: add rte_keepalive_xstats_get() Harry van Haaren
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-02-22 11:26 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch sets a timestamp on each lcore when it is registered
for keepalive. This causes the first values read by the monitor
to show time since the core was registered, instead of the delta
between 0 and the timestamp counter.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_eal/common/rte_keepalive.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index bd1f16b..be9e30d 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -38,6 +38,7 @@
 #include <rte_log.h>
 #include <rte_keepalive.h>
 #include <rte_malloc.h>
+#include <rte_cycles.h>
 
 struct rte_keepalive {
 	/** Core Liveness. */
@@ -139,8 +140,10 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
-	if (id_core < RTE_KEEPALIVE_MAXCORES)
+	if (id_core < RTE_KEEPALIVE_MAXCORES) {
 		keepcfg->active_cores[id_core] = 1;
+		keepcfg->last_alive[id_core] = rte_rdtsc();
+	}
 }
 
 
-- 
2.5.0

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

* [dpdk-dev] [PATCH v3 3/3] keepalive: add rte_keepalive_xstats_get()
  2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide Harry van Haaren
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 2/3] eal: add keepalive core register timestamp Harry van Haaren
@ 2016-02-22 11:26     ` Harry van Haaren
  2016-02-29  9:19       ` Thomas Monjalon
  2016-02-22 13:12     ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function and doc fixes Remy Horton
  2016-03-08 10:50     ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Harry van Haaren
  4 siblings, 1 reply; 23+ messages in thread
From: Harry van Haaren @ 2016-02-22 11:26 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch adds a function that exposes keepalive statistics
using a rte_keepalive_xstats struct. The function provides
the client API the opportunity to read last-seen and status of
each core.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/rel_notes/release_16_04.rst          |  7 ++++
 doc/guides/sample_app_ug/keep_alive.rst         | 11 ++++++
 examples/l2fwd-keepalive/main.c                 | 22 ++++++++++--
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_keepalive.h   | 31 ++++++++++++++++-
 lib/librte_eal/common/rte_keepalive.c           | 46 ++++++++++++++++++++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 7 files changed, 114 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
index 5786f74..08b2785 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -46,6 +46,13 @@ This section should contain new features added in this release. Sample format:
 
 * **Added vhost-user live migration support.**
 
+* **Keepalive extended stats.**
+
+  A function ``rte_keepalive_xstats_get()`` has been added to the
+  keepalive header, allowing the retrieval of keepalive statistics
+  such as last-alive-time and the status of each core registered
+  for monitoring. The API reflects that of the existing xstats API.
+
 
 Resolved Issues
 ---------------
diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst
index 1478faf..7c2d2a4 100644
--- a/doc/guides/sample_app_ug/keep_alive.rst
+++ b/doc/guides/sample_app_ug/keep_alive.rst
@@ -190,3 +190,14 @@ The rte_keepalive_mark_alive function simply sets the core state to alive.
     {
         keepcfg->state_flags[rte_lcore_id()] = ALIVE;
     }
+
+Keepalive exposes its statistics using an API very similar to the xstats API.
+This allows client code to call the function and retrieve the current status
+of keepalive, providing information like last-alive time and status per-core.
+
+.. code-block:: c
+
+    nstats = rte_keepalive_xstats_get(rte_global_keepalive_info, xstats,
+                                      nstats);
+    for (i = 0; i < nstats; i++)
+        printf("%s : %lu\n", xstats[i].name, xstats[i].value);
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index f4d52f2..80307f8 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -66,6 +66,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ring.h>
+#include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_timer.h>
@@ -139,7 +140,7 @@ struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
 /* A tsc-based timer responsible for triggering statistics printout */
 #define TIMER_MILLISECOND 1
 #define MAX_TIMER_PERIOD 86400 /* 1 day max */
-static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; /* 10 seconds */
+static int64_t timer_period = TIMER_MILLISECOND * 1000; /* 1 second */
 static int64_t check_period = 5; /* default check cycle is 5ms */
 
 /* Keepalive structure */
@@ -189,7 +190,22 @@ print_stats(__attribute__((unused)) struct rte_timer *ptr_timer,
 		   total_packets_tx,
 		   total_packets_rx,
 		   total_packets_dropped);
-	printf("\n====================================================\n");
+
+	printf("\nKeep Alive xstats ==================================\n");
+	unsigned nstats = rte_keepalive_xstats_get(rte_global_keepalive_info,
+						   0, 0);
+	struct rte_keepalive_xstats *xstats =
+		rte_zmalloc("RTE_KEEPALIVE_XSTATS",
+			    sizeof(struct rte_keepalive_xstats) * nstats,
+			    RTE_CACHE_LINE_SIZE);
+
+	nstats = rte_keepalive_xstats_get(rte_global_keepalive_info, xstats,
+				      nstats);
+	unsigned i;
+	for (i = 0; i < nstats; i++)
+		printf("%s\t%lu\n", xstats[i].name, xstats[i].value);
+	printf("====================================================\n");
+	rte_free(xstats);
 }
 
 /* Send the burst of packets on an output interface */
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 4f93ab7..b6eaeb3 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -146,5 +146,6 @@ DPDK_2.3 {
 	rte_eal_pci_ioport_write;
 	rte_eal_pci_map_device;
 	rte_eal_pci_unmap_device;
+	rte_keepalive_xstats_get;
 
 } DPDK_2.2;
diff --git a/lib/librte_eal/common/include/rte_keepalive.h b/lib/librte_eal/common/include/rte_keepalive.h
index f4cec04..bd19855 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,20 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif
 
+#define RTE_KEEPALIVE_XSTATS_NAME_LEN 64
+
+/**
+ * Keepalive extended statistic structure
+ *
+ * This structure is used by rte_keepalive_xstats_get() to provide
+ * statistics that are not provided in the generic rte_eth_stats
+ * structure.
+ */
+struct rte_keepalive_xstats {
+	char name[RTE_KEEPALIVE_XSTATS_NAME_LEN];
+	uint64_t value;
+};
+
 
 /**
  * Keepalive failure callback.
@@ -99,6 +113,21 @@ void rte_keepalive_dispatch_pings(void *ptr_timer, void *ptr_data);
 void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
 	const int id_core);
 
+/**
+ * Get statistics of the keepalive state. If xstats NULL or n is zero, the
+ * function returns the number of xstats available. If xstats is a pointer to
+ * array of size n, n items will be filled in, and then returned.
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ * @param *xstats
+ *   An array of rte_eth_xstats, or NULL.
+ * @param n
+ *   Size of the array of xstats being passed in
+ */
+int rte_keepalive_xstats_get(struct rte_keepalive *keepcfg,
+			     struct rte_keepalive_xstats *xstats, unsigned n);
+
+
 
 /**
  * Per-core keepalive check.
diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index be9e30d..77b3622 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -40,6 +40,8 @@
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 
+#define RTE_KEEPALIVE_NSTATS 2
+
 struct rte_keepalive {
 	/** Core Liveness. */
 	enum rte_keepalive_state {
@@ -81,6 +83,48 @@ print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
 	      );
 }
 
+int
+rte_keepalive_xstats_get(struct rte_keepalive *ka,
+			 struct rte_keepalive_xstats *xstats, unsigned n)
+{
+	unsigned i, c, active = 0;
+	for (i = 0; i < RTE_KEEPALIVE_MAXCORES; i++) {
+		if (ka->active_cores[i])
+			active++;
+	}
+
+	const unsigned nstats = active * RTE_KEEPALIVE_NSTATS;
+
+	/* Indicate number of ka-xstats */
+	if (n < nstats)
+		return nstats;
+
+	if (xstats == NULL)
+		return nstats;
+
+	uint64_t tsc = rte_rdtsc();
+	i = 0;
+	for (c = 0; c < RTE_KEEPALIVE_MAXCORES; c++) {
+		if (ka->active_cores[c]) {
+			snprintf(xstats[i].name,
+				 RTE_KEEPALIVE_XSTATS_NAME_LEN,
+				 "%s%u%s", "keepalive_core",
+				 c, "_last_time");
+			xstats[i].value = ((tsc - ka->last_alive[c])*1000) /
+				rte_get_tsc_hz();
+			i++;
+
+			snprintf(xstats[i].name,
+				 RTE_KEEPALIVE_XSTATS_NAME_LEN,
+				 "%s%u%s\t", "keepalive_core",
+				 c, "_status");
+			xstats[i].value = (uint32_t)ka->state_flags[c];
+			i++;
+		}
+	}
+
+	return nstats;
+}
 
 void
 rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index e8d8660..b26a79c 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -149,5 +149,6 @@ DPDK_2.3 {
 	rte_eal_pci_ioport_write;
 	rte_eal_pci_map_device;
 	rte_eal_pci_unmap_device;
+	rte_keepalive_xstats_get;
 
 } DPDK_2.2;
-- 
2.5.0

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

* Re: [dpdk-dev] [PATCH v3 0/3] Keepalive stats function and doc fixes
  2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
                       ` (2 preceding siblings ...)
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 3/3] keepalive: add rte_keepalive_xstats_get() Harry van Haaren
@ 2016-02-22 13:12     ` Remy Horton
  2016-03-08 10:50     ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Harry van Haaren
  4 siblings, 0 replies; 23+ messages in thread
From: Remy Horton @ 2016-02-22 13:12 UTC (permalink / raw)
  To: Harry van Haaren; +Cc: dev

For some reason git apply choked on the patches but patch -p1 applied 
them fine. Guessing Thunderbird was adding a few rogue newlines..


On 22/02/2016 11:25, Harry van Haaren wrote:
> Harry van Haaren (3):
>    doc: fix keepalive sample app guide
>    eal: add keepalive core register timestamp
>    keepalive: add rte_keepalive_xstats_get()

Acked-by: Remy Horton <remy.horton@intel.com>

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

* Re: [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide Harry van Haaren
@ 2016-02-22 16:54       ` Mcnamara, John
  0 siblings, 0 replies; 23+ messages in thread
From: Mcnamara, John @ 2016-02-22 16:54 UTC (permalink / raw)
  To: Van Haaren, Harry, Horton, Remy; +Cc: dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren
> Sent: Monday, February 22, 2016 11:26 AM
> To: Horton, Remy <remy.horton@intel.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide
> 
> This patch fixes some mismatches between the keepalive code and the docs.
> Struct names, and descriptions are not in line with the codebase.
> 
> Fixes: e64833f2273a ("examples/l2fwd-keepalive: add sample application")
> 
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>


Acked-by: John McNamara <john.mcnamara@intel.com>

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

* Re: [dpdk-dev] [PATCH v3 3/3] keepalive: add rte_keepalive_xstats_get()
  2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 3/3] keepalive: add rte_keepalive_xstats_get() Harry van Haaren
@ 2016-02-29  9:19       ` Thomas Monjalon
  0 siblings, 0 replies; 23+ messages in thread
From: Thomas Monjalon @ 2016-02-29  9:19 UTC (permalink / raw)
  To: Harry van Haaren; +Cc: dev

Hi,

There is a compilation error for 32-bit arch:

2016-02-22 11:26, Harry van Haaren:
> +       for (i = 0; i < nstats; i++)
> +               printf("%s\t%lu\n", xstats[i].name, xstats[i].value);

examples/l2fwd-keepalive/main.c:206:10: error:
format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3
has type ‘uint64_t {aka long long unsigned int}’

Please keep acks when re-sending.
Thanks

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

* [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update
  2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
                       ` (3 preceding siblings ...)
  2016-02-22 13:12     ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function and doc fixes Remy Horton
@ 2016-03-08 10:50     ` Harry van Haaren
  2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 1/3] doc: fix keepalive sample app guide Harry van Haaren
                         ` (3 more replies)
  4 siblings, 4 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-03-08 10:50 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patchset adds a timestamp to when keepalive registers a core,
fixes the documentation to be in-line with the source, and fixes
whitespace in keepalive.[hc]

Harry van Haaren (3):
  doc: fix keepalive sample app guide
  eal: add keepalive core register timestamp
  keepalive: fix whitespace, removes double newlines

 doc/guides/sample_app_ug/keep_alive.rst       | 19 ++++++++++---------
 lib/librte_eal/common/include/rte_keepalive.h |  7 -------
 lib/librte_eal/common/rte_keepalive.c         | 12 +++++-------
 3 files changed, 15 insertions(+), 23 deletions(-)

-- 
2.5.0

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

* [dpdk-dev] [PATCH v4 1/3] doc: fix keepalive sample app guide
  2016-03-08 10:50     ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Harry van Haaren
@ 2016-03-08 10:50       ` Harry van Haaren
  2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 2/3] eal: add keepalive core register timestamp Harry van Haaren
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-03-08 10:50 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch fixes some mismatches between the keepalive code
and the docs. Struct names, and descriptions are not in line
with the codebase.

Fixes: e64833f2273a ("examples/l2fwd-keepalive: add sample application")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
---
 doc/guides/sample_app_ug/keep_alive.rst | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst
index b00f43b..3897377 100644
--- a/doc/guides/sample_app_ug/keep_alive.rst
+++ b/doc/guides/sample_app_ug/keep_alive.rst
@@ -1,6 +1,6 @@
 
 ..  BSD LICENSE
-    Copyright(c) 2015 Intel Corporation. All rights reserved.
+    Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -141,17 +141,17 @@ The Keep-Alive/'Liveliness' conceptual scheme:
 The following sections provide some explanation of the code aspects
 that are specific to the Keep Alive sample application.
 
-The heartbeat functionality is initialized with a struct
-rte_heartbeat and the callback function to invoke in the
+The keepalive functionality is initialized with a struct
+rte_keepalive and the callback function to invoke in the
 case of a timeout.
 
 .. code-block:: c
 
     rte_global_keepalive_info = rte_keepalive_create(&dead_core, NULL);
-    if (rte_global_hbeat_info == NULL)
+    if (rte_global_keepalive_info == NULL)
         rte_exit(EXIT_FAILURE, "keepalive_create() failed");
 
-The function that issues the pings hbeat_dispatch_pings()
+The function that issues the pings keepalive_dispatch_pings()
 is configured to run every check_period milliseconds.
 
 .. code-block:: c
@@ -160,7 +160,8 @@ is configured to run every check_period milliseconds.
             (check_period * rte_get_timer_hz()) / 1000,
             PERIODICAL,
             rte_lcore_id(),
-            &hbeat_dispatch_pings, rte_global_keepalive_info
+            &rte_keepalive_dispatch_pings,
+            rte_global_keepalive_info
             ) != 0 )
         rte_exit(EXIT_FAILURE, "Keepalive setup failure.\n");
 
@@ -171,7 +172,7 @@ functionality and the example random failures.
 
 .. code-block:: c
 
-    rte_keepalive_mark_alive(&rte_global_hbeat_info);
+    rte_keepalive_mark_alive(&rte_global_keepalive_info);
     cur_tsc = rte_rdtsc();
 
     /* Die randomly within 7 secs for demo purposes.. */
@@ -183,7 +184,7 @@ The rte_keepalive_mark_alive function simply sets the core state to alive.
 .. code-block:: c
 
     static inline void
-    rte_keepalive_mark_alive(struct rte_heartbeat *keepcfg)
+    rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
     {
-        keepcfg->state_flags[rte_lcore_id()] = 1;
+        keepcfg->state_flags[rte_lcore_id()] = ALIVE;
     }
-- 
2.5.0

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

* [dpdk-dev] [PATCH v4 2/3] eal: add keepalive core register timestamp
  2016-03-08 10:50     ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Harry van Haaren
  2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 1/3] doc: fix keepalive sample app guide Harry van Haaren
@ 2016-03-08 10:50       ` Harry van Haaren
  2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 3/3] keepalive: fix whitespace, removes double newlines Harry van Haaren
  2016-03-08 10:58       ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Thomas Monjalon
  3 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-03-08 10:50 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch sets a timestamp on each lcore when it is registered
for keepalive. This causes the first values read by the monitor
to show time since the core was registered, instead of the delta
between 0 and the timestamp counter.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 lib/librte_eal/common/rte_keepalive.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index bd1f16b..56df0b1 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -38,6 +38,7 @@
 #include <rte_log.h>
 #include <rte_keepalive.h>
 #include <rte_malloc.h>
+#include <rte_cycles.h>
 
 struct rte_keepalive {
 	/** Core Liveness. */
@@ -139,8 +140,10 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
-	if (id_core < RTE_KEEPALIVE_MAXCORES)
+	if (id_core < RTE_KEEPALIVE_MAXCORES) {
 		keepcfg->active_cores[id_core] = 1;
+		keepcfg->last_alive[id_core] = rte_rdtsc();
+	}
 }
 
 
-- 
2.5.0

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

* [dpdk-dev] [PATCH v4 3/3] keepalive: fix whitespace, removes double newlines
  2016-03-08 10:50     ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Harry van Haaren
  2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 1/3] doc: fix keepalive sample app guide Harry van Haaren
  2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 2/3] eal: add keepalive core register timestamp Harry van Haaren
@ 2016-03-08 10:50       ` Harry van Haaren
  2016-03-08 10:58       ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Thomas Monjalon
  3 siblings, 0 replies; 23+ messages in thread
From: Harry van Haaren @ 2016-03-08 10:50 UTC (permalink / raw)
  To: remy.horton; +Cc: dev

This patch removes double newlines between functions
in keepalive.[hc] aligning it with the rest of DPDK.
Fixes: 75583b0d1efd ("eal: add keep alive monitoring")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_eal/common/include/rte_keepalive.h | 7 -------
 lib/librte_eal/common/rte_keepalive.c         | 5 -----
 2 files changed, 12 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_keepalive.h b/lib/librte_eal/common/include/rte_keepalive.h
index f4cec04..10dac2e 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -48,7 +48,6 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif
 
-
 /**
  * Keepalive failure callback.
  *
@@ -59,14 +58,12 @@ typedef void (*rte_keepalive_failure_callback_t)(
 	void *data,
 	const int id_core);
 
-
 /**
  * Keepalive state structure.
  * @internal
  */
 struct rte_keepalive;
 
-
 /**
  * Initialise keepalive sub-system.
  * @param callback
@@ -80,7 +77,6 @@ struct rte_keepalive *rte_keepalive_create(
 	rte_keepalive_failure_callback_t callback,
 	void *data);
 
-
 /**
  * Checks & handles keepalive state of monitored cores.
  * @param *ptr_timer Triggering timer (unused)
@@ -88,7 +84,6 @@ struct rte_keepalive *rte_keepalive_create(
  */
 void rte_keepalive_dispatch_pings(void *ptr_timer, void *ptr_data);
 
-
 /**
  * Registers a core for keepalive checks.
  * @param *keepcfg
@@ -99,7 +94,6 @@ void rte_keepalive_dispatch_pings(void *ptr_timer, void *ptr_data);
 void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
 	const int id_core);
 
-
 /**
  * Per-core keepalive check.
  * @param *keepcfg
@@ -111,5 +105,4 @@ void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);
 
-
 #endif /* _KEEPALIVE_H_ */
diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index 56df0b1..23363ec 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -70,7 +70,6 @@ struct rte_keepalive {
 	uint64_t tsc_mhz;
 };
 
-
 static void
 print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
 {
@@ -81,7 +80,6 @@ print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
 	      );
 }
 
-
 void
 rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 	void *ptr_data)
@@ -117,7 +115,6 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 	}
 }
 
-
 struct rte_keepalive *
 rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 	void *data)
@@ -136,7 +133,6 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 	return keepcfg;
 }
 
-
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
@@ -146,7 +142,6 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 	}
 }
 
-
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
-- 
2.5.0

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

* Re: [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update
  2016-03-08 10:50     ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Harry van Haaren
                         ` (2 preceding siblings ...)
  2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 3/3] keepalive: fix whitespace, removes double newlines Harry van Haaren
@ 2016-03-08 10:58       ` Thomas Monjalon
  3 siblings, 0 replies; 23+ messages in thread
From: Thomas Monjalon @ 2016-03-08 10:58 UTC (permalink / raw)
  To: Harry van Haaren; +Cc: dev

2016-03-08 10:50, Harry van Haaren:
> This patchset adds a timestamp to when keepalive registers a core,
> fixes the documentation to be in-line with the source, and fixes
> whitespace in keepalive.[hc]
> 
> Harry van Haaren (3):
>   doc: fix keepalive sample app guide
>   eal: add keepalive core register timestamp
>   keepalive: fix whitespace, removes double newlines

Applied, thanks

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

end of thread, other threads:[~2016-03-08 11:00 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 15:53 [dpdk-dev] [PATCH 0/3] Keep-alive stats and doc fixes Harry van Haaren
2016-01-20 15:53 ` [dpdk-dev] [PATCH 1/3] doc: fix keepalive sample app guide Harry van Haaren
2016-01-20 15:53 ` [dpdk-dev] [PATCH 2/3] eal: add keepalive core register timestamp Harry van Haaren
2016-01-20 15:53 ` [dpdk-dev] [PATCH 3/3] keepalive: add rte_keepalive_xstats() and example Harry van Haaren
2016-01-21  9:57   ` Remy Horton
2016-01-21 11:05 ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Harry van Haaren
2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 1/3] doc: fix keepalive sample app guide Harry van Haaren
2016-02-19 17:28     ` Mcnamara, John
2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 2/3] eal: add keepalive core register timestamp Harry van Haaren
2016-01-21 11:05   ` [dpdk-dev] [PATCH v2 3/3] keepalive: add rte_keepalive_xstats_get() and example Harry van Haaren
2016-01-21 12:12   ` [dpdk-dev] [PATCH v2 0/3] Keep-alive stats and doc fixes Remy Horton
2016-02-22 11:25   ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function " Harry van Haaren
2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 1/3] doc: fix keepalive sample app guide Harry van Haaren
2016-02-22 16:54       ` Mcnamara, John
2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 2/3] eal: add keepalive core register timestamp Harry van Haaren
2016-02-22 11:26     ` [dpdk-dev] [PATCH v3 3/3] keepalive: add rte_keepalive_xstats_get() Harry van Haaren
2016-02-29  9:19       ` Thomas Monjalon
2016-02-22 13:12     ` [dpdk-dev] [PATCH v3 0/3] Keepalive stats function and doc fixes Remy Horton
2016-03-08 10:50     ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Harry van Haaren
2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 1/3] doc: fix keepalive sample app guide Harry van Haaren
2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 2/3] eal: add keepalive core register timestamp Harry van Haaren
2016-03-08 10:50       ` [dpdk-dev] [PATCH v4 3/3] keepalive: fix whitespace, removes double newlines Harry van Haaren
2016-03-08 10:58       ` [dpdk-dev] [PATCH v4 0/3] Keepalive register timestamp and doc update Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).