aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/handoff.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-07-20 18:47:05 +0200
committerDamjan Marion <damarion@cisco.com>2018-07-20 19:43:36 +0200
commit78fd7e810c24b9d638ac7c7f08edabf692543743 (patch)
treec676d0f4bc9a7471fd5c60cb02fb995868fa65d6 /src/vnet/handoff.c
parent508498f74d2df98e70a961d030cf0128a63a926d (diff)
Add congestion drop in interface handoff
This prevents deadlock in case when worker A sends to B and worker B sends to A Change-Id: Id9436960f932c58325fe4f5ef8ec67b50031aeda Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/handoff.c')
-rw-r--r--src/vnet/handoff.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/vnet/handoff.c b/src/vnet/handoff.c
index 11b877e500d..4e635e5d1b0 100644
--- a/src/vnet/handoff.c
+++ b/src/vnet/handoff.c
@@ -49,6 +49,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)
@@ -71,7 +88,7 @@ worker_handoff_node_fn (vlib_main_t * vm,
{
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);
@@ -130,8 +147,13 @@ 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;
}
@@ -142,6 +164,8 @@ VLIB_REGISTER_NODE (worker_handoff_node) = {
.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 = {