Fixes for buliding for 32bit targets: 97/16497/6
authorDavid Johnson <davijoh3@cisco.com>
Fri, 14 Dec 2018 19:53:41 +0000 (14:53 -0500)
committerDavid Johnson <davijoh3@cisco.com>
Wed, 2 Jan 2019 15:55:55 +0000 (10:55 -0500)
  * u32/u64/uword mismatches
  * pointer-to-int fixes
  * printf formatting issues
  * issues with incorrect "ULL" and related suffixes
  * structure alignment and padding issues

Change-Id: I70b989007758755fe8211c074f651150680f60b4
Signed-off-by: David Johnson <davijoh3@cisco.com>
33 files changed:
src/plugins/dpdk/ipsec/ipsec.h
src/plugins/flowprobe/node.c
src/plugins/lb/lbhash.h
src/plugins/memif/private.h
src/plugins/unittest/bihash_test.c
src/svm/ssvm.c
src/svm/ssvm.h
src/svm/svm_common.h
src/svm/svm_fifo_segment.c
src/svm/svm_fifo_segment.h
src/svm/test_svm_fifo1.c
src/tests/vnet/session/tcp_echo.c
src/tests/vnet/session/udp_echo.c
src/vcl/ldp.c
src/vcl/sock_test_client.c
src/vcl/sock_test_server.c
src/vcl/vcl_cfg.c
src/vcl/vcl_private.h
src/vcl/vcl_test_client.c
src/vcl/vppcom.c
src/vlibmemory/memory_api.c
src/vnet/classify/vnet_classify.h
src/vnet/devices/virtio/virtio.h
src/vnet/ip/ip6_neighbor.c
src/vnet/session/application.c
src/vnet/session/segment_manager.c
src/vnet/session/session.c
src/vnet/session/session_node.c
src/vppinfra/clib.h
src/vppinfra/crc32.h
src/vppinfra/cuckoo_template.h
src/vppinfra/dlmalloc.c
src/vppinfra/dlmalloc.h

