interface: remove vnet_device_input_runtime_t
[vpp.git] / src / plugins / vmxnet3 / input.c
index 64fdf1c..affc369 100644 (file)
@@ -23,7 +23,7 @@
 #include <vnet/ip/ip6_packet.h>
 #include <vnet/ip/ip4_packet.h>
 #include <vnet/udp/udp_packet.h>
-
+#include <vnet/interface/rx_queue_funcs.h>
 #include <vmxnet3/vmxnet3.h>
 
 #define foreach_vmxnet3_input_error \
@@ -269,7 +269,6 @@ vmxnet3_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
       b0->flags = 0;
       b0->error = 0;
       b0->current_config_index = 0;
-      ASSERT (b0->current_length != 0);
 
       if (PREDICT_FALSE ((rx_comp->index & VMXNET3_RXCI_EOP) &&
                         (rx_comp->len & VMXNET3_RXCL_ERROR)))
@@ -317,12 +316,19 @@ vmxnet3_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
       else if (rx_comp->index & VMXNET3_RXCI_EOP)
        {
          /* end of segment */
-         if (prev_b0)
+         if (PREDICT_TRUE (prev_b0 != 0))
            {
-             prev_b0->flags |= VLIB_BUFFER_NEXT_PRESENT;
-             prev_b0->next_buffer = bi0;
-             hb->total_length_not_including_first_buffer +=
-               b0->current_length;
+             if (PREDICT_TRUE (b0->current_length != 0))
+               {
+                 prev_b0->flags |= VLIB_BUFFER_NEXT_PRESENT;
+                 prev_b0->next_buffer = bi0;
+                 hb->total_length_not_including_first_buffer +=
+                   b0->current_length;
+               }
+             else
+               {
+                 vlib_buffer_free_one (vm, bi0);
+               }
              prev_b0 = 0;
              got_packet = 1;
            }
@@ -387,7 +393,7 @@ vmxnet3_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
              ethernet_header_t *e = (ethernet_header_t *) hb->data;
 
              next[0] = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
-             if (!ethernet_frame_is_tagged (e->type))
+             if (!ethernet_frame_is_tagged (ntohs (e->type)))
                vmxnet3_handle_offload (rx_comp, hb, gso_size);
            }
 
@@ -412,17 +418,18 @@ vmxnet3_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
       next = nexts;
       while (n_trace && n_left)
        {
-         vlib_buffer_t *b;
-         vmxnet3_input_trace_t *tr;
-
-         b = vlib_get_buffer (vm, bi[0]);
-         vlib_trace_buffer (vm, node, next[0], b, /* follow_chain */ 0);
-         tr = vlib_add_trace (vm, node, b, sizeof (*tr));
-         tr->next_index = next[0];
-         tr->hw_if_index = vd->hw_if_index;
-         tr->buffer = *b;
-
-         n_trace--;
+         vlib_buffer_t *b = vlib_get_buffer (vm, bi[0]);
+         if (PREDICT_TRUE
+             (vlib_trace_buffer
+              (vm, node, next[0], b, /* follow_chain */ 0)))
+           {
+             vmxnet3_input_trace_t *tr =
+               vlib_add_trace (vm, node, b, sizeof (*tr));
+             tr->next_index = next[0];
+             tr->hw_if_index = vd->hw_if_index;
+             tr->buffer = *b;
+             n_trace--;
+           }
          n_left--;
          bi++;
          next++;
@@ -462,17 +469,17 @@ VLIB_NODE_FN (vmxnet3_input_node) (vlib_main_t * vm,
 {
   u32 n_rx = 0;
   vmxnet3_main_t *vmxm = &vmxnet3_main;
-  vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
-  vnet_device_and_queue_t *dq;
-
-  foreach_device_and_queue (dq, rt->devices_and_queues)
-  {
-    vmxnet3_device_t *vd;
-    vd = vec_elt_at_index (vmxm->devices, dq->dev_instance);
-    if ((vd->flags & VMXNET3_DEVICE_F_ADMIN_UP) == 0)
-      continue;
-    n_rx += vmxnet3_device_input_inline (vm, node, frame, vd, dq->queue_id);
-  }
+  vnet_hw_if_rxq_poll_vector_t *pv = vnet_hw_if_get_rxq_poll_vector (vm, node);
+  vnet_hw_if_rxq_poll_vector_t *pve;
+
+  vec_foreach (pve, pv)
+    {
+      vmxnet3_device_t *vd;
+      vd = vec_elt_at_index (vmxm->devices, pve->dev_instance);
+      if ((vd->flags & VMXNET3_DEVICE_F_ADMIN_UP) == 0)
+       continue;
+      n_rx += vmxnet3_device_input_inline (vm, node, frame, vd, pve->queue_id);
+    }
   return n_rx;
 }
 
@@ -481,6 +488,7 @@ VLIB_NODE_FN (vmxnet3_input_node) (vlib_main_t * vm,
 VLIB_REGISTER_NODE (vmxnet3_input_node) = {
   .name = "vmxnet3-input",
   .sibling_of = "device-input",
+  .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED,
   .format_trace = format_vmxnet3_input_trace,
   .type = VLIB_NODE_TYPE_INPUT,
   .state = VLIB_NODE_STATE_DISABLED,