Skip to contentSkip to conversation

virtio-net: enable big mode correctly

PATCH In review Jason Wang 3 participants 14 messages Nov 25, 2021

Subsystems (4)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 virtio-net: enable big mode correctly

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
 		dev->mtu = mtu;
 		dev->max_mtu = mtu;
 
-		/* TODO: size buffers correctly in this case. */
-		if (dev->mtu > ETH_DATA_LEN)
-			vi->big_packets = true;
 	}
 
+	/* TODO: size buffers correctly in this case. */
+	if (dev->max_mtu > ETH_DATA_LEN)
+		vi->big_packets = true;
+
 	if (vi->any_header_sg)
 		dev->needed_headroom = vi->hdr_len;
 
Signature · 6 lines
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#1 lore raw
Quoted 7 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated.

This will slow down dpdk hosts which disable mergeable buffers and send standard MTU sized packets.

Quoted 1 line

We can do optimization on top.

I don't think it works like this, increasing mtu from guest >4k never worked, we can't regress everyone's performance with a promise to maybe sometime bring it back.

Quoted 30 lines
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
 		dev->mtu = mtu;
 		dev->max_mtu = mtu;
 
-		/* TODO: size buffers correctly in this case. */
-		if (dev->mtu > ETH_DATA_LEN)
-			vi->big_packets = true;
 	}
 
+	/* TODO: size buffers correctly in this case. */
+	if (dev->max_mtu > ETH_DATA_LEN)
+		vi->big_packets = true;
+
 	if (vi->any_header_sg)
 		dev->needed_headroom = vi->hdr_len;
 
Signature · 1 line
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#2 lore raw
Quoted 10 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated.

Quoted 7 lines

This will slow down dpdk hosts which disable mergeable buffers and send standard MTU sized packets.

Quoted 1 line

We can do optimization on top.

I don't think it works like this, increasing mtu
from guest >4k never worked,

Looking at add_recvbuf_small() it's actually GOOD_PACKET_LEN if I was not wrong.

Quoted 2 lines

we can't regress everyone's
performance with a promise to maybe sometime bring it back.

So consider it never work before I wonder if we can assume a 1500 as max_mtu value instead of simply using MAX_MTU?

Thanks

Quoted 29 lines
Quoted 29 lines
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
Quoted 3 lines
Quoted 2 lines

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
Quoted 14 lines · Jason Wang
Quoted 13 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated.

This will slow down dpdk hosts which disable mergeable buffers and send standard MTU sized packets.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

We can do optimization on top.

I don't think it works like this, increasing mtu
from guest >4k never worked,

Looking at add_recvbuf_small() it's actually GOOD_PACKET_LEN if I was not wrong.

OK, even more so then.

Quoted 7 lines
Quoted 2 lines

we can't regress everyone's
performance with a promise to maybe sometime bring it back.

So consider it never work before I wonder if we can assume a 1500 as max_mtu value instead of simply using MAX_MTU?

Thanks

You want to block guests from setting MTU to a value >GOOD_PACKET_LEN? Maybe ... it will prevent sending large packets which did work ... I'd tread carefully here, and I don't think this kind of thing is net material.

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#4 lore raw
Quoted 28 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang
Quoted 13 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated.

This will slow down dpdk hosts which disable mergeable buffers and send standard MTU sized packets.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

We can do optimization on top.

I don't think it works like this, increasing mtu
from guest >4k never worked,

Looking at add_recvbuf_small() it's actually GOOD_PACKET_LEN if I was not wrong.

OK, even more so then.

Quoted 3 lines
Quoted 2 lines

we can't regress everyone's
performance with a promise to maybe sometime bring it back.

Quoted 6 lines
Quoted 4 lines

So consider it never work before I wonder if we can assume a 1500 as max_mtu value instead of simply using MAX_MTU?

Thanks

You want to block guests from setting MTU to a value >GOOD_PACKET_LEN?

Yes, or fix the issue to let large packets on RX work (e.g as the TODO said, size the buffer: for <=4K mtu continue to work as add_recvbuf_small(), for >= 4K switch to use big).

