Add support for AArch32 99/799/3
authorChristophe Fontaine <christophe.fontaine@qosmos.com>
Sat, 9 Apr 2016 03:38:49 +0000 (12:38 +0900)
committerDave Barach <openvpp@barachs.net>
Mon, 18 Apr 2016 13:20:57 +0000 (13:20 +0000)
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>
31 files changed:
build-data/packages/vnet.mk
build-data/packages/vpp.mk
build-data/platforms/arm32.mk [new file with mode: 0644]
svm/ssvm.c
svm/ssvm.h
vlib-api/vlibmemory/memory_vlib.c
vlib/vlib/buffer.h
vlib/vlib/threads.c
vlib/vlib/threads.h
vlib/vlib/unix/cj.c
vlib/vlib/unix/physmem.c
vnet/vnet/classify/vnet_classify.h
vnet/vnet/devices/dpdk/vhost_user.c
vnet/vnet/devices/ssvm/node.c
vnet/vnet/devices/ssvm/ssvm_eth.c
vnet/vnet/devices/ssvm/ssvm_eth.h
vnet/vnet/ip/lookup.h
vnet/vnet/l2/l2_flood.c
vpp/api/api.c
vpp/api/gmon.c
vppapigen/node.c
vppinfra/vppinfra/byte_order.h
vppinfra/vppinfra/cache.h
vppinfra/vppinfra/hash.c
vppinfra/vppinfra/hash.h
vppinfra/vppinfra/longjmp.S
vppinfra/vppinfra/macros.c
vppinfra/vppinfra/random_isaac.c
vppinfra/vppinfra/test_vec.c
vppinfra/vppinfra/time.h
vppinfra/vppinfra/vector.h

index 46d3c1d..cafb939 100644 (file)
@@ -6,14 +6,12 @@ vnet_configure_depend =                       \
 
 vnet_CPPFLAGS = $(call installed_includes_fn,  \
     vppinfra                                   \
-    openssl                                    \
     svm                                                \
     vlib                                       \
     vlib-api)
 
 vnet_LDFLAGS = $(call installed_libs_fn,       \
     vppinfra                                   \
-    openssl                                    \
     svm                                                \
     vlib                                       \
     vlib-api)
@@ -25,6 +23,12 @@ endif
 # Platform dependent configure flags
 vnet_configure_args += $(vnet_configure_args_$(PLATFORM))
 
+# include & link with openssl only if needed
+ifneq ($($(PLATFORM)_uses_openssl),no)
+vnet_CPPFLAGS += $(call installed_includes_fn, openssl)
+vnet_LDFLAGS += $(call installed_libs_fn, openssl)
+endif
+
 ifneq ($($(PLATFORM)_uses_dpdk),no)
 ifeq ($($(PLATFORM)_uses_external_dpdk),yes)
 vnet_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir)
