summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-07-20 18:10:35 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2017-09-07 16:09:21 +0000
commit49d66f1f42cbc310e4fa0dc526b9fdb91d0ca220 (patch)
treed6ebe20d0d6791650cd28b6b800d1dee2950f439 /src/plugins
parentd630713d733718701f38176f98d563fd32679d06 (diff)
vlib physmem rework
This patch adds supprot support for multiple numa-aware physmem regions. Change-Id: I5c69a6f4da33c8ee21bdb8604d52fd2886f2327e Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rwxr-xr-xsrc/plugins/dpdk/api/dpdk_api.c1
-rwxr-xr-xsrc/plugins/dpdk/device/init.c17
-rw-r--r--src/plugins/dpdk/hqos/hqos.c1
-rw-r--r--src/plugins/ixge/ixge.c32
-rw-r--r--src/plugins/ixge/ixge.h2
5 files changed, 35 insertions, 18 deletions
diff --git a/src/plugins/dpdk/api/dpdk_api.c b/src/plugins/dpdk/api/dpdk_api.c
index 08afdd700ef..97c4bc75721 100755
--- a/src/plugins/dpdk/api/dpdk_api.c
+++ b/src/plugins/dpdk/api/dpdk_api.c
@@ -20,7 +20,6 @@
#include <vnet/ethernet/ethernet.h>
#include <dpdk/device/dpdk.h>
-#include <vlib/unix/physmem.h>
#include <vlib/pci/pci.h>
#include <stdio.h>
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index a795ba0e88e..e23542f7554 100755
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -17,10 +17,10 @@
#include <vppinfra/error.h>
#include <vppinfra/format.h>
#include <vppinfra/bitmap.h>
+#include <vlib/unix/unix.h>
#include <vnet/ethernet/ethernet.h>
#include <dpdk/device/dpdk.h>
-#include <vlib/unix/physmem.h>
#include <vlib/pci/pci.h>
#include <stdio.h>
@@ -1026,21 +1026,28 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
clib_bitmap_foreach (c, tm->cpu_socket_bitmap, (
{
int pages_avail, page_size, mem;
+ clib_error_t *e = 0;
vec_validate(mem_by_socket, c);
mem = mem_by_socket[c];
page_size = 1024;
- pages_avail = vlib_sysfs_get_free_hugepages(c, page_size * 1024);
+ e = vlib_sysfs_get_free_hugepages(c, page_size * 1024, &pages_avail);
- if (pages_avail < 0 || page_size * pages_avail < mem)
+ if (e != 0 || pages_avail < 0 || page_size * pages_avail < mem)
use_1g = 0;
+ if (e)
+ clib_error_free (e);
+
page_size = 2;
- pages_avail = vlib_sysfs_get_free_hugepages(c, page_size * 1024);
+ e = vlib_sysfs_get_free_hugepages(c, page_size * 1024, &pages_avail);
- if (pages_avail < 0 || page_size * pages_avail < mem)
+ if (e != 0 || pages_avail < 0 || page_size * pages_avail < mem)
use_2m = 0;
+
+ if (e)
+ clib_error_free (e);
}));
/* *INDENT-ON* */
diff --git a/src/plugins/dpdk/hqos/hqos.c b/src/plugins/dpdk/hqos/hqos.c
index 813eb91cf99..c9b85652863 100644
--- a/src/plugins/dpdk/hqos/hqos.c
+++ b/src/plugins/dpdk/hqos/hqos.c
@@ -29,7 +29,6 @@
#include <vnet/ethernet/ethernet.h>
#include <dpdk/device/dpdk.h>
-#include <vlib/unix/physmem.h>
#include <vlib/pci/pci.h>
#include <vlibmemory/api.h>
#include <vlibmemory/vl_memory_msg_enum.h> /* enumerate all vlib messages */
diff --git a/src/plugins/ixge/ixge.c b/src/plugins/ixge/ixge.c
index e0150f41a70..222c148c67d 100644
--- a/src/plugins/ixge/ixge.c
+++ b/src/plugins/ixge/ixge.c
@@ -2493,10 +2493,11 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
round_pow2 (xm->n_descriptors[rt], xm->n_descriptors_per_cache_line);
dq->head_index = dq->tail_index = 0;
- dq->descriptors = vlib_physmem_alloc_aligned (vm, &error,
- dq->n_descriptors *
- sizeof (dq->descriptors[0]),
- 128 /* per chip spec */ );
+ dq->descriptors =
+ vlib_physmem_alloc_aligned (vm, xm->physmem_region, &error,
+ dq->n_descriptors *
+ sizeof (dq->descriptors[0]),
+ 128 /* per chip spec */ );
if (error)
return error;
@@ -2518,7 +2519,8 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
vlib_buffer_t *b =
vlib_get_buffer (vm, dq->descriptor_buffer_indices[i]);
dq->descriptors[i].rx_to_hw.tail_address =
- vlib_physmem_virtual_to_physical (vm, b->data);
+ vlib_physmem_virtual_to_physical (vm, xm->physmem_region,
+ b->data);
}
}
else
@@ -2526,7 +2528,8 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
u32 i;
dq->tx.head_index_write_back =
- vlib_physmem_alloc (vm, &error, CLIB_CACHE_LINE_BYTES);
+ vlib_physmem_alloc (vm, vm->buffer_main->physmem_region, &error,
+ CLIB_CACHE_LINE_BYTES);
for (i = 0; i < dq->n_descriptors; i++)
dq->descriptors[i].tx = xm->tx_descriptor_template;
@@ -2538,7 +2541,9 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
ixge_dma_regs_t *dr = get_dma_regs (xd, rt, queue_index);
u64 a;
- a = vlib_physmem_virtual_to_physical (vm, dq->descriptors);
+ a =
+ vlib_physmem_virtual_to_physical (vm, vm->buffer_main->physmem_region,
+ dq->descriptors);
dr->descriptor_address[0] = a & 0xFFFFFFFF;
dr->descriptor_address[1] = a >> (u64) 32;
dr->n_descriptor_bytes = dq->n_descriptors * sizeof (dq->descriptors[0]);
@@ -2564,7 +2569,9 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
dq->tx.head_index_write_back[0] = dq->head_index;
a =
- vlib_physmem_virtual_to_physical (vm, dq->tx.head_index_write_back);
+ vlib_physmem_virtual_to_physical (vm,
+ vm->buffer_main->physmem_region,
+ dq->tx.head_index_write_back);
dr->tx.head_index_write_back_address[0] = /* enable bit */ 1 | a;
dr->tx.head_index_write_back_address[1] = (u64) a >> (u64) 32;
}
@@ -2850,9 +2857,12 @@ ixge_pci_init (vlib_main_t * vm, vlib_pci_device_t * dev)
void *r;
ixge_device_t *xd;
- /* Device found: make sure we have dma memory. */
- if (unix_physmem_is_fake (vm))
- return clib_error_return (0, "no physical memory available");
+ /* Allocate physmem region for DMA buffers */
+ error = vlib_physmem_region_alloc (vm, "ixge decriptors", 2 << 20, 0,
+ VLIB_PHYSMEM_F_INIT_MHEAP,
+ &xm->physmem_region);
+ if (error)
+ return error;
error = vlib_pci_map_resource (dev, 0, &r);
if (error)
diff --git a/src/plugins/ixge/ixge.h b/src/plugins/ixge/ixge.h
index 779603b391b..42c1bfa5c9b 100644
--- a/src/plugins/ixge/ixge.h
+++ b/src/plugins/ixge/ixge.h
@@ -1266,6 +1266,8 @@ typedef struct
u32 *rx_buffers_to_add;
f64 time_last_stats_update;
+
+ vlib_physmem_region_index_t physmem_region;
} ixge_main_t;
ixge_main_t ixge_main;