X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fdevices%2Fvirtio%2Fvhost_user_input.c;h=a371e57e8e38b7e60a10f8efede3bf1b1656b475;hb=b232d192f2f77114e26cf7f99b57bcd6140872d0;hp=488764ba0b7035531c7b3ba34faf2bb73ec78749;hpb=5dedae7291236a399a234ac6fa86f16d9030a0d6;p=vpp.git diff --git a/src/vnet/devices/virtio/vhost_user_input.c b/src/vnet/devices/virtio/vhost_user_input.c index 488764ba0b7..a371e57e8e3 100644 --- a/src/vnet/devices/virtio/vhost_user_input.c +++ b/src/vnet/devices/virtio/vhost_user_input.c @@ -426,7 +426,7 @@ vhost_user_if_input (vlib_main_t * vm, /* * For small packets (<2kB), we will not need more than one vlib buffer - * per packet. In case packets are bigger, we will just yeld at some point + * per packet. In case packets are bigger, we will just yield at some point * in the loop and come back later. This is not an issue as for big packet, * processing cost really comes from the memory copy. * The assumption is that big packets will fit in 40 buffers. @@ -544,13 +544,11 @@ vhost_user_if_input (vlib_main_t * vm, /* This depends on the setup but is very consistent * So I think the CPU branch predictor will make a pretty good job * at optimizing the decision. */ - u8 indirect = 0; if (txvq->desc[desc_current].flags & VIRTQ_DESC_F_INDIRECT) { desc_table = map_guest_mem (vui, txvq->desc[desc_current].addr, &map_hint); desc_current = 0; - indirect = 1; if (PREDICT_FALSE (desc_table == 0)) { vlib_error_count (vm, node->node_index, @@ -559,51 +557,42 @@ vhost_user_if_input (vlib_main_t * vm, } } - if (PREDICT_TRUE (vui->is_any_layout) || - (!(desc_table[desc_current].flags & VIRTQ_DESC_F_NEXT))) - { - /* ANYLAYOUT or single buffer */ - desc_data_offset = vui->virtio_net_hdr_sz; - } - else - { - /* CSR case without ANYLAYOUT, skip 1st buffer */ - desc_data_offset = desc_table[desc_current].len; - } + desc_data_offset = vui->virtio_net_hdr_sz; if (enable_csum) { virtio_net_hdr_mrg_rxbuf_t *hdr; u8 *b_data; - u16 current = desc_current; - u32 data_offset = desc_data_offset; + u16 current; - if ((data_offset == desc_table[current].len) && - (desc_table[current].flags & VIRTQ_DESC_F_NEXT)) - { - current = desc_table[current].next; - data_offset = 0; - } - hdr = map_guest_mem (vui, desc_table[current].addr, &map_hint); + hdr = map_guest_mem (vui, desc_table[desc_current].addr, &map_hint); if (PREDICT_FALSE (hdr == 0)) { vlib_error_count (vm, node->node_index, VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, 1); goto out; } - b_data = (u8 *) hdr + data_offset; - if (indirect) + if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { - hdr = map_guest_mem (vui, desc_table[desc_current].addr, - &map_hint); - if (PREDICT_FALSE (hdr == 0)) + if ((desc_data_offset == desc_table[desc_current].len) && + (desc_table[desc_current].flags & VIRTQ_DESC_F_NEXT)) { - vlib_error_count (vm, node->node_index, - VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, 1); - goto out; + current = desc_table[desc_current].next; + b_data = map_guest_mem (vui, desc_table[current].addr, + &map_hint); + if (PREDICT_FALSE (b_data == 0)) + { + vlib_error_count (vm, node->node_index, + VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, + 1); + goto out; + } } + else + b_data = (u8 *) hdr + desc_data_offset; + + vhost_user_handle_rx_offload (b_head, b_data, &hdr->hdr); } - vhost_user_handle_rx_offload (b_head, b_data, &hdr->hdr); } while (1) @@ -654,6 +643,7 @@ vhost_user_if_input (vlib_main_t * vm, } /* Prepare a copy order executed later for the data */ + ASSERT (copy_len < VHOST_USER_COPY_ARRAY_N); vhost_copy_t *cpy = &cpu->copy[copy_len]; copy_len++; u32 desc_data_l = desc_table[desc_current].len - desc_data_offset; @@ -794,6 +784,7 @@ VLIB_REGISTER_NODE (vhost_user_input_node) = { .type = VLIB_NODE_TYPE_INPUT, .name = "vhost-user-input", .sibling_of = "device-input", + .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED, /* Will be enabled if/when hardware is detected. */ .state = VLIB_NODE_STATE_DISABLED,