X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fvmxnet3%2Foutput.c;h=8ba3f99022f8f7497e236bf37ff3ec958aaefb64;hb=5e6184317a0edfa65cef522aee7e6716ccd13909;hp=2a8494ed447cf1228682173b4572ab7dd99d463c;hpb=8b0995366110ff8c97d1d10aaa8291ad465b0b2f;p=vpp.git diff --git a/src/plugins/vmxnet3/output.c b/src/plugins/vmxnet3/output.c index 2a8494ed447..8ba3f99022f 100644 --- a/src/plugins/vmxnet3/output.c +++ b/src/plugins/vmxnet3/output.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include @@ -100,7 +102,7 @@ VNET_DEVICE_CLASS_TX_FN (vmxnet3_device_class) (vlib_main_t * vm, vmxnet3_main_t *vmxm = &vmxnet3_main; vnet_interface_output_runtime_t *rd = (void *) node->runtime_data; vmxnet3_device_t *vd = pool_elt_at_index (vmxm->devices, rd->dev_instance); - u32 *buffers = vlib_frame_args (frame); + u32 *buffers = vlib_frame_vector_args (frame); u32 bi0; vlib_buffer_t *b0; vmxnet3_tx_desc *txd = 0; @@ -108,8 +110,8 @@ VNET_DEVICE_CLASS_TX_FN (vmxnet3_device_class) (vlib_main_t * vm, u16 space_left; u16 n_left = frame->n_vectors; vmxnet3_txq_t *txq; - u32 thread_index = vm->thread_index; - u16 qid = thread_index; + vnet_hw_if_tx_frame_t *tf = vlib_frame_scalar_args (frame); + u16 qid = tf->queue_id, produce; if (PREDICT_FALSE (!(vd->flags & VMXNET3_DEVICE_F_LINK_UP))) { @@ -119,15 +121,20 @@ VNET_DEVICE_CLASS_TX_FN (vmxnet3_device_class) (vlib_main_t * vm, return (0); } - txq = vec_elt_at_index (vd->txqs, qid % vd->num_tx_queues); - clib_spinlock_lock_if_init (&txq->lock); + txq = vec_elt_at_index (vd->txqs, qid); + if (tf->shared_queue) + clib_spinlock_lock (&txq->lock); vmxnet3_txq_release (vm, vd, txq); - while (n_left) + produce = txq->tx_ring.produce; + while (PREDICT_TRUE (n_left)) { u16 space_needed = 1, i; + u32 gso_size = 0; + u32 l4_hdr_sz; vlib_buffer_t *b; + u32 hdr_len = 0; bi0 = buffers[0]; b0 = vlib_get_buffer (vm, bi0); @@ -170,7 +177,6 @@ VNET_DEVICE_CLASS_TX_FN (vmxnet3_device_class) (vlib_main_t * vm, for (i = 0; i < space_needed; i++) { b0 = vlib_get_buffer (vm, bi0); - VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0); desc_idx = txq->tx_ring.produce; @@ -178,32 +184,54 @@ VNET_DEVICE_CLASS_TX_FN (vmxnet3_device_class) (vlib_main_t * vm, txq->tx_ring.bufs[desc_idx] = bi0; txd = &txq->tx_desc[desc_idx]; - txd->address = - vlib_get_buffer_data_physical_address (vm, - bi0) + b0->current_data; + + txd->address = vlib_buffer_get_current_pa (vm, b0); txd->flags[0] = generation | b0->current_length; + txd->flags[1] = 0; + if (PREDICT_FALSE (b0->flags & VNET_BUFFER_F_GSO)) + { + /* + * We should not be getting GSO outbound traffic unless it is + * lro is enable + */ + ASSERT (vd->gso_enable == 1); + gso_size = vnet_buffer2 (b0)->gso_size; + l4_hdr_sz = vnet_buffer2 (b0)->gso_l4_hdr_sz; + if (b0->flags & VNET_BUFFER_F_IS_IP6) + hdr_len = sizeof (ethernet_header_t) + sizeof (ip6_header_t) + + l4_hdr_sz; + else + hdr_len = sizeof (ethernet_header_t) + sizeof (ip4_header_t) + + l4_hdr_sz; + } generation = txq->tx_ring.gen; - - txd->flags[1] = 0; bi0 = b0->next_buffer; } - - txd->flags[1] = VMXNET3_TXF_CQ | VMXNET3_TXF_EOP; + if (PREDICT_FALSE (gso_size != 0)) + { + txq->tx_desc[first_idx].flags[1] = hdr_len; + txq->tx_desc[first_idx].flags[1] |= VMXNET3_TXF_OM (VMXNET3_OM_TSO); + txq->tx_desc[first_idx].flags[0] |= VMXNET3_TXF_MSSCOF (gso_size); + } + txd->flags[1] |= VMXNET3_TXF_CQ | VMXNET3_TXF_EOP; asm volatile ("":::"memory"); /* * Now toggle back the generation bit for the first segment. * Device can start reading the packet */ txq->tx_desc[first_idx].flags[0] ^= VMXNET3_TXF_GEN; - vmxnet3_reg_write (vd, 0, VMXNET3_REG_TXPROD, txq->tx_ring.produce); buffers++; n_left--; } - clib_spinlock_unlock_if_init (&txq->lock); + if (PREDICT_TRUE (produce != txq->tx_ring.produce)) + vmxnet3_reg_write_inline (vd, 0, txq->reg_txprod, txq->tx_ring.produce); + + if (tf->shared_queue) + clib_spinlock_unlock (&txq->lock); return (frame->n_vectors - n_left); }