Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82819
b: refs/heads/master
c: 34a4857
h: refs/heads/master
i:
  82817: 21f4dd9
  82815: ea18d4a
v: v3
  • Loading branch information
Rusty Russell committed Feb 4, 2008
1 parent 79038f0 commit db6220f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 50c8ea8080700014872f2bbd7466d31ce0476290
refs/heads/master: 34a48579e4fb380604d06f0409db3851bd22d785
32 changes: 16 additions & 16 deletions trunk/drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <linux/virtio_net.h>
#include <linux/scatterlist.h>

static int csum = 1, gso = 1;
module_param(csum, bool, 0444);
module_param(gso, bool, 0444);

/* FIXME: MTU in config. */
#define MAX_PACKET_LEN (ETH_HLEN+ETH_DATA_LEN)

Expand Down Expand Up @@ -88,13 +92,10 @@ static void receive_skb(struct net_device *dev, struct sk_buff *skb,

if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
pr_debug("GSO!\n");
switch (hdr->gso_type) {
switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
case VIRTIO_NET_HDR_GSO_TCPV4:
skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
break;
case VIRTIO_NET_HDR_GSO_TCPV4_ECN:
skb_shinfo(skb)->gso_type = SKB_GSO_TCP_ECN;
break;
case VIRTIO_NET_HDR_GSO_UDP:
skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
break;
Expand All @@ -108,6 +109,9 @@ static void receive_skb(struct net_device *dev, struct sk_buff *skb,
goto frame_err;
}

if (hdr->gso_type & VIRTIO_NET_HDR_GSO_ECN)
skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;

skb_shinfo(skb)->gso_size = hdr->gso_size;
if (skb_shinfo(skb)->gso_size == 0) {
if (net_ratelimit())
Expand Down Expand Up @@ -244,16 +248,16 @@ static int start_xmit(struct sk_buff *skb, struct net_device *dev)
if (skb_is_gso(skb)) {
hdr->hdr_len = skb_transport_header(skb) - skb->data;
hdr->gso_size = skb_shinfo(skb)->gso_size;
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4_ECN;
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
else
BUG();
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
} else {
hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
hdr->gso_size = hdr->hdr_len = 0;
Expand Down Expand Up @@ -330,17 +334,13 @@ static int virtnet_probe(struct virtio_device *vdev)
SET_NETDEV_DEV(dev, &vdev->dev);

/* Do we support "hardware" checksums? */
if (vdev->config->feature(vdev, VIRTIO_NET_F_NO_CSUM)) {
if (csum && vdev->config->feature(vdev, VIRTIO_NET_F_CSUM)) {
/* This opens up the world of extra features. */
dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
if (vdev->config->feature(vdev, VIRTIO_NET_F_TSO4))
dev->features |= NETIF_F_TSO;
if (vdev->config->feature(vdev, VIRTIO_NET_F_UFO))
dev->features |= NETIF_F_UFO;
if (vdev->config->feature(vdev, VIRTIO_NET_F_TSO4_ECN))
dev->features |= NETIF_F_TSO_ECN;
if (vdev->config->feature(vdev, VIRTIO_NET_F_TSO6))
dev->features |= NETIF_F_TSO6;
if (gso && vdev->config->feature(vdev, VIRTIO_NET_F_GSO)) {
dev->features |= NETIF_F_TSO | NETIF_F_UFO
| NETIF_F_TSO_ECN | NETIF_F_TSO6;
}
}

/* Configuration may specify what MAC to use. Otherwise random. */
Expand Down
12 changes: 4 additions & 8 deletions trunk/include/linux/virtio_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
#define VIRTIO_ID_NET 1

/* The feature bitmap for virtio net */
#define VIRTIO_NET_F_NO_CSUM 0
#define VIRTIO_NET_F_TSO4 1
#define VIRTIO_NET_F_UFO 2
#define VIRTIO_NET_F_TSO4_ECN 3
#define VIRTIO_NET_F_TSO6 4
#define VIRTIO_NET_F_MAC 5
#define VIRTIO_NET_F_CSUM 0 /* Can handle pkts w/ partial csum */
#define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
#define VIRTIO_NET_F_GSO 6 /* Can handle pkts w/ any GSO type */

struct virtio_net_config
{
Expand All @@ -27,10 +24,9 @@ struct virtio_net_hdr
__u8 flags;
#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame
#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO)
/* FIXME: Do we need this? If they said they can handle ECN, do they care? */
#define VIRTIO_NET_HDR_GSO_TCPV4_ECN 2 // GSO frame, IPv4 TCP w/ ECN
#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO)
#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP
#define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set
__u8 gso_type;
__u16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
__u16 gso_size; /* Bytes to append to gso_hdr_len per frame */
Expand Down

0 comments on commit db6220f

Please sign in to comment.