index f96235f..be10e17 100644 (file)
@@ -18,7 +18,6 @@ vpp_configure_args += $(vpp_configure_args_$(PLATFORM))
 
 vpp_CPPFLAGS = $(call installed_includes_fn,   \
        vppinfra                                \
-        openssl                                        \
        svm                                     \
        vlib                                    \
        vlib-api                                \
@@ -26,12 +25,17 @@ vpp_CPPFLAGS = $(call installed_includes_fn,        \
 
 vpp_LDFLAGS = $(call installed_libs_fn,                \
        vppinfra                                \
-       openssl                                 \
        svm                                     \
        vlib                                    \
        vlib-api                                \
        vnet)
 
+# include & link with openssl only if needed
+ifneq ($($(PLATFORM)_uses_openssl),no)
+vpp_CPPFLAGS += $(call installed_includes_fn, openssl)
+vpp_LDFLAGS += $(call installed_libs_fn, openssl)
+endif
+
 ifneq ($($(PLATFORM)_uses_dpdk),no)
 ifeq ($($(PLATFORM)_uses_external_dpdk),yes)
 vpp_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir)
diff --git a/build-data/platforms/arm32.mk b/build-data/platforms/arm32.mk
new file mode 100644 (file)
index 0000000..fecc5bb
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# vector packet processor
+arm32_arch = native
+arm32_native_tools = vppapigen
+
+arm32_uses_dpdk = no
+arm32_uses_openssl = no
+
+arm32_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \
+       vpp-japi gmod
+
+vlib_configure_args_arm32 = --with-pre-data=128
+
+vnet_configure_args_arm32 = --without-vcgn --without-ipsec --without-ipv6sr
+vpp_configure_args_arm32 = --without-vcgn --without-ipsec --without-ipv6sr
+
+arm32_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -DVLIB_MAX_CPUS=4 -march=armv7-a \
+       -fstack-protector-all -fPIC -Werror
+arm32_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -DVLIB_MAX_CPUS=4 -march=armv7-a \
+       -fstack-protector-all -fPIC -Werror
+
+arm32_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -DVLIB_MAX_CPUS=4 -march=armv7-a \
+       -fstack-protector -fPIC -Werror
+arm32_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -DVLIB_MAX_CPUS=4 -march=armv7-a \
+       -fstack-protector -fPIC -Werror
index b9c6ef9..92d86e6 100644 (file)
@@ -59,10 +59,10 @@ int ssvm_master_init (ssvm_private_t * ssvm, u32 master_index)
   if (ssvm->requested_va)
     ssvm->requested_va += randomize_baseva;
   
-  sh = ssvm->sh = (void *) mmap((void *)ssvm->requested_va, ssvm->ssvm_size, 
+  sh = ssvm->sh = (ssvm_shared_header_t *) mmap((void *)ssvm->requested_va, ssvm->ssvm_size, 
                                 PROT_READ | PROT_WRITE, flags, ssvm_fd, 0);
 
-  if ((u64) ssvm->sh == (u64) MAP_FAILED)
+  if (ssvm->sh == MAP_FAILED)
     {
       clib_unix_warning ("mmap");
       close(ssvm_fd);
@@ -78,7 +78,7 @@ int ssvm_master_init (ssvm_private_t * ssvm, u32 master_index)
     (((u8 *)sh) + MMAP_PAGESIZE, ssvm->ssvm_size - MMAP_PAGESIZE, 
      MHEAP_FLAG_DISABLE_VM | MHEAP_FLAG_THREAD_SAFE);
 
-  sh->ssvm_va = (u64) sh;
+  sh->ssvm_va = pointer_to_uword(sh);
   sh->master_index = master_index;
 
   oldheap = ssvm_push_heap (sh);
@@ -123,7 +123,7 @@ int ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds)
  map_it:
     sh = (void *) mmap (0, MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, 
                         ssvm_fd, 0);
-    if ((u64) sh == (u64) MAP_FAILED)
+    if (sh == MAP_FAILED)
       {
         clib_unix_warning ("slave research mmap");
         close (ssvm_fd);
@@ -150,7 +150,7 @@ int ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds)
                                   MAP_SHARED | MAP_FIXED,
                                   ssvm_fd, 0);
     
-    if ((u64) sh == (u64) MAP_FAILED)
+    if (sh == MAP_FAILED)
       {
         clib_unix_warning ("slave final mmap");
         close (ssvm_fd);
index 5116493..cd34afd 100644 (file)
@@ -73,7 +73,7 @@ typedef struct {
   u32 my_pid;
   u32 vlib_hw_if_index;
   u8 * name;
-  u64 requested_va;
+  uword requested_va;
   int i_am_master;
   u32 per_interface_next_index;
   u32 * rx_queue;
index 7ba76ec..107fddc 100644 (file)
@@ -1135,8 +1135,8 @@ static void vl_api_rpc_call_t_handler (vl_api_rpc_call_t * mp)
       if (mp->need_barrier_sync)
         vlib_worker_thread_barrier_sync (vm);
 
-      fp = (void *)(mp->function);
-      rv = (*fp)(mp->data);
+      fp = uword_to_pointer(mp->function, int(*)(void *));
+      rv = fp(mp->data);
 
       if (mp->need_barrier_sync)
         vlib_worker_thread_barrier_release (vm);
@@ -1174,7 +1174,7 @@ void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
   memset (mp, 0, sizeof (*mp));
   memcpy (mp->data, data, data_length);
   mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
-  mp->function = (u64)fp;
+  mp->function = pointer_to_uword(fp);
   mp->need_barrier_sync = 1;
   
   /* Use the "normal" control-plane mechanism for the main thread */
index 9c148ef..07ed85d 100644 (file)
@@ -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
index a69e455..efbef37 100644 (file)
  * 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__);
index 5773ed0..ce93b2c 100644 (file)
@@ -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
index 665a13f..782ddce 100644 (file)
@@ -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)
index d7428c9..185483d 100644 (file)
@@ -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);
index b7056c5..b19704e 100644 (file)
@@ -40,11 +40,11 @@ extern vlib_node_registration_t ip6_classify_node;
 
 #define CLASSIFY_TRACE 0
 