Quoted 1 line

Maybe ... it will prevent sending large packets which did work ...

Yes, but it's strange to allow TX but not RX

Quoted 2 lines

I'd tread carefully here, and I don't think this kind of thing is net material.

I agree consider it can't be fixed easily.

Thanks

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#5 lore raw
Quoted 32 lines · Jason Wang
Quoted 31 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang
Quoted 13 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated.

This will slow down dpdk hosts which disable mergeable buffers and send standard MTU sized packets.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

We can do optimization on top.

I don't think it works like this, increasing mtu
from guest >4k never worked,

Looking at add_recvbuf_small() it's actually GOOD_PACKET_LEN if I was not wrong.

OK, even more so then.

Quoted 6 lines
Quoted 2 lines

we can't regress everyone's
performance with a promise to maybe sometime bring it back.

So consider it never work before I wonder if we can assume a 1500 as max_mtu value instead of simply using MAX_MTU?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks

You want to block guests from setting MTU to a value >GOOD_PACKET_LEN?

Yes, or fix the issue to let large packets on RX work (e.g as the TODO said, size the buffer: for <=4K mtu continue to work as add_recvbuf_small(), for >= 4K switch to use big).

Right. The difficulty is with changing modes, current code isn't designed for it.

Quoted 45 lines
Quoted 1 line

Maybe ... it will prevent sending large packets which did work ...

Yes, but it's strange to allow TX but not RX

Quoted 2 lines

I'd tread carefully here, and I don't think this kind of thing is net material.

I agree consider it can't be fixed easily.

Thanks

Quoted 34 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -4
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
--

2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#6 lore raw
Quoted 36 lines · Michael S. Tsirkin
Quoted 34 lines · Jason Wang
Quoted 33 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang
Quoted 13 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated.

This will slow down dpdk hosts which disable mergeable buffers and send standard MTU sized packets.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

We can do optimization on top.

I don't think it works like this, increasing mtu
from guest >4k never worked,

Looking at add_recvbuf_small() it's actually GOOD_PACKET_LEN if I was not wrong.

OK, even more so then.

Quoted 7 lines
Quoted 2 lines

we can't regress everyone's
performance with a promise to maybe sometime bring it back.

So consider it never work before I wonder if we can assume a 1500 as max_mtu value instead of simply using MAX_MTU?

Thanks

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

You want to block guests from setting MTU to a value >GOOD_PACKET_LEN?

Yes, or fix the issue to let large packets on RX work (e.g as the TODO said, size the buffer: for <=4K mtu continue to work as add_recvbuf_small(), for >= 4K switch to use big).

Right. The difficulty is with changing modes, current code isn't designed for it.

I think it might work if we reset the device during the mode change.

Thanks

Quoted 42 lines
Quoted 42 lines
Quoted 2 lines

Maybe ... it will prevent sending large packets which did work ...

Yes, but it's strange to allow TX but not RX

Quoted 2 lines

I'd tread carefully here, and I don't think this kind of thing is net material.

I agree consider it can't be fixed easily.

Thanks

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#7 lore raw
Quoted 43 lines · Jason Wang
Quoted 42 lines · Michael S. Tsirkin
Quoted 39 lines · Jason Wang
Quoted 28 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang
Quoted 13 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated.

This will slow down dpdk hosts which disable mergeable buffers and send standard MTU sized packets.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

We can do optimization on top.

I don't think it works like this, increasing mtu
from guest >4k never worked,

Looking at add_recvbuf_small() it's actually GOOD_PACKET_LEN if I was not wrong.

OK, even more so then.

Quoted 3 lines
Quoted 2 lines

we can't regress everyone's
performance with a promise to maybe sometime bring it back.

Quoted 6 lines
Quoted 4 lines

So consider it never work before I wonder if we can assume a 1500 as max_mtu value instead of simply using MAX_MTU?

Thanks

You want to block guests from setting MTU to a value >GOOD_PACKET_LEN?

Yes, or fix the issue to let large packets on RX work (e.g as the TODO said, size the buffer: for <=4K mtu continue to work as add_recvbuf_small(), for >= 4K switch to use big).

