aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorIon Badulescu <ionut@badula.org>2005-10-03 22:31:36 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-10-03 22:31:36 -0400
commit67974231d4354fe26aaa39a3153b5c0945b94858 (patch)
tree14eccea7e68aed055aff5847b8dfdb32500aece0 /drivers/net
parent32fa2bfcf882f8901ca206e33b0d8975cc8e89a2 (diff)
[netdrvr starfire] fix highmem and broken firmware issues
Unfortunately, [your patch] might address the crash but doesn't address the real problem. It turns out that the problem is one of padding (the firmware cksum engine works only on 32-bit chunks, yuck), so the special casing for length == 1 wasn't sufficient anyway. This patch addresses the issue, as well the other issue of i386 + CONFIG_HIGHMEM being broken. It is pretty much the same workaround that Adaptec themselves used in their Windows driver. I have yet to check if it fixes the problem when the skb is non-linear, but this patch _will_ solve the problem for 99% of the users out there (those not using sendfile). Signed-off-by: Ion Badulescu <ionut@badula.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/starfire.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 88b89dc95c77..efdb179ecc8c 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -133,14 +133,18 @@
133 - finally added firmware (GPL'ed by Adaptec) 133 - finally added firmware (GPL'ed by Adaptec)
134 - removed compatibility code for 2.2.x 134 - removed compatibility code for 2.2.x
135 135
136 LK1.4.2.1 (Ion Badulescu)
137 - fixed 32/64 bit issues on i386 + CONFIG_HIGHMEM
138 - added 32-bit padding to outgoing skb's, removed previous workaround
139
136TODO: - fix forced speed/duplexing code (broken a long time ago, when 140TODO: - fix forced speed/duplexing code (broken a long time ago, when
137 somebody converted the driver to use the generic MII code) 141 somebody converted the driver to use the generic MII code)
138 - fix VLAN support 142 - fix VLAN support
139*/ 143*/
140 144
141#define DRV_NAME "starfire" 145#define DRV_NAME "starfire"
142#define DRV_VERSION "1.03+LK1.4.2" 146#define DRV_VERSION "1.03+LK1.4.2.1"
143#define DRV_RELDATE "January 19, 2005" 147#define DRV_RELDATE "October 3, 2005"
144 148
145#include <linux/config.h> 149#include <linux/config.h>
146#include <linux/version.h> 150#include <linux/version.h>
@@ -165,6 +169,14 @@ TODO: - fix forced speed/duplexing code (broken a long time ago, when
165 * of length 1. If and when this is fixed, the #define below can be removed. 169 * of length 1. If and when this is fixed, the #define below can be removed.
166 */ 170 */
167#define HAS_BROKEN_FIRMWARE 171#define HAS_BROKEN_FIRMWARE
172
173/*
174 * If using the broken firmware, data must be padded to the next 32-bit boundary.
175 */
176#ifdef HAS_BROKEN_FIRMWARE
177#define PADDING_MASK 3
178#endif
179
168/* 180/*
169 * Define this if using the driver with the zero-copy patch 181 * Define this if using the driver with the zero-copy patch
170 */ 182 */
@@ -257,9 +269,10 @@ static int full_duplex[MAX_UNITS] = {0, };
257 * This SUCKS. 269 * This SUCKS.
258 * We need a much better method to determine if dma_addr_t is 64-bit. 270 * We need a much better method to determine if dma_addr_t is 64-bit.
259 */ 271 */
260#if (defined(__i386__) && defined(CONFIG_HIGHMEM) && (LINUX_VERSION_CODE > 0x20500 || defined(CONFIG_HIGHMEM64G))) || defined(__x86_64__) || defined (__ia64__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) 272#if (defined(__i386__) && defined(CONFIG_HIGHMEM64G)) || defined(__x86_64__) || defined (__ia64__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR))
261/* 64-bit dma_addr_t */ 273/* 64-bit dma_addr_t */
262#define ADDR_64BITS /* This chip uses 64 bit addresses. */ 274#define ADDR_64BITS /* This chip uses 64 bit addresses. */
275#define netdrv_addr_t u64
263#define cpu_to_dma(x) cpu_to_le64(x) 276#define cpu_to_dma(x) cpu_to_le64(x)
264#define dma_to_cpu(x) le64_to_cpu(x) 277#define dma_to_cpu(x) le64_to_cpu(x)
265#define RX_DESC_Q_ADDR_SIZE RxDescQAddr64bit 278#define RX_DESC_Q_ADDR_SIZE RxDescQAddr64bit
@@ -268,6 +281,7 @@ static int full_duplex[MAX_UNITS] = {0, };
268#define TX_COMPL_Q_ADDR_SIZE TxComplQAddr64bit 281#define TX_COMPL_Q_ADDR_SIZE TxComplQAddr64bit
269#define RX_DESC_ADDR_SIZE RxDescAddr64bit 282#define RX_DESC_ADDR_SIZE RxDescAddr64bit
270#else /* 32-bit dma_addr_t */ 283#else /* 32-bit dma_addr_t */
284#define netdrv_addr_t u32
271#define cpu_to_dma(x) cpu_to_le32(x) 285#define cpu_to_dma(x) cpu_to_le32(x)
272#define dma_to_cpu(x) le32_to_cpu(x) 286#define dma_to_cpu(x) le32_to_cpu(x)
273#define RX_DESC_Q_ADDR_SIZE RxDescQAddr32bit 287#define RX_DESC_Q_ADDR_SIZE RxDescQAddr32bit
@@ -1333,21 +1347,10 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
1333 } 1347 }
1334 1348
1335#if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE) 1349#if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE)
1336 { 1350 if (skb->ip_summed == CHECKSUM_HW) {
1337 int has_bad_length = 0; 1351 skb = skb_padto(skb, (skb->len + PADDING_MASK) & ~PADDING_MASK);
1338 1352 if (skb == NULL)
1339 if (skb_first_frag_len(skb) == 1) 1353 return NETDEV_TX_OK;
1340 has_bad_length = 1;
1341 else {
1342 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1343 if (skb_shinfo(skb)->frags[i].size == 1) {
1344 has_bad_length = 1;
1345 break;
1346 }
1347 }
1348
1349 if (has_bad_length)
1350 skb_checksum_help(skb, 0);
1351 } 1354 }
1352#endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */ 1355#endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */
1353 1356
@@ -2127,13 +2130,12 @@ static int __init starfire_init (void)
2127#endif 2130#endif
2128#endif 2131#endif
2129 2132
2130#ifndef ADDR_64BITS
2131 /* we can do this test only at run-time... sigh */ 2133 /* we can do this test only at run-time... sigh */
2132 if (sizeof(dma_addr_t) == sizeof(u64)) { 2134 if (sizeof(dma_addr_t) != sizeof(netdrv_addr_t)) {
2133 printk("This driver has not been ported to this 64-bit architecture yet\n"); 2135 printk("This driver has dma_addr_t issues, please send email to maintainer\n");
2134 return -ENODEV; 2136 return -ENODEV;
2135 } 2137 }
2136#endif /* not ADDR_64BITS */ 2138
2137 return pci_module_init (&starfire_driver); 2139 return pci_module_init (&starfire_driver);
2138} 2140}
2139 2141