Skip to contentSkip to conversation

XDP for virtio_net

PATCH Superseded John Fastabend 2 participants 5 messages Nov 29, 2016 – Dec 1, 2016

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover XDP for virtio_net

This implements virtio_net for the mergeable buffers and big_packet modes. I tested this with vhost_net running on qemu and did not see any issues. For testing num_buf > 1 I added a hack to vhost driver to only but 100 bytes per buffer.

There are some restrictions for XDP to be enabled and work well (see patch 3) for more details.

1. LRO must be off
2. MTU must be less than PAGE_SIZE
3. queues must be available to dedicate to XDP
4. num_bufs received in mergeable buffers must be 1
5. big_packet mode must have all data on single page

Please review any comments/feedback welcome as always.

v2, fixes rcu usage throughout thanks to Eric and the use of num_online_cpus() usage thanks to Jakub.

v3, add slowpath patch to handle num_bufs > 1

Thanks,
John
---

John Fastabend (6):
net: virtio dynamically disable/enable LRO
net: xdp: add invalid buffer warning
virtio_net: Add XDP support
virtio_net: add dedicated XDP transmit queues
virtio_net: add XDP_TX support
virtio_net: xdp, add slowpath case for non contiguous buffers

 drivers/net/virtio_net.c |  344 +++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/filter.h   |    1 
 net/core/filter.c        |    6 +
 3 files changed, 346 insertions(+), 5 deletions(-)
#1 lore raw
Quoted 16 lines · John Fastabend

This implements virtio_net for the mergeable buffers and big_packet modes. I tested this with vhost_net running on qemu and did not see any issues. For testing num_buf > 1 I added a hack to vhost driver to only but 100 bytes per buffer.

There are some restrictions for XDP to be enabled and work well (see patch 3) for more details.

1. LRO must be off
2. MTU must be less than PAGE_SIZE
3. queues must be available to dedicate to XDP
4. num_bufs received in mergeable buffers must be 1
5. big_packet mode must have all data on single page

Please review any comments/feedback welcome as always.

Quoted 7 lines

v2, fixes rcu usage throughout thanks to Eric and the use of num_online_cpus() usage thanks to Jakub.

v3, add slowpath patch to handle num_bufs > 1

Thanks,
John

BTW this is threaded incorrectly: patch 1/6 isn't a reply to 0/6, patches 2 and on are replies to patch 1.

I'm busy until end of week, I'll review Monday. Sorry about the delay.

Quoted 18 lines

---

John Fastabend (6):
net: virtio dynamically disable/enable LRO
net: xdp: add invalid buffer warning
virtio_net: Add XDP support
virtio_net: add dedicated XDP transmit queues
virtio_net: add XDP_TX support
virtio_net: xdp, add slowpath case for non contiguous buffers

 drivers/net/virtio_net.c |  344 +++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/filter.h   |    1 
 net/core/filter.c        |    6 +
 3 files changed, 346 insertions(+), 5 deletions(-)

--
Signature

#2 lore raw
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · John Fastabend

This implements virtio_net for the mergeable buffers and big_packet modes. I tested this with vhost_net running on qemu and did not see any issues. For testing num_buf > 1 I added a hack to vhost driver to only but 100 bytes per buffer.

There are some restrictions for XDP to be enabled and work well (see patch 3) for more details.

1. LRO must be off
2. MTU must be less than PAGE_SIZE
3. queues must be available to dedicate to XDP
4. num_bufs received in mergeable buffers must be 1
5. big_packet mode must have all data on single page

Please review any comments/feedback welcome as always.

v2, fixes rcu usage throughout thanks to Eric and the use of num_online_cpus() usage thanks to Jakub.

Quoted 8 lines
Quoted 4 lines

v3, add slowpath patch to handle num_bufs > 1

Thanks,
John

BTW this is threaded incorrectly: patch 1/6 isn't a reply to 0/6, patches 2 and on are replies to patch 1.

Ah yep, if you mangle the command line git will send the cover letter even if you have mangled 'to' email addresses but when it hits a real patch it aborts. At least on my version of git.

Quoted 1 line

I'm busy until end of week, I'll review Monday. Sorry about the delay.

