vlib: fix trace number accounting
[vpp.git] / src / plugins / dpdk / device / node.c
index e8a11a9..e7d836f 100644 (file)
@@ -287,6 +287,7 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
                   vlib_node_runtime_t * node, u32 thread_index, u16 queue_id)
 {
   uword n_rx_packets = 0, n_rx_bytes;
+  dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, queue_id);
   u32 n_left, n_trace;
   u32 *buffers;
   u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
@@ -324,7 +325,7 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
   bt->error = node->errors[DPDK_ERROR_NONE];
   /* as DPDK is allocating empty buffers from mempool provided before interface
      start for each queue, it is safe to store this in the template */
-  bt->buffer_pool_index = xd->buffer_pool_for_queue[queue_id];
+  bt->buffer_pool_index = rxq->buffer_pool_index;
   bt->ref_count = 1;
   vnet_buffer (bt)->feature_arc_index = 0;
   bt->current_config_index = 0;
@@ -378,7 +379,7 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
          vlib_frame_t *f;
          ethernet_input_frame_t *ef;
          nf = vlib_node_runtime_get_next_frame (vm, node, next_index);
-         f = vlib_get_frame (vm, nf->frame_index);
+         f = vlib_get_frame (vm, nf->frame);
          f->flags = ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX;
 
          ef = vlib_frame_scalar_args (f);
@@ -416,21 +417,28 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
          b0 = vlib_get_buffer (vm, buffers[0]);
          if (single_next == 0)
            next_index = next[0];
-         vlib_trace_buffer (vm, node, next_index, b0, /* follow_chain */ 0);
-
-         dpdk_rx_trace_t *t0 = vlib_add_trace (vm, node, b0, sizeof t0[0]);
-         t0->queue_index = queue_id;
-         t0->device_index = xd->device_index;
-         t0->buffer_index = vlib_get_buffer_index (vm, b0);
-
-         clib_memcpy_fast (&t0->mb, mb[0], sizeof t0->mb);
-         clib_memcpy_fast (&t0->buffer, b0,
-                           sizeof b0[0] - sizeof b0->pre_data);
-         clib_memcpy_fast (t0->buffer.pre_data, b0->data,
-                           sizeof t0->buffer.pre_data);
-         clib_memcpy_fast (&t0->data, mb[0]->buf_addr + mb[0]->data_off,
-                           sizeof t0->data);
-         n_trace--;
+
+         if (PREDICT_TRUE
+             (vlib_trace_buffer
+              (vm, node, next_index, b0, /* follow_chain */ 0)))
+           {
+
+             dpdk_rx_trace_t *t0 =
+               vlib_add_trace (vm, node, b0, sizeof t0[0]);
+             t0->queue_index = queue_id;
+             t0->device_index = xd->device_index;
+             t0->buffer_index = vlib_get_buffer_index (vm, b0);
+
+             clib_memcpy_fast (&t0->mb, mb[0], sizeof t0->mb);
+             clib_memcpy_fast (&t0->buffer, b0,
+                               sizeof b0[0] - sizeof b0->pre_data);
+             clib_memcpy_fast (t0->buffer.pre_data, b0->data,
+                               sizeof t0->buffer.pre_data);
+             clib_memcpy_fast (&t0->data, mb[0]->buf_addr + mb[0]->data_off,
+                               sizeof t0->data);
+             n_trace--;
+           }
+
          n_left--;
          buffers++;
          mb++;
@@ -478,6 +486,7 @@ VLIB_REGISTER_NODE (dpdk_input_node) = {
   .type = VLIB_NODE_TYPE_INPUT,
   .name = "dpdk-input",
   .sibling_of = "device-input",
+  .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED,
 
   /* Will be enabled if/when hardware is detected. */
   .state = VLIB_NODE_STATE_DISABLED,