# \[PATCH v3 01/20\] net/xen-netback: xenvif\_gop\_frag\_copy: move GSO check out of the loop

- Subsystems: NETWORKING DRIVERS, THE REST, XEN NETWORK BACKEND DRIVER
- Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, Wei Liu, Paul Durrant
- Revision v3 (2 revisions archived).
- List: netdev
- 2 messages, 2 authors
- Page: https://ratatoskr.run/netdev/2015/08/4553521/t

## \[PATCH v3 01/20\] net/xen-netback: xenvif\_gop\_frag\_copy: move GSO check out of the loop

- From: Julien Grall \<hidden\>
- Date: 2015-08-07 16:50:00 
- Message: https://ratatoskr.run/netdev/2015/08/4553521.md

```text
The skb doesn't change within the function. Therefore it's only
necessary to check if we need GSO once at the beginning.

Signed-off-by: Julien Grall <redacted>

---
Cc: Ian Campbell <redacted>
Cc: Wei Liu <redacted>
Cc: <redacted>

    Changes in v2:
        - Patch added
---
 drivers/net/xen-netback/netback.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 8293374..66f1780 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -277,6 +277,13 @@ static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb
 	unsigned long bytes;
 	int gso_type = XEN_NETIF_GSO_TYPE_NONE;
 
+	if (skb_is_gso(skb)) {
+		if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
+			gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
+		else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
+			gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
+	}
+
 	/* Data must not cross a page boundary. */
 	BUG_ON(size + offset > PAGE_SIZE<<compound_order(page));
 
@@ -336,13 +343,6 @@ static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb
 		}
 
 		/* Leave a gap for the GSO descriptor. */
-		if (skb_is_gso(skb)) {
-			if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
-				gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
-			else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
-				gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
-		}
-
 		if (*head && ((1 << gso_type) & queue->vif->gso_mask))
 			queue->rx.req_cons++;
 
-- 
2.1.4
```

## Re: \[PATCH v3 01/20\] net/xen-netback: xenvif\_gop\_frag\_copy: move GSO check out of the loop

- From: Wei Liu \<hidden\>
- Date: 2015-08-08 13:59:10 
- Message: https://ratatoskr.run/netdev/2015/08/4553882.md

```text
On Fri, Aug 07, 2015 at 05:46:40PM +0100, Julien Grall wrote:
> The skb doesn't change within the function. Therefore it's only
> necessary to check if we need GSO once at the beginning.
> 
> Signed-off-by: Julien Grall <redacted>
> 

Acked-by: Wei Liu <redacted>
```