In the meantime I'll post a v4 with better commit message (Alexei) and address a corner cases Jakub pointed out.

Quoted 19 lines
Quoted 19 lines

---

John Fastabend (6):
net: virtio dynamically disable/enable LRO
net: xdp: add invalid buffer warning
virtio_net: Add XDP support
virtio_net: add dedicated XDP transmit queues
virtio_net: add XDP_TX support
virtio_net: xdp, add slowpath case for non contiguous buffers

 drivers/net/virtio_net.c |  344 +++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/filter.h   |    1 
 net/core/filter.c        |    6 +
 3 files changed, 346 insertions(+), 5 deletions(-)

--
Signature

#3 lore raw
Quoted 30 lines · John Fastabend
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · John Fastabend

This implements virtio_net for the mergeable buffers and big_packet modes. I tested this with vhost_net running on qemu and did not see any issues. For testing num_buf > 1 I added a hack to vhost driver to only but 100 bytes per buffer.

There are some restrictions for XDP to be enabled and work well (see patch 3) for more details.

1. LRO must be off
2. MTU must be less than PAGE_SIZE
3. queues must be available to dedicate to XDP
4. num_bufs received in mergeable buffers must be 1
5. big_packet mode must have all data on single page

Please review any comments/feedback welcome as always.

v2, fixes rcu usage throughout thanks to Eric and the use of num_online_cpus() usage thanks to Jakub.

Quoted 8 lines
Quoted 4 lines

v3, add slowpath patch to handle num_bufs > 1

Thanks,
John

BTW this is threaded incorrectly: patch 1/6 isn't a reply to 0/6, patches 2 and on are replies to patch 1.

Quoted 8 lines

Ah yep, if you mangle the command line git will send the cover letter even if you have mangled 'to' email addresses but when it hits a real patch it aborts. At least on my version of git.

Quoted 1 line

I'm busy until end of week, I'll review Monday. Sorry about the delay.

In the meantime I'll post a v4 with better commit message (Alexei) and address a corner cases Jakub pointed out.

I did a quick look and found some too, but a detailed review will have to wait till next week.

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

---

John Fastabend (6):
net: virtio dynamically disable/enable LRO
net: xdp: add invalid buffer warning
virtio_net: Add XDP support
virtio_net: add dedicated XDP transmit queues
virtio_net: add XDP_TX support
virtio_net: xdp, add slowpath case for non contiguous buffers

 drivers/net/virtio_net.c |  344 +++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/filter.h   |    1 
 net/core/filter.c        |    6 +
 3 files changed, 346 insertions(+), 5 deletions(-)

--
Signature

#4 lore raw
Quoted 35 lines · Michael S. Tsirkin
Quoted 34 lines · John Fastabend
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · John Fastabend

This implements virtio_net for the mergeable buffers and big_packet modes. I tested this with vhost_net running on qemu and did not see any issues. For testing num_buf > 1 I added a hack to vhost driver to only but 100 bytes per buffer.

There are some restrictions for XDP to be enabled and work well (see patch 3) for more details.

1. LRO must be off
2. MTU must be less than PAGE_SIZE
3. queues must be available to dedicate to XDP
4. num_bufs received in mergeable buffers must be 1
5. big_packet mode must have all data on single page

Please review any comments/feedback welcome as always.

v2, fixes rcu usage throughout thanks to Eric and the use of num_online_cpus() usage thanks to Jakub.

Quoted 8 lines
Quoted 4 lines

v3, add slowpath patch to handle num_bufs > 1

Thanks,
John

BTW this is threaded incorrectly: patch 1/6 isn't a reply to 0/6, patches 2 and on are replies to patch 1.

Ah yep, if you mangle the command line git will send the cover letter even if you have mangled 'to' email addresses but when it hits a real patch it aborts. At least on my version of git.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I'm busy until end of week, I'll review Monday. Sorry about the delay.

In the meantime I'll post a v4 with better commit message (Alexei) and address a corner cases Jakub pointed out.

I did a quick look and found some too, but a detailed review will have to wait till next week.

Thanks! I'll address all the comments and have a v4 by then.