summaryrefslogtreecommitdiffstats
path: root/src/plugins/memif/memif.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-11-02 17:07:59 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-22 15:54:43 +0000
commit5c37ce3e0264c0bec75610837c5819ff4407bd5c (patch)
tree445c8d5f9fa2ee7bdb1f8fb6e1228c1bcbf633d9 /src/plugins/memif/memif.c
parent32f4e18c59f368e9c43f4483de12353280c2149b (diff)
memif: version 2
In version 1 of the protocol sender was always ring producer and receiver was consumer. In version 2 slave is always producer, and in case of master-to-slave rings, slave is responsible for populating ring with empty buffers. As this is major change, we need to bump version number. In addition, descriptor size is reduced to 16 bytes. This change allows zero-copy-slave operation (to be privided in the separate patch). Change-Id: I02115d232f455ffc05c0bd247f7d03f47252cfaf Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'src/plugins/memif/memif.c')
-rw-r--r--src/plugins/memif/memif.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index d630f2a6182..c83a955090c 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -240,6 +240,8 @@ memif_connect (memif_if_t * mif)
if (rxmode == VNET_HW_INTERFACE_RX_MODE_POLLING)
mq->ring->flags |= MEMIF_RING_FLAG_MASK_INT;
+ else
+ vnet_device_input_set_interrupt_pending (vnm, mif->hw_if_index, i);
}
}
@@ -308,7 +310,7 @@ memif_init_regions_and_queues (memif_if_t * mif)
ring->desc[j].region = 0;
ring->desc[j].offset =
buffer_offset + (u32) (slot * mif->run.buffer_size);
- ring->desc[j].buffer_length = mif->run.buffer_size;
+ ring->desc[j].length = mif->run.buffer_size;
}
}
for (i = 0; i < mif->run.num_m2s_rings; i++)
@@ -323,7 +325,7 @@ memif_init_regions_and_queues (memif_if_t * mif)
ring->desc[j].region = 0;
ring->desc[j].offset =
buffer_offset + (u32) (slot * mif->run.buffer_size);
- ring->desc[j].buffer_length = mif->run.buffer_size;
+ ring->desc[j].length = mif->run.buffer_size;
}
}
@@ -722,6 +724,35 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
DBG ("initializing socket file %s", msf->filename);
}
+ if (mm->per_thread_data == 0)
+ {
+ int i;
+ vlib_buffer_free_list_t *fl;
+
+ vec_validate_aligned (mm->per_thread_data, tm->n_vlib_mains - 1,
+ CLIB_CACHE_LINE_BYTES);
+
+ fl =
+ vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
+ for (i = 0; i < tm->n_vlib_mains; i++)
+ {
+ memif_per_thread_data_t *ptd =
+ vec_elt_at_index (mm->per_thread_data, i);
+ vlib_buffer_t *bt = &ptd->buffer_template;
+ vlib_buffer_init_for_free_list (bt, fl);
+ bt->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID;
+ bt->total_length_not_including_first_buffer = 0;
+ vnet_buffer (bt)->sw_if_index[VLIB_TX] = (u32) ~ 0;
+
+ /* initially prealloc copy_ops so we can use
+ _vec_len instead of vec_elen */
+ vec_validate_aligned (ptd->copy_ops, 0, CLIB_CACHE_LINE_BYTES);
+ vec_reset_length (ptd->copy_ops);
+ vec_validate_aligned (ptd->buffers, 0, CLIB_CACHE_LINE_BYTES);
+ vec_reset_length (ptd->buffers);
+ }
+ }
+
pool_get (mm->interfaces, mif);
memset (mif, 0, sizeof (*mif));
mif->dev_instance = mif - mm->interfaces;
@@ -860,7 +891,6 @@ static clib_error_t *
memif_init (vlib_main_t * vm)
{
memif_main_t *mm = &memif_main;
- vlib_thread_main_t *tm = vlib_get_thread_main ();
u8 *filename;
memset (mm, 0, sizeof (memif_main_t));
@@ -878,9 +908,6 @@ memif_init (vlib_main_t * vm)
MEMIF_DEFAULT_SOCKET_FILENAME, 0);
memif_add_socket_file (0, filename);
- vec_validate_aligned (mm->rx_buffers, tm->n_vlib_mains - 1,
- CLIB_CACHE_LINE_BYTES);
-
return 0;
}