netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] xen-netfront: transmit fully GSO-sized packets
@ 2015-03-31 10:05 Jonathan Davies
  2015-04-02 20:19 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Davies @ 2015-03-31 10:05 UTC (permalink / raw)
  To: netdev, xen-devel, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel
  Cc: Jonathan Davies, Wei Liu, Eric Dumazet

xen-netfront limits transmitted skbs to be at most 44 segments in size. However,
GSO permits up to 65536 bytes, which means a maximum of 45 segments of 1448
bytes each. This slight reduction in the size of packets means a slight loss in
efficiency.

Since c/s 9ecd1a75d, xen-netfront sets gso_max_size to
    XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER,
where XEN_NETIF_MAX_TX_SIZE is 65535 bytes.

The calculation used by tcp_tso_autosize (and also tcp_xmit_size_goal since c/s
6c09fa09d) in determining when to split an skb into two is
    sk->sk_gso_max_size - 1 - MAX_TCP_HEADER.

So the maximum permitted size of an skb is calculated to be
    (XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER) - 1 - MAX_TCP_HEADER.

Intuitively, this looks like the wrong formula -- we don't need two TCP headers.
Instead, there is no need to deviate from the default gso_max_size of 65536 as
this already accommodates the size of the header.

Currently, the largest skb transmitted by netfront is 63712 bytes (44 segments
of 1448 bytes each), as observed via tcpdump. This patch makes netfront send
skbs of up to 65160 bytes (45 segments of 1448 bytes each).

Similarly, the maximum allowable mtu does not need to subtract MAX_TCP_HEADER as
it relates to the size of the whole packet, including the header.

Fixes: 9ecd1a75d977 ("xen-netfront: reduce gso_max_size to account for max TCP header")
Signed-off-by: Jonathan Davies <jonathan.davies@citrix.com>

---
Changes in v2:
 - Also correct max mtu in xennet_change_mtu.
---
 drivers/net/xen-netfront.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index e9b960f..720aaf6 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1008,8 +1008,7 @@ err:
 
 static int xennet_change_mtu(struct net_device *dev, int mtu)
 {
-	int max = xennet_can_sg(dev) ?
-		XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER : ETH_DATA_LEN;
+	int max = xennet_can_sg(dev) ? XEN_NETIF_MAX_TX_SIZE : ETH_DATA_LEN;
 
 	if (mtu > max)
 		return -EINVAL;
@@ -1279,8 +1278,6 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
 	netdev->ethtool_ops = &xennet_ethtool_ops;
 	SET_NETDEV_DEV(netdev, &dev->dev);
 
-	netif_set_gso_max_size(netdev, XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER);
-
 	np->netdev = netdev;
 
 	netif_carrier_off(netdev);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] xen-netfront: transmit fully GSO-sized packets
  2015-03-31 10:05 [PATCH v2] xen-netfront: transmit fully GSO-sized packets Jonathan Davies
@ 2015-04-02 20:19 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-04-02 20:19 UTC (permalink / raw)
  To: jonathan.davies
  Cc: netdev, xen-devel, konrad.wilk, boris.ostrovsky, david.vrabel,
	wei.liu2, edumazet

From: Jonathan Davies <jonathan.davies@citrix.com>
Date: Tue, 31 Mar 2015 11:05:15 +0100

> xen-netfront limits transmitted skbs to be at most 44 segments in size. However,
> GSO permits up to 65536 bytes, which means a maximum of 45 segments of 1448
> bytes each. This slight reduction in the size of packets means a slight loss in
> efficiency.
> 
> Since c/s 9ecd1a75d, xen-netfront sets gso_max_size to
>     XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER,
> where XEN_NETIF_MAX_TX_SIZE is 65535 bytes.
> 
> The calculation used by tcp_tso_autosize (and also tcp_xmit_size_goal since c/s
> 6c09fa09d) in determining when to split an skb into two is
>     sk->sk_gso_max_size - 1 - MAX_TCP_HEADER.
> 
> So the maximum permitted size of an skb is calculated to be
>     (XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER) - 1 - MAX_TCP_HEADER.
> 
> Intuitively, this looks like the wrong formula -- we don't need two TCP headers.
> Instead, there is no need to deviate from the default gso_max_size of 65536 as
> this already accommodates the size of the header.
> 
> Currently, the largest skb transmitted by netfront is 63712 bytes (44 segments
> of 1448 bytes each), as observed via tcpdump. This patch makes netfront send
> skbs of up to 65160 bytes (45 segments of 1448 bytes each).
> 
> Similarly, the maximum allowable mtu does not need to subtract MAX_TCP_HEADER as
> it relates to the size of the whole packet, including the header.
> 
> Fixes: 9ecd1a75d977 ("xen-netfront: reduce gso_max_size to account for max TCP header")
> Signed-off-by: Jonathan Davies <jonathan.davies@citrix.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-02 20:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-31 10:05 [PATCH v2] xen-netfront: transmit fully GSO-sized packets Jonathan Davies
2015-04-02 20:19 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).