[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] [LINUX] netfront: Cleanup and fix TSO/GSO/CHECKSUM conditionals
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Date 1187019215 -3600 # Node ID d423292c407d0652c1151dd61e361c404ecc0a59 # Parent 877c2e42a701d6a32ca30f35da34ade0b935f820 [LINUX] netfront: Cleanup and fix TSO/GSO/CHECKSUM conditionals This patch tries to minimise the amount of code that is conditionally compiled. This is desirable (and the Linux way) as it helps to prevent people breaking code unwittingly since conditionals may hide compile problems. It also adds a missing conditional around the TSO ethtool operations. This also helps the building of netfront under Linux 2.4 which doesn't have TSO. Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> --- drivers/xen/netfront/netfront.c | 36 ++++++++++++++++++------------------ 1 files changed, 18 insertions(+), 18 deletions(-) diff -r 877c2e42a701 -r d423292c407d drivers/xen/netfront/netfront.c --- a/drivers/xen/netfront/netfront.c Mon Aug 13 12:21:19 2007 +0100 +++ b/drivers/xen/netfront/netfront.c Mon Aug 13 16:33:35 2007 +0100 @@ -99,6 +99,7 @@ static const int MODPARM_rx_flip = 0; #if defined(NETIF_F_GSO) #define HAVE_GSO 1 #define HAVE_TSO 1 /* TSO is a subset of GSO */ +#define HAVE_CSUM_OFFLOAD 1 static inline void dev_disable_gso_features(struct net_device *dev) { /* Turn off all GSO bits except ROBUST. */ @@ -106,6 +107,7 @@ static inline void dev_disable_gso_featu dev->features |= NETIF_F_GSO_ROBUST; } #elif defined(NETIF_F_TSO) +#define HAVE_GSO 0 #define HAVE_TSO 1 /* Some older kernels cannot cope with incorrect checksums, @@ -113,7 +115,7 @@ static inline void dev_disable_gso_featu * with the presence of NETIF_F_TSO but it appears to be a good first * approximiation. */ -#define HAVE_NO_CSUM_OFFLOAD 1 +#define HAVE_CSUM_OFFLOAD 0 #define gso_size tso_size #define gso_segs tso_segs @@ -138,8 +140,12 @@ static inline int netif_needs_gso(struct unlikely(skb->ip_summed != CHECKSUM_HW)); } #else +#define HAVE_GSO 0 +#define HAVE_TSO 0 +#define HAVE_CSUM_OFFLOAD 0 #define netif_needs_gso(dev, skb) 0 #define dev_disable_gso_features(dev) ((void)0) +#define ethtool_op_set_tso(dev, data) (-ENOSYS) #endif #define GRANT_INVALID_REF 0 @@ -412,13 +418,12 @@ again: goto abort_transaction; } -#ifdef HAVE_NO_CSUM_OFFLOAD - err = xenbus_printf(xbt, dev->nodename, "feature-no-csum-offload", "%d", 1); + err = xenbus_printf(xbt, dev->nodename, "feature-no-csum-offload", + "%d", !HAVE_CSUM_OFFLOAD); if (err) { message = "writing feature-no-csum-offload"; goto abort_transaction; } -#endif err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", 1); if (err) { @@ -426,13 +431,12 @@ again: goto abort_transaction; } -#ifdef HAVE_TSO - err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", 1); + err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", + HAVE_TSO); if (err) { message = "writing feature-gso-tcpv4"; goto abort_transaction; } -#endif err = xenbus_transaction_end(xbt, 0); if (err) { @@ -983,7 +987,7 @@ static int network_start_xmit(struct sk_ tx->flags |= NETTXF_data_validated; #endif -#ifdef HAVE_TSO +#if HAVE_TSO if (skb_shinfo(skb)->gso_size) { struct netif_extra_info *gso = (struct netif_extra_info *) RING_GET_REQUEST(&np->tx, ++i); @@ -1280,9 +1284,9 @@ static int xennet_set_skb_gso(struct sk_ return -EINVAL; } -#ifdef HAVE_TSO +#if HAVE_TSO skb_shinfo(skb)->gso_size = gso->u.gso.size; -#ifdef HAVE_GSO +#if HAVE_GSO skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; /* Header must be checked, and gso_segs computed. */ @@ -1702,7 +1706,6 @@ static int xennet_set_sg(struct net_devi static int xennet_set_tso(struct net_device *dev, u32 data) { -#ifdef HAVE_TSO if (data) { struct netfront_info *np = netdev_priv(dev); int val; @@ -1715,9 +1718,6 @@ static int xennet_set_tso(struct net_dev } return ethtool_op_set_tso(dev, data); -#else - return -ENOSYS; -#endif } static void xennet_set_features(struct net_device *dev) @@ -1735,10 +1735,8 @@ static void xennet_set_features(struct n /* Before 2.6.9 TSO seems to be unreliable so do not enable it * on older kernels. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9) - xennet_set_tso(dev, 1); -#endif - + if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9)) + xennet_set_tso(dev, 1); } static int network_connect(struct net_device *dev) @@ -1866,8 +1864,10 @@ static struct ethtool_ops network_ethtoo .set_tx_csum = ethtool_op_set_tx_csum, .get_sg = ethtool_op_get_sg, .set_sg = xennet_set_sg, +#if HAVE_TSO .get_tso = ethtool_op_get_tso, .set_tso = xennet_set_tso, +#endif .get_link = ethtool_op_get_link, }; _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |