summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/memif/memif.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 05a7f83b3b1..c1bab0ba15f 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -344,11 +344,11 @@ clib_error_t *
memif_init_regions_and_queues (memif_if_t * mif)
{
vlib_main_t *vm = vlib_get_main ();
+ memif_socket_file_t *msf;
memif_ring_t *ring = NULL;
- int i, j;
+ int fd, i, j;
u64 buffer_offset;
memif_region_t *r;
- clib_mem_vm_alloc_t alloc = { 0 };
clib_error_t *err;
ASSERT (vec_len (mif->regions) == 0);
@@ -364,16 +364,31 @@ memif_init_regions_and_queues (memif_if_t * mif)
r->region_size += mif->run.buffer_size * (1 << mif->run.log2_ring_size) *
(mif->run.num_s2m_rings + mif->run.num_m2s_rings);
- alloc.name = "memif region";
- alloc.size = r->region_size;
- alloc.flags = CLIB_MEM_VM_F_SHARED;
+ if ((fd = clib_mem_vm_create_fd (CLIB_MEM_PAGE_SZ_DEFAULT, "%U region 0",
+ format_memif_device_name,
+ mif->dev_instance)) == -1)
+ {
+ err = clib_mem_get_last_error ();
+ goto error;
+ }
- err = clib_mem_vm_ext_alloc (&alloc);
- if (err)
- goto error;
+ if ((ftruncate (fd, r->region_size)) == -1)
+ {
+ err = clib_error_return_unix (0, "ftruncate");
+ goto error;
+ }
+
+ msf = pool_elt_at_index (memif_main.socket_files, mif->socket_file_index);
+ r->shm = clib_mem_vm_map_shared (0, r->region_size, fd, 0, "memif%lu/%lu:0",
+ msf->socket_id, mif->id);
+
+ if (r->shm == CLIB_MEM_VM_MAP_FAILED)
+ {
+ err = clib_error_return_unix (0, "memif shared region map failed");
+ goto error;
+ }
- r->fd = alloc.fd;
- r->shm = alloc.addr;
+ r->fd = fd;
if (mif->flags & MEMIF_IF_FLAG_ZERO_COPY)
{