aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-09-14 19:04:50 +0200
committerDave Barach <openvpp@barachs.net>2017-09-15 16:34:50 +0000
commit01914ce45729833cec88c65689de9a0336cd40cc (patch)
tree99068f85d2b7b4e55154706286ab629acc7e4ab6 /src/plugins
parentce41a5c8032ff581a56b990361a2368c879a7adf (diff)
vppinfra: add clib_mem_vm_ext_alloc function
Change-Id: Iff33694fc42cc3bcc73cf1372339053a6365039c Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rwxr-xr-xsrc/plugins/dpdk/device/init.c6
-rw-r--r--src/plugins/memif/memif.c21
2 files changed, 13 insertions, 14 deletions
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 95176fb8490..ee61f94e399 100755
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -17,7 +17,7 @@
#include <vppinfra/error.h>
#include <vppinfra/format.h>
#include <vppinfra/bitmap.h>
-#include <vlib/linux/sysfs.h>
+#include <vppinfra/linux/sysfs.h>
#include <vlib/unix/unix.h>
#include <vnet/ethernet/ethernet.h>
@@ -1040,7 +1040,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
mem = mem_by_socket[c];
page_size = 1024;
- e = vlib_sysfs_get_free_hugepages(c, page_size * 1024, &pages_avail);
+ e = clib_sysfs_get_free_hugepages(c, page_size * 1024, &pages_avail);
if (e != 0 || pages_avail < 0 || page_size * pages_avail < mem)
use_1g = 0;
@@ -1049,7 +1049,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
clib_error_free (e);
page_size = 2;
- e = vlib_sysfs_get_free_hugepages(c, page_size * 1024, &pages_avail);
+ e = clib_sysfs_get_free_hugepages(c, page_size * 1024, &pages_avail);
if (e != 0 || pages_avail < 0 || page_size * pages_avail < mem)
use_2m = 0;
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 8fec409a16d..6a609a574e2 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -33,7 +33,7 @@
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
-#include <vlib/linux/syscall.h>
+#include <vppinfra/linux/syscall.h>
#include <vnet/plugin/plugin.h>
#include <vnet/ethernet/ethernet.h>
#include <vpp/app/version.h>
@@ -267,6 +267,8 @@ memif_init_regions_and_queues (memif_if_t * mif)
int i, j;
u64 buffer_offset;
memif_region_t *r;
+ clib_mem_vm_alloc_t alloc = { 0 };
+ clib_error_t *err;
vec_validate_aligned (mif->regions, 0, CLIB_CACHE_LINE_BYTES);
r = vec_elt_at_index (mif->regions, 0);
@@ -279,18 +281,15 @@ memif_init_regions_and_queues (memif_if_t * mif)
mif->run.buffer_size * (1 << mif->run.log2_ring_size) *
(mif->run.num_s2m_rings + mif->run.num_m2s_rings);
- if ((r->fd = memfd_create ("memif region 0", MFD_ALLOW_SEALING)) == -1)
- return clib_error_return_unix (0, "memfd_create");
-
- if ((fcntl (r->fd, F_ADD_SEALS, F_SEAL_SHRINK)) == -1)
- return clib_error_return_unix (0, "fcntl (F_ADD_SEALS, F_SEAL_SHRINK)");
+ alloc.name = "memif region";
+ alloc.size = r->region_size;
+ alloc.flags = CLIB_MEM_VM_F_SHARED;
- if ((ftruncate (r->fd, r->region_size)) == -1)
- return clib_error_return_unix (0, "ftruncate");
+ err = clib_mem_vm_ext_alloc (&alloc);
+ if (err)
+ return err;
- if ((r->shm = mmap (NULL, r->region_size, PROT_READ | PROT_WRITE,
- MAP_SHARED, r->fd, 0)) == MAP_FAILED)
- return clib_error_return_unix (0, "mmap");
+ r->fd = alloc.fd;
for (i = 0; i < mif->run.num_s2m_rings; i++)
{