Re: [NET] IOC3: Switch hw checksumming to ethtool configurable.

2007-07-30 Thread Jeff Garzik

Ralf Baechle wrote:

Signed-off-by: Ralf Baechle [EMAIL PROTECTED]


applied to #upstream (2.6.24)



I've previously sent out this patch a long time ago.  At that time I was
told NETIF_F_IP_CSUM wouldn't make any sense without NETIF_F_SG.  IOC3's
S/G abilities are very limited; it can do upto three segments of which
the first one is upto 104 bytes and part of the packet's TX ring entry,
the second and 3rd ones can be anywhere in the 64-bit PCI address space
but may not cross a 16kB page boundary.  So setting NETIF_F_SG isn't
really an option unless the IOC3 was going to linearize any packet it
can't cope with itself.

So the big question, does NETIF_F_IP_CSUM without NETIF_F_SG make sense?


Conventional wisdom has always been that NETIF_F_SG is required if 
NETIF_F_*CSUM is present, and vice versa.


I admit I've not verified this in the past year or two.

Jeff


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[NET] IOC3: Switch hw checksumming to ethtool configurable.

2007-07-25 Thread Ralf Baechle
Signed-off-by: Ralf Baechle [EMAIL PROTECTED]

---

I've previously sent out this patch a long time ago.  At that time I was
told NETIF_F_IP_CSUM wouldn't make any sense without NETIF_F_SG.  IOC3's
S/G abilities are very limited; it can do upto three segments of which
the first one is upto 104 bytes and part of the packet's TX ring entry,
the second and 3rd ones can be anywhere in the 64-bit PCI address space
but may not cross a 16kB page boundary.  So setting NETIF_F_SG isn't
really an option unless the IOC3 was going to linearize any packet it
can't cope with itself.

So the big question, does NETIF_F_IP_CSUM without NETIF_F_SG make sense?

 drivers/net/Kconfig|   20 
 drivers/net/ioc3-eth.c |   48 
 2 files changed, 32 insertions(+), 36 deletions(-)

Index: linux-2.6/drivers/net/Kconfig
===
--- linux-2.6.orig/drivers/net/Kconfig
+++ linux-2.6/drivers/net/Kconfig
@@ -480,26 +480,6 @@ config SGI_IOC3_ETH
  the Ethernet-HOWTO, available from
  http://www.tldp.org/docs.html#howto.
 
-config SGI_IOC3_ETH_HW_RX_CSUM
-   bool Receive hardware checksums
-   depends on SGI_IOC3_ETH  INET
-   default y
-   help
- The SGI IOC3 network adapter supports TCP and UDP checksums in
- hardware to offload processing of these checksums from the CPU.  At
- the moment only acceleration of IPv4 is supported.  This option
- enables offloading for checksums on receive.  If unsure, say Y.
-
-config SGI_IOC3_ETH_HW_TX_CSUM
-   bool Transmit hardware checksums
-   depends on SGI_IOC3_ETH  INET
-   default y
-   help
- The SGI IOC3 network adapter supports TCP and UDP checksums in
- hardware to offload processing of these checksums from the CPU.  At
- the moment only acceleration of IPv4 is supported.  This option
- enables offloading for checksums on transmit.  If unsure, say Y.
-
 config MIPS_SIM_NET
tristate MIPS simulator Network device
depends on MIPS_SIM
Index: linux-2.6/drivers/net/ioc3-eth.c
===
--- linux-2.6.orig/drivers/net/ioc3-eth.c
+++ linux-2.6/drivers/net/ioc3-eth.c
@@ -5,7 +5,7 @@
  *
  * Driver for SGI's IOC3 based Ethernet cards as found in the PCI card.
  *
- * Copyright (C) 1999, 2000, 2001, 2003 Ralf Baechle
+ * Copyright (C) 1999, 2000, 01, 03, 06 Ralf Baechle
  * Copyright (C) 1995, 1999, 2000, 2001 by Silicon Graphics, Inc.
  *
  * References:
@@ -61,12 +61,7 @@
 #include asm/pgtable.h
 #include asm/uaccess.h
 #include asm/sn/types.h
-#include asm/sn/sn0/addrs.h
-#include asm/sn/sn0/hubni.h
-#include asm/sn/sn0/hubio.h
-#include asm/sn/klconfig.h
 #include asm/sn/ioc3.h
-#include asm/sn/sn0/ip27.h
 #include asm/pci/bridge.h
 
 /*
@@ -94,6 +89,9 @@ struct ioc3_private {
u32 emcr, ehar_h, ehar_l;
spinlock_t ioc3_lock;
struct mii_if_info mii;
+   unsigned long flags;
+#define IOC3_FLAG_RX_CHECKSUMS 1
+
struct pci_dev *pdev;
 
/* Members used by autonegotiation  */
@@ -520,8 +518,6 @@ static struct net_device_stats *ioc3_get
return ip-stats;
 }
 
-#ifdef CONFIG_SGI_IOC3_ETH_HW_RX_CSUM
-
 static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
 {
struct ethhdr *eh = eth_hdr(skb);
@@ -589,7 +585,6 @@ static void ioc3_tcpudp_checksum(struct 
if (csum == 0x)
skb-ip_summed = CHECKSUM_UNNECESSARY;
 }
-#endif /* CONFIG_SGI_IOC3_ETH_HW_RX_CSUM */
 
 static inline void ioc3_rx(struct ioc3_private *ip)
 {
@@ -624,9 +619,9 @@ static inline void ioc3_rx(struct ioc3_p
goto next;
}
 
-#ifdef CONFIG_SGI_IOC3_ETH_HW_RX_CSUM
-   ioc3_tcpudp_checksum(skb, w0  ERXBUF_IPCKSUM_MASK,len);
-#endif
+   if (likely(ip-flags  IOC3_FLAG_RX_CHECKSUMS))
+   ioc3_tcpudp_checksum(skb,
+   w0  ERXBUF_IPCKSUM_MASK, len);
 
netif_rx(skb);
 
@@ -1298,9 +1293,7 @@ static int ioc3_probe(struct pci_dev *pd
dev-set_multicast_list = ioc3_set_multicast_list;
dev-set_mac_address= ioc3_set_mac_address;
dev-ethtool_ops= ioc3_ethtool_ops;
-#ifdef CONFIG_SGI_IOC3_ETH_HW_TX_CSUM
dev-features   = NETIF_F_IP_CSUM;
-#endif
 
sw_physid1 = ioc3_mdio_read(dev, ip-mii.phy_id, MII_PHYSID1);
sw_physid2 = ioc3_mdio_read(dev, ip-mii.phy_id, MII_PHYSID2);
@@ -1390,7 +1383,6 @@ static int ioc3_start_xmit(struct sk_buf
uint32_t w0 = 0;
int produce;
 
-#ifdef CONFIG_SGI_IOC3_ETH_HW_TX_CSUM
/*
 * IOC3 has a fairly simple minded checksumming hardware which simply
 * adds up the 1's complement checksum for the entire packet and
@@ -1438,7 +1430,6 @@ static