- /* Get new next frame since previous incomplete frame may have less
- than VNET_FRAME_SIZE vectors in it. */
- vlib_get_new_next_frame (vm, node, VNET_INTERFACE_OUTPUT_NEXT_TX,
- to_tx, n_left_to_tx);
-
- while (from + 4 <= from_end && n_left_to_tx >= 2)
- {
- u32 bi0, bi1;
- vlib_buffer_t *b0, *b1;
-
- /* Prefetch next iteration. */
- vlib_prefetch_buffer_with_index (vm, from[2], LOAD);
- vlib_prefetch_buffer_with_index (vm, from[3], LOAD);
-
- bi0 = from[0];
- bi1 = from[1];
- to_tx[0] = bi0;
- to_tx[1] = bi1;
- from += 2;
- to_tx += 2;
- n_left_to_tx -= 2;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
-
- /* Be grumpy about zero length buffers for benefit of
- driver tx function. */
- ASSERT (b0->current_length > 0);
- ASSERT (b1->current_length > 0);
-
- if (PREDICT_FALSE
- ((b0->flags | b1->flags) & VLIB_BUFFER_NEXT_PRESENT))
- {
- u32 n_buffers, n_slow_bytes, i;
-
- /* Undo. */
- from -= 2;
- to_tx -= 2;
- n_left_to_tx += 2;
-
- /* Do slow path two times. */
- for (i = 0; i < 2; i++)
- {
- u32 bi = i ? bi1 : bi0;
- vlib_buffer_t *b = i ? b1 : b0;
-
- n_buffers = slow_path (vm, bi, b,
- n_left_to_tx, to_tx, &n_slow_bytes);
-
- /* Not enough room for single packet? */
- if (n_buffers == 0)
- goto put;
-
- from += 1;
- to_tx += n_buffers;
- n_left_to_tx -= n_buffers;
- incr_output_stats (vnm, thread_index, n_slow_bytes,
- vnet_buffer (b)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
- }
- }
- else
- {
- incr_output_stats (vnm, thread_index,
- vlib_buffer_length_in_chain (vm, b0),
- vnet_buffer (b0)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
- incr_output_stats (vnm, thread_index,
- vlib_buffer_length_in_chain (vm, b0),
- vnet_buffer (b1)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
- }
- }
-
- while (from + 1 <= from_end && n_left_to_tx >= 1)
- {
- u32 bi0;
- vlib_buffer_t *b0;
-
- bi0 = from[0];
- to_tx[0] = bi0;
- from += 1;
- to_tx += 1;
- n_left_to_tx -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
-
- /* Be grumpy about zero length buffers for benefit of
- driver tx function. */
- ASSERT (b0->current_length > 0);
-
- if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_NEXT_PRESENT))
- {
- u32 n_buffers, n_slow_bytes;
-
- /* Undo. */
- from -= 1;
- to_tx -= 1;
- n_left_to_tx += 1;
-
- n_buffers = slow_path (vm, bi0, b0,
- n_left_to_tx, to_tx, &n_slow_bytes);
-
- /* Not enough room for single packet? */
- if (n_buffers == 0)
- goto put;
-
- from += 1;
- to_tx += n_buffers;
- n_left_to_tx -= n_buffers;
- }
- incr_output_stats (vnm, thread_index,
- vlib_buffer_length_in_chain (vm, b0),
- vnet_buffer (b0)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
- }
-
- put:
- vlib_put_next_frame (vm, node, VNET_INTERFACE_OUTPUT_NEXT_TX,
- n_left_to_tx);