Quoted 6 lines
Quoted 2 lines

Right. The difficulty is with changing modes, current code isn't designed for it.

I think it might work if we reset the device during the mode change.

Thanks

For sure. It's hard to do without races though, and we need to carefully restore all the programming done so far. Maybe it will be easier if we do something like disable_irq to reliably suppress interrupts from hardware.

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 2 lines

Maybe ... it will prevent sending large packets which did work ...

Yes, but it's strange to allow TX but not RX

Quoted 2 lines

I'd tread carefully here, and I don't think this kind of thing is net material.

I agree consider it can't be fixed easily.

Thanks

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +4 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#8 lore raw
In reply to Jason Wang
Quoted 22 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +0 -0
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
 		dev->mtu = mtu;
 		dev->max_mtu = mtu;

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 3208

Quoted 10 lines
drivers/net/virtio_net.c +4 -3
 
-		/* TODO: size buffers correctly in this case. */
-		if (dev->mtu > ETH_DATA_LEN)
-			vi->big_packets = true;
 	}
 
+	/* TODO: size buffers correctly in this case. */
+	if (dev->max_mtu > ETH_DATA_LEN)
+		vi->big_packets = true;
+

If VIRTIO_NET_F_MTU is provided, then dev->max_mtu is going to equal ETH_DATA_LEN (will be set in ether_setup()) so I don't think it will set big_packets to true.

Quoted 6 lines
drivers/net/virtio_net.c +0 -0
 	if (vi->any_header_sg)
 		dev->needed_headroom = vi->hdr_len;
 
Signature · 1 line
2.25.1
author
#9 lore raw
Quoted 30 lines · Eli Cohen
Quoted 28 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +0 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 3208

Quoted 4 lines
drivers/net/virtio_net.c +4 -0
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+

If VIRTIO_NET_F_MTU is provided, then dev->max_mtu is going to equal ETH_DATA_LEN (will be set in ether_setup()) so I don't think it will set big_packets to true.

I may miss something, the dev->max_mtu is just assigned to the mtu value read from the config space in the code block above (inside the feature check of VIRTIO_NET_F_MTU).

Thanks

Quoted 9 lines
Quoted 8 lines
drivers/net/virtio_net.c +0 -1
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
--

2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#10 lore raw
Quoted 40 lines · Jason Wang
Quoted 30 lines · Eli Cohen
Quoted 28 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +0 -3
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 3208

Quoted 4 lines
drivers/net/virtio_net.c +4 -0
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+

If VIRTIO_NET_F_MTU is provided, then dev->max_mtu is going to equal ETH_DATA_LEN (will be set in ether_setup()) so I don't think it will set big_packets to true.

Quoted 3 lines

I may miss something, the dev->max_mtu is just assigned to the mtu value read from the config space in the code block above (inside the feature check of VIRTIO_NET_F_MTU).

Sorry, I meant "If VIRTIO_NET_F_MTU is ***NOT*** provided". In that case dev->max_mtu eauals ETH_DATA_LEN so you won't set vi->big_packets to true.

Quoted 13 lines

Thanks

Quoted 9 lines
Quoted 8 lines
drivers/net/virtio_net.c +0 -1
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
--

2.25.1

author
#11 lore raw
Quoted 42 lines · Eli Cohen
Quoted 40 lines · Jason Wang
Quoted 38 lines · Eli Cohen
Quoted 22 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +0 -0
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 3208

Quoted 10 lines
drivers/net/virtio_net.c +4 -3
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+

If VIRTIO_NET_F_MTU is provided, then dev->max_mtu is going to equal ETH_DATA_LEN (will be set in ether_setup()) so I don't think it will set big_packets to true.

Quoted 7 lines
Quoted 3 lines

I may miss something, the dev->max_mtu is just assigned to the mtu value read from the config space in the code block above (inside the feature check of VIRTIO_NET_F_MTU).

Sorry, I meant "If VIRTIO_NET_F_MTU is ***NOT*** provided". In that case dev->max_mtu eauals ETH_DATA_LEN so you won't set vi->big_packets to true.

