ia64/xen-unstable

changeset 11195:8d5e6a78d51e

[NET] front: Make netfront compile against kernels without the GSO patch.
Signed-off-by: Steven Smith <ssmith@xensource.com>
author kfraser@localhost.localdomain
date Thu Aug 17 16:57:43 2006 +0100 (2006-08-17)
parents 28de3548c65f
children cbdc98fc3a6f
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 Aug 17 16:57:16 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Aug 17 16:57:43 2006 +0100
     1.3 @@ -64,6 +64,20 @@
     1.4  
     1.5  #define RX_COPY_THRESHOLD 256
     1.6  
     1.7 +/* If we don't have GSO, fake things up so that we never try to use it. */
     1.8 +#ifndef NETIF_F_GSO
     1.9 +#define netif_needs_gso(dev, skb)	0
    1.10 +#define dev_disable_gso_features(dev)	((void)0)
    1.11 +#else
    1.12 +#define HAVE_GSO			1
    1.13 +static inline void dev_disable_gso_features(struct net_device *dev)
    1.14 +{
    1.15 +	/* Turn off all GSO bits except ROBUST. */
    1.16 +	dev->features &= (1 << NETIF_F_GSO_SHIFT) - 1;
    1.17 +	dev->features |= NETIF_F_GSO_ROBUST;
    1.18 +}
    1.19 +#endif
    1.20 +
    1.21  #define GRANT_INVALID_REF	0
    1.22  
    1.23  #define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE)
    1.24 @@ -362,11 +376,13 @@ again:
    1.25  		goto abort_transaction;
    1.26  	}
    1.27  
    1.28 +#ifdef HAVE_GSO
    1.29  	err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", 1);
    1.30  	if (err) {
    1.31  		message = "writing feature-gso-tcpv4";
    1.32  		goto abort_transaction;
    1.33  	}
    1.34 +#endif
    1.35  
    1.36  	err = xenbus_transaction_end(xbt, 0);
    1.37  	if (err) {
    1.38 @@ -887,6 +903,7 @@ static int network_start_xmit(struct sk_
    1.39  	if (skb->proto_data_valid) /* remote but checksummed? */
    1.40  		tx->flags |= NETTXF_data_validated;
    1.41  
    1.42 +#ifdef HAVE_GSO
    1.43  	if (skb_shinfo(skb)->gso_size) {
    1.44  		struct netif_extra_info *gso = (struct netif_extra_info *)
    1.45  			RING_GET_REQUEST(&np->tx, ++i);
    1.46 @@ -905,6 +922,7 @@ static int network_start_xmit(struct sk_
    1.47  		gso->flags = 0;
    1.48  		extra = gso;
    1.49  	}
    1.50 +#endif
    1.51  
    1.52  	np->tx.req_prod_pvt = i + 1;
    1.53  
    1.54 @@ -1151,7 +1169,8 @@ static RING_IDX xennet_fill_frags(struct
    1.55  	return cons;
    1.56  }
    1.57  
    1.58 -static int xennet_set_skb_gso(struct sk_buff *skb, struct netif_extra_info *gso)
    1.59 +static int xennet_set_skb_gso(struct sk_buff *skb,
    1.60 +			      struct netif_extra_info *gso)
    1.61  {
    1.62  	if (!gso->u.gso.size) {
    1.63  		if (net_ratelimit())
    1.64 @@ -1166,6 +1185,7 @@ static int xennet_set_skb_gso(struct sk_
    1.65  		return -EINVAL;
    1.66  	}
    1.67  
    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 @@ -1174,6 +1194,11 @@ static int xennet_set_skb_gso(struct sk_
    1.73  	skb_shinfo(skb)->gso_segs = 0;
    1.74  
    1.75  	return 0;
    1.76 +#else
    1.77 +	if (net_ratelimit())
    1.78 +		WPRINTK("GSO unsupported by this kernel.\n");
    1.79 +	return -EINVAL;
    1.80 +#endif
    1.81  }
    1.82  
    1.83  static int netif_poll(struct net_device *dev, int *pbudget)
    1.84 @@ -1408,6 +1433,7 @@ static int xennet_set_sg(struct net_devi
    1.85  
    1.86  static int xennet_set_tso(struct net_device *dev, u32 data)
    1.87  {
    1.88 +#ifdef HAVE_GSO
    1.89  	if (data) {
    1.90  		struct netfront_info *np = netdev_priv(dev);
    1.91  		int val;
    1.92 @@ -1420,13 +1446,14 @@ static int xennet_set_tso(struct net_dev
    1.93  	}
    1.94  
    1.95  	return ethtool_op_set_tso(dev, data);
    1.96 +#else
    1.97 +	return -ENOSYS;
    1.98 +#endif
    1.99  }
   1.100  
   1.101  static void xennet_set_features(struct net_device *dev)
   1.102  {
   1.103 -	/* Turn off all GSO bits except ROBUST. */
   1.104 -	dev->features &= (1 << NETIF_F_GSO_SHIFT) - 1;
   1.105 -	dev->features |= NETIF_F_GSO_ROBUST;
   1.106 +	dev_disable_gso_features(dev);
   1.107  	xennet_set_sg(dev, 0);
   1.108  
   1.109  	/* We need checksum offload to enable scatter/gather and TSO. */