virtio-net: enable big mode correctly
Subsystems (4)
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
@@ -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
Michael S. Tsirkin
maintainerQuoted 7 lines · Jason Wang
When
VIRTIO_NET_F_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis 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
Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +4
-3@@ -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
Quoted 10 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang
When
VIRTIO_NET_F_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis 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
Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +4
-3@@ -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
Michael S. Tsirkin
maintainerQuoted 14 lines · Jason Wang
Quoted 13 lines · Michael S. Tsirkin
Quoted 7 lines · Jason Wang
When
VIRTIO_NET_F_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis 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 actuallyGOOD_PACKET_LENif 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_mtuvalue instead of simply usingMAX_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
Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +4
-3@@ -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
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_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis 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 actuallyGOOD_PACKET_LENif 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_mtuvalue instead of simply usingMAX_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
Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +4
-3@@ -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
Michael S. Tsirkin
maintainerQuoted 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_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis 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 actuallyGOOD_PACKET_LENif 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_mtuvalue instead of simply usingMAX_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
Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +4
-4@@ -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
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_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis 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 actuallyGOOD_PACKET_LENif 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_mtuvalue instead of simply usingMAX_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
Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +4
-3@@ -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
Michael S. Tsirkin
maintainerQuoted 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_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis 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 actuallyGOOD_PACKET_LENif 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_mtuvalue instead of simply usingMAX_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
Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +4
-3@@ -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
Quoted 22 lines · Jason Wang
When
VIRTIO_NET_F_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis not negotiated. We can do optimization on top.Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +0
-0@@ -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
-0if (vi->any_header_sg) dev->needed_headroom = vi->hdr_len;Signature · 1 line
2.25.1
Quoted 30 lines · Eli Cohen
Quoted 28 lines · Jason Wang
When
VIRTIO_NET_F_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis not negotiated. We can do optimization on top.Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +0
-3@@ -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_MTUis provided, thendev->max_mtuis going to equalETH_DATA_LEN(will be set inether_setup()) so I don't think it will setbig_packetsto 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
-1if (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
Quoted 40 lines · Jason Wang
Quoted 30 lines · Eli Cohen
Quoted 28 lines · Jason Wang
When
VIRTIO_NET_F_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis not negotiated. We can do optimization on top.Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +0
-3@@ -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_MTUis provided, thendev->max_mtuis going to equalETH_DATA_LEN(will be set inether_setup()) so I don't think it will setbig_packetsto true.
Quoted 3 lines
I may miss something, the
dev->max_mtuis just assigned to the mtu value read from the config space in the code block above (inside the feature check ofVIRTIO_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
-1if (vi->any_header_sg) dev->needed_headroom = vi->hdr_len; --2.25.1
Quoted 42 lines · Eli Cohen
Quoted 40 lines · Jason Wang
Quoted 38 lines · Eli Cohen
Quoted 22 lines · Jason Wang
When
VIRTIO_NET_F_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis not negotiated. We can do optimization on top.Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +0
-0@@ -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_MTUis provided, thendev->max_mtuis going to equalETH_DATA_LEN(will be set inether_setup()) so I don't think it will setbig_packetsto true.
Quoted 7 lines
Quoted 3 lines
I may miss something, the
dev->max_mtuis just assigned to the mtu value read from the config space in the code block above (inside the feature check ofVIRTIO_NET_F_MTU).Sorry, I meant "If
VIRTIO_NET_F_MTUis ***NOT*** provided". In that casedev->max_mtueaualsETH_DATA_LENso you won't setvi->big_packetsto 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
-1if (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
Michael S. Tsirkin
maintainerQuoted 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_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis not negotiated. We can do optimization on top.Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +0
-0@@ -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_MTUis provided, thendev->max_mtuis going to equalETH_DATA_LEN(will be set inether_setup()) so I don't think it will setbig_packetsto true.Quoted 7 lines
Quoted 3 lines
I may miss something, the
dev->max_mtuis just assigned to the mtu value read from the config space in the code block above (inside the feature check ofVIRTIO_NET_F_MTU).Sorry, I meant "If
VIRTIO_NET_F_MTUis ***NOT*** provided". In that casedev->max_mtueaualsETH_DATA_LENso you won't setvi->big_packetsto 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 callsether_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
-0if (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
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_MTUfeature is not negotiated, we assume a very largemax_mtu. In this case, using small packet mode is not correct since it may breaks the networking when MTU is grater thanETH_DATA_LEN.To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTUis not negotiated. We can do optimization on top.Reported-by Eli Cohen <[email protected]>Cc Eli Cohen <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/virtio_net.c +0
-0@@ -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_MTUis provided, thendev->max_mtuis going to equalETH_DATA_LEN(will be set inether_setup()) so I don't think it will setbig_packetsto true.Quoted 7 lines
Quoted 3 lines
I may miss something, the
dev->max_mtuis just assigned to the mtu value read from the config space in the code block above (inside the feature check ofVIRTIO_NET_F_MTU).Sorry, I meant "If
VIRTIO_NET_F_MTUis ***NOT*** provided". In that casedev->max_mtueaualsETH_DATA_LENso you won't setvi->big_packetsto 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 callsether_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
-1if (vi->any_header_sg) dev->needed_headroom = vi->hdr_len; --2.25.1