{.str = NULL}
};
-static vlib_node_registration_t lacp_process_node;
-
/** \file
2 x LACP graph nodes: an "interior" node to process
{
u32 n_left_from, *from;
lacp_input_trace_t *t0;
- uword n_trace = vlib_get_trace_count (vm, node);
from = vlib_frame_vector_args (frame); /* array of buffer indices */
n_left_from = frame->n_vectors; /* number of buffer indices */
b0->error = node->errors[error0];
/* If this pkt is traced, snapshoot the data */
- if (PREDICT_FALSE (n_trace > 0))
+ if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
{
int len;
- vlib_trace_buffer (vm, node, next0, b0,
- /* follow_chain */ 0);
- vlib_set_trace_count (vm, node, --n_trace);
+
t0 = vlib_add_trace (vm, node, b0, sizeof (*t0));
len = (b0->current_length < sizeof (t0->pkt))
? b0->current_length : sizeof (t0->pkt);
t0->len = len;
t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
- clib_memcpy (&t0->pkt, vlib_buffer_get_current (b0), len);
+ clib_memcpy_fast (&t0->pkt, vlib_buffer_get_current (b0), len);
}
/* push this pkt to the next graph node, always error-drop */
vlib_set_next_frame_buffer (vm, node, next0, bi0);
};
/* *INDENT-ON* */
+static void
+lacp_elog_start_event (void)
+{
+ lacp_main_t *lm = &lacp_main;
+ /* *INDENT-OFF* */
+ ELOG_TYPE_DECLARE (e) =
+ {
+ .format = "Starting LACP process, interface count = %d",
+ .format_args = "i4",
+ };
+ /* *INDENT-ON* */
+ struct
+ {
+ u32 count;
+ } *ed;
+
+ ed = ELOG_DATA (&vlib_global_main.elog_main, e);
+ ed->count = lm->lacp_int;
+}
+
+static void
+lacp_elog_stop_event (void)
+{
+ lacp_main_t *lm = &lacp_main;
+ /* *INDENT-OFF* */
+ ELOG_TYPE_DECLARE (e) =
+ {
+ .format = "Stopping LACP process, interface count = %d",
+ .format_args = "i4",
+ };
+ /* *INDENT-ON* */
+ struct
+ {
+ u32 count;
+ } *ed;
+
+ ed = ELOG_DATA (&vlib_global_main.elog_main, e);
+ ed->count = lm->lacp_int;
+}
+
/*
* lacp periodic function
*/
lacp_main_t *lm = &lacp_main;
f64 poll_time_remaining;
uword event_type, *event_data = 0;
- u8 enabled = 0;
-
- /* So we can send events to the lacp process */
- lm->lacp_process_node_index = lacp_process_node.index;
ethernet_register_input_type (vm, ETHERNET_TYPE_SLOW_PROTOCOLS /* LACP */ ,
lacp_input_node.index);
poll_time_remaining = 0.2;
while (1)
{
- if (enabled)
+ if (lm->lacp_int > 0)
poll_time_remaining =
vlib_process_wait_for_event_or_clock (vm, poll_time_remaining);
else
case ~0: /* no events => timeout */
break;
case LACP_PROCESS_EVENT_START:
- enabled = 1;
+ poll_time_remaining = 0.2;
+ lacp_elog_start_event ();
break;
case LACP_PROCESS_EVENT_STOP:
- enabled = 0;
- continue;
+ if (lm->lacp_int == 0)
+ {
+ poll_time_remaining = SECS_IN_A_DAY;
+ lacp_elog_stop_event ();
+ }
+ break;
default:
clib_warning ("BUG: event type 0x%wx", event_type);
break;
}
- if (event_data)
- _vec_len (event_data) = 0;
+ vec_reset_length (event_data);
if (vlib_process_suspend_time_is_zero (poll_time_remaining))
{
return 0;
}
-/*
- * lacp periodic node declaration
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (lacp_process_node, static) = {
- .function = lacp_process,
- .type = VLIB_NODE_TYPE_PROCESS,
- .name = "lacp-process",
-};
-/* *INDENT-ON* */
+void
+lacp_create_periodic_process (void)
+{
+ lacp_main_t *lm = &lacp_main;
+
+ /* Already created the process node? */
+ if (lm->lacp_process_node_index > 0)
+ return;
+
+ /* No, create it now and make a note of the node index */
+ lm->lacp_process_node_index =
+ vlib_process_create (lm->vlib_main, "lacp-process", lacp_process,
+ 16 /* log2_n_stack_bytes */ );
+}
/*
* fd.io coding-style-patch-verification: ON