- /* Out of local buffer cache? */
- if (PREDICT_FALSE (_vec_len (my_buffer_cache) == 0))
- {
- u32 n =
- vlib_buffer_alloc (vm, my_buffer_cache, VLIB_FRAME_SIZE);
- _vec_len (my_buffer_cache) = n;
-
- /* Ugh, drop the rest of the expired entries */
- if (n == 0)
- {
- u32 drops = 0;
- while (ep->tx_time <= now && wp->cursize)
- {
- wp->head++;
- if (wp->head == wp->wheel_size)
- wp->head = 0;
- ep = wp->entries + wp->head;
- wp->cursize--;
- drops++;
- }
- /* Count the drops */
- vlib_node_increment_counter (vm, node->node_index,
- NSIM_TX_ERROR_DROPPED, drops);
- /* Ship any pkts we already processed */
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- return n_rx_packets + drops;
- }
- }
-
- /* Allocate a buffer */
- bi0 = my_buffer_cache[_vec_len (my_buffer_cache) - 1];
- _vec_len (my_buffer_cache) -= 1;
+ /* 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;