I see but in this case, the above assignment:

        /* MTU range: 68 - 65535 */
        dev->min_mtu = MIN_MTU;
        dev->max_mtu = MAX_MTU;

happens after alloc_etherdev_mq() which calls ether_setup(), so we are probably fine here.

Thanks

Quoted 6 lines
Quoted 6 lines

Thanks

Quoted 2 lines
Quoted 9 lines
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
drivers/net/virtio_net.c +0 -1
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
--

2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#12 lore raw
Quoted 53 lines · Jason Wang
Quoted 42 lines · Eli Cohen
Quoted 40 lines · Jason Wang
Quoted 38 lines · Eli Cohen
Quoted 22 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +0 -0
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 3208

Quoted 10 lines
drivers/net/virtio_net.c +4 -3
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+

If VIRTIO_NET_F_MTU is provided, then dev->max_mtu is going to equal ETH_DATA_LEN (will be set in ether_setup()) so I don't think it will set big_packets to true.

Quoted 7 lines
Quoted 3 lines

I may miss something, the dev->max_mtu is just assigned to the mtu value read from the config space in the code block above (inside the feature check of VIRTIO_NET_F_MTU).

Sorry, I meant "If VIRTIO_NET_F_MTU is ***NOT*** provided". In that case dev->max_mtu eauals ETH_DATA_LEN so you won't set vi->big_packets to true.

I see but in this case, the above assignment:

Quoted 8 lines
        /* MTU range: 68 - 65535 */
        dev->min_mtu = MIN_MTU;
        dev->max_mtu = MAX_MTU;

happens after alloc_etherdev_mq() which calls ether_setup(), so we are probably fine here.

Thanks

Actually the issue with VIRTIO_NET_F_MTU is that devices might be tempted to expose 9k here simply because they support jumbo frames, if they also don't support mergeable buffers this will force big packet mode.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Thanks

Quoted 5 lines
Quoted 5 lines
drivers/net/virtio_net.c +0 -0
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#13 lore raw
In reply to Jason Wang
Quoted 51 lines · Jason Wang
Quoted 42 lines · Eli Cohen
Quoted 40 lines · Jason Wang
Quoted 38 lines · Eli Cohen
Quoted 22 lines · Jason Wang

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very large max_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater than ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +0 -0
index 7c43bfc1ce44..83ae3ef5eb11 100644
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
              dev->mtu = mtu;
              dev->max_mtu = mtu;

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 3208

Quoted 10 lines
drivers/net/virtio_net.c +4 -3
 
-             /* TODO: size buffers correctly in this case. */
-             if (dev->mtu > ETH_DATA_LEN)
-                     vi->big_packets = true;
      }
 
+     /* TODO: size buffers correctly in this case. */
+     if (dev->max_mtu > ETH_DATA_LEN)
+             vi->big_packets = true;
+

If VIRTIO_NET_F_MTU is provided, then dev->max_mtu is going to equal ETH_DATA_LEN (will be set in ether_setup()) so I don't think it will set big_packets to true.

Quoted 7 lines
Quoted 3 lines

I may miss something, the dev->max_mtu is just assigned to the mtu value read from the config space in the code block above (inside the feature check of VIRTIO_NET_F_MTU).

Sorry, I meant "If VIRTIO_NET_F_MTU is ***NOT*** provided". In that case dev->max_mtu eauals ETH_DATA_LEN so you won't set vi->big_packets to true.

Quoted 9 lines

I see but in this case, the above assignment:

        /* MTU range: 68 - 65535 */
        dev->min_mtu = MIN_MTU;
        dev->max_mtu = MAX_MTU;

happens after alloc_etherdev_mq() which calls ether_setup(), so we are probably fine here.

I see, thanks.

Quoted 18 lines

Thanks

Quoted 15 lines
Quoted 14 lines

Thanks

Quoted 9 lines
Quoted 8 lines
drivers/net/virtio_net.c +0 -1
      if (vi->any_header_sg)
              dev->needed_headroom = vi->hdr_len;
 
--

2.25.1