Skip to contentSkip to conversation

virtio: use zeroed memory for simple TX header

PATCH Applied Rich Lane 4 participants 6 messages Apr 5, 2016 – Apr 6, 2016 Network drivers

lore
Share & tools
lore

Rich Lane

author
#0 lore raw

PATCH v2 1/1 virtio: use zeroed memory for simple TX header

For simple TX the virtio-net header must be zeroed, but it was using memory that had been initialized with indirect descriptor tables. This resulted in "unsupported gso type" errors from librte_vhost.

We can use the same memory for every descriptor to save cachelines in the vswitch.

Fixes 6dc5de3a (virtio: use indirect ring elements)

---
v1-v2:
- Use offsetof to get address of tx_hdr

 drivers/net/virtio/virtio_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio/virtio_rxtx.c +1 -1
index 2b88efd..ef21d8e 100644
@@ -377,7 +377,7 @@ virtio_dev_vring_start(struct virtqueue *vq, int queue_type)
 				vq->vq_ring.desc[i + mid_idx].next = i;
 				vq->vq_ring.desc[i + mid_idx].addr =
 					vq->virtio_net_hdr_mem +
-						i * vq->hw->vtnet_hdr_size;
+					offsetof(struct virtio_tx_region, tx_hdr);
 				vq->vq_ring.desc[i + mid_idx].len =
 					vq->hw->vtnet_hdr_size;
 				vq->vq_ring.desc[i + mid_idx].flags =
Signature · 1 line
1.9.1
#1 lore raw

Hi,

Quoted 6 lines · Rich Lane

For simple TX the virtio-net header must be zeroed, but it was using memory that had been initialized with indirect descriptor tables. This resulted in "unsupported gso type" errors from librte_vhost.

We can use the same memory for every descriptor to save cachelines in the vswitch.

Pointing all virtio_net_hdr into the same memory may brings performance, but how much? It also introduces difficulty to adding tso in future?

Thanks,
Jianfeng

Quoted 23 lines
Fixes 6dc5de3a (virtio: use indirect ring elements)

---
v1-v2:
- Use offsetof to get address of tx_hdr

  drivers/net/virtio/virtio_rxtx.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio/virtio_rxtx.c +1 -1
index 2b88efd..ef21d8e 100644
@@ -377,7 +377,7 @@ virtio_dev_vring_start(struct virtqueue *vq, int queue_type)
  				vq->vq_ring.desc[i + mid_idx].next = i;
  				vq->vq_ring.desc[i + mid_idx].addr =
  					vq->virtio_net_hdr_mem +
-						i * vq->hw->vtnet_hdr_size;
+					offsetof(struct virtio_tx_region, tx_hdr);
  				vq->vq_ring.desc[i + mid_idx].len =
  					vq->hw->vtnet_hdr_size;
  				vq->vq_ring.desc[i + mid_idx].flags =
#2 lore raw
Quoted 7 lines · Jianfeng

Hi,

Quoted 4 lines · Rich Lane

For simple TX the virtio-net header must be zeroed, but it was using memory that had been initialized with indirect descriptor tables. This resulted in "unsupported gso type" errors from librte_vhost.

Quoted 5 lines
Quoted 2 lines

We can use the same memory for every descriptor to save cachelines in the vswitch.

Pointing all virtio_net_hdr into the same memory may brings performance, but how much? It also introduces difficulty to adding tso in future?

simple rxtx will not be enabled when TSO is enabled.

	--yliu
Acked-by
#3 lore raw

Hi,

Quoted 8 lines · Yuanhan Liu
Quoted 7 lines · Jianfeng

Hi,

Quoted 4 lines · Rich Lane

For simple TX the virtio-net header must be zeroed, but it was using memory that had been initialized with indirect descriptor tables. This resulted in "unsupported gso type" errors from librte_vhost.

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

We can use the same memory for every descriptor to save cachelines in the vswitch.

Pointing all virtio_net_hdr into the same memory may brings performance, but how much? It also introduces difficulty to adding tso in future?

simple rxtx will not be enabled when TSO is enabled.

Yes, I was missing simple rxtx is conflicting with ETH_TXQ_FLAGS_NOOFFLOADS, which indicates that simple rxtx does not want to fill any fields in the hdr.

Thanks,
Jianfeng

Quoted 2 lines
	--yliu
Acked-by on v2 1/1
#4 lore raw
In reply to Rich Lane
Quoted 9 lines · Rich Lane

For simple TX the virtio-net header must be zeroed, but it was using memory that had been initialized with indirect descriptor tables. This resulted in "unsupported gso type" errors from librte_vhost.

We can use the same memory for every descriptor to save cachelines in the vswitch.

Fixes 6dc5de3a (virtio: use indirect ring elements)

Thanks.

	--yliu
#5 lore raw
Quoted 11 lines
Quoted 9 lines

For simple TX the virtio-net header must be zeroed, but it was using memory that had been initialized with indirect descriptor tables. This resulted in "unsupported gso type" errors from librte_vhost.

We can use the same memory for every descriptor to save cachelines in the vswitch.

Fixes 6dc5de3a (virtio: use indirect ring elements)

Applied, thanks