19cd2d7a5SSteven/*
29cd2d7a5SSteven * Copyright (c) 2017 Cisco and/or its affiliates.
39cd2d7a5SSteven * Licensed under the Apache License, Version 2.0 (the "License");
49cd2d7a5SSteven * you may not use this file except in compliance with the License.
59cd2d7a5SSteven * You may obtain a copy of the License at:
69cd2d7a5SSteven *
79cd2d7a5SSteven *     http://www.apache.org/licenses/LICENSE-2.0
89cd2d7a5SSteven *
99cd2d7a5SSteven * Unless required by applicable law or agreed to in writing, software
109cd2d7a5SSteven * distributed under the License is distributed on an "AS IS" BASIS,
119cd2d7a5SSteven * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129cd2d7a5SSteven * See the License for the specific language governing permissions and
139cd2d7a5SSteven * limitations under the License.
149cd2d7a5SSteven */
159cd2d7a5SSteven
169cd2d7a5SSteven#ifndef	__LACP_MUX_MACHINE_H__
179cd2d7a5SSteven#define	__LACP_MUX_MACHINE_H__
189cd2d7a5SSteven
199cd2d7a5SSteven#include <stdint.h>
209cd2d7a5SSteven#include <lacp/machine.h>
219cd2d7a5SSteven
229cd2d7a5SSteven#define foreach_lacp_mux_event          \
239cd2d7a5SSteven  _(0, BEGIN, "begin")                  \
249cd2d7a5SSteven  _(1, SELECTED, "selected")            \
259cd2d7a5SSteven  _(2, STANDBY, "standby")              \
269cd2d7a5SSteven  _(3, UNSELECTED, "unselected")        \
279cd2d7a5SSteven  _(4, READY, "ready")                  \
289cd2d7a5SSteven  _(5, SYNC, "sync")
299cd2d7a5SSteven
309cd2d7a5SSteventypedef enum
319cd2d7a5SSteven{
329cd2d7a5SSteven#define _(a, b, c) LACP_MUX_EVENT_##b = (a),
339cd2d7a5SSteven  foreach_lacp_mux_event
349cd2d7a5SSteven#undef _
359cd2d7a5SSteven} lacp_mux_event_t;
369cd2d7a5SSteven
379cd2d7a5SSteven#define foreach_lacp_mux_sm_state       \
389cd2d7a5SSteven  _(0, DETACHED, "detached")            \
399cd2d7a5SSteven  _(1, WAITING, "waiting")              \
409cd2d7a5SSteven  _(2, ATTACHED, "attached")            \
419cd2d7a5SSteven  _(3, COLLECTING_DISTRIBUTING, "collecting distributing")
429cd2d7a5SSteven
439cd2d7a5SSteventypedef enum
449cd2d7a5SSteven{
459cd2d7a5SSteven#define _(a, b, c) LACP_MUX_STATE_##b = (a),
469cd2d7a5SSteven  foreach_lacp_mux_sm_state
479cd2d7a5SSteven#undef _
489cd2d7a5SSteven} lacp_mux_sm_state_t;
499cd2d7a5SSteven
509cd2d7a5SStevenextern lacp_machine_t lacp_mux_machine;
519cd2d7a5SSteven
529cd2d7a5SStevenint lacp_mux_action_detached (void *p1, void *p2);
539cd2d7a5SStevenint lacp_mux_action_attached (void *p1, void *p2);
549cd2d7a5SStevenint lacp_mux_action_waiting (void *p1, void *p2);
559cd2d7a5SStevenint lacp_mux_action_collecting_distributing (void *p1, void *p2);
569cd2d7a5SStevenvoid lacp_mux_debug_func (slave_if_t * sif, int event, int state,
579cd2d7a5SSteven			  lacp_fsm_state_t * transition);
589cd2d7a5SSteven
599cd2d7a5SSteven#define LACP_ACTION_DETACHED LACP_ACTION_ROUTINE(lacp_mux_action_detached)
609cd2d7a5SSteven#define LACP_ACTION_ATTACHED LACP_ACTION_ROUTINE(lacp_mux_action_attached)
619cd2d7a5SSteven#define LACP_ACTION_WAITING LACP_ACTION_ROUTINE(lacp_mux_action_waiting)
629cd2d7a5SSteven#define LACP_ACTION_COLLECTING_DISTRIBUTING \
639cd2d7a5SSteven  LACP_ACTION_ROUTINE(lacp_mux_action_collecting_distributing)
649cd2d7a5SSteven
659cd2d7a5SStevenstatic inline void
669cd2d7a5SStevenlacp_start_wait_while_timer (vlib_main_t * vm, slave_if_t * sif,
679cd2d7a5SSteven			     u8 expiration)
689cd2d7a5SSteven{
699cd2d7a5SSteven  sif->wait_while_timer = vlib_time_now (vm) + expiration;
709cd2d7a5SSteven}
719cd2d7a5SSteven
729cd2d7a5SSteven#endif /* __LACP_MUX_MACHINE_H__ */
739cd2d7a5SSteven
749cd2d7a5SSteven/*
759cd2d7a5SSteven * fd.io coding-style-patch-verification: ON
769cd2d7a5SSteven *
779cd2d7a5SSteven * Local Variables:
789cd2d7a5SSteven * eval: (c-set-style "gnu")
799cd2d7a5SSteven * End:
809cd2d7a5SSteven */
81