if (!is_tso && !(b->flags & VNET_BUFFER_F_OFFLOAD))
return 0;
- u32 oflags = vnet_buffer2 (b)->oflags;
+ vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
u32 is_tcp = is_tso || oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM;
u32 is_udp = !is_tso && oflags & VNET_BUFFER_OFFLOAD_F_UDP_CKSUM;
+
+ if (!is_tcp && !is_udp)
+ return 0;
+
u32 is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
u32 is_ip6 = b->flags & VNET_BUFFER_F_IS_IP6;
- ASSERT (!is_tcp || !is_udp);
+
+ ASSERT (!(is_tcp && is_udp));
ASSERT (is_ip4 || is_ip6);
i16 l2_hdr_offset = b->current_data;
i16 l3_hdr_offset = vnet_buffer (b)->l3_hdr_offset;
ip6_header_t *ip6 = (void *) (b->data + l3_hdr_offset);
tcp_header_t *tcp = (void *) (b->data + l4_hdr_offset);
udp_header_t *udp = (void *) (b->data + l4_hdr_offset);
- u16 l4_len =
- is_tcp ? tcp_header_bytes (tcp) : is_udp ? sizeof (udp_header_t) : 0;
+ u16 l4_len = is_tcp ? tcp_header_bytes (tcp) : sizeof (udp_header_t);
u16 sum = 0;
flags |= AVF_TXD_OFFSET_MACLEN (l2_len) |
AVF_TXD_OFFSET_IPLEN (l3_len) | AVF_TXD_OFFSET_L4LEN (l4_len);
flags |= is_ip4 ? AVF_TXD_CMD_IIPT_IPV4 : AVF_TXD_CMD_IIPT_IPV6;
- flags |= is_tcp ? AVF_TXD_CMD_L4T_TCP : is_udp ? AVF_TXD_CMD_L4T_UDP : 0;
+ flags |= is_tcp ? AVF_TXD_CMD_L4T_TCP : AVF_TXD_CMD_L4T_UDP;
if (is_ip4)
ip4->checksum = 0;
ip6->payload_length = 0;
}
- if (is_tcp || is_udp)
- {
if (is_ip4)
{
struct avf_ip4_psh psh = { 0 };
psh.l4len = is_tso ? 0 : ip6->payload_length;
sum = ~ip_csum (&psh, sizeof (psh));
}
- }
+
/* ip_csum does a byte swap for some reason... */
sum = clib_net_to_host_u16 (sum);
if (is_tcp)
tcp->checksum = sum;
- else if (is_udp)
+ else
udp->checksum = sum;
return flags;
}
{
vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
avf_device_t *ad = avf_get_device (rd->dev_instance);
- u32 thread_index = vm->thread_index;
- u8 qid = thread_index;
- avf_txq_t *txq = vec_elt_at_index (ad->txqs, qid % ad->num_queue_pairs);
- u16 next = txq->next;
+ vnet_hw_if_tx_frame_t *tf = vlib_frame_scalar_args (frame);
+ u8 qid = tf->queue_id;
+ avf_txq_t *txq = vec_elt_at_index (ad->txqs, qid);
+ u16 next;
u16 mask = txq->size - 1;
u32 *buffers = vlib_frame_vector_args (frame);
u16 n_enq, n_left, n_desc, *slot;
u16 n_retry = 2;
- clib_spinlock_lock_if_init (&txq->lock);
+ if (tf->shared_queue)
+ clib_spinlock_lock (&txq->lock);
n_left = frame->n_vectors;
retry:
+ next = txq->next;
/* release consumed bufs */
if (txq->n_enqueued)
{
AVF_TX_ERROR_NO_FREE_SLOTS, n_left);
}
- clib_spinlock_unlock_if_init (&txq->lock);
+ if (tf->shared_queue)
+ clib_spinlock_unlock (&txq->lock);
return frame->n_vectors - n_left;
}