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_RX_MACHINE_H__
179cd2d7a5SSteven#define	__LACP_RX_MACHINE_H__
189cd2d7a5SSteven
199cd2d7a5SSteven#include <stdint.h>
209cd2d7a5SSteven#include <lacp/machine.h>
219cd2d7a5SSteven
229cd2d7a5SSteven#define foreach_lacp_rx_event          \
239cd2d7a5SSteven  _(0, BEGIN, "begin")                 \
249cd2d7a5SSteven  _(1, PORT_DISABLED, "port disabled") \
259cd2d7a5SSteven  _(2, PORT_MOVED, "port moved")       \
269cd2d7a5SSteven  _(3, LACP_ENABLED, "lacp enabled")   \
279cd2d7a5SSteven  _(4, LACP_DISABLED, "lacp disabled") \
289cd2d7a5SSteven  _(5, PDU_RECEIVED, "pdu received")   \
299cd2d7a5SSteven  _(6, TIMER_EXPIRED, "timer expired")
309cd2d7a5SSteven
319cd2d7a5SSteventypedef enum
329cd2d7a5SSteven{
339cd2d7a5SSteven#define _(a, b, c) LACP_RX_EVENT_##b = (a),
349cd2d7a5SSteven  foreach_lacp_rx_event
359cd2d7a5SSteven#undef _
369cd2d7a5SSteven} lacp_rx_event_t;
379cd2d7a5SSteven
389cd2d7a5SSteven#define foreach_lacp_rx_sm_state       \
399cd2d7a5SSteven  _(0, INITIALIZE, "initialize")       \
409cd2d7a5SSteven  _(1, PORT_DISABLED, "port disabled") \
419cd2d7a5SSteven  _(2, EXPIRED, "expired")             \
429cd2d7a5SSteven  _(3, LACP_DISABLED, "lacp disabled") \
439cd2d7a5SSteven  _(4, DEFAULTED, "defaulted")         \
449cd2d7a5SSteven  _(5, CURRENT, "current")
459cd2d7a5SSteven
469cd2d7a5SSteventypedef enum
479cd2d7a5SSteven{
489cd2d7a5SSteven#define _(a, b, c) LACP_RX_STATE_##b = (a),
499cd2d7a5SSteven  foreach_lacp_rx_sm_state
509cd2d7a5SSteven#undef _
519cd2d7a5SSteven} lacp_rx_sm_state_t;
529cd2d7a5SSteven
539cd2d7a5SStevenextern lacp_machine_t lacp_rx_machine;
549cd2d7a5SSteven
559cd2d7a5SStevenint lacp_rx_action_initialize (void *, void *);
569cd2d7a5SStevenint lacp_rx_action_port_disabled (void *, void *);
579cd2d7a5SStevenint lacp_rx_action_pdu_received (void *, void *);
589cd2d7a5SStevenint lacp_rx_action_expired (void *, void *);
599cd2d7a5SStevenint lacp_rx_action_lacp_disabled (void *, void *);
609cd2d7a5SStevenint lacp_rx_action_defaulted (void *, void *);
619cd2d7a5SStevenint lacp_rx_action_current (void *, void *);
629cd2d7a5SStevenvoid lacp_rx_debug_func (slave_if_t * sif, int event, int state,
639cd2d7a5SSteven			 lacp_fsm_state_t * transition);
649cd2d7a5SSteven
659cd2d7a5SSteven#define LACP_ACTION_INITIALIZE \
669cd2d7a5SSteven  LACP_ACTION_ROUTINE(lacp_rx_action_initialize)
679cd2d7a5SSteven#define LACP_ACTION_PORT_DISABLED \
689cd2d7a5SSteven  LACP_ACTION_ROUTINE(lacp_rx_action_port_disabled)
699cd2d7a5SSteven#define LACP_ACTION_EXPIRED \
709cd2d7a5SSteven  LACP_ACTION_ROUTINE(lacp_rx_action_expired)
719cd2d7a5SSteven#define LACP_ACTION_LACP_DISABLED \
729cd2d7a5SSteven  LACP_ACTION_ROUTINE(lacp_rx_action_lacp_disabled)
739cd2d7a5SSteven#define LACP_ACTION_DEFAULTED LACP_ACTION_ROUTINE(lacp_rx_action_defaulted)
749cd2d7a5SSteven#define LACP_ACTION_CURRENT LACP_ACTION_ROUTINE(lacp_rx_action_current)
759cd2d7a5SSteven
769cd2d7a5SStevenstatic inline void
779cd2d7a5SStevenlacp_start_current_while_timer (vlib_main_t * vm, slave_if_t * sif,
789cd2d7a5SSteven				u8 expiration)
799cd2d7a5SSteven{
809cd2d7a5SSteven  sif->current_while_timer = vlib_time_now (vm) + expiration;
819cd2d7a5SSteven}
829cd2d7a5SSteven
839cd2d7a5SSteven#endif /* __LACP_RX_MACHINE_H__ */
849cd2d7a5SSteven
859cd2d7a5SSteven/*
869cd2d7a5SSteven * fd.io coding-style-patch-verification: ON
879cd2d7a5SSteven *
889cd2d7a5SSteven * Local Variables:
899cd2d7a5SSteven * eval: (c-set-style "gnu")
909cd2d7a5SSteven * End:
919cd2d7a5SSteven */
92