X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fhandoff.c;h=ca46b5a7ab61b79e582a17e4d343f04b30f0094c;hb=f539578bac8b64886b57c460c9d74273e6613f8b;hp=11b877e500d4cf0a07a12cd92fc3072260c45a35;hpb=4d56e059f78b991cb19ec4e5cf4a07a5607a0642;p=vpp.git diff --git a/src/vnet/handoff.c b/src/vnet/handoff.c index 11b877e500d..ca46b5a7ab6 100644 --- a/src/vnet/handoff.c +++ b/src/vnet/handoff.c @@ -40,7 +40,11 @@ typedef struct 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 { @@ -49,6 +53,23 @@ 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) @@ -63,15 +84,13 @@ 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); @@ -105,7 +124,7 @@ worker_handoff_node_fn (vlib_main_t * vm, 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); @@ -130,18 +149,24 @@ worker_handoff_node_fn (vlib_main_t * vm, 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 = { @@ -149,9 +174,9 @@ VLIB_REGISTER_NODE (worker_handoff_node) = { }, }; -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) @@ -311,6 +336,7 @@ handoff_init (vlib_main_t * vm) VLIB_INIT_FUNCTION (handoff_init); +#endif /* CLIB_MARCH_VARIANT */ /* * fd.io coding-style-patch-verification: ON *