aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/networking/dm9000.txt167
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c7
-rw-r--r--arch/blackfin/mach-bf533/boards/H8606.c7
-rw-r--r--arch/blackfin/mach-bf537/boards/generic_board.c7
-rw-r--r--drivers/net/8139cp.c1
-rw-r--r--drivers/net/8139too.c13
-rw-r--r--drivers/net/Kconfig31
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c21
-rw-r--r--drivers/net/cxgb3/t3cdev.h3
-rw-r--r--drivers/net/dl2k.c2
-rw-r--r--drivers/net/dm9000.c1159
-rw-r--r--drivers/net/dm9000.h11
-rw-r--r--drivers/net/e1000/e1000_main.c34
-rw-r--r--drivers/net/e1000e/e1000.h4
-rw-r--r--drivers/net/e1000e/netdev.c48
-rw-r--r--drivers/net/fealnx.c43
-rw-r--r--drivers/net/forcedeth.c5
-rw-r--r--drivers/net/igb/igb.h4
-rw-r--r--drivers/net/igb/igb_main.c47
-rw-r--r--drivers/net/ixgbe/ixgbe.h9
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c11
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c111
-rw-r--r--drivers/net/pci-skeleton.c1
-rw-r--r--drivers/net/sh_eth.c4
-rw-r--r--drivers/net/sh_eth.h4
-rw-r--r--drivers/net/tsi108_eth.c1
-rw-r--r--drivers/net/tulip/21142.c6
-rw-r--r--drivers/net/tulip/de2104x.c10
-rw-r--r--drivers/net/tulip/eeprom.c6
-rw-r--r--drivers/net/tulip/interrupt.c5
-rw-r--r--drivers/net/tulip/media.c5
-rw-r--r--drivers/net/tulip/pnic.c5
-rw-r--r--drivers/net/tulip/pnic2.c5
-rw-r--r--drivers/net/tulip/timer.c6
-rw-r--r--drivers/net/tulip/tulip.h4
-rw-r--r--drivers/net/tulip/tulip_core.c8
-rw-r--r--drivers/net/typhoon.c3
-rw-r--r--drivers/net/usb/rndis_host.c14
-rw-r--r--drivers/net/wireless/rndis_wlan.c4
-rw-r--r--drivers/pci/pci-acpi.c20
-rw-r--r--include/linux/dm9000.h1
-rw-r--r--include/linux/usb/rndis_host.h3
42 files changed, 1122 insertions, 738 deletions
diff --git a/Documentation/networking/dm9000.txt b/Documentation/networking/dm9000.txt
new file mode 100644
index 000000000000..65df3dea5561
--- /dev/null
+++ b/Documentation/networking/dm9000.txt
@@ -0,0 +1,167 @@
1DM9000 Network driver
2=====================
3
4Copyright 2008 Simtec Electronics,
5 Ben Dooks <ben@simtec.co.uk> <ben-linux@fluff.org>
6
7
8Introduction
9------------
10
11This file describes how to use the DM9000 platform-device based network driver
12that is contained in the files drivers/net/dm9000.c and drivers/net/dm9000.h.
13
14The driver supports three DM9000 variants, the DM9000E which is the first chip
15supported as well as the newer DM9000A and DM9000B devices. It is currently
16maintained and tested by Ben Dooks, who should be CC: to any patches for this
17driver.
18
19
20Defining the platform device
21----------------------------
22
23The minimum set of resources attached to the platform device are as follows:
24
25 1) The physical address of the address register
26 2) The physical address of the data register
27 3) The IRQ line the device's interrupt pin is connected to.
28
29These resources should be specified in that order, as the ordering of the
30two address regions is important (the driver expects these to be address
31and then data).
32
33An example from arch/arm/mach-s3c2410/mach-bast.c is:
34
35static struct resource bast_dm9k_resource[] = {
36 [0] = {
37 .start = S3C2410_CS5 + BAST_PA_DM9000,
38 .end = S3C2410_CS5 + BAST_PA_DM9000 + 3,
39 .flags = IORESOURCE_MEM,
40 },
41 [1] = {
42 .start = S3C2410_CS5 + BAST_PA_DM9000 + 0x40,
43 .end = S3C2410_CS5 + BAST_PA_DM9000 + 0x40 + 0x3f,
44 .flags = IORESOURCE_MEM,
45 },
46 [2] = {
47 .start = IRQ_DM9000,
48 .end = IRQ_DM9000,
49 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
50 }
51};
52
53static struct platform_device bast_device_dm9k = {
54 .name = "dm9000",
55 .id = 0,
56 .num_resources = ARRAY_SIZE(bast_dm9k_resource),
57 .resource = bast_dm9k_resource,
58};
59
60Note the setting of the IRQ trigger flag in bast_dm9k_resource[2].flags,
61as this will generate a warning if it is not present. The trigger from
62the flags field will be passed to request_irq() when registering the IRQ
63handler to ensure that the IRQ is setup correctly.
64
65This shows a typical platform device, without the optional configuration
66platform data supplied. The next example uses the same resources, but adds
67the optional platform data to pass extra configuration data:
68
69static struct dm9000_plat_data bast_dm9k_platdata = {
70 .flags = DM9000_PLATF_16BITONLY,
71};
72
73static struct platform_device bast_device_dm9k = {
74 .name = "dm9000",
75 .id = 0,
76 .num_resources = ARRAY_SIZE(bast_dm9k_resource),
77 .resource = bast_dm9k_resource,
78 .dev = {
79 .platform_data = &bast_dm9k_platdata,
80 }
81};
82
83The platform data is defined in include/linux/dm9000.h and described below.
84
85
86Platform data
87-------------
88
89Extra platform data for the DM9000 can describe the IO bus width to the
90device, whether or not an external PHY is attached to the device and
91the availability of an external configuration EEPROM.
92
93The flags for the platform data .flags field are as follows:
94
95DM9000_PLATF_8BITONLY
96
97 The IO should be done with 8bit operations.
98
99DM9000_PLATF_16BITONLY
100
101 The IO should be done with 16bit operations.
102
103DM9000_PLATF_32BITONLY
104
105 The IO should be done with 32bit operations.
106
107DM9000_PLATF_EXT_PHY
108
109 The chip is connected to an external PHY.
110
111DM9000_PLATF_NO_EEPROM
112
113 This can be used to signify that the board does not have an
114 EEPROM, or that the EEPROM should be hidden from the user.
115
116DM9000_PLATF_SIMPLE_PHY
117
118 Switch to using the simpler PHY polling method which does not
119 try and read the MII PHY state regularly. This is only available
120 when using the internal PHY. See the section on link state polling
121 for more information.
122
123 The config symbol DM9000_FORCE_SIMPLE_PHY_POLL, Kconfig entry
124 "Force simple NSR based PHY polling" allows this flag to be
125 forced on at build time.
126
127
128PHY Link state polling
129----------------------
130
131The driver keeps track of the link state and informs the network core
132about link (carrier) availablilty. This is managed by several methods
133depending on the version of the chip and on which PHY is being used.
134
135For the internal PHY, the original (and currently default) method is
136to read the MII state, either when the status changes if we have the
137necessary interrupt support in the chip or every two seconds via a
138periodic timer.
139
140To reduce the overhead for the internal PHY, there is now the option
141of using the DM9000_FORCE_SIMPLE_PHY_POLL config, or DM9000_PLATF_SIMPLE_PHY
142platform data option to read the summary information without the
143expensive MII accesses. This method is faster, but does not print
144as much information.
145
146When using an external PHY, the driver currently has to poll the MII
147link status as there is no method for getting an interrupt on link change.
148
149
150DM9000A / DM9000B
151-----------------
152
153These chips are functionally similar to the DM9000E and are supported easily
154by the same driver. The features are:
155
156 1) Interrupt on internal PHY state change. This means that the periodic
157 polling of the PHY status may be disabled on these devices when using
158 the internal PHY.
159
160 2) TCP/UDP checksum offloading, which the driver does not currently support.
161
162
163ethtool
164-------
165
166The driver supports the ethtool interface for access to the driver
167state information, the PHY state and the EEPROM.
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index 5958eecefcf1..689b69c98ee4 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -323,10 +323,15 @@ static struct platform_device smc91x_device = {
323static struct resource dm9000_resources[] = { 323static struct resource dm9000_resources[] = {
324 [0] = { 324 [0] = {
325 .start = 0x203FB800, 325 .start = 0x203FB800,
326 .end = 0x203FB800 + 8, 326 .end = 0x203FB800 + 1,
327 .flags = IORESOURCE_MEM, 327 .flags = IORESOURCE_MEM,
328 }, 328 },
329 [1] = { 329 [1] = {
330 .start = 0x203FB800 + 4,
331 .end = 0x203FB800 + 5,
332 .flags = IORESOURCE_MEM,
333 },
334 [2] = {
330 .start = IRQ_PF9, 335 .start = IRQ_PF9,
331 .end = IRQ_PF9, 336 .end = IRQ_PF9,
332 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE), 337 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
diff --git a/arch/blackfin/mach-bf533/boards/H8606.c b/arch/blackfin/mach-bf533/boards/H8606.c
index 7cc4864f6aaf..4103a97c1a70 100644
--- a/arch/blackfin/mach-bf533/boards/H8606.c
+++ b/arch/blackfin/mach-bf533/boards/H8606.c
@@ -65,10 +65,15 @@ static struct platform_device rtc_device = {
65static struct resource dm9000_resources[] = { 65static struct resource dm9000_resources[] = {
66 [0] = { 66 [0] = {
67 .start = 0x20300000, 67 .start = 0x20300000,
68 .end = 0x20300000 + 8, 68 .end = 0x20300000 + 1,
69 .flags = IORESOURCE_MEM, 69 .flags = IORESOURCE_MEM,
70 }, 70 },
71 [1] = { 71 [1] = {
72 .start = 0x20300000 + 4,
73 .end = 0x20300000 + 5,
74 .flags = IORESOURCE_MEM,
75 },
76 [2] = {
72 .start = IRQ_PF10, 77 .start = IRQ_PF10,
73 .end = IRQ_PF10, 78 .end = IRQ_PF10,
74 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE), 79 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
diff --git a/arch/blackfin/mach-bf537/boards/generic_board.c b/arch/blackfin/mach-bf537/boards/generic_board.c
index 7d250828dad8..01b63e2ec18f 100644
--- a/arch/blackfin/mach-bf537/boards/generic_board.c
+++ b/arch/blackfin/mach-bf537/boards/generic_board.c
@@ -166,10 +166,15 @@ static struct platform_device smc91x_device = {
166static struct resource dm9000_resources[] = { 166static struct resource dm9000_resources[] = {
167 [0] = { 167 [0] = {
168 .start = 0x203FB800, 168 .start = 0x203FB800,
169 .end = 0x203FB800 + 8, 169 .end = 0x203FB800 + 1,
170 .flags = IORESOURCE_MEM, 170 .flags = IORESOURCE_MEM,
171 }, 171 },
172 [1] = { 172 [1] = {
173 .start = 0x203FB800 + 4,
174 .end = 0x203FB800 + 5,
175 .flags = IORESOURCE_MEM,
176 },
177 [2] = {
173 .start = IRQ_PF9, 178 .start = IRQ_PF9,
174 .end = IRQ_PF9, 179 .end = IRQ_PF9,
175 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE), 180 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 934db350e339..6011d6fabef0 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1213,7 +1213,6 @@ static int cp_close (struct net_device *dev)
1213 1213
1214 spin_unlock_irqrestore(&cp->lock, flags); 1214 spin_unlock_irqrestore(&cp->lock, flags);
1215 1215
1216 synchronize_irq(dev->irq);
1217 free_irq(dev->irq, dev); 1216 free_irq(dev->irq, dev);
1218 1217
1219 cp_free_rings(cp); 1218 cp_free_rings(cp);
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index b23a00c5b84f..75317a14ad1c 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -107,8 +107,8 @@
107#include <linux/mii.h> 107#include <linux/mii.h>
108#include <linux/completion.h> 108#include <linux/completion.h>
109#include <linux/crc32.h> 109#include <linux/crc32.h>
110#include <asm/io.h> 110#include <linux/io.h>
111#include <asm/uaccess.h> 111#include <linux/uaccess.h>
112#include <asm/irq.h> 112#include <asm/irq.h>
113 113
114#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION 114#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION
@@ -134,7 +134,7 @@
134 134
135#if RTL8139_DEBUG 135#if RTL8139_DEBUG
136/* note: prints function name for you */ 136/* note: prints function name for you */
137# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) 137# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
138#else 138#else
139# define DPRINTK(fmt, args...) 139# define DPRINTK(fmt, args...)
140#endif 140#endif
@@ -145,7 +145,7 @@
145# define assert(expr) \ 145# define assert(expr) \
146 if(unlikely(!(expr))) { \ 146 if(unlikely(!(expr))) { \
147 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ 147 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
148 #expr,__FILE__,__FUNCTION__,__LINE__); \ 148 #expr, __FILE__, __func__, __LINE__); \
149 } 149 }
150#endif 150#endif
151 151
@@ -219,7 +219,7 @@ enum {
219#define RTL8139B_IO_SIZE 256 219#define RTL8139B_IO_SIZE 256
220 220
221#define RTL8129_CAPS HAS_MII_XCVR 221#define RTL8129_CAPS HAS_MII_XCVR
222#define RTL8139_CAPS HAS_CHIP_XCVR|HAS_LNK_CHNG 222#define RTL8139_CAPS (HAS_CHIP_XCVR|HAS_LNK_CHNG)
223 223
224typedef enum { 224typedef enum {
225 RTL8139 = 0, 225 RTL8139 = 0,
@@ -1889,7 +1889,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1889} 1889}
1890 1890
1891#if RX_BUF_IDX == 3 1891#if RX_BUF_IDX == 3
1892static __inline__ void wrap_copy(struct sk_buff *skb, const unsigned char *ring, 1892static inline void wrap_copy(struct sk_buff *skb, const unsigned char *ring,
1893 u32 offset, unsigned int size) 1893 u32 offset, unsigned int size)
1894{ 1894{
1895 u32 left = RX_BUF_LEN - offset; 1895 u32 left = RX_BUF_LEN - offset;
@@ -2231,7 +2231,6 @@ static int rtl8139_close (struct net_device *dev)
2231 2231
2232 spin_unlock_irqrestore (&tp->lock, flags); 2232 spin_unlock_irqrestore (&tp->lock, flags);
2233 2233
2234 synchronize_irq (dev->irq); /* racy, but that's ok here */
2235 free_irq (dev->irq, dev); 2234 free_irq (dev->irq, dev);
2236 2235
2237 rtl8139_tx_clear (tp); 2236 rtl8139_tx_clear (tp);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 287d0873c60d..d85b9d067597 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -938,6 +938,23 @@ config DM9000
938 To compile this driver as a module, choose M here. The module 938 To compile this driver as a module, choose M here. The module
939 will be called dm9000. 939 will be called dm9000.
940 940
941config DM9000_DEBUGLEVEL
942 int "DM9000 maximum debug level"
943 depends on DM9000
944 default 4
945 help
946 The maximum level of debugging code compiled into the DM9000
947 driver.
948
949config DM9000_FORCE_SIMPLE_PHY_POLL
950 bool "Force simple NSR based PHY polling"
951 depends on DM9000
952 ---help---
953 This configuration forces the DM9000 to use the NSR's LinkStatus
954 bit to determine if the link is up or down instead of the more
955 costly MII PHY reads. Note, this will not work if the chip is
956 operating with an external PHY.
957
941config ENC28J60 958config ENC28J60
942 tristate "ENC28J60 support" 959 tristate "ENC28J60 support"
943 depends on EXPERIMENTAL && SPI && NET_ETHERNET 960 depends on EXPERIMENTAL && SPI && NET_ETHERNET
@@ -955,14 +972,6 @@ config ENC28J60_WRITEVERIFY
955 Enable the verify after the buffer write useful for debugging purpose. 972 Enable the verify after the buffer write useful for debugging purpose.
956 If unsure, say N. 973 If unsure, say N.
957 974
958config DM9000_DEBUGLEVEL
959 int "DM9000 maximum debug level"
960 depends on DM9000
961 default 4
962 help
963 The maximum level of debugging code compiled into the DM9000
964 driver.
965
966config SMC911X 975config SMC911X
967 tristate "SMSC LAN911[5678] support" 976 tristate "SMSC LAN911[5678] support"
968 select CRC32 977 select CRC32
@@ -2025,9 +2034,6 @@ config E1000E
2025 To compile this driver as a module, choose M here. The module 2034 To compile this driver as a module, choose M here. The module
2026 will be called e1000e. 2035 will be called e1000e.
2027 2036
2028config E1000E_ENABLED
2029 def_bool E1000E != n
2030
2031config IP1000 2037config IP1000
2032 tristate "IP1000 Gigabit Ethernet support" 2038 tristate "IP1000 Gigabit Ethernet support"
2033 depends on PCI && EXPERIMENTAL 2039 depends on PCI && EXPERIMENTAL
@@ -2462,7 +2468,8 @@ config EHEA
2462 2468
2463config IXGBE 2469config IXGBE
2464 tristate "Intel(R) 10GbE PCI Express adapters support" 2470 tristate "Intel(R) 10GbE PCI Express adapters support"
2465 depends on PCI 2471 depends on PCI && INET
2472 select INET_LRO
2466 ---help--- 2473 ---help---
2467 This driver supports Intel(R) 10GbE PCI Express family of 2474 This driver supports Intel(R) 10GbE PCI Express family of
2468 adapters. For more information on how to identify your adapter, go 2475 adapters. For more information on how to identify your adapter, go
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index ff9c013ce535..ae6ff5df779c 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -1248,6 +1248,25 @@ static inline void unregister_tdev(struct t3cdev *tdev)
1248 mutex_unlock(&cxgb3_db_lock); 1248 mutex_unlock(&cxgb3_db_lock);
1249} 1249}
1250 1250
1251static inline int adap2type(struct adapter *adapter)
1252{
1253 int type = 0;
1254
1255 switch (adapter->params.rev) {
1256 case T3_REV_A:
1257 type = T3A;
1258 break;
1259 case T3_REV_B:
1260 case T3_REV_B2:
1261 type = T3B;
1262 break;
1263 case T3_REV_C:
1264 type = T3C;
1265 break;
1266 }
1267 return type;
1268}
1269
1251void __devinit cxgb3_adapter_ofld(struct adapter *adapter) 1270void __devinit cxgb3_adapter_ofld(struct adapter *adapter)
1252{ 1271{
1253 struct t3cdev *tdev = &adapter->tdev; 1272 struct t3cdev *tdev = &adapter->tdev;
@@ -1257,7 +1276,7 @@ void __devinit cxgb3_adapter_ofld(struct adapter *adapter)
1257 cxgb3_set_dummy_ops(tdev); 1276 cxgb3_set_dummy_ops(tdev);
1258 tdev->send = t3_offload_tx; 1277 tdev->send = t3_offload_tx;
1259 tdev->ctl = cxgb_offload_ctl; 1278 tdev->ctl = cxgb_offload_ctl;
1260 tdev->type = adapter->params.rev == 0 ? T3A : T3B; 1279 tdev->type = adap2type(adapter);
1261 1280
1262 register_tdev(tdev); 1281 register_tdev(tdev);
1263} 1282}
diff --git a/drivers/net/cxgb3/t3cdev.h b/drivers/net/cxgb3/t3cdev.h
index a18c8a140424..8556628fd5af 100644
--- a/drivers/net/cxgb3/t3cdev.h
+++ b/drivers/net/cxgb3/t3cdev.h
@@ -45,7 +45,8 @@ struct cxgb3_client;
45 45
46enum t3ctype { 46enum t3ctype {
47 T3A = 0, 47 T3A = 0,
48 T3B 48 T3B,
49 T3C,
49}; 50};
50 51
51struct t3cdev { 52struct t3cdev {
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index 8277e89e552d..f8037110a522 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -1753,7 +1753,7 @@ rio_close (struct net_device *dev)
1753 1753
1754 /* Stop Tx and Rx logics */ 1754 /* Stop Tx and Rx logics */
1755 writel (TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl); 1755 writel (TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl);
1756 synchronize_irq (dev->irq); 1756
1757 free_irq (dev->irq, dev); 1757 free_irq (dev->irq, dev);
1758 del_timer_sync (&np->timer); 1758 del_timer_sync (&np->timer);
1759 1759
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 08a7365a7d10..952e10d686ec 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -44,9 +44,8 @@
44 44
45#define DM9000_PHY 0x40 /* PHY address 0x01 */ 45#define DM9000_PHY 0x40 /* PHY address 0x01 */
46 46
47#define CARDNAME "dm9000" 47#define CARDNAME "dm9000"
48#define PFX CARDNAME ": " 48#define DRV_VERSION "1.31"
49#define DRV_VERSION "1.30"
50 49
51#ifdef CONFIG_BLACKFIN 50#ifdef CONFIG_BLACKFIN
52#define readsb insb 51#define readsb insb
@@ -55,9 +54,6 @@
55#define writesb outsb 54#define writesb outsb
56#define writesw outsw 55#define writesw outsw
57#define writesl outsl 56#define writesl outsl
58#define DEFAULT_TRIGGER IRQF_TRIGGER_HIGH
59#else
60#define DEFAULT_TRIGGER (0)
61#endif 57#endif
62 58
63/* 59/*
@@ -85,23 +81,36 @@ MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
85 * these two devices. 81 * these two devices.
86 */ 82 */
87 83
84/* The driver supports the original DM9000E, and now the two newer
85 * devices, DM9000A and DM9000B.
86 */
87
88enum dm9000_type {
89 TYPE_DM9000E, /* original DM9000 */
90 TYPE_DM9000A,
91 TYPE_DM9000B
92};
93
88/* Structure/enum declaration ------------------------------- */ 94/* Structure/enum declaration ------------------------------- */
89typedef struct board_info { 95typedef struct board_info {
90 96
91 void __iomem *io_addr; /* Register I/O base address */ 97 void __iomem *io_addr; /* Register I/O base address */
92 void __iomem *io_data; /* Data I/O address */ 98 void __iomem *io_data; /* Data I/O address */
93 u16 irq; /* IRQ */ 99 u16 irq; /* IRQ */
94 100
95 u16 tx_pkt_cnt; 101 u16 tx_pkt_cnt;
96 u16 queue_pkt_len; 102 u16 queue_pkt_len;
97 u16 queue_start_addr; 103 u16 queue_start_addr;
98 u16 dbug_cnt; 104 u16 dbug_cnt;
99 u8 io_mode; /* 0:word, 2:byte */ 105 u8 io_mode; /* 0:word, 2:byte */
100 u8 phy_addr; 106 u8 phy_addr;
101 unsigned int flags; 107 u8 imr_all;
102 unsigned int in_suspend :1;
103 108
104 int debug_level; 109 unsigned int flags;
110 unsigned int in_suspend :1;
111 int debug_level;
112
113 enum dm9000_type type;
105 114
106 void (*inblk)(void __iomem *port, void *data, int length); 115 void (*inblk)(void __iomem *port, void *data, int length);
107 void (*outblk)(void __iomem *port, void *data, int length); 116 void (*outblk)(void __iomem *port, void *data, int length);
@@ -120,10 +129,10 @@ typedef struct board_info {
120 struct delayed_work phy_poll; 129 struct delayed_work phy_poll;
121 struct net_device *ndev; 130 struct net_device *ndev;
122 131
123 spinlock_t lock; 132 spinlock_t lock;
124 133
125 struct mii_if_info mii; 134 struct mii_if_info mii;
126 u32 msg_enable; 135 u32 msg_enable;
127} board_info_t; 136} board_info_t;
128 137
129/* debug code */ 138/* debug code */
@@ -140,26 +149,6 @@ static inline board_info_t *to_dm9000_board(struct net_device *dev)
140 return dev->priv; 149 return dev->priv;
141} 150}
142 151
143/* function declaration ------------------------------------- */
144static int dm9000_probe(struct platform_device *);
145static int dm9000_open(struct net_device *);
146static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
147static int dm9000_stop(struct net_device *);
148static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
149
150static void dm9000_init_dm9000(struct net_device *);
151
152static irqreturn_t dm9000_interrupt(int, void *);
153
154static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int reg);
155static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg,
156 int value);
157
158static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
159static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
160static void dm9000_rx(struct net_device *);
161static void dm9000_hash_table(struct net_device *);
162
163/* DM9000 network board routine ---------------------------- */ 152/* DM9000 network board routine ---------------------------- */
164 153
165static void 154static void
@@ -302,52 +291,135 @@ static void dm9000_set_io(struct board_info *db, int byte_width)
302 291
303static void dm9000_schedule_poll(board_info_t *db) 292static void dm9000_schedule_poll(board_info_t *db)
304{ 293{
305 schedule_delayed_work(&db->phy_poll, HZ * 2); 294 if (db->type == TYPE_DM9000E)
295 schedule_delayed_work(&db->phy_poll, HZ * 2);
306} 296}
307 297
308/* Our watchdog timed out. Called by the networking layer */ 298static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
309static void dm9000_timeout(struct net_device *dev) 299{
300 board_info_t *dm = to_dm9000_board(dev);
301
302 if (!netif_running(dev))
303 return -EINVAL;
304
305 return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL);
306}
307
308static unsigned int
309dm9000_read_locked(board_info_t *db, int reg)
310{ 310{
311 board_info_t *db = (board_info_t *) dev->priv;
312 u8 reg_save;
313 unsigned long flags; 311 unsigned long flags;
312 unsigned int ret;
314 313
315 /* Save previous register address */ 314 spin_lock_irqsave(&db->lock, flags);
316 reg_save = readb(db->io_addr); 315 ret = ior(db, reg);
317 spin_lock_irqsave(&db->lock,flags); 316 spin_unlock_irqrestore(&db->lock, flags);
318 317
319 netif_stop_queue(dev); 318 return ret;
320 dm9000_reset(db); 319}
321 dm9000_init_dm9000(dev);
322 /* We can accept TX packets again */
323 dev->trans_start = jiffies;
324 netif_wake_queue(dev);
325 320
326 /* Restore previous register address */ 321static int dm9000_wait_eeprom(board_info_t *db)
327 writeb(reg_save, db->io_addr); 322{
328 spin_unlock_irqrestore(&db->lock,flags); 323 unsigned int status;
324 int timeout = 8; /* wait max 8msec */
325
326 /* The DM9000 data sheets say we should be able to
327 * poll the ERRE bit in EPCR to wait for the EEPROM
328 * operation. From testing several chips, this bit
329 * does not seem to work.
330 *
331 * We attempt to use the bit, but fall back to the
332 * timeout (which is why we do not return an error
333 * on expiry) to say that the EEPROM operation has
334 * completed.
335 */
336
337 while (1) {
338 status = dm9000_read_locked(db, DM9000_EPCR);
339
340 if ((status & EPCR_ERRE) == 0)
341 break;
342
343 msleep(1);
344
345 if (timeout-- < 0) {
346 dev_dbg(db->dev, "timeout waiting EEPROM\n");
347 break;
348 }
349 }
350
351 return 0;
329} 352}
330 353
331#ifdef CONFIG_NET_POLL_CONTROLLER
332/* 354/*
333 *Used by netconsole 355 * Read a word data from EEPROM
334 */ 356 */
335static void dm9000_poll_controller(struct net_device *dev) 357static void
358dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
336{ 359{
337 disable_irq(dev->irq); 360 unsigned long flags;
338 dm9000_interrupt(dev->irq,dev); 361
339 enable_irq(dev->irq); 362 if (db->flags & DM9000_PLATF_NO_EEPROM) {
363 to[0] = 0xff;
364 to[1] = 0xff;
365 return;
366 }
367
368 mutex_lock(&db->addr_lock);
369
370 spin_lock_irqsave(&db->lock, flags);
371
372 iow(db, DM9000_EPAR, offset);
373 iow(db, DM9000_EPCR, EPCR_ERPRR);
374
375 spin_unlock_irqrestore(&db->lock, flags);
376
377 dm9000_wait_eeprom(db);
378
379 /* delay for at-least 150uS */
380 msleep(1);
381
382 spin_lock_irqsave(&db->lock, flags);
383
384 iow(db, DM9000_EPCR, 0x0);
385
386 to[0] = ior(db, DM9000_EPDRL);
387 to[1] = ior(db, DM9000_EPDRH);
388
389 spin_unlock_irqrestore(&db->lock, flags);
390
391 mutex_unlock(&db->addr_lock);
340} 392}
341#endif
342 393
343static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 394/*
395 * Write a word data to SROM
396 */
397static void
398dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
344{ 399{
345 board_info_t *dm = to_dm9000_board(dev); 400 unsigned long flags;
346 401
347 if (!netif_running(dev)) 402 if (db->flags & DM9000_PLATF_NO_EEPROM)
348 return -EINVAL; 403 return;
349 404
350 return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL); 405 mutex_lock(&db->addr_lock);
406
407 spin_lock_irqsave(&db->lock, flags);
408 iow(db, DM9000_EPAR, offset);
409 iow(db, DM9000_EPDRH, data[1]);
410 iow(db, DM9000_EPDRL, data[0]);
411 iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
412 spin_unlock_irqrestore(&db->lock, flags);
413
414 dm9000_wait_eeprom(db);
415
416 mdelay(1); /* wait at least 150uS to clear */
417
418 spin_lock_irqsave(&db->lock, flags);
419 iow(db, DM9000_EPCR, 0);
420 spin_unlock_irqrestore(&db->lock, flags);
421
422 mutex_unlock(&db->addr_lock);
351} 423}
352 424
353/* ethtool ops */ 425/* ethtool ops */
@@ -400,7 +472,14 @@ static int dm9000_nway_reset(struct net_device *dev)
400static u32 dm9000_get_link(struct net_device *dev) 472static u32 dm9000_get_link(struct net_device *dev)
401{ 473{
402 board_info_t *dm = to_dm9000_board(dev); 474 board_info_t *dm = to_dm9000_board(dev);
403 return mii_link_ok(&dm->mii); 475 u32 ret;
476
477 if (dm->flags & DM9000_PLATF_EXT_PHY)
478 ret = mii_link_ok(&dm->mii);
479 else
480 ret = dm9000_read_locked(dm, DM9000_NSR) & NSR_LINKST ? 1 : 0;
481
482 return ret;
404} 483}
405 484
406#define DM_EEPROM_MAGIC (0x444D394B) 485#define DM_EEPROM_MAGIC (0x444D394B)
@@ -472,15 +551,48 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
472 .set_eeprom = dm9000_set_eeprom, 551 .set_eeprom = dm9000_set_eeprom,
473}; 552};
474 553
554static void dm9000_show_carrier(board_info_t *db,
555 unsigned carrier, unsigned nsr)
556{
557 struct net_device *ndev = db->ndev;
558 unsigned ncr = dm9000_read_locked(db, DM9000_NCR);
559
560 if (carrier)
561 dev_info(db->dev, "%s: link up, %dMbps, %s-duplex, no LPA\n",
562 ndev->name, (nsr & NSR_SPEED) ? 10 : 100,
563 (ncr & NCR_FDX) ? "full" : "half");
564 else
565 dev_info(db->dev, "%s: link down\n", ndev->name);
566}
567
475static void 568static void
476dm9000_poll_work(struct work_struct *w) 569dm9000_poll_work(struct work_struct *w)
477{ 570{
478 struct delayed_work *dw = container_of(w, struct delayed_work, work); 571 struct delayed_work *dw = container_of(w, struct delayed_work, work);
479 board_info_t *db = container_of(dw, board_info_t, phy_poll); 572 board_info_t *db = container_of(dw, board_info_t, phy_poll);
573 struct net_device *ndev = db->ndev;
574
575 if (db->flags & DM9000_PLATF_SIMPLE_PHY &&
576 !(db->flags & DM9000_PLATF_EXT_PHY)) {
577 unsigned nsr = dm9000_read_locked(db, DM9000_NSR);
578 unsigned old_carrier = netif_carrier_ok(ndev) ? 1 : 0;
579 unsigned new_carrier;
480 580
481 mii_check_media(&db->mii, netif_msg_link(db), 0); 581 new_carrier = (nsr & NSR_LINKST) ? 1 : 0;
582
583 if (old_carrier != new_carrier) {
584 if (netif_msg_link(db))
585 dm9000_show_carrier(db, new_carrier, nsr);
586
587 if (!new_carrier)
588 netif_carrier_off(ndev);
589 else
590 netif_carrier_on(ndev);
591 }
592 } else
593 mii_check_media(&db->mii, netif_msg_link(db), 0);
482 594
483 if (netif_running(db->ndev)) 595 if (netif_running(ndev))
484 dm9000_schedule_poll(db); 596 dm9000_schedule_poll(db);
485} 597}
486 598
@@ -492,12 +604,6 @@ dm9000_poll_work(struct work_struct *w)
492static void 604static void
493dm9000_release_board(struct platform_device *pdev, struct board_info *db) 605dm9000_release_board(struct platform_device *pdev, struct board_info *db)
494{ 606{
495 if (db->data_res == NULL) {
496 if (db->addr_res != NULL)
497 release_mem_region((unsigned long)db->io_addr, 4);
498 return;
499 }
500
501 /* unmap our resources */ 607 /* unmap our resources */
502 608
503 iounmap(db->io_addr); 609 iounmap(db->io_addr);
@@ -505,288 +611,73 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db)
505 611
506 /* release the resources */ 612 /* release the resources */
507 613
508 if (db->data_req != NULL) { 614 release_resource(db->data_req);
509 release_resource(db->data_req); 615 kfree(db->data_req);
510 kfree(db->data_req);
511 }
512 616
513 if (db->addr_req != NULL) { 617 release_resource(db->addr_req);
514 release_resource(db->addr_req); 618 kfree(db->addr_req);
515 kfree(db->addr_req);
516 }
517} 619}
518 620
519#define res_size(_r) (((_r)->end - (_r)->start) + 1) 621static unsigned char dm9000_type_to_char(enum dm9000_type type)
520
521/*
522 * Search DM9000 board, allocate space and register it
523 */
524static int __devinit
525dm9000_probe(struct platform_device *pdev)
526{ 622{
527 struct dm9000_plat_data *pdata = pdev->dev.platform_data; 623 switch (type) {
528 struct board_info *db; /* Point a board information structure */ 624 case TYPE_DM9000E: return 'e';
529 struct net_device *ndev; 625 case TYPE_DM9000A: return 'a';
530 const unsigned char *mac_src; 626 case TYPE_DM9000B: return 'b';
531 unsigned long base;
532 int ret = 0;
533 int iosize;
534 int i;
535 u32 id_val;
536
537 /* Init network device */
538 ndev = alloc_etherdev(sizeof (struct board_info));
539 if (!ndev) {
540 dev_err(&pdev->dev, "could not allocate device.\n");
541 return -ENOMEM;
542 }
543
544 SET_NETDEV_DEV(ndev, &pdev->dev);
545
546 dev_dbg(&pdev->dev, "dm9000_probe()\n");
547
548 /* setup board info structure */
549 db = (struct board_info *) ndev->priv;
550 memset(db, 0, sizeof (*db));
551
552 db->dev = &pdev->dev;
553 db->ndev = ndev;
554
555 spin_lock_init(&db->lock);
556 mutex_init(&db->addr_lock);
557
558 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
559
560
561 if (pdev->num_resources < 2) {
562 ret = -ENODEV;
563 goto out;
564 } else if (pdev->num_resources == 2) {
565 base = pdev->resource[0].start;
566
567 if (!request_mem_region(base, 4, ndev->name)) {
568 ret = -EBUSY;
569 goto out;
570 }
571
572 ndev->base_addr = base;
573 ndev->irq = pdev->resource[1].start;
574 db->io_addr = (void __iomem *)base;
575 db->io_data = (void __iomem *)(base + 4);
576
577 /* ensure at least we have a default set of IO routines */
578 dm9000_set_io(db, 2);
579
580 } else {
581 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
582 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
583 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
584
585 if (db->addr_res == NULL || db->data_res == NULL ||
586 db->irq_res == NULL) {
587 dev_err(db->dev, "insufficient resources\n");
588 ret = -ENOENT;
589 goto out;
590 }
591
592 i = res_size(db->addr_res);
593 db->addr_req = request_mem_region(db->addr_res->start, i,
594 pdev->name);
595
596 if (db->addr_req == NULL) {
597 dev_err(db->dev, "cannot claim address reg area\n");
598 ret = -EIO;
599 goto out;
600 }
601
602 db->io_addr = ioremap(db->addr_res->start, i);
603
604 if (db->io_addr == NULL) {
605 dev_err(db->dev, "failed to ioremap address reg\n");
606 ret = -EINVAL;
607 goto out;
608 }
609
610 iosize = res_size(db->data_res);
611 db->data_req = request_mem_region(db->data_res->start, iosize,
612 pdev->name);
613
614 if (db->data_req == NULL) {
615 dev_err(db->dev, "cannot claim data reg area\n");
616 ret = -EIO;
617 goto out;
618 }
619
620 db->io_data = ioremap(db->data_res->start, iosize);
621
622 if (db->io_data == NULL) {
623 dev_err(db->dev,"failed to ioremap data reg\n");
624 ret = -EINVAL;
625 goto out;
626 }
627
628 /* fill in parameters for net-dev structure */
629
630 ndev->base_addr = (unsigned long)db->io_addr;
631 ndev->irq = db->irq_res->start;
632
633 /* ensure at least we have a default set of IO routines */
634 dm9000_set_io(db, iosize);
635 } 627 }
636 628
637 /* check to see if anything is being over-ridden */ 629 return '?';
638 if (pdata != NULL) {
639 /* check to see if the driver wants to over-ride the
640 * default IO width */
641
642 if (pdata->flags & DM9000_PLATF_8BITONLY)
643 dm9000_set_io(db, 1);
644
645 if (pdata->flags & DM9000_PLATF_16BITONLY)
646 dm9000_set_io(db, 2);
647
648 if (pdata->flags & DM9000_PLATF_32BITONLY)
649 dm9000_set_io(db, 4);
650
651 /* check to see if there are any IO routine
652 * over-rides */
653
654 if (pdata->inblk != NULL)
655 db->inblk = pdata->inblk;
656
657 if (pdata->outblk != NULL)
658 db->outblk = pdata->outblk;
659
660 if (pdata->dumpblk != NULL)
661 db->dumpblk = pdata->dumpblk;
662
663 db->flags = pdata->flags;
664 }
665
666 dm9000_reset(db);
667
668 /* try two times, DM9000 sometimes gets the first read wrong */
669 for (i = 0; i < 8; i++) {
670 id_val = ior(db, DM9000_VIDL);
671 id_val |= (u32)ior(db, DM9000_VIDH) << 8;
672 id_val |= (u32)ior(db, DM9000_PIDL) << 16;
673 id_val |= (u32)ior(db, DM9000_PIDH) << 24;
674
675 if (id_val == DM9000_ID)
676 break;
677 dev_err(db->dev, "read wrong id 0x%08x\n", id_val);
678 }
679
680 if (id_val != DM9000_ID) {
681 dev_err(db->dev, "wrong id: 0x%08x\n", id_val);
682 ret = -ENODEV;
683 goto out;
684 }
685
686 /* from this point we assume that we have found a DM9000 */
687
688 /* driver system function */
689 ether_setup(ndev);
690
691 ndev->open = &dm9000_open;
692 ndev->hard_start_xmit = &dm9000_start_xmit;
693 ndev->tx_timeout = &dm9000_timeout;
694 ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
695 ndev->stop = &dm9000_stop;
696 ndev->set_multicast_list = &dm9000_hash_table;
697 ndev->ethtool_ops = &dm9000_ethtool_ops;
698 ndev->do_ioctl = &dm9000_ioctl;
699
700#ifdef CONFIG_NET_POLL_CONTROLLER
701 ndev->poll_controller = &dm9000_poll_controller;
702#endif
703
704 db->msg_enable = NETIF_MSG_LINK;
705 db->mii.phy_id_mask = 0x1f;
706 db->mii.reg_num_mask = 0x1f;
707 db->mii.force_media = 0;
708 db->mii.full_duplex = 0;
709 db->mii.dev = ndev;
710 db->mii.mdio_read = dm9000_phy_read;
711 db->mii.mdio_write = dm9000_phy_write;
712
713 mac_src = "eeprom";
714
715 /* try reading the node address from the attached EEPROM */
716 for (i = 0; i < 6; i += 2)
717 dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
718
719 if (!is_valid_ether_addr(ndev->dev_addr)) {
720 /* try reading from mac */
721
722 mac_src = "chip";
723 for (i = 0; i < 6; i++)
724 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
725 }
726
727 if (!is_valid_ether_addr(ndev->dev_addr))
728 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
729 "set using ifconfig\n", ndev->name);
730
731 platform_set_drvdata(pdev, ndev);
732 ret = register_netdev(ndev);
733
734 if (ret == 0) {
735 DECLARE_MAC_BUF(mac);
736 printk("%s: dm9000 at %p,%p IRQ %d MAC: %s (%s)\n",
737 ndev->name, db->io_addr, db->io_data, ndev->irq,
738 print_mac(mac, ndev->dev_addr), mac_src);
739 }
740 return 0;
741
742out:
743 dev_err(db->dev, "not found (%d).\n", ret);
744
745 dm9000_release_board(pdev, db);
746 free_netdev(ndev);
747
748 return ret;
749} 630}
750 631
751/* 632/*
752 * Open the interface. 633 * Set DM9000 multicast address
753 * The interface is opened whenever "ifconfig" actives it.
754 */ 634 */
755static int 635static void
756dm9000_open(struct net_device *dev) 636dm9000_hash_table(struct net_device *dev)
757{ 637{
758 board_info_t *db = (board_info_t *) dev->priv; 638 board_info_t *db = (board_info_t *) dev->priv;
759 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK; 639 struct dev_mc_list *mcptr = dev->mc_list;
640 int mc_cnt = dev->mc_count;
641 int i, oft;
642 u32 hash_val;
643 u16 hash_table[4];
644 u8 rcr = RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN;
645 unsigned long flags;
760 646
761 if (netif_msg_ifup(db)) 647 dm9000_dbg(db, 1, "entering %s\n", __func__);
762 dev_dbg(db->dev, "enabling %s\n", dev->name);
763 648
764 /* If there is no IRQ type specified, default to something that 649 spin_lock_irqsave(&db->lock, flags);
765 * may work, and tell the user that this is a problem */
766 650
767 if (irqflags == IRQF_TRIGGER_NONE) { 651 for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
768 dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n"); 652 iow(db, oft, dev->dev_addr[i]);
769 irqflags = DEFAULT_TRIGGER;
770 }
771 653
772 irqflags |= IRQF_SHARED; 654 /* Clear Hash Table */
655 for (i = 0; i < 4; i++)
656 hash_table[i] = 0x0;
773 657
774 if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev)) 658 /* broadcast address */
775 return -EAGAIN; 659 hash_table[3] = 0x8000;
776 660
777 /* Initialize DM9000 board */ 661 if (dev->flags & IFF_PROMISC)
778 dm9000_reset(db); 662 rcr |= RCR_PRMSC;
779 dm9000_init_dm9000(dev);
780 663
781 /* Init driver variable */ 664 if (dev->flags & IFF_ALLMULTI)
782 db->dbug_cnt = 0; 665 rcr |= RCR_ALL;
783 666
784 mii_check_media(&db->mii, netif_msg_link(db), 1); 667 /* the multicast address in Hash Table : 64 bits */
785 netif_start_queue(dev); 668 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
786 669 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
787 dm9000_schedule_poll(db); 670 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
671 }
788 672
789 return 0; 673 /* Write the hash table to MAC MD table */
674 for (i = 0, oft = DM9000_MAR; i < 4; i++) {
675 iow(db, oft++, hash_table[i]);
676 iow(db, oft++, hash_table[i] >> 8);
677 }
678
679 iow(db, DM9000_RCR, rcr);
680 spin_unlock_irqrestore(&db->lock, flags);
790} 681}
791 682
792/* 683/*
@@ -795,7 +686,8 @@ dm9000_open(struct net_device *dev)
795static void 686static void
796dm9000_init_dm9000(struct net_device *dev) 687dm9000_init_dm9000(struct net_device *dev)
797{ 688{
798 board_info_t *db = (board_info_t *) dev->priv; 689 board_info_t *db = dev->priv;
690 unsigned int imr;
799 691
800 dm9000_dbg(db, 1, "entering %s\n", __func__); 692 dm9000_dbg(db, 1, "entering %s\n", __func__);
801 693
@@ -822,8 +714,14 @@ dm9000_init_dm9000(struct net_device *dev)
822 /* Set address filter table */ 714 /* Set address filter table */
823 dm9000_hash_table(dev); 715 dm9000_hash_table(dev);
824 716
717 imr = IMR_PAR | IMR_PTM | IMR_PRM;
718 if (db->type != TYPE_DM9000E)
719 imr |= IMR_LNKCHNG;
720
721 db->imr_all = imr;
722
825 /* Enable TX/RX interrupt mask */ 723 /* Enable TX/RX interrupt mask */
826 iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM); 724 iow(db, DM9000_IMR, imr);
827 725
828 /* Init Driver variable */ 726 /* Init Driver variable */
829 db->tx_pkt_cnt = 0; 727 db->tx_pkt_cnt = 0;
@@ -831,6 +729,29 @@ dm9000_init_dm9000(struct net_device *dev)
831 dev->trans_start = 0; 729 dev->trans_start = 0;
832} 730}
833 731
732/* Our watchdog timed out. Called by the networking layer */
733static void dm9000_timeout(struct net_device *dev)
734{
735 board_info_t *db = (board_info_t *) dev->priv;
736 u8 reg_save;
737 unsigned long flags;
738
739 /* Save previous register address */
740 reg_save = readb(db->io_addr);
741 spin_lock_irqsave(&db->lock, flags);
742
743 netif_stop_queue(dev);
744 dm9000_reset(db);
745 dm9000_init_dm9000(dev);
746 /* We can accept TX packets again */
747 dev->trans_start = jiffies;
748 netif_wake_queue(dev);
749
750 /* Restore previous register address */
751 writeb(reg_save, db->io_addr);
752 spin_unlock_irqrestore(&db->lock, flags);
753}
754
834/* 755/*
835 * Hardware start transmission. 756 * Hardware start transmission.
836 * Send a packet to media from the upper layer. 757 * Send a packet to media from the upper layer.
@@ -839,7 +760,7 @@ static int
839dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) 760dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
840{ 761{
841 unsigned long flags; 762 unsigned long flags;
842 board_info_t *db = (board_info_t *) dev->priv; 763 board_info_t *db = dev->priv;
843 764
844 dm9000_dbg(db, 3, "%s:\n", __func__); 765 dm9000_dbg(db, 3, "%s:\n", __func__);
845 766
@@ -879,50 +800,12 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
879 return 0; 800 return 0;
880} 801}
881 802
882static void
883dm9000_shutdown(struct net_device *dev)
884{
885 board_info_t *db = (board_info_t *) dev->priv;
886
887 /* RESET device */
888 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
889 iow(db, DM9000_GPR, 0x01); /* Power-Down PHY */
890 iow(db, DM9000_IMR, IMR_PAR); /* Disable all interrupt */
891 iow(db, DM9000_RCR, 0x00); /* Disable RX */
892}
893
894/*
895 * Stop the interface.
896 * The interface is stopped when it is brought.
897 */
898static int
899dm9000_stop(struct net_device *ndev)
900{
901 board_info_t *db = (board_info_t *) ndev->priv;
902
903 if (netif_msg_ifdown(db))
904 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
905
906 cancel_delayed_work_sync(&db->phy_poll);
907
908 netif_stop_queue(ndev);
909 netif_carrier_off(ndev);
910
911 /* free interrupt */
912 free_irq(ndev->irq, ndev);
913
914 dm9000_shutdown(ndev);
915
916 return 0;
917}
918
919/* 803/*
920 * DM9000 interrupt handler 804 * DM9000 interrupt handler
921 * receive the packet to upper layer, free the transmitted packet 805 * receive the packet to upper layer, free the transmitted packet
922 */ 806 */
923 807
924static void 808static void dm9000_tx_done(struct net_device *dev, board_info_t *db)
925dm9000_tx_done(struct net_device *dev, board_info_t * db)
926{ 809{
927 int tx_status = ior(db, DM9000_NSR); /* Got TX status */ 810 int tx_status = ior(db, DM9000_NSR); /* Got TX status */
928 811
@@ -945,52 +828,6 @@ dm9000_tx_done(struct net_device *dev, board_info_t * db)
945 } 828 }
946} 829}
947 830
948static irqreturn_t
949dm9000_interrupt(int irq, void *dev_id)
950{
951 struct net_device *dev = dev_id;
952 board_info_t *db = (board_info_t *) dev->priv;
953 int int_status;
954 u8 reg_save;
955
956 dm9000_dbg(db, 3, "entering %s\n", __func__);
957
958 /* A real interrupt coming */
959
960 spin_lock(&db->lock);
961
962 /* Save previous register address */
963 reg_save = readb(db->io_addr);
964
965 /* Disable all interrupts */
966 iow(db, DM9000_IMR, IMR_PAR);
967
968 /* Got DM9000 interrupt status */
969 int_status = ior(db, DM9000_ISR); /* Got ISR */
970 iow(db, DM9000_ISR, int_status); /* Clear ISR status */
971
972 if (netif_msg_intr(db))
973 dev_dbg(db->dev, "interrupt status %02x\n", int_status);
974
975 /* Received the coming packet */
976 if (int_status & ISR_PRS)
977 dm9000_rx(dev);
978
979 /* Trnasmit Interrupt check */
980 if (int_status & ISR_PTS)
981 dm9000_tx_done(dev, db);
982
983 /* Re-enable interrupt mask */
984 iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
985
986 /* Restore previous register address */
987 writeb(reg_save, db->io_addr);
988
989 spin_unlock(&db->lock);
990
991 return IRQ_HANDLED;
992}
993
994struct dm9000_rxhdr { 831struct dm9000_rxhdr {
995 u8 RxPktReady; 832 u8 RxPktReady;
996 u8 RxStatus; 833 u8 RxStatus;
@@ -1094,173 +931,109 @@ dm9000_rx(struct net_device *dev)
1094 } while (rxbyte == DM9000_PKT_RDY); 931 } while (rxbyte == DM9000_PKT_RDY);
1095} 932}
1096 933
1097static unsigned int 934static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
1098dm9000_read_locked(board_info_t *db, int reg)
1099{ 935{
1100 unsigned long flags; 936 struct net_device *dev = dev_id;
1101 unsigned int ret; 937 board_info_t *db = dev->priv;
938 int int_status;
939 u8 reg_save;
1102 940
1103 spin_lock_irqsave(&db->lock, flags); 941 dm9000_dbg(db, 3, "entering %s\n", __func__);
1104 ret = ior(db, reg);
1105 spin_unlock_irqrestore(&db->lock, flags);
1106 942
1107 return ret; 943 /* A real interrupt coming */
1108}
1109 944
1110static int dm9000_wait_eeprom(board_info_t *db) 945 spin_lock(&db->lock);
1111{
1112 unsigned int status;
1113 int timeout = 8; /* wait max 8msec */
1114 946
1115 /* The DM9000 data sheets say we should be able to 947 /* Save previous register address */
1116 * poll the ERRE bit in EPCR to wait for the EEPROM 948 reg_save = readb(db->io_addr);
1117 * operation. From testing several chips, this bit
1118 * does not seem to work.
1119 *
1120 * We attempt to use the bit, but fall back to the
1121 * timeout (which is why we do not return an error
1122 * on expiry) to say that the EEPROM operation has
1123 * completed.
1124 */
1125 949
1126 while (1) { 950 /* Disable all interrupts */
1127 status = dm9000_read_locked(db, DM9000_EPCR); 951 iow(db, DM9000_IMR, IMR_PAR);
1128 952
1129 if ((status & EPCR_ERRE) == 0) 953 /* Got DM9000 interrupt status */
1130 break; 954 int_status = ior(db, DM9000_ISR); /* Got ISR */
955 iow(db, DM9000_ISR, int_status); /* Clear ISR status */
1131 956
1132 if (timeout-- < 0) { 957 if (netif_msg_intr(db))
1133 dev_dbg(db->dev, "timeout waiting EEPROM\n"); 958 dev_dbg(db->dev, "interrupt status %02x\n", int_status);
1134 break;
1135 }
1136 }
1137 959
1138 return 0; 960 /* Received the coming packet */
1139} 961 if (int_status & ISR_PRS)
962 dm9000_rx(dev);
1140 963
1141/* 964 /* Trnasmit Interrupt check */
1142 * Read a word data from EEPROM 965 if (int_status & ISR_PTS)
1143 */ 966 dm9000_tx_done(dev, db);
1144static void
1145dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
1146{
1147 unsigned long flags;
1148 967
1149 if (db->flags & DM9000_PLATF_NO_EEPROM) { 968 if (db->type != TYPE_DM9000E) {
1150 to[0] = 0xff; 969 if (int_status & ISR_LNKCHNG) {
1151 to[1] = 0xff; 970 /* fire a link-change request */
1152 return; 971 schedule_delayed_work(&db->phy_poll, 1);
972 }
1153 } 973 }
1154 974
1155 mutex_lock(&db->addr_lock); 975 /* Re-enable interrupt mask */
1156 976 iow(db, DM9000_IMR, db->imr_all);
1157 spin_lock_irqsave(&db->lock, flags);
1158
1159 iow(db, DM9000_EPAR, offset);
1160 iow(db, DM9000_EPCR, EPCR_ERPRR);
1161
1162 spin_unlock_irqrestore(&db->lock, flags);
1163
1164 dm9000_wait_eeprom(db);
1165
1166 /* delay for at-least 150uS */
1167 msleep(1);
1168
1169 spin_lock_irqsave(&db->lock, flags);
1170
1171 iow(db, DM9000_EPCR, 0x0);
1172 977
1173 to[0] = ior(db, DM9000_EPDRL); 978 /* Restore previous register address */
1174 to[1] = ior(db, DM9000_EPDRH); 979 writeb(reg_save, db->io_addr);
1175 980
1176 spin_unlock_irqrestore(&db->lock, flags); 981 spin_unlock(&db->lock);
1177 982
1178 mutex_unlock(&db->addr_lock); 983 return IRQ_HANDLED;
1179} 984}
1180 985
986#ifdef CONFIG_NET_POLL_CONTROLLER
1181/* 987/*
1182 * Write a word data to SROM 988 *Used by netconsole
1183 */ 989 */
1184static void 990static void dm9000_poll_controller(struct net_device *dev)
1185dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
1186{ 991{
1187 unsigned long flags; 992 disable_irq(dev->irq);
1188 993 dm9000_interrupt(dev->irq, dev);
1189 if (db->flags & DM9000_PLATF_NO_EEPROM) 994 enable_irq(dev->irq);
1190 return;
1191
1192 mutex_lock(&db->addr_lock);
1193
1194 spin_lock_irqsave(&db->lock, flags);
1195 iow(db, DM9000_EPAR, offset);
1196 iow(db, DM9000_EPDRH, data[1]);
1197 iow(db, DM9000_EPDRL, data[0]);
1198 iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
1199 spin_unlock_irqrestore(&db->lock, flags);
1200
1201 dm9000_wait_eeprom(db);
1202
1203 mdelay(1); /* wait at least 150uS to clear */
1204
1205 spin_lock_irqsave(&db->lock, flags);
1206 iow(db, DM9000_EPCR, 0);
1207 spin_unlock_irqrestore(&db->lock, flags);
1208
1209 mutex_unlock(&db->addr_lock);
1210} 995}
996#endif
1211 997
1212/* 998/*
1213 * Set DM9000 multicast address 999 * Open the interface.
1000 * The interface is opened whenever "ifconfig" actives it.
1214 */ 1001 */
1215static void 1002static int
1216dm9000_hash_table(struct net_device *dev) 1003dm9000_open(struct net_device *dev)
1217{ 1004{
1218 board_info_t *db = (board_info_t *) dev->priv; 1005 board_info_t *db = dev->priv;
1219 struct dev_mc_list *mcptr = dev->mc_list; 1006 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
1220 int mc_cnt = dev->mc_count;
1221 int i, oft;
1222 u32 hash_val;
1223 u16 hash_table[4];
1224 u8 rcr = RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN;
1225 unsigned long flags;
1226
1227 dm9000_dbg(db, 1, "entering %s\n", __func__);
1228 1007
1229 spin_lock_irqsave(&db->lock, flags); 1008 if (netif_msg_ifup(db))
1009 dev_dbg(db->dev, "enabling %s\n", dev->name);
1230 1010
1231 for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++) 1011 /* If there is no IRQ type specified, default to something that
1232 iow(db, oft, dev->dev_addr[i]); 1012 * may work, and tell the user that this is a problem */
1233 1013
1234 /* Clear Hash Table */ 1014 if (irqflags == IRQF_TRIGGER_NONE)
1235 for (i = 0; i < 4; i++) 1015 dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
1236 hash_table[i] = 0x0;
1237 1016
1238 /* broadcast address */ 1017 irqflags |= IRQF_SHARED;
1239 hash_table[3] = 0x8000;
1240 1018
1241 if (dev->flags & IFF_PROMISC) 1019 if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
1242 rcr |= RCR_PRMSC; 1020 return -EAGAIN;
1243 1021
1244 if (dev->flags & IFF_ALLMULTI) 1022 /* Initialize DM9000 board */
1245 rcr |= RCR_ALL; 1023 dm9000_reset(db);
1024 dm9000_init_dm9000(dev);
1246 1025
1247 /* the multicast address in Hash Table : 64 bits */ 1026 /* Init driver variable */
1248 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1027 db->dbug_cnt = 0;
1249 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
1250 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
1251 }
1252 1028
1253 /* Write the hash table to MAC MD table */ 1029 mii_check_media(&db->mii, netif_msg_link(db), 1);
1254 for (i = 0, oft = DM9000_MAR; i < 4; i++) { 1030 netif_start_queue(dev);
1255 iow(db, oft++, hash_table[i]); 1031
1256 iow(db, oft++, hash_table[i] >> 8); 1032 dm9000_schedule_poll(db);
1257 }
1258 1033
1259 iow(db, DM9000_RCR, rcr); 1034 return 0;
1260 spin_unlock_irqrestore(&db->lock, flags);
1261} 1035}
1262 1036
1263
1264/* 1037/*
1265 * Sleep, either by using msleep() or if we are suspending, then 1038 * Sleep, either by using msleep() or if we are suspending, then
1266 * use mdelay() to sleep. 1039 * use mdelay() to sleep.
@@ -1323,7 +1096,8 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1323 * Write a word to phyxcer 1096 * Write a word to phyxcer
1324 */ 1097 */
1325static void 1098static void
1326dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) 1099dm9000_phy_write(struct net_device *dev,
1100 int phyaddr_unused, int reg, int value)
1327{ 1101{
1328 board_info_t *db = (board_info_t *) dev->priv; 1102 board_info_t *db = (board_info_t *) dev->priv;
1329 unsigned long flags; 1103 unsigned long flags;
@@ -1363,6 +1137,273 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1363 mutex_unlock(&db->addr_lock); 1137 mutex_unlock(&db->addr_lock);
1364} 1138}
1365 1139
1140static void
1141dm9000_shutdown(struct net_device *dev)
1142{
1143 board_info_t *db = dev->priv;
1144
1145 /* RESET device */
1146 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
1147 iow(db, DM9000_GPR, 0x01); /* Power-Down PHY */
1148 iow(db, DM9000_IMR, IMR_PAR); /* Disable all interrupt */
1149 iow(db, DM9000_RCR, 0x00); /* Disable RX */
1150}
1151
1152/*
1153 * Stop the interface.
1154 * The interface is stopped when it is brought.
1155 */
1156static int
1157dm9000_stop(struct net_device *ndev)
1158{
1159 board_info_t *db = ndev->priv;
1160
1161 if (netif_msg_ifdown(db))
1162 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
1163
1164 cancel_delayed_work_sync(&db->phy_poll);
1165
1166 netif_stop_queue(ndev);
1167 netif_carrier_off(ndev);
1168
1169 /* free interrupt */
1170 free_irq(ndev->irq, ndev);
1171
1172 dm9000_shutdown(ndev);
1173
1174 return 0;
1175}
1176
1177#define res_size(_r) (((_r)->end - (_r)->start) + 1)
1178
1179/*
1180 * Search DM9000 board, allocate space and register it
1181 */
1182static int __devinit
1183dm9000_probe(struct platform_device *pdev)
1184{
1185 struct dm9000_plat_data *pdata = pdev->dev.platform_data;
1186 struct board_info *db; /* Point a board information structure */
1187 struct net_device *ndev;
1188 const unsigned char *mac_src;
1189 int ret = 0;
1190 int iosize;
1191 int i;
1192 u32 id_val;
1193
1194 /* Init network device */
1195 ndev = alloc_etherdev(sizeof(struct board_info));
1196 if (!ndev) {
1197 dev_err(&pdev->dev, "could not allocate device.\n");
1198 return -ENOMEM;
1199 }
1200
1201 SET_NETDEV_DEV(ndev, &pdev->dev);
1202
1203 dev_dbg(&pdev->dev, "dm9000_probe()\n");
1204
1205 /* setup board info structure */
1206 db = ndev->priv;
1207 memset(db, 0, sizeof(*db));
1208
1209 db->dev = &pdev->dev;
1210 db->ndev = ndev;
1211
1212 spin_lock_init(&db->lock);
1213 mutex_init(&db->addr_lock);
1214
1215 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
1216
1217 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1218 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1219 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1220
1221 if (db->addr_res == NULL || db->data_res == NULL ||
1222 db->irq_res == NULL) {
1223 dev_err(db->dev, "insufficient resources\n");
1224 ret = -ENOENT;
1225 goto out;
1226 }
1227
1228 iosize = res_size(db->addr_res);
1229 db->addr_req = request_mem_region(db->addr_res->start, iosize,
1230 pdev->name);
1231
1232 if (db->addr_req == NULL) {
1233 dev_err(db->dev, "cannot claim address reg area\n");
1234 ret = -EIO;
1235 goto out;
1236 }
1237
1238 db->io_addr = ioremap(db->addr_res->start, iosize);
1239
1240 if (db->io_addr == NULL) {
1241 dev_err(db->dev, "failed to ioremap address reg\n");
1242 ret = -EINVAL;
1243 goto out;
1244 }
1245
1246 iosize = res_size(db->data_res);
1247 db->data_req = request_mem_region(db->data_res->start, iosize,
1248 pdev->name);
1249
1250 if (db->data_req == NULL) {
1251 dev_err(db->dev, "cannot claim data reg area\n");
1252 ret = -EIO;
1253 goto out;
1254 }
1255
1256 db->io_data = ioremap(db->data_res->start, iosize);
1257
1258 if (db->io_data == NULL) {
1259 dev_err(db->dev, "failed to ioremap data reg\n");
1260 ret = -EINVAL;
1261 goto out;
1262 }
1263
1264 /* fill in parameters for net-dev structure */
1265 ndev->base_addr = (unsigned long)db->io_addr;
1266 ndev->irq = db->irq_res->start;
1267
1268 /* ensure at least we have a default set of IO routines */
1269 dm9000_set_io(db, iosize);
1270
1271 /* check to see if anything is being over-ridden */
1272 if (pdata != NULL) {
1273 /* check to see if the driver wants to over-ride the
1274 * default IO width */
1275
1276 if (pdata->flags & DM9000_PLATF_8BITONLY)
1277 dm9000_set_io(db, 1);
1278
1279 if (pdata->flags & DM9000_PLATF_16BITONLY)
1280 dm9000_set_io(db, 2);
1281
1282 if (pdata->flags & DM9000_PLATF_32BITONLY)
1283 dm9000_set_io(db, 4);
1284
1285 /* check to see if there are any IO routine
1286 * over-rides */
1287
1288 if (pdata->inblk != NULL)
1289 db->inblk = pdata->inblk;
1290
1291 if (pdata->outblk != NULL)
1292 db->outblk = pdata->outblk;
1293
1294 if (pdata->dumpblk != NULL)
1295 db->dumpblk = pdata->dumpblk;
1296
1297 db->flags = pdata->flags;
1298 }
1299
1300#ifdef CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL
1301 db->flags |= DM9000_PLATF_SIMPLE_PHY;
1302#endif
1303
1304 dm9000_reset(db);
1305
1306 /* try multiple times, DM9000 sometimes gets the read wrong */
1307 for (i = 0; i < 8; i++) {
1308 id_val = ior(db, DM9000_VIDL);
1309 id_val |= (u32)ior(db, DM9000_VIDH) << 8;
1310 id_val |= (u32)ior(db, DM9000_PIDL) << 16;
1311 id_val |= (u32)ior(db, DM9000_PIDH) << 24;
1312
1313 if (id_val == DM9000_ID)
1314 break;
1315 dev_err(db->dev, "read wrong id 0x%08x\n", id_val);
1316 }
1317
1318 if (id_val != DM9000_ID) {
1319 dev_err(db->dev, "wrong id: 0x%08x\n", id_val);
1320 ret = -ENODEV;
1321 goto out;
1322 }
1323
1324 /* Identify what type of DM9000 we are working on */
1325
1326 id_val = ior(db, DM9000_CHIPR);
1327 dev_dbg(db->dev, "dm9000 revision 0x%02x\n", id_val);
1328
1329 switch (id_val) {
1330 case CHIPR_DM9000A:
1331 db->type = TYPE_DM9000A;
1332 break;
1333 case CHIPR_DM9000B:
1334 db->type = TYPE_DM9000B;
1335 break;
1336 default:
1337 dev_dbg(db->dev, "ID %02x => defaulting to DM9000E\n", id_val);
1338 db->type = TYPE_DM9000E;
1339 }
1340
1341 /* from this point we assume that we have found a DM9000 */
1342
1343 /* driver system function */
1344 ether_setup(ndev);
1345
1346 ndev->open = &dm9000_open;
1347 ndev->hard_start_xmit = &dm9000_start_xmit;
1348 ndev->tx_timeout = &dm9000_timeout;
1349 ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
1350 ndev->stop = &dm9000_stop;
1351 ndev->set_multicast_list = &dm9000_hash_table;
1352 ndev->ethtool_ops = &dm9000_ethtool_ops;
1353 ndev->do_ioctl = &dm9000_ioctl;
1354
1355#ifdef CONFIG_NET_POLL_CONTROLLER
1356 ndev->poll_controller = &dm9000_poll_controller;
1357#endif
1358
1359 db->msg_enable = NETIF_MSG_LINK;
1360 db->mii.phy_id_mask = 0x1f;
1361 db->mii.reg_num_mask = 0x1f;
1362 db->mii.force_media = 0;
1363 db->mii.full_duplex = 0;
1364 db->mii.dev = ndev;
1365 db->mii.mdio_read = dm9000_phy_read;
1366 db->mii.mdio_write = dm9000_phy_write;
1367
1368 mac_src = "eeprom";
1369
1370 /* try reading the node address from the attached EEPROM */
1371 for (i = 0; i < 6; i += 2)
1372 dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
1373
1374 if (!is_valid_ether_addr(ndev->dev_addr)) {
1375 /* try reading from mac */
1376
1377 mac_src = "chip";
1378 for (i = 0; i < 6; i++)
1379 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
1380 }
1381
1382 if (!is_valid_ether_addr(ndev->dev_addr))
1383 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
1384 "set using ifconfig\n", ndev->name);
1385
1386 platform_set_drvdata(pdev, ndev);
1387 ret = register_netdev(ndev);
1388
1389 if (ret == 0) {
1390 DECLARE_MAC_BUF(mac);
1391 printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %s (%s)\n",
1392 ndev->name, dm9000_type_to_char(db->type),
1393 db->io_addr, db->io_data, ndev->irq,
1394 print_mac(mac, ndev->dev_addr), mac_src);
1395 }
1396 return 0;
1397
1398out:
1399 dev_err(db->dev, "not found (%d).\n", ret);
1400
1401 dm9000_release_board(pdev, db);
1402 free_netdev(ndev);
1403
1404 return ret;
1405}
1406
1366static int 1407static int
1367dm9000_drv_suspend(struct platform_device *dev, pm_message_t state) 1408dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
1368{ 1409{
@@ -1432,7 +1473,7 @@ dm9000_init(void)
1432{ 1473{
1433 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION); 1474 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
1434 1475
1435 return platform_driver_register(&dm9000_driver); /* search board and register */ 1476 return platform_driver_register(&dm9000_driver);
1436} 1477}
1437 1478
1438static void __exit 1479static void __exit
diff --git a/drivers/net/dm9000.h b/drivers/net/dm9000.h
index 82cad360bafc..ba25cf541420 100644
--- a/drivers/net/dm9000.h
+++ b/drivers/net/dm9000.h
@@ -45,6 +45,9 @@
45#define DM9000_CHIPR 0x2C 45#define DM9000_CHIPR 0x2C
46#define DM9000_SMCR 0x2F 46#define DM9000_SMCR 0x2F
47 47
48#define CHIPR_DM9000A 0x19
49#define CHIPR_DM9000B 0x1B
50
48#define DM9000_MRCMDX 0xF0 51#define DM9000_MRCMDX 0xF0
49#define DM9000_MRCMD 0xF2 52#define DM9000_MRCMD 0xF2
50#define DM9000_MRRL 0xF4 53#define DM9000_MRRL 0xF4
@@ -131,5 +134,13 @@
131#define DM9000_PKT_RDY 0x01 /* Packet ready to receive */ 134#define DM9000_PKT_RDY 0x01 /* Packet ready to receive */
132#define DM9000_PKT_MAX 1536 /* Received packet max size */ 135#define DM9000_PKT_MAX 1536 /* Received packet max size */
133 136
137/* DM9000A / DM9000B definitions */
138
139#define IMR_LNKCHNG (1<<5)
140#define IMR_UNDERRUN (1<<4)
141
142#define ISR_LNKCHNG (1<<5)
143#define ISR_UNDERRUN (1<<4)
144
134#endif /* _DM9000X_H_ */ 145#endif /* _DM9000X_H_ */
135 146
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 59579b1d8843..311ca266bd77 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -47,12 +47,6 @@ static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation
47 * Macro expands to... 47 * Macro expands to...
48 * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} 48 * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
49 */ 49 */
50#ifdef CONFIG_E1000E_ENABLED
51 #define PCIE(x)
52#else
53 #define PCIE(x) x,
54#endif
55
56static struct pci_device_id e1000_pci_tbl[] = { 50static struct pci_device_id e1000_pci_tbl[] = {
57 INTEL_E1000_ETHERNET_DEVICE(0x1000), 51 INTEL_E1000_ETHERNET_DEVICE(0x1000),
58 INTEL_E1000_ETHERNET_DEVICE(0x1001), 52 INTEL_E1000_ETHERNET_DEVICE(0x1001),
@@ -79,14 +73,6 @@ static struct pci_device_id e1000_pci_tbl[] = {
79 INTEL_E1000_ETHERNET_DEVICE(0x1026), 73 INTEL_E1000_ETHERNET_DEVICE(0x1026),
80 INTEL_E1000_ETHERNET_DEVICE(0x1027), 74 INTEL_E1000_ETHERNET_DEVICE(0x1027),
81 INTEL_E1000_ETHERNET_DEVICE(0x1028), 75 INTEL_E1000_ETHERNET_DEVICE(0x1028),
82PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1049))
83PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104A))
84PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104B))
85PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104C))
86PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104D))
87PCIE( INTEL_E1000_ETHERNET_DEVICE(0x105E))
88PCIE( INTEL_E1000_ETHERNET_DEVICE(0x105F))
89PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1060))
90 INTEL_E1000_ETHERNET_DEVICE(0x1075), 76 INTEL_E1000_ETHERNET_DEVICE(0x1075),
91 INTEL_E1000_ETHERNET_DEVICE(0x1076), 77 INTEL_E1000_ETHERNET_DEVICE(0x1076),
92 INTEL_E1000_ETHERNET_DEVICE(0x1077), 78 INTEL_E1000_ETHERNET_DEVICE(0x1077),
@@ -95,28 +81,9 @@ PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1060))
95 INTEL_E1000_ETHERNET_DEVICE(0x107A), 81 INTEL_E1000_ETHERNET_DEVICE(0x107A),
96 INTEL_E1000_ETHERNET_DEVICE(0x107B), 82 INTEL_E1000_ETHERNET_DEVICE(0x107B),
97 INTEL_E1000_ETHERNET_DEVICE(0x107C), 83 INTEL_E1000_ETHERNET_DEVICE(0x107C),
98PCIE( INTEL_E1000_ETHERNET_DEVICE(0x107D))
99PCIE( INTEL_E1000_ETHERNET_DEVICE(0x107E))
100PCIE( INTEL_E1000_ETHERNET_DEVICE(0x107F))
101 INTEL_E1000_ETHERNET_DEVICE(0x108A), 84 INTEL_E1000_ETHERNET_DEVICE(0x108A),
102PCIE( INTEL_E1000_ETHERNET_DEVICE(0x108B))
103PCIE( INTEL_E1000_ETHERNET_DEVICE(0x108C))
104PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1096))
105PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1098))
106 INTEL_E1000_ETHERNET_DEVICE(0x1099), 85 INTEL_E1000_ETHERNET_DEVICE(0x1099),
107PCIE( INTEL_E1000_ETHERNET_DEVICE(0x109A))
108PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10A4))
109PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10A5))
110 INTEL_E1000_ETHERNET_DEVICE(0x10B5), 86 INTEL_E1000_ETHERNET_DEVICE(0x10B5),
111PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10B9))
112PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10BA))
113PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10BB))
114PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10BC))
115PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10C4))
116PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10C5))
117PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10D5))
118PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10D9))
119PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10DA))
120 /* required last entry */ 87 /* required last entry */
121 {0,} 88 {0,}
122}; 89};
@@ -5284,7 +5251,6 @@ e1000_netpoll(struct net_device *netdev)
5284 5251
5285 disable_irq(adapter->pdev->irq); 5252 disable_irq(adapter->pdev->irq);
5286 e1000_intr(adapter->pdev->irq, netdev); 5253 e1000_intr(adapter->pdev->irq, netdev);
5287 e1000_clean_tx_irq(adapter, adapter->tx_ring);
5288#ifndef CONFIG_E1000_NAPI 5254#ifndef CONFIG_E1000_NAPI
5289 adapter->clean_rx(adapter, adapter->rx_ring); 5255 adapter->clean_rx(adapter, adapter->rx_ring);
5290#endif 5256#endif
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index d3bc6f8101fa..4a4f62e002b2 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -283,6 +283,10 @@ struct e1000_adapter {
283 unsigned long led_status; 283 unsigned long led_status;
284 284
285 unsigned int flags; 285 unsigned int flags;
286
287 /* for ioport free */
288 int bars;
289 int need_ioport;
286}; 290};
287 291
288struct e1000_info { 292struct e1000_info {
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 0320925a42a8..acdd616c96f6 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4003,7 +4003,11 @@ static int e1000_resume(struct pci_dev *pdev)
4003 pci_set_power_state(pdev, PCI_D0); 4003 pci_set_power_state(pdev, PCI_D0);
4004 pci_restore_state(pdev); 4004 pci_restore_state(pdev);
4005 e1000e_disable_l1aspm(pdev); 4005 e1000e_disable_l1aspm(pdev);
4006 err = pci_enable_device(pdev); 4006
4007 if (adapter->need_ioport)
4008 err = pci_enable_device(pdev);
4009 else
4010 err = pci_enable_device_mem(pdev);
4007 if (err) { 4011 if (err) {
4008 dev_err(&pdev->dev, 4012 dev_err(&pdev->dev,
4009 "Cannot enable PCI device from suspend\n"); 4013 "Cannot enable PCI device from suspend\n");
@@ -4104,9 +4108,14 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4104 struct net_device *netdev = pci_get_drvdata(pdev); 4108 struct net_device *netdev = pci_get_drvdata(pdev);
4105 struct e1000_adapter *adapter = netdev_priv(netdev); 4109 struct e1000_adapter *adapter = netdev_priv(netdev);
4106 struct e1000_hw *hw = &adapter->hw; 4110 struct e1000_hw *hw = &adapter->hw;
4111 int err;
4107 4112
4108 e1000e_disable_l1aspm(pdev); 4113 e1000e_disable_l1aspm(pdev);
4109 if (pci_enable_device(pdev)) { 4114 if (adapter->need_ioport)
4115 err = pci_enable_device(pdev);
4116 else
4117 err = pci_enable_device_mem(pdev);
4118 if (err) {
4110 dev_err(&pdev->dev, 4119 dev_err(&pdev->dev,
4111 "Cannot re-enable PCI device after reset.\n"); 4120 "Cannot re-enable PCI device after reset.\n");
4112 return PCI_ERS_RESULT_DISCONNECT; 4121 return PCI_ERS_RESULT_DISCONNECT;
@@ -4185,6 +4194,21 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
4185} 4194}
4186 4195
4187/** 4196/**
4197 * e1000e_is_need_ioport - determine if an adapter needs ioport resources or not
4198 * @pdev: PCI device information struct
4199 *
4200 * Returns true if an adapters needs ioport resources
4201 **/
4202static int e1000e_is_need_ioport(struct pci_dev *pdev)
4203{
4204 switch (pdev->device) {
4205 /* Currently there are no adapters that need ioport resources */
4206 default:
4207 return false;
4208 }
4209}
4210
4211/**
4188 * e1000_probe - Device Initialization Routine 4212 * e1000_probe - Device Initialization Routine
4189 * @pdev: PCI device information struct 4213 * @pdev: PCI device information struct
4190 * @ent: entry in e1000_pci_tbl 4214 * @ent: entry in e1000_pci_tbl
@@ -4209,9 +4233,19 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4209 int i, err, pci_using_dac; 4233 int i, err, pci_using_dac;
4210 u16 eeprom_data = 0; 4234 u16 eeprom_data = 0;
4211 u16 eeprom_apme_mask = E1000_EEPROM_APME; 4235 u16 eeprom_apme_mask = E1000_EEPROM_APME;
4236 int bars, need_ioport;
4212 4237
4213 e1000e_disable_l1aspm(pdev); 4238 e1000e_disable_l1aspm(pdev);
4214 err = pci_enable_device(pdev); 4239
4240 /* do not allocate ioport bars when not needed */
4241 need_ioport = e1000e_is_need_ioport(pdev);
4242 if (need_ioport) {
4243 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
4244 err = pci_enable_device(pdev);
4245 } else {
4246 bars = pci_select_bars(pdev, IORESOURCE_MEM);
4247 err = pci_enable_device_mem(pdev);
4248 }
4215 if (err) 4249 if (err)
4216 return err; 4250 return err;
4217 4251
@@ -4234,7 +4268,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4234 } 4268 }
4235 } 4269 }
4236 4270
4237 err = pci_request_regions(pdev, e1000e_driver_name); 4271 err = pci_request_selected_regions(pdev, bars, e1000e_driver_name);
4238 if (err) 4272 if (err)
4239 goto err_pci_reg; 4273 goto err_pci_reg;
4240 4274
@@ -4259,6 +4293,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4259 adapter->hw.adapter = adapter; 4293 adapter->hw.adapter = adapter;
4260 adapter->hw.mac.type = ei->mac; 4294 adapter->hw.mac.type = ei->mac;
4261 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; 4295 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
4296 adapter->bars = bars;
4297 adapter->need_ioport = need_ioport;
4262 4298
4263 mmio_start = pci_resource_start(pdev, 0); 4299 mmio_start = pci_resource_start(pdev, 0);
4264 mmio_len = pci_resource_len(pdev, 0); 4300 mmio_len = pci_resource_len(pdev, 0);
@@ -4498,7 +4534,7 @@ err_sw_init:
4498err_ioremap: 4534err_ioremap:
4499 free_netdev(netdev); 4535 free_netdev(netdev);
4500err_alloc_etherdev: 4536err_alloc_etherdev:
4501 pci_release_regions(pdev); 4537 pci_release_selected_regions(pdev, bars);
4502err_pci_reg: 4538err_pci_reg:
4503err_dma: 4539err_dma:
4504 pci_disable_device(pdev); 4540 pci_disable_device(pdev);
@@ -4546,7 +4582,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
4546 iounmap(adapter->hw.hw_addr); 4582 iounmap(adapter->hw.hw_addr);
4547 if (adapter->hw.flash_address) 4583 if (adapter->hw.flash_address)
4548 iounmap(adapter->hw.flash_address); 4584 iounmap(adapter->hw.flash_address);
4549 pci_release_regions(pdev); 4585 pci_release_selected_regions(pdev, adapter->bars);
4550 4586
4551 free_netdev(netdev); 4587 free_netdev(netdev);
4552 4588
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 7bb9c728a1d3..3c1364de2b66 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -90,6 +90,7 @@ static int full_duplex[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
90#include <asm/processor.h> /* Processor type for cache alignment. */ 90#include <asm/processor.h> /* Processor type for cache alignment. */
91#include <asm/io.h> 91#include <asm/io.h>
92#include <asm/uaccess.h> 92#include <asm/uaccess.h>
93#include <asm/byteorder.h>
93 94
94/* These identify the driver base version and may not be removed. */ 95/* These identify the driver base version and may not be removed. */
95static char version[] = 96static char version[] =
@@ -861,40 +862,20 @@ static int netdev_open(struct net_device *dev)
861 Wait the specified 50 PCI cycles after a reset by initializing 862 Wait the specified 50 PCI cycles after a reset by initializing
862 Tx and Rx queues and the address filter list. 863 Tx and Rx queues and the address filter list.
863 FIXME (Ueimor): optimistic for alpha + posted writes ? */ 864 FIXME (Ueimor): optimistic for alpha + posted writes ? */
864#if defined(__powerpc__) || defined(__sparc__) 865
865// 89/9/1 modify,
866// np->bcrvalue=0x04 | 0x0x38; /* big-endian, 256 burst length */
867 np->bcrvalue = 0x04 | 0x10; /* big-endian, tx 8 burst length */
868 np->crvalue = 0xe00; /* rx 128 burst length */
869#elif defined(__alpha__) || defined(__x86_64__)
870// 89/9/1 modify,
871// np->bcrvalue=0x38; /* little-endian, 256 burst length */
872 np->bcrvalue = 0x10; /* little-endian, 8 burst length */
873 np->crvalue = 0xe00; /* rx 128 burst length */
874#elif defined(__i386__)
875#if defined(MODULE)
876// 89/9/1 modify,
877// np->bcrvalue=0x38; /* little-endian, 256 burst length */
878 np->bcrvalue = 0x10; /* little-endian, 8 burst length */ 866 np->bcrvalue = 0x10; /* little-endian, 8 burst length */
879 np->crvalue = 0xe00; /* rx 128 burst length */ 867#ifdef __BIG_ENDIAN
880#else 868 np->bcrvalue |= 0x04; /* big-endian */
881 /* When not a module we can work around broken '486 PCI boards. */
882#define x86 boot_cpu_data.x86
883// 89/9/1 modify,
884// np->bcrvalue=(x86 <= 4 ? 0x10 : 0x38);
885 np->bcrvalue = 0x10;
886 np->crvalue = (x86 <= 4 ? 0xa00 : 0xe00);
887 if (x86 <= 4)
888 printk(KERN_INFO "%s: This is a 386/486 PCI system, setting burst "
889 "length to %x.\n", dev->name, (x86 <= 4 ? 0x10 : 0x38));
890#endif 869#endif
891#else 870
892// 89/9/1 modify, 871#if defined(__i386__) && !defined(MODULE)
893// np->bcrvalue=0x38; 872 if (boot_cpu_data.x86 <= 4)
894 np->bcrvalue = 0x10; 873 np->crvalue = 0xa00;
895 np->crvalue = 0xe00; /* rx 128 burst length */ 874 else
896#warning Processor architecture undefined!
897#endif 875#endif
876 np->crvalue = 0xe00; /* rx 128 burst length */
877
878
898// 89/12/29 add, 879// 89/12/29 add,
899// 90/1/16 modify, 880// 90/1/16 modify,
900// np->imrvalue=FBE|TUNF|CNTOVF|RBU|TI|RI; 881// np->imrvalue=FBE|TUNF|CNTOVF|RBU|TI|RI;
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index c980ce9719af..afd063fe11af 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -5559,6 +5559,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5559 /* set mac address */ 5559 /* set mac address */
5560 nv_copy_mac_to_hw(dev); 5560 nv_copy_mac_to_hw(dev);
5561 5561
5562 /* Workaround current PCI init glitch: wakeup bits aren't
5563 * being set from PCI PM capability.
5564 */
5565 device_init_wakeup(&pci_dev->dev, 1);
5566
5562 /* disable WOL */ 5567 /* disable WOL */
5563 writel(0, base + NvRegWakeUpFlags); 5568 writel(0, base + NvRegWakeUpFlags);
5564 np->wolenabled = 0; 5569 np->wolenabled = 0;
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 6b2e7d351d65..0eecb8b2abd2 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -271,6 +271,10 @@ struct igb_adapter {
271 unsigned int msi_enabled; 271 unsigned int msi_enabled;
272 272
273 u32 eeprom_wol; 273 u32 eeprom_wol;
274
275 /* for ioport free */
276 int bars;
277 int need_ioport;
274}; 278};
275 279
276enum e1000_state_t { 280enum e1000_state_t {
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 6f1ad5368ae5..171d1fc1fbf8 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -821,6 +821,21 @@ void igb_reset(struct igb_adapter *adapter)
821} 821}
822 822
823/** 823/**
824 * igb_is_need_ioport - determine if an adapter needs ioport resources or not
825 * @pdev: PCI device information struct
826 *
827 * Returns true if an adapter needs ioport resources
828 **/
829static int igb_is_need_ioport(struct pci_dev *pdev)
830{
831 switch (pdev->device) {
832 /* Currently there are no adapters that need ioport resources */
833 default:
834 return false;
835 }
836}
837
838/**
824 * igb_probe - Device Initialization Routine 839 * igb_probe - Device Initialization Routine
825 * @pdev: PCI device information struct 840 * @pdev: PCI device information struct
826 * @ent: entry in igb_pci_tbl 841 * @ent: entry in igb_pci_tbl
@@ -844,8 +859,17 @@ static int __devinit igb_probe(struct pci_dev *pdev,
844 u16 eeprom_data = 0; 859 u16 eeprom_data = 0;
845 u16 eeprom_apme_mask = IGB_EEPROM_APME; 860 u16 eeprom_apme_mask = IGB_EEPROM_APME;
846 u32 part_num; 861 u32 part_num;
862 int bars, need_ioport;
847 863
848 err = pci_enable_device(pdev); 864 /* do not allocate ioport bars when not needed */
865 need_ioport = igb_is_need_ioport(pdev);
866 if (need_ioport) {
867 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
868 err = pci_enable_device(pdev);
869 } else {
870 bars = pci_select_bars(pdev, IORESOURCE_MEM);
871 err = pci_enable_device_mem(pdev);
872 }
849 if (err) 873 if (err)
850 return err; 874 return err;
851 875
@@ -867,7 +891,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
867 } 891 }
868 } 892 }
869 893
870 err = pci_request_regions(pdev, igb_driver_name); 894 err = pci_request_selected_regions(pdev, bars, igb_driver_name);
871 if (err) 895 if (err)
872 goto err_pci_reg; 896 goto err_pci_reg;
873 897
@@ -888,6 +912,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,
888 hw = &adapter->hw; 912 hw = &adapter->hw;
889 hw->back = adapter; 913 hw->back = adapter;
890 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE; 914 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE;
915 adapter->bars = bars;
916 adapter->need_ioport = need_ioport;
891 917
892 mmio_start = pci_resource_start(pdev, 0); 918 mmio_start = pci_resource_start(pdev, 0);
893 mmio_len = pci_resource_len(pdev, 0); 919 mmio_len = pci_resource_len(pdev, 0);
@@ -1128,7 +1154,7 @@ err_hw_init:
1128err_ioremap: 1154err_ioremap:
1129 free_netdev(netdev); 1155 free_netdev(netdev);
1130err_alloc_etherdev: 1156err_alloc_etherdev:
1131 pci_release_regions(pdev); 1157 pci_release_selected_regions(pdev, bars);
1132err_pci_reg: 1158err_pci_reg:
1133err_dma: 1159err_dma:
1134 pci_disable_device(pdev); 1160 pci_disable_device(pdev);
@@ -1175,7 +1201,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
1175 iounmap(adapter->hw.hw_addr); 1201 iounmap(adapter->hw.hw_addr);
1176 if (adapter->hw.flash_address) 1202 if (adapter->hw.flash_address)
1177 iounmap(adapter->hw.flash_address); 1203 iounmap(adapter->hw.flash_address);
1178 pci_release_regions(pdev); 1204 pci_release_selected_regions(pdev, adapter->bars);
1179 1205
1180 free_netdev(netdev); 1206 free_netdev(netdev);
1181 1207
@@ -3976,7 +4002,11 @@ static int igb_resume(struct pci_dev *pdev)
3976 4002
3977 pci_set_power_state(pdev, PCI_D0); 4003 pci_set_power_state(pdev, PCI_D0);
3978 pci_restore_state(pdev); 4004 pci_restore_state(pdev);
3979 err = pci_enable_device(pdev); 4005
4006 if (adapter->need_ioport)
4007 err = pci_enable_device(pdev);
4008 else
4009 err = pci_enable_device_mem(pdev);
3980 if (err) { 4010 if (err) {
3981 dev_err(&pdev->dev, 4011 dev_err(&pdev->dev,
3982 "igb: Cannot enable PCI device from suspend\n"); 4012 "igb: Cannot enable PCI device from suspend\n");
@@ -4079,8 +4109,13 @@ static pci_ers_result_t igb_io_slot_reset(struct pci_dev *pdev)
4079 struct net_device *netdev = pci_get_drvdata(pdev); 4109 struct net_device *netdev = pci_get_drvdata(pdev);
4080 struct igb_adapter *adapter = netdev_priv(netdev); 4110 struct igb_adapter *adapter = netdev_priv(netdev);
4081 struct e1000_hw *hw = &adapter->hw; 4111 struct e1000_hw *hw = &adapter->hw;
4112 int err;
4082 4113
4083 if (pci_enable_device(pdev)) { 4114 if (adapter->need_ioport)
4115 err = pci_enable_device(pdev);
4116 else
4117 err = pci_enable_device_mem(pdev);
4118 if (err) {
4084 dev_err(&pdev->dev, 4119 dev_err(&pdev->dev,
4085 "Cannot re-enable PCI device after reset.\n"); 4120 "Cannot re-enable PCI device after reset.\n");
4086 return PCI_ERS_RESULT_DISCONNECT; 4121 return PCI_ERS_RESULT_DISCONNECT;
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index d98113472a89..956914a5028d 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -32,6 +32,7 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/netdevice.h> 34#include <linux/netdevice.h>
35#include <linux/inet_lro.h>
35 36
36#include "ixgbe_type.h" 37#include "ixgbe_type.h"
37#include "ixgbe_common.h" 38#include "ixgbe_common.h"
@@ -100,6 +101,9 @@
100#define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000 101#define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000
101#define IXGBE_TX_FLAGS_VLAN_SHIFT 16 102#define IXGBE_TX_FLAGS_VLAN_SHIFT 16
102 103
104#define IXGBE_MAX_LRO_DESCRIPTORS 8
105#define IXGBE_MAX_LRO_AGGREGATE 32
106
103/* wrapper around a pointer to a socket buffer, 107/* wrapper around a pointer to a socket buffer,
104 * so a DMA handle can be stored along with the buffer */ 108 * so a DMA handle can be stored along with the buffer */
105struct ixgbe_tx_buffer { 109struct ixgbe_tx_buffer {
@@ -150,6 +154,8 @@ struct ixgbe_ring {
150 /* cpu for tx queue */ 154 /* cpu for tx queue */
151 int cpu; 155 int cpu;
152#endif 156#endif
157 struct net_lro_mgr lro_mgr;
158 bool lro_used;
153 struct ixgbe_queue_stats stats; 159 struct ixgbe_queue_stats stats;
154 u8 v_idx; /* maps directly to the index for this ring in the hardware 160 u8 v_idx; /* maps directly to the index for this ring in the hardware
155 * vector array, can also be used for finding the bit in EICR 161 * vector array, can also be used for finding the bit in EICR
@@ -287,6 +293,9 @@ struct ixgbe_adapter {
287 293
288 unsigned long state; 294 unsigned long state;
289 u64 tx_busy; 295 u64 tx_busy;
296 u64 lro_aggregated;
297 u64 lro_flushed;
298 u64 lro_no_desc;
290}; 299};
291 300
292enum ixbge_state_t { 301enum ixbge_state_t {
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 4e463778bcfd..12990b1fe7e4 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -90,6 +90,8 @@ static struct ixgbe_stats ixgbe_gstrings_stats[] = {
90 {"rx_header_split", IXGBE_STAT(rx_hdr_split)}, 90 {"rx_header_split", IXGBE_STAT(rx_hdr_split)},
91 {"alloc_rx_page_failed", IXGBE_STAT(alloc_rx_page_failed)}, 91 {"alloc_rx_page_failed", IXGBE_STAT(alloc_rx_page_failed)},
92 {"alloc_rx_buff_failed", IXGBE_STAT(alloc_rx_buff_failed)}, 92 {"alloc_rx_buff_failed", IXGBE_STAT(alloc_rx_buff_failed)},
93 {"lro_aggregated", IXGBE_STAT(lro_aggregated)},
94 {"lro_flushed", IXGBE_STAT(lro_flushed)},
93}; 95};
94 96
95#define IXGBE_QUEUE_STATS_LEN \ 97#define IXGBE_QUEUE_STATS_LEN \
@@ -787,6 +789,7 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
787 int stat_count = sizeof(struct ixgbe_queue_stats) / sizeof(u64); 789 int stat_count = sizeof(struct ixgbe_queue_stats) / sizeof(u64);
788 int j, k; 790 int j, k;
789 int i; 791 int i;
792 u64 aggregated = 0, flushed = 0, no_desc = 0;
790 793
791 ixgbe_update_stats(adapter); 794 ixgbe_update_stats(adapter);
792 for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) { 795 for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) {
@@ -801,11 +804,17 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
801 i += k; 804 i += k;
802 } 805 }
803 for (j = 0; j < adapter->num_rx_queues; j++) { 806 for (j = 0; j < adapter->num_rx_queues; j++) {
807 aggregated += adapter->rx_ring[j].lro_mgr.stats.aggregated;
808 flushed += adapter->rx_ring[j].lro_mgr.stats.flushed;
809 no_desc += adapter->rx_ring[j].lro_mgr.stats.no_desc;
804 queue_stat = (u64 *)&adapter->rx_ring[j].stats; 810 queue_stat = (u64 *)&adapter->rx_ring[j].stats;
805 for (k = 0; k < stat_count; k++) 811 for (k = 0; k < stat_count; k++)
806 data[i + k] = queue_stat[k]; 812 data[i + k] = queue_stat[k];
807 i += k; 813 i += k;
808 } 814 }
815 adapter->lro_aggregated = aggregated;
816 adapter->lro_flushed = flushed;
817 adapter->lro_no_desc = no_desc;
809} 818}
810 819
811static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, 820static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
@@ -973,6 +982,8 @@ static struct ethtool_ops ixgbe_ethtool_ops = {
973 .get_ethtool_stats = ixgbe_get_ethtool_stats, 982 .get_ethtool_stats = ixgbe_get_ethtool_stats,
974 .get_coalesce = ixgbe_get_coalesce, 983 .get_coalesce = ixgbe_get_coalesce,
975 .set_coalesce = ixgbe_set_coalesce, 984 .set_coalesce = ixgbe_set_coalesce,
985 .get_flags = ethtool_op_get_flags,
986 .set_flags = ethtool_op_set_flags,
976}; 987};
977 988
978void ixgbe_set_ethtool_ops(struct net_device *netdev) 989void ixgbe_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 1674b6a5b903..b37d618d8e2a 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -389,24 +389,39 @@ static int __ixgbe_notify_dca(struct device *dev, void *data)
389 * ixgbe_receive_skb - Send a completed packet up the stack 389 * ixgbe_receive_skb - Send a completed packet up the stack
390 * @adapter: board private structure 390 * @adapter: board private structure
391 * @skb: packet to send up 391 * @skb: packet to send up
392 * @is_vlan: packet has a VLAN tag 392 * @status: hardware indication of status of receive
393 * @tag: VLAN tag from descriptor 393 * @rx_ring: rx descriptor ring (for a specific queue) to setup
394 * @rx_desc: rx descriptor
394 **/ 395 **/
395static void ixgbe_receive_skb(struct ixgbe_adapter *adapter, 396static void ixgbe_receive_skb(struct ixgbe_adapter *adapter,
396 struct sk_buff *skb, bool is_vlan, 397 struct sk_buff *skb, u8 status,
397 u16 tag) 398 struct ixgbe_ring *ring,
399 union ixgbe_adv_rx_desc *rx_desc)
398{ 400{
399 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) { 401 bool is_vlan = (status & IXGBE_RXD_STAT_VP);
400 if (adapter->vlgrp && is_vlan) 402 u16 tag = le16_to_cpu(rx_desc->wb.upper.vlan);
401 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, tag);
402 else
403 netif_receive_skb(skb);
404 } else {
405 403
404 if (adapter->netdev->features & NETIF_F_LRO &&
405 skb->ip_summed == CHECKSUM_UNNECESSARY) {
406 if (adapter->vlgrp && is_vlan) 406 if (adapter->vlgrp && is_vlan)
407 vlan_hwaccel_rx(skb, adapter->vlgrp, tag); 407 lro_vlan_hwaccel_receive_skb(&ring->lro_mgr, skb,
408 adapter->vlgrp, tag,
409 rx_desc);
408 else 410 else
409 netif_rx(skb); 411 lro_receive_skb(&ring->lro_mgr, skb, rx_desc);
412 ring->lro_used = true;
413 } else {
414 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) {
415 if (adapter->vlgrp && is_vlan)
416 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, tag);
417 else
418 netif_receive_skb(skb);
419 } else {
420 if (adapter->vlgrp && is_vlan)
421 vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
422 else
423 netif_rx(skb);
424 }
410 } 425 }
411} 426}
412 427
@@ -546,8 +561,8 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter *adapter,
546 struct sk_buff *skb; 561 struct sk_buff *skb;
547 unsigned int i; 562 unsigned int i;
548 u32 upper_len, len, staterr; 563 u32 upper_len, len, staterr;
549 u16 hdr_info, vlan_tag; 564 u16 hdr_info;
550 bool is_vlan, cleaned = false; 565 bool cleaned = false;
551 int cleaned_count = 0; 566 int cleaned_count = 0;
552 unsigned int total_rx_bytes = 0, total_rx_packets = 0; 567 unsigned int total_rx_bytes = 0, total_rx_packets = 0;
553 568
@@ -556,8 +571,6 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter *adapter,
556 rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i); 571 rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i);
557 staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 572 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
558 rx_buffer_info = &rx_ring->rx_buffer_info[i]; 573 rx_buffer_info = &rx_ring->rx_buffer_info[i];
559 is_vlan = (staterr & IXGBE_RXD_STAT_VP);
560 vlan_tag = le16_to_cpu(rx_desc->wb.upper.vlan);
561 574
562 while (staterr & IXGBE_RXD_STAT_DD) { 575 while (staterr & IXGBE_RXD_STAT_DD) {
563 if (*work_done >= work_to_do) 576 if (*work_done >= work_to_do)
@@ -635,7 +648,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter *adapter,
635 total_rx_packets++; 648 total_rx_packets++;
636 649
637 skb->protocol = eth_type_trans(skb, netdev); 650 skb->protocol = eth_type_trans(skb, netdev);
638 ixgbe_receive_skb(adapter, skb, is_vlan, vlan_tag); 651 ixgbe_receive_skb(adapter, skb, staterr, rx_ring, rx_desc);
639 netdev->last_rx = jiffies; 652 netdev->last_rx = jiffies;
640 653
641next_desc: 654next_desc:
@@ -652,8 +665,11 @@ next_desc:
652 rx_buffer_info = next_buffer; 665 rx_buffer_info = next_buffer;
653 666
654 staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 667 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
655 is_vlan = (staterr & IXGBE_RXD_STAT_VP); 668 }
656 vlan_tag = le16_to_cpu(rx_desc->wb.upper.vlan); 669
670 if (rx_ring->lro_used) {
671 lro_flush_all(&rx_ring->lro_mgr);
672 rx_ring->lro_used = false;
657 } 673 }
658 674
659 rx_ring->next_to_clean = i; 675 rx_ring->next_to_clean = i;
@@ -1382,6 +1398,33 @@ static void ixgbe_configure_tx(struct ixgbe_adapter *adapter)
1382 1398
1383#define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2 1399#define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2
1384/** 1400/**
1401 * ixgbe_get_skb_hdr - helper function for LRO header processing
1402 * @skb: pointer to sk_buff to be added to LRO packet
1403 * @iphdr: pointer to tcp header structure
1404 * @tcph: pointer to tcp header structure
1405 * @hdr_flags: pointer to header flags
1406 * @priv: private data
1407 **/
1408static int ixgbe_get_skb_hdr(struct sk_buff *skb, void **iphdr, void **tcph,
1409 u64 *hdr_flags, void *priv)
1410{
1411 union ixgbe_adv_rx_desc *rx_desc = priv;
1412
1413 /* Verify that this is a valid IPv4 TCP packet */
1414 if (!(rx_desc->wb.lower.lo_dword.pkt_info &
1415 (IXGBE_RXDADV_PKTTYPE_IPV4 | IXGBE_RXDADV_PKTTYPE_TCP)))
1416 return -1;
1417
1418 /* Set network headers */
1419 skb_reset_network_header(skb);
1420 skb_set_transport_header(skb, ip_hdrlen(skb));
1421 *iphdr = ip_hdr(skb);
1422 *tcph = tcp_hdr(skb);
1423 *hdr_flags = LRO_IPV4 | LRO_TCP;
1424 return 0;
1425}
1426
1427/**
1385 * ixgbe_configure_rx - Configure 8254x Receive Unit after Reset 1428 * ixgbe_configure_rx - Configure 8254x Receive Unit after Reset
1386 * @adapter: board private structure 1429 * @adapter: board private structure
1387 * 1430 *
@@ -1470,6 +1513,17 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
1470 adapter->rx_ring[i].tail = IXGBE_RDT(i); 1513 adapter->rx_ring[i].tail = IXGBE_RDT(i);
1471 } 1514 }
1472 1515
1516 /* Intitial LRO Settings */
1517 adapter->rx_ring[i].lro_mgr.max_aggr = IXGBE_MAX_LRO_AGGREGATE;
1518 adapter->rx_ring[i].lro_mgr.max_desc = IXGBE_MAX_LRO_DESCRIPTORS;
1519 adapter->rx_ring[i].lro_mgr.get_skb_header = ixgbe_get_skb_hdr;
1520 adapter->rx_ring[i].lro_mgr.features = LRO_F_EXTRACT_VLAN_ID;
1521 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL))
1522 adapter->rx_ring[i].lro_mgr.features |= LRO_F_NAPI;
1523 adapter->rx_ring[i].lro_mgr.dev = adapter->netdev;
1524 adapter->rx_ring[i].lro_mgr.ip_summed = CHECKSUM_UNNECESSARY;
1525 adapter->rx_ring[i].lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY;
1526
1473 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { 1527 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
1474 /* Fill out redirection table */ 1528 /* Fill out redirection table */
1475 for (i = 0, j = 0; i < 128; i++, j++) { 1529 for (i = 0, j = 0; i < 128; i++, j++) {
@@ -2490,12 +2544,18 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
2490 struct pci_dev *pdev = adapter->pdev; 2544 struct pci_dev *pdev = adapter->pdev;
2491 int size; 2545 int size;
2492 2546
2547 size = sizeof(struct net_lro_desc) * IXGBE_MAX_LRO_DESCRIPTORS;
2548 rxdr->lro_mgr.lro_arr = vmalloc(size);
2549 if (!rxdr->lro_mgr.lro_arr)
2550 return -ENOMEM;
2551 memset(rxdr->lro_mgr.lro_arr, 0, size);
2552
2493 size = sizeof(struct ixgbe_rx_buffer) * rxdr->count; 2553 size = sizeof(struct ixgbe_rx_buffer) * rxdr->count;
2494 rxdr->rx_buffer_info = vmalloc(size); 2554 rxdr->rx_buffer_info = vmalloc(size);
2495 if (!rxdr->rx_buffer_info) { 2555 if (!rxdr->rx_buffer_info) {
2496 DPRINTK(PROBE, ERR, 2556 DPRINTK(PROBE, ERR,
2497 "vmalloc allocation failed for the rx desc ring\n"); 2557 "vmalloc allocation failed for the rx desc ring\n");
2498 return -ENOMEM; 2558 goto alloc_failed;
2499 } 2559 }
2500 memset(rxdr->rx_buffer_info, 0, size); 2560 memset(rxdr->rx_buffer_info, 0, size);
2501 2561
@@ -2509,13 +2569,18 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
2509 DPRINTK(PROBE, ERR, 2569 DPRINTK(PROBE, ERR,
2510 "Memory allocation failed for the rx desc ring\n"); 2570 "Memory allocation failed for the rx desc ring\n");
2511 vfree(rxdr->rx_buffer_info); 2571 vfree(rxdr->rx_buffer_info);
2512 return -ENOMEM; 2572 goto alloc_failed;
2513 } 2573 }
2514 2574
2515 rxdr->next_to_clean = 0; 2575 rxdr->next_to_clean = 0;
2516 rxdr->next_to_use = 0; 2576 rxdr->next_to_use = 0;
2517 2577
2518 return 0; 2578 return 0;
2579
2580alloc_failed:
2581 vfree(rxdr->lro_mgr.lro_arr);
2582 rxdr->lro_mgr.lro_arr = NULL;
2583 return -ENOMEM;
2519} 2584}
2520 2585
2521/** 2586/**
@@ -2566,6 +2631,9 @@ static void ixgbe_free_rx_resources(struct ixgbe_adapter *adapter,
2566{ 2631{
2567 struct pci_dev *pdev = adapter->pdev; 2632 struct pci_dev *pdev = adapter->pdev;
2568 2633
2634 vfree(rx_ring->lro_mgr.lro_arr);
2635 rx_ring->lro_mgr.lro_arr = NULL;
2636
2569 ixgbe_clean_rx_ring(adapter, rx_ring); 2637 ixgbe_clean_rx_ring(adapter, rx_ring);
2570 2638
2571 vfree(rx_ring->rx_buffer_info); 2639 vfree(rx_ring->rx_buffer_info);
@@ -3518,6 +3586,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3518 NETIF_F_HW_VLAN_RX | 3586 NETIF_F_HW_VLAN_RX |
3519 NETIF_F_HW_VLAN_FILTER; 3587 NETIF_F_HW_VLAN_FILTER;
3520 3588
3589 netdev->features |= NETIF_F_LRO;
3521 netdev->features |= NETIF_F_TSO; 3590 netdev->features |= NETIF_F_TSO;
3522 netdev->features |= NETIF_F_TSO6; 3591 netdev->features |= NETIF_F_TSO6;
3523 3592
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index fffc49befe04..53451c3b2c0d 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -1739,7 +1739,6 @@ static int netdrv_close (struct net_device *dev)
1739 1739
1740 spin_unlock_irqrestore (&tp->lock, flags); 1740 spin_unlock_irqrestore (&tp->lock, flags);
1741 1741
1742 synchronize_irq (dev->irq);
1743 free_irq (dev->irq, dev); 1742 free_irq (dev->irq, dev);
1744 1743
1745 netdrv_tx_clear (dev); 1744 netdrv_tx_clear (dev);
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index f64d987140a9..37f3116ea6bd 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -322,7 +322,7 @@ static int sh_eth_dev_init(struct net_device *ndev)
322 ctrl_outl((FIFO_SIZE_T | FIFO_SIZE_R), ioaddr + FDR); 322 ctrl_outl((FIFO_SIZE_T | FIFO_SIZE_R), ioaddr + FDR);
323 ctrl_outl(0, ioaddr + TFTR); 323 ctrl_outl(0, ioaddr + TFTR);
324 324
325 ctrl_outl(RMCR_RST, ioaddr + RMCR); 325 ctrl_outl(0, ioaddr + RMCR);
326 326
327 rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5; 327 rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5;
328 tx_int_var = mdp->tx_int_var = DESC_I_TINT2; 328 tx_int_var = mdp->tx_int_var = DESC_I_TINT2;
@@ -994,7 +994,7 @@ static int sh_mdio_init(struct net_device *ndev, int id)
994 /* Hook up MII support for ethtool */ 994 /* Hook up MII support for ethtool */
995 mdp->mii_bus->name = "sh_mii"; 995 mdp->mii_bus->name = "sh_mii";
996 mdp->mii_bus->dev = &ndev->dev; 996 mdp->mii_bus->dev = &ndev->dev;
997 mdp->mii_bus->id = id; 997 mdp->mii_bus->id[0] = id;
998 998
999 /* PHY IRQ */ 999 /* PHY IRQ */
1000 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1000 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
index ca2db6bb3c61..e01e1c347715 100644
--- a/drivers/net/sh_eth.h
+++ b/drivers/net/sh_eth.h
@@ -40,8 +40,6 @@
40#define PKT_BUF_SZ 1538 40#define PKT_BUF_SZ 1538
41 41
42/* Chip Base Address */ 42/* Chip Base Address */
43#define SH_ETH0_BASE 0xA7000000
44#define SH_ETH1_BASE 0xA7000400
45#define SH_TSU_ADDR 0xA7000804 43#define SH_TSU_ADDR 0xA7000804
46 44
47/* Chip Registers */ 45/* Chip Registers */
@@ -462,3 +460,5 @@ static void swaps(char *src, int len)
462 *p = swab32(*p); 460 *p = swab32(*p);
463#endif 461#endif
464} 462}
463
464#endif
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index febfaee44fe9..43fde99b24ac 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -1437,7 +1437,6 @@ static int tsi108_close(struct net_device *dev)
1437 dev_kfree_skb(skb); 1437 dev_kfree_skb(skb);
1438 } 1438 }
1439 1439
1440 synchronize_irq(data->irq_num);
1441 free_irq(data->irq_num, dev); 1440 free_irq(data->irq_num, dev);
1442 1441
1443 /* Discard the RX ring. */ 1442 /* Discard the RX ring. */
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index 6c400ccd38b4..1210fb3748a7 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/21142.c 2 drivers/net/tulip/21142.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,8 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/ 12 Please submit bugs to http://bugzilla.kernel.org/ .
14
15*/ 13*/
16 14
17#include <linux/delay.h> 15#include <linux/delay.h>
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 1b5edd646a8c..9281d06d5aaa 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -124,8 +124,6 @@ MODULE_PARM_DESC (rx_copybreak, "de2104x Breakpoint at which Rx packets are copi
124/* Time in jiffies before concluding the transmitter is hung. */ 124/* Time in jiffies before concluding the transmitter is hung. */
125#define TX_TIMEOUT (6*HZ) 125#define TX_TIMEOUT (6*HZ)
126 126
127#define DE_UNALIGNED_16(a) (u16)(get_unaligned((u16 *)(a)))
128
129/* This is a mysterious value that can be written to CSR11 in the 21040 (only) 127/* This is a mysterious value that can be written to CSR11 in the 21040 (only)
130 to support a pre-NWay full-duplex signaling mechanism using short frames. 128 to support a pre-NWay full-duplex signaling mechanism using short frames.
131 No one knows what it should be, but if left at its default value some 129 No one knows what it should be, but if left at its default value some
@@ -1811,7 +1809,7 @@ static void __devinit de21041_get_srom_info (struct de_private *de)
1811 goto bad_srom; 1809 goto bad_srom;
1812 1810
1813 /* get default media type */ 1811 /* get default media type */
1814 switch (DE_UNALIGNED_16(&il->default_media)) { 1812 switch (get_unaligned(&il->default_media)) {
1815 case 0x0001: de->media_type = DE_MEDIA_BNC; break; 1813 case 0x0001: de->media_type = DE_MEDIA_BNC; break;
1816 case 0x0002: de->media_type = DE_MEDIA_AUI; break; 1814 case 0x0002: de->media_type = DE_MEDIA_AUI; break;
1817 case 0x0204: de->media_type = DE_MEDIA_TP_FD; break; 1815 case 0x0204: de->media_type = DE_MEDIA_TP_FD; break;
@@ -1875,9 +1873,9 @@ static void __devinit de21041_get_srom_info (struct de_private *de)
1875 bufp += sizeof (ib->opts); 1873 bufp += sizeof (ib->opts);
1876 1874
1877 if (ib->opts & MediaCustomCSRs) { 1875 if (ib->opts & MediaCustomCSRs) {
1878 de->media[idx].csr13 = DE_UNALIGNED_16(&ib->csr13); 1876 de->media[idx].csr13 = get_unaligned(&ib->csr13);
1879 de->media[idx].csr14 = DE_UNALIGNED_16(&ib->csr14); 1877 de->media[idx].csr14 = get_unaligned(&ib->csr14);
1880 de->media[idx].csr15 = DE_UNALIGNED_16(&ib->csr15); 1878 de->media[idx].csr15 = get_unaligned(&ib->csr15);
1881 bufp += sizeof(ib->csr13) + sizeof(ib->csr14) + 1879 bufp += sizeof(ib->csr13) + sizeof(ib->csr14) +
1882 sizeof(ib->csr15); 1880 sizeof(ib->csr15);
1883 1881
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index da2206f6021d..0dcced1263b9 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/eeprom.c 2 drivers/net/tulip/eeprom.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,8 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/ 12 Please submit bug reports to http://bugzilla.kernel.org/.
14
15*/ 13*/
16 14
17#include <linux/pci.h> 15#include <linux/pci.h>
diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
index 6284afd14bbb..c6bad987d63e 100644
--- a/drivers/net/tulip/interrupt.c
+++ b/drivers/net/tulip/interrupt.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/interrupt.c 2 drivers/net/tulip/interrupt.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,8 +8,8 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/ 12 Please submit bugs to http://bugzilla.kernel.org/ .
14 13
15*/ 14*/
16 15
diff --git a/drivers/net/tulip/media.c b/drivers/net/tulip/media.c
index b56256636543..91cf9c863910 100644
--- a/drivers/net/tulip/media.c
+++ b/drivers/net/tulip/media.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/media.c 2 drivers/net/tulip/media.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,9 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 14*/
16 15
17#include <linux/kernel.h> 16#include <linux/kernel.h>
diff --git a/drivers/net/tulip/pnic.c b/drivers/net/tulip/pnic.c
index be82a2effee3..d3253ed09dfc 100644
--- a/drivers/net/tulip/pnic.c
+++ b/drivers/net/tulip/pnic.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/pnic.c 2 drivers/net/tulip/pnic.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,9 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 14*/
16 15
17#include <linux/kernel.h> 16#include <linux/kernel.h>
diff --git a/drivers/net/tulip/pnic2.c b/drivers/net/tulip/pnic2.c
index 4e4a879c3fa5..f49579128fb5 100644
--- a/drivers/net/tulip/pnic2.c
+++ b/drivers/net/tulip/pnic2.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/pnic2.c 2 drivers/net/tulip/pnic2.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 Modified to hep support PNIC_II by Kevin B. Hendricks 6 Modified to hep support PNIC_II by Kevin B. Hendricks
@@ -10,9 +9,9 @@
10 of the GNU General Public License, incorporated herein by reference. 9 of the GNU General Public License, incorporated herein by reference.
11 10
12 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
13 for more information on this driver, or visit the project 12 for more information on this driver.
14 Web page at http://sourceforge.net/projects/tulip/
15 13
14 Please submit bugs to http://bugzilla.kernel.org/ .
16*/ 15*/
17 16
18 17
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
index d2c1f42109b0..a0e084223082 100644
--- a/drivers/net/tulip/timer.c
+++ b/drivers/net/tulip/timer.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/timer.c 2 drivers/net/tulip/timer.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,11 +8,12 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 14*/
16 15
16
17#include "tulip.h" 17#include "tulip.h"
18 18
19 19
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index 92c68a22f16b..19abbc36b60a 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -8,9 +8,9 @@
8 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
9 9
10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
11 for more information on this driver, or visit the project 11 for more information on this driver.
12 Web page at http://sourceforge.net/projects/tulip/
13 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
14*/ 14*/
15 15
16#ifndef __NET_TULIP_H__ 16#ifndef __NET_TULIP_H__
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index af8d2c436efd..cafa89e60167 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1,7 +1,5 @@
1/* tulip_core.c: A DEC 21x4x-family ethernet driver for Linux. */ 1/* tulip_core.c: A DEC 21x4x-family ethernet driver for Linux.
2 2
3/*
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 3 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 4 Written/copyright 1994-2001 by Donald Becker.
7 5
@@ -9,9 +7,9 @@
9 of the GNU General Public License, incorporated herein by reference. 7 of the GNU General Public License, incorporated herein by reference.
10 8
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 9 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 10 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 11
12 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 13*/
16 14
17 15
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index c0dd25ba7a18..8549f1159a30 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -334,8 +334,6 @@ enum state_values {
334#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY) 334#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY)
335#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY) 335#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY)
336 336
337#define typhoon_synchronize_irq(x) synchronize_irq(x)
338
339#if defined(NETIF_F_TSO) 337#if defined(NETIF_F_TSO)
340#define skb_tso_size(x) (skb_shinfo(x)->gso_size) 338#define skb_tso_size(x) (skb_shinfo(x)->gso_size)
341#define TSO_NUM_DESCRIPTORS 2 339#define TSO_NUM_DESCRIPTORS 2
@@ -2143,7 +2141,6 @@ typhoon_close(struct net_device *dev)
2143 printk(KERN_ERR "%s: unable to stop runtime\n", dev->name); 2141 printk(KERN_ERR "%s: unable to stop runtime\n", dev->name);
2144 2142
2145 /* Make sure there is no irq handler running on a different CPU. */ 2143 /* Make sure there is no irq handler running on a different CPU. */
2146 typhoon_synchronize_irq(dev->irq);
2147 free_irq(dev->irq, dev); 2144 free_irq(dev->irq, dev);
2148 2145
2149 typhoon_free_rx_rings(tp); 2146 typhoon_free_rx_rings(tp);
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index ae467f182c40..61c98beb4d17 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(rndis_status);
74 * Call context is likely probe(), before interface name is known, 74 * Call context is likely probe(), before interface name is known,
75 * which is why we won't try to use it in the diagnostics. 75 * which is why we won't try to use it in the diagnostics.
76 */ 76 */
77int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf) 77int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
78{ 78{
79 struct cdc_state *info = (void *) &dev->data; 79 struct cdc_state *info = (void *) &dev->data;
80 int master_ifnum; 80 int master_ifnum;
@@ -121,7 +121,7 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
121 USB_CDC_GET_ENCAPSULATED_RESPONSE, 121 USB_CDC_GET_ENCAPSULATED_RESPONSE,
122 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 122 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
123 0, master_ifnum, 123 0, master_ifnum,
124 buf, CONTROL_BUFFER_SIZE, 124 buf, buflen,
125 RNDIS_CONTROL_TIMEOUT_MS); 125 RNDIS_CONTROL_TIMEOUT_MS);
126 if (likely(retval >= 8)) { 126 if (likely(retval >= 8)) {
127 msg_len = le32_to_cpu(buf->msg_len); 127 msg_len = le32_to_cpu(buf->msg_len);
@@ -239,7 +239,7 @@ static int rndis_query(struct usbnet *dev, struct usb_interface *intf,
239 u.get->len = cpu_to_le32(in_len); 239 u.get->len = cpu_to_le32(in_len);
240 u.get->offset = ccpu2(20); 240 u.get->offset = ccpu2(20);
241 241
242 retval = rndis_command(dev, u.header); 242 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
243 if (unlikely(retval < 0)) { 243 if (unlikely(retval < 0)) {
244 dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n", 244 dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n",
245 oid, retval); 245 oid, retval);
@@ -328,7 +328,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
328 u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size); 328 u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size);
329 329
330 net->change_mtu = NULL; 330 net->change_mtu = NULL;
331 retval = rndis_command(dev, u.header); 331 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
332 if (unlikely(retval < 0)) { 332 if (unlikely(retval < 0)) {
333 /* it might not even be an RNDIS device!! */ 333 /* it might not even be an RNDIS device!! */
334 dev_err(&intf->dev, "RNDIS init failed, %d\n", retval); 334 dev_err(&intf->dev, "RNDIS init failed, %d\n", retval);
@@ -409,7 +409,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
409 u.set->offset = ccpu2((sizeof *u.set) - 8); 409 u.set->offset = ccpu2((sizeof *u.set) - 8);
410 *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER; 410 *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER;
411 411
412 retval = rndis_command(dev, u.header); 412 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
413 if (unlikely(retval < 0)) { 413 if (unlikely(retval < 0)) {
414 dev_err(&intf->dev, "rndis set packet filter, %d\n", retval); 414 dev_err(&intf->dev, "rndis set packet filter, %d\n", retval);
415 goto halt_fail_and_release; 415 goto halt_fail_and_release;
@@ -424,7 +424,7 @@ halt_fail_and_release:
424 memset(u.halt, 0, sizeof *u.halt); 424 memset(u.halt, 0, sizeof *u.halt);
425 u.halt->msg_type = RNDIS_MSG_HALT; 425 u.halt->msg_type = RNDIS_MSG_HALT;
426 u.halt->msg_len = ccpu2(sizeof *u.halt); 426 u.halt->msg_len = ccpu2(sizeof *u.halt);
427 (void) rndis_command(dev, (void *)u.halt); 427 (void) rndis_command(dev, (void *)u.halt, CONTROL_BUFFER_SIZE);
428fail_and_release: 428fail_and_release:
429 usb_set_intfdata(info->data, NULL); 429 usb_set_intfdata(info->data, NULL);
430 usb_driver_release_interface(driver_of(intf), info->data); 430 usb_driver_release_interface(driver_of(intf), info->data);
@@ -449,7 +449,7 @@ void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
449 if (halt) { 449 if (halt) {
450 halt->msg_type = RNDIS_MSG_HALT; 450 halt->msg_type = RNDIS_MSG_HALT;
451 halt->msg_len = ccpu2(sizeof *halt); 451 halt->msg_len = ccpu2(sizeof *halt);
452 (void) rndis_command(dev, (void *)halt); 452 (void) rndis_command(dev, (void *)halt, CONTROL_BUFFER_SIZE);
453 kfree(halt); 453 kfree(halt);
454 } 454 }
455 455
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index a36d2c85e26e..f001f2afd05e 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -448,7 +448,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
448 u.get->msg_len = ccpu2(sizeof *u.get); 448 u.get->msg_len = ccpu2(sizeof *u.get);
449 u.get->oid = oid; 449 u.get->oid = oid;
450 450
451 ret = rndis_command(dev, u.header); 451 ret = rndis_command(dev, u.header, buflen);
452 if (ret == 0) { 452 if (ret == 0) {
453 ret = le32_to_cpu(u.get_c->len); 453 ret = le32_to_cpu(u.get_c->len);
454 *len = (*len > ret) ? ret : *len; 454 *len = (*len > ret) ? ret : *len;
@@ -498,7 +498,7 @@ static int rndis_set_oid(struct usbnet *dev, __le32 oid, void *data, int len)
498 u.set->handle = ccpu2(0); 498 u.set->handle = ccpu2(0);
499 memcpy(u.buf + sizeof(*u.set), data, len); 499 memcpy(u.buf + sizeof(*u.set), data, len);
500 500
501 ret = rndis_command(dev, u.header); 501 ret = rndis_command(dev, u.header, buflen);
502 if (ret == 0) 502 if (ret == 0)
503 ret = rndis_error_status(u.set_c->status); 503 ret = rndis_error_status(u.set_c->status);
504 504
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 9d6fc8e6285d..f7904ff2ace0 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -315,6 +315,25 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev,
315 } 315 }
316 return PCI_POWER_ERROR; 316 return PCI_POWER_ERROR;
317} 317}
318
319static int acpi_platform_enable_wakeup(struct device *dev, int is_on)
320{
321 struct acpi_device *adev;
322 int status;
323
324 if (!device_can_wakeup(dev))
325 return -EINVAL;
326
327 if (is_on && !device_may_wakeup(dev))
328 return -EINVAL;
329
330 status = acpi_bus_get_device(DEVICE_ACPI_HANDLE(dev), &adev);
331 if (status < 0)
332 return status;
333
334 adev->wakeup.state.enabled = !!is_on;
335 return 0;
336}
318#endif 337#endif
319 338
320static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) 339static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
@@ -399,6 +418,7 @@ static int __init acpi_pci_init(void)
399 return 0; 418 return 0;
400#ifdef CONFIG_ACPI_SLEEP 419#ifdef CONFIG_ACPI_SLEEP
401 platform_pci_choose_state = acpi_pci_choose_state; 420 platform_pci_choose_state = acpi_pci_choose_state;
421 platform_enable_wakeup = acpi_platform_enable_wakeup;
402#endif 422#endif
403 platform_pci_set_power_state = acpi_pci_set_power_state; 423 platform_pci_set_power_state = acpi_pci_set_power_state;
404 return 0; 424 return 0;
diff --git a/include/linux/dm9000.h b/include/linux/dm9000.h
index a3750462f9e3..fc82446b6425 100644
--- a/include/linux/dm9000.h
+++ b/include/linux/dm9000.h
@@ -21,6 +21,7 @@
21#define DM9000_PLATF_32BITONLY (0x0004) 21#define DM9000_PLATF_32BITONLY (0x0004)
22#define DM9000_PLATF_EXT_PHY (0x0008) 22#define DM9000_PLATF_EXT_PHY (0x0008)
23#define DM9000_PLATF_NO_EEPROM (0x0010) 23#define DM9000_PLATF_NO_EEPROM (0x0010)
24#define DM9000_PLATF_SIMPLE_PHY (0x0020) /* Use NSR to find LinkStatus */
24 25
25/* platfrom data for platfrom device structure's platfrom_data field */ 26/* platfrom data for platfrom device structure's platfrom_data field */
26 27
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index 29d6458ecb8d..0a6e6d4b929a 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -260,7 +260,8 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */
260 260
261 261
262extern void rndis_status(struct usbnet *dev, struct urb *urb); 262extern void rndis_status(struct usbnet *dev, struct urb *urb);
263extern int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf); 263extern int
264rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
264extern int 265extern int
265generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); 266generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
266extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); 267extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);