u64 (*hash_fn) (ethernet_header_t *);
} handoff_main_t;
+extern handoff_main_t handoff_main;
+
+#ifndef CLIB_MARCH_VARIANT
handoff_main_t handoff_main;
+#endif /* CLIB_MARCH_VARIANT */
typedef struct
{
u32 buffer_index;
} worker_handoff_trace_t;
+#define foreach_worker_handoff_error \
+ _(CONGESTION_DROP, "congestion drop")
+
+typedef enum
+{
+#define _(sym,str) WORKER_HANDOFF_ERROR_##sym,
+ foreach_worker_handoff_error
+#undef _
+ WORKER_HANDOFF_N_ERROR,
+} worker_handoff_error_t;
+
+static char *worker_handoff_error_strings[] = {
+#define _(sym,string) string,
+ foreach_worker_handoff_error
+#undef _
+};
+
/* packet trace format function */
static u8 *
format_worker_handoff_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t handoff_node;
-
-static uword
-worker_handoff_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (worker_handoff_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
handoff_main_t *hm = &handoff_main;
vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
- u32 n_left_from, *from;
+ u32 n_enq, n_left_from, *from;
u16 thread_indices[VLIB_FRAME_SIZE], *ti;
from = vlib_frame_vector_args (frame);
hash = (u32) clib_xxhash (hash_key);
/* if input node did not specify next index, then packet
- should go to eternet-input */
+ should go to ethernet-input */
if (PREDICT_TRUE (is_pow2 (vec_len (ihd0->workers))))
index0 = hash & (vec_len (ihd0->workers) - 1);
b += 1;
}
- vlib_buffer_enqueue_to_thread (vm, hm->frame_queue_index, from,
- thread_indices, frame->n_vectors);
+ n_enq = vlib_buffer_enqueue_to_thread (vm, hm->frame_queue_index, from,
+ thread_indices, frame->n_vectors, 1);
+
+ if (n_enq < frame->n_vectors)
+ vlib_node_increment_counter (vm, node->node_index,
+ WORKER_HANDOFF_ERROR_CONGESTION_DROP,
+ frame->n_vectors - n_enq);
return frame->n_vectors;
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (worker_handoff_node) = {
- .function = worker_handoff_node_fn,
.name = "worker-handoff",
.vector_size = sizeof (u32),
.format_trace = format_worker_handoff_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(worker_handoff_error_strings),
+ .error_strings = worker_handoff_error_strings,
.n_next_nodes = 1,
.next_nodes = {
},
};
-VLIB_NODE_FUNCTION_MULTIARCH (worker_handoff_node, worker_handoff_node_fn)
/* *INDENT-ON* */
+#ifndef CLIB_MARCH_VARIANT
int
interface_handoff_enable_disable (vlib_main_t * vm, u32 sw_if_index,
uword * bitmap, int enable_disable)
VLIB_INIT_FUNCTION (handoff_init);
+#endif /* CLIB_MARCH_VARIANT */
/*
* fd.io coding-style-patch-verification: ON
*