2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
18 #include <vnet/bonding/node.h>
19 #include <lacp/node.h>
22 * LACP State = TRANSMIT
24 static lacp_fsm_state_t lacp_tx_state_transmit[] = {
25 {LACP_ACTION_TRANSMIT, LACP_TX_STATE_TRANSMIT}, // event 0 BEGIN
26 {LACP_ACTION_TRANSMIT, LACP_TX_STATE_TRANSMIT}, // event 1 NTT
29 static lacp_fsm_machine_t lacp_tx_fsm_table[] = {
30 {lacp_tx_state_transmit},
33 lacp_machine_t lacp_tx_machine = {
39 lacp_tx_action_transmit (void *p1, void *p2)
43 f64 now = vlib_time_now (vm);
45 if (!lacp_timer_is_running (sif->periodic_timer))
48 // No more than 3 LACPDUs per fast interval
49 if (now <= (sif->last_lacpdu_sent_time + 0.333))
54 lacp_send_lacp_pdu (vm, sif);
55 lacp_schedule_periodic_timer (vm, sif);
63 format_tx_event (u8 * s, va_list * args)
65 static lacp_event_struct lacp_tx_event_array[] = {
66 #define _(b, s, n) {.bit = b, .str = #s, },
71 int e = va_arg (*args, int);
72 lacp_event_struct *event_entry = lacp_tx_event_array;
74 if (e >= (sizeof (lacp_tx_event_array) / sizeof (*event_entry)))
75 s = format (s, "Bad event %d", e);
77 s = format (s, "%s", event_entry[e].str);
83 lacp_tx_debug_func (slave_if_t * sif, int event, int state,
84 lacp_fsm_state_t * transition)
86 vlib_worker_thread_t *w = vlib_worker_threads + os_get_thread_index ();
88 ELOG_TYPE_DECLARE (e) =
99 ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track);
100 ed->event = elog_string (&vlib_global_main.elog_main, "%U-TX: %U, %U->%U%c",
101 format_vnet_sw_if_index_name, vnet_get_main (),
102 sif->sw_if_index, format_tx_event, event,
103 format_tx_sm_state, state, format_tx_sm_state,
104 transition->next_state, 0);
108 lacp_init_tx_machine (vlib_main_t * vm, slave_if_t * sif)
110 lacp_machine_dispatch (&lacp_tx_machine, vm, sif, LACP_TX_EVENT_BEGIN,
115 * fd.io coding-style-patch-verification: ON
118 * eval: (c-set-style "gnu")