Add support for multiple microarchitectures in single binary
[vpp.git] / vnet / vnet / devices / af_packet / device.c
index c00c689..0671d9e 100644 (file)
@@ -47,7 +47,7 @@ static u8 * format_af_packet_device_name (u8 * s, va_list * args)
 {
   u32 i = va_arg (*args, u32);
   af_packet_main_t * apm = &af_packet_main;
-  af_packet_if_t * apif = vec_elt_at_index (apm->interfaces, i);
+  af_packet_if_t * apif = pool_elt_at_index (apm->interfaces, i);
 
   s = format (s, "host-%s", apif->host_if_name);
   return s;
@@ -75,7 +75,7 @@ af_packet_interface_tx (vlib_main_t * vm,
   u32 n_left = frame->n_vectors;
   u32 n_sent = 0;
   vnet_interface_output_runtime_t * rd = (void *) node->runtime_data;
-  af_packet_if_t * apif = vec_elt_at_index (apm->interfaces, rd->dev_instance);
+  af_packet_if_t * apif = pool_elt_at_index (apm->interfaces, rd->dev_instance);
   int block = 0;
   u32 block_size = apif->tx_req->tp_block_size;
   u32 frame_size = apif->tx_req->tp_frame_size;
@@ -106,7 +106,7 @@ af_packet_interface_tx (vlib_main_t * vm,
        {
          b0 = vlib_get_buffer (vm, bi);
          len = b0->current_length;
-         memcpy((u8 *) tph + TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + offset,
+         clib_memcpy((u8 *) tph + TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + offset,
                 vlib_buffer_get_current(b0), len);
          offset += len;
        }
@@ -166,9 +166,17 @@ af_packet_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags
   af_packet_main_t * apm = &af_packet_main;
   vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
   af_packet_if_t * apif = pool_elt_at_index (apm->interfaces, hw->dev_instance);
+  u32 hw_flags;
 
   apif->is_admin_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
 
+  if (apif->is_admin_up)
+    hw_flags = VNET_HW_INTERFACE_FLAG_LINK_UP;
+  else
+    hw_flags = 0;
+
+  vnet_hw_interface_set_flags(vnm, hw_if_index, hw_flags);
+
   return 0;
 }
 
@@ -195,4 +203,7 @@ VNET_DEVICE_CLASS (af_packet_device_class) = {
   .admin_up_down_function = af_packet_interface_admin_up_down,
   .subif_add_del_function = af_packet_subif_add_del_function,
   .no_flatten_output_chains = 1,
-};
\ No newline at end of file
+};
+
+VLIB_DEVICE_TX_FUNCTION_MULTIARCH (af_packet_device_class,
+                                  af_packet_interface_tx)