-#ifndef __aarch64__
+#if !defined( __aarch64__) && !defined(__arm__)
 #define CLASSIFY_USE_SSE //Allow usage of SSE operations
 #endif
 
-#define U32X4_ALIGNED(p) PREDICT_TRUE((((u64)p) & 0xf) == 0)
+#define U32X4_ALIGNED(p) PREDICT_TRUE((((intptr_t)p) & 0xf) == 0)
 
 struct _vnet_classify_main;
 typedef struct _vnet_classify_main vnet_classify_main_t;
index 9db4a0a..9cdf664 100644 (file)
@@ -495,9 +495,9 @@ dpdk_vhost_user_set_mem_table(u32 hw_if_index, vhost_user_memory_t * vum, int fd
     mem->regions[i].userspace_address      = vum->regions[i].userspace_addr;
 
     mapped_size = mem->regions[i].memory_size + vum->regions[i].mmap_offset;
-    mapped_address = (uint64_t)(uintptr_t)mmap(NULL, mapped_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd[i], 0);
+    mapped_address = pointer_to_uword(mmap(NULL, mapped_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd[i], 0));
 
-    if ((void *)mapped_address == MAP_FAILED)
+    if (uword_to_pointer(mapped_address, void*) == MAP_FAILED)
     {
       clib_warning("mmap error");
       return 0;
index b26d73d..3a5709d 100644 (file)
@@ -97,8 +97,8 @@ ssvm_eth_device_input (ssvm_eth_main_t * em,
   uword n_trace = vlib_get_trace_count (vm, node);
 
   /* Either side down? buh-bye... */
-  if ((u64)(sh->opaque [MASTER_ADMIN_STATE_INDEX]) == 0 ||
-      (u64)(sh->opaque [SLAVE_ADMIN_STATE_INDEX]) == 0)
+  if (pointer_to_uword(sh->opaque [MASTER_ADMIN_STATE_INDEX]) == 0 ||
+      pointer_to_uword(sh->opaque [SLAVE_ADMIN_STATE_INDEX]) == 0)
     return 0;
 
   if (intfc->i_am_master)
@@ -271,14 +271,14 @@ ssvm_eth_device_input (ssvm_eth_main_t * em,
 
   ASSERT(vec_len(intfc->rx_queue) > 0);
 
-  n_available = (u32)(u64)(sh->opaque[CHUNK_POOL_NFREE]);
+  n_available = (u32)pointer_to_uword(sh->opaque[CHUNK_POOL_NFREE]);
   elt_indices = (u32 *)(sh->opaque[CHUNK_POOL_FREELIST_INDEX]);
 
   memcpy (&elt_indices[n_available], intfc->rx_queue, 
           vec_len (intfc->rx_queue) * sizeof (u32));
 
   n_available += vec_len (intfc->rx_queue);
-  sh->opaque[CHUNK_POOL_NFREE] = (void *) (u64) n_available;
+  sh->opaque[CHUNK_POOL_NFREE] = uword_to_pointer(n_available, void* );
 
   ssvm_unlock (sh);
 
index 7d937f0..23ec026 100644 (file)
@@ -95,7 +95,7 @@ int ssvm_eth_create (ssvm_eth_main_t * em, u8 * name, int is_master)
 
   sh->opaque [CHUNK_POOL_INDEX] = (void *) elts;
   sh->opaque [CHUNK_POOL_FREELIST_INDEX] = (void *) elt_indices;
-  sh->opaque [CHUNK_POOL_NFREE] = (void *) em->nbuffers;
+  sh->opaque [CHUNK_POOL_NFREE] = (void *)(uword) em->nbuffers;
   
   ssvm_pop_heap (oldheap);
 
@@ -276,8 +276,8 @@ ssvm_eth_interface_tx (vlib_main_t * vm,
   n_present_in_cache = vec_len (em->chunk_cache);
 
   /* admin / link up/down check */
-  if ((u64)(sh->opaque [MASTER_ADMIN_STATE_INDEX]) == 0 ||
-      (u64)(sh->opaque [SLAVE_ADMIN_STATE_INDEX]) == 0)
+  if (sh->opaque [MASTER_ADMIN_STATE_INDEX] == 0 ||
+      sh->opaque [SLAVE_ADMIN_STATE_INDEX] == 0)
     {
       interface_down = 1;
       goto out;
@@ -287,7 +287,7 @@ ssvm_eth_interface_tx (vlib_main_t * vm,
 
   elts = (ssvm_eth_queue_elt_t *) (sh->opaque [CHUNK_POOL_INDEX]);
   elt_indices = (u32 *) (sh->opaque [CHUNK_POOL_FREELIST_INDEX]);
-  n_available = (u32) (u64) (sh->opaque [CHUNK_POOL_NFREE]);
+  n_available = (u32) pointer_to_uword(sh->opaque [CHUNK_POOL_NFREE]);
 
   if (n_present_in_cache < n_left*2)
     {
@@ -305,7 +305,7 @@ ssvm_eth_interface_tx (vlib_main_t * vm,
 
       n_present_in_cache += n_allocated;
       n_available -= n_allocated;
-      sh->opaque [CHUNK_POOL_NFREE] = (void *) (u64) n_available;
+      sh->opaque [CHUNK_POOL_NFREE] = uword_to_pointer(n_available, void*);
       _vec_len (em->chunk_cache) = n_present_in_cache;
     }
 
index 8f1f889..23af7ed 100644 (file)
@@ -114,7 +114,7 @@ static inline void ssvm_eth_validate_freelists (int need_lock)
         ssvm_lock (sh, my_pid, 15);
 
       elt_indices = (u32 *) (sh->opaque [CHUNK_POOL_FREELIST_INDEX]);
-      n_available = (u32) (u64) (sh->opaque [CHUNK_POOL_NFREE]);
+      n_available = (u32) (uword) (sh->opaque [CHUNK_POOL_NFREE]);
 
       for (i = 0; i < n_available; i++)
        ASSERT (elt_indices[i] < 2048);
index 76d803d..23cb02d 100644 (file)
@@ -198,14 +198,14 @@ vnet_ip_adjacency_signature (ip_adjacency_t * adj)
   uword signature = 0xfeedfaceULL;
 
   /* Skip heap handle, sum everything up to but not including share_count */
-  signature = hash_memory64
+  signature = hash_memory
       (STRUCT_MARK_PTR(adj, signature_start),
        STRUCT_OFFSET_OF(ip_adjacency_t, signature_end)
        - STRUCT_OFFSET_OF(ip_adjacency_t, signature_start),
        signature);
 
   /* and the rewrite */
-  signature = hash_memory64 (&adj->rewrite_header, VLIB_BUFFER_PRE_DATA_SIZE,
+  signature = hash_memory (&adj->rewrite_header, VLIB_BUFFER_PRE_DATA_SIZE,
                              signature);
   return signature;
 }
index 0d25f58..e0c4bb7 100644 (file)
@@ -174,7 +174,7 @@ l2flood_process (vlib_main_t * vm,
          (!in_shg || members[0].shg != in_shg)))) {
       // If more than one member then initiate replication
       ctx = replication_prep (vm, b0, l2flood_node.index, 1 /* l2_packet */);
-      ctx->feature_replicas = (u64) members;
+      ctx->feature_replicas = (uword) members;
       ctx->feature_counter = current_member;
     }
 
@@ -194,7 +194,7 @@ l2flood_process (vlib_main_t * vm,
     ctx = replication_get_ctx (b0);
     replication_clear_recycled (b0);
 
-    members = (l2_flood_member_t *) ctx->feature_replicas;
+    members = (l2_flood_member_t *)(intptr_t) ctx->feature_replicas;
     current_member = (i32)ctx->feature_counter - 1;
 
     // Need to update input index from saved packet context
index 37cd57f..b47214f 100644 (file)
@@ -3314,7 +3314,7 @@ static void vl_api_cli_request_t_handler
     rp->_vl_msg_id = ntohs(VL_API_CLI_REPLY);
     rp->context = mp->context;
 
-    unformat_init_vector (&input, (u8 *)mp->cmd_in_shmem);
+    unformat_init_vector (&input, (u8 *)(uword)mp->cmd_in_shmem);
 
     vlib_cli_input (vm, &input, shmem_cli_output, 
                     (uword)&shmem_vec);
@@ -5191,11 +5191,11 @@ static void
 vl_api_ikev2_profile_add_del_t_handler
 (vl_api_ikev2_profile_add_del_t * mp)
 {
-    vlib_main_t * vm = vlib_get_main();
     vl_api_ikev2_profile_add_del_reply_t * rmp;
     int rv = 0;
 
 #if IPSEC > 0
+    vlib_main_t * vm = vlib_get_main();
     clib_error_t * error;
     u8 * tmp = format(0, "%s", mp->name);
     error = ikev2_add_del_profile(vm, tmp, mp->is_add);
@@ -5213,11 +5213,11 @@ static void
 vl_api_ikev2_profile_set_auth_t_handler
 (vl_api_ikev2_profile_set_auth_t * mp)
 {
-    vlib_main_t * vm = vlib_get_main();
     vl_api_ikev2_profile_set_auth_reply_t * rmp;
     int rv = 0;
 
 #if IPSEC > 0
+    vlib_main_t * vm = vlib_get_main();
     clib_error_t * error;
     u8 * tmp = format(0, "%s", mp->name);
     u8 * data = vec_new (u8, mp->data_len);
@@ -5238,11 +5238,11 @@ static void
 vl_api_ikev2_profile_set_id_t_handler
 (vl_api_ikev2_profile_set_id_t * mp)
 {
-    vlib_main_t * vm = vlib_get_main();
-    vl_api_ikev2_profile_set_id_reply_t * rmp;
+    vl_api_ikev2_profile_add_del_reply_t * rmp;
     int rv = 0;
 
 #if IPSEC > 0
+    vlib_main_t * vm = vlib_get_main();
     clib_error_t * error;
     u8 * tmp = format(0, "%s", mp->name);
     u8 * data = vec_new (u8, mp->data_len);
@@ -5263,11 +5263,11 @@ static void
 vl_api_ikev2_profile_set_ts_t_handler
 (vl_api_ikev2_profile_set_ts_t * mp)
 {
-    vlib_main_t * vm = vlib_get_main();
     vl_api_ikev2_profile_set_ts_reply_t * rmp;
     int rv = 0;
 
 #if IPSEC > 0
+    vlib_main_t * vm = vlib_get_main();
     clib_error_t * error;
     u8 * tmp = format(0, "%s", mp->name);
     error = ikev2_set_profile_ts(vm, tmp, mp->proto, mp->start_port,
@@ -5287,11 +5287,11 @@ static void
 vl_api_ikev2_set_local_key_t_handler
 (vl_api_ikev2_set_local_key_t * mp)
 {
-    vlib_main_t * vm = vlib_get_main();
-    vl_api_ikev2_set_local_key_reply_t * rmp;
+    vl_api_ikev2_profile_set_ts_reply_t * rmp;
     int rv = 0;
 
 #if IPSEC > 0
+    vlib_main_t * vm = vlib_get_main();
     clib_error_t * error;
 
     error = ikev2_set_local_key(vm, mp->key_file);
index 3098423..32786d6 100644 (file)
@@ -52,7 +52,7 @@ typedef struct {
   pid_t *vpef_pid_ptr;
   u64 last_sig_errors;
   u64 current_sig_errors;
-  u64 * sig_error_bitmap;
+  uword * sig_error_bitmap;
   vlib_main_t *vlib_main;
   vlib_main_t ** my_vlib_mains;
 
index 966ff81..3a32abe 100644 (file)
@@ -285,8 +285,8 @@ void primtype_java_code (node_t * this, enum passid which, FILE *ofp,
             indent_me(ofp);
             fprintf(ofp, "int _i;\n");
             indent_me(ofp);
-            fprintf(ofp, "for (_i = 0; _i < %d; _i++) {\n", 
-                    (int)(u64)(deeper->data[1]));
+            fprintf(ofp, "for (_i = 0; _i < %u; _i++) {\n",
+                    (u64)(deeper->data[1]));
             indent += 4;
             indent_me(ofp);
             fprintf(ofp, "mp->%s[_i] = %s(%sP[_i]);\n",
index 4f385f1..b2c26e5 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <vppinfra/clib.h>
 
-#if defined(__x86_64__) || defined(i386) || defined(__aarch64__)
+#if (__BYTE_ORDER__)==( __ORDER_LITTLE_ENDIAN__)
 #define CLIB_ARCH_IS_BIG_ENDIAN (0)
 #define CLIB_ARCH_IS_LITTLE_ENDIAN (1)
 #else
index fea1116..92e1e8c 100644 (file)
@@ -45,7 +45,7 @@
  */
 #ifndef CLIB_LOG2_CACHE_LINE_BYTES
 
-#ifdef __x86_64__
+#if defined(__x86_64__) || defined(__ARM_ARCH_7A__)
 #define CLIB_LOG2_CACHE_LINE_BYTES 6
 #endif
 
index 9e038b4..adadf01 100644 (file)
@@ -88,7 +88,7 @@ static inline u64 zap64 (u64 x, word n)
     return x & masks_little_endian[n];
 }
 
-u64 hash_memory64 (void * p, word n_bytes, u64 state)
+static inline u64 hash_memory64 (void * p, word n_bytes, u64 state)
 {
   u64 * q = p;
   u64 a, b, c, n;
@@ -155,7 +155,7 @@ static inline u32 zap32 (u32 x, word n)
     return x & masks_little_endian[n];
 }
 
-u32 hash_memory32 (void * p, word n_bytes, u32 state)
+static inline u32 hash_memory32 (void * p, word n_bytes, u32 state)
 {
   u32 * q = p;
   u32 a, b, c, n;
index 3c4daad..978230b 100644 (file)
@@ -586,8 +586,6 @@ do {                                                \
   hash_v3_finalize_step_2_u32x(a,b,c);         \
 } while (0)
 
-extern u64 hash_memory64 (void * p, word n_bytes, u64 state);
-extern u32 hash_memory32 (void * p, word n_bytes, u32 state);
 extern uword hash_memory (void * p, word n_bytes, uword state);
 
 extern uword mem_key_sum (hash_t * h, uword key);
index 9ba237d..d4dd4c7 100644 (file)
@@ -478,7 +478,7 @@ clib_setjmp:
 #endif
 
        /* Give back user's return value. */
-       mov r1, r0
+       mov r0, r1
        bx lr
        
        .global clib_longjmp
@@ -501,7 +501,7 @@ clib_longjmp:
 #endif
        
        /* Give back user's return value. */
-       mov r1, r0
+       mov r0, r1
        bx lr
 
        .global clib_calljmp
index 4107464..f16948e 100644 (file)
@@ -214,7 +214,7 @@ void clib_macro_init(macro_main_t * mm)
 {
   if (mm->the_builtin_eval_hash != 0)
     {
-      clib_warning ("mm %llx already initialized", (u64)mm);
+      clib_warning ("mm %p already initialized", mm);
       return;
     }
 
index e928740..ad2c165 100644 (file)
@@ -110,7 +110,7 @@ void isaac2 (isaac_t * ctx, uword * results)
   u32 a##n, b##n, c##n, x##n, y##n, * m##n, * mm##n, * m2##n, * r##n, * mend##n
 
   _ (0); _ (1);
-
+  (void)mend1; /* "set but unused variable" error on mend1 with gcc 4.9  */
 #undef _
 
 #define _(n)                                                   \
index 12c0603..80832bf 100644 (file)
@@ -1050,7 +1050,7 @@ int test_vec_main (unformat_input_t * input)
       u8 * bigboy = 0;
       u64 one_gig = (1<<30);
       u64 size;
-      i64 index;
+      u64 index;
 
       fformat (stdout, "giant vector test...");
       size = 5ULL * one_gig;
@@ -1090,7 +1090,7 @@ int main (int argc, char * argv[])
   unformat_input_t i;
   int ret;
 
-  mheap_alloc (0, 10ULL<<30);
+  mheap_alloc (0, (uword)10ULL<<30);
 
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
index 3c48108..29398f3 100644 (file)
@@ -113,7 +113,14 @@ always_inline u64 clib_cpu_time_now (void)
 }
 
 #elif defined (__arm__)
-
+#if defined(__ARM_ARCH_7A__)
+always_inline u64 clib_cpu_time_now (void)
+{
+  u64 tsc;
+  asm volatile("mrrc p15, 0, %Q0, %R0, c9" : "=r" (tsc));
+  return tsc;
+}
+#else
 always_inline u64 clib_cpu_time_now (void)
 {
   u32 lo;
@@ -121,6 +128,7 @@ always_inline u64 clib_cpu_time_now (void)
                : [lo] "=r" (lo));
   return (u64) lo;
 }
+#endif
 
 #elif defined (__xtensa__)
 
index 84c52a2..a6f4111 100644 (file)
@@ -61,7 +61,7 @@
 
 #define _vector_size(n) __attribute__ ((vector_size (n)))
 
-#if defined (__aarch64__)
+#if defined (__aarch64__) || defined (__arm__)
 typedef unsigned int u32x4 _vector_size (16);
 #endif