A couple of minor comments inline. -Antonio
> -----Original Message----- > From: [email protected] [mailto:[email protected]] > On Behalf Of Bhanuprakash Bodireddy > Sent: Friday, September 15, 2017 5:40 PM > To: [email protected] > Subject: [ovs-dev] [PATCH v5 05/10] dpif-netdev: Enable heartbeats for DPDK > datapath. > > This commit adds heartbeat mechanism support for DPDK datapath. Heartbeats > are sent to registered PMD threads at predefined intervals (as set in ovsdb > with 'keepalive-interval'). > > The heartbeats are only enabled when there is atleast one port added to > the bridge and with active PMD thread polling the port. > > Signed-off-by: Bhanuprakash Bodireddy <[email protected]> > --- > lib/dpif-netdev.c | 15 +++++++++++++-- > lib/keepalive.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > lib/keepalive.h | 1 + > 3 files changed, 58 insertions(+), 2 deletions(-) > > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c > index da419d5..fd0ce61 100644 > --- a/lib/dpif-netdev.c > +++ b/lib/dpif-netdev.c > @@ -1021,14 +1021,25 @@ sorted_poll_thread_list(struct dp_netdev *dp, > } > > static void * > -ovs_keepalive(void *f_ OVS_UNUSED) > +ovs_keepalive(void *f_) > { > + struct dp_netdev *dp = f_; > + > pthread_detach(pthread_self()); > > for (;;) { > - int interval; > + int interval, n_pmds; > + bool hb_enable; > > interval = get_ka_interval(); > + n_pmds = cmap_count(&dp->poll_threads) - 1; > + hb_enable = (n_pmds > 0) ? true : false; > + > + /* Dispatch heartbeats only if pmd[s] exist. */ > + if (hb_enable) { > + dispatch_heartbeats(); > + } > + > xnanosleep(interval); > } > > diff --git a/lib/keepalive.c b/lib/keepalive.c > index da4defd..3067e73 100644 > --- a/lib/keepalive.c > +++ b/lib/keepalive.c > @@ -284,6 +284,50 @@ ka_mark_pmd_thread_sleep(int tid) > } > } > > +/* Dispatch heartbeats from 'ovs_keepalive' thread. */ > +void > +dispatch_heartbeats(void) > +{ [Antonio] I'd rather call this function ka_state_update() or similar? > + struct ka_process_info *pinfo, *pinfo_next; > + > + /* Iterates over the list of processes in 'cached_process_list' map. */ > + HMAP_FOR_EACH_SAFE (pinfo, pinfo_next, node, > + &ka_info.cached_process_list) { > + if (pinfo->state == KA_STATE_UNUSED) { > + continue; > + } > + > + switch (pinfo->state) { > + case KA_STATE_UNUSED: [Antonio] this case statement could be removed as already managed above. > + break; > + case KA_STATE_ALIVE: > + pinfo->state = KA_STATE_MISSING; > + pinfo->last_seen_time = time_wall_msec(); > + break; > + case KA_STATE_MISSING: > + pinfo->state = KA_STATE_DEAD; > + break; > + case KA_STATE_DEAD: > + pinfo->state = KA_STATE_GONE; > + break; > + case KA_STATE_GONE: > + break; > + case KA_STATE_DOZING: > + pinfo->state = KA_STATE_SLEEP; > + pinfo->last_seen_time = time_wall_msec(); > + break; > + case KA_STATE_SLEEP: > + break; > + default: > + OVS_NOT_REACHED(); > + } > + > + /* Invoke 'ka_update_thread_state' cb function to update state info > + * in to 'ka_info.process_list' map. */ > + ka_info.relay_cb(pinfo->tid, pinfo->state, pinfo->last_seen_time); > + } > +} > + > void > ka_init(const struct smap *ovs_other_config) > { > diff --git a/lib/keepalive.h b/lib/keepalive.h > index 9e8bfdf..392a701 100644 > --- a/lib/keepalive.h > +++ b/lib/keepalive.h > @@ -102,6 +102,7 @@ void ka_free_cached_threads(void); > void ka_cache_registered_threads(void); > void ka_mark_pmd_thread_alive(int); > void ka_mark_pmd_thread_sleep(int); > +void dispatch_heartbeats(void); > void ka_init(const struct smap *); > void ka_destroy(void); > > -- > 2.4.11 > > _______________________________________________ > dev mailing list > [email protected] > https://mail.openvswitch.org/mailman/listinfo/ovs-dev _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
