diff mbox series

[ovs-dev,v6,5/8] bridge: Update keepalive status in OVSDB.

Message ID 1512734667-23202-6-git-send-email-bhanuprakash.bodireddy@intel.com
State Changes Requested
Headers show
Series Add OVS DPDK keep-alive functionality. | expand

Commit Message

Bodireddy, Bhanuprakash Dec. 8, 2017, 12:04 p.m. UTC
This commit allows vswitchd thread to update the OVSDB with the
status of all registered PMD threads. The status can be monitored
using ovsdb-client and the sample output is below.

$ ovsdb-client monitor Open_vSwitch Open_vSwitch keepalive

    row                            action keepalive
7b746190-ee71-4dcc-becf-f8cb9c7cb909 old  {
"pmd62"="ALIVE,0,9226457935188922"
                                            "pmd63"="ALIVE,1,1503333678618"
                                            "pmd64"="ALIVE,2,1503333678618"
                                            "pmd65"="ALIVE,3,1503333678618"}

                                     new  {
"pmd62"="ALIVE,0,9226460230167364"
                                            "pmd63"="ALIVE,1,1503333679619"
                                            "pmd64"="ALIVE,2,1503333679619"
                                            "pmd65"="ALIVE,3,1503333679619""}

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
---
 lib/keepalive.c   | 15 +++++++++++++++
 lib/keepalive.h   |  1 +
 vswitchd/bridge.c | 26 ++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)

Comments

Fischetti, Antonio Dec. 15, 2017, 2:24 p.m. UTC | #1
LGTM,

Tested-by: Antonio Fischetti <antonio.fischetti@intel.com>
Acked-by: Antonio Fischetti <antonio.fischetti@intel.com>


> -----Original Message-----
> From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-
> bounces@openvswitch.org] On Behalf Of Bhanuprakash Bodireddy
> Sent: Friday, December 8, 2017 12:04 PM
> To: dev@openvswitch.org
> Subject: [ovs-dev] [PATCH v6 5/8] bridge: Update keepalive status in
> OVSDB.
> 
> This commit allows vswitchd thread to update the OVSDB with the
> status of all registered PMD threads. The status can be monitored
> using ovsdb-client and the sample output is below.
> 
> $ ovsdb-client monitor Open_vSwitch Open_vSwitch keepalive
> 
>     row                            action keepalive
> 7b746190-ee71-4dcc-becf-f8cb9c7cb909 old  {
> "pmd62"="ALIVE,0,9226457935188922"
> 
> "pmd63"="ALIVE,1,1503333678618"
> 
> "pmd64"="ALIVE,2,1503333678618"
> 
> "pmd65"="ALIVE,3,1503333678618"}
> 
>                                      new  {
> "pmd62"="ALIVE,0,9226460230167364"
> 
> "pmd63"="ALIVE,1,1503333679619"
> 
> "pmd64"="ALIVE,2,1503333679619"
> 
> "pmd65"="ALIVE,3,1503333679619""}
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
> ---
>  lib/keepalive.c   | 15 +++++++++++++++
>  lib/keepalive.h   |  1 +
>  vswitchd/bridge.c | 26 ++++++++++++++++++++++++++
>  3 files changed, 42 insertions(+)
> 
> diff --git a/lib/keepalive.c b/lib/keepalive.c
> index 7d3dbad..14ac093 100644
> --- a/lib/keepalive.c
> +++ b/lib/keepalive.c
> @@ -347,6 +347,21 @@ get_ka_stats(void)
>      ovs_mutex_unlock(&mutex);
>  }
> 
> +struct smap *
> +ka_stats_run(void)
> +{
> +    struct smap *ka_stats = NULL;
> +
> +    ovs_mutex_lock(&mutex);
> +    if (keepalive_stats) {
> +        ka_stats = keepalive_stats;
> +        keepalive_stats = NULL;
> +    }
> +    ovs_mutex_unlock(&mutex);
> +
> +    return ka_stats;
> +}
> +
>  /* Dispatch heartbeats from 'ovs_keepalive' thread. */
>  void
>  dispatch_heartbeats(void)
> diff --git a/lib/keepalive.h b/lib/keepalive.h
> index 2bae8f1..e84646a 100644
> --- a/lib/keepalive.h
> +++ b/lib/keepalive.h
> @@ -101,6 +101,7 @@ void ka_cache_registered_threads(void);
>  void ka_mark_pmd_thread_alive(int);
>  void ka_mark_pmd_thread_sleep(int);
>  void get_ka_stats(void);
> +struct smap *ka_stats_run(void);
>  void dispatch_heartbeats(void);
>  void ka_init(const struct smap *);
>  void ka_destroy(void);
> diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
> index f70407f..55c925e 100644
> --- a/vswitchd/bridge.c
> +++ b/vswitchd/bridge.c
> @@ -286,6 +286,7 @@ static bool port_is_synthetic(const struct port *);
> 
>  static void reconfigure_system_stats(const struct ovsrec_open_vswitch
> *);
>  static void run_system_stats(void);
> +static void run_keepalive_stats(void);
> 
>  static void bridge_configure_mirrors(struct bridge *);
>  static struct mirror *mirror_create(struct bridge *,
> @@ -403,6 +404,7 @@ bridge_init(const char *remote)
> 
>      ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_cur_cfg);
>      ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_statistics);
> +    ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_keepalive);
>      ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_datapath_types);
>      ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_iface_types);
>      ovsdb_idl_omit(idl, &ovsrec_open_vswitch_col_external_ids);
> @@ -2686,6 +2688,29 @@ run_system_stats(void)
>      }
>  }
> 
> +void
> +run_keepalive_stats(void)
> +{
> +    struct smap *ka_stats;
> +    const struct ovsrec_open_vswitch *cfg =
> ovsrec_open_vswitch_first(idl);
> +
> +    ka_stats = ka_stats_run();
> +    if (ka_stats && cfg) {
> +        struct ovsdb_idl_txn *txn;
> +        struct ovsdb_datum datum;
> +
> +        txn = ovsdb_idl_txn_create(idl);
> +        ovsdb_datum_from_smap(&datum, ka_stats);
> +        smap_destroy(ka_stats);
> +        ovsdb_idl_txn_write(&cfg->header_,
> &ovsrec_open_vswitch_col_keepalive,
> +                            &datum);
> +        ovsdb_idl_txn_commit(txn);
> +        ovsdb_idl_txn_destroy(txn);
> +
> +        free(ka_stats);
> +    }
> +}
> +
>  static const char *
>  ofp12_controller_role_to_str(enum ofp12_controller_role role)
>  {
> @@ -3039,6 +3064,7 @@ bridge_run(void)
>      run_stats_update();
>      run_status_update();
>      run_system_stats();
> +    run_keepalive_stats();
>  }
> 
>  void
> --
> 2.4.11
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

