netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] xen-netback: add gso_segs calculation
@ 2013-12-17 11:44 Paul Durrant
  2013-12-17 22:15 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Paul Durrant @ 2013-12-17 11:44 UTC (permalink / raw)
  To: xen-devel, netdev
  Cc: Paul Durrant, Wei Liu, Ian Campbell, David Vrabel, Eric Dumazet

netback already has code which parses IPv4 and v6 headers to set up checksum
offsets and these are always applied to GSO packets being sent from
frontends. It's therefore suboptimal that GSOs are being marked
SKB_GSO_DODGY to defer the gso_segs calculation when netback already has all
necessary information to hand to do the calculation. This patch adds that
calculation.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
---
v2:
 - Fixed header size calculation

 drivers/net/xen-netback/netback.c |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 904e497..d376e27 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -1043,10 +1043,7 @@ static int xenvif_set_skb_gso(struct xenvif *vif,
 	}
 
 	skb_shinfo(skb)->gso_size = gso->u.gso.size;
-
-	/* Header must be checked, and gso_segs computed. */
-	skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
-	skb_shinfo(skb)->gso_segs = 0;
+	/* gso_segs will be calculated later */
 
 	return 0;
 }
@@ -1582,6 +1579,20 @@ static int xenvif_tx_submit(struct xenvif *vif, int budget)
 
 		skb_probe_transport_header(skb, 0);
 
+		/* If the packet is GSO then we will have just set up the
+		 * transport header offset in checksum_setup so it's now
+		 * straightforward to calculate gso_segs.
+		 */
+		if (skb_is_gso(skb)) {
+			int mss = skb_shinfo(skb)->gso_size;
+			int hdrlen = skb_transport_header(skb) -
+				skb_mac_header(skb) +
+				tcp_hdrlen(skb);
+
+			skb_shinfo(skb)->gso_segs =
+				DIV_ROUND_UP(skb->len - hdrlen, mss);
+		}
+
 		vif->dev->stats.rx_bytes += skb->len;
 		vif->dev->stats.rx_packets++;
 
-- 
1.7.10.4

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

* Re: [PATCH net-next v2] xen-netback: add gso_segs calculation
  2013-12-17 11:44 [PATCH net-next v2] xen-netback: add gso_segs calculation Paul Durrant
@ 2013-12-17 22:15 ` Eric Dumazet
  2013-12-19  9:14   ` Paul Durrant
  2013-12-17 22:56 ` Wei Liu
  2013-12-19 20:12 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2013-12-17 22:15 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, netdev, Wei Liu, Ian Campbell, David Vrabel

On Tue, 2013-12-17 at 11:44 +0000, Paul Durrant wrote:
> netback already has code which parses IPv4 and v6 headers to set up checksum
> offsets and these are always applied to GSO packets being sent from
> frontends. It's therefore suboptimal that GSOs are being marked
> SKB_GSO_DODGY to defer the gso_segs calculation when netback already has all
> necessary information to hand to do the calculation. This patch adds that
> calculation.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: David Vrabel <david.vrabel@citrix.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> ---

Acked-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH net-next v2] xen-netback: add gso_segs calculation
  2013-12-17 11:44 [PATCH net-next v2] xen-netback: add gso_segs calculation Paul Durrant
  2013-12-17 22:15 ` Eric Dumazet
@ 2013-12-17 22:56 ` Wei Liu
  2013-12-19 20:12 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2013-12-17 22:56 UTC (permalink / raw)
  To: Paul Durrant
  Cc: xen-devel, netdev, Wei Liu, Ian Campbell, David Vrabel, Eric Dumazet

On Tue, Dec 17, 2013 at 11:44:35AM +0000, Paul Durrant wrote:
> netback already has code which parses IPv4 and v6 headers to set up checksum
> offsets and these are always applied to GSO packets being sent from
> frontends. It's therefore suboptimal that GSOs are being marked
> SKB_GSO_DODGY to defer the gso_segs calculation when netback already has all
> necessary information to hand to do the calculation. This patch adds that
> calculation.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: David Vrabel <david.vrabel@citrix.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

* RE: [PATCH net-next v2] xen-netback: add gso_segs calculation
  2013-12-17 22:15 ` Eric Dumazet
@ 2013-12-19  9:14   ` Paul Durrant
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Durrant @ 2013-12-19  9:14 UTC (permalink / raw)
  To: Eric Dumazet, David Miller (davem@davemloft.net)
  Cc: xen-devel, netdev, Wei Liu, Ian Campbell, David Vrabel

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org] On Behalf Of Eric Dumazet
> Sent: 17 December 2013 22:15
> To: Paul Durrant
> Cc: xen-devel@lists.xen.org; netdev@vger.kernel.org; Wei Liu; Ian Campbell;
> David Vrabel
> Subject: Re: [PATCH net-next v2] xen-netback: add gso_segs calculation
> 
> On Tue, 2013-12-17 at 11:44 +0000, Paul Durrant wrote:
> > netback already has code which parses IPv4 and v6 headers to set up
> checksum
> > offsets and these are always applied to GSO packets being sent from
> > frontends. It's therefore suboptimal that GSOs are being marked
> > SKB_GSO_DODGY to defer the gso_segs calculation when netback already
> has all
> > necessary information to hand to do the calculation. This patch adds that
> > calculation.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > Cc: Wei Liu <wei.liu2@citrix.com>
> > Cc: Ian Campbell <ian.campbell@citrix.com>
> > Cc: David Vrabel <david.vrabel@citrix.com>
> > Cc: Eric Dumazet <eric.dumazet@gmail.com>
> > ---
> 
> Acked-by: Eric Dumazet <edumazet@google.com>
> 

Thanks :-)

  Paul

> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH net-next v2] xen-netback: add gso_segs calculation
  2013-12-17 11:44 [PATCH net-next v2] xen-netback: add gso_segs calculation Paul Durrant
  2013-12-17 22:15 ` Eric Dumazet
  2013-12-17 22:56 ` Wei Liu
@ 2013-12-19 20:12 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-12-19 20:12 UTC (permalink / raw)
  To: paul.durrant
  Cc: xen-devel, netdev, wei.liu2, ian.campbell, david.vrabel, eric.dumazet

From: Paul Durrant <paul.durrant@citrix.com>
Date: Tue, 17 Dec 2013 11:44:35 +0000

> netback already has code which parses IPv4 and v6 headers to set up checksum
> offsets and these are always applied to GSO packets being sent from
> frontends. It's therefore suboptimal that GSOs are being marked
> SKB_GSO_DODGY to defer the gso_segs calculation when netback already has all
> necessary information to hand to do the calculation. This patch adds that
> calculation.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Applied, thanks.

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

end of thread, other threads:[~2013-12-19 20:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-17 11:44 [PATCH net-next v2] xen-netback: add gso_segs calculation Paul Durrant
2013-12-17 22:15 ` Eric Dumazet
2013-12-19  9:14   ` Paul Durrant
2013-12-17 22:56 ` Wei Liu
2013-12-19 20:12 ` 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).