summaryrefslogtreecommitdiffstats
path: root/src/vlib/threads.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-05-01 14:56:13 +0200
committerDamjan Marion <dmarion@me.com>2021-05-03 11:09:38 +0000
commiteee099e9579083fbce665e8c4a3617b9f0e5ea2f (patch)
tree300190f1778c296fa4f3ec98ce4b9b0692053a1f /src/vlib/threads.c
parent757f470aefea09fda41df9cfa713ed16a9b67452 (diff)
vlib: multiarch vlib_frame_queue_dequeue()
Fact that it needs to copy buffer indices justifies this move. Type: improvement Change-Id: I5eb815ccc4cca0ef70b092eb83a49b713efdcbeb Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/threads.c')
-rw-r--r--src/vlib/threads.c139
1 files changed, 0 insertions, 139 deletions
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 11d5a7220ad..c65460e3234 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -1644,145 +1644,6 @@ vlib_worker_wait_one_loop (void)
return;
}
-/*
- * Check the frame queue to see if any frames are available.
- * If so, pull the packets off the frames and put them to
- * the handoff node.
- */
-int
-vlib_frame_queue_dequeue (vlib_main_t * vm, vlib_frame_queue_main_t * fqm)
-{
- u32 thread_id = vm->thread_index;
- vlib_frame_queue_t *fq = fqm->vlib_frame_queues[thread_id];
- vlib_frame_queue_elt_t *elt;
- u32 *from, *to;
- vlib_frame_t *f;
- int msg_type;
- int processed = 0;
- u32 n_left_to_node;
- u32 vectors = 0;
-
- ASSERT (fq);
- ASSERT (vm == vlib_global_main.vlib_mains[thread_id]);
-
- if (PREDICT_FALSE (fqm->node_index == ~0))
- return 0;
- /*
- * Gather trace data for frame queues
- */
- if (PREDICT_FALSE (fq->trace))
- {
- frame_queue_trace_t *fqt;
- frame_queue_nelt_counter_t *fqh;
- u32 elix;
-
- fqt = &fqm->frame_queue_traces[thread_id];
-
- fqt->nelts = fq->nelts;
- fqt->head = fq->head;
- fqt->head_hint = fq->head_hint;
- fqt->tail = fq->tail;
- fqt->threshold = fq->vector_threshold;
- fqt->n_in_use = fqt->tail - fqt->head;
- if (fqt->n_in_use >= fqt->nelts)
- {
- // if beyond max then use max
- fqt->n_in_use = fqt->nelts - 1;
- }
-
- /* Record the number of elements in use in the histogram */
- fqh = &fqm->frame_queue_histogram[thread_id];
- fqh->count[fqt->n_in_use]++;
-
- /* Record a snapshot of the elements in use */
- for (elix = 0; elix < fqt->nelts; elix++)
- {
- elt = fq->elts + ((fq->head + 1 + elix) & (fq->nelts - 1));
- if (1 || elt->valid)
- {
- fqt->n_vectors[elix] = elt->n_vectors;
- }
- }
- fqt->written = 1;
- }
-
- while (1)
- {
- vlib_buffer_t *b;
- if (fq->head == fq->tail)
- {
- fq->head_hint = fq->head;
- return processed;
- }
-
- elt = fq->elts + ((fq->head + 1) & (fq->nelts - 1));
-
- if (!elt->valid)
- {
- fq->head_hint = fq->head;
- return processed;
- }
-
- from = elt->buffer_index;
- msg_type = elt->msg_type;
-
- ASSERT (msg_type == VLIB_FRAME_QUEUE_ELT_DISPATCH_FRAME);
- ASSERT (elt->n_vectors <= VLIB_FRAME_SIZE);
-
- f = vlib_get_frame_to_node (vm, fqm->node_index);
-
- /* If the first vector is traced, set the frame trace flag */
- b = vlib_get_buffer (vm, from[0]);
- if (b->flags & VLIB_BUFFER_IS_TRACED)
- f->frame_flags |= VLIB_NODE_FLAG_TRACE;
-
- to = vlib_frame_vector_args (f);
-
- n_left_to_node = elt->n_vectors;
-
- while (n_left_to_node >= 4)
- {
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
- to[3] = from[3];
- to += 4;
- from += 4;
- n_left_to_node -= 4;
- }
-
- while (n_left_to_node > 0)
- {
- to[0] = from[0];
- to++;
- from++;
- n_left_to_node--;
- }
-
- vectors += elt->n_vectors;
- f->n_vectors = elt->n_vectors;
- vlib_put_frame_to_node (vm, fqm->node_index, f);
-
- elt->valid = 0;
- elt->n_vectors = 0;
- elt->msg_type = 0xfefefefe;
- CLIB_MEMORY_BARRIER ();
- fq->head++;
- processed++;
-
- /*
- * Limit the number of packets pushed into the graph
- */
- if (vectors >= fq->vector_threshold)
- {
- fq->head_hint = fq->head;
- return processed;
- }
- }
- ASSERT (0);
- return processed;
-}
-
void
vlib_worker_thread_fn (void *arg)
{