X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnsim%2Fnsim_input.c;h=889d9c9841f73c962b8493911f5283abaa7d04eb;hb=HEAD;hp=3ce89bc98471fda22da07651473c934c87a10386;hpb=b966b96aa4ec125cea9dcd0b9f2d4268709f3896;p=vpp.git diff --git a/src/plugins/nsim/nsim_input.c b/src/plugins/nsim/nsim_input.c index 3ce89bc9847..889d9c9841f 100644 --- a/src/plugins/nsim/nsim_input.c +++ b/src/plugins/nsim/nsim_input.c @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -71,15 +70,9 @@ nsim_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * f, int is_trace) { nsim_main_t *nsm = &nsim_main; - u32 my_thread_index = vm->thread_index; - nsim_wheel_t *wp = nsm->wheel_by_thread[my_thread_index]; - f64 now = vlib_time_now (vm); - uword n_tx_packets = 0; - u32 bi0, next0; - u32 *to_next; - u32 next_index; - u32 n_left_to_next; + nsim_wheel_t *wp = nsm->wheel_by_thread[vm->thread_index]; nsim_wheel_entry_t *ep; + f64 now; /* Nothing on the scheduler wheel? */ if (wp->cursize == 0) @@ -87,67 +80,37 @@ nsim_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, /* First entry on the wheel isn't expired? */ ep = wp->entries + wp->head; + now = vlib_time_now (vm); if (ep->tx_time > now) - return n_tx_packets; + return 0; - next_index = node->cached_next_index; + u32 n_burst = clib_min (wp->cursize, NSIM_MAX_TX_BURST), n_tx_packets = 0; + u32 froms[NSIM_MAX_TX_BURST], *from; + u16 nexts[NSIM_MAX_TX_BURST], *next; - /* Be aware: this is not the usual coding pattern */ - while (wp->cursize && ep->tx_time <= now) + from = froms; + next = nexts; + while (n_tx_packets < n_burst && ep->tx_time <= now) { - vlib_buffer_t *b0; - - vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); - - while (n_left_to_next > 0) - { - /* prefetch one line / 2 entries ahead */ - if ((((uword) ep) & (CLIB_CACHE_LINE_BYTES - 1)) == 0) - CLIB_PREFETCH ((ep + 2), CLIB_CACHE_LINE_BYTES, LOAD); - /* Pick up buffer from the wheel */ - bi0 = ep->buffer_index; - - to_next[0] = bi0; - to_next += 1; - n_left_to_next -= 1; - - next0 = ep->output_next_index; - - /* verify speculative enqueue, maybe switch current next frame */ - vlib_validate_buffer_enqueue_x1 (vm, node, next_index, - to_next, n_left_to_next, - bi0, next0); - /* Advance to the next ring entry */ - wp->head++; - if (wp->head == wp->wheel_size) - wp->head = 0; - wp->cursize--; - ep = wp->entries + wp->head; - n_tx_packets++; - - if (is_trace) - { - b0 = vlib_get_buffer (vm, bi0); - if (b0->flags & VLIB_BUFFER_IS_TRACED) - { - nsim_tx_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - t->expired = now; - t->next_index = next0; - } - } - - /* Out of ring entries? */ - if (PREDICT_FALSE (wp->cursize == 0)) - break; - } - - vlib_put_next_frame (vm, node, next_index, n_left_to_next); - - /* If the current entry hasn't expired, we're done */ - if (ep->tx_time > now) - break; + /* prefetch one line / 2 entries ahead */ + if ((((uword) ep) & (CLIB_CACHE_LINE_BYTES - 1)) == 0) + clib_prefetch_load ((ep + 2)); + + ep = wp->entries + wp->head; + from[0] = ep->buffer_index; + next[0] = ep->output_next_index; + + wp->head++; + if (wp->head == wp->wheel_size) + wp->head = 0; + + from += 1; + next += 1; + n_tx_packets++; } + + wp->cursize -= n_tx_packets; + vlib_buffer_enqueue_to_next (vm, node, froms, nexts, n_tx_packets); vlib_node_increment_counter (vm, node->node_index, NSIM_TX_ERROR_TRANSMITTED, n_tx_packets); return n_tx_packets; @@ -163,7 +126,6 @@ VLIB_NODE_FN (nsim_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, } -/* *INDENT-OFF* */ #ifndef CLIB_MARCH_VARIANT VLIB_REGISTER_NODE (nsim_input_node) = { @@ -179,7 +141,6 @@ VLIB_REGISTER_NODE (nsim_input_node) = .error_strings = nsim_tx_error_strings, }; #endif /* CLIB_MARCH_VARIANT */ -/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON