Add support for multiple microarchitectures in single binary
[vpp.git] / vnet / vnet / devices / af_packet / node.c
index 1739cb3..0c608ea 100644 (file)
@@ -180,7 +180,7 @@ af_packet_device_input_fn  (vlib_main_t * vm, vlib_node_runtime_t * node,
              /* copy data */
              u32 bytes_to_copy = data_len > n_buffer_bytes ? n_buffer_bytes : data_len;
              b0->current_data = 0;
-             memcpy (vlib_buffer_get_current (b0), (u8 *) tph + tph->tp_mac + offset, bytes_to_copy);
+             clib_memcpy (vlib_buffer_get_current (b0), (u8 *) tph + tph->tp_mac + offset, bytes_to_copy);
 
              /* fill buffer header */
              b0->clone_count = 0;
@@ -188,6 +188,11 @@ af_packet_device_input_fn  (vlib_main_t * vm, vlib_node_runtime_t * node,
 
              if (offset == 0)
                {
+#if DPDK > 0
+                 struct rte_mbuf * mb = rte_mbuf_from_vlib_buffer(b0);
+                 rte_pktmbuf_data_len (mb) = b0->current_length;
+                 rte_pktmbuf_pkt_len (mb) = b0->current_length;
+#endif
                  b0->total_length_not_including_first_buffer = 0;
                  b0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID;
                  vnet_buffer(b0)->sw_if_index[VLIB_RX] = apif->sw_if_index;
@@ -217,7 +222,7 @@ af_packet_device_input_fn  (vlib_main_t * vm, vlib_node_runtime_t * node,
              tr = vlib_add_trace (vm, node, first_b0, sizeof (*tr));
              tr->next_index = next0;
              tr->hw_if_index = apif->hw_if_index;
-             memcpy(&tr->tph, tph, sizeof(struct tpacket2_hdr));
+             clib_memcpy(&tr->tph, tph, sizeof(struct tpacket2_hdr));
            }
          /* enque and take next packet */
          vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
@@ -255,13 +260,13 @@ af_packet_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
 
   clib_bitmap_foreach (i, apm->pending_input_bitmap,
     ({
+      clib_bitmap_set (apm->pending_input_bitmap, i, 0);
       n_rx_packets += af_packet_device_input_fn(vm, node, frame, i);
     }));
 
   return n_rx_packets;
 }
 
-
 VLIB_REGISTER_NODE (af_packet_input_node) = {
   .function = af_packet_input_fn,
   .name = "af-packet-input",
@@ -277,3 +282,6 @@ VLIB_REGISTER_NODE (af_packet_input_node) = {
     [AF_PACKET_INPUT_NEXT_ETHERNET_INPUT] = "ethernet-input",
   },
 };
+
+VLIB_NODE_FUNCTION_MULTIARCH (af_packet_input_node, af_packet_input_fn)
+