aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2006-01-03 02:18:01 -0500
committerDave Airlie <airlied@linux.ie>2006-01-03 02:18:01 -0500
commit97f2aab6698f3ab2552c41c1024a65ffd0763a6d (patch)
treebb6e3b2949459f54f884c710fc74d40eef00d834 /drivers/net
parentd985c1088146607532093d9eaaaf99758f6a4d21 (diff)
parent88026842b0a760145aa71d69e74fbc9ec118ca44 (diff)
drm: merge in Linus mainline
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/3c509.c13
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/au1000_eth.c1
-rw-r--r--drivers/net/b44.c13
-rw-r--r--drivers/net/bnx2.c16
-rw-r--r--drivers/net/depca.c26
-rw-r--r--drivers/net/dgrs.c2
-rw-r--r--drivers/net/dm9000.c35
-rw-r--r--drivers/net/e100.c275
-rw-r--r--drivers/net/e1000/e1000_main.c14
-rw-r--r--drivers/net/fec_8xx/Kconfig2
-rw-r--r--drivers/net/forcedeth.c244
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c1
-rw-r--r--drivers/net/fs_enet/mac-fcc.c1
-rw-r--r--drivers/net/fs_enet/mac-fec.c1
-rw-r--r--drivers/net/fs_enet/mac-scc.c1
-rw-r--r--drivers/net/gianfar.c30
-rw-r--r--drivers/net/gianfar.h2
-rw-r--r--drivers/net/gianfar_ethtool.c2
-rw-r--r--drivers/net/gianfar_mii.c4
-rw-r--r--drivers/net/gianfar_mii.h2
-rw-r--r--drivers/net/gt96100eth.c10
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c38
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.h2
-rw-r--r--drivers/net/ibmveth.c2
-rw-r--r--drivers/net/ioc3-eth.c2
-rw-r--r--drivers/net/irda/ali-ircc.c1
-rw-r--r--drivers/net/irda/nsc-ircc.c1
-rw-r--r--drivers/net/irda/sa1100_ir.c28
-rw-r--r--drivers/net/irda/smsc-ircc2.c27
-rw-r--r--drivers/net/jazzsonic.c25
-rw-r--r--drivers/net/macsonic.c21
-rw-r--r--drivers/net/mipsnet.h30
-rw-r--r--drivers/net/mv643xx_eth.c40
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c32
-rw-r--r--drivers/net/pcnet32.c5
-rw-r--r--drivers/net/phy/phy_device.c4
-rw-r--r--drivers/net/ppp_generic.c3
-rw-r--r--drivers/net/r8169.c6
-rw-r--r--drivers/net/s2io.c10
-rw-r--r--drivers/net/saa9730.c613
-rw-r--r--drivers/net/saa9730.h36
-rw-r--r--drivers/net/sk98lin/Makefile5
-rw-r--r--drivers/net/sk98lin/h/skdrv2nd.h4
-rw-r--r--drivers/net/sk98lin/skcsum.c871
-rw-r--r--drivers/net/sk98lin/skethtool.c2
-rw-r--r--drivers/net/sk98lin/skge.c174
-rw-r--r--drivers/net/skge.c14
-rw-r--r--drivers/net/smc91x.c55
-rw-r--r--drivers/net/smc91x.h48
-rw-r--r--drivers/net/spider_net.c1
-rw-r--r--drivers/net/sungem.c6
-rw-r--r--drivers/net/tg3.c266
-rw-r--r--drivers/net/tg3.h14
-rw-r--r--drivers/net/tokenring/proteon.c17
-rw-r--r--drivers/net/tokenring/skisa.c17
-rw-r--r--drivers/net/wan/hdlc_cisco.c6
-rw-r--r--drivers/net/wan/hdlc_fr.c4
-rw-r--r--drivers/net/wan/hdlc_generic.c6
-rw-r--r--drivers/net/wan/sdladrv.c2
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/airo.c4
-rw-r--r--drivers/net/wireless/atmel.c88
-rw-r--r--drivers/net/wireless/atmel.h4
-rw-r--r--drivers/net/wireless/atmel_cs.c176
-rw-r--r--drivers/net/wireless/atmel_pci.c2
-rw-r--r--drivers/net/wireless/hermes.c6
-rw-r--r--drivers/net/wireless/hermes.h6
-rw-r--r--drivers/net/wireless/i82593.h11
-rw-r--r--drivers/net/wireless/ipw2100.c29
-rw-r--r--drivers/net/wireless/ipw2100.h2
-rw-r--r--drivers/net/wireless/ipw2200.c7
-rw-r--r--drivers/net/wireless/orinoco.c3
-rw-r--r--drivers/net/wireless/orinoco_nortel.c6
-rw-r--r--drivers/net/wireless/prism54/isl_38xx.c4
75 files changed, 1427 insertions, 2058 deletions
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index 977935a3d898..824e430486c2 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -84,6 +84,7 @@ static int max_interrupt_work = 10;
84#include <linux/netdevice.h> 84#include <linux/netdevice.h>
85#include <linux/etherdevice.h> 85#include <linux/etherdevice.h>
86#include <linux/pm.h> 86#include <linux/pm.h>
87#include <linux/pm_legacy.h>
87#include <linux/skbuff.h> 88#include <linux/skbuff.h>
88#include <linux/delay.h> /* for udelay() */ 89#include <linux/delay.h> /* for udelay() */
89#include <linux/spinlock.h> 90#include <linux/spinlock.h>
@@ -173,7 +174,7 @@ struct el3_private {
173 /* skb send-queue */ 174 /* skb send-queue */
174 int head, size; 175 int head, size;
175 struct sk_buff *queue[SKB_QUEUE_SIZE]; 176 struct sk_buff *queue[SKB_QUEUE_SIZE];
176#ifdef CONFIG_PM 177#ifdef CONFIG_PM_LEGACY
177 struct pm_dev *pmdev; 178 struct pm_dev *pmdev;
178#endif 179#endif
179 enum { 180 enum {
@@ -200,7 +201,7 @@ static void el3_tx_timeout (struct net_device *dev);
200static void el3_down(struct net_device *dev); 201static void el3_down(struct net_device *dev);
201static void el3_up(struct net_device *dev); 202static void el3_up(struct net_device *dev);
202static struct ethtool_ops ethtool_ops; 203static struct ethtool_ops ethtool_ops;
203#ifdef CONFIG_PM 204#ifdef CONFIG_PM_LEGACY
204static int el3_suspend(struct pm_dev *pdev); 205static int el3_suspend(struct pm_dev *pdev);
205static int el3_resume(struct pm_dev *pdev); 206static int el3_resume(struct pm_dev *pdev);
206static int el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data); 207static int el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data);
@@ -361,7 +362,7 @@ static void el3_common_remove (struct net_device *dev)
361 struct el3_private *lp = netdev_priv(dev); 362 struct el3_private *lp = netdev_priv(dev);
362 363
363 (void) lp; /* Keep gcc quiet... */ 364 (void) lp; /* Keep gcc quiet... */
364#ifdef CONFIG_PM 365#ifdef CONFIG_PM_LEGACY
365 if (lp->pmdev) 366 if (lp->pmdev)
366 pm_unregister(lp->pmdev); 367 pm_unregister(lp->pmdev);
367#endif 368#endif
@@ -571,7 +572,7 @@ no_pnp:
571 if (err) 572 if (err)
572 goto out1; 573 goto out1;
573 574
574#ifdef CONFIG_PM 575#ifdef CONFIG_PM_LEGACY
575 /* register power management */ 576 /* register power management */
576 lp->pmdev = pm_register(PM_ISA_DEV, card_idx, el3_pm_callback); 577 lp->pmdev = pm_register(PM_ISA_DEV, card_idx, el3_pm_callback);
577 if (lp->pmdev) { 578 if (lp->pmdev) {
@@ -1479,7 +1480,7 @@ el3_up(struct net_device *dev)
1479} 1480}
1480 1481
1481/* Power Management support functions */ 1482/* Power Management support functions */
1482#ifdef CONFIG_PM 1483#ifdef CONFIG_PM_LEGACY
1483 1484
1484static int 1485static int
1485el3_suspend(struct pm_dev *pdev) 1486el3_suspend(struct pm_dev *pdev)
@@ -1548,7 +1549,7 @@ el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data)
1548 return 0; 1549 return 0;
1549} 1550}
1550 1551
1551#endif /* CONFIG_PM */ 1552#endif /* CONFIG_PM_LEGACY */
1552 1553
1553/* Parameters that may be passed into the module. */ 1554/* Parameters that may be passed into the module. */
1554static int debug = -1; 1555static int debug = -1;
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 5c69d57f8548..ebd7313d7fc1 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -812,7 +812,7 @@ config SMC91X
812 tristate "SMC 91C9x/91C1xxx support" 812 tristate "SMC 91C9x/91C1xxx support"
813 select CRC32 813 select CRC32
814 select MII 814 select MII
815 depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH) 815 depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00)
816 help 816 help
817 This is a driver for SMC's 91x series of Ethernet chipsets, 817 This is a driver for SMC's 91x series of Ethernet chipsets,
818 including the SMC91C94 and the SMC91C111. Say Y if you want it 818 including the SMC91C94 and the SMC91C111. Say Y if you want it
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 332e9953c55c..cd0b1dccfb61 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -32,6 +32,7 @@
32 * 32 *
33 */ 33 */
34 34
35#include <linux/config.h>
35#include <linux/module.h> 36#include <linux/module.h>
36#include <linux/kernel.h> 37#include <linux/kernel.h>
37#include <linux/sched.h> 38#include <linux/sched.h>
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index c53848f787eb..7aa49b974dc5 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -28,8 +28,8 @@
28 28
29#define DRV_MODULE_NAME "b44" 29#define DRV_MODULE_NAME "b44"
30#define PFX DRV_MODULE_NAME ": " 30#define PFX DRV_MODULE_NAME ": "
31#define DRV_MODULE_VERSION "0.96" 31#define DRV_MODULE_VERSION "0.97"
32#define DRV_MODULE_RELDATE "Nov 8, 2005" 32#define DRV_MODULE_RELDATE "Nov 30, 2005"
33 33
34#define B44_DEF_MSG_ENABLE \ 34#define B44_DEF_MSG_ENABLE \
35 (NETIF_MSG_DRV | \ 35 (NETIF_MSG_DRV | \
@@ -1417,6 +1417,7 @@ static int b44_open(struct net_device *dev)
1417 add_timer(&bp->timer); 1417 add_timer(&bp->timer);
1418 1418
1419 b44_enable_ints(bp); 1419 b44_enable_ints(bp);
1420 netif_start_queue(dev);
1420out: 1421out:
1421 return err; 1422 return err;
1422} 1423}
@@ -1837,12 +1838,15 @@ static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1837{ 1838{
1838 struct mii_ioctl_data *data = if_mii(ifr); 1839 struct mii_ioctl_data *data = if_mii(ifr);
1839 struct b44 *bp = netdev_priv(dev); 1840 struct b44 *bp = netdev_priv(dev);
1840 int err; 1841 int err = -EINVAL;
1842
1843 if (!netif_running(dev))
1844 goto out;
1841 1845
1842 spin_lock_irq(&bp->lock); 1846 spin_lock_irq(&bp->lock);
1843 err = generic_mii_ioctl(&bp->mii_if, data, cmd, NULL); 1847 err = generic_mii_ioctl(&bp->mii_if, data, cmd, NULL);
1844 spin_unlock_irq(&bp->lock); 1848 spin_unlock_irq(&bp->lock);
1845 1849out:
1846 return err; 1850 return err;
1847} 1851}
1848 1852
@@ -2113,6 +2117,7 @@ static int b44_resume(struct pci_dev *pdev)
2113 add_timer(&bp->timer); 2117 add_timer(&bp->timer);
2114 2118
2115 b44_enable_ints(bp); 2119 b44_enable_ints(bp);
2120 netif_wake_queue(dev);
2116 return 0; 2121 return 0;
2117} 2122}
2118 2123
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 8f464271664d..49fa1e4413fa 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2707,7 +2707,7 @@ bnx2_init_nvram(struct bnx2 *bp)
2707 2707
2708 if (j == entry_count) { 2708 if (j == entry_count) {
2709 bp->flash_info = NULL; 2709 bp->flash_info = NULL;
2710 printk(KERN_ALERT "Unknown flash/EEPROM type.\n"); 2710 printk(KERN_ALERT PFX "Unknown flash/EEPROM type.\n");
2711 rc = -ENODEV; 2711 rc = -ENODEV;
2712 } 2712 }
2713 2713
@@ -3903,6 +3903,8 @@ bnx2_test_loopback(struct bnx2 *bp)
3903 3903
3904 pkt_size = 1514; 3904 pkt_size = 1514;
3905 skb = dev_alloc_skb(pkt_size); 3905 skb = dev_alloc_skb(pkt_size);
3906 if (!skb)
3907 return -ENOMEM;
3906 packet = skb_put(skb, pkt_size); 3908 packet = skb_put(skb, pkt_size);
3907 memcpy(packet, bp->mac_addr, 6); 3909 memcpy(packet, bp->mac_addr, 6);
3908 memset(packet + 6, 0x0, 8); 3910 memset(packet + 6, 0x0, 8);
@@ -4798,11 +4800,7 @@ bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4798 struct bnx2 *bp = dev->priv; 4800 struct bnx2 *bp = dev->priv;
4799 int rc; 4801 int rc;
4800 4802
4801 if (eeprom->offset > bp->flash_info->total_size) 4803 /* parameters already validated in ethtool_get_eeprom */
4802 return -EINVAL;
4803
4804 if ((eeprom->offset + eeprom->len) > bp->flash_info->total_size)
4805 eeprom->len = bp->flash_info->total_size - eeprom->offset;
4806 4804
4807 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len); 4805 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
4808 4806
@@ -4816,11 +4814,7 @@ bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4816 struct bnx2 *bp = dev->priv; 4814 struct bnx2 *bp = dev->priv;
4817 int rc; 4815 int rc;
4818 4816
4819 if (eeprom->offset > bp->flash_info->total_size) 4817 /* parameters already validated in ethtool_set_eeprom */
4820 return -EINVAL;
4821
4822 if ((eeprom->offset + eeprom->len) > bp->flash_info->total_size)
4823 eeprom->len = bp->flash_info->total_size - eeprom->offset;
4824 4818
4825 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len); 4819 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
4826 4820
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 0d33a93df96b..03804cc38be0 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -398,13 +398,19 @@ static struct mca_driver depca_mca_driver = {
398}; 398};
399#endif 399#endif
400 400
401static int depca_isa_probe (struct device *); 401static int depca_isa_probe (struct platform_device *);
402 402
403static struct device_driver depca_isa_driver = { 403static int __devexit depca_isa_remove(struct platform_device *pdev)
404 .name = depca_string, 404{
405 .bus = &platform_bus_type, 405 return depca_device_remove(&pdev->dev);
406}
407
408static struct platform_driver depca_isa_driver = {
406 .probe = depca_isa_probe, 409 .probe = depca_isa_probe,
407 .remove = __devexit_p(depca_device_remove), 410 .remove = __devexit_p(depca_isa_remove),
411 .driver = {
412 .name = depca_string,
413 },
408}; 414};
409 415
410/* 416/*
@@ -1525,7 +1531,7 @@ static enum depca_type __init depca_shmem_probe (ulong *mem_start)
1525 return adapter; 1531 return adapter;
1526} 1532}
1527 1533
1528static int __init depca_isa_probe (struct device *device) 1534static int __init depca_isa_probe (struct platform_device *device)
1529{ 1535{
1530 struct net_device *dev; 1536 struct net_device *dev;
1531 struct depca_private *lp; 1537 struct depca_private *lp;
@@ -1533,7 +1539,7 @@ static int __init depca_isa_probe (struct device *device)
1533 enum depca_type adapter = unknown; 1539 enum depca_type adapter = unknown;
1534 int status = 0; 1540 int status = 0;
1535 1541
1536 ioaddr = (u_long) device->platform_data; 1542 ioaddr = (u_long) device->dev.platform_data;
1537 1543
1538 if ((status = depca_common_init (ioaddr, &dev))) 1544 if ((status = depca_common_init (ioaddr, &dev)))
1539 goto out; 1545 goto out;
@@ -1553,7 +1559,7 @@ static int __init depca_isa_probe (struct device *device)
1553 lp->adapter = adapter; 1559 lp->adapter = adapter;
1554 lp->mem_start = mem_start; 1560 lp->mem_start = mem_start;
1555 1561
1556 if ((status = depca_hw_init(dev, device))) 1562 if ((status = depca_hw_init(dev, &device->dev)))
1557 goto out_free; 1563 goto out_free;
1558 1564
1559 return 0; 1565 return 0;
@@ -2082,7 +2088,7 @@ static int __init depca_module_init (void)
2082#ifdef CONFIG_EISA 2088#ifdef CONFIG_EISA
2083 err |= eisa_driver_register (&depca_eisa_driver); 2089 err |= eisa_driver_register (&depca_eisa_driver);
2084#endif 2090#endif
2085 err |= driver_register (&depca_isa_driver); 2091 err |= platform_driver_register (&depca_isa_driver);
2086 depca_platform_probe (); 2092 depca_platform_probe ();
2087 2093
2088 return err; 2094 return err;
@@ -2097,7 +2103,7 @@ static void __exit depca_module_exit (void)
2097#ifdef CONFIG_EISA 2103#ifdef CONFIG_EISA
2098 eisa_driver_unregister (&depca_eisa_driver); 2104 eisa_driver_unregister (&depca_eisa_driver);
2099#endif 2105#endif
2100 driver_unregister (&depca_isa_driver); 2106 platform_driver_unregister (&depca_isa_driver);
2101 2107
2102 for (i = 0; depca_io_ports[i].iobase; i++) { 2108 for (i = 0; depca_io_ports[i].iobase; i++) {
2103 if (depca_io_ports[i].device) { 2109 if (depca_io_ports[i].device) {
diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c
index 2a290cc397ad..70b47e4c4e9c 100644
--- a/drivers/net/dgrs.c
+++ b/drivers/net/dgrs.c
@@ -1458,6 +1458,8 @@ static struct pci_driver dgrs_pci_driver = {
1458 .probe = dgrs_pci_probe, 1458 .probe = dgrs_pci_probe,
1459 .remove = __devexit_p(dgrs_pci_remove), 1459 .remove = __devexit_p(dgrs_pci_remove),
1460}; 1460};
1461#else
1462static struct pci_driver dgrs_pci_driver = {};
1461#endif 1463#endif
1462 1464
1463 1465
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index f8c9bcdab68b..24996da4c1c4 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -148,7 +148,7 @@ typedef struct board_info {
148} board_info_t; 148} board_info_t;
149 149
150/* function declaration ------------------------------------- */ 150/* function declaration ------------------------------------- */
151static int dm9000_probe(struct device *); 151static int dm9000_probe(struct platform_device *);
152static int dm9000_open(struct net_device *); 152static int dm9000_open(struct net_device *);
153static int dm9000_start_xmit(struct sk_buff *, struct net_device *); 153static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
154static int dm9000_stop(struct net_device *); 154static int dm9000_stop(struct net_device *);
@@ -378,9 +378,8 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db)
378 * Search DM9000 board, allocate space and register it 378 * Search DM9000 board, allocate space and register it
379 */ 379 */
380static int 380static int
381dm9000_probe(struct device *dev) 381dm9000_probe(struct platform_device *pdev)
382{ 382{
383 struct platform_device *pdev = to_platform_device(dev);
384 struct dm9000_plat_data *pdata = pdev->dev.platform_data; 383 struct dm9000_plat_data *pdata = pdev->dev.platform_data;
385 struct board_info *db; /* Point a board information structure */ 384 struct board_info *db; /* Point a board information structure */
386 struct net_device *ndev; 385 struct net_device *ndev;
@@ -398,7 +397,7 @@ dm9000_probe(struct device *dev)
398 } 397 }
399 398
400 SET_MODULE_OWNER(ndev); 399 SET_MODULE_OWNER(ndev);
401 SET_NETDEV_DEV(ndev, dev); 400 SET_NETDEV_DEV(ndev, &pdev->dev);
402 401
403 PRINTK2("dm9000_probe()"); 402 PRINTK2("dm9000_probe()");
404 403
@@ -569,7 +568,7 @@ dm9000_probe(struct device *dev)
569 printk("%s: Invalid ethernet MAC address. Please " 568 printk("%s: Invalid ethernet MAC address. Please "
570 "set using ifconfig\n", ndev->name); 569 "set using ifconfig\n", ndev->name);
571 570
572 dev_set_drvdata(dev, ndev); 571 platform_set_drvdata(pdev, ndev);
573 ret = register_netdev(ndev); 572 ret = register_netdev(ndev);
574 573
575 if (ret == 0) { 574 if (ret == 0) {
@@ -1140,9 +1139,9 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1140} 1139}
1141 1140
1142static int 1141static int
1143dm9000_drv_suspend(struct device *dev, pm_message_t state) 1142dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
1144{ 1143{
1145 struct net_device *ndev = dev_get_drvdata(dev); 1144 struct net_device *ndev = platform_get_drvdata(dev);
1146 1145
1147 if (ndev) { 1146 if (ndev) {
1148 if (netif_running(ndev)) { 1147 if (netif_running(ndev)) {
@@ -1154,9 +1153,9 @@ dm9000_drv_suspend(struct device *dev, pm_message_t state)
1154} 1153}
1155 1154
1156static int 1155static int
1157dm9000_drv_resume(struct device *dev) 1156dm9000_drv_resume(struct platform_device *dev)
1158{ 1157{
1159 struct net_device *ndev = dev_get_drvdata(dev); 1158 struct net_device *ndev = platform_get_drvdata(dev);
1160 board_info_t *db = (board_info_t *) ndev->priv; 1159 board_info_t *db = (board_info_t *) ndev->priv;
1161 1160
1162 if (ndev) { 1161 if (ndev) {
@@ -1172,12 +1171,11 @@ dm9000_drv_resume(struct device *dev)
1172} 1171}
1173 1172
1174static int 1173static int
1175dm9000_drv_remove(struct device *dev) 1174dm9000_drv_remove(struct platform_device *pdev)
1176{ 1175{
1177 struct platform_device *pdev = to_platform_device(dev); 1176 struct net_device *ndev = platform_get_drvdata(pdev);
1178 struct net_device *ndev = dev_get_drvdata(dev);
1179 1177
1180 dev_set_drvdata(dev, NULL); 1178 platform_set_drvdata(pdev, NULL);
1181 1179
1182 unregister_netdev(ndev); 1180 unregister_netdev(ndev);
1183 dm9000_release_board(pdev, (board_info_t *) ndev->priv); 1181 dm9000_release_board(pdev, (board_info_t *) ndev->priv);
@@ -1188,13 +1186,14 @@ dm9000_drv_remove(struct device *dev)
1188 return 0; 1186 return 0;
1189} 1187}
1190 1188
1191static struct device_driver dm9000_driver = { 1189static struct platform_driver dm9000_driver = {
1192 .name = "dm9000",
1193 .bus = &platform_bus_type,
1194 .probe = dm9000_probe, 1190 .probe = dm9000_probe,
1195 .remove = dm9000_drv_remove, 1191 .remove = dm9000_drv_remove,
1196 .suspend = dm9000_drv_suspend, 1192 .suspend = dm9000_drv_suspend,
1197 .resume = dm9000_drv_resume, 1193 .resume = dm9000_drv_resume,
1194 .driver = {
1195 .name = "dm9000",
1196 },
1198}; 1197};
1199 1198
1200static int __init 1199static int __init
@@ -1202,13 +1201,13 @@ dm9000_init(void)
1202{ 1201{
1203 printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME); 1202 printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME);
1204 1203
1205 return driver_register(&dm9000_driver); /* search board and register */ 1204 return platform_driver_register(&dm9000_driver); /* search board and register */
1206} 1205}
1207 1206
1208static void __exit 1207static void __exit
1209dm9000_cleanup(void) 1208dm9000_cleanup(void)
1210{ 1209{
1211 driver_unregister(&dm9000_driver); 1210 platform_driver_unregister(&dm9000_driver);
1212} 1211}
1213 1212
1214module_init(dm9000_init); 1213module_init(dm9000_init);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 7a6aeae2c9fa..22cd04556707 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -156,7 +156,7 @@
156 156
157#define DRV_NAME "e100" 157#define DRV_NAME "e100"
158#define DRV_EXT "-NAPI" 158#define DRV_EXT "-NAPI"
159#define DRV_VERSION "3.4.14-k2"DRV_EXT 159#define DRV_VERSION "3.4.14-k4"DRV_EXT
160#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" 160#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
161#define DRV_COPYRIGHT "Copyright(c) 1999-2005 Intel Corporation" 161#define DRV_COPYRIGHT "Copyright(c) 1999-2005 Intel Corporation"
162#define PFX DRV_NAME ": " 162#define PFX DRV_NAME ": "
@@ -903,8 +903,8 @@ static void mdio_write(struct net_device *netdev, int addr, int reg, int data)
903 903
904static void e100_get_defaults(struct nic *nic) 904static void e100_get_defaults(struct nic *nic)
905{ 905{
906 struct param_range rfds = { .min = 16, .max = 256, .count = 64 }; 906 struct param_range rfds = { .min = 16, .max = 256, .count = 256 };
907 struct param_range cbs = { .min = 64, .max = 256, .count = 64 }; 907 struct param_range cbs = { .min = 64, .max = 256, .count = 128 };
908 908
909 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id); 909 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id);
910 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */ 910 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */
@@ -1007,25 +1007,264 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1007 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]); 1007 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
1008} 1008}
1009 1009
1010/********************************************************/
1011/* Micro code for 8086:1229 Rev 8 */
1012/********************************************************/
1013
1014/* Parameter values for the D101M B-step */
1015#define D101M_CPUSAVER_TIMER_DWORD 78
1016#define D101M_CPUSAVER_BUNDLE_DWORD 65
1017#define D101M_CPUSAVER_MIN_SIZE_DWORD 126
1018
1019#define D101M_B_RCVBUNDLE_UCODE \
1020{\
10210x00550215, 0xFFFF0437, 0xFFFFFFFF, 0x06A70789, 0xFFFFFFFF, 0x0558FFFF, \
10220x000C0001, 0x00101312, 0x000C0008, 0x00380216, \
10230x0010009C, 0x00204056, 0x002380CC, 0x00380056, \
10240x0010009C, 0x00244C0B, 0x00000800, 0x00124818, \
10250x00380438, 0x00000000, 0x00140000, 0x00380555, \
10260x00308000, 0x00100662, 0x00100561, 0x000E0408, \
10270x00134861, 0x000C0002, 0x00103093, 0x00308000, \
10280x00100624, 0x00100561, 0x000E0408, 0x00100861, \
10290x000C007E, 0x00222C21, 0x000C0002, 0x00103093, \
10300x00380C7A, 0x00080000, 0x00103090, 0x00380C7A, \
10310x00000000, 0x00000000, 0x00000000, 0x00000000, \
10320x0010009C, 0x00244C2D, 0x00010004, 0x00041000, \
10330x003A0437, 0x00044010, 0x0038078A, 0x00000000, \
10340x00100099, 0x00206C7A, 0x0010009C, 0x00244C48, \
10350x00130824, 0x000C0001, 0x00101213, 0x00260C75, \
10360x00041000, 0x00010004, 0x00130826, 0x000C0006, \
10370x002206A8, 0x0013C926, 0x00101313, 0x003806A8, \
10380x00000000, 0x00000000, 0x00000000, 0x00000000, \
10390x00000000, 0x00000000, 0x00000000, 0x00000000, \
10400x00080600, 0x00101B10, 0x00050004, 0x00100826, \
10410x00101210, 0x00380C34, 0x00000000, 0x00000000, \
10420x0021155B, 0x00100099, 0x00206559, 0x0010009C, \
10430x00244559, 0x00130836, 0x000C0000, 0x00220C62, \
10440x000C0001, 0x00101B13, 0x00229C0E, 0x00210C0E, \
10450x00226C0E, 0x00216C0E, 0x0022FC0E, 0x00215C0E, \
10460x00214C0E, 0x00380555, 0x00010004, 0x00041000, \
10470x00278C67, 0x00040800, 0x00018100, 0x003A0437, \
10480x00130826, 0x000C0001, 0x00220559, 0x00101313, \
10490x00380559, 0x00000000, 0x00000000, 0x00000000, \
10500x00000000, 0x00000000, 0x00000000, 0x00000000, \
10510x00000000, 0x00130831, 0x0010090B, 0x00124813, \
10520x000CFF80, 0x002606AB, 0x00041000, 0x00010004, \
10530x003806A8, 0x00000000, 0x00000000, 0x00000000, \
1054}
1055
1056/********************************************************/
1057/* Micro code for 8086:1229 Rev 9 */
1058/********************************************************/
1059
1060/* Parameter values for the D101S */
1061#define D101S_CPUSAVER_TIMER_DWORD 78
1062#define D101S_CPUSAVER_BUNDLE_DWORD 67
1063#define D101S_CPUSAVER_MIN_SIZE_DWORD 128
1064
1065#define D101S_RCVBUNDLE_UCODE \
1066{\
10670x00550242, 0xFFFF047E, 0xFFFFFFFF, 0x06FF0818, 0xFFFFFFFF, 0x05A6FFFF, \
10680x000C0001, 0x00101312, 0x000C0008, 0x00380243, \
10690x0010009C, 0x00204056, 0x002380D0, 0x00380056, \
10700x0010009C, 0x00244F8B, 0x00000800, 0x00124818, \
10710x0038047F, 0x00000000, 0x00140000, 0x003805A3, \
10720x00308000, 0x00100610, 0x00100561, 0x000E0408, \
10730x00134861, 0x000C0002, 0x00103093, 0x00308000, \
10740x00100624, 0x00100561, 0x000E0408, 0x00100861, \
10750x000C007E, 0x00222FA1, 0x000C0002, 0x00103093, \
10760x00380F90, 0x00080000, 0x00103090, 0x00380F90, \
10770x00000000, 0x00000000, 0x00000000, 0x00000000, \
10780x0010009C, 0x00244FAD, 0x00010004, 0x00041000, \
10790x003A047E, 0x00044010, 0x00380819, 0x00000000, \
10800x00100099, 0x00206FFD, 0x0010009A, 0x0020AFFD, \
10810x0010009C, 0x00244FC8, 0x00130824, 0x000C0001, \
10820x00101213, 0x00260FF7, 0x00041000, 0x00010004, \
10830x00130826, 0x000C0006, 0x00220700, 0x0013C926, \
10840x00101313, 0x00380700, 0x00000000, 0x00000000, \
10850x00000000, 0x00000000, 0x00000000, 0x00000000, \
10860x00080600, 0x00101B10, 0x00050004, 0x00100826, \
10870x00101210, 0x00380FB6, 0x00000000, 0x00000000, \
10880x002115A9, 0x00100099, 0x002065A7, 0x0010009A, \
10890x0020A5A7, 0x0010009C, 0x002445A7, 0x00130836, \
10900x000C0000, 0x00220FE4, 0x000C0001, 0x00101B13, \
10910x00229F8E, 0x00210F8E, 0x00226F8E, 0x00216F8E, \
10920x0022FF8E, 0x00215F8E, 0x00214F8E, 0x003805A3, \
10930x00010004, 0x00041000, 0x00278FE9, 0x00040800, \
10940x00018100, 0x003A047E, 0x00130826, 0x000C0001, \
10950x002205A7, 0x00101313, 0x003805A7, 0x00000000, \
10960x00000000, 0x00000000, 0x00000000, 0x00000000, \
10970x00000000, 0x00000000, 0x00000000, 0x00130831, \
10980x0010090B, 0x00124813, 0x000CFF80, 0x00260703, \
10990x00041000, 0x00010004, 0x00380700 \
1100}
1101
1102/********************************************************/
1103/* Micro code for the 8086:1229 Rev F/10 */
1104/********************************************************/
1105
1106/* Parameter values for the D102 E-step */
1107#define D102_E_CPUSAVER_TIMER_DWORD 42
1108#define D102_E_CPUSAVER_BUNDLE_DWORD 54
1109#define D102_E_CPUSAVER_MIN_SIZE_DWORD 46
1110
1111#define D102_E_RCVBUNDLE_UCODE \
1112{\
11130x007D028F, 0x0E4204F9, 0x14ED0C85, 0x14FA14E9, 0x0EF70E36, 0x1FFF1FFF, \
11140x00E014B9, 0x00000000, 0x00000000, 0x00000000, \
11150x00E014BD, 0x00000000, 0x00000000, 0x00000000, \
11160x00E014D5, 0x00000000, 0x00000000, 0x00000000, \
11170x00000000, 0x00000000, 0x00000000, 0x00000000, \
11180x00E014C1, 0x00000000, 0x00000000, 0x00000000, \
11190x00000000, 0x00000000, 0x00000000, 0x00000000, \
11200x00000000, 0x00000000, 0x00000000, 0x00000000, \
11210x00000000, 0x00000000, 0x00000000, 0x00000000, \
11220x00E014C8, 0x00000000, 0x00000000, 0x00000000, \
11230x00200600, 0x00E014EE, 0x00000000, 0x00000000, \
11240x0030FF80, 0x00940E46, 0x00038200, 0x00102000, \
11250x00E00E43, 0x00000000, 0x00000000, 0x00000000, \
11260x00300006, 0x00E014FB, 0x00000000, 0x00000000, \
11270x00000000, 0x00000000, 0x00000000, 0x00000000, \
11280x00000000, 0x00000000, 0x00000000, 0x00000000, \
11290x00000000, 0x00000000, 0x00000000, 0x00000000, \
11300x00906E41, 0x00800E3C, 0x00E00E39, 0x00000000, \
11310x00906EFD, 0x00900EFD, 0x00E00EF8, 0x00000000, \
11320x00000000, 0x00000000, 0x00000000, 0x00000000, \
11330x00000000, 0x00000000, 0x00000000, 0x00000000, \
11340x00000000, 0x00000000, 0x00000000, 0x00000000, \
11350x00000000, 0x00000000, 0x00000000, 0x00000000, \
11360x00000000, 0x00000000, 0x00000000, 0x00000000, \
11370x00000000, 0x00000000, 0x00000000, 0x00000000, \
11380x00000000, 0x00000000, 0x00000000, 0x00000000, \
11390x00000000, 0x00000000, 0x00000000, 0x00000000, \
11400x00000000, 0x00000000, 0x00000000, 0x00000000, \
11410x00000000, 0x00000000, 0x00000000, 0x00000000, \
11420x00000000, 0x00000000, 0x00000000, 0x00000000, \
11430x00000000, 0x00000000, 0x00000000, 0x00000000, \
11440x00000000, 0x00000000, 0x00000000, 0x00000000, \
11450x00000000, 0x00000000, 0x00000000, 0x00000000, \
1146}
1147
1010static void e100_load_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb) 1148static void e100_load_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1011{ 1149{
1012 int i; 1150/* *INDENT-OFF* */
1013 static const u32 ucode[UCODE_SIZE] = { 1151 static struct {
1014 /* NFS packets are misinterpreted as TCO packets and 1152 u32 ucode[UCODE_SIZE + 1];
1015 * incorrectly routed to the BMC over SMBus. This 1153 u8 mac;
1016 * microcode patch checks the fragmented IP bit in the 1154 u8 timer_dword;
1017 * NFS/UDP header to distinguish between NFS and TCO. */ 1155 u8 bundle_dword;
1018 0x0EF70E36, 0x1FFF1FFF, 0x1FFF1FFF, 0x1FFF1FFF, 0x1FFF1FFF, 1156 u8 min_size_dword;
1019 0x1FFF1FFF, 0x00906E41, 0x00800E3C, 0x00E00E39, 0x00000000, 1157 } ucode_opts[] = {
1020 0x00906EFD, 0x00900EFD, 0x00E00EF8, 1158 { D101M_B_RCVBUNDLE_UCODE,
1021 }; 1159 mac_82559_D101M,
1022 1160 D101M_CPUSAVER_TIMER_DWORD,
1023 if(nic->mac == mac_82551_F || nic->mac == mac_82551_10) { 1161 D101M_CPUSAVER_BUNDLE_DWORD,
1024 for(i = 0; i < UCODE_SIZE; i++) 1162 D101M_CPUSAVER_MIN_SIZE_DWORD },
1163 { D101S_RCVBUNDLE_UCODE,
1164 mac_82559_D101S,
1165 D101S_CPUSAVER_TIMER_DWORD,
1166 D101S_CPUSAVER_BUNDLE_DWORD,
1167 D101S_CPUSAVER_MIN_SIZE_DWORD },
1168 { D102_E_RCVBUNDLE_UCODE,
1169 mac_82551_F,
1170 D102_E_CPUSAVER_TIMER_DWORD,
1171 D102_E_CPUSAVER_BUNDLE_DWORD,
1172 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1173 { D102_E_RCVBUNDLE_UCODE,
1174 mac_82551_10,
1175 D102_E_CPUSAVER_TIMER_DWORD,
1176 D102_E_CPUSAVER_BUNDLE_DWORD,
1177 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1178 { {0}, 0, 0, 0, 0}
1179 }, *opts;
1180/* *INDENT-ON* */
1181
1182/*************************************************************************
1183* CPUSaver parameters
1184*
1185* All CPUSaver parameters are 16-bit literals that are part of a
1186* "move immediate value" instruction. By changing the value of
1187* the literal in the instruction before the code is loaded, the
1188* driver can change the algorithm.
1189*
1190* INTDELAY - This loads the dead-man timer with its inital value.
1191* When this timer expires the interrupt is asserted, and the
1192* timer is reset each time a new packet is received. (see
1193* BUNDLEMAX below to set the limit on number of chained packets)
1194* The current default is 0x600 or 1536. Experiments show that
1195* the value should probably stay within the 0x200 - 0x1000.
1196*
1197* BUNDLEMAX -
1198* This sets the maximum number of frames that will be bundled. In
1199* some situations, such as the TCP windowing algorithm, it may be
1200* better to limit the growth of the bundle size than let it go as
1201* high as it can, because that could cause too much added latency.
1202* The default is six, because this is the number of packets in the
1203* default TCP window size. A value of 1 would make CPUSaver indicate
1204* an interrupt for every frame received. If you do not want to put
1205* a limit on the bundle size, set this value to xFFFF.
1206*
1207* BUNDLESMALL -
1208* This contains a bit-mask describing the minimum size frame that
1209* will be bundled. The default masks the lower 7 bits, which means
1210* that any frame less than 128 bytes in length will not be bundled,
1211* but will instead immediately generate an interrupt. This does
1212* not affect the current bundle in any way. Any frame that is 128
1213* bytes or large will be bundled normally. This feature is meant
1214* to provide immediate indication of ACK frames in a TCP environment.
1215* Customers were seeing poor performance when a machine with CPUSaver
1216* enabled was sending but not receiving. The delay introduced when
1217* the ACKs were received was enough to reduce total throughput, because
1218* the sender would sit idle until the ACK was finally seen.
1219*
1220* The current default is 0xFF80, which masks out the lower 7 bits.
1221* This means that any frame which is x7F (127) bytes or smaller
1222* will cause an immediate interrupt. Because this value must be a
1223* bit mask, there are only a few valid values that can be used. To
1224* turn this feature off, the driver can write the value xFFFF to the
1225* lower word of this instruction (in the same way that the other
1226* parameters are used). Likewise, a value of 0xF800 (2047) would
1227* cause an interrupt to be generated for every frame, because all
1228* standard Ethernet frames are <= 2047 bytes in length.
1229*************************************************************************/
1230
1231/* if you wish to disable the ucode functionality, while maintaining the
1232 * workarounds it provides, set the following defines to:
1233 * BUNDLESMALL 0
1234 * BUNDLEMAX 1
1235 * INTDELAY 1
1236 */
1237#define BUNDLESMALL 1
1238#define BUNDLEMAX (u16)6
1239#define INTDELAY (u16)1536 /* 0x600 */
1240
1241 /* do not load u-code for ICH devices */
1242 if (nic->flags & ich)
1243 goto noloaducode;
1244
1245 /* Search for ucode match against h/w rev_id */
1246 for (opts = ucode_opts; opts->mac; opts++) {
1247 int i;
1248 u32 *ucode = opts->ucode;
1249 if (nic->mac != opts->mac)
1250 continue;
1251
1252 /* Insert user-tunable settings */
1253 ucode[opts->timer_dword] &= 0xFFFF0000;
1254 ucode[opts->timer_dword] |= INTDELAY;
1255 ucode[opts->bundle_dword] &= 0xFFFF0000;
1256 ucode[opts->bundle_dword] |= BUNDLEMAX;
1257 ucode[opts->min_size_dword] &= 0xFFFF0000;
1258 ucode[opts->min_size_dword] |= (BUNDLESMALL) ? 0xFFFF : 0xFF80;
1259
1260 for (i = 0; i < UCODE_SIZE; i++)
1025 cb->u.ucode[i] = cpu_to_le32(ucode[i]); 1261 cb->u.ucode[i] = cpu_to_le32(ucode[i]);
1026 cb->command = cpu_to_le16(cb_ucode); 1262 cb->command = cpu_to_le16(cb_ucode);
1027 } else 1263 return;
1028 cb->command = cpu_to_le16(cb_nop); 1264 }
1265
1266noloaducode:
1267 cb->command = cpu_to_le16(cb_nop);
1029} 1268}
1030 1269
1031static void e100_setup_iaaddr(struct nic *nic, struct cb *cb, 1270static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 8b207f0e139e..e0ae248b4313 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2621,19 +2621,7 @@ e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
2621 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) 2621 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
2622 return 0; 2622 return 0;
2623 } 2623 }
2624 if(htons(ETH_P_IP) == skb->protocol) { 2624 if ((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
2625 const struct iphdr *ip = skb->nh.iph;
2626 if(IPPROTO_UDP == ip->protocol) {
2627 struct udphdr *udp = (struct udphdr *)(skb->h.uh);
2628 if(ntohs(udp->dest) == 67) {
2629 offset = (uint8_t *)udp + 8 - skb->data;
2630 length = skb->len - offset;
2631
2632 return e1000_mng_write_dhcp_info(hw,
2633 (uint8_t *)udp + 8, length);
2634 }
2635 }
2636 } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
2637 struct ethhdr *eth = (struct ethhdr *) skb->data; 2625 struct ethhdr *eth = (struct ethhdr *) skb->data;
2638 if((htons(ETH_P_IP) == eth->h_proto)) { 2626 if((htons(ETH_P_IP) == eth->h_proto)) {
2639 const struct iphdr *ip = 2627 const struct iphdr *ip =
diff --git a/drivers/net/fec_8xx/Kconfig b/drivers/net/fec_8xx/Kconfig
index 94e7a9af8705..a84c232395e3 100644
--- a/drivers/net/fec_8xx/Kconfig
+++ b/drivers/net/fec_8xx/Kconfig
@@ -1,6 +1,6 @@
1config FEC_8XX 1config FEC_8XX
2 tristate "Motorola 8xx FEC driver" 2 tristate "Motorola 8xx FEC driver"
3 depends on NET_ETHERNET && FEC 3 depends on NET_ETHERNET && 8xx
4 select MII 4 select MII
5 5
6config FEC_8XX_GENERIC_PHY 6config FEC_8XX_GENERIC_PHY
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 22aec6ed80f5..c39344adecce 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -10,7 +10,7 @@
10 * trademarks of NVIDIA Corporation in the United States and other 10 * trademarks of NVIDIA Corporation in the United States and other
11 * countries. 11 * countries.
12 * 12 *
13 * Copyright (C) 2003,4 Manfred Spraul 13 * Copyright (C) 2003,4,5 Manfred Spraul
14 * Copyright (C) 2004 Andrew de Quincey (wol support) 14 * Copyright (C) 2004 Andrew de Quincey (wol support)
15 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane 15 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane
16 * IRQ rate fixes, bigendian fixes, cleanups, verification) 16 * IRQ rate fixes, bigendian fixes, cleanups, verification)
@@ -80,7 +80,7 @@
80 * into nv_close, otherwise reenabling for wol can 80 * into nv_close, otherwise reenabling for wol can
81 * cause DMA to kfree'd memory. 81 * cause DMA to kfree'd memory.
82 * 0.31: 14 Nov 2004: ethtool support for getting/setting link 82 * 0.31: 14 Nov 2004: ethtool support for getting/setting link
83 * capabilities. 83 * capabilities.
84 * 0.32: 16 Apr 2005: RX_ERROR4 handling added. 84 * 0.32: 16 Apr 2005: RX_ERROR4 handling added.
85 * 0.33: 16 May 2005: Support for MCP51 added. 85 * 0.33: 16 May 2005: Support for MCP51 added.
86 * 0.34: 18 Jun 2005: Add DEV_NEED_LINKTIMER to all nForce nics. 86 * 0.34: 18 Jun 2005: Add DEV_NEED_LINKTIMER to all nForce nics.
@@ -89,14 +89,18 @@
89 * 0.37: 10 Jul 2005: Additional ethtool support, cleanup of pci id list 89 * 0.37: 10 Jul 2005: Additional ethtool support, cleanup of pci id list
90 * 0.38: 16 Jul 2005: tx irq rewrite: Use global flags instead of 90 * 0.38: 16 Jul 2005: tx irq rewrite: Use global flags instead of
91 * per-packet flags. 91 * per-packet flags.
92 * 0.39: 18 Jul 2005: Add 64bit descriptor support. 92 * 0.39: 18 Jul 2005: Add 64bit descriptor support.
93 * 0.40: 19 Jul 2005: Add support for mac address change. 93 * 0.40: 19 Jul 2005: Add support for mac address change.
94 * 0.41: 30 Jul 2005: Write back original MAC in nv_close instead 94 * 0.41: 30 Jul 2005: Write back original MAC in nv_close instead
95 * of nv_remove 95 * of nv_remove
96 * 0.42: 06 Aug 2005: Fix lack of link speed initialization 96 * 0.42: 06 Aug 2005: Fix lack of link speed initialization
97 * in the second (and later) nv_open call 97 * in the second (and later) nv_open call
98 * 0.43: 10 Aug 2005: Add support for tx checksum. 98 * 0.43: 10 Aug 2005: Add support for tx checksum.
99 * 0.44: 20 Aug 2005: Add support for scatter gather and segmentation. 99 * 0.44: 20 Aug 2005: Add support for scatter gather and segmentation.
100 * 0.45: 18 Sep 2005: Remove nv_stop/start_rx from every link check
101 * 0.46: 20 Oct 2005: Add irq optimization modes.
102 * 0.47: 26 Oct 2005: Add phyaddr 0 in phy scan.
103 * 0.48: 24 Dec 2005: Disable TSO, bugfix for pci_map_single
100 * 104 *
101 * Known bugs: 105 * Known bugs:
102 * We suspect that on some hardware no TX done interrupts are generated. 106 * We suspect that on some hardware no TX done interrupts are generated.
@@ -108,7 +112,7 @@
108 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 112 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
109 * superfluous timer interrupts from the nic. 113 * superfluous timer interrupts from the nic.
110 */ 114 */
111#define FORCEDETH_VERSION "0.44" 115#define FORCEDETH_VERSION "0.48"
112#define DRV_NAME "forcedeth" 116#define DRV_NAME "forcedeth"
113 117
114#include <linux/module.h> 118#include <linux/module.h>
@@ -163,7 +167,8 @@ enum {
163#define NVREG_IRQ_LINK 0x0040 167#define NVREG_IRQ_LINK 0x0040
164#define NVREG_IRQ_TX_ERROR 0x0080 168#define NVREG_IRQ_TX_ERROR 0x0080
165#define NVREG_IRQ_TX1 0x0100 169#define NVREG_IRQ_TX1 0x0100
166#define NVREG_IRQMASK_WANTED 0x00df 170#define NVREG_IRQMASK_THROUGHPUT 0x00df
171#define NVREG_IRQMASK_CPU 0x0040
167 172
168#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \ 173#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \
169 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX_ERROR| \ 174 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX_ERROR| \
@@ -177,7 +182,8 @@ enum {
177 * NVREG_POLL_DEFAULT=97 would result in an interval length of 1 ms 182 * NVREG_POLL_DEFAULT=97 would result in an interval length of 1 ms
178 */ 183 */
179 NvRegPollingInterval = 0x00c, 184 NvRegPollingInterval = 0x00c,
180#define NVREG_POLL_DEFAULT 970 185#define NVREG_POLL_DEFAULT_THROUGHPUT 970
186#define NVREG_POLL_DEFAULT_CPU 13
181 NvRegMisc1 = 0x080, 187 NvRegMisc1 = 0x080,
182#define NVREG_MISC1_HD 0x02 188#define NVREG_MISC1_HD 0x02
183#define NVREG_MISC1_FORCE 0x3b0f3c 189#define NVREG_MISC1_FORCE 0x3b0f3c
@@ -538,6 +544,25 @@ struct fe_priv {
538 */ 544 */
539static int max_interrupt_work = 5; 545static int max_interrupt_work = 5;
540 546
547/*
548 * Optimization can be either throuput mode or cpu mode
549 *
550 * Throughput Mode: Every tx and rx packet will generate an interrupt.
551 * CPU Mode: Interrupts are controlled by a timer.
552 */
553#define NV_OPTIMIZATION_MODE_THROUGHPUT 0
554#define NV_OPTIMIZATION_MODE_CPU 1
555static int optimization_mode = NV_OPTIMIZATION_MODE_THROUGHPUT;
556
557/*
558 * Poll interval for timer irq
559 *
560 * This interval determines how frequent an interrupt is generated.
561 * The is value is determined by [(time_in_micro_secs * 100) / (2^10)]
562 * Min = 0, and Max = 65535
563 */
564static int poll_interval = -1;
565
541static inline struct fe_priv *get_nvpriv(struct net_device *dev) 566static inline struct fe_priv *get_nvpriv(struct net_device *dev)
542{ 567{
543 return netdev_priv(dev); 568 return netdev_priv(dev);
@@ -847,8 +872,8 @@ static int nv_alloc_rx(struct net_device *dev)
847 } else { 872 } else {
848 skb = np->rx_skbuff[nr]; 873 skb = np->rx_skbuff[nr];
849 } 874 }
850 np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len, 875 np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data,
851 PCI_DMA_FROMDEVICE); 876 skb->end-skb->data, PCI_DMA_FROMDEVICE);
852 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) { 877 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
853 np->rx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]); 878 np->rx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]);
854 wmb(); 879 wmb();
@@ -975,7 +1000,7 @@ static void nv_drain_rx(struct net_device *dev)
975 wmb(); 1000 wmb();
976 if (np->rx_skbuff[i]) { 1001 if (np->rx_skbuff[i]) {
977 pci_unmap_single(np->pci_dev, np->rx_dma[i], 1002 pci_unmap_single(np->pci_dev, np->rx_dma[i],
978 np->rx_skbuff[i]->len, 1003 np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
979 PCI_DMA_FROMDEVICE); 1004 PCI_DMA_FROMDEVICE);
980 dev_kfree_skb(np->rx_skbuff[i]); 1005 dev_kfree_skb(np->rx_skbuff[i]);
981 np->rx_skbuff[i] = NULL; 1006 np->rx_skbuff[i] = NULL;
@@ -1310,7 +1335,7 @@ static void nv_rx_process(struct net_device *dev)
1310 * the performance. 1335 * the performance.
1311 */ 1336 */
1312 pci_unmap_single(np->pci_dev, np->rx_dma[i], 1337 pci_unmap_single(np->pci_dev, np->rx_dma[i],
1313 np->rx_skbuff[i]->len, 1338 np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
1314 PCI_DMA_FROMDEVICE); 1339 PCI_DMA_FROMDEVICE);
1315 1340
1316 { 1341 {
@@ -1328,67 +1353,71 @@ static void nv_rx_process(struct net_device *dev)
1328 if (!(Flags & NV_RX_DESCRIPTORVALID)) 1353 if (!(Flags & NV_RX_DESCRIPTORVALID))
1329 goto next_pkt; 1354 goto next_pkt;
1330 1355
1331 if (Flags & NV_RX_MISSEDFRAME) { 1356 if (Flags & NV_RX_ERROR) {
1332 np->stats.rx_missed_errors++; 1357 if (Flags & NV_RX_MISSEDFRAME) {
1333 np->stats.rx_errors++; 1358 np->stats.rx_missed_errors++;
1334 goto next_pkt;
1335 }
1336 if (Flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
1337 np->stats.rx_errors++;
1338 goto next_pkt;
1339 }
1340 if (Flags & NV_RX_CRCERR) {
1341 np->stats.rx_crc_errors++;
1342 np->stats.rx_errors++;
1343 goto next_pkt;
1344 }
1345 if (Flags & NV_RX_OVERFLOW) {
1346 np->stats.rx_over_errors++;
1347 np->stats.rx_errors++;
1348 goto next_pkt;
1349 }
1350 if (Flags & NV_RX_ERROR4) {
1351 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1352 if (len < 0) {
1353 np->stats.rx_errors++; 1359 np->stats.rx_errors++;
1354 goto next_pkt; 1360 goto next_pkt;
1355 } 1361 }
1356 } 1362 if (Flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
1357 /* framing errors are soft errors. */ 1363 np->stats.rx_errors++;
1358 if (Flags & NV_RX_FRAMINGERR) { 1364 goto next_pkt;
1359 if (Flags & NV_RX_SUBSTRACT1) { 1365 }
1360 len--; 1366 if (Flags & NV_RX_CRCERR) {
1367 np->stats.rx_crc_errors++;
1368 np->stats.rx_errors++;
1369 goto next_pkt;
1370 }
1371 if (Flags & NV_RX_OVERFLOW) {
1372 np->stats.rx_over_errors++;
1373 np->stats.rx_errors++;
1374 goto next_pkt;
1375 }
1376 if (Flags & NV_RX_ERROR4) {
1377 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1378 if (len < 0) {
1379 np->stats.rx_errors++;
1380 goto next_pkt;
1381 }
1382 }
1383 /* framing errors are soft errors. */
1384 if (Flags & NV_RX_FRAMINGERR) {
1385 if (Flags & NV_RX_SUBSTRACT1) {
1386 len--;
1387 }
1361 } 1388 }
1362 } 1389 }
1363 } else { 1390 } else {
1364 if (!(Flags & NV_RX2_DESCRIPTORVALID)) 1391 if (!(Flags & NV_RX2_DESCRIPTORVALID))
1365 goto next_pkt; 1392 goto next_pkt;
1366 1393
1367 if (Flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) { 1394 if (Flags & NV_RX2_ERROR) {
1368 np->stats.rx_errors++; 1395 if (Flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) {
1369 goto next_pkt;
1370 }
1371 if (Flags & NV_RX2_CRCERR) {
1372 np->stats.rx_crc_errors++;
1373 np->stats.rx_errors++;
1374 goto next_pkt;
1375 }
1376 if (Flags & NV_RX2_OVERFLOW) {
1377 np->stats.rx_over_errors++;
1378 np->stats.rx_errors++;
1379 goto next_pkt;
1380 }
1381 if (Flags & NV_RX2_ERROR4) {
1382 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1383 if (len < 0) {
1384 np->stats.rx_errors++; 1396 np->stats.rx_errors++;
1385 goto next_pkt; 1397 goto next_pkt;
1386 } 1398 }
1387 } 1399 if (Flags & NV_RX2_CRCERR) {
1388 /* framing errors are soft errors */ 1400 np->stats.rx_crc_errors++;
1389 if (Flags & NV_RX2_FRAMINGERR) { 1401 np->stats.rx_errors++;
1390 if (Flags & NV_RX2_SUBSTRACT1) { 1402 goto next_pkt;
1391 len--; 1403 }
1404 if (Flags & NV_RX2_OVERFLOW) {
1405 np->stats.rx_over_errors++;
1406 np->stats.rx_errors++;
1407 goto next_pkt;
1408 }
1409 if (Flags & NV_RX2_ERROR4) {
1410 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1411 if (len < 0) {
1412 np->stats.rx_errors++;
1413 goto next_pkt;
1414 }
1415 }
1416 /* framing errors are soft errors */
1417 if (Flags & NV_RX2_FRAMINGERR) {
1418 if (Flags & NV_RX2_SUBSTRACT1) {
1419 len--;
1420 }
1392 } 1421 }
1393 } 1422 }
1394 Flags &= NV_RX2_CHECKSUMMASK; 1423 Flags &= NV_RX2_CHECKSUMMASK;
@@ -1612,6 +1641,17 @@ static void nv_set_multicast(struct net_device *dev)
1612 spin_unlock_irq(&np->lock); 1641 spin_unlock_irq(&np->lock);
1613} 1642}
1614 1643
1644/**
1645 * nv_update_linkspeed: Setup the MAC according to the link partner
1646 * @dev: Network device to be configured
1647 *
1648 * The function queries the PHY and checks if there is a link partner.
1649 * If yes, then it sets up the MAC accordingly. Otherwise, the MAC is
1650 * set to 10 MBit HD.
1651 *
1652 * The function returns 0 if there is no link partner and 1 if there is
1653 * a good link partner.
1654 */
1615static int nv_update_linkspeed(struct net_device *dev) 1655static int nv_update_linkspeed(struct net_device *dev)
1616{ 1656{
1617 struct fe_priv *np = netdev_priv(dev); 1657 struct fe_priv *np = netdev_priv(dev);
@@ -1751,13 +1791,11 @@ set_speed:
1751static void nv_linkchange(struct net_device *dev) 1791static void nv_linkchange(struct net_device *dev)
1752{ 1792{
1753 if (nv_update_linkspeed(dev)) { 1793 if (nv_update_linkspeed(dev)) {
1754 if (netif_carrier_ok(dev)) { 1794 if (!netif_carrier_ok(dev)) {
1755 nv_stop_rx(dev);
1756 } else {
1757 netif_carrier_on(dev); 1795 netif_carrier_on(dev);
1758 printk(KERN_INFO "%s: link up.\n", dev->name); 1796 printk(KERN_INFO "%s: link up.\n", dev->name);
1797 nv_start_rx(dev);
1759 } 1798 }
1760 nv_start_rx(dev);
1761 } else { 1799 } else {
1762 if (netif_carrier_ok(dev)) { 1800 if (netif_carrier_ok(dev)) {
1763 netif_carrier_off(dev); 1801 netif_carrier_off(dev);
@@ -1799,22 +1837,18 @@ static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs)
1799 if (!(events & np->irqmask)) 1837 if (!(events & np->irqmask))
1800 break; 1838 break;
1801 1839
1802 if (events & (NVREG_IRQ_TX1|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_ERROR|NVREG_IRQ_TX_ERR)) { 1840 spin_lock(&np->lock);
1841 nv_tx_done(dev);
1842 spin_unlock(&np->lock);
1843
1844 nv_rx_process(dev);
1845 if (nv_alloc_rx(dev)) {
1803 spin_lock(&np->lock); 1846 spin_lock(&np->lock);
1804 nv_tx_done(dev); 1847 if (!np->in_shutdown)
1848 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
1805 spin_unlock(&np->lock); 1849 spin_unlock(&np->lock);
1806 } 1850 }
1807 1851
1808 if (events & (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF)) {
1809 nv_rx_process(dev);
1810 if (nv_alloc_rx(dev)) {
1811 spin_lock(&np->lock);
1812 if (!np->in_shutdown)
1813 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
1814 spin_unlock(&np->lock);
1815 }
1816 }
1817
1818 if (events & NVREG_IRQ_LINK) { 1852 if (events & NVREG_IRQ_LINK) {
1819 spin_lock(&np->lock); 1853 spin_lock(&np->lock);
1820 nv_link_irq(dev); 1854 nv_link_irq(dev);
@@ -2216,7 +2250,14 @@ static int nv_open(struct net_device *dev)
2216 writel(NVREG_RNDSEED_FORCE | (i&NVREG_RNDSEED_MASK), base + NvRegRandomSeed); 2250 writel(NVREG_RNDSEED_FORCE | (i&NVREG_RNDSEED_MASK), base + NvRegRandomSeed);
2217 writel(NVREG_UNKSETUP1_VAL, base + NvRegUnknownSetupReg1); 2251 writel(NVREG_UNKSETUP1_VAL, base + NvRegUnknownSetupReg1);
2218 writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2); 2252 writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2);
2219 writel(NVREG_POLL_DEFAULT, base + NvRegPollingInterval); 2253 if (poll_interval == -1) {
2254 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT)
2255 writel(NVREG_POLL_DEFAULT_THROUGHPUT, base + NvRegPollingInterval);
2256 else
2257 writel(NVREG_POLL_DEFAULT_CPU, base + NvRegPollingInterval);
2258 }
2259 else
2260 writel(poll_interval & 0xFFFF, base + NvRegPollingInterval);
2220 writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6); 2261 writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
2221 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING, 2262 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING,
2222 base + NvRegAdapterControl); 2263 base + NvRegAdapterControl);
@@ -2415,7 +2456,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2415 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK; 2456 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
2416 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; 2457 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
2417#ifdef NETIF_F_TSO 2458#ifdef NETIF_F_TSO
2418 dev->features |= NETIF_F_TSO; 2459 /* disabled dev->features |= NETIF_F_TSO; */
2419#endif 2460#endif
2420 } 2461 }
2421 2462
@@ -2501,7 +2542,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2501 } else { 2542 } else {
2502 np->tx_flags = NV_TX2_VALID; 2543 np->tx_flags = NV_TX2_VALID;
2503 } 2544 }
2504 np->irqmask = NVREG_IRQMASK_WANTED; 2545 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT)
2546 np->irqmask = NVREG_IRQMASK_THROUGHPUT;
2547 else
2548 np->irqmask = NVREG_IRQMASK_CPU;
2549
2505 if (id->driver_data & DEV_NEED_TIMERIRQ) 2550 if (id->driver_data & DEV_NEED_TIMERIRQ)
2506 np->irqmask |= NVREG_IRQ_TIMER; 2551 np->irqmask |= NVREG_IRQ_TIMER;
2507 if (id->driver_data & DEV_NEED_LINKTIMER) { 2552 if (id->driver_data & DEV_NEED_LINKTIMER) {
@@ -2514,16 +2559,17 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2514 } 2559 }
2515 2560
2516 /* find a suitable phy */ 2561 /* find a suitable phy */
2517 for (i = 1; i < 32; i++) { 2562 for (i = 1; i <= 32; i++) {
2518 int id1, id2; 2563 int id1, id2;
2564 int phyaddr = i & 0x1F;
2519 2565
2520 spin_lock_irq(&np->lock); 2566 spin_lock_irq(&np->lock);
2521 id1 = mii_rw(dev, i, MII_PHYSID1, MII_READ); 2567 id1 = mii_rw(dev, phyaddr, MII_PHYSID1, MII_READ);
2522 spin_unlock_irq(&np->lock); 2568 spin_unlock_irq(&np->lock);
2523 if (id1 < 0 || id1 == 0xffff) 2569 if (id1 < 0 || id1 == 0xffff)
2524 continue; 2570 continue;
2525 spin_lock_irq(&np->lock); 2571 spin_lock_irq(&np->lock);
2526 id2 = mii_rw(dev, i, MII_PHYSID2, MII_READ); 2572 id2 = mii_rw(dev, phyaddr, MII_PHYSID2, MII_READ);
2527 spin_unlock_irq(&np->lock); 2573 spin_unlock_irq(&np->lock);
2528 if (id2 < 0 || id2 == 0xffff) 2574 if (id2 < 0 || id2 == 0xffff)
2529 continue; 2575 continue;
@@ -2531,23 +2577,19 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2531 id1 = (id1 & PHYID1_OUI_MASK) << PHYID1_OUI_SHFT; 2577 id1 = (id1 & PHYID1_OUI_MASK) << PHYID1_OUI_SHFT;
2532 id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT; 2578 id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT;
2533 dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n", 2579 dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n",
2534 pci_name(pci_dev), id1, id2, i); 2580 pci_name(pci_dev), id1, id2, phyaddr);
2535 np->phyaddr = i; 2581 np->phyaddr = phyaddr;
2536 np->phy_oui = id1 | id2; 2582 np->phy_oui = id1 | id2;
2537 break; 2583 break;
2538 } 2584 }
2539 if (i == 32) { 2585 if (i == 33) {
2540 /* PHY in isolate mode? No phy attached and user wants to
2541 * test loopback? Very odd, but can be correct.
2542 */
2543 printk(KERN_INFO "%s: open: Could not find a valid PHY.\n", 2586 printk(KERN_INFO "%s: open: Could not find a valid PHY.\n",
2544 pci_name(pci_dev)); 2587 pci_name(pci_dev));
2545 } 2588 goto out_freering;
2546
2547 if (i != 32) {
2548 /* reset it */
2549 phy_init(dev);
2550 } 2589 }
2590
2591 /* reset it */
2592 phy_init(dev);
2551 2593
2552 /* set default link speed settings */ 2594 /* set default link speed settings */
2553 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; 2595 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
@@ -2689,6 +2731,10 @@ static void __exit exit_nic(void)
2689 2731
2690module_param(max_interrupt_work, int, 0); 2732module_param(max_interrupt_work, int, 0);
2691MODULE_PARM_DESC(max_interrupt_work, "forcedeth maximum events handled per interrupt"); 2733MODULE_PARM_DESC(max_interrupt_work, "forcedeth maximum events handled per interrupt");
2734module_param(optimization_mode, int, 0);
2735MODULE_PARM_DESC(optimization_mode, "In throughput mode (0), every tx & rx packet will generate an interrupt. In CPU mode (1), interrupts are controlled by a timer.");
2736module_param(poll_interval, int, 0);
2737MODULE_PARM_DESC(poll_interval, "Interval determines how frequent timer interrupt is generated by [(time_in_micro_secs * 100) / (2^10)]. Min is 0 and Max is 65535.");
2692 2738
2693MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>"); 2739MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>");
2694MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver"); 2740MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver");
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 9342d5bc7bb4..f5d49a110654 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -37,6 +37,7 @@
37#include <linux/ethtool.h> 37#include <linux/ethtool.h>
38#include <linux/bitops.h> 38#include <linux/bitops.h>
39#include <linux/fs.h> 39#include <linux/fs.h>
40#include <linux/platform_device.h>
40 41
41#include <linux/vmalloc.h> 42#include <linux/vmalloc.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index a940b96433c7..e67b1d06611c 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -34,6 +34,7 @@
34#include <linux/ethtool.h> 34#include <linux/ethtool.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/platform_device.h>
37 38
38#include <asm/immap_cpm2.h> 39#include <asm/immap_cpm2.h>
39#include <asm/mpc8260.h> 40#include <asm/mpc8260.h>
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index 5ef4e845a387..2e8f44469699 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -34,6 +34,7 @@
34#include <linux/ethtool.h> 34#include <linux/ethtool.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/platform_device.h>
37 38
38#include <asm/irq.h> 39#include <asm/irq.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index d8c6e9cadcf5..a3897fda71fa 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -34,6 +34,7 @@
34#include <linux/ethtool.h> 34#include <linux/ethtool.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/platform_device.h>
37 38
38#include <asm/irq.h> 39#include <asm/irq.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 54d294ad6df5..0f030b73cbb3 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -6,7 +6,7 @@
6 * Based on 8260_io/fcc_enet.c 6 * Based on 8260_io/fcc_enet.c
7 * 7 *
8 * Author: Andy Fleming 8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 9 * Maintainer: Kumar Gala
10 * 10 *
11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
12 * 12 *
@@ -126,8 +126,8 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs);
126static void adjust_link(struct net_device *dev); 126static void adjust_link(struct net_device *dev);
127static void init_registers(struct net_device *dev); 127static void init_registers(struct net_device *dev);
128static int init_phy(struct net_device *dev); 128static int init_phy(struct net_device *dev);
129static int gfar_probe(struct device *device); 129static int gfar_probe(struct platform_device *pdev);
130static int gfar_remove(struct device *device); 130static int gfar_remove(struct platform_device *pdev);
131static void free_skb_resources(struct gfar_private *priv); 131static void free_skb_resources(struct gfar_private *priv);
132static void gfar_set_multi(struct net_device *dev); 132static void gfar_set_multi(struct net_device *dev);
133static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); 133static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
@@ -156,12 +156,11 @@ int gfar_uses_fcb(struct gfar_private *priv)
156 156
157/* Set up the ethernet device structure, private data, 157/* Set up the ethernet device structure, private data,
158 * and anything else we need before we start */ 158 * and anything else we need before we start */
159static int gfar_probe(struct device *device) 159static int gfar_probe(struct platform_device *pdev)
160{ 160{
161 u32 tempval; 161 u32 tempval;
162 struct net_device *dev = NULL; 162 struct net_device *dev = NULL;
163 struct gfar_private *priv = NULL; 163 struct gfar_private *priv = NULL;
164 struct platform_device *pdev = to_platform_device(device);
165 struct gianfar_platform_data *einfo; 164 struct gianfar_platform_data *einfo;
166 struct resource *r; 165 struct resource *r;
167 int idx; 166 int idx;
@@ -208,7 +207,7 @@ static int gfar_probe(struct device *device)
208 207
209 spin_lock_init(&priv->lock); 208 spin_lock_init(&priv->lock);
210 209
211 dev_set_drvdata(device, dev); 210 platform_set_drvdata(pdev, dev);
212 211
213 /* Stop the DMA engine now, in case it was running before */ 212 /* Stop the DMA engine now, in case it was running before */
214 /* (The firmware could have used it, and left it running). */ 213 /* (The firmware could have used it, and left it running). */
@@ -245,7 +244,7 @@ static int gfar_probe(struct device *device)
245 dev->base_addr = (unsigned long) (priv->regs); 244 dev->base_addr = (unsigned long) (priv->regs);
246 245
247 SET_MODULE_OWNER(dev); 246 SET_MODULE_OWNER(dev);
248 SET_NETDEV_DEV(dev, device); 247 SET_NETDEV_DEV(dev, &pdev->dev);
249 248
250 /* Fill in the dev structure */ 249 /* Fill in the dev structure */
251 dev->open = gfar_enet_open; 250 dev->open = gfar_enet_open;
@@ -377,12 +376,12 @@ regs_fail:
377 return err; 376 return err;
378} 377}
379 378
380static int gfar_remove(struct device *device) 379static int gfar_remove(struct platform_device *pdev)
381{ 380{
382 struct net_device *dev = dev_get_drvdata(device); 381 struct net_device *dev = platform_get_drvdata(pdev);
383 struct gfar_private *priv = netdev_priv(dev); 382 struct gfar_private *priv = netdev_priv(dev);
384 383
385 dev_set_drvdata(device, NULL); 384 platform_set_drvdata(pdev, NULL);
386 385
387 iounmap((void *) priv->regs); 386 iounmap((void *) priv->regs);
388 free_netdev(dev); 387 free_netdev(dev);
@@ -1861,11 +1860,12 @@ static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs)
1861} 1860}
1862 1861
1863/* Structure for a device driver */ 1862/* Structure for a device driver */
1864static struct device_driver gfar_driver = { 1863static struct platform_driver gfar_driver = {
1865 .name = "fsl-gianfar",
1866 .bus = &platform_bus_type,
1867 .probe = gfar_probe, 1864 .probe = gfar_probe,
1868 .remove = gfar_remove, 1865 .remove = gfar_remove,
1866 .driver = {
1867 .name = "fsl-gianfar",
1868 },
1869}; 1869};
1870 1870
1871static int __init gfar_init(void) 1871static int __init gfar_init(void)
@@ -1875,7 +1875,7 @@ static int __init gfar_init(void)
1875 if (err) 1875 if (err)
1876 return err; 1876 return err;
1877 1877
1878 err = driver_register(&gfar_driver); 1878 err = platform_driver_register(&gfar_driver);
1879 1879
1880 if (err) 1880 if (err)
1881 gfar_mdio_exit(); 1881 gfar_mdio_exit();
@@ -1885,7 +1885,7 @@ static int __init gfar_init(void)
1885 1885
1886static void __exit gfar_exit(void) 1886static void __exit gfar_exit(void)
1887{ 1887{
1888 driver_unregister(&gfar_driver); 1888 platform_driver_unregister(&gfar_driver);
1889 gfar_mdio_exit(); 1889 gfar_mdio_exit();
1890} 1890}
1891 1891
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 220084e53341..5065ba82cb76 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -6,7 +6,7 @@
6 * Based on 8260_io/fcc_enet.c 6 * Based on 8260_io/fcc_enet.c
7 * 7 *
8 * Author: Andy Fleming 8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 9 * Maintainer: Kumar Gala
10 * 10 *
11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
12 * 12 *
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index 5a2d810ce575..cfa3cd7c91a0 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -6,7 +6,7 @@
6 * Based on e1000 ethtool support 6 * Based on e1000 ethtool support
7 * 7 *
8 * Author: Andy Fleming 8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 9 * Maintainer: Kumar Gala
10 * 10 *
11 * Copyright (c) 2003,2004 Freescale Semiconductor, Inc. 11 * Copyright (c) 2003,2004 Freescale Semiconductor, Inc.
12 * 12 *
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index 7263395d78bb..04a462c2a5b7 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -5,7 +5,7 @@
5 * Provides Bus interface for MIIM regs 5 * Provides Bus interface for MIIM regs
6 * 6 *
7 * Author: Andy Fleming 7 * Author: Andy Fleming
8 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 8 * Maintainer: Kumar Gala
9 * 9 *
10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
11 * 11 *
@@ -133,7 +133,7 @@ int gfar_mdio_probe(struct device *dev)
133 if (NULL == dev) 133 if (NULL == dev)
134 return -EINVAL; 134 return -EINVAL;
135 135
136 new_bus = kmalloc(sizeof(struct mii_bus), GFP_KERNEL); 136 new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL);
137 137
138 if (NULL == new_bus) 138 if (NULL == new_bus)
139 return -ENOMEM; 139 return -ENOMEM;
diff --git a/drivers/net/gianfar_mii.h b/drivers/net/gianfar_mii.h
index 56e5665d5c9b..e85eb216fb5b 100644
--- a/drivers/net/gianfar_mii.h
+++ b/drivers/net/gianfar_mii.h
@@ -5,7 +5,7 @@
5 * Driver for the MDIO bus controller in the Gianfar register space 5 * Driver for the MDIO bus controller in the Gianfar register space
6 * 6 *
7 * Author: Andy Fleming 7 * Author: Andy Fleming
8 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 8 * Maintainer: Kumar Gala
9 * 9 *
10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
11 * 11 *
diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
index 666cfbbcf6d9..5958a6314723 100644
--- a/drivers/net/gt96100eth.c
+++ b/drivers/net/gt96100eth.c
@@ -72,8 +72,6 @@ static void dump_tx_desc(int dbg_lvl, struct net_device *dev, int i);
72static void dump_rx_desc(int dbg_lvl, struct net_device *dev, int i); 72static void dump_rx_desc(int dbg_lvl, struct net_device *dev, int i);
73static void dump_skb(int dbg_lvl, struct net_device *dev, 73static void dump_skb(int dbg_lvl, struct net_device *dev,
74 struct sk_buff *skb); 74 struct sk_buff *skb);
75static void dump_hw_addr(int dbg_lvl, struct net_device *dev,
76 const char* pfx, unsigned char* addr_str);
77static void update_stats(struct gt96100_private *gp); 75static void update_stats(struct gt96100_private *gp);
78static void abort(struct net_device *dev, u32 abort_bits); 76static void abort(struct net_device *dev, u32 abort_bits);
79static void hard_stop(struct net_device *dev); 77static void hard_stop(struct net_device *dev);
@@ -334,13 +332,13 @@ dump_MII(int dbg_lvl, struct net_device *dev)
334 332
335static void 333static void
336dump_hw_addr(int dbg_lvl, struct net_device *dev, const char* pfx, 334dump_hw_addr(int dbg_lvl, struct net_device *dev, const char* pfx,
337 unsigned char* addr_str) 335 const char* func, unsigned char* addr_str)
338{ 336{
339 int i; 337 int i;
340 char buf[100], octet[5]; 338 char buf[100], octet[5];
341 339
342 if (dbg_lvl <= GT96100_DEBUG) { 340 if (dbg_lvl <= GT96100_DEBUG) {
343 strcpy(buf, pfx); 341 sprintf(buf, pfx, func);
344 for (i = 0; i < 6; i++) { 342 for (i = 0; i < 6; i++) {
345 sprintf(octet, "%2.2x%s", 343 sprintf(octet, "%2.2x%s",
346 addr_str[i], i<5 ? ":" : "\n"); 344 addr_str[i], i<5 ? ":" : "\n");
@@ -708,7 +706,7 @@ static int __init gt96100_probe1(struct pci_dev *pci, int port_num)
708 706
709 info("%s found at 0x%x, irq %d\n", 707 info("%s found at 0x%x, irq %d\n",
710 chip_name(gp->chip_rev), gtif->iobase, gtif->irq); 708 chip_name(gp->chip_rev), gtif->iobase, gtif->irq);
711 dump_hw_addr(0, dev, "HW Address ", dev->dev_addr); 709 dump_hw_addr(0, dev, "%s: HW Address ", __FUNCTION__, dev->dev_addr);
712 info("%s chip revision=%d\n", chip_name(gp->chip_rev), gp->chip_rev); 710 info("%s chip revision=%d\n", chip_name(gp->chip_rev), gp->chip_rev);
713 info("%s ethernet port %d\n", chip_name(gp->chip_rev), gp->port_num); 711 info("%s ethernet port %d\n", chip_name(gp->chip_rev), gp->port_num);
714 info("external PHY ID1=0x%04x, ID2=0x%04x\n", phy_id1, phy_id2); 712 info("external PHY ID1=0x%04x, ID2=0x%04x\n", phy_id1, phy_id2);
@@ -1488,7 +1486,7 @@ gt96100_set_rx_mode(struct net_device *dev)
1488 gt96100_add_hash_entry(dev, dev->dev_addr); 1486 gt96100_add_hash_entry(dev, dev->dev_addr);
1489 1487
1490 for (mcptr = dev->mc_list; mcptr; mcptr = mcptr->next) { 1488 for (mcptr = dev->mc_list; mcptr; mcptr = mcptr->next) {
1491 dump_hw_addr(2, dev, __FUNCTION__ ": addr=", 1489 dump_hw_addr(2, dev, "%s: addr=", __FUNCTION__,
1492 mcptr->dmi_addr); 1490 mcptr->dmi_addr);
1493 gt96100_add_hash_entry(dev, mcptr->dmi_addr); 1491 gt96100_add_hash_entry(dev, mcptr->dmi_addr);
1494 } 1492 }
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index eb7d69478715..1da8a66f91e1 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -65,7 +65,7 @@
65 */ 65 */
66 66
67#define DRV_NAME "emac" 67#define DRV_NAME "emac"
68#define DRV_VERSION "3.53" 68#define DRV_VERSION "3.54"
69#define DRV_DESC "PPC 4xx OCP EMAC driver" 69#define DRV_DESC "PPC 4xx OCP EMAC driver"
70 70
71MODULE_DESCRIPTION(DRV_DESC); 71MODULE_DESCRIPTION(DRV_DESC);
@@ -158,6 +158,14 @@ static inline void emac_report_timeout_error(struct ocp_enet_private *dev,
158#define PHY_POLL_LINK_ON HZ 158#define PHY_POLL_LINK_ON HZ
159#define PHY_POLL_LINK_OFF (HZ / 5) 159#define PHY_POLL_LINK_OFF (HZ / 5)
160 160
161/* Graceful stop timeouts in us.
162 * We should allow up to 1 frame time (full-duplex, ignoring collisions)
163 */
164#define STOP_TIMEOUT_10 1230
165#define STOP_TIMEOUT_100 124
166#define STOP_TIMEOUT_1000 13
167#define STOP_TIMEOUT_1000_JUMBO 73
168
161/* Please, keep in sync with struct ibm_emac_stats/ibm_emac_error_stats */ 169/* Please, keep in sync with struct ibm_emac_stats/ibm_emac_error_stats */
162static const char emac_stats_keys[EMAC_ETHTOOL_STATS_COUNT][ETH_GSTRING_LEN] = { 170static const char emac_stats_keys[EMAC_ETHTOOL_STATS_COUNT][ETH_GSTRING_LEN] = {
163 "rx_packets", "rx_bytes", "tx_packets", "tx_bytes", "rx_packets_csum", 171 "rx_packets", "rx_bytes", "tx_packets", "tx_bytes", "rx_packets_csum",
@@ -222,10 +230,12 @@ static void emac_tx_disable(struct ocp_enet_private *dev)
222 230
223 r = in_be32(&p->mr0); 231 r = in_be32(&p->mr0);
224 if (r & EMAC_MR0_TXE) { 232 if (r & EMAC_MR0_TXE) {
225 int n = 300; 233 int n = dev->stop_timeout;
226 out_be32(&p->mr0, r & ~EMAC_MR0_TXE); 234 out_be32(&p->mr0, r & ~EMAC_MR0_TXE);
227 while (!(in_be32(&p->mr0) & EMAC_MR0_TXI) && n) 235 while (!(in_be32(&p->mr0) & EMAC_MR0_TXI) && n) {
236 udelay(1);
228 --n; 237 --n;
238 }
229 if (unlikely(!n)) 239 if (unlikely(!n))
230 emac_report_timeout_error(dev, "TX disable timeout"); 240 emac_report_timeout_error(dev, "TX disable timeout");
231 } 241 }
@@ -248,9 +258,11 @@ static void emac_rx_enable(struct ocp_enet_private *dev)
248 if (!(r & EMAC_MR0_RXE)) { 258 if (!(r & EMAC_MR0_RXE)) {
249 if (unlikely(!(r & EMAC_MR0_RXI))) { 259 if (unlikely(!(r & EMAC_MR0_RXI))) {
250 /* Wait if previous async disable is still in progress */ 260 /* Wait if previous async disable is still in progress */
251 int n = 100; 261 int n = dev->stop_timeout;
252 while (!(r = in_be32(&p->mr0) & EMAC_MR0_RXI) && n) 262 while (!(r = in_be32(&p->mr0) & EMAC_MR0_RXI) && n) {
263 udelay(1);
253 --n; 264 --n;
265 }
254 if (unlikely(!n)) 266 if (unlikely(!n))
255 emac_report_timeout_error(dev, 267 emac_report_timeout_error(dev,
256 "RX disable timeout"); 268 "RX disable timeout");
@@ -273,10 +285,12 @@ static void emac_rx_disable(struct ocp_enet_private *dev)
273 285
274 r = in_be32(&p->mr0); 286 r = in_be32(&p->mr0);
275 if (r & EMAC_MR0_RXE) { 287 if (r & EMAC_MR0_RXE) {
276 int n = 300; 288 int n = dev->stop_timeout;
277 out_be32(&p->mr0, r & ~EMAC_MR0_RXE); 289 out_be32(&p->mr0, r & ~EMAC_MR0_RXE);
278 while (!(in_be32(&p->mr0) & EMAC_MR0_RXI) && n) 290 while (!(in_be32(&p->mr0) & EMAC_MR0_RXI) && n) {
291 udelay(1);
279 --n; 292 --n;
293 }
280 if (unlikely(!n)) 294 if (unlikely(!n))
281 emac_report_timeout_error(dev, "RX disable timeout"); 295 emac_report_timeout_error(dev, "RX disable timeout");
282 } 296 }
@@ -395,6 +409,7 @@ static int emac_configure(struct ocp_enet_private *dev)
395 r = EMAC_MR1_BASE(emac_opb_mhz()) | EMAC_MR1_VLE | EMAC_MR1_IST; 409 r = EMAC_MR1_BASE(emac_opb_mhz()) | EMAC_MR1_VLE | EMAC_MR1_IST;
396 if (dev->phy.duplex == DUPLEX_FULL) 410 if (dev->phy.duplex == DUPLEX_FULL)
397 r |= EMAC_MR1_FDE; 411 r |= EMAC_MR1_FDE;
412 dev->stop_timeout = STOP_TIMEOUT_10;
398 switch (dev->phy.speed) { 413 switch (dev->phy.speed) {
399 case SPEED_1000: 414 case SPEED_1000:
400 if (emac_phy_gpcs(dev->phy.mode)) { 415 if (emac_phy_gpcs(dev->phy.mode)) {
@@ -409,12 +424,16 @@ static int emac_configure(struct ocp_enet_private *dev)
409 r |= EMAC_MR1_MF_1000; 424 r |= EMAC_MR1_MF_1000;
410 r |= EMAC_MR1_RFS_16K; 425 r |= EMAC_MR1_RFS_16K;
411 gige = 1; 426 gige = 1;
412 427
413 if (dev->ndev->mtu > ETH_DATA_LEN) 428 if (dev->ndev->mtu > ETH_DATA_LEN) {
414 r |= EMAC_MR1_JPSM; 429 r |= EMAC_MR1_JPSM;
430 dev->stop_timeout = STOP_TIMEOUT_1000_JUMBO;
431 } else
432 dev->stop_timeout = STOP_TIMEOUT_1000;
415 break; 433 break;
416 case SPEED_100: 434 case SPEED_100:
417 r |= EMAC_MR1_MF_100; 435 r |= EMAC_MR1_MF_100;
436 dev->stop_timeout = STOP_TIMEOUT_100;
418 /* Fall through */ 437 /* Fall through */
419 default: 438 default:
420 r |= EMAC_MR1_RFS_4K; 439 r |= EMAC_MR1_RFS_4K;
@@ -2048,6 +2067,7 @@ static int __init emac_probe(struct ocp_device *ocpdev)
2048 dev->phy.duplex = DUPLEX_FULL; 2067 dev->phy.duplex = DUPLEX_FULL;
2049 dev->phy.autoneg = AUTONEG_DISABLE; 2068 dev->phy.autoneg = AUTONEG_DISABLE;
2050 dev->phy.pause = dev->phy.asym_pause = 0; 2069 dev->phy.pause = dev->phy.asym_pause = 0;
2070 dev->stop_timeout = STOP_TIMEOUT_100;
2051 init_timer(&dev->link_timer); 2071 init_timer(&dev->link_timer);
2052 dev->link_timer.function = emac_link_timer; 2072 dev->link_timer.function = emac_link_timer;
2053 dev->link_timer.data = (unsigned long)dev; 2073 dev->link_timer.data = (unsigned long)dev;
diff --git a/drivers/net/ibm_emac/ibm_emac_core.h b/drivers/net/ibm_emac/ibm_emac_core.h
index e9b44d030ac3..911abbaf471b 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.h
+++ b/drivers/net/ibm_emac/ibm_emac_core.h
@@ -189,6 +189,8 @@ struct ocp_enet_private {
189 struct timer_list link_timer; 189 struct timer_list link_timer;
190 int reset_failed; 190 int reset_failed;
191 191
192 int stop_timeout; /* in us */
193
192 struct ibm_emac_error_stats estats; 194 struct ibm_emac_error_stats estats;
193 struct net_device_stats nstats; 195 struct net_device_stats nstats;
194 196
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index be191d80ef9c..ceb98fd398af 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -58,7 +58,7 @@
58 58
59#include "ibmveth.h" 59#include "ibmveth.h"
60 60
61#define DEBUG 1 61#undef DEBUG
62 62
63#define ibmveth_printk(fmt, args...) \ 63#define ibmveth_printk(fmt, args...) \
64 printk(KERN_INFO "%s: " fmt, __FILE__, ## args) 64 printk(KERN_INFO "%s: " fmt, __FILE__, ## args)
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index 6a3129bc15a6..9b8295ee06ef 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -1360,7 +1360,7 @@ static struct pci_driver ioc3_driver = {
1360 1360
1361static int __init ioc3_init_module(void) 1361static int __init ioc3_init_module(void)
1362{ 1362{
1363 return pci_module_init(&ioc3_driver); 1363 return pci_register_driver(&ioc3_driver);
1364} 1364}
1365 1365
1366static void __exit ioc3_cleanup_module(void) 1366static void __exit ioc3_cleanup_module(void)
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 9bf34681d3df..2e7882eb7d6f 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -40,6 +40,7 @@
40#include <asm/byteorder.h> 40#include <asm/byteorder.h>
41 41
42#include <linux/pm.h> 42#include <linux/pm.h>
43#include <linux/pm_legacy.h>
43 44
44#include <net/irda/wrapper.h> 45#include <net/irda/wrapper.h>
45#include <net/irda/irda.h> 46#include <net/irda/irda.h>
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index 805714ec9a8a..ee717d0e939e 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -59,6 +59,7 @@
59#include <asm/byteorder.h> 59#include <asm/byteorder.h>
60 60
61#include <linux/pm.h> 61#include <linux/pm.h>
62#include <linux/pm_legacy.h>
62 63
63#include <net/irda/wrapper.h> 64#include <net/irda/wrapper.h>
64#include <net/irda/irda.h> 65#include <net/irda/irda.h>
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 76e0b9fb5e96..63d38fbbd04e 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -291,9 +291,9 @@ static void sa1100_irda_shutdown(struct sa1100_irda *si)
291/* 291/*
292 * Suspend the IrDA interface. 292 * Suspend the IrDA interface.
293 */ 293 */
294static int sa1100_irda_suspend(struct device *_dev, pm_message_t state) 294static int sa1100_irda_suspend(struct platform_device *pdev, pm_message_t state)
295{ 295{
296 struct net_device *dev = dev_get_drvdata(_dev); 296 struct net_device *dev = platform_get_drvdata(pdev);
297 struct sa1100_irda *si; 297 struct sa1100_irda *si;
298 298
299 if (!dev) 299 if (!dev)
@@ -316,9 +316,9 @@ static int sa1100_irda_suspend(struct device *_dev, pm_message_t state)
316/* 316/*
317 * Resume the IrDA interface. 317 * Resume the IrDA interface.
318 */ 318 */
319static int sa1100_irda_resume(struct device *_dev) 319static int sa1100_irda_resume(struct platform_device *pdev)
320{ 320{
321 struct net_device *dev = dev_get_drvdata(_dev); 321 struct net_device *dev = platform_get_drvdata(pdev);
322 struct sa1100_irda *si; 322 struct sa1100_irda *si;
323 323
324 if (!dev) 324 if (!dev)
@@ -886,9 +886,8 @@ static int sa1100_irda_init_iobuf(iobuff_t *io, int size)
886 return io->head ? 0 : -ENOMEM; 886 return io->head ? 0 : -ENOMEM;
887} 887}
888 888
889static int sa1100_irda_probe(struct device *_dev) 889static int sa1100_irda_probe(struct platform_device *pdev)
890{ 890{
891 struct platform_device *pdev = to_platform_device(_dev);
892 struct net_device *dev; 891 struct net_device *dev;
893 struct sa1100_irda *si; 892 struct sa1100_irda *si;
894 unsigned int baudrate_mask; 893 unsigned int baudrate_mask;
@@ -967,7 +966,7 @@ static int sa1100_irda_probe(struct device *_dev)
967 966
968 err = register_netdev(dev); 967 err = register_netdev(dev);
969 if (err == 0) 968 if (err == 0)
970 dev_set_drvdata(&pdev->dev, dev); 969 platform_set_drvdata(pdev, dev);
971 970
972 if (err) { 971 if (err) {
973 err_mem_5: 972 err_mem_5:
@@ -985,9 +984,9 @@ static int sa1100_irda_probe(struct device *_dev)
985 return err; 984 return err;
986} 985}
987 986
988static int sa1100_irda_remove(struct device *_dev) 987static int sa1100_irda_remove(struct platform_device *pdev)
989{ 988{
990 struct net_device *dev = dev_get_drvdata(_dev); 989 struct net_device *dev = platform_get_drvdata(pdev);
991 990
992 if (dev) { 991 if (dev) {
993 struct sa1100_irda *si = dev->priv; 992 struct sa1100_irda *si = dev->priv;
@@ -1004,13 +1003,14 @@ static int sa1100_irda_remove(struct device *_dev)
1004 return 0; 1003 return 0;
1005} 1004}
1006 1005
1007static struct device_driver sa1100ir_driver = { 1006static struct platform_driver sa1100ir_driver = {
1008 .name = "sa11x0-ir",
1009 .bus = &platform_bus_type,
1010 .probe = sa1100_irda_probe, 1007 .probe = sa1100_irda_probe,
1011 .remove = sa1100_irda_remove, 1008 .remove = sa1100_irda_remove,
1012 .suspend = sa1100_irda_suspend, 1009 .suspend = sa1100_irda_suspend,
1013 .resume = sa1100_irda_resume, 1010 .resume = sa1100_irda_resume,
1011 .driver = {
1012 .name = "sa11x0-ir",
1013 },
1014}; 1014};
1015 1015
1016static int __init sa1100_irda_init(void) 1016static int __init sa1100_irda_init(void)
@@ -1023,12 +1023,12 @@ static int __init sa1100_irda_init(void)
1023 if (power_level > 3) 1023 if (power_level > 3)
1024 power_level = 3; 1024 power_level = 3;
1025 1025
1026 return driver_register(&sa1100ir_driver); 1026 return platform_driver_register(&sa1100ir_driver);
1027} 1027}
1028 1028
1029static void __exit sa1100_irda_exit(void) 1029static void __exit sa1100_irda_exit(void)
1030{ 1030{
1031 driver_unregister(&sa1100ir_driver); 1031 platform_driver_unregister(&sa1100ir_driver);
1032} 1032}
1033 1033
1034module_init(sa1100_irda_init); 1034module_init(sa1100_irda_init);
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index a1d207f2fa68..ec94ecdb103d 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -214,14 +214,15 @@ static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
214 214
215/* Power Management */ 215/* Power Management */
216 216
217static int smsc_ircc_suspend(struct device *dev, pm_message_t state); 217static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state);
218static int smsc_ircc_resume(struct device *dev); 218static int smsc_ircc_resume(struct platform_device *dev);
219 219
220static struct device_driver smsc_ircc_driver = { 220static struct platform_driver smsc_ircc_driver = {
221 .name = SMSC_IRCC2_DRIVER_NAME,
222 .bus = &platform_bus_type,
223 .suspend = smsc_ircc_suspend, 221 .suspend = smsc_ircc_suspend,
224 .resume = smsc_ircc_resume, 222 .resume = smsc_ircc_resume,
223 .driver = {
224 .name = SMSC_IRCC2_DRIVER_NAME,
225 },
225}; 226};
226 227
227/* Transceivers for SMSC-ircc */ 228/* Transceivers for SMSC-ircc */
@@ -346,7 +347,7 @@ static int __init smsc_ircc_init(void)
346 347
347 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 348 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
348 349
349 ret = driver_register(&smsc_ircc_driver); 350 ret = platform_driver_register(&smsc_ircc_driver);
350 if (ret) { 351 if (ret) {
351 IRDA_ERROR("%s, Can't register driver!\n", driver_name); 352 IRDA_ERROR("%s, Can't register driver!\n", driver_name);
352 return ret; 353 return ret;
@@ -378,7 +379,7 @@ static int __init smsc_ircc_init(void)
378 } 379 }
379 380
380 if (ret) 381 if (ret)
381 driver_unregister(&smsc_ircc_driver); 382 platform_driver_unregister(&smsc_ircc_driver);
382 383
383 return ret; 384 return ret;
384} 385}
@@ -491,7 +492,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u
491 err = PTR_ERR(self->pldev); 492 err = PTR_ERR(self->pldev);
492 goto err_out5; 493 goto err_out5;
493 } 494 }
494 dev_set_drvdata(&self->pldev->dev, self); 495 platform_set_drvdata(self->pldev, self);
495 496
496 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name); 497 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
497 dev_count++; 498 dev_count++;
@@ -1685,9 +1686,9 @@ static int smsc_ircc_net_close(struct net_device *dev)
1685 return 0; 1686 return 0;
1686} 1687}
1687 1688
1688static int smsc_ircc_suspend(struct device *dev, pm_message_t state) 1689static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state)
1689{ 1690{
1690 struct smsc_ircc_cb *self = dev_get_drvdata(dev); 1691 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
1691 1692
1692 if (!self->io.suspended) { 1693 if (!self->io.suspended) {
1693 IRDA_DEBUG(1, "%s, Suspending\n", driver_name); 1694 IRDA_DEBUG(1, "%s, Suspending\n", driver_name);
@@ -1706,9 +1707,9 @@ static int smsc_ircc_suspend(struct device *dev, pm_message_t state)
1706 return 0; 1707 return 0;
1707} 1708}
1708 1709
1709static int smsc_ircc_resume(struct device *dev) 1710static int smsc_ircc_resume(struct platform_device *dev)
1710{ 1711{
1711 struct smsc_ircc_cb *self = dev_get_drvdata(dev); 1712 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
1712 1713
1713 if (self->io.suspended) { 1714 if (self->io.suspended) {
1714 IRDA_DEBUG(1, "%s, Waking up\n", driver_name); 1715 IRDA_DEBUG(1, "%s, Waking up\n", driver_name);
@@ -1788,7 +1789,7 @@ static void __exit smsc_ircc_cleanup(void)
1788 smsc_ircc_close(dev_self[i]); 1789 smsc_ircc_close(dev_self[i]);
1789 } 1790 }
1790 1791
1791 driver_unregister(&smsc_ircc_driver); 1792 platform_driver_unregister(&smsc_ircc_driver);
1792} 1793}
1793 1794
1794/* 1795/*
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index 2fb3101cb33e..272d331d29cd 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -194,7 +194,7 @@ out:
194 * Probe for a SONIC ethernet controller on a Mips Jazz board. 194 * Probe for a SONIC ethernet controller on a Mips Jazz board.
195 * Actually probing is superfluous but we're paranoid. 195 * Actually probing is superfluous but we're paranoid.
196 */ 196 */
197static int __init jazz_sonic_probe(struct device *device) 197static int __init jazz_sonic_probe(struct platform_device *pdev)
198{ 198{
199 struct net_device *dev; 199 struct net_device *dev;
200 struct sonic_local *lp; 200 struct sonic_local *lp;
@@ -212,8 +212,8 @@ static int __init jazz_sonic_probe(struct device *device)
212 return -ENOMEM; 212 return -ENOMEM;
213 213
214 lp = netdev_priv(dev); 214 lp = netdev_priv(dev);
215 lp->device = device; 215 lp->device = &pdev->dev;
216 SET_NETDEV_DEV(dev, device); 216 SET_NETDEV_DEV(dev, &pdev->dev);
217 SET_MODULE_OWNER(dev); 217 SET_MODULE_OWNER(dev);
218 218
219 netdev_boot_setup_check(dev); 219 netdev_boot_setup_check(dev);
@@ -264,9 +264,9 @@ MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
264 264
265#include "sonic.c" 265#include "sonic.c"
266 266
267static int __devexit jazz_sonic_device_remove (struct device *device) 267static int __devexit jazz_sonic_device_remove (struct platform_device *pdev)
268{ 268{
269 struct net_device *dev = device->driver_data; 269 struct net_device *dev = platform_get_drvdata(pdev);
270 struct sonic_local* lp = netdev_priv(dev); 270 struct sonic_local* lp = netdev_priv(dev);
271 271
272 unregister_netdev (dev); 272 unregister_netdev (dev);
@@ -278,24 +278,25 @@ static int __devexit jazz_sonic_device_remove (struct device *device)
278 return 0; 278 return 0;
279} 279}
280 280
281static struct device_driver jazz_sonic_driver = { 281static struct platform_driver jazz_sonic_driver = {
282 .name = jazz_sonic_string,
283 .bus = &platform_bus_type,
284 .probe = jazz_sonic_probe, 282 .probe = jazz_sonic_probe,
285 .remove = __devexit_p(jazz_sonic_device_remove), 283 .remove = __devexit_p(jazz_sonic_device_remove),
284 .driver = {
285 .name = jazz_sonic_string,
286 },
286}; 287};
287 288
288static int __init jazz_sonic_init_module(void) 289static int __init jazz_sonic_init_module(void)
289{ 290{
290 int err; 291 int err;
291 292
292 if ((err = driver_register(&jazz_sonic_driver))) { 293 if ((err = platform_driver_register(&jazz_sonic_driver))) {
293 printk(KERN_ERR "Driver registration failed\n"); 294 printk(KERN_ERR "Driver registration failed\n");
294 return err; 295 return err;
295 } 296 }
296 297
297 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0); 298 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0);
298 if (!jazz_sonnic_device) 299 if (!jazz_sonic_device)
299 goto out_unregister; 300 goto out_unregister;
300 301
301 if (platform_device_add(jazz_sonic_device)) { 302 if (platform_device_add(jazz_sonic_device)) {
@@ -306,14 +307,14 @@ static int __init jazz_sonic_init_module(void)
306 return 0; 307 return 0;
307 308
308out_unregister: 309out_unregister:
309 driver_unregister(&jazz_sonic_driver); 310 platform_driver_unregister(&jazz_sonic_driver);
310 311
311 return -ENOMEM; 312 return -ENOMEM;
312} 313}
313 314
314static void __exit jazz_sonic_cleanup_module(void) 315static void __exit jazz_sonic_cleanup_module(void)
315{ 316{
316 driver_unregister(&jazz_sonic_driver); 317 platform_driver_unregister(&jazz_sonic_driver);
317 318
318 if (jazz_sonic_device) { 319 if (jazz_sonic_device) {
319 platform_device_unregister(jazz_sonic_device); 320 platform_device_unregister(jazz_sonic_device);
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index 9ef4592aca03..02d5c6822733 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -525,7 +525,7 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
525 return macsonic_init(dev); 525 return macsonic_init(dev);
526} 526}
527 527
528static int __init mac_sonic_probe(struct device *device) 528static int __init mac_sonic_probe(struct platform_device *device)
529{ 529{
530 struct net_device *dev; 530 struct net_device *dev;
531 struct sonic_local *lp; 531 struct sonic_local *lp;
@@ -537,8 +537,8 @@ static int __init mac_sonic_probe(struct device *device)
537 return -ENOMEM; 537 return -ENOMEM;
538 538
539 lp = netdev_priv(dev); 539 lp = netdev_priv(dev);
540 lp->device = device; 540 lp->device = &device->dev;
541 SET_NETDEV_DEV(dev, device); 541 SET_NETDEV_DEV(dev, &device->dev);
542 SET_MODULE_OWNER(dev); 542 SET_MODULE_OWNER(dev);
543 543
544 /* This will catch fatal stuff like -ENOMEM as well as success */ 544 /* This will catch fatal stuff like -ENOMEM as well as success */
@@ -579,9 +579,9 @@ MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
579 579
580#include "sonic.c" 580#include "sonic.c"
581 581
582static int __devexit mac_sonic_device_remove (struct device *device) 582static int __devexit mac_sonic_device_remove (struct platform_device *device)
583{ 583{
584 struct net_device *dev = device->driver_data; 584 struct net_device *dev = platform_get_drvdata(device);
585 struct sonic_local* lp = netdev_priv(dev); 585 struct sonic_local* lp = netdev_priv(dev);
586 586
587 unregister_netdev (dev); 587 unregister_netdev (dev);
@@ -592,18 +592,19 @@ static int __devexit mac_sonic_device_remove (struct device *device)
592 return 0; 592 return 0;
593} 593}
594 594
595static struct device_driver mac_sonic_driver = { 595static struct platform_driver mac_sonic_driver = {
596 .name = mac_sonic_string,
597 .bus = &platform_bus_type,
598 .probe = mac_sonic_probe, 596 .probe = mac_sonic_probe,
599 .remove = __devexit_p(mac_sonic_device_remove), 597 .remove = __devexit_p(mac_sonic_device_remove),
598 .driver = {
599 .name = mac_sonic_string,
600 },
600}; 601};
601 602
602static int __init mac_sonic_init_module(void) 603static int __init mac_sonic_init_module(void)
603{ 604{
604 int err; 605 int err;
605 606
606 if ((err = driver_register(&mac_sonic_driver))) { 607 if ((err = platform_driver_register(&mac_sonic_driver))) {
607 printk(KERN_ERR "Driver registration failed\n"); 608 printk(KERN_ERR "Driver registration failed\n");
608 return err; 609 return err;
609 } 610 }
@@ -628,7 +629,7 @@ out_unregister:
628 629
629static void __exit mac_sonic_cleanup_module(void) 630static void __exit mac_sonic_cleanup_module(void)
630{ 631{
631 driver_unregister(&mac_sonic_driver); 632 platform_driver_unregister(&mac_sonic_driver);
632 633
633 if (mac_sonic_device) { 634 if (mac_sonic_device) {
634 platform_device_unregister(mac_sonic_device); 635 platform_device_unregister(mac_sonic_device);
diff --git a/drivers/net/mipsnet.h b/drivers/net/mipsnet.h
index 878535953cb1..026c732024c9 100644
--- a/drivers/net/mipsnet.h
+++ b/drivers/net/mipsnet.h
@@ -1,28 +1,8 @@
1// 1/*
2// <COPYRIGHT CLASS="1B" YEAR="2005"> 2 * This file is subject to the terms and conditions of the GNU General Public
3// Unpublished work (c) MIPS Technologies, Inc. All rights reserved. 3 * License. See the file "COPYING" in the main directory of this archive
4// Unpublished rights reserved under the copyright laws of the U.S.A. and 4 * for more details.
5// other countries. 5 */
6//
7// PROPRIETARY / SECRET CONFIDENTIAL INFORMATION OF MIPS TECHNOLOGIES, INC.
8// FOR INTERNAL USE ONLY.
9//
10// Under no circumstances (contract or otherwise) may this information be
11// disclosed to, or copied, modified or used by anyone other than employees
12// or contractors of MIPS Technologies having a need to know.
13// </COPYRIGHT>
14//
15//++
16// File: MIPS_Net.h
17//
18// Description:
19// The definition of the emulated MIPSNET device's interface.
20//
21// Notes: This include file needs to work from a Linux device drivers.
22//
23//--
24//
25
26#ifndef __MIPSNET_H 6#ifndef __MIPSNET_H
27#define __MIPSNET_H 7#define __MIPSNET_H
28 8
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 71f2c6705bc3..3cb9b3fe0cf1 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1387,9 +1387,8 @@ static void mv643xx_netpoll(struct net_device *netdev)
1387 * Input : struct device * 1387 * Input : struct device *
1388 * Output : -ENOMEM if failed , 0 if success 1388 * Output : -ENOMEM if failed , 0 if success
1389 */ 1389 */
1390static int mv643xx_eth_probe(struct device *ddev) 1390static int mv643xx_eth_probe(struct platform_device *pdev)
1391{ 1391{
1392 struct platform_device *pdev = to_platform_device(ddev);
1393 struct mv643xx_eth_platform_data *pd; 1392 struct mv643xx_eth_platform_data *pd;
1394 int port_num = pdev->id; 1393 int port_num = pdev->id;
1395 struct mv643xx_private *mp; 1394 struct mv643xx_private *mp;
@@ -1402,7 +1401,7 @@ static int mv643xx_eth_probe(struct device *ddev)
1402 if (!dev) 1401 if (!dev)
1403 return -ENOMEM; 1402 return -ENOMEM;
1404 1403
1405 dev_set_drvdata(ddev, dev); 1404 platform_set_drvdata(pdev, dev);
1406 1405
1407 mp = netdev_priv(dev); 1406 mp = netdev_priv(dev);
1408 1407
@@ -1546,21 +1545,20 @@ out:
1546 return err; 1545 return err;
1547} 1546}
1548 1547
1549static int mv643xx_eth_remove(struct device *ddev) 1548static int mv643xx_eth_remove(struct platform_device *pdev)
1550{ 1549{
1551 struct net_device *dev = dev_get_drvdata(ddev); 1550 struct net_device *dev = platform_get_drvdata(pdev);
1552 1551
1553 unregister_netdev(dev); 1552 unregister_netdev(dev);
1554 flush_scheduled_work(); 1553 flush_scheduled_work();
1555 1554
1556 free_netdev(dev); 1555 free_netdev(dev);
1557 dev_set_drvdata(ddev, NULL); 1556 platform_set_drvdata(pdev, NULL);
1558 return 0; 1557 return 0;
1559} 1558}
1560 1559
1561static int mv643xx_eth_shared_probe(struct device *ddev) 1560static int mv643xx_eth_shared_probe(struct platform_device *pdev)
1562{ 1561{
1563 struct platform_device *pdev = to_platform_device(ddev);
1564 struct resource *res; 1562 struct resource *res;
1565 1563
1566 printk(KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n"); 1564 printk(KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n");
@@ -1578,7 +1576,7 @@ static int mv643xx_eth_shared_probe(struct device *ddev)
1578 1576
1579} 1577}
1580 1578
1581static int mv643xx_eth_shared_remove(struct device *ddev) 1579static int mv643xx_eth_shared_remove(struct platform_device *pdev)
1582{ 1580{
1583 iounmap(mv643xx_eth_shared_base); 1581 iounmap(mv643xx_eth_shared_base);
1584 mv643xx_eth_shared_base = NULL; 1582 mv643xx_eth_shared_base = NULL;
@@ -1586,18 +1584,20 @@ static int mv643xx_eth_shared_remove(struct device *ddev)
1586 return 0; 1584 return 0;
1587} 1585}
1588 1586
1589static struct device_driver mv643xx_eth_driver = { 1587static struct platform_driver mv643xx_eth_driver = {
1590 .name = MV643XX_ETH_NAME,
1591 .bus = &platform_bus_type,
1592 .probe = mv643xx_eth_probe, 1588 .probe = mv643xx_eth_probe,
1593 .remove = mv643xx_eth_remove, 1589 .remove = mv643xx_eth_remove,
1590 .driver = {
1591 .name = MV643XX_ETH_NAME,
1592 },
1594}; 1593};
1595 1594
1596static struct device_driver mv643xx_eth_shared_driver = { 1595static struct platform_driver mv643xx_eth_shared_driver = {
1597 .name = MV643XX_ETH_SHARED_NAME,
1598 .bus = &platform_bus_type,
1599 .probe = mv643xx_eth_shared_probe, 1596 .probe = mv643xx_eth_shared_probe,
1600 .remove = mv643xx_eth_shared_remove, 1597 .remove = mv643xx_eth_shared_remove,
1598 .driver = {
1599 .name = MV643XX_ETH_SHARED_NAME,
1600 },
1601}; 1601};
1602 1602
1603/* 1603/*
@@ -1613,11 +1613,11 @@ static int __init mv643xx_init_module(void)
1613{ 1613{
1614 int rc; 1614 int rc;
1615 1615
1616 rc = driver_register(&mv643xx_eth_shared_driver); 1616 rc = platform_driver_register(&mv643xx_eth_shared_driver);
1617 if (!rc) { 1617 if (!rc) {
1618 rc = driver_register(&mv643xx_eth_driver); 1618 rc = platform_driver_register(&mv643xx_eth_driver);
1619 if (rc) 1619 if (rc)
1620 driver_unregister(&mv643xx_eth_shared_driver); 1620 platform_driver_unregister(&mv643xx_eth_shared_driver);
1621 } 1621 }
1622 return rc; 1622 return rc;
1623} 1623}
@@ -1633,8 +1633,8 @@ static int __init mv643xx_init_module(void)
1633 */ 1633 */
1634static void __exit mv643xx_cleanup_module(void) 1634static void __exit mv643xx_cleanup_module(void)
1635{ 1635{
1636 driver_unregister(&mv643xx_eth_driver); 1636 platform_driver_unregister(&mv643xx_eth_driver);
1637 driver_unregister(&mv643xx_eth_shared_driver); 1637 platform_driver_unregister(&mv643xx_eth_shared_driver);
1638} 1638}
1639 1639
1640module_init(mv643xx_init_module); 1640module_init(mv643xx_init_module);
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 384a736a0d2f..356f50909222 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -131,10 +131,9 @@ typedef struct local_info_t {
131 u_short tx_queue_len; 131 u_short tx_queue_len;
132 cardtype_t cardtype; 132 cardtype_t cardtype;
133 u_short sent; 133 u_short sent;
134 u_char mc_filter[8];
135} local_info_t; 134} local_info_t;
136 135
137#define MC_FILTERBREAK 8 136#define MC_FILTERBREAK 64
138 137
139/*====================================================================*/ 138/*====================================================================*/
140/* 139/*
@@ -1005,15 +1004,8 @@ static void fjn_reset(struct net_device *dev)
1005 for (i = 0; i < 6; i++) 1004 for (i = 0; i < 6; i++)
1006 outb(dev->dev_addr[i], ioaddr + NODE_ID + i); 1005 outb(dev->dev_addr[i], ioaddr + NODE_ID + i);
1007 1006
1008 /* Switch to bank 1 */ 1007 /* (re)initialize the multicast table */
1009 if (lp->cardtype == MBH10302) 1008 set_rx_mode(dev);
1010 outb(BANK_1, ioaddr + CONFIG_1);
1011 else
1012 outb(BANK_1U, ioaddr + CONFIG_1);
1013
1014 /* set the multicast table to accept none. */
1015 for (i = 0; i < 8; i++)
1016 outb(0x00, ioaddr + MAR_ADR + i);
1017 1009
1018 /* Switch to bank 2 (runtime mode) */ 1010 /* Switch to bank 2 (runtime mode) */
1019 if (lp->cardtype == MBH10302) 1011 if (lp->cardtype == MBH10302)
@@ -1264,11 +1256,11 @@ static struct net_device_stats *fjn_get_stats(struct net_device *dev)
1264static void set_rx_mode(struct net_device *dev) 1256static void set_rx_mode(struct net_device *dev)
1265{ 1257{
1266 kio_addr_t ioaddr = dev->base_addr; 1258 kio_addr_t ioaddr = dev->base_addr;
1267 struct local_info_t *lp = netdev_priv(dev);
1268 u_char mc_filter[8]; /* Multicast hash filter */ 1259 u_char mc_filter[8]; /* Multicast hash filter */
1269 u_long flags; 1260 u_long flags;
1270 int i; 1261 int i;
1271 1262
1263 int saved_bank;
1272 int saved_config_0 = inb(ioaddr + CONFIG_0); 1264 int saved_config_0 = inb(ioaddr + CONFIG_0);
1273 1265
1274 local_irq_save(flags); 1266 local_irq_save(flags);
@@ -1306,15 +1298,13 @@ static void set_rx_mode(struct net_device *dev)
1306 outb(2, ioaddr + RX_MODE); /* Use normal mode. */ 1298 outb(2, ioaddr + RX_MODE); /* Use normal mode. */
1307 } 1299 }
1308 1300
1309 if (memcmp(mc_filter, lp->mc_filter, sizeof(mc_filter))) { 1301 /* Switch to bank 1 and set the multicast table. */
1310 int saved_bank = inb(ioaddr + CONFIG_1); 1302 saved_bank = inb(ioaddr + CONFIG_1);
1311 /* Switch to bank 1 and set the multicast table. */ 1303 outb(0xe4, ioaddr + CONFIG_1);
1312 outb(0xe4, ioaddr + CONFIG_1); 1304
1313 for (i = 0; i < 8; i++) 1305 for (i = 0; i < 8; i++)
1314 outb(mc_filter[i], ioaddr + MAR_ADR + i); 1306 outb(mc_filter[i], ioaddr + MAR_ADR + i);
1315 memcpy(lp->mc_filter, mc_filter, sizeof(mc_filter)); 1307 outb(saved_bank, ioaddr + CONFIG_1);
1316 outb(saved_bank, ioaddr + CONFIG_1);
1317 }
1318 1308
1319 outb(saved_config_0, ioaddr + CONFIG_0); 1309 outb(saved_config_0, ioaddr + CONFIG_0);
1320 1310
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index be319229f543..8f6cf8c896a4 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1251,12 +1251,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1251 1251
1252 if (memcmp(promaddr, dev->dev_addr, 6) 1252 if (memcmp(promaddr, dev->dev_addr, 6)
1253 || !is_valid_ether_addr(dev->dev_addr)) { 1253 || !is_valid_ether_addr(dev->dev_addr)) {
1254#ifndef __powerpc__
1255 if (is_valid_ether_addr(promaddr)) { 1254 if (is_valid_ether_addr(promaddr)) {
1256#else
1257 if (!is_valid_ether_addr(dev->dev_addr)
1258 && is_valid_ether_addr(promaddr)) {
1259#endif
1260 if (pcnet32_debug & NETIF_MSG_PROBE) { 1255 if (pcnet32_debug & NETIF_MSG_PROBE) {
1261 printk(" warning: CSR address invalid,\n"); 1256 printk(" warning: CSR address invalid,\n");
1262 printk(KERN_INFO " using instead PROM address of"); 1257 printk(KERN_INFO " using instead PROM address of");
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 16bebe7a7ce1..7da0e3dd5fe3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -38,6 +38,10 @@
38#include <asm/irq.h> 38#include <asm/irq.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40 40
41MODULE_DESCRIPTION("PHY library");
42MODULE_AUTHOR("Andy Fleming");
43MODULE_LICENSE("GPL");
44
41static struct phy_driver genphy_driver; 45static struct phy_driver genphy_driver;
42extern int mdio_bus_init(void); 46extern int mdio_bus_init(void);
43extern void mdio_bus_exit(void); 47extern void mdio_bus_exit(void);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 50430f79f8cf..1c6d328165bb 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -524,9 +524,6 @@ static int get_filter(void __user *arg, struct sock_filter **p)
524 if (copy_from_user(&uprog, arg, sizeof(uprog))) 524 if (copy_from_user(&uprog, arg, sizeof(uprog)))
525 return -EFAULT; 525 return -EFAULT;
526 526
527 if (uprog.len > BPF_MAXINSNS)
528 return -EINVAL;
529
530 if (!uprog.len) { 527 if (!uprog.len) {
531 *p = NULL; 528 *p = NULL;
532 return 0; 529 return 0;
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 159b56a56ef4..14a76f7cf900 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1346,10 +1346,8 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1346 } else { 1346 } else {
1347 if (netif_msg_probe(tp)) { 1347 if (netif_msg_probe(tp)) {
1348 printk(KERN_ERR PFX 1348 printk(KERN_ERR PFX
1349 "Cannot find PowerManagement capability. " 1349 "PowerManagement capability not found.\n");
1350 "Aborting.\n");
1351 } 1350 }
1352 goto err_out_mwi;
1353 } 1351 }
1354 1352
1355 /* make sure PCI base addr 1 is MMIO */ 1353 /* make sure PCI base addr 1 is MMIO */
@@ -2516,7 +2514,7 @@ rtl8169_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
2516 } while (boguscnt > 0); 2514 } while (boguscnt > 0);
2517 2515
2518 if (boguscnt <= 0) { 2516 if (boguscnt <= 0) {
2519 if (net_ratelimit() && netif_msg_intr(tp)) { 2517 if (netif_msg_intr(tp) && net_ratelimit() ) {
2520 printk(KERN_WARNING 2518 printk(KERN_WARNING
2521 "%s: Too much work at interrupt!\n", dev->name); 2519 "%s: Too much work at interrupt!\n", dev->name);
2522 } 2520 }
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index e57df8dfe6b4..669dd52c412a 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -3078,7 +3078,7 @@ int s2io_set_swapper(nic_t * sp)
3078 3078
3079static int wait_for_msix_trans(nic_t *nic, int i) 3079static int wait_for_msix_trans(nic_t *nic, int i)
3080{ 3080{
3081 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3081 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3082 u64 val64; 3082 u64 val64;
3083 int ret = 0, cnt = 0; 3083 int ret = 0, cnt = 0;
3084 3084
@@ -3099,7 +3099,7 @@ static int wait_for_msix_trans(nic_t *nic, int i)
3099 3099
3100void restore_xmsi_data(nic_t *nic) 3100void restore_xmsi_data(nic_t *nic)
3101{ 3101{
3102 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3102 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3103 u64 val64; 3103 u64 val64;
3104 int i; 3104 int i;
3105 3105
@@ -3117,7 +3117,7 @@ void restore_xmsi_data(nic_t *nic)
3117 3117
3118static void store_xmsi_data(nic_t *nic) 3118static void store_xmsi_data(nic_t *nic)
3119{ 3119{
3120 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3120 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3121 u64 val64, addr, data; 3121 u64 val64, addr, data;
3122 int i; 3122 int i;
3123 3123
@@ -3140,7 +3140,7 @@ static void store_xmsi_data(nic_t *nic)
3140 3140
3141int s2io_enable_msi(nic_t *nic) 3141int s2io_enable_msi(nic_t *nic)
3142{ 3142{
3143 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3143 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3144 u16 msi_ctrl, msg_val; 3144 u16 msi_ctrl, msg_val;
3145 struct config_param *config = &nic->config; 3145 struct config_param *config = &nic->config;
3146 struct net_device *dev = nic->dev; 3146 struct net_device *dev = nic->dev;
@@ -3190,7 +3190,7 @@ int s2io_enable_msi(nic_t *nic)
3190 3190
3191int s2io_enable_msi_x(nic_t *nic) 3191int s2io_enable_msi_x(nic_t *nic)
3192{ 3192{
3193 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3193 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3194 u64 tx_mat, rx_mat; 3194 u64 tx_mat, rx_mat;
3195 u16 msi_control; /* Temp variable */ 3195 u16 msi_control; /* Temp variable */
3196 int ret, i, j, msix_indx = 1; 3196 int ret, i, j, msix_indx = 1;
diff --git a/drivers/net/saa9730.c b/drivers/net/saa9730.c
index 110e777f206e..b2acedbefa8f 100644
--- a/drivers/net/saa9730.c
+++ b/drivers/net/saa9730.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Carsten Langgaard, carstenl@mips.com 2 * Copyright (C) 2000, 2005 MIPS Technologies, Inc. All rights reserved.
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. 3 * Authors: Carsten Langgaard <carstenl@mips.com>
4 * 4 * Maciej W. Rozycki <macro@mips.com>
5 * ######################################################################## 5 * Copyright (C) 2004 Ralf Baechle <ralf@linux-mips.org>
6 * 6 *
7 * This program is free software; you can distribute it and/or modify it 7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as 8 * under the terms of the GNU General Public License (Version 2) as
@@ -17,15 +17,13 @@
17 * with this program; if not, write to the Free Software Foundation, Inc., 17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 * 19 *
20 * ########################################################################
21 *
22 * SAA9730 ethernet driver. 20 * SAA9730 ethernet driver.
23 * 21 *
24 * Changes: 22 * Changes:
25 * Angelo Dell'Aera <buffer@antifork.org> : Conversion to the new PCI API (pci_driver). 23 * Angelo Dell'Aera <buffer@antifork.org> : Conversion to the new PCI API
26 * Conversion to spinlocks. 24 * (pci_driver).
27 * Error handling fixes. 25 * Conversion to spinlocks.
28 * 26 * Error handling fixes.
29 */ 27 */
30 28
31#include <linux/init.h> 29#include <linux/init.h>
@@ -36,8 +34,11 @@
36#include <linux/skbuff.h> 34#include <linux/skbuff.h>
37#include <linux/pci.h> 35#include <linux/pci.h>
38#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/types.h>
39 38
40#include <asm/addrspace.h> 39#include <asm/addrspace.h>
40#include <asm/io.h>
41
41#include <asm/mips-boards/prom.h> 42#include <asm/mips-boards/prom.h>
42 43
43#include "saa9730.h" 44#include "saa9730.h"
@@ -51,8 +52,8 @@ int lan_saa9730_debug;
51#define DRV_MODULE_NAME "saa9730" 52#define DRV_MODULE_NAME "saa9730"
52 53
53static struct pci_device_id saa9730_pci_tbl[] = { 54static struct pci_device_id saa9730_pci_tbl[] = {
54 { PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA9370, 55 { PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA9730,
55 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 56 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
56 { 0, } 57 { 0, }
57}; 58};
58 59
@@ -61,50 +62,48 @@ MODULE_DEVICE_TABLE(pci, saa9730_pci_tbl);
61/* Non-zero only if the current card is a PCI with BIOS-set IRQ. */ 62/* Non-zero only if the current card is a PCI with BIOS-set IRQ. */
62static unsigned int pci_irq_line; 63static unsigned int pci_irq_line;
63 64
64#define INL(a) inl((unsigned long)a)
65#define OUTL(x,a) outl(x,(unsigned long)a)
66
67static void evm_saa9730_enable_lan_int(struct lan_saa9730_private *lp) 65static void evm_saa9730_enable_lan_int(struct lan_saa9730_private *lp)
68{ 66{
69 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT, 67 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
70 &lp->evm_saa9730_regs->InterruptBlock1); 68 &lp->evm_saa9730_regs->InterruptBlock1);
71 OUTL(INL(&lp->evm_saa9730_regs->InterruptStatus1) | EVM_LAN_INT, 69 outl(readl(&lp->evm_saa9730_regs->InterruptStatus1) | EVM_LAN_INT,
72 &lp->evm_saa9730_regs->InterruptStatus1); 70 &lp->evm_saa9730_regs->InterruptStatus1);
73 OUTL(INL(&lp->evm_saa9730_regs->InterruptEnable1) | EVM_LAN_INT | 71 outl(readl(&lp->evm_saa9730_regs->InterruptEnable1) | EVM_LAN_INT |
74 EVM_MASTER_EN, &lp->evm_saa9730_regs->InterruptEnable1); 72 EVM_MASTER_EN, &lp->evm_saa9730_regs->InterruptEnable1);
75} 73}
74
76static void evm_saa9730_disable_lan_int(struct lan_saa9730_private *lp) 75static void evm_saa9730_disable_lan_int(struct lan_saa9730_private *lp)
77{ 76{
78 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT, 77 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
79 &lp->evm_saa9730_regs->InterruptBlock1); 78 &lp->evm_saa9730_regs->InterruptBlock1);
80 OUTL(INL(&lp->evm_saa9730_regs->InterruptEnable1) & ~EVM_LAN_INT, 79 outl(readl(&lp->evm_saa9730_regs->InterruptEnable1) & ~EVM_LAN_INT,
81 &lp->evm_saa9730_regs->InterruptEnable1); 80 &lp->evm_saa9730_regs->InterruptEnable1);
82} 81}
83 82
84static void evm_saa9730_clear_lan_int(struct lan_saa9730_private *lp) 83static void evm_saa9730_clear_lan_int(struct lan_saa9730_private *lp)
85{ 84{
86 OUTL(EVM_LAN_INT, &lp->evm_saa9730_regs->InterruptStatus1); 85 outl(EVM_LAN_INT, &lp->evm_saa9730_regs->InterruptStatus1);
87} 86}
88 87
89static void evm_saa9730_block_lan_int(struct lan_saa9730_private *lp) 88static void evm_saa9730_block_lan_int(struct lan_saa9730_private *lp)
90{ 89{
91 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT, 90 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
92 &lp->evm_saa9730_regs->InterruptBlock1); 91 &lp->evm_saa9730_regs->InterruptBlock1);
93} 92}
94 93
95static void evm_saa9730_unblock_lan_int(struct lan_saa9730_private *lp) 94static void evm_saa9730_unblock_lan_int(struct lan_saa9730_private *lp)
96{ 95{
97 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT, 96 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
98 &lp->evm_saa9730_regs->InterruptBlock1); 97 &lp->evm_saa9730_regs->InterruptBlock1);
99} 98}
100 99
101static void show_saa9730_regs(struct lan_saa9730_private *lp) 100static void __attribute_used__ show_saa9730_regs(struct lan_saa9730_private *lp)
102{ 101{
103 int i, j; 102 int i, j;
104 printk("TxmBufferA = %x\n", lp->TxmBuffer[0][0]); 103 printk("TxmBufferA = %p\n", lp->TxmBuffer[0][0]);
105 printk("TxmBufferB = %x\n", lp->TxmBuffer[1][0]); 104 printk("TxmBufferB = %p\n", lp->TxmBuffer[1][0]);
106 printk("RcvBufferA = %x\n", lp->RcvBuffer[0][0]); 105 printk("RcvBufferA = %p\n", lp->RcvBuffer[0][0]);
107 printk("RcvBufferB = %x\n", lp->RcvBuffer[1][0]); 106 printk("RcvBufferB = %p\n", lp->RcvBuffer[1][0]);
108 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) { 107 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {
109 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) { 108 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) {
110 printk("TxmBuffer[%d][%d] = %x\n", i, j, 109 printk("TxmBuffer[%d][%d] = %x\n", i, j,
@@ -120,13 +119,13 @@ static void show_saa9730_regs(struct lan_saa9730_private *lp)
120 } 119 }
121 } 120 }
122 printk("lp->evm_saa9730_regs->InterruptBlock1 = %x\n", 121 printk("lp->evm_saa9730_regs->InterruptBlock1 = %x\n",
123 INL(&lp->evm_saa9730_regs->InterruptBlock1)); 122 readl(&lp->evm_saa9730_regs->InterruptBlock1));
124 printk("lp->evm_saa9730_regs->InterruptStatus1 = %x\n", 123 printk("lp->evm_saa9730_regs->InterruptStatus1 = %x\n",
125 INL(&lp->evm_saa9730_regs->InterruptStatus1)); 124 readl(&lp->evm_saa9730_regs->InterruptStatus1));
126 printk("lp->evm_saa9730_regs->InterruptEnable1 = %x\n", 125 printk("lp->evm_saa9730_regs->InterruptEnable1 = %x\n",
127 INL(&lp->evm_saa9730_regs->InterruptEnable1)); 126 readl(&lp->evm_saa9730_regs->InterruptEnable1));
128 printk("lp->lan_saa9730_regs->Ok2Use = %x\n", 127 printk("lp->lan_saa9730_regs->Ok2Use = %x\n",
129 INL(&lp->lan_saa9730_regs->Ok2Use)); 128 readl(&lp->lan_saa9730_regs->Ok2Use));
130 printk("lp->NextTxmBufferIndex = %x\n", lp->NextTxmBufferIndex); 129 printk("lp->NextTxmBufferIndex = %x\n", lp->NextTxmBufferIndex);
131 printk("lp->NextTxmPacketIndex = %x\n", lp->NextTxmPacketIndex); 130 printk("lp->NextTxmPacketIndex = %x\n", lp->NextTxmPacketIndex);
132 printk("lp->PendingTxmBufferIndex = %x\n", 131 printk("lp->PendingTxmBufferIndex = %x\n",
@@ -134,23 +133,23 @@ static void show_saa9730_regs(struct lan_saa9730_private *lp)
134 printk("lp->PendingTxmPacketIndex = %x\n", 133 printk("lp->PendingTxmPacketIndex = %x\n",
135 lp->PendingTxmPacketIndex); 134 lp->PendingTxmPacketIndex);
136 printk("lp->lan_saa9730_regs->LanDmaCtl = %x\n", 135 printk("lp->lan_saa9730_regs->LanDmaCtl = %x\n",
137 INL(&lp->lan_saa9730_regs->LanDmaCtl)); 136 readl(&lp->lan_saa9730_regs->LanDmaCtl));
138 printk("lp->lan_saa9730_regs->DmaStatus = %x\n", 137 printk("lp->lan_saa9730_regs->DmaStatus = %x\n",
139 INL(&lp->lan_saa9730_regs->DmaStatus)); 138 readl(&lp->lan_saa9730_regs->DmaStatus));
140 printk("lp->lan_saa9730_regs->CamCtl = %x\n", 139 printk("lp->lan_saa9730_regs->CamCtl = %x\n",
141 INL(&lp->lan_saa9730_regs->CamCtl)); 140 readl(&lp->lan_saa9730_regs->CamCtl));
142 printk("lp->lan_saa9730_regs->TxCtl = %x\n", 141 printk("lp->lan_saa9730_regs->TxCtl = %x\n",
143 INL(&lp->lan_saa9730_regs->TxCtl)); 142 readl(&lp->lan_saa9730_regs->TxCtl));
144 printk("lp->lan_saa9730_regs->TxStatus = %x\n", 143 printk("lp->lan_saa9730_regs->TxStatus = %x\n",
145 INL(&lp->lan_saa9730_regs->TxStatus)); 144 readl(&lp->lan_saa9730_regs->TxStatus));
146 printk("lp->lan_saa9730_regs->RxCtl = %x\n", 145 printk("lp->lan_saa9730_regs->RxCtl = %x\n",
147 INL(&lp->lan_saa9730_regs->RxCtl)); 146 readl(&lp->lan_saa9730_regs->RxCtl));
148 printk("lp->lan_saa9730_regs->RxStatus = %x\n", 147 printk("lp->lan_saa9730_regs->RxStatus = %x\n",
149 INL(&lp->lan_saa9730_regs->RxStatus)); 148 readl(&lp->lan_saa9730_regs->RxStatus));
150 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) { 149 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) {
151 OUTL(i, &lp->lan_saa9730_regs->CamAddress); 150 outl(i, &lp->lan_saa9730_regs->CamAddress);
152 printk("lp->lan_saa9730_regs->CamData = %x\n", 151 printk("lp->lan_saa9730_regs->CamData = %x\n",
153 INL(&lp->lan_saa9730_regs->CamData)); 152 readl(&lp->lan_saa9730_regs->CamData));
154 } 153 }
155 printk("lp->stats.tx_packets = %lx\n", lp->stats.tx_packets); 154 printk("lp->stats.tx_packets = %lx\n", lp->stats.tx_packets);
156 printk("lp->stats.tx_errors = %lx\n", lp->stats.tx_errors); 155 printk("lp->stats.tx_errors = %lx\n", lp->stats.tx_errors);
@@ -178,17 +177,17 @@ static void show_saa9730_regs(struct lan_saa9730_private *lp)
178 lp->stats.rx_length_errors); 177 lp->stats.rx_length_errors);
179 178
180 printk("lp->lan_saa9730_regs->DebugPCIMasterAddr = %x\n", 179 printk("lp->lan_saa9730_regs->DebugPCIMasterAddr = %x\n",
181 INL(&lp->lan_saa9730_regs->DebugPCIMasterAddr)); 180 readl(&lp->lan_saa9730_regs->DebugPCIMasterAddr));
182 printk("lp->lan_saa9730_regs->DebugLanTxStateMachine = %x\n", 181 printk("lp->lan_saa9730_regs->DebugLanTxStateMachine = %x\n",
183 INL(&lp->lan_saa9730_regs->DebugLanTxStateMachine)); 182 readl(&lp->lan_saa9730_regs->DebugLanTxStateMachine));
184 printk("lp->lan_saa9730_regs->DebugLanRxStateMachine = %x\n", 183 printk("lp->lan_saa9730_regs->DebugLanRxStateMachine = %x\n",
185 INL(&lp->lan_saa9730_regs->DebugLanRxStateMachine)); 184 readl(&lp->lan_saa9730_regs->DebugLanRxStateMachine));
186 printk("lp->lan_saa9730_regs->DebugLanTxFifoPointers = %x\n", 185 printk("lp->lan_saa9730_regs->DebugLanTxFifoPointers = %x\n",
187 INL(&lp->lan_saa9730_regs->DebugLanTxFifoPointers)); 186 readl(&lp->lan_saa9730_regs->DebugLanTxFifoPointers));
188 printk("lp->lan_saa9730_regs->DebugLanRxFifoPointers = %x\n", 187 printk("lp->lan_saa9730_regs->DebugLanRxFifoPointers = %x\n",
189 INL(&lp->lan_saa9730_regs->DebugLanRxFifoPointers)); 188 readl(&lp->lan_saa9730_regs->DebugLanRxFifoPointers));
190 printk("lp->lan_saa9730_regs->DebugLanCtlStateMachine = %x\n", 189 printk("lp->lan_saa9730_regs->DebugLanCtlStateMachine = %x\n",
191 INL(&lp->lan_saa9730_regs->DebugLanCtlStateMachine)); 190 readl(&lp->lan_saa9730_regs->DebugLanCtlStateMachine));
192} 191}
193 192
194static void lan_saa9730_buffer_init(struct lan_saa9730_private *lp) 193static void lan_saa9730_buffer_init(struct lan_saa9730_private *lp)
@@ -214,98 +213,108 @@ static void lan_saa9730_buffer_init(struct lan_saa9730_private *lp)
214 } 213 }
215} 214}
216 215
217static int lan_saa9730_allocate_buffers(struct lan_saa9730_private *lp) 216static void lan_saa9730_free_buffers(struct pci_dev *pdev,
217 struct lan_saa9730_private *lp)
218{ 218{
219 unsigned int mem_size; 219 pci_free_consistent(pdev, lp->buffer_size, lp->buffer_start,
220 void *Pa; 220 lp->dma_addr);
221 unsigned int i, j, RcvBufferSize, TxmBufferSize; 221}
222 unsigned int buffer_start;
223 222
224 /* 223static int lan_saa9730_allocate_buffers(struct pci_dev *pdev,
225 * Allocate all RX and TX packets in one chunk. 224 struct lan_saa9730_private *lp)
226 * The Rx and Tx packets must be PACKET_SIZE aligned. 225{
227 */ 226 void *Pa;
228 mem_size = ((LAN_SAA9730_RCV_Q_SIZE + LAN_SAA9730_TXM_Q_SIZE) * 227 unsigned int i, j, rxoffset, txoffset;
229 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_BUFFERS) + 228 int ret;
230 LAN_SAA9730_PACKET_SIZE;
231 buffer_start =
232 (unsigned int) kmalloc(mem_size, GFP_DMA | GFP_KERNEL);
233
234 if (!buffer_start)
235 return -ENOMEM;
236
237 /*
238 * Set DMA buffer to kseg1 (uncached).
239 * Make sure to flush before using it uncached.
240 */
241 Pa = (void *) KSEG1ADDR((buffer_start + LAN_SAA9730_PACKET_SIZE) &
242 ~(LAN_SAA9730_PACKET_SIZE - 1));
243 dma_cache_wback_inv((unsigned long) Pa, mem_size);
244 229
245 /* Initialize buffer space */ 230 /* Initialize buffer space */
246 RcvBufferSize = LAN_SAA9730_PACKET_SIZE;
247 TxmBufferSize = LAN_SAA9730_PACKET_SIZE;
248 lp->DmaRcvPackets = LAN_SAA9730_RCV_Q_SIZE; 231 lp->DmaRcvPackets = LAN_SAA9730_RCV_Q_SIZE;
249 lp->DmaTxmPackets = LAN_SAA9730_TXM_Q_SIZE; 232 lp->DmaTxmPackets = LAN_SAA9730_TXM_Q_SIZE;
250 233
234 /* Initialize Rx Buffer Index */
235 lp->NextRcvPacketIndex = 0;
236 lp->NextRcvBufferIndex = 0;
237
238 /* Set current buffer index & next available packet index */
239 lp->NextTxmPacketIndex = 0;
240 lp->NextTxmBufferIndex = 0;
241 lp->PendingTxmPacketIndex = 0;
242 lp->PendingTxmBufferIndex = 0;
243
244 /*
245 * Allocate all RX and TX packets in one chunk.
246 * The Rx and Tx packets must be PACKET_SIZE aligned.
247 */
248 lp->buffer_size = ((LAN_SAA9730_RCV_Q_SIZE + LAN_SAA9730_TXM_Q_SIZE) *
249 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_BUFFERS) +
250 LAN_SAA9730_PACKET_SIZE;
251 lp->buffer_start = pci_alloc_consistent(pdev, lp->buffer_size,
252 &lp->dma_addr);
253 if (!lp->buffer_start) {
254 ret = -ENOMEM;
255 goto out;
256 }
257
258 Pa = (void *)ALIGN((unsigned long)lp->buffer_start,
259 LAN_SAA9730_PACKET_SIZE);
260
261 rxoffset = Pa - lp->buffer_start;
262
251 /* Init RX buffers */ 263 /* Init RX buffers */
252 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) { 264 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {
253 for (j = 0; j < LAN_SAA9730_RCV_Q_SIZE; j++) { 265 for (j = 0; j < LAN_SAA9730_RCV_Q_SIZE; j++) {
254 *(unsigned int *) Pa = 266 *(unsigned int *) Pa =
255 cpu_to_le32(RXSF_READY << 267 cpu_to_le32(RXSF_READY <<
256 RX_STAT_CTL_OWNER_SHF); 268 RX_STAT_CTL_OWNER_SHF);
257 lp->RcvBuffer[i][j] = (unsigned int) Pa; 269 lp->RcvBuffer[i][j] = Pa;
258 Pa += RcvBufferSize; 270 Pa += LAN_SAA9730_PACKET_SIZE;
259 } 271 }
260 } 272 }
261 273
274 txoffset = Pa - lp->buffer_start;
275
262 /* Init TX buffers */ 276 /* Init TX buffers */
263 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) { 277 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {
264 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) { 278 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) {
265 *(unsigned int *) Pa = 279 *(unsigned int *) Pa =
266 cpu_to_le32(TXSF_EMPTY << 280 cpu_to_le32(TXSF_EMPTY <<
267 TX_STAT_CTL_OWNER_SHF); 281 TX_STAT_CTL_OWNER_SHF);
268 lp->TxmBuffer[i][j] = (unsigned int) Pa; 282 lp->TxmBuffer[i][j] = Pa;
269 Pa += TxmBufferSize; 283 Pa += LAN_SAA9730_PACKET_SIZE;
270 } 284 }
271 } 285 }
272 286
273 /* 287 /*
274 * Set rx buffer A and rx buffer B to point to the first two buffer 288 * Set rx buffer A and rx buffer B to point to the first two buffer
275 * spaces. 289 * spaces.
276 */ 290 */
277 OUTL(PHYSADDR(lp->RcvBuffer[0][0]), 291 outl(lp->dma_addr + rxoffset,
278 &lp->lan_saa9730_regs->RxBuffA); 292 &lp->lan_saa9730_regs->RxBuffA);
279 OUTL(PHYSADDR(lp->RcvBuffer[1][0]), 293 outl(lp->dma_addr + rxoffset +
294 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_RCV_Q_SIZE,
280 &lp->lan_saa9730_regs->RxBuffB); 295 &lp->lan_saa9730_regs->RxBuffB);
281 296
282 /* Initialize Buffer Index */ 297 /*
283 lp->NextRcvPacketIndex = 0;
284 lp->NextRcvToUseIsA = 1;
285
286 /* Set current buffer index & next availble packet index */
287 lp->NextTxmPacketIndex = 0;
288 lp->NextTxmBufferIndex = 0;
289 lp->PendingTxmPacketIndex = 0;
290 lp->PendingTxmBufferIndex = 0;
291
292 /*
293 * Set txm_buf_a and txm_buf_b to point to the first two buffer 298 * Set txm_buf_a and txm_buf_b to point to the first two buffer
294 * space 299 * space
295 */ 300 */
296 OUTL(PHYSADDR(lp->TxmBuffer[0][0]), 301 outl(lp->dma_addr + txoffset,
297 &lp->lan_saa9730_regs->TxBuffA); 302 &lp->lan_saa9730_regs->TxBuffA);
298 OUTL(PHYSADDR(lp->TxmBuffer[1][0]), 303 outl(lp->dma_addr + txoffset +
304 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_TXM_Q_SIZE,
299 &lp->lan_saa9730_regs->TxBuffB); 305 &lp->lan_saa9730_regs->TxBuffB);
300 306
301 /* Set packet number */ 307 /* Set packet number */
302 OUTL((lp->DmaRcvPackets << PK_COUNT_RX_A_SHF) | 308 outl((lp->DmaRcvPackets << PK_COUNT_RX_A_SHF) |
303 (lp->DmaRcvPackets << PK_COUNT_RX_B_SHF) | 309 (lp->DmaRcvPackets << PK_COUNT_RX_B_SHF) |
304 (lp->DmaTxmPackets << PK_COUNT_TX_A_SHF) | 310 (lp->DmaTxmPackets << PK_COUNT_TX_A_SHF) |
305 (lp->DmaTxmPackets << PK_COUNT_TX_B_SHF), 311 (lp->DmaTxmPackets << PK_COUNT_TX_B_SHF),
306 &lp->lan_saa9730_regs->PacketCount); 312 &lp->lan_saa9730_regs->PacketCount);
307 313
308 return 0; 314 return 0;
315
316out:
317 return ret;
309} 318}
310 319
311static int lan_saa9730_cam_load(struct lan_saa9730_private *lp) 320static int lan_saa9730_cam_load(struct lan_saa9730_private *lp)
@@ -317,8 +326,8 @@ static int lan_saa9730_cam_load(struct lan_saa9730_private *lp)
317 326
318 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) { 327 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) {
319 /* First set address to where data is written */ 328 /* First set address to where data is written */
320 OUTL(i, &lp->lan_saa9730_regs->CamAddress); 329 outl(i, &lp->lan_saa9730_regs->CamAddress);
321 OUTL((NetworkAddress[0] << 24) | (NetworkAddress[1] << 16) 330 outl((NetworkAddress[0] << 24) | (NetworkAddress[1] << 16)
322 | (NetworkAddress[2] << 8) | NetworkAddress[3], 331 | (NetworkAddress[2] << 8) | NetworkAddress[3],
323 &lp->lan_saa9730_regs->CamData); 332 &lp->lan_saa9730_regs->CamData);
324 NetworkAddress += 4; 333 NetworkAddress += 4;
@@ -328,8 +337,7 @@ static int lan_saa9730_cam_load(struct lan_saa9730_private *lp)
328 337
329static int lan_saa9730_cam_init(struct net_device *dev) 338static int lan_saa9730_cam_init(struct net_device *dev)
330{ 339{
331 struct lan_saa9730_private *lp = 340 struct lan_saa9730_private *lp = netdev_priv(dev);
332 (struct lan_saa9730_private *) dev->priv;
333 unsigned int i; 341 unsigned int i;
334 342
335 /* Copy MAC-address into all entries. */ 343 /* Copy MAC-address into all entries. */
@@ -347,7 +355,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
347 355
348 /* Check link status, spin here till station is not busy. */ 356 /* Check link status, spin here till station is not busy. */
349 i = 0; 357 i = 0;
350 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) { 358 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) {
351 i++; 359 i++;
352 if (i > 100) { 360 if (i > 100) {
353 printk("Error: lan_saa9730_mii_init: timeout\n"); 361 printk("Error: lan_saa9730_mii_init: timeout\n");
@@ -357,12 +365,12 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
357 } 365 }
358 366
359 /* Now set the control and address register. */ 367 /* Now set the control and address register. */
360 OUTL(MD_CA_BUSY | PHY_STATUS | PHY_ADDRESS << MD_CA_PHY_SHF, 368 outl(MD_CA_BUSY | PHY_STATUS | PHY_ADDRESS << MD_CA_PHY_SHF,
361 &lp->lan_saa9730_regs->StationMgmtCtl); 369 &lp->lan_saa9730_regs->StationMgmtCtl);
362 370
363 /* check link status, spin here till station is not busy */ 371 /* check link status, spin here till station is not busy */
364 i = 0; 372 i = 0;
365 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) { 373 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) {
366 i++; 374 i++;
367 if (i > 100) { 375 if (i > 100) {
368 printk("Error: lan_saa9730_mii_init: timeout\n"); 376 printk("Error: lan_saa9730_mii_init: timeout\n");
@@ -375,7 +383,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
375 mdelay(1); 383 mdelay(1);
376 384
377 /* Check the link status. */ 385 /* Check the link status. */
378 if (INL(&lp->lan_saa9730_regs->StationMgmtData) & 386 if (readl(&lp->lan_saa9730_regs->StationMgmtData) &
379 PHY_STATUS_LINK_UP) { 387 PHY_STATUS_LINK_UP) {
380 /* Link is up. */ 388 /* Link is up. */
381 return 0; 389 return 0;
@@ -383,14 +391,14 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
383 /* Link is down, reset the PHY first. */ 391 /* Link is down, reset the PHY first. */
384 392
385 /* set PHY address = 'CONTROL' */ 393 /* set PHY address = 'CONTROL' */
386 OUTL(PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR | PHY_CONTROL, 394 outl(PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR | PHY_CONTROL,
387 &lp->lan_saa9730_regs->StationMgmtCtl); 395 &lp->lan_saa9730_regs->StationMgmtCtl);
388 396
389 /* Wait for 1 ms. */ 397 /* Wait for 1 ms. */
390 mdelay(1); 398 mdelay(1);
391 399
392 /* set 'CONTROL' = force reset and renegotiate */ 400 /* set 'CONTROL' = force reset and renegotiate */
393 OUTL(PHY_CONTROL_RESET | PHY_CONTROL_AUTO_NEG | 401 outl(PHY_CONTROL_RESET | PHY_CONTROL_AUTO_NEG |
394 PHY_CONTROL_RESTART_AUTO_NEG, 402 PHY_CONTROL_RESTART_AUTO_NEG,
395 &lp->lan_saa9730_regs->StationMgmtData); 403 &lp->lan_saa9730_regs->StationMgmtData);
396 404
@@ -398,12 +406,12 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
398 mdelay(50); 406 mdelay(50);
399 407
400 /* set 'BUSY' to start operation */ 408 /* set 'BUSY' to start operation */
401 OUTL(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR | 409 outl(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR |
402 PHY_CONTROL, &lp->lan_saa9730_regs->StationMgmtCtl); 410 PHY_CONTROL, &lp->lan_saa9730_regs->StationMgmtCtl);
403 411
404 /* await completion */ 412 /* await completion */
405 i = 0; 413 i = 0;
406 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & 414 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) &
407 MD_CA_BUSY) { 415 MD_CA_BUSY) {
408 i++; 416 i++;
409 if (i > 100) { 417 if (i > 100) {
@@ -419,13 +427,13 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
419 427
420 for (l = 0; l < 2; l++) { 428 for (l = 0; l < 2; l++) {
421 /* set PHY address = 'STATUS' */ 429 /* set PHY address = 'STATUS' */
422 OUTL(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF | 430 outl(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF |
423 PHY_STATUS, 431 PHY_STATUS,
424 &lp->lan_saa9730_regs->StationMgmtCtl); 432 &lp->lan_saa9730_regs->StationMgmtCtl);
425 433
426 /* await completion */ 434 /* await completion */
427 i = 0; 435 i = 0;
428 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & 436 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) &
429 MD_CA_BUSY) { 437 MD_CA_BUSY) {
430 i++; 438 i++;
431 if (i > 100) { 439 if (i > 100) {
@@ -440,7 +448,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
440 mdelay(3000); 448 mdelay(3000);
441 449
442 /* check the link status */ 450 /* check the link status */
443 if (INL(&lp->lan_saa9730_regs->StationMgmtData) & 451 if (readl(&lp->lan_saa9730_regs->StationMgmtData) &
444 PHY_STATUS_LINK_UP) { 452 PHY_STATUS_LINK_UP) {
445 /* link is up */ 453 /* link is up */
446 break; 454 break;
@@ -454,7 +462,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
454static int lan_saa9730_control_init(struct lan_saa9730_private *lp) 462static int lan_saa9730_control_init(struct lan_saa9730_private *lp)
455{ 463{
456 /* Initialize DMA control register. */ 464 /* Initialize DMA control register. */
457 OUTL((LANMB_ANY << DMA_CTL_MAX_XFER_SHF) | 465 outl((LANMB_ANY << DMA_CTL_MAX_XFER_SHF) |
458 (LANEND_LITTLE << DMA_CTL_ENDIAN_SHF) | 466 (LANEND_LITTLE << DMA_CTL_ENDIAN_SHF) |
459 (LAN_SAA9730_RCV_Q_INT_THRESHOLD << DMA_CTL_RX_INT_COUNT_SHF) 467 (LAN_SAA9730_RCV_Q_INT_THRESHOLD << DMA_CTL_RX_INT_COUNT_SHF)
460 | DMA_CTL_RX_INT_TO_EN | DMA_CTL_RX_INT_EN | 468 | DMA_CTL_RX_INT_TO_EN | DMA_CTL_RX_INT_EN |
@@ -462,27 +470,27 @@ static int lan_saa9730_control_init(struct lan_saa9730_private *lp)
462 &lp->lan_saa9730_regs->LanDmaCtl); 470 &lp->lan_saa9730_regs->LanDmaCtl);
463 471
464 /* Initial MAC control register. */ 472 /* Initial MAC control register. */
465 OUTL((MACCM_MII << MAC_CONTROL_CONN_SHF) | MAC_CONTROL_FULL_DUP, 473 outl((MACCM_MII << MAC_CONTROL_CONN_SHF) | MAC_CONTROL_FULL_DUP,
466 &lp->lan_saa9730_regs->MacCtl); 474 &lp->lan_saa9730_regs->MacCtl);
467 475
468 /* Initialize CAM control register. */ 476 /* Initialize CAM control register. */
469 OUTL(CAM_CONTROL_COMP_EN | CAM_CONTROL_BROAD_ACC, 477 outl(CAM_CONTROL_COMP_EN | CAM_CONTROL_BROAD_ACC,
470 &lp->lan_saa9730_regs->CamCtl); 478 &lp->lan_saa9730_regs->CamCtl);
471 479
472 /* 480 /*
473 * Initialize CAM enable register, only turn on first entry, should 481 * Initialize CAM enable register, only turn on first entry, should
474 * contain own addr. 482 * contain own addr.
475 */ 483 */
476 OUTL(0x0001, &lp->lan_saa9730_regs->CamEnable); 484 outl(0x0001, &lp->lan_saa9730_regs->CamEnable);
477 485
478 /* Initialize Tx control register */ 486 /* Initialize Tx control register */
479 OUTL(TX_CTL_EN_COMP, &lp->lan_saa9730_regs->TxCtl); 487 outl(TX_CTL_EN_COMP, &lp->lan_saa9730_regs->TxCtl);
480 488
481 /* Initialize Rcv control register */ 489 /* Initialize Rcv control register */
482 OUTL(RX_CTL_STRIP_CRC, &lp->lan_saa9730_regs->RxCtl); 490 outl(RX_CTL_STRIP_CRC, &lp->lan_saa9730_regs->RxCtl);
483 491
484 /* Reset DMA engine */ 492 /* Reset DMA engine */
485 OUTL(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest); 493 outl(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest);
486 494
487 return 0; 495 return 0;
488} 496}
@@ -492,21 +500,21 @@ static int lan_saa9730_stop(struct lan_saa9730_private *lp)
492 int i; 500 int i;
493 501
494 /* Stop DMA first */ 502 /* Stop DMA first */
495 OUTL(INL(&lp->lan_saa9730_regs->LanDmaCtl) & 503 outl(readl(&lp->lan_saa9730_regs->LanDmaCtl) &
496 ~(DMA_CTL_EN_TX_DMA | DMA_CTL_EN_RX_DMA), 504 ~(DMA_CTL_EN_TX_DMA | DMA_CTL_EN_RX_DMA),
497 &lp->lan_saa9730_regs->LanDmaCtl); 505 &lp->lan_saa9730_regs->LanDmaCtl);
498 506
499 /* Set the SW Reset bits in DMA and MAC control registers */ 507 /* Set the SW Reset bits in DMA and MAC control registers */
500 OUTL(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest); 508 outl(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest);
501 OUTL(INL(&lp->lan_saa9730_regs->MacCtl) | MAC_CONTROL_RESET, 509 outl(readl(&lp->lan_saa9730_regs->MacCtl) | MAC_CONTROL_RESET,
502 &lp->lan_saa9730_regs->MacCtl); 510 &lp->lan_saa9730_regs->MacCtl);
503 511
504 /* 512 /*
505 * Wait for MAC reset to have finished. The reset bit is auto cleared 513 * Wait for MAC reset to have finished. The reset bit is auto cleared
506 * when the reset is done. 514 * when the reset is done.
507 */ 515 */
508 i = 0; 516 i = 0;
509 while (INL(&lp->lan_saa9730_regs->MacCtl) & MAC_CONTROL_RESET) { 517 while (readl(&lp->lan_saa9730_regs->MacCtl) & MAC_CONTROL_RESET) {
510 i++; 518 i++;
511 if (i > 100) { 519 if (i > 100) {
512 printk 520 printk
@@ -524,7 +532,7 @@ static int lan_saa9730_dma_init(struct lan_saa9730_private *lp)
524 /* Stop lan controller. */ 532 /* Stop lan controller. */
525 lan_saa9730_stop(lp); 533 lan_saa9730_stop(lp);
526 534
527 OUTL(LAN_SAA9730_DEFAULT_TIME_OUT_CNT, 535 outl(LAN_SAA9730_DEFAULT_TIME_OUT_CNT,
528 &lp->lan_saa9730_regs->Timeout); 536 &lp->lan_saa9730_regs->Timeout);
529 537
530 return 0; 538 return 0;
@@ -536,28 +544,27 @@ static int lan_saa9730_start(struct lan_saa9730_private *lp)
536 544
537 /* Initialize Rx Buffer Index */ 545 /* Initialize Rx Buffer Index */
538 lp->NextRcvPacketIndex = 0; 546 lp->NextRcvPacketIndex = 0;
539 lp->NextRcvToUseIsA = 1; 547 lp->NextRcvBufferIndex = 0;
540 548
541 /* Set current buffer index & next availble packet index */ 549 /* Set current buffer index & next available packet index */
542 lp->NextTxmPacketIndex = 0; 550 lp->NextTxmPacketIndex = 0;
543 lp->NextTxmBufferIndex = 0; 551 lp->NextTxmBufferIndex = 0;
544 lp->PendingTxmPacketIndex = 0; 552 lp->PendingTxmPacketIndex = 0;
545 lp->PendingTxmBufferIndex = 0; 553 lp->PendingTxmBufferIndex = 0;
546 554
547 OUTL(INL(&lp->lan_saa9730_regs->LanDmaCtl) | DMA_CTL_EN_TX_DMA | 555 outl(readl(&lp->lan_saa9730_regs->LanDmaCtl) | DMA_CTL_EN_TX_DMA |
548 DMA_CTL_EN_RX_DMA, &lp->lan_saa9730_regs->LanDmaCtl); 556 DMA_CTL_EN_RX_DMA, &lp->lan_saa9730_regs->LanDmaCtl);
549 557
550 /* For Tx, turn on MAC then DMA */ 558 /* For Tx, turn on MAC then DMA */
551 OUTL(INL(&lp->lan_saa9730_regs->TxCtl) | TX_CTL_TX_EN, 559 outl(readl(&lp->lan_saa9730_regs->TxCtl) | TX_CTL_TX_EN,
552 &lp->lan_saa9730_regs->TxCtl); 560 &lp->lan_saa9730_regs->TxCtl);
553 561
554 /* For Rx, turn on DMA then MAC */ 562 /* For Rx, turn on DMA then MAC */
555 OUTL(INL(&lp->lan_saa9730_regs->RxCtl) | RX_CTL_RX_EN, 563 outl(readl(&lp->lan_saa9730_regs->RxCtl) | RX_CTL_RX_EN,
556 &lp->lan_saa9730_regs->RxCtl); 564 &lp->lan_saa9730_regs->RxCtl);
557 565
558 /* Set Ok2Use to let hardware owns the buffers */ 566 /* Set Ok2Use to let hardware own the buffers. */
559 OUTL(OK2USE_RX_A | OK2USE_RX_B | OK2USE_TX_A | OK2USE_TX_B, 567 outl(OK2USE_RX_A | OK2USE_RX_B, &lp->lan_saa9730_regs->Ok2Use);
560 &lp->lan_saa9730_regs->Ok2Use);
561 568
562 return 0; 569 return 0;
563} 570}
@@ -572,8 +579,7 @@ static int lan_saa9730_restart(struct lan_saa9730_private *lp)
572 579
573static int lan_saa9730_tx(struct net_device *dev) 580static int lan_saa9730_tx(struct net_device *dev)
574{ 581{
575 struct lan_saa9730_private *lp = 582 struct lan_saa9730_private *lp = netdev_priv(dev);
576 (struct lan_saa9730_private *) dev->priv;
577 unsigned int *pPacket; 583 unsigned int *pPacket;
578 unsigned int tx_status; 584 unsigned int tx_status;
579 585
@@ -581,13 +587,11 @@ static int lan_saa9730_tx(struct net_device *dev)
581 printk("lan_saa9730_tx interrupt\n"); 587 printk("lan_saa9730_tx interrupt\n");
582 588
583 /* Clear interrupt. */ 589 /* Clear interrupt. */
584 OUTL(DMA_STATUS_MAC_TX_INT, &lp->lan_saa9730_regs->DmaStatus); 590 outl(DMA_STATUS_MAC_TX_INT, &lp->lan_saa9730_regs->DmaStatus);
585 591
586 while (1) { 592 while (1) {
587 pPacket = 593 pPacket = lp->TxmBuffer[lp->PendingTxmBufferIndex]
588 (unsigned int *) lp->TxmBuffer[lp-> 594 [lp->PendingTxmPacketIndex];
589 PendingTxmBufferIndex]
590 [lp->PendingTxmPacketIndex];
591 595
592 /* Get status of first packet transmitted. */ 596 /* Get status of first packet transmitted. */
593 tx_status = le32_to_cpu(*pPacket); 597 tx_status = le32_to_cpu(*pPacket);
@@ -605,23 +609,22 @@ static int lan_saa9730_tx(struct net_device *dev)
605 lp->stats.tx_errors++; 609 lp->stats.tx_errors++;
606 if (tx_status & 610 if (tx_status &
607 (TX_STATUS_EX_COLL << TX_STAT_CTL_STATUS_SHF)) 611 (TX_STATUS_EX_COLL << TX_STAT_CTL_STATUS_SHF))
608 lp->stats.tx_aborted_errors++; 612 lp->stats.tx_aborted_errors++;
609 if (tx_status & 613 if (tx_status &
610 (TX_STATUS_LATE_COLL << 614 (TX_STATUS_LATE_COLL << TX_STAT_CTL_STATUS_SHF))
611 TX_STAT_CTL_STATUS_SHF)) lp->stats. 615 lp->stats.tx_window_errors++;
612 tx_window_errors++;
613 if (tx_status & 616 if (tx_status &
614 (TX_STATUS_L_CARR << TX_STAT_CTL_STATUS_SHF)) 617 (TX_STATUS_L_CARR << TX_STAT_CTL_STATUS_SHF))
615 lp->stats.tx_carrier_errors++; 618 lp->stats.tx_carrier_errors++;
616 if (tx_status & 619 if (tx_status &
617 (TX_STATUS_UNDER << TX_STAT_CTL_STATUS_SHF)) 620 (TX_STATUS_UNDER << TX_STAT_CTL_STATUS_SHF))
618 lp->stats.tx_fifo_errors++; 621 lp->stats.tx_fifo_errors++;
619 if (tx_status & 622 if (tx_status &
620 (TX_STATUS_SQ_ERR << TX_STAT_CTL_STATUS_SHF)) 623 (TX_STATUS_SQ_ERR << TX_STAT_CTL_STATUS_SHF))
621 lp->stats.tx_heartbeat_errors++; 624 lp->stats.tx_heartbeat_errors++;
622 625
623 lp->stats.collisions += 626 lp->stats.collisions +=
624 tx_status & TX_STATUS_TX_COLL_MSK; 627 tx_status & TX_STATUS_TX_COLL_MSK;
625 } 628 }
626 629
627 /* Free buffer. */ 630 /* Free buffer. */
@@ -636,21 +639,15 @@ static int lan_saa9730_tx(struct net_device *dev)
636 } 639 }
637 } 640 }
638 641
639 /* Make sure A and B are available to hardware. */ 642 /* The tx buffer is no longer full. */
640 OUTL(OK2USE_TX_A | OK2USE_TX_B, &lp->lan_saa9730_regs->Ok2Use); 643 netif_wake_queue(dev);
641
642 if (netif_queue_stopped(dev)) {
643 /* The tx buffer is no longer full. */
644 netif_wake_queue(dev);
645 }
646 644
647 return 0; 645 return 0;
648} 646}
649 647
650static int lan_saa9730_rx(struct net_device *dev) 648static int lan_saa9730_rx(struct net_device *dev)
651{ 649{
652 struct lan_saa9730_private *lp = 650 struct lan_saa9730_private *lp = netdev_priv(dev);
653 (struct lan_saa9730_private *) dev->priv;
654 int len = 0; 651 int len = 0;
655 struct sk_buff *skb = 0; 652 struct sk_buff *skb = 0;
656 unsigned int rx_status; 653 unsigned int rx_status;
@@ -663,16 +660,13 @@ static int lan_saa9730_rx(struct net_device *dev)
663 printk("lan_saa9730_rx interrupt\n"); 660 printk("lan_saa9730_rx interrupt\n");
664 661
665 /* Clear receive interrupts. */ 662 /* Clear receive interrupts. */
666 OUTL(DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT | 663 outl(DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT |
667 DMA_STATUS_RX_TO_INT, &lp->lan_saa9730_regs->DmaStatus); 664 DMA_STATUS_RX_TO_INT, &lp->lan_saa9730_regs->DmaStatus);
668 665
669 /* Address next packet */ 666 /* Address next packet */
670 if (lp->NextRcvToUseIsA) 667 BufferIndex = lp->NextRcvBufferIndex;
671 BufferIndex = 0;
672 else
673 BufferIndex = 1;
674 PacketIndex = lp->NextRcvPacketIndex; 668 PacketIndex = lp->NextRcvPacketIndex;
675 pPacket = (unsigned int *) lp->RcvBuffer[BufferIndex][PacketIndex]; 669 pPacket = lp->RcvBuffer[BufferIndex][PacketIndex];
676 rx_status = le32_to_cpu(*pPacket); 670 rx_status = le32_to_cpu(*pPacket);
677 671
678 /* Process each packet. */ 672 /* Process each packet. */
@@ -715,51 +709,39 @@ static int lan_saa9730_rx(struct net_device *dev)
715 lp->stats.rx_errors++; 709 lp->stats.rx_errors++;
716 if (rx_status & 710 if (rx_status &
717 (RX_STATUS_CRC_ERR << RX_STAT_CTL_STATUS_SHF)) 711 (RX_STATUS_CRC_ERR << RX_STAT_CTL_STATUS_SHF))
718 lp->stats.rx_crc_errors++; 712 lp->stats.rx_crc_errors++;
719 if (rx_status & 713 if (rx_status &
720 (RX_STATUS_ALIGN_ERR << 714 (RX_STATUS_ALIGN_ERR << RX_STAT_CTL_STATUS_SHF))
721 RX_STAT_CTL_STATUS_SHF)) lp->stats. 715 lp->stats.rx_frame_errors++;
722 rx_frame_errors++;
723 if (rx_status & 716 if (rx_status &
724 (RX_STATUS_OVERFLOW << RX_STAT_CTL_STATUS_SHF)) 717 (RX_STATUS_OVERFLOW << RX_STAT_CTL_STATUS_SHF))
725 lp->stats.rx_fifo_errors++; 718 lp->stats.rx_fifo_errors++;
726 if (rx_status & 719 if (rx_status &
727 (RX_STATUS_LONG_ERR << RX_STAT_CTL_STATUS_SHF)) 720 (RX_STATUS_LONG_ERR << RX_STAT_CTL_STATUS_SHF))
728 lp->stats.rx_length_errors++; 721 lp->stats.rx_length_errors++;
729 } 722 }
730 723
731 /* Indicate we have processed the buffer. */ 724 /* Indicate we have processed the buffer. */
732 *pPacket = 725 *pPacket = cpu_to_le32(RXSF_READY << RX_STAT_CTL_OWNER_SHF);
733 cpu_to_le32(RXSF_READY << RX_STAT_CTL_OWNER_SHF); 726
727 /* Make sure A or B is available to hardware as appropriate. */
728 outl(BufferIndex ? OK2USE_RX_B : OK2USE_RX_A,
729 &lp->lan_saa9730_regs->Ok2Use);
734 730
735 /* Go to next packet in sequence. */ 731 /* Go to next packet in sequence. */
736 lp->NextRcvPacketIndex++; 732 lp->NextRcvPacketIndex++;
737 if (lp->NextRcvPacketIndex >= LAN_SAA9730_RCV_Q_SIZE) { 733 if (lp->NextRcvPacketIndex >= LAN_SAA9730_RCV_Q_SIZE) {
738 lp->NextRcvPacketIndex = 0; 734 lp->NextRcvPacketIndex = 0;
739 if (BufferIndex) { 735 lp->NextRcvBufferIndex ^= 1;
740 lp->NextRcvToUseIsA = 1;
741 } else {
742 lp->NextRcvToUseIsA = 0;
743 }
744 } 736 }
745 OUTL(OK2USE_RX_A | OK2USE_RX_B,
746 &lp->lan_saa9730_regs->Ok2Use);
747 737
748 /* Address next packet */ 738 /* Address next packet */
749 if (lp->NextRcvToUseIsA) 739 BufferIndex = lp->NextRcvBufferIndex;
750 BufferIndex = 0;
751 else
752 BufferIndex = 1;
753 PacketIndex = lp->NextRcvPacketIndex; 740 PacketIndex = lp->NextRcvPacketIndex;
754 pPacket = 741 pPacket = lp->RcvBuffer[BufferIndex][PacketIndex];
755 (unsigned int *) lp->
756 RcvBuffer[BufferIndex][PacketIndex];
757 rx_status = le32_to_cpu(*pPacket); 742 rx_status = le32_to_cpu(*pPacket);
758 } 743 }
759 744
760 /* Make sure A and B are available to hardware. */
761 OUTL(OK2USE_RX_A | OK2USE_RX_B, &lp->lan_saa9730_regs->Ok2Use);
762
763 return 0; 745 return 0;
764} 746}
765 747
@@ -767,8 +749,7 @@ static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id,
767 struct pt_regs *regs) 749 struct pt_regs *regs)
768{ 750{
769 struct net_device *dev = (struct net_device *) dev_id; 751 struct net_device *dev = (struct net_device *) dev_id;
770 struct lan_saa9730_private *lp = 752 struct lan_saa9730_private *lp = netdev_priv(dev);
771 (struct lan_saa9730_private *) dev->priv;
772 753
773 if (lan_saa9730_debug > 5) 754 if (lan_saa9730_debug > 5)
774 printk("lan_saa9730_interrupt\n"); 755 printk("lan_saa9730_interrupt\n");
@@ -780,11 +761,11 @@ static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id,
780 evm_saa9730_clear_lan_int(lp); 761 evm_saa9730_clear_lan_int(lp);
781 762
782 /* Service pending transmit interrupts. */ 763 /* Service pending transmit interrupts. */
783 if (INL(&lp->lan_saa9730_regs->DmaStatus) & DMA_STATUS_MAC_TX_INT) 764 if (readl(&lp->lan_saa9730_regs->DmaStatus) & DMA_STATUS_MAC_TX_INT)
784 lan_saa9730_tx(dev); 765 lan_saa9730_tx(dev);
785 766
786 /* Service pending receive interrupts. */ 767 /* Service pending receive interrupts. */
787 if (INL(&lp->lan_saa9730_regs->DmaStatus) & 768 if (readl(&lp->lan_saa9730_regs->DmaStatus) &
788 (DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT | 769 (DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT |
789 DMA_STATUS_RX_TO_INT)) lan_saa9730_rx(dev); 770 DMA_STATUS_RX_TO_INT)) lan_saa9730_rx(dev);
790 771
@@ -794,15 +775,9 @@ static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id,
794 return IRQ_HANDLED; 775 return IRQ_HANDLED;
795} 776}
796 777
797static int lan_saa9730_open_fail(struct net_device *dev)
798{
799 return -ENODEV;
800}
801
802static int lan_saa9730_open(struct net_device *dev) 778static int lan_saa9730_open(struct net_device *dev)
803{ 779{
804 struct lan_saa9730_private *lp = 780 struct lan_saa9730_private *lp = netdev_priv(dev);
805 (struct lan_saa9730_private *) dev->priv;
806 781
807 /* Associate IRQ with lan_saa9730_interrupt */ 782 /* Associate IRQ with lan_saa9730_interrupt */
808 if (request_irq(dev->irq, &lan_saa9730_interrupt, 0, "SAA9730 Eth", 783 if (request_irq(dev->irq, &lan_saa9730_interrupt, 0, "SAA9730 Eth",
@@ -834,15 +809,13 @@ static int lan_saa9730_write(struct lan_saa9730_private *lp,
834 int PacketIndex; 809 int PacketIndex;
835 810
836 if (lan_saa9730_debug > 5) 811 if (lan_saa9730_debug > 5)
837 printk("lan_saa9730_write: skb=%08x\n", 812 printk("lan_saa9730_write: skb=%p\n", skb);
838 (unsigned int) skb);
839 813
840 BufferIndex = lp->NextTxmBufferIndex; 814 BufferIndex = lp->NextTxmBufferIndex;
841 PacketIndex = lp->NextTxmPacketIndex; 815 PacketIndex = lp->NextTxmPacketIndex;
842 816
843 tx_status = 817 tx_status = le32_to_cpu(*(unsigned int *)lp->TxmBuffer[BufferIndex]
844 le32_to_cpu(*(unsigned int *) lp-> 818 [PacketIndex]);
845 TxmBuffer[BufferIndex][PacketIndex]);
846 if ((tx_status & TX_STAT_CTL_OWNER_MSK) != 819 if ((tx_status & TX_STAT_CTL_OWNER_MSK) !=
847 (TXSF_EMPTY << TX_STAT_CTL_OWNER_SHF)) { 820 (TXSF_EMPTY << TX_STAT_CTL_OWNER_SHF)) {
848 if (lan_saa9730_debug > 4) 821 if (lan_saa9730_debug > 4)
@@ -858,29 +831,29 @@ static int lan_saa9730_write(struct lan_saa9730_private *lp,
858 lp->NextTxmBufferIndex ^= 1; 831 lp->NextTxmBufferIndex ^= 1;
859 } 832 }
860 833
861 pbPacketData = 834 pbPacketData = lp->TxmBuffer[BufferIndex][PacketIndex];
862 (unsigned char *) lp->TxmBuffer[BufferIndex][PacketIndex];
863 pbPacketData += 4; 835 pbPacketData += 4;
864 836
865 /* copy the bits */ 837 /* copy the bits */
866 memcpy(pbPacketData, pbData, len); 838 memcpy(pbPacketData, pbData, len);
867 839
868 /* Set transmit status for hardware */ 840 /* Set transmit status for hardware */
869 *(unsigned int *) lp->TxmBuffer[BufferIndex][PacketIndex] = 841 *(unsigned int *)lp->TxmBuffer[BufferIndex][PacketIndex] =
870 cpu_to_le32((TXSF_READY << TX_STAT_CTL_OWNER_SHF) | 842 cpu_to_le32((TXSF_READY << TX_STAT_CTL_OWNER_SHF) |
871 (TX_STAT_CTL_INT_AFTER_TX << TX_STAT_CTL_FRAME_SHF) 843 (TX_STAT_CTL_INT_AFTER_TX <<
872 | (len << TX_STAT_CTL_LENGTH_SHF)); 844 TX_STAT_CTL_FRAME_SHF) |
873 845 (len << TX_STAT_CTL_LENGTH_SHF));
874 /* Set hardware tx buffer. */ 846
875 OUTL(OK2USE_TX_A | OK2USE_TX_B, &lp->lan_saa9730_regs->Ok2Use); 847 /* Make sure A or B is available to hardware as appropriate. */
848 outl(BufferIndex ? OK2USE_TX_B : OK2USE_TX_A,
849 &lp->lan_saa9730_regs->Ok2Use);
876 850
877 return 0; 851 return 0;
878} 852}
879 853
880static void lan_saa9730_tx_timeout(struct net_device *dev) 854static void lan_saa9730_tx_timeout(struct net_device *dev)
881{ 855{
882 struct lan_saa9730_private *lp = 856 struct lan_saa9730_private *lp = netdev_priv(dev);
883 (struct lan_saa9730_private *) dev->priv;
884 857
885 /* Transmitter timeout, serious problems */ 858 /* Transmitter timeout, serious problems */
886 lp->stats.tx_errors++; 859 lp->stats.tx_errors++;
@@ -889,20 +862,19 @@ static void lan_saa9730_tx_timeout(struct net_device *dev)
889 lan_saa9730_restart(lp); 862 lan_saa9730_restart(lp);
890 863
891 dev->trans_start = jiffies; 864 dev->trans_start = jiffies;
892 netif_start_queue(dev); 865 netif_wake_queue(dev);
893} 866}
894 867
895static int lan_saa9730_start_xmit(struct sk_buff *skb, 868static int lan_saa9730_start_xmit(struct sk_buff *skb,
896 struct net_device *dev) 869 struct net_device *dev)
897{ 870{
898 struct lan_saa9730_private *lp = 871 struct lan_saa9730_private *lp = netdev_priv(dev);
899 (struct lan_saa9730_private *) dev->priv;
900 unsigned long flags; 872 unsigned long flags;
901 int skblen; 873 int skblen;
902 int len; 874 int len;
903 875
904 if (lan_saa9730_debug > 4) 876 if (lan_saa9730_debug > 4)
905 printk("Send packet: skb=%08x\n", (unsigned int) skb); 877 printk("Send packet: skb=%p\n", skb);
906 878
907 skblen = skb->len; 879 skblen = skb->len;
908 880
@@ -912,8 +884,7 @@ static int lan_saa9730_start_xmit(struct sk_buff *skb,
912 884
913 if (lan_saa9730_write(lp, skb, skblen)) { 885 if (lan_saa9730_write(lp, skb, skblen)) {
914 spin_unlock_irqrestore(&lp->lock, flags); 886 spin_unlock_irqrestore(&lp->lock, flags);
915 printk("Error when writing packet to controller: skb=%08x\n", 887 printk("Error when writing packet to controller: skb=%p\n", skb);
916 (unsigned int) skb);
917 netif_stop_queue(dev); 888 netif_stop_queue(dev);
918 return -1; 889 return -1;
919 } 890 }
@@ -922,7 +893,7 @@ static int lan_saa9730_start_xmit(struct sk_buff *skb,
922 lp->stats.tx_packets++; 893 lp->stats.tx_packets++;
923 894
924 dev->trans_start = jiffies; 895 dev->trans_start = jiffies;
925 netif_start_queue(dev); 896 netif_wake_queue(dev);
926 dev_kfree_skb(skb); 897 dev_kfree_skb(skb);
927 898
928 spin_unlock_irqrestore(&lp->lock, flags); 899 spin_unlock_irqrestore(&lp->lock, flags);
@@ -932,8 +903,7 @@ static int lan_saa9730_start_xmit(struct sk_buff *skb,
932 903
933static int lan_saa9730_close(struct net_device *dev) 904static int lan_saa9730_close(struct net_device *dev)
934{ 905{
935 struct lan_saa9730_private *lp = 906 struct lan_saa9730_private *lp = netdev_priv(dev);
936 (struct lan_saa9730_private *) dev->priv;
937 907
938 if (lan_saa9730_debug > 1) 908 if (lan_saa9730_debug > 1)
939 printk("lan_saa9730_close:\n"); 909 printk("lan_saa9730_close:\n");
@@ -955,33 +925,31 @@ static int lan_saa9730_close(struct net_device *dev)
955static struct net_device_stats *lan_saa9730_get_stats(struct net_device 925static struct net_device_stats *lan_saa9730_get_stats(struct net_device
956 *dev) 926 *dev)
957{ 927{
958 struct lan_saa9730_private *lp = 928 struct lan_saa9730_private *lp = netdev_priv(dev);
959 (struct lan_saa9730_private *) dev->priv;
960 929
961 return &lp->stats; 930 return &lp->stats;
962} 931}
963 932
964static void lan_saa9730_set_multicast(struct net_device *dev) 933static void lan_saa9730_set_multicast(struct net_device *dev)
965{ 934{
966 struct lan_saa9730_private *lp = 935 struct lan_saa9730_private *lp = netdev_priv(dev);
967 (struct lan_saa9730_private *) dev->priv;
968 936
969 /* Stop the controller */ 937 /* Stop the controller */
970 lan_saa9730_stop(lp); 938 lan_saa9730_stop(lp);
971 939
972 if (dev->flags & IFF_PROMISC) { 940 if (dev->flags & IFF_PROMISC) {
973 /* accept all packets */ 941 /* accept all packets */
974 OUTL(CAM_CONTROL_COMP_EN | CAM_CONTROL_STATION_ACC | 942 outl(CAM_CONTROL_COMP_EN | CAM_CONTROL_STATION_ACC |
975 CAM_CONTROL_GROUP_ACC | CAM_CONTROL_BROAD_ACC, 943 CAM_CONTROL_GROUP_ACC | CAM_CONTROL_BROAD_ACC,
976 &lp->lan_saa9730_regs->CamCtl); 944 &lp->lan_saa9730_regs->CamCtl);
977 } else { 945 } else {
978 if (dev->flags & IFF_ALLMULTI) { 946 if (dev->flags & IFF_ALLMULTI) {
979 /* accept all multicast packets */ 947 /* accept all multicast packets */
980 OUTL(CAM_CONTROL_COMP_EN | CAM_CONTROL_GROUP_ACC | 948 outl(CAM_CONTROL_COMP_EN | CAM_CONTROL_GROUP_ACC |
981 CAM_CONTROL_BROAD_ACC, 949 CAM_CONTROL_BROAD_ACC,
982 &lp->lan_saa9730_regs->CamCtl); 950 &lp->lan_saa9730_regs->CamCtl);
983 } else { 951 } else {
984 /* 952 /*
985 * Will handle the multicast stuff later. -carstenl 953 * Will handle the multicast stuff later. -carstenl
986 */ 954 */
987 } 955 }
@@ -993,91 +961,86 @@ static void lan_saa9730_set_multicast(struct net_device *dev)
993 961
994static void __devexit saa9730_remove_one(struct pci_dev *pdev) 962static void __devexit saa9730_remove_one(struct pci_dev *pdev)
995{ 963{
996 struct net_device *dev = pci_get_drvdata(pdev); 964 struct net_device *dev = pci_get_drvdata(pdev);
997 965 struct lan_saa9730_private *lp = netdev_priv(dev);
998 if (dev) { 966
999 unregister_netdev(dev); 967 if (dev) {
1000 kfree(dev->priv); 968 unregister_netdev(dev);
1001 free_netdev(dev); 969 lan_saa9730_free_buffers(pdev, lp);
1002 pci_release_regions(pdev); 970 iounmap(lp->lan_saa9730_regs);
1003 pci_disable_device(pdev); 971 iounmap(lp->evm_saa9730_regs);
1004 pci_set_drvdata(pdev, NULL); 972 free_netdev(dev);
1005 } 973 pci_release_regions(pdev);
974 pci_disable_device(pdev);
975 pci_set_drvdata(pdev, NULL);
976 }
1006} 977}
1007 978
1008 979
1009static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) 980static int lan_saa9730_init(struct net_device *dev, struct pci_dev *pdev,
981 unsigned long ioaddr, int irq)
1010{ 982{
1011 struct lan_saa9730_private *lp; 983 struct lan_saa9730_private *lp = netdev_priv(dev);
1012 unsigned char ethernet_addr[6]; 984 unsigned char ethernet_addr[6];
1013 int ret = 0; 985 int ret;
1014 986
1015 dev->open = lan_saa9730_open_fail; 987 if (get_ethernet_addr(ethernet_addr)) {
988 ret = -ENODEV;
989 goto out;
990 }
1016 991
1017 if (get_ethernet_addr(ethernet_addr))
1018 return -ENODEV;
1019
1020 memcpy(dev->dev_addr, ethernet_addr, 6); 992 memcpy(dev->dev_addr, ethernet_addr, 6);
1021 dev->base_addr = ioaddr; 993 dev->base_addr = ioaddr;
1022 dev->irq = irq; 994 dev->irq = irq;
1023
1024 /*
1025 * Make certain the data structures used by the controller are aligned
1026 * and DMAble.
1027 */
1028 /*
1029 * XXX: that is obviously broken - kfree() won't be happy with us.
1030 */
1031 lp = (struct lan_saa9730_private *) (((unsigned long)
1032 kmalloc(sizeof(*lp) + 7,
1033 GFP_DMA | GFP_KERNEL)
1034 + 7) & ~7);
1035 995
1036 if (!lp) 996 lp->pci_dev = pdev;
1037 return -ENOMEM;
1038
1039 dev->priv = lp;
1040 memset(lp, 0, sizeof(*lp));
1041 997
1042 /* Set SAA9730 LAN base address. */ 998 /* Set SAA9730 LAN base address. */
1043 lp->lan_saa9730_regs = (t_lan_saa9730_regmap *) (ioaddr + 999 lp->lan_saa9730_regs = ioremap(ioaddr + SAA9730_LAN_REGS_ADDR,
1044 SAA9730_LAN_REGS_ADDR); 1000 SAA9730_LAN_REGS_SIZE);
1001 if (!lp->lan_saa9730_regs) {
1002 ret = -ENOMEM;
1003 goto out;
1004 }
1045 1005
1046 /* Set SAA9730 EVM base address. */ 1006 /* Set SAA9730 EVM base address. */
1047 lp->evm_saa9730_regs = (t_evm_saa9730_regmap *) (ioaddr + 1007 lp->evm_saa9730_regs = ioremap(ioaddr + SAA9730_EVM_REGS_ADDR,
1048 SAA9730_EVM_REGS_ADDR); 1008 SAA9730_EVM_REGS_SIZE);
1009 if (!lp->evm_saa9730_regs) {
1010 ret = -ENOMEM;
1011 goto out_iounmap_lan;
1012 }
1049 1013
1050 /* Allocate LAN RX/TX frame buffer space. */ 1014 /* Allocate LAN RX/TX frame buffer space. */
1051 /* FIXME: a leak */ 1015 if ((ret = lan_saa9730_allocate_buffers(pdev, lp)))
1052 if ((ret = lan_saa9730_allocate_buffers(lp))) 1016 goto out_iounmap;
1053 goto out;
1054 1017
1055 /* Stop LAN controller. */ 1018 /* Stop LAN controller. */
1056 if ((ret = lan_saa9730_stop(lp))) 1019 if ((ret = lan_saa9730_stop(lp)))
1057 goto out; 1020 goto out_free_consistent;
1058 1021
1059 /* Initialize CAM registers. */ 1022 /* Initialize CAM registers. */
1060 if ((ret = lan_saa9730_cam_init(dev))) 1023 if ((ret = lan_saa9730_cam_init(dev)))
1061 goto out; 1024 goto out_free_consistent;
1062 1025
1063 /* Initialize MII registers. */ 1026 /* Initialize MII registers. */
1064 if ((ret = lan_saa9730_mii_init(lp))) 1027 if ((ret = lan_saa9730_mii_init(lp)))
1065 goto out; 1028 goto out_free_consistent;
1066 1029
1067 /* Initialize control registers. */ 1030 /* Initialize control registers. */
1068 if ((ret = lan_saa9730_control_init(lp))) 1031 if ((ret = lan_saa9730_control_init(lp)))
1069 goto out; 1032 goto out_free_consistent;
1070 1033
1071 /* Load CAM registers. */ 1034 /* Load CAM registers. */
1072 if ((ret = lan_saa9730_cam_load(lp))) 1035 if ((ret = lan_saa9730_cam_load(lp)))
1073 goto out; 1036 goto out_free_consistent;
1074 1037
1075 /* Initialize DMA context registers. */ 1038 /* Initialize DMA context registers. */
1076 if ((ret = lan_saa9730_dma_init(lp))) 1039 if ((ret = lan_saa9730_dma_init(lp)))
1077 goto out; 1040 goto out_free_consistent;
1078 1041
1079 spin_lock_init(&lp->lock); 1042 spin_lock_init(&lp->lock);
1080 1043
1081 dev->open = lan_saa9730_open; 1044 dev->open = lan_saa9730_open;
1082 dev->hard_start_xmit = lan_saa9730_start_xmit; 1045 dev->hard_start_xmit = lan_saa9730_start_xmit;
1083 dev->stop = lan_saa9730_close; 1046 dev->stop = lan_saa9730_close;
@@ -1086,44 +1049,43 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq)
1086 dev->tx_timeout = lan_saa9730_tx_timeout; 1049 dev->tx_timeout = lan_saa9730_tx_timeout;
1087 dev->watchdog_timeo = (HZ >> 1); 1050 dev->watchdog_timeo = (HZ >> 1);
1088 dev->dma = 0; 1051 dev->dma = 0;
1089 1052
1090 ret = register_netdev(dev); 1053 ret = register_netdev (dev);
1091 if (ret) 1054 if (ret)
1092 goto out; 1055 goto out_free_consistent;
1056
1093 return 0; 1057 return 0;
1094 1058
1095 out: 1059out_free_consistent:
1096 kfree(dev->priv); 1060 lan_saa9730_free_buffers(pdev, lp);
1061out_iounmap:
1062 iounmap(lp->evm_saa9730_regs);
1063out_iounmap_lan:
1064 iounmap(lp->lan_saa9730_regs);
1065out:
1097 return ret; 1066 return ret;
1098} 1067}
1099 1068
1100 1069
1101static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1070static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1102{ 1071{
1103 struct net_device *dev; 1072 struct net_device *dev = NULL;
1104 unsigned int pci_ioaddr; 1073 unsigned long pci_ioaddr;
1105 int err; 1074 int err;
1106 1075
1107 if (lan_saa9730_debug > 1) 1076 if (lan_saa9730_debug > 1)
1108 printk("saa9730.c: PCI bios is present, checking for devices...\n"); 1077 printk("saa9730.c: PCI bios is present, checking for devices...\n");
1109 1078
1110 err = -ENOMEM;
1111 dev = alloc_etherdev(0);
1112 if (!dev)
1113 goto out;
1114
1115 SET_MODULE_OWNER(dev);
1116
1117 err = pci_enable_device(pdev); 1079 err = pci_enable_device(pdev);
1118 if (err) { 1080 if (err) {
1119 printk(KERN_ERR "Cannot enable PCI device, aborting.\n"); 1081 printk(KERN_ERR "Cannot enable PCI device, aborting.\n");
1120 goto out1; 1082 goto out;
1121 } 1083 }
1122 1084
1123 err = pci_request_regions(pdev, DRV_MODULE_NAME); 1085 err = pci_request_regions(pdev, DRV_MODULE_NAME);
1124 if (err) { 1086 if (err) {
1125 printk(KERN_ERR "Cannot obtain PCI resources, aborting.\n"); 1087 printk(KERN_ERR "Cannot obtain PCI resources, aborting.\n");
1126 goto out2; 1088 goto out_disable_pdev;
1127 } 1089 }
1128 1090
1129 pci_irq_line = pdev->irq; 1091 pci_irq_line = pdev->irq;
@@ -1132,49 +1094,54 @@ static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_dev
1132 pci_ioaddr = pci_resource_start(pdev, 1); 1094 pci_ioaddr = pci_resource_start(pdev, 1);
1133 pci_set_master(pdev); 1095 pci_set_master(pdev);
1134 1096
1135 printk("Found SAA9730 (PCI) at %#x, irq %d.\n", 1097 printk("Found SAA9730 (PCI) at %lx, irq %d.\n",
1136 pci_ioaddr, pci_irq_line); 1098 pci_ioaddr, pci_irq_line);
1137 1099
1138 err = lan_saa9730_init(dev, pci_ioaddr, pci_irq_line); 1100 dev = alloc_etherdev(sizeof(struct lan_saa9730_private));
1101 if (!dev)
1102 goto out_disable_pdev;
1103
1104 err = lan_saa9730_init(dev, pdev, pci_ioaddr, pci_irq_line);
1139 if (err) { 1105 if (err) {
1140 printk("Lan init failed"); 1106 printk("LAN init failed");
1141 goto out2; 1107 goto out_free_netdev;
1142 } 1108 }
1143 1109
1144 pci_set_drvdata(pdev, dev); 1110 pci_set_drvdata(pdev, dev);
1145 SET_NETDEV_DEV(dev, &pdev->dev); 1111 SET_NETDEV_DEV(dev, &pdev->dev);
1146 return 0; 1112 return 0;
1147 1113
1148out2: 1114out_free_netdev:
1149 pci_disable_device(pdev);
1150out1:
1151 free_netdev(dev); 1115 free_netdev(dev);
1116out_disable_pdev:
1117 pci_disable_device(pdev);
1152out: 1118out:
1119 pci_set_drvdata(pdev, NULL);
1153 return err; 1120 return err;
1154} 1121}
1155 1122
1156 1123
1157static struct pci_driver saa9730_driver = { 1124static struct pci_driver saa9730_driver = {
1158 .name = DRV_MODULE_NAME, 1125 .name = DRV_MODULE_NAME,
1159 .id_table = saa9730_pci_tbl, 1126 .id_table = saa9730_pci_tbl,
1160 .probe = saa9730_init_one, 1127 .probe = saa9730_init_one,
1161 .remove = __devexit_p(saa9730_remove_one), 1128 .remove = __devexit_p(saa9730_remove_one),
1162}; 1129};
1163 1130
1164 1131
1165static int __init saa9730_init(void) 1132static int __init saa9730_init(void)
1166{ 1133{
1167 return pci_module_init(&saa9730_driver); 1134 return pci_module_init(&saa9730_driver);
1168} 1135}
1169 1136
1170static void __exit saa9730_cleanup(void) 1137static void __exit saa9730_cleanup(void)
1171{ 1138{
1172 pci_unregister_driver(&saa9730_driver); 1139 pci_unregister_driver(&saa9730_driver);
1173} 1140}
1174 1141
1175module_init(saa9730_init); 1142module_init(saa9730_init);
1176module_exit(saa9730_cleanup); 1143module_exit(saa9730_cleanup);
1177 1144
1178 1145MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
1179 1146MODULE_DESCRIPTION("Philips SAA9730 ethernet driver");
1180MODULE_LICENSE("GPL"); 1147MODULE_LICENSE("GPL");
diff --git a/drivers/net/saa9730.h b/drivers/net/saa9730.h
index 9e9da6b4080f..a7e9d29a86a7 100644
--- a/drivers/net/saa9730.h
+++ b/drivers/net/saa9730.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * Carsten Langgaard, carstenl@mips.com 2 * Copyright (C) 2000, 2005 MIPS Technologies, Inc. All rights reserved.
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. 3 * Authors: Carsten Langgaard <carstenl@mips.com>
4 * Maciej W. Rozycki <macro@mips.com>
4 * 5 *
5 * ######################################################################## 6 * ########################################################################
6 * 7 *
@@ -265,6 +266,7 @@
265 266
266/* The SAA9730 (LAN) controller register map, as seen via the PCI-bus. */ 267/* The SAA9730 (LAN) controller register map, as seen via the PCI-bus. */
267#define SAA9730_LAN_REGS_ADDR 0x20400 268#define SAA9730_LAN_REGS_ADDR 0x20400
269#define SAA9730_LAN_REGS_SIZE 0x00400
268 270
269struct lan_saa9730_regmap { 271struct lan_saa9730_regmap {
270 volatile unsigned int TxBuffA; /* 0x20400 */ 272 volatile unsigned int TxBuffA; /* 0x20400 */
@@ -309,6 +311,7 @@ typedef volatile struct lan_saa9730_regmap t_lan_saa9730_regmap;
309 311
310/* The SAA9730 (EVM) controller register map, as seen via the PCI-bus. */ 312/* The SAA9730 (EVM) controller register map, as seen via the PCI-bus. */
311#define SAA9730_EVM_REGS_ADDR 0x02000 313#define SAA9730_EVM_REGS_ADDR 0x02000
314#define SAA9730_EVM_REGS_SIZE 0x00400
312 315
313struct evm_saa9730_regmap { 316struct evm_saa9730_regmap {
314 volatile unsigned int InterruptStatus1; /* 0x2000 */ 317 volatile unsigned int InterruptStatus1; /* 0x2000 */
@@ -329,16 +332,32 @@ typedef volatile struct evm_saa9730_regmap t_evm_saa9730_regmap;
329 332
330 333
331struct lan_saa9730_private { 334struct lan_saa9730_private {
335 /*
336 * Rx/Tx packet buffers.
337 * The Rx and Tx packets must be PACKET_SIZE aligned.
338 */
339 void *buffer_start;
340 unsigned int buffer_size;
341
342 /*
343 * DMA address of beginning of this object, returned
344 * by pci_alloc_consistent().
345 */
346 dma_addr_t dma_addr;
347
348 /* Pointer to the associated pci device structure */
349 struct pci_dev *pci_dev;
350
332 /* Pointer for the SAA9730 LAN controller register set. */ 351 /* Pointer for the SAA9730 LAN controller register set. */
333 t_lan_saa9730_regmap *lan_saa9730_regs; 352 t_lan_saa9730_regmap *lan_saa9730_regs;
334 353
335 /* Pointer to the SAA9730 EVM register. */ 354 /* Pointer to the SAA9730 EVM register. */
336 t_evm_saa9730_regmap *evm_saa9730_regs; 355 t_evm_saa9730_regmap *evm_saa9730_regs;
337 356
338 /* TRUE if the next buffer to write is RxBuffA, FALSE if RxBuffB. */
339 unsigned char NextRcvToUseIsA;
340 /* Rcv buffer Index. */ 357 /* Rcv buffer Index. */
341 unsigned char NextRcvPacketIndex; 358 unsigned char NextRcvPacketIndex;
359 /* Next buffer index. */
360 unsigned char NextRcvBufferIndex;
342 361
343 /* Index of next packet to use in that buffer. */ 362 /* Index of next packet to use in that buffer. */
344 unsigned char NextTxmPacketIndex; 363 unsigned char NextTxmPacketIndex;
@@ -353,13 +372,8 @@ struct lan_saa9730_private {
353 unsigned char DmaRcvPackets; 372 unsigned char DmaRcvPackets;
354 unsigned char DmaTxmPackets; 373 unsigned char DmaTxmPackets;
355 374
356 unsigned char RcvAIndex; /* index into RcvBufferSpace[] for Blk A */ 375 void *TxmBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_TXM_Q_SIZE];
357 unsigned char RcvBIndex; /* index into RcvBufferSpace[] for Blk B */ 376 void *RcvBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_RCV_Q_SIZE];
358
359 unsigned int
360 TxmBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_TXM_Q_SIZE];
361 unsigned int
362 RcvBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_RCV_Q_SIZE];
363 unsigned int TxBufferFree[LAN_SAA9730_BUFFERS]; 377 unsigned int TxBufferFree[LAN_SAA9730_BUFFERS];
364 378
365 unsigned char PhysicalAddress[LAN_SAA9730_CAM_ENTRIES][6]; 379 unsigned char PhysicalAddress[LAN_SAA9730_CAM_ENTRIES][6];
diff --git a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
index 6783039ffb75..7653d6e33aa2 100644
--- a/drivers/net/sk98lin/Makefile
+++ b/drivers/net/sk98lin/Makefile
@@ -27,8 +27,7 @@ sk98lin-objs := \
27 sktimer.o \ 27 sktimer.o \
28 skvpd.o \ 28 skvpd.o \
29 skxmac2.o \ 29 skxmac2.o \
30 skproc.o \ 30 skproc.o
31 skcsum.o
32 31
33# DBGDEF = \ 32# DBGDEF = \
34# -DDEBUG 33# -DDEBUG
@@ -77,7 +76,7 @@ endif
77# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources 76# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources
78# SK_DBGCAT_DRV_EVENT 0x08000000 driver events 77# SK_DBGCAT_DRV_EVENT 0x08000000 driver events
79 78
80EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM) 79EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
81 80
82clean: 81clean:
83 rm -f core *.o *.a *.s 82 rm -f core *.o *.a *.s
diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
index 542cec57f86a..2dc5728e3ef6 100644
--- a/drivers/net/sk98lin/h/skdrv2nd.h
+++ b/drivers/net/sk98lin/h/skdrv2nd.h
@@ -425,10 +425,6 @@ struct s_AC {
425 TX_PORT TxPort[SK_MAX_MACS][2]; 425 TX_PORT TxPort[SK_MAX_MACS][2];
426 RX_PORT RxPort[SK_MAX_MACS]; 426 RX_PORT RxPort[SK_MAX_MACS];
427 427
428 unsigned int CsOfs1; /* for checksum calculation */
429 unsigned int CsOfs2; /* for checksum calculation */
430 SK_U32 CsOfs; /* for checksum calculation */
431
432 SK_BOOL CheckQueue; /* check event queue soon */ 428 SK_BOOL CheckQueue; /* check event queue soon */
433 SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */ 429 SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */
434 DIM_INFO DynIrqModInfo; /* all data related to DIM */ 430 DIM_INFO DynIrqModInfo; /* all data related to DIM */
diff --git a/drivers/net/sk98lin/skcsum.c b/drivers/net/sk98lin/skcsum.c
deleted file mode 100644
index 38a6e7a631f3..000000000000
--- a/drivers/net/sk98lin/skcsum.c
+++ /dev/null
@@ -1,871 +0,0 @@
1/******************************************************************************
2 *
3 * Name: skcsum.c
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.12 $
6 * Date: $Date: 2003/08/20 13:55:53 $
7 * Purpose: Store/verify Internet checksum in send/receive packets.
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * The information in this file is provided "AS IS" without warranty.
21 *
22 ******************************************************************************/
23
24#ifdef SK_USE_CSUM /* Check if CSUM is to be used. */
25
26#ifndef lint
27static const char SysKonnectFileId[] =
28 "@(#) $Id: skcsum.c,v 1.12 2003/08/20 13:55:53 mschmid Exp $ (C) SysKonnect.";
29#endif /* !lint */
30
31/******************************************************************************
32 *
33 * Description:
34 *
35 * This is the "GEnesis" common module "CSUM".
36 *
37 * This module contains the code necessary to calculate, store, and verify the
38 * Internet Checksum of IP, TCP, and UDP frames.
39 *
40 * "GEnesis" is an abbreviation of "Gigabit Ethernet Network System in Silicon"
41 * and is the code name of this SysKonnect project.
42 *
43 * Compilation Options:
44 *
45 * SK_USE_CSUM - Define if CSUM is to be used. Otherwise, CSUM will be an
46 * empty module.
47 *
48 * SKCS_OVERWRITE_PROTO - Define to overwrite the default protocol id
49 * definitions. In this case, all SKCS_PROTO_xxx definitions must be made
50 * external.
51 *
52 * SKCS_OVERWRITE_STATUS - Define to overwrite the default return status
53 * definitions. In this case, all SKCS_STATUS_xxx definitions must be made
54 * external.
55 *
56 * Include File Hierarchy:
57 *
58 * "h/skdrv1st.h"
59 * "h/skcsum.h"
60 * "h/sktypes.h"
61 * "h/skqueue.h"
62 * "h/skdrv2nd.h"
63 *
64 ******************************************************************************/
65
66#include "h/skdrv1st.h"
67#include "h/skcsum.h"
68#include "h/skdrv2nd.h"
69
70/* defines ********************************************************************/
71
72/* The size of an Ethernet MAC header. */
73#define SKCS_ETHERNET_MAC_HEADER_SIZE (6+6+2)
74
75/* The size of the used topology's MAC header. */
76#define SKCS_MAC_HEADER_SIZE SKCS_ETHERNET_MAC_HEADER_SIZE
77
78/* The size of the IP header without any option fields. */
79#define SKCS_IP_HEADER_SIZE 20
80
81/*
82 * Field offsets within the IP header.
83 */
84
85/* "Internet Header Version" and "Length". */
86#define SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH 0
87
88/* "Total Length". */
89#define SKCS_OFS_IP_TOTAL_LENGTH 2
90
91/* "Flags" "Fragment Offset". */
92#define SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET 6
93
94/* "Next Level Protocol" identifier. */
95#define SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL 9
96
97/* Source IP address. */
98#define SKCS_OFS_IP_SOURCE_ADDRESS 12
99
100/* Destination IP address. */
101#define SKCS_OFS_IP_DESTINATION_ADDRESS 16
102
103
104/*
105 * Field offsets within the UDP header.
106 */
107
108/* UDP checksum. */
109#define SKCS_OFS_UDP_CHECKSUM 6
110
111/* IP "Next Level Protocol" identifiers (see RFC 790). */
112#define SKCS_PROTO_ID_TCP 6 /* Transport Control Protocol */
113#define SKCS_PROTO_ID_UDP 17 /* User Datagram Protocol */
114
115/* IP "Don't Fragment" bit. */
116#define SKCS_IP_DONT_FRAGMENT SKCS_HTON16(0x4000)
117
118/* Add a byte offset to a pointer. */
119#define SKCS_IDX(pPtr, Ofs) ((void *) ((char *) (pPtr) + (Ofs)))
120
121/*
122 * Macros that convert host to network representation and vice versa, i.e.
123 * little/big endian conversion on little endian machines only.
124 */
125#ifdef SK_LITTLE_ENDIAN
126#define SKCS_HTON16(Val16) (((unsigned) (Val16) >> 8) | (((Val16) & 0xff) << 8))
127#endif /* SK_LITTLE_ENDIAN */
128#ifdef SK_BIG_ENDIAN
129#define SKCS_HTON16(Val16) (Val16)
130#endif /* SK_BIG_ENDIAN */
131#define SKCS_NTOH16(Val16) SKCS_HTON16(Val16)
132
133/* typedefs *******************************************************************/
134
135/* function prototypes ********************************************************/
136
137/******************************************************************************
138 *
139 * SkCsGetSendInfo - get checksum information for a send packet
140 *
141 * Description:
142 * Get all checksum information necessary to send a TCP or UDP packet. The
143 * function checks the IP header passed to it. If the high-level protocol
144 * is either TCP or UDP the pseudo header checksum is calculated and
145 * returned.
146 *
147 * The function returns the total length of the IP header (including any
148 * IP option fields), which is the same as the start offset of the IP data
149 * which in turn is the start offset of the TCP or UDP header.
150 *
151 * The function also returns the TCP or UDP pseudo header checksum, which
152 * should be used as the start value for the hardware checksum calculation.
153 * (Note that any actual pseudo header checksum can never calculate to
154 * zero.)
155 *
156 * Note:
157 * There is a bug in the GENESIS ASIC which may lead to wrong checksums.
158 *
159 * Arguments:
160 * pAc - A pointer to the adapter context struct.
161 *
162 * pIpHeader - Pointer to IP header. Must be at least the IP header *not*
163 * including any option fields, i.e. at least 20 bytes.
164 *
165 * Note: This pointer will be used to address 8-, 16-, and 32-bit
166 * variables with the respective alignment offsets relative to the pointer.
167 * Thus, the pointer should point to a 32-bit aligned address. If the
168 * target system cannot address 32-bit variables on non 32-bit aligned
169 * addresses, then the pointer *must* point to a 32-bit aligned address.
170 *
171 * pPacketInfo - A pointer to the packet information structure for this
172 * packet. Before calling this SkCsGetSendInfo(), the following field must
173 * be initialized:
174 *
175 * ProtocolFlags - Initialize with any combination of
176 * SKCS_PROTO_XXX bit flags. SkCsGetSendInfo() will only work on
177 * the protocols specified here. Any protocol(s) not specified
178 * here will be ignored.
179 *
180 * Note: Only one checksum can be calculated in hardware. Thus, if
181 * SKCS_PROTO_IP is specified in the 'ProtocolFlags',
182 * SkCsGetSendInfo() must calculate the IP header checksum in
183 * software. It might be a better idea to have the calling
184 * protocol stack calculate the IP header checksum.
185 *
186 * Returns: N/A
187 * On return, the following fields in 'pPacketInfo' may or may not have
188 * been filled with information, depending on the protocol(s) found in the
189 * packet:
190 *
191 * ProtocolFlags - Returns the SKCS_PROTO_XXX bit flags of the protocol(s)
192 * that were both requested by the caller and actually found in the packet.
193 * Protocol(s) not specified by the caller and/or not found in the packet
194 * will have their respective SKCS_PROTO_XXX bit flags reset.
195 *
196 * Note: For IP fragments, TCP and UDP packet information is ignored.
197 *
198 * IpHeaderLength - The total length in bytes of the complete IP header
199 * including any option fields is returned here. This is the start offset
200 * of the IP data, i.e. the TCP or UDP header if present.
201 *
202 * IpHeaderChecksum - If IP has been specified in the 'ProtocolFlags', the
203 * 16-bit Internet Checksum of the IP header is returned here. This value
204 * is to be stored into the packet's 'IP Header Checksum' field.
205 *
206 * PseudoHeaderChecksum - If this is a TCP or UDP packet and if TCP or UDP
207 * has been specified in the 'ProtocolFlags', the 16-bit Internet Checksum
208 * of the TCP or UDP pseudo header is returned here.
209 */
210void SkCsGetSendInfo(
211SK_AC *pAc, /* Adapter context struct. */
212void *pIpHeader, /* IP header. */
213SKCS_PACKET_INFO *pPacketInfo, /* Packet information struct. */
214int NetNumber) /* Net number */
215{
216 /* Internet Header Version found in IP header. */
217 unsigned InternetHeaderVersion;
218
219 /* Length of the IP header as found in IP header. */
220 unsigned IpHeaderLength;
221
222 /* Bit field specifiying the desired/found protocols. */
223 unsigned ProtocolFlags;
224
225 /* Next level protocol identifier found in IP header. */
226 unsigned NextLevelProtocol;
227
228 /* Length of IP data portion. */
229 unsigned IpDataLength;
230
231 /* TCP/UDP pseudo header checksum. */
232 unsigned long PseudoHeaderChecksum;
233
234 /* Pointer to next level protocol statistics structure. */
235 SKCS_PROTO_STATS *NextLevelProtoStats;
236
237 /* Temporary variable. */
238 unsigned Tmp;
239
240 Tmp = *(SK_U8 *)
241 SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
242
243 /* Get the Internet Header Version (IHV). */
244 /* Note: The IHV is stored in the upper four bits. */
245
246 InternetHeaderVersion = Tmp >> 4;
247
248 /* Check the Internet Header Version. */
249 /* Note: We currently only support IP version 4. */
250
251 if (InternetHeaderVersion != 4) { /* IPv4? */
252 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
253 ("Tx: Unknown Internet Header Version %u.\n",
254 InternetHeaderVersion));
255 pPacketInfo->ProtocolFlags = 0;
256 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
257 return;
258 }
259
260 /* Get the IP header length (IHL). */
261 /*
262 * Note: The IHL is stored in the lower four bits as the number of
263 * 4-byte words.
264 */
265
266 IpHeaderLength = (Tmp & 0xf) * 4;
267 pPacketInfo->IpHeaderLength = IpHeaderLength;
268
269 /* Check the IP header length. */
270
271 /* 04-Aug-1998 sw - Really check the IHL? Necessary? */
272
273 if (IpHeaderLength < 5*4) {
274 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
275 ("Tx: Invalid IP Header Length %u.\n", IpHeaderLength));
276 pPacketInfo->ProtocolFlags = 0;
277 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
278 return;
279 }
280
281 /* This is an IPv4 frame with a header of valid length. */
282
283 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxOkCts++;
284
285 /* Check if we should calculate the IP header checksum. */
286
287 ProtocolFlags = pPacketInfo->ProtocolFlags;
288
289 if (ProtocolFlags & SKCS_PROTO_IP) {
290 pPacketInfo->IpHeaderChecksum =
291 SkCsCalculateChecksum(pIpHeader, IpHeaderLength);
292 }
293
294 /* Get the next level protocol identifier. */
295
296 NextLevelProtocol =
297 *(SK_U8 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
298
299 /*
300 * Check if this is a TCP or UDP frame and if we should calculate the
301 * TCP/UDP pseudo header checksum.
302 *
303 * Also clear all protocol bit flags of protocols not present in the
304 * frame.
305 */
306
307 if ((ProtocolFlags & SKCS_PROTO_TCP) != 0 &&
308 NextLevelProtocol == SKCS_PROTO_ID_TCP) {
309 /* TCP/IP frame. */
310 ProtocolFlags &= SKCS_PROTO_TCP | SKCS_PROTO_IP;
311 NextLevelProtoStats =
312 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
313 }
314 else if ((ProtocolFlags & SKCS_PROTO_UDP) != 0 &&
315 NextLevelProtocol == SKCS_PROTO_ID_UDP) {
316 /* UDP/IP frame. */
317 ProtocolFlags &= SKCS_PROTO_UDP | SKCS_PROTO_IP;
318 NextLevelProtoStats =
319 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
320 }
321 else {
322 /*
323 * Either not a TCP or UDP frame and/or TCP/UDP processing not
324 * specified.
325 */
326 pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
327 return;
328 }
329
330 /* Check if this is an IP fragment. */
331
332 /*
333 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
334 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
335 * and the "More Fragments" are zero, it is *not* a fragment. We can
336 * easily check both at the same time since they are in the same 16-bit
337 * word.
338 */
339
340 if ((*(SK_U16 *)
341 SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
342 ~SKCS_IP_DONT_FRAGMENT) != 0) {
343 /* IP fragment; ignore all other protocols. */
344 pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
345 NextLevelProtoStats->TxUnableCts++;
346 return;
347 }
348
349 /*
350 * Calculate the TCP/UDP pseudo header checksum.
351 */
352
353 /* Get total length of IP header and data. */
354
355 IpDataLength =
356 *(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
357
358 /* Get length of IP data portion. */
359
360 IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
361
362 /* Calculate the sum of all pseudo header fields (16-bit). */
363
364 PseudoHeaderChecksum =
365 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
366 SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
367 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
368 SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
369 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
370 SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
371 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
372 SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
373 (unsigned long) SKCS_HTON16(NextLevelProtocol) +
374 (unsigned long) SKCS_HTON16(IpDataLength);
375
376 /* Add-in any carries. */
377
378 SKCS_OC_ADD(PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
379
380 /* Add-in any new carry. */
381
382 SKCS_OC_ADD(pPacketInfo->PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
383
384 pPacketInfo->ProtocolFlags = ProtocolFlags;
385 NextLevelProtoStats->TxOkCts++; /* Success. */
386} /* SkCsGetSendInfo */
387
388
389/******************************************************************************
390 *
391 * SkCsGetReceiveInfo - verify checksum information for a received packet
392 *
393 * Description:
394 * Verify a received frame's checksum. The function returns a status code
395 * reflecting the result of the verification.
396 *
397 * Note:
398 * Before calling this function you have to verify that the frame is
399 * not padded and Checksum1 and Checksum2 are bigger than 1.
400 *
401 * Arguments:
402 * pAc - Pointer to adapter context struct.
403 *
404 * pIpHeader - Pointer to IP header. Must be at least the length in bytes
405 * of the received IP header including any option fields. For UDP packets,
406 * 8 additional bytes are needed to access the UDP checksum.
407 *
408 * Note: The actual length of the IP header is stored in the lower four
409 * bits of the first octet of the IP header as the number of 4-byte words,
410 * so it must be multiplied by four to get the length in bytes. Thus, the
411 * maximum IP header length is 15 * 4 = 60 bytes.
412 *
413 * Checksum1 - The first 16-bit Internet Checksum calculated by the
414 * hardware starting at the offset returned by SkCsSetReceiveFlags().
415 *
416 * Checksum2 - The second 16-bit Internet Checksum calculated by the
417 * hardware starting at the offset returned by SkCsSetReceiveFlags().
418 *
419 * Returns:
420 * SKCS_STATUS_UNKNOWN_IP_VERSION - Not an IP v4 frame.
421 * SKCS_STATUS_IP_CSUM_ERROR - IP checksum error.
422 * SKCS_STATUS_IP_CSUM_ERROR_TCP - IP checksum error in TCP frame.
423 * SKCS_STATUS_IP_CSUM_ERROR_UDP - IP checksum error in UDP frame
424 * SKCS_STATUS_IP_FRAGMENT - IP fragment (IP checksum ok).
425 * SKCS_STATUS_IP_CSUM_OK - IP checksum ok (not a TCP or UDP frame).
426 * SKCS_STATUS_TCP_CSUM_ERROR - TCP checksum error (IP checksum ok).
427 * SKCS_STATUS_UDP_CSUM_ERROR - UDP checksum error (IP checksum ok).
428 * SKCS_STATUS_TCP_CSUM_OK - IP and TCP checksum ok.
429 * SKCS_STATUS_UDP_CSUM_OK - IP and UDP checksum ok.
430 * SKCS_STATUS_IP_CSUM_OK_NO_UDP - IP checksum OK and no UDP checksum.
431 *
432 * Note: If SKCS_OVERWRITE_STATUS is defined, the SKCS_STATUS_XXX values
433 * returned here can be defined in some header file by the module using CSUM.
434 * In this way, the calling module can assign return values for its own needs,
435 * e.g. by assigning bit flags to the individual protocols.
436 */
437SKCS_STATUS SkCsGetReceiveInfo(
438SK_AC *pAc, /* Adapter context struct. */
439void *pIpHeader, /* IP header. */
440unsigned Checksum1, /* Hardware checksum 1. */
441unsigned Checksum2, /* Hardware checksum 2. */
442int NetNumber) /* Net number */
443{
444 /* Internet Header Version found in IP header. */
445 unsigned InternetHeaderVersion;
446
447 /* Length of the IP header as found in IP header. */
448 unsigned IpHeaderLength;
449
450 /* Length of IP data portion. */
451 unsigned IpDataLength;
452
453 /* IP header checksum. */
454 unsigned IpHeaderChecksum;
455
456 /* IP header options checksum, if any. */
457 unsigned IpOptionsChecksum;
458
459 /* IP data checksum, i.e. TCP/UDP checksum. */
460 unsigned IpDataChecksum;
461
462 /* Next level protocol identifier found in IP header. */
463 unsigned NextLevelProtocol;
464
465 /* The checksum of the "next level protocol", i.e. TCP or UDP. */
466 unsigned long NextLevelProtocolChecksum;
467
468 /* Pointer to next level protocol statistics structure. */
469 SKCS_PROTO_STATS *NextLevelProtoStats;
470
471 /* Temporary variable. */
472 unsigned Tmp;
473
474 Tmp = *(SK_U8 *)
475 SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
476
477 /* Get the Internet Header Version (IHV). */
478 /* Note: The IHV is stored in the upper four bits. */
479
480 InternetHeaderVersion = Tmp >> 4;
481
482 /* Check the Internet Header Version. */
483 /* Note: We currently only support IP version 4. */
484
485 if (InternetHeaderVersion != 4) { /* IPv4? */
486 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
487 ("Rx: Unknown Internet Header Version %u.\n",
488 InternetHeaderVersion));
489 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxUnableCts++;
490 return (SKCS_STATUS_UNKNOWN_IP_VERSION);
491 }
492
493 /* Get the IP header length (IHL). */
494 /*
495 * Note: The IHL is stored in the lower four bits as the number of
496 * 4-byte words.
497 */
498
499 IpHeaderLength = (Tmp & 0xf) * 4;
500
501 /* Check the IP header length. */
502
503 /* 04-Aug-1998 sw - Really check the IHL? Necessary? */
504
505 if (IpHeaderLength < 5*4) {
506 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
507 ("Rx: Invalid IP Header Length %u.\n", IpHeaderLength));
508 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
509 return (SKCS_STATUS_IP_CSUM_ERROR);
510 }
511
512 /* This is an IPv4 frame with a header of valid length. */
513
514 /* Get the IP header and data checksum. */
515
516 IpDataChecksum = Checksum2;
517
518 /*
519 * The IP header checksum is calculated as follows:
520 *
521 * IpHeaderChecksum = Checksum1 - Checksum2
522 */
523
524 SKCS_OC_SUB(IpHeaderChecksum, Checksum1, Checksum2);
525
526 /* Check if any IP header options. */
527
528 if (IpHeaderLength > SKCS_IP_HEADER_SIZE) {
529
530 /* Get the IP options checksum. */
531
532 IpOptionsChecksum = SkCsCalculateChecksum(
533 SKCS_IDX(pIpHeader, SKCS_IP_HEADER_SIZE),
534 IpHeaderLength - SKCS_IP_HEADER_SIZE);
535
536 /* Adjust the IP header and IP data checksums. */
537
538 SKCS_OC_ADD(IpHeaderChecksum, IpHeaderChecksum, IpOptionsChecksum);
539
540 SKCS_OC_SUB(IpDataChecksum, IpDataChecksum, IpOptionsChecksum);
541 }
542
543 /*
544 * Check if the IP header checksum is ok.
545 *
546 * NOTE: We must check the IP header checksum even if the caller just wants
547 * us to check upper-layer checksums, because we cannot do any further
548 * processing of the packet without a valid IP checksum.
549 */
550
551 /* Get the next level protocol identifier. */
552
553 NextLevelProtocol = *(SK_U8 *)
554 SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
555
556 if (IpHeaderChecksum != 0xffff) {
557 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
558 /* the NDIS tester wants to know the upper level protocol too */
559 if (NextLevelProtocol == SKCS_PROTO_ID_TCP) {
560 return(SKCS_STATUS_IP_CSUM_ERROR_TCP);
561 }
562 else if (NextLevelProtocol == SKCS_PROTO_ID_UDP) {
563 return(SKCS_STATUS_IP_CSUM_ERROR_UDP);
564 }
565 return (SKCS_STATUS_IP_CSUM_ERROR);
566 }
567
568 /*
569 * Check if this is a TCP or UDP frame and if we should calculate the
570 * TCP/UDP pseudo header checksum.
571 *
572 * Also clear all protocol bit flags of protocols not present in the
573 * frame.
574 */
575
576 if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_TCP) != 0 &&
577 NextLevelProtocol == SKCS_PROTO_ID_TCP) {
578 /* TCP/IP frame. */
579 NextLevelProtoStats =
580 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
581 }
582 else if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_UDP) != 0 &&
583 NextLevelProtocol == SKCS_PROTO_ID_UDP) {
584 /* UDP/IP frame. */
585 NextLevelProtoStats =
586 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
587 }
588 else {
589 /*
590 * Either not a TCP or UDP frame and/or TCP/UDP processing not
591 * specified.
592 */
593 return (SKCS_STATUS_IP_CSUM_OK);
594 }
595
596 /* Check if this is an IP fragment. */
597
598 /*
599 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
600 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
601 * and the "More Fragments" are zero, it is *not* a fragment. We can
602 * easily check both at the same time since they are in the same 16-bit
603 * word.
604 */
605
606 if ((*(SK_U16 *)
607 SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
608 ~SKCS_IP_DONT_FRAGMENT) != 0) {
609 /* IP fragment; ignore all other protocols. */
610 NextLevelProtoStats->RxUnableCts++;
611 return (SKCS_STATUS_IP_FRAGMENT);
612 }
613
614 /*
615 * 08-May-2000 ra
616 *
617 * From RFC 768 (UDP)
618 * If the computed checksum is zero, it is transmitted as all ones (the
619 * equivalent in one's complement arithmetic). An all zero transmitted
620 * checksum value means that the transmitter generated no checksum (for
621 * debugging or for higher level protocols that don't care).
622 */
623
624 if (NextLevelProtocol == SKCS_PROTO_ID_UDP &&
625 *(SK_U16*)SKCS_IDX(pIpHeader, IpHeaderLength + 6) == 0x0000) {
626
627 NextLevelProtoStats->RxOkCts++;
628
629 return (SKCS_STATUS_IP_CSUM_OK_NO_UDP);
630 }
631
632 /*
633 * Calculate the TCP/UDP checksum.
634 */
635
636 /* Get total length of IP header and data. */
637
638 IpDataLength =
639 *(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
640
641 /* Get length of IP data portion. */
642
643 IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
644
645 NextLevelProtocolChecksum =
646
647 /* Calculate the pseudo header checksum. */
648
649 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
650 SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
651 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
652 SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
653 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
654 SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
655 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
656 SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
657 (unsigned long) SKCS_HTON16(NextLevelProtocol) +
658 (unsigned long) SKCS_HTON16(IpDataLength) +
659
660 /* Add the TCP/UDP header checksum. */
661
662 (unsigned long) IpDataChecksum;
663
664 /* Add-in any carries. */
665
666 SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
667
668 /* Add-in any new carry. */
669
670 SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
671
672 /* Check if the TCP/UDP checksum is ok. */
673
674 if ((unsigned) NextLevelProtocolChecksum == 0xffff) {
675
676 /* TCP/UDP checksum ok. */
677
678 NextLevelProtoStats->RxOkCts++;
679
680 return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
681 SKCS_STATUS_TCP_CSUM_OK : SKCS_STATUS_UDP_CSUM_OK);
682 }
683
684 /* TCP/UDP checksum error. */
685
686 NextLevelProtoStats->RxErrCts++;
687
688 return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
689 SKCS_STATUS_TCP_CSUM_ERROR : SKCS_STATUS_UDP_CSUM_ERROR);
690} /* SkCsGetReceiveInfo */
691
692
693/******************************************************************************
694 *
695 * SkCsSetReceiveFlags - set checksum receive flags
696 *
697 * Description:
698 * Use this function to set the various receive flags. According to the
699 * protocol flags set by the caller, the start offsets within received
700 * packets of the two hardware checksums are returned. These offsets must
701 * be stored in all receive descriptors.
702 *
703 * Arguments:
704 * pAc - Pointer to adapter context struct.
705 *
706 * ReceiveFlags - Any combination of SK_PROTO_XXX flags of the protocols
707 * for which the caller wants checksum information on received frames.
708 *
709 * pChecksum1Offset - The start offset of the first receive descriptor
710 * hardware checksum to be calculated for received frames is returned
711 * here.
712 *
713 * pChecksum2Offset - The start offset of the second receive descriptor
714 * hardware checksum to be calculated for received frames is returned
715 * here.
716 *
717 * Returns: N/A
718 * Returns the two hardware checksum start offsets.
719 */
720void SkCsSetReceiveFlags(
721SK_AC *pAc, /* Adapter context struct. */
722unsigned ReceiveFlags, /* New receive flags. */
723unsigned *pChecksum1Offset, /* Offset for hardware checksum 1. */
724unsigned *pChecksum2Offset, /* Offset for hardware checksum 2. */
725int NetNumber)
726{
727 /* Save the receive flags. */
728
729 pAc->Csum.ReceiveFlags[NetNumber] = ReceiveFlags;
730
731 /* First checksum start offset is the IP header. */
732 *pChecksum1Offset = SKCS_MAC_HEADER_SIZE;
733
734 /*
735 * Second checksum start offset is the IP data. Note that this may vary
736 * if there are any IP header options in the actual packet.
737 */
738 *pChecksum2Offset = SKCS_MAC_HEADER_SIZE + SKCS_IP_HEADER_SIZE;
739} /* SkCsSetReceiveFlags */
740
741#ifndef SK_CS_CALCULATE_CHECKSUM
742
743/******************************************************************************
744 *
745 * SkCsCalculateChecksum - calculate checksum for specified data
746 *
747 * Description:
748 * Calculate and return the 16-bit Internet Checksum for the specified
749 * data.
750 *
751 * Arguments:
752 * pData - Pointer to data for which the checksum shall be calculated.
753 * Note: The pointer should be aligned on a 16-bit boundary.
754 *
755 * Length - Length in bytes of data to checksum.
756 *
757 * Returns:
758 * The 16-bit Internet Checksum for the specified data.
759 *
760 * Note: The checksum is calculated in the machine's natural byte order,
761 * i.e. little vs. big endian. Thus, the resulting checksum is different
762 * for the same input data on little and big endian machines.
763 *
764 * However, when written back to the network packet, the byte order is
765 * always in correct network order.
766 */
767unsigned SkCsCalculateChecksum(
768void *pData, /* Data to checksum. */
769unsigned Length) /* Length of data. */
770{
771 SK_U16 *pU16; /* Pointer to the data as 16-bit words. */
772 unsigned long Checksum; /* Checksum; must be at least 32 bits. */
773
774 /* Sum up all 16-bit words. */
775
776 pU16 = (SK_U16 *) pData;
777 for (Checksum = 0; Length > 1; Length -= 2) {
778 Checksum += *pU16++;
779 }
780
781 /* If this is an odd number of bytes, add-in the last byte. */
782
783 if (Length > 0) {
784#ifdef SK_BIG_ENDIAN
785 /* Add the last byte as the high byte. */
786 Checksum += ((unsigned) *(SK_U8 *) pU16) << 8;
787#else /* !SK_BIG_ENDIAN */
788 /* Add the last byte as the low byte. */
789 Checksum += *(SK_U8 *) pU16;
790#endif /* !SK_BIG_ENDIAN */
791 }
792
793 /* Add-in any carries. */
794
795 SKCS_OC_ADD(Checksum, Checksum, 0);
796
797 /* Add-in any new carry. */
798
799 SKCS_OC_ADD(Checksum, Checksum, 0);
800
801 /* Note: All bits beyond the 16-bit limit are now zero. */
802
803 return ((unsigned) Checksum);
804} /* SkCsCalculateChecksum */
805
806#endif /* SK_CS_CALCULATE_CHECKSUM */
807
808/******************************************************************************
809 *
810 * SkCsEvent - the CSUM event dispatcher
811 *
812 * Description:
813 * This is the event handler for the CSUM module.
814 *
815 * Arguments:
816 * pAc - Pointer to adapter context.
817 *
818 * Ioc - I/O context.
819 *
820 * Event - Event id.
821 *
822 * Param - Event dependent parameter.
823 *
824 * Returns:
825 * The 16-bit Internet Checksum for the specified data.
826 *
827 * Note: The checksum is calculated in the machine's natural byte order,
828 * i.e. little vs. big endian. Thus, the resulting checksum is different
829 * for the same input data on little and big endian machines.
830 *
831 * However, when written back to the network packet, the byte order is
832 * always in correct network order.
833 */
834int SkCsEvent(
835SK_AC *pAc, /* Pointer to adapter context. */
836SK_IOC Ioc, /* I/O context. */
837SK_U32 Event, /* Event id. */
838SK_EVPARA Param) /* Event dependent parameter. */
839{
840 int ProtoIndex;
841 int NetNumber;
842
843 switch (Event) {
844 /*
845 * Clear protocol statistics.
846 *
847 * Param - Protocol index, or -1 for all protocols.
848 * - Net number.
849 */
850 case SK_CSUM_EVENT_CLEAR_PROTO_STATS:
851
852 ProtoIndex = (int)Param.Para32[1];
853 NetNumber = (int)Param.Para32[0];
854 if (ProtoIndex < 0) { /* Clear for all protocols. */
855 if (NetNumber >= 0) {
856 SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][0], 0,
857 sizeof(pAc->Csum.ProtoStats[NetNumber]));
858 }
859 }
860 else { /* Clear for individual protocol. */
861 SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][ProtoIndex], 0,
862 sizeof(pAc->Csum.ProtoStats[NetNumber][ProtoIndex]));
863 }
864 break;
865 default:
866 break;
867 }
868 return (0); /* Success. */
869} /* SkCsEvent */
870
871#endif /* SK_USE_CSUM */
diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
index fb639959292b..b71769ae4603 100644
--- a/drivers/net/sk98lin/skethtool.c
+++ b/drivers/net/sk98lin/skethtool.c
@@ -549,4 +549,6 @@ struct ethtool_ops SkGeEthtoolOps = {
549 .phys_id = locateDevice, 549 .phys_id = locateDevice,
550 .get_pauseparam = getPauseParams, 550 .get_pauseparam = getPauseParams,
551 .set_pauseparam = setPauseParams, 551 .set_pauseparam = setPauseParams,
552 .get_link = ethtool_op_get_link,
553 .get_perm_addr = ethtool_op_get_perm_addr,
552}; 554};
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index b18c92cb629e..ae7343934758 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -101,7 +101,6 @@
101 * "h/skgeinit.h" 101 * "h/skgeinit.h"
102 * "h/skaddr.h" 102 * "h/skaddr.h"
103 * "h/skgesirq.h" 103 * "h/skgesirq.h"
104 * "h/skcsum.h"
105 * "h/skrlmt.h" 104 * "h/skrlmt.h"
106 * 105 *
107 ******************************************************************************/ 106 ******************************************************************************/
@@ -113,6 +112,7 @@
113#include <linux/init.h> 112#include <linux/init.h>
114#include <linux/proc_fs.h> 113#include <linux/proc_fs.h>
115#include <linux/dma-mapping.h> 114#include <linux/dma-mapping.h>
115#include <linux/ip.h>
116 116
117#include "h/skdrv1st.h" 117#include "h/skdrv1st.h"
118#include "h/skdrv2nd.h" 118#include "h/skdrv2nd.h"
@@ -601,11 +601,6 @@ SK_BOOL DualNet;
601 return(-EAGAIN); 601 return(-EAGAIN);
602 } 602 }
603 603
604 SkCsSetReceiveFlags(pAC,
605 SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
606 &pAC->CsOfs1, &pAC->CsOfs2, 0);
607 pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
608
609 BoardInitMem(pAC); 604 BoardInitMem(pAC);
610 /* tschilling: New common function with minimum size check. */ 605 /* tschilling: New common function with minimum size check. */
611 DualNet = SK_FALSE; 606 DualNet = SK_FALSE;
@@ -823,7 +818,7 @@ uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */
823 /* set the pointers right */ 818 /* set the pointers right */
824 pDescr->VNextRxd = VNextDescr & 0xffffffffULL; 819 pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
825 pDescr->pNextRxd = pNextDescr; 820 pDescr->pNextRxd = pNextDescr;
826 pDescr->TcpSumStarts = pAC->CsOfs; 821 if (!IsTx) pDescr->TcpSumStarts = ETH_HLEN << 16 | ETH_HLEN;
827 822
828 /* advance one step */ 823 /* advance one step */
829 pPrevDescr = pDescr; 824 pPrevDescr = pDescr;
@@ -1505,8 +1500,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1505 TXD *pOldTxd; 1500 TXD *pOldTxd;
1506 unsigned long Flags; 1501 unsigned long Flags;
1507 SK_U64 PhysAddr; 1502 SK_U64 PhysAddr;
1508 int Protocol;
1509 int IpHeaderLength;
1510 int BytesSend = pMessage->len; 1503 int BytesSend = pMessage->len;
1511 1504
1512 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X")); 1505 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X"));
@@ -1579,8 +1572,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1579 pTxd->pMBuf = pMessage; 1572 pTxd->pMBuf = pMessage;
1580 1573
1581 if (pMessage->ip_summed == CHECKSUM_HW) { 1574 if (pMessage->ip_summed == CHECKSUM_HW) {
1582 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1575 u16 hdrlen = pMessage->h.raw - pMessage->data;
1583 if ((Protocol == C_PROTO_ID_UDP) && 1576 u16 offset = hdrlen + pMessage->csum;
1577
1578 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1584 (pAC->GIni.GIChipRev == 0) && 1579 (pAC->GIni.GIChipRev == 0) &&
1585 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1580 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1586 pTxd->TBControl = BMU_TCP_CHECK; 1581 pTxd->TBControl = BMU_TCP_CHECK;
@@ -1588,14 +1583,9 @@ struct sk_buff *pMessage) /* pointer to send-message */
1588 pTxd->TBControl = BMU_UDP_CHECK; 1583 pTxd->TBControl = BMU_UDP_CHECK;
1589 } 1584 }
1590 1585
1591 IpHeaderLength = (SK_U8)pMessage->data[C_OFFSET_IPHEADER]; 1586 pTxd->TcpSumOfs = 0;
1592 IpHeaderLength = (IpHeaderLength & 0xf) * 4; 1587 pTxd->TcpSumSt = hdrlen;
1593 pTxd->TcpSumOfs = 0; /* PH-Checksum already calculated */ 1588 pTxd->TcpSumWr = offset;
1594 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength +
1595 (Protocol == C_PROTO_ID_UDP ?
1596 C_OFFSET_UDPHEADER_UDPCS :
1597 C_OFFSET_TCPHEADER_TCPCS);
1598 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength;
1599 1589
1600 pTxd->TBControl |= BMU_OWN | BMU_STF | 1590 pTxd->TBControl |= BMU_OWN | BMU_STF |
1601 BMU_SW | BMU_EOF | 1591 BMU_SW | BMU_EOF |
@@ -1658,11 +1648,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1658 TXD *pTxdLst; 1648 TXD *pTxdLst;
1659 int CurrFrag; 1649 int CurrFrag;
1660 int BytesSend; 1650 int BytesSend;
1661 int IpHeaderLength;
1662 int Protocol;
1663 skb_frag_t *sk_frag; 1651 skb_frag_t *sk_frag;
1664 SK_U64 PhysAddr; 1652 SK_U64 PhysAddr;
1665 unsigned long Flags; 1653 unsigned long Flags;
1654 SK_U32 Control;
1666 1655
1667 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags); 1656 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
1668#ifndef USE_TX_COMPLETE 1657#ifndef USE_TX_COMPLETE
@@ -1685,7 +1674,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1685 pTxdFst = pTxd; 1674 pTxdFst = pTxd;
1686 pTxdLst = pTxd; 1675 pTxdLst = pTxd;
1687 BytesSend = 0; 1676 BytesSend = 0;
1688 Protocol = 0;
1689 1677
1690 /* 1678 /*
1691 ** Map the first fragment (header) into the DMA-space 1679 ** Map the first fragment (header) into the DMA-space
@@ -1703,32 +1691,31 @@ struct sk_buff *pMessage) /* pointer to send-message */
1703 ** Does the HW need to evaluate checksum for TCP or UDP packets? 1691 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1704 */ 1692 */
1705 if (pMessage->ip_summed == CHECKSUM_HW) { 1693 if (pMessage->ip_summed == CHECKSUM_HW) {
1706 pTxd->TBControl = BMU_STF | BMU_STFWD | skb_headlen(pMessage); 1694 u16 hdrlen = pMessage->h.raw - pMessage->data;
1695 u16 offset = hdrlen + pMessage->csum;
1696
1697 Control = BMU_STFWD;
1698
1707 /* 1699 /*
1708 ** We have to use the opcode for tcp here, because the 1700 ** We have to use the opcode for tcp here, because the
1709 ** opcode for udp is not working in the hardware yet 1701 ** opcode for udp is not working in the hardware yet
1710 ** (Revision 2.0) 1702 ** (Revision 2.0)
1711 */ 1703 */
1712 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1704 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1713 if ((Protocol == C_PROTO_ID_UDP) &&
1714 (pAC->GIni.GIChipRev == 0) && 1705 (pAC->GIni.GIChipRev == 0) &&
1715 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1706 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1716 pTxd->TBControl |= BMU_TCP_CHECK; 1707 Control |= BMU_TCP_CHECK;
1717 } else { 1708 } else {
1718 pTxd->TBControl |= BMU_UDP_CHECK; 1709 Control |= BMU_UDP_CHECK;
1719 } 1710 }
1720 1711
1721 IpHeaderLength = ((SK_U8)pMessage->data[C_OFFSET_IPHEADER] & 0xf)*4; 1712 pTxd->TcpSumOfs = 0;
1722 pTxd->TcpSumOfs = 0; /* PH-Checksum already claculated */ 1713 pTxd->TcpSumSt = hdrlen;
1723 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength + 1714 pTxd->TcpSumWr = offset;
1724 (Protocol == C_PROTO_ID_UDP ? 1715 } else
1725 C_OFFSET_UDPHEADER_UDPCS : 1716 Control = BMU_CHECK | BMU_SW;
1726 C_OFFSET_TCPHEADER_TCPCS); 1717
1727 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength; 1718 pTxd->TBControl = BMU_STF | Control | skb_headlen(pMessage);
1728 } else {
1729 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_STF |
1730 skb_headlen(pMessage);
1731 }
1732 1719
1733 pTxd = pTxd->pNextTxd; 1720 pTxd = pTxd->pNextTxd;
1734 pTxPort->TxdRingFree--; 1721 pTxPort->TxdRingFree--;
@@ -1752,40 +1739,18 @@ struct sk_buff *pMessage) /* pointer to send-message */
1752 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); 1739 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
1753 pTxd->pMBuf = pMessage; 1740 pTxd->pMBuf = pMessage;
1754 1741
1755 /* 1742 pTxd->TBControl = Control | BMU_OWN | sk_frag->size;;
1756 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1757 */
1758 if (pMessage->ip_summed == CHECKSUM_HW) {
1759 pTxd->TBControl = BMU_OWN | BMU_SW | BMU_STFWD;
1760 /*
1761 ** We have to use the opcode for tcp here because the
1762 ** opcode for udp is not working in the hardware yet
1763 ** (revision 2.0)
1764 */
1765 if ((Protocol == C_PROTO_ID_UDP) &&
1766 (pAC->GIni.GIChipRev == 0) &&
1767 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1768 pTxd->TBControl |= BMU_TCP_CHECK;
1769 } else {
1770 pTxd->TBControl |= BMU_UDP_CHECK;
1771 }
1772 } else {
1773 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_OWN;
1774 }
1775 1743
1776 /* 1744 /*
1777 ** Do we have the last fragment? 1745 ** Do we have the last fragment?
1778 */ 1746 */
1779 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) { 1747 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) {
1780#ifdef USE_TX_COMPLETE 1748#ifdef USE_TX_COMPLETE
1781 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF | sk_frag->size; 1749 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF;
1782#else 1750#else
1783 pTxd->TBControl |= BMU_EOF | sk_frag->size; 1751 pTxd->TBControl |= BMU_EOF;
1784#endif 1752#endif
1785 pTxdFst->TBControl |= BMU_OWN | BMU_SW; 1753 pTxdFst->TBControl |= BMU_OWN | BMU_SW;
1786
1787 } else {
1788 pTxd->TBControl |= sk_frag->size;
1789 } 1754 }
1790 pTxdLst = pTxd; 1755 pTxdLst = pTxd;
1791 pTxd = pTxd->pNextTxd; 1756 pTxd = pTxd->pNextTxd;
@@ -2032,7 +1997,6 @@ SK_U32 Control; /* control field of descriptor */
2032struct sk_buff *pMsg; /* pointer to message holding frame */ 1997struct sk_buff *pMsg; /* pointer to message holding frame */
2033struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */ 1998struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */
2034int FrameLength; /* total length of received frame */ 1999int FrameLength; /* total length of received frame */
2035int IpFrameLength;
2036SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */ 2000SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */
2037SK_EVPARA EvPara; /* an event parameter union */ 2001SK_EVPARA EvPara; /* an event parameter union */
2038unsigned long Flags; /* for spin lock */ 2002unsigned long Flags; /* for spin lock */
@@ -2045,10 +2009,6 @@ SK_BOOL IsMc;
2045SK_BOOL IsBadFrame; /* Bad frame */ 2009SK_BOOL IsBadFrame; /* Bad frame */
2046 2010
2047SK_U32 FrameStat; 2011SK_U32 FrameStat;
2048unsigned short Csum1;
2049unsigned short Csum2;
2050unsigned short Type;
2051int Result;
2052SK_U64 PhysAddr; 2012SK_U64 PhysAddr;
2053 2013
2054rx_start: 2014rx_start:
@@ -2177,8 +2137,8 @@ rx_start:
2177 (dma_addr_t) PhysAddr, 2137 (dma_addr_t) PhysAddr,
2178 FrameLength, 2138 FrameLength,
2179 PCI_DMA_FROMDEVICE); 2139 PCI_DMA_FROMDEVICE);
2180 eth_copy_and_sum(pNewMsg, pMsg->data, 2140 memcpy(pNewMsg->data, pMsg, FrameLength);
2181 FrameLength, 0); 2141
2182 pci_dma_sync_single_for_device(pAC->PciDev, 2142 pci_dma_sync_single_for_device(pAC->PciDev,
2183 (dma_addr_t) PhysAddr, 2143 (dma_addr_t) PhysAddr,
2184 FrameLength, 2144 FrameLength,
@@ -2206,69 +2166,16 @@ rx_start:
2206 2166
2207 /* set length in message */ 2167 /* set length in message */
2208 skb_put(pMsg, FrameLength); 2168 skb_put(pMsg, FrameLength);
2209 /* hardware checksum */ 2169 } /* frame > SK_COPY_TRESHOLD */
2210 Type = ntohs(*((short*)&pMsg->data[12]));
2211 2170
2212#ifdef USE_SK_RX_CHECKSUM 2171#ifdef USE_SK_RX_CHECKSUM
2213 if (Type == 0x800) { 2172 pMsg->csum = pRxd->TcpSums & 0xffff;
2214 Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff); 2173 pMsg->ip_summed = CHECKSUM_HW;
2215 Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
2216 IpFrameLength = (int) ntohs((unsigned short)
2217 ((unsigned short *) pMsg->data)[8]);
2218
2219 /*
2220 * Test: If frame is padded, a check is not possible!
2221 * Frame not padded? Length difference must be 14 (0xe)!
2222 */
2223 if ((FrameLength - IpFrameLength) != 0xe) {
2224 /* Frame padded => TCP offload not possible! */
2225 pMsg->ip_summed = CHECKSUM_NONE;
2226 } else {
2227 /* Frame not padded => TCP offload! */
2228 if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
2229 (pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
2230 (pAC->ChipsetType)) {
2231 Result = SkCsGetReceiveInfo(pAC,
2232 &pMsg->data[14],
2233 Csum1, Csum2, pRxPort->PortIndex);
2234 if (Result ==
2235 SKCS_STATUS_IP_FRAGMENT ||
2236 Result ==
2237 SKCS_STATUS_IP_CSUM_OK ||
2238 Result ==
2239 SKCS_STATUS_TCP_CSUM_OK ||
2240 Result ==
2241 SKCS_STATUS_UDP_CSUM_OK) {
2242 pMsg->ip_summed =
2243 CHECKSUM_UNNECESSARY;
2244 }
2245 else if (Result ==
2246 SKCS_STATUS_TCP_CSUM_ERROR ||
2247 Result ==
2248 SKCS_STATUS_UDP_CSUM_ERROR ||
2249 Result ==
2250 SKCS_STATUS_IP_CSUM_ERROR_UDP ||
2251 Result ==
2252 SKCS_STATUS_IP_CSUM_ERROR_TCP ||
2253 Result ==
2254 SKCS_STATUS_IP_CSUM_ERROR ) {
2255 /* HW Checksum error */
2256 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2257 SK_DBGCAT_DRV_RX_PROGRESS,
2258 ("skge: CRC error. Frame dropped!\n"));
2259 goto rx_failed;
2260 } else {
2261 pMsg->ip_summed =
2262 CHECKSUM_NONE;
2263 }
2264 }/* checksumControl calculation valid */
2265 } /* Frame length check */
2266 } /* IP frame */
2267#else 2174#else
2268 pMsg->ip_summed = CHECKSUM_NONE; 2175 pMsg->ip_summed = CHECKSUM_NONE;
2269#endif 2176#endif
2270 } /* frame > SK_COPY_TRESHOLD */ 2177
2271 2178
2272 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V")); 2179 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V"));
2273 ForRlmt = SK_RLMT_RX_PROTOCOL; 2180 ForRlmt = SK_RLMT_RX_PROTOCOL;
2274#if 0 2181#if 0
@@ -4946,7 +4853,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4946 dev->irq = pdev->irq; 4853 dev->irq = pdev->irq;
4947 error = SkGeInitPCI(pAC); 4854 error = SkGeInitPCI(pAC);
4948 if (error) { 4855 if (error) {
4949 printk("SKGE: PCI setup failed: %i\n", error); 4856 printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error);
4950 goto out_free_netdev; 4857 goto out_free_netdev;
4951 } 4858 }
4952 4859
@@ -4982,7 +4889,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4982 4889
4983 /* Register net device */ 4890 /* Register net device */
4984 if (register_netdev(dev)) { 4891 if (register_netdev(dev)) {
4985 printk(KERN_ERR "SKGE: Could not register device.\n"); 4892 printk(KERN_ERR "sk98lin: Could not register device.\n");
4986 goto out_free_resources; 4893 goto out_free_resources;
4987 } 4894 }
4988 4895
@@ -5001,8 +4908,8 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5001 4908
5002 SkGeYellowLED(pAC, pAC->IoBase, 1); 4909 SkGeYellowLED(pAC, pAC->IoBase, 1);
5003 4910
5004
5005 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); 4911 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
4912 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5006 4913
5007 SkGeProcCreate(dev); 4914 SkGeProcCreate(dev);
5008 4915
@@ -5048,13 +4955,14 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5048#endif 4955#endif
5049 4956
5050 if (register_netdev(dev)) { 4957 if (register_netdev(dev)) {
5051 printk(KERN_ERR "SKGE: Could not register device.\n"); 4958 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n");
5052 free_netdev(dev); 4959 free_netdev(dev);
5053 pAC->dev[1] = pAC->dev[0]; 4960 pAC->dev[1] = pAC->dev[0];
5054 } else { 4961 } else {
5055 SkGeProcCreate(dev); 4962 SkGeProcCreate(dev);
5056 memcpy(&dev->dev_addr, 4963 memcpy(&dev->dev_addr,
5057 &pAC->Addr.Net[1].CurrentMacAddress, 6); 4964 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4965 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5058 4966
5059 printk("%s: %s\n", dev->name, pAC->DeviceStr); 4967 printk("%s: %s\n", dev->name, pAC->DeviceStr);
5060 printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); 4968 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 596c93b12daa..00d683063c01 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2280,11 +2280,13 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2280 } 2280 }
2281 2281
2282 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) { 2282 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) {
2283 netif_stop_queue(dev); 2283 if (!netif_queue_stopped(dev)) {
2284 spin_unlock_irqrestore(&skge->tx_lock, flags); 2284 netif_stop_queue(dev);
2285 2285
2286 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", 2286 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n",
2287 dev->name); 2287 dev->name);
2288 }
2289 spin_unlock_irqrestore(&skge->tx_lock, flags);
2288 return NETDEV_TX_BUSY; 2290 return NETDEV_TX_BUSY;
2289 } 2291 }
2290 2292
@@ -2300,14 +2302,12 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2300 td->dma_hi = map >> 32; 2302 td->dma_hi = map >> 32;
2301 2303
2302 if (skb->ip_summed == CHECKSUM_HW) { 2304 if (skb->ip_summed == CHECKSUM_HW) {
2303 const struct iphdr *ip
2304 = (const struct iphdr *) (skb->data + ETH_HLEN);
2305 int offset = skb->h.raw - skb->data; 2305 int offset = skb->h.raw - skb->data;
2306 2306
2307 /* This seems backwards, but it is what the sk98lin 2307 /* This seems backwards, but it is what the sk98lin
2308 * does. Looks like hardware is wrong? 2308 * does. Looks like hardware is wrong?
2309 */ 2309 */
2310 if (ip->protocol == IPPROTO_UDP 2310 if (skb->h.ipiph->protocol == IPPROTO_UDP
2311 && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON) 2311 && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON)
2312 control = BMU_TCP_CHECK; 2312 control = BMU_TCP_CHECK;
2313 else 2313 else
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 74d5f1a6fdea..28bf2e69eb5e 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -155,6 +155,12 @@ MODULE_LICENSE("GPL");
155#define MEMORY_WAIT_TIME 16 155#define MEMORY_WAIT_TIME 16
156 156
157/* 157/*
158 * The maximum number of processing loops allowed for each call to the
159 * IRQ handler.
160 */
161#define MAX_IRQ_LOOPS 8
162
163/*
158 * This selects whether TX packets are sent one by one to the SMC91x internal 164 * This selects whether TX packets are sent one by one to the SMC91x internal
159 * memory and throttled until transmission completes. This may prevent 165 * memory and throttled until transmission completes. This may prevent
160 * RX overruns a litle by keeping much of the memory free for RX packets 166 * RX overruns a litle by keeping much of the memory free for RX packets
@@ -684,7 +690,6 @@ static void smc_hardware_send_pkt(unsigned long data)
684 690
685 /* queue the packet for TX */ 691 /* queue the packet for TX */
686 SMC_SET_MMU_CMD(MC_ENQUEUE); 692 SMC_SET_MMU_CMD(MC_ENQUEUE);
687 SMC_ACK_INT(IM_TX_EMPTY_INT);
688 smc_special_unlock(&lp->lock); 693 smc_special_unlock(&lp->lock);
689 694
690 dev->trans_start = jiffies; 695 dev->trans_start = jiffies;
@@ -1207,6 +1212,7 @@ static void smc_phy_configure(void *data)
1207 smc_phy_check_media(dev, 1); 1212 smc_phy_check_media(dev, 1);
1208 1213
1209smc_phy_configure_exit: 1214smc_phy_configure_exit:
1215 SMC_SELECT_BANK(2);
1210 spin_unlock_irq(&lp->lock); 1216 spin_unlock_irq(&lp->lock);
1211 lp->work_pending = 0; 1217 lp->work_pending = 0;
1212} 1218}
@@ -1305,7 +1311,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1305 SMC_SET_INT_MASK(0); 1311 SMC_SET_INT_MASK(0);
1306 1312
1307 /* set a timeout value, so I don't stay here forever */ 1313 /* set a timeout value, so I don't stay here forever */
1308 timeout = 8; 1314 timeout = MAX_IRQ_LOOPS;
1309 1315
1310 do { 1316 do {
1311 status = SMC_GET_INT(); 1317 status = SMC_GET_INT();
@@ -1372,10 +1378,13 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1372 /* restore register states */ 1378 /* restore register states */
1373 SMC_SET_PTR(saved_pointer); 1379 SMC_SET_PTR(saved_pointer);
1374 SMC_SET_INT_MASK(mask); 1380 SMC_SET_INT_MASK(mask);
1375
1376 spin_unlock(&lp->lock); 1381 spin_unlock(&lp->lock);
1377 1382
1378 DBG(3, "%s: Interrupt done (%d loops)\n", dev->name, 8-timeout); 1383 if (timeout == MAX_IRQ_LOOPS)
1384 PRINTK("%s: spurious interrupt (mask = 0x%02x)\n",
1385 dev->name, mask);
1386 DBG(3, "%s: Interrupt done (%d loops)\n",
1387 dev->name, MAX_IRQ_LOOPS - timeout);
1379 1388
1380 /* 1389 /*
1381 * We return IRQ_HANDLED unconditionally here even if there was 1390 * We return IRQ_HANDLED unconditionally here even if there was
@@ -2183,9 +2192,8 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
2183 * 0 --> there is a device 2192 * 0 --> there is a device
2184 * anything else, error 2193 * anything else, error
2185 */ 2194 */
2186static int smc_drv_probe(struct device *dev) 2195static int smc_drv_probe(struct platform_device *pdev)
2187{ 2196{
2188 struct platform_device *pdev = to_platform_device(dev);
2189 struct net_device *ndev; 2197 struct net_device *ndev;
2190 struct resource *res; 2198 struct resource *res;
2191 unsigned int __iomem *addr; 2199 unsigned int __iomem *addr;
@@ -2212,7 +2220,7 @@ static int smc_drv_probe(struct device *dev)
2212 goto out_release_io; 2220 goto out_release_io;
2213 } 2221 }
2214 SET_MODULE_OWNER(ndev); 2222 SET_MODULE_OWNER(ndev);
2215 SET_NETDEV_DEV(ndev, dev); 2223 SET_NETDEV_DEV(ndev, &pdev->dev);
2216 2224
2217 ndev->dma = (unsigned char)-1; 2225 ndev->dma = (unsigned char)-1;
2218 ndev->irq = platform_get_irq(pdev, 0); 2226 ndev->irq = platform_get_irq(pdev, 0);
@@ -2233,7 +2241,7 @@ static int smc_drv_probe(struct device *dev)
2233 goto out_release_attrib; 2241 goto out_release_attrib;
2234 } 2242 }
2235 2243
2236 dev_set_drvdata(dev, ndev); 2244 platform_set_drvdata(pdev, ndev);
2237 ret = smc_probe(ndev, addr); 2245 ret = smc_probe(ndev, addr);
2238 if (ret != 0) 2246 if (ret != 0)
2239 goto out_iounmap; 2247 goto out_iounmap;
@@ -2249,7 +2257,7 @@ static int smc_drv_probe(struct device *dev)
2249 return 0; 2257 return 0;
2250 2258
2251 out_iounmap: 2259 out_iounmap:
2252 dev_set_drvdata(dev, NULL); 2260 platform_set_drvdata(pdev, NULL);
2253 iounmap(addr); 2261 iounmap(addr);
2254 out_release_attrib: 2262 out_release_attrib:
2255 smc_release_attrib(pdev); 2263 smc_release_attrib(pdev);
@@ -2263,14 +2271,13 @@ static int smc_drv_probe(struct device *dev)
2263 return ret; 2271 return ret;
2264} 2272}
2265 2273
2266static int smc_drv_remove(struct device *dev) 2274static int smc_drv_remove(struct platform_device *pdev)
2267{ 2275{
2268 struct platform_device *pdev = to_platform_device(dev); 2276 struct net_device *ndev = platform_get_drvdata(pdev);
2269 struct net_device *ndev = dev_get_drvdata(dev);
2270 struct smc_local *lp = netdev_priv(ndev); 2277 struct smc_local *lp = netdev_priv(ndev);
2271 struct resource *res; 2278 struct resource *res;
2272 2279
2273 dev_set_drvdata(dev, NULL); 2280 platform_set_drvdata(pdev, NULL);
2274 2281
2275 unregister_netdev(ndev); 2282 unregister_netdev(ndev);
2276 2283
@@ -2295,9 +2302,9 @@ static int smc_drv_remove(struct device *dev)
2295 return 0; 2302 return 0;
2296} 2303}
2297 2304
2298static int smc_drv_suspend(struct device *dev, pm_message_t state) 2305static int smc_drv_suspend(struct platform_device *dev, pm_message_t state)
2299{ 2306{
2300 struct net_device *ndev = dev_get_drvdata(dev); 2307 struct net_device *ndev = platform_get_drvdata(dev);
2301 2308
2302 if (ndev) { 2309 if (ndev) {
2303 if (netif_running(ndev)) { 2310 if (netif_running(ndev)) {
@@ -2309,14 +2316,13 @@ static int smc_drv_suspend(struct device *dev, pm_message_t state)
2309 return 0; 2316 return 0;
2310} 2317}
2311 2318
2312static int smc_drv_resume(struct device *dev) 2319static int smc_drv_resume(struct platform_device *dev)
2313{ 2320{
2314 struct platform_device *pdev = to_platform_device(dev); 2321 struct net_device *ndev = platform_get_drvdata(dev);
2315 struct net_device *ndev = dev_get_drvdata(dev);
2316 2322
2317 if (ndev) { 2323 if (ndev) {
2318 struct smc_local *lp = netdev_priv(ndev); 2324 struct smc_local *lp = netdev_priv(ndev);
2319 smc_enable_device(pdev); 2325 smc_enable_device(dev);
2320 if (netif_running(ndev)) { 2326 if (netif_running(ndev)) {
2321 smc_reset(ndev); 2327 smc_reset(ndev);
2322 smc_enable(ndev); 2328 smc_enable(ndev);
@@ -2328,13 +2334,14 @@ static int smc_drv_resume(struct device *dev)
2328 return 0; 2334 return 0;
2329} 2335}
2330 2336
2331static struct device_driver smc_driver = { 2337static struct platform_driver smc_driver = {
2332 .name = CARDNAME,
2333 .bus = &platform_bus_type,
2334 .probe = smc_drv_probe, 2338 .probe = smc_drv_probe,
2335 .remove = smc_drv_remove, 2339 .remove = smc_drv_remove,
2336 .suspend = smc_drv_suspend, 2340 .suspend = smc_drv_suspend,
2337 .resume = smc_drv_resume, 2341 .resume = smc_drv_resume,
2342 .driver = {
2343 .name = CARDNAME,
2344 },
2338}; 2345};
2339 2346
2340static int __init smc_init(void) 2347static int __init smc_init(void)
@@ -2348,12 +2355,12 @@ static int __init smc_init(void)
2348#endif 2355#endif
2349#endif 2356#endif
2350 2357
2351 return driver_register(&smc_driver); 2358 return platform_driver_register(&smc_driver);
2352} 2359}
2353 2360
2354static void __exit smc_cleanup(void) 2361static void __exit smc_cleanup(void)
2355{ 2362{
2356 driver_unregister(&smc_driver); 2363 platform_driver_unregister(&smc_driver);
2357} 2364}
2358 2365
2359module_init(smc_init); 2366module_init(smc_init);
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 817f200742c3..5c2824be4ee6 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -100,14 +100,14 @@
100#define SMC_IO_SHIFT 0 100#define SMC_IO_SHIFT 0
101#define SMC_NOWAIT 1 101#define SMC_NOWAIT 1
102 102
103#define SMC_inb(a, r) inb((a) + (r)) 103#define SMC_inb(a, r) readb((a) + (r))
104#define SMC_insb(a, r, p, l) insb((a) + (r), p, (l)) 104#define SMC_insb(a, r, p, l) readsb((a) + (r), p, (l))
105#define SMC_inw(a, r) inw((a) + (r)) 105#define SMC_inw(a, r) readw((a) + (r))
106#define SMC_insw(a, r, p, l) insw((a) + (r), p, l) 106#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
107#define SMC_outb(v, a, r) outb(v, (a) + (r)) 107#define SMC_outb(v, a, r) writeb(v, (a) + (r))
108#define SMC_outsb(a, r, p, l) outsb((a) + (r), p, (l)) 108#define SMC_outsb(a, r, p, l) writesb((a) + (r), p, (l))
109#define SMC_outw(v, a, r) outw(v, (a) + (r)) 109#define SMC_outw(v, a, r) writew(v, (a) + (r))
110#define SMC_outsw(a, r, p, l) outsw((a) + (r), p, l) 110#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
111 111
112#define set_irq_type(irq, type) do {} while (0) 112#define set_irq_type(irq, type) do {} while (0)
113 113
@@ -289,6 +289,38 @@ static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
289#define RPC_LSA_DEFAULT RPC_LED_TX_RX 289#define RPC_LSA_DEFAULT RPC_LED_TX_RX
290#define RPC_LSB_DEFAULT RPC_LED_100_10 290#define RPC_LSB_DEFAULT RPC_LED_100_10
291 291
292#elif defined(CONFIG_SOC_AU1X00)
293
294#include <au1xxx.h>
295
296/* We can only do 16-bit reads and writes in the static memory space. */
297#define SMC_CAN_USE_8BIT 0
298#define SMC_CAN_USE_16BIT 1
299#define SMC_CAN_USE_32BIT 0
300#define SMC_IO_SHIFT 0
301#define SMC_NOWAIT 1
302
303#define SMC_inw(a, r) au_readw((unsigned long)((a) + (r)))
304#define SMC_insw(a, r, p, l) \
305 do { \
306 unsigned long _a = (unsigned long)((a) + (r)); \
307 int _l = (l); \
308 u16 *_p = (u16 *)(p); \
309 while (_l-- > 0) \
310 *_p++ = au_readw(_a); \
311 } while(0)
312#define SMC_outw(v, a, r) au_writew(v, (unsigned long)((a) + (r)))
313#define SMC_outsw(a, r, p, l) \
314 do { \
315 unsigned long _a = (unsigned long)((a) + (r)); \
316 int _l = (l); \
317 const u16 *_p = (const u16 *)(p); \
318 while (_l-- > 0) \
319 au_writew(*_p++ , _a); \
320 } while(0)
321
322#define set_irq_type(irq, type) do {} while (0)
323
292#else 324#else
293 325
294#define SMC_CAN_USE_8BIT 1 326#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index c796f41b4a52..0d765f1733b5 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -2290,7 +2290,6 @@ spider_net_remove(struct pci_dev *pdev)
2290} 2290}
2291 2291
2292static struct pci_driver spider_net_driver = { 2292static struct pci_driver spider_net_driver = {
2293 .owner = THIS_MODULE,
2294 .name = spider_net_driver_name, 2293 .name = spider_net_driver_name,
2295 .id_table = spider_net_pci_tbl, 2294 .id_table = spider_net_pci_tbl,
2296 .probe = spider_net_probe, 2295 .probe = spider_net_probe,
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index de399563a9db..28ce47a02408 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -128,6 +128,8 @@ static struct pci_device_id gem_pci_tbl[] = {
128 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 128 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
129 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_SUNGEM, 129 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_SUNGEM,
130 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 130 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
131 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_GMAC,
132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
131 {0, } 133 {0, }
132}; 134};
133 135
@@ -2905,7 +2907,7 @@ static int __devinit gem_get_device_address(struct gem *gp)
2905 return 0; 2907 return 0;
2906} 2908}
2907 2909
2908static void __devexit gem_remove_one(struct pci_dev *pdev) 2910static void gem_remove_one(struct pci_dev *pdev)
2909{ 2911{
2910 struct net_device *dev = pci_get_drvdata(pdev); 2912 struct net_device *dev = pci_get_drvdata(pdev);
2911 2913
@@ -3179,7 +3181,7 @@ static struct pci_driver gem_driver = {
3179 .name = GEM_MODULE_NAME, 3181 .name = GEM_MODULE_NAME,
3180 .id_table = gem_pci_tbl, 3182 .id_table = gem_pci_tbl,
3181 .probe = gem_init_one, 3183 .probe = gem_init_one,
3182 .remove = __devexit_p(gem_remove_one), 3184 .remove = gem_remove_one,
3183#ifdef CONFIG_PM 3185#ifdef CONFIG_PM
3184 .suspend = gem_suspend, 3186 .suspend = gem_suspend,
3185 .resume = gem_resume, 3187 .resume = gem_resume,
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 1828a6bf8458..2fc9893d69e1 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.43" 71#define DRV_MODULE_VERSION "3.47"
72#define DRV_MODULE_RELDATE "Oct 24, 2005" 72#define DRV_MODULE_RELDATE "Dec 28, 2005"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -341,6 +341,16 @@ static struct {
341 { "interrupt test (offline)" }, 341 { "interrupt test (offline)" },
342}; 342};
343 343
344static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
345{
346 writel(val, tp->regs + off);
347}
348
349static u32 tg3_read32(struct tg3 *tp, u32 off)
350{
351 return (readl(tp->regs + off));
352}
353
344static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val) 354static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val)
345{ 355{
346 unsigned long flags; 356 unsigned long flags;
@@ -411,13 +421,29 @@ static u32 tg3_read_indirect_mbox(struct tg3 *tp, u32 off)
411 return val; 421 return val;
412} 422}
413 423
414static void _tw32_flush(struct tg3 *tp, u32 off, u32 val) 424/* usec_wait specifies the wait time in usec when writing to certain registers
425 * where it is unsafe to read back the register without some delay.
426 * GRC_LOCAL_CTRL is one example if the GPIOs are toggled to switch power.
427 * TG3PCI_CLOCK_CTRL is another example if the clock frequencies are changed.
428 */
429static void _tw32_flush(struct tg3 *tp, u32 off, u32 val, u32 usec_wait)
415{ 430{
416 tp->write32(tp, off, val); 431 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) ||
417 if (!(tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) && 432 (tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
418 !(tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) && 433 /* Non-posted methods */
419 !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)) 434 tp->write32(tp, off, val);
420 tp->read32(tp, off); /* flush */ 435 else {
436 /* Posted method */
437 tg3_write32(tp, off, val);
438 if (usec_wait)
439 udelay(usec_wait);
440 tp->read32(tp, off);
441 }
442 /* Wait again after the read for the posted method to guarantee that
443 * the wait time is met.
444 */
445 if (usec_wait)
446 udelay(usec_wait);
421} 447}
422 448
423static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val) 449static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
@@ -438,16 +464,6 @@ static void tg3_write32_tx_mbox(struct tg3 *tp, u32 off, u32 val)
438 readl(mbox); 464 readl(mbox);
439} 465}
440 466
441static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
442{
443 writel(val, tp->regs + off);
444}
445
446static u32 tg3_read32(struct tg3 *tp, u32 off)
447{
448 return (readl(tp->regs + off));
449}
450
451#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val) 467#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val)
452#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val)) 468#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val))
453#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val) 469#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val)
@@ -455,7 +471,8 @@ static u32 tg3_read32(struct tg3 *tp, u32 off)
455#define tr32_mailbox(reg) tp->read32_mbox(tp, reg) 471#define tr32_mailbox(reg) tp->read32_mbox(tp, reg)
456 472
457#define tw32(reg,val) tp->write32(tp, reg, val) 473#define tw32(reg,val) tp->write32(tp, reg, val)
458#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val)) 474#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val), 0)
475#define tw32_wait_f(reg,val,us) _tw32_flush(tp,(reg),(val), (us))
459#define tr32(reg) tp->read32(tp, reg) 476#define tr32(reg) tp->read32(tp, reg)
460 477
461static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val) 478static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
@@ -595,21 +612,19 @@ static void tg3_switch_clocks(struct tg3 *tp)
595 612
596 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { 613 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
597 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) { 614 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) {
598 tw32_f(TG3PCI_CLOCK_CTRL, 615 tw32_wait_f(TG3PCI_CLOCK_CTRL,
599 clock_ctrl | CLOCK_CTRL_625_CORE); 616 clock_ctrl | CLOCK_CTRL_625_CORE, 40);
600 udelay(40);
601 } 617 }
602 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) { 618 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
603 tw32_f(TG3PCI_CLOCK_CTRL, 619 tw32_wait_f(TG3PCI_CLOCK_CTRL,
604 clock_ctrl | 620 clock_ctrl |
605 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK)); 621 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK),
606 udelay(40); 622 40);
607 tw32_f(TG3PCI_CLOCK_CTRL, 623 tw32_wait_f(TG3PCI_CLOCK_CTRL,
608 clock_ctrl | (CLOCK_CTRL_ALTCLK)); 624 clock_ctrl | (CLOCK_CTRL_ALTCLK),
609 udelay(40); 625 40);
610 } 626 }
611 tw32_f(TG3PCI_CLOCK_CTRL, clock_ctrl); 627 tw32_wait_f(TG3PCI_CLOCK_CTRL, clock_ctrl, 40);
612 udelay(40);
613} 628}
614 629
615#define PHY_BUSY_LOOPS 5000 630#define PHY_BUSY_LOOPS 5000
@@ -1017,37 +1032,50 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1017 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0) 1032 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
1018 return; 1033 return;
1019 1034
1020 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 1035 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
1021 tp_peer = pci_get_drvdata(tp->pdev_peer); 1036 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714)) {
1022 if (!tp_peer) 1037 struct net_device *dev_peer;
1038
1039 dev_peer = pci_get_drvdata(tp->pdev_peer);
1040 if (!dev_peer)
1023 BUG(); 1041 BUG();
1042 tp_peer = netdev_priv(dev_peer);
1024 } 1043 }
1025 1044
1026
1027 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || 1045 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1028 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0) { 1046 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 ||
1047 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1048 (tp_peer->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) {
1029 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 1049 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
1030 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) { 1050 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
1031 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1051 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1032 (GRC_LCLCTRL_GPIO_OE0 | 1052 (GRC_LCLCTRL_GPIO_OE0 |
1033 GRC_LCLCTRL_GPIO_OE1 | 1053 GRC_LCLCTRL_GPIO_OE1 |
1034 GRC_LCLCTRL_GPIO_OE2 | 1054 GRC_LCLCTRL_GPIO_OE2 |
1035 GRC_LCLCTRL_GPIO_OUTPUT0 | 1055 GRC_LCLCTRL_GPIO_OUTPUT0 |
1036 GRC_LCLCTRL_GPIO_OUTPUT1)); 1056 GRC_LCLCTRL_GPIO_OUTPUT1),
1037 udelay(100); 1057 100);
1038 } else { 1058 } else {
1039 u32 no_gpio2; 1059 u32 no_gpio2;
1040 u32 grc_local_ctrl; 1060 u32 grc_local_ctrl = 0;
1041 1061
1042 if (tp_peer != tp && 1062 if (tp_peer != tp &&
1043 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1063 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1044 return; 1064 return;
1045 1065
1066 /* Workaround to prevent overdrawing Amps. */
1067 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
1068 ASIC_REV_5714) {
1069 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
1070 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1071 grc_local_ctrl, 100);
1072 }
1073
1046 /* On 5753 and variants, GPIO2 cannot be used. */ 1074 /* On 5753 and variants, GPIO2 cannot be used. */
1047 no_gpio2 = tp->nic_sram_data_cfg & 1075 no_gpio2 = tp->nic_sram_data_cfg &
1048 NIC_SRAM_DATA_CFG_NO_GPIO2; 1076 NIC_SRAM_DATA_CFG_NO_GPIO2;
1049 1077
1050 grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 | 1078 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE0 |
1051 GRC_LCLCTRL_GPIO_OE1 | 1079 GRC_LCLCTRL_GPIO_OE1 |
1052 GRC_LCLCTRL_GPIO_OE2 | 1080 GRC_LCLCTRL_GPIO_OE2 |
1053 GRC_LCLCTRL_GPIO_OUTPUT1 | 1081 GRC_LCLCTRL_GPIO_OUTPUT1 |
@@ -1056,21 +1084,18 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1056 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 | 1084 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 |
1057 GRC_LCLCTRL_GPIO_OUTPUT2); 1085 GRC_LCLCTRL_GPIO_OUTPUT2);
1058 } 1086 }
1059 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1087 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1060 grc_local_ctrl); 1088 grc_local_ctrl, 100);
1061 udelay(100);
1062 1089
1063 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0; 1090 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0;
1064 1091
1065 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1092 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1066 grc_local_ctrl); 1093 grc_local_ctrl, 100);
1067 udelay(100);
1068 1094
1069 if (!no_gpio2) { 1095 if (!no_gpio2) {
1070 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2; 1096 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2;
1071 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1097 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1072 grc_local_ctrl); 1098 grc_local_ctrl, 100);
1073 udelay(100);
1074 } 1099 }
1075 } 1100 }
1076 } else { 1101 } else {
@@ -1080,19 +1105,16 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1080 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1105 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1081 return; 1106 return;
1082 1107
1083 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1108 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1084 (GRC_LCLCTRL_GPIO_OE1 | 1109 (GRC_LCLCTRL_GPIO_OE1 |
1085 GRC_LCLCTRL_GPIO_OUTPUT1)); 1110 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1086 udelay(100);
1087 1111
1088 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1112 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1089 (GRC_LCLCTRL_GPIO_OE1)); 1113 GRC_LCLCTRL_GPIO_OE1, 100);
1090 udelay(100);
1091 1114
1092 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1115 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1093 (GRC_LCLCTRL_GPIO_OE1 | 1116 (GRC_LCLCTRL_GPIO_OE1 |
1094 GRC_LCLCTRL_GPIO_OUTPUT1)); 1117 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1095 udelay(100);
1096 } 1118 }
1097 } 1119 }
1098} 1120}
@@ -1105,6 +1127,8 @@ static int tg3_setup_phy(struct tg3 *, int);
1105 1127
1106static void tg3_write_sig_post_reset(struct tg3 *, int); 1128static void tg3_write_sig_post_reset(struct tg3 *, int);
1107static int tg3_halt_cpu(struct tg3 *, u32); 1129static int tg3_halt_cpu(struct tg3 *, u32);
1130static int tg3_nvram_lock(struct tg3 *);
1131static void tg3_nvram_unlock(struct tg3 *);
1108 1132
1109static int tg3_set_power_state(struct tg3 *tp, int state) 1133static int tg3_set_power_state(struct tg3 *tp, int state)
1110{ 1134{
@@ -1133,10 +1157,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1133 udelay(100); /* Delay after power state change */ 1157 udelay(100); /* Delay after power state change */
1134 1158
1135 /* Switch out of Vaux if it is not a LOM */ 1159 /* Switch out of Vaux if it is not a LOM */
1136 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) { 1160 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
1137 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 1161 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
1138 udelay(100);
1139 }
1140 1162
1141 return 0; 1163 return 0;
1142 1164
@@ -1179,6 +1201,21 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1179 tg3_setup_phy(tp, 0); 1201 tg3_setup_phy(tp, 0);
1180 } 1202 }
1181 1203
1204 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1205 int i;
1206 u32 val;
1207
1208 for (i = 0; i < 200; i++) {
1209 tg3_read_mem(tp, NIC_SRAM_FW_ASF_STATUS_MBOX, &val);
1210 if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
1211 break;
1212 msleep(1);
1213 }
1214 }
1215 tg3_write_mem(tp, NIC_SRAM_WOL_MBOX, WOL_SIGNATURE |
1216 WOL_DRV_STATE_SHUTDOWN |
1217 WOL_DRV_WOL | WOL_SET_MAGIC_PKT);
1218
1182 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps); 1219 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps);
1183 1220
1184 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) { 1221 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) {
@@ -1220,10 +1257,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1220 base_val |= (CLOCK_CTRL_RXCLK_DISABLE | 1257 base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
1221 CLOCK_CTRL_TXCLK_DISABLE); 1258 CLOCK_CTRL_TXCLK_DISABLE);
1222 1259
1223 tw32_f(TG3PCI_CLOCK_CTRL, base_val | 1260 tw32_wait_f(TG3PCI_CLOCK_CTRL, base_val | CLOCK_CTRL_ALTCLK |
1224 CLOCK_CTRL_ALTCLK | 1261 CLOCK_CTRL_PWRDOWN_PLL133, 40);
1225 CLOCK_CTRL_PWRDOWN_PLL133);
1226 udelay(40);
1227 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) { 1262 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) {
1228 /* do nothing */ 1263 /* do nothing */
1229 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 1264 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
@@ -1244,11 +1279,11 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1244 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE; 1279 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
1245 } 1280 }
1246 1281
1247 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1); 1282 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1,
1248 udelay(40); 1283 40);
1249 1284
1250 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2); 1285 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2,
1251 udelay(40); 1286 40);
1252 1287
1253 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 1288 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
1254 u32 newbits3; 1289 u32 newbits3;
@@ -1262,9 +1297,20 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1262 newbits3 = CLOCK_CTRL_44MHZ_CORE; 1297 newbits3 = CLOCK_CTRL_44MHZ_CORE;
1263 } 1298 }
1264 1299
1265 tw32_f(TG3PCI_CLOCK_CTRL, 1300 tw32_wait_f(TG3PCI_CLOCK_CTRL,
1266 tp->pci_clock_ctrl | newbits3); 1301 tp->pci_clock_ctrl | newbits3, 40);
1267 udelay(40); 1302 }
1303 }
1304
1305 if (!(tp->tg3_flags & TG3_FLAG_WOL_ENABLE) &&
1306 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1307 /* Turn off the PHY */
1308 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) {
1309 tg3_writephy(tp, MII_TG3_EXT_CTRL,
1310 MII_TG3_EXT_CTRL_FORCE_LED_OFF);
1311 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2);
1312 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700)
1313 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN);
1268 } 1314 }
1269 } 1315 }
1270 1316
@@ -1277,8 +1323,12 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1277 1323
1278 val &= ~((1 << 16) | (1 << 4) | (1 << 2) | (1 << 1) | 1); 1324 val &= ~((1 << 16) | (1 << 4) | (1 << 2) | (1 << 1) | 1);
1279 tw32(0x7d00, val); 1325 tw32(0x7d00, val);
1280 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) 1326 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1327 tg3_nvram_lock(tp);
1281 tg3_halt_cpu(tp, RX_CPU_BASE); 1328 tg3_halt_cpu(tp, RX_CPU_BASE);
1329 tw32_f(NVRAM_SWARB, SWARB_REQ_CLR0);
1330 tg3_nvram_unlock(tp);
1331 }
1282 } 1332 }
1283 1333
1284 /* Finally, set the new power state. */ 1334 /* Finally, set the new power state. */
@@ -1812,7 +1862,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
1812 } 1862 }
1813 } 1863 }
1814relink: 1864relink:
1815 if (current_link_up == 0) { 1865 if (current_link_up == 0 || tp->link_config.phy_is_low_power) {
1816 u32 tmp; 1866 u32 tmp;
1817 1867
1818 tg3_phy_copper_begin(tp); 1868 tg3_phy_copper_begin(tp);
@@ -3565,12 +3615,15 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3565 if (!spin_trylock(&tp->tx_lock)) 3615 if (!spin_trylock(&tp->tx_lock))
3566 return NETDEV_TX_LOCKED; 3616 return NETDEV_TX_LOCKED;
3567 3617
3568 /* This is a hard error, log it. */
3569 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { 3618 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) {
3570 netif_stop_queue(dev); 3619 if (!netif_queue_stopped(dev)) {
3620 netif_stop_queue(dev);
3621
3622 /* This is a hard error, log it. */
3623 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
3624 "queue awake!\n", dev->name);
3625 }
3571 spin_unlock(&tp->tx_lock); 3626 spin_unlock(&tp->tx_lock);
3572 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n",
3573 dev->name);
3574 return NETDEV_TX_BUSY; 3627 return NETDEV_TX_BUSY;
3575 } 3628 }
3576 3629
@@ -7098,8 +7151,13 @@ do { p = (u32 *)(orig_p + (reg)); \
7098 GET_REG32_LOOP(BUFMGR_MODE, 0x58); 7151 GET_REG32_LOOP(BUFMGR_MODE, 0x58);
7099 GET_REG32_LOOP(RDMAC_MODE, 0x08); 7152 GET_REG32_LOOP(RDMAC_MODE, 0x08);
7100 GET_REG32_LOOP(WDMAC_MODE, 0x08); 7153 GET_REG32_LOOP(WDMAC_MODE, 0x08);
7101 GET_REG32_LOOP(RX_CPU_BASE, 0x280); 7154 GET_REG32_1(RX_CPU_MODE);
7102 GET_REG32_LOOP(TX_CPU_BASE, 0x280); 7155 GET_REG32_1(RX_CPU_STATE);
7156 GET_REG32_1(RX_CPU_PGMCTR);
7157 GET_REG32_1(RX_CPU_HWBKPT);
7158 GET_REG32_1(TX_CPU_MODE);
7159 GET_REG32_1(TX_CPU_STATE);
7160 GET_REG32_1(TX_CPU_PGMCTR);
7103 GET_REG32_LOOP(GRCMBOX_INTERRUPT_0, 0x110); 7161 GET_REG32_LOOP(GRCMBOX_INTERRUPT_0, 0x110);
7104 GET_REG32_LOOP(FTQ_RESET, 0x120); 7162 GET_REG32_LOOP(FTQ_RESET, 0x120);
7105 GET_REG32_LOOP(MSGINT_MODE, 0x0c); 7163 GET_REG32_LOOP(MSGINT_MODE, 0x0c);
@@ -7922,13 +7980,12 @@ static int tg3_test_memory(struct tg3 *tp)
7922 u32 offset; 7980 u32 offset;
7923 u32 len; 7981 u32 len;
7924 } mem_tbl_570x[] = { 7982 } mem_tbl_570x[] = {
7925 { 0x00000000, 0x01000}, 7983 { 0x00000000, 0x00b50},
7926 { 0x00002000, 0x1c000}, 7984 { 0x00002000, 0x1c000},
7927 { 0xffffffff, 0x00000} 7985 { 0xffffffff, 0x00000}
7928 }, mem_tbl_5705[] = { 7986 }, mem_tbl_5705[] = {
7929 { 0x00000100, 0x0000c}, 7987 { 0x00000100, 0x0000c},
7930 { 0x00000200, 0x00008}, 7988 { 0x00000200, 0x00008},
7931 { 0x00000b50, 0x00400},
7932 { 0x00004000, 0x00800}, 7989 { 0x00004000, 0x00800},
7933 { 0x00006000, 0x01000}, 7990 { 0x00006000, 0x01000},
7934 { 0x00008000, 0x02000}, 7991 { 0x00008000, 0x02000},
@@ -8530,6 +8587,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
8530 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) { 8587 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
8531 tp->tg3_flags |= TG3_FLAG_NVRAM; 8588 tp->tg3_flags |= TG3_FLAG_NVRAM;
8532 8589
8590 tg3_nvram_lock(tp);
8533 tg3_enable_nvram_access(tp); 8591 tg3_enable_nvram_access(tp);
8534 8592
8535 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 8593 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
@@ -8540,6 +8598,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
8540 tg3_get_nvram_size(tp); 8598 tg3_get_nvram_size(tp);
8541 8599
8542 tg3_disable_nvram_access(tp); 8600 tg3_disable_nvram_access(tp);
8601 tg3_nvram_unlock(tp);
8543 8602
8544 } else { 8603 } else {
8545 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED); 8604 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
@@ -8637,10 +8696,10 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
8637 if (ret == 0) 8696 if (ret == 0)
8638 *val = swab32(tr32(NVRAM_RDDATA)); 8697 *val = swab32(tr32(NVRAM_RDDATA));
8639 8698
8640 tg3_nvram_unlock(tp);
8641
8642 tg3_disable_nvram_access(tp); 8699 tg3_disable_nvram_access(tp);
8643 8700
8701 tg3_nvram_unlock(tp);
8702
8644 return ret; 8703 return ret;
8645} 8704}
8646 8705
@@ -8725,6 +8784,10 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
8725 8784
8726 offset = offset + (pagesize - page_off); 8785 offset = offset + (pagesize - page_off);
8727 8786
8787 /* Nvram lock released by tg3_nvram_read() above,
8788 * so need to get it again.
8789 */
8790 tg3_nvram_lock(tp);
8728 tg3_enable_nvram_access(tp); 8791 tg3_enable_nvram_access(tp);
8729 8792
8730 /* 8793 /*
@@ -10423,7 +10486,7 @@ static char * __devinit tg3_bus_string(struct tg3 *tp, char *str)
10423 return str; 10486 return str;
10424} 10487}
10425 10488
10426static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp) 10489static struct pci_dev * __devinit tg3_find_peer(struct tg3 *tp)
10427{ 10490{
10428 struct pci_dev *peer; 10491 struct pci_dev *peer;
10429 unsigned int func, devnr = tp->pdev->devfn & ~7; 10492 unsigned int func, devnr = tp->pdev->devfn & ~7;
@@ -10434,8 +10497,13 @@ static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
10434 break; 10497 break;
10435 pci_dev_put(peer); 10498 pci_dev_put(peer);
10436 } 10499 }
10437 if (!peer || peer == tp->pdev) 10500 /* 5704 can be configured in single-port mode, set peer to
10438 BUG(); 10501 * tp->pdev in that case.
10502 */
10503 if (!peer) {
10504 peer = tp->pdev;
10505 return peer;
10506 }
10439 10507
10440 /* 10508 /*
10441 * We don't need to keep the refcount elevated; there's no way 10509 * We don't need to keep the refcount elevated; there's no way
@@ -10671,8 +10739,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10671 tp->rx_pending = 63; 10739 tp->rx_pending = 63;
10672 } 10740 }
10673 10741
10674 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) 10742 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10675 tp->pdev_peer = tg3_find_5704_peer(tp); 10743 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
10744 tp->pdev_peer = tg3_find_peer(tp);
10676 10745
10677 err = tg3_get_device_address(tp); 10746 err = tg3_get_device_address(tp);
10678 if (err) { 10747 if (err) {
@@ -10817,12 +10886,14 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
10817 10886
10818 tg3_full_lock(tp, 0); 10887 tg3_full_lock(tp, 0);
10819 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 10888 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
10889 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
10820 tg3_full_unlock(tp); 10890 tg3_full_unlock(tp);
10821 10891
10822 err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); 10892 err = tg3_set_power_state(tp, pci_choose_state(pdev, state));
10823 if (err) { 10893 if (err) {
10824 tg3_full_lock(tp, 0); 10894 tg3_full_lock(tp, 0);
10825 10895
10896 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
10826 tg3_init_hw(tp); 10897 tg3_init_hw(tp);
10827 10898
10828 tp->timer.expires = jiffies + tp->timer_offset; 10899 tp->timer.expires = jiffies + tp->timer_offset;
@@ -10856,6 +10927,7 @@ static int tg3_resume(struct pci_dev *pdev)
10856 10927
10857 tg3_full_lock(tp, 0); 10928 tg3_full_lock(tp, 0);
10858 10929
10930 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
10859 tg3_init_hw(tp); 10931 tg3_init_hw(tp);
10860 10932
10861 tp->timer.expires = jiffies + tp->timer_offset; 10933 tp->timer.expires = jiffies + tp->timer_offset;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index fb7e2a5f4a08..890e1635996b 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -1124,7 +1124,14 @@
1124/* 0x280 --> 0x400 unused */ 1124/* 0x280 --> 0x400 unused */
1125 1125
1126#define RX_CPU_BASE 0x00005000 1126#define RX_CPU_BASE 0x00005000
1127#define RX_CPU_MODE 0x00005000
1128#define RX_CPU_STATE 0x00005004
1129#define RX_CPU_PGMCTR 0x0000501c
1130#define RX_CPU_HWBKPT 0x00005034
1127#define TX_CPU_BASE 0x00005400 1131#define TX_CPU_BASE 0x00005400
1132#define TX_CPU_MODE 0x00005400
1133#define TX_CPU_STATE 0x00005404
1134#define TX_CPU_PGMCTR 0x0000541c
1128 1135
1129/* Mailboxes */ 1136/* Mailboxes */
1130#define GRCMBOX_INTERRUPT_0 0x00005800 /* 64-bit */ 1137#define GRCMBOX_INTERRUPT_0 0x00005800 /* 64-bit */
@@ -1529,6 +1536,12 @@
1529#define NIC_SRAM_MAC_ADDR_HIGH_MBOX 0x00000c14 1536#define NIC_SRAM_MAC_ADDR_HIGH_MBOX 0x00000c14
1530#define NIC_SRAM_MAC_ADDR_LOW_MBOX 0x00000c18 1537#define NIC_SRAM_MAC_ADDR_LOW_MBOX 0x00000c18
1531 1538
1539#define NIC_SRAM_WOL_MBOX 0x00000d30
1540#define WOL_SIGNATURE 0x474c0000
1541#define WOL_DRV_STATE_SHUTDOWN 0x00000001
1542#define WOL_DRV_WOL 0x00000002
1543#define WOL_SET_MAGIC_PKT 0x00000004
1544
1532#define NIC_SRAM_DATA_CFG_2 0x00000d38 1545#define NIC_SRAM_DATA_CFG_2 0x00000d38
1533 1546
1534#define SHASTA_EXT_LED_MODE_MASK 0x00018000 1547#define SHASTA_EXT_LED_MODE_MASK 0x00018000
@@ -1565,6 +1578,7 @@
1565#define MII_TG3_EXT_CTRL 0x10 /* Extended control register */ 1578#define MII_TG3_EXT_CTRL 0x10 /* Extended control register */
1566#define MII_TG3_EXT_CTRL_FIFO_ELASTIC 0x0001 1579#define MII_TG3_EXT_CTRL_FIFO_ELASTIC 0x0001
1567#define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002 1580#define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002
1581#define MII_TG3_EXT_CTRL_FORCE_LED_OFF 0x0008
1568#define MII_TG3_EXT_CTRL_TBI 0x8000 1582#define MII_TG3_EXT_CTRL_TBI 0x8000
1569 1583
1570#define MII_TG3_EXT_STAT 0x11 /* Extended status register */ 1584#define MII_TG3_EXT_STAT 0x11 /* Extended status register */
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index d04c918ebef8..4f756960db2a 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -344,9 +344,10 @@ module_param_array(dma, int, NULL, 0);
344 344
345static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS]; 345static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS];
346 346
347static struct device_driver proteon_driver = { 347static struct platform_driver proteon_driver = {
348 .name = "proteon", 348 .driver = {
349 .bus = &platform_bus_type, 349 .name = "proteon",
350 },
350}; 351};
351 352
352static int __init proteon_init(void) 353static int __init proteon_init(void)
@@ -355,7 +356,7 @@ static int __init proteon_init(void)
355 struct platform_device *pdev; 356 struct platform_device *pdev;
356 int i, num = 0, err = 0; 357 int i, num = 0, err = 0;
357 358
358 err = driver_register(&proteon_driver); 359 err = platform_driver_register(&proteon_driver);
359 if (err) 360 if (err)
360 return err; 361 return err;
361 362
@@ -372,7 +373,7 @@ static int __init proteon_init(void)
372 err = setup_card(dev, &pdev->dev); 373 err = setup_card(dev, &pdev->dev);
373 if (!err) { 374 if (!err) {
374 proteon_dev[i] = pdev; 375 proteon_dev[i] = pdev;
375 dev_set_drvdata(&pdev->dev, dev); 376 platform_set_drvdata(pdev, dev);
376 ++num; 377 ++num;
377 } else { 378 } else {
378 platform_device_unregister(pdev); 379 platform_device_unregister(pdev);
@@ -399,17 +400,17 @@ static void __exit proteon_cleanup(void)
399 400
400 if (!pdev) 401 if (!pdev)
401 continue; 402 continue;
402 dev = dev_get_drvdata(&pdev->dev); 403 dev = platform_get_drvdata(pdev);
403 unregister_netdev(dev); 404 unregister_netdev(dev);
404 release_region(dev->base_addr, PROTEON_IO_EXTENT); 405 release_region(dev->base_addr, PROTEON_IO_EXTENT);
405 free_irq(dev->irq, dev); 406 free_irq(dev->irq, dev);
406 free_dma(dev->dma); 407 free_dma(dev->dma);
407 tmsdev_term(dev); 408 tmsdev_term(dev);
408 free_netdev(dev); 409 free_netdev(dev);
409 dev_set_drvdata(&pdev->dev, NULL); 410 platform_set_drvdata(pdev, NULL);
410 platform_device_unregister(pdev); 411 platform_device_unregister(pdev);
411 } 412 }
412 driver_unregister(&proteon_driver); 413 platform_driver_unregister(&proteon_driver);
413} 414}
414 415
415module_init(proteon_init); 416module_init(proteon_init);
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index 72cf708396be..d6ba41cf3110 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -354,9 +354,10 @@ module_param_array(dma, int, NULL, 0);
354 354
355static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS]; 355static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS];
356 356
357static struct device_driver sk_isa_driver = { 357static struct platform_driver sk_isa_driver = {
358 .name = "skisa", 358 .driver = {
359 .bus = &platform_bus_type, 359 .name = "skisa",
360 },
360}; 361};
361 362
362static int __init sk_isa_init(void) 363static int __init sk_isa_init(void)
@@ -365,7 +366,7 @@ static int __init sk_isa_init(void)
365 struct platform_device *pdev; 366 struct platform_device *pdev;
366 int i, num = 0, err = 0; 367 int i, num = 0, err = 0;
367 368
368 err = driver_register(&sk_isa_driver); 369 err = platform_driver_register(&sk_isa_driver);
369 if (err) 370 if (err)
370 return err; 371 return err;
371 372
@@ -382,7 +383,7 @@ static int __init sk_isa_init(void)
382 err = setup_card(dev, &pdev->dev); 383 err = setup_card(dev, &pdev->dev);
383 if (!err) { 384 if (!err) {
384 sk_isa_dev[i] = pdev; 385 sk_isa_dev[i] = pdev;
385 dev_set_drvdata(&sk_isa_dev[i]->dev, dev); 386 platform_set_drvdata(sk_isa_dev[i], dev);
386 ++num; 387 ++num;
387 } else { 388 } else {
388 platform_device_unregister(pdev); 389 platform_device_unregister(pdev);
@@ -409,17 +410,17 @@ static void __exit sk_isa_cleanup(void)
409 410
410 if (!pdev) 411 if (!pdev)
411 continue; 412 continue;
412 dev = dev_get_drvdata(&pdev->dev); 413 dev = platform_get_drvdata(pdev);
413 unregister_netdev(dev); 414 unregister_netdev(dev);
414 release_region(dev->base_addr, SK_ISA_IO_EXTENT); 415 release_region(dev->base_addr, SK_ISA_IO_EXTENT);
415 free_irq(dev->irq, dev); 416 free_irq(dev->irq, dev);
416 free_dma(dev->dma); 417 free_dma(dev->dma);
417 tmsdev_term(dev); 418 tmsdev_term(dev);
418 free_netdev(dev); 419 free_netdev(dev);
419 dev_set_drvdata(&pdev->dev, NULL); 420 platform_set_drvdata(pdev, NULL);
420 platform_device_unregister(pdev); 421 platform_device_unregister(pdev);
421 } 422 }
422 driver_unregister(&sk_isa_driver); 423 platform_driver_unregister(&sk_isa_driver);
423} 424}
424 425
425module_init(sk_isa_init); 426module_init(sk_isa_init);
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index a01efa6d5c62..1fd04662c4fc 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -192,7 +192,9 @@ static int cisco_rx(struct sk_buff *skb)
192 "uptime %ud%uh%um%us)\n", 192 "uptime %ud%uh%um%us)\n",
193 dev->name, days, hrs, 193 dev->name, days, hrs,
194 min, sec); 194 min, sec);
195#if 0
195 netif_carrier_on(dev); 196 netif_carrier_on(dev);
197#endif
196 hdlc->state.cisco.up = 1; 198 hdlc->state.cisco.up = 1;
197 } 199 }
198 } 200 }
@@ -225,7 +227,9 @@ static void cisco_timer(unsigned long arg)
225 hdlc->state.cisco.settings.timeout * HZ)) { 227 hdlc->state.cisco.settings.timeout * HZ)) {
226 hdlc->state.cisco.up = 0; 228 hdlc->state.cisco.up = 0;
227 printk(KERN_INFO "%s: Link down\n", dev->name); 229 printk(KERN_INFO "%s: Link down\n", dev->name);
230#if 0
228 netif_carrier_off(dev); 231 netif_carrier_off(dev);
232#endif
229 } 233 }
230 234
231 cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ, 235 cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ,
@@ -261,8 +265,10 @@ static void cisco_stop(struct net_device *dev)
261{ 265{
262 hdlc_device *hdlc = dev_to_hdlc(dev); 266 hdlc_device *hdlc = dev_to_hdlc(dev);
263 del_timer_sync(&hdlc->state.cisco.timer); 267 del_timer_sync(&hdlc->state.cisco.timer);
268#if 0
264 if (netif_carrier_ok(dev)) 269 if (netif_carrier_ok(dev))
265 netif_carrier_off(dev); 270 netif_carrier_off(dev);
271#endif
266 hdlc->state.cisco.up = 0; 272 hdlc->state.cisco.up = 0;
267 hdlc->state.cisco.request_sent = 0; 273 hdlc->state.cisco.request_sent = 0;
268} 274}
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index e1601d35dced..523afe17564e 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -545,8 +545,10 @@ static void fr_set_link_state(int reliable, struct net_device *dev)
545 545
546 hdlc->state.fr.reliable = reliable; 546 hdlc->state.fr.reliable = reliable;
547 if (reliable) { 547 if (reliable) {
548#if 0
548 if (!netif_carrier_ok(dev)) 549 if (!netif_carrier_ok(dev))
549 netif_carrier_on(dev); 550 netif_carrier_on(dev);
551#endif
550 552
551 hdlc->state.fr.n391cnt = 0; /* Request full status */ 553 hdlc->state.fr.n391cnt = 0; /* Request full status */
552 hdlc->state.fr.dce_changed = 1; 554 hdlc->state.fr.dce_changed = 1;
@@ -560,8 +562,10 @@ static void fr_set_link_state(int reliable, struct net_device *dev)
560 } 562 }
561 } 563 }
562 } else { 564 } else {
565#if 0
563 if (netif_carrier_ok(dev)) 566 if (netif_carrier_ok(dev))
564 netif_carrier_off(dev); 567 netif_carrier_off(dev);
568#endif
565 569
566 while (pvc) { /* Deactivate all PVCs */ 570 while (pvc) { /* Deactivate all PVCs */
567 pvc_carrier(0, pvc); 571 pvc_carrier(0, pvc);
diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c
index cdd4c09c2d90..46cef8f92133 100644
--- a/drivers/net/wan/hdlc_generic.c
+++ b/drivers/net/wan/hdlc_generic.c
@@ -79,11 +79,13 @@ static void __hdlc_set_carrier_on(struct net_device *dev)
79 hdlc_device *hdlc = dev_to_hdlc(dev); 79 hdlc_device *hdlc = dev_to_hdlc(dev);
80 if (hdlc->proto.start) 80 if (hdlc->proto.start)
81 return hdlc->proto.start(dev); 81 return hdlc->proto.start(dev);
82#if 0
82#ifdef DEBUG_LINK 83#ifdef DEBUG_LINK
83 if (netif_carrier_ok(dev)) 84 if (netif_carrier_ok(dev))
84 printk(KERN_ERR "hdlc_set_carrier_on(): already on\n"); 85 printk(KERN_ERR "hdlc_set_carrier_on(): already on\n");
85#endif 86#endif
86 netif_carrier_on(dev); 87 netif_carrier_on(dev);
88#endif
87} 89}
88 90
89 91
@@ -94,11 +96,13 @@ static void __hdlc_set_carrier_off(struct net_device *dev)
94 if (hdlc->proto.stop) 96 if (hdlc->proto.stop)
95 return hdlc->proto.stop(dev); 97 return hdlc->proto.stop(dev);
96 98
99#if 0
97#ifdef DEBUG_LINK 100#ifdef DEBUG_LINK
98 if (!netif_carrier_ok(dev)) 101 if (!netif_carrier_ok(dev))
99 printk(KERN_ERR "hdlc_set_carrier_off(): already off\n"); 102 printk(KERN_ERR "hdlc_set_carrier_off(): already off\n");
100#endif 103#endif
101 netif_carrier_off(dev); 104 netif_carrier_off(dev);
105#endif
102} 106}
103 107
104 108
@@ -294,8 +298,10 @@ int register_hdlc_device(struct net_device *dev)
294 if (result != 0) 298 if (result != 0)
295 return -EIO; 299 return -EIO;
296 300
301#if 0
297 if (netif_carrier_ok(dev)) 302 if (netif_carrier_ok(dev))
298 netif_carrier_off(dev); /* no carrier until DCD goes up */ 303 netif_carrier_off(dev); /* no carrier until DCD goes up */
304#endif
299 305
300 return 0; 306 return 0;
301} 307}
diff --git a/drivers/net/wan/sdladrv.c b/drivers/net/wan/sdladrv.c
index 7c2cf2e76300..032c0f81928e 100644
--- a/drivers/net/wan/sdladrv.c
+++ b/drivers/net/wan/sdladrv.c
@@ -1994,7 +1994,7 @@ static int detect_s514 (sdlahw_t* hw)
1994 modname, hw->irq); 1994 modname, hw->irq);
1995 1995
1996 /* map the physical PCI memory to virtual memory */ 1996 /* map the physical PCI memory to virtual memory */
1997 (void *)hw->dpmbase = ioremap((unsigned long)S514_mem_base_addr, 1997 hw->dpmbase = ioremap((unsigned long)S514_mem_base_addr,
1998 (unsigned long)MAX_SIZEOF_S514_MEMORY); 1998 (unsigned long)MAX_SIZEOF_S514_MEMORY);
1999 /* map the physical control register memory to virtual memory */ 1999 /* map the physical control register memory to virtual memory */
2000 hw->vector = (unsigned long)ioremap( 2000 hw->vector = (unsigned long)ioremap(
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 7187958e40ca..00e55165b760 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -330,7 +330,7 @@ config PCI_HERMES
330 330
331config ATMEL 331config ATMEL
332 tristate "Atmel at76c50x chipset 802.11b support" 332 tristate "Atmel at76c50x chipset 802.11b support"
333 depends on NET_RADIO && EXPERIMENTAL 333 depends on NET_RADIO
334 select FW_LOADER 334 select FW_LOADER
335 select CRC32 335 select CRC32
336 ---help--- 336 ---help---
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 340ab4ee4b67..7a92b1cbd6aa 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2755,8 +2755,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2755 SET_NETDEV_DEV(dev, dmdev); 2755 SET_NETDEV_DEV(dev, dmdev);
2756 2756
2757 2757
2758 if (test_bit(FLAG_MPI,&ai->flags)) 2758 reset_card (dev, 1);
2759 reset_card (dev, 1); 2759 msleep(400);
2760 2760
2761 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev ); 2761 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev );
2762 if (rc) { 2762 if (rc) {
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index a3e23527fe7f..5e53c5258a33 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -72,7 +72,7 @@
72#include "atmel.h" 72#include "atmel.h"
73 73
74#define DRIVER_MAJOR 0 74#define DRIVER_MAJOR 0
75#define DRIVER_MINOR 96 75#define DRIVER_MINOR 98
76 76
77MODULE_AUTHOR("Simon Kelley"); 77MODULE_AUTHOR("Simon Kelley");
78MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards."); 78MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.");
@@ -1504,7 +1504,7 @@ static int atmel_read_proc(char *page, char **start, off_t off,
1504 return len; 1504 return len;
1505} 1505}
1506 1506
1507struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWType fw_type, 1507struct net_device *init_atmel_card( unsigned short irq, unsigned long port, const AtmelFWType fw_type,
1508 struct device *sys_dev, int (*card_present)(void *), void *card) 1508 struct device *sys_dev, int (*card_present)(void *), void *card)
1509{ 1509{
1510 struct net_device *dev; 1510 struct net_device *dev;
@@ -1605,8 +1605,8 @@ struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWT
1605 goto err_out_free; 1605 goto err_out_free;
1606 } 1606 }
1607 1607
1608 if (priv->bus_type == BUS_TYPE_PCI && 1608 if (!request_region(dev->base_addr, 32,
1609 !request_region( dev->base_addr, 64, dev->name )) { 1609 priv->bus_type == BUS_TYPE_PCCARD ? "atmel_cs" : "atmel_pci")) {
1610 goto err_out_irq; 1610 goto err_out_irq;
1611 } 1611 }
1612 1612
@@ -1622,15 +1622,16 @@ struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWT
1622 1622
1623 create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); 1623 create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv);
1624 1624
1625 printk(KERN_INFO "%s: Atmel at76c50x wireless. Version %d.%d simon@thekelleys.org.uk\n", 1625 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
1626 dev->name, DRIVER_MAJOR, DRIVER_MINOR); 1626 dev->name, DRIVER_MAJOR, DRIVER_MINOR,
1627 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1628 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] );
1627 1629
1628 SET_MODULE_OWNER(dev); 1630 SET_MODULE_OWNER(dev);
1629 return dev; 1631 return dev;
1630 1632
1631 err_out_res: 1633 err_out_res:
1632 if (priv->bus_type == BUS_TYPE_PCI) 1634 release_region( dev->base_addr, 32);
1633 release_region( dev->base_addr, 64 );
1634 err_out_irq: 1635 err_out_irq:
1635 free_irq(dev->irq, dev); 1636 free_irq(dev->irq, dev);
1636 err_out_free: 1637 err_out_free:
@@ -1640,7 +1641,7 @@ struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWT
1640 1641
1641EXPORT_SYMBOL(init_atmel_card); 1642EXPORT_SYMBOL(init_atmel_card);
1642 1643
1643void stop_atmel_card(struct net_device *dev, int freeres) 1644void stop_atmel_card(struct net_device *dev)
1644{ 1645{
1645 struct atmel_private *priv = netdev_priv(dev); 1646 struct atmel_private *priv = netdev_priv(dev);
1646 1647
@@ -1654,10 +1655,7 @@ void stop_atmel_card(struct net_device *dev, int freeres)
1654 remove_proc_entry("driver/atmel", NULL); 1655 remove_proc_entry("driver/atmel", NULL);
1655 free_irq(dev->irq, dev); 1656 free_irq(dev->irq, dev);
1656 kfree(priv->firmware); 1657 kfree(priv->firmware);
1657 if (freeres) { 1658 release_region(dev->base_addr, 32);
1658 /* PCMCIA frees this stuff, so only for PCI */
1659 release_region(dev->base_addr, 64);
1660 }
1661 free_netdev(dev); 1659 free_netdev(dev);
1662} 1660}
1663 1661
@@ -1810,9 +1808,9 @@ static int atmel_set_encode(struct net_device *dev,
1810 } 1808 }
1811 if(dwrq->flags & IW_ENCODE_RESTRICTED) 1809 if(dwrq->flags & IW_ENCODE_RESTRICTED)
1812 priv->exclude_unencrypted = 1; 1810 priv->exclude_unencrypted = 1;
1813 if(dwrq->flags & IW_ENCODE_OPEN) 1811 if(dwrq->flags & IW_ENCODE_OPEN)
1814 priv->exclude_unencrypted = 0; 1812 priv->exclude_unencrypted = 0;
1815 1813
1816 return -EINPROGRESS; /* Call commit handler */ 1814 return -EINPROGRESS; /* Call commit handler */
1817} 1815}
1818 1816
@@ -1827,11 +1825,12 @@ static int atmel_get_encode(struct net_device *dev,
1827 1825
1828 if (!priv->wep_is_on) 1826 if (!priv->wep_is_on)
1829 dwrq->flags = IW_ENCODE_DISABLED; 1827 dwrq->flags = IW_ENCODE_DISABLED;
1830 else if (priv->exclude_unencrypted) 1828 else {
1831 dwrq->flags = IW_ENCODE_RESTRICTED; 1829 if (priv->exclude_unencrypted)
1832 else 1830 dwrq->flags = IW_ENCODE_RESTRICTED;
1833 dwrq->flags = IW_ENCODE_OPEN; 1831 else
1834 1832 dwrq->flags = IW_ENCODE_OPEN;
1833 }
1835 /* Which key do we want ? -1 -> tx index */ 1834 /* Which key do we want ? -1 -> tx index */
1836 if (index < 0 || index >= 4) 1835 if (index < 0 || index >= 4)
1837 index = priv->default_key; 1836 index = priv->default_key;
@@ -2645,8 +2644,8 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 c
2645 } 2644 }
2646} 2645}
2647 2646
2648 2647
2649static void send_authentication_request(struct atmel_private *priv, u8 *challenge, int challenge_len) 2648static void send_authentication_request(struct atmel_private *priv, u16 system, u8 *challenge, int challenge_len)
2650{ 2649{
2651 struct ieee80211_hdr_4addr header; 2650 struct ieee80211_hdr_4addr header;
2652 struct auth_body auth; 2651 struct auth_body auth;
@@ -2658,14 +2657,11 @@ static void send_authentication_request(struct atmel_private *priv, u8 *challeng
2658 memcpy(header.addr2, priv->dev->dev_addr, 6); 2657 memcpy(header.addr2, priv->dev->dev_addr, 6);
2659 memcpy(header.addr3, priv->CurrentBSSID, 6); 2658 memcpy(header.addr3, priv->CurrentBSSID, 6);
2660 2659
2661 if (priv->wep_is_on) { 2660 if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1)
2662 auth.alg = cpu_to_le16(C80211_MGMT_AAN_SHAREDKEY);
2663 /* no WEP for authentication frames with TrSeqNo 1 */ 2661 /* no WEP for authentication frames with TrSeqNo 1 */
2664 if (priv->CurrentAuthentTransactionSeqNum != 1) 2662 header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
2665 header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); 2663
2666 } else { 2664 auth.alg = cpu_to_le16(system);
2667 auth.alg = cpu_to_le16(C80211_MGMT_AAN_OPENSYSTEM);
2668 }
2669 2665
2670 auth.status = 0; 2666 auth.status = 0;
2671 auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum); 2667 auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum);
@@ -2834,6 +2830,7 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2834 struct auth_body *auth = (struct auth_body *)priv->rx_buf; 2830 struct auth_body *auth = (struct auth_body *)priv->rx_buf;
2835 u16 status = le16_to_cpu(auth->status); 2831 u16 status = le16_to_cpu(auth->status);
2836 u16 trans_seq_no = le16_to_cpu(auth->trans_seq); 2832 u16 trans_seq_no = le16_to_cpu(auth->trans_seq);
2833 u16 system = le16_to_cpu(auth->alg);
2837 2834
2838 if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) { 2835 if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) {
2839 /* no WEP */ 2836 /* no WEP */
@@ -2855,7 +2852,7 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2855 2852
2856 if (trans_seq_no == 0x0002 && 2853 if (trans_seq_no == 0x0002 &&
2857 auth->el_id == C80211_MGMT_ElementID_ChallengeText) { 2854 auth->el_id == C80211_MGMT_ElementID_ChallengeText) {
2858 send_authentication_request(priv, auth->chall_text, auth->chall_text_len); 2855 send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len);
2859 return; 2856 return;
2860 } 2857 }
2861 2858
@@ -2872,14 +2869,20 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2872 } 2869 }
2873 } 2870 }
2874 2871
2875 if (status == C80211_MGMT_SC_AuthAlgNotSupported && priv->connect_to_any_BSS) { 2872 if (status == C80211_MGMT_SC_AuthAlgNotSupported) {
2876 int bss_index; 2873 /* Do opensystem first, then try sharedkey */
2877 2874 if (system == C80211_MGMT_AAN_OPENSYSTEM) {
2878 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; 2875 priv->CurrentAuthentTransactionSeqNum = 0x001;
2879 2876 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0);
2880 if ((bss_index = retrieve_bss(priv)) != -1) { 2877 } else if (priv->connect_to_any_BSS) {
2881 atmel_join_bss(priv, bss_index); 2878 int bss_index;
2882 return; 2879
2880 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80;
2881
2882 if ((bss_index = retrieve_bss(priv)) != -1) {
2883 atmel_join_bss(priv, bss_index);
2884 return;
2885 }
2883 } 2886 }
2884 } 2887 }
2885 2888
@@ -3205,7 +3208,7 @@ static void atmel_management_timer(u_long a)
3205 priv->AuthenticationRequestRetryCnt++; 3208 priv->AuthenticationRequestRetryCnt++;
3206 priv->CurrentAuthentTransactionSeqNum = 0x0001; 3209 priv->CurrentAuthentTransactionSeqNum = 0x0001;
3207 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); 3210 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3208 send_authentication_request(priv, NULL, 0); 3211 send_authentication_request(priv, C80211_MGMT_AAN_OPENSYSTEM, NULL, 0);
3209 } 3212 }
3210 3213
3211 break; 3214 break;
@@ -3312,7 +3315,7 @@ static void atmel_command_irq(struct atmel_private *priv)
3312 3315
3313 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); 3316 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3314 priv->CurrentAuthentTransactionSeqNum = 0x0001; 3317 priv->CurrentAuthentTransactionSeqNum = 0x0001;
3315 send_authentication_request(priv, NULL, 0); 3318 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0);
3316 } 3319 }
3317 return; 3320 return;
3318 } 3321 }
@@ -3482,11 +3485,6 @@ static int probe_atmel_card(struct net_device *dev)
3482 printk(KERN_ALERT "%s: *** Invalid MAC address. UPGRADE Firmware ****\n", dev->name); 3485 printk(KERN_ALERT "%s: *** Invalid MAC address. UPGRADE Firmware ****\n", dev->name);
3483 memcpy(dev->dev_addr, default_mac, 6); 3486 memcpy(dev->dev_addr, default_mac, 6);
3484 } 3487 }
3485 printk(KERN_INFO "%s: MAC address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
3486 dev->name,
3487 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
3488 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] );
3489
3490 } 3488 }
3491 3489
3492 return rc; 3490 return rc;
diff --git a/drivers/net/wireless/atmel.h b/drivers/net/wireless/atmel.h
index 825000edfc2c..b9b3e5b76544 100644
--- a/drivers/net/wireless/atmel.h
+++ b/drivers/net/wireless/atmel.h
@@ -35,9 +35,9 @@ typedef enum {
35 ATMEL_FW_TYPE_506 35 ATMEL_FW_TYPE_506
36} AtmelFWType; 36} AtmelFWType;
37 37
38struct net_device *init_atmel_card(unsigned short, int, const AtmelFWType, struct device *, 38struct net_device *init_atmel_card(unsigned short, unsigned long, const AtmelFWType, struct device *,
39 int (*present_func)(void *), void * ); 39 int (*present_func)(void *), void * );
40void stop_atmel_card( struct net_device *, int ); 40void stop_atmel_card( struct net_device *);
41int atmel_open( struct net_device * ); 41int atmel_open( struct net_device * );
42 42
43#endif 43#endif
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 1bd13146c644..17d1fd90f832 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -63,6 +63,7 @@
63 be present but disabled -- but it can then be enabled for specific 63 be present but disabled -- but it can then be enabled for specific
64 modules at load time with a 'pc_debug=#' option to insmod. 64 modules at load time with a 'pc_debug=#' option to insmod.
65*/ 65*/
66
66#ifdef PCMCIA_DEBUG 67#ifdef PCMCIA_DEBUG
67static int pc_debug = PCMCIA_DEBUG; 68static int pc_debug = PCMCIA_DEBUG;
68module_param(pc_debug, int, 0); 69module_param(pc_debug, int, 0);
@@ -285,41 +286,6 @@ static int card_present(void *arg)
285 return 0; 286 return 0;
286} 287}
287 288
288/* list of cards we know about and their firmware requirements.
289 Go either by Manfid or version strings.
290 Cards not in this list will need a firmware parameter to the module
291 in all probability. Note that the SMC 2632 V2 and V3 have the same
292 manfids, so we ignore those and use the version1 strings. */
293
294static struct {
295 int manf, card;
296 char *ver1;
297 AtmelFWType firmware;
298 char *name;
299} card_table[] = {
300 { 0, 0, "WLAN/802.11b PC CARD", ATMEL_FW_TYPE_502D, "Actiontec 802CAT1" },
301 { 0, 0, "ATMEL/AT76C502AR", ATMEL_FW_TYPE_502, "NoName-RFMD" },
302 { 0, 0, "ATMEL/AT76C502AR_D", ATMEL_FW_TYPE_502D, "NoName-revD" },
303 { 0, 0, "ATMEL/AT76C502AR_E", ATMEL_FW_TYPE_502E, "NoName-revE" },
304 { 0, 0, "ATMEL/AT76C504", ATMEL_FW_TYPE_504, "NoName-504" },
305 { 0, 0, "ATMEL/AT76C504A", ATMEL_FW_TYPE_504A_2958, "NoName-504a-2958" },
306 { 0, 0, "ATMEL/AT76C504_R", ATMEL_FW_TYPE_504_2958, "NoName-504-2958" },
307 { MANFID_3COM, 0x0620, NULL, ATMEL_FW_TYPE_502_3COM, "3com 3CRWE62092B" },
308 { MANFID_3COM, 0x0696, NULL, ATMEL_FW_TYPE_502_3COM, "3com 3CRSHPW196" },
309 { 0, 0, "SMC/2632W-V2", ATMEL_FW_TYPE_502, "SMC 2632W-V2" },
310 { 0, 0, "SMC/2632W", ATMEL_FW_TYPE_502D, "SMC 2632W-V3" },
311 { 0xd601, 0x0007, NULL, ATMEL_FW_TYPE_502, "Sitecom WLAN-011" },
312 { 0x01bf, 0x3302, NULL, ATMEL_FW_TYPE_502E, "Belkin F5D6020-V2" },
313 { 0, 0, "BT/Voyager 1020 Laptop Adapter", ATMEL_FW_TYPE_502, "BT Voyager 1020" },
314 { 0, 0, "IEEE 802.11b/Wireless LAN PC Card", ATMEL_FW_TYPE_502, "Siemens Gigaset PC Card II" },
315 { 0, 0, "IEEE 802.11b/Wireless LAN Card S", ATMEL_FW_TYPE_504_2958, "Siemens Gigaset PC Card II" },
316 { 0, 0, "CNet/CNWLC 11Mbps Wireless PC Card V-5", ATMEL_FW_TYPE_502E, "CNet CNWLC-811ARL" },
317 { 0, 0, "Wireless/PC_CARD", ATMEL_FW_TYPE_502D, "Planet WL-3552" },
318 { 0, 0, "OEM/11Mbps Wireless LAN PC Card V-3", ATMEL_FW_TYPE_502, "OEM 11Mbps WLAN PCMCIA Card" },
319 { 0, 0, "11WAVE/11WP611AL-E", ATMEL_FW_TYPE_502E, "11WAVE WaveBuddy" },
320 { 0, 0, "LG/LW2100N", ATMEL_FW_TYPE_502E, "LG LW2100N 11Mbps WLAN PCMCIA Card" },
321};
322
323static void atmel_config(dev_link_t *link) 289static void atmel_config(dev_link_t *link)
324{ 290{
325 client_handle_t handle; 291 client_handle_t handle;
@@ -328,10 +294,11 @@ static void atmel_config(dev_link_t *link)
328 local_info_t *dev; 294 local_info_t *dev;
329 int last_fn, last_ret; 295 int last_fn, last_ret;
330 u_char buf[64]; 296 u_char buf[64];
331 int card_index = -1, done = 0; 297 struct pcmcia_device_id *did;
332 298
333 handle = link->handle; 299 handle = link->handle;
334 dev = link->priv; 300 dev = link->priv;
301 did = handle_to_dev(handle).driver_data;
335 302
336 DEBUG(0, "atmel_config(0x%p)\n", link); 303 DEBUG(0, "atmel_config(0x%p)\n", link);
337 304
@@ -340,59 +307,6 @@ static void atmel_config(dev_link_t *link)
340 tuple.TupleDataMax = sizeof(buf); 307 tuple.TupleDataMax = sizeof(buf);
341 tuple.TupleOffset = 0; 308 tuple.TupleOffset = 0;
342 309
343 tuple.DesiredTuple = CISTPL_MANFID;
344 if (pcmcia_get_first_tuple(handle, &tuple) == 0) {
345 int i;
346 cistpl_manfid_t *manfid;
347 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
348 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
349 manfid = &(parse.manfid);
350 for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
351 if (!card_table[i].ver1 &&
352 manfid->manf == card_table[i].manf &&
353 manfid->card == card_table[i].card) {
354 card_index = i;
355 done = 1;
356 }
357 }
358 }
359
360 tuple.DesiredTuple = CISTPL_VERS_1;
361 if (!done && (pcmcia_get_first_tuple(handle, &tuple) == 0)) {
362 int i, j, k;
363 cistpl_vers_1_t *ver1;
364 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
365 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
366 ver1 = &(parse.version_1);
367
368 for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
369 for (j = 0; j < ver1->ns; j++) {
370 char *p = card_table[i].ver1;
371 char *q = &ver1->str[ver1->ofs[j]];
372 if (!p)
373 goto mismatch;
374 for (k = 0; k < j; k++) {
375 while ((*p != '\0') && (*p != '/')) p++;
376 if (*p == '\0') {
377 if (*q != '\0')
378 goto mismatch;
379 } else {
380 p++;
381 }
382 }
383 while((*q != '\0') && (*p != '\0') &&
384 (*p != '/') && (*p == *q)) p++, q++;
385 if (((*p != '\0') && *p != '/') || *q != '\0')
386 goto mismatch;
387 }
388 card_index = i;
389 break; /* done */
390
391 mismatch:
392 j = 0; /* dummy stmt to shut up compiler */
393 }
394 }
395
396 /* 310 /*
397 This reads the card's CONFIG tuple to find its configuration 311 This reads the card's CONFIG tuple to find its configuration
398 registers. 312 registers.
@@ -509,12 +423,13 @@ static void atmel_config(dev_link_t *link)
509 ((local_info_t*)link->priv)->eth_dev = 423 ((local_info_t*)link->priv)->eth_dev =
510 init_atmel_card(link->irq.AssignedIRQ, 424 init_atmel_card(link->irq.AssignedIRQ,
511 link->io.BasePort1, 425 link->io.BasePort1,
512 card_index == -1 ? ATMEL_FW_TYPE_NONE : card_table[card_index].firmware, 426 did ? did->driver_info : ATMEL_FW_TYPE_NONE,
513 &handle_to_dev(handle), 427 &handle_to_dev(handle),
514 card_present, 428 card_present,
515 link); 429 link);
516 if (!((local_info_t*)link->priv)->eth_dev) 430 if (!((local_info_t*)link->priv)->eth_dev)
517 goto cs_failed; 431 goto cs_failed;
432
518 433
519 /* 434 /*
520 At this point, the dev_node_t structure(s) need to be 435 At this point, the dev_node_t structure(s) need to be
@@ -523,26 +438,7 @@ static void atmel_config(dev_link_t *link)
523 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 438 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
524 dev->node.major = dev->node.minor = 0; 439 dev->node.major = dev->node.minor = 0;
525 link->dev = &dev->node; 440 link->dev = &dev->node;
526 441
527 /* Finally, report what we've done */
528 printk(KERN_INFO "%s: %s%sindex 0x%02x: Vcc %d.%d",
529 dev->node.dev_name,
530 card_index == -1 ? "" : card_table[card_index].name,
531 card_index == -1 ? "" : " ",
532 link->conf.ConfigIndex,
533 link->conf.Vcc/10, link->conf.Vcc%10);
534 if (link->conf.Vpp1)
535 printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10);
536 if (link->conf.Attributes & CONF_ENABLE_IRQ)
537 printk(", irq %d", link->irq.AssignedIRQ);
538 if (link->io.NumPorts1)
539 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
540 link->io.BasePort1+link->io.NumPorts1-1);
541 if (link->io.NumPorts2)
542 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
543 link->io.BasePort2+link->io.NumPorts2-1);
544 printk("\n");
545
546 link->state &= ~DEV_CONFIG_PENDING; 442 link->state &= ~DEV_CONFIG_PENDING;
547 return; 443 return;
548 444
@@ -569,7 +465,7 @@ static void atmel_release(dev_link_t *link)
569 link->dev = NULL; 465 link->dev = NULL;
570 466
571 if (dev) 467 if (dev)
572 stop_atmel_card(dev, 0); 468 stop_atmel_card(dev);
573 ((local_info_t*)link->priv)->eth_dev = NULL; 469 ((local_info_t*)link->priv)->eth_dev = NULL;
574 470
575 /* Don't bother checking to see if these succeed or not */ 471 /* Don't bother checking to see if these succeed or not */
@@ -637,25 +533,47 @@ static int atmel_event(event_t event, int priority,
637} /* atmel_event */ 533} /* atmel_event */
638 534
639/*====================================================================*/ 535/*====================================================================*/
536/* We use the driver_info field to store the correct firmware type for a card. */
537
538#define PCMCIA_DEVICE_MANF_CARD_INFO(manf, card, info) { \
539 .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \
540 PCMCIA_DEV_ID_MATCH_CARD_ID, \
541 .manf_id = (manf), \
542 .card_id = (card), \
543 .driver_info = (kernel_ulong_t)(info), }
544
545#define PCMCIA_DEVICE_PROD_ID12_INFO(v1, v2, vh1, vh2, info) { \
546 .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID1| \
547 PCMCIA_DEV_ID_MATCH_PROD_ID2, \
548 .prod_id = { (v1), (v2), NULL, NULL }, \
549 .prod_id_hash = { (vh1), (vh2), 0, 0 }, \
550 .driver_info = (kernel_ulong_t)(info), }
551
640static struct pcmcia_device_id atmel_ids[] = { 552static struct pcmcia_device_id atmel_ids[] = {
641 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0620), 553 PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0620, ATMEL_FW_TYPE_502_3COM),
642 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0696), 554 PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0696, ATMEL_FW_TYPE_502_3COM),
643 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3302), 555 PCMCIA_DEVICE_MANF_CARD_INFO(0x01bf, 0x3302, ATMEL_FW_TYPE_502E),
644 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0007), 556 PCMCIA_DEVICE_MANF_CARD_INFO(0xd601, 0x0007, ATMEL_FW_TYPE_502),
645 PCMCIA_DEVICE_PROD_ID12("11WAVE", "11WP611AL-E", 0x9eb2da1f, 0xc9a0d3f9), 557 PCMCIA_DEVICE_PROD_ID12_INFO("11WAVE", "11WP611AL-E", 0x9eb2da1f, 0xc9a0d3f9, ATMEL_FW_TYPE_502E),
646 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C502AR", 0xabda4164, 0x41b37e1f), 558 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C502AR", 0xabda4164, 0x41b37e1f, ATMEL_FW_TYPE_502),
647 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504", 0xabda4164, 0x5040670a), 559 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C502AR_D", 0xabda4164, 0x3675d704, ATMEL_FW_TYPE_502D),
648 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504A", 0xabda4164, 0xe15ed87f), 560 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C502AR_E", 0xabda4164, 0x4172e792, ATMEL_FW_TYPE_502E),
649 PCMCIA_DEVICE_PROD_ID12("BT", "Voyager 1020 Laptop Adapter", 0xae49b86a, 0x1e957cd5), 561 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C504_R", 0xabda4164, 0x917f3d72, ATMEL_FW_TYPE_504_2958),
650 PCMCIA_DEVICE_PROD_ID12("CNet", "CNWLC 11Mbps Wireless PC Card V-5", 0xbc477dde, 0x502fae6b), 562 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C504", 0xabda4164, 0x5040670a, ATMEL_FW_TYPE_504),
651 PCMCIA_DEVICE_PROD_ID12("IEEE 802.11b", "Wireless LAN PC Card", 0x5b878724, 0x122f1df6), 563 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C504A", 0xabda4164, 0xe15ed87f, ATMEL_FW_TYPE_504A_2958),
652 PCMCIA_DEVICE_PROD_ID12("OEM", "11Mbps Wireless LAN PC Card V-3", 0xfea54c90, 0x1c5b0f68), 564 PCMCIA_DEVICE_PROD_ID12_INFO("BT", "Voyager 1020 Laptop Adapter", 0xae49b86a, 0x1e957cd5, ATMEL_FW_TYPE_502),
653 PCMCIA_DEVICE_PROD_ID12("SMC", "2632W", 0xc4f8b18b, 0x30f38774), 565 PCMCIA_DEVICE_PROD_ID12_INFO("CNet", "CNWLC 11Mbps Wireless PC Card V-5", 0xbc477dde, 0x502fae6b, ATMEL_FW_TYPE_502E),
654 PCMCIA_DEVICE_PROD_ID12("SMC", "2632W-V2", 0xc4f8b18b, 0x172d1377), 566 PCMCIA_DEVICE_PROD_ID12_INFO("IEEE 802.11b", "Wireless LAN PC Card", 0x5b878724, 0x122f1df6, ATMEL_FW_TYPE_502),
655 PCMCIA_DEVICE_PROD_ID12("Wireless", "PC", 0xa407ecdd, 0x556e4d7e), 567 PCMCIA_DEVICE_PROD_ID12_INFO("IEEE 802.11b", "Wireless LAN Card S", 0x5b878724, 0x5fba533a, ATMEL_FW_TYPE_504_2958),
656 PCMCIA_DEVICE_PROD_ID12("WLAN", "802.11b PC CARD", 0x575c516c, 0xb1f6dbc4), 568 PCMCIA_DEVICE_PROD_ID12_INFO("OEM", "11Mbps Wireless LAN PC Card V-3", 0xfea54c90, 0x1c5b0f68, ATMEL_FW_TYPE_502),
569 PCMCIA_DEVICE_PROD_ID12_INFO("SMC", "2632W", 0xc4f8b18b, 0x30f38774, ATMEL_FW_TYPE_502D),
570 PCMCIA_DEVICE_PROD_ID12_INFO("SMC", "2632W-V2", 0xc4f8b18b, 0x172d1377, ATMEL_FW_TYPE_502),
571 PCMCIA_DEVICE_PROD_ID12_INFO("Wireless", "PC_CARD", 0xa407ecdd, 0x119f6314, ATMEL_FW_TYPE_502D),
572 PCMCIA_DEVICE_PROD_ID12_INFO("WLAN", "802.11b PC CARD", 0x575c516c, 0xb1f6dbc4, ATMEL_FW_TYPE_502D),
573 PCMCIA_DEVICE_PROD_ID12_INFO("LG", "LW2100N", 0xb474d43a, 0x6b1fec94, ATMEL_FW_TYPE_502E),
657 PCMCIA_DEVICE_NULL 574 PCMCIA_DEVICE_NULL
658}; 575};
576
659MODULE_DEVICE_TABLE(pcmcia, atmel_ids); 577MODULE_DEVICE_TABLE(pcmcia, atmel_ids);
660 578
661static struct pcmcia_driver atmel_driver = { 579static struct pcmcia_driver atmel_driver = {
diff --git a/drivers/net/wireless/atmel_pci.c b/drivers/net/wireless/atmel_pci.c
index 2eb00a957bbe..a61b3bc6cccf 100644
--- a/drivers/net/wireless/atmel_pci.c
+++ b/drivers/net/wireless/atmel_pci.c
@@ -72,7 +72,7 @@ static int __devinit atmel_pci_probe(struct pci_dev *pdev,
72 72
73static void __devexit atmel_pci_remove(struct pci_dev *pdev) 73static void __devexit atmel_pci_remove(struct pci_dev *pdev)
74{ 74{
75 stop_atmel_card(pci_get_drvdata(pdev), 1); 75 stop_atmel_card(pci_get_drvdata(pdev));
76} 76}
77 77
78static int __init atmel_init_module(void) 78static int __init atmel_init_module(void)
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 579480dad374..346c6febb033 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -398,7 +398,7 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
398 * 398 *
399 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 399 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
400 */ 400 */
401int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len, 401int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
402 u16 id, u16 offset) 402 u16 id, u16 offset)
403{ 403{
404 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 404 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -424,7 +424,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len,
424 * 424 *
425 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 425 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
426 */ 426 */
427int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len, 427int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
428 u16 id, u16 offset) 428 u16 id, u16 offset)
429{ 429{
430 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 430 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -450,7 +450,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len,
450 * 450 *
451 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 451 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
452 */ 452 */
453int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, unsigned len, 453int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, int len,
454 u16 id, u16 offset) 454 u16 id, u16 offset)
455{ 455{
456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h
index a6bd472d75d4..7644f72a9f4e 100644
--- a/drivers/net/wireless/hermes.h
+++ b/drivers/net/wireless/hermes.h
@@ -372,12 +372,12 @@ int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
372 struct hermes_response *resp); 372 struct hermes_response *resp);
373int hermes_allocate(hermes_t *hw, u16 size, u16 *fid); 373int hermes_allocate(hermes_t *hw, u16 size, u16 *fid);
374 374
375int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len, 375int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
376 u16 id, u16 offset); 376 u16 id, u16 offset);
377int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len, 377int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
378 u16 id, u16 offset); 378 u16 id, u16 offset);
379int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, 379int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf,
380 unsigned data_len, unsigned len, u16 id, u16 offset); 380 unsigned data_len, int len, u16 id, u16 offset);
381int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen, 381int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen,
382 u16 *length, void *buf); 382 u16 *length, void *buf);
383int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 383int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
diff --git a/drivers/net/wireless/i82593.h b/drivers/net/wireless/i82593.h
index 33acb8add4d6..afac5c7a323d 100644
--- a/drivers/net/wireless/i82593.h
+++ b/drivers/net/wireless/i82593.h
@@ -7,11 +7,16 @@
7 * 7 *
8 * Copyright 1994, Anders Klemets <klemets@it.kth.se> 8 * Copyright 1994, Anders Klemets <klemets@it.kth.se>
9 * 9 *
10 * This software may be freely distributed for noncommercial purposes
11 * as long as this notice is retained.
12 *
13 * HISTORY 10 * HISTORY
14 * i82593.h,v 11 * i82593.h,v
12 * Revision 1.4 2005/11/4 09:15:00 baroniunas
13 * Modified copyright with permission of author as follows:
14 *
15 * "If I82539.H is the only file with my copyright statement
16 * that is included in the Source Forge project, then you have
17 * my approval to change the copyright statement to be a GPL
18 * license, in the way you proposed on October 10."
19 *
15 * Revision 1.1 1996/07/17 15:23:12 root 20 * Revision 1.1 1996/07/17 15:23:12 root
16 * Initial revision 21 * Initial revision
17 * 22 *
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index a2e6214169e9..77d2a21d4cd0 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -6344,7 +6344,8 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6344 dev->ethtool_ops = &ipw2100_ethtool_ops; 6344 dev->ethtool_ops = &ipw2100_ethtool_ops;
6345 dev->tx_timeout = ipw2100_tx_timeout; 6345 dev->tx_timeout = ipw2100_tx_timeout;
6346 dev->wireless_handlers = &ipw2100_wx_handler_def; 6346 dev->wireless_handlers = &ipw2100_wx_handler_def;
6347 dev->get_wireless_stats = ipw2100_wx_wireless_stats; 6347 priv->wireless_data.ieee80211 = priv->ieee;
6348 dev->wireless_data = &priv->wireless_data;
6348 dev->set_mac_address = ipw2100_set_address; 6349 dev->set_mac_address = ipw2100_set_address;
6349 dev->watchdog_timeo = 3 * HZ; 6350 dev->watchdog_timeo = 3 * HZ;
6350 dev->irq = 0; 6351 dev->irq = 0;
@@ -7178,6 +7179,11 @@ static int ipw2100_wx_get_range(struct net_device *dev,
7178 } 7179 }
7179 range->num_frequency = val; 7180 range->num_frequency = val;
7180 7181
7182 /* Event capability (kernel + driver) */
7183 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
7184 IW_EVENT_CAPA_MASK(SIOCGIWAP));
7185 range->event_capa[1] = IW_EVENT_CAPA_K_1;
7186
7181 IPW_DEBUG_WX("GET Range\n"); 7187 IPW_DEBUG_WX("GET Range\n");
7182 7188
7183 return 0; 7189 return 0;
@@ -8446,16 +8452,6 @@ static iw_handler ipw2100_private_handler[] = {
8446#endif /* CONFIG_IPW2100_MONITOR */ 8452#endif /* CONFIG_IPW2100_MONITOR */
8447}; 8453};
8448 8454
8449static struct iw_handler_def ipw2100_wx_handler_def = {
8450 .standard = ipw2100_wx_handlers,
8451 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler),
8452 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler),
8453 .num_private_args = sizeof(ipw2100_private_args) /
8454 sizeof(struct iw_priv_args),
8455 .private = (iw_handler *) ipw2100_private_handler,
8456 .private_args = (struct iw_priv_args *)ipw2100_private_args,
8457};
8458
8459/* 8455/*
8460 * Get wireless statistics. 8456 * Get wireless statistics.
8461 * Called by /proc/net/wireless 8457 * Called by /proc/net/wireless
@@ -8597,6 +8593,17 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev)
8597 return (struct iw_statistics *)NULL; 8593 return (struct iw_statistics *)NULL;
8598} 8594}
8599 8595
8596static struct iw_handler_def ipw2100_wx_handler_def = {
8597 .standard = ipw2100_wx_handlers,
8598 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler),
8599 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler),
8600 .num_private_args = sizeof(ipw2100_private_args) /
8601 sizeof(struct iw_priv_args),
8602 .private = (iw_handler *) ipw2100_private_handler,
8603 .private_args = (struct iw_priv_args *)ipw2100_private_args,
8604 .get_wireless_stats = ipw2100_wx_wireless_stats,
8605};
8606
8600static void ipw2100_wx_event_work(struct ipw2100_priv *priv) 8607static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8601{ 8608{
8602 union iwreq_data wrqu; 8609 union iwreq_data wrqu;
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index 140fdf2a0a09..7c65b10bb164 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -571,6 +571,8 @@ struct ipw2100_priv {
571 struct net_device *net_dev; 571 struct net_device *net_dev;
572 struct iw_statistics wstats; 572 struct iw_statistics wstats;
573 573
574 struct iw_public_data wireless_data;
575
574 struct tasklet_struct irq_tasklet; 576 struct tasklet_struct irq_tasklet;
575 577
576 struct workqueue_struct *workqueue; 578 struct workqueue_struct *workqueue;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index b0d195d1721a..5e7c7e944c9d 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -1110,8 +1110,7 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv)
1110 error->elem_len = elem_len; 1110 error->elem_len = elem_len;
1111 error->log_len = log_len; 1111 error->log_len = log_len;
1112 error->elem = (struct ipw_error_elem *)error->payload; 1112 error->elem = (struct ipw_error_elem *)error->payload;
1113 error->log = (struct ipw_event *)(error->elem + 1113 error->log = (struct ipw_event *)(error->elem + elem_len);
1114 (sizeof(*error->elem) * elem_len));
1115 1114
1116 ipw_capture_event_log(priv, log_len, error->log); 1115 ipw_capture_event_log(priv, log_len, error->log);
1117 1116
@@ -8926,6 +8925,10 @@ static int ipw_request_direct_scan(struct ipw_priv *priv, char *essid,
8926 struct ipw_scan_request_ext scan; 8925 struct ipw_scan_request_ext scan;
8927 int err = 0, scan_type; 8926 int err = 0, scan_type;
8928 8927
8928 if (!(priv->status & STATUS_INIT) ||
8929 (priv->status & STATUS_EXIT_PENDING))
8930 return 0;
8931
8929 down(&priv->sem); 8932 down(&priv->sem);
8930 8933
8931 if (priv->status & STATUS_RF_KILL_MASK) { 8934 if (priv->status & STATUS_RF_KILL_MASK) {
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 488ab06fb79f..6fd0bf736830 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -3512,9 +3512,8 @@ static int orinoco_ioctl_setpower(struct net_device *dev,
3512 break; 3512 break;
3513 default: 3513 default:
3514 err = -EINVAL; 3514 err = -EINVAL;
3515 }
3516 if (err)
3517 goto out; 3515 goto out;
3516 }
3518 3517
3519 if (prq->flags & IW_POWER_TIMEOUT) { 3518 if (prq->flags & IW_POWER_TIMEOUT) {
3520 priv->pm_on = 1; 3519 priv->pm_on = 1;
diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco_nortel.c
index d8afd51ff8a5..d1a670b35338 100644
--- a/drivers/net/wireless/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco_nortel.c
@@ -1,6 +1,8 @@
1/* orinoco_nortel.c 1/* orinoco_nortel.c
2 * 2 *
3 * Driver for Prism II devices which would usually be driven by orinoco_cs, 3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a PCI-to-PCMCIA adapter used in
5 * Nortel emobility, Symbol LA-4113 and Symbol LA-4123.
4 * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter. 6 * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter.
5 * 7 *
6 * Copyright (C) 2002 Tobias Hoffmann 8 * Copyright (C) 2002 Tobias Hoffmann
@@ -165,7 +167,7 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
165 goto fail_resources; 167 goto fail_resources;
166 } 168 }
167 169
168 iomem = pci_iomap(pdev, 3, 0); 170 iomem = pci_iomap(pdev, 2, 0);
169 if (!iomem) { 171 if (!iomem) {
170 err = -ENOMEM; 172 err = -ENOMEM;
171 goto fail_map_io; 173 goto fail_map_io;
@@ -265,6 +267,8 @@ static void __devexit nortel_pci_remove_one(struct pci_dev *pdev)
265static struct pci_device_id nortel_pci_id_table[] = { 267static struct pci_device_id nortel_pci_id_table[] = {
266 /* Nortel emobility PCI */ 268 /* Nortel emobility PCI */
267 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,}, 269 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,},
270 /* Symbol LA-4123 PCI */
271 {0x1562, 0x0001, PCI_ANY_ID, PCI_ANY_ID,},
268 {0,}, 272 {0,},
269}; 273};
270 274
diff --git a/drivers/net/wireless/prism54/isl_38xx.c b/drivers/net/wireless/prism54/isl_38xx.c
index 109a96d90007..23deee69974b 100644
--- a/drivers/net/wireless/prism54/isl_38xx.c
+++ b/drivers/net/wireless/prism54/isl_38xx.c
@@ -164,12 +164,12 @@ isl38xx_trigger_device(int asleep, void __iomem *device_base)
164 /* assert the Wakeup interrupt in the Device Interrupt Register */ 164 /* assert the Wakeup interrupt in the Device Interrupt Register */
165 isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_WAKEUP, 165 isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_WAKEUP,
166 ISL38XX_DEV_INT_REG); 166 ISL38XX_DEV_INT_REG);
167
168#if VERBOSE > SHOW_ERROR_MESSAGES
167 udelay(ISL38XX_WRITEIO_DELAY); 169 udelay(ISL38XX_WRITEIO_DELAY);
168 170
169 /* perform another read on the Device Status Register */ 171 /* perform another read on the Device Status Register */
170 reg = readl(device_base + ISL38XX_CTRL_STAT_REG); 172 reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
171
172#if VERBOSE > SHOW_ERROR_MESSAGES
173 do_gettimeofday(&current_time); 173 do_gettimeofday(&current_time);
174 DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n", 174 DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n",
175 current_time.tv_sec, (long)current_time.tv_usec, reg); 175 current_time.tv_sec, (long)current_time.tv_usec, reg);