diff --git a/lib/keepalive.c b/lib/keepalive.c
index 7d3dbad..14ac093 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -347,6 +347,21 @@  get_ka_stats(void)
     ovs_mutex_unlock(&mutex);
 }
 
+struct smap *
+ka_stats_run(void)
+{
+    struct smap *ka_stats = NULL;
+
+    ovs_mutex_lock(&mutex);
+    if (keepalive_stats) {
+        ka_stats = keepalive_stats;
+        keepalive_stats = NULL;
+    }
+    ovs_mutex_unlock(&mutex);
+
+    return ka_stats;
+}
+
 /* Dispatch heartbeats from 'ovs_keepalive' thread. */
 void
 dispatch_heartbeats(void)
diff --git a/lib/keepalive.h b/lib/keepalive.h
index 2bae8f1..e84646a 100644
--- a/lib/keepalive.h
+++ b/lib/keepalive.h
@@ -101,6 +101,7 @@  void ka_cache_registered_threads(void);
 void ka_mark_pmd_thread_alive(int);
 void ka_mark_pmd_thread_sleep(int);
 void get_ka_stats(void);
+struct smap *ka_stats_run(void);
 void dispatch_heartbeats(void);
 void ka_init(const struct smap *);
 void ka_destroy(void);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index f70407f..55c925e 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -286,6 +286,7 @@  static bool port_is_synthetic(const struct port *);
 
 static void reconfigure_system_stats(const struct ovsrec_open_vswitch *);
 static void run_system_stats(void);
+static void run_keepalive_stats(void);
 
 static void bridge_configure_mirrors(struct bridge *);
 static struct mirror *mirror_create(struct bridge *,
@@ -403,6 +404,7 @@  bridge_init(const char *remote)
 
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_cur_cfg);
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_statistics);
+    ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_keepalive);
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_datapath_types);
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_iface_types);
     ovsdb_idl_omit(idl, &ovsrec_open_vswitch_col_external_ids);
@@ -2686,6 +2688,29 @@  run_system_stats(void)
     }
 }
 
+void
+run_keepalive_stats(void)
+{
+    struct smap *ka_stats;
+    const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(idl);
+
+    ka_stats = ka_stats_run();
+    if (ka_stats && cfg) {
+        struct ovsdb_idl_txn *txn;
+        struct ovsdb_datum datum;
+
+        txn = ovsdb_idl_txn_create(idl);
+        ovsdb_datum_from_smap(&datum, ka_stats);
+        smap_destroy(ka_stats);
+        ovsdb_idl_txn_write(&cfg->header_, &ovsrec_open_vswitch_col_keepalive,
+                            &datum);
+        ovsdb_idl_txn_commit(txn);
+        ovsdb_idl_txn_destroy(txn);
+
+        free(ka_stats);
+    }
+}
+
 static const char *
 ofp12_controller_role_to_str(enum ofp12_controller_role role)
 {
@@ -3039,6 +3064,7 @@  bridge_run(void)
     run_stats_update();
     run_status_update();
     run_system_stats();
+    run_keepalive_stats();
 }
 
 void