ia64/xen-unstable
changeset 11747:ad926cc0a50e
[NET] front: If the kernel does not include GSO then look for TSO.
This allows us to take advantage of TSO when running as PV-on-HVM on
older kernels.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
This allows us to take advantage of TSO when running as PV-on-HVM on
older kernels.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author | Ian Campbell <ian.campbell@xensource.com> |
---|---|
date | Thu Oct 05 10:09:25 2006 +0100 (2006-10-05) |
parents | 55e53c556f9f |
children | a72fdb6a19a1 |
files | linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu Oct 05 10:09:20 2006 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu Oct 05 10:09:25 2006 +0100 1.3 @@ -85,14 +85,39 @@ static const int MODPARM_rx_flip = 0; 1.4 #define RX_COPY_THRESHOLD 256 1.5 1.6 /* If we don't have GSO, fake things up so that we never try to use it. */ 1.7 -#ifdef NETIF_F_GSO 1.8 +#if defined(NETIF_F_GSO) 1.9 #define HAVE_GSO 1 1.10 +#define HAVE_TSO 1 /* TSO is a subset of GSO */ 1.11 static inline void dev_disable_gso_features(struct net_device *dev) 1.12 { 1.13 /* Turn off all GSO bits except ROBUST. */ 1.14 dev->features &= (1 << NETIF_F_GSO_SHIFT) - 1; 1.15 dev->features |= NETIF_F_GSO_ROBUST; 1.16 } 1.17 +#elif defined(NETIF_F_TSO) 1.18 +#define HAVE_TSO 1 1.19 +#define gso_size tso_size 1.20 +#define gso_segs tso_segs 1.21 +static inline void dev_disable_gso_features(struct net_device *dev) 1.22 +{ 1.23 + /* Turn off all TSO bits. */ 1.24 + dev->features &= ~NETIF_F_TSO; 1.25 +} 1.26 +static inline int skb_is_gso(const struct sk_buff *skb) 1.27 +{ 1.28 + return skb_shinfo(skb)->tso_size; 1.29 +} 1.30 +static inline int skb_gso_ok(struct sk_buff *skb, int features) 1.31 +{ 1.32 + return (features & NETIF_F_TSO); 1.33 +} 1.34 + 1.35 +static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb) 1.36 +{ 1.37 + return skb_is_gso(skb) && 1.38 + (!skb_gso_ok(skb, dev->features) || 1.39 + unlikely(skb->ip_summed != CHECKSUM_HW)); 1.40 +} 1.41 #else 1.42 #define netif_needs_gso(dev, skb) 0 1.43 #define dev_disable_gso_features(dev) ((void)0) 1.44 @@ -408,7 +433,7 @@ again: 1.45 goto abort_transaction; 1.46 } 1.47 1.48 -#ifdef HAVE_GSO 1.49 +#ifdef HAVE_TSO 1.50 err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", 1); 1.51 if (err) { 1.52 message = "writing feature-gso-tcpv4"; 1.53 @@ -940,7 +965,7 @@ static int network_start_xmit(struct sk_ 1.54 tx->flags |= NETTXF_data_validated; 1.55 #endif 1.56 1.57 -#ifdef HAVE_GSO 1.58 +#ifdef HAVE_TSO 1.59 if (skb_shinfo(skb)->gso_size) { 1.60 struct netif_extra_info *gso = (struct netif_extra_info *) 1.61 RING_GET_REQUEST(&np->tx, ++i); 1.62 @@ -1228,12 +1253,14 @@ static int xennet_set_skb_gso(struct sk_ 1.63 return -EINVAL; 1.64 } 1.65 1.66 +#ifdef HAVE_TSO 1.67 + skb_shinfo(skb)->gso_size = gso->u.gso.size; 1.68 #ifdef HAVE_GSO 1.69 - skb_shinfo(skb)->gso_size = gso->u.gso.size; 1.70 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; 1.71 1.72 /* Header must be checked, and gso_segs computed. */ 1.73 skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; 1.74 +#endif 1.75 skb_shinfo(skb)->gso_segs = 0; 1.76 1.77 return 0; 1.78 @@ -1584,7 +1611,7 @@ static int xennet_set_sg(struct net_devi 1.79 1.80 static int xennet_set_tso(struct net_device *dev, u32 data) 1.81 { 1.82 -#ifdef HAVE_GSO 1.83 +#ifdef HAVE_TSO 1.84 if (data) { 1.85 struct netfront_info *np = netdev_priv(dev); 1.86 int val;