aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2008-02-04 23:50:01 -0500
committerRusty Russell <rusty@rustcorp.com.au>2008-02-04 07:50:02 -0500
commit50c8ea8080700014872f2bbd7466d31ce0476290 (patch)
tree8c863eb9ed295758a585e8f8f865faf9f6ba9302
parent24a5ae5d0340d5a45df840b24a10d62aa9516116 (diff)
virtio: Net header needs hdr_len
It's far easier to deal with packets if we don't have to parse the packet to figure out the header length to know how much to pull into the skb data. Add the field to the virtio_net_hdr struct (and fix the spaces that somehow crept in there). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--drivers/net/virtio_net.c3
-rw-r--r--include/linux/virtio_net.h11
2 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7b0059f0f5d4..3492ae0951de 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -242,6 +242,7 @@ static int start_xmit(struct sk_buff *skb, struct net_device *dev)
242 } 242 }
243 243
244 if (skb_is_gso(skb)) { 244 if (skb_is_gso(skb)) {
245 hdr->hdr_len = skb_transport_header(skb) - skb->data;
245 hdr->gso_size = skb_shinfo(skb)->gso_size; 246 hdr->gso_size = skb_shinfo(skb)->gso_size;
246 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN) 247 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
247 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4_ECN; 248 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4_ECN;
@@ -255,7 +256,7 @@ static int start_xmit(struct sk_buff *skb, struct net_device *dev)
255 BUG(); 256 BUG();
256 } else { 257 } else {
257 hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE; 258 hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
258 hdr->gso_size = 0; 259 hdr->gso_size = hdr->hdr_len = 0;
259 } 260 }
260 261
261 vnet_hdr_to_sg(sg, skb); 262 vnet_hdr_to_sg(sg, skb);
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 6e8fdfea8cd0..1456f7b936d0 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -24,16 +24,17 @@ struct virtio_net_config
24struct virtio_net_hdr 24struct virtio_net_hdr
25{ 25{
26#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset 26#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset
27 __u8 flags; 27 __u8 flags;
28#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame 28#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame
29#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO) 29#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO)
30/* FIXME: Do we need this? If they said they can handle ECN, do they care? */ 30/* FIXME: Do we need this? If they said they can handle ECN, do they care? */
31#define VIRTIO_NET_HDR_GSO_TCPV4_ECN 2 // GSO frame, IPv4 TCP w/ ECN 31#define VIRTIO_NET_HDR_GSO_TCPV4_ECN 2 // GSO frame, IPv4 TCP w/ ECN
32#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO) 32#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO)
33#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP 33#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP
34 __u8 gso_type; 34 __u8 gso_type;
35 __u16 gso_size; 35 __u16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
36 __u16 csum_start; 36 __u16 gso_size; /* Bytes to append to gso_hdr_len per frame */
37 __u16 csum_offset; 37 __u16 csum_start; /* Position to start checksumming from */
38 __u16 csum_offset; /* Offset after that to place checksum */
38}; 39};
39#endif /* _LINUX_VIRTIO_NET_H */ 40#endif /* _LINUX_VIRTIO_NET_H */