diff options
author | 2016-09-07 11:54:22 +0200 | |
---|---|---|
committer | 2016-09-12 09:45:51 +0000 | |
commit | 553f6bd8530b28f60f9e58da93849dae509a9328 (patch) | |
tree | c0737d11898df15095f7683a18790b6a1522df8b /vnet | |
parent | 019481ba1d2d6e5b82a98f10d7d6d4bdab9e8380 (diff) |
af_packet: allocate per-worker list of free buffers
Change-Id: I7850f04787fa7ce10c0ae8adefa166c91420f02d
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r-- | vnet/vnet/devices/af_packet/af_packet.c | 4 | ||||
-rw-r--r-- | vnet/vnet/devices/af_packet/af_packet.h | 2 | ||||
-rw-r--r-- | vnet/vnet/devices/af_packet/node.c | 17 |
3 files changed, 15 insertions, 8 deletions
diff --git a/vnet/vnet/devices/af_packet/af_packet.c b/vnet/vnet/devices/af_packet/af_packet.c index cb5f88a2..17eddd65 100644 --- a/vnet/vnet/devices/af_packet/af_packet.c +++ b/vnet/vnet/devices/af_packet/af_packet.c @@ -339,11 +339,15 @@ static clib_error_t * af_packet_init (vlib_main_t * vm) { af_packet_main_t *apm = &af_packet_main; + vlib_thread_main_t *tm = vlib_get_thread_main (); memset (apm, 0, sizeof (af_packet_main_t)); mhash_init_vec_string (&apm->if_index_by_host_if_name, sizeof (uword)); + vec_validate_aligned (apm->rx_buffers, tm->n_vlib_mains - 1, + CLIB_CACHE_LINE_BYTES); + return 0; } diff --git a/vnet/vnet/devices/af_packet/af_packet.h b/vnet/vnet/devices/af_packet/af_packet.h index 1896ddf5..19e2523d 100644 --- a/vnet/vnet/devices/af_packet/af_packet.h +++ b/vnet/vnet/devices/af_packet/af_packet.h @@ -46,7 +46,7 @@ typedef struct uword *pending_input_bitmap; /* rx buffer cache */ - u32 *rx_buffers; + u32 **rx_buffers; /* hash of host interface names */ mhash_t if_index_by_host_if_name; diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c index fa2b5ac1..3a3807d8 100644 --- a/vnet/vnet/devices/af_packet/node.c +++ b/vnet/vnet/devices/af_packet/node.c @@ -144,18 +144,20 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_buffer_bytes = vlib_buffer_free_list_buffer_size (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); u32 min_bufs = apif->rx_req->tp_frame_size / n_buffer_bytes; + int cpu_index = node->cpu_index; if (apif->per_interface_next_index != ~0) next_index = apif->per_interface_next_index; - n_free_bufs = vec_len (apm->rx_buffers); + n_free_bufs = vec_len (apm->rx_buffers[cpu_index]); if (PREDICT_FALSE (n_free_bufs < VLIB_FRAME_SIZE)) { - vec_validate (apm->rx_buffers, VLIB_FRAME_SIZE + n_free_bufs - 1); + vec_validate (apm->rx_buffers[cpu_index], + VLIB_FRAME_SIZE + n_free_bufs - 1); n_free_bufs += - vlib_buffer_alloc (vm, &apm->rx_buffers[n_free_bufs], + vlib_buffer_alloc (vm, &apm->rx_buffers[cpu_index][n_free_bufs], VLIB_FRAME_SIZE); - _vec_len (apm->rx_buffers) = n_free_bufs; + _vec_len (apm->rx_buffers[cpu_index]) = n_free_bufs; } rx_frame = apif->next_rx_frame; @@ -177,11 +179,12 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, while (data_len) { /* grab free buffer */ - u32 last_empty_buffer = vec_len (apm->rx_buffers) - 1; + u32 last_empty_buffer = + vec_len (apm->rx_buffers[cpu_index]) - 1; prev_bi0 = bi0; - bi0 = apm->rx_buffers[last_empty_buffer]; + bi0 = apm->rx_buffers[cpu_index][last_empty_buffer]; b0 = vlib_get_buffer (vm, bi0); - _vec_len (apm->rx_buffers) = last_empty_buffer; + _vec_len (apm->rx_buffers[cpu_index]) = last_empty_buffer; n_free_bufs--; /* copy data */ |