X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Flacp%2Fptx_machine.h;h=7b8fc535da8fb9eadf95f6738bc1240fb595d172;hb=4c4223edf;hp=a9af4bb89d3a91230af8f3f03dd45f1ef607410d;hpb=9cd2d7a5a4fafadb65d772c48109d55d1e19d425;p=vpp.git diff --git a/src/plugins/lacp/ptx_machine.h b/src/plugins/lacp/ptx_machine.h index a9af4bb89d3..7b8fc535da8 100644 --- a/src/plugins/lacp/ptx_machine.h +++ b/src/plugins/lacp/ptx_machine.h @@ -20,7 +20,7 @@ #include #define foreach_lacp_ptx_event \ - _(0, BEGIN, "begin") \ + _(0, NO_PERIODIC, "no periodic") \ _(1, LONG_TIMEOUT, "long tiemout") \ _(2, TIMER_EXPIRED, "timer expired") \ _(3, SHORT_TIMEOUT, "short timeout") @@ -51,7 +51,7 @@ int lacp_ptx_action_no_periodic (void *p1, void *p2); int lacp_ptx_action_slow_periodic (void *p1, void *p2); int lacp_ptx_action_fast_periodic (void *p1, void *p2); int lacp_ptx_action_timer_expired (void *p1, void *p2); -void lacp_ptx_debug_func (slave_if_t * sif, int event, int state, +void lacp_ptx_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition); #define LACP_ACTION_NO_PERIODIC \ @@ -64,9 +64,36 @@ void lacp_ptx_debug_func (slave_if_t * sif, int event, int state, LACP_ACTION_ROUTINE(lacp_ptx_action_timer_expired) static inline void -lacp_start_periodic_timer (vlib_main_t * vm, slave_if_t * sif, u8 expiration) +lacp_start_periodic_timer (vlib_main_t * vm, member_if_t * mif, u8 expiration) +{ + mif->periodic_timer = vlib_time_now (vm) + expiration; +} + +static inline void +lacp_schedule_periodic_timer (vlib_main_t * vm, member_if_t * mif) +{ + // do fast rate if partner is in short timeout or + // we are not yet synchronized + if ((mif->partner.state & LACP_STATE_LACP_TIMEOUT) || + (((mif->actor.state & (LACP_STATE_SYNCHRONIZATION | + LACP_STATE_COLLECTING | + LACP_STATE_DISTRIBUTING)) != + (LACP_STATE_SYNCHRONIZATION | LACP_STATE_COLLECTING | + LACP_STATE_DISTRIBUTING)) + && (mif->partner.state & LACP_STATE_AGGREGATION))) + lacp_start_periodic_timer (vm, mif, LACP_FAST_PERIODIC_TIMER); + else + lacp_start_periodic_timer (vm, mif, LACP_SLOW_PERIODIC_TIMER); +} + +static inline void +lacp_ptx_post_short_timeout_event (vlib_main_t * vm, member_if_t * mif) { - sif->periodic_timer = vlib_time_now (vm) + expiration; + if (mif->lacp_enabled && mif->port_enabled && + ((mif->partner.state & LACP_STATE_LACP_ACTIVITY) || + (mif->actor.state & LACP_STATE_LACP_ACTIVITY))) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_SHORT_TIMEOUT, &mif->ptx_state); } #endif /* __LACP_PTX_MACHINE_H__ */