index 7d7ba56..054fe9b 100644 (file)
@@ -74,6 +74,7 @@ typedef struct
 
 typedef struct
 {
+  CLIB_ALIGN_MARK (pad, 8);    /* align up to 8 bytes for 32bit builds */
   char *name;
   enum rte_crypto_sym_xform_type type;
   u32 alg;
@@ -83,7 +84,7 @@ typedef struct
   u8 boundary;
   u8 disabled;
   u8 resources;
-} crypto_alg_t __attribute__ ((aligned (8)));
+} crypto_alg_t;
 
 typedef struct
 {
@@ -128,6 +129,7 @@ typedef struct
 
 typedef struct
 {
+  CLIB_ALIGN_MARK (pad, 16);   /* align up to 16 bytes for 32bit builds */
   struct rte_cryptodev_sym_session *session;
   u64 dev_mask;
 } crypto_session_by_drv_t;
index 79d37f8..2cd754b 100644 (file)
@@ -148,7 +148,7 @@ flowprobe_get_variant (flowprobe_variant_t which,
 /*
  * NTP rfc868 : 2 208 988 800 corresponds to 00:00  1 Jan 1970 GMT
  */
-#define NTP_TIMESTAMP 2208988800L
+#define NTP_TIMESTAMP 2208988800LU
 
 static inline u32
 flowprobe_common_add (vlib_buffer_t * to_b, flowprobe_entry_t * e, u16 offset)
index 5d2ff24..585b377 100644 (file)
@@ -84,7 +84,7 @@ lb_hash_t *lb_hash_alloc(u32 buckets, u32 timeout)
     return NULL;
 
   // Allocate 1 more bucket for prefetch
-  u32 size = ((u64)&((lb_hash_t *)(0))->buckets[0]) +
+  u32 size = ((uword)&((lb_hash_t *)(0))->buckets[0]) +
       sizeof(lb_hash_bucket_t) * (buckets + 1);
   u8 *mem = 0;
   lb_hash_t *h;
index 0116de3..a938b85 100644 (file)
@@ -113,6 +113,7 @@ typedef struct
 
 typedef struct
 {
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   /* ring data */
   memif_ring_t *ring;
   memif_log2_ring_size_t log2_ring_size;
@@ -205,6 +206,7 @@ typedef struct
 
 typedef struct
 {
+  CLIB_ALIGN_MARK (pad, 16);   /* align up to 16 bytes for 32bit builds */
   void *data;
   u32 data_len;
   i16 buffer_offset;
index 3ce41cf..d418ced 100644 (file)
@@ -99,7 +99,7 @@ test_bihash_thread_fn (void *arg)
   BVT (clib_bihash_kv) kv;
   bihash_test_main_t *tm = &bihash_test_main;
   int i, j;
-  u32 my_thread_index = (u32) (u64) arg;
+  u32 my_thread_index = (uword) arg;
 
   while (tm->thread_barrier)
     ;
@@ -150,7 +150,7 @@ test_bihash_threads (bihash_test_main_t * tm)
   for (i = 0; i < tm->nthreads; i++)
     {
       rv = pthread_create (&handle, NULL, test_bihash_thread_fn,
-                          (void *) (u64) i);
+                          (void *) (uword) i);
       if (rv)
        {
          clib_unix_warning ("pthread_create returned %d", rv);
index 73517ae..3e61709 100644 (file)
@@ -177,7 +177,7 @@ map_it:
   return SSVM_API_ERROR_SLAVE_TIMEOUT;
 
 re_map_it:
-  ssvm->requested_va = (u64) sh->ssvm_va;
+  ssvm->requested_va = sh->ssvm_va;
   ssvm->ssvm_size = sh->ssvm_size;
   munmap (sh, MMAP_PAGESIZE);
 
index 5b2bf0d..59b582e 100644 (file)
@@ -64,9 +64,9 @@ typedef struct
   void *heap;
 
   /* Segment must be mapped at this address, or no supper */
-  u64 ssvm_va;
+  uword ssvm_va;
   /* The actual mmap size */
-  u64 ssvm_size;
+  uword ssvm_size;
   u32 master_pid;
   u32 slave_pid;
   u8 *name;
index e523da5..ce07c37 100644 (file)
@@ -66,7 +66,7 @@ typedef struct svm_map_region_args_
 {
   const char *root_path;       /* NULL means use the truly global arena */
   const char *name;
-  u64 baseva;
+  uword baseva;
   u64 size;
   u64 pvt_heap_size;
   uword flags;
@@ -77,6 +77,16 @@ typedef struct svm_map_region_args_
   int gid;
 } svm_map_region_args_t;
 
+/*
+ * Memory mapped to high addresses for session/vppcom/vcl/etc...
+ */
+#if __WORDSIZE == 64
+#define HIGH_SEGMENT_BASEVA (8ULL   << 30)     /* 8GB */
+#elif __WORDSIZE == 32
+#define HIGH_SEGMENT_BASEVA (3584UL << 20)     /* 3.5GB */
+#else
+#error "unknown __WORDSIZE"
+#endif
 
 /*
  * Memory shared across all router instances. Packet buffers, etc
index c72de40..6897e0c 100644 (file)
@@ -575,8 +575,8 @@ svm_fifo_segment_num_free_fifos (svm_fifo_segment_private_t * fifo_segment,
 }
 
 void
-svm_fifo_segment_info (svm_fifo_segment_private_t * seg, uword * address,
-                      u64 * size)
+svm_fifo_segment_info (svm_fifo_segment_private_t * seg, char **address,
+                      size_t * size)
 {
   if (ssvm_type (&seg->ssvm) == SSVM_SEGMENT_PRIVATE)
     {
@@ -587,14 +587,12 @@ svm_fifo_segment_info (svm_fifo_segment_private_t * seg, uword * address,
       heap_header = mheap_header (seg->ssvm.sh->heap);
       *size = heap_header->max_size;
 #else
-      mspace_get_address_and_size (seg->ssvm.sh->heap,
-                                  (unsigned long long *) address,
-                                  (unsigned long long *) size);
+      mspace_get_address_and_size (seg->ssvm.sh->heap, address, size);
 #endif
     }
   else
     {
-      *address = seg->ssvm.sh->ssvm_va;
+      *address = (char *) seg->ssvm.sh->ssvm_va;
       *size = seg->ssvm.ssvm_size;
     }
 }
index a769554..caa9544 100644 (file)
@@ -116,8 +116,8 @@ u32 svm_fifo_segment_index (svm_fifo_segment_main_t * sm,
 u32 svm_fifo_segment_num_fifos (svm_fifo_segment_private_t * fifo_segment);
 u32 svm_fifo_segment_num_free_fifos (svm_fifo_segment_private_t *
                                     fifo_segment, u32 fifo_size_in_bytes);
-void svm_fifo_segment_info (svm_fifo_segment_private_t * seg, uword * address,
-                           u64 * size);
+void svm_fifo_segment_info (svm_fifo_segment_private_t * seg, char **address,
+                           size_t * size);
 
 svm_fifo_segment_private_t
   * svm_fifo_segment_segments_pool (svm_fifo_segment_main_t * sm);
index 0a09916..1e63f80 100644 (file)
@@ -281,7 +281,7 @@ test_ssvm_fifo1 (unformat_input_t * input)
   int verbose = 0;
   int test_id = 0;
 
-  svm_fifo_segment_main_init (sm, 0x200000000ULL, 20);
+  svm_fifo_segment_main_init (sm, HIGH_SEGMENT_BASEVA, 20);
 
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
index e553a3a..1f49ab6 100644 (file)
@@ -1408,7 +1408,7 @@ main (int argc, char **argv)
 
   clib_time_init (&em->clib_time);
   init_error_string_table (em);
-  svm_fifo_segment_main_init (sm, 0x200000000ULL, 20);
+  svm_fifo_segment_main_init (sm, HIGH_SEGMENT_BASEVA, 20);
   unformat_init_command_line (a, argv);
 
   while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT)
index b8c4c5d..813aee2 100644 (file)
@@ -942,7 +942,8 @@ vl_api_unmap_segment_t_handler (vl_api_unmap_segment_t * mp)
   udp_echo_main_t *utm = &udp_echo_main;
   svm_fifo_segment_main_t *sm = &utm->segment_main;
   svm_fifo_segment_private_t *seg;
-  u64 *seg_indexp, segment_handle;
+  uword *seg_indexp;
+  u64 segment_handle;
 
   segment_handle = clib_net_to_host_u64 (mp->segment_handle);
   seg_indexp = hash_get (utm->segments_table, segment_handle);
@@ -1220,7 +1221,7 @@ main (int argc, char **argv)
 
   clib_mem_init_thread_safe (0, 256 << 20);
 
-  svm_fifo_segment_main_init (sm, 0x200000000ULL, 20);
+  svm_fifo_segment_main_init (sm, HIGH_SEGMENT_BASEVA, 20);
 
   vec_validate (utm->rx_buf, 128 << 10);
   utm->session_index_by_vpp_handles = hash_create (0, sizeof (uword));
index 5041556..ee35396 100644 (file)
@@ -959,9 +959,12 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
                                  sizeof (clib_bitmap_t));
 
              rv = vppcom_select (sid_bits,
-                                 readfds ? ldpw->rd_bitmap : NULL,
-                                 writefds ? ldpw->wr_bitmap : NULL,
-                                 exceptfds ? ldpw->ex_bitmap : NULL, 0);
+                                 readfds ? (unsigned long *) ldpw->rd_bitmap
+                                 : NULL,
+                                 writefds ? (unsigned long *) ldpw->wr_bitmap
+                                 : NULL,
+                                 exceptfds ? (unsigned long *)
+                                 ldpw->ex_bitmap : NULL, 0);
              if (rv < 0)
                {
                  errno = -rv;
index 7898797..fb71cd7 100644 (file)
@@ -157,8 +157,9 @@ echo_test_client ()
       _rfdset = rd_fdset;
 
 #ifdef VCL_TEST
-      rv = vppcom_select (nfds, (uint64_t *) rfdset, (uint64_t *) wfdset,
-                         NULL, 0);
+      rv =
+       vppcom_select (nfds, (unsigned long *) rfdset,
+                      (unsigned long *) wfdset, NULL, 0);
 #else
       {
        struct timeval timeout;
@@ -417,8 +418,9 @@ stream_test_client (vcl_test_t test)
       _rfdset = rd_fdset;
 
 #ifdef VCL_TEST
-      rv = vppcom_select (nfds, (uint64_t *) rfdset, (uint64_t *) wfdset,
-                         NULL, 0);
+      rv =
+       vppcom_select (nfds, (unsigned long *) rfdset,
+                      (unsigned long *) wfdset, NULL, 0);
 #else
       {
        struct timeval timeout;
index 354b990..101bc48 100644 (file)
@@ -751,7 +751,7 @@ main (int argc, char **argv)
       _rfdset = ssm->rd_fdset;
 
 #ifdef VCL_TEST
-      rv = vppcom_select (ssm->nfds, (uint64_t *) rfdset, NULL, NULL, 0);
+      rv = vppcom_select (ssm->nfds, (unsigned long *) rfdset, NULL, NULL, 0);
 #else
       {
        struct timeval timeout;
index 8baae82..12a4fd8 100644 (file)
@@ -35,7 +35,7 @@ vppcom_cfg_init (vppcom_cfg_t * vcl_cfg)
   vcl_cfg->heapsize = (256ULL << 20);
   vcl_cfg->max_workers = 16;
   vcl_cfg->vpp_api_q_length = 1024;
-  vcl_cfg->segment_baseva = 0x200000000ULL;
+  vcl_cfg->segment_baseva = HIGH_SEGMENT_BASEVA;
   vcl_cfg->segment_size = (256 << 20);
   vcl_cfg->add_segment_size = (128 << 20);
   vcl_cfg->preallocated_fifo_pairs = 8;
@@ -75,7 +75,8 @@ vppcom_cfg_heapsize (char *conf_fname)
   if (fp == NULL)
     {
       VCFG_DBG (0, "VCL<%d>: using default heapsize %lu (0x%lx)",
-               getpid (), vcl_cfg->heapsize, vcl_cfg->heapsize);
+               getpid (), (unsigned long) vcl_cfg->heapsize,
+               (unsigned long) vcl_cfg->heapsize);
       goto defaulted;
     }
 
@@ -83,7 +84,8 @@ vppcom_cfg_heapsize (char *conf_fname)
   if (argv == NULL)
     {
       VCFG_DBG (0, "VCL<%d>: calloc failed, using default heapsize %lu"
-               " (0x%lx)", getpid (), vcl_cfg->heapsize, vcl_cfg->heapsize);
+               " (0x%lx)", getpid (), (unsigned long) vcl_cfg->heapsize,
+               (unsigned long) vcl_cfg->heapsize);
       goto defaulted;
     }
 
@@ -102,7 +104,8 @@ vppcom_cfg_heapsize (char *conf_fname)
            {
              VCFG_DBG (0, "VCL<%d>: realloc failed, using default "
                        "heapsize %lu (0x%lx)", getpid (),
-                       vcl_cfg->heapsize, vcl_cfg->heapsize);
+                       (unsigned long) vcl_cfg->heapsize,
+                       (unsigned long) vcl_cfg->heapsize);
              goto defaulted;
            }
          argv = tmp;
@@ -110,8 +113,9 @@ vppcom_cfg_heapsize (char *conf_fname)
          if (arg == NULL)
            {
              VCFG_DBG (0, "VCL<%d>: strndup failed, using default "
-                       "heapsize %ld (0x%lx)", getpid (),
-                       vcl_cfg->heapsize, vcl_cfg->heapsize);
+                       "heapsize %lu (0x%lx)", getpid (),
+                       (unsigned long) vcl_cfg->heapsize,
+                       (unsigned long) vcl_cfg->heapsize);
              goto defaulted;
            }
          argv[argc - 1] = arg;
@@ -125,8 +129,9 @@ vppcom_cfg_heapsize (char *conf_fname)
   char **tmp = realloc (argv, (argc + 1) * sizeof (char *));
   if (tmp == NULL)
     {
-      VCFG_DBG (0, "VCL<%d>: realloc failed, using default heapsize %ld "
-               "(0x%lx)", getpid (), vcl_cfg->heapsize, vcl_cfg->heapsize);
+      VCFG_DBG (0, "VCL<%d>: realloc failed, using default heapsize %lu "
+               "(0x%lx)", getpid (), (unsigned long) vcl_cfg->heapsize,
+               (unsigned long) vcl_cfg->heapsize);
       goto defaulted;
     }
   argv = tmp;
@@ -153,8 +158,9 @@ vppcom_cfg_heapsize (char *conf_fname)
          if (size == 0)
            {
              VCFG_DBG (0, "VCL<%d>: parse error '%s %s', using default "
-                       "heapsize %ld (0x%lx)", getpid (), argv[i],
-                       argv[i + 1], vcl_cfg->heapsize, vcl_cfg->heapsize);
+                       "heapsize %lu (0x%lx)", getpid (), argv[i],
+                       argv[i + 1], (unsigned long) vcl_cfg->heapsize,
+                       (unsigned long) vcl_cfg->heapsize);
              goto defaulted;
            }
 
@@ -165,8 +171,9 @@ vppcom_cfg_heapsize (char *conf_fname)
          else
            {
              VCFG_DBG (0, "VCL<%d>: parse error '%s %s', using default "
-                       "heapsize %ld (0x%lx)", getpid (), argv[i],
-                       argv[i + 1], vcl_cfg->heapsize, vcl_cfg->heapsize);
+                       "heapsize %lu (0x%lx)", getpid (), argv[i],
+                       argv[i + 1], (unsigned long) vcl_cfg->heapsize,
+                       (unsigned long) vcl_cfg->heapsize);
              goto defaulted;
            }
        }
@@ -183,10 +190,11 @@ defaulted:
                  MAP_SHARED | MAP_ANONYMOUS, -1, 0);
   if (vcl_mem == MAP_FAILED)
     {
-      VCFG_DBG (0, "VCL<%d>: ERROR: mmap(0, %ld == 0x%lx, "
+      VCFG_DBG (0, "VCL<%d>: ERROR: mmap(0, %lu == 0x%lx, "
                "PROT_READ | PROT_WRITE,MAP_SHARED | MAP_ANONYMOUS, "
-               "-1, 0) failed!", getpid (), vcl_cfg->heapsize,
-               vcl_cfg->heapsize);
+               "-1, 0) failed!", getpid (),
+               (unsigned long) vcl_cfg->heapsize,
+               (unsigned long) vcl_cfg->heapsize);
       ASSERT (vcl_mem != MAP_FAILED);
       return;
     }
@@ -208,8 +216,9 @@ defaulted:
   clib_memcpy (vcl_mem, &_vppcom_main, sizeof (_vppcom_main));
   vcm = vcl_mem;
 
-  VCFG_DBG (0, "VCL<%d>: allocated VCL heap = %p, size %ld (0x%lx)",
-           getpid (), heap, vcl_cfg->heapsize, vcl_cfg->heapsize);
+  VCFG_DBG (0, "VCL<%d>: allocated VCL heap = %p, size %lu (0x%lx)",
+           getpid (), heap, (unsigned long) vcl_cfg->heapsize,
+           (unsigned long) vcl_cfg->heapsize);
 }
 
 void
@@ -264,7 +273,7 @@ vppcom_cfg_read_file (char *conf_fname)
                        &vcl_cfg->heapsize))
            {
              VCFG_DBG (0, "VCL<%d>: configured heapsize %lu", getpid (),
-                       vcl_cfg->heapsize);
+                       (unsigned long) vcl_cfg->heapsize);
            }
          else
            if (unformat
@@ -325,7 +334,7 @@ vppcom_cfg_read_file (char *conf_fname)
                             &vcl_cfg->segment_baseva))
            {
              VCFG_DBG (0, "VCL<%d>: configured segment_baseva 0x%lx",
-                       getpid (), vcl_cfg->segment_baseva);
+                       getpid (), (unsigned long) vcl_cfg->segment_baseva);
            }
          else if (unformat (line_input, "segment-size 0x%x",
                             &vcl_cfg->segment_size))
@@ -463,9 +472,11 @@ vppcom_cfg_read_file (char *conf_fname)
          else if (unformat (line_input, "namespace-secret %lu",
                             &vcl_cfg->namespace_secret))
            {
-             VCFG_DBG (0, "VCL<%d>: configured namespace_secret %lu (0x%lx)",
-                       getpid (), vcl_cfg->namespace_secret,
-                       vcl_cfg->namespace_secret);
+             VCFG_DBG (0,
+                       "VCL<%d>: configured namespace_secret %llu (0x%llx)",
+                       getpid (),
+                       (unsigned long long) vcl_cfg->namespace_secret,
+                       (unsigned long long) vcl_cfg->namespace_secret);
            }
          else if (unformat (line_input, "namespace-id %v",
                             &vcl_cfg->namespace_id))
@@ -576,7 +587,7 @@ vppcom_cfg (vppcom_cfg_t * vcl_cfg)
   if (env_var_str)
     {
       u64 tmp;
-      if (sscanf (env_var_str, "%lu", &tmp) != 1)
+      if (sscanf (env_var_str, "%llu", (unsigned long long *) &tmp) != 1)
        {
          VCFG_DBG (0, "VCL<%d>: WARNING: Invalid namespace secret specified"
                    " in the environment variable "
@@ -586,9 +597,9 @@ vppcom_cfg (vppcom_cfg_t * vcl_cfg)
       else
        {
          vcm->cfg.namespace_secret = tmp;
-         VCFG_DBG (0, "VCL<%d>: configured namespace secret (%lu) from "
+         VCFG_DBG (0, "VCL<%d>: configured namespace secret (%llu) from "
                    VPPCOM_ENV_APP_NAMESPACE_SECRET "!", getpid (),
-                   vcm->cfg.namespace_secret);
+                   (unsigned long long) vcm->cfg.namespace_secret);
        }
     }
   if (getenv (VPPCOM_ENV_APP_PROXY_TRANSPORT_TCP))
index 3d6c85e..34098ac 100644 (file)
@@ -180,10 +180,10 @@ typedef struct
 
 typedef struct vppcom_cfg_t_
 {
-  u64 heapsize;
+  uword heapsize;
   u32 max_workers;
   u32 vpp_api_q_length;
-  u64 segment_baseva;
+  uword segment_baseva;
   u32 segment_size;
   u32 add_segment_size;
   u32 preallocated_fifo_pairs;
index 59286ee..e1d7b3b 100644 (file)
@@ -350,8 +350,8 @@ vtc_worker_loop (void *arg)
       _wfdset = wrk->wr_fdset;
       _rfdset = wrk->rd_fdset;
 
-      rv = vppcom_select (wrk->max_fd_index, (uint64_t *) rfdset,
-                         (uint64_t *) wfdset, NULL, 0);
+      rv = vppcom_select (wrk->max_fd_index, (unsigned long *) rfdset,
+                         (unsigned long *) wfdset, NULL, 0);
       if (rv < 0)
        {
          vterr ("vppcom_select()", rv);
index f1c58c4..be72936 100644 (file)
@@ -1944,7 +1944,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
        break;
       if (sid < n_bits && read_map)
        {
-         clib_bitmap_set_no_check (read_map, sid, 1);
+         clib_bitmap_set_no_check ((uword *) read_map, sid, 1);
          *bits_set += 1;
        }
       break;
@@ -1955,7 +1955,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
        break;
       if (sid < n_bits && write_map)
        {
-         clib_bitmap_set_no_check (write_map, sid, 1);
+         clib_bitmap_set_no_check ((uword *) write_map, sid, 1);
          *bits_set += 1;
        }
       break;
@@ -1967,7 +1967,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
       sid = session->session_index;
       if (sid < n_bits && read_map)
        {
-         clib_bitmap_set_no_check (read_map, sid, 1);
+         clib_bitmap_set_no_check ((uword *) read_map, sid, 1);
          *bits_set += 1;
        }
       break;
@@ -1978,7 +1978,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
       sid = session->session_index;
       if (sid < n_bits && write_map)
        {
-         clib_bitmap_set_no_check (write_map, sid, 1);
+         clib_bitmap_set_no_check ((uword *) write_map, sid, 1);
          *bits_set += 1;
        }
       break;
@@ -1990,7 +1990,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
       sid = session->session_index;
       if (sid < n_bits && read_map)
        {
-         clib_bitmap_set_no_check (read_map, sid, 1);
+         clib_bitmap_set_no_check ((uword *) read_map, sid, 1);
          *bits_set += 1;
        }
       break;
@@ -2006,7 +2006,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
       sid = session->session_index;
       if (sid < n_bits && except_map)
        {
-         clib_bitmap_set_no_check (except_map, sid, 1);
+         clib_bitmap_set_no_check ((uword *) except_map, sid, 1);
          *bits_set += 1;
        }
       break;
@@ -2014,7 +2014,7 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
       sid = vcl_session_reset_handler (wrk, (session_reset_msg_t *) e->data);
       if (sid < n_bits && except_map)
        {
-         clib_bitmap_set_no_check (except_map, sid, 1);
+         clib_bitmap_set_no_check ((uword *) except_map, sid, 1);
          *bits_set += 1;
        }
       break;
@@ -2144,30 +2144,35 @@ vppcom_select (unsigned long n_bits, unsigned long *read_map,
   vcl_session_t *session = 0;
   int rv, i;
 
-  ASSERT (sizeof (clib_bitmap_t) == sizeof (long int));
+  STATIC_ASSERT (sizeof (clib_bitmap_t) == sizeof (unsigned long),
+                "vppcom bitmap size mismatch");
+  STATIC_ASSERT (sizeof (clib_bitmap_t) == sizeof (fd_mask),
+                "vppcom bitmap size mismatch");
+  STATIC_ASSERT (sizeof (clib_bitmap_t) == sizeof (uword),
+                "vppcom bitmap size mismatch");
 
   if (n_bits && read_map)
     {
       clib_bitmap_validate (wrk->rd_bitmap, minbits);
       clib_memcpy_fast (wrk->rd_bitmap, read_map,
-                       vec_len (wrk->rd_bitmap) * sizeof (clib_bitmap_t));
-      memset (read_map, 0, vec_len (wrk->rd_bitmap) * sizeof (clib_bitmap_t));
+                       vec_len (wrk->rd_bitmap) * sizeof (unsigned long));
+      memset (read_map, 0, vec_len (wrk->rd_bitmap) * sizeof (unsigned long));
     }
   if (n_bits && write_map)
     {
       clib_bitmap_validate (wrk->wr_bitmap, minbits);
       clib_memcpy_fast (wrk->wr_bitmap, write_map,
-                       vec_len (wrk->wr_bitmap) * sizeof (clib_bitmap_t));
+                       vec_len (wrk->wr_bitmap) * sizeof (unsigned long));
       memset (write_map, 0,
-             vec_len (wrk->wr_bitmap) * sizeof (clib_bitmap_t));
+             vec_len (wrk->wr_bitmap) * sizeof (unsigned long));
     }
   if (n_bits && except_map)
     {
       clib_bitmap_validate (wrk->ex_bitmap, minbits);
       clib_memcpy_fast (wrk->ex_bitmap, except_map,
-                       vec_len (wrk->ex_bitmap) * sizeof (clib_bitmap_t));
+                       vec_len (wrk->ex_bitmap) * sizeof (unsigned long));
       memset (except_map, 0,
-             vec_len (wrk->ex_bitmap) * sizeof (clib_bitmap_t));
+             vec_len (wrk->ex_bitmap) * sizeof (unsigned long));
     }
 
   if (!n_bits)
@@ -2188,7 +2193,7 @@ vppcom_select (unsigned long n_bits, unsigned long *read_map,
     rv = svm_fifo_is_full (session->tx_fifo);
     if (!rv)
       {
-        clib_bitmap_set_no_check (write_map, sid, 1);
+        clib_bitmap_set_no_check ((uword*)write_map, sid, 1);
         bits_set++;
       }
   }));
@@ -2208,7 +2213,7 @@ check_rd:
     rv = vppcom_session_read_ready (session);
     if (rv)
       {
-        clib_bitmap_set_no_check (read_map, sid, 1);
+        clib_bitmap_set_no_check ((uword*)read_map, sid, 1);
         bits_set++;
       }
   }));
index cb15f0c..1727c28 100644 (file)
@@ -326,8 +326,8 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
          if (am->vlib_private_rps[i] == svm)
            {
              /* Note: account for the memfd header page */
-             u64 virtual_base = svm->virtual_base - MMAP_PAGESIZE;
-             u64 virtual_size = svm->virtual_size + MMAP_PAGESIZE;
+             uword virtual_base = svm->virtual_base - MMAP_PAGESIZE;
+             uword virtual_size = svm->virtual_size + MMAP_PAGESIZE;
 
              /*
               * Kill the registration pool element before we make
@@ -650,8 +650,8 @@ vl_mem_api_dead_client_scan (api_main_t * am, vl_shmem_hdr_t * shm, f64 now)
                  int i;
                  svm_region_t *dead_rp = (*regpp)->vlib_rp;
                  /* Note: account for the memfd header page */
-                 u64 virtual_base = dead_rp->virtual_base - MMAP_PAGESIZE;
-                 u64 virtual_size = dead_rp->virtual_size + MMAP_PAGESIZE;
+                 uword virtual_base = dead_rp->virtual_base - MMAP_PAGESIZE;
+                 uword virtual_size = dead_rp->virtual_size + MMAP_PAGESIZE;
 
                  /* For horizontal scaling, add a hash table... */
                  for (i = 0; i < vec_len (am->vlib_private_rps); i++)
index 4fea95d..2bc1224 100644 (file)
@@ -149,6 +149,7 @@ typedef struct
 
 typedef struct
 {
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   /* Mask to apply after skipping N vectors */
   u32x4 *mask;
   /* Buckets and entries */
index 5fc5216..e401f2d 100644 (file)
@@ -73,6 +73,7 @@ typedef enum
 
 typedef struct
 {
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   struct vring_desc *desc;
   struct vring_used *used;
   struct vring_avail *avail;
index a7ce279..f9acfef 100755 (executable)
@@ -2348,7 +2348,7 @@ create_buffer_for_rs (vlib_main_t * vm, ip6_radv_t * radv_info)
   rh->ip.hop_limit = 255;
   rh->ip.src_address = radv_info->link_local_address;
   /* set address ff02::2 */
-  rh->ip.dst_address.as_u64[0] = clib_host_to_net_u64 (0xff02L << 48);
+  rh->ip.dst_address.as_u64[0] = clib_host_to_net_u64 (0xff02ULL << 48);
   rh->ip.dst_address.as_u64[1] = clib_host_to_net_u64 (2);
 
   rh->neighbor.icmp.checksum = ip6_tcp_udp_icmp_compute_checksum (vm, p0,
index 01dc818..19c8fa2 100644 (file)
@@ -1695,14 +1695,14 @@ failed:
   return rv;
 }
 
-static uword
+static u64
 application_client_local_connect_key (local_session_t * ls)
 {
-  return ((uword) ls->app_wrk_index << 32 | (uword) ls->session_index);
+  return (((u64) ls->app_wrk_index) << 32 | (u64) ls->session_index);
 }
 
 static void
-application_client_local_connect_key_parse (uword key, u32 * app_wrk_index,
+application_client_local_connect_key_parse (u64 key, u32 * app_wrk_index,
                                            u32 * session_index)
 {
   *app_wrk_index = key >> 32;
@@ -1718,7 +1718,7 @@ application_local_session_connect_notify (local_session_t * ls)
   application_t *client;
   int rv, is_fail = 0;
   u64 segment_handle;
-  uword client_key;
+  u64 client_key;
 
   client_wrk = app_worker_get (ls->client_wrk_index);
   server_wrk = app_worker_get (ls->app_wrk_index);
@@ -1759,7 +1759,7 @@ application_local_session_cleanup (app_worker_t * client_wrk,
   svm_fifo_segment_private_t *seg;
   stream_session_t *listener;
   segment_manager_t *sm;
-  uword client_key;
+  u64 client_key;
   u8 has_transport;
 
   /* Retrieve listener transport type as it is the one that decides where
@@ -2179,7 +2179,7 @@ app_worker_format_local_connects (app_worker_t * app, int verbose)
   u32 app_wrk_index, session_index;
   app_worker_t *server_wrk;
   local_session_t *ls;
-  uword client_key;
+  u64 client_key;
   u64 value;
 
   /* Header */
index 2b8a732..e48e951 100644 (file)
@@ -186,7 +186,7 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
   segment_manager_main_t *smm = &segment_manager_main;
   u32 rnd_margin = 128 << 10, seg_index, page_size;
   segment_manager_properties_t *props;
-  uword baseva = (u64) ~ 0, alloc_size;
+  uword baseva = (uword) ~ 0ULL, alloc_size;
   svm_fifo_segment_private_t *seg;
   u8 *seg_name;
   int rv;
@@ -735,8 +735,8 @@ segment_manager_show_fn (vlib_main_t * vm, unformat_input_t * input,
   svm_fifo_segment_private_t *seg;
   segment_manager_t *sm;
   u8 show_segments = 0, verbose = 0;
-  uword address;
-  u64 size;
+  char *address;
+  size_t size;
   u32 active_fifos;
   u32 free_fifos;
 
index d30254e..4cf0f9e 100644 (file)
@@ -1539,9 +1539,14 @@ clib_error_t *
 session_manager_main_init (vlib_main_t * vm)
 {
   session_manager_main_t *smm = &session_manager_main;
-  smm->session_baseva = 0x200000000ULL;
-  smm->session_va_space_size = (u64) 128 << 30;
+  smm->session_baseva = HIGH_SEGMENT_BASEVA;
+#if (HIGH_SEGMENT_BASEVA > (4ULL << 30))
+  smm->session_va_space_size = 128ULL << 30;
   smm->evt_qs_segment_size = 64 << 20;
+#else
+  smm->session_va_space_size = 128 << 20;
+  smm->evt_qs_segment_size = 1 << 20;
+#endif
   smm->is_enabled = 0;
   return 0;
 }
index a01f01c..98965f3 100644 (file)
@@ -589,8 +589,8 @@ session_tx_fifo_read_and_snd_i (vlib_main_t * vm, vlib_node_runtime_t * node,
     }
 
   ctx->snd_space = transport_connection_snd_space (ctx->tc,
-                                                  vm->
-                                                  clib_time.last_cpu_time,
+                                                  vm->clib_time.
+                                                  last_cpu_time,
                                                   ctx->snd_mss);
   if (ctx->snd_space == 0 || ctx->snd_mss == 0)
     {
@@ -1008,7 +1008,8 @@ dump_thread_0_event_queue (void)
 
        case FIFO_EVENT_RPC:
          fformat (stdout, "[%04d] RPC call %llx with %llx\n",
-                  i, (u64) (e->rpc_args.fp), (u64) (e->rpc_args.arg));
+                  i, (u64) (uword) (e->rpc_args.fp),
+                  (u64) (uword) (e->rpc_args.arg));
          break;
 
        default:
index 95dadd9..8aec1f1 100644 (file)
@@ -81,6 +81,9 @@
 #define CLIB_PACKED(x) x __attribute__ ((packed))
 #define CLIB_UNUSED(x) x __attribute__ ((unused))
 
+/* similar to CLIB_CACHE_LINE_ALIGN_MARK() but with arbitrary alignment */
+#define CLIB_ALIGN_MARK(name, alignment) u8 name[0] __attribute__((aligned(alignment)))
+
 /* Make a string from the macro's argument */
 #define CLIB_STRING_MACRO(x) #x
 
index 5f4d94f..fec67cd 100644 (file)
@@ -30,14 +30,14 @@ clib_crc32c (u8 * s, int len)
 {
   u32 v = 0;
 
-#if __x86_64__
+#if defined(__x86_64__)
   for (; len >= 8; len -= 8, s += 8)
     v = _mm_crc32_u64 (v, *((u64 *) s));
 #else
   /* workaround weird GCC bug when using _mm_crc32_u32
      which happens with -O2 optimization */
 #if !defined (__i686__)
-  volatile ("":::"memory");
+  asm volatile ("":::"memory");
 #endif
 #endif
 
index eccbde1..c3b2bc9 100644 (file)
@@ -291,7 +291,7 @@ typedef struct CV (clib_cuckoo)
 } CVT (clib_cuckoo);
 
 void CV (clib_cuckoo_init) (CVT (clib_cuckoo) * h, const char *name,
-                           u64 nbuckets,
+                           uword nbuckets,
                            void (*garbage_callback) (CVT (clib_cuckoo) *,
                                                      void *),
                            void *garbage_ctx);
index 8a07621..9ed1e04 100644 (file)
@@ -4089,8 +4089,7 @@ size_t destroy_mspace(mspace msp) {
   return freed;
 }
 
-void mspace_get_address_and_size (mspace msp, unsigned long long *addrp,
-                                  unsigned long long *sizep)
+void mspace_get_address_and_size (mspace msp, char **addrp, size_t *sizep)
 {
   mstate ms;
   msegment *this_seg;
@@ -4098,7 +4097,7 @@ void mspace_get_address_and_size (mspace msp, unsigned long long *addrp,
   ms = (mstate)msp;
   this_seg = &ms->seg;
 
-  *addrp = (unsigned long long) this_seg->base;
+  *addrp = this_seg->base;
   *sizep = this_seg->size;
 }
 
@@ -4157,11 +4156,11 @@ int mspace_enable_disable_trace (mspace msp, int enable)
 }
 
 void* mspace_get_aligned (mspace msp, 
-                          unsigned long long n_user_data_bytes,
-                          unsigned long long align, 
-                          unsigned long long align_offset) {
+                          unsigned long n_user_data_bytes,
+                          unsigned long align, 
+                          unsigned long align_offset) {
   char *rv;
-  unsigned long long searchp;
+  unsigned long searchp;
   unsigned *wwp;                /* "where's Waldo" pointer */
   mstate ms = (mstate)msp;
 
@@ -4183,7 +4182,7 @@ void* mspace_get_aligned (mspace msp,
       mchunkptr p  = mem2chunk(rv);
       size_t psize = chunksize(p);
       
-      mheap_get_trace ((u64)rv + sizeof (unsigned), psize);
+      mheap_get_trace ((unsigned long)rv + sizeof (unsigned), psize);
     }
 
     wwp = (unsigned *)rv;
@@ -4201,7 +4200,7 @@ void* mspace_get_aligned (mspace msp,
    * Waldo is the address of the chunk of memory returned by mspace_malloc, 
    * which we need later to call mspace_free...
    */
-  if (align > 4<<10 || align_offset == ~0ULL) {
+  if (align > 4<<10 || align_offset == ~0UL) {
     n_user_data_bytes -= sizeof(unsigned);
     assert(align_offset == 0);
     rv = internal_memalign(ms, (size_t)align, n_user_data_bytes);
@@ -4210,7 +4209,7 @@ void* mspace_get_aligned (mspace msp,
     if (rv && use_trace(ms)) {
       mchunkptr p  = mem2chunk(rv);
       size_t psize = chunksize(p);
-      mheap_get_trace ((u64)rv, psize);
+      mheap_get_trace ((unsigned long)rv, psize);
     }
     return rv;
   }
@@ -4228,7 +4227,7 @@ void* mspace_get_aligned (mspace msp,
       return rv;
 
   /* Honor the alignment request */
-  searchp = (unsigned long long)(rv + sizeof (unsigned));
+  searchp = (unsigned long)(rv + sizeof (unsigned));
 
 #if 0  /* this is the idea... */
   while ((searchp + align_offset) % align)
@@ -4236,7 +4235,7 @@ void* mspace_get_aligned (mspace msp,
 #endif
 
   {
-    unsigned long long where_now, delta;
+    unsigned long where_now, delta;
 
     where_now = (searchp + align_offset) % align;
     delta = align - where_now;
@@ -4245,13 +4244,13 @@ void* mspace_get_aligned (mspace msp,
   }
 
   wwp = (unsigned *)(searchp - sizeof(unsigned));
-  *wwp = (searchp - (((unsigned long long) rv) + sizeof (*wwp)));
+  *wwp = (searchp - (((unsigned long) rv) + sizeof (*wwp)));
   assert (*wwp < align);
 
   if (use_trace(ms)) {
     mchunkptr p  = mem2chunk(rv);
     size_t psize = chunksize(p);
-    mheap_get_trace ((u64)rv, psize);
+    mheap_get_trace ((unsigned long)rv, psize);
   }
   return (void *) searchp;
 }
@@ -4276,7 +4275,7 @@ void mspace_put (mspace msp, void *p_arg)
       mchunkptr p  = mem2chunk(object_header);
       size_t psize = chunksize(p);
 
-      mheap_put_trace ((u64)p_arg, psize);
+      mheap_put_trace ((unsigned long)p_arg, psize);
     }
 
 #if CLIB_DEBUG > 0
@@ -4300,7 +4299,7 @@ void mspace_put_no_offset (mspace msp, void *p_arg)
       mchunkptr p  = mem2chunk(p_arg);
       size_t psize = chunksize(p);
 
-      mheap_put_trace ((u64)p_arg, psize);
+      mheap_put_trace ((unsigned long)p_arg, psize);
     }
   mspace_free (msp, p_arg);
 }
index b7a8eea..216df47 100644 (file)
@@ -1448,22 +1448,20 @@ DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad);
 DLMALLOC_EXPORT int mspace_mallopt(int, int);
 
 DLMALLOC_EXPORT void* mspace_get_aligned (mspace msp, 
-                                          unsigned long long n_user_data_bytes,
-                                          unsigned long long align, 
-                                          unsigned long long align_offset);
+                                          unsigned long n_user_data_bytes,
+                                          unsigned long align, 
+                                          unsigned long align_offset);
 
 DLMALLOC_EXPORT int mspace_is_heap_object (mspace msp, void *p);
 
-DLMALLOC_EXPORT void mspace_get_address_and_size (mspace msp, 
-                                                  unsigned long long *addrp,
-                                                  unsigned long long *sizep);
+DLMALLOC_EXPORT void mspace_get_address_and_size (mspace msp, char **addrp, size_t *sizep);
 DLMALLOC_EXPORT void mspace_put (mspace msp, void *p);
 DLMALLOC_EXPORT void mspace_put_no_offset (mspace msp, void *p);
 DLMALLOC_EXPORT size_t mspace_usable_size_with_delta (const void *p);
 DLMALLOC_EXPORT void mspace_disable_expand (mspace msp);
 DLMALLOC_EXPORT void *mspace_least_addr (mspace msp);
-DLMALLOC_EXPORT void mheap_get_trace (u64 offset, u64 size);
-DLMALLOC_EXPORT void mheap_put_trace (u64 offset, u64 size);
+DLMALLOC_EXPORT void mheap_get_trace (uword offset, uword size);
+DLMALLOC_EXPORT void mheap_put_trace (uword offset, uword size);
 DLMALLOC_EXPORT int mspace_enable_disable_trace (mspace msp, int enable);
 
 #endif /* MSPACES */