Add support for multiple microarchitectures in single binary
[vpp.git] / vnet / vnet / devices / ssvm / ssvm_eth.c
index aad63f0..7c65e21 100644 (file)
@@ -49,6 +49,7 @@ int ssvm_eth_create (ssvm_eth_main_t * em, u8 * name, int is_master)
   intfc->ssvm_size = em->segment_size;
   intfc->i_am_master = 1;
   intfc->name = name;
+  intfc->my_pid = getpid();
   if (is_master == 0)
     {
       rv = ssvm_slave_init (intfc, 20 /* timeout in seconds */);
@@ -94,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);
 
@@ -275,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;
@@ -286,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)
     {
@@ -297,14 +298,14 @@ ssvm_eth_interface_tx (vlib_main_t * vm,
 
       if (PREDICT_TRUE(n_allocated > 0))
        {
-         memcpy (&em->chunk_cache[n_present_in_cache],
+         clib_memcpy (&em->chunk_cache[n_present_in_cache],
                  &elt_indices[n_available - n_allocated],
                  sizeof(u32) * n_allocated);
        }
 
       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;
     }
 
@@ -345,7 +346,7 @@ ssvm_eth_interface_tx (vlib_main_t * vm,
           elt->owner = !i_am_master;
           elt->tag = 1;
          
-          memcpy (elt->data, b0->data + b0->current_data, b0->current_length);
+          clib_memcpy (elt->data, b0->data + b0->current_data, b0->current_length);
           
           if (PREDICT_FALSE (prev_elt != 0))
             prev_elt->next_index = elt - elts;
@@ -473,3 +474,6 @@ VNET_DEVICE_CLASS (ssvm_eth_device_class) = {
   .rx_redirect_to_node = ssvm_eth_set_interface_next_node,
   .no_flatten_output_chains = 1,
 };
+
+VLIB_DEVICE_TX_FUNCTION_MULTIARCH (ssvm_eth_device_class,
+                                  ssvm_eth_interface_tx)