summaryrefslogtreecommitdiffstats
path: root/vlib
diff options
context:
space:
mode:
authorChristophe Fontaine <christophe.fontaine@qosmos.com>2016-04-09 12:38:49 +0900
committerDave Barach <openvpp@barachs.net>2016-04-18 13:20:57 +0000
commitfef15b4bb88c61248393b93d13b1f79bb628def0 (patch)
tree0f34cc14987dde62a32201101c29b24b023fd36b /vlib
parent7a2a378d2dcdba900651b02859b686cafe6dfd22 (diff)
Add support for AArch32
gcc version 4.9.2 (Raspbian 4.9.2-10) Tested on Linux raspberrypi 4.4.6-v7+ #875 SMP Tue Apr 12 16:33:02 BST 2016 armv7l GNU/Linux CPUs may be little or big endian, detect with gcc flags, not the processor architecture Add a new flag $(PLATFORM)_uses_openssl which allows to disable the link with openssl lib. vlib/vlib/threads.c: startup.conf must: - specify the heapsize as we don't have hugepages on raspbian cpu { main-core 3 } heapsize 64M Corrects in various files the assumption uword == u64 and replaces 'u64' cast with 'pointer_to_uword' and 'uword_to_pointer' where appropriate. 256 CPUs may create an OOM when testing with small memory footprint ( heapsize 64M ), allows the number of VLIB_MAX_CPUS to be set in platforms/*.mk vppinfra/vppinfra/longjmp.S: ARM - copy r1 (1st parameter of the setjmp call) to r0 (return value) vppinfra/vppinfra/time.h: On ARMv7 in AArch32 mode, we can access to a 64bit register to retreive the cycles count. gcc on rpi only declare ARM_ARCH 6. Override this info, and check if it is possible to use 'mrrc'. /!\ the time function will NOT work without allowing the user mode access to the PMU. You may download the source of the kmod here: https://github.com/christophefontaine/arm_rdtsc Change-Id: I8142606436d9671a184133b935398427f08a8bd2 Signed-off-by: Christophe Fontaine <christophe.fontaine@qosmos.com>
Diffstat (limited to 'vlib')
-rw-r--r--vlib/vlib/buffer.h2
-rw-r--r--vlib/vlib/threads.c33
-rw-r--r--vlib/vlib/threads.h2
-rw-r--r--vlib/vlib/unix/cj.c4
-rw-r--r--vlib/vlib/unix/physmem.c4
5 files changed, 35 insertions, 10 deletions
diff --git a/vlib/vlib/buffer.h b/vlib/vlib/buffer.h
index 9c148ef2f21..07ed85d8c31 100644
--- a/vlib/vlib/buffer.h
+++ b/vlib/vlib/buffer.h
@@ -59,7 +59,7 @@
#ifdef CLIB_HAVE_VEC128
typedef u8x16 vlib_copy_unit_t;
#else
-typedef uword vlib_copy_unit_t;
+typedef u64 vlib_copy_unit_t;
#endif
/** \file
diff --git a/vlib/vlib/threads.c b/vlib/vlib/threads.c
index a69e4555af0..efbef379ba9 100644
--- a/vlib/vlib/threads.c
+++ b/vlib/vlib/threads.c
@@ -12,16 +12,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#define _GNU_SOURCE
+#include <sched.h>
+
#include <signal.h>
#include <math.h>
#include <vppinfra/format.h>
#include <vlib/vlib.h>
#include <vlib/threads.h>
-#include <vlib/unix/physmem.h>
-
#include <vlib/unix/cj.h>
+
#if DPDK==1
#include <rte_config.h>
#include <rte_common.h>
@@ -175,6 +177,16 @@ vlib_thread_init (vlib_main_t * vm)
if (!tm->cpu_socket_bitmap)
tm->cpu_socket_bitmap = clib_bitmap_set(0, 0, 1);
+ /* pin main thread to main_lcore */
+#if DPDK==0
+ {
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(tm->main_lcore, &cpuset);
+ pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+ }
+#endif
+
/* as many threads as stacks... */
vec_validate_aligned (vlib_worker_threads, vec_len(vlib_thread_stacks)-1,
CLIB_CACHE_LINE_BYTES);
@@ -486,7 +498,6 @@ void *vlib_worker_thread_bootstrap_fn (void *arg)
static int
vlib_launch_thread (void *fp, vlib_worker_thread_t *w, unsigned lcore_id)
{
- pthread_t dummy;
void *(*fp_arg)(void *) = fp;
#if DPDK==1
@@ -497,7 +508,19 @@ vlib_launch_thread (void *fp, vlib_worker_thread_t *w, unsigned lcore_id)
return -1;
else
#endif
- return pthread_create (&dummy, NULL /* attr */, fp_arg, (void *)w);
+ {
+ int ret;
+ pthread_t worker;
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(lcore_id, &cpuset);
+
+ ret = pthread_create (&worker, NULL /* attr */, fp_arg, (void *)w);
+ if(ret == 0)
+ return pthread_setaffinity_np(worker, sizeof(cpu_set_t), &cpuset);
+ else
+ return ret;
+ }
}
static clib_error_t * start_workers (vlib_main_t * vm)
@@ -1031,7 +1054,7 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
VLIB_EARLY_CONFIG_FUNCTION (cpu_config, "cpu");
-#if !defined (__x86_64__) && !defined (__aarch64__) && !defined (__powerpc64__)
+#if !defined (__x86_64__) && !defined (__aarch64__) && !defined (__powerpc64__) && !defined(__arm__)
void __sync_fetch_and_add_8 (void)
{
fformat(stderr, "%s called\n", __FUNCTION__);
diff --git a/vlib/vlib/threads.h b/vlib/vlib/threads.h
index 5773ed05a62..ce93b2c67cb 100644
--- a/vlib/vlib/threads.h
+++ b/vlib/vlib/threads.h
@@ -48,7 +48,9 @@ typedef struct vlib_thread_registration_ {
* Make VLIB_MAX_CPUS a power-of-two, please...
*/
+#ifndef VLIB_MAX_CPUS
#define VLIB_MAX_CPUS 256
+#endif
#if VLIB_MAX_CPUS > CLIB_MAX_MHEAPS
#error Please increase number of per-cpu mheaps
diff --git a/vlib/vlib/unix/cj.c b/vlib/vlib/unix/cj.c
index 665a13fa4f5..782ddce3099 100644
--- a/vlib/vlib/unix/cj.c
+++ b/vlib/vlib/unix/cj.c
@@ -40,8 +40,8 @@ cj_log (u32 type, void * data0, void * data1)
r->time = vlib_time_now (cjm->vlib_main);
r->cpu = os_get_cpu_number();
r->type = type;
- r->data[0] = (u64) data0;
- r->data[1] = (u64) data1;
+ r->data[0] = pointer_to_uword(data0);
+ r->data[1] = pointer_to_uword(data1);
}
void cj_stop(void)
diff --git a/vlib/vlib/unix/physmem.c b/vlib/vlib/unix/physmem.c
index d7428c9b227..185483d6f14 100644
--- a/vlib/vlib/unix/physmem.c
+++ b/vlib/vlib/unix/physmem.c
@@ -158,10 +158,10 @@ static int htlb_init (vlib_main_t * vm)
/* Don't want mheap mmap/munmap with IO memory. */
MHEAP_FLAG_DISABLE_VM);
- cur = (u64) pm->mem;
+ cur = pointer_to_uword(pm->mem);
i = 0;
- while (cur < (u64) pm->mem + pm->mem_size)
+ while (cur < pointer_to_uword(pm->mem) + pm->mem_size)
{
pfn = (u64) cur / pagesize;
seek_loc = pfn * sizeof (u64);