aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-08-29 16:40:27 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-08-29 16:40:27 -0400
commitc1b054d03f5b31c33eaa0b267c629b118eaf3790 (patch)
tree9333907ca767be24fcb3667877242976c3e3c8dd /drivers/net
parent559fb51ba7e66fe298b8355fabde1275b7def35f (diff)
parentbf4e70e54cf31dcca48d279c7f7e71328eebe749 (diff)
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/3c503.c16
-rw-r--r--drivers/net/3c505.c8
-rw-r--r--drivers/net/3c509.c1
-rw-r--r--drivers/net/3c515.c16
-rw-r--r--drivers/net/3c523.c19
-rw-r--r--drivers/net/3c59x.c6
-rw-r--r--drivers/net/8139cp.c32
-rw-r--r--drivers/net/8139too.c8
-rw-r--r--drivers/net/82596.c14
-rw-r--r--drivers/net/Kconfig71
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/Space.c12
-rw-r--r--drivers/net/ac3200.c19
-rw-r--r--drivers/net/acenic.c5
-rwxr-xr-xdrivers/net/amd8111e.c10
-rw-r--r--drivers/net/appletalk/Kconfig27
-rw-r--r--drivers/net/appletalk/ltpc.c6
-rw-r--r--drivers/net/arm/etherh.c16
-rw-r--r--drivers/net/at1700.c4
-rw-r--r--drivers/net/b44.c6
-rw-r--r--drivers/net/bmac.c7
-rw-r--r--drivers/net/bonding/bond_3ad.c3
-rw-r--r--drivers/net/bonding/bond_alb.c17
-rw-r--r--drivers/net/bonding/bond_main.c448
-rw-r--r--drivers/net/bonding/bonding.h15
-rw-r--r--drivers/net/cs89x0.c72
-rw-r--r--drivers/net/cs89x0.h3
-rw-r--r--drivers/net/defxx.c88
-rw-r--r--drivers/net/dl2k.c8
-rw-r--r--drivers/net/dm9000.c56
-rw-r--r--drivers/net/e100.c37
-rw-r--r--drivers/net/e1000/e1000.h4
-rw-r--r--drivers/net/e1000/e1000_ethtool.c131
-rw-r--r--drivers/net/e1000/e1000_hw.c23
-rw-r--r--drivers/net/e1000/e1000_hw.h1
-rw-r--r--drivers/net/e1000/e1000_main.c142
-rw-r--r--drivers/net/e2100.c15
-rw-r--r--drivers/net/eepro.c21
-rw-r--r--drivers/net/eepro100.c16
-rw-r--r--drivers/net/eexpress.c12
-rw-r--r--drivers/net/epic100.c6
-rw-r--r--drivers/net/eql.c16
-rw-r--r--drivers/net/es3210.c16
-rw-r--r--drivers/net/eth16i.c20
-rw-r--r--drivers/net/ewrk3.c12
-rw-r--r--drivers/net/fealnx.c11
-rw-r--r--drivers/net/forcedeth.c571
-rw-r--r--drivers/net/gianfar.c652
-rw-r--r--drivers/net/gianfar.h363
-rw-r--r--drivers/net/gianfar_ethtool.c277
-rw-r--r--drivers/net/gianfar_phy.c2
-rw-r--r--drivers/net/hamachi.c12
-rw-r--r--drivers/net/hamradio/6pack.c31
-rw-r--r--drivers/net/hamradio/Kconfig4
-rw-r--r--drivers/net/hamradio/baycom_epp.c3
-rw-r--r--drivers/net/hamradio/baycom_par.c3
-rw-r--r--drivers/net/hamradio/baycom_ser_fdx.c3
-rw-r--r--drivers/net/hamradio/baycom_ser_hdx.c3
-rw-r--r--drivers/net/hamradio/mkiss.c1086
-rw-r--r--drivers/net/hamradio/scc.c5
-rw-r--r--drivers/net/hp-plus.c15
-rw-r--r--drivers/net/hp.c17
-rw-r--r--drivers/net/hp100.c44
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c5
-rw-r--r--drivers/net/ioc3-eth.c8
-rw-r--r--drivers/net/irda/irtty-sir.c2
-rw-r--r--drivers/net/irda/sir_kthread.c3
-rw-r--r--drivers/net/irda/stir4200.c4
-rw-r--r--drivers/net/isa-skeleton.c20
-rw-r--r--drivers/net/ixgb/ixgb.h2
-rw-r--r--drivers/net/ixgb/ixgb_ee.c170
-rw-r--r--drivers/net/ixgb/ixgb_ethtool.c59
-rw-r--r--drivers/net/ixgb/ixgb_hw.h9
-rw-r--r--drivers/net/ixgb/ixgb_main.c54
-rw-r--r--drivers/net/jazzsonic.c186
-rw-r--r--drivers/net/lance.c17
-rw-r--r--drivers/net/lasi_82596.c8
-rw-r--r--drivers/net/lne390.c19
-rw-r--r--drivers/net/loopback.c24
-rw-r--r--drivers/net/mace.c6
-rw-r--r--drivers/net/macsonic.c538
-rw-r--r--drivers/net/mv643xx_eth.c29
-rw-r--r--drivers/net/mv643xx_eth.h4
-rw-r--r--drivers/net/myri_code.h1283
-rw-r--r--drivers/net/myri_sbus.c2
-rw-r--r--drivers/net/natsemi.c4
-rw-r--r--drivers/net/ne-h8300.c19
-rw-r--r--drivers/net/ne.c22
-rw-r--r--drivers/net/ne2.c19
-rw-r--r--drivers/net/ne2k-pci.c3
-rw-r--r--drivers/net/ns83820.c5
-rw-r--r--drivers/net/pci-skeleton.c6
-rw-r--r--drivers/net/pcmcia/3c574_cs.c15
-rw-r--r--drivers/net/pcmcia/3c589_cs.c19
-rw-r--r--drivers/net/pcmcia/axnet_cs.c36
-rw-r--r--drivers/net/pcmcia/com20020_cs.c14
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c62
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c18
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c15
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c221
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c329
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c35
-rw-r--r--drivers/net/pcnet32.c8
-rw-r--r--drivers/net/phy/Kconfig57
-rw-r--r--drivers/net/phy/Makefile10
-rw-r--r--drivers/net/phy/cicada.c134
-rw-r--r--drivers/net/phy/davicom.c195
-rw-r--r--drivers/net/phy/lxt.c179
-rw-r--r--drivers/net/phy/marvell.c140
-rw-r--r--drivers/net/phy/mdio_bus.c176
-rw-r--r--drivers/net/phy/phy.c871
-rw-r--r--drivers/net/phy/phy_device.c696
-rw-r--r--drivers/net/phy/qsemi.c143
-rw-r--r--drivers/net/plip.c31
-rw-r--r--drivers/net/ppp_async.c4
-rw-r--r--drivers/net/ppp_generic.c12
-rw-r--r--drivers/net/ppp_synctty.c4
-rw-r--r--drivers/net/r8169.c5
-rw-r--r--drivers/net/s2io-regs.h87
-rw-r--r--drivers/net/s2io.c3100
-rw-r--r--drivers/net/s2io.h364
-rw-r--r--drivers/net/sb1000.c14
-rw-r--r--drivers/net/sb1250-mac.c4
-rw-r--r--drivers/net/shaper.c42
-rw-r--r--drivers/net/sis900.c11
-rw-r--r--drivers/net/sk98lin/skge.c85
-rw-r--r--drivers/net/sk98lin/skgeinit.c2
-rw-r--r--drivers/net/sk98lin/skxmac2.c8
-rw-r--r--drivers/net/skfp/Makefile4
-rw-r--r--drivers/net/skfp/drvfbi.c222
-rw-r--r--drivers/net/skfp/ess.c4
-rw-r--r--drivers/net/skfp/fplustm.c70
-rw-r--r--drivers/net/skfp/h/cmtdef.h7
-rw-r--r--drivers/net/skfp/h/hwmtm.h25
-rw-r--r--drivers/net/skfp/h/osdef1st.h2
-rw-r--r--drivers/net/skfp/hwmtm.c34
-rw-r--r--drivers/net/skfp/lnkstat.c204
-rw-r--r--drivers/net/skfp/pcmplc.c7
-rw-r--r--drivers/net/skfp/pmf.c11
-rw-r--r--drivers/net/skfp/skfddi.c1
-rw-r--r--drivers/net/skfp/smt.c48
-rw-r--r--drivers/net/skfp/smtdef.c5
-rw-r--r--drivers/net/skfp/smtparse.c467
-rw-r--r--drivers/net/skge.c1902
-rw-r--r--drivers/net/skge.h637
-rw-r--r--drivers/net/slip.c23
-rw-r--r--drivers/net/smc-mca.c60
-rw-r--r--drivers/net/smc-mca.h61
-rw-r--r--drivers/net/smc-ultra.c16
-rw-r--r--drivers/net/smc91x.c45
-rw-r--r--drivers/net/smc91x.h13
-rw-r--r--drivers/net/sonic.c676
-rw-r--r--drivers/net/sonic.h460
-rw-r--r--drivers/net/starfire.c6
-rw-r--r--drivers/net/sundance.c6
-rw-r--r--drivers/net/sungem.c9
-rw-r--r--drivers/net/sungem_phy.c69
-rw-r--r--drivers/net/sungem_phy.h3
-rw-r--r--drivers/net/tg3.c831
-rw-r--r--drivers/net/tg3.h49
-rw-r--r--drivers/net/tlan.c3
-rw-r--r--drivers/net/tokenring/3c359.c3
-rw-r--r--drivers/net/tokenring/3c359_microcode.h2
-rw-r--r--drivers/net/tokenring/Kconfig4
-rw-r--r--drivers/net/tokenring/abyss.c13
-rw-r--r--drivers/net/tokenring/ibmtr.c28
-rw-r--r--drivers/net/tokenring/lanstreamer.c9
-rw-r--r--drivers/net/tokenring/madgemc.c535
-rw-r--r--drivers/net/tokenring/proteon.c115
-rw-r--r--drivers/net/tokenring/skisa.c115
-rw-r--r--drivers/net/tokenring/smctr.c2
-rw-r--r--drivers/net/tokenring/smctr_firmware.h2
-rw-r--r--drivers/net/tokenring/tms380tr.c59
-rw-r--r--drivers/net/tokenring/tms380tr.h9
-rw-r--r--drivers/net/tokenring/tmspci.c15
-rw-r--r--drivers/net/tulip/de2104x.c6
-rw-r--r--drivers/net/tulip/dmfe.c23
-rw-r--r--drivers/net/tulip/eeprom.c16
-rw-r--r--drivers/net/tulip/interrupt.c10
-rw-r--r--drivers/net/tulip/media.c3
-rw-r--r--drivers/net/tulip/tulip_core.c50
-rw-r--r--drivers/net/tulip/winbond-840.c9
-rw-r--r--drivers/net/tulip/xircom_tulip_cb.c4
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/net/typhoon.c10
-rw-r--r--drivers/net/via-rhine.c26
-rw-r--r--drivers/net/via-velocity.c6
-rw-r--r--drivers/net/via-velocity.h4
-rw-r--r--drivers/net/wan/Kconfig2
-rw-r--r--drivers/net/wan/cycx_drv.c24
-rw-r--r--drivers/net/wan/farsync.c4
-rw-r--r--drivers/net/wan/hdlc_cisco.c5
-rw-r--r--drivers/net/wan/hdlc_ppp.c3
-rw-r--r--drivers/net/wan/hdlc_raw.c3
-rw-r--r--drivers/net/wan/sdla_fr.c7
-rw-r--r--drivers/net/wan/sdla_ft1.c3
-rw-r--r--drivers/net/wan/sdla_ppp.c3
-rw-r--r--drivers/net/wan/sdla_x25.c3
-rw-r--r--drivers/net/wan/wanpipe_multppp.c9
-rw-r--r--drivers/net/wan/wanxl.c5
-rw-r--r--drivers/net/wan/x25_asy.c2
-rw-r--r--drivers/net/wd.c18
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/airo.c20
-rw-r--r--drivers/net/wireless/airo_cs.c17
-rw-r--r--drivers/net/wireless/airport.c8
-rw-r--r--drivers/net/wireless/arlan-main.c26
-rw-r--r--drivers/net/wireless/atmel_cs.c39
-rw-r--r--drivers/net/wireless/netwave_cs.c14
-rw-r--r--drivers/net/wireless/orinoco.c2465
-rw-r--r--drivers/net/wireless/orinoco.h30
-rw-r--r--drivers/net/wireless/orinoco_cs.c56
-rw-r--r--drivers/net/wireless/prism54/isl_38xx.c6
-rw-r--r--drivers/net/wireless/ray_cs.c14
-rw-r--r--drivers/net/wireless/strip.c2
-rw-r--r--drivers/net/wireless/wavelan_cs.c17
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h1
-rw-r--r--drivers/net/wireless/wl3501_cs.c26
-rw-r--r--drivers/net/yellowfin.c8
219 files changed, 13700 insertions, 10466 deletions
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index 29dfd47f41d2..5c5eebdb6914 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -171,12 +171,7 @@ struct net_device * __init el2_probe(int unit)
171 err = do_el2_probe(dev); 171 err = do_el2_probe(dev);
172 if (err) 172 if (err)
173 goto out; 173 goto out;
174 err = register_netdev(dev);
175 if (err)
176 goto out1;
177 return dev; 174 return dev;
178out1:
179 cleanup_card(dev);
180out: 175out:
181 free_netdev(dev); 176 free_netdev(dev);
182 return ERR_PTR(err); 177 return ERR_PTR(err);
@@ -356,6 +351,10 @@ el2_probe1(struct net_device *dev, int ioaddr)
356 dev->poll_controller = ei_poll; 351 dev->poll_controller = ei_poll;
357#endif 352#endif
358 353
354 retval = register_netdev(dev);
355 if (retval)
356 goto out1;
357
359 if (dev->mem_start) 358 if (dev->mem_start)
360 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n", 359 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
361 dev->name, ei_status.name, (wordlength+1)<<3, 360 dev->name, ei_status.name, (wordlength+1)<<3,
@@ -715,11 +714,8 @@ init_module(void)
715 dev->base_addr = io[this_dev]; 714 dev->base_addr = io[this_dev];
716 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */ 715 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
717 if (do_el2_probe(dev) == 0) { 716 if (do_el2_probe(dev) == 0) {
718 if (register_netdev(dev) == 0) { 717 dev_el2[found++] = dev;
719 dev_el2[found++] = dev; 718 continue;
720 continue;
721 }
722 cleanup_card(dev);
723 } 719 }
724 free_netdev(dev); 720 free_netdev(dev);
725 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]); 721 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 76fa8cc24085..111601ca4ca3 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -272,7 +272,7 @@ static inline void set_hsf(struct net_device *dev, int hsf)
272 272
273static int start_receive(struct net_device *, pcb_struct *); 273static int start_receive(struct net_device *, pcb_struct *);
274 274
275inline static void adapter_reset(struct net_device *dev) 275static inline void adapter_reset(struct net_device *dev)
276{ 276{
277 unsigned long timeout; 277 unsigned long timeout;
278 elp_device *adapter = dev->priv; 278 elp_device *adapter = dev->priv;
@@ -1317,8 +1317,7 @@ static int __init elp_sense(struct net_device *dev)
1317 if (orig_HSR & DIR) { 1317 if (orig_HSR & DIR) {
1318 /* If HCR.DIR is up, we pull it down. HSR.DIR should follow. */ 1318 /* If HCR.DIR is up, we pull it down. HSR.DIR should follow. */
1319 outb(0, dev->base_addr + PORT_CONTROL); 1319 outb(0, dev->base_addr + PORT_CONTROL);
1320 set_current_state(TASK_UNINTERRUPTIBLE); 1320 msleep(300);
1321 schedule_timeout(30*HZ/100);
1322 if (inb_status(addr) & DIR) { 1321 if (inb_status(addr) & DIR) {
1323 if (elp_debug > 0) 1322 if (elp_debug > 0)
1324 printk(notfound_msg, 2); 1323 printk(notfound_msg, 2);
@@ -1327,8 +1326,7 @@ static int __init elp_sense(struct net_device *dev)
1327 } else { 1326 } else {
1328 /* If HCR.DIR is down, we pull it up. HSR.DIR should follow. */ 1327 /* If HCR.DIR is down, we pull it up. HSR.DIR should follow. */
1329 outb(DIR, dev->base_addr + PORT_CONTROL); 1328 outb(DIR, dev->base_addr + PORT_CONTROL);
1330 set_current_state(TASK_UNINTERRUPTIBLE); 1329 msleep(300);
1331 schedule_timeout(30*HZ/100);
1332 if (!(inb_status(addr) & DIR)) { 1330 if (!(inb_status(addr) & DIR)) {
1333 if (elp_debug > 0) 1331 if (elp_debug > 0)
1334 printk(notfound_msg, 3); 1332 printk(notfound_msg, 3);
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index e843109d4f62..977935a3d898 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -217,6 +217,7 @@ static void el3_poll_controller(struct net_device *dev);
217static struct eisa_device_id el3_eisa_ids[] = { 217static struct eisa_device_id el3_eisa_ids[] = {
218 { "TCM5092" }, 218 { "TCM5092" },
219 { "TCM5093" }, 219 { "TCM5093" },
220 { "TCM5095" },
220 { "" } 221 { "" }
221}; 222};
222 223
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index c4cf4fcd1344..91d1c4c24d9b 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -365,7 +365,7 @@ static int nopnp;
365#endif /* __ISAPNP__ */ 365#endif /* __ISAPNP__ */
366 366
367static struct net_device *corkscrew_scan(int unit); 367static struct net_device *corkscrew_scan(int unit);
368static void corkscrew_setup(struct net_device *dev, int ioaddr, 368static int corkscrew_setup(struct net_device *dev, int ioaddr,
369 struct pnp_dev *idev, int card_number); 369 struct pnp_dev *idev, int card_number);
370static int corkscrew_open(struct net_device *dev); 370static int corkscrew_open(struct net_device *dev);
371static void corkscrew_timer(unsigned long arg); 371static void corkscrew_timer(unsigned long arg);
@@ -539,10 +539,9 @@ static struct net_device *corkscrew_scan(int unit)
539 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n", 539 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n",
540 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000)); 540 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
541 /* irq = inw(ioaddr + 0x2002) & 15; */ /* Use the irq from isapnp */ 541 /* irq = inw(ioaddr + 0x2002) & 15; */ /* Use the irq from isapnp */
542 corkscrew_setup(dev, ioaddr, idev, cards_found++);
543 SET_NETDEV_DEV(dev, &idev->dev); 542 SET_NETDEV_DEV(dev, &idev->dev);
544 pnp_cards++; 543 pnp_cards++;
545 err = register_netdev(dev); 544 err = corkscrew_setup(dev, ioaddr, idev, cards_found++);
546 if (!err) 545 if (!err)
547 return dev; 546 return dev;
548 cleanup_card(dev); 547 cleanup_card(dev);
@@ -558,8 +557,7 @@ no_pnp:
558 557
559 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n", 558 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n",
560 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000)); 559 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
561 corkscrew_setup(dev, ioaddr, NULL, cards_found++); 560 err = corkscrew_setup(dev, ioaddr, NULL, cards_found++);
562 err = register_netdev(dev);
563 if (!err) 561 if (!err)
564 return dev; 562 return dev;
565 cleanup_card(dev); 563 cleanup_card(dev);
@@ -568,7 +566,7 @@ no_pnp:
568 return NULL; 566 return NULL;
569} 567}
570 568
571static void corkscrew_setup(struct net_device *dev, int ioaddr, 569static int corkscrew_setup(struct net_device *dev, int ioaddr,
572 struct pnp_dev *idev, int card_number) 570 struct pnp_dev *idev, int card_number)
573{ 571{
574 struct corkscrew_private *vp = netdev_priv(dev); 572 struct corkscrew_private *vp = netdev_priv(dev);
@@ -691,6 +689,8 @@ static void corkscrew_setup(struct net_device *dev, int ioaddr,
691 dev->get_stats = &corkscrew_get_stats; 689 dev->get_stats = &corkscrew_get_stats;
692 dev->set_multicast_list = &set_rx_mode; 690 dev->set_multicast_list = &set_rx_mode;
693 dev->ethtool_ops = &netdev_ethtool_ops; 691 dev->ethtool_ops = &netdev_ethtool_ops;
692
693 return register_netdev(dev);
694} 694}
695 695
696 696
@@ -822,7 +822,7 @@ static int corkscrew_open(struct net_device *dev)
822 break; /* Bad news! */ 822 break; /* Bad news! */
823 skb->dev = dev; /* Mark as being used by this device. */ 823 skb->dev = dev; /* Mark as being used by this device. */
824 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 824 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
825 vp->rx_ring[i].addr = isa_virt_to_bus(skb->tail); 825 vp->rx_ring[i].addr = isa_virt_to_bus(skb->data);
826 } 826 }
827 vp->rx_ring[i - 1].next = isa_virt_to_bus(&vp->rx_ring[0]); /* Wrap the ring. */ 827 vp->rx_ring[i - 1].next = isa_virt_to_bus(&vp->rx_ring[0]); /* Wrap the ring. */
828 outl(isa_virt_to_bus(&vp->rx_ring[0]), ioaddr + UpListPtr); 828 outl(isa_virt_to_bus(&vp->rx_ring[0]), ioaddr + UpListPtr);
@@ -1406,7 +1406,7 @@ static int boomerang_rx(struct net_device *dev)
1406 break; /* Bad news! */ 1406 break; /* Bad news! */
1407 skb->dev = dev; /* Mark as being used by this device. */ 1407 skb->dev = dev; /* Mark as being used by this device. */
1408 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1408 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1409 vp->rx_ring[entry].addr = isa_virt_to_bus(skb->tail); 1409 vp->rx_ring[entry].addr = isa_virt_to_bus(skb->data);
1410 vp->rx_skbuff[entry] = skb; 1410 vp->rx_skbuff[entry] = skb;
1411 } 1411 }
1412 vp->rx_ring[entry].status = 0; /* Clear complete bit. */ 1412 vp->rx_ring[entry].status = 0; /* Clear complete bit. */
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index 8f6b2fa13e28..9e1fe2e0478c 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -572,6 +572,10 @@ static int __init do_elmc_probe(struct net_device *dev)
572 dev->flags&=~IFF_MULTICAST; /* Multicast doesn't work */ 572 dev->flags&=~IFF_MULTICAST; /* Multicast doesn't work */
573#endif 573#endif
574 574
575 retval = register_netdev(dev);
576 if (retval)
577 goto err_out;
578
575 return 0; 579 return 0;
576err_out: 580err_out:
577 mca_set_adapter_procfn(slot, NULL, NULL); 581 mca_set_adapter_procfn(slot, NULL, NULL);
@@ -600,12 +604,7 @@ struct net_device * __init elmc_probe(int unit)
600 err = do_elmc_probe(dev); 604 err = do_elmc_probe(dev);
601 if (err) 605 if (err)
602 goto out; 606 goto out;
603 err = register_netdev(dev);
604 if (err)
605 goto out1;
606 return dev; 607 return dev;
607out1:
608 cleanup_card(dev);
609out: 608out:
610 free_netdev(dev); 609 free_netdev(dev);
611 return ERR_PTR(err); 610 return ERR_PTR(err);
@@ -1275,6 +1274,7 @@ module_param_array(irq, int, NULL, 0);
1275module_param_array(io, int, NULL, 0); 1274module_param_array(io, int, NULL, 0);
1276MODULE_PARM_DESC(io, "EtherLink/MC I/O base address(es)"); 1275MODULE_PARM_DESC(io, "EtherLink/MC I/O base address(es)");
1277MODULE_PARM_DESC(irq, "EtherLink/MC IRQ number(s)"); 1276MODULE_PARM_DESC(irq, "EtherLink/MC IRQ number(s)");
1277MODULE_LICENSE("GPL");
1278 1278
1279int init_module(void) 1279int init_module(void)
1280{ 1280{
@@ -1288,12 +1288,9 @@ int init_module(void)
1288 dev->irq=irq[this_dev]; 1288 dev->irq=irq[this_dev];
1289 dev->base_addr=io[this_dev]; 1289 dev->base_addr=io[this_dev];
1290 if (do_elmc_probe(dev) == 0) { 1290 if (do_elmc_probe(dev) == 0) {
1291 if (register_netdev(dev) == 0) { 1291 dev_elmc[this_dev] = dev;
1292 dev_elmc[this_dev] = dev; 1292 found++;
1293 found++; 1293 continue;
1294 continue;
1295 }
1296 cleanup_card(dev);
1297 } 1294 }
1298 free_netdev(dev); 1295 free_netdev(dev);
1299 if (io[this_dev]==0) 1296 if (io[this_dev]==0)
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 80ec9aa575bb..07746b95fd83 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1802,7 +1802,7 @@ vortex_open(struct net_device *dev)
1802 break; /* Bad news! */ 1802 break; /* Bad news! */
1803 skb->dev = dev; /* Mark as being used by this device. */ 1803 skb->dev = dev; /* Mark as being used by this device. */
1804 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1804 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1805 vp->rx_ring[i].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->tail, PKT_BUF_SZ, PCI_DMA_FROMDEVICE)); 1805 vp->rx_ring[i].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE));
1806 } 1806 }
1807 if (i != RX_RING_SIZE) { 1807 if (i != RX_RING_SIZE) {
1808 int j; 1808 int j;
@@ -2632,7 +2632,7 @@ boomerang_rx(struct net_device *dev)
2632 pci_dma_sync_single_for_cpu(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 2632 pci_dma_sync_single_for_cpu(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
2633 /* 'skb_put()' points to the start of sk_buff data area. */ 2633 /* 'skb_put()' points to the start of sk_buff data area. */
2634 memcpy(skb_put(skb, pkt_len), 2634 memcpy(skb_put(skb, pkt_len),
2635 vp->rx_skbuff[entry]->tail, 2635 vp->rx_skbuff[entry]->data,
2636 pkt_len); 2636 pkt_len);
2637 pci_dma_sync_single_for_device(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 2637 pci_dma_sync_single_for_device(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
2638 vp->rx_copy++; 2638 vp->rx_copy++;
@@ -2678,7 +2678,7 @@ boomerang_rx(struct net_device *dev)
2678 } 2678 }
2679 skb->dev = dev; /* Mark as being used by this device. */ 2679 skb->dev = dev; /* Mark as being used by this device. */
2680 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 2680 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
2681 vp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->tail, PKT_BUF_SZ, PCI_DMA_FROMDEVICE)); 2681 vp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE));
2682 vp->rx_skbuff[entry] = skb; 2682 vp->rx_skbuff[entry] = skb;
2683 } 2683 }
2684 vp->rx_ring[entry].status = 0; /* Clear complete bit. */ 2684 vp->rx_ring[entry].status = 0; /* Clear complete bit. */
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 72cdf19e1be1..34b80de34fae 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -61,6 +61,7 @@
61#include <linux/etherdevice.h> 61#include <linux/etherdevice.h>
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/pci.h> 63#include <linux/pci.h>
64#include <linux/dma-mapping.h>
64#include <linux/delay.h> 65#include <linux/delay.h>
65#include <linux/ethtool.h> 66#include <linux/ethtool.h>
66#include <linux/mii.h> 67#include <linux/mii.h>
@@ -595,7 +596,7 @@ rx_status_loop:
595 596
596 mapping = 597 mapping =
597 cp->rx_skb[rx_tail].mapping = 598 cp->rx_skb[rx_tail].mapping =
598 pci_map_single(cp->pdev, new_skb->tail, 599 pci_map_single(cp->pdev, new_skb->data,
599 buflen, PCI_DMA_FROMDEVICE); 600 buflen, PCI_DMA_FROMDEVICE);
600 cp->rx_skb[rx_tail].skb = new_skb; 601 cp->rx_skb[rx_tail].skb = new_skb;
601 602
@@ -1100,7 +1101,7 @@ static int cp_refill_rx (struct cp_private *cp)
1100 skb_reserve(skb, RX_OFFSET); 1101 skb_reserve(skb, RX_OFFSET);
1101 1102
1102 cp->rx_skb[i].mapping = pci_map_single(cp->pdev, 1103 cp->rx_skb[i].mapping = pci_map_single(cp->pdev,
1103 skb->tail, cp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1104 skb->data, cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1104 cp->rx_skb[i].skb = skb; 1105 cp->rx_skb[i].skb = skb;
1105 1106
1106 cp->rx_ring[i].opts2 = 0; 1107 cp->rx_ring[i].opts2 = 0;
@@ -1515,22 +1516,22 @@ static void cp_get_ethtool_stats (struct net_device *dev,
1515 struct ethtool_stats *estats, u64 *tmp_stats) 1516 struct ethtool_stats *estats, u64 *tmp_stats)
1516{ 1517{
1517 struct cp_private *cp = netdev_priv(dev); 1518 struct cp_private *cp = netdev_priv(dev);
1518 unsigned int work = 100;
1519 int i; 1519 int i;
1520 1520
1521 memset(cp->nic_stats, 0, sizeof(struct cp_dma_stats));
1522
1521 /* begin NIC statistics dump */ 1523 /* begin NIC statistics dump */
1522 cpw32(StatsAddr + 4, (cp->nic_stats_dma >> 16) >> 16); 1524 cpw32(StatsAddr + 4, (cp->nic_stats_dma >> 16) >> 16);
1523 cpw32(StatsAddr, (cp->nic_stats_dma & 0xffffffff) | DumpStats); 1525 cpw32(StatsAddr, (cp->nic_stats_dma & 0xffffffff) | DumpStats);
1524 cpr32(StatsAddr); 1526 cpr32(StatsAddr);
1525 1527
1526 while (work-- > 0) { 1528 for (i = 0; i < 1000; i++) {
1527 if ((cpr32(StatsAddr) & DumpStats) == 0) 1529 if ((cpr32(StatsAddr) & DumpStats) == 0)
1528 break; 1530 break;
1529 cpu_relax(); 1531 udelay(10);
1530 } 1532 }
1531 1533 cpw32(StatsAddr, 0);
1532 if (cpr32(StatsAddr) & DumpStats) 1534 cpw32(StatsAddr + 4, 0);
1533 return /* -EIO */;
1534 1535
1535 i = 0; 1536 i = 0;
1536 tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok); 1537 tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
@@ -1732,19 +1733,19 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1732 1733
1733 /* Configure DMA attributes. */ 1734 /* Configure DMA attributes. */
1734 if ((sizeof(dma_addr_t) > 4) && 1735 if ((sizeof(dma_addr_t) > 4) &&
1735 !pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL) && 1736 !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) &&
1736 !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) { 1737 !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
1737 pci_using_dac = 1; 1738 pci_using_dac = 1;
1738 } else { 1739 } else {
1739 pci_using_dac = 0; 1740 pci_using_dac = 0;
1740 1741
1741 rc = pci_set_dma_mask(pdev, 0xffffffffULL); 1742 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
1742 if (rc) { 1743 if (rc) {
1743 printk(KERN_ERR PFX "No usable DMA configuration, " 1744 printk(KERN_ERR PFX "No usable DMA configuration, "
1744 "aborting.\n"); 1745 "aborting.\n");
1745 goto err_out_res; 1746 goto err_out_res;
1746 } 1747 }
1747 rc = pci_set_consistent_dma_mask(pdev, 0xffffffffULL); 1748 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
1748 if (rc) { 1749 if (rc) {
1749 printk(KERN_ERR PFX "No usable consistent DMA configuration, " 1750 printk(KERN_ERR PFX "No usable consistent DMA configuration, "
1750 "aborting.\n"); 1751 "aborting.\n");
@@ -1896,6 +1897,7 @@ static int cp_resume (struct pci_dev *pdev)
1896{ 1897{
1897 struct net_device *dev; 1898 struct net_device *dev;
1898 struct cp_private *cp; 1899 struct cp_private *cp;
1900 unsigned long flags;
1899 1901
1900 dev = pci_get_drvdata (pdev); 1902 dev = pci_get_drvdata (pdev);
1901 cp = netdev_priv(dev); 1903 cp = netdev_priv(dev);
@@ -1909,6 +1911,12 @@ static int cp_resume (struct pci_dev *pdev)
1909 1911
1910 cp_init_hw (cp); 1912 cp_init_hw (cp);
1911 netif_start_queue (dev); 1913 netif_start_queue (dev);
1914
1915 spin_lock_irqsave (&cp->lock, flags);
1916
1917 mii_check_media(&cp->mii_if, netif_msg_link(cp), FALSE);
1918
1919 spin_unlock_irqrestore (&cp->lock, flags);
1912 1920
1913 return 0; 1921 return 0;
1914} 1922}
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 047202c4d9a8..4c2cf7bbd252 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -126,14 +126,14 @@
126#define USE_IO_OPS 1 126#define USE_IO_OPS 1
127#endif 127#endif
128 128
129/* define to 1 to enable copious debugging info */ 129/* define to 1, 2 or 3 to enable copious debugging info */
130#undef RTL8139_DEBUG 130#define RTL8139_DEBUG 0
131 131
132/* define to 1 to disable lightweight runtime debugging checks */ 132/* define to 1 to disable lightweight runtime debugging checks */
133#undef RTL8139_NDEBUG 133#undef RTL8139_NDEBUG
134 134
135 135
136#ifdef RTL8139_DEBUG 136#if RTL8139_DEBUG
137/* note: prints function name for you */ 137/* note: prints function name for you */
138# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) 138# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
139#else 139#else
@@ -1606,7 +1606,7 @@ static int rtl8139_thread (void *data)
1606 do { 1606 do {
1607 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout); 1607 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
1608 /* make swsusp happy with our thread */ 1608 /* make swsusp happy with our thread */
1609 try_to_freeze(PF_FREEZE); 1609 try_to_freeze();
1610 } while (!signal_pending (current) && (timeout > 0)); 1610 } while (!signal_pending (current) && (timeout > 0));
1611 1611
1612 if (signal_pending (current)) { 1612 if (signal_pending (current)) {
diff --git a/drivers/net/82596.c b/drivers/net/82596.c
index 65f97b1dc581..13b745b39667 100644
--- a/drivers/net/82596.c
+++ b/drivers/net/82596.c
@@ -546,11 +546,11 @@ static inline void init_rx_bufs(struct net_device *dev)
546 rbd->b_next = WSWAPrbd(virt_to_bus(rbd+1)); 546 rbd->b_next = WSWAPrbd(virt_to_bus(rbd+1));
547 rbd->b_addr = WSWAPrbd(virt_to_bus(rbd)); 547 rbd->b_addr = WSWAPrbd(virt_to_bus(rbd));
548 rbd->skb = skb; 548 rbd->skb = skb;
549 rbd->v_data = skb->tail; 549 rbd->v_data = skb->data;
550 rbd->b_data = WSWAPchar(virt_to_bus(skb->tail)); 550 rbd->b_data = WSWAPchar(virt_to_bus(skb->data));
551 rbd->size = PKT_BUF_SZ; 551 rbd->size = PKT_BUF_SZ;
552#ifdef __mc68000__ 552#ifdef __mc68000__
553 cache_clear(virt_to_phys(skb->tail), PKT_BUF_SZ); 553 cache_clear(virt_to_phys(skb->data), PKT_BUF_SZ);
554#endif 554#endif
555 } 555 }
556 lp->rbd_head = lp->rbds; 556 lp->rbd_head = lp->rbds;
@@ -816,10 +816,10 @@ static inline int i596_rx(struct net_device *dev)
816 rx_in_place = 1; 816 rx_in_place = 1;
817 rbd->skb = newskb; 817 rbd->skb = newskb;
818 newskb->dev = dev; 818 newskb->dev = dev;
819 rbd->v_data = newskb->tail; 819 rbd->v_data = newskb->data;
820 rbd->b_data = WSWAPchar(virt_to_bus(newskb->tail)); 820 rbd->b_data = WSWAPchar(virt_to_bus(newskb->data));
821#ifdef __mc68000__ 821#ifdef __mc68000__
822 cache_clear(virt_to_phys(newskb->tail), PKT_BUF_SZ); 822 cache_clear(virt_to_phys(newskb->data), PKT_BUF_SZ);
823#endif 823#endif
824 } 824 }
825 else 825 else
@@ -840,7 +840,7 @@ memory_squeeze:
840 skb->protocol=eth_type_trans(skb,dev); 840 skb->protocol=eth_type_trans(skb,dev);
841 skb->len = pkt_len; 841 skb->len = pkt_len;
842#ifdef __mc68000__ 842#ifdef __mc68000__
843 cache_clear(virt_to_phys(rbd->skb->tail), 843 cache_clear(virt_to_phys(rbd->skb->data),
844 pkt_len); 844 pkt_len);
845#endif 845#endif
846 netif_rx(skb); 846 netif_rx(skb);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 0313af45c1ec..a6a441b969fd 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -3,6 +3,8 @@
3# Network device configuration 3# Network device configuration
4# 4#
5 5
6menu "Network device support"
7
6config NETDEVICES 8config NETDEVICES
7 depends on NET 9 depends on NET
8 bool "Network device support" 10 bool "Network device support"
@@ -21,9 +23,12 @@ config NETDEVICES
21 23
22 If unsure, say Y. 24 If unsure, say Y.
23 25
26# All the following symbols are dependent on NETDEVICES - do not repeat
27# that for each of the symbols.
28if NETDEVICES
29
24config DUMMY 30config DUMMY
25 tristate "Dummy net driver support" 31 tristate "Dummy net driver support"
26 depends on NETDEVICES
27 ---help--- 32 ---help---
28 This is essentially a bit-bucket device (i.e. traffic you send to 33 This is essentially a bit-bucket device (i.e. traffic you send to
29 this device is consigned into oblivion) with a configurable IP 34 this device is consigned into oblivion) with a configurable IP
@@ -43,7 +48,6 @@ config DUMMY
43 48
44config BONDING 49config BONDING
45 tristate "Bonding driver support" 50 tristate "Bonding driver support"
46 depends on NETDEVICES
47 depends on INET 51 depends on INET
48 ---help--- 52 ---help---
49 Say 'Y' or 'M' if you wish to be able to 'bond' multiple Ethernet 53 Say 'Y' or 'M' if you wish to be able to 'bond' multiple Ethernet
@@ -61,7 +65,6 @@ config BONDING
61 65
62config EQUALIZER 66config EQUALIZER
63 tristate "EQL (serial line load balancing) support" 67 tristate "EQL (serial line load balancing) support"
64 depends on NETDEVICES
65 ---help--- 68 ---help---
66 If you have two serial connections to some other computer (this 69 If you have two serial connections to some other computer (this
67 usually requires two modems and two telephone lines) and you use 70 usually requires two modems and two telephone lines) and you use
@@ -81,7 +84,6 @@ config EQUALIZER
81 84
82config TUN 85config TUN
83 tristate "Universal TUN/TAP device driver support" 86 tristate "Universal TUN/TAP device driver support"
84 depends on NETDEVICES
85 select CRC32 87 select CRC32
86 ---help--- 88 ---help---
87 TUN/TAP provides packet reception and transmission for user space 89 TUN/TAP provides packet reception and transmission for user space
@@ -105,7 +107,7 @@ config TUN
105 107
106config NET_SB1000 108config NET_SB1000
107 tristate "General Instruments Surfboard 1000" 109 tristate "General Instruments Surfboard 1000"
108 depends on NETDEVICES && PNP 110 depends on PNP
109 ---help--- 111 ---help---
110 This is a driver for the General Instrument (also known as 112 This is a driver for the General Instrument (also known as
111 NextLevel) SURFboard 1000 internal 113 NextLevel) SURFboard 1000 internal
@@ -127,16 +129,16 @@ config NET_SB1000
127 129
128 If you don't have this card, of course say N. 130 If you don't have this card, of course say N.
129 131
130if NETDEVICES
131 source "drivers/net/arcnet/Kconfig" 132 source "drivers/net/arcnet/Kconfig"
132endif 133
134source "drivers/net/phy/Kconfig"
133 135
134# 136#
135# Ethernet 137# Ethernet
136# 138#
137 139
138menu "Ethernet (10 or 100Mbit)" 140menu "Ethernet (10 or 100Mbit)"
139 depends on NETDEVICES && !UML 141 depends on !UML
140 142
141config NET_ETHERNET 143config NET_ETHERNET
142 bool "Ethernet (10 or 100Mbit)" 144 bool "Ethernet (10 or 100Mbit)"
@@ -1135,7 +1137,7 @@ config IBMLANA
1135 1137
1136config IBMVETH 1138config IBMVETH
1137 tristate "IBM LAN Virtual Ethernet support" 1139 tristate "IBM LAN Virtual Ethernet support"
1138 depends on NETDEVICES && NET_ETHERNET && PPC_PSERIES 1140 depends on NET_ETHERNET && PPC_PSERIES
1139 ---help--- 1141 ---help---
1140 This driver supports virtual ethernet adapters on newer IBM iSeries 1142 This driver supports virtual ethernet adapters on newer IBM iSeries
1141 and pSeries systems. 1143 and pSeries systems.
@@ -1145,7 +1147,7 @@ config IBMVETH
1145 be called ibmveth. 1147 be called ibmveth.
1146 1148
1147config IBM_EMAC 1149config IBM_EMAC
1148 tristate "IBM PPC4xx EMAC driver support" 1150 bool "IBM PPC4xx EMAC driver support"
1149 depends on 4xx 1151 depends on 4xx
1150 select CRC32 1152 select CRC32
1151 ---help--- 1153 ---help---
@@ -1154,7 +1156,7 @@ config IBM_EMAC
1154 1156
1155config IBM_EMAC_ERRMSG 1157config IBM_EMAC_ERRMSG
1156 bool "Verbose error messages" 1158 bool "Verbose error messages"
1157 depends on IBM_EMAC 1159 depends on IBM_EMAC && BROKEN
1158 1160
1159config IBM_EMAC_RXB 1161config IBM_EMAC_RXB
1160 int "Number of receive buffers" 1162 int "Number of receive buffers"
@@ -1320,7 +1322,7 @@ config FORCEDETH
1320 1322
1321config CS89x0 1323config CS89x0
1322 tristate "CS89x0 support" 1324 tristate "CS89x0 support"
1323 depends on NET_PCI && (ISA || ARCH_IXDP2X01) 1325 depends on (NET_PCI && (ISA || ARCH_IXDP2X01)) || ARCH_PNX0105
1324 ---help--- 1326 ---help---
1325 Support for CS89x0 chipset based Ethernet cards. If you have a 1327 Support for CS89x0 chipset based Ethernet cards. If you have a
1326 network (Ethernet) card of this type, say Y and read the 1328 network (Ethernet) card of this type, say Y and read the
@@ -1488,14 +1490,14 @@ config 8139CP
1488 will be called 8139cp. This is recommended. 1490 will be called 8139cp. This is recommended.
1489 1491
1490config 8139TOO 1492config 8139TOO
1491 tristate "RealTek RTL-8139 PCI Fast Ethernet Adapter support" 1493 tristate "RealTek RTL-8129/8130/8139 PCI Fast Ethernet Adapter support"
1492 depends on NET_PCI && PCI 1494 depends on NET_PCI && PCI
1493 select CRC32 1495 select CRC32
1494 select MII 1496 select MII
1495 ---help--- 1497 ---help---
1496 This is a driver for the Fast Ethernet PCI network cards based on 1498 This is a driver for the Fast Ethernet PCI network cards based on
1497 the RTL8139 chips. If you have one of those, say Y and read 1499 the RTL 8129/8130/8139 chips. If you have one of those, say Y and
1498 the Ethernet-HOWTO <http://www.tldp.org/docs.html#howto>. 1500 read the Ethernet-HOWTO <http://www.tldp.org/docs.html#howto>.
1499 1501
1500 To compile this driver as a module, choose M here: the module 1502 To compile this driver as a module, choose M here: the module
1501 will be called 8139too. This is recommended. 1503 will be called 8139too. This is recommended.
@@ -1758,7 +1760,7 @@ endmenu
1758# 1760#
1759 1761
1760menu "Ethernet (1000 Mbit)" 1762menu "Ethernet (1000 Mbit)"
1761 depends on NETDEVICES && !UML 1763 depends on !UML
1762 1764
1763config ACENIC 1765config ACENIC
1764 tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" 1766 tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
@@ -2089,7 +2091,7 @@ endmenu
2089# 2091#
2090 2092
2091menu "Ethernet (10000 Mbit)" 2093menu "Ethernet (10000 Mbit)"
2092 depends on NETDEVICES && !UML 2094 depends on !UML
2093 2095
2094config CHELSIO_T1 2096config CHELSIO_T1
2095 tristate "Chelsio 10Gb Ethernet support" 2097 tristate "Chelsio 10Gb Ethernet support"
@@ -2203,11 +2205,11 @@ source "drivers/s390/net/Kconfig"
2203 2205
2204config ISERIES_VETH 2206config ISERIES_VETH
2205 tristate "iSeries Virtual Ethernet driver support" 2207 tristate "iSeries Virtual Ethernet driver support"
2206 depends on NETDEVICES && PPC_ISERIES 2208 depends on PPC_ISERIES
2207 2209
2208config FDDI 2210config FDDI
2209 bool "FDDI driver support" 2211 bool "FDDI driver support"
2210 depends on NETDEVICES && (PCI || EISA) 2212 depends on (PCI || EISA)
2211 help 2213 help
2212 Fiber Distributed Data Interface is a high speed local area network 2214 Fiber Distributed Data Interface is a high speed local area network
2213 design; essentially a replacement for high speed Ethernet. FDDI can 2215 design; essentially a replacement for high speed Ethernet. FDDI can
@@ -2256,7 +2258,7 @@ config SKFP
2256 2258
2257config HIPPI 2259config HIPPI
2258 bool "HIPPI driver support (EXPERIMENTAL)" 2260 bool "HIPPI driver support (EXPERIMENTAL)"
2259 depends on NETDEVICES && EXPERIMENTAL && INET && PCI 2261 depends on EXPERIMENTAL && INET && PCI
2260 help 2262 help
2261 HIgh Performance Parallel Interface (HIPPI) is a 800Mbit/sec and 2263 HIgh Performance Parallel Interface (HIPPI) is a 800Mbit/sec and
2262 1600Mbit/sec dual-simplex switched or point-to-point network. HIPPI 2264 1600Mbit/sec dual-simplex switched or point-to-point network. HIPPI
@@ -2288,7 +2290,7 @@ config ROADRUNNER_LARGE_RINGS
2288 2290
2289config PLIP 2291config PLIP
2290 tristate "PLIP (parallel port) support" 2292 tristate "PLIP (parallel port) support"
2291 depends on NETDEVICES && PARPORT 2293 depends on PARPORT
2292 ---help--- 2294 ---help---
2293 PLIP (Parallel Line Internet Protocol) is used to create a 2295 PLIP (Parallel Line Internet Protocol) is used to create a
2294 reasonably fast mini network consisting of two (or, rarely, more) 2296 reasonably fast mini network consisting of two (or, rarely, more)
@@ -2324,7 +2326,6 @@ config PLIP
2324 2326
2325config PPP 2327config PPP
2326 tristate "PPP (point-to-point protocol) support" 2328 tristate "PPP (point-to-point protocol) support"
2327 depends on NETDEVICES
2328 ---help--- 2329 ---help---
2329 PPP (Point to Point Protocol) is a newer and better SLIP. It serves 2330 PPP (Point to Point Protocol) is a newer and better SLIP. It serves
2330 the same purpose: sending Internet traffic over telephone (and other 2331 the same purpose: sending Internet traffic over telephone (and other
@@ -2460,7 +2461,6 @@ config PPPOATM
2460 2461
2461config SLIP 2462config SLIP
2462 tristate "SLIP (serial line) support" 2463 tristate "SLIP (serial line) support"
2463 depends on NETDEVICES
2464 ---help--- 2464 ---help---
2465 Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to 2465 Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to
2466 connect to your Internet service provider or to connect to some 2466 connect to your Internet service provider or to connect to some
@@ -2527,7 +2527,7 @@ config SLIP_MODE_SLIP6
2527 2527
2528config NET_FC 2528config NET_FC
2529 bool "Fibre Channel driver support" 2529 bool "Fibre Channel driver support"
2530 depends on NETDEVICES && SCSI && PCI 2530 depends on SCSI && PCI
2531 help 2531 help
2532 Fibre Channel is a high speed serial protocol mainly used to connect 2532 Fibre Channel is a high speed serial protocol mainly used to connect
2533 large storage devices to the computer; it is compatible with and 2533 large storage devices to the computer; it is compatible with and
@@ -2540,7 +2540,7 @@ config NET_FC
2540 2540
2541config SHAPER 2541config SHAPER
2542 tristate "Traffic Shaper (EXPERIMENTAL)" 2542 tristate "Traffic Shaper (EXPERIMENTAL)"
2543 depends on NETDEVICES && EXPERIMENTAL 2543 depends on EXPERIMENTAL
2544 ---help--- 2544 ---help---
2545 The traffic shaper is a virtual network device that allows you to 2545 The traffic shaper is a virtual network device that allows you to
2546 limit the rate of outgoing data flow over some other network device. 2546 limit the rate of outgoing data flow over some other network device.
@@ -2561,8 +2561,27 @@ config SHAPER
2561 2561
2562config NETCONSOLE 2562config NETCONSOLE
2563 tristate "Network console logging support (EXPERIMENTAL)" 2563 tristate "Network console logging support (EXPERIMENTAL)"
2564 depends on NETDEVICES && EXPERIMENTAL 2564 depends on EXPERIMENTAL
2565 ---help--- 2565 ---help---
2566 If you want to log kernel messages over the network, enable this. 2566 If you want to log kernel messages over the network, enable this.
2567 See <file:Documentation/networking/netconsole.txt> for details. 2567 See <file:Documentation/networking/netconsole.txt> for details.
2568 2568
2569endif #NETDEVICES
2570
2571config NETPOLL
2572 def_bool NETCONSOLE
2573
2574config NETPOLL_RX
2575 bool "Netpoll support for trapping incoming packets"
2576 default n
2577 depends on NETPOLL
2578
2579config NETPOLL_TRAP
2580 bool "Netpoll traffic trapping"
2581 default n
2582 depends on NETPOLL
2583
2584config NET_POLL_CONTROLLER
2585 def_bool NETPOLL
2586
2587endmenu
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index e871993b6694..954d26297d7c 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_ADAPTEC_STARFIRE) += starfire.o
66# 66#
67 67
68obj-$(CONFIG_MII) += mii.o 68obj-$(CONFIG_MII) += mii.o
69obj-$(CONFIG_PHYLIB) += phy/
69 70
70obj-$(CONFIG_SUNDANCE) += sundance.o 71obj-$(CONFIG_SUNDANCE) += sundance.o
71obj-$(CONFIG_HAMACHI) += hamachi.o 72obj-$(CONFIG_HAMACHI) += hamachi.o
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index 3707df6b0cfa..60304f7e7e5b 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -87,7 +87,6 @@ extern struct net_device *mvme147lance_probe(int unit);
87extern struct net_device *tc515_probe(int unit); 87extern struct net_device *tc515_probe(int unit);
88extern struct net_device *lance_probe(int unit); 88extern struct net_device *lance_probe(int unit);
89extern struct net_device *mace_probe(int unit); 89extern struct net_device *mace_probe(int unit);
90extern struct net_device *macsonic_probe(int unit);
91extern struct net_device *mac8390_probe(int unit); 90extern struct net_device *mac8390_probe(int unit);
92extern struct net_device *mac89x0_probe(int unit); 91extern struct net_device *mac89x0_probe(int unit);
93extern struct net_device *mc32_probe(int unit); 92extern struct net_device *mc32_probe(int unit);
@@ -284,9 +283,6 @@ static struct devprobe2 m68k_probes[] __initdata = {
284#ifdef CONFIG_MACMACE /* Mac 68k Quadra AV builtin Ethernet */ 283#ifdef CONFIG_MACMACE /* Mac 68k Quadra AV builtin Ethernet */
285 {mace_probe, 0}, 284 {mace_probe, 0},
286#endif 285#endif
287#ifdef CONFIG_MACSONIC /* Mac SONIC-based Ethernet of all sorts */
288 {macsonic_probe, 0},
289#endif
290#ifdef CONFIG_MAC8390 /* NuBus NS8390-based cards */ 286#ifdef CONFIG_MAC8390 /* NuBus NS8390-based cards */
291 {mac8390_probe, 0}, 287 {mac8390_probe, 0},
292#endif 288#endif
@@ -318,17 +314,9 @@ static void __init ethif_probe2(int unit)
318#ifdef CONFIG_TR 314#ifdef CONFIG_TR
319/* Token-ring device probe */ 315/* Token-ring device probe */
320extern int ibmtr_probe_card(struct net_device *); 316extern int ibmtr_probe_card(struct net_device *);
321extern struct net_device *sk_isa_probe(int unit);
322extern struct net_device *proteon_probe(int unit);
323extern struct net_device *smctr_probe(int unit); 317extern struct net_device *smctr_probe(int unit);
324 318
325static struct devprobe2 tr_probes2[] __initdata = { 319static struct devprobe2 tr_probes2[] __initdata = {
326#ifdef CONFIG_SKISA
327 {sk_isa_probe, 0},
328#endif
329#ifdef CONFIG_PROTEON
330 {proteon_probe, 0},
331#endif
332#ifdef CONFIG_SMCTR 320#ifdef CONFIG_SMCTR
333 {smctr_probe, 0}, 321 {smctr_probe, 0},
334#endif 322#endif
diff --git a/drivers/net/ac3200.c b/drivers/net/ac3200.c
index 24fba36b5c1d..91791ba37769 100644
--- a/drivers/net/ac3200.c
+++ b/drivers/net/ac3200.c
@@ -146,12 +146,7 @@ struct net_device * __init ac3200_probe(int unit)
146 err = do_ac3200_probe(dev); 146 err = do_ac3200_probe(dev);
147 if (err) 147 if (err)
148 goto out; 148 goto out;
149 err = register_netdev(dev);
150 if (err)
151 goto out1;
152 return dev; 149 return dev;
153out1:
154 cleanup_card(dev);
155out: 150out:
156 free_netdev(dev); 151 free_netdev(dev);
157 return ERR_PTR(err); 152 return ERR_PTR(err);
@@ -273,7 +268,14 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
273 dev->poll_controller = ei_poll; 268 dev->poll_controller = ei_poll;
274#endif 269#endif
275 NS8390_init(dev, 0); 270 NS8390_init(dev, 0);
271
272 retval = register_netdev(dev);
273 if (retval)
274 goto out2;
276 return 0; 275 return 0;
276out2:
277 if (ei_status.reg0)
278 iounmap((void *)dev->mem_start);
277out1: 279out1:
278 free_irq(dev->irq, dev); 280 free_irq(dev->irq, dev);
279out: 281out:
@@ -392,11 +394,8 @@ init_module(void)
392 dev->base_addr = io[this_dev]; 394 dev->base_addr = io[this_dev];
393 dev->mem_start = mem[this_dev]; /* Currently ignored by driver */ 395 dev->mem_start = mem[this_dev]; /* Currently ignored by driver */
394 if (do_ac3200_probe(dev) == 0) { 396 if (do_ac3200_probe(dev) == 0) {
395 if (register_netdev(dev) == 0) { 397 dev_ac32[found++] = dev;
396 dev_ac32[found++] = dev; 398 continue;
397 continue;
398 }
399 cleanup_card(dev);
400 } 399 }
401 free_netdev(dev); 400 free_netdev(dev);
402 printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]); 401 printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 6eea3a8accb7..dbecc6bf7851 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -58,6 +58,7 @@
58#include <linux/errno.h> 58#include <linux/errno.h>
59#include <linux/ioport.h> 59#include <linux/ioport.h>
60#include <linux/pci.h> 60#include <linux/pci.h>
61#include <linux/dma-mapping.h>
61#include <linux/kernel.h> 62#include <linux/kernel.h>
62#include <linux/netdevice.h> 63#include <linux/netdevice.h>
63#include <linux/etherdevice.h> 64#include <linux/etherdevice.h>
@@ -1167,9 +1168,9 @@ static int __devinit ace_init(struct net_device *dev)
1167 /* 1168 /*
1168 * Configure DMA attributes. 1169 * Configure DMA attributes.
1169 */ 1170 */
1170 if (!pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) { 1171 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
1171 ap->pci_using_dac = 1; 1172 ap->pci_using_dac = 1;
1172 } else if (!pci_set_dma_mask(pdev, 0xffffffffULL)) { 1173 } else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1173 ap->pci_using_dac = 0; 1174 ap->pci_using_dac = 0;
1174 } else { 1175 } else {
1175 ecode = -ENODEV; 1176 ecode = -ENODEV;
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index b7dd7260cafb..d9ba8be72af8 100755
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -87,6 +87,7 @@ Revision History:
87#include <linux/if_vlan.h> 87#include <linux/if_vlan.h>
88#include <linux/ctype.h> 88#include <linux/ctype.h>
89#include <linux/crc32.h> 89#include <linux/crc32.h>
90#include <linux/dma-mapping.h>
90 91
91#include <asm/system.h> 92#include <asm/system.h>
92#include <asm/io.h> 93#include <asm/io.h>
@@ -1289,7 +1290,7 @@ static irqreturn_t amd8111e_interrupt(int irq, void *dev_id, struct pt_regs *reg
1289 writel(intr0, mmio + INT0); 1290 writel(intr0, mmio + INT0);
1290 1291
1291 /* Check if Receive Interrupt has occurred. */ 1292 /* Check if Receive Interrupt has occurred. */
1292#if CONFIG_AMD8111E_NAPI 1293#ifdef CONFIG_AMD8111E_NAPI
1293 if(intr0 & RINT0){ 1294 if(intr0 & RINT0){
1294 if(netif_rx_schedule_prep(dev)){ 1295 if(netif_rx_schedule_prep(dev)){
1295 /* Disable receive interupts */ 1296 /* Disable receive interupts */
@@ -2006,12 +2007,11 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
2006 } 2007 }
2007 2008
2008 /* Initialize DMA */ 2009 /* Initialize DMA */
2009 if(!pci_dma_supported(pdev, 0xffffffff)){ 2010 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) < 0) {
2010 printk(KERN_ERR "amd8111e: DMA not supported," 2011 printk(KERN_ERR "amd8111e: DMA not supported,"
2011 "exiting.\n"); 2012 "exiting.\n");
2012 goto err_free_reg; 2013 goto err_free_reg;
2013 } else 2014 }
2014 pdev->dma_mask = 0xffffffff;
2015 2015
2016 reg_addr = pci_resource_start(pdev, 0); 2016 reg_addr = pci_resource_start(pdev, 0);
2017 reg_len = pci_resource_len(pdev, 0); 2017 reg_len = pci_resource_len(pdev, 0);
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 69c488d933a2..b14e89004c3a 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -1,6 +1,33 @@
1# 1#
2# Appletalk driver configuration 2# Appletalk driver configuration
3# 3#
4config ATALK
5 tristate "Appletalk protocol support"
6 select LLC
7 ---help---
8 AppleTalk is the protocol that Apple computers can use to communicate
9 on a network. If your Linux box is connected to such a network and you
10 wish to connect to it, say Y. You will need to use the netatalk package
11 so that your Linux box can act as a print and file server for Macs as
12 well as access AppleTalk printers. Check out
13 <http://www.zettabyte.net/netatalk/> on the WWW for details.
14 EtherTalk is the name used for AppleTalk over Ethernet and the
15 cheaper and slower LocalTalk is AppleTalk over a proprietary Apple
16 network using serial links. EtherTalk and LocalTalk are fully
17 supported by Linux.
18
19 General information about how to connect Linux, Windows machines and
20 Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>. The
21 NET-3-HOWTO, available from
22 <http://www.tldp.org/docs.html#howto>, contains valuable
23 information as well.
24
25 To compile this driver as a module, choose M here: the module will be
26 called appletalk. You almost certainly want to compile it as a
27 module so you can restart your AppleTalk stack without rebooting
28 your machine. I hear that the GNU boycott of Apple is over, so
29 even politically correct people are allowed to say Y here.
30
4config DEV_APPLETALK 31config DEV_APPLETALK
5 bool "Appletalk interfaces support" 32 bool "Appletalk interfaces support"
6 depends on ATALK 33 depends on ATALK
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index db4f369637b6..d5666c37cb0d 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -1109,8 +1109,7 @@ struct net_device * __init ltpc_probe(void)
1109 inb_p(io+1); 1109 inb_p(io+1);
1110 inb_p(io+3); 1110 inb_p(io+3);
1111 1111
1112 set_current_state(TASK_UNINTERRUPTIBLE); 1112 msleep(20);
1113 schedule_timeout(2*HZ/100);
1114 1113
1115 inb_p(io+0); 1114 inb_p(io+0);
1116 inb_p(io+2); 1115 inb_p(io+2);
@@ -1120,8 +1119,7 @@ struct net_device * __init ltpc_probe(void)
1120 inb_p(io+5); /* enable dma */ 1119 inb_p(io+5); /* enable dma */
1121 inb_p(io+6); /* tri-state interrupt line */ 1120 inb_p(io+6); /* tri-state interrupt line */
1122 1121
1123 set_current_state(TASK_UNINTERRUPTIBLE); 1122 ssleep(1);
1124 schedule_timeout(HZ);
1125 1123
1126 /* now, figure out which dma channel we're using, unless it's 1124 /* now, figure out which dma channel we're using, unless it's
1127 already been specified */ 1125 already been specified */
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 2e28c201dcc0..942a2819576c 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -68,7 +68,6 @@ struct etherh_priv {
68 void __iomem *dma_base; 68 void __iomem *dma_base;
69 unsigned int id; 69 unsigned int id;
70 void __iomem *ctrl_port; 70 void __iomem *ctrl_port;
71 void __iomem *base;
72 unsigned char ctrl; 71 unsigned char ctrl;
73 u32 supported; 72 u32 supported;
74}; 73};
@@ -178,7 +177,7 @@ etherh_setif(struct net_device *dev)
178 switch (etherh_priv(dev)->id) { 177 switch (etherh_priv(dev)->id) {
179 case PROD_I3_ETHERLAN600: 178 case PROD_I3_ETHERLAN600:
180 case PROD_I3_ETHERLAN600A: 179 case PROD_I3_ETHERLAN600A:
181 addr = etherh_priv(dev)->base + EN0_RCNTHI; 180 addr = (void *)dev->base_addr + EN0_RCNTHI;
182 181
183 switch (dev->if_port) { 182 switch (dev->if_port) {
184 case IF_PORT_10BASE2: 183 case IF_PORT_10BASE2:
@@ -219,7 +218,7 @@ etherh_getifstat(struct net_device *dev)
219 switch (etherh_priv(dev)->id) { 218 switch (etherh_priv(dev)->id) {
220 case PROD_I3_ETHERLAN600: 219 case PROD_I3_ETHERLAN600:
221 case PROD_I3_ETHERLAN600A: 220 case PROD_I3_ETHERLAN600A:
222 addr = etherh_priv(dev)->base + EN0_RCNTHI; 221 addr = (void *)dev->base_addr + EN0_RCNTHI;
223 switch (dev->if_port) { 222 switch (dev->if_port) {
224 case IF_PORT_10BASE2: 223 case IF_PORT_10BASE2:
225 stat = 1; 224 stat = 1;
@@ -282,7 +281,7 @@ static void
282etherh_reset(struct net_device *dev) 281etherh_reset(struct net_device *dev)
283{ 282{
284 struct ei_device *ei_local = netdev_priv(dev); 283 struct ei_device *ei_local = netdev_priv(dev);
285 void __iomem *addr = etherh_priv(dev)->base; 284 void __iomem *addr = (void *)dev->base_addr;
286 285
287 writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr); 286 writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr);
288 287
@@ -328,7 +327,7 @@ etherh_block_output (struct net_device *dev, int count, const unsigned char *buf
328 327
329 ei_local->dmaing = 1; 328 ei_local->dmaing = 1;
330 329
331 addr = etherh_priv(dev)->base; 330 addr = (void *)dev->base_addr;
332 dma_base = etherh_priv(dev)->dma_base; 331 dma_base = etherh_priv(dev)->dma_base;
333 332
334 count = (count + 1) & ~1; 333 count = (count + 1) & ~1;
@@ -388,7 +387,7 @@ etherh_block_input (struct net_device *dev, int count, struct sk_buff *skb, int
388 387
389 ei_local->dmaing = 1; 388 ei_local->dmaing = 1;
390 389
391 addr = etherh_priv(dev)->base; 390 addr = (void *)dev->base_addr;
392 dma_base = etherh_priv(dev)->dma_base; 391 dma_base = etherh_priv(dev)->dma_base;
393 392
394 buf = skb->data; 393 buf = skb->data;
@@ -428,7 +427,7 @@ etherh_get_header (struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_p
428 427
429 ei_local->dmaing = 1; 428 ei_local->dmaing = 1;
430 429
431 addr = etherh_priv(dev)->base; 430 addr = (void *)dev->base_addr;
432 dma_base = etherh_priv(dev)->dma_base; 431 dma_base = etherh_priv(dev)->dma_base;
433 432
434 writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD); 433 writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD);
@@ -697,8 +696,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
697 eh->ctrl_port = eh->ioc_fast; 696 eh->ctrl_port = eh->ioc_fast;
698 } 697 }
699 698
700 eh->base = eh->memc + data->ns8390_offset; 699 dev->base_addr = (unsigned long)eh->memc + data->ns8390_offset;
701 dev->base_addr = (unsigned long)eh->base;
702 eh->dma_base = eh->memc + data->dataport_offset; 700 eh->dma_base = eh->memc + data->dataport_offset;
703 eh->ctrl_port += data->ctrlport_offset; 701 eh->ctrl_port += data->ctrlport_offset;
704 702
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c
index b8ab2b6355eb..e613cc289749 100644
--- a/drivers/net/at1700.c
+++ b/drivers/net/at1700.c
@@ -34,10 +34,6 @@
34 only is it difficult to detect, it also moves around in I/O space in 34 only is it difficult to detect, it also moves around in I/O space in
35 response to inb()s from other device probes! 35 response to inb()s from other device probes!
36*/ 36*/
37/*
38 99/03/03 Allied Telesis RE1000 Plus support by T.Hagawa
39 99/12/30 port to 2.3.35 by K.Takai
40*/
41 37
42#include <linux/config.h> 38#include <linux/config.h>
43#include <linux/errno.h> 39#include <linux/errno.h>
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 3fe8ba992c38..94939f570f78 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1285,6 +1285,9 @@ static int b44_open(struct net_device *dev)
1285 b44_init_hw(bp); 1285 b44_init_hw(bp);
1286 bp->flags |= B44_FLAG_INIT_COMPLETE; 1286 bp->flags |= B44_FLAG_INIT_COMPLETE;
1287 1287
1288 netif_carrier_off(dev);
1289 b44_check_phy(bp);
1290
1288 spin_unlock_irq(&bp->lock); 1291 spin_unlock_irq(&bp->lock);
1289 1292
1290 init_timer(&bp->timer); 1293 init_timer(&bp->timer);
@@ -1927,6 +1930,7 @@ static int b44_suspend(struct pci_dev *pdev, pm_message_t state)
1927 b44_free_rings(bp); 1930 b44_free_rings(bp);
1928 1931
1929 spin_unlock_irq(&bp->lock); 1932 spin_unlock_irq(&bp->lock);
1933 pci_disable_device(pdev);
1930 return 0; 1934 return 0;
1931} 1935}
1932 1936
@@ -1936,6 +1940,8 @@ static int b44_resume(struct pci_dev *pdev)
1936 struct b44 *bp = netdev_priv(dev); 1940 struct b44 *bp = netdev_priv(dev);
1937 1941
1938 pci_restore_state(pdev); 1942 pci_restore_state(pdev);
1943 pci_enable_device(pdev);
1944 pci_set_master(pdev);
1939 1945
1940 if (!netif_running(dev)) 1946 if (!netif_running(dev))
1941 return 0; 1947 return 0;
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 00e5257b176f..8dc657fc8afb 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -1261,7 +1261,7 @@ static void bmac_reset_and_enable(struct net_device *dev)
1261 spin_unlock_irqrestore(&bp->lock, flags); 1261 spin_unlock_irqrestore(&bp->lock, flags);
1262} 1262}
1263 1263
1264static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_match *match) 1264static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
1265{ 1265{
1266 int j, rev, ret; 1266 int j, rev, ret;
1267 struct bmac_data *bp; 1267 struct bmac_data *bp;
@@ -1645,16 +1645,13 @@ static int __devexit bmac_remove(struct macio_dev *mdev)
1645 return 0; 1645 return 0;
1646} 1646}
1647 1647
1648static struct of_match bmac_match[] = 1648static struct of_device_id bmac_match[] =
1649{ 1649{
1650 { 1650 {
1651 .name = "bmac", 1651 .name = "bmac",
1652 .type = OF_ANY_MATCH,
1653 .compatible = OF_ANY_MATCH,
1654 .data = (void *)0, 1652 .data = (void *)0,
1655 }, 1653 },
1656 { 1654 {
1657 .name = OF_ANY_MATCH,
1658 .type = "network", 1655 .type = "network",
1659 .compatible = "bmac+", 1656 .compatible = "bmac+",
1660 .data = (void *)1, 1657 .data = (void *)1,
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 6233c4ffb805..a2e8dda5afac 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2346,7 +2346,6 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2346{ 2346{
2347 struct slave *slave, *start_at; 2347 struct slave *slave, *start_at;
2348 struct bonding *bond = dev->priv; 2348 struct bonding *bond = dev->priv;
2349 struct ethhdr *data = (struct ethhdr *)skb->data;
2350 int slave_agg_no; 2349 int slave_agg_no;
2351 int slaves_in_agg; 2350 int slaves_in_agg;
2352 int agg_id; 2351 int agg_id;
@@ -2377,7 +2376,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2377 goto out; 2376 goto out;
2378 } 2377 }
2379 2378
2380 slave_agg_no = (data->h_dest[5]^bond->dev->dev_addr[5]) % slaves_in_agg; 2379 slave_agg_no = bond->xmit_hash_policy(skb, dev, slaves_in_agg);
2381 2380
2382 bond_for_each_slave(bond, slave, i) { 2381 bond_for_each_slave(bond, slave, i) {
2383 struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator; 2382 struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 5ce606d9dc03..19e829b567d0 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1106,18 +1106,13 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
1106 } 1106 }
1107 } 1107 }
1108 1108
1109 if (found) { 1109 if (!found)
1110 /* a slave was found that is using the mac address 1110 return 0;
1111 * of the new slave
1112 */
1113 printk(KERN_ERR DRV_NAME
1114 ": Error: the hw address of slave %s is not "
1115 "unique - cannot enslave it!",
1116 slave->dev->name);
1117 return -EINVAL;
1118 }
1119 1111
1120 return 0; 1112 /* Try setting slave mac to bond address and fall-through
1113 to code handling that situation below... */
1114 alb_set_slave_mac_addr(slave, bond->dev->dev_addr,
1115 bond->alb_info.rlb_enabled);
1121 } 1116 }
1122 1117
1123 /* The slave's address is equal to the address of the bond. 1118 /* The slave's address is equal to the address of the bond.
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 269a5e407349..94c9f68dd16b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -475,7 +475,18 @@
475 * Solution is to move call to dev_remove_pack outside of the 475 * Solution is to move call to dev_remove_pack outside of the
476 * spinlock. 476 * spinlock.
477 * Set version to 2.6.1. 477 * Set version to 2.6.1.
478 * 478 * 2005/06/05 - Jay Vosburgh <fubar@us.ibm.com>
479 * - Support for generating gratuitous ARPs in active-backup mode.
480 * Includes support for VLAN tagging all bonding-generated ARPs
481 * as needed. Set version to 2.6.2.
482 * 2005/06/08 - Jason Gabler <jygabler at lbl dot gov>
483 * - alternate hashing policy support for mode 2
484 * * Added kernel parameter "xmit_hash_policy" to allow the selection
485 * of different hashing policies for mode 2. The original mode 2
486 * policy is the default, now found in xmit_hash_policy_layer2().
487 * * Added xmit_hash_policy_layer34()
488 * - Modified by Jay Vosburgh <fubar@us.ibm.com> to also support mode 4.
489 * Set version to 2.6.3.
479 */ 490 */
480 491
481//#define BONDING_DEBUG 1 492//#define BONDING_DEBUG 1
@@ -490,7 +501,10 @@
490#include <linux/ptrace.h> 501#include <linux/ptrace.h>
491#include <linux/ioport.h> 502#include <linux/ioport.h>
492#include <linux/in.h> 503#include <linux/in.h>
504#include <net/ip.h>
493#include <linux/ip.h> 505#include <linux/ip.h>
506#include <linux/tcp.h>
507#include <linux/udp.h>
494#include <linux/slab.h> 508#include <linux/slab.h>
495#include <linux/string.h> 509#include <linux/string.h>
496#include <linux/init.h> 510#include <linux/init.h>
@@ -519,6 +533,7 @@
519#include <linux/ethtool.h> 533#include <linux/ethtool.h>
520#include <linux/if_vlan.h> 534#include <linux/if_vlan.h>
521#include <linux/if_bonding.h> 535#include <linux/if_bonding.h>
536#include <net/route.h>
522#include "bonding.h" 537#include "bonding.h"
523#include "bond_3ad.h" 538#include "bond_3ad.h"
524#include "bond_alb.h" 539#include "bond_alb.h"
@@ -537,6 +552,7 @@ static int use_carrier = 1;
537static char *mode = NULL; 552static char *mode = NULL;
538static char *primary = NULL; 553static char *primary = NULL;
539static char *lacp_rate = NULL; 554static char *lacp_rate = NULL;
555static char *xmit_hash_policy = NULL;
540static int arp_interval = BOND_LINK_ARP_INTERV; 556static int arp_interval = BOND_LINK_ARP_INTERV;
541static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; 557static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, };
542 558
@@ -556,6 +572,8 @@ module_param(primary, charp, 0);
556MODULE_PARM_DESC(primary, "Primary network device to use"); 572MODULE_PARM_DESC(primary, "Primary network device to use");
557module_param(lacp_rate, charp, 0); 573module_param(lacp_rate, charp, 0);
558MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)"); 574MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)");
575module_param(xmit_hash_policy, charp, 0);
576MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method : 0 for layer 2 (default), 1 for layer 3+4");
559module_param(arp_interval, int, 0); 577module_param(arp_interval, int, 0);
560MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); 578MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds");
561module_param_array(arp_ip_target, charp, NULL, 0); 579module_param_array(arp_ip_target, charp, NULL, 0);
@@ -574,8 +592,8 @@ static struct proc_dir_entry *bond_proc_dir = NULL;
574 592
575static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; 593static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ;
576static int arp_ip_count = 0; 594static int arp_ip_count = 0;
577static u32 my_ip = 0;
578static int bond_mode = BOND_MODE_ROUNDROBIN; 595static int bond_mode = BOND_MODE_ROUNDROBIN;
596static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2;
579static int lacp_fast = 0; 597static int lacp_fast = 0;
580static int app_abi_ver = 0; 598static int app_abi_ver = 0;
581static int orig_app_abi_ver = -1; /* This is used to save the first ABI version 599static int orig_app_abi_ver = -1; /* This is used to save the first ABI version
@@ -585,7 +603,6 @@ static int orig_app_abi_ver = -1; /* This is used to save the first ABI version
585 * command comes from an application using 603 * command comes from an application using
586 * another ABI version. 604 * another ABI version.
587 */ 605 */
588
589struct bond_parm_tbl { 606struct bond_parm_tbl {
590 char *modename; 607 char *modename;
591 int mode; 608 int mode;
@@ -608,9 +625,16 @@ static struct bond_parm_tbl bond_mode_tbl[] = {
608{ NULL, -1}, 625{ NULL, -1},
609}; 626};
610 627
628static struct bond_parm_tbl xmit_hashtype_tbl[] = {
629{ "layer2", BOND_XMIT_POLICY_LAYER2},
630{ "layer3+4", BOND_XMIT_POLICY_LAYER34},
631{ NULL, -1},
632};
633
611/*-------------------------- Forward declarations ---------------------------*/ 634/*-------------------------- Forward declarations ---------------------------*/
612 635
613static inline void bond_set_mode_ops(struct net_device *bond_dev, int mode); 636static inline void bond_set_mode_ops(struct bonding *bond, int mode);
637static void bond_send_gratuitous_arp(struct bonding *bond);
614 638
615/*---------------------------- General routines -----------------------------*/ 639/*---------------------------- General routines -----------------------------*/
616 640
@@ -659,6 +683,7 @@ static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
659 683
660 INIT_LIST_HEAD(&vlan->vlan_list); 684 INIT_LIST_HEAD(&vlan->vlan_list);
661 vlan->vlan_id = vlan_id; 685 vlan->vlan_id = vlan_id;
686 vlan->vlan_ip = 0;
662 687
663 write_lock_bh(&bond->lock); 688 write_lock_bh(&bond->lock);
664 689
@@ -1468,16 +1493,6 @@ static void bond_change_active_slave(struct bonding *bond, struct slave *new_act
1468 } 1493 }
1469 } 1494 }
1470 1495
1471 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
1472 if (old_active) {
1473 bond_set_slave_inactive_flags(old_active);
1474 }
1475
1476 if (new_active) {
1477 bond_set_slave_active_flags(new_active);
1478 }
1479 }
1480
1481 if (USES_PRIMARY(bond->params.mode)) { 1496 if (USES_PRIMARY(bond->params.mode)) {
1482 bond_mc_swap(bond, new_active, old_active); 1497 bond_mc_swap(bond, new_active, old_active);
1483 } 1498 }
@@ -1488,6 +1503,17 @@ static void bond_change_active_slave(struct bonding *bond, struct slave *new_act
1488 } else { 1503 } else {
1489 bond->curr_active_slave = new_active; 1504 bond->curr_active_slave = new_active;
1490 } 1505 }
1506
1507 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
1508 if (old_active) {
1509 bond_set_slave_inactive_flags(old_active);
1510 }
1511
1512 if (new_active) {
1513 bond_set_slave_active_flags(new_active);
1514 }
1515 bond_send_gratuitous_arp(bond);
1516 }
1491} 1517}
1492 1518
1493/** 1519/**
@@ -1578,6 +1604,44 @@ static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_
1578 return 0; 1604 return 0;
1579} 1605}
1580 1606
1607#define BOND_INTERSECT_FEATURES \
1608 (NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM)
1609
1610/*
1611 * Compute the features available to the bonding device by
1612 * intersection of all of the slave devices' BOND_INTERSECT_FEATURES.
1613 * Call this after attaching or detaching a slave to update the
1614 * bond's features.
1615 */
1616static int bond_compute_features(struct bonding *bond)
1617{
1618 int i;
1619 struct slave *slave;
1620 struct net_device *bond_dev = bond->dev;
1621 int features = bond->bond_features;
1622
1623 bond_for_each_slave(bond, slave, i) {
1624 struct net_device * slave_dev = slave->dev;
1625 if (i == 0) {
1626 features |= BOND_INTERSECT_FEATURES;
1627 }
1628 features &=
1629 ~(~slave_dev->features & BOND_INTERSECT_FEATURES);
1630 }
1631
1632 /* turn off NETIF_F_SG if we need a csum and h/w can't do it */
1633 if ((features & NETIF_F_SG) &&
1634 !(features & (NETIF_F_IP_CSUM |
1635 NETIF_F_NO_CSUM |
1636 NETIF_F_HW_CSUM))) {
1637 features &= ~NETIF_F_SG;
1638 }
1639
1640 bond_dev->features = features;
1641
1642 return 0;
1643}
1644
1581/* enslave device <slave> to bond device <master> */ 1645/* enslave device <slave> to bond device <master> */
1582static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) 1646static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1583{ 1647{
@@ -1785,6 +1849,8 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1785 new_slave->delay = 0; 1849 new_slave->delay = 0;
1786 new_slave->link_failure_count = 0; 1850 new_slave->link_failure_count = 0;
1787 1851
1852 bond_compute_features(bond);
1853
1788 if (bond->params.miimon && !bond->params.use_carrier) { 1854 if (bond->params.miimon && !bond->params.use_carrier) {
1789 link_reporting = bond_check_dev_link(bond, slave_dev, 1); 1855 link_reporting = bond_check_dev_link(bond, slave_dev, 1);
1790 1856
@@ -1989,7 +2055,7 @@ err_free:
1989 2055
1990err_undo_flags: 2056err_undo_flags:
1991 bond_dev->features = old_features; 2057 bond_dev->features = old_features;
1992 2058
1993 return res; 2059 return res;
1994} 2060}
1995 2061
@@ -2074,6 +2140,8 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de
2074 /* release the slave from its bond */ 2140 /* release the slave from its bond */
2075 bond_detach_slave(bond, slave); 2141 bond_detach_slave(bond, slave);
2076 2142
2143 bond_compute_features(bond);
2144
2077 if (bond->primary_slave == slave) { 2145 if (bond->primary_slave == slave) {
2078 bond->primary_slave = NULL; 2146 bond->primary_slave = NULL;
2079 } 2147 }
@@ -2217,6 +2285,8 @@ static int bond_release_all(struct net_device *bond_dev)
2217 bond_alb_deinit_slave(bond, slave); 2285 bond_alb_deinit_slave(bond, slave);
2218 } 2286 }
2219 2287
2288 bond_compute_features(bond);
2289
2220 /* now that the slave is detached, unlock and perform 2290 /* now that the slave is detached, unlock and perform
2221 * all the undo steps that should not be called from 2291 * all the undo steps that should not be called from
2222 * within a lock. 2292 * within a lock.
@@ -2694,15 +2764,180 @@ out:
2694 read_unlock(&bond->lock); 2764 read_unlock(&bond->lock);
2695} 2765}
2696 2766
2767
2768static u32 bond_glean_dev_ip(struct net_device *dev)
2769{
2770 struct in_device *idev;
2771 struct in_ifaddr *ifa;
2772 u32 addr = 0;
2773
2774 if (!dev)
2775 return 0;
2776
2777 rcu_read_lock();
2778 idev = __in_dev_get(dev);
2779 if (!idev)
2780 goto out;
2781
2782 ifa = idev->ifa_list;
2783 if (!ifa)
2784 goto out;
2785
2786 addr = ifa->ifa_local;
2787out:
2788 rcu_read_unlock();
2789 return addr;
2790}
2791
2792static int bond_has_ip(struct bonding *bond)
2793{
2794 struct vlan_entry *vlan, *vlan_next;
2795
2796 if (bond->master_ip)
2797 return 1;
2798
2799 if (list_empty(&bond->vlan_list))
2800 return 0;
2801
2802 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
2803 vlan_list) {
2804 if (vlan->vlan_ip)
2805 return 1;
2806 }
2807
2808 return 0;
2809}
2810
2811/*
2812 * We go to the (large) trouble of VLAN tagging ARP frames because
2813 * switches in VLAN mode (especially if ports are configured as
2814 * "native" to a VLAN) might not pass non-tagged frames.
2815 */
2816static void bond_arp_send(struct net_device *slave_dev, int arp_op, u32 dest_ip, u32 src_ip, unsigned short vlan_id)
2817{
2818 struct sk_buff *skb;
2819
2820 dprintk("arp %d on slave %s: dst %x src %x vid %d\n", arp_op,
2821 slave_dev->name, dest_ip, src_ip, vlan_id);
2822
2823 skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip,
2824 NULL, slave_dev->dev_addr, NULL);
2825
2826 if (!skb) {
2827 printk(KERN_ERR DRV_NAME ": ARP packet allocation failed\n");
2828 return;
2829 }
2830 if (vlan_id) {
2831 skb = vlan_put_tag(skb, vlan_id);
2832 if (!skb) {
2833 printk(KERN_ERR DRV_NAME ": failed to insert VLAN tag\n");
2834 return;
2835 }
2836 }
2837 arp_xmit(skb);
2838}
2839
2840
2697static void bond_arp_send_all(struct bonding *bond, struct slave *slave) 2841static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2698{ 2842{
2699 int i; 2843 int i, vlan_id, rv;
2700 u32 *targets = bond->params.arp_targets; 2844 u32 *targets = bond->params.arp_targets;
2845 struct vlan_entry *vlan, *vlan_next;
2846 struct net_device *vlan_dev;
2847 struct flowi fl;
2848 struct rtable *rt;
2701 2849
2702 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) { 2850 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
2703 arp_send(ARPOP_REQUEST, ETH_P_ARP, targets[i], slave->dev, 2851 dprintk("basa: target %x\n", targets[i]);
2704 my_ip, NULL, slave->dev->dev_addr, 2852 if (list_empty(&bond->vlan_list)) {
2705 NULL); 2853 dprintk("basa: empty vlan: arp_send\n");
2854 bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
2855 bond->master_ip, 0);
2856 continue;
2857 }
2858
2859 /*
2860 * If VLANs are configured, we do a route lookup to
2861 * determine which VLAN interface would be used, so we
2862 * can tag the ARP with the proper VLAN tag.
2863 */
2864 memset(&fl, 0, sizeof(fl));
2865 fl.fl4_dst = targets[i];
2866 fl.fl4_tos = RTO_ONLINK;
2867
2868 rv = ip_route_output_key(&rt, &fl);
2869 if (rv) {
2870 if (net_ratelimit()) {
2871 printk(KERN_WARNING DRV_NAME
2872 ": %s: no route to arp_ip_target %u.%u.%u.%u\n",
2873 bond->dev->name, NIPQUAD(fl.fl4_dst));
2874 }
2875 continue;
2876 }
2877
2878 /*
2879 * This target is not on a VLAN
2880 */
2881 if (rt->u.dst.dev == bond->dev) {
2882 dprintk("basa: rtdev == bond->dev: arp_send\n");
2883 bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
2884 bond->master_ip, 0);
2885 continue;
2886 }
2887
2888 vlan_id = 0;
2889 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
2890 vlan_list) {
2891 vlan_dev = bond->vlgrp->vlan_devices[vlan->vlan_id];
2892 if (vlan_dev == rt->u.dst.dev) {
2893 vlan_id = vlan->vlan_id;
2894 dprintk("basa: vlan match on %s %d\n",
2895 vlan_dev->name, vlan_id);
2896 break;
2897 }
2898 }
2899
2900 if (vlan_id) {
2901 bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
2902 vlan->vlan_ip, vlan_id);
2903 continue;
2904 }
2905
2906 if (net_ratelimit()) {
2907 printk(KERN_WARNING DRV_NAME
2908 ": %s: no path to arp_ip_target %u.%u.%u.%u via rt.dev %s\n",
2909 bond->dev->name, NIPQUAD(fl.fl4_dst),
2910 rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
2911 }
2912 }
2913}
2914
2915/*
2916 * Kick out a gratuitous ARP for an IP on the bonding master plus one
2917 * for each VLAN above us.
2918 */
2919static void bond_send_gratuitous_arp(struct bonding *bond)
2920{
2921 struct slave *slave = bond->curr_active_slave;
2922 struct vlan_entry *vlan;
2923 struct net_device *vlan_dev;
2924
2925 dprintk("bond_send_grat_arp: bond %s slave %s\n", bond->dev->name,
2926 slave ? slave->dev->name : "NULL");
2927 if (!slave)
2928 return;
2929
2930 if (bond->master_ip) {
2931 bond_arp_send(slave->dev, ARPOP_REPLY, bond->master_ip,
2932 bond->master_ip, 0);
2933 }
2934
2935 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
2936 vlan_dev = bond->vlgrp->vlan_devices[vlan->vlan_id];
2937 if (vlan->vlan_ip) {
2938 bond_arp_send(slave->dev, ARPOP_REPLY, vlan->vlan_ip,
2939 vlan->vlan_ip, vlan->vlan_id);
2940 }
2706 } 2941 }
2707} 2942}
2708 2943
@@ -2781,7 +3016,7 @@ static void bond_loadbalance_arp_mon(struct net_device *bond_dev)
2781 */ 3016 */
2782 if (((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || 3017 if (((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) ||
2783 (((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) && 3018 (((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) &&
2784 my_ip)) { 3019 bond_has_ip(bond))) {
2785 3020
2786 slave->link = BOND_LINK_DOWN; 3021 slave->link = BOND_LINK_DOWN;
2787 slave->state = BOND_STATE_BACKUP; 3022 slave->state = BOND_STATE_BACKUP;
@@ -2920,7 +3155,7 @@ static void bond_activebackup_arp_mon(struct net_device *bond_dev)
2920 if ((slave != bond->curr_active_slave) && 3155 if ((slave != bond->curr_active_slave) &&
2921 (!bond->current_arp_slave) && 3156 (!bond->current_arp_slave) &&
2922 (((jiffies - slave->dev->last_rx) >= 3*delta_in_ticks) && 3157 (((jiffies - slave->dev->last_rx) >= 3*delta_in_ticks) &&
2923 my_ip)) { 3158 bond_has_ip(bond))) {
2924 /* a backup slave has gone down; three times 3159 /* a backup slave has gone down; three times
2925 * the delta allows the current slave to be 3160 * the delta allows the current slave to be
2926 * taken out before the backup slave. 3161 * taken out before the backup slave.
@@ -2966,8 +3201,8 @@ static void bond_activebackup_arp_mon(struct net_device *bond_dev)
2966 * if it is up and needs to take over as the curr_active_slave 3201 * if it is up and needs to take over as the curr_active_slave
2967 */ 3202 */
2968 if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || 3203 if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) ||
2969 (((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) && 3204 (((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) &&
2970 my_ip)) && 3205 bond_has_ip(bond))) &&
2971 ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) { 3206 ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) {
2972 3207
2973 slave->link = BOND_LINK_DOWN; 3208 slave->link = BOND_LINK_DOWN;
@@ -3019,7 +3254,7 @@ static void bond_activebackup_arp_mon(struct net_device *bond_dev)
3019 /* the current slave must tx an arp to ensure backup slaves 3254 /* the current slave must tx an arp to ensure backup slaves
3020 * rx traffic 3255 * rx traffic
3021 */ 3256 */
3022 if (slave && my_ip) { 3257 if (slave && bond_has_ip(bond)) {
3023 bond_arp_send_all(bond, slave); 3258 bond_arp_send_all(bond, slave);
3024 } 3259 }
3025 } 3260 }
@@ -3397,6 +3632,7 @@ static int bond_master_netdev_event(unsigned long event, struct net_device *bond
3397static int bond_slave_netdev_event(unsigned long event, struct net_device *slave_dev) 3632static int bond_slave_netdev_event(unsigned long event, struct net_device *slave_dev)
3398{ 3633{
3399 struct net_device *bond_dev = slave_dev->master; 3634 struct net_device *bond_dev = slave_dev->master;
3635 struct bonding *bond = bond_dev->priv;
3400 3636
3401 switch (event) { 3637 switch (event) {
3402 case NETDEV_UNREGISTER: 3638 case NETDEV_UNREGISTER:
@@ -3435,6 +3671,9 @@ static int bond_slave_netdev_event(unsigned long event, struct net_device *slave
3435 * TODO: handle changing the primary's name 3671 * TODO: handle changing the primary's name
3436 */ 3672 */
3437 break; 3673 break;
3674 case NETDEV_FEAT_CHANGE:
3675 bond_compute_features(bond);
3676 break;
3438 default: 3677 default:
3439 break; 3678 break;
3440 } 3679 }
@@ -3471,10 +3710,67 @@ static int bond_netdev_event(struct notifier_block *this, unsigned long event, v
3471 return NOTIFY_DONE; 3710 return NOTIFY_DONE;
3472} 3711}
3473 3712
3713/*
3714 * bond_inetaddr_event: handle inetaddr notifier chain events.
3715 *
3716 * We keep track of device IPs primarily to use as source addresses in
3717 * ARP monitor probes (rather than spewing out broadcasts all the time).
3718 *
3719 * We track one IP for the main device (if it has one), plus one per VLAN.
3720 */
3721static int bond_inetaddr_event(struct notifier_block *this, unsigned long event, void *ptr)
3722{
3723 struct in_ifaddr *ifa = ptr;
3724 struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev;
3725 struct bonding *bond, *bond_next;
3726 struct vlan_entry *vlan, *vlan_next;
3727
3728 list_for_each_entry_safe(bond, bond_next, &bond_dev_list, bond_list) {
3729 if (bond->dev == event_dev) {
3730 switch (event) {
3731 case NETDEV_UP:
3732 bond->master_ip = ifa->ifa_local;
3733 return NOTIFY_OK;
3734 case NETDEV_DOWN:
3735 bond->master_ip = bond_glean_dev_ip(bond->dev);
3736 return NOTIFY_OK;
3737 default:
3738 return NOTIFY_DONE;
3739 }
3740 }
3741
3742 if (list_empty(&bond->vlan_list))
3743 continue;
3744
3745 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
3746 vlan_list) {
3747 vlan_dev = bond->vlgrp->vlan_devices[vlan->vlan_id];
3748 if (vlan_dev == event_dev) {
3749 switch (event) {
3750 case NETDEV_UP:
3751 vlan->vlan_ip = ifa->ifa_local;
3752 return NOTIFY_OK;
3753 case NETDEV_DOWN:
3754 vlan->vlan_ip =
3755 bond_glean_dev_ip(vlan_dev);
3756 return NOTIFY_OK;
3757 default:
3758 return NOTIFY_DONE;
3759 }
3760 }
3761 }
3762 }
3763 return NOTIFY_DONE;
3764}
3765
3474static struct notifier_block bond_netdev_notifier = { 3766static struct notifier_block bond_netdev_notifier = {
3475 .notifier_call = bond_netdev_event, 3767 .notifier_call = bond_netdev_event,
3476}; 3768};
3477 3769
3770static struct notifier_block bond_inetaddr_notifier = {
3771 .notifier_call = bond_inetaddr_event,
3772};
3773
3478/*-------------------------- Packet type handling ---------------------------*/ 3774/*-------------------------- Packet type handling ---------------------------*/
3479 3775
3480/* register to receive lacpdus on a bond */ 3776/* register to receive lacpdus on a bond */
@@ -3496,6 +3792,46 @@ static void bond_unregister_lacpdu(struct bonding *bond)
3496 dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); 3792 dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type));
3497} 3793}
3498 3794
3795/*---------------------------- Hashing Policies -----------------------------*/
3796
3797/*
3798 * Hash for the the output device based upon layer 3 and layer 4 data. If
3799 * the packet is a frag or not TCP or UDP, just use layer 3 data. If it is
3800 * altogether not IP, mimic bond_xmit_hash_policy_l2()
3801 */
3802static int bond_xmit_hash_policy_l34(struct sk_buff *skb,
3803 struct net_device *bond_dev, int count)
3804{
3805 struct ethhdr *data = (struct ethhdr *)skb->data;
3806 struct iphdr *iph = skb->nh.iph;
3807 u16 *layer4hdr = (u16 *)((u32 *)iph + iph->ihl);
3808 int layer4_xor = 0;
3809
3810 if (skb->protocol == __constant_htons(ETH_P_IP)) {
3811 if (!(iph->frag_off & __constant_htons(IP_MF|IP_OFFSET)) &&
3812 (iph->protocol == IPPROTO_TCP ||
3813 iph->protocol == IPPROTO_UDP)) {
3814 layer4_xor = htons((*layer4hdr ^ *(layer4hdr + 1)));
3815 }
3816 return (layer4_xor ^
3817 ((ntohl(iph->saddr ^ iph->daddr)) & 0xffff)) % count;
3818
3819 }
3820
3821 return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count;
3822}
3823
3824/*
3825 * Hash for the output device based upon layer 2 data
3826 */
3827static int bond_xmit_hash_policy_l2(struct sk_buff *skb,
3828 struct net_device *bond_dev, int count)
3829{
3830 struct ethhdr *data = (struct ethhdr *)skb->data;
3831
3832 return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count;
3833}
3834
3499/*-------------------------- Device entry points ----------------------------*/ 3835/*-------------------------- Device entry points ----------------------------*/
3500 3836
3501static int bond_open(struct net_device *bond_dev) 3837static int bond_open(struct net_device *bond_dev)
@@ -4060,17 +4396,6 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
4060 struct bonding *bond = bond_dev->priv; 4396 struct bonding *bond = bond_dev->priv;
4061 int res = 1; 4397 int res = 1;
4062 4398
4063 /* if we are sending arp packets, try to at least
4064 identify our own ip address */
4065 if (bond->params.arp_interval && !my_ip &&
4066 (skb->protocol == __constant_htons(ETH_P_ARP))) {
4067 char *the_ip = (char *)skb->data +
4068 sizeof(struct ethhdr) +
4069 sizeof(struct arphdr) +
4070 ETH_ALEN;
4071 memcpy(&my_ip, the_ip, 4);
4072 }
4073
4074 read_lock(&bond->lock); 4399 read_lock(&bond->lock);
4075 read_lock(&bond->curr_slave_lock); 4400 read_lock(&bond->curr_slave_lock);
4076 4401
@@ -4093,14 +4418,13 @@ out:
4093} 4418}
4094 4419
4095/* 4420/*
4096 * in XOR mode, we determine the output device by performing xor on 4421 * In bond_xmit_xor() , we determine the output device by using a pre-
4097 * the source and destination hw adresses. If this device is not 4422 * determined xmit_hash_policy(), If the selected device is not enabled,
4098 * enabled, find the next slave following this xor slave. 4423 * find the next active slave.
4099 */ 4424 */
4100static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) 4425static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
4101{ 4426{
4102 struct bonding *bond = bond_dev->priv; 4427 struct bonding *bond = bond_dev->priv;
4103 struct ethhdr *data = (struct ethhdr *)skb->data;
4104 struct slave *slave, *start_at; 4428 struct slave *slave, *start_at;
4105 int slave_no; 4429 int slave_no;
4106 int i; 4430 int i;
@@ -4112,7 +4436,7 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
4112 goto out; 4436 goto out;
4113 } 4437 }
4114 4438
4115 slave_no = (data->h_dest[5]^bond_dev->dev_addr[5]) % bond->slave_cnt; 4439 slave_no = bond->xmit_hash_policy(skb, bond_dev, bond->slave_cnt);
4116 4440
4117 bond_for_each_slave(bond, slave, i) { 4441 bond_for_each_slave(bond, slave, i) {
4118 slave_no--; 4442 slave_no--;
@@ -4208,8 +4532,10 @@ out:
4208/* 4532/*
4209 * set bond mode specific net device operations 4533 * set bond mode specific net device operations
4210 */ 4534 */
4211static inline void bond_set_mode_ops(struct net_device *bond_dev, int mode) 4535static inline void bond_set_mode_ops(struct bonding *bond, int mode)
4212{ 4536{
4537 struct net_device *bond_dev = bond->dev;
4538
4213 switch (mode) { 4539 switch (mode) {
4214 case BOND_MODE_ROUNDROBIN: 4540 case BOND_MODE_ROUNDROBIN:
4215 bond_dev->hard_start_xmit = bond_xmit_roundrobin; 4541 bond_dev->hard_start_xmit = bond_xmit_roundrobin;
@@ -4219,12 +4545,20 @@ static inline void bond_set_mode_ops(struct net_device *bond_dev, int mode)
4219 break; 4545 break;
4220 case BOND_MODE_XOR: 4546 case BOND_MODE_XOR:
4221 bond_dev->hard_start_xmit = bond_xmit_xor; 4547 bond_dev->hard_start_xmit = bond_xmit_xor;
4548 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34)
4549 bond->xmit_hash_policy = bond_xmit_hash_policy_l34;
4550 else
4551 bond->xmit_hash_policy = bond_xmit_hash_policy_l2;
4222 break; 4552 break;
4223 case BOND_MODE_BROADCAST: 4553 case BOND_MODE_BROADCAST:
4224 bond_dev->hard_start_xmit = bond_xmit_broadcast; 4554 bond_dev->hard_start_xmit = bond_xmit_broadcast;
4225 break; 4555 break;
4226 case BOND_MODE_8023AD: 4556 case BOND_MODE_8023AD:
4227 bond_dev->hard_start_xmit = bond_3ad_xmit_xor; 4557 bond_dev->hard_start_xmit = bond_3ad_xmit_xor;
4558 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34)
4559 bond->xmit_hash_policy = bond_xmit_hash_policy_l34;
4560 else
4561 bond->xmit_hash_policy = bond_xmit_hash_policy_l2;
4228 break; 4562 break;
4229 case BOND_MODE_TLB: 4563 case BOND_MODE_TLB:
4230 case BOND_MODE_ALB: 4564 case BOND_MODE_ALB:
@@ -4240,6 +4574,11 @@ static inline void bond_set_mode_ops(struct net_device *bond_dev, int mode)
4240 } 4574 }
4241} 4575}
4242 4576
4577static struct ethtool_ops bond_ethtool_ops = {
4578 .get_tx_csum = ethtool_op_get_tx_csum,
4579 .get_sg = ethtool_op_get_sg,
4580};
4581
4243/* 4582/*
4244 * Does not allocate but creates a /proc entry. 4583 * Does not allocate but creates a /proc entry.
4245 * Allowed to fail. 4584 * Allowed to fail.
@@ -4269,11 +4608,12 @@ static int __init bond_init(struct net_device *bond_dev, struct bond_params *par
4269 bond_dev->stop = bond_close; 4608 bond_dev->stop = bond_close;
4270 bond_dev->get_stats = bond_get_stats; 4609 bond_dev->get_stats = bond_get_stats;
4271 bond_dev->do_ioctl = bond_do_ioctl; 4610 bond_dev->do_ioctl = bond_do_ioctl;
4611 bond_dev->ethtool_ops = &bond_ethtool_ops;
4272 bond_dev->set_multicast_list = bond_set_multicast_list; 4612 bond_dev->set_multicast_list = bond_set_multicast_list;
4273 bond_dev->change_mtu = bond_change_mtu; 4613 bond_dev->change_mtu = bond_change_mtu;
4274 bond_dev->set_mac_address = bond_set_mac_address; 4614 bond_dev->set_mac_address = bond_set_mac_address;
4275 4615
4276 bond_set_mode_ops(bond_dev, bond->params.mode); 4616 bond_set_mode_ops(bond, bond->params.mode);
4277 4617
4278 bond_dev->destructor = free_netdev; 4618 bond_dev->destructor = free_netdev;
4279 4619
@@ -4305,6 +4645,8 @@ static int __init bond_init(struct net_device *bond_dev, struct bond_params *par
4305 NETIF_F_HW_VLAN_RX | 4645 NETIF_F_HW_VLAN_RX |
4306 NETIF_F_HW_VLAN_FILTER); 4646 NETIF_F_HW_VLAN_FILTER);
4307 4647
4648 bond->bond_features = bond_dev->features;
4649
4308#ifdef CONFIG_PROC_FS 4650#ifdef CONFIG_PROC_FS
4309 bond_create_proc_entry(bond); 4651 bond_create_proc_entry(bond);
4310#endif 4652#endif
@@ -4384,6 +4726,25 @@ static int bond_check_params(struct bond_params *params)
4384 } 4726 }
4385 } 4727 }
4386 4728
4729 if (xmit_hash_policy) {
4730 if ((bond_mode != BOND_MODE_XOR) &&
4731 (bond_mode != BOND_MODE_8023AD)) {
4732 printk(KERN_INFO DRV_NAME
4733 ": xor_mode param is irrelevant in mode %s\n",
4734 bond_mode_name(bond_mode));
4735 } else {
4736 xmit_hashtype = bond_parse_parm(xmit_hash_policy,
4737 xmit_hashtype_tbl);
4738 if (xmit_hashtype == -1) {
4739 printk(KERN_ERR DRV_NAME
4740 ": Error: Invalid xmit_hash_policy \"%s\"\n",
4741 xmit_hash_policy == NULL ? "NULL" :
4742 xmit_hash_policy);
4743 return -EINVAL;
4744 }
4745 }
4746 }
4747
4387 if (lacp_rate) { 4748 if (lacp_rate) {
4388 if (bond_mode != BOND_MODE_8023AD) { 4749 if (bond_mode != BOND_MODE_8023AD) {
4389 printk(KERN_INFO DRV_NAME 4750 printk(KERN_INFO DRV_NAME
@@ -4595,6 +4956,7 @@ static int bond_check_params(struct bond_params *params)
4595 4956
4596 /* fill params struct with the proper values */ 4957 /* fill params struct with the proper values */
4597 params->mode = bond_mode; 4958 params->mode = bond_mode;
4959 params->xmit_policy = xmit_hashtype;
4598 params->miimon = miimon; 4960 params->miimon = miimon;
4599 params->arp_interval = arp_interval; 4961 params->arp_interval = arp_interval;
4600 params->updelay = updelay; 4962 params->updelay = updelay;
@@ -4669,6 +5031,7 @@ static int __init bonding_init(void)
4669 5031
4670 rtnl_unlock(); 5032 rtnl_unlock();
4671 register_netdevice_notifier(&bond_netdev_notifier); 5033 register_netdevice_notifier(&bond_netdev_notifier);
5034 register_inetaddr_notifier(&bond_inetaddr_notifier);
4672 5035
4673 return 0; 5036 return 0;
4674 5037
@@ -4684,6 +5047,7 @@ out_err:
4684static void __exit bonding_exit(void) 5047static void __exit bonding_exit(void)
4685{ 5048{
4686 unregister_netdevice_notifier(&bond_netdev_notifier); 5049 unregister_netdevice_notifier(&bond_netdev_notifier);
5050 unregister_inetaddr_notifier(&bond_inetaddr_notifier);
4687 5051
4688 rtnl_lock(); 5052 rtnl_lock();
4689 bond_free_all(); 5053 bond_free_all();
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 8c325308489d..388196980862 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -25,6 +25,10 @@
25 * 25 *
26 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com> 26 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
27 * - Code cleanup and style changes 27 * - Code cleanup and style changes
28 *
29 * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov>
30 * - added "xmit_policy" kernel parameter for alternate hashing policy
31 * support for mode 2
28 */ 32 */
29 33
30#ifndef _LINUX_BONDING_H 34#ifndef _LINUX_BONDING_H
@@ -36,8 +40,8 @@
36#include "bond_3ad.h" 40#include "bond_3ad.h"
37#include "bond_alb.h" 41#include "bond_alb.h"
38 42
39#define DRV_VERSION "2.6.1" 43#define DRV_VERSION "2.6.3"
40#define DRV_RELDATE "October 29, 2004" 44#define DRV_RELDATE "June 8, 2005"
41#define DRV_NAME "bonding" 45#define DRV_NAME "bonding"
42#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" 46#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
43 47
@@ -137,6 +141,7 @@
137 141
138struct bond_params { 142struct bond_params {
139 int mode; 143 int mode;
144 int xmit_policy;
140 int miimon; 145 int miimon;
141 int arp_interval; 146 int arp_interval;
142 int use_carrier; 147 int use_carrier;
@@ -149,6 +154,7 @@ struct bond_params {
149 154
150struct vlan_entry { 155struct vlan_entry {
151 struct list_head vlan_list; 156 struct list_head vlan_list;
157 u32 vlan_ip;
152 unsigned short vlan_id; 158 unsigned short vlan_id;
153}; 159};
154 160
@@ -197,12 +203,17 @@ struct bonding {
197#endif /* CONFIG_PROC_FS */ 203#endif /* CONFIG_PROC_FS */
198 struct list_head bond_list; 204 struct list_head bond_list;
199 struct dev_mc_list *mc_list; 205 struct dev_mc_list *mc_list;
206 int (*xmit_hash_policy)(struct sk_buff *, struct net_device *, int);
207 u32 master_ip;
200 u16 flags; 208 u16 flags;
201 struct ad_bond_info ad_info; 209 struct ad_bond_info ad_info;
202 struct alb_bond_info alb_info; 210 struct alb_bond_info alb_info;
203 struct bond_params params; 211 struct bond_params params;
204 struct list_head vlan_list; 212 struct list_head vlan_list;
205 struct vlan_group *vlgrp; 213 struct vlan_group *vlgrp;
214 /* the features the bonding device supports, independently
215 * of any slaves */
216 int bond_features;
206}; 217};
207 218
208/** 219/**
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 5c5f540da26a..b780307093eb 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -174,6 +174,13 @@ static unsigned int cs8900_irq_map[] = {1,0,0,0};
174#include <asm/irq.h> 174#include <asm/irq.h>
175static unsigned int netcard_portlist[] __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0}; 175static unsigned int netcard_portlist[] __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0};
176static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0}; 176static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0};
177#elif defined(CONFIG_ARCH_PNX0105)
178#include <asm/irq.h>
179#include <asm/arch/gpio.h>
180#define CIRRUS_DEFAULT_BASE IO_ADDRESS(EXT_STATIC2_s0_BASE + 0x200000) /* = Physical address 0x48200000 */
181#define CIRRUS_DEFAULT_IRQ VH_INTC_INT_NUM_CASCADED_INTERRUPT_1 /* Event inputs bank 1 - ID 35/bit 3 */
182static unsigned int netcard_portlist[] __initdata = {CIRRUS_DEFAULT_BASE, 0};
183static unsigned int cs8900_irq_map[] = {CIRRUS_DEFAULT_IRQ, 0, 0, 0};
177#else 184#else
178static unsigned int netcard_portlist[] __initdata = 185static unsigned int netcard_portlist[] __initdata =
179 { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; 186 { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
@@ -319,13 +326,7 @@ struct net_device * __init cs89x0_probe(int unit)
319 } 326 }
320 if (err) 327 if (err)
321 goto out; 328 goto out;
322 err = register_netdev(dev);
323 if (err)
324 goto out1;
325 return dev; 329 return dev;
326out1:
327 outw(PP_ChipID, dev->base_addr + ADD_PORT);
328 release_region(dev->base_addr, NETCARD_IO_EXTENT);
329out: 330out:
330 free_netdev(dev); 331 free_netdev(dev);
331 printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected. Be sure to disable PnP with SETUP\n"); 332 printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected. Be sure to disable PnP with SETUP\n");
@@ -416,6 +417,7 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
416 struct net_local *lp = netdev_priv(dev); 417 struct net_local *lp = netdev_priv(dev);
417 static unsigned version_printed; 418 static unsigned version_printed;
418 int i; 419 int i;
420 int tmp;
419 unsigned rev_type = 0; 421 unsigned rev_type = 0;
420 int eeprom_buff[CHKSUM_LEN]; 422 int eeprom_buff[CHKSUM_LEN];
421 int retval; 423 int retval;
@@ -437,6 +439,30 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
437#endif 439#endif
438 } 440 }
439 441
442#ifdef CONFIG_ARCH_PNX0105
443 initialize_ebi();
444
445 /* Map GPIO registers for the pins connected to the CS8900a. */
446 if (map_cirrus_gpio() < 0)
447 return -ENODEV;
448
449 reset_cirrus();
450
451 /* Map event-router registers. */
452 if (map_event_router() < 0)
453 return -ENODEV;
454
455 enable_cirrus_irq();
456
457 unmap_cirrus_gpio();
458 unmap_event_router();
459
460 dev->base_addr = ioaddr;
461
462 for (i = 0 ; i < 3 ; i++)
463 readreg(dev, 0);
464#endif
465
440 /* Grab the region so we can find another board if autoIRQ fails. */ 466 /* Grab the region so we can find another board if autoIRQ fails. */
441 /* WTF is going on here? */ 467 /* WTF is going on here? */
442 if (!request_region(ioaddr & ~3, NETCARD_IO_EXTENT, DRV_NAME)) { 468 if (!request_region(ioaddr & ~3, NETCARD_IO_EXTENT, DRV_NAME)) {
@@ -467,14 +493,17 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
467 goto out2; 493 goto out2;
468 } 494 }
469 } 495 }
470printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT)); 496 printk(KERN_DEBUG "PP_addr at %x: 0x%x\n",
497 ioaddr + ADD_PORT, inw(ioaddr + ADD_PORT));
471 498
472 ioaddr &= ~3; 499 ioaddr &= ~3;
473 outw(PP_ChipID, ioaddr + ADD_PORT); 500 outw(PP_ChipID, ioaddr + ADD_PORT);
474 501
475 if (inw(ioaddr + DATA_PORT) != CHIP_EISA_ID_SIG) { 502 tmp = inw(ioaddr + DATA_PORT);
476 printk(KERN_ERR "%s: incorrect signature 0x%x\n", 503 if (tmp != CHIP_EISA_ID_SIG) {
477 dev->name, inw(ioaddr + DATA_PORT)); 504 printk(KERN_DEBUG "%s: incorrect signature at %x: 0x%x!="
505 CHIP_EISA_ID_SIG_STR "\n",
506 dev->name, ioaddr + DATA_PORT, tmp);
478 retval = -ENODEV; 507 retval = -ENODEV;
479 goto out2; 508 goto out2;
480 } 509 }
@@ -678,7 +707,7 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
678 } else { 707 } else {
679 i = lp->isa_config & INT_NO_MASK; 708 i = lp->isa_config & INT_NO_MASK;
680 if (lp->chip_type == CS8900) { 709 if (lp->chip_type == CS8900) {
681#ifdef CONFIG_ARCH_IXDP2X01 710#if defined(CONFIG_ARCH_IXDP2X01) || defined(CONFIG_ARCH_PNX0105)
682 i = cs8900_irq_map[0]; 711 i = cs8900_irq_map[0];
683#else 712#else
684 /* Translate the IRQ using the IRQ mapping table. */ 713 /* Translate the IRQ using the IRQ mapping table. */
@@ -735,7 +764,13 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
735 printk("\n"); 764 printk("\n");
736 if (net_debug) 765 if (net_debug)
737 printk("cs89x0_probe1() successful\n"); 766 printk("cs89x0_probe1() successful\n");
767
768 retval = register_netdev(dev);
769 if (retval)
770 goto out3;
738 return 0; 771 return 0;
772out3:
773 outw(PP_ChipID, dev->base_addr + ADD_PORT);
739out2: 774out2:
740 release_region(ioaddr & ~3, NETCARD_IO_EXTENT); 775 release_region(ioaddr & ~3, NETCARD_IO_EXTENT);
741out1: 776out1:
@@ -1145,7 +1180,7 @@ net_open(struct net_device *dev)
1145 int i; 1180 int i;
1146 int ret; 1181 int ret;
1147 1182
1148#ifndef CONFIG_SH_HICOSH4 /* uses irq#1, so this won't work */ 1183#if !defined(CONFIG_SH_HICOSH4) && !defined(CONFIG_ARCH_PNX0105) /* uses irq#1, so this won't work */
1149 if (dev->irq < 2) { 1184 if (dev->irq < 2) {
1150 /* Allow interrupts to be generated by the chip */ 1185 /* Allow interrupts to be generated by the chip */
1151/* Cirrus' release had this: */ 1186/* Cirrus' release had this: */
@@ -1176,7 +1211,7 @@ net_open(struct net_device *dev)
1176 else 1211 else
1177#endif 1212#endif
1178 { 1213 {
1179#ifndef CONFIG_ARCH_IXDP2X01 1214#if !defined(CONFIG_ARCH_IXDP2X01) && !defined(CONFIG_ARCH_PNX0105)
1180 if (((1 << dev->irq) & lp->irq_map) == 0) { 1215 if (((1 << dev->irq) & lp->irq_map) == 0) {
1181 printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", 1216 printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n",
1182 dev->name, dev->irq, lp->irq_map); 1217 dev->name, dev->irq, lp->irq_map);
@@ -1261,6 +1296,9 @@ net_open(struct net_device *dev)
1261 case A_CNF_MEDIA_10B_2: result = lp->adapter_cnf & A_CNF_10B_2; break; 1296 case A_CNF_MEDIA_10B_2: result = lp->adapter_cnf & A_CNF_10B_2; break;
1262 default: result = lp->adapter_cnf & (A_CNF_10B_T | A_CNF_AUI | A_CNF_10B_2); 1297 default: result = lp->adapter_cnf & (A_CNF_10B_T | A_CNF_AUI | A_CNF_10B_2);
1263 } 1298 }
1299#ifdef CONFIG_ARCH_PNX0105
1300 result = A_CNF_10B_T;
1301#endif
1264 if (!result) { 1302 if (!result) {
1265 printk(KERN_ERR "%s: EEPROM is configured for unavailable media\n", dev->name); 1303 printk(KERN_ERR "%s: EEPROM is configured for unavailable media\n", dev->name);
1266 release_irq: 1304 release_irq:
@@ -1416,6 +1454,7 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
1416 /* Write the contents of the packet */ 1454 /* Write the contents of the packet */
1417 outsw(dev->base_addr + TX_FRAME_PORT,skb->data,(skb->len+1) >>1); 1455 outsw(dev->base_addr + TX_FRAME_PORT,skb->data,(skb->len+1) >>1);
1418 spin_unlock_irq(&lp->lock); 1456 spin_unlock_irq(&lp->lock);
1457 lp->stats.tx_bytes += skb->len;
1419 dev->trans_start = jiffies; 1458 dev->trans_start = jiffies;
1420 dev_kfree_skb (skb); 1459 dev_kfree_skb (skb);
1421 1460
@@ -1831,13 +1870,6 @@ init_module(void)
1831 if (ret) 1870 if (ret)
1832 goto out; 1871 goto out;
1833 1872
1834 if (register_netdev(dev) != 0) {
1835 printk(KERN_ERR "cs89x0.c: No card found at 0x%x\n", io);
1836 ret = -ENXIO;
1837 outw(PP_ChipID, dev->base_addr + ADD_PORT);
1838 release_region(dev->base_addr, NETCARD_IO_EXTENT);
1839 goto out;
1840 }
1841 dev_cs89x0 = dev; 1873 dev_cs89x0 = dev;
1842 return 0; 1874 return 0;
1843out: 1875out:
diff --git a/drivers/net/cs89x0.h b/drivers/net/cs89x0.h
index b0ef7ad2baad..decea264f121 100644
--- a/drivers/net/cs89x0.h
+++ b/drivers/net/cs89x0.h
@@ -16,7 +16,7 @@
16 16
17#include <linux/config.h> 17#include <linux/config.h>
18 18
19#ifdef CONFIG_ARCH_IXDP2X01 19#if defined(CONFIG_ARCH_IXDP2X01) || defined(CONFIG_ARCH_PNX0105)
20/* IXDP2401/IXDP2801 uses dword-aligned register addressing */ 20/* IXDP2401/IXDP2801 uses dword-aligned register addressing */
21#define CS89x0_PORT(reg) ((reg) * 2) 21#define CS89x0_PORT(reg) ((reg) * 2)
22#else 22#else
@@ -93,6 +93,7 @@
93#endif 93#endif
94 94
95#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */ 95#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */
96#define CHIP_EISA_ID_SIG_STR "0x630E"
96 97
97#ifdef IBMEIPKT 98#ifdef IBMEIPKT
98#define EISA_ID_SIG 0x4D24 /* IBM */ 99#define EISA_ID_SIG 0x4D24 /* IBM */
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index a6aa56598f27..5acd35c312ac 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -191,6 +191,7 @@
191 * Feb 2001 davej PCI enable cleanups. 191 * Feb 2001 davej PCI enable cleanups.
192 * 04 Aug 2003 macro Converted to the DMA API. 192 * 04 Aug 2003 macro Converted to the DMA API.
193 * 14 Aug 2004 macro Fix device names reported. 193 * 14 Aug 2004 macro Fix device names reported.
194 * 14 Jun 2005 macro Use irqreturn_t.
194 */ 195 */
195 196
196/* Include files */ 197/* Include files */
@@ -217,8 +218,8 @@
217 218
218/* Version information string should be updated prior to each new release! */ 219/* Version information string should be updated prior to each new release! */
219#define DRV_NAME "defxx" 220#define DRV_NAME "defxx"
220#define DRV_VERSION "v1.07" 221#define DRV_VERSION "v1.08"
221#define DRV_RELDATE "2004/08/14" 222#define DRV_RELDATE "2005/06/14"
222 223
223static char version[] __devinitdata = 224static char version[] __devinitdata =
224 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE 225 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
@@ -247,7 +248,8 @@ static int dfx_close(struct net_device *dev);
247static void dfx_int_pr_halt_id(DFX_board_t *bp); 248static void dfx_int_pr_halt_id(DFX_board_t *bp);
248static void dfx_int_type_0_process(DFX_board_t *bp); 249static void dfx_int_type_0_process(DFX_board_t *bp);
249static void dfx_int_common(struct net_device *dev); 250static void dfx_int_common(struct net_device *dev);
250static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs); 251static irqreturn_t dfx_interrupt(int irq, void *dev_id,
252 struct pt_regs *regs);
251 253
252static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev); 254static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev);
253static void dfx_ctl_set_multicast_list(struct net_device *dev); 255static void dfx_ctl_set_multicast_list(struct net_device *dev);
@@ -437,7 +439,8 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
437 } 439 }
438 440
439 SET_MODULE_OWNER(dev); 441 SET_MODULE_OWNER(dev);
440 SET_NETDEV_DEV(dev, &pdev->dev); 442 if (pdev != NULL)
443 SET_NETDEV_DEV(dev, &pdev->dev);
441 444
442 bp = dev->priv; 445 bp = dev->priv;
443 446
@@ -1225,7 +1228,7 @@ static int dfx_open(struct net_device *dev)
1225 1228
1226 /* Register IRQ - support shared interrupts by passing device ptr */ 1229 /* Register IRQ - support shared interrupts by passing device ptr */
1227 1230
1228 ret = request_irq(dev->irq, (void *)dfx_interrupt, SA_SHIRQ, dev->name, dev); 1231 ret = request_irq(dev->irq, dfx_interrupt, SA_SHIRQ, dev->name, dev);
1229 if (ret) { 1232 if (ret) {
1230 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq); 1233 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
1231 return ret; 1234 return ret;
@@ -1680,13 +1683,13 @@ static void dfx_int_common(struct net_device *dev)
1680 * ================= 1683 * =================
1681 * = dfx_interrupt = 1684 * = dfx_interrupt =
1682 * ================= 1685 * =================
1683 * 1686 *
1684 * Overview: 1687 * Overview:
1685 * Interrupt processing routine 1688 * Interrupt processing routine
1686 * 1689 *
1687 * Returns: 1690 * Returns:
1688 * None 1691 * Whether a valid interrupt was seen.
1689 * 1692 *
1690 * Arguments: 1693 * Arguments:
1691 * irq - interrupt vector 1694 * irq - interrupt vector
1692 * dev_id - pointer to device information 1695 * dev_id - pointer to device information
@@ -1699,7 +1702,8 @@ static void dfx_int_common(struct net_device *dev)
1699 * structure context. 1702 * structure context.
1700 * 1703 *
1701 * Return Codes: 1704 * Return Codes:
1702 * None 1705 * IRQ_HANDLED - an IRQ was handled.
1706 * IRQ_NONE - no IRQ was handled.
1703 * 1707 *
1704 * Assumptions: 1708 * Assumptions:
1705 * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC 1709 * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC
@@ -1712,60 +1716,70 @@ static void dfx_int_common(struct net_device *dev)
1712 * Interrupts are disabled, then reenabled at the adapter. 1716 * Interrupts are disabled, then reenabled at the adapter.
1713 */ 1717 */
1714 1718
1715static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1719static irqreturn_t dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1716 { 1720{
1717 struct net_device *dev = dev_id; 1721 struct net_device *dev = dev_id;
1718 DFX_board_t *bp; /* private board structure pointer */ 1722 DFX_board_t *bp; /* private board structure pointer */
1719 u8 tmp; /* used for disabling/enabling ints */
1720 1723
1721 /* Get board pointer only if device structure is valid */ 1724 /* Get board pointer only if device structure is valid */
1722 1725
1723 bp = dev->priv; 1726 bp = dev->priv;
1724 1727
1725 spin_lock(&bp->lock);
1726
1727 /* See if we're already servicing an interrupt */ 1728 /* See if we're already servicing an interrupt */
1728 1729
1729 /* Service adapter interrupts */ 1730 /* Service adapter interrupts */
1730 1731
1731 if (bp->bus_type == DFX_BUS_TYPE_PCI) 1732 if (bp->bus_type == DFX_BUS_TYPE_PCI) {
1732 { 1733 u32 status;
1733 /* Disable PDQ-PFI interrupts at PFI */
1734 1734
1735 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, PFI_MODE_M_DMA_ENB); 1735 dfx_port_read_long(bp, PFI_K_REG_STATUS, &status);
1736 if (!(status & PFI_STATUS_M_PDQ_INT))
1737 return IRQ_NONE;
1736 1738
1737 /* Call interrupt service routine for this adapter */ 1739 spin_lock(&bp->lock);
1740
1741 /* Disable PDQ-PFI interrupts at PFI */
1742 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
1743 PFI_MODE_M_DMA_ENB);
1738 1744
1745 /* Call interrupt service routine for this adapter */
1739 dfx_int_common(dev); 1746 dfx_int_common(dev);
1740 1747
1741 /* Clear PDQ interrupt status bit and reenable interrupts */ 1748 /* Clear PDQ interrupt status bit and reenable interrupts */
1742 1749 dfx_port_write_long(bp, PFI_K_REG_STATUS,
1743 dfx_port_write_long(bp, PFI_K_REG_STATUS, PFI_STATUS_M_PDQ_INT); 1750 PFI_STATUS_M_PDQ_INT);
1744 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, 1751 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
1745 (PFI_MODE_M_PDQ_INT_ENB + PFI_MODE_M_DMA_ENB)); 1752 (PFI_MODE_M_PDQ_INT_ENB |
1746 } 1753 PFI_MODE_M_DMA_ENB));
1747 else
1748 {
1749 /* Disable interrupts at the ESIC */
1750 1754
1751 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp); 1755 spin_unlock(&bp->lock);
1752 tmp &= ~PI_CONFIG_STAT_0_M_INT_ENB; 1756 } else {
1753 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp); 1757 u8 status;
1754 1758
1755 /* Call interrupt service routine for this adapter */ 1759 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status);
1760 if (!(status & PI_CONFIG_STAT_0_M_PEND))
1761 return IRQ_NONE;
1756 1762
1763 spin_lock(&bp->lock);
1764
1765 /* Disable interrupts at the ESIC */
1766 status &= ~PI_CONFIG_STAT_0_M_INT_ENB;
1767 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status);
1768
1769 /* Call interrupt service routine for this adapter */
1757 dfx_int_common(dev); 1770 dfx_int_common(dev);
1758 1771
1759 /* Reenable interrupts at the ESIC */ 1772 /* Reenable interrupts at the ESIC */
1773 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status);
1774 status |= PI_CONFIG_STAT_0_M_INT_ENB;
1775 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status);
1760 1776
1761 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp); 1777 spin_unlock(&bp->lock);
1762 tmp |= PI_CONFIG_STAT_0_M_INT_ENB;
1763 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);
1764 }
1765
1766 spin_unlock(&bp->lock);
1767 } 1778 }
1768 1779
1780 return IRQ_HANDLED;
1781}
1782
1769 1783
1770/* 1784/*
1771 * ===================== 1785 * =====================
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index aa42b7a27735..430c628279b3 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -547,7 +547,7 @@ rio_timer (unsigned long data)
547 skb_reserve (skb, 2); 547 skb_reserve (skb, 2);
548 np->rx_ring[entry].fraginfo = 548 np->rx_ring[entry].fraginfo =
549 cpu_to_le64 (pci_map_single 549 cpu_to_le64 (pci_map_single
550 (np->pdev, skb->tail, np->rx_buf_sz, 550 (np->pdev, skb->data, np->rx_buf_sz,
551 PCI_DMA_FROMDEVICE)); 551 PCI_DMA_FROMDEVICE));
552 } 552 }
553 np->rx_ring[entry].fraginfo |= 553 np->rx_ring[entry].fraginfo |=
@@ -618,7 +618,7 @@ alloc_list (struct net_device *dev)
618 /* Rubicon now supports 40 bits of addressing space. */ 618 /* Rubicon now supports 40 bits of addressing space. */
619 np->rx_ring[i].fraginfo = 619 np->rx_ring[i].fraginfo =
620 cpu_to_le64 ( pci_map_single ( 620 cpu_to_le64 ( pci_map_single (
621 np->pdev, skb->tail, np->rx_buf_sz, 621 np->pdev, skb->data, np->rx_buf_sz,
622 PCI_DMA_FROMDEVICE)); 622 PCI_DMA_FROMDEVICE));
623 np->rx_ring[i].fraginfo |= cpu_to_le64 (np->rx_buf_sz) << 48; 623 np->rx_ring[i].fraginfo |= cpu_to_le64 (np->rx_buf_sz) << 48;
624 } 624 }
@@ -906,7 +906,7 @@ receive_packet (struct net_device *dev)
906 /* 16 byte align the IP header */ 906 /* 16 byte align the IP header */
907 skb_reserve (skb, 2); 907 skb_reserve (skb, 2);
908 eth_copy_and_sum (skb, 908 eth_copy_and_sum (skb,
909 np->rx_skbuff[entry]->tail, 909 np->rx_skbuff[entry]->data,
910 pkt_len, 0); 910 pkt_len, 0);
911 skb_put (skb, pkt_len); 911 skb_put (skb, pkt_len);
912 pci_dma_sync_single_for_device(np->pdev, 912 pci_dma_sync_single_for_device(np->pdev,
@@ -950,7 +950,7 @@ receive_packet (struct net_device *dev)
950 skb_reserve (skb, 2); 950 skb_reserve (skb, 2);
951 np->rx_ring[entry].fraginfo = 951 np->rx_ring[entry].fraginfo =
952 cpu_to_le64 (pci_map_single 952 cpu_to_le64 (pci_map_single
953 (np->pdev, skb->tail, np->rx_buf_sz, 953 (np->pdev, skb->data, np->rx_buf_sz,
954 PCI_DMA_FROMDEVICE)); 954 PCI_DMA_FROMDEVICE));
955 } 955 }
956 np->rx_ring[entry].fraginfo |= 956 np->rx_ring[entry].fraginfo |=
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index f4ba0ffb8637..6440a892bb81 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -48,6 +48,10 @@
48 * net_device_stats 48 * net_device_stats
49 * * introduced tx_timeout function 49 * * introduced tx_timeout function
50 * * reworked locking 50 * * reworked locking
51 *
52 * 01-Jul-2005 Ben Dooks <ben@simtec.co.uk>
53 * * fixed spinlock call without pointer
54 * * ensure spinlock is initialised
51 */ 55 */
52 56
53#include <linux/module.h> 57#include <linux/module.h>
@@ -148,7 +152,6 @@ static int dm9000_probe(struct device *);
148static int dm9000_open(struct net_device *); 152static int dm9000_open(struct net_device *);
149static int dm9000_start_xmit(struct sk_buff *, struct net_device *); 153static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
150static int dm9000_stop(struct net_device *); 154static int dm9000_stop(struct net_device *);
151static int dm9000_do_ioctl(struct net_device *, struct ifreq *, int);
152 155
153 156
154static void dm9000_timer(unsigned long); 157static void dm9000_timer(unsigned long);
@@ -224,7 +227,7 @@ static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
224 227
225static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count) 228static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
226{ 229{
227 readsb(reg, data, count+1); 230 readsb(reg, data, count);
228} 231}
229 232
230 233
@@ -322,7 +325,7 @@ static void dm9000_timeout(struct net_device *dev)
322 325
323 /* Save previous register address */ 326 /* Save previous register address */
324 reg_save = readb(db->io_addr); 327 reg_save = readb(db->io_addr);
325 spin_lock_irqsave(db->lock,flags); 328 spin_lock_irqsave(&db->lock,flags);
326 329
327 netif_stop_queue(dev); 330 netif_stop_queue(dev);
328 dm9000_reset(db); 331 dm9000_reset(db);
@@ -333,7 +336,7 @@ static void dm9000_timeout(struct net_device *dev)
333 336
334 /* Restore previous register address */ 337 /* Restore previous register address */
335 writeb(reg_save, db->io_addr); 338 writeb(reg_save, db->io_addr);
336 spin_unlock_irqrestore(db->lock,flags); 339 spin_unlock_irqrestore(&db->lock,flags);
337} 340}
338 341
339 342
@@ -364,7 +367,7 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db)
364 } 367 }
365 368
366 if (db->addr_res != NULL) { 369 if (db->addr_res != NULL) {
367 release_resource(db->data_req); 370 release_resource(db->addr_res);
368 kfree(db->addr_req); 371 kfree(db->addr_req);
369 } 372 }
370} 373}
@@ -387,8 +390,6 @@ dm9000_probe(struct device *dev)
387 int i; 390 int i;
388 u32 id_val; 391 u32 id_val;
389 392
390 printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME);
391
392 /* Init network device */ 393 /* Init network device */
393 ndev = alloc_etherdev(sizeof (struct board_info)); 394 ndev = alloc_etherdev(sizeof (struct board_info));
394 if (!ndev) { 395 if (!ndev) {
@@ -405,6 +406,8 @@ dm9000_probe(struct device *dev)
405 db = (struct board_info *) ndev->priv; 406 db = (struct board_info *) ndev->priv;
406 memset(db, 0, sizeof (*db)); 407 memset(db, 0, sizeof (*db));
407 408
409 spin_lock_init(&db->lock);
410
408 if (pdev->num_resources < 2) { 411 if (pdev->num_resources < 2) {
409 ret = -ENODEV; 412 ret = -ENODEV;
410 goto out; 413 goto out;
@@ -541,7 +544,6 @@ dm9000_probe(struct device *dev)
541 ndev->stop = &dm9000_stop; 544 ndev->stop = &dm9000_stop;
542 ndev->get_stats = &dm9000_get_stats; 545 ndev->get_stats = &dm9000_get_stats;
543 ndev->set_multicast_list = &dm9000_hash_table; 546 ndev->set_multicast_list = &dm9000_hash_table;
544 ndev->do_ioctl = &dm9000_do_ioctl;
545 547
546#ifdef DM9000_PROGRAM_EEPROM 548#ifdef DM9000_PROGRAM_EEPROM
547 program_eeprom(db); 549 program_eeprom(db);
@@ -612,7 +614,7 @@ dm9000_open(struct net_device *dev)
612 614
613 /* set and active a timer process */ 615 /* set and active a timer process */
614 init_timer(&db->timer); 616 init_timer(&db->timer);
615 db->timer.expires = DM9000_TIMER_WUT * 2; 617 db->timer.expires = DM9000_TIMER_WUT;
616 db->timer.data = (unsigned long) dev; 618 db->timer.data = (unsigned long) dev;
617 db->timer.function = &dm9000_timer; 619 db->timer.function = &dm9000_timer;
618 add_timer(&db->timer); 620 add_timer(&db->timer);
@@ -845,15 +847,6 @@ dm9000_get_stats(struct net_device *dev)
845 return &db->stats; 847 return &db->stats;
846} 848}
847 849
848/*
849 * Process the upper socket ioctl command
850 */
851static int
852dm9000_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
853{
854 PRINTK1("entering %s\n",__FUNCTION__);
855 return 0;
856}
857 850
858/* 851/*
859 * A periodic timer routine 852 * A periodic timer routine
@@ -864,21 +857,11 @@ dm9000_timer(unsigned long data)
864{ 857{
865 struct net_device *dev = (struct net_device *) data; 858 struct net_device *dev = (struct net_device *) data;
866 board_info_t *db = (board_info_t *) dev->priv; 859 board_info_t *db = (board_info_t *) dev->priv;
867 u8 reg_save;
868 unsigned long flags;
869 860
870 PRINTK3("dm9000_timer()\n"); 861 PRINTK3("dm9000_timer()\n");
871 862
872 spin_lock_irqsave(db->lock,flags);
873 /* Save previous register address */
874 reg_save = readb(db->io_addr);
875
876 mii_check_media(&db->mii, netif_msg_link(db), 0); 863 mii_check_media(&db->mii, netif_msg_link(db), 0);
877 864
878 /* Restore previous register address */
879 writeb(reg_save, db->io_addr);
880 spin_unlock_irqrestore(db->lock,flags);
881
882 /* Set timer again */ 865 /* Set timer again */
883 db->timer.expires = DM9000_TIMER_WUT; 866 db->timer.expires = DM9000_TIMER_WUT;
884 add_timer(&db->timer); 867 add_timer(&db->timer);
@@ -1098,9 +1081,14 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1098{ 1081{
1099 board_info_t *db = (board_info_t *) dev->priv; 1082 board_info_t *db = (board_info_t *) dev->priv;
1100 unsigned long flags; 1083 unsigned long flags;
1084 unsigned int reg_save;
1101 int ret; 1085 int ret;
1102 1086
1103 spin_lock_irqsave(&db->lock,flags); 1087 spin_lock_irqsave(&db->lock,flags);
1088
1089 /* Save previous register address */
1090 reg_save = readb(db->io_addr);
1091
1104 /* Fill the phyxcer register into REG_0C */ 1092 /* Fill the phyxcer register into REG_0C */
1105 iow(db, DM9000_EPAR, DM9000_PHY | reg); 1093 iow(db, DM9000_EPAR, DM9000_PHY | reg);
1106 1094
@@ -1111,6 +1099,9 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1111 /* The read data keeps on REG_0D & REG_0E */ 1099 /* The read data keeps on REG_0D & REG_0E */
1112 ret = (ior(db, DM9000_EPDRH) << 8) | ior(db, DM9000_EPDRL); 1100 ret = (ior(db, DM9000_EPDRH) << 8) | ior(db, DM9000_EPDRL);
1113 1101
1102 /* restore the previous address */
1103 writeb(reg_save, db->io_addr);
1104
1114 spin_unlock_irqrestore(&db->lock,flags); 1105 spin_unlock_irqrestore(&db->lock,flags);
1115 1106
1116 return ret; 1107 return ret;
@@ -1124,9 +1115,13 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1124{ 1115{
1125 board_info_t *db = (board_info_t *) dev->priv; 1116 board_info_t *db = (board_info_t *) dev->priv;
1126 unsigned long flags; 1117 unsigned long flags;
1118 unsigned long reg_save;
1127 1119
1128 spin_lock_irqsave(&db->lock,flags); 1120 spin_lock_irqsave(&db->lock,flags);
1129 1121
1122 /* Save previous register address */
1123 reg_save = readb(db->io_addr);
1124
1130 /* Fill the phyxcer register into REG_0C */ 1125 /* Fill the phyxcer register into REG_0C */
1131 iow(db, DM9000_EPAR, DM9000_PHY | reg); 1126 iow(db, DM9000_EPAR, DM9000_PHY | reg);
1132 1127
@@ -1138,6 +1133,9 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1138 udelay(500); /* Wait write complete */ 1133 udelay(500); /* Wait write complete */
1139 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */ 1134 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */
1140 1135
1136 /* restore the previous address */
1137 writeb(reg_save, db->io_addr);
1138
1141 spin_unlock_irqrestore(&db->lock,flags); 1139 spin_unlock_irqrestore(&db->lock,flags);
1142} 1140}
1143 1141
@@ -1202,6 +1200,8 @@ static struct device_driver dm9000_driver = {
1202static int __init 1200static int __init
1203dm9000_init(void) 1201dm9000_init(void)
1204{ 1202{
1203 printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME);
1204
1205 return driver_register(&dm9000_driver); /* search board and register */ 1205 return driver_register(&dm9000_driver); /* search board and register */
1206} 1206}
1207 1207
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 4a47df5a9ff9..d0fa2448761d 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -143,6 +143,7 @@
143#include <linux/delay.h> 143#include <linux/delay.h>
144#include <linux/init.h> 144#include <linux/init.h>
145#include <linux/pci.h> 145#include <linux/pci.h>
146#include <linux/dma-mapping.h>
146#include <linux/netdevice.h> 147#include <linux/netdevice.h>
147#include <linux/etherdevice.h> 148#include <linux/etherdevice.h>
148#include <linux/mii.h> 149#include <linux/mii.h>
@@ -1092,11 +1093,16 @@ static int e100_phy_init(struct nic *nic)
1092 } 1093 }
1093 1094
1094 if((nic->mac >= mac_82550_D102) || ((nic->flags & ich) && 1095 if((nic->mac >= mac_82550_D102) || ((nic->flags & ich) &&
1095 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) && 1096 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000))) {
1096 (nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) 1097 /* enable/disable MDI/MDI-X auto-switching.
1097 /* enable/disable MDI/MDI-X auto-switching */ 1098 MDI/MDI-X auto-switching is disabled for 82551ER/QM chips */
1098 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, 1099 if((nic->mac == mac_82551_E) || (nic->mac == mac_82551_F) ||
1099 nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH); 1100 (nic->mac == mac_82551_10) || (nic->mii.force_media) ||
1101 !(nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))
1102 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, 0);
1103 else
1104 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, NCONFIG_AUTO_SWITCH);
1105 }
1100 1106
1101 return 0; 1107 return 0;
1102} 1108}
@@ -1665,8 +1671,10 @@ static irqreturn_t e100_intr(int irq, void *dev_id, struct pt_regs *regs)
1665 if(stat_ack & stat_ack_rnr) 1671 if(stat_ack & stat_ack_rnr)
1666 nic->ru_running = RU_SUSPENDED; 1672 nic->ru_running = RU_SUSPENDED;
1667 1673
1668 e100_disable_irq(nic); 1674 if(likely(netif_rx_schedule_prep(netdev))) {
1669 netif_rx_schedule(netdev); 1675 e100_disable_irq(nic);
1676 __netif_rx_schedule(netdev);
1677 }
1670 1678
1671 return IRQ_HANDLED; 1679 return IRQ_HANDLED;
1672} 1680}
@@ -2286,7 +2294,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2286 goto err_out_disable_pdev; 2294 goto err_out_disable_pdev;
2287 } 2295 }
2288 2296
2289 if((err = pci_set_dma_mask(pdev, 0xFFFFFFFFULL))) { 2297 if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
2290 DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n"); 2298 DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n");
2291 goto err_out_free_res; 2299 goto err_out_free_res;
2292 } 2300 }
@@ -2334,11 +2342,11 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2334 goto err_out_iounmap; 2342 goto err_out_iounmap;
2335 } 2343 }
2336 2344
2337 e100_phy_init(nic);
2338
2339 if((err = e100_eeprom_load(nic))) 2345 if((err = e100_eeprom_load(nic)))
2340 goto err_out_free; 2346 goto err_out_free;
2341 2347
2348 e100_phy_init(nic);
2349
2342 memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN); 2350 memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN);
2343 if(!is_valid_ether_addr(netdev->dev_addr)) { 2351 if(!is_valid_ether_addr(netdev->dev_addr)) {
2344 DPRINTK(PROBE, ERR, "Invalid MAC address from " 2352 DPRINTK(PROBE, ERR, "Invalid MAC address from "
@@ -2439,9 +2447,8 @@ static int e100_resume(struct pci_dev *pdev)
2439#endif 2447#endif
2440 2448
2441 2449
2442static void e100_shutdown(struct device *dev) 2450static void e100_shutdown(struct pci_dev *pdev)
2443{ 2451{
2444 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
2445 struct net_device *netdev = pci_get_drvdata(pdev); 2452 struct net_device *netdev = pci_get_drvdata(pdev);
2446 struct nic *nic = netdev_priv(netdev); 2453 struct nic *nic = netdev_priv(netdev);
2447 2454
@@ -2462,11 +2469,7 @@ static struct pci_driver e100_driver = {
2462 .suspend = e100_suspend, 2469 .suspend = e100_suspend,
2463 .resume = e100_resume, 2470 .resume = e100_resume,
2464#endif 2471#endif
2465 2472 .shutdown = e100_shutdown,
2466 .driver = {
2467 .shutdown = e100_shutdown,
2468 }
2469
2470}; 2473};
2471 2474
2472static int __init e100_init_module(void) 2475static int __init e100_init_module(void)
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index af1e82c5b808..092757bc721f 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -140,7 +140,7 @@ struct e1000_adapter;
140#define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */ 140#define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
141 141
142#define AUTO_ALL_MODES 0 142#define AUTO_ALL_MODES 0
143#define E1000_EEPROM_82544_APM 0x0400 143#define E1000_EEPROM_82544_APM 0x0004
144#define E1000_EEPROM_APME 0x0400 144#define E1000_EEPROM_APME 0x0400
145 145
146#ifndef E1000_MASTER_SLAVE 146#ifndef E1000_MASTER_SLAVE
@@ -159,7 +159,7 @@ struct e1000_adapter;
159 * so a DMA handle can be stored along with the buffer */ 159 * so a DMA handle can be stored along with the buffer */
160struct e1000_buffer { 160struct e1000_buffer {
161 struct sk_buff *skb; 161 struct sk_buff *skb;
162 uint64_t dma; 162 dma_addr_t dma;
163 unsigned long time_stamp; 163 unsigned long time_stamp;
164 uint16_t length; 164 uint16_t length;
165 uint16_t next_to_watch; 165 uint16_t next_to_watch;
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 237247f74df4..f133ff0b0b94 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -105,7 +105,7 @@ static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
105static int 105static int
106e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 106e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
107{ 107{
108 struct e1000_adapter *adapter = netdev->priv; 108 struct e1000_adapter *adapter = netdev_priv(netdev);
109 struct e1000_hw *hw = &adapter->hw; 109 struct e1000_hw *hw = &adapter->hw;
110 110
111 if(hw->media_type == e1000_media_type_copper) { 111 if(hw->media_type == e1000_media_type_copper) {
@@ -141,9 +141,9 @@ e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
141 SUPPORTED_FIBRE | 141 SUPPORTED_FIBRE |
142 SUPPORTED_Autoneg); 142 SUPPORTED_Autoneg);
143 143
144 ecmd->advertising = (SUPPORTED_1000baseT_Full | 144 ecmd->advertising = (ADVERTISED_1000baseT_Full |
145 SUPPORTED_FIBRE | 145 ADVERTISED_FIBRE |
146 SUPPORTED_Autoneg); 146 ADVERTISED_Autoneg);
147 147
148 ecmd->port = PORT_FIBRE; 148 ecmd->port = PORT_FIBRE;
149 149
@@ -179,13 +179,24 @@ e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
179static int 179static int
180e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 180e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
181{ 181{
182 struct e1000_adapter *adapter = netdev->priv; 182 struct e1000_adapter *adapter = netdev_priv(netdev);
183 struct e1000_hw *hw = &adapter->hw; 183 struct e1000_hw *hw = &adapter->hw;
184 184
185 if(ecmd->autoneg == AUTONEG_ENABLE) { 185 if(ecmd->autoneg == AUTONEG_ENABLE) {
186 hw->autoneg = 1; 186 hw->autoneg = 1;
187 hw->autoneg_advertised = 0x002F; 187 if(hw->media_type == e1000_media_type_fiber)
188 ecmd->advertising = 0x002F; 188 hw->autoneg_advertised = ADVERTISED_1000baseT_Full |
189 ADVERTISED_FIBRE |
190 ADVERTISED_Autoneg;
191 else
192 hw->autoneg_advertised = ADVERTISED_10baseT_Half |
193 ADVERTISED_10baseT_Full |
194 ADVERTISED_100baseT_Half |
195 ADVERTISED_100baseT_Full |
196 ADVERTISED_1000baseT_Full|
197 ADVERTISED_Autoneg |
198 ADVERTISED_TP;
199 ecmd->advertising = hw->autoneg_advertised;
189 } else 200 } else
190 if(e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) 201 if(e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex))
191 return -EINVAL; 202 return -EINVAL;
@@ -206,7 +217,7 @@ static void
206e1000_get_pauseparam(struct net_device *netdev, 217e1000_get_pauseparam(struct net_device *netdev,
207 struct ethtool_pauseparam *pause) 218 struct ethtool_pauseparam *pause)
208{ 219{
209 struct e1000_adapter *adapter = netdev->priv; 220 struct e1000_adapter *adapter = netdev_priv(netdev);
210 struct e1000_hw *hw = &adapter->hw; 221 struct e1000_hw *hw = &adapter->hw;
211 222
212 pause->autoneg = 223 pause->autoneg =
@@ -226,7 +237,7 @@ static int
226e1000_set_pauseparam(struct net_device *netdev, 237e1000_set_pauseparam(struct net_device *netdev,
227 struct ethtool_pauseparam *pause) 238 struct ethtool_pauseparam *pause)
228{ 239{
229 struct e1000_adapter *adapter = netdev->priv; 240 struct e1000_adapter *adapter = netdev_priv(netdev);
230 struct e1000_hw *hw = &adapter->hw; 241 struct e1000_hw *hw = &adapter->hw;
231 242
232 adapter->fc_autoneg = pause->autoneg; 243 adapter->fc_autoneg = pause->autoneg;
@@ -259,14 +270,14 @@ e1000_set_pauseparam(struct net_device *netdev,
259static uint32_t 270static uint32_t
260e1000_get_rx_csum(struct net_device *netdev) 271e1000_get_rx_csum(struct net_device *netdev)
261{ 272{
262 struct e1000_adapter *adapter = netdev->priv; 273 struct e1000_adapter *adapter = netdev_priv(netdev);
263 return adapter->rx_csum; 274 return adapter->rx_csum;
264} 275}
265 276
266static int 277static int
267e1000_set_rx_csum(struct net_device *netdev, uint32_t data) 278e1000_set_rx_csum(struct net_device *netdev, uint32_t data)
268{ 279{
269 struct e1000_adapter *adapter = netdev->priv; 280 struct e1000_adapter *adapter = netdev_priv(netdev);
270 adapter->rx_csum = data; 281 adapter->rx_csum = data;
271 282
272 if(netif_running(netdev)) { 283 if(netif_running(netdev)) {
@@ -286,7 +297,7 @@ e1000_get_tx_csum(struct net_device *netdev)
286static int 297static int
287e1000_set_tx_csum(struct net_device *netdev, uint32_t data) 298e1000_set_tx_csum(struct net_device *netdev, uint32_t data)
288{ 299{
289 struct e1000_adapter *adapter = netdev->priv; 300 struct e1000_adapter *adapter = netdev_priv(netdev);
290 301
291 if(adapter->hw.mac_type < e1000_82543) { 302 if(adapter->hw.mac_type < e1000_82543) {
292 if (!data) 303 if (!data)
@@ -306,8 +317,8 @@ e1000_set_tx_csum(struct net_device *netdev, uint32_t data)
306static int 317static int
307e1000_set_tso(struct net_device *netdev, uint32_t data) 318e1000_set_tso(struct net_device *netdev, uint32_t data)
308{ 319{
309 struct e1000_adapter *adapter = netdev->priv; 320 struct e1000_adapter *adapter = netdev_priv(netdev);
310 if ((adapter->hw.mac_type < e1000_82544) || 321 if((adapter->hw.mac_type < e1000_82544) ||
311 (adapter->hw.mac_type == e1000_82547)) 322 (adapter->hw.mac_type == e1000_82547))
312 return data ? -EINVAL : 0; 323 return data ? -EINVAL : 0;
313 324
@@ -322,14 +333,14 @@ e1000_set_tso(struct net_device *netdev, uint32_t data)
322static uint32_t 333static uint32_t
323e1000_get_msglevel(struct net_device *netdev) 334e1000_get_msglevel(struct net_device *netdev)
324{ 335{
325 struct e1000_adapter *adapter = netdev->priv; 336 struct e1000_adapter *adapter = netdev_priv(netdev);
326 return adapter->msg_enable; 337 return adapter->msg_enable;
327} 338}
328 339
329static void 340static void
330e1000_set_msglevel(struct net_device *netdev, uint32_t data) 341e1000_set_msglevel(struct net_device *netdev, uint32_t data)
331{ 342{
332 struct e1000_adapter *adapter = netdev->priv; 343 struct e1000_adapter *adapter = netdev_priv(netdev);
333 adapter->msg_enable = data; 344 adapter->msg_enable = data;
334} 345}
335 346
@@ -344,7 +355,7 @@ static void
344e1000_get_regs(struct net_device *netdev, 355e1000_get_regs(struct net_device *netdev,
345 struct ethtool_regs *regs, void *p) 356 struct ethtool_regs *regs, void *p)
346{ 357{
347 struct e1000_adapter *adapter = netdev->priv; 358 struct e1000_adapter *adapter = netdev_priv(netdev);
348 struct e1000_hw *hw = &adapter->hw; 359 struct e1000_hw *hw = &adapter->hw;
349 uint32_t *regs_buff = p; 360 uint32_t *regs_buff = p;
350 uint16_t phy_data; 361 uint16_t phy_data;
@@ -432,7 +443,7 @@ e1000_get_regs(struct net_device *netdev,
432static int 443static int
433e1000_get_eeprom_len(struct net_device *netdev) 444e1000_get_eeprom_len(struct net_device *netdev)
434{ 445{
435 struct e1000_adapter *adapter = netdev->priv; 446 struct e1000_adapter *adapter = netdev_priv(netdev);
436 return adapter->hw.eeprom.word_size * 2; 447 return adapter->hw.eeprom.word_size * 2;
437} 448}
438 449
@@ -440,7 +451,7 @@ static int
440e1000_get_eeprom(struct net_device *netdev, 451e1000_get_eeprom(struct net_device *netdev,
441 struct ethtool_eeprom *eeprom, uint8_t *bytes) 452 struct ethtool_eeprom *eeprom, uint8_t *bytes)
442{ 453{
443 struct e1000_adapter *adapter = netdev->priv; 454 struct e1000_adapter *adapter = netdev_priv(netdev);
444 struct e1000_hw *hw = &adapter->hw; 455 struct e1000_hw *hw = &adapter->hw;
445 uint16_t *eeprom_buff; 456 uint16_t *eeprom_buff;
446 int first_word, last_word; 457 int first_word, last_word;
@@ -486,7 +497,7 @@ static int
486e1000_set_eeprom(struct net_device *netdev, 497e1000_set_eeprom(struct net_device *netdev,
487 struct ethtool_eeprom *eeprom, uint8_t *bytes) 498 struct ethtool_eeprom *eeprom, uint8_t *bytes)
488{ 499{
489 struct e1000_adapter *adapter = netdev->priv; 500 struct e1000_adapter *adapter = netdev_priv(netdev);
490 struct e1000_hw *hw = &adapter->hw; 501 struct e1000_hw *hw = &adapter->hw;
491 uint16_t *eeprom_buff; 502 uint16_t *eeprom_buff;
492 void *ptr; 503 void *ptr;
@@ -547,7 +558,7 @@ static void
547e1000_get_drvinfo(struct net_device *netdev, 558e1000_get_drvinfo(struct net_device *netdev,
548 struct ethtool_drvinfo *drvinfo) 559 struct ethtool_drvinfo *drvinfo)
549{ 560{
550 struct e1000_adapter *adapter = netdev->priv; 561 struct e1000_adapter *adapter = netdev_priv(netdev);
551 562
552 strncpy(drvinfo->driver, e1000_driver_name, 32); 563 strncpy(drvinfo->driver, e1000_driver_name, 32);
553 strncpy(drvinfo->version, e1000_driver_version, 32); 564 strncpy(drvinfo->version, e1000_driver_version, 32);
@@ -563,7 +574,7 @@ static void
563e1000_get_ringparam(struct net_device *netdev, 574e1000_get_ringparam(struct net_device *netdev,
564 struct ethtool_ringparam *ring) 575 struct ethtool_ringparam *ring)
565{ 576{
566 struct e1000_adapter *adapter = netdev->priv; 577 struct e1000_adapter *adapter = netdev_priv(netdev);
567 e1000_mac_type mac_type = adapter->hw.mac_type; 578 e1000_mac_type mac_type = adapter->hw.mac_type;
568 struct e1000_desc_ring *txdr = &adapter->tx_ring; 579 struct e1000_desc_ring *txdr = &adapter->tx_ring;
569 struct e1000_desc_ring *rxdr = &adapter->rx_ring; 580 struct e1000_desc_ring *rxdr = &adapter->rx_ring;
@@ -584,7 +595,7 @@ static int
584e1000_set_ringparam(struct net_device *netdev, 595e1000_set_ringparam(struct net_device *netdev,
585 struct ethtool_ringparam *ring) 596 struct ethtool_ringparam *ring)
586{ 597{
587 struct e1000_adapter *adapter = netdev->priv; 598 struct e1000_adapter *adapter = netdev_priv(netdev);
588 e1000_mac_type mac_type = adapter->hw.mac_type; 599 e1000_mac_type mac_type = adapter->hw.mac_type;
589 struct e1000_desc_ring *txdr = &adapter->tx_ring; 600 struct e1000_desc_ring *txdr = &adapter->tx_ring;
590 struct e1000_desc_ring *rxdr = &adapter->rx_ring; 601 struct e1000_desc_ring *rxdr = &adapter->rx_ring;
@@ -651,6 +662,9 @@ err_setup_rx:
651 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \ 662 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
652 value = E1000_READ_REG(&adapter->hw, R); \ 663 value = E1000_READ_REG(&adapter->hw, R); \
653 if(value != (test[pat] & W & M)) { \ 664 if(value != (test[pat] & W & M)) { \
665 DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \
666 "0x%08X expected 0x%08X\n", \
667 E1000_##R, value, (test[pat] & W & M)); \
654 *data = (adapter->hw.mac_type < e1000_82543) ? \ 668 *data = (adapter->hw.mac_type < e1000_82543) ? \
655 E1000_82542_##R : E1000_##R; \ 669 E1000_82542_##R : E1000_##R; \
656 return 1; \ 670 return 1; \
@@ -663,7 +677,9 @@ err_setup_rx:
663 uint32_t value; \ 677 uint32_t value; \
664 E1000_WRITE_REG(&adapter->hw, R, W & M); \ 678 E1000_WRITE_REG(&adapter->hw, R, W & M); \
665 value = E1000_READ_REG(&adapter->hw, R); \ 679 value = E1000_READ_REG(&adapter->hw, R); \
666 if ((W & M) != (value & M)) { \ 680 if((W & M) != (value & M)) { \
681 DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\
682 "expected 0x%08X\n", E1000_##R, (value & M), (W & M)); \
667 *data = (adapter->hw.mac_type < e1000_82543) ? \ 683 *data = (adapter->hw.mac_type < e1000_82543) ? \
668 E1000_82542_##R : E1000_##R; \ 684 E1000_82542_##R : E1000_##R; \
669 return 1; \ 685 return 1; \
@@ -673,18 +689,33 @@ err_setup_rx:
673static int 689static int
674e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data) 690e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
675{ 691{
676 uint32_t value; 692 uint32_t value, before, after;
677 uint32_t i; 693 uint32_t i, toggle;
678 694
679 /* The status register is Read Only, so a write should fail. 695 /* The status register is Read Only, so a write should fail.
680 * Some bits that get toggled are ignored. 696 * Some bits that get toggled are ignored.
681 */ 697 */
682 value = (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833)); 698 switch (adapter->hw.mac_type) {
683 E1000_WRITE_REG(&adapter->hw, STATUS, (0xFFFFFFFF)); 699 case e1000_82573:
684 if(value != (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833))) { 700 toggle = 0x7FFFF033;
701 break;
702 default:
703 toggle = 0xFFFFF833;
704 break;
705 }
706
707 before = E1000_READ_REG(&adapter->hw, STATUS);
708 value = (E1000_READ_REG(&adapter->hw, STATUS) & toggle);
709 E1000_WRITE_REG(&adapter->hw, STATUS, toggle);
710 after = E1000_READ_REG(&adapter->hw, STATUS) & toggle;
711 if(value != after) {
712 DPRINTK(DRV, ERR, "failed STATUS register test got: "
713 "0x%08X expected: 0x%08X\n", after, value);
685 *data = 1; 714 *data = 1;
686 return 1; 715 return 1;
687 } 716 }
717 /* restore previous status */
718 E1000_WRITE_REG(&adapter->hw, STATUS, before);
688 719
689 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF); 720 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
690 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF); 721 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
@@ -766,7 +797,7 @@ e1000_test_intr(int irq,
766 struct pt_regs *regs) 797 struct pt_regs *regs)
767{ 798{
768 struct net_device *netdev = (struct net_device *) data; 799 struct net_device *netdev = (struct net_device *) data;
769 struct e1000_adapter *adapter = netdev->priv; 800 struct e1000_adapter *adapter = netdev_priv(netdev);
770 801
771 adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR); 802 adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR);
772 803
@@ -1214,6 +1245,7 @@ e1000_set_phy_loopback(struct e1000_adapter *adapter)
1214 case e1000_82541_rev_2: 1245 case e1000_82541_rev_2:
1215 case e1000_82547: 1246 case e1000_82547:
1216 case e1000_82547_rev_2: 1247 case e1000_82547_rev_2:
1248 case e1000_82573:
1217 return e1000_integrated_phy_loopback(adapter); 1249 return e1000_integrated_phy_loopback(adapter);
1218 break; 1250 break;
1219 1251
@@ -1422,7 +1454,7 @@ static void
1422e1000_diag_test(struct net_device *netdev, 1454e1000_diag_test(struct net_device *netdev,
1423 struct ethtool_test *eth_test, uint64_t *data) 1455 struct ethtool_test *eth_test, uint64_t *data)
1424{ 1456{
1425 struct e1000_adapter *adapter = netdev->priv; 1457 struct e1000_adapter *adapter = netdev_priv(netdev);
1426 boolean_t if_running = netif_running(netdev); 1458 boolean_t if_running = netif_running(netdev);
1427 1459
1428 if(eth_test->flags == ETH_TEST_FL_OFFLINE) { 1460 if(eth_test->flags == ETH_TEST_FL_OFFLINE) {
@@ -1482,7 +1514,7 @@ e1000_diag_test(struct net_device *netdev,
1482static void 1514static void
1483e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) 1515e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1484{ 1516{
1485 struct e1000_adapter *adapter = netdev->priv; 1517 struct e1000_adapter *adapter = netdev_priv(netdev);
1486 struct e1000_hw *hw = &adapter->hw; 1518 struct e1000_hw *hw = &adapter->hw;
1487 1519
1488 switch(adapter->hw.device_id) { 1520 switch(adapter->hw.device_id) {
@@ -1527,7 +1559,7 @@ e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1527static int 1559static int
1528e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) 1560e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1529{ 1561{
1530 struct e1000_adapter *adapter = netdev->priv; 1562 struct e1000_adapter *adapter = netdev_priv(netdev);
1531 struct e1000_hw *hw = &adapter->hw; 1563 struct e1000_hw *hw = &adapter->hw;
1532 1564
1533 switch(adapter->hw.device_id) { 1565 switch(adapter->hw.device_id) {
@@ -1588,22 +1620,31 @@ e1000_led_blink_callback(unsigned long data)
1588static int 1620static int
1589e1000_phys_id(struct net_device *netdev, uint32_t data) 1621e1000_phys_id(struct net_device *netdev, uint32_t data)
1590{ 1622{
1591 struct e1000_adapter *adapter = netdev->priv; 1623 struct e1000_adapter *adapter = netdev_priv(netdev);
1592 1624
1593 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ)) 1625 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ))
1594 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ); 1626 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ);
1595 1627
1596 if(!adapter->blink_timer.function) { 1628 if(adapter->hw.mac_type < e1000_82573) {
1597 init_timer(&adapter->blink_timer); 1629 if(!adapter->blink_timer.function) {
1598 adapter->blink_timer.function = e1000_led_blink_callback; 1630 init_timer(&adapter->blink_timer);
1599 adapter->blink_timer.data = (unsigned long) adapter; 1631 adapter->blink_timer.function = e1000_led_blink_callback;
1632 adapter->blink_timer.data = (unsigned long) adapter;
1633 }
1634 e1000_setup_led(&adapter->hw);
1635 mod_timer(&adapter->blink_timer, jiffies);
1636 msleep_interruptible(data * 1000);
1637 del_timer_sync(&adapter->blink_timer);
1638 }
1639 else {
1640 E1000_WRITE_REG(&adapter->hw, LEDCTL, (E1000_LEDCTL_LED2_BLINK_RATE |
1641 E1000_LEDCTL_LED1_BLINK | E1000_LEDCTL_LED2_BLINK |
1642 (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED2_MODE_SHIFT) |
1643 (E1000_LEDCTL_MODE_LINK_ACTIVITY << E1000_LEDCTL_LED1_MODE_SHIFT) |
1644 (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED0_MODE_SHIFT)));
1645 msleep_interruptible(data * 1000);
1600 } 1646 }
1601 1647
1602 e1000_setup_led(&adapter->hw);
1603 mod_timer(&adapter->blink_timer, jiffies);
1604
1605 msleep_interruptible(data * 1000);
1606 del_timer_sync(&adapter->blink_timer);
1607 e1000_led_off(&adapter->hw); 1648 e1000_led_off(&adapter->hw);
1608 clear_bit(E1000_LED_ON, &adapter->led_status); 1649 clear_bit(E1000_LED_ON, &adapter->led_status);
1609 e1000_cleanup_led(&adapter->hw); 1650 e1000_cleanup_led(&adapter->hw);
@@ -1614,7 +1655,7 @@ e1000_phys_id(struct net_device *netdev, uint32_t data)
1614static int 1655static int
1615e1000_nway_reset(struct net_device *netdev) 1656e1000_nway_reset(struct net_device *netdev)
1616{ 1657{
1617 struct e1000_adapter *adapter = netdev->priv; 1658 struct e1000_adapter *adapter = netdev_priv(netdev);
1618 if(netif_running(netdev)) { 1659 if(netif_running(netdev)) {
1619 e1000_down(adapter); 1660 e1000_down(adapter);
1620 e1000_up(adapter); 1661 e1000_up(adapter);
@@ -1632,7 +1673,7 @@ static void
1632e1000_get_ethtool_stats(struct net_device *netdev, 1673e1000_get_ethtool_stats(struct net_device *netdev,
1633 struct ethtool_stats *stats, uint64_t *data) 1674 struct ethtool_stats *stats, uint64_t *data)
1634{ 1675{
1635 struct e1000_adapter *adapter = netdev->priv; 1676 struct e1000_adapter *adapter = netdev_priv(netdev);
1636 int i; 1677 int i;
1637 1678
1638 e1000_update_stats(adapter); 1679 e1000_update_stats(adapter);
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 723589b28be5..045f5426ab9a 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -354,18 +354,27 @@ e1000_set_media_type(struct e1000_hw *hw)
354 hw->media_type = e1000_media_type_internal_serdes; 354 hw->media_type = e1000_media_type_internal_serdes;
355 break; 355 break;
356 default: 356 default:
357 if(hw->mac_type >= e1000_82543) { 357 switch (hw->mac_type) {
358 case e1000_82542_rev2_0:
359 case e1000_82542_rev2_1:
360 hw->media_type = e1000_media_type_fiber;
361 break;
362 case e1000_82573:
363 /* The STATUS_TBIMODE bit is reserved or reused for the this
364 * device.
365 */
366 hw->media_type = e1000_media_type_copper;
367 break;
368 default:
358 status = E1000_READ_REG(hw, STATUS); 369 status = E1000_READ_REG(hw, STATUS);
359 if(status & E1000_STATUS_TBIMODE) { 370 if (status & E1000_STATUS_TBIMODE) {
360 hw->media_type = e1000_media_type_fiber; 371 hw->media_type = e1000_media_type_fiber;
361 /* tbi_compatibility not valid on fiber */ 372 /* tbi_compatibility not valid on fiber */
362 hw->tbi_compatibility_en = FALSE; 373 hw->tbi_compatibility_en = FALSE;
363 } else { 374 } else {
364 hw->media_type = e1000_media_type_copper; 375 hw->media_type = e1000_media_type_copper;
365 } 376 }
366 } else { 377 break;
367 /* This is an 82542 (fiber only) */
368 hw->media_type = e1000_media_type_fiber;
369 } 378 }
370 } 379 }
371} 380}
@@ -1189,9 +1198,9 @@ e1000_copper_link_igp_setup(struct e1000_hw *hw)
1189 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data); 1198 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1190 if(ret_val) 1199 if(ret_val)
1191 return ret_val; 1200 return ret_val;
1192 } 1201 }
1193 1202
1194 return E1000_SUCCESS; 1203 return E1000_SUCCESS;
1195} 1204}
1196 1205
1197 1206
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index a0263ee96c6b..93e9f8788751 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -66,6 +66,7 @@ typedef enum {
66 e1000_eeprom_spi, 66 e1000_eeprom_spi,
67 e1000_eeprom_microwire, 67 e1000_eeprom_microwire,
68 e1000_eeprom_flash, 68 e1000_eeprom_flash,
69 e1000_eeprom_none, /* No NVM support */
69 e1000_num_eeprom_types 70 e1000_num_eeprom_types
70} e1000_eeprom_type; 71} e1000_eeprom_type;
71 72
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 325495b8b60c..9b596e0bbf95 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -29,6 +29,8 @@
29#include "e1000.h" 29#include "e1000.h"
30 30
31/* Change Log 31/* Change Log
32 * 6.0.58 4/20/05
33 * o Accepted ethtool cleanup patch from Stephen Hemminger
32 * 6.0.44+ 2/15/05 34 * 6.0.44+ 2/15/05
33 * o applied Anton's patch to resolve tx hang in hardware 35 * o applied Anton's patch to resolve tx hang in hardware
34 * o Applied Andrew Mortons patch - e1000 stops working after resume 36 * o Applied Andrew Mortons patch - e1000 stops working after resume
@@ -41,9 +43,9 @@ char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
41#else 43#else
42#define DRIVERNAPI "-NAPI" 44#define DRIVERNAPI "-NAPI"
43#endif 45#endif
44#define DRV_VERSION "6.0.54-k2"DRIVERNAPI 46#define DRV_VERSION "6.0.60-k2"DRIVERNAPI
45char e1000_driver_version[] = DRV_VERSION; 47char e1000_driver_version[] = DRV_VERSION;
46char e1000_copyright[] = "Copyright (c) 1999-2004 Intel Corporation."; 48char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
47 49
48/* e1000_pci_tbl - PCI Device ID Table 50/* e1000_pci_tbl - PCI Device ID Table
49 * 51 *
@@ -160,7 +162,6 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
160static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid); 162static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
161static void e1000_restore_vlan(struct e1000_adapter *adapter); 163static void e1000_restore_vlan(struct e1000_adapter *adapter);
162 164
163static int e1000_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
164static int e1000_suspend(struct pci_dev *pdev, uint32_t state); 165static int e1000_suspend(struct pci_dev *pdev, uint32_t state);
165#ifdef CONFIG_PM 166#ifdef CONFIG_PM
166static int e1000_resume(struct pci_dev *pdev); 167static int e1000_resume(struct pci_dev *pdev);
@@ -171,12 +172,6 @@ static int e1000_resume(struct pci_dev *pdev);
171static void e1000_netpoll (struct net_device *netdev); 172static void e1000_netpoll (struct net_device *netdev);
172#endif 173#endif
173 174
174struct notifier_block e1000_notifier_reboot = {
175 .notifier_call = e1000_notify_reboot,
176 .next = NULL,
177 .priority = 0
178};
179
180/* Exported from other modules */ 175/* Exported from other modules */
181 176
182extern void e1000_check_options(struct e1000_adapter *adapter); 177extern void e1000_check_options(struct e1000_adapter *adapter);
@@ -219,9 +214,7 @@ e1000_init_module(void)
219 printk(KERN_INFO "%s\n", e1000_copyright); 214 printk(KERN_INFO "%s\n", e1000_copyright);
220 215
221 ret = pci_module_init(&e1000_driver); 216 ret = pci_module_init(&e1000_driver);
222 if(ret >= 0) { 217
223 register_reboot_notifier(&e1000_notifier_reboot);
224 }
225 return ret; 218 return ret;
226} 219}
227 220
@@ -237,7 +230,6 @@ module_init(e1000_init_module);
237static void __exit 230static void __exit
238e1000_exit_module(void) 231e1000_exit_module(void)
239{ 232{
240 unregister_reboot_notifier(&e1000_notifier_reboot);
241 pci_unregister_driver(&e1000_driver); 233 pci_unregister_driver(&e1000_driver);
242} 234}
243 235
@@ -517,7 +509,7 @@ e1000_probe(struct pci_dev *pdev,
517 SET_NETDEV_DEV(netdev, &pdev->dev); 509 SET_NETDEV_DEV(netdev, &pdev->dev);
518 510
519 pci_set_drvdata(pdev, netdev); 511 pci_set_drvdata(pdev, netdev);
520 adapter = netdev->priv; 512 adapter = netdev_priv(netdev);
521 adapter->netdev = netdev; 513 adapter->netdev = netdev;
522 adapter->pdev = pdev; 514 adapter->pdev = pdev;
523 adapter->hw.back = adapter; 515 adapter->hw.back = adapter;
@@ -738,7 +730,7 @@ static void __devexit
738e1000_remove(struct pci_dev *pdev) 730e1000_remove(struct pci_dev *pdev)
739{ 731{
740 struct net_device *netdev = pci_get_drvdata(pdev); 732 struct net_device *netdev = pci_get_drvdata(pdev);
741 struct e1000_adapter *adapter = netdev->priv; 733 struct e1000_adapter *adapter = netdev_priv(netdev);
742 uint32_t manc, swsm; 734 uint32_t manc, swsm;
743 735
744 flush_scheduled_work(); 736 flush_scheduled_work();
@@ -871,7 +863,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
871static int 863static int
872e1000_open(struct net_device *netdev) 864e1000_open(struct net_device *netdev)
873{ 865{
874 struct e1000_adapter *adapter = netdev->priv; 866 struct e1000_adapter *adapter = netdev_priv(netdev);
875 int err; 867 int err;
876 868
877 /* allocate transmit descriptors */ 869 /* allocate transmit descriptors */
@@ -919,7 +911,7 @@ err_setup_tx:
919static int 911static int
920e1000_close(struct net_device *netdev) 912e1000_close(struct net_device *netdev)
921{ 913{
922 struct e1000_adapter *adapter = netdev->priv; 914 struct e1000_adapter *adapter = netdev_priv(netdev);
923 915
924 e1000_down(adapter); 916 e1000_down(adapter);
925 917
@@ -1599,7 +1591,7 @@ e1000_leave_82542_rst(struct e1000_adapter *adapter)
1599static int 1591static int
1600e1000_set_mac(struct net_device *netdev, void *p) 1592e1000_set_mac(struct net_device *netdev, void *p)
1601{ 1593{
1602 struct e1000_adapter *adapter = netdev->priv; 1594 struct e1000_adapter *adapter = netdev_priv(netdev);
1603 struct sockaddr *addr = p; 1595 struct sockaddr *addr = p;
1604 1596
1605 if(!is_valid_ether_addr(addr->sa_data)) 1597 if(!is_valid_ether_addr(addr->sa_data))
@@ -1634,7 +1626,7 @@ e1000_set_mac(struct net_device *netdev, void *p)
1634static void 1626static void
1635e1000_set_multi(struct net_device *netdev) 1627e1000_set_multi(struct net_device *netdev)
1636{ 1628{
1637 struct e1000_adapter *adapter = netdev->priv; 1629 struct e1000_adapter *adapter = netdev_priv(netdev);
1638 struct e1000_hw *hw = &adapter->hw; 1630 struct e1000_hw *hw = &adapter->hw;
1639 struct dev_mc_list *mc_ptr; 1631 struct dev_mc_list *mc_ptr;
1640 unsigned long flags; 1632 unsigned long flags;
@@ -2213,7 +2205,7 @@ e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
2213static int 2205static int
2214e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 2206e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2215{ 2207{
2216 struct e1000_adapter *adapter = netdev->priv; 2208 struct e1000_adapter *adapter = netdev_priv(netdev);
2217 unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD; 2209 unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
2218 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR; 2210 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
2219 unsigned int tx_flags = 0; 2211 unsigned int tx_flags = 0;
@@ -2307,6 +2299,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2307 tso = e1000_tso(adapter, skb); 2299 tso = e1000_tso(adapter, skb);
2308 if (tso < 0) { 2300 if (tso < 0) {
2309 dev_kfree_skb_any(skb); 2301 dev_kfree_skb_any(skb);
2302 spin_unlock_irqrestore(&adapter->tx_lock, flags);
2310 return NETDEV_TX_OK; 2303 return NETDEV_TX_OK;
2311 } 2304 }
2312 2305
@@ -2343,7 +2336,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2343static void 2336static void
2344e1000_tx_timeout(struct net_device *netdev) 2337e1000_tx_timeout(struct net_device *netdev)
2345{ 2338{
2346 struct e1000_adapter *adapter = netdev->priv; 2339 struct e1000_adapter *adapter = netdev_priv(netdev);
2347 2340
2348 /* Do the reset outside of interrupt context */ 2341 /* Do the reset outside of interrupt context */
2349 schedule_work(&adapter->tx_timeout_task); 2342 schedule_work(&adapter->tx_timeout_task);
@@ -2352,7 +2345,7 @@ e1000_tx_timeout(struct net_device *netdev)
2352static void 2345static void
2353e1000_tx_timeout_task(struct net_device *netdev) 2346e1000_tx_timeout_task(struct net_device *netdev)
2354{ 2347{
2355 struct e1000_adapter *adapter = netdev->priv; 2348 struct e1000_adapter *adapter = netdev_priv(netdev);
2356 2349
2357 e1000_down(adapter); 2350 e1000_down(adapter);
2358 e1000_up(adapter); 2351 e1000_up(adapter);
@@ -2369,7 +2362,7 @@ e1000_tx_timeout_task(struct net_device *netdev)
2369static struct net_device_stats * 2362static struct net_device_stats *
2370e1000_get_stats(struct net_device *netdev) 2363e1000_get_stats(struct net_device *netdev)
2371{ 2364{
2372 struct e1000_adapter *adapter = netdev->priv; 2365 struct e1000_adapter *adapter = netdev_priv(netdev);
2373 2366
2374 e1000_update_stats(adapter); 2367 e1000_update_stats(adapter);
2375 return &adapter->net_stats; 2368 return &adapter->net_stats;
@@ -2386,7 +2379,7 @@ e1000_get_stats(struct net_device *netdev)
2386static int 2379static int
2387e1000_change_mtu(struct net_device *netdev, int new_mtu) 2380e1000_change_mtu(struct net_device *netdev, int new_mtu)
2388{ 2381{
2389 struct e1000_adapter *adapter = netdev->priv; 2382 struct e1000_adapter *adapter = netdev_priv(netdev);
2390 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 2383 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
2391 2384
2392 if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || 2385 if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
@@ -2597,7 +2590,7 @@ static irqreturn_t
2597e1000_intr(int irq, void *data, struct pt_regs *regs) 2590e1000_intr(int irq, void *data, struct pt_regs *regs)
2598{ 2591{
2599 struct net_device *netdev = data; 2592 struct net_device *netdev = data;
2600 struct e1000_adapter *adapter = netdev->priv; 2593 struct e1000_adapter *adapter = netdev_priv(netdev);
2601 struct e1000_hw *hw = &adapter->hw; 2594 struct e1000_hw *hw = &adapter->hw;
2602 uint32_t icr = E1000_READ_REG(hw, ICR); 2595 uint32_t icr = E1000_READ_REG(hw, ICR);
2603#ifndef CONFIG_E1000_NAPI 2596#ifndef CONFIG_E1000_NAPI
@@ -2660,7 +2653,7 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
2660static int 2653static int
2661e1000_clean(struct net_device *netdev, int *budget) 2654e1000_clean(struct net_device *netdev, int *budget)
2662{ 2655{
2663 struct e1000_adapter *adapter = netdev->priv; 2656 struct e1000_adapter *adapter = netdev_priv(netdev);
2664 int work_to_do = min(*budget, netdev->quota); 2657 int work_to_do = min(*budget, netdev->quota);
2665 int tx_cleaned; 2658 int tx_cleaned;
2666 int work_done = 0; 2659 int work_done = 0;
@@ -2671,8 +2664,8 @@ e1000_clean(struct net_device *netdev, int *budget)
2671 *budget -= work_done; 2664 *budget -= work_done;
2672 netdev->quota -= work_done; 2665 netdev->quota -= work_done;
2673 2666
2674 /* If no Tx and no Rx work done, exit the polling mode */
2675 if ((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) { 2667 if ((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) {
2668 /* If no Tx and not enough Rx work done, exit the polling mode */
2676 netif_rx_complete(netdev); 2669 netif_rx_complete(netdev);
2677 e1000_irq_enable(adapter); 2670 e1000_irq_enable(adapter);
2678 return 0; 2671 return 0;
@@ -2768,7 +2761,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2768 i = tx_ring->next_to_clean; 2761 i = tx_ring->next_to_clean;
2769 eop = tx_ring->buffer_info[i].next_to_watch; 2762 eop = tx_ring->buffer_info[i].next_to_watch;
2770 eop_desc = E1000_TX_DESC(*tx_ring, eop); 2763 eop_desc = E1000_TX_DESC(*tx_ring, eop);
2771 DPRINTK(TX_ERR, ERR, "Detected Tx Unit Hang\n" 2764 DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
2772 " TDH <%x>\n" 2765 " TDH <%x>\n"
2773 " TDT <%x>\n" 2766 " TDT <%x>\n"
2774 " next_to_use <%x>\n" 2767 " next_to_use <%x>\n"
@@ -2783,7 +2776,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2783 E1000_READ_REG(&adapter->hw, TDT), 2776 E1000_READ_REG(&adapter->hw, TDT),
2784 tx_ring->next_to_use, 2777 tx_ring->next_to_use,
2785 i, 2778 i,
2786 tx_ring->buffer_info[i].dma, 2779 (unsigned long long)tx_ring->buffer_info[i].dma,
2787 tx_ring->buffer_info[i].time_stamp, 2780 tx_ring->buffer_info[i].time_stamp,
2788 eop, 2781 eop,
2789 jiffies, 2782 jiffies,
@@ -2993,7 +2986,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter)
2993 2986
2994 i = rx_ring->next_to_clean; 2987 i = rx_ring->next_to_clean;
2995 rx_desc = E1000_RX_DESC_PS(*rx_ring, i); 2988 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
2996 staterr = rx_desc->wb.middle.status_error; 2989 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
2997 2990
2998 while(staterr & E1000_RXD_STAT_DD) { 2991 while(staterr & E1000_RXD_STAT_DD) {
2999 buffer_info = &rx_ring->buffer_info[i]; 2992 buffer_info = &rx_ring->buffer_info[i];
@@ -3064,16 +3057,16 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter)
3064#ifdef CONFIG_E1000_NAPI 3057#ifdef CONFIG_E1000_NAPI
3065 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) { 3058 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
3066 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, 3059 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
3067 le16_to_cpu(rx_desc->wb.middle.vlan & 3060 le16_to_cpu(rx_desc->wb.middle.vlan) &
3068 E1000_RXD_SPC_VLAN_MASK)); 3061 E1000_RXD_SPC_VLAN_MASK);
3069 } else { 3062 } else {
3070 netif_receive_skb(skb); 3063 netif_receive_skb(skb);
3071 } 3064 }
3072#else /* CONFIG_E1000_NAPI */ 3065#else /* CONFIG_E1000_NAPI */
3073 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) { 3066 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
3074 vlan_hwaccel_rx(skb, adapter->vlgrp, 3067 vlan_hwaccel_rx(skb, adapter->vlgrp,
3075 le16_to_cpu(rx_desc->wb.middle.vlan & 3068 le16_to_cpu(rx_desc->wb.middle.vlan) &
3076 E1000_RXD_SPC_VLAN_MASK)); 3069 E1000_RXD_SPC_VLAN_MASK);
3077 } else { 3070 } else {
3078 netif_rx(skb); 3071 netif_rx(skb);
3079 } 3072 }
@@ -3086,7 +3079,7 @@ next_desc:
3086 if(unlikely(++i == rx_ring->count)) i = 0; 3079 if(unlikely(++i == rx_ring->count)) i = 0;
3087 3080
3088 rx_desc = E1000_RX_DESC_PS(*rx_ring, i); 3081 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
3089 staterr = rx_desc->wb.middle.status_error; 3082 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
3090 } 3083 }
3091 rx_ring->next_to_clean = i; 3084 rx_ring->next_to_clean = i;
3092 adapter->alloc_rx_buf(adapter); 3085 adapter->alloc_rx_buf(adapter);
@@ -3370,11 +3363,12 @@ e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
3370static int 3363static int
3371e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 3364e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
3372{ 3365{
3373 struct e1000_adapter *adapter = netdev->priv; 3366 struct e1000_adapter *adapter = netdev_priv(netdev);
3374 struct mii_ioctl_data *data = if_mii(ifr); 3367 struct mii_ioctl_data *data = if_mii(ifr);
3375 int retval; 3368 int retval;
3376 uint16_t mii_reg; 3369 uint16_t mii_reg;
3377 uint16_t spddplx; 3370 uint16_t spddplx;
3371 unsigned long flags;
3378 3372
3379 if(adapter->hw.media_type != e1000_media_type_copper) 3373 if(adapter->hw.media_type != e1000_media_type_copper)
3380 return -EOPNOTSUPP; 3374 return -EOPNOTSUPP;
@@ -3384,22 +3378,29 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
3384 data->phy_id = adapter->hw.phy_addr; 3378 data->phy_id = adapter->hw.phy_addr;
3385 break; 3379 break;
3386 case SIOCGMIIREG: 3380 case SIOCGMIIREG:
3387 if (!capable(CAP_NET_ADMIN)) 3381 if(!capable(CAP_NET_ADMIN))
3388 return -EPERM; 3382 return -EPERM;
3389 if (e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F, 3383 spin_lock_irqsave(&adapter->stats_lock, flags);
3390 &data->val_out)) 3384 if(e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
3385 &data->val_out)) {
3386 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3391 return -EIO; 3387 return -EIO;
3388 }
3389 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3392 break; 3390 break;
3393 case SIOCSMIIREG: 3391 case SIOCSMIIREG:
3394 if (!capable(CAP_NET_ADMIN)) 3392 if(!capable(CAP_NET_ADMIN))
3395 return -EPERM; 3393 return -EPERM;
3396 if (data->reg_num & ~(0x1F)) 3394 if(data->reg_num & ~(0x1F))
3397 return -EFAULT; 3395 return -EFAULT;
3398 mii_reg = data->val_in; 3396 mii_reg = data->val_in;
3399 if (e1000_write_phy_reg(&adapter->hw, data->reg_num, 3397 spin_lock_irqsave(&adapter->stats_lock, flags);
3400 mii_reg)) 3398 if(e1000_write_phy_reg(&adapter->hw, data->reg_num,
3399 mii_reg)) {
3400 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3401 return -EIO; 3401 return -EIO;
3402 if (adapter->hw.phy_type == e1000_phy_m88) { 3402 }
3403 if(adapter->hw.phy_type == e1000_phy_m88) {
3403 switch (data->reg_num) { 3404 switch (data->reg_num) {
3404 case PHY_CTRL: 3405 case PHY_CTRL:
3405 if(mii_reg & MII_CR_POWER_DOWN) 3406 if(mii_reg & MII_CR_POWER_DOWN)
@@ -3419,8 +3420,12 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
3419 HALF_DUPLEX; 3420 HALF_DUPLEX;
3420 retval = e1000_set_spd_dplx(adapter, 3421 retval = e1000_set_spd_dplx(adapter,
3421 spddplx); 3422 spddplx);
3422 if(retval) 3423 if(retval) {
3424 spin_unlock_irqrestore(
3425 &adapter->stats_lock,
3426 flags);
3423 return retval; 3427 return retval;
3428 }
3424 } 3429 }
3425 if(netif_running(adapter->netdev)) { 3430 if(netif_running(adapter->netdev)) {
3426 e1000_down(adapter); 3431 e1000_down(adapter);
@@ -3430,8 +3435,11 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
3430 break; 3435 break;
3431 case M88E1000_PHY_SPEC_CTRL: 3436 case M88E1000_PHY_SPEC_CTRL:
3432 case M88E1000_EXT_PHY_SPEC_CTRL: 3437 case M88E1000_EXT_PHY_SPEC_CTRL:
3433 if (e1000_phy_reset(&adapter->hw)) 3438 if(e1000_phy_reset(&adapter->hw)) {
3439 spin_unlock_irqrestore(
3440 &adapter->stats_lock, flags);
3434 return -EIO; 3441 return -EIO;
3442 }
3435 break; 3443 break;
3436 } 3444 }
3437 } else { 3445 } else {
@@ -3447,6 +3455,7 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
3447 break; 3455 break;
3448 } 3456 }
3449 } 3457 }
3458 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3450 break; 3459 break;
3451 default: 3460 default:
3452 return -EOPNOTSUPP; 3461 return -EOPNOTSUPP;
@@ -3503,7 +3512,7 @@ e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value)
3503static void 3512static void
3504e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) 3513e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
3505{ 3514{
3506 struct e1000_adapter *adapter = netdev->priv; 3515 struct e1000_adapter *adapter = netdev_priv(netdev);
3507 uint32_t ctrl, rctl; 3516 uint32_t ctrl, rctl;
3508 3517
3509 e1000_irq_disable(adapter); 3518 e1000_irq_disable(adapter);
@@ -3543,7 +3552,7 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
3543static void 3552static void
3544e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid) 3553e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
3545{ 3554{
3546 struct e1000_adapter *adapter = netdev->priv; 3555 struct e1000_adapter *adapter = netdev_priv(netdev);
3547 uint32_t vfta, index; 3556 uint32_t vfta, index;
3548 if((adapter->hw.mng_cookie.status & 3557 if((adapter->hw.mng_cookie.status &
3549 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && 3558 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
@@ -3559,7 +3568,7 @@ e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
3559static void 3568static void
3560e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid) 3569e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
3561{ 3570{
3562 struct e1000_adapter *adapter = netdev->priv; 3571 struct e1000_adapter *adapter = netdev_priv(netdev);
3563 uint32_t vfta, index; 3572 uint32_t vfta, index;
3564 3573
3565 e1000_irq_disable(adapter); 3574 e1000_irq_disable(adapter);
@@ -3600,6 +3609,13 @@ e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
3600{ 3609{
3601 adapter->hw.autoneg = 0; 3610 adapter->hw.autoneg = 0;
3602 3611
3612 /* Fiber NICs only allow 1000 gbps Full duplex */
3613 if((adapter->hw.media_type == e1000_media_type_fiber) &&
3614 spddplx != (SPEED_1000 + DUPLEX_FULL)) {
3615 DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
3616 return -EINVAL;
3617 }
3618
3603 switch(spddplx) { 3619 switch(spddplx) {
3604 case SPEED_10 + DUPLEX_HALF: 3620 case SPEED_10 + DUPLEX_HALF:
3605 adapter->hw.forced_speed_duplex = e1000_10_half; 3621 adapter->hw.forced_speed_duplex = e1000_10_half;
@@ -3626,27 +3642,10 @@ e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
3626} 3642}
3627 3643
3628static int 3644static int
3629e1000_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
3630{
3631 struct pci_dev *pdev = NULL;
3632
3633 switch(event) {
3634 case SYS_DOWN:
3635 case SYS_HALT:
3636 case SYS_POWER_OFF:
3637 while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
3638 if(pci_dev_driver(pdev) == &e1000_driver)
3639 e1000_suspend(pdev, 3);
3640 }
3641 }
3642 return NOTIFY_DONE;
3643}
3644
3645static int
3646e1000_suspend(struct pci_dev *pdev, uint32_t state) 3645e1000_suspend(struct pci_dev *pdev, uint32_t state)
3647{ 3646{
3648 struct net_device *netdev = pci_get_drvdata(pdev); 3647 struct net_device *netdev = pci_get_drvdata(pdev);
3649 struct e1000_adapter *adapter = netdev->priv; 3648 struct e1000_adapter *adapter = netdev_priv(netdev);
3650 uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm; 3649 uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
3651 uint32_t wufc = adapter->wol; 3650 uint32_t wufc = adapter->wol;
3652 3651
@@ -3739,12 +3738,12 @@ static int
3739e1000_resume(struct pci_dev *pdev) 3738e1000_resume(struct pci_dev *pdev)
3740{ 3739{
3741 struct net_device *netdev = pci_get_drvdata(pdev); 3740 struct net_device *netdev = pci_get_drvdata(pdev);
3742 struct e1000_adapter *adapter = netdev->priv; 3741 struct e1000_adapter *adapter = netdev_priv(netdev);
3743 uint32_t manc, ret, swsm; 3742 uint32_t manc, ret_val, swsm;
3744 3743
3745 pci_set_power_state(pdev, 0); 3744 pci_set_power_state(pdev, 0);
3746 pci_restore_state(pdev); 3745 pci_restore_state(pdev);
3747 ret = pci_enable_device(pdev); 3746 ret_val = pci_enable_device(pdev);
3748 pci_set_master(pdev); 3747 pci_set_master(pdev);
3749 3748
3750 pci_enable_wake(pdev, 3, 0); 3749 pci_enable_wake(pdev, 3, 0);
@@ -3787,9 +3786,10 @@ e1000_resume(struct pci_dev *pdev)
3787static void 3786static void
3788e1000_netpoll(struct net_device *netdev) 3787e1000_netpoll(struct net_device *netdev)
3789{ 3788{
3790 struct e1000_adapter *adapter = netdev->priv; 3789 struct e1000_adapter *adapter = netdev_priv(netdev);
3791 disable_irq(adapter->pdev->irq); 3790 disable_irq(adapter->pdev->irq);
3792 e1000_intr(adapter->pdev->irq, netdev, NULL); 3791 e1000_intr(adapter->pdev->irq, netdev, NULL);
3792 e1000_clean_tx_irq(adapter);
3793 enable_irq(adapter->pdev->irq); 3793 enable_irq(adapter->pdev->irq);
3794} 3794}
3795#endif 3795#endif
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c
index 51c9fa260830..f5a4dd7d8564 100644
--- a/drivers/net/e2100.c
+++ b/drivers/net/e2100.c
@@ -162,12 +162,7 @@ struct net_device * __init e2100_probe(int unit)
162 err = do_e2100_probe(dev); 162 err = do_e2100_probe(dev);
163 if (err) 163 if (err)
164 goto out; 164 goto out;
165 err = register_netdev(dev);
166 if (err)
167 goto out1;
168 return dev; 165 return dev;
169out1:
170 cleanup_card(dev);
171out: 166out:
172 free_netdev(dev); 167 free_netdev(dev);
173 return ERR_PTR(err); 168 return ERR_PTR(err);
@@ -286,6 +281,9 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
286#endif 281#endif
287 NS8390_init(dev, 0); 282 NS8390_init(dev, 0);
288 283
284 retval = register_netdev(dev);
285 if (retval)
286 goto out;
289 return 0; 287 return 0;
290out: 288out:
291 release_region(ioaddr, E21_IO_EXTENT); 289 release_region(ioaddr, E21_IO_EXTENT);
@@ -453,11 +451,8 @@ init_module(void)
453 dev->mem_start = mem[this_dev]; 451 dev->mem_start = mem[this_dev];
454 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */ 452 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
455 if (do_e2100_probe(dev) == 0) { 453 if (do_e2100_probe(dev) == 0) {
456 if (register_netdev(dev) == 0) { 454 dev_e21[found++] = dev;
457 dev_e21[found++] = dev; 455 continue;
458 continue;
459 }
460 cleanup_card(dev);
461 } 456 }
462 free_netdev(dev); 457 free_netdev(dev);
463 printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]); 458 printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index cd2475683027..dcb3028bb60f 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -600,12 +600,7 @@ struct net_device * __init eepro_probe(int unit)
600 err = do_eepro_probe(dev); 600 err = do_eepro_probe(dev);
601 if (err) 601 if (err)
602 goto out; 602 goto out;
603 err = register_netdev(dev);
604 if (err)
605 goto out1;
606 return dev; 603 return dev;
607out1:
608 release_region(dev->base_addr, EEPRO_IO_EXTENT);
609out: 604out:
610 free_netdev(dev); 605 free_netdev(dev);
611 return ERR_PTR(err); 606 return ERR_PTR(err);
@@ -758,6 +753,7 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
758 int i; 753 int i;
759 struct eepro_local *lp; 754 struct eepro_local *lp;
760 int ioaddr = dev->base_addr; 755 int ioaddr = dev->base_addr;
756 int err;
761 757
762 /* Grab the region so we can find another board if autoIRQ fails. */ 758 /* Grab the region so we can find another board if autoIRQ fails. */
763 if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) { 759 if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) {
@@ -873,10 +869,16 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
873 869
874 /* reset 82595 */ 870 /* reset 82595 */
875 eepro_reset(ioaddr); 871 eepro_reset(ioaddr);
872
873 err = register_netdev(dev);
874 if (err)
875 goto err;
876 return 0; 876 return 0;
877exit: 877exit:
878 err = -ENODEV;
879err:
878 release_region(dev->base_addr, EEPRO_IO_EXTENT); 880 release_region(dev->base_addr, EEPRO_IO_EXTENT);
879 return -ENODEV; 881 return err;
880} 882}
881 883
882/* Open/initialize the board. This is called (in the current kernel) 884/* Open/initialize the board. This is called (in the current kernel)
@@ -1834,11 +1836,8 @@ init_module(void)
1834 dev->irq = irq[i]; 1836 dev->irq = irq[i];
1835 1837
1836 if (do_eepro_probe(dev) == 0) { 1838 if (do_eepro_probe(dev) == 0) {
1837 if (register_netdev(dev) == 0) { 1839 dev_eepro[n_eepro++] = dev;
1838 dev_eepro[n_eepro++] = dev; 1840 continue;
1839 continue;
1840 }
1841 release_region(dev->base_addr, EEPRO_IO_EXTENT);
1842 } 1841 }
1843 free_netdev(dev); 1842 free_netdev(dev);
1844 break; 1843 break;
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 98b3a2fdce90..8c62ced2c9b2 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -1263,13 +1263,13 @@ speedo_init_rx_ring(struct net_device *dev)
1263 for (i = 0; i < RX_RING_SIZE; i++) { 1263 for (i = 0; i < RX_RING_SIZE; i++) {
1264 struct sk_buff *skb; 1264 struct sk_buff *skb;
1265 skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD)); 1265 skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD));
1266 /* XXX: do we really want to call this before the NULL check? --hch */ 1266 if (skb)
1267 rx_align(skb); /* Align IP on 16 byte boundary */ 1267 rx_align(skb); /* Align IP on 16 byte boundary */
1268 sp->rx_skbuff[i] = skb; 1268 sp->rx_skbuff[i] = skb;
1269 if (skb == NULL) 1269 if (skb == NULL)
1270 break; /* OK. Just initially short of Rx bufs. */ 1270 break; /* OK. Just initially short of Rx bufs. */
1271 skb->dev = dev; /* Mark as being used by this device. */ 1271 skb->dev = dev; /* Mark as being used by this device. */
1272 rxf = (struct RxFD *)skb->tail; 1272 rxf = (struct RxFD *)skb->data;
1273 sp->rx_ringp[i] = rxf; 1273 sp->rx_ringp[i] = rxf;
1274 sp->rx_ring_dma[i] = 1274 sp->rx_ring_dma[i] =
1275 pci_map_single(sp->pdev, rxf, 1275 pci_map_single(sp->pdev, rxf,
@@ -1654,14 +1654,14 @@ static inline struct RxFD *speedo_rx_alloc(struct net_device *dev, int entry)
1654 struct sk_buff *skb; 1654 struct sk_buff *skb;
1655 /* Get a fresh skbuff to replace the consumed one. */ 1655 /* Get a fresh skbuff to replace the consumed one. */
1656 skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD)); 1656 skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD));
1657 /* XXX: do we really want to call this before the NULL check? --hch */ 1657 if (skb)
1658 rx_align(skb); /* Align IP on 16 byte boundary */ 1658 rx_align(skb); /* Align IP on 16 byte boundary */
1659 sp->rx_skbuff[entry] = skb; 1659 sp->rx_skbuff[entry] = skb;
1660 if (skb == NULL) { 1660 if (skb == NULL) {
1661 sp->rx_ringp[entry] = NULL; 1661 sp->rx_ringp[entry] = NULL;
1662 return NULL; 1662 return NULL;
1663 } 1663 }
1664 rxf = sp->rx_ringp[entry] = (struct RxFD *)skb->tail; 1664 rxf = sp->rx_ringp[entry] = (struct RxFD *)skb->data;
1665 sp->rx_ring_dma[entry] = 1665 sp->rx_ring_dma[entry] =
1666 pci_map_single(sp->pdev, rxf, 1666 pci_map_single(sp->pdev, rxf,
1667 PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE); 1667 PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
@@ -1808,10 +1808,10 @@ speedo_rx(struct net_device *dev)
1808 1808
1809#if 1 || USE_IP_CSUM 1809#if 1 || USE_IP_CSUM
1810 /* Packet is in one chunk -- we can copy + cksum. */ 1810 /* Packet is in one chunk -- we can copy + cksum. */
1811 eth_copy_and_sum(skb, sp->rx_skbuff[entry]->tail, pkt_len, 0); 1811 eth_copy_and_sum(skb, sp->rx_skbuff[entry]->data, pkt_len, 0);
1812 skb_put(skb, pkt_len); 1812 skb_put(skb, pkt_len);
1813#else 1813#else
1814 memcpy(skb_put(skb, pkt_len), sp->rx_skbuff[entry]->tail, 1814 memcpy(skb_put(skb, pkt_len), sp->rx_skbuff[entry]->data,
1815 pkt_len); 1815 pkt_len);
1816#endif 1816#endif
1817 pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[entry], 1817 pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[entry],
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index fc8e7947b334..82bd356e4f3a 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -436,11 +436,8 @@ struct net_device * __init express_probe(int unit)
436 netdev_boot_setup_check(dev); 436 netdev_boot_setup_check(dev);
437 437
438 err = do_express_probe(dev); 438 err = do_express_probe(dev);
439 if (!err) { 439 if (!err)
440 err = register_netdev(dev); 440 return dev;
441 if (!err)
442 return dev;
443 }
444 free_netdev(dev); 441 free_netdev(dev);
445 return ERR_PTR(err); 442 return ERR_PTR(err);
446} 443}
@@ -1205,7 +1202,8 @@ static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
1205 dev->set_multicast_list = &eexp_set_multicast; 1202 dev->set_multicast_list = &eexp_set_multicast;
1206 dev->tx_timeout = eexp_timeout; 1203 dev->tx_timeout = eexp_timeout;
1207 dev->watchdog_timeo = 2*HZ; 1204 dev->watchdog_timeo = 2*HZ;
1208 return 0; 1205
1206 return register_netdev(dev);
1209} 1207}
1210 1208
1211/* 1209/*
@@ -1716,7 +1714,7 @@ int init_module(void)
1716 break; 1714 break;
1717 printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n"); 1715 printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n");
1718 } 1716 }
1719 if (do_express_probe(dev) == 0 && register_netdev(dev) == 0) { 1717 if (do_express_probe(dev) == 0) {
1720 dev_eexp[this_dev] = dev; 1718 dev_eexp[this_dev] = dev;
1721 found++; 1719 found++;
1722 continue; 1720 continue;
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 81ebaedaa240..87f522738bfc 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -1003,7 +1003,7 @@ static void epic_init_ring(struct net_device *dev)
1003 skb->dev = dev; /* Mark as being used by this device. */ 1003 skb->dev = dev; /* Mark as being used by this device. */
1004 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1004 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1005 ep->rx_ring[i].bufaddr = pci_map_single(ep->pci_dev, 1005 ep->rx_ring[i].bufaddr = pci_map_single(ep->pci_dev,
1006 skb->tail, ep->rx_buf_sz, PCI_DMA_FROMDEVICE); 1006 skb->data, ep->rx_buf_sz, PCI_DMA_FROMDEVICE);
1007 ep->rx_ring[i].rxstatus = cpu_to_le32(DescOwn); 1007 ep->rx_ring[i].rxstatus = cpu_to_le32(DescOwn);
1008 } 1008 }
1009 ep->dirty_rx = (unsigned int)(i - RX_RING_SIZE); 1009 ep->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
@@ -1274,7 +1274,7 @@ static int epic_rx(struct net_device *dev, int budget)
1274 ep->rx_ring[entry].bufaddr, 1274 ep->rx_ring[entry].bufaddr,
1275 ep->rx_buf_sz, 1275 ep->rx_buf_sz,
1276 PCI_DMA_FROMDEVICE); 1276 PCI_DMA_FROMDEVICE);
1277 eth_copy_and_sum(skb, ep->rx_skbuff[entry]->tail, pkt_len, 0); 1277 eth_copy_and_sum(skb, ep->rx_skbuff[entry]->data, pkt_len, 0);
1278 skb_put(skb, pkt_len); 1278 skb_put(skb, pkt_len);
1279 pci_dma_sync_single_for_device(ep->pci_dev, 1279 pci_dma_sync_single_for_device(ep->pci_dev,
1280 ep->rx_ring[entry].bufaddr, 1280 ep->rx_ring[entry].bufaddr,
@@ -1308,7 +1308,7 @@ static int epic_rx(struct net_device *dev, int budget)
1308 skb->dev = dev; /* Mark as being used by this device. */ 1308 skb->dev = dev; /* Mark as being used by this device. */
1309 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1309 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1310 ep->rx_ring[entry].bufaddr = pci_map_single(ep->pci_dev, 1310 ep->rx_ring[entry].bufaddr = pci_map_single(ep->pci_dev,
1311 skb->tail, ep->rx_buf_sz, PCI_DMA_FROMDEVICE); 1311 skb->data, ep->rx_buf_sz, PCI_DMA_FROMDEVICE);
1312 work_done++; 1312 work_done++;
1313 } 1313 }
1314 ep->rx_ring[entry].rxstatus = cpu_to_le32(DescOwn); 1314 ep->rx_ring[entry].rxstatus = cpu_to_le32(DescOwn);
diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index dd6865820372..aa1569182fd6 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -132,7 +132,7 @@ static struct net_device_stats *eql_get_stats(struct net_device *dev);
132#define eql_is_slave(dev) ((dev->flags & IFF_SLAVE) == IFF_SLAVE) 132#define eql_is_slave(dev) ((dev->flags & IFF_SLAVE) == IFF_SLAVE)
133#define eql_is_master(dev) ((dev->flags & IFF_MASTER) == IFF_MASTER) 133#define eql_is_master(dev) ((dev->flags & IFF_MASTER) == IFF_MASTER)
134 134
135static void eql_kill_one_slave(slave_t *slave); 135static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave);
136 136
137static void eql_timer(unsigned long param) 137static void eql_timer(unsigned long param)
138{ 138{
@@ -149,7 +149,7 @@ static void eql_timer(unsigned long param)
149 if (slave->bytes_queued < 0) 149 if (slave->bytes_queued < 0)
150 slave->bytes_queued = 0; 150 slave->bytes_queued = 0;
151 } else { 151 } else {
152 eql_kill_one_slave(slave); 152 eql_kill_one_slave(&eql->queue, slave);
153 } 153 }
154 154
155 } 155 }
@@ -214,9 +214,10 @@ static int eql_open(struct net_device *dev)
214 return 0; 214 return 0;
215} 215}
216 216
217static void eql_kill_one_slave(slave_t *slave) 217static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave)
218{ 218{
219 list_del(&slave->list); 219 list_del(&slave->list);
220 queue->num_slaves--;
220 slave->dev->flags &= ~IFF_SLAVE; 221 slave->dev->flags &= ~IFF_SLAVE;
221 dev_put(slave->dev); 222 dev_put(slave->dev);
222 kfree(slave); 223 kfree(slave);
@@ -232,8 +233,7 @@ static void eql_kill_slave_queue(slave_queue_t *queue)
232 list_for_each_safe(this, tmp, head) { 233 list_for_each_safe(this, tmp, head) {
233 slave_t *s = list_entry(this, slave_t, list); 234 slave_t *s = list_entry(this, slave_t, list);
234 235
235 eql_kill_one_slave(s); 236 eql_kill_one_slave(queue, s);
236 queue->num_slaves--;
237 } 237 }
238 238
239 spin_unlock_bh(&queue->lock); 239 spin_unlock_bh(&queue->lock);
@@ -318,7 +318,7 @@ static slave_t *__eql_schedule_slaves(slave_queue_t *queue)
318 } 318 }
319 } else { 319 } else {
320 /* We found a dead slave, kill it. */ 320 /* We found a dead slave, kill it. */
321 eql_kill_one_slave(slave); 321 eql_kill_one_slave(queue, slave);
322 } 322 }
323 } 323 }
324 return best_slave; 324 return best_slave;
@@ -393,7 +393,7 @@ static int __eql_insert_slave(slave_queue_t *queue, slave_t *slave)
393 393
394 duplicate_slave = __eql_find_slave_dev(queue, slave->dev); 394 duplicate_slave = __eql_find_slave_dev(queue, slave->dev);
395 if (duplicate_slave != 0) 395 if (duplicate_slave != 0)
396 eql_kill_one_slave(duplicate_slave); 396 eql_kill_one_slave(queue, duplicate_slave);
397 397
398 list_add(&slave->list, &queue->all_slaves); 398 list_add(&slave->list, &queue->all_slaves);
399 queue->num_slaves++; 399 queue->num_slaves++;
@@ -471,7 +471,7 @@ static int eql_emancipate(struct net_device *master_dev, slaving_request_t __use
471 slave_dev); 471 slave_dev);
472 472
473 if (slave) { 473 if (slave) {
474 eql_kill_one_slave(slave); 474 eql_kill_one_slave(&eql->queue, slave);
475 ret = 0; 475 ret = 0;
476 } 476 }
477 } 477 }
diff --git a/drivers/net/es3210.c b/drivers/net/es3210.c
index f1e8150ed2a0..50f8e23bb9e5 100644
--- a/drivers/net/es3210.c
+++ b/drivers/net/es3210.c
@@ -177,12 +177,7 @@ struct net_device * __init es_probe(int unit)
177 err = do_es_probe(dev); 177 err = do_es_probe(dev);
178 if (err) 178 if (err)
179 goto out; 179 goto out;
180 err = register_netdev(dev);
181 if (err)
182 goto out1;
183 return dev; 180 return dev;
184out1:
185 cleanup_card(dev);
186out: 181out:
187 free_netdev(dev); 182 free_netdev(dev);
188 return ERR_PTR(err); 183 return ERR_PTR(err);
@@ -310,6 +305,10 @@ static int __init es_probe1(struct net_device *dev, int ioaddr)
310 dev->poll_controller = ei_poll; 305 dev->poll_controller = ei_poll;
311#endif 306#endif
312 NS8390_init(dev, 0); 307 NS8390_init(dev, 0);
308
309 retval = register_netdev(dev);
310 if (retval)
311 goto out1;
313 return 0; 312 return 0;
314out1: 313out1:
315 free_irq(dev->irq, dev); 314 free_irq(dev->irq, dev);
@@ -445,11 +444,8 @@ init_module(void)
445 dev->base_addr = io[this_dev]; 444 dev->base_addr = io[this_dev];
446 dev->mem_start = mem[this_dev]; 445 dev->mem_start = mem[this_dev];
447 if (do_es_probe(dev) == 0) { 446 if (do_es_probe(dev) == 0) {
448 if (register_netdev(dev) == 0) { 447 dev_es3210[found++] = dev;
449 dev_es3210[found++] = dev; 448 continue;
450 continue;
451 }
452 cleanup_card(dev);
453 } 449 }
454 free_netdev(dev); 450 free_netdev(dev);
455 printk(KERN_WARNING "es3210.c: No es3210 card found (i/o = 0x%x).\n", io[this_dev]); 451 printk(KERN_WARNING "es3210.c: No es3210 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index ccae6ba5f7c5..f32a6b3acb2a 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -473,13 +473,7 @@ struct net_device * __init eth16i_probe(int unit)
473 err = do_eth16i_probe(dev); 473 err = do_eth16i_probe(dev);
474 if (err) 474 if (err)
475 goto out; 475 goto out;
476 err = register_netdev(dev);
477 if (err)
478 goto out1;
479 return dev; 476 return dev;
480out1:
481 free_irq(dev->irq, dev);
482 release_region(dev->base_addr, ETH16I_IO_EXTENT);
483out: 477out:
484 free_netdev(dev); 478 free_netdev(dev);
485 return ERR_PTR(err); 479 return ERR_PTR(err);
@@ -569,7 +563,13 @@ static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
569 dev->tx_timeout = eth16i_timeout; 563 dev->tx_timeout = eth16i_timeout;
570 dev->watchdog_timeo = TX_TIMEOUT; 564 dev->watchdog_timeo = TX_TIMEOUT;
571 spin_lock_init(&lp->lock); 565 spin_lock_init(&lp->lock);
566
567 retval = register_netdev(dev);
568 if (retval)
569 goto out1;
572 return 0; 570 return 0;
571out1:
572 free_irq(dev->irq, dev);
573out: 573out:
574 release_region(ioaddr, ETH16I_IO_EXTENT); 574 release_region(ioaddr, ETH16I_IO_EXTENT);
575 return retval; 575 return retval;
@@ -1462,12 +1462,8 @@ int init_module(void)
1462 } 1462 }
1463 1463
1464 if (do_eth16i_probe(dev) == 0) { 1464 if (do_eth16i_probe(dev) == 0) {
1465 if (register_netdev(dev) == 0) { 1465 dev_eth16i[found++] = dev;
1466 dev_eth16i[found++] = dev; 1466 continue;
1467 continue;
1468 }
1469 free_irq(dev->irq, dev);
1470 release_region(dev->base_addr, ETH16I_IO_EXTENT);
1471 } 1467 }
1472 printk(KERN_WARNING "eth16i.c No Eth16i card found (i/o = 0x%x).\n", 1468 printk(KERN_WARNING "eth16i.c No Eth16i card found (i/o = 0x%x).\n",
1473 io[this_dev]); 1469 io[this_dev]);
diff --git a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c
index dcf969b20be9..b987f9474730 100644
--- a/drivers/net/ewrk3.c
+++ b/drivers/net/ewrk3.c
@@ -1308,15 +1308,9 @@ static int __init eisa_probe(struct net_device *dev, u_long ioaddr)
1308 if (ioaddr < 0x1000) 1308 if (ioaddr < 0x1000)
1309 goto out; 1309 goto out;
1310 1310
1311 if (ioaddr == 0) { /* Autoprobing */ 1311 iobase = ioaddr;
1312 iobase = EISA_SLOT_INC; /* Get the first slot address */ 1312 i = (ioaddr >> 12);
1313 i = 1; 1313 maxSlots = i + 1;
1314 maxSlots = MAX_EISA_SLOTS;
1315 } else { /* Probe a specific location */
1316 iobase = ioaddr;
1317 i = (ioaddr >> 12);
1318 maxSlots = i + 1;
1319 }
1320 1314
1321 for (i = 1; (i < maxSlots) && (dev != NULL); i++, iobase += EISA_SLOT_INC) { 1315 for (i = 1; (i < maxSlots) && (dev != NULL); i++, iobase += EISA_SLOT_INC) {
1322 if (EISA_signature(name, EISA_ID) == 0) { 1316 if (EISA_signature(name, EISA_ID) == 0) {
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index d05e9dd1e140..55dbe9a3fd56 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -1107,7 +1107,7 @@ static void allocate_rx_buffers(struct net_device *dev)
1107 1107
1108 skb->dev = dev; /* Mark as being used by this device. */ 1108 skb->dev = dev; /* Mark as being used by this device. */
1109 np->lack_rxbuf->skbuff = skb; 1109 np->lack_rxbuf->skbuff = skb;
1110 np->lack_rxbuf->buffer = pci_map_single(np->pci_dev, skb->tail, 1110 np->lack_rxbuf->buffer = pci_map_single(np->pci_dev, skb->data,
1111 np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1111 np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1112 np->lack_rxbuf->status = RXOWN; 1112 np->lack_rxbuf->status = RXOWN;
1113 ++np->really_rx_count; 1113 ++np->really_rx_count;
@@ -1300,7 +1300,7 @@ static void init_ring(struct net_device *dev)
1300 ++np->really_rx_count; 1300 ++np->really_rx_count;
1301 np->rx_ring[i].skbuff = skb; 1301 np->rx_ring[i].skbuff = skb;
1302 skb->dev = dev; /* Mark as being used by this device. */ 1302 skb->dev = dev; /* Mark as being used by this device. */
1303 np->rx_ring[i].buffer = pci_map_single(np->pci_dev, skb->tail, 1303 np->rx_ring[i].buffer = pci_map_single(np->pci_dev, skb->data,
1304 np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1304 np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1305 np->rx_ring[i].status = RXOWN; 1305 np->rx_ring[i].status = RXOWN;
1306 np->rx_ring[i].control |= RXIC; 1306 np->rx_ring[i].control |= RXIC;
@@ -1423,8 +1423,7 @@ static void reset_tx_descriptors(struct net_device *dev)
1423 if (cur->skbuff) { 1423 if (cur->skbuff) {
1424 pci_unmap_single(np->pci_dev, cur->buffer, 1424 pci_unmap_single(np->pci_dev, cur->buffer,
1425 cur->skbuff->len, PCI_DMA_TODEVICE); 1425 cur->skbuff->len, PCI_DMA_TODEVICE);
1426 dev_kfree_skb(cur->skbuff); 1426 dev_kfree_skb_any(cur->skbuff);
1427 /* or dev_kfree_skb_irq(cur->skbuff); ? */
1428 cur->skbuff = NULL; 1427 cur->skbuff = NULL;
1429 } 1428 }
1430 cur->status = 0; 1429 cur->status = 0;
@@ -1738,11 +1737,11 @@ static int netdev_rx(struct net_device *dev)
1738 1737
1739#if ! defined(__alpha__) 1738#if ! defined(__alpha__)
1740 eth_copy_and_sum(skb, 1739 eth_copy_and_sum(skb,
1741 np->cur_rx->skbuff->tail, pkt_len, 0); 1740 np->cur_rx->skbuff->data, pkt_len, 0);
1742 skb_put(skb, pkt_len); 1741 skb_put(skb, pkt_len);
1743#else 1742#else
1744 memcpy(skb_put(skb, pkt_len), 1743 memcpy(skb_put(skb, pkt_len),
1745 np->cur_rx->skbuff->tail, pkt_len); 1744 np->cur_rx->skbuff->data, pkt_len);
1746#endif 1745#endif
1747 pci_dma_sync_single_for_device(np->pci_dev, 1746 pci_dma_sync_single_for_device(np->pci_dev,
1748 np->cur_rx->buffer, 1747 np->cur_rx->buffer,
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 4ebcd052e150..7d93948aec83 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -82,6 +82,19 @@
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.
86 * 0.34: 18 Jun 2005: Add DEV_NEED_LINKTIMER to all nForce nics.
87 * 0.35: 26 Jun 2005: Support for MCP55 added.
88 * 0.36: 28 Jun 2005: Add jumbo frame support.
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
91 * per-packet flags.
92 * 0.39: 18 Jul 2005: Add 64bit descriptor support.
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
95 * of nv_remove
96 * 0.42: 06 Aug 2005: Fix lack of link speed initialization
97 * in the second (and later) nv_open call
85 * 98 *
86 * Known bugs: 99 * Known bugs:
87 * We suspect that on some hardware no TX done interrupts are generated. 100 * We suspect that on some hardware no TX done interrupts are generated.
@@ -93,7 +106,7 @@
93 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 106 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
94 * superfluous timer interrupts from the nic. 107 * superfluous timer interrupts from the nic.
95 */ 108 */
96#define FORCEDETH_VERSION "0.32" 109#define FORCEDETH_VERSION "0.41"
97#define DRV_NAME "forcedeth" 110#define DRV_NAME "forcedeth"
98 111
99#include <linux/module.h> 112#include <linux/module.h>
@@ -128,11 +141,10 @@
128 * Hardware access: 141 * Hardware access:
129 */ 142 */
130 143
131#define DEV_NEED_LASTPACKET1 0x0001 /* set LASTPACKET1 in tx flags */ 144#define DEV_NEED_TIMERIRQ 0x0001 /* set the timer irq flag in the irq mask */
132#define DEV_IRQMASK_1 0x0002 /* use NVREG_IRQMASK_WANTED_1 for irq mask */ 145#define DEV_NEED_LINKTIMER 0x0002 /* poll link settings. Relies on the timer irq */
133#define DEV_IRQMASK_2 0x0004 /* use NVREG_IRQMASK_WANTED_2 for irq mask */ 146#define DEV_HAS_LARGEDESC 0x0004 /* device supports jumbo frames and needs packet format 2 */
134#define DEV_NEED_TIMERIRQ 0x0008 /* set the timer irq flag in the irq mask */ 147#define DEV_HAS_HIGH_DMA 0x0008 /* device supports 64bit dma */
135#define DEV_NEED_LINKTIMER 0x0010 /* poll link settings. Relies on the timer irq */
136 148
137enum { 149enum {
138 NvRegIrqStatus = 0x000, 150 NvRegIrqStatus = 0x000,
@@ -143,13 +155,16 @@ enum {
143#define NVREG_IRQ_RX 0x0002 155#define NVREG_IRQ_RX 0x0002
144#define NVREG_IRQ_RX_NOBUF 0x0004 156#define NVREG_IRQ_RX_NOBUF 0x0004
145#define NVREG_IRQ_TX_ERR 0x0008 157#define NVREG_IRQ_TX_ERR 0x0008
146#define NVREG_IRQ_TX2 0x0010 158#define NVREG_IRQ_TX_OK 0x0010
147#define NVREG_IRQ_TIMER 0x0020 159#define NVREG_IRQ_TIMER 0x0020
148#define NVREG_IRQ_LINK 0x0040 160#define NVREG_IRQ_LINK 0x0040
161#define NVREG_IRQ_TX_ERROR 0x0080
149#define NVREG_IRQ_TX1 0x0100 162#define NVREG_IRQ_TX1 0x0100
150#define NVREG_IRQMASK_WANTED_1 0x005f 163#define NVREG_IRQMASK_WANTED 0x00df
151#define NVREG_IRQMASK_WANTED_2 0x0147 164
152#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR|NVREG_IRQ_TX2|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX1)) 165#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \
166 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX_ERROR| \
167 NVREG_IRQ_TX1))
153 168
154 NvRegUnknownSetupReg6 = 0x008, 169 NvRegUnknownSetupReg6 = 0x008,
155#define NVREG_UNKSETUP6_VAL 3 170#define NVREG_UNKSETUP6_VAL 3
@@ -283,6 +298,18 @@ struct ring_desc {
283 u32 FlagLen; 298 u32 FlagLen;
284}; 299};
285 300
301struct ring_desc_ex {
302 u32 PacketBufferHigh;
303 u32 PacketBufferLow;
304 u32 Reserved;
305 u32 FlagLen;
306};
307
308typedef union _ring_type {
309 struct ring_desc* orig;
310 struct ring_desc_ex* ex;
311} ring_type;
312
286#define FLAG_MASK_V1 0xffff0000 313#define FLAG_MASK_V1 0xffff0000
287#define FLAG_MASK_V2 0xffffc000 314#define FLAG_MASK_V2 0xffffc000
288#define LEN_MASK_V1 (0xffffffff ^ FLAG_MASK_V1) 315#define LEN_MASK_V1 (0xffffffff ^ FLAG_MASK_V1)
@@ -290,7 +317,7 @@ struct ring_desc {
290 317
291#define NV_TX_LASTPACKET (1<<16) 318#define NV_TX_LASTPACKET (1<<16)
292#define NV_TX_RETRYERROR (1<<19) 319#define NV_TX_RETRYERROR (1<<19)
293#define NV_TX_LASTPACKET1 (1<<24) 320#define NV_TX_FORCED_INTERRUPT (1<<24)
294#define NV_TX_DEFERRED (1<<26) 321#define NV_TX_DEFERRED (1<<26)
295#define NV_TX_CARRIERLOST (1<<27) 322#define NV_TX_CARRIERLOST (1<<27)
296#define NV_TX_LATECOLLISION (1<<28) 323#define NV_TX_LATECOLLISION (1<<28)
@@ -300,7 +327,7 @@ struct ring_desc {
300 327
301#define NV_TX2_LASTPACKET (1<<29) 328#define NV_TX2_LASTPACKET (1<<29)
302#define NV_TX2_RETRYERROR (1<<18) 329#define NV_TX2_RETRYERROR (1<<18)
303#define NV_TX2_LASTPACKET1 (1<<23) 330#define NV_TX2_FORCED_INTERRUPT (1<<30)
304#define NV_TX2_DEFERRED (1<<25) 331#define NV_TX2_DEFERRED (1<<25)
305#define NV_TX2_CARRIERLOST (1<<26) 332#define NV_TX2_CARRIERLOST (1<<26)
306#define NV_TX2_LATECOLLISION (1<<27) 333#define NV_TX2_LATECOLLISION (1<<27)
@@ -376,9 +403,13 @@ struct ring_desc {
376#define TX_LIMIT_START 62 403#define TX_LIMIT_START 62
377 404
378/* rx/tx mac addr + type + vlan + align + slack*/ 405/* rx/tx mac addr + type + vlan + align + slack*/
379#define RX_NIC_BUFSIZE (ETH_DATA_LEN + 64) 406#define NV_RX_HEADERS (64)
380/* even more slack */ 407/* even more slack. */
381#define RX_ALLOC_BUFSIZE (ETH_DATA_LEN + 128) 408#define NV_RX_ALLOC_PAD (64)
409
410/* maximum mtu size */
411#define NV_PKTLIMIT_1 ETH_DATA_LEN /* hard limit not known */
412#define NV_PKTLIMIT_2 9100 /* Actual limit according to NVidia: 9202 */
382 413
383#define OOM_REFILL (1+HZ/20) 414#define OOM_REFILL (1+HZ/20)
384#define POLL_WAIT (1+HZ/100) 415#define POLL_WAIT (1+HZ/100)
@@ -393,6 +424,7 @@ struct ring_desc {
393 */ 424 */
394#define DESC_VER_1 0x0 425#define DESC_VER_1 0x0
395#define DESC_VER_2 (0x02100|NVREG_TXRXCTL_RXCHECK) 426#define DESC_VER_2 (0x02100|NVREG_TXRXCTL_RXCHECK)
427#define DESC_VER_3 (0x02200|NVREG_TXRXCTL_RXCHECK)
396 428
397/* PHY defines */ 429/* PHY defines */
398#define PHY_OUI_MARVELL 0x5043 430#define PHY_OUI_MARVELL 0x5043
@@ -465,11 +497,12 @@ struct fe_priv {
465 /* rx specific fields. 497 /* rx specific fields.
466 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock); 498 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
467 */ 499 */
468 struct ring_desc *rx_ring; 500 ring_type rx_ring;
469 unsigned int cur_rx, refill_rx; 501 unsigned int cur_rx, refill_rx;
470 struct sk_buff *rx_skbuff[RX_RING]; 502 struct sk_buff *rx_skbuff[RX_RING];
471 dma_addr_t rx_dma[RX_RING]; 503 dma_addr_t rx_dma[RX_RING];
472 unsigned int rx_buf_sz; 504 unsigned int rx_buf_sz;
505 unsigned int pkt_limit;
473 struct timer_list oom_kick; 506 struct timer_list oom_kick;
474 struct timer_list nic_poll; 507 struct timer_list nic_poll;
475 508
@@ -481,7 +514,7 @@ struct fe_priv {
481 /* 514 /*
482 * tx specific fields. 515 * tx specific fields.
483 */ 516 */
484 struct ring_desc *tx_ring; 517 ring_type tx_ring;
485 unsigned int next_tx, nic_tx; 518 unsigned int next_tx, nic_tx;
486 struct sk_buff *tx_skbuff[TX_RING]; 519 struct sk_buff *tx_skbuff[TX_RING];
487 dma_addr_t tx_dma[TX_RING]; 520 dma_addr_t tx_dma[TX_RING];
@@ -516,6 +549,11 @@ static inline u32 nv_descr_getlength(struct ring_desc *prd, u32 v)
516 & ((v == DESC_VER_1) ? LEN_MASK_V1 : LEN_MASK_V2); 549 & ((v == DESC_VER_1) ? LEN_MASK_V1 : LEN_MASK_V2);
517} 550}
518 551
552static inline u32 nv_descr_getlength_ex(struct ring_desc_ex *prd, u32 v)
553{
554 return le32_to_cpu(prd->FlagLen) & LEN_MASK_V2;
555}
556
519static int reg_delay(struct net_device *dev, int offset, u32 mask, u32 target, 557static int reg_delay(struct net_device *dev, int offset, u32 mask, u32 target,
520 int delay, int delaymax, const char *msg) 558 int delay, int delaymax, const char *msg)
521{ 559{
@@ -789,7 +827,7 @@ static int nv_alloc_rx(struct net_device *dev)
789 nr = refill_rx % RX_RING; 827 nr = refill_rx % RX_RING;
790 if (np->rx_skbuff[nr] == NULL) { 828 if (np->rx_skbuff[nr] == NULL) {
791 829
792 skb = dev_alloc_skb(RX_ALLOC_BUFSIZE); 830 skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
793 if (!skb) 831 if (!skb)
794 break; 832 break;
795 833
@@ -800,9 +838,16 @@ static int nv_alloc_rx(struct net_device *dev)
800 } 838 }
801 np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len, 839 np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len,
802 PCI_DMA_FROMDEVICE); 840 PCI_DMA_FROMDEVICE);
803 np->rx_ring[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]); 841 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
804 wmb(); 842 np->rx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]);
805 np->rx_ring[nr].FlagLen = cpu_to_le32(RX_NIC_BUFSIZE | NV_RX_AVAIL); 843 wmb();
844 np->rx_ring.orig[nr].FlagLen = cpu_to_le32(np->rx_buf_sz | NV_RX_AVAIL);
845 } else {
846 np->rx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->rx_dma[nr]) >> 32;
847 np->rx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->rx_dma[nr]) & 0x0FFFFFFFF;
848 wmb();
849 np->rx_ring.ex[nr].FlagLen = cpu_to_le32(np->rx_buf_sz | NV_RX2_AVAIL);
850 }
806 dprintk(KERN_DEBUG "%s: nv_alloc_rx: Packet %d marked as Available\n", 851 dprintk(KERN_DEBUG "%s: nv_alloc_rx: Packet %d marked as Available\n",
807 dev->name, refill_rx); 852 dev->name, refill_rx);
808 refill_rx++; 853 refill_rx++;
@@ -828,19 +873,37 @@ static void nv_do_rx_refill(unsigned long data)
828 enable_irq(dev->irq); 873 enable_irq(dev->irq);
829} 874}
830 875
831static int nv_init_ring(struct net_device *dev) 876static void nv_init_rx(struct net_device *dev)
832{ 877{
833 struct fe_priv *np = get_nvpriv(dev); 878 struct fe_priv *np = get_nvpriv(dev);
834 int i; 879 int i;
835 880
836 np->next_tx = np->nic_tx = 0;
837 for (i = 0; i < TX_RING; i++)
838 np->tx_ring[i].FlagLen = 0;
839
840 np->cur_rx = RX_RING; 881 np->cur_rx = RX_RING;
841 np->refill_rx = 0; 882 np->refill_rx = 0;
842 for (i = 0; i < RX_RING; i++) 883 for (i = 0; i < RX_RING; i++)
843 np->rx_ring[i].FlagLen = 0; 884 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
885 np->rx_ring.orig[i].FlagLen = 0;
886 else
887 np->rx_ring.ex[i].FlagLen = 0;
888}
889
890static void nv_init_tx(struct net_device *dev)
891{
892 struct fe_priv *np = get_nvpriv(dev);
893 int i;
894
895 np->next_tx = np->nic_tx = 0;
896 for (i = 0; i < TX_RING; i++)
897 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
898 np->tx_ring.orig[i].FlagLen = 0;
899 else
900 np->tx_ring.ex[i].FlagLen = 0;
901}
902
903static int nv_init_ring(struct net_device *dev)
904{
905 nv_init_tx(dev);
906 nv_init_rx(dev);
844 return nv_alloc_rx(dev); 907 return nv_alloc_rx(dev);
845} 908}
846 909
@@ -849,7 +912,10 @@ static void nv_drain_tx(struct net_device *dev)
849 struct fe_priv *np = get_nvpriv(dev); 912 struct fe_priv *np = get_nvpriv(dev);
850 int i; 913 int i;
851 for (i = 0; i < TX_RING; i++) { 914 for (i = 0; i < TX_RING; i++) {
852 np->tx_ring[i].FlagLen = 0; 915 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
916 np->tx_ring.orig[i].FlagLen = 0;
917 else
918 np->tx_ring.ex[i].FlagLen = 0;
853 if (np->tx_skbuff[i]) { 919 if (np->tx_skbuff[i]) {
854 pci_unmap_single(np->pci_dev, np->tx_dma[i], 920 pci_unmap_single(np->pci_dev, np->tx_dma[i],
855 np->tx_skbuff[i]->len, 921 np->tx_skbuff[i]->len,
@@ -866,7 +932,10 @@ static void nv_drain_rx(struct net_device *dev)
866 struct fe_priv *np = get_nvpriv(dev); 932 struct fe_priv *np = get_nvpriv(dev);
867 int i; 933 int i;
868 for (i = 0; i < RX_RING; i++) { 934 for (i = 0; i < RX_RING; i++) {
869 np->rx_ring[i].FlagLen = 0; 935 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
936 np->rx_ring.orig[i].FlagLen = 0;
937 else
938 np->rx_ring.ex[i].FlagLen = 0;
870 wmb(); 939 wmb();
871 if (np->rx_skbuff[i]) { 940 if (np->rx_skbuff[i]) {
872 pci_unmap_single(np->pci_dev, np->rx_dma[i], 941 pci_unmap_single(np->pci_dev, np->rx_dma[i],
@@ -897,11 +966,19 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
897 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data,skb->len, 966 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data,skb->len,
898 PCI_DMA_TODEVICE); 967 PCI_DMA_TODEVICE);
899 968
900 np->tx_ring[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]); 969 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
970 np->tx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]);
971 else {
972 np->tx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->tx_dma[nr]) >> 32;
973 np->tx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF;
974 }
901 975
902 spin_lock_irq(&np->lock); 976 spin_lock_irq(&np->lock);
903 wmb(); 977 wmb();
904 np->tx_ring[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags ); 978 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
979 np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags );
980 else
981 np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags );
905 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission.\n", 982 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission.\n",
906 dev->name, np->next_tx); 983 dev->name, np->next_tx);
907 { 984 {
@@ -939,7 +1016,10 @@ static void nv_tx_done(struct net_device *dev)
939 while (np->nic_tx != np->next_tx) { 1016 while (np->nic_tx != np->next_tx) {
940 i = np->nic_tx % TX_RING; 1017 i = np->nic_tx % TX_RING;
941 1018
942 Flags = le32_to_cpu(np->tx_ring[i].FlagLen); 1019 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1020 Flags = le32_to_cpu(np->tx_ring.orig[i].FlagLen);
1021 else
1022 Flags = le32_to_cpu(np->tx_ring.ex[i].FlagLen);
943 1023
944 dprintk(KERN_DEBUG "%s: nv_tx_done: looking at packet %d, Flags 0x%x.\n", 1024 dprintk(KERN_DEBUG "%s: nv_tx_done: looking at packet %d, Flags 0x%x.\n",
945 dev->name, np->nic_tx, Flags); 1025 dev->name, np->nic_tx, Flags);
@@ -990,9 +1070,56 @@ static void nv_tx_timeout(struct net_device *dev)
990 struct fe_priv *np = get_nvpriv(dev); 1070 struct fe_priv *np = get_nvpriv(dev);
991 u8 __iomem *base = get_hwbase(dev); 1071 u8 __iomem *base = get_hwbase(dev);
992 1072
993 dprintk(KERN_DEBUG "%s: Got tx_timeout. irq: %08x\n", dev->name, 1073 printk(KERN_INFO "%s: Got tx_timeout. irq: %08x\n", dev->name,
994 readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK); 1074 readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK);
995 1075
1076 {
1077 int i;
1078
1079 printk(KERN_INFO "%s: Ring at %lx: next %d nic %d\n",
1080 dev->name, (unsigned long)np->ring_addr,
1081 np->next_tx, np->nic_tx);
1082 printk(KERN_INFO "%s: Dumping tx registers\n", dev->name);
1083 for (i=0;i<0x400;i+= 32) {
1084 printk(KERN_INFO "%3x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
1085 i,
1086 readl(base + i + 0), readl(base + i + 4),
1087 readl(base + i + 8), readl(base + i + 12),
1088 readl(base + i + 16), readl(base + i + 20),
1089 readl(base + i + 24), readl(base + i + 28));
1090 }
1091 printk(KERN_INFO "%s: Dumping tx ring\n", dev->name);
1092 for (i=0;i<TX_RING;i+= 4) {
1093 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
1094 printk(KERN_INFO "%03x: %08x %08x // %08x %08x // %08x %08x // %08x %08x\n",
1095 i,
1096 le32_to_cpu(np->tx_ring.orig[i].PacketBuffer),
1097 le32_to_cpu(np->tx_ring.orig[i].FlagLen),
1098 le32_to_cpu(np->tx_ring.orig[i+1].PacketBuffer),
1099 le32_to_cpu(np->tx_ring.orig[i+1].FlagLen),
1100 le32_to_cpu(np->tx_ring.orig[i+2].PacketBuffer),
1101 le32_to_cpu(np->tx_ring.orig[i+2].FlagLen),
1102 le32_to_cpu(np->tx_ring.orig[i+3].PacketBuffer),
1103 le32_to_cpu(np->tx_ring.orig[i+3].FlagLen));
1104 } else {
1105 printk(KERN_INFO "%03x: %08x %08x %08x // %08x %08x %08x // %08x %08x %08x // %08x %08x %08x\n",
1106 i,
1107 le32_to_cpu(np->tx_ring.ex[i].PacketBufferHigh),
1108 le32_to_cpu(np->tx_ring.ex[i].PacketBufferLow),
1109 le32_to_cpu(np->tx_ring.ex[i].FlagLen),
1110 le32_to_cpu(np->tx_ring.ex[i+1].PacketBufferHigh),
1111 le32_to_cpu(np->tx_ring.ex[i+1].PacketBufferLow),
1112 le32_to_cpu(np->tx_ring.ex[i+1].FlagLen),
1113 le32_to_cpu(np->tx_ring.ex[i+2].PacketBufferHigh),
1114 le32_to_cpu(np->tx_ring.ex[i+2].PacketBufferLow),
1115 le32_to_cpu(np->tx_ring.ex[i+2].FlagLen),
1116 le32_to_cpu(np->tx_ring.ex[i+3].PacketBufferHigh),
1117 le32_to_cpu(np->tx_ring.ex[i+3].PacketBufferLow),
1118 le32_to_cpu(np->tx_ring.ex[i+3].FlagLen));
1119 }
1120 }
1121 }
1122
996 spin_lock_irq(&np->lock); 1123 spin_lock_irq(&np->lock);
997 1124
998 /* 1) stop tx engine */ 1125 /* 1) stop tx engine */
@@ -1006,7 +1133,10 @@ static void nv_tx_timeout(struct net_device *dev)
1006 printk(KERN_DEBUG "%s: tx_timeout: dead entries!\n", dev->name); 1133 printk(KERN_DEBUG "%s: tx_timeout: dead entries!\n", dev->name);
1007 nv_drain_tx(dev); 1134 nv_drain_tx(dev);
1008 np->next_tx = np->nic_tx = 0; 1135 np->next_tx = np->nic_tx = 0;
1009 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr); 1136 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1137 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr);
1138 else
1139 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc_ex)), base + NvRegTxRingPhysAddr);
1010 netif_wake_queue(dev); 1140 netif_wake_queue(dev);
1011 } 1141 }
1012 1142
@@ -1081,8 +1211,13 @@ static void nv_rx_process(struct net_device *dev)
1081 break; /* we scanned the whole ring - do not continue */ 1211 break; /* we scanned the whole ring - do not continue */
1082 1212
1083 i = np->cur_rx % RX_RING; 1213 i = np->cur_rx % RX_RING;
1084 Flags = le32_to_cpu(np->rx_ring[i].FlagLen); 1214 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
1085 len = nv_descr_getlength(&np->rx_ring[i], np->desc_ver); 1215 Flags = le32_to_cpu(np->rx_ring.orig[i].FlagLen);
1216 len = nv_descr_getlength(&np->rx_ring.orig[i], np->desc_ver);
1217 } else {
1218 Flags = le32_to_cpu(np->rx_ring.ex[i].FlagLen);
1219 len = nv_descr_getlength_ex(&np->rx_ring.ex[i], np->desc_ver);
1220 }
1086 1221
1087 dprintk(KERN_DEBUG "%s: nv_rx_process: looking at packet %d, Flags 0x%x.\n", 1222 dprintk(KERN_DEBUG "%s: nv_rx_process: looking at packet %d, Flags 0x%x.\n",
1088 dev->name, np->cur_rx, Flags); 1223 dev->name, np->cur_rx, Flags);
@@ -1204,15 +1339,133 @@ next_pkt:
1204 } 1339 }
1205} 1340}
1206 1341
1342static void set_bufsize(struct net_device *dev)
1343{
1344 struct fe_priv *np = netdev_priv(dev);
1345
1346 if (dev->mtu <= ETH_DATA_LEN)
1347 np->rx_buf_sz = ETH_DATA_LEN + NV_RX_HEADERS;
1348 else
1349 np->rx_buf_sz = dev->mtu + NV_RX_HEADERS;
1350}
1351
1207/* 1352/*
1208 * nv_change_mtu: dev->change_mtu function 1353 * nv_change_mtu: dev->change_mtu function
1209 * Called with dev_base_lock held for read. 1354 * Called with dev_base_lock held for read.
1210 */ 1355 */
1211static int nv_change_mtu(struct net_device *dev, int new_mtu) 1356static int nv_change_mtu(struct net_device *dev, int new_mtu)
1212{ 1357{
1213 if (new_mtu > ETH_DATA_LEN) 1358 struct fe_priv *np = get_nvpriv(dev);
1359 int old_mtu;
1360
1361 if (new_mtu < 64 || new_mtu > np->pkt_limit)
1214 return -EINVAL; 1362 return -EINVAL;
1363
1364 old_mtu = dev->mtu;
1215 dev->mtu = new_mtu; 1365 dev->mtu = new_mtu;
1366
1367 /* return early if the buffer sizes will not change */
1368 if (old_mtu <= ETH_DATA_LEN && new_mtu <= ETH_DATA_LEN)
1369 return 0;
1370 if (old_mtu == new_mtu)
1371 return 0;
1372
1373 /* synchronized against open : rtnl_lock() held by caller */
1374 if (netif_running(dev)) {
1375 u8 *base = get_hwbase(dev);
1376 /*
1377 * It seems that the nic preloads valid ring entries into an
1378 * internal buffer. The procedure for flushing everything is
1379 * guessed, there is probably a simpler approach.
1380 * Changing the MTU is a rare event, it shouldn't matter.
1381 */
1382 disable_irq(dev->irq);
1383 spin_lock_bh(&dev->xmit_lock);
1384 spin_lock(&np->lock);
1385 /* stop engines */
1386 nv_stop_rx(dev);
1387 nv_stop_tx(dev);
1388 nv_txrx_reset(dev);
1389 /* drain rx queue */
1390 nv_drain_rx(dev);
1391 nv_drain_tx(dev);
1392 /* reinit driver view of the rx queue */
1393 nv_init_rx(dev);
1394 nv_init_tx(dev);
1395 /* alloc new rx buffers */
1396 set_bufsize(dev);
1397 if (nv_alloc_rx(dev)) {
1398 if (!np->in_shutdown)
1399 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
1400 }
1401 /* reinit nic view of the rx queue */
1402 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
1403 writel((u32) np->ring_addr, base + NvRegRxRingPhysAddr);
1404 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1405 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr);
1406 else
1407 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc_ex)), base + NvRegTxRingPhysAddr);
1408 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT),
1409 base + NvRegRingSizes);
1410 pci_push(base);
1411 writel(NVREG_TXRXCTL_KICK|np->desc_ver, get_hwbase(dev) + NvRegTxRxControl);
1412 pci_push(base);
1413
1414 /* restart rx engine */
1415 nv_start_rx(dev);
1416 nv_start_tx(dev);
1417 spin_unlock(&np->lock);
1418 spin_unlock_bh(&dev->xmit_lock);
1419 enable_irq(dev->irq);
1420 }
1421 return 0;
1422}
1423
1424static void nv_copy_mac_to_hw(struct net_device *dev)
1425{
1426 u8 *base = get_hwbase(dev);
1427 u32 mac[2];
1428
1429 mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) +
1430 (dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
1431 mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8);
1432
1433 writel(mac[0], base + NvRegMacAddrA);
1434 writel(mac[1], base + NvRegMacAddrB);
1435}
1436
1437/*
1438 * nv_set_mac_address: dev->set_mac_address function
1439 * Called with rtnl_lock() held.
1440 */
1441static int nv_set_mac_address(struct net_device *dev, void *addr)
1442{
1443 struct fe_priv *np = get_nvpriv(dev);
1444 struct sockaddr *macaddr = (struct sockaddr*)addr;
1445
1446 if(!is_valid_ether_addr(macaddr->sa_data))
1447 return -EADDRNOTAVAIL;
1448
1449 /* synchronized against open : rtnl_lock() held by caller */
1450 memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN);
1451
1452 if (netif_running(dev)) {
1453 spin_lock_bh(&dev->xmit_lock);
1454 spin_lock_irq(&np->lock);
1455
1456 /* stop rx engine */
1457 nv_stop_rx(dev);
1458
1459 /* set mac address */
1460 nv_copy_mac_to_hw(dev);
1461
1462 /* restart rx engine */
1463 nv_start_rx(dev);
1464 spin_unlock_irq(&np->lock);
1465 spin_unlock_bh(&dev->xmit_lock);
1466 } else {
1467 nv_copy_mac_to_hw(dev);
1468 }
1216 return 0; 1469 return 0;
1217} 1470}
1218 1471
@@ -1467,7 +1720,7 @@ static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs)
1467 if (!(events & np->irqmask)) 1720 if (!(events & np->irqmask))
1468 break; 1721 break;
1469 1722
1470 if (events & (NVREG_IRQ_TX1|NVREG_IRQ_TX2|NVREG_IRQ_TX_ERR)) { 1723 if (events & (NVREG_IRQ_TX1|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_ERROR|NVREG_IRQ_TX_ERR)) {
1471 spin_lock(&np->lock); 1724 spin_lock(&np->lock);
1472 nv_tx_done(dev); 1725 nv_tx_done(dev);
1473 spin_unlock(&np->lock); 1726 spin_unlock(&np->lock);
@@ -1758,6 +2011,50 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1758 return 0; 2011 return 0;
1759} 2012}
1760 2013
2014#define FORCEDETH_REGS_VER 1
2015#define FORCEDETH_REGS_SIZE 0x400 /* 256 32-bit registers */
2016
2017static int nv_get_regs_len(struct net_device *dev)
2018{
2019 return FORCEDETH_REGS_SIZE;
2020}
2021
2022static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf)
2023{
2024 struct fe_priv *np = get_nvpriv(dev);
2025 u8 __iomem *base = get_hwbase(dev);
2026 u32 *rbuf = buf;
2027 int i;
2028
2029 regs->version = FORCEDETH_REGS_VER;
2030 spin_lock_irq(&np->lock);
2031 for (i=0;i<FORCEDETH_REGS_SIZE/sizeof(u32);i++)
2032 rbuf[i] = readl(base + i*sizeof(u32));
2033 spin_unlock_irq(&np->lock);
2034}
2035
2036static int nv_nway_reset(struct net_device *dev)
2037{
2038 struct fe_priv *np = get_nvpriv(dev);
2039 int ret;
2040
2041 spin_lock_irq(&np->lock);
2042 if (np->autoneg) {
2043 int bmcr;
2044
2045 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
2046 bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
2047 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
2048
2049 ret = 0;
2050 } else {
2051 ret = -EINVAL;
2052 }
2053 spin_unlock_irq(&np->lock);
2054
2055 return ret;
2056}
2057
1761static struct ethtool_ops ops = { 2058static struct ethtool_ops ops = {
1762 .get_drvinfo = nv_get_drvinfo, 2059 .get_drvinfo = nv_get_drvinfo,
1763 .get_link = ethtool_op_get_link, 2060 .get_link = ethtool_op_get_link,
@@ -1765,6 +2062,9 @@ static struct ethtool_ops ops = {
1765 .set_wol = nv_set_wol, 2062 .set_wol = nv_set_wol,
1766 .get_settings = nv_get_settings, 2063 .get_settings = nv_get_settings,
1767 .set_settings = nv_set_settings, 2064 .set_settings = nv_set_settings,
2065 .get_regs_len = nv_get_regs_len,
2066 .get_regs = nv_get_regs,
2067 .nway_reset = nv_nway_reset,
1768}; 2068};
1769 2069
1770static int nv_open(struct net_device *dev) 2070static int nv_open(struct net_device *dev)
@@ -1789,6 +2089,7 @@ static int nv_open(struct net_device *dev)
1789 writel(0, base + NvRegAdapterControl); 2089 writel(0, base + NvRegAdapterControl);
1790 2090
1791 /* 2) initialize descriptor rings */ 2091 /* 2) initialize descriptor rings */
2092 set_bufsize(dev);
1792 oom = nv_init_ring(dev); 2093 oom = nv_init_ring(dev);
1793 2094
1794 writel(0, base + NvRegLinkSpeed); 2095 writel(0, base + NvRegLinkSpeed);
@@ -1799,20 +2100,14 @@ static int nv_open(struct net_device *dev)
1799 np->in_shutdown = 0; 2100 np->in_shutdown = 0;
1800 2101
1801 /* 3) set mac address */ 2102 /* 3) set mac address */
1802 { 2103 nv_copy_mac_to_hw(dev);
1803 u32 mac[2];
1804
1805 mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) +
1806 (dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
1807 mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8);
1808
1809 writel(mac[0], base + NvRegMacAddrA);
1810 writel(mac[1], base + NvRegMacAddrB);
1811 }
1812 2104
1813 /* 4) give hw rings */ 2105 /* 4) give hw rings */
1814 writel((u32) np->ring_addr, base + NvRegRxRingPhysAddr); 2106 writel((u32) np->ring_addr, base + NvRegRxRingPhysAddr);
1815 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr); 2107 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
2108 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr);
2109 else
2110 writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc_ex)), base + NvRegTxRingPhysAddr);
1816 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT), 2111 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT),
1817 base + NvRegRingSizes); 2112 base + NvRegRingSizes);
1818 2113
@@ -1834,7 +2129,7 @@ static int nv_open(struct net_device *dev)
1834 writel(NVREG_MISC1_FORCE | NVREG_MISC1_HD, base + NvRegMisc1); 2129 writel(NVREG_MISC1_FORCE | NVREG_MISC1_HD, base + NvRegMisc1);
1835 writel(readl(base + NvRegTransmitterStatus), base + NvRegTransmitterStatus); 2130 writel(readl(base + NvRegTransmitterStatus), base + NvRegTransmitterStatus);
1836 writel(NVREG_PFF_ALWAYS, base + NvRegPacketFilterFlags); 2131 writel(NVREG_PFF_ALWAYS, base + NvRegPacketFilterFlags);
1837 writel(NVREG_OFFLOAD_NORMAL, base + NvRegOffloadConfig); 2132 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
1838 2133
1839 writel(readl(base + NvRegReceiverStatus), base + NvRegReceiverStatus); 2134 writel(readl(base + NvRegReceiverStatus), base + NvRegReceiverStatus);
1840 get_random_bytes(&i, sizeof(i)); 2135 get_random_bytes(&i, sizeof(i));
@@ -1885,6 +2180,9 @@ static int nv_open(struct net_device *dev)
1885 writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus); 2180 writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
1886 dprintk(KERN_INFO "startup: got 0x%08x.\n", miistat); 2181 dprintk(KERN_INFO "startup: got 0x%08x.\n", miistat);
1887 } 2182 }
2183 /* set linkspeed to invalid value, thus force nv_update_linkspeed
2184 * to init hw */
2185 np->linkspeed = 0;
1888 ret = nv_update_linkspeed(dev); 2186 ret = nv_update_linkspeed(dev);
1889 nv_start_rx(dev); 2187 nv_start_rx(dev);
1890 nv_start_tx(dev); 2188 nv_start_tx(dev);
@@ -1939,6 +2237,12 @@ static int nv_close(struct net_device *dev)
1939 if (np->wolenabled) 2237 if (np->wolenabled)
1940 nv_start_rx(dev); 2238 nv_start_rx(dev);
1941 2239
2240 /* special op: write back the misordered MAC address - otherwise
2241 * the next nv_probe would see a wrong address.
2242 */
2243 writel(np->orig_mac[0], base + NvRegMacAddrA);
2244 writel(np->orig_mac[1], base + NvRegMacAddrB);
2245
1942 /* FIXME: power down nic */ 2246 /* FIXME: power down nic */
1943 2247
1944 return 0; 2248 return 0;
@@ -2003,30 +2307,55 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2003 } 2307 }
2004 2308
2005 /* handle different descriptor versions */ 2309 /* handle different descriptor versions */
2006 if (pci_dev->device == PCI_DEVICE_ID_NVIDIA_NVENET_1 || 2310 if (id->driver_data & DEV_HAS_HIGH_DMA) {
2007 pci_dev->device == PCI_DEVICE_ID_NVIDIA_NVENET_2 || 2311 /* packet format 3: supports 40-bit addressing */
2008 pci_dev->device == PCI_DEVICE_ID_NVIDIA_NVENET_3) 2312 np->desc_ver = DESC_VER_3;
2009 np->desc_ver = DESC_VER_1; 2313 if (pci_set_dma_mask(pci_dev, 0x0000007fffffffffULL)) {
2010 else 2314 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n",
2315 pci_name(pci_dev));
2316 }
2317 } else if (id->driver_data & DEV_HAS_LARGEDESC) {
2318 /* packet format 2: supports jumbo frames */
2011 np->desc_ver = DESC_VER_2; 2319 np->desc_ver = DESC_VER_2;
2320 } else {
2321 /* original packet format */
2322 np->desc_ver = DESC_VER_1;
2323 }
2324
2325 np->pkt_limit = NV_PKTLIMIT_1;
2326 if (id->driver_data & DEV_HAS_LARGEDESC)
2327 np->pkt_limit = NV_PKTLIMIT_2;
2012 2328
2013 err = -ENOMEM; 2329 err = -ENOMEM;
2014 np->base = ioremap(addr, NV_PCI_REGSZ); 2330 np->base = ioremap(addr, NV_PCI_REGSZ);
2015 if (!np->base) 2331 if (!np->base)
2016 goto out_relreg; 2332 goto out_relreg;
2017 dev->base_addr = (unsigned long)np->base; 2333 dev->base_addr = (unsigned long)np->base;
2334
2018 dev->irq = pci_dev->irq; 2335 dev->irq = pci_dev->irq;
2019 np->rx_ring = pci_alloc_consistent(pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING), 2336
2020 &np->ring_addr); 2337 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
2021 if (!np->rx_ring) 2338 np->rx_ring.orig = pci_alloc_consistent(pci_dev,
2022 goto out_unmap; 2339 sizeof(struct ring_desc) * (RX_RING + TX_RING),
2023 np->tx_ring = &np->rx_ring[RX_RING]; 2340 &np->ring_addr);
2341 if (!np->rx_ring.orig)
2342 goto out_unmap;
2343 np->tx_ring.orig = &np->rx_ring.orig[RX_RING];
2344 } else {
2345 np->rx_ring.ex = pci_alloc_consistent(pci_dev,
2346 sizeof(struct ring_desc_ex) * (RX_RING + TX_RING),
2347 &np->ring_addr);
2348 if (!np->rx_ring.ex)
2349 goto out_unmap;
2350 np->tx_ring.ex = &np->rx_ring.ex[RX_RING];
2351 }
2024 2352
2025 dev->open = nv_open; 2353 dev->open = nv_open;
2026 dev->stop = nv_close; 2354 dev->stop = nv_close;
2027 dev->hard_start_xmit = nv_start_xmit; 2355 dev->hard_start_xmit = nv_start_xmit;
2028 dev->get_stats = nv_get_stats; 2356 dev->get_stats = nv_get_stats;
2029 dev->change_mtu = nv_change_mtu; 2357 dev->change_mtu = nv_change_mtu;
2358 dev->set_mac_address = nv_set_mac_address;
2030 dev->set_multicast_list = nv_set_multicast; 2359 dev->set_multicast_list = nv_set_multicast;
2031#ifdef CONFIG_NET_POLL_CONTROLLER 2360#ifdef CONFIG_NET_POLL_CONTROLLER
2032 dev->poll_controller = nv_poll_controller; 2361 dev->poll_controller = nv_poll_controller;
@@ -2075,17 +2404,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2075 2404
2076 if (np->desc_ver == DESC_VER_1) { 2405 if (np->desc_ver == DESC_VER_1) {
2077 np->tx_flags = NV_TX_LASTPACKET|NV_TX_VALID; 2406 np->tx_flags = NV_TX_LASTPACKET|NV_TX_VALID;
2078 if (id->driver_data & DEV_NEED_LASTPACKET1)
2079 np->tx_flags |= NV_TX_LASTPACKET1;
2080 } else { 2407 } else {
2081 np->tx_flags = NV_TX2_LASTPACKET|NV_TX2_VALID; 2408 np->tx_flags = NV_TX2_LASTPACKET|NV_TX2_VALID;
2082 if (id->driver_data & DEV_NEED_LASTPACKET1)
2083 np->tx_flags |= NV_TX2_LASTPACKET1;
2084 } 2409 }
2085 if (id->driver_data & DEV_IRQMASK_1) 2410 np->irqmask = NVREG_IRQMASK_WANTED;
2086 np->irqmask = NVREG_IRQMASK_WANTED_1;
2087 if (id->driver_data & DEV_IRQMASK_2)
2088 np->irqmask = NVREG_IRQMASK_WANTED_2;
2089 if (id->driver_data & DEV_NEED_TIMERIRQ) 2411 if (id->driver_data & DEV_NEED_TIMERIRQ)
2090 np->irqmask |= NVREG_IRQ_TIMER; 2412 np->irqmask |= NVREG_IRQ_TIMER;
2091 if (id->driver_data & DEV_NEED_LINKTIMER) { 2413 if (id->driver_data & DEV_NEED_LINKTIMER) {
@@ -2150,8 +2472,12 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2150 return 0; 2472 return 0;
2151 2473
2152out_freering: 2474out_freering:
2153 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING), 2475 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
2154 np->rx_ring, np->ring_addr); 2476 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING),
2477 np->rx_ring.orig, np->ring_addr);
2478 else
2479 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (RX_RING + TX_RING),
2480 np->rx_ring.ex, np->ring_addr);
2155 pci_set_drvdata(pci_dev, NULL); 2481 pci_set_drvdata(pci_dev, NULL);
2156out_unmap: 2482out_unmap:
2157 iounmap(get_hwbase(dev)); 2483 iounmap(get_hwbase(dev));
@@ -2169,18 +2495,14 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
2169{ 2495{
2170 struct net_device *dev = pci_get_drvdata(pci_dev); 2496 struct net_device *dev = pci_get_drvdata(pci_dev);
2171 struct fe_priv *np = get_nvpriv(dev); 2497 struct fe_priv *np = get_nvpriv(dev);
2172 u8 __iomem *base = get_hwbase(dev);
2173 2498
2174 unregister_netdev(dev); 2499 unregister_netdev(dev);
2175 2500
2176 /* special op: write back the misordered MAC address - otherwise
2177 * the next nv_probe would see a wrong address.
2178 */
2179 writel(np->orig_mac[0], base + NvRegMacAddrA);
2180 writel(np->orig_mac[1], base + NvRegMacAddrB);
2181
2182 /* free all structures */ 2501 /* free all structures */
2183 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING), np->rx_ring, np->ring_addr); 2502 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
2503 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING), np->rx_ring.orig, np->ring_addr);
2504 else
2505 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (RX_RING + TX_RING), np->rx_ring.ex, np->ring_addr);
2184 iounmap(get_hwbase(dev)); 2506 iounmap(get_hwbase(dev));
2185 pci_release_regions(pci_dev); 2507 pci_release_regions(pci_dev);
2186 pci_disable_device(pci_dev); 2508 pci_disable_device(pci_dev);
@@ -2190,81 +2512,64 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
2190 2512
2191static struct pci_device_id pci_tbl[] = { 2513static struct pci_device_id pci_tbl[] = {
2192 { /* nForce Ethernet Controller */ 2514 { /* nForce Ethernet Controller */
2193 .vendor = PCI_VENDOR_ID_NVIDIA, 2515 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_1),
2194 .device = PCI_DEVICE_ID_NVIDIA_NVENET_1, 2516 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
2195 .subvendor = PCI_ANY_ID,
2196 .subdevice = PCI_ANY_ID,
2197 .driver_data = DEV_IRQMASK_1|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
2198 }, 2517 },
2199 { /* nForce2 Ethernet Controller */ 2518 { /* nForce2 Ethernet Controller */
2200 .vendor = PCI_VENDOR_ID_NVIDIA, 2519 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_2),
2201 .device = PCI_DEVICE_ID_NVIDIA_NVENET_2, 2520 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
2202 .subvendor = PCI_ANY_ID,
2203 .subdevice = PCI_ANY_ID,
2204 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
2205 }, 2521 },
2206 { /* nForce3 Ethernet Controller */ 2522 { /* nForce3 Ethernet Controller */
2207 .vendor = PCI_VENDOR_ID_NVIDIA, 2523 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_3),
2208 .device = PCI_DEVICE_ID_NVIDIA_NVENET_3, 2524 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
2209 .subvendor = PCI_ANY_ID,
2210 .subdevice = PCI_ANY_ID,
2211 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
2212 }, 2525 },
2213 { /* nForce3 Ethernet Controller */ 2526 { /* nForce3 Ethernet Controller */
2214 .vendor = PCI_VENDOR_ID_NVIDIA, 2527 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_4),
2215 .device = PCI_DEVICE_ID_NVIDIA_NVENET_4, 2528 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC,
2216 .subvendor = PCI_ANY_ID,
2217 .subdevice = PCI_ANY_ID,
2218 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ,
2219 }, 2529 },
2220 { /* nForce3 Ethernet Controller */ 2530 { /* nForce3 Ethernet Controller */
2221 .vendor = PCI_VENDOR_ID_NVIDIA, 2531 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_5),
2222 .device = PCI_DEVICE_ID_NVIDIA_NVENET_5, 2532 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC,
2223 .subvendor = PCI_ANY_ID,
2224 .subdevice = PCI_ANY_ID,
2225 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ,
2226 }, 2533 },
2227 { /* nForce3 Ethernet Controller */ 2534 { /* nForce3 Ethernet Controller */
2228 .vendor = PCI_VENDOR_ID_NVIDIA, 2535 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_6),
2229 .device = PCI_DEVICE_ID_NVIDIA_NVENET_6, 2536 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC,
2230 .subvendor = PCI_ANY_ID,
2231 .subdevice = PCI_ANY_ID,
2232 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ,
2233 }, 2537 },
2234 { /* nForce3 Ethernet Controller */ 2538 { /* nForce3 Ethernet Controller */
2235 .vendor = PCI_VENDOR_ID_NVIDIA, 2539 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_7),
2236 .device = PCI_DEVICE_ID_NVIDIA_NVENET_7, 2540 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC,
2237 .subvendor = PCI_ANY_ID,
2238 .subdevice = PCI_ANY_ID,
2239 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ,
2240 }, 2541 },
2241 { /* CK804 Ethernet Controller */ 2542 { /* CK804 Ethernet Controller */
2242 .vendor = PCI_VENDOR_ID_NVIDIA, 2543 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_8),
2243 .device = PCI_DEVICE_ID_NVIDIA_NVENET_8, 2544 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA,
2244 .subvendor = PCI_ANY_ID,
2245 .subdevice = PCI_ANY_ID,
2246 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ,
2247 }, 2545 },
2248 { /* CK804 Ethernet Controller */ 2546 { /* CK804 Ethernet Controller */
2249 .vendor = PCI_VENDOR_ID_NVIDIA, 2547 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_9),
2250 .device = PCI_DEVICE_ID_NVIDIA_NVENET_9, 2548 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA,
2251 .subvendor = PCI_ANY_ID,
2252 .subdevice = PCI_ANY_ID,
2253 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ,
2254 }, 2549 },
2255 { /* MCP04 Ethernet Controller */ 2550 { /* MCP04 Ethernet Controller */
2256 .vendor = PCI_VENDOR_ID_NVIDIA, 2551 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_10),
2257 .device = PCI_DEVICE_ID_NVIDIA_NVENET_10, 2552 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA,
2258 .subvendor = PCI_ANY_ID,
2259 .subdevice = PCI_ANY_ID,
2260 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ,
2261 }, 2553 },
2262 { /* MCP04 Ethernet Controller */ 2554 { /* MCP04 Ethernet Controller */
2263 .vendor = PCI_VENDOR_ID_NVIDIA, 2555 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_11),
2264 .device = PCI_DEVICE_ID_NVIDIA_NVENET_11, 2556 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA,
2265 .subvendor = PCI_ANY_ID, 2557 },
2266 .subdevice = PCI_ANY_ID, 2558 { /* MCP51 Ethernet Controller */
2267 .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, 2559 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12),
2560 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA,
2561 },
2562 { /* MCP51 Ethernet Controller */
2563 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_13),
2564 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA,
2565 },
2566 { /* MCP55 Ethernet Controller */
2567 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
2568 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA,
2569 },
2570 { /* MCP55 Ethernet Controller */
2571 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
2572 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA,
2268 }, 2573 },
2269 {0,}, 2574 {0,},
2270}; 2575};
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b43b2b11aacd..6518334b9280 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * drivers/net/gianfar.c 2 * drivers/net/gianfar.c
3 * 3 *
4 * Gianfar Ethernet Driver 4 * Gianfar Ethernet Driver
@@ -22,10 +22,9 @@
22 * B-V +1.62 22 * B-V +1.62
23 * 23 *
24 * Theory of operation 24 * Theory of operation
25 * This driver is designed for the Triple-speed Ethernet 25 * This driver is designed for the non-CPM ethernet controllers
26 * controllers on the Freescale 8540/8560 integrated processors, 26 * on the 85xx and 83xx family of integrated processors
27 * as well as the Fast Ethernet Controller on the 8540. 27 *
28 *
29 * The driver is initialized through platform_device. Structures which 28 * The driver is initialized through platform_device. Structures which
30 * define the configuration needed by the board are defined in a 29 * define the configuration needed by the board are defined in a
31 * board structure in arch/ppc/platforms (though I do not 30 * board structure in arch/ppc/platforms (though I do not
@@ -39,12 +38,12 @@
39 * 38 *
40 * The Gianfar Ethernet Controller uses a ring of buffer 39 * The Gianfar Ethernet Controller uses a ring of buffer
41 * descriptors. The beginning is indicated by a register 40 * descriptors. The beginning is indicated by a register
42 * pointing to the physical address of the start of the ring. 41 * pointing to the physical address of the start of the ring.
43 * The end is determined by a "wrap" bit being set in the 42 * The end is determined by a "wrap" bit being set in the
44 * last descriptor of the ring. 43 * last descriptor of the ring.
45 * 44 *
46 * When a packet is received, the RXF bit in the 45 * When a packet is received, the RXF bit in the
47 * IEVENT register is set, triggering an interrupt when the 46 * IEVENT register is set, triggering an interrupt when the
48 * corresponding bit in the IMASK register is also set (if 47 * corresponding bit in the IMASK register is also set (if
49 * interrupt coalescing is active, then the interrupt may not 48 * interrupt coalescing is active, then the interrupt may not
50 * happen immediately, but will wait until either a set number 49 * happen immediately, but will wait until either a set number
@@ -52,7 +51,7 @@
52 * interrupt handler will signal there is work to be done, and 51 * interrupt handler will signal there is work to be done, and
53 * exit. Without NAPI, the packet(s) will be handled 52 * exit. Without NAPI, the packet(s) will be handled
54 * immediately. Both methods will start at the last known empty 53 * immediately. Both methods will start at the last known empty
55 * descriptor, and process every subsequent descriptor until there 54 * descriptor, and process every subsequent descriptor until there
56 * are none left with data (NAPI will stop after a set number of 55 * are none left with data (NAPI will stop after a set number of
57 * packets to give time to other tasks, but will eventually 56 * packets to give time to other tasks, but will eventually
58 * process all the packets). The data arrives inside a 57 * process all the packets). The data arrives inside a
@@ -83,9 +82,13 @@
83#include <linux/netdevice.h> 82#include <linux/netdevice.h>
84#include <linux/etherdevice.h> 83#include <linux/etherdevice.h>
85#include <linux/skbuff.h> 84#include <linux/skbuff.h>
85#include <linux/if_vlan.h>
86#include <linux/spinlock.h> 86#include <linux/spinlock.h>
87#include <linux/mm.h> 87#include <linux/mm.h>
88#include <linux/device.h> 88#include <linux/device.h>
89#include <linux/ip.h>
90#include <linux/tcp.h>
91#include <linux/udp.h>
89 92
90#include <asm/io.h> 93#include <asm/io.h>
91#include <asm/irq.h> 94#include <asm/irq.h>
@@ -123,7 +126,7 @@ static int gfar_set_mac_address(struct net_device *dev);
123static int gfar_change_mtu(struct net_device *dev, int new_mtu); 126static int gfar_change_mtu(struct net_device *dev, int new_mtu);
124static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs); 127static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs);
125static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs); 128static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs);
126irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs); 129static irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs);
127static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs); 130static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs);
128static irqreturn_t phy_interrupt(int irq, void *dev_id, struct pt_regs *regs); 131static irqreturn_t phy_interrupt(int irq, void *dev_id, struct pt_regs *regs);
129static void gfar_phy_change(void *data); 132static void gfar_phy_change(void *data);
@@ -139,9 +142,12 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
139#ifdef CONFIG_GFAR_NAPI 142#ifdef CONFIG_GFAR_NAPI
140static int gfar_poll(struct net_device *dev, int *budget); 143static int gfar_poll(struct net_device *dev, int *budget);
141#endif 144#endif
142static int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); 145int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
143static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length); 146static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length);
144static void gfar_phy_startup_timer(unsigned long data); 147static void gfar_phy_startup_timer(unsigned long data);
148static void gfar_vlan_rx_register(struct net_device *netdev,
149 struct vlan_group *grp);
150static void gfar_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
145 151
146extern struct ethtool_ops gfar_ethtool_ops; 152extern struct ethtool_ops gfar_ethtool_ops;
147 153
@@ -149,6 +155,13 @@ MODULE_AUTHOR("Freescale Semiconductor, Inc");
149MODULE_DESCRIPTION("Gianfar Ethernet Driver"); 155MODULE_DESCRIPTION("Gianfar Ethernet Driver");
150MODULE_LICENSE("GPL"); 156MODULE_LICENSE("GPL");
151 157
158int gfar_uses_fcb(struct gfar_private *priv)
159{
160 if (priv->vlan_enable || priv->rx_csum_enable)
161 return 1;
162 else
163 return 0;
164}
152static int gfar_probe(struct device *device) 165static int gfar_probe(struct device *device)
153{ 166{
154 u32 tempval; 167 u32 tempval;
@@ -159,7 +172,6 @@ static int gfar_probe(struct device *device)
159 struct resource *r; 172 struct resource *r;
160 int idx; 173 int idx;
161 int err = 0; 174 int err = 0;
162 int dev_ethtool_ops = 0;
163 175
164 einfo = (struct gianfar_platform_data *) pdev->dev.platform_data; 176 einfo = (struct gianfar_platform_data *) pdev->dev.platform_data;
165 177
@@ -265,15 +277,69 @@ static int gfar_probe(struct device *device)
265 dev->mtu = 1500; 277 dev->mtu = 1500;
266 dev->set_multicast_list = gfar_set_multi; 278 dev->set_multicast_list = gfar_set_multi;
267 279
268 /* Index into the array of possible ethtool 280 dev->ethtool_ops = &gfar_ethtool_ops;
269 * ops to catch all 4 possibilities */ 281
270 if((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) == 0) 282 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
271 dev_ethtool_ops += 1; 283 priv->rx_csum_enable = 1;
284 dev->features |= NETIF_F_IP_CSUM;
285 } else
286 priv->rx_csum_enable = 0;
287
288 priv->vlgrp = NULL;
272 289
273 if((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE) == 0) 290 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_VLAN) {
274 dev_ethtool_ops += 2; 291 dev->vlan_rx_register = gfar_vlan_rx_register;
292 dev->vlan_rx_kill_vid = gfar_vlan_rx_kill_vid;
275 293
276 dev->ethtool_ops = gfar_op_array[dev_ethtool_ops]; 294 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
295
296 priv->vlan_enable = 1;
297 }
298
299 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_EXTENDED_HASH) {
300 priv->extended_hash = 1;
301 priv->hash_width = 9;
302
303 priv->hash_regs[0] = &priv->regs->igaddr0;
304 priv->hash_regs[1] = &priv->regs->igaddr1;
305 priv->hash_regs[2] = &priv->regs->igaddr2;
306 priv->hash_regs[3] = &priv->regs->igaddr3;
307 priv->hash_regs[4] = &priv->regs->igaddr4;
308 priv->hash_regs[5] = &priv->regs->igaddr5;
309 priv->hash_regs[6] = &priv->regs->igaddr6;
310 priv->hash_regs[7] = &priv->regs->igaddr7;
311 priv->hash_regs[8] = &priv->regs->gaddr0;
312 priv->hash_regs[9] = &priv->regs->gaddr1;
313 priv->hash_regs[10] = &priv->regs->gaddr2;
314 priv->hash_regs[11] = &priv->regs->gaddr3;
315 priv->hash_regs[12] = &priv->regs->gaddr4;
316 priv->hash_regs[13] = &priv->regs->gaddr5;
317 priv->hash_regs[14] = &priv->regs->gaddr6;
318 priv->hash_regs[15] = &priv->regs->gaddr7;
319
320 } else {
321 priv->extended_hash = 0;
322 priv->hash_width = 8;
323
324 priv->hash_regs[0] = &priv->regs->gaddr0;
325 priv->hash_regs[1] = &priv->regs->gaddr1;
326 priv->hash_regs[2] = &priv->regs->gaddr2;
327 priv->hash_regs[3] = &priv->regs->gaddr3;
328 priv->hash_regs[4] = &priv->regs->gaddr4;
329 priv->hash_regs[5] = &priv->regs->gaddr5;
330 priv->hash_regs[6] = &priv->regs->gaddr6;
331 priv->hash_regs[7] = &priv->regs->gaddr7;
332 }
333
334 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_PADDING)
335 priv->padding = DEFAULT_PADDING;
336 else
337 priv->padding = 0;
338
339 dev->hard_header_len += priv->padding;
340
341 if (dev->features & NETIF_F_IP_CSUM)
342 dev->hard_header_len += GMAC_FCB_LEN;
277 343
278 priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE; 344 priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE;
279#ifdef CONFIG_GFAR_BUFSTASH 345#ifdef CONFIG_GFAR_BUFSTASH
@@ -289,6 +355,9 @@ static int gfar_probe(struct device *device)
289 priv->rxcount = DEFAULT_RXCOUNT; 355 priv->rxcount = DEFAULT_RXCOUNT;
290 priv->rxtime = DEFAULT_RXTIME; 356 priv->rxtime = DEFAULT_RXTIME;
291 357
358 /* Enable most messages by default */
359 priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1;
360
292 err = register_netdev(dev); 361 err = register_netdev(dev);
293 362
294 if (err) { 363 if (err) {
@@ -360,8 +429,9 @@ static int init_phy(struct net_device *dev)
360 GFP_KERNEL); 429 GFP_KERNEL);
361 430
362 if(NULL == mii_info) { 431 if(NULL == mii_info) {
363 printk(KERN_ERR "%s: Could not allocate mii_info\n", 432 if (netif_msg_ifup(priv))
364 dev->name); 433 printk(KERN_ERR "%s: Could not allocate mii_info\n",
434 dev->name);
365 return -ENOMEM; 435 return -ENOMEM;
366 } 436 }
367 437
@@ -410,7 +480,8 @@ static int init_phy(struct net_device *dev)
410 curphy = get_phy_info(priv->mii_info); 480 curphy = get_phy_info(priv->mii_info);
411 481
412 if (curphy == NULL) { 482 if (curphy == NULL) {
413 printk(KERN_ERR "%s: No PHY found\n", dev->name); 483 if (netif_msg_ifup(priv))
484 printk(KERN_ERR "%s: No PHY found\n", dev->name);
414 err = -1; 485 err = -1;
415 goto no_phy; 486 goto no_phy;
416 } 487 }
@@ -421,7 +492,7 @@ static int init_phy(struct net_device *dev)
421 if(curphy->init) { 492 if(curphy->init) {
422 err = curphy->init(priv->mii_info); 493 err = curphy->init(priv->mii_info);
423 494
424 if (err) 495 if (err)
425 goto phy_init_fail; 496 goto phy_init_fail;
426 } 497 }
427 498
@@ -446,14 +517,14 @@ static void init_registers(struct net_device *dev)
446 gfar_write(&priv->regs->imask, IMASK_INIT_CLEAR); 517 gfar_write(&priv->regs->imask, IMASK_INIT_CLEAR);
447 518
448 /* Init hash registers to zero */ 519 /* Init hash registers to zero */
449 gfar_write(&priv->regs->iaddr0, 0); 520 gfar_write(&priv->regs->igaddr0, 0);
450 gfar_write(&priv->regs->iaddr1, 0); 521 gfar_write(&priv->regs->igaddr1, 0);
451 gfar_write(&priv->regs->iaddr2, 0); 522 gfar_write(&priv->regs->igaddr2, 0);
452 gfar_write(&priv->regs->iaddr3, 0); 523 gfar_write(&priv->regs->igaddr3, 0);
453 gfar_write(&priv->regs->iaddr4, 0); 524 gfar_write(&priv->regs->igaddr4, 0);
454 gfar_write(&priv->regs->iaddr5, 0); 525 gfar_write(&priv->regs->igaddr5, 0);
455 gfar_write(&priv->regs->iaddr6, 0); 526 gfar_write(&priv->regs->igaddr6, 0);
456 gfar_write(&priv->regs->iaddr7, 0); 527 gfar_write(&priv->regs->igaddr7, 0);
457 528
458 gfar_write(&priv->regs->gaddr0, 0); 529 gfar_write(&priv->regs->gaddr0, 0);
459 gfar_write(&priv->regs->gaddr1, 0); 530 gfar_write(&priv->regs->gaddr1, 0);
@@ -464,9 +535,6 @@ static void init_registers(struct net_device *dev)
464 gfar_write(&priv->regs->gaddr6, 0); 535 gfar_write(&priv->regs->gaddr6, 0);
465 gfar_write(&priv->regs->gaddr7, 0); 536 gfar_write(&priv->regs->gaddr7, 0);
466 537
467 /* Zero out rctrl */
468 gfar_write(&priv->regs->rctrl, 0x00000000);
469
470 /* Zero out the rmon mib registers if it has them */ 538 /* Zero out the rmon mib registers if it has them */
471 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { 539 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
472 memset((void *) &(priv->regs->rmon), 0, 540 memset((void *) &(priv->regs->rmon), 0,
@@ -497,20 +565,14 @@ static void init_registers(struct net_device *dev)
497 gfar_write(&priv->regs->tbipa, TBIPA_VALUE); 565 gfar_write(&priv->regs->tbipa, TBIPA_VALUE);
498} 566}
499 567
500void stop_gfar(struct net_device *dev) 568
569/* Halt the receive and transmit queues */
570void gfar_halt(struct net_device *dev)
501{ 571{
502 struct gfar_private *priv = netdev_priv(dev); 572 struct gfar_private *priv = netdev_priv(dev);
503 struct gfar *regs = priv->regs; 573 struct gfar *regs = priv->regs;
504 unsigned long flags;
505 u32 tempval; 574 u32 tempval;
506 575
507 /* Lock it down */
508 spin_lock_irqsave(&priv->lock, flags);
509
510 /* Tell the kernel the link is down */
511 priv->mii_info->link = 0;
512 adjust_link(dev);
513
514 /* Mask all interrupts */ 576 /* Mask all interrupts */
515 gfar_write(&regs->imask, IMASK_INIT_CLEAR); 577 gfar_write(&regs->imask, IMASK_INIT_CLEAR);
516 578
@@ -533,13 +595,29 @@ void stop_gfar(struct net_device *dev)
533 tempval = gfar_read(&regs->maccfg1); 595 tempval = gfar_read(&regs->maccfg1);
534 tempval &= ~(MACCFG1_RX_EN | MACCFG1_TX_EN); 596 tempval &= ~(MACCFG1_RX_EN | MACCFG1_TX_EN);
535 gfar_write(&regs->maccfg1, tempval); 597 gfar_write(&regs->maccfg1, tempval);
598}
599
600void stop_gfar(struct net_device *dev)
601{
602 struct gfar_private *priv = netdev_priv(dev);
603 struct gfar *regs = priv->regs;
604 unsigned long flags;
605
606 /* Lock it down */
607 spin_lock_irqsave(&priv->lock, flags);
608
609 /* Tell the kernel the link is down */
610 priv->mii_info->link = 0;
611 adjust_link(dev);
612
613 gfar_halt(dev);
536 614
537 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR) { 615 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR) {
538 /* Clear any pending interrupts */ 616 /* Clear any pending interrupts */
539 mii_clear_phy_interrupt(priv->mii_info); 617 mii_clear_phy_interrupt(priv->mii_info);
540 618
541 /* Disable PHY Interrupts */ 619 /* Disable PHY Interrupts */
542 mii_configure_phy_interrupt(priv->mii_info, 620 mii_configure_phy_interrupt(priv->mii_info,
543 MII_INTERRUPT_DISABLED); 621 MII_INTERRUPT_DISABLED);
544 } 622 }
545 623
@@ -566,7 +644,7 @@ void stop_gfar(struct net_device *dev)
566 sizeof(struct txbd8)*priv->tx_ring_size 644 sizeof(struct txbd8)*priv->tx_ring_size
567 + sizeof(struct rxbd8)*priv->rx_ring_size, 645 + sizeof(struct rxbd8)*priv->rx_ring_size,
568 priv->tx_bd_base, 646 priv->tx_bd_base,
569 gfar_read(&regs->tbase)); 647 gfar_read(&regs->tbase0));
570} 648}
571 649
572/* If there are any tx skbs or rx skbs still around, free them. 650/* If there are any tx skbs or rx skbs still around, free them.
@@ -620,6 +698,34 @@ void free_skb_resources(struct gfar_private *priv)
620 } 698 }
621} 699}
622 700
701void gfar_start(struct net_device *dev)
702{
703 struct gfar_private *priv = netdev_priv(dev);
704 struct gfar *regs = priv->regs;
705 u32 tempval;
706
707 /* Enable Rx and Tx in MACCFG1 */
708 tempval = gfar_read(&regs->maccfg1);
709 tempval |= (MACCFG1_RX_EN | MACCFG1_TX_EN);
710 gfar_write(&regs->maccfg1, tempval);
711
712 /* Initialize DMACTRL to have WWR and WOP */
713 tempval = gfar_read(&priv->regs->dmactrl);
714 tempval |= DMACTRL_INIT_SETTINGS;
715 gfar_write(&priv->regs->dmactrl, tempval);
716
717 /* Clear THLT, so that the DMA starts polling now */
718 gfar_write(&regs->tstat, TSTAT_CLEAR_THALT);
719
720 /* Make sure we aren't stopped */
721 tempval = gfar_read(&priv->regs->dmactrl);
722 tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);
723 gfar_write(&priv->regs->dmactrl, tempval);
724
725 /* Unmask the interrupts we look for */
726 gfar_write(&regs->imask, IMASK_DEFAULT);
727}
728
623/* Bring the controller up and running */ 729/* Bring the controller up and running */
624int startup_gfar(struct net_device *dev) 730int startup_gfar(struct net_device *dev)
625{ 731{
@@ -630,33 +736,34 @@ int startup_gfar(struct net_device *dev)
630 int i; 736 int i;
631 struct gfar_private *priv = netdev_priv(dev); 737 struct gfar_private *priv = netdev_priv(dev);
632 struct gfar *regs = priv->regs; 738 struct gfar *regs = priv->regs;
633 u32 tempval;
634 int err = 0; 739 int err = 0;
740 u32 rctrl = 0;
635 741
636 gfar_write(&regs->imask, IMASK_INIT_CLEAR); 742 gfar_write(&regs->imask, IMASK_INIT_CLEAR);
637 743
638 /* Allocate memory for the buffer descriptors */ 744 /* Allocate memory for the buffer descriptors */
639 vaddr = (unsigned long) dma_alloc_coherent(NULL, 745 vaddr = (unsigned long) dma_alloc_coherent(NULL,
640 sizeof (struct txbd8) * priv->tx_ring_size + 746 sizeof (struct txbd8) * priv->tx_ring_size +
641 sizeof (struct rxbd8) * priv->rx_ring_size, 747 sizeof (struct rxbd8) * priv->rx_ring_size,
642 &addr, GFP_KERNEL); 748 &addr, GFP_KERNEL);
643 749
644 if (vaddr == 0) { 750 if (vaddr == 0) {
645 printk(KERN_ERR "%s: Could not allocate buffer descriptors!\n", 751 if (netif_msg_ifup(priv))
646 dev->name); 752 printk(KERN_ERR "%s: Could not allocate buffer descriptors!\n",
753 dev->name);
647 return -ENOMEM; 754 return -ENOMEM;
648 } 755 }
649 756
650 priv->tx_bd_base = (struct txbd8 *) vaddr; 757 priv->tx_bd_base = (struct txbd8 *) vaddr;
651 758
652 /* enet DMA only understands physical addresses */ 759 /* enet DMA only understands physical addresses */
653 gfar_write(&regs->tbase, addr); 760 gfar_write(&regs->tbase0, addr);
654 761
655 /* Start the rx descriptor ring where the tx ring leaves off */ 762 /* Start the rx descriptor ring where the tx ring leaves off */
656 addr = addr + sizeof (struct txbd8) * priv->tx_ring_size; 763 addr = addr + sizeof (struct txbd8) * priv->tx_ring_size;
657 vaddr = vaddr + sizeof (struct txbd8) * priv->tx_ring_size; 764 vaddr = vaddr + sizeof (struct txbd8) * priv->tx_ring_size;
658 priv->rx_bd_base = (struct rxbd8 *) vaddr; 765 priv->rx_bd_base = (struct rxbd8 *) vaddr;
659 gfar_write(&regs->rbase, addr); 766 gfar_write(&regs->rbase0, addr);
660 767
661 /* Setup the skbuff rings */ 768 /* Setup the skbuff rings */
662 priv->tx_skbuff = 769 priv->tx_skbuff =
@@ -664,8 +771,9 @@ int startup_gfar(struct net_device *dev)
664 priv->tx_ring_size, GFP_KERNEL); 771 priv->tx_ring_size, GFP_KERNEL);
665 772
666 if (priv->tx_skbuff == NULL) { 773 if (priv->tx_skbuff == NULL) {
667 printk(KERN_ERR "%s: Could not allocate tx_skbuff\n", 774 if (netif_msg_ifup(priv))
668 dev->name); 775 printk(KERN_ERR "%s: Could not allocate tx_skbuff\n",
776 dev->name);
669 err = -ENOMEM; 777 err = -ENOMEM;
670 goto tx_skb_fail; 778 goto tx_skb_fail;
671 } 779 }
@@ -678,8 +786,9 @@ int startup_gfar(struct net_device *dev)
678 priv->rx_ring_size, GFP_KERNEL); 786 priv->rx_ring_size, GFP_KERNEL);
679 787
680 if (priv->rx_skbuff == NULL) { 788 if (priv->rx_skbuff == NULL) {
681 printk(KERN_ERR "%s: Could not allocate rx_skbuff\n", 789 if (netif_msg_ifup(priv))
682 dev->name); 790 printk(KERN_ERR "%s: Could not allocate rx_skbuff\n",
791 dev->name);
683 err = -ENOMEM; 792 err = -ENOMEM;
684 goto rx_skb_fail; 793 goto rx_skb_fail;
685 } 794 }
@@ -726,12 +835,13 @@ int startup_gfar(struct net_device *dev)
726 /* If the device has multiple interrupts, register for 835 /* If the device has multiple interrupts, register for
727 * them. Otherwise, only register for the one */ 836 * them. Otherwise, only register for the one */
728 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { 837 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
729 /* Install our interrupt handlers for Error, 838 /* Install our interrupt handlers for Error,
730 * Transmit, and Receive */ 839 * Transmit, and Receive */
731 if (request_irq(priv->interruptError, gfar_error, 840 if (request_irq(priv->interruptError, gfar_error,
732 0, "enet_error", dev) < 0) { 841 0, "enet_error", dev) < 0) {
733 printk(KERN_ERR "%s: Can't get IRQ %d\n", 842 if (netif_msg_intr(priv))
734 dev->name, priv->interruptError); 843 printk(KERN_ERR "%s: Can't get IRQ %d\n",
844 dev->name, priv->interruptError);
735 845
736 err = -1; 846 err = -1;
737 goto err_irq_fail; 847 goto err_irq_fail;
@@ -739,8 +849,9 @@ int startup_gfar(struct net_device *dev)
739 849
740 if (request_irq(priv->interruptTransmit, gfar_transmit, 850 if (request_irq(priv->interruptTransmit, gfar_transmit,
741 0, "enet_tx", dev) < 0) { 851 0, "enet_tx", dev) < 0) {
742 printk(KERN_ERR "%s: Can't get IRQ %d\n", 852 if (netif_msg_intr(priv))
743 dev->name, priv->interruptTransmit); 853 printk(KERN_ERR "%s: Can't get IRQ %d\n",
854 dev->name, priv->interruptTransmit);
744 855
745 err = -1; 856 err = -1;
746 857
@@ -749,8 +860,9 @@ int startup_gfar(struct net_device *dev)
749 860
750 if (request_irq(priv->interruptReceive, gfar_receive, 861 if (request_irq(priv->interruptReceive, gfar_receive,
751 0, "enet_rx", dev) < 0) { 862 0, "enet_rx", dev) < 0) {
752 printk(KERN_ERR "%s: Can't get IRQ %d (receive0)\n", 863 if (netif_msg_intr(priv))
753 dev->name, priv->interruptReceive); 864 printk(KERN_ERR "%s: Can't get IRQ %d (receive0)\n",
865 dev->name, priv->interruptReceive);
754 866
755 err = -1; 867 err = -1;
756 goto rx_irq_fail; 868 goto rx_irq_fail;
@@ -758,8 +870,9 @@ int startup_gfar(struct net_device *dev)
758 } else { 870 } else {
759 if (request_irq(priv->interruptTransmit, gfar_interrupt, 871 if (request_irq(priv->interruptTransmit, gfar_interrupt,
760 0, "gfar_interrupt", dev) < 0) { 872 0, "gfar_interrupt", dev) < 0) {
761 printk(KERN_ERR "%s: Can't get IRQ %d\n", 873 if (netif_msg_intr(priv))
762 dev->name, priv->interruptError); 874 printk(KERN_ERR "%s: Can't get IRQ %d\n",
875 dev->name, priv->interruptError);
763 876
764 err = -1; 877 err = -1;
765 goto err_irq_fail; 878 goto err_irq_fail;
@@ -787,28 +900,22 @@ int startup_gfar(struct net_device *dev)
787 else 900 else
788 gfar_write(&regs->rxic, 0); 901 gfar_write(&regs->rxic, 0);
789 902
790 init_waitqueue_head(&priv->rxcleanupq); 903 if (priv->rx_csum_enable)
904 rctrl |= RCTRL_CHECKSUMMING;
791 905
792 /* Enable Rx and Tx in MACCFG1 */ 906 if (priv->extended_hash)
793 tempval = gfar_read(&regs->maccfg1); 907 rctrl |= RCTRL_EXTHASH;
794 tempval |= (MACCFG1_RX_EN | MACCFG1_TX_EN);
795 gfar_write(&regs->maccfg1, tempval);
796 908
797 /* Initialize DMACTRL to have WWR and WOP */ 909 if (priv->vlan_enable)
798 tempval = gfar_read(&priv->regs->dmactrl); 910 rctrl |= RCTRL_VLAN;
799 tempval |= DMACTRL_INIT_SETTINGS;
800 gfar_write(&priv->regs->dmactrl, tempval);
801 911
802 /* Clear THLT, so that the DMA starts polling now */ 912 /* Init rctrl based on our settings */
803 gfar_write(&regs->tstat, TSTAT_CLEAR_THALT); 913 gfar_write(&priv->regs->rctrl, rctrl);
804 914
805 /* Make sure we aren't stopped */ 915 if (dev->features & NETIF_F_IP_CSUM)
806 tempval = gfar_read(&priv->regs->dmactrl); 916 gfar_write(&priv->regs->tctrl, TCTRL_INIT_CSUM);
807 tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);
808 gfar_write(&priv->regs->dmactrl, tempval);
809 917
810 /* Unmask the interrupts we look for */ 918 gfar_start(dev);
811 gfar_write(&regs->imask, IMASK_DEFAULT);
812 919
813 return 0; 920 return 0;
814 921
@@ -824,7 +931,7 @@ tx_skb_fail:
824 sizeof(struct txbd8)*priv->tx_ring_size 931 sizeof(struct txbd8)*priv->tx_ring_size
825 + sizeof(struct rxbd8)*priv->rx_ring_size, 932 + sizeof(struct rxbd8)*priv->rx_ring_size,
826 priv->tx_bd_base, 933 priv->tx_bd_base,
827 gfar_read(&regs->tbase)); 934 gfar_read(&regs->tbase0));
828 935
829 if (priv->mii_info->phyinfo->close) 936 if (priv->mii_info->phyinfo->close)
830 priv->mii_info->phyinfo->close(priv->mii_info); 937 priv->mii_info->phyinfo->close(priv->mii_info);
@@ -857,11 +964,62 @@ static int gfar_enet_open(struct net_device *dev)
857 return err; 964 return err;
858} 965}
859 966
967static struct txfcb *gfar_add_fcb(struct sk_buff *skb, struct txbd8 *bdp)
968{
969 struct txfcb *fcb = (struct txfcb *)skb_push (skb, GMAC_FCB_LEN);
970
971 memset(fcb, 0, GMAC_FCB_LEN);
972
973 /* Flag the bd so the controller looks for the FCB */
974 bdp->status |= TXBD_TOE;
975
976 return fcb;
977}
978
979static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
980{
981 int len;
982
983 /* If we're here, it's a IP packet with a TCP or UDP
984 * payload. We set it to checksum, using a pseudo-header
985 * we provide
986 */
987 fcb->ip = 1;
988 fcb->tup = 1;
989 fcb->ctu = 1;
990 fcb->nph = 1;
991
992 /* Notify the controller what the protocol is */
993 if (skb->nh.iph->protocol == IPPROTO_UDP)
994 fcb->udp = 1;
995
996 /* l3os is the distance between the start of the
997 * frame (skb->data) and the start of the IP hdr.
998 * l4os is the distance between the start of the
999 * l3 hdr and the l4 hdr */
1000 fcb->l3os = (u16)(skb->nh.raw - skb->data - GMAC_FCB_LEN);
1001 fcb->l4os = (u16)(skb->h.raw - skb->nh.raw);
1002
1003 len = skb->nh.iph->tot_len - fcb->l4os;
1004
1005 /* Provide the pseudoheader csum */
1006 fcb->phcs = ~csum_tcpudp_magic(skb->nh.iph->saddr,
1007 skb->nh.iph->daddr, len,
1008 skb->nh.iph->protocol, 0);
1009}
1010
1011void gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb)
1012{
1013 fcb->vln = 1;
1014 fcb->vlctl = vlan_tx_tag_get(skb);
1015}
1016
860/* This is called by the kernel when a frame is ready for transmission. */ 1017/* This is called by the kernel when a frame is ready for transmission. */
861/* It is pointed to by the dev->hard_start_xmit function pointer */ 1018/* It is pointed to by the dev->hard_start_xmit function pointer */
862static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) 1019static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
863{ 1020{
864 struct gfar_private *priv = netdev_priv(dev); 1021 struct gfar_private *priv = netdev_priv(dev);
1022 struct txfcb *fcb = NULL;
865 struct txbd8 *txbdp; 1023 struct txbd8 *txbdp;
866 1024
867 /* Update transmit stats */ 1025 /* Update transmit stats */
@@ -876,9 +1034,24 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
876 /* Clear all but the WRAP status flags */ 1034 /* Clear all but the WRAP status flags */
877 txbdp->status &= TXBD_WRAP; 1035 txbdp->status &= TXBD_WRAP;
878 1036
1037 /* Set up checksumming */
1038 if ((dev->features & NETIF_F_IP_CSUM)
1039 && (CHECKSUM_HW == skb->ip_summed)) {
1040 fcb = gfar_add_fcb(skb, txbdp);
1041 gfar_tx_checksum(skb, fcb);
1042 }
1043
1044 if (priv->vlan_enable &&
1045 unlikely(priv->vlgrp && vlan_tx_tag_present(skb))) {
1046 if (NULL == fcb)
1047 fcb = gfar_add_fcb(skb, txbdp);
1048
1049 gfar_tx_vlan(skb, fcb);
1050 }
1051
879 /* Set buffer length and pointer */ 1052 /* Set buffer length and pointer */
880 txbdp->length = skb->len; 1053 txbdp->length = skb->len;
881 txbdp->bufPtr = dma_map_single(NULL, skb->data, 1054 txbdp->bufPtr = dma_map_single(NULL, skb->data,
882 skb->len, DMA_TO_DEVICE); 1055 skb->len, DMA_TO_DEVICE);
883 1056
884 /* Save the skb pointer so we can free it later */ 1057 /* Save the skb pointer so we can free it later */
@@ -972,15 +1145,78 @@ int gfar_set_mac_address(struct net_device *dev)
972} 1145}
973 1146
974 1147
1148/* Enables and disables VLAN insertion/extraction */
1149static void gfar_vlan_rx_register(struct net_device *dev,
1150 struct vlan_group *grp)
1151{
1152 struct gfar_private *priv = netdev_priv(dev);
1153 unsigned long flags;
1154 u32 tempval;
1155
1156 spin_lock_irqsave(&priv->lock, flags);
1157
1158 priv->vlgrp = grp;
1159
1160 if (grp) {
1161 /* Enable VLAN tag insertion */
1162 tempval = gfar_read(&priv->regs->tctrl);
1163 tempval |= TCTRL_VLINS;
1164
1165 gfar_write(&priv->regs->tctrl, tempval);
1166
1167 /* Enable VLAN tag extraction */
1168 tempval = gfar_read(&priv->regs->rctrl);
1169 tempval |= RCTRL_VLEX;
1170 gfar_write(&priv->regs->rctrl, tempval);
1171 } else {
1172 /* Disable VLAN tag insertion */
1173 tempval = gfar_read(&priv->regs->tctrl);
1174 tempval &= ~TCTRL_VLINS;
1175 gfar_write(&priv->regs->tctrl, tempval);
1176
1177 /* Disable VLAN tag extraction */
1178 tempval = gfar_read(&priv->regs->rctrl);
1179 tempval &= ~RCTRL_VLEX;
1180 gfar_write(&priv->regs->rctrl, tempval);
1181 }
1182
1183 spin_unlock_irqrestore(&priv->lock, flags);
1184}
1185
1186
1187static void gfar_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
1188{
1189 struct gfar_private *priv = netdev_priv(dev);
1190 unsigned long flags;
1191
1192 spin_lock_irqsave(&priv->lock, flags);
1193
1194 if (priv->vlgrp)
1195 priv->vlgrp->vlan_devices[vid] = NULL;
1196
1197 spin_unlock_irqrestore(&priv->lock, flags);
1198}
1199
1200
975static int gfar_change_mtu(struct net_device *dev, int new_mtu) 1201static int gfar_change_mtu(struct net_device *dev, int new_mtu)
976{ 1202{
977 int tempsize, tempval; 1203 int tempsize, tempval;
978 struct gfar_private *priv = netdev_priv(dev); 1204 struct gfar_private *priv = netdev_priv(dev);
979 int oldsize = priv->rx_buffer_size; 1205 int oldsize = priv->rx_buffer_size;
980 int frame_size = new_mtu + 18; 1206 int frame_size = new_mtu + ETH_HLEN;
1207
1208 if (priv->vlan_enable)
1209 frame_size += VLAN_ETH_HLEN;
1210
1211 if (gfar_uses_fcb(priv))
1212 frame_size += GMAC_FCB_LEN;
1213
1214 frame_size += priv->padding;
981 1215
982 if ((frame_size < 64) || (frame_size > JUMBO_FRAME_SIZE)) { 1216 if ((frame_size < 64) || (frame_size > JUMBO_FRAME_SIZE)) {
983 printk(KERN_ERR "%s: Invalid MTU setting\n", dev->name); 1217 if (netif_msg_drv(priv))
1218 printk(KERN_ERR "%s: Invalid MTU setting\n",
1219 dev->name);
984 return -EINVAL; 1220 return -EINVAL;
985 } 1221 }
986 1222
@@ -1120,7 +1356,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
1120 skb->dev = dev; 1356 skb->dev = dev;
1121 1357
1122 bdp->bufPtr = dma_map_single(NULL, skb->data, 1358 bdp->bufPtr = dma_map_single(NULL, skb->data,
1123 priv->rx_buffer_size + RXBUF_ALIGNMENT, 1359 priv->rx_buffer_size + RXBUF_ALIGNMENT,
1124 DMA_FROM_DEVICE); 1360 DMA_FROM_DEVICE);
1125 1361
1126 bdp->length = 0; 1362 bdp->length = 0;
@@ -1190,11 +1426,10 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs)
1190 1426
1191 __netif_rx_schedule(dev); 1427 __netif_rx_schedule(dev);
1192 } else { 1428 } else {
1193#ifdef VERBOSE_GFAR_ERRORS 1429 if (netif_msg_rx_err(priv))
1194 printk(KERN_DEBUG "%s: receive called twice (%x)[%x]\n", 1430 printk(KERN_DEBUG "%s: receive called twice (%x)[%x]\n",
1195 dev->name, gfar_read(&priv->regs->ievent), 1431 dev->name, gfar_read(&priv->regs->ievent),
1196 gfar_read(&priv->regs->imask)); 1432 gfar_read(&priv->regs->imask));
1197#endif
1198 } 1433 }
1199#else 1434#else
1200 1435
@@ -1209,15 +1444,43 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs)
1209 else 1444 else
1210 gfar_write(&priv->regs->rxic, 0); 1445 gfar_write(&priv->regs->rxic, 0);
1211 1446
1212 /* Just in case we need to wake the ring param changer */
1213 priv->rxclean = 1;
1214
1215 spin_unlock(&priv->lock); 1447 spin_unlock(&priv->lock);
1216#endif 1448#endif
1217 1449
1218 return IRQ_HANDLED; 1450 return IRQ_HANDLED;
1219} 1451}
1220 1452
1453static inline int gfar_rx_vlan(struct sk_buff *skb,
1454 struct vlan_group *vlgrp, unsigned short vlctl)
1455{
1456#ifdef CONFIG_GFAR_NAPI
1457 return vlan_hwaccel_receive_skb(skb, vlgrp, vlctl);
1458#else
1459 return vlan_hwaccel_rx(skb, vlgrp, vlctl);
1460#endif
1461}
1462
1463static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb)
1464{
1465 /* If valid headers were found, and valid sums
1466 * were verified, then we tell the kernel that no
1467 * checksumming is necessary. Otherwise, it is */
1468 if (fcb->cip && !fcb->eip && fcb->ctu && !fcb->etu)
1469 skb->ip_summed = CHECKSUM_UNNECESSARY;
1470 else
1471 skb->ip_summed = CHECKSUM_NONE;
1472}
1473
1474
1475static inline struct rxfcb *gfar_get_fcb(struct sk_buff *skb)
1476{
1477 struct rxfcb *fcb = (struct rxfcb *)skb->data;
1478
1479 /* Remove the FCB from the skb */
1480 skb_pull(skb, GMAC_FCB_LEN);
1481
1482 return fcb;
1483}
1221 1484
1222/* gfar_process_frame() -- handle one incoming packet if skb 1485/* gfar_process_frame() -- handle one incoming packet if skb
1223 * isn't NULL. */ 1486 * isn't NULL. */
@@ -1225,35 +1488,51 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
1225 int length) 1488 int length)
1226{ 1489{
1227 struct gfar_private *priv = netdev_priv(dev); 1490 struct gfar_private *priv = netdev_priv(dev);
1491 struct rxfcb *fcb = NULL;
1228 1492
1229 if (skb == NULL) { 1493 if (skb == NULL) {
1230#ifdef BRIEF_GFAR_ERRORS 1494 if (netif_msg_rx_err(priv))
1231 printk(KERN_WARNING "%s: Missing skb!!.\n", 1495 printk(KERN_WARNING "%s: Missing skb!!.\n", dev->name);
1232 dev->name);
1233#endif
1234 priv->stats.rx_dropped++; 1496 priv->stats.rx_dropped++;
1235 priv->extra_stats.rx_skbmissing++; 1497 priv->extra_stats.rx_skbmissing++;
1236 } else { 1498 } else {
1499 int ret;
1500
1237 /* Prep the skb for the packet */ 1501 /* Prep the skb for the packet */
1238 skb_put(skb, length); 1502 skb_put(skb, length);
1239 1503
1504 /* Grab the FCB if there is one */
1505 if (gfar_uses_fcb(priv))
1506 fcb = gfar_get_fcb(skb);
1507
1508 /* Remove the padded bytes, if there are any */
1509 if (priv->padding)
1510 skb_pull(skb, priv->padding);
1511
1512 if (priv->rx_csum_enable)
1513 gfar_rx_checksum(skb, fcb);
1514
1240 /* Tell the skb what kind of packet this is */ 1515 /* Tell the skb what kind of packet this is */
1241 skb->protocol = eth_type_trans(skb, dev); 1516 skb->protocol = eth_type_trans(skb, dev);
1242 1517
1243 /* Send the packet up the stack */ 1518 /* Send the packet up the stack */
1244 if (RECEIVE(skb) == NET_RX_DROP) { 1519 if (unlikely(priv->vlgrp && fcb->vln))
1520 ret = gfar_rx_vlan(skb, priv->vlgrp, fcb->vlctl);
1521 else
1522 ret = RECEIVE(skb);
1523
1524 if (NET_RX_DROP == ret)
1245 priv->extra_stats.kernel_dropped++; 1525 priv->extra_stats.kernel_dropped++;
1246 }
1247 } 1526 }
1248 1527
1249 return 0; 1528 return 0;
1250} 1529}
1251 1530
1252/* gfar_clean_rx_ring() -- Processes each frame in the rx ring 1531/* gfar_clean_rx_ring() -- Processes each frame in the rx ring
1253 * until the budget/quota has been reached. Returns the number 1532 * until the budget/quota has been reached. Returns the number
1254 * of frames handled 1533 * of frames handled
1255 */ 1534 */
1256static int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit) 1535int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
1257{ 1536{
1258 struct rxbd8 *bdp; 1537 struct rxbd8 *bdp;
1259 struct sk_buff *skb; 1538 struct sk_buff *skb;
@@ -1355,9 +1634,6 @@ static int gfar_poll(struct net_device *dev, int *budget)
1355 mk_ic_value(priv->rxcount, priv->rxtime)); 1634 mk_ic_value(priv->rxcount, priv->rxtime));
1356 else 1635 else
1357 gfar_write(&priv->regs->rxic, 0); 1636 gfar_write(&priv->regs->rxic, 0);
1358
1359 /* Signal to the ring size changer that it's safe to go */
1360 priv->rxclean = 1;
1361 } 1637 }
1362 1638
1363 return (rx_work_limit < 0) ? 1 : 0; 1639 return (rx_work_limit < 0) ? 1 : 0;
@@ -1393,10 +1669,8 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1393 if (events & IEVENT_CRL) 1669 if (events & IEVENT_CRL)
1394 priv->stats.tx_aborted_errors++; 1670 priv->stats.tx_aborted_errors++;
1395 if (events & IEVENT_XFUN) { 1671 if (events & IEVENT_XFUN) {
1396#ifdef VERBOSE_GFAR_ERRORS 1672 if (netif_msg_tx_err(priv))
1397 printk(KERN_WARNING "%s: tx underrun. dropped packet\n", 1673 printk(KERN_WARNING "%s: tx underrun. dropped packet\n", dev->name);
1398 dev->name);
1399#endif
1400 priv->stats.tx_dropped++; 1674 priv->stats.tx_dropped++;
1401 priv->extra_stats.tx_underrun++; 1675 priv->extra_stats.tx_underrun++;
1402 1676
@@ -1415,36 +1689,30 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1415 gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT); 1689 gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT);
1416#endif 1690#endif
1417 1691
1418#ifdef VERBOSE_GFAR_ERRORS 1692 if (netif_msg_rx_err(priv))
1419 printk(KERN_DEBUG "%s: busy error (rhalt: %x)\n", dev->name, 1693 printk(KERN_DEBUG "%s: busy error (rhalt: %x)\n",
1420 gfar_read(&priv->regs->rstat)); 1694 dev->name,
1421#endif 1695 gfar_read(&priv->regs->rstat));
1422 } 1696 }
1423 if (events & IEVENT_BABR) { 1697 if (events & IEVENT_BABR) {
1424 priv->stats.rx_errors++; 1698 priv->stats.rx_errors++;
1425 priv->extra_stats.rx_babr++; 1699 priv->extra_stats.rx_babr++;
1426 1700
1427#ifdef VERBOSE_GFAR_ERRORS 1701 if (netif_msg_rx_err(priv))
1428 printk(KERN_DEBUG "%s: babbling error\n", dev->name); 1702 printk(KERN_DEBUG "%s: babbling error\n", dev->name);
1429#endif
1430 } 1703 }
1431 if (events & IEVENT_EBERR) { 1704 if (events & IEVENT_EBERR) {
1432 priv->extra_stats.eberr++; 1705 priv->extra_stats.eberr++;
1433#ifdef VERBOSE_GFAR_ERRORS 1706 if (netif_msg_rx_err(priv))
1434 printk(KERN_DEBUG "%s: EBERR\n", dev->name); 1707 printk(KERN_DEBUG "%s: EBERR\n", dev->name);
1435#endif
1436 }
1437 if (events & IEVENT_RXC) {
1438#ifdef VERBOSE_GFAR_ERRORS
1439 printk(KERN_DEBUG "%s: control frame\n", dev->name);
1440#endif
1441 } 1708 }
1709 if ((events & IEVENT_RXC) && (netif_msg_rx_err(priv)))
1710 printk(KERN_DEBUG "%s: control frame\n", dev->name);
1442 1711
1443 if (events & IEVENT_BABT) { 1712 if (events & IEVENT_BABT) {
1444 priv->extra_stats.tx_babt++; 1713 priv->extra_stats.tx_babt++;
1445#ifdef VERBOSE_GFAR_ERRORS 1714 if (netif_msg_rx_err(priv))
1446 printk(KERN_DEBUG "%s: babt error\n", dev->name); 1715 printk(KERN_DEBUG "%s: babt error\n", dev->name);
1447#endif
1448 } 1716 }
1449 1717
1450 return IRQ_HANDLED; 1718 return IRQ_HANDLED;
@@ -1510,7 +1778,7 @@ static void gfar_phy_timer(unsigned long data)
1510 * If, after GFAR_AN_TIMEOUT seconds, it has not 1778 * If, after GFAR_AN_TIMEOUT seconds, it has not
1511 * finished, we switch to forced. 1779 * finished, we switch to forced.
1512 * Either way, once the process has completed, we either 1780 * Either way, once the process has completed, we either
1513 * request the interrupt, or switch the timer over to 1781 * request the interrupt, or switch the timer over to
1514 * using gfar_phy_timer to check status */ 1782 * using gfar_phy_timer to check status */
1515static void gfar_phy_startup_timer(unsigned long data) 1783static void gfar_phy_startup_timer(unsigned long data)
1516{ 1784{
@@ -1535,8 +1803,9 @@ static void gfar_phy_startup_timer(unsigned long data)
1535 1803
1536 /* Forcing failed! Give up */ 1804 /* Forcing failed! Give up */
1537 if(result) { 1805 if(result) {
1538 printk(KERN_ERR "%s: Forcing failed!\n", 1806 if (netif_msg_link(priv))
1539 mii_info->dev->name); 1807 printk(KERN_ERR "%s: Forcing failed!\n",
1808 mii_info->dev->name);
1540 return; 1809 return;
1541 } 1810 }
1542 } 1811 }
@@ -1546,16 +1815,17 @@ static void gfar_phy_startup_timer(unsigned long data)
1546 1815
1547 /* Grab the PHY interrupt, if necessary/possible */ 1816 /* Grab the PHY interrupt, if necessary/possible */
1548 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR) { 1817 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR) {
1549 if (request_irq(priv->einfo->interruptPHY, 1818 if (request_irq(priv->einfo->interruptPHY,
1550 phy_interrupt, 1819 phy_interrupt,
1551 SA_SHIRQ, 1820 SA_SHIRQ,
1552 "phy_interrupt", 1821 "phy_interrupt",
1553 mii_info->dev) < 0) { 1822 mii_info->dev) < 0) {
1554 printk(KERN_ERR "%s: Can't get IRQ %d (PHY)\n", 1823 if (netif_msg_intr(priv))
1555 mii_info->dev->name, 1824 printk(KERN_ERR "%s: Can't get IRQ %d (PHY)\n",
1825 mii_info->dev->name,
1556 priv->einfo->interruptPHY); 1826 priv->einfo->interruptPHY);
1557 } else { 1827 } else {
1558 mii_configure_phy_interrupt(priv->mii_info, 1828 mii_configure_phy_interrupt(priv->mii_info,
1559 MII_INTERRUPT_ENABLED); 1829 MII_INTERRUPT_ENABLED);
1560 return; 1830 return;
1561 } 1831 }
@@ -1592,15 +1862,17 @@ static void adjust_link(struct net_device *dev)
1592 tempval &= ~(MACCFG2_FULL_DUPLEX); 1862 tempval &= ~(MACCFG2_FULL_DUPLEX);
1593 gfar_write(&regs->maccfg2, tempval); 1863 gfar_write(&regs->maccfg2, tempval);
1594 1864
1595 printk(KERN_INFO "%s: Half Duplex\n", 1865 if (netif_msg_link(priv))
1596 dev->name); 1866 printk(KERN_INFO "%s: Half Duplex\n",
1867 dev->name);
1597 } else { 1868 } else {
1598 tempval = gfar_read(&regs->maccfg2); 1869 tempval = gfar_read(&regs->maccfg2);
1599 tempval |= MACCFG2_FULL_DUPLEX; 1870 tempval |= MACCFG2_FULL_DUPLEX;
1600 gfar_write(&regs->maccfg2, tempval); 1871 gfar_write(&regs->maccfg2, tempval);
1601 1872
1602 printk(KERN_INFO "%s: Full Duplex\n", 1873 if (netif_msg_link(priv))
1603 dev->name); 1874 printk(KERN_INFO "%s: Full Duplex\n",
1875 dev->name);
1604 } 1876 }
1605 1877
1606 priv->oldduplex = mii_info->duplex; 1878 priv->oldduplex = mii_info->duplex;
@@ -1622,27 +1894,32 @@ static void adjust_link(struct net_device *dev)
1622 gfar_write(&regs->maccfg2, tempval); 1894 gfar_write(&regs->maccfg2, tempval);
1623 break; 1895 break;
1624 default: 1896 default:
1625 printk(KERN_WARNING 1897 if (netif_msg_link(priv))
1626 "%s: Ack! Speed (%d) is not 10/100/1000!\n", 1898 printk(KERN_WARNING
1627 dev->name, mii_info->speed); 1899 "%s: Ack! Speed (%d) is not 10/100/1000!\n",
1900 dev->name, mii_info->speed);
1628 break; 1901 break;
1629 } 1902 }
1630 1903
1631 printk(KERN_INFO "%s: Speed %dBT\n", dev->name, 1904 if (netif_msg_link(priv))
1632 mii_info->speed); 1905 printk(KERN_INFO "%s: Speed %dBT\n", dev->name,
1906 mii_info->speed);
1633 1907
1634 priv->oldspeed = mii_info->speed; 1908 priv->oldspeed = mii_info->speed;
1635 } 1909 }
1636 1910
1637 if (!priv->oldlink) { 1911 if (!priv->oldlink) {
1638 printk(KERN_INFO "%s: Link is up\n", dev->name); 1912 if (netif_msg_link(priv))
1913 printk(KERN_INFO "%s: Link is up\n", dev->name);
1639 priv->oldlink = 1; 1914 priv->oldlink = 1;
1640 netif_carrier_on(dev); 1915 netif_carrier_on(dev);
1641 netif_schedule(dev); 1916 netif_schedule(dev);
1642 } 1917 }
1643 } else { 1918 } else {
1644 if (priv->oldlink) { 1919 if (priv->oldlink) {
1645 printk(KERN_INFO "%s: Link is down\n", dev->name); 1920 if (netif_msg_link(priv))
1921 printk(KERN_INFO "%s: Link is down\n",
1922 dev->name);
1646 priv->oldlink = 0; 1923 priv->oldlink = 0;
1647 priv->oldspeed = 0; 1924 priv->oldspeed = 0;
1648 priv->oldduplex = -1; 1925 priv->oldduplex = -1;
@@ -1664,8 +1941,9 @@ static void gfar_set_multi(struct net_device *dev)
1664 u32 tempval; 1941 u32 tempval;
1665 1942
1666 if(dev->flags & IFF_PROMISC) { 1943 if(dev->flags & IFF_PROMISC) {
1667 printk(KERN_INFO "%s: Entering promiscuous mode.\n", 1944 if (netif_msg_drv(priv))
1668 dev->name); 1945 printk(KERN_INFO "%s: Entering promiscuous mode.\n",
1946 dev->name);
1669 /* Set RCTRL to PROM */ 1947 /* Set RCTRL to PROM */
1670 tempval = gfar_read(&regs->rctrl); 1948 tempval = gfar_read(&regs->rctrl);
1671 tempval |= RCTRL_PROM; 1949 tempval |= RCTRL_PROM;
@@ -1679,6 +1957,14 @@ static void gfar_set_multi(struct net_device *dev)
1679 1957
1680 if(dev->flags & IFF_ALLMULTI) { 1958 if(dev->flags & IFF_ALLMULTI) {
1681 /* Set the hash to rx all multicast frames */ 1959 /* Set the hash to rx all multicast frames */
1960 gfar_write(&regs->igaddr0, 0xffffffff);
1961 gfar_write(&regs->igaddr1, 0xffffffff);
1962 gfar_write(&regs->igaddr2, 0xffffffff);
1963 gfar_write(&regs->igaddr3, 0xffffffff);
1964 gfar_write(&regs->igaddr4, 0xffffffff);
1965 gfar_write(&regs->igaddr5, 0xffffffff);
1966 gfar_write(&regs->igaddr6, 0xffffffff);
1967 gfar_write(&regs->igaddr7, 0xffffffff);
1682 gfar_write(&regs->gaddr0, 0xffffffff); 1968 gfar_write(&regs->gaddr0, 0xffffffff);
1683 gfar_write(&regs->gaddr1, 0xffffffff); 1969 gfar_write(&regs->gaddr1, 0xffffffff);
1684 gfar_write(&regs->gaddr2, 0xffffffff); 1970 gfar_write(&regs->gaddr2, 0xffffffff);
@@ -1689,6 +1975,14 @@ static void gfar_set_multi(struct net_device *dev)
1689 gfar_write(&regs->gaddr7, 0xffffffff); 1975 gfar_write(&regs->gaddr7, 0xffffffff);
1690 } else { 1976 } else {
1691 /* zero out the hash */ 1977 /* zero out the hash */
1978 gfar_write(&regs->igaddr0, 0x0);
1979 gfar_write(&regs->igaddr1, 0x0);
1980 gfar_write(&regs->igaddr2, 0x0);
1981 gfar_write(&regs->igaddr3, 0x0);
1982 gfar_write(&regs->igaddr4, 0x0);
1983 gfar_write(&regs->igaddr5, 0x0);
1984 gfar_write(&regs->igaddr6, 0x0);
1985 gfar_write(&regs->igaddr7, 0x0);
1692 gfar_write(&regs->gaddr0, 0x0); 1986 gfar_write(&regs->gaddr0, 0x0);
1693 gfar_write(&regs->gaddr1, 0x0); 1987 gfar_write(&regs->gaddr1, 0x0);
1694 gfar_write(&regs->gaddr2, 0x0); 1988 gfar_write(&regs->gaddr2, 0x0);
@@ -1727,16 +2021,15 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr)
1727{ 2021{
1728 u32 tempval; 2022 u32 tempval;
1729 struct gfar_private *priv = netdev_priv(dev); 2023 struct gfar_private *priv = netdev_priv(dev);
1730 struct gfar *regs = priv->regs;
1731 u32 *hash = &regs->gaddr0;
1732 u32 result = ether_crc(MAC_ADDR_LEN, addr); 2024 u32 result = ether_crc(MAC_ADDR_LEN, addr);
1733 u8 whichreg = ((result >> 29) & 0x7); 2025 int width = priv->hash_width;
1734 u8 whichbit = ((result >> 24) & 0x1f); 2026 u8 whichbit = (result >> (32 - width)) & 0x1f;
2027 u8 whichreg = result >> (32 - width + 5);
1735 u32 value = (1 << (31-whichbit)); 2028 u32 value = (1 << (31-whichbit));
1736 2029
1737 tempval = gfar_read(&hash[whichreg]); 2030 tempval = gfar_read(priv->hash_regs[whichreg]);
1738 tempval |= value; 2031 tempval |= value;
1739 gfar_write(&hash[whichreg], tempval); 2032 gfar_write(priv->hash_regs[whichreg], tempval);
1740 2033
1741 return; 2034 return;
1742} 2035}
@@ -1754,10 +2047,9 @@ static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs)
1754 gfar_write(&priv->regs->ievent, IEVENT_ERR_MASK); 2047 gfar_write(&priv->regs->ievent, IEVENT_ERR_MASK);
1755 2048
1756 /* Hmm... */ 2049 /* Hmm... */
1757#if defined (BRIEF_GFAR_ERRORS) || defined (VERBOSE_GFAR_ERRORS) 2050 if (netif_msg_rx_err(priv) || netif_msg_tx_err(priv))
1758 printk(KERN_DEBUG "%s: error interrupt (ievent=0x%08x imask=0x%08x)\n", 2051 printk(KERN_DEBUG "%s: error interrupt (ievent=0x%08x imask=0x%08x)\n",
1759 dev->name, events, gfar_read(&priv->regs->imask)); 2052 dev->name, events, gfar_read(&priv->regs->imask));
1760#endif
1761 2053
1762 /* Update the error counters */ 2054 /* Update the error counters */
1763 if (events & IEVENT_TXE) { 2055 if (events & IEVENT_TXE) {
@@ -1768,19 +2060,17 @@ static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs)
1768 if (events & IEVENT_CRL) 2060 if (events & IEVENT_CRL)
1769 priv->stats.tx_aborted_errors++; 2061 priv->stats.tx_aborted_errors++;
1770 if (events & IEVENT_XFUN) { 2062 if (events & IEVENT_XFUN) {
1771#ifdef VERBOSE_GFAR_ERRORS 2063 if (netif_msg_tx_err(priv))
1772 printk(KERN_DEBUG "%s: underrun. packet dropped.\n", 2064 printk(KERN_DEBUG "%s: underrun. packet dropped.\n",
1773 dev->name); 2065 dev->name);
1774#endif
1775 priv->stats.tx_dropped++; 2066 priv->stats.tx_dropped++;
1776 priv->extra_stats.tx_underrun++; 2067 priv->extra_stats.tx_underrun++;
1777 2068
1778 /* Reactivate the Tx Queues */ 2069 /* Reactivate the Tx Queues */
1779 gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT); 2070 gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT);
1780 } 2071 }
1781#ifdef VERBOSE_GFAR_ERRORS 2072 if (netif_msg_tx_err(priv))
1782 printk(KERN_DEBUG "%s: Transmit Error\n", dev->name); 2073 printk(KERN_DEBUG "%s: Transmit Error\n", dev->name);
1783#endif
1784 } 2074 }
1785 if (events & IEVENT_BSY) { 2075 if (events & IEVENT_BSY) {
1786 priv->stats.rx_errors++; 2076 priv->stats.rx_errors++;
@@ -1793,35 +2083,31 @@ static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs)
1793 gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT); 2083 gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT);
1794#endif 2084#endif
1795 2085
1796#ifdef VERBOSE_GFAR_ERRORS 2086 if (netif_msg_rx_err(priv))
1797 printk(KERN_DEBUG "%s: busy error (rhalt: %x)\n", dev->name, 2087 printk(KERN_DEBUG "%s: busy error (rhalt: %x)\n",
1798 gfar_read(&priv->regs->rstat)); 2088 dev->name,
1799#endif 2089 gfar_read(&priv->regs->rstat));
1800 } 2090 }
1801 if (events & IEVENT_BABR) { 2091 if (events & IEVENT_BABR) {
1802 priv->stats.rx_errors++; 2092 priv->stats.rx_errors++;
1803 priv->extra_stats.rx_babr++; 2093 priv->extra_stats.rx_babr++;
1804 2094
1805#ifdef VERBOSE_GFAR_ERRORS 2095 if (netif_msg_rx_err(priv))
1806 printk(KERN_DEBUG "%s: babbling error\n", dev->name); 2096 printk(KERN_DEBUG "%s: babbling error\n", dev->name);
1807#endif
1808 } 2097 }
1809 if (events & IEVENT_EBERR) { 2098 if (events & IEVENT_EBERR) {
1810 priv->extra_stats.eberr++; 2099 priv->extra_stats.eberr++;
1811#ifdef VERBOSE_GFAR_ERRORS 2100 if (netif_msg_rx_err(priv))
1812 printk(KERN_DEBUG "%s: EBERR\n", dev->name); 2101 printk(KERN_DEBUG "%s: EBERR\n", dev->name);
1813#endif
1814 } 2102 }
1815 if (events & IEVENT_RXC) 2103 if ((events & IEVENT_RXC) && netif_msg_rx_status(priv))
1816#ifdef VERBOSE_GFAR_ERRORS 2104 if (netif_msg_rx_status(priv))
1817 printk(KERN_DEBUG "%s: control frame\n", dev->name); 2105 printk(KERN_DEBUG "%s: control frame\n", dev->name);
1818#endif
1819 2106
1820 if (events & IEVENT_BABT) { 2107 if (events & IEVENT_BABT) {
1821 priv->extra_stats.tx_babt++; 2108 priv->extra_stats.tx_babt++;
1822#ifdef VERBOSE_GFAR_ERRORS 2109 if (netif_msg_tx_err(priv))
1823 printk(KERN_DEBUG "%s: babt error\n", dev->name); 2110 printk(KERN_DEBUG "%s: babt error\n", dev->name);
1824#endif
1825 } 2111 }
1826 return IRQ_HANDLED; 2112 return IRQ_HANDLED;
1827} 2113}
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index c2f783a6a9fa..28af087d9fbb 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * drivers/net/gianfar.h 2 * drivers/net/gianfar.h
3 * 3 *
4 * Gianfar Ethernet Driver 4 * Gianfar Ethernet Driver
@@ -53,6 +53,12 @@
53/* The maximum number of packets to be handled in one call of gfar_poll */ 53/* The maximum number of packets to be handled in one call of gfar_poll */
54#define GFAR_DEV_WEIGHT 64 54#define GFAR_DEV_WEIGHT 64
55 55
56/* Length for FCB */
57#define GMAC_FCB_LEN 8
58
59/* Default padding amount */
60#define DEFAULT_PADDING 2
61
56/* Number of bytes to align the rx bufs to */ 62/* Number of bytes to align the rx bufs to */
57#define RXBUF_ALIGNMENT 64 63#define RXBUF_ALIGNMENT 64
58 64
@@ -91,7 +97,7 @@ extern const char gfar_driver_version[];
91#define JUMBO_FRAME_SIZE 9600 97#define JUMBO_FRAME_SIZE 9600
92 98
93/* Latency of interface clock in nanoseconds */ 99/* Latency of interface clock in nanoseconds */
94/* Interface clock latency , in this case, means the 100/* Interface clock latency , in this case, means the
95 * time described by a value of 1 in the interrupt 101 * time described by a value of 1 in the interrupt
96 * coalescing registers' time fields. Since those fields 102 * coalescing registers' time fields. Since those fields
97 * refer to the time it takes for 64 clocks to pass, the 103 * refer to the time it takes for 64 clocks to pass, the
@@ -166,9 +172,28 @@ extern const char gfar_driver_version[];
166 mk_ic_icft(count) | \ 172 mk_ic_icft(count) | \
167 mk_ic_ictt(time)) 173 mk_ic_ictt(time))
168 174
175#define RCTRL_PAL_MASK 0x001f0000
176#define RCTRL_VLEX 0x00002000
177#define RCTRL_FILREN 0x00001000
178#define RCTRL_GHTX 0x00000400
179#define RCTRL_IPCSEN 0x00000200
180#define RCTRL_TUCSEN 0x00000100
181#define RCTRL_PRSDEP_MASK 0x000000c0
182#define RCTRL_PRSDEP_INIT 0x000000c0
169#define RCTRL_PROM 0x00000008 183#define RCTRL_PROM 0x00000008
184#define RCTRL_CHECKSUMMING (RCTRL_IPCSEN \
185 | RCTRL_TUCSEN | RCTRL_PRSDEP_INIT)
186#define RCTRL_EXTHASH (RCTRL_GHTX)
187#define RCTRL_VLAN (RCTRL_PRSDEP_INIT)
188
189
170#define RSTAT_CLEAR_RHALT 0x00800000 190#define RSTAT_CLEAR_RHALT 0x00800000
171 191
192#define TCTRL_IPCSEN 0x00004000
193#define TCTRL_TUCSEN 0x00002000
194#define TCTRL_VLINS 0x00001000
195#define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN)
196
172#define IEVENT_INIT_CLEAR 0xffffffff 197#define IEVENT_INIT_CLEAR 0xffffffff
173#define IEVENT_BABR 0x80000000 198#define IEVENT_BABR 0x80000000
174#define IEVENT_RXC 0x40000000 199#define IEVENT_RXC 0x40000000
@@ -187,12 +212,16 @@ extern const char gfar_driver_version[];
187#define IEVENT_RXB0 0x00008000 212#define IEVENT_RXB0 0x00008000
188#define IEVENT_GRSC 0x00000100 213#define IEVENT_GRSC 0x00000100
189#define IEVENT_RXF0 0x00000080 214#define IEVENT_RXF0 0x00000080
215#define IEVENT_FIR 0x00000008
216#define IEVENT_FIQ 0x00000004
217#define IEVENT_DPE 0x00000002
218#define IEVENT_PERR 0x00000001
190#define IEVENT_RX_MASK (IEVENT_RXB0 | IEVENT_RXF0) 219#define IEVENT_RX_MASK (IEVENT_RXB0 | IEVENT_RXF0)
191#define IEVENT_TX_MASK (IEVENT_TXB | IEVENT_TXF) 220#define IEVENT_TX_MASK (IEVENT_TXB | IEVENT_TXF)
192#define IEVENT_ERR_MASK \ 221#define IEVENT_ERR_MASK \
193(IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \ 222(IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \
194 IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \ 223 IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \
195 | IEVENT_CRL | IEVENT_XFUN) 224 | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR)
196 225
197#define IMASK_INIT_CLEAR 0x00000000 226#define IMASK_INIT_CLEAR 0x00000000
198#define IMASK_BABR 0x80000000 227#define IMASK_BABR 0x80000000
@@ -212,10 +241,15 @@ extern const char gfar_driver_version[];
212#define IMASK_RXB0 0x00008000 241#define IMASK_RXB0 0x00008000
213#define IMASK_GTSC 0x00000100 242#define IMASK_GTSC 0x00000100
214#define IMASK_RXFEN0 0x00000080 243#define IMASK_RXFEN0 0x00000080
244#define IMASK_FIR 0x00000008
245#define IMASK_FIQ 0x00000004
246#define IMASK_DPE 0x00000002
247#define IMASK_PERR 0x00000001
215#define IMASK_RX_DISABLED ~(IMASK_RXFEN0 | IMASK_BSY) 248#define IMASK_RX_DISABLED ~(IMASK_RXFEN0 | IMASK_BSY)
216#define IMASK_DEFAULT (IMASK_TXEEN | IMASK_TXFEN | IMASK_TXBEN | \ 249#define IMASK_DEFAULT (IMASK_TXEEN | IMASK_TXFEN | IMASK_TXBEN | \
217 IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \ 250 IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \
218 IMASK_XFUN | IMASK_RXC | IMASK_BABT) 251 IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \
252 | IMASK_PERR)
219 253
220 254
221/* Attribute fields */ 255/* Attribute fields */
@@ -254,6 +288,18 @@ extern const char gfar_driver_version[];
254#define TXBD_RETRYLIMIT 0x0040 288#define TXBD_RETRYLIMIT 0x0040
255#define TXBD_RETRYCOUNTMASK 0x003c 289#define TXBD_RETRYCOUNTMASK 0x003c
256#define TXBD_UNDERRUN 0x0002 290#define TXBD_UNDERRUN 0x0002
291#define TXBD_TOE 0x0002
292
293/* Tx FCB param bits */
294#define TXFCB_VLN 0x80
295#define TXFCB_IP 0x40
296#define TXFCB_IP6 0x20
297#define TXFCB_TUP 0x10
298#define TXFCB_UDP 0x08
299#define TXFCB_CIP 0x04
300#define TXFCB_CTU 0x02
301#define TXFCB_NPH 0x01
302#define TXFCB_DEFAULT (TXFCB_IP|TXFCB_TUP|TXFCB_CTU|TXFCB_NPH)
257 303
258/* RxBD status field bits */ 304/* RxBD status field bits */
259#define RXBD_EMPTY 0x8000 305#define RXBD_EMPTY 0x8000
@@ -273,6 +319,18 @@ extern const char gfar_driver_version[];
273#define RXBD_TRUNCATED 0x0001 319#define RXBD_TRUNCATED 0x0001
274#define RXBD_STATS 0x01ff 320#define RXBD_STATS 0x01ff
275 321
322/* Rx FCB status field bits */
323#define RXFCB_VLN 0x8000
324#define RXFCB_IP 0x4000
325#define RXFCB_IP6 0x2000
326#define RXFCB_TUP 0x1000
327#define RXFCB_CIP 0x0800
328#define RXFCB_CTU 0x0400
329#define RXFCB_EIP 0x0200
330#define RXFCB_ETU 0x0100
331#define RXFCB_PERR_MASK 0x000c
332#define RXFCB_PERR_BADL3 0x0008
333
276struct txbd8 334struct txbd8
277{ 335{
278 u16 status; /* Status Fields */ 336 u16 status; /* Status Fields */
@@ -280,6 +338,22 @@ struct txbd8
280 u32 bufPtr; /* Buffer Pointer */ 338 u32 bufPtr; /* Buffer Pointer */
281}; 339};
282 340
341struct txfcb {
342 u8 vln:1,
343 ip:1,
344 ip6:1,
345 tup:1,
346 udp:1,
347 cip:1,
348 ctu:1,
349 nph:1;
350 u8 reserved;
351 u8 l4os; /* Level 4 Header Offset */
352 u8 l3os; /* Level 3 Header Offset */
353 u16 phcs; /* Pseudo-header Checksum */
354 u16 vlctl; /* VLAN control word */
355};
356
283struct rxbd8 357struct rxbd8
284{ 358{
285 u16 status; /* Status Fields */ 359 u16 status; /* Status Fields */
@@ -287,6 +361,21 @@ struct rxbd8
287 u32 bufPtr; /* Buffer Pointer */ 361 u32 bufPtr; /* Buffer Pointer */
288}; 362};
289 363
364struct rxfcb {
365 u16 vln:1,
366 ip:1,
367 ip6:1,
368 tup:1,
369 cip:1,
370 ctu:1,
371 eip:1,
372 etu:1;
373 u8 rq; /* Receive Queue index */
374 u8 pro; /* Layer 4 Protocol */
375 u16 reserved;
376 u16 vlctl; /* VLAN control word */
377};
378
290struct rmon_mib 379struct rmon_mib
291{ 380{
292 u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */ 381 u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */
@@ -371,90 +460,191 @@ struct gfar_stats {
371 460
372 461
373struct gfar { 462struct gfar {
374 u8 res1[16]; 463 u32 tsec_id; /* 0x.000 - Controller ID register */
375 u32 ievent; /* 0x.010 - Interrupt Event Register */ 464 u8 res1[12];
376 u32 imask; /* 0x.014 - Interrupt Mask Register */ 465 u32 ievent; /* 0x.010 - Interrupt Event Register */
377 u32 edis; /* 0x.018 - Error Disabled Register */ 466 u32 imask; /* 0x.014 - Interrupt Mask Register */
467 u32 edis; /* 0x.018 - Error Disabled Register */
378 u8 res2[4]; 468 u8 res2[4];
379 u32 ecntrl; /* 0x.020 - Ethernet Control Register */ 469 u32 ecntrl; /* 0x.020 - Ethernet Control Register */
380 u32 minflr; /* 0x.024 - Minimum Frame Length Register */ 470 u32 minflr; /* 0x.024 - Minimum Frame Length Register */
381 u32 ptv; /* 0x.028 - Pause Time Value Register */ 471 u32 ptv; /* 0x.028 - Pause Time Value Register */
382 u32 dmactrl; /* 0x.02c - DMA Control Register */ 472 u32 dmactrl; /* 0x.02c - DMA Control Register */
383 u32 tbipa; /* 0x.030 - TBI PHY Address Register */ 473 u32 tbipa; /* 0x.030 - TBI PHY Address Register */
384 u8 res3[88]; 474 u8 res3[88];
385 u32 fifo_tx_thr; /* 0x.08c - FIFO transmit threshold register */ 475 u32 fifo_tx_thr; /* 0x.08c - FIFO transmit threshold register */
386 u8 res4[8]; 476 u8 res4[8];
387 u32 fifo_tx_starve; /* 0x.098 - FIFO transmit starve register */ 477 u32 fifo_tx_starve; /* 0x.098 - FIFO transmit starve register */
388 u32 fifo_tx_starve_shutoff; /* 0x.09c - FIFO transmit starve shutoff register */ 478 u32 fifo_tx_starve_shutoff; /* 0x.09c - FIFO transmit starve shutoff register */
389 u8 res5[96]; 479 u8 res5[4];
390 u32 tctrl; /* 0x.100 - Transmit Control Register */ 480 u32 fifo_rx_pause; /* 0x.0a4 - FIFO receive pause threshold register */
391 u32 tstat; /* 0x.104 - Transmit Status Register */ 481 u32 fifo_rx_alarm; /* 0x.0a8 - FIFO receive alarm threshold register */
392 u8 res6[4]; 482 u8 res6[84];
393 u32 tbdlen; /* 0x.10c - Transmit Buffer Descriptor Data Length Register */ 483 u32 tctrl; /* 0x.100 - Transmit Control Register */
394 u32 txic; /* 0x.110 - Transmit Interrupt Coalescing Configuration Register */ 484 u32 tstat; /* 0x.104 - Transmit Status Register */
395 u8 res7[16]; 485 u32 dfvlan; /* 0x.108 - Default VLAN Control word */
396 u32 ctbptr; /* 0x.124 - Current Transmit Buffer Descriptor Pointer Register */ 486 u32 tbdlen; /* 0x.10c - Transmit Buffer Descriptor Data Length Register */
397 u8 res8[92]; 487 u32 txic; /* 0x.110 - Transmit Interrupt Coalescing Configuration Register */
398 u32 tbptr; /* 0x.184 - Transmit Buffer Descriptor Pointer Low Register */ 488 u32 tqueue; /* 0x.114 - Transmit queue control register */
399 u8 res9[124]; 489 u8 res7[40];
400 u32 tbase; /* 0x.204 - Transmit Descriptor Base Address Register */ 490 u32 tr03wt; /* 0x.140 - TxBD Rings 0-3 round-robin weightings */
401 u8 res10[168]; 491 u32 tr47wt; /* 0x.144 - TxBD Rings 4-7 round-robin weightings */
402 u32 ostbd; /* 0x.2b0 - Out-of-Sequence Transmit Buffer Descriptor Register */ 492 u8 res8[52];
403 u32 ostbdp; /* 0x.2b4 - Out-of-Sequence Transmit Data Buffer Pointer Register */ 493 u32 tbdbph; /* 0x.17c - Tx data buffer pointer high */
404 u8 res11[72]; 494 u8 res9a[4];
405 u32 rctrl; /* 0x.300 - Receive Control Register */ 495 u32 tbptr0; /* 0x.184 - TxBD Pointer for ring 0 */
406 u32 rstat; /* 0x.304 - Receive Status Register */ 496 u8 res9b[4];
407 u8 res12[4]; 497 u32 tbptr1; /* 0x.18c - TxBD Pointer for ring 1 */
408 u32 rbdlen; /* 0x.30c - RxBD Data Length Register */ 498 u8 res9c[4];
409 u32 rxic; /* 0x.310 - Receive Interrupt Coalescing Configuration Register */ 499 u32 tbptr2; /* 0x.194 - TxBD Pointer for ring 2 */
410 u8 res13[16]; 500 u8 res9d[4];
411 u32 crbptr; /* 0x.324 - Current Receive Buffer Descriptor Pointer */ 501 u32 tbptr3; /* 0x.19c - TxBD Pointer for ring 3 */
412 u8 res14[24]; 502 u8 res9e[4];
413 u32 mrblr; /* 0x.340 - Maximum Receive Buffer Length Register */ 503 u32 tbptr4; /* 0x.1a4 - TxBD Pointer for ring 4 */
414 u8 res15[64]; 504 u8 res9f[4];
415 u32 rbptr; /* 0x.384 - Receive Buffer Descriptor Pointer */ 505 u32 tbptr5; /* 0x.1ac - TxBD Pointer for ring 5 */
416 u8 res16[124]; 506 u8 res9g[4];
417 u32 rbase; /* 0x.404 - Receive Descriptor Base Address */ 507 u32 tbptr6; /* 0x.1b4 - TxBD Pointer for ring 6 */
418 u8 res17[248]; 508 u8 res9h[4];
419 u32 maccfg1; /* 0x.500 - MAC Configuration 1 Register */ 509 u32 tbptr7; /* 0x.1bc - TxBD Pointer for ring 7 */
420 u32 maccfg2; /* 0x.504 - MAC Configuration 2 Register */ 510 u8 res9[64];
421 u32 ipgifg; /* 0x.508 - Inter Packet Gap/Inter Frame Gap Register */ 511 u32 tbaseh; /* 0x.200 - TxBD base address high */
422 u32 hafdup; /* 0x.50c - Half Duplex Register */ 512 u32 tbase0; /* 0x.204 - TxBD Base Address of ring 0 */
423 u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */ 513 u8 res10a[4];
514 u32 tbase1; /* 0x.20c - TxBD Base Address of ring 1 */
515 u8 res10b[4];
516 u32 tbase2; /* 0x.214 - TxBD Base Address of ring 2 */
517 u8 res10c[4];
518 u32 tbase3; /* 0x.21c - TxBD Base Address of ring 3 */
519 u8 res10d[4];
520 u32 tbase4; /* 0x.224 - TxBD Base Address of ring 4 */
521 u8 res10e[4];
522 u32 tbase5; /* 0x.22c - TxBD Base Address of ring 5 */
523 u8 res10f[4];
524 u32 tbase6; /* 0x.234 - TxBD Base Address of ring 6 */
525 u8 res10g[4];
526 u32 tbase7; /* 0x.23c - TxBD Base Address of ring 7 */
527 u8 res10[192];
528 u32 rctrl; /* 0x.300 - Receive Control Register */
529 u32 rstat; /* 0x.304 - Receive Status Register */
530 u8 res12[8];
531 u32 rxic; /* 0x.310 - Receive Interrupt Coalescing Configuration Register */
532 u32 rqueue; /* 0x.314 - Receive queue control register */
533 u8 res13[24];
534 u32 rbifx; /* 0x.330 - Receive bit field extract control register */
535 u32 rqfar; /* 0x.334 - Receive queue filing table address register */
536 u32 rqfcr; /* 0x.338 - Receive queue filing table control register */
537 u32 rqfpr; /* 0x.33c - Receive queue filing table property register */
538 u32 mrblr; /* 0x.340 - Maximum Receive Buffer Length Register */
539 u8 res14[56];
540 u32 rbdbph; /* 0x.37c - Rx data buffer pointer high */
541 u8 res15a[4];
542 u32 rbptr0; /* 0x.384 - RxBD pointer for ring 0 */
543 u8 res15b[4];
544 u32 rbptr1; /* 0x.38c - RxBD pointer for ring 1 */
545 u8 res15c[4];
546 u32 rbptr2; /* 0x.394 - RxBD pointer for ring 2 */
547 u8 res15d[4];
548 u32 rbptr3; /* 0x.39c - RxBD pointer for ring 3 */
549 u8 res15e[4];
550 u32 rbptr4; /* 0x.3a4 - RxBD pointer for ring 4 */
551 u8 res15f[4];
552 u32 rbptr5; /* 0x.3ac - RxBD pointer for ring 5 */
553 u8 res15g[4];
554 u32 rbptr6; /* 0x.3b4 - RxBD pointer for ring 6 */
555 u8 res15h[4];
556 u32 rbptr7; /* 0x.3bc - RxBD pointer for ring 7 */
557 u8 res16[64];
558 u32 rbaseh; /* 0x.400 - RxBD base address high */
559 u32 rbase0; /* 0x.404 - RxBD base address of ring 0 */
560 u8 res17a[4];
561 u32 rbase1; /* 0x.40c - RxBD base address of ring 1 */
562 u8 res17b[4];
563 u32 rbase2; /* 0x.414 - RxBD base address of ring 2 */
564 u8 res17c[4];
565 u32 rbase3; /* 0x.41c - RxBD base address of ring 3 */
566 u8 res17d[4];
567 u32 rbase4; /* 0x.424 - RxBD base address of ring 4 */
568 u8 res17e[4];
569 u32 rbase5; /* 0x.42c - RxBD base address of ring 5 */
570 u8 res17f[4];
571 u32 rbase6; /* 0x.434 - RxBD base address of ring 6 */
572 u8 res17g[4];
573 u32 rbase7; /* 0x.43c - RxBD base address of ring 7 */
574 u8 res17[192];
575 u32 maccfg1; /* 0x.500 - MAC Configuration 1 Register */
576 u32 maccfg2; /* 0x.504 - MAC Configuration 2 Register */
577 u32 ipgifg; /* 0x.508 - Inter Packet Gap/Inter Frame Gap Register */
578 u32 hafdup; /* 0x.50c - Half Duplex Register */
579 u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */
424 u8 res18[12]; 580 u8 res18[12];
425 u32 miimcfg; /* 0x.520 - MII Management Configuration Register */ 581 u32 miimcfg; /* 0x.520 - MII Management Configuration Register */
426 u32 miimcom; /* 0x.524 - MII Management Command Register */ 582 u32 miimcom; /* 0x.524 - MII Management Command Register */
427 u32 miimadd; /* 0x.528 - MII Management Address Register */ 583 u32 miimadd; /* 0x.528 - MII Management Address Register */
428 u32 miimcon; /* 0x.52c - MII Management Control Register */ 584 u32 miimcon; /* 0x.52c - MII Management Control Register */
429 u32 miimstat; /* 0x.530 - MII Management Status Register */ 585 u32 miimstat; /* 0x.530 - MII Management Status Register */
430 u32 miimind; /* 0x.534 - MII Management Indicator Register */ 586 u32 miimind; /* 0x.534 - MII Management Indicator Register */
431 u8 res19[4]; 587 u8 res19[4];
432 u32 ifstat; /* 0x.53c - Interface Status Register */ 588 u32 ifstat; /* 0x.53c - Interface Status Register */
433 u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */ 589 u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */
434 u32 macstnaddr2; /* 0x.544 - Station Address Part 2 Register */ 590 u32 macstnaddr2; /* 0x.544 - Station Address Part 2 Register */
435 u8 res20[312]; 591 u32 mac01addr1; /* 0x.548 - MAC exact match address 1, part 1 */
436 struct rmon_mib rmon; 592 u32 mac01addr2; /* 0x.54c - MAC exact match address 1, part 2 */
437 u8 res21[192]; 593 u32 mac02addr1; /* 0x.550 - MAC exact match address 2, part 1 */
438 u32 iaddr0; /* 0x.800 - Indivdual address register 0 */ 594 u32 mac02addr2; /* 0x.554 - MAC exact match address 2, part 2 */
439 u32 iaddr1; /* 0x.804 - Indivdual address register 1 */ 595 u32 mac03addr1; /* 0x.558 - MAC exact match address 3, part 1 */
440 u32 iaddr2; /* 0x.808 - Indivdual address register 2 */ 596 u32 mac03addr2; /* 0x.55c - MAC exact match address 3, part 2 */
441 u32 iaddr3; /* 0x.80c - Indivdual address register 3 */ 597 u32 mac04addr1; /* 0x.560 - MAC exact match address 4, part 1 */
442 u32 iaddr4; /* 0x.810 - Indivdual address register 4 */ 598 u32 mac04addr2; /* 0x.564 - MAC exact match address 4, part 2 */
443 u32 iaddr5; /* 0x.814 - Indivdual address register 5 */ 599 u32 mac05addr1; /* 0x.568 - MAC exact match address 5, part 1 */
444 u32 iaddr6; /* 0x.818 - Indivdual address register 6 */ 600 u32 mac05addr2; /* 0x.56c - MAC exact match address 5, part 2 */
445 u32 iaddr7; /* 0x.81c - Indivdual address register 7 */ 601 u32 mac06addr1; /* 0x.570 - MAC exact match address 6, part 1 */
602 u32 mac06addr2; /* 0x.574 - MAC exact match address 6, part 2 */
603 u32 mac07addr1; /* 0x.578 - MAC exact match address 7, part 1 */
604 u32 mac07addr2; /* 0x.57c - MAC exact match address 7, part 2 */
605 u32 mac08addr1; /* 0x.580 - MAC exact match address 8, part 1 */
606 u32 mac08addr2; /* 0x.584 - MAC exact match address 8, part 2 */
607 u32 mac09addr1; /* 0x.588 - MAC exact match address 9, part 1 */
608 u32 mac09addr2; /* 0x.58c - MAC exact match address 9, part 2 */
609 u32 mac10addr1; /* 0x.590 - MAC exact match address 10, part 1*/
610 u32 mac10addr2; /* 0x.594 - MAC exact match address 10, part 2*/
611 u32 mac11addr1; /* 0x.598 - MAC exact match address 11, part 1*/
612 u32 mac11addr2; /* 0x.59c - MAC exact match address 11, part 2*/
613 u32 mac12addr1; /* 0x.5a0 - MAC exact match address 12, part 1*/
614 u32 mac12addr2; /* 0x.5a4 - MAC exact match address 12, part 2*/
615 u32 mac13addr1; /* 0x.5a8 - MAC exact match address 13, part 1*/
616 u32 mac13addr2; /* 0x.5ac - MAC exact match address 13, part 2*/
617 u32 mac14addr1; /* 0x.5b0 - MAC exact match address 14, part 1*/
618 u32 mac14addr2; /* 0x.5b4 - MAC exact match address 14, part 2*/
619 u32 mac15addr1; /* 0x.5b8 - MAC exact match address 15, part 1*/
620 u32 mac15addr2; /* 0x.5bc - MAC exact match address 15, part 2*/
621 u8 res20[192];
622 struct rmon_mib rmon; /* 0x.680-0x.73c */
623 u32 rrej; /* 0x.740 - Receive filer rejected packet counter */
624 u8 res21[188];
625 u32 igaddr0; /* 0x.800 - Indivdual/Group address register 0*/
626 u32 igaddr1; /* 0x.804 - Indivdual/Group address register 1*/
627 u32 igaddr2; /* 0x.808 - Indivdual/Group address register 2*/
628 u32 igaddr3; /* 0x.80c - Indivdual/Group address register 3*/
629 u32 igaddr4; /* 0x.810 - Indivdual/Group address register 4*/
630 u32 igaddr5; /* 0x.814 - Indivdual/Group address register 5*/
631 u32 igaddr6; /* 0x.818 - Indivdual/Group address register 6*/
632 u32 igaddr7; /* 0x.81c - Indivdual/Group address register 7*/
446 u8 res22[96]; 633 u8 res22[96];
447 u32 gaddr0; /* 0x.880 - Global address register 0 */ 634 u32 gaddr0; /* 0x.880 - Group address register 0 */
448 u32 gaddr1; /* 0x.884 - Global address register 1 */ 635 u32 gaddr1; /* 0x.884 - Group address register 1 */
449 u32 gaddr2; /* 0x.888 - Global address register 2 */ 636 u32 gaddr2; /* 0x.888 - Group address register 2 */
450 u32 gaddr3; /* 0x.88c - Global address register 3 */ 637 u32 gaddr3; /* 0x.88c - Group address register 3 */
451 u32 gaddr4; /* 0x.890 - Global address register 4 */ 638 u32 gaddr4; /* 0x.890 - Group address register 4 */
452 u32 gaddr5; /* 0x.894 - Global address register 5 */ 639 u32 gaddr5; /* 0x.894 - Group address register 5 */
453 u32 gaddr6; /* 0x.898 - Global address register 6 */ 640 u32 gaddr6; /* 0x.898 - Group address register 6 */
454 u32 gaddr7; /* 0x.89c - Global address register 7 */ 641 u32 gaddr7; /* 0x.89c - Group address register 7 */
455 u8 res23[856]; 642 u8 res23a[352];
456 u32 attr; /* 0x.bf8 - Attributes Register */ 643 u32 fifocfg; /* 0x.a00 - FIFO interface config register */
457 u32 attreli; /* 0x.bfc - Attributes Extract Length and Extract Index Register */ 644 u8 res23b[252];
645 u8 res23c[248];
646 u32 attr; /* 0x.bf8 - Attributes Register */
647 u32 attreli; /* 0x.bfc - Attributes Extract Length and Extract Index Register */
458 u8 res24[1024]; 648 u8 res24[1024];
459 649
460}; 650};
@@ -496,6 +686,8 @@ struct gfar_private {
496 struct txbd8 *cur_tx; /* Next free ring entry */ 686 struct txbd8 *cur_tx; /* Next free ring entry */
497 struct txbd8 *dirty_tx; /* The Ring entry to be freed. */ 687 struct txbd8 *dirty_tx; /* The Ring entry to be freed. */
498 struct gfar *regs; /* Pointer to the GFAR memory mapped Registers */ 688 struct gfar *regs; /* Pointer to the GFAR memory mapped Registers */
689 u32 *hash_regs[16];
690 int hash_width;
499 struct gfar *phyregs; 691 struct gfar *phyregs;
500 struct work_struct tq; 692 struct work_struct tq;
501 struct timer_list phy_info_timer; 693 struct timer_list phy_info_timer;
@@ -506,9 +698,12 @@ struct gfar_private {
506 unsigned int rx_stash_size; 698 unsigned int rx_stash_size;
507 unsigned int tx_ring_size; 699 unsigned int tx_ring_size;
508 unsigned int rx_ring_size; 700 unsigned int rx_ring_size;
509 wait_queue_head_t rxcleanupq;
510 unsigned int rxclean;
511 701
702 unsigned char vlan_enable:1,
703 rx_csum_enable:1,
704 extended_hash:1;
705 unsigned short padding;
706 struct vlan_group *vlgrp;
512 /* Info structure initialized by board setup code */ 707 /* Info structure initialized by board setup code */
513 unsigned int interruptTransmit; 708 unsigned int interruptTransmit;
514 unsigned int interruptReceive; 709 unsigned int interruptReceive;
@@ -519,6 +714,8 @@ struct gfar_private {
519 int oldspeed; 714 int oldspeed;
520 int oldduplex; 715 int oldduplex;
521 int oldlink; 716 int oldlink;
717
718 uint32_t msg_enable;
522}; 719};
523 720
524extern inline u32 gfar_read(volatile unsigned *addr) 721extern inline u32 gfar_read(volatile unsigned *addr)
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index 28046e9e88ba..a451de629197 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -46,16 +46,18 @@
46 46
47extern int startup_gfar(struct net_device *dev); 47extern int startup_gfar(struct net_device *dev);
48extern void stop_gfar(struct net_device *dev); 48extern void stop_gfar(struct net_device *dev);
49extern void gfar_receive(int irq, void *dev_id, struct pt_regs *regs); 49extern void gfar_halt(struct net_device *dev);
50extern void gfar_start(struct net_device *dev);
51extern int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
50 52
51void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy, 53static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
52 u64 * buf); 54 u64 * buf);
53void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf); 55static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf);
54int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals); 56static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals);
55int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals); 57static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals);
56void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals); 58static void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals);
57int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals); 59static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals);
58void gfar_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo); 60static void gfar_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo);
59 61
60static char stat_gstrings[][ETH_GSTRING_LEN] = { 62static char stat_gstrings[][ETH_GSTRING_LEN] = {
61 "rx-dropped-by-kernel", 63 "rx-dropped-by-kernel",
@@ -118,57 +120,56 @@ static char stat_gstrings[][ETH_GSTRING_LEN] = {
118 "tx-fragmented-frames", 120 "tx-fragmented-frames",
119}; 121};
120 122
123/* Fill in a buffer with the strings which correspond to the
124 * stats */
125static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf)
126{
127 struct gfar_private *priv = netdev_priv(dev);
128
129 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
130 memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN);
131 else
132 memcpy(buf, stat_gstrings,
133 GFAR_EXTRA_STATS_LEN * ETH_GSTRING_LEN);
134}
135
121/* Fill in an array of 64-bit statistics from various sources. 136/* Fill in an array of 64-bit statistics from various sources.
122 * This array will be appended to the end of the ethtool_stats 137 * This array will be appended to the end of the ethtool_stats
123 * structure, and returned to user space 138 * structure, and returned to user space
124 */ 139 */
125void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy, u64 * buf) 140static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy, u64 * buf)
126{ 141{
127 int i; 142 int i;
128 struct gfar_private *priv = netdev_priv(dev); 143 struct gfar_private *priv = netdev_priv(dev);
129 u32 *rmon = (u32 *) & priv->regs->rmon;
130 u64 *extra = (u64 *) & priv->extra_stats; 144 u64 *extra = (u64 *) & priv->extra_stats;
131 struct gfar_stats *stats = (struct gfar_stats *) buf;
132 145
133 for (i = 0; i < GFAR_RMON_LEN; i++) { 146 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
134 stats->rmon[i] = (u64) (rmon[i]); 147 u32 *rmon = (u32 *) & priv->regs->rmon;
135 } 148 struct gfar_stats *stats = (struct gfar_stats *) buf;
136
137 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++) {
138 stats->extra[i] = extra[i];
139 }
140}
141 149
142/* Returns the number of stats (and their corresponding strings) */ 150 for (i = 0; i < GFAR_RMON_LEN; i++)
143int gfar_stats_count(struct net_device *dev) 151 stats->rmon[i] = (u64) (rmon[i]);
144{
145 return GFAR_STATS_LEN;
146}
147 152
148void gfar_gstrings_normon(struct net_device *dev, u32 stringset, u8 * buf) 153 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
149{ 154 stats->extra[i] = extra[i];
150 memcpy(buf, stat_gstrings, GFAR_EXTRA_STATS_LEN * ETH_GSTRING_LEN); 155 } else
156 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
157 buf[i] = extra[i];
151} 158}
152 159
153void gfar_fill_stats_normon(struct net_device *dev, 160/* Returns the number of stats (and their corresponding strings) */
154 struct ethtool_stats *dummy, u64 * buf) 161static int gfar_stats_count(struct net_device *dev)
155{ 162{
156 int i;
157 struct gfar_private *priv = netdev_priv(dev); 163 struct gfar_private *priv = netdev_priv(dev);
158 u64 *extra = (u64 *) & priv->extra_stats;
159 164
160 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++) { 165 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
161 buf[i] = extra[i]; 166 return GFAR_STATS_LEN;
162 } 167 else
168 return GFAR_EXTRA_STATS_LEN;
163} 169}
164 170
165
166int gfar_stats_count_normon(struct net_device *dev)
167{
168 return GFAR_EXTRA_STATS_LEN;
169}
170/* Fills in the drvinfo structure with some basic info */ 171/* Fills in the drvinfo structure with some basic info */
171void gfar_gdrvinfo(struct net_device *dev, struct 172static void gfar_gdrvinfo(struct net_device *dev, struct
172 ethtool_drvinfo *drvinfo) 173 ethtool_drvinfo *drvinfo)
173{ 174{
174 strncpy(drvinfo->driver, DRV_NAME, GFAR_INFOSTR_LEN); 175 strncpy(drvinfo->driver, DRV_NAME, GFAR_INFOSTR_LEN);
@@ -182,7 +183,7 @@ void gfar_gdrvinfo(struct net_device *dev, struct
182} 183}
183 184
184/* Return the current settings in the ethtool_cmd structure */ 185/* Return the current settings in the ethtool_cmd structure */
185int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd) 186static int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd)
186{ 187{
187 struct gfar_private *priv = netdev_priv(dev); 188 struct gfar_private *priv = netdev_priv(dev);
188 uint gigabit_support = 189 uint gigabit_support =
@@ -216,13 +217,13 @@ int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd)
216} 217}
217 218
218/* Return the length of the register structure */ 219/* Return the length of the register structure */
219int gfar_reglen(struct net_device *dev) 220static int gfar_reglen(struct net_device *dev)
220{ 221{
221 return sizeof (struct gfar); 222 return sizeof (struct gfar);
222} 223}
223 224
224/* Return a dump of the GFAR register space */ 225/* Return a dump of the GFAR register space */
225void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf) 226static void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
226{ 227{
227 int i; 228 int i;
228 struct gfar_private *priv = netdev_priv(dev); 229 struct gfar_private *priv = netdev_priv(dev);
@@ -233,13 +234,6 @@ void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regb
233 buf[i] = theregs[i]; 234 buf[i] = theregs[i];
234} 235}
235 236
236/* Fill in a buffer with the strings which correspond to the
237 * stats */
238void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf)
239{
240 memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN);
241}
242
243/* Convert microseconds to ethernet clock ticks, which changes 237/* Convert microseconds to ethernet clock ticks, which changes
244 * depending on what speed the controller is running at */ 238 * depending on what speed the controller is running at */
245static unsigned int gfar_usecs2ticks(struct gfar_private *priv, unsigned int usecs) 239static unsigned int gfar_usecs2ticks(struct gfar_private *priv, unsigned int usecs)
@@ -291,9 +285,12 @@ static unsigned int gfar_ticks2usecs(struct gfar_private *priv, unsigned int tic
291 285
292/* Get the coalescing parameters, and put them in the cvals 286/* Get the coalescing parameters, and put them in the cvals
293 * structure. */ 287 * structure. */
294int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals) 288static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
295{ 289{
296 struct gfar_private *priv = netdev_priv(dev); 290 struct gfar_private *priv = netdev_priv(dev);
291
292 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
293 return -EOPNOTSUPP;
297 294
298 cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, priv->rxtime); 295 cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, priv->rxtime);
299 cvals->rx_max_coalesced_frames = priv->rxcount; 296 cvals->rx_max_coalesced_frames = priv->rxcount;
@@ -337,10 +334,13 @@ int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
337 * Both cvals->*_usecs and cvals->*_frames have to be > 0 334 * Both cvals->*_usecs and cvals->*_frames have to be > 0
338 * in order for coalescing to be active 335 * in order for coalescing to be active
339 */ 336 */
340int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals) 337static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
341{ 338{
342 struct gfar_private *priv = netdev_priv(dev); 339 struct gfar_private *priv = netdev_priv(dev);
343 340
341 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
342 return -EOPNOTSUPP;
343
344 /* Set up rx coalescing */ 344 /* Set up rx coalescing */
345 if ((cvals->rx_coalesce_usecs == 0) || 345 if ((cvals->rx_coalesce_usecs == 0) ||
346 (cvals->rx_max_coalesced_frames == 0)) 346 (cvals->rx_max_coalesced_frames == 0))
@@ -379,7 +379,7 @@ int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
379/* Fills in rvals with the current ring parameters. Currently, 379/* Fills in rvals with the current ring parameters. Currently,
380 * rx, rx_mini, and rx_jumbo rings are the same size, as mini and 380 * rx, rx_mini, and rx_jumbo rings are the same size, as mini and
381 * jumbo are ignored by the driver */ 381 * jumbo are ignored by the driver */
382void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals) 382static void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
383{ 383{
384 struct gfar_private *priv = netdev_priv(dev); 384 struct gfar_private *priv = netdev_priv(dev);
385 385
@@ -401,9 +401,8 @@ void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
401 * necessary so that we don't mess things up while we're in 401 * necessary so that we don't mess things up while we're in
402 * motion. We wait for the ring to be clean before reallocating 402 * motion. We wait for the ring to be clean before reallocating
403 * the rings. */ 403 * the rings. */
404int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals) 404static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
405{ 405{
406 u32 tempval;
407 struct gfar_private *priv = netdev_priv(dev); 406 struct gfar_private *priv = netdev_priv(dev);
408 int err = 0; 407 int err = 0;
409 408
@@ -425,37 +424,54 @@ int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
425 return -EINVAL; 424 return -EINVAL;
426 } 425 }
427 426
428 /* Stop the controller so we don't rx any more frames */ 427 if (dev->flags & IFF_UP) {
429 /* But first, make sure we clear the bits */ 428 unsigned long flags;
430 tempval = gfar_read(&priv->regs->dmactrl);
431 tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);
432 gfar_write(&priv->regs->dmactrl, tempval);
433 429
434 tempval = gfar_read(&priv->regs->dmactrl); 430 /* Halt TX and RX, and process the frames which
435 tempval |= (DMACTRL_GRS | DMACTRL_GTS); 431 * have already been received */
436 gfar_write(&priv->regs->dmactrl, tempval); 432 spin_lock_irqsave(&priv->lock, flags);
433 gfar_halt(dev);
434 gfar_clean_rx_ring(dev, priv->rx_ring_size);
435 spin_unlock_irqrestore(&priv->lock, flags);
437 436
438 while (!(gfar_read(&priv->regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC))) 437 /* Now we take down the rings to rebuild them */
439 cpu_relax(); 438 stop_gfar(dev);
439 }
440 440
441 /* Note that rx is not clean right now */ 441 /* Change the size */
442 priv->rxclean = 0; 442 priv->rx_ring_size = rvals->rx_pending;
443 priv->tx_ring_size = rvals->tx_pending;
443 444
444 if (dev->flags & IFF_UP) { 445 /* Rebuild the rings with the new size */
445 /* Tell the driver to process the rest of the frames */ 446 if (dev->flags & IFF_UP)
446 gfar_receive(0, (void *) dev, NULL); 447 err = startup_gfar(dev);
447 448
448 /* Now wait for it to be done */ 449 return err;
449 wait_event_interruptible(priv->rxcleanupq, priv->rxclean); 450}
450 451
451 /* Ok, all packets have been handled. Now we bring it down, 452static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
452 * change the ring size, and bring it up */ 453{
454 struct gfar_private *priv = netdev_priv(dev);
455 int err = 0;
453 456
457 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
458 return -EOPNOTSUPP;
459
460 if (dev->flags & IFF_UP) {
461 unsigned long flags;
462
463 /* Halt TX and RX, and process the frames which
464 * have already been received */
465 spin_lock_irqsave(&priv->lock, flags);
466 gfar_halt(dev);
467 gfar_clean_rx_ring(dev, priv->rx_ring_size);
468 spin_unlock_irqrestore(&priv->lock, flags);
469
470 /* Now we take down the rings to rebuild them */
454 stop_gfar(dev); 471 stop_gfar(dev);
455 } 472 }
456 473
457 priv->rx_ring_size = rvals->rx_pending; 474 priv->rx_csum_enable = data;
458 priv->tx_ring_size = rvals->tx_pending;
459 475
460 if (dev->flags & IFF_UP) 476 if (dev->flags & IFF_UP)
461 err = startup_gfar(dev); 477 err = startup_gfar(dev);
@@ -463,6 +479,61 @@ int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
463 return err; 479 return err;
464} 480}
465 481
482static uint32_t gfar_get_rx_csum(struct net_device *dev)
483{
484 struct gfar_private *priv = netdev_priv(dev);
485
486 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
487 return 0;
488
489 return priv->rx_csum_enable;
490}
491
492static int gfar_set_tx_csum(struct net_device *dev, uint32_t data)
493{
494 unsigned long flags;
495 struct gfar_private *priv = netdev_priv(dev);
496
497 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
498 return -EOPNOTSUPP;
499
500 spin_lock_irqsave(&priv->lock, flags);
501 gfar_halt(dev);
502
503 if (data)
504 dev->features |= NETIF_F_IP_CSUM;
505 else
506 dev->features &= ~NETIF_F_IP_CSUM;
507
508 gfar_start(dev);
509 spin_unlock_irqrestore(&priv->lock, flags);
510
511 return 0;
512}
513
514static uint32_t gfar_get_tx_csum(struct net_device *dev)
515{
516 struct gfar_private *priv = netdev_priv(dev);
517
518 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
519 return 0;
520
521 return (dev->features & NETIF_F_IP_CSUM) != 0;
522}
523
524static uint32_t gfar_get_msglevel(struct net_device *dev)
525{
526 struct gfar_private *priv = netdev_priv(dev);
527 return priv->msg_enable;
528}
529
530static void gfar_set_msglevel(struct net_device *dev, uint32_t data)
531{
532 struct gfar_private *priv = netdev_priv(dev);
533 priv->msg_enable = data;
534}
535
536
466struct ethtool_ops gfar_ethtool_ops = { 537struct ethtool_ops gfar_ethtool_ops = {
467 .get_settings = gfar_gsettings, 538 .get_settings = gfar_gsettings,
468 .get_drvinfo = gfar_gdrvinfo, 539 .get_drvinfo = gfar_gdrvinfo,
@@ -476,52 +547,10 @@ struct ethtool_ops gfar_ethtool_ops = {
476 .get_strings = gfar_gstrings, 547 .get_strings = gfar_gstrings,
477 .get_stats_count = gfar_stats_count, 548 .get_stats_count = gfar_stats_count,
478 .get_ethtool_stats = gfar_fill_stats, 549 .get_ethtool_stats = gfar_fill_stats,
479}; 550 .get_rx_csum = gfar_get_rx_csum,
480 551 .get_tx_csum = gfar_get_tx_csum,
481struct ethtool_ops gfar_normon_nocoalesce_ethtool_ops = { 552 .set_rx_csum = gfar_set_rx_csum,
482 .get_settings = gfar_gsettings, 553 .set_tx_csum = gfar_set_tx_csum,
483 .get_drvinfo = gfar_gdrvinfo, 554 .get_msglevel = gfar_get_msglevel,
484 .get_regs_len = gfar_reglen, 555 .set_msglevel = gfar_set_msglevel,
485 .get_regs = gfar_get_regs,
486 .get_link = ethtool_op_get_link,
487 .get_ringparam = gfar_gringparam,
488 .set_ringparam = gfar_sringparam,
489 .get_strings = gfar_gstrings_normon,
490 .get_stats_count = gfar_stats_count_normon,
491 .get_ethtool_stats = gfar_fill_stats_normon,
492};
493
494struct ethtool_ops gfar_nocoalesce_ethtool_ops = {
495 .get_settings = gfar_gsettings,
496 .get_drvinfo = gfar_gdrvinfo,
497 .get_regs_len = gfar_reglen,
498 .get_regs = gfar_get_regs,
499 .get_link = ethtool_op_get_link,
500 .get_ringparam = gfar_gringparam,
501 .set_ringparam = gfar_sringparam,
502 .get_strings = gfar_gstrings,
503 .get_stats_count = gfar_stats_count,
504 .get_ethtool_stats = gfar_fill_stats,
505};
506
507struct ethtool_ops gfar_normon_ethtool_ops = {
508 .get_settings = gfar_gsettings,
509 .get_drvinfo = gfar_gdrvinfo,
510 .get_regs_len = gfar_reglen,
511 .get_regs = gfar_get_regs,
512 .get_link = ethtool_op_get_link,
513 .get_coalesce = gfar_gcoalesce,
514 .set_coalesce = gfar_scoalesce,
515 .get_ringparam = gfar_gringparam,
516 .set_ringparam = gfar_sringparam,
517 .get_strings = gfar_gstrings_normon,
518 .get_stats_count = gfar_stats_count_normon,
519 .get_ethtool_stats = gfar_fill_stats_normon,
520};
521
522struct ethtool_ops *gfar_op_array[] = {
523 &gfar_ethtool_ops,
524 &gfar_normon_ethtool_ops,
525 &gfar_nocoalesce_ethtool_ops,
526 &gfar_normon_nocoalesce_ethtool_ops
527}; 556};
diff --git a/drivers/net/gianfar_phy.c b/drivers/net/gianfar_phy.c
index 02b16abc89bd..7c965f268a82 100644
--- a/drivers/net/gianfar_phy.c
+++ b/drivers/net/gianfar_phy.c
@@ -572,7 +572,7 @@ static struct phy_info phy_info_dm9161 = {
572static struct phy_info phy_info_marvell = { 572static struct phy_info phy_info_marvell = {
573 .phy_id = 0x01410c00, 573 .phy_id = 0x01410c00,
574 .phy_id_mask = 0xffffff00, 574 .phy_id_mask = 0xffffff00,
575 .name = "Marvell 88E1101", 575 .name = "Marvell 88E1101/88E1111",
576 .features = MII_GBIT_FEATURES, 576 .features = MII_GBIT_FEATURES,
577 .config_aneg = &marvell_config_aneg, 577 .config_aneg = &marvell_config_aneg,
578 .read_status = &marvell_read_status, 578 .read_status = &marvell_read_status,
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 3d96714ed3cf..d9df1d9a5739 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -1149,7 +1149,7 @@ static void hamachi_tx_timeout(struct net_device *dev)
1149 skb->dev = dev; /* Mark as being used by this device. */ 1149 skb->dev = dev; /* Mark as being used by this device. */
1150 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1150 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1151 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1151 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1152 skb->tail, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1152 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
1153 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn | 1153 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn |
1154 DescEndPacket | DescIntr | (hmp->rx_buf_sz - 2)); 1154 DescEndPacket | DescIntr | (hmp->rx_buf_sz - 2));
1155 } 1155 }
@@ -1210,7 +1210,7 @@ static void hamachi_init_ring(struct net_device *dev)
1210 skb->dev = dev; /* Mark as being used by this device. */ 1210 skb->dev = dev; /* Mark as being used by this device. */
1211 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1211 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1212 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1212 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1213 skb->tail, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1213 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
1214 /* -2 because it doesn't REALLY have that first 2 bytes -KDU */ 1214 /* -2 because it doesn't REALLY have that first 2 bytes -KDU */
1215 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn | 1215 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn |
1216 DescEndPacket | DescIntr | (hmp->rx_buf_sz -2)); 1216 DescEndPacket | DescIntr | (hmp->rx_buf_sz -2));
@@ -1509,7 +1509,7 @@ static int hamachi_rx(struct net_device *dev)
1509 desc->addr, 1509 desc->addr,
1510 hmp->rx_buf_sz, 1510 hmp->rx_buf_sz,
1511 PCI_DMA_FROMDEVICE); 1511 PCI_DMA_FROMDEVICE);
1512 buf_addr = (u8 *) hmp->rx_skbuff[entry]->tail; 1512 buf_addr = (u8 *) hmp->rx_skbuff[entry]->data;
1513 frame_status = le32_to_cpu(get_unaligned((s32*)&(buf_addr[data_size - 12]))); 1513 frame_status = le32_to_cpu(get_unaligned((s32*)&(buf_addr[data_size - 12])));
1514 if (hamachi_debug > 4) 1514 if (hamachi_debug > 4)
1515 printk(KERN_DEBUG " hamachi_rx() status was %8.8x.\n", 1515 printk(KERN_DEBUG " hamachi_rx() status was %8.8x.\n",
@@ -1678,7 +1678,7 @@ static int hamachi_rx(struct net_device *dev)
1678 skb->dev = dev; /* Mark as being used by this device. */ 1678 skb->dev = dev; /* Mark as being used by this device. */
1679 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1679 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1680 desc->addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1680 desc->addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1681 skb->tail, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1681 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
1682 } 1682 }
1683 desc->status_n_length = cpu_to_le32(hmp->rx_buf_sz); 1683 desc->status_n_length = cpu_to_le32(hmp->rx_buf_sz);
1684 if (entry >= RX_RING_SIZE-1) 1684 if (entry >= RX_RING_SIZE-1)
@@ -1772,9 +1772,9 @@ static int hamachi_close(struct net_device *dev)
1772 readl(ioaddr + RxCurPtr) == (long)&hmp->rx_ring[i] ? '>' : ' ', 1772 readl(ioaddr + RxCurPtr) == (long)&hmp->rx_ring[i] ? '>' : ' ',
1773 i, hmp->rx_ring[i].status_n_length, hmp->rx_ring[i].addr); 1773 i, hmp->rx_ring[i].status_n_length, hmp->rx_ring[i].addr);
1774 if (hamachi_debug > 6) { 1774 if (hamachi_debug > 6) {
1775 if (*(u8*)hmp->rx_skbuff[i]->tail != 0x69) { 1775 if (*(u8*)hmp->rx_skbuff[i]->data != 0x69) {
1776 u16 *addr = (u16 *) 1776 u16 *addr = (u16 *)
1777 hmp->rx_skbuff[i]->tail; 1777 hmp->rx_skbuff[i]->data;
1778 int j; 1778 int j;
1779 1779
1780 for (j = 0; j < 0x50; j++) 1780 for (j = 0; j < 0x50; j++)
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 89454915b857..0b230222bfea 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -130,12 +130,11 @@ struct sixpack {
130 130
131#define AX25_6PACK_HEADER_LEN 0 131#define AX25_6PACK_HEADER_LEN 0
132 132
133static void sp_start_tx_timer(struct sixpack *);
134static void sixpack_decode(struct sixpack *, unsigned char[], int); 133static void sixpack_decode(struct sixpack *, unsigned char[], int);
135static int encode_sixpack(unsigned char *, unsigned char *, int, unsigned char); 134static int encode_sixpack(unsigned char *, unsigned char *, int, unsigned char);
136 135
137/* 136/*
138 * perform the persistence/slottime algorithm for CSMA access. If the 137 * Perform the persistence/slottime algorithm for CSMA access. If the
139 * persistence check was successful, write the data to the serial driver. 138 * persistence check was successful, write the data to the serial driver.
140 * Note that in case of DAMA operation, the data is not sent here. 139 * Note that in case of DAMA operation, the data is not sent here.
141 */ 140 */
@@ -143,7 +142,7 @@ static int encode_sixpack(unsigned char *, unsigned char *, int, unsigned char);
143static void sp_xmit_on_air(unsigned long channel) 142static void sp_xmit_on_air(unsigned long channel)
144{ 143{
145 struct sixpack *sp = (struct sixpack *) channel; 144 struct sixpack *sp = (struct sixpack *) channel;
146 int actual; 145 int actual, when = sp->slottime;
147 static unsigned char random; 146 static unsigned char random;
148 147
149 random = random * 17 + 41; 148 random = random * 17 + 41;
@@ -159,20 +158,10 @@ static void sp_xmit_on_air(unsigned long channel)
159 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 158 sp->tty->driver->write(sp->tty, &sp->led_state, 1);
160 sp->status2 = 0; 159 sp->status2 = 0;
161 } else 160 } else
162 sp_start_tx_timer(sp); 161 mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100);
163} 162}
164 163
165/* ----> 6pack timer interrupt handler and friends. <---- */ 164/* ----> 6pack timer interrupt handler and friends. <---- */
166static void sp_start_tx_timer(struct sixpack *sp)
167{
168 int when = sp->slottime;
169
170 del_timer(&sp->tx_t);
171 sp->tx_t.data = (unsigned long) sp;
172 sp->tx_t.function = sp_xmit_on_air;
173 sp->tx_t.expires = jiffies + ((when + 1) * HZ) / 100;
174 add_timer(&sp->tx_t);
175}
176 165
177/* Encapsulate one AX.25 frame and stuff into a TTY queue. */ 166/* Encapsulate one AX.25 frame and stuff into a TTY queue. */
178static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len) 167static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len)
@@ -243,8 +232,7 @@ static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len)
243 sp->xleft = count; 232 sp->xleft = count;
244 sp->xhead = sp->xbuff; 233 sp->xhead = sp->xbuff;
245 sp->status2 = count; 234 sp->status2 = count;
246 if (sp->duplex == 0) 235 sp_xmit_on_air((unsigned long)sp);
247 sp_start_tx_timer(sp);
248 } 236 }
249 237
250 return; 238 return;
@@ -320,12 +308,6 @@ static int sp_set_mac_address(struct net_device *dev, void *addr)
320{ 308{
321 struct sockaddr_ax25 *sa = addr; 309 struct sockaddr_ax25 *sa = addr;
322 310
323 if (sa->sax25_family != AF_AX25)
324 return -EINVAL;
325
326 if (!sa->sax25_ndigis)
327 return -EINVAL;
328
329 spin_lock_irq(&dev->xmit_lock); 311 spin_lock_irq(&dev->xmit_lock);
330 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN); 312 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN);
331 spin_unlock_irq(&dev->xmit_lock); 313 spin_unlock_irq(&dev->xmit_lock);
@@ -680,6 +662,9 @@ static int sixpack_open(struct tty_struct *tty)
680 netif_start_queue(dev); 662 netif_start_queue(dev);
681 663
682 init_timer(&sp->tx_t); 664 init_timer(&sp->tx_t);
665 sp->tx_t.function = sp_xmit_on_air;
666 sp->tx_t.data = (unsigned long) sp;
667
683 init_timer(&sp->resync_t); 668 init_timer(&sp->resync_t);
684 669
685 spin_unlock_bh(&sp->lock); 670 spin_unlock_bh(&sp->lock);
@@ -848,7 +833,7 @@ static void __exit sixpack_exit_driver(void)
848{ 833{
849 int ret; 834 int ret;
850 835
851 if ((ret = tty_register_ldisc(N_6PACK, NULL))) 836 if ((ret = tty_unregister_ldisc(N_6PACK)))
852 printk(msg_unregfail, ret); 837 printk(msg_unregfail, ret);
853} 838}
854 839
diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
index 7cdebe1a0b61..de087cd609d9 100644
--- a/drivers/net/hamradio/Kconfig
+++ b/drivers/net/hamradio/Kconfig
@@ -1,6 +1,6 @@
1config MKISS 1config MKISS
2 tristate "Serial port KISS driver" 2 tristate "Serial port KISS driver"
3 depends on AX25 && BROKEN_ON_SMP 3 depends on AX25
4 ---help--- 4 ---help---
5 KISS is a protocol used for the exchange of data between a computer 5 KISS is a protocol used for the exchange of data between a computer
6 and a Terminal Node Controller (a small embedded system commonly 6 and a Terminal Node Controller (a small embedded system commonly
@@ -17,7 +17,7 @@ config MKISS
17 17
18config 6PACK 18config 6PACK
19 tristate "Serial port 6PACK driver" 19 tristate "Serial port 6PACK driver"
20 depends on AX25 && BROKEN_ON_SMP 20 depends on AX25
21 ---help--- 21 ---help---
22 6pack is a transmission protocol for the data exchange between your 22 6pack is a transmission protocol for the data exchange between your
23 PC and your TNC (the Terminal Node Controller acts as a kind of 23 PC and your TNC (the Terminal Node Controller acts as a kind of
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index a7f15d9f13e5..5298096afbdb 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -54,6 +54,7 @@
54#include <linux/kmod.h> 54#include <linux/kmod.h>
55#include <linux/hdlcdrv.h> 55#include <linux/hdlcdrv.h>
56#include <linux/baycom.h> 56#include <linux/baycom.h>
57#include <linux/jiffies.h>
57#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 58#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
58/* prototypes for ax25_encapsulate and ax25_rebuild_header */ 59/* prototypes for ax25_encapsulate and ax25_rebuild_header */
59#include <net/ax25.h> 60#include <net/ax25.h>
@@ -287,7 +288,7 @@ static inline void baycom_int_freq(struct baycom_state *bc)
287 * measure the interrupt frequency 288 * measure the interrupt frequency
288 */ 289 */
289 bc->debug_vals.cur_intcnt++; 290 bc->debug_vals.cur_intcnt++;
290 if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { 291 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
291 bc->debug_vals.last_jiffies = cur_jiffies; 292 bc->debug_vals.last_jiffies = cur_jiffies;
292 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; 293 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
293 bc->debug_vals.cur_intcnt = 0; 294 bc->debug_vals.cur_intcnt = 0;
diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c
index 612ad452bee0..3b1bef1ee215 100644
--- a/drivers/net/hamradio/baycom_par.c
+++ b/drivers/net/hamradio/baycom_par.c
@@ -84,6 +84,7 @@
84#include <linux/baycom.h> 84#include <linux/baycom.h>
85#include <linux/parport.h> 85#include <linux/parport.h>
86#include <linux/bitops.h> 86#include <linux/bitops.h>
87#include <linux/jiffies.h>
87 88
88#include <asm/bug.h> 89#include <asm/bug.h>
89#include <asm/system.h> 90#include <asm/system.h>
@@ -165,7 +166,7 @@ static void __inline__ baycom_int_freq(struct baycom_state *bc)
165 * measure the interrupt frequency 166 * measure the interrupt frequency
166 */ 167 */
167 bc->debug_vals.cur_intcnt++; 168 bc->debug_vals.cur_intcnt++;
168 if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { 169 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
169 bc->debug_vals.last_jiffies = cur_jiffies; 170 bc->debug_vals.last_jiffies = cur_jiffies;
170 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; 171 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
171 bc->debug_vals.cur_intcnt = 0; 172 bc->debug_vals.cur_intcnt = 0;
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 25f270b05378..232793d2ce6b 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -79,6 +79,7 @@
79#include <asm/io.h> 79#include <asm/io.h>
80#include <linux/hdlcdrv.h> 80#include <linux/hdlcdrv.h>
81#include <linux/baycom.h> 81#include <linux/baycom.h>
82#include <linux/jiffies.h>
82 83
83/* --------------------------------------------------------------------- */ 84/* --------------------------------------------------------------------- */
84 85
@@ -159,7 +160,7 @@ static inline void baycom_int_freq(struct baycom_state *bc)
159 * measure the interrupt frequency 160 * measure the interrupt frequency
160 */ 161 */
161 bc->debug_vals.cur_intcnt++; 162 bc->debug_vals.cur_intcnt++;
162 if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { 163 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
163 bc->debug_vals.last_jiffies = cur_jiffies; 164 bc->debug_vals.last_jiffies = cur_jiffies;
164 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; 165 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
165 bc->debug_vals.cur_intcnt = 0; 166 bc->debug_vals.cur_intcnt = 0;
diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c
index eead85d00962..be596a3eb3fd 100644
--- a/drivers/net/hamradio/baycom_ser_hdx.c
+++ b/drivers/net/hamradio/baycom_ser_hdx.c
@@ -69,6 +69,7 @@
69#include <asm/io.h> 69#include <asm/io.h>
70#include <linux/hdlcdrv.h> 70#include <linux/hdlcdrv.h>
71#include <linux/baycom.h> 71#include <linux/baycom.h>
72#include <linux/jiffies.h>
72 73
73/* --------------------------------------------------------------------- */ 74/* --------------------------------------------------------------------- */
74 75
@@ -150,7 +151,7 @@ static inline void baycom_int_freq(struct baycom_state *bc)
150 * measure the interrupt frequency 151 * measure the interrupt frequency
151 */ 152 */
152 bc->debug_vals.cur_intcnt++; 153 bc->debug_vals.cur_intcnt++;
153 if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { 154 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
154 bc->debug_vals.last_jiffies = cur_jiffies; 155 bc->debug_vals.last_jiffies = cur_jiffies;
155 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; 156 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
156 bc->debug_vals.cur_intcnt = 0; 157 bc->debug_vals.cur_intcnt = 0;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 62790511098f..63b1a2b86acb 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -1,30 +1,19 @@
1/* 1/*
2 * MKISS Driver 2 * This program is free software; you can distribute it and/or modify it
3 * under the terms of the GNU General Public License (Version 2) as
4 * published by the Free Software Foundation.
3 * 5 *
4 * This module: 6 * This program is distributed in the hope it will be useful, but WITHOUT
5 * This module is free software; you can redistribute it and/or 7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6 * modify it under the terms of the GNU General Public License 8 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7 * as published by the Free Software Foundation; either version 9 * for more details.
8 * 2 of the License, or (at your option) any later version.
9 * 10 *
10 * This module implements the AX.25 protocol for kernel-based 11 * You should have received a copy of the GNU General Public License along
11 * devices like TTYs. It interfaces between a raw TTY, and the 12 * with this program; if not, write to the Free Software Foundation, Inc.,
12 * kernel's AX.25 protocol layers, just like slip.c. 13 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
13 * AX.25 needs to be separated from slip.c while slip.c is no
14 * longer a static kernel device since it is a module.
15 * This method clears the way to implement other kiss protocols
16 * like mkiss smack g8bpq ..... so far only mkiss is implemented.
17 * 14 *
18 * Hans Alblas <hans@esrac.ele.tue.nl> 15 * Copyright (C) Hans Alblas PE1AYX <hans@esrac.ele.tue.nl>
19 * 16 * Copyright (C) 2004, 05 Ralf Baechle DL5RB <ralf@linux-mips.org>
20 * History
21 * Jonathan (G4KLX) Fixed to match Linux networking changes - 2.1.15.
22 * Matthias (DG2FEF) Added support for FlexNet CRC (on special request)
23 * Fixed bug in ax25_close(): dev_lock_wait() was
24 * called twice, causing a deadlock.
25 * Jeroen (PE1RXQ) Removed old MKISS_MAGIC stuff and calls to
26 * MOD_*_USE_COUNT
27 * Remove cli() and fix rtnl lock usage.
28 */ 17 */
29 18
30#include <linux/config.h> 19#include <linux/config.h>
@@ -46,177 +35,300 @@
46#include <linux/etherdevice.h> 35#include <linux/etherdevice.h>
47#include <linux/skbuff.h> 36#include <linux/skbuff.h>
48#include <linux/if_arp.h> 37#include <linux/if_arp.h>
38#include <linux/jiffies.h>
49 39
50#include <net/ax25.h> 40#include <net/ax25.h>
51 41
52#include "mkiss.h"
53
54#ifdef CONFIG_INET 42#ifdef CONFIG_INET
55#include <linux/ip.h> 43#include <linux/ip.h>
56#include <linux/tcp.h> 44#include <linux/tcp.h>
57#endif 45#endif
58 46
59static char banner[] __initdata = KERN_INFO "mkiss: AX.25 Multikiss, Hans Albas PE1AYX\n"; 47#define AX_MTU 236
60 48
61typedef struct ax25_ctrl { 49/* SLIP/KISS protocol characters. */
62 struct ax_disp ctrl; /* */ 50#define END 0300 /* indicates end of frame */
63 struct net_device dev; /* the device */ 51#define ESC 0333 /* indicates byte stuffing */
64} ax25_ctrl_t; 52#define ESC_END 0334 /* ESC ESC_END means END 'data' */
65 53#define ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */
66static ax25_ctrl_t **ax25_ctrls; 54
67 55struct mkiss {
68int ax25_maxdev = AX25_MAXDEV; /* Can be overridden with insmod! */ 56 struct tty_struct *tty; /* ptr to TTY structure */
69 57 struct net_device *dev; /* easy for intr handling */
70static struct tty_ldisc ax_ldisc; 58
71 59 /* These are pointers to the malloc()ed frame buffers. */
72static int ax25_init(struct net_device *); 60 spinlock_t buflock;/* lock for rbuf and xbuf */
73static int kiss_esc(unsigned char *, unsigned char *, int); 61 unsigned char *rbuff; /* receiver buffer */
74static int kiss_esc_crc(unsigned char *, unsigned char *, unsigned short, int); 62 int rcount; /* received chars counter */
75static void kiss_unesc(struct ax_disp *, unsigned char); 63 unsigned char *xbuff; /* transmitter buffer */
64 unsigned char *xhead; /* pointer to next byte to XMIT */
65 int xleft; /* bytes left in XMIT queue */
66
67 struct net_device_stats stats;
68
69 /* Detailed SLIP statistics. */
70 int mtu; /* Our mtu (to spot changes!) */
71 int buffsize; /* Max buffers sizes */
72
73 unsigned long flags; /* Flag values/ mode etc */
74 /* long req'd: used by set_bit --RR */
75#define AXF_INUSE 0 /* Channel in use */
76#define AXF_ESCAPE 1 /* ESC received */
77#define AXF_ERROR 2 /* Parity, etc. error */
78#define AXF_KEEPTEST 3 /* Keepalive test flag */
79#define AXF_OUTWAIT 4 /* is outpacket was flag */
80
81 int mode;
82 int crcmode; /* MW: for FlexNet, SMACK etc. */
83#define CRC_MODE_NONE 0
84#define CRC_MODE_FLEX 1
85#define CRC_MODE_SMACK 2
86
87 atomic_t refcnt;
88 struct semaphore dead_sem;
89};
76 90
77/*---------------------------------------------------------------------------*/ 91/*---------------------------------------------------------------------------*/
78 92
79static const unsigned short Crc_flex_table[] = { 93static const unsigned short crc_flex_table[] = {
80 0x0f87, 0x1e0e, 0x2c95, 0x3d1c, 0x49a3, 0x582a, 0x6ab1, 0x7b38, 94 0x0f87, 0x1e0e, 0x2c95, 0x3d1c, 0x49a3, 0x582a, 0x6ab1, 0x7b38,
81 0x83cf, 0x9246, 0xa0dd, 0xb154, 0xc5eb, 0xd462, 0xe6f9, 0xf770, 95 0x83cf, 0x9246, 0xa0dd, 0xb154, 0xc5eb, 0xd462, 0xe6f9, 0xf770,
82 0x1f06, 0x0e8f, 0x3c14, 0x2d9d, 0x5922, 0x48ab, 0x7a30, 0x6bb9, 96 0x1f06, 0x0e8f, 0x3c14, 0x2d9d, 0x5922, 0x48ab, 0x7a30, 0x6bb9,
83 0x934e, 0x82c7, 0xb05c, 0xa1d5, 0xd56a, 0xc4e3, 0xf678, 0xe7f1, 97 0x934e, 0x82c7, 0xb05c, 0xa1d5, 0xd56a, 0xc4e3, 0xf678, 0xe7f1,
84 0x2e85, 0x3f0c, 0x0d97, 0x1c1e, 0x68a1, 0x7928, 0x4bb3, 0x5a3a, 98 0x2e85, 0x3f0c, 0x0d97, 0x1c1e, 0x68a1, 0x7928, 0x4bb3, 0x5a3a,
85 0xa2cd, 0xb344, 0x81df, 0x9056, 0xe4e9, 0xf560, 0xc7fb, 0xd672, 99 0xa2cd, 0xb344, 0x81df, 0x9056, 0xe4e9, 0xf560, 0xc7fb, 0xd672,
86 0x3e04, 0x2f8d, 0x1d16, 0x0c9f, 0x7820, 0x69a9, 0x5b32, 0x4abb, 100 0x3e04, 0x2f8d, 0x1d16, 0x0c9f, 0x7820, 0x69a9, 0x5b32, 0x4abb,
87 0xb24c, 0xa3c5, 0x915e, 0x80d7, 0xf468, 0xe5e1, 0xd77a, 0xc6f3, 101 0xb24c, 0xa3c5, 0x915e, 0x80d7, 0xf468, 0xe5e1, 0xd77a, 0xc6f3,
88 0x4d83, 0x5c0a, 0x6e91, 0x7f18, 0x0ba7, 0x1a2e, 0x28b5, 0x393c, 102 0x4d83, 0x5c0a, 0x6e91, 0x7f18, 0x0ba7, 0x1a2e, 0x28b5, 0x393c,
89 0xc1cb, 0xd042, 0xe2d9, 0xf350, 0x87ef, 0x9666, 0xa4fd, 0xb574, 103 0xc1cb, 0xd042, 0xe2d9, 0xf350, 0x87ef, 0x9666, 0xa4fd, 0xb574,
90 0x5d02, 0x4c8b, 0x7e10, 0x6f99, 0x1b26, 0x0aaf, 0x3834, 0x29bd, 104 0x5d02, 0x4c8b, 0x7e10, 0x6f99, 0x1b26, 0x0aaf, 0x3834, 0x29bd,
91 0xd14a, 0xc0c3, 0xf258, 0xe3d1, 0x976e, 0x86e7, 0xb47c, 0xa5f5, 105 0xd14a, 0xc0c3, 0xf258, 0xe3d1, 0x976e, 0x86e7, 0xb47c, 0xa5f5,
92 0x6c81, 0x7d08, 0x4f93, 0x5e1a, 0x2aa5, 0x3b2c, 0x09b7, 0x183e, 106 0x6c81, 0x7d08, 0x4f93, 0x5e1a, 0x2aa5, 0x3b2c, 0x09b7, 0x183e,
93 0xe0c9, 0xf140, 0xc3db, 0xd252, 0xa6ed, 0xb764, 0x85ff, 0x9476, 107 0xe0c9, 0xf140, 0xc3db, 0xd252, 0xa6ed, 0xb764, 0x85ff, 0x9476,
94 0x7c00, 0x6d89, 0x5f12, 0x4e9b, 0x3a24, 0x2bad, 0x1936, 0x08bf, 108 0x7c00, 0x6d89, 0x5f12, 0x4e9b, 0x3a24, 0x2bad, 0x1936, 0x08bf,
95 0xf048, 0xe1c1, 0xd35a, 0xc2d3, 0xb66c, 0xa7e5, 0x957e, 0x84f7, 109 0xf048, 0xe1c1, 0xd35a, 0xc2d3, 0xb66c, 0xa7e5, 0x957e, 0x84f7,
96 0x8b8f, 0x9a06, 0xa89d, 0xb914, 0xcdab, 0xdc22, 0xeeb9, 0xff30, 110 0x8b8f, 0x9a06, 0xa89d, 0xb914, 0xcdab, 0xdc22, 0xeeb9, 0xff30,
97 0x07c7, 0x164e, 0x24d5, 0x355c, 0x41e3, 0x506a, 0x62f1, 0x7378, 111 0x07c7, 0x164e, 0x24d5, 0x355c, 0x41e3, 0x506a, 0x62f1, 0x7378,
98 0x9b0e, 0x8a87, 0xb81c, 0xa995, 0xdd2a, 0xcca3, 0xfe38, 0xefb1, 112 0x9b0e, 0x8a87, 0xb81c, 0xa995, 0xdd2a, 0xcca3, 0xfe38, 0xefb1,
99 0x1746, 0x06cf, 0x3454, 0x25dd, 0x5162, 0x40eb, 0x7270, 0x63f9, 113 0x1746, 0x06cf, 0x3454, 0x25dd, 0x5162, 0x40eb, 0x7270, 0x63f9,
100 0xaa8d, 0xbb04, 0x899f, 0x9816, 0xeca9, 0xfd20, 0xcfbb, 0xde32, 114 0xaa8d, 0xbb04, 0x899f, 0x9816, 0xeca9, 0xfd20, 0xcfbb, 0xde32,
101 0x26c5, 0x374c, 0x05d7, 0x145e, 0x60e1, 0x7168, 0x43f3, 0x527a, 115 0x26c5, 0x374c, 0x05d7, 0x145e, 0x60e1, 0x7168, 0x43f3, 0x527a,
102 0xba0c, 0xab85, 0x991e, 0x8897, 0xfc28, 0xeda1, 0xdf3a, 0xceb3, 116 0xba0c, 0xab85, 0x991e, 0x8897, 0xfc28, 0xeda1, 0xdf3a, 0xceb3,
103 0x3644, 0x27cd, 0x1556, 0x04df, 0x7060, 0x61e9, 0x5372, 0x42fb, 117 0x3644, 0x27cd, 0x1556, 0x04df, 0x7060, 0x61e9, 0x5372, 0x42fb,
104 0xc98b, 0xd802, 0xea99, 0xfb10, 0x8faf, 0x9e26, 0xacbd, 0xbd34, 118 0xc98b, 0xd802, 0xea99, 0xfb10, 0x8faf, 0x9e26, 0xacbd, 0xbd34,
105 0x45c3, 0x544a, 0x66d1, 0x7758, 0x03e7, 0x126e, 0x20f5, 0x317c, 119 0x45c3, 0x544a, 0x66d1, 0x7758, 0x03e7, 0x126e, 0x20f5, 0x317c,
106 0xd90a, 0xc883, 0xfa18, 0xeb91, 0x9f2e, 0x8ea7, 0xbc3c, 0xadb5, 120 0xd90a, 0xc883, 0xfa18, 0xeb91, 0x9f2e, 0x8ea7, 0xbc3c, 0xadb5,
107 0x5542, 0x44cb, 0x7650, 0x67d9, 0x1366, 0x02ef, 0x3074, 0x21fd, 121 0x5542, 0x44cb, 0x7650, 0x67d9, 0x1366, 0x02ef, 0x3074, 0x21fd,
108 0xe889, 0xf900, 0xcb9b, 0xda12, 0xaead, 0xbf24, 0x8dbf, 0x9c36, 122 0xe889, 0xf900, 0xcb9b, 0xda12, 0xaead, 0xbf24, 0x8dbf, 0x9c36,
109 0x64c1, 0x7548, 0x47d3, 0x565a, 0x22e5, 0x336c, 0x01f7, 0x107e, 123 0x64c1, 0x7548, 0x47d3, 0x565a, 0x22e5, 0x336c, 0x01f7, 0x107e,
110 0xf808, 0xe981, 0xdb1a, 0xca93, 0xbe2c, 0xafa5, 0x9d3e, 0x8cb7, 124 0xf808, 0xe981, 0xdb1a, 0xca93, 0xbe2c, 0xafa5, 0x9d3e, 0x8cb7,
111 0x7440, 0x65c9, 0x5752, 0x46db, 0x3264, 0x23ed, 0x1176, 0x00ff 125 0x7440, 0x65c9, 0x5752, 0x46db, 0x3264, 0x23ed, 0x1176, 0x00ff
112}; 126};
113 127
114/*---------------------------------------------------------------------------*/
115
116static unsigned short calc_crc_flex(unsigned char *cp, int size) 128static unsigned short calc_crc_flex(unsigned char *cp, int size)
117{ 129{
118 unsigned short crc = 0xffff; 130 unsigned short crc = 0xffff;
119
120 while (size--)
121 crc = (crc << 8) ^ Crc_flex_table[((crc >> 8) ^ *cp++) & 0xff];
122 131
123 return crc; 132 while (size--)
124} 133 crc = (crc << 8) ^ crc_flex_table[((crc >> 8) ^ *cp++) & 0xff];
125 134
126/*---------------------------------------------------------------------------*/ 135 return crc;
136}
127 137
128static int check_crc_flex(unsigned char *cp, int size) 138static int check_crc_flex(unsigned char *cp, int size)
129{ 139{
130 unsigned short crc = 0xffff; 140 unsigned short crc = 0xffff;
131 141
132 if (size < 3) 142 if (size < 3)
133 return -1; 143 return -1;
134 144
135 while (size--) 145 while (size--)
136 crc = (crc << 8) ^ Crc_flex_table[((crc >> 8) ^ *cp++) & 0xff]; 146 crc = (crc << 8) ^ crc_flex_table[((crc >> 8) ^ *cp++) & 0xff];
137 147
138 if ((crc & 0xffff) != 0x7070) 148 if ((crc & 0xffff) != 0x7070)
139 return -1; 149 return -1;
140 150
141 return 0; 151 return 0;
142} 152}
143 153
144/*---------------------------------------------------------------------------*/ 154/*
155 * Standard encapsulation
156 */
145 157
146/* Find a free channel, and link in this `tty' line. */ 158static int kiss_esc(unsigned char *s, unsigned char *d, int len)
147static inline struct ax_disp *ax_alloc(void)
148{ 159{
149 ax25_ctrl_t *axp=NULL; 160 unsigned char *ptr = d;
150 int i; 161 unsigned char c;
151 162
152 for (i = 0; i < ax25_maxdev; i++) { 163 /*
153 axp = ax25_ctrls[i]; 164 * Send an initial END character to flush out any data that may have
165 * accumulated in the receiver due to line noise.
166 */
154 167
155 /* Not allocated ? */ 168 *ptr++ = END;
156 if (axp == NULL)
157 break;
158 169
159 /* Not in use ? */ 170 while (len-- > 0) {
160 if (!test_and_set_bit(AXF_INUSE, &axp->ctrl.flags)) 171 switch (c = *s++) {
172 case END:
173 *ptr++ = ESC;
174 *ptr++ = ESC_END;
161 break; 175 break;
176 case ESC:
177 *ptr++ = ESC;
178 *ptr++ = ESC_ESC;
179 break;
180 default:
181 *ptr++ = c;
182 break;
183 }
162 } 184 }
163 185
164 /* Sorry, too many, all slots in use */ 186 *ptr++ = END;
165 if (i >= ax25_maxdev) 187
166 return NULL; 188 return ptr - d;
189}
190
191/*
192 * MW:
193 * OK its ugly, but tell me a better solution without copying the
194 * packet to a temporary buffer :-)
195 */
196static int kiss_esc_crc(unsigned char *s, unsigned char *d, unsigned short crc,
197 int len)
198{
199 unsigned char *ptr = d;
200 unsigned char c=0;
201
202 *ptr++ = END;
203 while (len > 0) {
204 if (len > 2)
205 c = *s++;
206 else if (len > 1)
207 c = crc >> 8;
208 else if (len > 0)
209 c = crc & 0xff;
210
211 len--;
167 212
168 /* If no channels are available, allocate one */ 213 switch (c) {
169 if (axp == NULL && (ax25_ctrls[i] = kmalloc(sizeof(ax25_ctrl_t), GFP_KERNEL)) != NULL) { 214 case END:
170 axp = ax25_ctrls[i]; 215 *ptr++ = ESC;
216 *ptr++ = ESC_END;
217 break;
218 case ESC:
219 *ptr++ = ESC;
220 *ptr++ = ESC_ESC;
221 break;
222 default:
223 *ptr++ = c;
224 break;
225 }
171 } 226 }
172 memset(axp, 0, sizeof(ax25_ctrl_t)); 227 *ptr++ = END;
173 228
174 /* Initialize channel control data */ 229 return ptr - d;
175 set_bit(AXF_INUSE, &axp->ctrl.flags); 230}
176 sprintf(axp->dev.name, "ax%d", i++); 231
177 axp->ctrl.tty = NULL; 232/* Send one completely decapsulated AX.25 packet to the AX.25 layer. */
178 axp->dev.base_addr = i; 233static void ax_bump(struct mkiss *ax)
179 axp->dev.priv = (void *)&axp->ctrl; 234{
180 axp->dev.next = NULL; 235 struct sk_buff *skb;
181 axp->dev.init = ax25_init; 236 int count;
182 237
183 if (axp != NULL) { 238 spin_lock_bh(&ax->buflock);
184 /* 239 if (ax->rbuff[0] > 0x0f) {
185 * register device so that it can be ifconfig'ed 240 if (ax->rbuff[0] & 0x20) {
186 * ax25_init() will be called as a side-effect 241 ax->crcmode = CRC_MODE_FLEX;
187 * SIDE-EFFECT WARNING: ax25_init() CLEARS axp->ctrl ! 242 if (check_crc_flex(ax->rbuff, ax->rcount) < 0) {
188 */ 243 ax->stats.rx_errors++;
189 if (register_netdev(&axp->dev) == 0) { 244 return;
190 /* (Re-)Set the INUSE bit. Very Important! */ 245 }
191 set_bit(AXF_INUSE, &axp->ctrl.flags); 246 ax->rcount -= 2;
192 axp->ctrl.dev = &axp->dev; 247 /* dl9sau bugfix: the trailling two bytes flexnet crc
193 axp->dev.priv = (void *) &axp->ctrl; 248 * will not be passed to the kernel. thus we have
194 249 * to correct the kissparm signature, because it
195 return &axp->ctrl; 250 * indicates a crc but there's none
196 } else { 251 */
197 clear_bit(AXF_INUSE,&axp->ctrl.flags); 252 *ax->rbuff &= ~0x20;
198 printk(KERN_ERR "mkiss: ax_alloc() - register_netdev() failure.\n");
199 } 253 }
254 }
255 spin_unlock_bh(&ax->buflock);
256
257 count = ax->rcount;
258
259 if ((skb = dev_alloc_skb(count)) == NULL) {
260 printk(KERN_ERR "mkiss: %s: memory squeeze, dropping packet.\n",
261 ax->dev->name);
262 ax->stats.rx_dropped++;
263 return;
200 } 264 }
201 265
202 return NULL; 266 spin_lock_bh(&ax->buflock);
267 memcpy(skb_put(skb,count), ax->rbuff, count);
268 spin_unlock_bh(&ax->buflock);
269 skb->protocol = ax25_type_trans(skb, ax->dev);
270 netif_rx(skb);
271 ax->dev->last_rx = jiffies;
272 ax->stats.rx_packets++;
273 ax->stats.rx_bytes += count;
203} 274}
204 275
205/* Free an AX25 channel. */ 276static void kiss_unesc(struct mkiss *ax, unsigned char s)
206static inline void ax_free(struct ax_disp *ax)
207{ 277{
208 /* Free all AX25 frame buffers. */ 278 switch (s) {
209 if (ax->rbuff) 279 case END:
210 kfree(ax->rbuff); 280 /* drop keeptest bit = VSV */
211 ax->rbuff = NULL; 281 if (test_bit(AXF_KEEPTEST, &ax->flags))
212 if (ax->xbuff) 282 clear_bit(AXF_KEEPTEST, &ax->flags);
213 kfree(ax->xbuff); 283
214 ax->xbuff = NULL; 284 if (!test_and_clear_bit(AXF_ERROR, &ax->flags) && (ax->rcount > 2))
215 if (!test_and_clear_bit(AXF_INUSE, &ax->flags)) 285 ax_bump(ax);
216 printk(KERN_ERR "mkiss: %s: ax_free for already free unit.\n", ax->dev->name); 286
287 clear_bit(AXF_ESCAPE, &ax->flags);
288 ax->rcount = 0;
289 return;
290
291 case ESC:
292 set_bit(AXF_ESCAPE, &ax->flags);
293 return;
294 case ESC_ESC:
295 if (test_and_clear_bit(AXF_ESCAPE, &ax->flags))
296 s = ESC;
297 break;
298 case ESC_END:
299 if (test_and_clear_bit(AXF_ESCAPE, &ax->flags))
300 s = END;
301 break;
302 }
303
304 spin_lock_bh(&ax->buflock);
305 if (!test_bit(AXF_ERROR, &ax->flags)) {
306 if (ax->rcount < ax->buffsize) {
307 ax->rbuff[ax->rcount++] = s;
308 spin_unlock_bh(&ax->buflock);
309 return;
310 }
311
312 ax->stats.rx_over_errors++;
313 set_bit(AXF_ERROR, &ax->flags);
314 }
315 spin_unlock_bh(&ax->buflock);
316}
317
318static int ax_set_mac_address(struct net_device *dev, void *addr)
319{
320 struct sockaddr_ax25 *sa = addr;
321
322 spin_lock_irq(&dev->xmit_lock);
323 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN);
324 spin_unlock_irq(&dev->xmit_lock);
325
326 return 0;
217} 327}
218 328
219static void ax_changedmtu(struct ax_disp *ax) 329/*---------------------------------------------------------------------------*/
330
331static void ax_changedmtu(struct mkiss *ax)
220{ 332{
221 struct net_device *dev = ax->dev; 333 struct net_device *dev = ax->dev;
222 unsigned char *xbuff, *rbuff, *oxbuff, *orbuff; 334 unsigned char *xbuff, *rbuff, *oxbuff, *orbuff;
@@ -236,7 +348,8 @@ static void ax_changedmtu(struct ax_disp *ax)
236 rbuff = kmalloc(len + 4, GFP_ATOMIC); 348 rbuff = kmalloc(len + 4, GFP_ATOMIC);
237 349
238 if (xbuff == NULL || rbuff == NULL) { 350 if (xbuff == NULL || rbuff == NULL) {
239 printk(KERN_ERR "mkiss: %s: unable to grow ax25 buffers, MTU change cancelled.\n", 351 printk(KERN_ERR "mkiss: %s: unable to grow ax25 buffers, "
352 "MTU change cancelled.\n",
240 ax->dev->name); 353 ax->dev->name);
241 dev->mtu = ax->mtu; 354 dev->mtu = ax->mtu;
242 if (xbuff != NULL) 355 if (xbuff != NULL)
@@ -258,7 +371,7 @@ static void ax_changedmtu(struct ax_disp *ax)
258 memcpy(ax->xbuff, ax->xhead, ax->xleft); 371 memcpy(ax->xbuff, ax->xhead, ax->xleft);
259 } else { 372 } else {
260 ax->xleft = 0; 373 ax->xleft = 0;
261 ax->tx_dropped++; 374 ax->stats.tx_dropped++;
262 } 375 }
263 } 376 }
264 377
@@ -269,7 +382,7 @@ static void ax_changedmtu(struct ax_disp *ax)
269 memcpy(ax->rbuff, orbuff, ax->rcount); 382 memcpy(ax->rbuff, orbuff, ax->rcount);
270 } else { 383 } else {
271 ax->rcount = 0; 384 ax->rcount = 0;
272 ax->rx_over_errors++; 385 ax->stats.rx_over_errors++;
273 set_bit(AXF_ERROR, &ax->flags); 386 set_bit(AXF_ERROR, &ax->flags);
274 } 387 }
275 } 388 }
@@ -279,72 +392,14 @@ static void ax_changedmtu(struct ax_disp *ax)
279 392
280 spin_unlock_bh(&ax->buflock); 393 spin_unlock_bh(&ax->buflock);
281 394
282 if (oxbuff != NULL) 395 kfree(oxbuff);
283 kfree(oxbuff); 396 kfree(orbuff);
284 if (orbuff != NULL)
285 kfree(orbuff);
286}
287
288
289/* Set the "sending" flag. This must be atomic. */
290static inline void ax_lock(struct ax_disp *ax)
291{
292 netif_stop_queue(ax->dev);
293}
294
295
296/* Clear the "sending" flag. This must be atomic. */
297static inline void ax_unlock(struct ax_disp *ax)
298{
299 netif_start_queue(ax->dev);
300}
301
302/* Send one completely decapsulated AX.25 packet to the AX.25 layer. */
303static void ax_bump(struct ax_disp *ax)
304{
305 struct sk_buff *skb;
306 int count;
307
308 spin_lock_bh(&ax->buflock);
309 if (ax->rbuff[0] > 0x0f) {
310 if (ax->rbuff[0] & 0x20) {
311 ax->crcmode = CRC_MODE_FLEX;
312 if (check_crc_flex(ax->rbuff, ax->rcount) < 0) {
313 ax->rx_errors++;
314 return;
315 }
316 ax->rcount -= 2;
317 /* dl9sau bugfix: the trailling two bytes flexnet crc
318 * will not be passed to the kernel. thus we have
319 * to correct the kissparm signature, because it
320 * indicates a crc but there's none
321 */
322 *ax->rbuff &= ~0x20;
323 }
324 }
325 spin_unlock_bh(&ax->buflock);
326
327 count = ax->rcount;
328
329 if ((skb = dev_alloc_skb(count)) == NULL) {
330 printk(KERN_ERR "mkiss: %s: memory squeeze, dropping packet.\n", ax->dev->name);
331 ax->rx_dropped++;
332 return;
333 }
334
335 spin_lock_bh(&ax->buflock);
336 memcpy(skb_put(skb,count), ax->rbuff, count);
337 spin_unlock_bh(&ax->buflock);
338 skb->protocol = ax25_type_trans(skb, ax->dev);
339 netif_rx(skb);
340 ax->dev->last_rx = jiffies;
341 ax->rx_packets++;
342 ax->rx_bytes+=count;
343} 397}
344 398
345/* Encapsulate one AX.25 packet and stuff into a TTY queue. */ 399/* Encapsulate one AX.25 packet and stuff into a TTY queue. */
346static void ax_encaps(struct ax_disp *ax, unsigned char *icp, int len) 400static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
347{ 401{
402 struct mkiss *ax = netdev_priv(dev);
348 unsigned char *p; 403 unsigned char *p;
349 int actual, count; 404 int actual, count;
350 405
@@ -354,8 +409,8 @@ static void ax_encaps(struct ax_disp *ax, unsigned char *icp, int len)
354 if (len > ax->mtu) { /* Sigh, shouldn't occur BUT ... */ 409 if (len > ax->mtu) { /* Sigh, shouldn't occur BUT ... */
355 len = ax->mtu; 410 len = ax->mtu;
356 printk(KERN_ERR "mkiss: %s: truncating oversized transmit packet!\n", ax->dev->name); 411 printk(KERN_ERR "mkiss: %s: truncating oversized transmit packet!\n", ax->dev->name);
357 ax->tx_dropped++; 412 ax->stats.tx_dropped++;
358 ax_unlock(ax); 413 netif_start_queue(dev);
359 return; 414 return;
360 } 415 }
361 416
@@ -376,10 +431,11 @@ static void ax_encaps(struct ax_disp *ax, unsigned char *icp, int len)
376 break; 431 break;
377 } 432 }
378 433
379 ax->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); 434 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
380 actual = ax->tty->driver->write(ax->tty, ax->xbuff, count); 435 actual = ax->tty->driver->write(ax->tty, ax->xbuff, count);
381 ax->tx_packets++; 436 ax->stats.tx_packets++;
382 ax->tx_bytes+=actual; 437 ax->stats.tx_bytes += actual;
438
383 ax->dev->trans_start = jiffies; 439 ax->dev->trans_start = jiffies;
384 ax->xleft = count - actual; 440 ax->xleft = count - actual;
385 ax->xhead = ax->xbuff + actual; 441 ax->xhead = ax->xbuff + actual;
@@ -387,37 +443,10 @@ static void ax_encaps(struct ax_disp *ax, unsigned char *icp, int len)
387 spin_unlock_bh(&ax->buflock); 443 spin_unlock_bh(&ax->buflock);
388} 444}
389 445
390/*
391 * Called by the driver when there's room for more data. If we have
392 * more packets to send, we send them here.
393 */
394static void ax25_write_wakeup(struct tty_struct *tty)
395{
396 int actual;
397 struct ax_disp *ax = (struct ax_disp *) tty->disc_data;
398
399 /* First make sure we're connected. */
400 if (ax == NULL || ax->magic != AX25_MAGIC || !netif_running(ax->dev))
401 return;
402 if (ax->xleft <= 0) {
403 /* Now serial buffer is almost free & we can start
404 * transmission of another packet
405 */
406 tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
407
408 netif_wake_queue(ax->dev);
409 return;
410 }
411
412 actual = tty->driver->write(tty, ax->xhead, ax->xleft);
413 ax->xleft -= actual;
414 ax->xhead += actual;
415}
416
417/* Encapsulate an AX.25 packet and kick it into a TTY queue. */ 446/* Encapsulate an AX.25 packet and kick it into a TTY queue. */
418static int ax_xmit(struct sk_buff *skb, struct net_device *dev) 447static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
419{ 448{
420 struct ax_disp *ax = netdev_priv(dev); 449 struct mkiss *ax = netdev_priv(dev);
421 450
422 if (!netif_running(dev)) { 451 if (!netif_running(dev)) {
423 printk(KERN_ERR "mkiss: %s: xmit call when iface is down\n", dev->name); 452 printk(KERN_ERR "mkiss: %s: xmit call when iface is down\n", dev->name);
@@ -429,7 +458,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
429 * May be we must check transmitter timeout here ? 458 * May be we must check transmitter timeout here ?
430 * 14 Oct 1994 Dmitry Gorodchanin. 459 * 14 Oct 1994 Dmitry Gorodchanin.
431 */ 460 */
432 if (jiffies - dev->trans_start < 20 * HZ) { 461 if (time_before(jiffies, dev->trans_start + 20 * HZ)) {
433 /* 20 sec timeout not reached */ 462 /* 20 sec timeout not reached */
434 return 1; 463 return 1;
435 } 464 }
@@ -439,20 +468,30 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
439 "bad line quality" : "driver error"); 468 "bad line quality" : "driver error");
440 469
441 ax->xleft = 0; 470 ax->xleft = 0;
442 ax->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); 471 clear_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
443 ax_unlock(ax); 472 netif_start_queue(dev);
444 } 473 }
445 474
446 /* We were not busy, so we are now... :-) */ 475 /* We were not busy, so we are now... :-) */
447 if (skb != NULL) { 476 if (skb != NULL) {
448 ax_lock(ax); 477 netif_stop_queue(dev);
449 ax_encaps(ax, skb->data, skb->len); 478 ax_encaps(dev, skb->data, skb->len);
450 kfree_skb(skb); 479 kfree_skb(skb);
451 } 480 }
452 481
453 return 0; 482 return 0;
454} 483}
455 484
485static int ax_open_dev(struct net_device *dev)
486{
487 struct mkiss *ax = netdev_priv(dev);
488
489 if (ax->tty == NULL)
490 return -ENODEV;
491
492 return 0;
493}
494
456#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 495#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
457 496
458/* Return the frame type ID */ 497/* Return the frame type ID */
@@ -481,7 +520,7 @@ static int ax_rebuild_header(struct sk_buff *skb)
481/* Open the low-level part of the AX25 channel. Easy! */ 520/* Open the low-level part of the AX25 channel. Easy! */
482static int ax_open(struct net_device *dev) 521static int ax_open(struct net_device *dev)
483{ 522{
484 struct ax_disp *ax = netdev_priv(dev); 523 struct mkiss *ax = netdev_priv(dev);
485 unsigned long len; 524 unsigned long len;
486 525
487 if (ax->tty == NULL) 526 if (ax->tty == NULL)
@@ -518,7 +557,6 @@ static int ax_open(struct net_device *dev)
518 557
519 spin_lock_init(&ax->buflock); 558 spin_lock_init(&ax->buflock);
520 559
521 netif_start_queue(dev);
522 return 0; 560 return 0;
523 561
524noxbuff: 562noxbuff:
@@ -532,68 +570,100 @@ norbuff:
532/* Close the low-level part of the AX25 channel. Easy! */ 570/* Close the low-level part of the AX25 channel. Easy! */
533static int ax_close(struct net_device *dev) 571static int ax_close(struct net_device *dev)
534{ 572{
535 struct ax_disp *ax = netdev_priv(dev); 573 struct mkiss *ax = netdev_priv(dev);
536 574
537 if (ax->tty == NULL) 575 if (ax->tty)
538 return -EBUSY; 576 clear_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
539
540 ax->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
541 577
542 netif_stop_queue(dev); 578 netif_stop_queue(dev);
543 579
544 return 0; 580 return 0;
545} 581}
546 582
547static int ax25_receive_room(struct tty_struct *tty) 583static struct net_device_stats *ax_get_stats(struct net_device *dev)
548{ 584{
549 return 65536; /* We can handle an infinite amount of data. :-) */ 585 struct mkiss *ax = netdev_priv(dev);
586
587 return &ax->stats;
588}
589
590static void ax_setup(struct net_device *dev)
591{
592 static char ax25_bcast[AX25_ADDR_LEN] =
593 {'Q'<<1,'S'<<1,'T'<<1,' '<<1,' '<<1,' '<<1,'0'<<1};
594 static char ax25_test[AX25_ADDR_LEN] =
595 {'L'<<1,'I'<<1,'N'<<1,'U'<<1,'X'<<1,' '<<1,'1'<<1};
596
597 /* Finish setting up the DEVICE info. */
598 dev->mtu = AX_MTU;
599 dev->hard_start_xmit = ax_xmit;
600 dev->open = ax_open_dev;
601 dev->stop = ax_close;
602 dev->get_stats = ax_get_stats;
603 dev->set_mac_address = ax_set_mac_address;
604 dev->hard_header_len = 0;
605 dev->addr_len = 0;
606 dev->type = ARPHRD_AX25;
607 dev->tx_queue_len = 10;
608 dev->hard_header = ax_header;
609 dev->rebuild_header = ax_rebuild_header;
610
611 memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
612 memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);
613
614 dev->flags = IFF_BROADCAST | IFF_MULTICAST;
550} 615}
551 616
552/* 617/*
553 * Handle the 'receiver data ready' interrupt. 618 * We have a potential race on dereferencing tty->disc_data, because the tty
554 * This function is called by the 'tty_io' module in the kernel when 619 * layer provides no locking at all - thus one cpu could be running
555 * a block of data has been received, which can now be decapsulated 620 * sixpack_receive_buf while another calls sixpack_close, which zeroes
556 * and sent on to the AX.25 layer for further processing. 621 * tty->disc_data and frees the memory that sixpack_receive_buf is using. The
622 * best way to fix this is to use a rwlock in the tty struct, but for now we
623 * use a single global rwlock for all ttys in ppp line discipline.
557 */ 624 */
558static void ax25_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 625static rwlock_t disc_data_lock = RW_LOCK_UNLOCKED;
626
627static struct mkiss *mkiss_get(struct tty_struct *tty)
559{ 628{
560 struct ax_disp *ax = (struct ax_disp *) tty->disc_data; 629 struct mkiss *ax;
561 630
562 if (ax == NULL || ax->magic != AX25_MAGIC || !netif_running(ax->dev)) 631 read_lock(&disc_data_lock);
563 return; 632 ax = tty->disc_data;
633 if (ax)
634 atomic_inc(&ax->refcnt);
635 read_unlock(&disc_data_lock);
564 636
565 /* 637 return ax;
566 * Argh! mtu change time! - costs us the packet part received 638}
567 * at the change
568 */
569 if (ax->mtu != ax->dev->mtu + 73)
570 ax_changedmtu(ax);
571
572 /* Read the characters out of the buffer */
573 while (count--) {
574 if (fp != NULL && *fp++) {
575 if (!test_and_set_bit(AXF_ERROR, &ax->flags))
576 ax->rx_errors++;
577 cp++;
578 continue;
579 }
580 639
581 kiss_unesc(ax, *cp++); 640static void mkiss_put(struct mkiss *ax)
582 } 641{
642 if (atomic_dec_and_test(&ax->refcnt))
643 up(&ax->dead_sem);
583} 644}
584 645
585static int ax25_open(struct tty_struct *tty) 646static int mkiss_open(struct tty_struct *tty)
586{ 647{
587 struct ax_disp *ax = (struct ax_disp *) tty->disc_data; 648 struct net_device *dev;
649 struct mkiss *ax;
588 int err; 650 int err;
589 651
590 /* First make sure we're not already connected. */ 652 if (!capable(CAP_NET_ADMIN))
591 if (ax && ax->magic == AX25_MAGIC) 653 return -EPERM;
592 return -EEXIST;
593 654
594 /* OK. Find a free AX25 channel to use. */ 655 dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup);
595 if ((ax = ax_alloc()) == NULL) 656 if (!dev) {
596 return -ENFILE; 657 err = -ENOMEM;
658 goto out;
659 }
660
661 ax = netdev_priv(dev);
662 ax->dev = dev;
663
664 spin_lock_init(&ax->buflock);
665 atomic_set(&ax->refcnt, 1);
666 init_MUTEX_LOCKED(&ax->dead_sem);
597 667
598 ax->tty = tty; 668 ax->tty = tty;
599 tty->disc_data = ax; 669 tty->disc_data = ax;
@@ -602,283 +672,212 @@ static int ax25_open(struct tty_struct *tty)
602 tty->driver->flush_buffer(tty); 672 tty->driver->flush_buffer(tty);
603 673
604 /* Restore default settings */ 674 /* Restore default settings */
605 ax->dev->type = ARPHRD_AX25; 675 dev->type = ARPHRD_AX25;
606 676
607 /* Perform the low-level AX25 initialization. */ 677 /* Perform the low-level AX25 initialization. */
608 if ((err = ax_open(ax->dev))) 678 if ((err = ax_open(ax->dev))) {
609 return err; 679 goto out_free_netdev;
680 }
610 681
611 /* Done. We have linked the TTY line to a channel. */ 682 if (register_netdev(dev))
612 return ax->dev->base_addr; 683 goto out_free_buffers;
613}
614 684
615static void ax25_close(struct tty_struct *tty) 685 netif_start_queue(dev);
616{
617 struct ax_disp *ax = (struct ax_disp *) tty->disc_data;
618 686
619 /* First make sure we're connected. */ 687 /* Done. We have linked the TTY line to a channel. */
620 if (ax == NULL || ax->magic != AX25_MAGIC) 688 return 0;
621 return;
622 689
623 unregister_netdev(ax->dev); 690out_free_buffers:
691 kfree(ax->rbuff);
692 kfree(ax->xbuff);
624 693
625 tty->disc_data = NULL; 694out_free_netdev:
626 ax->tty = NULL; 695 free_netdev(dev);
627 696
628 ax_free(ax); 697out:
698 return err;
629} 699}
630 700
631 701static void mkiss_close(struct tty_struct *tty)
632static struct net_device_stats *ax_get_stats(struct net_device *dev)
633{ 702{
634 static struct net_device_stats stats; 703 struct mkiss *ax;
635 struct ax_disp *ax = netdev_priv(dev);
636
637 memset(&stats, 0, sizeof(struct net_device_stats));
638
639 stats.rx_packets = ax->rx_packets;
640 stats.tx_packets = ax->tx_packets;
641 stats.rx_bytes = ax->rx_bytes;
642 stats.tx_bytes = ax->tx_bytes;
643 stats.rx_dropped = ax->rx_dropped;
644 stats.tx_dropped = ax->tx_dropped;
645 stats.tx_errors = ax->tx_errors;
646 stats.rx_errors = ax->rx_errors;
647 stats.rx_over_errors = ax->rx_over_errors;
648
649 return &stats;
650}
651 704
705 write_lock(&disc_data_lock);
706 ax = tty->disc_data;
707 tty->disc_data = NULL;
708 write_unlock(&disc_data_lock);
652 709
653/************************************************************************ 710 if (ax == 0)
654 * STANDARD ENCAPSULATION * 711 return;
655 ************************************************************************/
656
657static int kiss_esc(unsigned char *s, unsigned char *d, int len)
658{
659 unsigned char *ptr = d;
660 unsigned char c;
661 712
662 /* 713 /*
663 * Send an initial END character to flush out any 714 * We have now ensured that nobody can start using ap from now on, but
664 * data that may have accumulated in the receiver 715 * we have to wait for all existing users to finish.
665 * due to line noise.
666 */ 716 */
717 if (!atomic_dec_and_test(&ax->refcnt))
718 down(&ax->dead_sem);
667 719
668 *ptr++ = END; 720 unregister_netdev(ax->dev);
669
670 while (len-- > 0) {
671 switch (c = *s++) {
672 case END:
673 *ptr++ = ESC;
674 *ptr++ = ESC_END;
675 break;
676 case ESC:
677 *ptr++ = ESC;
678 *ptr++ = ESC_ESC;
679 break;
680 default:
681 *ptr++ = c;
682 break;
683 }
684 }
685 721
686 *ptr++ = END; 722 /* Free all AX25 frame buffers. */
723 kfree(ax->rbuff);
724 kfree(ax->xbuff);
687 725
688 return ptr - d; 726 ax->tty = NULL;
689} 727}
690 728
691/* 729/* Perform I/O control on an active ax25 channel. */
692 * MW: 730static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
693 * OK its ugly, but tell me a better solution without copying the 731 unsigned int cmd, unsigned long arg)
694 * packet to a temporary buffer :-)
695 */
696static int kiss_esc_crc(unsigned char *s, unsigned char *d, unsigned short crc, int len)
697{ 732{
698 unsigned char *ptr = d; 733 struct mkiss *ax = mkiss_get(tty);
699 unsigned char c=0; 734 struct net_device *dev = ax->dev;
700 735 unsigned int tmp, err;
701 *ptr++ = END;
702 while (len > 0) {
703 if (len > 2)
704 c = *s++;
705 else if (len > 1)
706 c = crc >> 8;
707 else if (len > 0)
708 c = crc & 0xff;
709 736
710 len--; 737 /* First make sure we're connected. */
738 if (ax == NULL)
739 return -ENXIO;
711 740
712 switch (c) { 741 switch (cmd) {
713 case END: 742 case SIOCGIFNAME:
714 *ptr++ = ESC; 743 err = copy_to_user((void __user *) arg, ax->dev->name,
715 *ptr++ = ESC_END; 744 strlen(ax->dev->name) + 1) ? -EFAULT : 0;
716 break; 745 break;
717 case ESC: 746
718 *ptr++ = ESC; 747 case SIOCGIFENCAP:
719 *ptr++ = ESC_ESC; 748 err = put_user(4, (int __user *) arg);
720 break; 749 break;
721 default: 750
722 *ptr++ = c; 751 case SIOCSIFENCAP:
723 break; 752 if (get_user(tmp, (int __user *) arg)) {
753 err = -EFAULT;
754 break;
724 } 755 }
725 }
726 *ptr++ = END;
727 return ptr - d;
728}
729 756
730static void kiss_unesc(struct ax_disp *ax, unsigned char s) 757 ax->mode = tmp;
731{ 758 dev->addr_len = AX25_ADDR_LEN;
732 switch (s) { 759 dev->hard_header_len = AX25_KISS_HEADER_LEN +
733 case END: 760 AX25_MAX_HEADER_LEN + 3;
734 /* drop keeptest bit = VSV */ 761 dev->type = ARPHRD_AX25;
735 if (test_bit(AXF_KEEPTEST, &ax->flags))
736 clear_bit(AXF_KEEPTEST, &ax->flags);
737 762
738 if (!test_and_clear_bit(AXF_ERROR, &ax->flags) && (ax->rcount > 2)) 763 err = 0;
739 ax_bump(ax); 764 break;
740 765
741 clear_bit(AXF_ESCAPE, &ax->flags); 766 case SIOCSIFHWADDR: {
742 ax->rcount = 0; 767 char addr[AX25_ADDR_LEN];
743 return; 768printk(KERN_INFO "In SIOCSIFHWADDR");
744 769
745 case ESC: 770 if (copy_from_user(&addr,
746 set_bit(AXF_ESCAPE, &ax->flags); 771 (void __user *) arg, AX25_ADDR_LEN)) {
747 return; 772 err = -EFAULT;
748 case ESC_ESC:
749 if (test_and_clear_bit(AXF_ESCAPE, &ax->flags))
750 s = ESC;
751 break; 773 break;
752 case ESC_END:
753 if (test_and_clear_bit(AXF_ESCAPE, &ax->flags))
754 s = END;
755 break;
756 }
757
758 spin_lock_bh(&ax->buflock);
759 if (!test_bit(AXF_ERROR, &ax->flags)) {
760 if (ax->rcount < ax->buffsize) {
761 ax->rbuff[ax->rcount++] = s;
762 spin_unlock_bh(&ax->buflock);
763 return;
764 } 774 }
765 775
766 ax->rx_over_errors++; 776 spin_lock_irq(&dev->xmit_lock);
767 set_bit(AXF_ERROR, &ax->flags); 777 memcpy(dev->dev_addr, addr, AX25_ADDR_LEN);
778 spin_unlock_irq(&dev->xmit_lock);
779
780 err = 0;
781 break;
782 }
783 default:
784 err = -ENOIOCTLCMD;
768 } 785 }
769 spin_unlock_bh(&ax->buflock);
770}
771 786
787 mkiss_put(ax);
772 788
773static int ax_set_mac_address(struct net_device *dev, void __user *addr) 789 return err;
774{
775 if (copy_from_user(dev->dev_addr, addr, AX25_ADDR_LEN))
776 return -EFAULT;
777 return 0;
778} 790}
779 791
780static int ax_set_dev_mac_address(struct net_device *dev, void *addr) 792/*
793 * Handle the 'receiver data ready' interrupt.
794 * This function is called by the 'tty_io' module in the kernel when
795 * a block of data has been received, which can now be decapsulated
796 * and sent on to the AX.25 layer for further processing.
797 */
798static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
799 char *fp, int count)
781{ 800{
782 struct sockaddr *sa = addr; 801 struct mkiss *ax = mkiss_get(tty);
783
784 memcpy(dev->dev_addr, sa->sa_data, AX25_ADDR_LEN);
785 802
786 return 0; 803 if (!ax)
787} 804 return;
788
789
790/* Perform I/O control on an active ax25 channel. */
791static int ax25_disp_ioctl(struct tty_struct *tty, void *file, int cmd, void __user *arg)
792{
793 struct ax_disp *ax = (struct ax_disp *) tty->disc_data;
794 unsigned int tmp;
795 805
796 /* First make sure we're connected. */ 806 /*
797 if (ax == NULL || ax->magic != AX25_MAGIC) 807 * Argh! mtu change time! - costs us the packet part received
798 return -EINVAL; 808 * at the change
809 */
810 if (ax->mtu != ax->dev->mtu + 73)
811 ax_changedmtu(ax);
799 812
800 switch (cmd) { 813 /* Read the characters out of the buffer */
801 case SIOCGIFNAME: 814 while (count--) {
802 if (copy_to_user(arg, ax->dev->name, strlen(ax->dev->name) + 1)) 815 if (fp != NULL && *fp++) {
803 return -EFAULT; 816 if (!test_and_set_bit(AXF_ERROR, &ax->flags))
804 return 0; 817 ax->stats.rx_errors++;
805 818 cp++;
806 case SIOCGIFENCAP: 819 continue;
807 return put_user(4, (int __user *)arg); 820 }
808
809 case SIOCSIFENCAP:
810 if (get_user(tmp, (int __user *)arg))
811 return -EFAULT;
812 ax->mode = tmp;
813 ax->dev->addr_len = AX25_ADDR_LEN; /* sizeof an AX.25 addr */
814 ax->dev->hard_header_len = AX25_KISS_HEADER_LEN + AX25_MAX_HEADER_LEN + 3;
815 ax->dev->type = ARPHRD_AX25;
816 return 0;
817
818 case SIOCSIFHWADDR:
819 return ax_set_mac_address(ax->dev, arg);
820 821
821 default: 822 kiss_unesc(ax, *cp++);
822 return -ENOIOCTLCMD;
823 } 823 }
824
825 mkiss_put(ax);
826 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
827 && tty->driver->unthrottle)
828 tty->driver->unthrottle(tty);
824} 829}
825 830
826static int ax_open_dev(struct net_device *dev) 831static int mkiss_receive_room(struct tty_struct *tty)
827{ 832{
828 struct ax_disp *ax = netdev_priv(dev); 833 return 65536; /* We can handle an infinite amount of data. :-) */
829
830 if (ax->tty == NULL)
831 return -ENODEV;
832
833 return 0;
834} 834}
835 835
836 836/*
837/* Initialize the driver. Called by network startup. */ 837 * Called by the driver when there's room for more data. If we have
838static int ax25_init(struct net_device *dev) 838 * more packets to send, we send them here.
839 */
840static void mkiss_write_wakeup(struct tty_struct *tty)
839{ 841{
840 struct ax_disp *ax = netdev_priv(dev); 842 struct mkiss *ax = mkiss_get(tty);
841 843 int actual;
842 static char ax25_bcast[AX25_ADDR_LEN] =
843 {'Q'<<1,'S'<<1,'T'<<1,' '<<1,' '<<1,' '<<1,'0'<<1};
844 static char ax25_test[AX25_ADDR_LEN] =
845 {'L'<<1,'I'<<1,'N'<<1,'U'<<1,'X'<<1,' '<<1,'1'<<1};
846
847 if (ax == NULL) /* Allocation failed ?? */
848 return -ENODEV;
849 844
850 /* Set up the "AX25 Control Block". (And clear statistics) */ 845 if (!ax)
851 memset(ax, 0, sizeof (struct ax_disp)); 846 return;
852 ax->magic = AX25_MAGIC;
853 ax->dev = dev;
854 847
855 /* Finish setting up the DEVICE info. */ 848 if (ax->xleft <= 0) {
856 dev->mtu = AX_MTU; 849 /* Now serial buffer is almost free & we can start
857 dev->hard_start_xmit = ax_xmit; 850 * transmission of another packet
858 dev->open = ax_open_dev; 851 */
859 dev->stop = ax_close; 852 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
860 dev->get_stats = ax_get_stats;
861 dev->set_mac_address = ax_set_dev_mac_address;
862 dev->hard_header_len = 0;
863 dev->addr_len = 0;
864 dev->type = ARPHRD_AX25;
865 dev->tx_queue_len = 10;
866 dev->hard_header = ax_header;
867 dev->rebuild_header = ax_rebuild_header;
868 853
869 memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN); 854 netif_wake_queue(ax->dev);
870 memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN); 855 goto out;
856 }
871 857
872 /* New-style flags. */ 858 actual = tty->driver->write(tty, ax->xhead, ax->xleft);
873 dev->flags = IFF_BROADCAST | IFF_MULTICAST; 859 ax->xleft -= actual;
860 ax->xhead += actual;
874 861
875 return 0; 862out:
863 mkiss_put(ax);
876} 864}
877 865
866static struct tty_ldisc ax_ldisc = {
867 .magic = TTY_LDISC_MAGIC,
868 .name = "mkiss",
869 .open = mkiss_open,
870 .close = mkiss_close,
871 .ioctl = mkiss_ioctl,
872 .receive_buf = mkiss_receive_buf,
873 .receive_room = mkiss_receive_room,
874 .write_wakeup = mkiss_write_wakeup
875};
878 876
879/* ******************************************************************** */ 877static char banner[] __initdata = KERN_INFO \
880/* * Init MKISS driver * */ 878 "mkiss: AX.25 Multikiss, Hans Albas PE1AYX\n";
881/* ******************************************************************** */ 879static char msg_regfail[] __initdata = KERN_ERR \
880 "mkiss: can't register line discipline (err = %d)\n";
882 881
883static int __init mkiss_init_driver(void) 882static int __init mkiss_init_driver(void)
884{ 883{
@@ -886,64 +885,27 @@ static int __init mkiss_init_driver(void)
886 885
887 printk(banner); 886 printk(banner);
888 887
889 if (ax25_maxdev < 4) 888 if ((status = tty_register_ldisc(N_AX25, &ax_ldisc)) != 0)
890 ax25_maxdev = 4; /* Sanity */ 889 printk(msg_regfail);
891 890
892 if ((ax25_ctrls = kmalloc(sizeof(void *) * ax25_maxdev, GFP_KERNEL)) == NULL) {
893 printk(KERN_ERR "mkiss: Can't allocate ax25_ctrls[] array!\n");
894 return -ENOMEM;
895 }
896
897 /* Clear the pointer array, we allocate devices when we need them */
898 memset(ax25_ctrls, 0, sizeof(void*) * ax25_maxdev); /* Pointers */
899
900 /* Fill in our line protocol discipline, and register it */
901 ax_ldisc.magic = TTY_LDISC_MAGIC;
902 ax_ldisc.name = "mkiss";
903 ax_ldisc.open = ax25_open;
904 ax_ldisc.close = ax25_close;
905 ax_ldisc.ioctl = (int (*)(struct tty_struct *, struct file *,
906 unsigned int, unsigned long))ax25_disp_ioctl;
907 ax_ldisc.receive_buf = ax25_receive_buf;
908 ax_ldisc.receive_room = ax25_receive_room;
909 ax_ldisc.write_wakeup = ax25_write_wakeup;
910
911 if ((status = tty_register_ldisc(N_AX25, &ax_ldisc)) != 0) {
912 printk(KERN_ERR "mkiss: can't register line discipline (err = %d)\n", status);
913 kfree(ax25_ctrls);
914 }
915 return status; 891 return status;
916} 892}
917 893
894static const char msg_unregfail[] __exitdata = KERN_ERR \
895 "mkiss: can't unregister line discipline (err = %d)\n";
896
918static void __exit mkiss_exit_driver(void) 897static void __exit mkiss_exit_driver(void)
919{ 898{
920 int i; 899 int ret;
921
922 for (i = 0; i < ax25_maxdev; i++) {
923 if (ax25_ctrls[i]) {
924 /*
925 * VSV = if dev->start==0, then device
926 * unregistered while close proc.
927 */
928 if (netif_running(&ax25_ctrls[i]->dev))
929 unregister_netdev(&ax25_ctrls[i]->dev);
930 kfree(ax25_ctrls[i]);
931 }
932 }
933 900
934 kfree(ax25_ctrls); 901 if ((ret = tty_unregister_ldisc(N_AX25)))
935 ax25_ctrls = NULL; 902 printk(msg_unregfail, ret);
936
937 if ((i = tty_register_ldisc(N_AX25, NULL)))
938 printk(KERN_ERR "mkiss: can't unregister line discipline (err = %d)\n", i);
939} 903}
940 904
941MODULE_AUTHOR("Hans Albas PE1AYX <hans@esrac.ele.tue.nl>"); 905MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>");
942MODULE_DESCRIPTION("KISS driver for AX.25 over TTYs"); 906MODULE_DESCRIPTION("KISS driver for AX.25 over TTYs");
943MODULE_PARM(ax25_maxdev, "i");
944MODULE_PARM_DESC(ax25_maxdev, "number of MKISS devices");
945MODULE_LICENSE("GPL"); 907MODULE_LICENSE("GPL");
946MODULE_ALIAS_LDISC(N_AX25); 908MODULE_ALIAS_LDISC(N_AX25);
909
947module_init(mkiss_init_driver); 910module_init(mkiss_init_driver);
948module_exit(mkiss_exit_driver); 911module_exit(mkiss_exit_driver);
949
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index ece1b1a13186..c27e417f32bf 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -304,7 +304,7 @@ static inline void scc_discard_buffers(struct scc_channel *scc)
304 scc->tx_buff = NULL; 304 scc->tx_buff = NULL;
305 } 305 }
306 306
307 while (skb_queue_len(&scc->tx_queue)) 307 while (!skb_queue_empty(&scc->tx_queue))
308 dev_kfree_skb(skb_dequeue(&scc->tx_queue)); 308 dev_kfree_skb(skb_dequeue(&scc->tx_queue));
309 309
310 spin_unlock_irqrestore(&scc->lock, flags); 310 spin_unlock_irqrestore(&scc->lock, flags);
@@ -1126,8 +1126,7 @@ static void t_dwait(unsigned long channel)
1126 1126
1127 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */ 1127 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */
1128 { 1128 {
1129 if (skb_queue_len(&scc->tx_queue) == 0) /* nothing to send */ 1129 if (skb_queue_empty(&scc->tx_queue)) { /* nothing to send */
1130 {
1131 scc->stat.tx_state = TXS_IDLE; 1130 scc->stat.tx_state = TXS_IDLE;
1132 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */ 1131 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */
1133 return; 1132 return;
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index 4834314b676d..0abf5dd08b4c 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -159,12 +159,7 @@ struct net_device * __init hp_plus_probe(int unit)
159 err = do_hpp_probe(dev); 159 err = do_hpp_probe(dev);
160 if (err) 160 if (err)
161 goto out; 161 goto out;
162 err = register_netdev(dev);
163 if (err)
164 goto out1;
165 return dev; 162 return dev;
166out1:
167 cleanup_card(dev);
168out: 163out:
169 free_netdev(dev); 164 free_netdev(dev);
170 return ERR_PTR(err); 165 return ERR_PTR(err);
@@ -271,6 +266,9 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
271 /* Leave the 8390 and HP chip reset. */ 266 /* Leave the 8390 and HP chip reset. */
272 outw(inw(ioaddr + HPP_OPTION) & ~EnableIRQ, ioaddr + HPP_OPTION); 267 outw(inw(ioaddr + HPP_OPTION) & ~EnableIRQ, ioaddr + HPP_OPTION);
273 268
269 retval = register_netdev(dev);
270 if (retval)
271 goto out;
274 return 0; 272 return 0;
275out: 273out:
276 release_region(ioaddr, HP_IO_EXTENT); 274 release_region(ioaddr, HP_IO_EXTENT);
@@ -463,11 +461,8 @@ init_module(void)
463 dev->irq = irq[this_dev]; 461 dev->irq = irq[this_dev];
464 dev->base_addr = io[this_dev]; 462 dev->base_addr = io[this_dev];
465 if (do_hpp_probe(dev) == 0) { 463 if (do_hpp_probe(dev) == 0) {
466 if (register_netdev(dev) == 0) { 464 dev_hpp[found++] = dev;
467 dev_hpp[found++] = dev; 465 continue;
468 continue;
469 }
470 cleanup_card(dev);
471 } 466 }
472 free_netdev(dev); 467 free_netdev(dev);
473 printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]); 468 printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/hp.c b/drivers/net/hp.c
index 026888611d6f..59cf841b14ab 100644
--- a/drivers/net/hp.c
+++ b/drivers/net/hp.c
@@ -123,12 +123,7 @@ struct net_device * __init hp_probe(int unit)
123 err = do_hp_probe(dev); 123 err = do_hp_probe(dev);
124 if (err) 124 if (err)
125 goto out; 125 goto out;
126 err = register_netdev(dev);
127 if (err)
128 goto out1;
129 return dev; 126 return dev;
130out1:
131 cleanup_card(dev);
132out: 127out:
133 free_netdev(dev); 128 free_netdev(dev);
134 return ERR_PTR(err); 129 return ERR_PTR(err);
@@ -227,7 +222,12 @@ static int __init hp_probe1(struct net_device *dev, int ioaddr)
227 ei_status.block_output = &hp_block_output; 222 ei_status.block_output = &hp_block_output;
228 hp_init_card(dev); 223 hp_init_card(dev);
229 224
225 retval = register_netdev(dev);
226 if (retval)
227 goto out1;
230 return 0; 228 return 0;
229out1:
230 free_irq(dev->irq, dev);
231out: 231out:
232 release_region(ioaddr, HP_IO_EXTENT); 232 release_region(ioaddr, HP_IO_EXTENT);
233 return retval; 233 return retval;
@@ -432,11 +432,8 @@ init_module(void)
432 dev->irq = irq[this_dev]; 432 dev->irq = irq[this_dev];
433 dev->base_addr = io[this_dev]; 433 dev->base_addr = io[this_dev];
434 if (do_hp_probe(dev) == 0) { 434 if (do_hp_probe(dev) == 0) {
435 if (register_netdev(dev) == 0) { 435 dev_hp[found++] = dev;
436 dev_hp[found++] = dev; 436 continue;
437 continue;
438 }
439 cleanup_card(dev);
440 } 437 }
441 free_netdev(dev); 438 free_netdev(dev);
442 printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]); 439 printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index b3a898c5a585..cf0ac6fda1a1 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -106,6 +106,7 @@
106#include <linux/interrupt.h> 106#include <linux/interrupt.h>
107#include <linux/eisa.h> 107#include <linux/eisa.h>
108#include <linux/pci.h> 108#include <linux/pci.h>
109#include <linux/dma-mapping.h>
109#include <linux/spinlock.h> 110#include <linux/spinlock.h>
110#include <linux/netdevice.h> 111#include <linux/netdevice.h>
111#include <linux/etherdevice.h> 112#include <linux/etherdevice.h>
@@ -417,12 +418,7 @@ struct net_device * __init hp100_probe(int unit)
417 if (err) 418 if (err)
418 goto out; 419 goto out;
419 420
420 err = register_netdev(dev);
421 if (err)
422 goto out1;
423 return dev; 421 return dev;
424 out1:
425 release_region(dev->base_addr, HP100_REGION_SIZE);
426 out: 422 out:
427 free_netdev(dev); 423 free_netdev(dev);
428 return ERR_PTR(err); 424 return ERR_PTR(err);
@@ -562,7 +558,7 @@ static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
562 * Also, we can have EISA Busmaster cards (not tested), 558 * Also, we can have EISA Busmaster cards (not tested),
563 * so beware !!! - Jean II */ 559 * so beware !!! - Jean II */
564 if((bus == HP100_BUS_PCI) && 560 if((bus == HP100_BUS_PCI) &&
565 (pci_set_dma_mask(pci_dev, 0xffffffff))) { 561 (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK))) {
566 /* Gracefully fallback to shared memory */ 562 /* Gracefully fallback to shared memory */
567 goto busmasterfail; 563 goto busmasterfail;
568 } 564 }
@@ -776,11 +772,22 @@ static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
776 printk("Warning! Link down.\n"); 772 printk("Warning! Link down.\n");
777 } 773 }
778 774
775 err = register_netdev(dev);
776 if (err)
777 goto out3;
778
779 return 0; 779 return 0;
780out3:
781 if (local_mode == 1)
782 pci_free_consistent(lp->pci_dev, MAX_RINGSIZE + 0x0f,
783 lp->page_vaddr_algn,
784 virt_to_whatever(dev, lp->page_vaddr_algn));
785 if (mem_ptr_virt)
786 iounmap(mem_ptr_virt);
780out2: 787out2:
781 release_region(ioaddr, HP100_REGION_SIZE); 788 release_region(ioaddr, HP100_REGION_SIZE);
782out1: 789out1:
783 return -ENODEV; 790 return err;
784} 791}
785 792
786/* This procedure puts the card into a stable init state */ 793/* This procedure puts the card into a stable init state */
@@ -2875,18 +2882,12 @@ static int __init hp100_eisa_probe (struct device *gendev)
2875 if (err) 2882 if (err)
2876 goto out1; 2883 goto out1;
2877 2884
2878 err = register_netdev(dev);
2879 if (err)
2880 goto out2;
2881
2882#ifdef HP100_DEBUG 2885#ifdef HP100_DEBUG
2883 printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name, 2886 printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name,
2884 dev->base_addr); 2887 dev->base_addr);
2885#endif 2888#endif
2886 gendev->driver_data = dev; 2889 gendev->driver_data = dev;
2887 return 0; 2890 return 0;
2888 out2:
2889 release_region(dev->base_addr, HP100_REGION_SIZE);
2890 out1: 2891 out1:
2891 free_netdev(dev); 2892 free_netdev(dev);
2892 return err; 2893 return err;
@@ -2951,17 +2952,12 @@ static int __devinit hp100_pci_probe (struct pci_dev *pdev,
2951 err = hp100_probe1(dev, ioaddr, HP100_BUS_PCI, pdev); 2952 err = hp100_probe1(dev, ioaddr, HP100_BUS_PCI, pdev);
2952 if (err) 2953 if (err)
2953 goto out1; 2954 goto out1;
2954 err = register_netdev(dev);
2955 if (err)
2956 goto out2;
2957 2955
2958#ifdef HP100_DEBUG 2956#ifdef HP100_DEBUG
2959 printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr); 2957 printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr);
2960#endif 2958#endif
2961 pci_set_drvdata(pdev, dev); 2959 pci_set_drvdata(pdev, dev);
2962 return 0; 2960 return 0;
2963 out2:
2964 release_region(dev->base_addr, HP100_REGION_SIZE);
2965 out1: 2961 out1:
2966 free_netdev(dev); 2962 free_netdev(dev);
2967 out0: 2963 out0:
@@ -3032,15 +3028,9 @@ static int __init hp100_isa_init(void)
3032 SET_MODULE_OWNER(dev); 3028 SET_MODULE_OWNER(dev);
3033 3029
3034 err = hp100_isa_probe(dev, hp100_port[i]); 3030 err = hp100_isa_probe(dev, hp100_port[i]);
3035 if (!err) { 3031 if (!err)
3036 err = register_netdev(dev); 3032 hp100_devlist[cards++] = dev;
3037 if (!err) 3033 else
3038 hp100_devlist[cards++] = dev;
3039 else
3040 release_region(dev->base_addr, HP100_REGION_SIZE);
3041 }
3042
3043 if (err)
3044 free_netdev(dev); 3034 free_netdev(dev);
3045 } 3035 }
3046 3036
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index 6482d994d489..0de3bb906174 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -1253,7 +1253,7 @@ static int emac_init_tah(struct ocp_enet_private *fep)
1253 TAH_MR_CVR | TAH_MR_ST_768 | TAH_MR_TFS_10KB | TAH_MR_DTFP | 1253 TAH_MR_CVR | TAH_MR_ST_768 | TAH_MR_TFS_10KB | TAH_MR_DTFP |
1254 TAH_MR_DIG); 1254 TAH_MR_DIG);
1255 1255
1256 iounmap(&tahp); 1256 iounmap(tahp);
1257 1257
1258 return 0; 1258 return 0;
1259} 1259}
@@ -1712,11 +1712,10 @@ struct mal_commac_ops emac_commac_ops = {
1712}; 1712};
1713 1713
1714#ifdef CONFIG_NET_POLL_CONTROLLER 1714#ifdef CONFIG_NET_POLL_CONTROLLER
1715static int emac_netpoll(struct net_device *ndev) 1715static void emac_netpoll(struct net_device *ndev)
1716{ 1716{
1717 emac_rxeob_dev((void *)ndev, 0); 1717 emac_rxeob_dev((void *)ndev, 0);
1718 emac_txeob_dev((void *)ndev, 0); 1718 emac_txeob_dev((void *)ndev, 0);
1719 return 0;
1720} 1719}
1721#endif 1720#endif
1722 1721
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index d520b5920d6c..49e5467bdd73 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -499,7 +499,7 @@ static int ioc3_mdio_read(struct net_device *dev, int phy, int reg)
499 ioc3_w_micr((phy << MICR_PHYADDR_SHIFT) | reg | MICR_READTRIG); 499 ioc3_w_micr((phy << MICR_PHYADDR_SHIFT) | reg | MICR_READTRIG);
500 while (ioc3_r_micr() & MICR_BUSY); 500 while (ioc3_r_micr() & MICR_BUSY);
501 501
502 return ioc3_r_micr() & MIDR_DATA_MASK; 502 return ioc3_r_midr_r() & MIDR_DATA_MASK;
503} 503}
504 504
505static void ioc3_mdio_write(struct net_device *dev, int phy, int reg, int data) 505static void ioc3_mdio_write(struct net_device *dev, int phy, int reg, int data)
@@ -1291,7 +1291,6 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1291 dev->features = NETIF_F_IP_CSUM; 1291 dev->features = NETIF_F_IP_CSUM;
1292#endif 1292#endif
1293 1293
1294 ioc3_setup_duplex(ip);
1295 sw_physid1 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID1); 1294 sw_physid1 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID1);
1296 sw_physid2 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID2); 1295 sw_physid2 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID2);
1297 1296
@@ -1300,6 +1299,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1300 goto out_stop; 1299 goto out_stop;
1301 1300
1302 mii_check_media(&ip->mii, 1, 1); 1301 mii_check_media(&ip->mii, 1, 1);
1302 ioc3_setup_duplex(ip);
1303 1303
1304 vendor = (sw_physid1 << 12) | (sw_physid2 >> 4); 1304 vendor = (sw_physid1 << 12) | (sw_physid2 >> 4);
1305 model = (sw_physid2 >> 4) & 0x3f; 1305 model = (sw_physid2 >> 4) & 0x3f;
@@ -1524,7 +1524,7 @@ static void ioc3_get_drvinfo (struct net_device *dev,
1524 struct ethtool_drvinfo *info) 1524 struct ethtool_drvinfo *info)
1525{ 1525{
1526 struct ioc3_private *ip = netdev_priv(dev); 1526 struct ioc3_private *ip = netdev_priv(dev);
1527 1527
1528 strcpy (info->driver, IOC3_NAME); 1528 strcpy (info->driver, IOC3_NAME);
1529 strcpy (info->version, IOC3_VERSION); 1529 strcpy (info->version, IOC3_VERSION);
1530 strcpy (info->bus_info, pci_name(ip->pdev)); 1530 strcpy (info->bus_info, pci_name(ip->pdev));
@@ -1550,7 +1550,7 @@ static int ioc3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1550 spin_lock_irq(&ip->ioc3_lock); 1550 spin_lock_irq(&ip->ioc3_lock);
1551 rc = mii_ethtool_sset(&ip->mii, cmd); 1551 rc = mii_ethtool_sset(&ip->mii, cmd);
1552 spin_unlock_irq(&ip->ioc3_lock); 1552 spin_unlock_irq(&ip->ioc3_lock);
1553 1553
1554 return rc; 1554 return rc;
1555} 1555}
1556 1556
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 7d23aa375908..b8d112348ba4 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -626,7 +626,7 @@ static void __exit irtty_sir_cleanup(void)
626{ 626{
627 int err; 627 int err;
628 628
629 if ((err = tty_register_ldisc(N_IRDA, NULL))) { 629 if ((err = tty_unregister_ldisc(N_IRDA))) {
630 IRDA_ERROR("%s(), can't unregister line discipline (err = %d)\n", 630 IRDA_ERROR("%s(), can't unregister line discipline (err = %d)\n",
631 __FUNCTION__, err); 631 __FUNCTION__, err);
632 } 632 }
diff --git a/drivers/net/irda/sir_kthread.c b/drivers/net/irda/sir_kthread.c
index 18cea1099530..c65054364bca 100644
--- a/drivers/net/irda/sir_kthread.c
+++ b/drivers/net/irda/sir_kthread.c
@@ -135,8 +135,7 @@ static int irda_thread(void *startup)
135 remove_wait_queue(&irda_rq_queue.kick, &wait); 135 remove_wait_queue(&irda_rq_queue.kick, &wait);
136 136
137 /* make swsusp happy with our thread */ 137 /* make swsusp happy with our thread */
138 if (current->flags & PF_FREEZE) 138 try_to_freeze();
139 refrigerator(PF_FREEZE);
140 139
141 run_irda_queue(); 140 run_irda_queue();
142 } 141 }
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 66f488c13717..15f207323d97 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -763,7 +763,7 @@ static int stir_transmit_thread(void *arg)
763 { 763 {
764#ifdef CONFIG_PM 764#ifdef CONFIG_PM
765 /* if suspending, then power off and wait */ 765 /* if suspending, then power off and wait */
766 if (unlikely(current->flags & PF_FREEZE)) { 766 if (unlikely(freezing(current))) {
767 if (stir->receiving) 767 if (stir->receiving)
768 receive_stop(stir); 768 receive_stop(stir);
769 else 769 else
@@ -771,7 +771,7 @@ static int stir_transmit_thread(void *arg)
771 771
772 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD); 772 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD);
773 773
774 refrigerator(PF_FREEZE); 774 refrigerator();
775 775
776 if (change_speed(stir, stir->speed)) 776 if (change_speed(stir, stir->speed))
777 break; 777 break;
diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c
index 50bebb55e9ee..88ae8a04fabc 100644
--- a/drivers/net/isa-skeleton.c
+++ b/drivers/net/isa-skeleton.c
@@ -176,12 +176,7 @@ struct net_device * __init netcard_probe(int unit)
176 err = do_netcard_probe(dev); 176 err = do_netcard_probe(dev);
177 if (err) 177 if (err)
178 goto out; 178 goto out;
179 err = register_netdev(dev);
180 if (err)
181 goto out1;
182 return dev; 179 return dev;
183out1:
184 cleanup_card(dev);
185out: 180out:
186 free_netdev(dev); 181 free_netdev(dev);
187 return ERR_PTR(err); 182 return ERR_PTR(err);
@@ -316,7 +311,15 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr)
316 311
317 dev->tx_timeout = &net_tx_timeout; 312 dev->tx_timeout = &net_tx_timeout;
318 dev->watchdog_timeo = MY_TX_TIMEOUT; 313 dev->watchdog_timeo = MY_TX_TIMEOUT;
314
315 err = register_netdev(dev);
316 if (err)
317 goto out2;
319 return 0; 318 return 0;
319out2:
320#ifdef jumpered_dma
321 free_dma(dev->dma);
322#endif
320out1: 323out1:
321#ifdef jumpered_interrupts 324#ifdef jumpered_interrupts
322 free_irq(dev->irq, dev); 325 free_irq(dev->irq, dev);
@@ -691,11 +694,8 @@ int init_module(void)
691 dev->dma = dma; 694 dev->dma = dma;
692 dev->mem_start = mem; 695 dev->mem_start = mem;
693 if (do_netcard_probe(dev) == 0) { 696 if (do_netcard_probe(dev) == 0) {
694 if (register_netdev(dev) == 0) 697 this_device = dev;
695 this_device = dev; 698 return 0;
696 return 0;
697 }
698 cleanup_card(dev);
699 } 699 }
700 free_netdev(dev); 700 free_netdev(dev);
701 return -ENXIO; 701 return -ENXIO;
diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
index f8d3385c7842..c83271b38621 100644
--- a/drivers/net/ixgb/ixgb.h
+++ b/drivers/net/ixgb/ixgb.h
@@ -119,7 +119,7 @@ struct ixgb_adapter;
119 * so a DMA handle can be stored along with the buffer */ 119 * so a DMA handle can be stored along with the buffer */
120struct ixgb_buffer { 120struct ixgb_buffer {
121 struct sk_buff *skb; 121 struct sk_buff *skb;
122 uint64_t dma; 122 dma_addr_t dma;
123 unsigned long time_stamp; 123 unsigned long time_stamp;
124 uint16_t length; 124 uint16_t length;
125 uint16_t next_to_watch; 125 uint16_t next_to_watch;
diff --git a/drivers/net/ixgb/ixgb_ee.c b/drivers/net/ixgb/ixgb_ee.c
index 3aae110c5560..661a46b95a61 100644
--- a/drivers/net/ixgb/ixgb_ee.c
+++ b/drivers/net/ixgb/ixgb_ee.c
@@ -565,24 +565,6 @@ ixgb_get_ee_mac_addr(struct ixgb_hw *hw,
565 } 565 }
566} 566}
567 567
568/******************************************************************************
569 * return the compatibility flags from EEPROM
570 *
571 * hw - Struct containing variables accessed by shared code
572 *
573 * Returns:
574 * compatibility flags if EEPROM contents are valid, 0 otherwise
575 ******************************************************************************/
576uint16_t
577ixgb_get_ee_compatibility(struct ixgb_hw *hw)
578{
579 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
580
581 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
582 return (le16_to_cpu(ee_map->compatibility));
583
584 return(0);
585}
586 568
587/****************************************************************************** 569/******************************************************************************
588 * return the Printed Board Assembly number from EEPROM 570 * return the Printed Board Assembly number from EEPROM
@@ -602,81 +584,6 @@ ixgb_get_ee_pba_number(struct ixgb_hw *hw)
602 return(0); 584 return(0);
603} 585}
604 586
605/******************************************************************************
606 * return the Initialization Control Word 1 from EEPROM
607 *
608 * hw - Struct containing variables accessed by shared code
609 *
610 * Returns:
611 * Initialization Control Word 1 if EEPROM contents are valid, 0 otherwise
612 ******************************************************************************/
613uint16_t
614ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw *hw)
615{
616 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
617
618 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
619 return (le16_to_cpu(ee_map->init_ctrl_reg_1));
620
621 return(0);
622}
623
624/******************************************************************************
625 * return the Initialization Control Word 2 from EEPROM
626 *
627 * hw - Struct containing variables accessed by shared code
628 *
629 * Returns:
630 * Initialization Control Word 2 if EEPROM contents are valid, 0 otherwise
631 ******************************************************************************/
632uint16_t
633ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw *hw)
634{
635 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
636
637 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
638 return (le16_to_cpu(ee_map->init_ctrl_reg_2));
639
640 return(0);
641}
642
643/******************************************************************************
644 * return the Subsystem Id from EEPROM
645 *
646 * hw - Struct containing variables accessed by shared code
647 *
648 * Returns:
649 * Subsystem Id if EEPROM contents are valid, 0 otherwise
650 ******************************************************************************/
651uint16_t
652ixgb_get_ee_subsystem_id(struct ixgb_hw *hw)
653{
654 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
655
656 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
657 return (le16_to_cpu(ee_map->subsystem_id));
658
659 return(0);
660}
661
662/******************************************************************************
663 * return the Sub Vendor Id from EEPROM
664 *
665 * hw - Struct containing variables accessed by shared code
666 *
667 * Returns:
668 * Sub Vendor Id if EEPROM contents are valid, 0 otherwise
669 ******************************************************************************/
670uint16_t
671ixgb_get_ee_subvendor_id(struct ixgb_hw *hw)
672{
673 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
674
675 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
676 return (le16_to_cpu(ee_map->subvendor_id));
677
678 return(0);
679}
680 587
681/****************************************************************************** 588/******************************************************************************
682 * return the Device Id from EEPROM 589 * return the Device Id from EEPROM
@@ -694,81 +601,6 @@ ixgb_get_ee_device_id(struct ixgb_hw *hw)
694 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 601 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
695 return (le16_to_cpu(ee_map->device_id)); 602 return (le16_to_cpu(ee_map->device_id));
696 603
697 return(0); 604 return (0);
698}
699
700/******************************************************************************
701 * return the Vendor Id from EEPROM
702 *
703 * hw - Struct containing variables accessed by shared code
704 *
705 * Returns:
706 * Device Id if EEPROM contents are valid, 0 otherwise
707 ******************************************************************************/
708uint16_t
709ixgb_get_ee_vendor_id(struct ixgb_hw *hw)
710{
711 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
712
713 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
714 return (le16_to_cpu(ee_map->vendor_id));
715
716 return(0);
717}
718
719/******************************************************************************
720 * return the Software Defined Pins Register from EEPROM
721 *
722 * hw - Struct containing variables accessed by shared code
723 *
724 * Returns:
725 * SDP Register if EEPROM contents are valid, 0 otherwise
726 ******************************************************************************/
727uint16_t
728ixgb_get_ee_swdpins_reg(struct ixgb_hw *hw)
729{
730 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
731
732 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
733 return (le16_to_cpu(ee_map->swdpins_reg));
734
735 return(0);
736} 605}
737 606
738/******************************************************************************
739 * return the D3 Power Management Bits from EEPROM
740 *
741 * hw - Struct containing variables accessed by shared code
742 *
743 * Returns:
744 * D3 Power Management Bits if EEPROM contents are valid, 0 otherwise
745 ******************************************************************************/
746uint8_t
747ixgb_get_ee_d3_power(struct ixgb_hw *hw)
748{
749 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
750
751 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
752 return (le16_to_cpu(ee_map->d3_power));
753
754 return(0);
755}
756
757/******************************************************************************
758 * return the D0 Power Management Bits from EEPROM
759 *
760 * hw - Struct containing variables accessed by shared code
761 *
762 * Returns:
763 * D0 Power Management Bits if EEPROM contents are valid, 0 otherwise
764 ******************************************************************************/
765uint8_t
766ixgb_get_ee_d0_power(struct ixgb_hw *hw)
767{
768 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
769
770 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
771 return (le16_to_cpu(ee_map->d0_power));
772
773 return(0);
774}
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index 3fa113854eeb..9d026ed77ddd 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -98,10 +98,10 @@ static struct ixgb_stats ixgb_gstrings_stats[] = {
98static int 98static int
99ixgb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 99ixgb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
100{ 100{
101 struct ixgb_adapter *adapter = netdev->priv; 101 struct ixgb_adapter *adapter = netdev_priv(netdev);
102 102
103 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); 103 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
104 ecmd->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); 104 ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
105 ecmd->port = PORT_FIBRE; 105 ecmd->port = PORT_FIBRE;
106 ecmd->transceiver = XCVR_EXTERNAL; 106 ecmd->transceiver = XCVR_EXTERNAL;
107 107
@@ -120,7 +120,7 @@ ixgb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
120static int 120static int
121ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 121ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
122{ 122{
123 struct ixgb_adapter *adapter = netdev->priv; 123 struct ixgb_adapter *adapter = netdev_priv(netdev);
124 124
125 if(ecmd->autoneg == AUTONEG_ENABLE || 125 if(ecmd->autoneg == AUTONEG_ENABLE ||
126 ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL) 126 ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
@@ -130,6 +130,12 @@ ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
130 ixgb_down(adapter, TRUE); 130 ixgb_down(adapter, TRUE);
131 ixgb_reset(adapter); 131 ixgb_reset(adapter);
132 ixgb_up(adapter); 132 ixgb_up(adapter);
133 /* be optimistic about our link, since we were up before */
134 adapter->link_speed = 10000;
135 adapter->link_duplex = FULL_DUPLEX;
136 netif_carrier_on(netdev);
137 netif_wake_queue(netdev);
138
133 } else 139 } else
134 ixgb_reset(adapter); 140 ixgb_reset(adapter);
135 141
@@ -140,7 +146,7 @@ static void
140ixgb_get_pauseparam(struct net_device *netdev, 146ixgb_get_pauseparam(struct net_device *netdev,
141 struct ethtool_pauseparam *pause) 147 struct ethtool_pauseparam *pause)
142{ 148{
143 struct ixgb_adapter *adapter = netdev->priv; 149 struct ixgb_adapter *adapter = netdev_priv(netdev);
144 struct ixgb_hw *hw = &adapter->hw; 150 struct ixgb_hw *hw = &adapter->hw;
145 151
146 pause->autoneg = AUTONEG_DISABLE; 152 pause->autoneg = AUTONEG_DISABLE;
@@ -159,7 +165,7 @@ static int
159ixgb_set_pauseparam(struct net_device *netdev, 165ixgb_set_pauseparam(struct net_device *netdev,
160 struct ethtool_pauseparam *pause) 166 struct ethtool_pauseparam *pause)
161{ 167{
162 struct ixgb_adapter *adapter = netdev->priv; 168 struct ixgb_adapter *adapter = netdev_priv(netdev);
163 struct ixgb_hw *hw = &adapter->hw; 169 struct ixgb_hw *hw = &adapter->hw;
164 170
165 if(pause->autoneg == AUTONEG_ENABLE) 171 if(pause->autoneg == AUTONEG_ENABLE)
@@ -177,6 +183,11 @@ ixgb_set_pauseparam(struct net_device *netdev,
177 if(netif_running(adapter->netdev)) { 183 if(netif_running(adapter->netdev)) {
178 ixgb_down(adapter, TRUE); 184 ixgb_down(adapter, TRUE);
179 ixgb_up(adapter); 185 ixgb_up(adapter);
186 /* be optimistic about our link, since we were up before */
187 adapter->link_speed = 10000;
188 adapter->link_duplex = FULL_DUPLEX;
189 netif_carrier_on(netdev);
190 netif_wake_queue(netdev);
180 } else 191 } else
181 ixgb_reset(adapter); 192 ixgb_reset(adapter);
182 193
@@ -186,19 +197,26 @@ ixgb_set_pauseparam(struct net_device *netdev,
186static uint32_t 197static uint32_t
187ixgb_get_rx_csum(struct net_device *netdev) 198ixgb_get_rx_csum(struct net_device *netdev)
188{ 199{
189 struct ixgb_adapter *adapter = netdev->priv; 200 struct ixgb_adapter *adapter = netdev_priv(netdev);
201
190 return adapter->rx_csum; 202 return adapter->rx_csum;
191} 203}
192 204
193static int 205static int
194ixgb_set_rx_csum(struct net_device *netdev, uint32_t data) 206ixgb_set_rx_csum(struct net_device *netdev, uint32_t data)
195{ 207{
196 struct ixgb_adapter *adapter = netdev->priv; 208 struct ixgb_adapter *adapter = netdev_priv(netdev);
209
197 adapter->rx_csum = data; 210 adapter->rx_csum = data;
198 211
199 if(netif_running(netdev)) { 212 if(netif_running(netdev)) {
200 ixgb_down(adapter,TRUE); 213 ixgb_down(adapter,TRUE);
201 ixgb_up(adapter); 214 ixgb_up(adapter);
215 /* be optimistic about our link, since we were up before */
216 adapter->link_speed = 10000;
217 adapter->link_duplex = FULL_DUPLEX;
218 netif_carrier_on(netdev);
219 netif_wake_queue(netdev);
202 } else 220 } else
203 ixgb_reset(adapter); 221 ixgb_reset(adapter);
204 return 0; 222 return 0;
@@ -246,14 +264,15 @@ static void
246ixgb_get_regs(struct net_device *netdev, 264ixgb_get_regs(struct net_device *netdev,
247 struct ethtool_regs *regs, void *p) 265 struct ethtool_regs *regs, void *p)
248{ 266{
249 struct ixgb_adapter *adapter = netdev->priv; 267 struct ixgb_adapter *adapter = netdev_priv(netdev);
250 struct ixgb_hw *hw = &adapter->hw; 268 struct ixgb_hw *hw = &adapter->hw;
251 uint32_t *reg = p; 269 uint32_t *reg = p;
252 uint32_t *reg_start = reg; 270 uint32_t *reg_start = reg;
253 uint8_t i; 271 uint8_t i;
254 272
255 /* the 1 (one) below indicates an attempt at versioning, if the 273 /* the 1 (one) below indicates an attempt at versioning, if the
256 * interface in ethtool or the driver this 1 should be incremented */ 274 * interface in ethtool or the driver changes, this 1 should be
275 * incremented */
257 regs->version = (1<<24) | hw->revision_id << 16 | hw->device_id; 276 regs->version = (1<<24) | hw->revision_id << 16 | hw->device_id;
258 277
259 /* General Registers */ 278 /* General Registers */
@@ -283,7 +302,8 @@ ixgb_get_regs(struct net_device *netdev,
283 *reg++ = IXGB_READ_REG(hw, RAIDC); /* 19 */ 302 *reg++ = IXGB_READ_REG(hw, RAIDC); /* 19 */
284 *reg++ = IXGB_READ_REG(hw, RXCSUM); /* 20 */ 303 *reg++ = IXGB_READ_REG(hw, RXCSUM); /* 20 */
285 304
286 for (i = 0; i < IXGB_RAR_ENTRIES; i++) { 305 /* there are 16 RAR entries in hardware, we only use 3 */
306 for(i = 0; i < 16; i++) {
287 *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */ 307 *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */
288 *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */ 308 *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */
289 } 309 }
@@ -391,7 +411,7 @@ static int
391ixgb_get_eeprom(struct net_device *netdev, 411ixgb_get_eeprom(struct net_device *netdev,
392 struct ethtool_eeprom *eeprom, uint8_t *bytes) 412 struct ethtool_eeprom *eeprom, uint8_t *bytes)
393{ 413{
394 struct ixgb_adapter *adapter = netdev->priv; 414 struct ixgb_adapter *adapter = netdev_priv(netdev);
395 struct ixgb_hw *hw = &adapter->hw; 415 struct ixgb_hw *hw = &adapter->hw;
396 uint16_t *eeprom_buff; 416 uint16_t *eeprom_buff;
397 int i, max_len, first_word, last_word; 417 int i, max_len, first_word, last_word;
@@ -439,7 +459,7 @@ static int
439ixgb_set_eeprom(struct net_device *netdev, 459ixgb_set_eeprom(struct net_device *netdev,
440 struct ethtool_eeprom *eeprom, uint8_t *bytes) 460 struct ethtool_eeprom *eeprom, uint8_t *bytes)
441{ 461{
442 struct ixgb_adapter *adapter = netdev->priv; 462 struct ixgb_adapter *adapter = netdev_priv(netdev);
443 struct ixgb_hw *hw = &adapter->hw; 463 struct ixgb_hw *hw = &adapter->hw;
444 uint16_t *eeprom_buff; 464 uint16_t *eeprom_buff;
445 void *ptr; 465 void *ptr;
@@ -497,7 +517,7 @@ static void
497ixgb_get_drvinfo(struct net_device *netdev, 517ixgb_get_drvinfo(struct net_device *netdev,
498 struct ethtool_drvinfo *drvinfo) 518 struct ethtool_drvinfo *drvinfo)
499{ 519{
500 struct ixgb_adapter *adapter = netdev->priv; 520 struct ixgb_adapter *adapter = netdev_priv(netdev);
501 521
502 strncpy(drvinfo->driver, ixgb_driver_name, 32); 522 strncpy(drvinfo->driver, ixgb_driver_name, 32);
503 strncpy(drvinfo->version, ixgb_driver_version, 32); 523 strncpy(drvinfo->version, ixgb_driver_version, 32);
@@ -512,7 +532,7 @@ static void
512ixgb_get_ringparam(struct net_device *netdev, 532ixgb_get_ringparam(struct net_device *netdev,
513 struct ethtool_ringparam *ring) 533 struct ethtool_ringparam *ring)
514{ 534{
515 struct ixgb_adapter *adapter = netdev->priv; 535 struct ixgb_adapter *adapter = netdev_priv(netdev);
516 struct ixgb_desc_ring *txdr = &adapter->tx_ring; 536 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
517 struct ixgb_desc_ring *rxdr = &adapter->rx_ring; 537 struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
518 538
@@ -530,7 +550,7 @@ static int
530ixgb_set_ringparam(struct net_device *netdev, 550ixgb_set_ringparam(struct net_device *netdev,
531 struct ethtool_ringparam *ring) 551 struct ethtool_ringparam *ring)
532{ 552{
533 struct ixgb_adapter *adapter = netdev->priv; 553 struct ixgb_adapter *adapter = netdev_priv(netdev);
534 struct ixgb_desc_ring *txdr = &adapter->tx_ring; 554 struct ixgb_desc_ring *txdr = &adapter->tx_ring;
535 struct ixgb_desc_ring *rxdr = &adapter->rx_ring; 555 struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
536 struct ixgb_desc_ring tx_old, tx_new, rx_old, rx_new; 556 struct ixgb_desc_ring tx_old, tx_new, rx_old, rx_new;
@@ -573,6 +593,11 @@ ixgb_set_ringparam(struct net_device *netdev,
573 adapter->tx_ring = tx_new; 593 adapter->tx_ring = tx_new;
574 if((err = ixgb_up(adapter))) 594 if((err = ixgb_up(adapter)))
575 return err; 595 return err;
596 /* be optimistic about our link, since we were up before */
597 adapter->link_speed = 10000;
598 adapter->link_duplex = FULL_DUPLEX;
599 netif_carrier_on(netdev);
600 netif_wake_queue(netdev);
576 } 601 }
577 602
578 return 0; 603 return 0;
@@ -607,7 +632,7 @@ ixgb_led_blink_callback(unsigned long data)
607static int 632static int
608ixgb_phys_id(struct net_device *netdev, uint32_t data) 633ixgb_phys_id(struct net_device *netdev, uint32_t data)
609{ 634{
610 struct ixgb_adapter *adapter = netdev->priv; 635 struct ixgb_adapter *adapter = netdev_priv(netdev);
611 636
612 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ)) 637 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ))
613 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ); 638 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ);
@@ -643,7 +668,7 @@ static void
643ixgb_get_ethtool_stats(struct net_device *netdev, 668ixgb_get_ethtool_stats(struct net_device *netdev,
644 struct ethtool_stats *stats, uint64_t *data) 669 struct ethtool_stats *stats, uint64_t *data)
645{ 670{
646 struct ixgb_adapter *adapter = netdev->priv; 671 struct ixgb_adapter *adapter = netdev_priv(netdev);
647 int i; 672 int i;
648 673
649 ixgb_update_stats(adapter); 674 ixgb_update_stats(adapter);
diff --git a/drivers/net/ixgb/ixgb_hw.h b/drivers/net/ixgb/ixgb_hw.h
index 97898efe7cc8..8bcf31ed10c2 100644
--- a/drivers/net/ixgb/ixgb_hw.h
+++ b/drivers/net/ixgb/ixgb_hw.h
@@ -822,17 +822,8 @@ extern void ixgb_clear_vfta(struct ixgb_hw *hw);
822 822
823/* Access functions to eeprom data */ 823/* Access functions to eeprom data */
824void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, uint8_t *mac_addr); 824void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, uint8_t *mac_addr);
825uint16_t ixgb_get_ee_compatibility(struct ixgb_hw *hw);
826uint32_t ixgb_get_ee_pba_number(struct ixgb_hw *hw); 825uint32_t ixgb_get_ee_pba_number(struct ixgb_hw *hw);
827uint16_t ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw *hw);
828uint16_t ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw *hw);
829uint16_t ixgb_get_ee_subsystem_id(struct ixgb_hw *hw);
830uint16_t ixgb_get_ee_subvendor_id(struct ixgb_hw *hw);
831uint16_t ixgb_get_ee_device_id(struct ixgb_hw *hw); 826uint16_t ixgb_get_ee_device_id(struct ixgb_hw *hw);
832uint16_t ixgb_get_ee_vendor_id(struct ixgb_hw *hw);
833uint16_t ixgb_get_ee_swdpins_reg(struct ixgb_hw *hw);
834uint8_t ixgb_get_ee_d3_power(struct ixgb_hw *hw);
835uint8_t ixgb_get_ee_d0_power(struct ixgb_hw *hw);
836boolean_t ixgb_get_eeprom_data(struct ixgb_hw *hw); 827boolean_t ixgb_get_eeprom_data(struct ixgb_hw *hw);
837uint16_t ixgb_get_eeprom_word(struct ixgb_hw *hw, uint16_t index); 828uint16_t ixgb_get_eeprom_word(struct ixgb_hw *hw, uint16_t index);
838 829
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 35f6a7c271a2..5c555373adbe 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -29,6 +29,11 @@
29#include "ixgb.h" 29#include "ixgb.h"
30 30
31/* Change Log 31/* Change Log
32 * 1.0.96 04/19/05
33 * - Make needlessly global code static -- bunk@stusta.de
34 * - ethtool cleanup -- shemminger@osdl.org
35 * - Support for MODULE_VERSION -- linville@tuxdriver.com
36 * - add skb_header_cloned check to the tso path -- herbert@apana.org.au
32 * 1.0.88 01/05/05 37 * 1.0.88 01/05/05
33 * - include fix to the condition that determines when to quit NAPI - Robert Olsson 38 * - include fix to the condition that determines when to quit NAPI - Robert Olsson
34 * - use netif_poll_{disable/enable} to synchronize between NAPI and i/f up/down 39 * - use netif_poll_{disable/enable} to synchronize between NAPI and i/f up/down
@@ -47,8 +52,9 @@ char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
47#else 52#else
48#define DRIVERNAPI "-NAPI" 53#define DRIVERNAPI "-NAPI"
49#endif 54#endif
50char ixgb_driver_version[] = "1.0.95-k2"DRIVERNAPI; 55#define DRV_VERSION "1.0.100-k2"DRIVERNAPI
51char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation."; 56char ixgb_driver_version[] = DRV_VERSION;
57static char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
52 58
53/* ixgb_pci_tbl - PCI Device ID Table 59/* ixgb_pci_tbl - PCI Device ID Table
54 * 60 *
@@ -140,12 +146,15 @@ static struct pci_driver ixgb_driver = {
140MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); 146MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
141MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver"); 147MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
142MODULE_LICENSE("GPL"); 148MODULE_LICENSE("GPL");
149MODULE_VERSION(DRV_VERSION);
143 150
144/* some defines for controlling descriptor fetches in h/w */ 151/* some defines for controlling descriptor fetches in h/w */
145#define RXDCTL_PTHRESH_DEFAULT 128 /* chip considers prefech below this */
146#define RXDCTL_HTHRESH_DEFAULT 16 /* chip will only prefetch if tail is
147 pushed this many descriptors from head */
148#define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */ 152#define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */
153#define RXDCTL_PTHRESH_DEFAULT 0 /* chip considers prefech below
154 * this */
155#define RXDCTL_HTHRESH_DEFAULT 0 /* chip will only prefetch if tail
156 * is pushed this many descriptors
157 * from head */
149 158
150/** 159/**
151 * ixgb_init_module - Driver Registration Routine 160 * ixgb_init_module - Driver Registration Routine
@@ -373,7 +382,7 @@ ixgb_probe(struct pci_dev *pdev,
373 SET_NETDEV_DEV(netdev, &pdev->dev); 382 SET_NETDEV_DEV(netdev, &pdev->dev);
374 383
375 pci_set_drvdata(pdev, netdev); 384 pci_set_drvdata(pdev, netdev);
376 adapter = netdev->priv; 385 adapter = netdev_priv(netdev);
377 adapter->netdev = netdev; 386 adapter->netdev = netdev;
378 adapter->pdev = pdev; 387 adapter->pdev = pdev;
379 adapter->hw.back = adapter; 388 adapter->hw.back = adapter;
@@ -509,7 +518,7 @@ static void __devexit
509ixgb_remove(struct pci_dev *pdev) 518ixgb_remove(struct pci_dev *pdev)
510{ 519{
511 struct net_device *netdev = pci_get_drvdata(pdev); 520 struct net_device *netdev = pci_get_drvdata(pdev);
512 struct ixgb_adapter *adapter = netdev->priv; 521 struct ixgb_adapter *adapter = netdev_priv(netdev);
513 522
514 unregister_netdev(netdev); 523 unregister_netdev(netdev);
515 524
@@ -580,7 +589,7 @@ ixgb_sw_init(struct ixgb_adapter *adapter)
580static int 589static int
581ixgb_open(struct net_device *netdev) 590ixgb_open(struct net_device *netdev)
582{ 591{
583 struct ixgb_adapter *adapter = netdev->priv; 592 struct ixgb_adapter *adapter = netdev_priv(netdev);
584 int err; 593 int err;
585 594
586 /* allocate transmit descriptors */ 595 /* allocate transmit descriptors */
@@ -623,7 +632,7 @@ err_setup_tx:
623static int 632static int
624ixgb_close(struct net_device *netdev) 633ixgb_close(struct net_device *netdev)
625{ 634{
626 struct ixgb_adapter *adapter = netdev->priv; 635 struct ixgb_adapter *adapter = netdev_priv(netdev);
627 636
628 ixgb_down(adapter, TRUE); 637 ixgb_down(adapter, TRUE);
629 638
@@ -1014,7 +1023,7 @@ ixgb_clean_rx_ring(struct ixgb_adapter *adapter)
1014static int 1023static int
1015ixgb_set_mac(struct net_device *netdev, void *p) 1024ixgb_set_mac(struct net_device *netdev, void *p)
1016{ 1025{
1017 struct ixgb_adapter *adapter = netdev->priv; 1026 struct ixgb_adapter *adapter = netdev_priv(netdev);
1018 struct sockaddr *addr = p; 1027 struct sockaddr *addr = p;
1019 1028
1020 if(!is_valid_ether_addr(addr->sa_data)) 1029 if(!is_valid_ether_addr(addr->sa_data))
@@ -1040,7 +1049,7 @@ ixgb_set_mac(struct net_device *netdev, void *p)
1040static void 1049static void
1041ixgb_set_multi(struct net_device *netdev) 1050ixgb_set_multi(struct net_device *netdev)
1042{ 1051{
1043 struct ixgb_adapter *adapter = netdev->priv; 1052 struct ixgb_adapter *adapter = netdev_priv(netdev);
1044 struct ixgb_hw *hw = &adapter->hw; 1053 struct ixgb_hw *hw = &adapter->hw;
1045 struct dev_mc_list *mc_ptr; 1054 struct dev_mc_list *mc_ptr;
1046 uint32_t rctl; 1055 uint32_t rctl;
@@ -1368,7 +1377,7 @@ ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,int tx_flags)
1368static int 1377static int
1369ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 1378ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1370{ 1379{
1371 struct ixgb_adapter *adapter = netdev->priv; 1380 struct ixgb_adapter *adapter = netdev_priv(netdev);
1372 unsigned int first; 1381 unsigned int first;
1373 unsigned int tx_flags = 0; 1382 unsigned int tx_flags = 0;
1374 unsigned long flags; 1383 unsigned long flags;
@@ -1422,7 +1431,7 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1422static void 1431static void
1423ixgb_tx_timeout(struct net_device *netdev) 1432ixgb_tx_timeout(struct net_device *netdev)
1424{ 1433{
1425 struct ixgb_adapter *adapter = netdev->priv; 1434 struct ixgb_adapter *adapter = netdev_priv(netdev);
1426 1435
1427 /* Do the reset outside of interrupt context */ 1436 /* Do the reset outside of interrupt context */
1428 schedule_work(&adapter->tx_timeout_task); 1437 schedule_work(&adapter->tx_timeout_task);
@@ -1431,7 +1440,7 @@ ixgb_tx_timeout(struct net_device *netdev)
1431static void 1440static void
1432ixgb_tx_timeout_task(struct net_device *netdev) 1441ixgb_tx_timeout_task(struct net_device *netdev)
1433{ 1442{
1434 struct ixgb_adapter *adapter = netdev->priv; 1443 struct ixgb_adapter *adapter = netdev_priv(netdev);
1435 1444
1436 ixgb_down(adapter, TRUE); 1445 ixgb_down(adapter, TRUE);
1437 ixgb_up(adapter); 1446 ixgb_up(adapter);
@@ -1448,7 +1457,7 @@ ixgb_tx_timeout_task(struct net_device *netdev)
1448static struct net_device_stats * 1457static struct net_device_stats *
1449ixgb_get_stats(struct net_device *netdev) 1458ixgb_get_stats(struct net_device *netdev)
1450{ 1459{
1451 struct ixgb_adapter *adapter = netdev->priv; 1460 struct ixgb_adapter *adapter = netdev_priv(netdev);
1452 1461
1453 return &adapter->net_stats; 1462 return &adapter->net_stats;
1454} 1463}
@@ -1464,7 +1473,7 @@ ixgb_get_stats(struct net_device *netdev)
1464static int 1473static int
1465ixgb_change_mtu(struct net_device *netdev, int new_mtu) 1474ixgb_change_mtu(struct net_device *netdev, int new_mtu)
1466{ 1475{
1467 struct ixgb_adapter *adapter = netdev->priv; 1476 struct ixgb_adapter *adapter = netdev_priv(netdev);
1468 int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH; 1477 int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
1469 int old_max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH; 1478 int old_max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
1470 1479
@@ -1519,7 +1528,8 @@ ixgb_update_stats(struct ixgb_adapter *adapter)
1519 1528
1520 multi |= ((u64)IXGB_READ_REG(&adapter->hw, MPRCH) << 32); 1529 multi |= ((u64)IXGB_READ_REG(&adapter->hw, MPRCH) << 32);
1521 /* fix up multicast stats by removing broadcasts */ 1530 /* fix up multicast stats by removing broadcasts */
1522 multi -= bcast; 1531 if(multi >= bcast)
1532 multi -= bcast;
1523 1533
1524 adapter->stats.mprcl += (multi & 0xFFFFFFFF); 1534 adapter->stats.mprcl += (multi & 0xFFFFFFFF);
1525 adapter->stats.mprch += (multi >> 32); 1535 adapter->stats.mprch += (multi >> 32);
@@ -1638,7 +1648,7 @@ static irqreturn_t
1638ixgb_intr(int irq, void *data, struct pt_regs *regs) 1648ixgb_intr(int irq, void *data, struct pt_regs *regs)
1639{ 1649{
1640 struct net_device *netdev = data; 1650 struct net_device *netdev = data;
1641 struct ixgb_adapter *adapter = netdev->priv; 1651 struct ixgb_adapter *adapter = netdev_priv(netdev);
1642 struct ixgb_hw *hw = &adapter->hw; 1652 struct ixgb_hw *hw = &adapter->hw;
1643 uint32_t icr = IXGB_READ_REG(hw, ICR); 1653 uint32_t icr = IXGB_READ_REG(hw, ICR);
1644#ifndef CONFIG_IXGB_NAPI 1654#ifndef CONFIG_IXGB_NAPI
@@ -1685,7 +1695,7 @@ ixgb_intr(int irq, void *data, struct pt_regs *regs)
1685static int 1695static int
1686ixgb_clean(struct net_device *netdev, int *budget) 1696ixgb_clean(struct net_device *netdev, int *budget)
1687{ 1697{
1688 struct ixgb_adapter *adapter = netdev->priv; 1698 struct ixgb_adapter *adapter = netdev_priv(netdev);
1689 int work_to_do = min(*budget, netdev->quota); 1699 int work_to_do = min(*budget, netdev->quota);
1690 int tx_cleaned; 1700 int tx_cleaned;
1691 int work_done = 0; 1701 int work_done = 0;
@@ -2014,7 +2024,7 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
2014static void 2024static void
2015ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) 2025ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2016{ 2026{
2017 struct ixgb_adapter *adapter = netdev->priv; 2027 struct ixgb_adapter *adapter = netdev_priv(netdev);
2018 uint32_t ctrl, rctl; 2028 uint32_t ctrl, rctl;
2019 2029
2020 ixgb_irq_disable(adapter); 2030 ixgb_irq_disable(adapter);
@@ -2052,7 +2062,7 @@ ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2052static void 2062static void
2053ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid) 2063ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
2054{ 2064{
2055 struct ixgb_adapter *adapter = netdev->priv; 2065 struct ixgb_adapter *adapter = netdev_priv(netdev);
2056 uint32_t vfta, index; 2066 uint32_t vfta, index;
2057 2067
2058 /* add VID to filter table */ 2068 /* add VID to filter table */
@@ -2066,7 +2076,7 @@ ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
2066static void 2076static void
2067ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid) 2077ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
2068{ 2078{
2069 struct ixgb_adapter *adapter = netdev->priv; 2079 struct ixgb_adapter *adapter = netdev_priv(netdev);
2070 uint32_t vfta, index; 2080 uint32_t vfta, index;
2071 2081
2072 ixgb_irq_disable(adapter); 2082 ixgb_irq_disable(adapter);
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index 7fec613e1675..8423cb6875f0 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -1,5 +1,10 @@
1/* 1/*
2 * sonic.c 2 * jazzsonic.c
3 *
4 * (C) 2005 Finn Thain
5 *
6 * Converted to DMA API, and (from the mac68k project) introduced
7 * dhd's support for 16-bit cards.
3 * 8 *
4 * (C) 1996,1998 by Thomas Bogendoerfer (tsbogend@alpha.franken.de) 9 * (C) 1996,1998 by Thomas Bogendoerfer (tsbogend@alpha.franken.de)
5 * 10 *
@@ -28,8 +33,8 @@
28#include <linux/netdevice.h> 33#include <linux/netdevice.h>
29#include <linux/etherdevice.h> 34#include <linux/etherdevice.h>
30#include <linux/skbuff.h> 35#include <linux/skbuff.h>
31#include <linux/bitops.h>
32#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/dma-mapping.h>
33 38
34#include <asm/bootinfo.h> 39#include <asm/bootinfo.h>
35#include <asm/system.h> 40#include <asm/system.h>
@@ -44,22 +49,20 @@ static struct platform_device *jazz_sonic_device;
44 49
45#define SONIC_MEM_SIZE 0x100 50#define SONIC_MEM_SIZE 0x100
46 51
47#define SREGS_PAD(n) u16 n;
48
49#include "sonic.h" 52#include "sonic.h"
50 53
51/* 54/*
52 * Macros to access SONIC registers 55 * Macros to access SONIC registers
53 */ 56 */
54#define SONIC_READ(reg) (*((volatile unsigned int *)base_addr+reg)) 57#define SONIC_READ(reg) (*((volatile unsigned int *)dev->base_addr+reg))
55 58
56#define SONIC_WRITE(reg,val) \ 59#define SONIC_WRITE(reg,val) \
57do { \ 60do { \
58 *((volatile unsigned int *)base_addr+(reg)) = (val); \ 61 *((volatile unsigned int *)dev->base_addr+(reg)) = (val); \
59} while (0) 62} while (0)
60 63
61 64
62/* use 0 for production, 1 for verification, >2 for debug */ 65/* use 0 for production, 1 for verification, >1 for debug */
63#ifdef SONIC_DEBUG 66#ifdef SONIC_DEBUG
64static unsigned int sonic_debug = SONIC_DEBUG; 67static unsigned int sonic_debug = SONIC_DEBUG;
65#else 68#else
@@ -85,18 +88,18 @@ static unsigned short known_revisions[] =
85 0xffff /* end of list */ 88 0xffff /* end of list */
86}; 89};
87 90
88static int __init sonic_probe1(struct net_device *dev, unsigned long base_addr, 91static int __init sonic_probe1(struct net_device *dev)
89 unsigned int irq)
90{ 92{
91 static unsigned version_printed; 93 static unsigned version_printed;
92 unsigned int silicon_revision; 94 unsigned int silicon_revision;
93 unsigned int val; 95 unsigned int val;
94 struct sonic_local *lp; 96 struct sonic_local *lp = netdev_priv(dev);
95 int err = -ENODEV; 97 int err = -ENODEV;
96 int i; 98 int i;
97 99
98 if (!request_mem_region(base_addr, SONIC_MEM_SIZE, jazz_sonic_string)) 100 if (!request_mem_region(dev->base_addr, SONIC_MEM_SIZE, jazz_sonic_string))
99 return -EBUSY; 101 return -EBUSY;
102
100 /* 103 /*
101 * get the Silicon Revision ID. If this is one of the known 104 * get the Silicon Revision ID. If this is one of the known
102 * one assume that we found a SONIC ethernet controller at 105 * one assume that we found a SONIC ethernet controller at
@@ -120,11 +123,7 @@ static int __init sonic_probe1(struct net_device *dev, unsigned long base_addr,
120 if (sonic_debug && version_printed++ == 0) 123 if (sonic_debug && version_printed++ == 0)
121 printk(version); 124 printk(version);
122 125
123 printk("%s: Sonic ethernet found at 0x%08lx, ", dev->name, base_addr); 126 printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ", lp->device->bus_id, dev->base_addr);
124
125 /* Fill in the 'dev' fields. */
126 dev->base_addr = base_addr;
127 dev->irq = irq;
128 127
129 /* 128 /*
130 * Put the sonic into software reset, then 129 * Put the sonic into software reset, then
@@ -138,84 +137,44 @@ static int __init sonic_probe1(struct net_device *dev, unsigned long base_addr,
138 dev->dev_addr[i*2+1] = val >> 8; 137 dev->dev_addr[i*2+1] = val >> 8;
139 } 138 }
140 139
141 printk("HW Address ");
142 for (i = 0; i < 6; i++) {
143 printk("%2.2x", dev->dev_addr[i]);
144 if (i<5)
145 printk(":");
146 }
147
148 printk(" IRQ %d\n", irq);
149
150 err = -ENOMEM; 140 err = -ENOMEM;
151 141
152 /* Initialize the device structure. */ 142 /* Initialize the device structure. */
153 if (dev->priv == NULL) {
154 /*
155 * the memory be located in the same 64kb segment
156 */
157 lp = NULL;
158 i = 0;
159 do {
160 lp = kmalloc(sizeof(*lp), GFP_KERNEL);
161 if ((unsigned long) lp >> 16
162 != ((unsigned long)lp + sizeof(*lp) ) >> 16) {
163 /* FIXME, free the memory later */
164 kfree(lp);
165 lp = NULL;
166 }
167 } while (lp == NULL && i++ < 20);
168
169 if (lp == NULL) {
170 printk("%s: couldn't allocate memory for descriptors\n",
171 dev->name);
172 goto out;
173 }
174 143
175 memset(lp, 0, sizeof(struct sonic_local)); 144 lp->dma_bitmode = SONIC_BITMODE32;
176
177 /* get the virtual dma address */
178 lp->cda_laddr = vdma_alloc(CPHYSADDR(lp),sizeof(*lp));
179 if (lp->cda_laddr == ~0UL) {
180 printk("%s: couldn't get DMA page entry for "
181 "descriptors\n", dev->name);
182 goto out1;
183 }
184
185 lp->tda_laddr = lp->cda_laddr + sizeof (lp->cda);
186 lp->rra_laddr = lp->tda_laddr + sizeof (lp->tda);
187 lp->rda_laddr = lp->rra_laddr + sizeof (lp->rra);
188
189 /* allocate receive buffer area */
190 /* FIXME, maybe we should use skbs */
191 lp->rba = kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_KERNEL);
192 if (!lp->rba) {
193 printk("%s: couldn't allocate receive buffers\n",
194 dev->name);
195 goto out2;
196 }
197 145
198 /* get virtual dma address */ 146 /* Allocate the entire chunk of memory for the descriptors.
199 lp->rba_laddr = vdma_alloc(CPHYSADDR(lp->rba), 147 Note that this cannot cross a 64K boundary. */
200 SONIC_NUM_RRS * SONIC_RBSIZE); 148 if ((lp->descriptors = dma_alloc_coherent(lp->device,
201 if (lp->rba_laddr == ~0UL) { 149 SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
202 printk("%s: couldn't get DMA page entry for receive " 150 &lp->descriptors_laddr, GFP_KERNEL)) == NULL) {
203 "buffers\n",dev->name); 151 printk(KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n", lp->device->bus_id);
204 goto out3; 152 goto out;
205 }
206
207 /* now convert pointer to KSEG1 pointer */
208 lp->rba = (char *)KSEG1ADDR(lp->rba);
209 flush_cache_all();
210 dev->priv = (struct sonic_local *)KSEG1ADDR(lp);
211 } 153 }
212 154
213 lp = (struct sonic_local *)dev->priv; 155 /* Now set up the pointers to point to the appropriate places */
156 lp->cda = lp->descriptors;
157 lp->tda = lp->cda + (SIZEOF_SONIC_CDA
158 * SONIC_BUS_SCALE(lp->dma_bitmode));
159 lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
160 * SONIC_BUS_SCALE(lp->dma_bitmode));
161 lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
162 * SONIC_BUS_SCALE(lp->dma_bitmode));
163
164 lp->cda_laddr = lp->descriptors_laddr;
165 lp->tda_laddr = lp->cda_laddr + (SIZEOF_SONIC_CDA
166 * SONIC_BUS_SCALE(lp->dma_bitmode));
167 lp->rda_laddr = lp->tda_laddr + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
168 * SONIC_BUS_SCALE(lp->dma_bitmode));
169 lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
170 * SONIC_BUS_SCALE(lp->dma_bitmode));
171
214 dev->open = sonic_open; 172 dev->open = sonic_open;
215 dev->stop = sonic_close; 173 dev->stop = sonic_close;
216 dev->hard_start_xmit = sonic_send_packet; 174 dev->hard_start_xmit = sonic_send_packet;
217 dev->get_stats = sonic_get_stats; 175 dev->get_stats = sonic_get_stats;
218 dev->set_multicast_list = &sonic_multicast_list; 176 dev->set_multicast_list = &sonic_multicast_list;
177 dev->tx_timeout = sonic_tx_timeout;
219 dev->watchdog_timeo = TX_TIMEOUT; 178 dev->watchdog_timeo = TX_TIMEOUT;
220 179
221 /* 180 /*
@@ -226,14 +185,8 @@ static int __init sonic_probe1(struct net_device *dev, unsigned long base_addr,
226 SONIC_WRITE(SONIC_MPT,0xffff); 185 SONIC_WRITE(SONIC_MPT,0xffff);
227 186
228 return 0; 187 return 0;
229out3:
230 kfree(lp->rba);
231out2:
232 vdma_free(lp->cda_laddr);
233out1:
234 kfree(lp);
235out: 188out:
236 release_region(base_addr, SONIC_MEM_SIZE); 189 release_region(dev->base_addr, SONIC_MEM_SIZE);
237 return err; 190 return err;
238} 191}
239 192
@@ -245,7 +198,6 @@ static int __init jazz_sonic_probe(struct device *device)
245{ 198{
246 struct net_device *dev; 199 struct net_device *dev;
247 struct sonic_local *lp; 200 struct sonic_local *lp;
248 unsigned long base_addr;
249 int err = 0; 201 int err = 0;
250 int i; 202 int i;
251 203
@@ -255,21 +207,26 @@ static int __init jazz_sonic_probe(struct device *device)
255 if (mips_machgroup != MACH_GROUP_JAZZ) 207 if (mips_machgroup != MACH_GROUP_JAZZ)
256 return -ENODEV; 208 return -ENODEV;
257 209
258 dev = alloc_etherdev(0); 210 dev = alloc_etherdev(sizeof(struct sonic_local));
259 if (!dev) 211 if (!dev)
260 return -ENOMEM; 212 return -ENOMEM;
261 213
214 lp = netdev_priv(dev);
215 lp->device = device;
216 SET_NETDEV_DEV(dev, device);
217 SET_MODULE_OWNER(dev);
218
262 netdev_boot_setup_check(dev); 219 netdev_boot_setup_check(dev);
263 base_addr = dev->base_addr;
264 220
265 if (base_addr >= KSEG0) { /* Check a single specified location. */ 221 if (dev->base_addr >= KSEG0) { /* Check a single specified location. */
266 err = sonic_probe1(dev, base_addr, dev->irq); 222 err = sonic_probe1(dev);
267 } else if (base_addr != 0) { /* Don't probe at all. */ 223 } else if (dev->base_addr != 0) { /* Don't probe at all. */
268 err = -ENXIO; 224 err = -ENXIO;
269 } else { 225 } else {
270 for (i = 0; sonic_portlist[i].port; i++) { 226 for (i = 0; sonic_portlist[i].port; i++) {
271 int io = sonic_portlist[i].port; 227 dev->base_addr = sonic_portlist[i].port;
272 if (sonic_probe1(dev, io, sonic_portlist[i].irq) == 0) 228 dev->irq = sonic_portlist[i].irq;
229 if (sonic_probe1(dev) == 0)
273 break; 230 break;
274 } 231 }
275 if (!sonic_portlist[i].port) 232 if (!sonic_portlist[i].port)
@@ -281,14 +238,17 @@ static int __init jazz_sonic_probe(struct device *device)
281 if (err) 238 if (err)
282 goto out1; 239 goto out1;
283 240
241 printk("%s: MAC ", dev->name);
242 for (i = 0; i < 6; i++) {
243 printk("%2.2x", dev->dev_addr[i]);
244 if (i < 5)
245 printk(":");
246 }
247 printk(" IRQ %d\n", dev->irq);
248
284 return 0; 249 return 0;
285 250
286out1: 251out1:
287 lp = dev->priv;
288 vdma_free(lp->rba_laddr);
289 kfree(lp->rba);
290 vdma_free(lp->cda_laddr);
291 kfree(lp);
292 release_region(dev->base_addr, SONIC_MEM_SIZE); 252 release_region(dev->base_addr, SONIC_MEM_SIZE);
293out: 253out:
294 free_netdev(dev); 254 free_netdev(dev);
@@ -296,21 +256,22 @@ out:
296 return err; 256 return err;
297} 257}
298 258
299/* 259MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
300 * SONIC uses a normal IRQ 260module_param(sonic_debug, int, 0);
301 */ 261MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
302#define sonic_request_irq request_irq
303#define sonic_free_irq free_irq
304 262
305#define sonic_chiptomem(x) KSEG1ADDR(vdma_log2phys(x)) 263#define SONIC_IRQ_FLAG SA_INTERRUPT
306 264
307#include "sonic.c" 265#include "sonic.c"
308 266
309static int __devexit jazz_sonic_device_remove (struct device *device) 267static int __devexit jazz_sonic_device_remove (struct device *device)
310{ 268{
311 struct net_device *dev = device->driver_data; 269 struct net_device *dev = device->driver_data;
270 struct sonic_local* lp = netdev_priv(dev);
312 271
313 unregister_netdev (dev); 272 unregister_netdev (dev);
273 dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
274 lp->descriptors, lp->descriptors_laddr);
314 release_region (dev->base_addr, SONIC_MEM_SIZE); 275 release_region (dev->base_addr, SONIC_MEM_SIZE);
315 free_netdev (dev); 276 free_netdev (dev);
316 277
@@ -323,7 +284,7 @@ static struct device_driver jazz_sonic_driver = {
323 .probe = jazz_sonic_probe, 284 .probe = jazz_sonic_probe,
324 .remove = __devexit_p(jazz_sonic_device_remove), 285 .remove = __devexit_p(jazz_sonic_device_remove),
325}; 286};
326 287
327static void jazz_sonic_platform_release (struct device *device) 288static void jazz_sonic_platform_release (struct device *device)
328{ 289{
329 struct platform_device *pldev; 290 struct platform_device *pldev;
@@ -336,10 +297,11 @@ static void jazz_sonic_platform_release (struct device *device)
336static int __init jazz_sonic_init_module(void) 297static int __init jazz_sonic_init_module(void)
337{ 298{
338 struct platform_device *pldev; 299 struct platform_device *pldev;
300 int err;
339 301
340 if (driver_register(&jazz_sonic_driver)) { 302 if ((err = driver_register(&jazz_sonic_driver))) {
341 printk(KERN_ERR "Driver registration failed\n"); 303 printk(KERN_ERR "Driver registration failed\n");
342 return -ENOMEM; 304 return err;
343 } 305 }
344 306
345 jazz_sonic_device = NULL; 307 jazz_sonic_device = NULL;
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index dec557fb6a99..b4929beb33b2 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -356,11 +356,8 @@ int init_module(void)
356 dev->base_addr = io[this_dev]; 356 dev->base_addr = io[this_dev];
357 dev->dma = dma[this_dev]; 357 dev->dma = dma[this_dev];
358 if (do_lance_probe(dev) == 0) { 358 if (do_lance_probe(dev) == 0) {
359 if (register_netdev(dev) == 0) { 359 dev_lance[found++] = dev;
360 dev_lance[found++] = dev; 360 continue;
361 continue;
362 }
363 cleanup_card(dev);
364 } 361 }
365 free_netdev(dev); 362 free_netdev(dev);
366 break; 363 break;
@@ -448,12 +445,7 @@ struct net_device * __init lance_probe(int unit)
448 err = do_lance_probe(dev); 445 err = do_lance_probe(dev);
449 if (err) 446 if (err)
450 goto out; 447 goto out;
451 err = register_netdev(dev);
452 if (err)
453 goto out1;
454 return dev; 448 return dev;
455out1:
456 cleanup_card(dev);
457out: 449out:
458 free_netdev(dev); 450 free_netdev(dev);
459 return ERR_PTR(err); 451 return ERR_PTR(err);
@@ -724,6 +716,9 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
724 dev->tx_timeout = lance_tx_timeout; 716 dev->tx_timeout = lance_tx_timeout;
725 dev->watchdog_timeo = TX_TIMEOUT; 717 dev->watchdog_timeo = TX_TIMEOUT;
726 718
719 err = register_netdev(dev);
720 if (err)
721 goto out_dma;
727 return 0; 722 return 0;
728out_dma: 723out_dma:
729 if (dev->dma != 4) 724 if (dev->dma != 4)
@@ -867,7 +862,7 @@ lance_init_ring(struct net_device *dev, int gfp)
867 lp->rx_skbuff[i] = skb; 862 lp->rx_skbuff[i] = skb;
868 if (skb) { 863 if (skb) {
869 skb->dev = dev; 864 skb->dev = dev;
870 rx_buff = skb->tail; 865 rx_buff = skb->data;
871 } else 866 } else
872 rx_buff = kmalloc(PKT_BUF_SZ, GFP_DMA | gfp); 867 rx_buff = kmalloc(PKT_BUF_SZ, GFP_DMA | gfp);
873 if (rx_buff == NULL) 868 if (rx_buff == NULL)
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index 5e263fcba669..41bad07ac1ac 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -553,14 +553,14 @@ static inline void init_rx_bufs(struct net_device *dev)
553 if (skb == NULL) 553 if (skb == NULL)
554 panic("%s: alloc_skb() failed", __FILE__); 554 panic("%s: alloc_skb() failed", __FILE__);
555 skb_reserve(skb, 2); 555 skb_reserve(skb, 2);
556 dma_addr = dma_map_single(lp->dev, skb->tail,PKT_BUF_SZ, 556 dma_addr = dma_map_single(lp->dev, skb->data,PKT_BUF_SZ,
557 DMA_FROM_DEVICE); 557 DMA_FROM_DEVICE);
558 skb->dev = dev; 558 skb->dev = dev;
559 rbd->v_next = rbd+1; 559 rbd->v_next = rbd+1;
560 rbd->b_next = WSWAPrbd(virt_to_dma(lp,rbd+1)); 560 rbd->b_next = WSWAPrbd(virt_to_dma(lp,rbd+1));
561 rbd->b_addr = WSWAPrbd(virt_to_dma(lp,rbd)); 561 rbd->b_addr = WSWAPrbd(virt_to_dma(lp,rbd));
562 rbd->skb = skb; 562 rbd->skb = skb;
563 rbd->v_data = skb->tail; 563 rbd->v_data = skb->data;
564 rbd->b_data = WSWAPchar(dma_addr); 564 rbd->b_data = WSWAPchar(dma_addr);
565 rbd->size = PKT_BUF_SZ; 565 rbd->size = PKT_BUF_SZ;
566 } 566 }
@@ -783,8 +783,8 @@ static inline int i596_rx(struct net_device *dev)
783 rx_in_place = 1; 783 rx_in_place = 1;
784 rbd->skb = newskb; 784 rbd->skb = newskb;
785 newskb->dev = dev; 785 newskb->dev = dev;
786 dma_addr = dma_map_single(lp->dev, newskb->tail, PKT_BUF_SZ, DMA_FROM_DEVICE); 786 dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE);
787 rbd->v_data = newskb->tail; 787 rbd->v_data = newskb->data;
788 rbd->b_data = WSWAPchar(dma_addr); 788 rbd->b_data = WSWAPchar(dma_addr);
789 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd)); 789 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd));
790 } 790 }
diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c
index 179a97c0af69..27f0d8ac4c40 100644
--- a/drivers/net/lne390.c
+++ b/drivers/net/lne390.c
@@ -167,12 +167,7 @@ struct net_device * __init lne390_probe(int unit)
167 err = do_lne390_probe(dev); 167 err = do_lne390_probe(dev);
168 if (err) 168 if (err)
169 goto out; 169 goto out;
170 err = register_netdev(dev);
171 if (err)
172 goto out1;
173 return dev; 170 return dev;
174out1:
175 cleanup_card(dev);
176out: 171out:
177 free_netdev(dev); 172 free_netdev(dev);
178 return ERR_PTR(err); 173 return ERR_PTR(err);
@@ -296,7 +291,14 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr)
296 dev->poll_controller = ei_poll; 291 dev->poll_controller = ei_poll;
297#endif 292#endif
298 NS8390_init(dev, 0); 293 NS8390_init(dev, 0);
294
295 ret = register_netdev(dev);
296 if (ret)
297 goto unmap;
299 return 0; 298 return 0;
299unmap:
300 if (ei_status.reg0)
301 iounmap((void *)dev->mem_start);
300cleanup: 302cleanup:
301 free_irq(dev->irq, dev); 303 free_irq(dev->irq, dev);
302 return ret; 304 return ret;
@@ -426,11 +428,8 @@ int init_module(void)
426 dev->base_addr = io[this_dev]; 428 dev->base_addr = io[this_dev];
427 dev->mem_start = mem[this_dev]; 429 dev->mem_start = mem[this_dev];
428 if (do_lne390_probe(dev) == 0) { 430 if (do_lne390_probe(dev) == 0) {
429 if (register_netdev(dev) == 0) { 431 dev_lne[found++] = dev;
430 dev_lne[found++] = dev; 432 continue;
431 continue;
432 }
433 cleanup_card(dev);
434 } 433 }
435 free_netdev(dev); 434 free_netdev(dev);
436 printk(KERN_WARNING "lne390.c: No LNE390 card found (i/o = 0x%x).\n", io[this_dev]); 435 printk(KERN_WARNING "lne390.c: No LNE390 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index b33111e21313..690a1aae0b34 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -68,6 +68,7 @@ static DEFINE_PER_CPU(struct net_device_stats, loopback_stats);
68 * of largesending device modulo TCP checksum, which is ignored for loopback. 68 * of largesending device modulo TCP checksum, which is ignored for loopback.
69 */ 69 */
70 70
71#ifdef LOOPBACK_TSO
71static void emulate_large_send_offload(struct sk_buff *skb) 72static void emulate_large_send_offload(struct sk_buff *skb)
72{ 73{
73 struct iphdr *iph = skb->nh.iph; 74 struct iphdr *iph = skb->nh.iph;
@@ -119,6 +120,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
119 120
120 dev_kfree_skb(skb); 121 dev_kfree_skb(skb);
121} 122}
123#endif /* LOOPBACK_TSO */
122 124
123/* 125/*
124 * The higher levels take care of making this non-reentrant (it's 126 * The higher levels take care of making this non-reentrant (it's
@@ -130,12 +132,13 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
130 132
131 skb_orphan(skb); 133 skb_orphan(skb);
132 134
133 skb->protocol=eth_type_trans(skb,dev); 135 skb->protocol = eth_type_trans(skb,dev);
134 skb->dev=dev; 136 skb->dev = dev;
135#ifndef LOOPBACK_MUST_CHECKSUM 137#ifndef LOOPBACK_MUST_CHECKSUM
136 skb->ip_summed = CHECKSUM_UNNECESSARY; 138 skb->ip_summed = CHECKSUM_UNNECESSARY;
137#endif 139#endif
138 140
141#ifdef LOOPBACK_TSO
139 if (skb_shinfo(skb)->tso_size) { 142 if (skb_shinfo(skb)->tso_size) {
140 BUG_ON(skb->protocol != htons(ETH_P_IP)); 143 BUG_ON(skb->protocol != htons(ETH_P_IP));
141 BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP); 144 BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP);
@@ -143,14 +146,14 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
143 emulate_large_send_offload(skb); 146 emulate_large_send_offload(skb);
144 return 0; 147 return 0;
145 } 148 }
146 149#endif
147 dev->last_rx = jiffies; 150 dev->last_rx = jiffies;
148 151
149 lb_stats = &per_cpu(loopback_stats, get_cpu()); 152 lb_stats = &per_cpu(loopback_stats, get_cpu());
150 lb_stats->rx_bytes += skb->len; 153 lb_stats->rx_bytes += skb->len;
151 lb_stats->tx_bytes += skb->len; 154 lb_stats->tx_bytes = lb_stats->rx_bytes;
152 lb_stats->rx_packets++; 155 lb_stats->rx_packets++;
153 lb_stats->tx_packets++; 156 lb_stats->tx_packets = lb_stats->rx_packets;
154 put_cpu(); 157 put_cpu();
155 158
156 netif_rx(skb); 159 netif_rx(skb);
@@ -208,13 +211,16 @@ struct net_device loopback_dev = {
208 .type = ARPHRD_LOOPBACK, /* 0x0001*/ 211 .type = ARPHRD_LOOPBACK, /* 0x0001*/
209 .rebuild_header = eth_rebuild_header, 212 .rebuild_header = eth_rebuild_header,
210 .flags = IFF_LOOPBACK, 213 .flags = IFF_LOOPBACK,
211 .features = NETIF_F_SG|NETIF_F_FRAGLIST 214 .features = NETIF_F_SG | NETIF_F_FRAGLIST
212 |NETIF_F_NO_CSUM|NETIF_F_HIGHDMA 215#ifdef LOOPBACK_TSO
213 |NETIF_F_LLTX, 216 | NETIF_F_TSO
217#endif
218 | NETIF_F_NO_CSUM | NETIF_F_HIGHDMA
219 | NETIF_F_LLTX,
214 .ethtool_ops = &loopback_ethtool_ops, 220 .ethtool_ops = &loopback_ethtool_ops,
215}; 221};
216 222
217/* Setup and register the of the LOOPBACK device. */ 223/* Setup and register the loopback device. */
218int __init loopback_init(void) 224int __init loopback_init(void)
219{ 225{
220 struct net_device_stats *stats; 226 struct net_device_stats *stats;
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index 6ed2d7dbd44c..81d0a26e4f41 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -109,7 +109,7 @@ bitrev(int b)
109} 109}
110 110
111 111
112static int __devinit mace_probe(struct macio_dev *mdev, const struct of_match *match) 112static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_id *match)
113{ 113{
114 struct device_node *mace = macio_get_of_node(mdev); 114 struct device_node *mace = macio_get_of_node(mdev);
115 struct net_device *dev; 115 struct net_device *dev;
@@ -1009,12 +1009,10 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id, struct pt_regs *regs)
1009 return IRQ_HANDLED; 1009 return IRQ_HANDLED;
1010} 1010}
1011 1011
1012static struct of_match mace_match[] = 1012static struct of_device_id mace_match[] =
1013{ 1013{
1014 { 1014 {
1015 .name = "mace", 1015 .name = "mace",
1016 .type = OF_ANY_MATCH,
1017 .compatible = OF_ANY_MATCH
1018 }, 1016 },
1019 {}, 1017 {},
1020}; 1018};
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index be28c65de729..405e18365ede 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -1,6 +1,12 @@
1/* 1/*
2 * macsonic.c 2 * macsonic.c
3 * 3 *
4 * (C) 2005 Finn Thain
5 *
6 * Converted to DMA API, converted to unified driver model, made it work as
7 * a module again, and from the mac68k project, introduced more 32-bit cards
8 * and dhd's support for 16-bit cards.
9 *
4 * (C) 1998 Alan Cox 10 * (C) 1998 Alan Cox
5 * 11 *
6 * Debugging Andreas Ehliar, Michael Schmitz 12 * Debugging Andreas Ehliar, Michael Schmitz
@@ -26,8 +32,8 @@
26 */ 32 */
27 33
28#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/module.h>
29#include <linux/types.h> 36#include <linux/types.h>
30#include <linux/ctype.h>
31#include <linux/fcntl.h> 37#include <linux/fcntl.h>
32#include <linux/interrupt.h> 38#include <linux/interrupt.h>
33#include <linux/init.h> 39#include <linux/init.h>
@@ -41,8 +47,8 @@
41#include <linux/netdevice.h> 47#include <linux/netdevice.h>
42#include <linux/etherdevice.h> 48#include <linux/etherdevice.h>
43#include <linux/skbuff.h> 49#include <linux/skbuff.h>
44#include <linux/module.h> 50#include <linux/device.h>
45#include <linux/bitops.h> 51#include <linux/dma-mapping.h>
46 52
47#include <asm/bootinfo.h> 53#include <asm/bootinfo.h>
48#include <asm/system.h> 54#include <asm/system.h>
@@ -54,25 +60,28 @@
54#include <asm/macints.h> 60#include <asm/macints.h>
55#include <asm/mac_via.h> 61#include <asm/mac_via.h>
56 62
57#define SREGS_PAD(n) u16 n; 63static char mac_sonic_string[] = "macsonic";
64static struct platform_device *mac_sonic_device;
58 65
59#include "sonic.h" 66#include "sonic.h"
60 67
61#define SONIC_READ(reg) \ 68/* These should basically be bus-size and endian independent (since
62 nubus_readl(base_addr+(reg)) 69 the SONIC is at least smart enough that it uses the same endianness
63#define SONIC_WRITE(reg,val) \ 70 as the host, unlike certain less enlightened Macintosh NICs) */
64 nubus_writel((val), base_addr+(reg)) 71#define SONIC_READ(reg) (nubus_readw(dev->base_addr + (reg * 4) \
65#define sonic_read(dev, reg) \ 72 + lp->reg_offset))
66 nubus_readl((dev)->base_addr+(reg)) 73#define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
67#define sonic_write(dev, reg, val) \ 74 + lp->reg_offset))
68 nubus_writel((val), (dev)->base_addr+(reg)) 75
69 76/* use 0 for production, 1 for verification, >1 for debug */
77#ifdef SONIC_DEBUG
78static unsigned int sonic_debug = SONIC_DEBUG;
79#else
80static unsigned int sonic_debug = 1;
81#endif
70 82
71static int sonic_debug;
72static int sonic_version_printed; 83static int sonic_version_printed;
73 84
74static int reg_offset;
75
76extern int mac_onboard_sonic_probe(struct net_device* dev); 85extern int mac_onboard_sonic_probe(struct net_device* dev);
77extern int mac_nubus_sonic_probe(struct net_device* dev); 86extern int mac_nubus_sonic_probe(struct net_device* dev);
78 87
@@ -108,40 +117,6 @@ enum macsonic_type {
108 117
109#define SONIC_READ_PROM(addr) nubus_readb(prom_addr+addr) 118#define SONIC_READ_PROM(addr) nubus_readb(prom_addr+addr)
110 119
111struct net_device * __init macsonic_probe(int unit)
112{
113 struct net_device *dev = alloc_etherdev(0);
114 int err;
115
116 if (!dev)
117 return ERR_PTR(-ENOMEM);
118
119 if (unit >= 0)
120 sprintf(dev->name, "eth%d", unit);
121
122 SET_MODULE_OWNER(dev);
123
124 /* This will catch fatal stuff like -ENOMEM as well as success */
125 err = mac_onboard_sonic_probe(dev);
126 if (err == 0)
127 goto found;
128 if (err != -ENODEV)
129 goto out;
130 err = mac_nubus_sonic_probe(dev);
131 if (err)
132 goto out;
133found:
134 err = register_netdev(dev);
135 if (err)
136 goto out1;
137 return dev;
138out1:
139 kfree(dev->priv);
140out:
141 free_netdev(dev);
142 return ERR_PTR(err);
143}
144
145/* 120/*
146 * For reversing the PROM address 121 * For reversing the PROM address
147 */ 122 */
@@ -160,103 +135,55 @@ static inline void bit_reverse_addr(unsigned char addr[6])
160 135
161int __init macsonic_init(struct net_device* dev) 136int __init macsonic_init(struct net_device* dev)
162{ 137{
163 struct sonic_local* lp = NULL; 138 struct sonic_local* lp = netdev_priv(dev);
164 int i;
165 139
166 /* Allocate the entire chunk of memory for the descriptors. 140 /* Allocate the entire chunk of memory for the descriptors.
167 Note that this cannot cross a 64K boundary. */ 141 Note that this cannot cross a 64K boundary. */
168 for (i = 0; i < 20; i++) { 142 if ((lp->descriptors = dma_alloc_coherent(lp->device,
169 unsigned long desc_base, desc_top; 143 SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
170 if((lp = kmalloc(sizeof(struct sonic_local), GFP_KERNEL | GFP_DMA)) == NULL) { 144 &lp->descriptors_laddr, GFP_KERNEL)) == NULL) {
171 printk(KERN_ERR "%s: couldn't allocate descriptor buffers\n", dev->name); 145 printk(KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n", lp->device->bus_id);
172 return -ENOMEM;
173 }
174
175 desc_base = (unsigned long) lp;
176 desc_top = desc_base + sizeof(struct sonic_local);
177 if ((desc_top & 0xffff) >= (desc_base & 0xffff))
178 break;
179 /* Hmm. try again (FIXME: does this actually work?) */
180 kfree(lp);
181 printk(KERN_DEBUG
182 "%s: didn't get continguous chunk [%08lx - %08lx], trying again\n",
183 dev->name, desc_base, desc_top);
184 }
185
186 if (lp == NULL) {
187 printk(KERN_ERR "%s: tried 20 times to allocate descriptor buffers, giving up.\n",
188 dev->name);
189 return -ENOMEM; 146 return -ENOMEM;
190 } 147 }
191
192 dev->priv = lp;
193
194#if 0
195 /* this code is only here as a curiousity... mainly, where the
196 fuck did SONIC_BUS_SCALE come from, and what was it supposed
197 to do? the normal allocation works great for 32 bit stuffs.. */
198 148
199 /* Now set up the pointers to point to the appropriate places */ 149 /* Now set up the pointers to point to the appropriate places */
200 lp->cda = lp->sonic_desc; 150 lp->cda = lp->descriptors;
201 lp->tda = lp->cda + (SIZEOF_SONIC_CDA * SONIC_BUS_SCALE(lp->dma_bitmode)); 151 lp->tda = lp->cda + (SIZEOF_SONIC_CDA
152 * SONIC_BUS_SCALE(lp->dma_bitmode));
202 lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS 153 lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
203 * SONIC_BUS_SCALE(lp->dma_bitmode)); 154 * SONIC_BUS_SCALE(lp->dma_bitmode));
204 lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS 155 lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
205 * SONIC_BUS_SCALE(lp->dma_bitmode)); 156 * SONIC_BUS_SCALE(lp->dma_bitmode));
206 157
207#endif 158 lp->cda_laddr = lp->descriptors_laddr;
208 159 lp->tda_laddr = lp->cda_laddr + (SIZEOF_SONIC_CDA
209 memset(lp, 0, sizeof(struct sonic_local)); 160 * SONIC_BUS_SCALE(lp->dma_bitmode));
210 161 lp->rda_laddr = lp->tda_laddr + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
211 lp->cda_laddr = (unsigned int)&(lp->cda); 162 * SONIC_BUS_SCALE(lp->dma_bitmode));
212 lp->tda_laddr = (unsigned int)lp->tda; 163 lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
213 lp->rra_laddr = (unsigned int)lp->rra; 164 * SONIC_BUS_SCALE(lp->dma_bitmode));
214 lp->rda_laddr = (unsigned int)lp->rda;
215
216 /* FIXME, maybe we should use skbs */
217 if ((lp->rba = (char *)
218 kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_KERNEL | GFP_DMA)) == NULL) {
219 printk(KERN_ERR "%s: couldn't allocate receive buffers\n", dev->name);
220 dev->priv = NULL;
221 kfree(lp);
222 return -ENOMEM;
223 }
224
225 lp->rba_laddr = (unsigned int)lp->rba;
226
227 {
228 int rs, ds;
229
230 /* almost always 12*4096, but let's not take chances */
231 rs = ((SONIC_NUM_RRS * SONIC_RBSIZE + 4095) / 4096) * 4096;
232 /* almost always under a page, but let's not take chances */
233 ds = ((sizeof(struct sonic_local) + 4095) / 4096) * 4096;
234 kernel_set_cachemode(lp->rba, rs, IOMAP_NOCACHE_SER);
235 kernel_set_cachemode(lp, ds, IOMAP_NOCACHE_SER);
236 }
237
238#if 0
239 flush_cache_all();
240#endif
241 165
242 dev->open = sonic_open; 166 dev->open = sonic_open;
243 dev->stop = sonic_close; 167 dev->stop = sonic_close;
244 dev->hard_start_xmit = sonic_send_packet; 168 dev->hard_start_xmit = sonic_send_packet;
245 dev->get_stats = sonic_get_stats; 169 dev->get_stats = sonic_get_stats;
246 dev->set_multicast_list = &sonic_multicast_list; 170 dev->set_multicast_list = &sonic_multicast_list;
171 dev->tx_timeout = sonic_tx_timeout;
172 dev->watchdog_timeo = TX_TIMEOUT;
247 173
248 /* 174 /*
249 * clear tally counter 175 * clear tally counter
250 */ 176 */
251 sonic_write(dev, SONIC_CRCT, 0xffff); 177 SONIC_WRITE(SONIC_CRCT, 0xffff);
252 sonic_write(dev, SONIC_FAET, 0xffff); 178 SONIC_WRITE(SONIC_FAET, 0xffff);
253 sonic_write(dev, SONIC_MPT, 0xffff); 179 SONIC_WRITE(SONIC_MPT, 0xffff);
254 180
255 return 0; 181 return 0;
256} 182}
257 183
258int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev) 184int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev)
259{ 185{
186 struct sonic_local *lp = netdev_priv(dev);
260 const int prom_addr = ONBOARD_SONIC_PROM_BASE; 187 const int prom_addr = ONBOARD_SONIC_PROM_BASE;
261 int i; 188 int i;
262 189
@@ -270,6 +197,7 @@ int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev)
270 why this is so. */ 197 why this is so. */
271 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) && 198 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
272 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) && 199 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
200 memcmp(dev->dev_addr, "\x00\x80\x19", 3) &&
273 memcmp(dev->dev_addr, "\x00\x05\x02", 3)) 201 memcmp(dev->dev_addr, "\x00\x05\x02", 3))
274 bit_reverse_addr(dev->dev_addr); 202 bit_reverse_addr(dev->dev_addr);
275 else 203 else
@@ -281,22 +209,23 @@ int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev)
281 the card... */ 209 the card... */
282 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) && 210 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
283 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) && 211 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
212 memcmp(dev->dev_addr, "\x00\x80\x19", 3) &&
284 memcmp(dev->dev_addr, "\x00\x05\x02", 3)) 213 memcmp(dev->dev_addr, "\x00\x05\x02", 3))
285 { 214 {
286 unsigned short val; 215 unsigned short val;
287 216
288 printk(KERN_INFO "macsonic: PROM seems to be wrong, trying CAM entry 15\n"); 217 printk(KERN_INFO "macsonic: PROM seems to be wrong, trying CAM entry 15\n");
289 218
290 sonic_write(dev, SONIC_CMD, SONIC_CR_RST); 219 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
291 sonic_write(dev, SONIC_CEP, 15); 220 SONIC_WRITE(SONIC_CEP, 15);
292 221
293 val = sonic_read(dev, SONIC_CAP2); 222 val = SONIC_READ(SONIC_CAP2);
294 dev->dev_addr[5] = val >> 8; 223 dev->dev_addr[5] = val >> 8;
295 dev->dev_addr[4] = val & 0xff; 224 dev->dev_addr[4] = val & 0xff;
296 val = sonic_read(dev, SONIC_CAP1); 225 val = SONIC_READ(SONIC_CAP1);
297 dev->dev_addr[3] = val >> 8; 226 dev->dev_addr[3] = val >> 8;
298 dev->dev_addr[2] = val & 0xff; 227 dev->dev_addr[2] = val & 0xff;
299 val = sonic_read(dev, SONIC_CAP0); 228 val = SONIC_READ(SONIC_CAP0);
300 dev->dev_addr[1] = val >> 8; 229 dev->dev_addr[1] = val >> 8;
301 dev->dev_addr[0] = val & 0xff; 230 dev->dev_addr[0] = val & 0xff;
302 231
@@ -311,6 +240,7 @@ int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev)
311 240
312 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) && 241 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
313 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) && 242 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
243 memcmp(dev->dev_addr, "\x00\x80\x19", 3) &&
314 memcmp(dev->dev_addr, "\x00\x05\x02", 3)) 244 memcmp(dev->dev_addr, "\x00\x05\x02", 3))
315 { 245 {
316 /* 246 /*
@@ -325,8 +255,9 @@ int __init mac_onboard_sonic_probe(struct net_device* dev)
325{ 255{
326 /* Bwahahaha */ 256 /* Bwahahaha */
327 static int once_is_more_than_enough; 257 static int once_is_more_than_enough;
328 int i; 258 struct sonic_local* lp = netdev_priv(dev);
329 int dma_bitmode; 259 int sr;
260 int commslot = 0;
330 261
331 if (once_is_more_than_enough) 262 if (once_is_more_than_enough)
332 return -ENODEV; 263 return -ENODEV;
@@ -335,20 +266,18 @@ int __init mac_onboard_sonic_probe(struct net_device* dev)
335 if (!MACH_IS_MAC) 266 if (!MACH_IS_MAC)
336 return -ENODEV; 267 return -ENODEV;
337 268
338 printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
339
340 if (macintosh_config->ether_type != MAC_ETHER_SONIC) 269 if (macintosh_config->ether_type != MAC_ETHER_SONIC)
341 {
342 printk("none.\n");
343 return -ENODEV; 270 return -ENODEV;
344 } 271
345 272 printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
273
346 /* Bogus probing, on the models which may or may not have 274 /* Bogus probing, on the models which may or may not have
347 Ethernet (BTW, the Ethernet *is* always at the same 275 Ethernet (BTW, the Ethernet *is* always at the same
348 address, and nothing else lives there, at least if Apple's 276 address, and nothing else lives there, at least if Apple's
349 documentation is to be believed) */ 277 documentation is to be believed) */
350 if (macintosh_config->ident == MAC_MODEL_Q630 || 278 if (macintosh_config->ident == MAC_MODEL_Q630 ||
351 macintosh_config->ident == MAC_MODEL_P588 || 279 macintosh_config->ident == MAC_MODEL_P588 ||
280 macintosh_config->ident == MAC_MODEL_P575 ||
352 macintosh_config->ident == MAC_MODEL_C610) { 281 macintosh_config->ident == MAC_MODEL_C610) {
353 unsigned long flags; 282 unsigned long flags;
354 int card_present; 283 int card_present;
@@ -361,13 +290,13 @@ int __init mac_onboard_sonic_probe(struct net_device* dev)
361 printk("none.\n"); 290 printk("none.\n");
362 return -ENODEV; 291 return -ENODEV;
363 } 292 }
293 commslot = 1;
364 } 294 }
365 295
366 printk("yes\n"); 296 printk("yes\n");
367 297
368 /* Danger! My arms are flailing wildly! You *must* set this 298 /* Danger! My arms are flailing wildly! You *must* set lp->reg_offset
369 before using sonic_read() */ 299 * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
370
371 dev->base_addr = ONBOARD_SONIC_REGISTERS; 300 dev->base_addr = ONBOARD_SONIC_REGISTERS;
372 if (via_alt_mapping) 301 if (via_alt_mapping)
373 dev->irq = IRQ_AUTO_3; 302 dev->irq = IRQ_AUTO_3;
@@ -379,84 +308,66 @@ int __init mac_onboard_sonic_probe(struct net_device* dev)
379 sonic_version_printed = 1; 308 sonic_version_printed = 1;
380 } 309 }
381 printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n", 310 printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n",
382 dev->name, dev->base_addr); 311 lp->device->bus_id, dev->base_addr);
383
384 /* Now do a song and dance routine in an attempt to determine
385 the bus width */
386 312
387 /* The PowerBook's SONIC is 16 bit always. */ 313 /* The PowerBook's SONIC is 16 bit always. */
388 if (macintosh_config->ident == MAC_MODEL_PB520) { 314 if (macintosh_config->ident == MAC_MODEL_PB520) {
389 reg_offset = 0; 315 lp->reg_offset = 0;
390 dma_bitmode = 0; 316 lp->dma_bitmode = SONIC_BITMODE16;
391 } else if (macintosh_config->ident == MAC_MODEL_C610) { 317 sr = SONIC_READ(SONIC_SR);
392 reg_offset = 0; 318 } else if (commslot) {
393 dma_bitmode = 1;
394 } else {
395 /* Some of the comm-slot cards are 16 bit. But some 319 /* Some of the comm-slot cards are 16 bit. But some
396 of them are not. The 32-bit cards use offset 2 and 320 of them are not. The 32-bit cards use offset 2 and
397 pad with zeroes or sometimes ones (I think...) 321 have known revisions, we try reading the revision
398 Therefore, if we try offset 0 and get a silicon 322 register at offset 2, if we don't get a known revision
399 revision of 0, we assume 16 bit. */ 323 we assume 16 bit at offset 0. */
400 int sr; 324 lp->reg_offset = 2;
401 325 lp->dma_bitmode = SONIC_BITMODE16;
402 /* Technically this is not necessary since we zeroed 326
403 it above */ 327 sr = SONIC_READ(SONIC_SR);
404 reg_offset = 0; 328 if (sr == 0x0004 || sr == 0x0006 || sr == 0x0100 || sr == 0x0101)
405 dma_bitmode = 0; 329 /* 83932 is 0x0004 or 0x0006, 83934 is 0x0100 or 0x0101 */
406 sr = sonic_read(dev, SONIC_SR); 330 lp->dma_bitmode = SONIC_BITMODE32;
407 if (sr == 0 || sr == 0xffff) { 331 else {
408 reg_offset = 2; 332 lp->dma_bitmode = SONIC_BITMODE16;
409 /* 83932 is 0x0004, 83934 is 0x0100 or 0x0101 */ 333 lp->reg_offset = 0;
410 sr = sonic_read(dev, SONIC_SR); 334 sr = SONIC_READ(SONIC_SR);
411 dma_bitmode = 1;
412
413 } 335 }
414 printk(KERN_INFO 336 } else {
415 "%s: revision 0x%04x, using %d bit DMA and register offset %d\n", 337 /* All onboard cards are at offset 2 with 32 bit DMA. */
416 dev->name, sr, dma_bitmode?32:16, reg_offset); 338 lp->reg_offset = 2;
339 lp->dma_bitmode = SONIC_BITMODE32;
340 sr = SONIC_READ(SONIC_SR);
417 } 341 }
418 342 printk(KERN_INFO
343 "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
344 lp->device->bus_id, sr, lp->dma_bitmode?32:16, lp->reg_offset);
419 345
420 /* this carries my sincere apologies -- by the time I got to updating 346#if 0 /* This is sometimes useful to find out how MacOS configured the card. */
421 the driver, support for "reg_offsets" appeares nowhere in the sonic 347 printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", lp->device->bus_id,
422 code, going back for over a year. Fortunately, my Mac does't seem 348 SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff);
423 to use whatever this was. 349#endif
424 350
425 If you know how this is supposed to be implemented, either fix it,
426 or contact me (sammy@oh.verio.com) to explain what it is. --Sam */
427
428 if(reg_offset) {
429 printk("%s: register offset unsupported. please fix this if you know what it is.\n", dev->name);
430 return -ENODEV;
431 }
432
433 /* Software reset, then initialize control registers. */ 351 /* Software reset, then initialize control registers. */
434 sonic_write(dev, SONIC_CMD, SONIC_CR_RST); 352 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
435 sonic_write(dev, SONIC_DCR, SONIC_DCR_BMS | 353
436 SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_EXBUS | 354 SONIC_WRITE(SONIC_DCR, SONIC_DCR_EXBUS | SONIC_DCR_BMS |
437 (dma_bitmode ? SONIC_DCR_DW : 0)); 355 SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
356 (lp->dma_bitmode ? SONIC_DCR_DW : 0));
438 357
439 /* This *must* be written back to in order to restore the 358 /* This *must* be written back to in order to restore the
440 extended programmable output bits */ 359 * extended programmable output bits, as it may not have been
441 sonic_write(dev, SONIC_DCR2, 0); 360 * initialised since the hardware reset. */
361 SONIC_WRITE(SONIC_DCR2, 0);
442 362
443 /* Clear *and* disable interrupts to be on the safe side */ 363 /* Clear *and* disable interrupts to be on the safe side */
444 sonic_write(dev, SONIC_ISR,0x7fff); 364 SONIC_WRITE(SONIC_IMR, 0);
445 sonic_write(dev, SONIC_IMR,0); 365 SONIC_WRITE(SONIC_ISR, 0x7fff);
446 366
447 /* Now look for the MAC address. */ 367 /* Now look for the MAC address. */
448 if (mac_onboard_sonic_ethernet_addr(dev) != 0) 368 if (mac_onboard_sonic_ethernet_addr(dev) != 0)
449 return -ENODEV; 369 return -ENODEV;
450 370
451 printk(KERN_INFO "MAC ");
452 for (i = 0; i < 6; i++) {
453 printk("%2.2x", dev->dev_addr[i]);
454 if (i < 5)
455 printk(":");
456 }
457
458 printk(" IRQ %d\n", dev->irq);
459
460 /* Shared init code */ 371 /* Shared init code */
461 return macsonic_init(dev); 372 return macsonic_init(dev);
462} 373}
@@ -468,8 +379,10 @@ int __init mac_nubus_sonic_ethernet_addr(struct net_device* dev,
468 int i; 379 int i;
469 for(i = 0; i < 6; i++) 380 for(i = 0; i < 6; i++)
470 dev->dev_addr[i] = SONIC_READ_PROM(i); 381 dev->dev_addr[i] = SONIC_READ_PROM(i);
471 /* For now we are going to assume that they're all bit-reversed */ 382
472 bit_reverse_addr(dev->dev_addr); 383 /* Some of the addresses are bit-reversed */
384 if (id != MACSONIC_DAYNA)
385 bit_reverse_addr(dev->dev_addr);
473 386
474 return 0; 387 return 0;
475} 388}
@@ -487,6 +400,15 @@ int __init macsonic_ident(struct nubus_dev* ndev)
487 else 400 else
488 return MACSONIC_APPLE; 401 return MACSONIC_APPLE;
489 } 402 }
403
404 if (ndev->dr_hw == NUBUS_DRHW_SMC9194 &&
405 ndev->dr_sw == NUBUS_DRSW_DAYNA)
406 return MACSONIC_DAYNA;
407
408 if (ndev->dr_hw == NUBUS_DRHW_SONIC_LC &&
409 ndev->dr_sw == 0) { /* huh? */
410 return MACSONIC_APPLE16;
411 }
490 return -1; 412 return -1;
491} 413}
492 414
@@ -494,12 +416,12 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
494{ 416{
495 static int slots; 417 static int slots;
496 struct nubus_dev* ndev = NULL; 418 struct nubus_dev* ndev = NULL;
419 struct sonic_local* lp = netdev_priv(dev);
497 unsigned long base_addr, prom_addr; 420 unsigned long base_addr, prom_addr;
498 u16 sonic_dcr; 421 u16 sonic_dcr;
499 int id; 422 int id = -1;
500 int i; 423 int reg_offset, dma_bitmode;
501 int dma_bitmode; 424
502
503 /* Find the first SONIC that hasn't been initialized already */ 425 /* Find the first SONIC that hasn't been initialized already */
504 while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, 426 while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK,
505 NUBUS_TYPE_ETHERNET, ndev)) != NULL) 427 NUBUS_TYPE_ETHERNET, ndev)) != NULL)
@@ -521,51 +443,52 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
521 case MACSONIC_DUODOCK: 443 case MACSONIC_DUODOCK:
522 base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS; 444 base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS;
523 prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE; 445 prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE;
524 sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 446 sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 |
525 | SONIC_DCR_TFT0; 447 SONIC_DCR_TFT0;
526 reg_offset = 2; 448 reg_offset = 2;
527 dma_bitmode = 1; 449 dma_bitmode = SONIC_BITMODE32;
528 break; 450 break;
529 case MACSONIC_APPLE: 451 case MACSONIC_APPLE:
530 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS; 452 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
531 prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE; 453 prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
532 sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0; 454 sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
533 reg_offset = 0; 455 reg_offset = 0;
534 dma_bitmode = 1; 456 dma_bitmode = SONIC_BITMODE32;
535 break; 457 break;
536 case MACSONIC_APPLE16: 458 case MACSONIC_APPLE16:
537 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS; 459 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
538 prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE; 460 prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
539 sonic_dcr = SONIC_DCR_EXBUS 461 sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
540 | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 462 SONIC_DCR_PO1 | SONIC_DCR_BMS;
541 | SONIC_DCR_PO1 | SONIC_DCR_BMS;
542 reg_offset = 0; 463 reg_offset = 0;
543 dma_bitmode = 0; 464 dma_bitmode = SONIC_BITMODE16;
544 break; 465 break;
545 case MACSONIC_DAYNALINK: 466 case MACSONIC_DAYNALINK:
546 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS; 467 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
547 prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE; 468 prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE;
548 sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 469 sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
549 | SONIC_DCR_PO1 | SONIC_DCR_BMS; 470 SONIC_DCR_PO1 | SONIC_DCR_BMS;
550 reg_offset = 0; 471 reg_offset = 0;
551 dma_bitmode = 0; 472 dma_bitmode = SONIC_BITMODE16;
552 break; 473 break;
553 case MACSONIC_DAYNA: 474 case MACSONIC_DAYNA:
554 base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS; 475 base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS;
555 prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR; 476 prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR;
556 sonic_dcr = SONIC_DCR_BMS 477 sonic_dcr = SONIC_DCR_BMS |
557 | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1; 478 SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
558 reg_offset = 0; 479 reg_offset = 0;
559 dma_bitmode = 0; 480 dma_bitmode = SONIC_BITMODE16;
560 break; 481 break;
561 default: 482 default:
562 printk(KERN_ERR "macsonic: WTF, id is %d\n", id); 483 printk(KERN_ERR "macsonic: WTF, id is %d\n", id);
563 return -ENODEV; 484 return -ENODEV;
564 } 485 }
565 486
566 /* Danger! My arms are flailing wildly! You *must* set this 487 /* Danger! My arms are flailing wildly! You *must* set lp->reg_offset
567 before using sonic_read() */ 488 * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
568 dev->base_addr = base_addr; 489 dev->base_addr = base_addr;
490 lp->reg_offset = reg_offset;
491 lp->dma_bitmode = dma_bitmode;
569 dev->irq = SLOT2IRQ(ndev->board->slot); 492 dev->irq = SLOT2IRQ(ndev->board->slot);
570 493
571 if (!sonic_version_printed) { 494 if (!sonic_version_printed) {
@@ -573,29 +496,66 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
573 sonic_version_printed = 1; 496 sonic_version_printed = 1;
574 } 497 }
575 printk(KERN_INFO "%s: %s in slot %X\n", 498 printk(KERN_INFO "%s: %s in slot %X\n",
576 dev->name, ndev->board->name, ndev->board->slot); 499 lp->device->bus_id, ndev->board->name, ndev->board->slot);
577 printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n", 500 printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
578 dev->name, sonic_read(dev, SONIC_SR), dma_bitmode?32:16, reg_offset); 501 lp->device->bus_id, SONIC_READ(SONIC_SR), dma_bitmode?32:16, reg_offset);
579 502
580 if(reg_offset) { 503#if 0 /* This is sometimes useful to find out how MacOS configured the card. */
581 printk("%s: register offset unsupported. please fix this if you know what it is.\n", dev->name); 504 printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", lp->device->bus_id,
582 return -ENODEV; 505 SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff);
583 } 506#endif
584 507
585 /* Software reset, then initialize control registers. */ 508 /* Software reset, then initialize control registers. */
586 sonic_write(dev, SONIC_CMD, SONIC_CR_RST); 509 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
587 sonic_write(dev, SONIC_DCR, sonic_dcr 510 SONIC_WRITE(SONIC_DCR, sonic_dcr | (dma_bitmode ? SONIC_DCR_DW : 0));
588 | (dma_bitmode ? SONIC_DCR_DW : 0)); 511 /* This *must* be written back to in order to restore the
512 * extended programmable output bits, since it may not have been
513 * initialised since the hardware reset. */
514 SONIC_WRITE(SONIC_DCR2, 0);
589 515
590 /* Clear *and* disable interrupts to be on the safe side */ 516 /* Clear *and* disable interrupts to be on the safe side */
591 sonic_write(dev, SONIC_ISR,0x7fff); 517 SONIC_WRITE(SONIC_IMR, 0);
592 sonic_write(dev, SONIC_IMR,0); 518 SONIC_WRITE(SONIC_ISR, 0x7fff);
593 519
594 /* Now look for the MAC address. */ 520 /* Now look for the MAC address. */
595 if (mac_nubus_sonic_ethernet_addr(dev, prom_addr, id) != 0) 521 if (mac_nubus_sonic_ethernet_addr(dev, prom_addr, id) != 0)
596 return -ENODEV; 522 return -ENODEV;
597 523
598 printk(KERN_INFO "MAC "); 524 /* Shared init code */
525 return macsonic_init(dev);
526}
527
528static int __init mac_sonic_probe(struct device *device)
529{
530 struct net_device *dev;
531 struct sonic_local *lp;
532 int err;
533 int i;
534
535 dev = alloc_etherdev(sizeof(struct sonic_local));
536 if (!dev)
537 return -ENOMEM;
538
539 lp = netdev_priv(dev);
540 lp->device = device;
541 SET_NETDEV_DEV(dev, device);
542 SET_MODULE_OWNER(dev);
543
544 /* This will catch fatal stuff like -ENOMEM as well as success */
545 err = mac_onboard_sonic_probe(dev);
546 if (err == 0)
547 goto found;
548 if (err != -ENODEV)
549 goto out;
550 err = mac_nubus_sonic_probe(dev);
551 if (err)
552 goto out;
553found:
554 err = register_netdev(dev);
555 if (err)
556 goto out;
557
558 printk("%s: MAC ", dev->name);
599 for (i = 0; i < 6; i++) { 559 for (i = 0; i < 6; i++) {
600 printk("%2.2x", dev->dev_addr[i]); 560 printk("%2.2x", dev->dev_addr[i]);
601 if (i < 5) 561 if (i < 5)
@@ -603,55 +563,95 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
603 } 563 }
604 printk(" IRQ %d\n", dev->irq); 564 printk(" IRQ %d\n", dev->irq);
605 565
606 /* Shared init code */ 566 return 0;
607 return macsonic_init(dev);
608}
609 567
610#ifdef MODULE 568out:
611static struct net_device *dev_macsonic; 569 free_netdev(dev);
612 570
613MODULE_PARM(sonic_debug, "i"); 571 return err;
572}
573
574MODULE_DESCRIPTION("Macintosh SONIC ethernet driver");
575module_param(sonic_debug, int, 0);
614MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)"); 576MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
615 577
616int 578#define SONIC_IRQ_FLAG IRQ_FLG_FAST
617init_module(void) 579
580#include "sonic.c"
581
582static int __devexit mac_sonic_device_remove (struct device *device)
618{ 583{
619 dev_macsonic = macsonic_probe(-1); 584 struct net_device *dev = device->driver_data;
620 if (IS_ERR(dev_macsonic)) { 585 struct sonic_local* lp = netdev_priv(dev);
621 printk(KERN_WARNING "macsonic.c: No card found\n"); 586
622 return PTR_ERR(dev_macsonic); 587 unregister_netdev (dev);
623 } 588 dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
589 lp->descriptors, lp->descriptors_laddr);
590 free_netdev (dev);
591
624 return 0; 592 return 0;
625} 593}
626 594
627void 595static struct device_driver mac_sonic_driver = {
628cleanup_module(void) 596 .name = mac_sonic_string,
597 .bus = &platform_bus_type,
598 .probe = mac_sonic_probe,
599 .remove = __devexit_p(mac_sonic_device_remove),
600};
601
602static void mac_sonic_platform_release(struct device *device)
629{ 603{
630 unregister_netdev(dev_macsonic); 604 struct platform_device *pldev;
631 kfree(dev_macsonic->priv); 605
632 free_netdev(dev_macsonic); 606 /* free device */
607 pldev = to_platform_device (device);
608 kfree (pldev);
633} 609}
634#endif /* MODULE */
635 610
611static int __init mac_sonic_init_module(void)
612{
613 struct platform_device *pldev;
614 int err;
636 615
637#define vdma_alloc(foo, bar) ((u32)foo) 616 if ((err = driver_register(&mac_sonic_driver))) {
638#define vdma_free(baz) 617 printk(KERN_ERR "Driver registration failed\n");
639#define sonic_chiptomem(bat) (bat) 618 return err;
640#define PHYSADDR(quux) (quux) 619 }
641#define CPHYSADDR(quux) (quux)
642 620
643#define sonic_request_irq request_irq 621 mac_sonic_device = NULL;
644#define sonic_free_irq free_irq
645 622
646#include "sonic.c" 623 if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
624 goto out_unregister;
625 }
647 626
648/* 627 memset(pldev, 0, sizeof (*pldev));
649 * Local variables: 628 pldev->name = mac_sonic_string;
650 * compile-command: "m68k-linux-gcc -D__KERNEL__ -I../../include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strength-reduce -ffixed-a2 -DMODULE -DMODVERSIONS -include ../../include/linux/modversions.h -c -o macsonic.o macsonic.c" 629 pldev->id = 0;
651 * version-control: t 630 pldev->dev.release = mac_sonic_platform_release;
652 * kept-new-versions: 5 631 mac_sonic_device = pldev;
653 * c-indent-level: 8 632
654 * tab-width: 8 633 if (platform_device_register (pldev)) {
655 * End: 634 kfree(pldev);
656 * 635 mac_sonic_device = NULL;
657 */ 636 }
637
638 return 0;
639
640out_unregister:
641 platform_device_unregister(pldev);
642
643 return -ENOMEM;
644}
645
646static void __exit mac_sonic_cleanup_module(void)
647{
648 driver_unregister(&mac_sonic_driver);
649
650 if (mac_sonic_device) {
651 platform_device_unregister(mac_sonic_device);
652 mac_sonic_device = NULL;
653 }
654}
655
656module_init(mac_sonic_init_module);
657module_exit(mac_sonic_cleanup_module);
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 0405e1f0d3df..fb6b232069d6 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1157,16 +1157,20 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
1157 if (!skb_shinfo(skb)->nr_frags) { 1157 if (!skb_shinfo(skb)->nr_frags) {
1158linear: 1158linear:
1159 if (skb->ip_summed != CHECKSUM_HW) { 1159 if (skb->ip_summed != CHECKSUM_HW) {
1160 /* Errata BTS #50, IHL must be 5 if no HW checksum */
1160 pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT | 1161 pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT |
1161 ETH_TX_FIRST_DESC | ETH_TX_LAST_DESC; 1162 ETH_TX_FIRST_DESC |
1163 ETH_TX_LAST_DESC |
1164 5 << ETH_TX_IHL_SHIFT;
1162 pkt_info.l4i_chk = 0; 1165 pkt_info.l4i_chk = 0;
1163 } else { 1166 } else {
1164 u32 ipheader = skb->nh.iph->ihl << 11;
1165 1167
1166 pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT | 1168 pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT |
1167 ETH_TX_FIRST_DESC | ETH_TX_LAST_DESC | 1169 ETH_TX_FIRST_DESC |
1168 ETH_GEN_TCP_UDP_CHECKSUM | 1170 ETH_TX_LAST_DESC |
1169 ETH_GEN_IP_V_4_CHECKSUM | ipheader; 1171 ETH_GEN_TCP_UDP_CHECKSUM |
1172 ETH_GEN_IP_V_4_CHECKSUM |
1173 skb->nh.iph->ihl << ETH_TX_IHL_SHIFT;
1170 /* CPU already calculated pseudo header checksum. */ 1174 /* CPU already calculated pseudo header checksum. */
1171 if (skb->nh.iph->protocol == IPPROTO_UDP) { 1175 if (skb->nh.iph->protocol == IPPROTO_UDP) {
1172 pkt_info.cmd_sts |= ETH_UDP_FRAME; 1176 pkt_info.cmd_sts |= ETH_UDP_FRAME;
@@ -1193,7 +1197,6 @@ linear:
1193 stats->tx_bytes += pkt_info.byte_cnt; 1197 stats->tx_bytes += pkt_info.byte_cnt;
1194 } else { 1198 } else {
1195 unsigned int frag; 1199 unsigned int frag;
1196 u32 ipheader;
1197 1200
1198 /* Since hardware can't handle unaligned fragments smaller 1201 /* Since hardware can't handle unaligned fragments smaller
1199 * than 9 bytes, if we find any, we linearize the skb 1202 * than 9 bytes, if we find any, we linearize the skb
@@ -1222,12 +1225,16 @@ linear:
1222 DMA_TO_DEVICE); 1225 DMA_TO_DEVICE);
1223 pkt_info.l4i_chk = 0; 1226 pkt_info.l4i_chk = 0;
1224 pkt_info.return_info = 0; 1227 pkt_info.return_info = 0;
1225 pkt_info.cmd_sts = ETH_TX_FIRST_DESC;
1226 1228
1227 if (skb->ip_summed == CHECKSUM_HW) { 1229 if (skb->ip_summed != CHECKSUM_HW)
1228 ipheader = skb->nh.iph->ihl << 11; 1230 /* Errata BTS #50, IHL must be 5 if no HW checksum */
1229 pkt_info.cmd_sts |= ETH_GEN_TCP_UDP_CHECKSUM | 1231 pkt_info.cmd_sts = ETH_TX_FIRST_DESC |
1230 ETH_GEN_IP_V_4_CHECKSUM | ipheader; 1232 5 << ETH_TX_IHL_SHIFT;
1233 else {
1234 pkt_info.cmd_sts = ETH_TX_FIRST_DESC |
1235 ETH_GEN_TCP_UDP_CHECKSUM |
1236 ETH_GEN_IP_V_4_CHECKSUM |
1237 skb->nh.iph->ihl << ETH_TX_IHL_SHIFT;
1231 /* CPU already calculated pseudo header checksum. */ 1238 /* CPU already calculated pseudo header checksum. */
1232 if (skb->nh.iph->protocol == IPPROTO_UDP) { 1239 if (skb->nh.iph->protocol == IPPROTO_UDP) {
1233 pkt_info.cmd_sts |= ETH_UDP_FRAME; 1240 pkt_info.cmd_sts |= ETH_UDP_FRAME;
diff --git a/drivers/net/mv643xx_eth.h b/drivers/net/mv643xx_eth.h
index 57c4f8fbfdb6..7678b59c2952 100644
--- a/drivers/net/mv643xx_eth.h
+++ b/drivers/net/mv643xx_eth.h
@@ -49,7 +49,7 @@
49/* Checksum offload for Tx works for most packets, but 49/* Checksum offload for Tx works for most packets, but
50 * fails if previous packet sent did not use hw csum 50 * fails if previous packet sent did not use hw csum
51 */ 51 */
52#undef MV643XX_CHECKSUM_OFFLOAD_TX 52#define MV643XX_CHECKSUM_OFFLOAD_TX
53#define MV643XX_NAPI 53#define MV643XX_NAPI
54#define MV643XX_TX_FAST_REFILL 54#define MV643XX_TX_FAST_REFILL
55#undef MV643XX_RX_QUEUE_FILL_ON_TASK /* Does not work, yet */ 55#undef MV643XX_RX_QUEUE_FILL_ON_TASK /* Does not work, yet */
@@ -217,6 +217,8 @@
217#define ETH_TX_ENABLE_INTERRUPT (BIT23) 217#define ETH_TX_ENABLE_INTERRUPT (BIT23)
218#define ETH_AUTO_MODE (BIT30) 218#define ETH_AUTO_MODE (BIT30)
219 219
220#define ETH_TX_IHL_SHIFT 11
221
220/* typedefs */ 222/* typedefs */
221 223
222typedef enum _eth_func_ret_status { 224typedef enum _eth_func_ret_status {
diff --git a/drivers/net/myri_code.h b/drivers/net/myri_code.h
index 851eba8a3e00..e9c6e569d1f4 100644
--- a/drivers/net/myri_code.h
+++ b/drivers/net/myri_code.h
@@ -4775,1288 +4775,7 @@ static unsigned char lanai4_code[76256] __initdata = {
4775/* This is the LANai data */ 4775/* This is the LANai data */
4776 4776
4777static unsigned int lanai4_data_off = 0x94F0; /* half-word offset */ 4777static unsigned int lanai4_data_off = 0x94F0; /* half-word offset */
4778static unsigned char lanai4_data[20472] __initdata = { 4778static unsigned char lanai4_data[20472] __initdata;
47790x00,0x00,
47800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
47990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
48990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
49990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
50990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
51990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
52990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
53990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
54990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
55990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
56990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
57990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x01,
58900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
58990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59590x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59600x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59610x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59620x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59630x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59640x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59650x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59660x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59670x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59680x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59690x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59700x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59710x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59720x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59730x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59740x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59750x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59760x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59770x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59780x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59790x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59800x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59810x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59820x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59830x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59840x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59850x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59860x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59870x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59880x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59890x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59900x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59910x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59920x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59930x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59940x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59950x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59960x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59970x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59980x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
59990x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60000x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60010x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60020x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60030x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60040x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60050x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60060x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60070x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60080x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60090x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60100x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60110x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60120x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60130x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60140x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60150x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60160x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60170x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60180x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60190x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60200x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60210x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60220x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60230x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60240x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60250x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60260x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60270x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60280x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60290x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60300x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60310x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60320x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60330x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60340x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60350x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60360x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60370x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60380x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60390x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60400x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60410x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60420x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60430x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60440x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60450x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60460x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60470x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60480x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60490x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60500x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60510x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60520x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60530x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60540x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60550x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60560x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60570x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60580x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
60590x00,0x00, 0x00,0x00, 0x00,0x00, } ;
6060 4779
6061 4780
6062#ifdef SYMBOL_DEFINES_COMPILED 4781#ifdef SYMBOL_DEFINES_COMPILED
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index aad5494c83cf..f0996ce5c268 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -369,7 +369,7 @@ static void myri_tx(struct myri_eth *mp, struct net_device *dev)
369 * assume 802.3 if the type field is short enough to be a length. 369 * assume 802.3 if the type field is short enough to be a length.
370 * This is normal practice and works for any 'now in use' protocol. 370 * This is normal practice and works for any 'now in use' protocol.
371 */ 371 */
372static unsigned short myri_type_trans(struct sk_buff *skb, struct net_device *dev) 372static __be16 myri_type_trans(struct sk_buff *skb, struct net_device *dev)
373{ 373{
374 struct ethhdr *eth; 374 struct ethhdr *eth;
375 unsigned char *rawp; 375 unsigned char *rawp;
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index babb59e146ea..9d6d2548c2d3 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -1926,7 +1926,7 @@ static void refill_rx(struct net_device *dev)
1926 break; /* Better luck next round. */ 1926 break; /* Better luck next round. */
1927 skb->dev = dev; /* Mark as being used by this device. */ 1927 skb->dev = dev; /* Mark as being used by this device. */
1928 np->rx_dma[entry] = pci_map_single(np->pci_dev, 1928 np->rx_dma[entry] = pci_map_single(np->pci_dev,
1929 skb->tail, buflen, PCI_DMA_FROMDEVICE); 1929 skb->data, buflen, PCI_DMA_FROMDEVICE);
1930 np->rx_ring[entry].addr = cpu_to_le32(np->rx_dma[entry]); 1930 np->rx_ring[entry].addr = cpu_to_le32(np->rx_dma[entry]);
1931 } 1931 }
1932 np->rx_ring[entry].cmd_status = cpu_to_le32(np->rx_buf_sz); 1932 np->rx_ring[entry].cmd_status = cpu_to_le32(np->rx_buf_sz);
@@ -2280,7 +2280,7 @@ static void netdev_rx(struct net_device *dev)
2280 buflen, 2280 buflen,
2281 PCI_DMA_FROMDEVICE); 2281 PCI_DMA_FROMDEVICE);
2282 eth_copy_and_sum(skb, 2282 eth_copy_and_sum(skb,
2283 np->rx_skbuff[entry]->tail, pkt_len, 0); 2283 np->rx_skbuff[entry]->data, pkt_len, 0);
2284 skb_put(skb, pkt_len); 2284 skb_put(skb, pkt_len);
2285 pci_dma_sync_single_for_device(np->pci_dev, 2285 pci_dma_sync_single_for_device(np->pci_dev,
2286 np->rx_dma[entry], 2286 np->rx_dma[entry],
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index 84e291e24935..8f40368cf2e9 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -180,12 +180,7 @@ struct net_device * __init ne_probe(int unit)
180 err = do_ne_probe(dev); 180 err = do_ne_probe(dev);
181 if (err) 181 if (err)
182 goto out; 182 goto out;
183 err = register_netdev(dev);
184 if (err)
185 goto out1;
186 return dev; 183 return dev;
187out1:
188 cleanup_card(dev);
189out: 184out:
190 free_netdev(dev); 185 free_netdev(dev);
191 return ERR_PTR(err); 186 return ERR_PTR(err);
@@ -325,8 +320,13 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
325 dev->poll_controller = ei_poll; 320 dev->poll_controller = ei_poll;
326#endif 321#endif
327 NS8390_init(dev, 0); 322 NS8390_init(dev, 0);
328 return 0;
329 323
324 ret = register_netdev(dev);
325 if (ret)
326 goto out_irq;
327 return 0;
328out_irq:
329 free_irq(dev->irq, dev);
330err_out: 330err_out:
331 release_region(ioaddr, NE_IO_EXTENT); 331 release_region(ioaddr, NE_IO_EXTENT);
332 return ret; 332 return ret;
@@ -633,11 +633,8 @@ int init_module(void)
633 err = init_reg_offset(dev, dev->base_addr); 633 err = init_reg_offset(dev, dev->base_addr);
634 if (!err) { 634 if (!err) {
635 if (do_ne_probe(dev) == 0) { 635 if (do_ne_probe(dev) == 0) {
636 if (register_netdev(dev) == 0) { 636 dev_ne[found++] = dev;
637 dev_ne[found++] = dev; 637 continue;
638 continue;
639 }
640 cleanup_card(dev);
641 } 638 }
642 } 639 }
643 free_netdev(dev); 640 free_netdev(dev);
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index 496433902ade..d209a1556b2e 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -129,9 +129,9 @@ bad_clone_list[] __initdata = {
129#define NESM_START_PG 0x40 /* First page of TX buffer */ 129#define NESM_START_PG 0x40 /* First page of TX buffer */
130#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ 130#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
131 131
132#ifdef CONFIG_PLAT_MAPPI 132#if defined(CONFIG_PLAT_MAPPI)
133# define DCR_VAL 0x4b 133# define DCR_VAL 0x4b
134#elif CONFIG_PLAT_OAKS32R 134#elif defined(CONFIG_PLAT_OAKS32R)
135# define DCR_VAL 0x48 135# define DCR_VAL 0x48
136#else 136#else
137# define DCR_VAL 0x49 137# define DCR_VAL 0x49
@@ -229,12 +229,7 @@ struct net_device * __init ne_probe(int unit)
229 err = do_ne_probe(dev); 229 err = do_ne_probe(dev);
230 if (err) 230 if (err)
231 goto out; 231 goto out;
232 err = register_netdev(dev);
233 if (err)
234 goto out1;
235 return dev; 232 return dev;
236out1:
237 cleanup_card(dev);
238out: 233out:
239 free_netdev(dev); 234 free_netdev(dev);
240 return ERR_PTR(err); 235 return ERR_PTR(err);
@@ -534,8 +529,14 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
534 dev->poll_controller = ei_poll; 529 dev->poll_controller = ei_poll;
535#endif 530#endif
536 NS8390_init(dev, 0); 531 NS8390_init(dev, 0);
532
533 ret = register_netdev(dev);
534 if (ret)
535 goto out_irq;
537 return 0; 536 return 0;
538 537
538out_irq:
539 free_irq(dev->irq, dev);
539err_out: 540err_out:
540 release_region(ioaddr, NE_IO_EXTENT); 541 release_region(ioaddr, NE_IO_EXTENT);
541 return ret; 542 return ret;
@@ -826,11 +827,8 @@ int init_module(void)
826 dev->mem_end = bad[this_dev]; 827 dev->mem_end = bad[this_dev];
827 dev->base_addr = io[this_dev]; 828 dev->base_addr = io[this_dev];
828 if (do_ne_probe(dev) == 0) { 829 if (do_ne_probe(dev) == 0) {
829 if (register_netdev(dev) == 0) { 830 dev_ne[found++] = dev;
830 dev_ne[found++] = dev; 831 continue;
831 continue;
832 }
833 cleanup_card(dev);
834 } 832 }
835 free_netdev(dev); 833 free_netdev(dev);
836 if (found) 834 if (found)
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index 6ebef27dbfae..6d62ada85de6 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -301,12 +301,7 @@ struct net_device * __init ne2_probe(int unit)
301 err = do_ne2_probe(dev); 301 err = do_ne2_probe(dev);
302 if (err) 302 if (err)
303 goto out; 303 goto out;
304 err = register_netdev(dev);
305 if (err)
306 goto out1;
307 return dev; 304 return dev;
308out1:
309 cleanup_card(dev);
310out: 305out:
311 free_netdev(dev); 306 free_netdev(dev);
312 return ERR_PTR(err); 307 return ERR_PTR(err);
@@ -517,7 +512,14 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
517 dev->poll_controller = ei_poll; 512 dev->poll_controller = ei_poll;
518#endif 513#endif
519 NS8390_init(dev, 0); 514 NS8390_init(dev, 0);
515
516 retval = register_netdev(dev);
517 if (retval)
518 goto out1;
520 return 0; 519 return 0;
520out1:
521 mca_set_adapter_procfn( ei_status.priv, NULL, NULL);
522 free_irq(dev->irq, dev);
521out: 523out:
522 release_region(base_addr, NE_IO_EXTENT); 524 release_region(base_addr, NE_IO_EXTENT);
523 return retval; 525 return retval;
@@ -798,11 +800,8 @@ int init_module(void)
798 dev->mem_end = bad[this_dev]; 800 dev->mem_end = bad[this_dev];
799 dev->base_addr = io[this_dev]; 801 dev->base_addr = io[this_dev];
800 if (do_ne2_probe(dev) == 0) { 802 if (do_ne2_probe(dev) == 0) {
801 if (register_netdev(dev) == 0) { 803 dev_ne[found++] = dev;
802 dev_ne[found++] = dev; 804 continue;
803 continue;
804 }
805 cleanup_card(dev);
806 } 805 }
807 free_netdev(dev); 806 free_netdev(dev);
808 break; 807 break;
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index a1a6c08e7dcf..f1c01ac29102 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -660,6 +660,7 @@ static int ne2k_pci_suspend (struct pci_dev *pdev, pm_message_t state)
660 660
661 netif_device_detach(dev); 661 netif_device_detach(dev);
662 pci_save_state(pdev); 662 pci_save_state(pdev);
663 pci_disable_device(pdev);
663 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 664 pci_set_power_state(pdev, pci_choose_state(pdev, state));
664 665
665 return 0; 666 return 0;
@@ -671,6 +672,8 @@ static int ne2k_pci_resume (struct pci_dev *pdev)
671 672
672 pci_set_power_state(pdev, 0); 673 pci_set_power_state(pdev, 0);
673 pci_restore_state(pdev); 674 pci_restore_state(pdev);
675 pci_enable_device(pdev);
676 pci_set_master(pdev);
674 NS8390_init(dev, 1); 677 NS8390_init(dev, 1);
675 netif_device_attach(dev); 678 netif_device_attach(dev);
676 679
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index c336b46bd332..e64df4d0800b 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -101,6 +101,7 @@
101#include <linux/moduleparam.h> 101#include <linux/moduleparam.h>
102#include <linux/types.h> 102#include <linux/types.h>
103#include <linux/pci.h> 103#include <linux/pci.h>
104#include <linux/dma-mapping.h>
104#include <linux/netdevice.h> 105#include <linux/netdevice.h>
105#include <linux/etherdevice.h> 106#include <linux/etherdevice.h>
106#include <linux/delay.h> 107#include <linux/delay.h>
@@ -573,7 +574,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
573 574
574 dev->rx_info.next_empty = (next_empty + 1) % NR_RX_DESC; 575 dev->rx_info.next_empty = (next_empty + 1) % NR_RX_DESC;
575 cmdsts = REAL_RX_BUF_SIZE | CMDSTS_INTR; 576 cmdsts = REAL_RX_BUF_SIZE | CMDSTS_INTR;
576 buf = pci_map_single(dev->pci_dev, skb->tail, 577 buf = pci_map_single(dev->pci_dev, skb->data,
577 REAL_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); 578 REAL_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
578 build_rx_desc(dev, sg, 0, buf, cmdsts, 0); 579 build_rx_desc(dev, sg, 0, buf, cmdsts, 0);
579 /* update link of previous rx */ 580 /* update link of previous rx */
@@ -603,7 +604,7 @@ static inline int rx_refill(struct net_device *ndev, int gfp)
603 if (unlikely(!skb)) 604 if (unlikely(!skb))
604 break; 605 break;
605 606
606 res = (long)skb->tail & 0xf; 607 res = (long)skb->data & 0xf;
607 res = 0x10 - res; 608 res = 0x10 - res;
608 res &= 0xf; 609 res &= 0xf;
609 skb_reserve(skb, res); 610 skb_reserve(skb, res);
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index 4a391ea0f58a..a1ac4bd1696e 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -486,9 +486,9 @@ struct netdrv_private {
486MODULE_AUTHOR ("Jeff Garzik <jgarzik@pobox.com>"); 486MODULE_AUTHOR ("Jeff Garzik <jgarzik@pobox.com>");
487MODULE_DESCRIPTION ("Skeleton for a PCI Fast Ethernet driver"); 487MODULE_DESCRIPTION ("Skeleton for a PCI Fast Ethernet driver");
488MODULE_LICENSE("GPL"); 488MODULE_LICENSE("GPL");
489MODULE_PARM (multicast_filter_limit, "i"); 489module_param(multicast_filter_limit, int, 0);
490MODULE_PARM (max_interrupt_work, "i"); 490module_param(max_interrupt_work, int, 0);
491MODULE_PARM (media, "1-" __MODULE_STRING(8) "i"); 491module_param_array(media, int, NULL, 0);
492MODULE_PARM_DESC (multicast_filter_limit, "pci-skeleton maximum number of filtered multicast addresses"); 492MODULE_PARM_DESC (multicast_filter_limit, "pci-skeleton maximum number of filtered multicast addresses");
493MODULE_PARM_DESC (max_interrupt_work, "pci-skeleton maximum events handled per interrupt"); 493MODULE_PARM_DESC (max_interrupt_work, "pci-skeleton maximum events handled per interrupt");
494MODULE_PARM_DESC (media, "pci-skeleton: Bits 0-3: media type, bit 17: full duplex"); 494MODULE_PARM_DESC (media, "pci-skeleton: Bits 0-3: media type, bit 17: full duplex");
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index c6e8b25f9685..71fd41122c91 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -86,7 +86,6 @@ earlier 3Com products.
86#include <linux/ethtool.h> 86#include <linux/ethtool.h>
87#include <linux/bitops.h> 87#include <linux/bitops.h>
88 88
89#include <pcmcia/version.h>
90#include <pcmcia/cs_types.h> 89#include <pcmcia/cs_types.h>
91#include <pcmcia/cs.h> 90#include <pcmcia/cs.h>
92#include <pcmcia/cistpl.h> 91#include <pcmcia/cistpl.h>
@@ -312,11 +311,6 @@ static dev_link_t *tc574_attach(void)
312 link->next = dev_list; 311 link->next = dev_list;
313 dev_list = link; 312 dev_list = link;
314 client_reg.dev_info = &dev_info; 313 client_reg.dev_info = &dev_info;
315 client_reg.EventMask =
316 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
317 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
318 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
319 client_reg.event_handler = &tc574_event;
320 client_reg.Version = 0x0210; 314 client_reg.Version = 0x0210;
321 client_reg.event_callback_args.client_data = link; 315 client_reg.event_callback_args.client_data = link;
322 ret = pcmcia_register_client(&link->handle, &client_reg); 316 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1286,13 +1280,22 @@ static int el3_close(struct net_device *dev)
1286 return 0; 1280 return 0;
1287} 1281}
1288 1282
1283static struct pcmcia_device_id tc574_ids[] = {
1284 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0574),
1285 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0556, "3CCFEM556.cis"),
1286 PCMCIA_DEVICE_NULL,
1287};
1288MODULE_DEVICE_TABLE(pcmcia, tc574_ids);
1289
1289static struct pcmcia_driver tc574_driver = { 1290static struct pcmcia_driver tc574_driver = {
1290 .owner = THIS_MODULE, 1291 .owner = THIS_MODULE,
1291 .drv = { 1292 .drv = {
1292 .name = "3c574_cs", 1293 .name = "3c574_cs",
1293 }, 1294 },
1294 .attach = tc574_attach, 1295 .attach = tc574_attach,
1296 .event = tc574_event,
1295 .detach = tc574_detach, 1297 .detach = tc574_detach,
1298 .id_table = tc574_ids,
1296}; 1299};
1297 1300
1298static int __init init_tc574(void) 1301static int __init init_tc574(void)
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 89abdda1d343..d83fdd8c1943 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -40,7 +40,6 @@
40#include <linux/ioport.h> 40#include <linux/ioport.h>
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42 42
43#include <pcmcia/version.h>
44#include <pcmcia/cs_types.h> 43#include <pcmcia/cs_types.h>
45#include <pcmcia/cs.h> 44#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
@@ -226,11 +225,6 @@ static dev_link_t *tc589_attach(void)
226 link->next = dev_list; 225 link->next = dev_list;
227 dev_list = link; 226 dev_list = link;
228 client_reg.dev_info = &dev_info; 227 client_reg.dev_info = &dev_info;
229 client_reg.EventMask =
230 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
231 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
232 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
233 client_reg.event_handler = &tc589_event;
234 client_reg.Version = 0x0210; 228 client_reg.Version = 0x0210;
235 client_reg.event_callback_args.client_data = link; 229 client_reg.event_callback_args.client_data = link;
236 ret = pcmcia_register_client(&link->handle, &client_reg); 230 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1057,13 +1051,26 @@ static int el3_close(struct net_device *dev)
1057 return 0; 1051 return 0;
1058} 1052}
1059 1053
1054static struct pcmcia_device_id tc589_ids[] = {
1055 PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0101, 0x0562),
1056 PCMCIA_MFC_DEVICE_PROD_ID1(0, "Motorola MARQUIS", 0xf03e4e77),
1057 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0589),
1058 PCMCIA_DEVICE_PROD_ID12("Farallon", "ENet", 0x58d93fc4, 0x992c2202),
1059 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0035, "3CXEM556.cis"),
1060 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x003d, "3CXEM556.cis"),
1061 PCMCIA_DEVICE_NULL,
1062};
1063MODULE_DEVICE_TABLE(pcmcia, tc589_ids);
1064
1060static struct pcmcia_driver tc589_driver = { 1065static struct pcmcia_driver tc589_driver = {
1061 .owner = THIS_MODULE, 1066 .owner = THIS_MODULE,
1062 .drv = { 1067 .drv = {
1063 .name = "3c589_cs", 1068 .name = "3c589_cs",
1064 }, 1069 },
1065 .attach = tc589_attach, 1070 .attach = tc589_attach,
1071 .event = tc589_event,
1066 .detach = tc589_detach, 1072 .detach = tc589_detach,
1073 .id_table = tc589_ids,
1067}; 1074};
1068 1075
1069static int __init init_tc589(void) 1076static int __init init_tc589(void)
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 853b586e481a..8bb4e85689ea 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -37,7 +37,6 @@
37#include <linux/netdevice.h> 37#include <linux/netdevice.h>
38#include "../8390.h" 38#include "../8390.h"
39 39
40#include <pcmcia/version.h>
41#include <pcmcia/cs_types.h> 40#include <pcmcia/cs_types.h>
42#include <pcmcia/cs.h> 41#include <pcmcia/cs.h>
43#include <pcmcia/cistpl.h> 42#include <pcmcia/cistpl.h>
@@ -181,11 +180,6 @@ static dev_link_t *axnet_attach(void)
181 link->next = dev_list; 180 link->next = dev_list;
182 dev_list = link; 181 dev_list = link;
183 client_reg.dev_info = &dev_info; 182 client_reg.dev_info = &dev_info;
184 client_reg.EventMask =
185 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
186 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
187 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
188 client_reg.event_handler = &axnet_event;
189 client_reg.Version = 0x0210; 183 client_reg.Version = 0x0210;
190 client_reg.event_callback_args.client_data = link; 184 client_reg.event_callback_args.client_data = link;
191 ret = pcmcia_register_client(&link->handle, &client_reg); 185 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -850,13 +844,43 @@ static void block_output(struct net_device *dev, int count,
850 outsw(nic_base + AXNET_DATAPORT, buf, count>>1); 844 outsw(nic_base + AXNET_DATAPORT, buf, count>>1);
851} 845}
852 846
847static struct pcmcia_device_id axnet_ids[] = {
848 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x016c, 0x0081),
849 PCMCIA_DEVICE_MANF_CARD(0x018a, 0x0301),
850 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0301),
851 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0303),
852 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0309),
853 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1106),
854 PCMCIA_DEVICE_MANF_CARD(0x8a01, 0xc1ab),
855 PCMCIA_DEVICE_PROD_ID124("Fast Ethernet", "16-bit PC Card", "AX88190", 0xb4be14e3, 0x9a12eb6a, 0xab9be5ef),
856 PCMCIA_DEVICE_PROD_ID12("ASIX", "AX88190", 0x0959823b, 0xab9be5ef),
857 PCMCIA_DEVICE_PROD_ID12("Billionton", "LNA-100B", 0x552ab682, 0xbc3b87e1),
858 PCMCIA_DEVICE_PROD_ID12("CHEETAH ETHERCARD", "EN2228", 0x00fa7bc8, 0x00e990cc),
859 PCMCIA_DEVICE_PROD_ID12("CNet", "CNF301", 0xbc477dde, 0x78c5f40b),
860 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEther PCC-TXD", 0x5261440f, 0x436768c5),
861 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEtherII PCC-TXD", 0x5261440f, 0x730df72e),
862 PCMCIA_DEVICE_PROD_ID12("Dynalink", "L100C16", 0x55632fd5, 0x66bc2a90),
863 PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V3)", 0x0733cc81, 0x232019a8),
864 PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC3-TX", 0x481e0094, 0xf91af609),
865 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "100BASE", 0x281f1c5d, 0x7c2add04),
866 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FastEtherCard", 0x281f1c5d, 0x7ef26116),
867 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FEP501", 0x281f1c5d, 0x2e272058),
868 PCMCIA_DEVICE_PROD_ID14("Network Everywhere", "AX88190", 0x820a67b6, 0xab9be5ef),
869 /* this is not specific enough */
870 /* PCMCIA_DEVICE_MANF_CARD(0x021b, 0x0202), */
871 PCMCIA_DEVICE_NULL,
872};
873MODULE_DEVICE_TABLE(pcmcia, axnet_ids);
874
853static struct pcmcia_driver axnet_cs_driver = { 875static struct pcmcia_driver axnet_cs_driver = {
854 .owner = THIS_MODULE, 876 .owner = THIS_MODULE,
855 .drv = { 877 .drv = {
856 .name = "axnet_cs", 878 .name = "axnet_cs",
857 }, 879 },
858 .attach = axnet_attach, 880 .attach = axnet_attach,
881 .event = axnet_event,
859 .detach = axnet_detach, 882 .detach = axnet_detach,
883 .id_table = axnet_ids,
860}; 884};
861 885
862static int __init init_axnet_cs(void) 886static int __init init_axnet_cs(void)
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 4294e1e3f156..b9355d9498a3 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -43,7 +43,6 @@
43#include <linux/arcdevice.h> 43#include <linux/arcdevice.h>
44#include <linux/com20020.h> 44#include <linux/com20020.h>
45 45
46#include <pcmcia/version.h>
47#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
@@ -200,11 +199,6 @@ static dev_link_t *com20020_attach(void)
200 link->next = dev_list; 199 link->next = dev_list;
201 dev_list = link; 200 dev_list = link;
202 client_reg.dev_info = &dev_info; 201 client_reg.dev_info = &dev_info;
203 client_reg.EventMask =
204 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
205 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
206 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
207 client_reg.event_handler = &com20020_event;
208 client_reg.Version = 0x0210; 202 client_reg.Version = 0x0210;
209 client_reg.event_callback_args.client_data = link; 203 client_reg.event_callback_args.client_data = link;
210 ret = pcmcia_register_client(&link->handle, &client_reg); 204 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -483,7 +477,11 @@ static int com20020_event(event_t event, int priority,
483 return 0; 477 return 0;
484} /* com20020_event */ 478} /* com20020_event */
485 479
486 480static struct pcmcia_device_id com20020_ids[] = {
481 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
482 PCMCIA_DEVICE_NULL
483};
484MODULE_DEVICE_TABLE(pcmcia, com20020_ids);
487 485
488static struct pcmcia_driver com20020_cs_driver = { 486static struct pcmcia_driver com20020_cs_driver = {
489 .owner = THIS_MODULE, 487 .owner = THIS_MODULE,
@@ -491,7 +489,9 @@ static struct pcmcia_driver com20020_cs_driver = {
491 .name = "com20020_cs", 489 .name = "com20020_cs",
492 }, 490 },
493 .attach = com20020_attach, 491 .attach = com20020_attach,
492 .event = com20020_event,
494 .detach = com20020_detach, 493 .detach = com20020_detach,
494 .id_table = com20020_ids,
495}; 495};
496 496
497static int __init init_com20020_cs(void) 497static int __init init_com20020_cs(void)
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 0424865e8094..384a736a0d2f 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -49,7 +49,6 @@
49#include <linux/ioport.h> 49#include <linux/ioport.h>
50#include <linux/crc32.h> 50#include <linux/crc32.h>
51 51
52#include <pcmcia/version.h>
53#include <pcmcia/cs_types.h> 52#include <pcmcia/cs_types.h>
54#include <pcmcia/cs.h> 53#include <pcmcia/cs.h>
55#include <pcmcia/cistpl.h> 54#include <pcmcia/cistpl.h>
@@ -135,7 +134,7 @@ typedef struct local_info_t {
135 u_char mc_filter[8]; 134 u_char mc_filter[8];
136} local_info_t; 135} local_info_t;
137 136
138#define MC_FILTERBREAK 64 137#define MC_FILTERBREAK 8
139 138
140/*====================================================================*/ 139/*====================================================================*/
141/* 140/*
@@ -288,11 +287,6 @@ static dev_link_t *fmvj18x_attach(void)
288 link->next = dev_list; 287 link->next = dev_list;
289 dev_list = link; 288 dev_list = link;
290 client_reg.dev_info = &dev_info; 289 client_reg.dev_info = &dev_info;
291 client_reg.EventMask =
292 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
293 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
294 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
295 client_reg.event_handler = &fmvj18x_event;
296 client_reg.Version = 0x0210; 290 client_reg.Version = 0x0210;
297 client_reg.event_callback_args.client_data = link; 291 client_reg.event_callback_args.client_data = link;
298 ret = pcmcia_register_client(&link->handle, &client_reg); 292 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -435,7 +429,9 @@ static void fmvj18x_config(dev_link_t *link)
435 pcmcia_get_status(handle, &status); 429 pcmcia_get_status(handle, &status);
436 if (status.CardState & CS_EVENT_3VCARD) 430 if (status.CardState & CS_EVENT_3VCARD)
437 link->conf.Vcc = 33; /* inserted in 3.3V slot */ 431 link->conf.Vcc = 33; /* inserted in 3.3V slot */
438 } else if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410) { 432 } else if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410
433 || le16_to_cpu(buf[1]) == PRODID_TDK_NP9610
434 || le16_to_cpu(buf[1]) == PRODID_TDK_MN3200) {
439 /* MultiFunction Card */ 435 /* MultiFunction Card */
440 link->conf.ConfigBase = 0x800; 436 link->conf.ConfigBase = 0x800;
441 link->conf.ConfigIndex = 0x47; 437 link->conf.ConfigIndex = 0x47;
@@ -764,13 +760,40 @@ static int fmvj18x_event(event_t event, int priority,
764 return 0; 760 return 0;
765} /* fmvj18x_event */ 761} /* fmvj18x_event */
766 762
763static struct pcmcia_device_id fmvj18x_ids[] = {
764 PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004),
765 PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59),
766 PCMCIA_DEVICE_PROD_ID12("Eiger Labs,Inc", "EPX-10BT PC Card Ethernet 10BT", 0x53af556e, 0x877f9922),
767 PCMCIA_DEVICE_PROD_ID12("Eiger labs,Inc.", "EPX-10BT PC Card Ethernet 10BT", 0xf47e6c66, 0x877f9922),
768 PCMCIA_DEVICE_PROD_ID12("FUJITSU", "LAN Card(FMV-J182)", 0x6ee5a3d8, 0x5baf31db),
769 PCMCIA_DEVICE_PROD_ID12("FUJITSU", "MBH10308", 0x6ee5a3d8, 0x3f04875e),
770 PCMCIA_DEVICE_PROD_ID12("FUJITSU TOWA", "LA501", 0xb8451188, 0x12939ba2),
771 PCMCIA_DEVICE_PROD_ID12("HITACHI", "HT-4840-11", 0xf4f43949, 0x773910f4),
772 PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310B Ver1.0 ", 0x8cef4d3a, 0x075fc7b6),
773 PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310 Ver1.0 ", 0x8cef4d3a, 0xbccf43e6),
774 PCMCIA_DEVICE_PROD_ID12("RATOC System Inc.", "10BASE_T CARD R280", 0x85c10e17, 0xd9413666),
775 PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CD02x", 0x1eae9475, 0x8fa0ee70),
776 PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CF010", 0x1eae9475, 0x7683bc9a),
777 PCMCIA_DEVICE_PROD_ID1("CONTEC Co.,Ltd.", 0x58d8fee2),
778 PCMCIA_DEVICE_PROD_ID1("PCMCIA LAN MBH10304 ES", 0x2599f454),
779 PCMCIA_DEVICE_PROD_ID1("PCMCIA MBH10302", 0x8f4005da),
780 PCMCIA_DEVICE_PROD_ID1("UBKK,V2.0", 0x90888080),
781 PCMCIA_PFC_DEVICE_PROD_ID12(0, "TDK", "GlobalNetworker 3410/3412", 0x1eae9475, 0xd9a93bed),
782 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0d0a),
783 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0e0a),
784 PCMCIA_DEVICE_NULL,
785};
786MODULE_DEVICE_TABLE(pcmcia, fmvj18x_ids);
787
767static struct pcmcia_driver fmvj18x_cs_driver = { 788static struct pcmcia_driver fmvj18x_cs_driver = {
768 .owner = THIS_MODULE, 789 .owner = THIS_MODULE,
769 .drv = { 790 .drv = {
770 .name = "fmvj18x_cs", 791 .name = "fmvj18x_cs",
771 }, 792 },
772 .attach = fmvj18x_attach, 793 .attach = fmvj18x_attach,
794 .event = fmvj18x_event,
773 .detach = fmvj18x_detach, 795 .detach = fmvj18x_detach,
796 .id_table = fmvj18x_ids,
774}; 797};
775 798
776static int __init init_fmvj18x_cs(void) 799static int __init init_fmvj18x_cs(void)
@@ -989,7 +1012,7 @@ static void fjn_reset(struct net_device *dev)
989 outb(BANK_1U, ioaddr + CONFIG_1); 1012 outb(BANK_1U, ioaddr + CONFIG_1);
990 1013
991 /* set the multicast table to accept none. */ 1014 /* set the multicast table to accept none. */
992 for (i = 0; i < 6; i++) 1015 for (i = 0; i < 8; i++)
993 outb(0x00, ioaddr + MAR_ADR + i); 1016 outb(0x00, ioaddr + MAR_ADR + i);
994 1017
995 /* Switch to bank 2 (runtime mode) */ 1018 /* Switch to bank 2 (runtime mode) */
@@ -1246,6 +1269,16 @@ static void set_rx_mode(struct net_device *dev)
1246 u_long flags; 1269 u_long flags;
1247 int i; 1270 int i;
1248 1271
1272 int saved_config_0 = inb(ioaddr + CONFIG_0);
1273
1274 local_irq_save(flags);
1275
1276 /* Disable Tx and Rx */
1277 if (sram_config == 0)
1278 outb(CONFIG0_RST, ioaddr + CONFIG_0);
1279 else
1280 outb(CONFIG0_RST_1, ioaddr + CONFIG_0);
1281
1249 if (dev->flags & IFF_PROMISC) { 1282 if (dev->flags & IFF_PROMISC) {
1250 /* Unconditionally log net taps. */ 1283 /* Unconditionally log net taps. */
1251 printk("%s: Promiscuous mode enabled.\n", dev->name); 1284 printk("%s: Promiscuous mode enabled.\n", dev->name);
@@ -1267,20 +1300,23 @@ static void set_rx_mode(struct net_device *dev)
1267 for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; 1300 for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
1268 i++, mclist = mclist->next) { 1301 i++, mclist = mclist->next) {
1269 unsigned int bit = 1302 unsigned int bit =
1270 ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f; 1303 ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26;
1271 mc_filter[bit >> 3] |= (1 << bit); 1304 mc_filter[bit >> 3] |= (1 << (bit & 7));
1272 } 1305 }
1306 outb(2, ioaddr + RX_MODE); /* Use normal mode. */
1273 } 1307 }
1274 1308
1275 local_irq_save(flags);
1276 if (memcmp(mc_filter, lp->mc_filter, sizeof(mc_filter))) { 1309 if (memcmp(mc_filter, lp->mc_filter, sizeof(mc_filter))) {
1277 int saved_bank = inb(ioaddr + CONFIG_1); 1310 int saved_bank = inb(ioaddr + CONFIG_1);
1278 /* Switch to bank 1 and set the multicast table. */ 1311 /* Switch to bank 1 and set the multicast table. */
1279 outb(0xe4, ioaddr + CONFIG_1); 1312 outb(0xe4, ioaddr + CONFIG_1);
1280 for (i = 0; i < 8; i++) 1313 for (i = 0; i < 8; i++)
1281 outb(mc_filter[i], ioaddr + 8 + i); 1314 outb(mc_filter[i], ioaddr + MAR_ADR + i);
1282 memcpy(lp->mc_filter, mc_filter, sizeof(mc_filter)); 1315 memcpy(lp->mc_filter, mc_filter, sizeof(mc_filter));
1283 outb(saved_bank, ioaddr + CONFIG_1); 1316 outb(saved_bank, ioaddr + CONFIG_1);
1284 } 1317 }
1318
1319 outb(saved_config_0, ioaddr + CONFIG_0);
1320
1285 local_irq_restore(flags); 1321 local_irq_restore(flags);
1286} 1322}
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 3107ccfe8f3d..b6c140eb9799 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -57,7 +57,6 @@
57#include <linux/trdevice.h> 57#include <linux/trdevice.h>
58#include <linux/ibmtr.h> 58#include <linux/ibmtr.h>
59 59
60#include <pcmcia/version.h>
61#include <pcmcia/cs_types.h> 60#include <pcmcia/cs_types.h>
62#include <pcmcia/cs.h> 61#include <pcmcia/cs.h>
63#include <pcmcia/cistpl.h> 62#include <pcmcia/cistpl.h>
@@ -119,9 +118,6 @@ static void ibmtr_detach(dev_link_t *);
119 118
120static dev_link_t *dev_list; 119static dev_link_t *dev_list;
121 120
122extern int ibmtr_probe_card(struct net_device *dev);
123extern irqreturn_t tok_interrupt (int irq, void *dev_id, struct pt_regs *regs);
124
125/*====================================================================*/ 121/*====================================================================*/
126 122
127typedef struct ibmtr_dev_t { 123typedef struct ibmtr_dev_t {
@@ -193,11 +189,6 @@ static dev_link_t *ibmtr_attach(void)
193 link->next = dev_list; 189 link->next = dev_list;
194 dev_list = link; 190 dev_list = link;
195 client_reg.dev_info = &dev_info; 191 client_reg.dev_info = &dev_info;
196 client_reg.EventMask =
197 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
198 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
199 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
200 client_reg.event_handler = &ibmtr_event;
201 client_reg.Version = 0x0210; 192 client_reg.Version = 0x0210;
202 client_reg.event_callback_args.client_data = link; 193 client_reg.event_callback_args.client_data = link;
203 ret = pcmcia_register_client(&link->handle, &client_reg); 194 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -511,13 +502,22 @@ static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase)
511 return; 502 return;
512} 503}
513 504
505static struct pcmcia_device_id ibmtr_ids[] = {
506 PCMCIA_DEVICE_PROD_ID12("3Com", "TokenLink Velocity PC Card", 0x41240e5b, 0x82c3734e),
507 PCMCIA_DEVICE_PROD_ID12("IBM", "TOKEN RING", 0xb569a6e5, 0xbf8eed47),
508 PCMCIA_DEVICE_NULL,
509};
510MODULE_DEVICE_TABLE(pcmcia, ibmtr_ids);
511
514static struct pcmcia_driver ibmtr_cs_driver = { 512static struct pcmcia_driver ibmtr_cs_driver = {
515 .owner = THIS_MODULE, 513 .owner = THIS_MODULE,
516 .drv = { 514 .drv = {
517 .name = "ibmtr_cs", 515 .name = "ibmtr_cs",
518 }, 516 },
519 .attach = ibmtr_attach, 517 .attach = ibmtr_attach,
518 .event = ibmtr_event,
520 .detach = ibmtr_detach, 519 .detach = ibmtr_detach,
520 .id_table = ibmtr_ids,
521}; 521};
522 522
523static int __init init_ibmtr_cs(void) 523static int __init init_ibmtr_cs(void)
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 4603807fcafb..980d7e5d66cb 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -146,7 +146,6 @@ Include Files
146#include <linux/ioport.h> 146#include <linux/ioport.h>
147#include <linux/bitops.h> 147#include <linux/bitops.h>
148 148
149#include <pcmcia/version.h>
150#include <pcmcia/cs_types.h> 149#include <pcmcia/cs_types.h>
151#include <pcmcia/cs.h> 150#include <pcmcia/cs.h>
152#include <pcmcia/cisreg.h> 151#include <pcmcia/cisreg.h>
@@ -502,11 +501,6 @@ static dev_link_t *nmclan_attach(void)
502 link->next = dev_list; 501 link->next = dev_list;
503 dev_list = link; 502 dev_list = link;
504 client_reg.dev_info = &dev_info; 503 client_reg.dev_info = &dev_info;
505 client_reg.EventMask =
506 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
507 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
508 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
509 client_reg.event_handler = &nmclan_event;
510 client_reg.Version = 0x0210; 504 client_reg.Version = 0x0210;
511 client_reg.event_callback_args.client_data = link; 505 client_reg.event_callback_args.client_data = link;
512 ret = pcmcia_register_client(&link->handle, &client_reg); 506 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1675,13 +1669,22 @@ static void set_multicast_list(struct net_device *dev)
1675 1669
1676} /* set_multicast_list */ 1670} /* set_multicast_list */
1677 1671
1672static struct pcmcia_device_id nmclan_ids[] = {
1673 PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "Ethernet", 0x085a850b, 0x00b2e941),
1674 PCMCIA_DEVICE_PROD_ID12("Portable Add-ons", "Ethernet+", 0xebf1d60, 0xad673aaf),
1675 PCMCIA_DEVICE_NULL,
1676};
1677MODULE_DEVICE_TABLE(pcmcia, nmclan_ids);
1678
1678static struct pcmcia_driver nmclan_cs_driver = { 1679static struct pcmcia_driver nmclan_cs_driver = {
1679 .owner = THIS_MODULE, 1680 .owner = THIS_MODULE,
1680 .drv = { 1681 .drv = {
1681 .name = "nmclan_cs", 1682 .name = "nmclan_cs",
1682 }, 1683 },
1683 .attach = nmclan_attach, 1684 .attach = nmclan_attach,
1685 .event = nmclan_event,
1684 .detach = nmclan_detach, 1686 .detach = nmclan_detach,
1687 .id_table = nmclan_ids,
1685}; 1688};
1686 1689
1687static int __init init_nmclan_cs(void) 1690static int __init init_nmclan_cs(void)
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 181b6ed55003..9f22d138e3ad 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -40,7 +40,6 @@
40#include <linux/netdevice.h> 40#include <linux/netdevice.h>
41#include <../drivers/net/8390.h> 41#include <../drivers/net/8390.h>
42 42
43#include <pcmcia/version.h>
44#include <pcmcia/cs_types.h> 43#include <pcmcia/cs_types.h>
45#include <pcmcia/cs.h> 44#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
@@ -276,11 +275,6 @@ static dev_link_t *pcnet_attach(void)
276 link->next = dev_list; 275 link->next = dev_list;
277 dev_list = link; 276 dev_list = link;
278 client_reg.dev_info = &dev_info; 277 client_reg.dev_info = &dev_info;
279 client_reg.EventMask =
280 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
281 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
282 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
283 client_reg.event_handler = &pcnet_event;
284 client_reg.Version = 0x0210; 278 client_reg.Version = 0x0210;
285 client_reg.event_callback_args.client_data = link; 279 client_reg.event_callback_args.client_data = link;
286 ret = pcmcia_register_client(&link->handle, &client_reg); 280 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1155,11 +1149,13 @@ static int set_config(struct net_device *dev, struct ifmap *map)
1155static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs) 1149static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs)
1156{ 1150{
1157 struct net_device *dev = dev_id; 1151 struct net_device *dev = dev_id;
1158 pcnet_dev_t *info = PRIV(dev); 1152 pcnet_dev_t *info;
1159 irqreturn_t ret = ei_interrupt(irq, dev_id, regs); 1153 irqreturn_t ret = ei_interrupt(irq, dev_id, regs);
1160 1154
1161 if (ret == IRQ_HANDLED) 1155 if (ret == IRQ_HANDLED) {
1156 info = PRIV(dev);
1162 info->stale = 0; 1157 info->stale = 0;
1158 }
1163 return ret; 1159 return ret;
1164} 1160}
1165 1161
@@ -1350,7 +1346,7 @@ static void dma_block_input(struct net_device *dev, int count,
1350 if (count & 0x01) 1346 if (count & 0x01)
1351 buf[count-1] = inb(nic_base + PCNET_DATAPORT), xfer_count++; 1347 buf[count-1] = inb(nic_base + PCNET_DATAPORT), xfer_count++;
1352 1348
1353 /* This was for the ALPHA version only, but enough people have 1349 /* This was for the ALPHA version only, but enough people have been
1354 encountering problems that it is still here. */ 1350 encountering problems that it is still here. */
1355#ifdef PCMCIA_DEBUG 1351#ifdef PCMCIA_DEBUG
1356 if (ei_debug > 4) { /* DMA termination address check... */ 1352 if (ei_debug > 4) { /* DMA termination address check... */
@@ -1424,7 +1420,7 @@ static void dma_block_output(struct net_device *dev, int count,
1424 dma_start = jiffies; 1420 dma_start = jiffies;
1425 1421
1426#ifdef PCMCIA_DEBUG 1422#ifdef PCMCIA_DEBUG
1427 /* This was for the ALPHA version only, but enough people have 1423 /* This was for the ALPHA version only, but enough people have been
1428 encountering problems that it is still here. */ 1424 encountering problems that it is still here. */
1429 if (ei_debug > 4) { /* DMA termination address check... */ 1425 if (ei_debug > 4) { /* DMA termination address check... */
1430 int addr, tries = 20; 1426 int addr, tries = 20;
@@ -1635,13 +1631,218 @@ failed:
1635 1631
1636/*====================================================================*/ 1632/*====================================================================*/
1637 1633
1634static struct pcmcia_device_id pcnet_ids[] = {
1635 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0057, 0x0021),
1636 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0104, 0x000a),
1637 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0xea15),
1638 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0143, 0x3341),
1639 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0143, 0xc0ab),
1640 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x021b, 0x0101),
1641 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x08a1, 0xc0ab),
1642 PCMCIA_PFC_DEVICE_PROD_ID12(0, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4),
1643 PCMCIA_PFC_DEVICE_PROD_ID12(0, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff),
1644 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae),
1645 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Linksys", "EtherFast 10&100 + 56K PC Card (PCMLM56)", 0x0733cc81, 0xb3765033),
1646 PCMCIA_PFC_DEVICE_PROD_ID12(0, "LINKSYS", "PCMLM336", 0xf7cb0b07, 0x7a821b58),
1647 PCMCIA_PFC_DEVICE_PROD_ID12(0, "PCMCIAs", "ComboCard", 0xdcfe12d3, 0xcd8906cc),
1648 PCMCIA_PFC_DEVICE_PROD_ID12(0, "PCMCIAs", "LanModem", 0xdcfe12d3, 0xc67c648f),
1649 PCMCIA_MFC_DEVICE_PROD_ID12(0, "IBM", "Home and Away 28.8 PC Card ", 0xb569a6e5, 0x5bd4ff2c),
1650 PCMCIA_MFC_DEVICE_PROD_ID12(0, "IBM", "Home and Away Credit Card Adapter", 0xb569a6e5, 0x4bdf15c3),
1651 PCMCIA_MFC_DEVICE_PROD_ID12(0, "IBM", "w95 Home and Away Credit Card ", 0xb569a6e5, 0xae911c15),
1652 PCMCIA_MFC_DEVICE_PROD_ID123(0, "APEX DATA", "MULTICARD", "ETHERNET-MODEM", 0x11c2da09, 0x7289dc5d, 0xaad95e1f),
1653 PCMCIA_MFC_DEVICE_PROD_ID2(0, "FAX/Modem/Ethernet Combo Card ", 0x1ed59302),
1654 PCMCIA_DEVICE_MANF_CARD(0x0057, 0x1004),
1655 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x000d),
1656 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0075),
1657 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0145),
1658 PCMCIA_DEVICE_MANF_CARD(0x0149, 0x0230),
1659 PCMCIA_DEVICE_MANF_CARD(0x0149, 0x4530),
1660/* PCMCIA_DEVICE_MANF_CARD(0x0149, 0xc1ab), conflict with axnet_cs */
1661 PCMCIA_DEVICE_MANF_CARD(0x0186, 0x0110),
1662 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x2328),
1663 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x8041),
1664 PCMCIA_DEVICE_MANF_CARD(0x0213, 0x2452),
1665/* PCMCIA_DEVICE_MANF_CARD(0x021b, 0x0202), conflict with axnet_cs */
1666 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0300),
1667 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0307),
1668 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030a),
1669 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1103),
1670 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1121),
1671 PCMCIA_DEVICE_PROD_ID12("2408LAN", "Ethernet", 0x352fff7f, 0x00b2e941),
1672 PCMCIA_DEVICE_PROD_ID123("Cardwell", "PCMCIA", "ETHERNET", 0x9533672e, 0x281f1c5d, 0x3ff7175b),
1673 PCMCIA_DEVICE_PROD_ID123("CNet ", "CN30BC", "ETHERNET", 0x9fe55d3d, 0x85601198, 0x3ff7175b),
1674 PCMCIA_DEVICE_PROD_ID123("Digital", "Ethernet", "Adapter", 0x9999ab35, 0x00b2e941, 0x4b0d829e),
1675 PCMCIA_DEVICE_PROD_ID123("Edimax Technology Inc.", "PCMCIA", "Ethernet Card", 0x738a0019, 0x281f1c5d, 0x5e9d92c0),
1676 PCMCIA_DEVICE_PROD_ID123("EFA ", "EFA207", "ETHERNET", 0x3d294be4, 0xeb9aab6c, 0x3ff7175b),
1677 PCMCIA_DEVICE_PROD_ID123("I-O DATA", "PCLA", "ETHERNET", 0x1d55d7ec, 0xe4c64d34, 0x3ff7175b),
1678 PCMCIA_DEVICE_PROD_ID123("IO DATA", "PCLATE", "ETHERNET", 0x547e66dc, 0x6b260753, 0x3ff7175b),
1679 PCMCIA_DEVICE_PROD_ID123("KingMax Technology Inc.", "EN10-T2", "PCMCIA Ethernet Card", 0x932b7189, 0x699e4436, 0x6f6652e0),
1680 PCMCIA_DEVICE_PROD_ID123("PCMCIA", "PCMCIA-ETHERNET-CARD", "UE2216", 0x281f1c5d, 0xd4cd2f20, 0xb87add82),
1681 PCMCIA_DEVICE_PROD_ID123("PCMCIA", "PCMCIA-ETHERNET-CARD", "UE2620", 0x281f1c5d, 0xd4cd2f20, 0x7d3d83a8),
1682 PCMCIA_DEVICE_PROD_ID1("2412LAN", 0x67f236ab),
1683 PCMCIA_DEVICE_PROD_ID12("ACCTON", "EN2212", 0xdfc6b5b2, 0xcb112a11),
1684 PCMCIA_DEVICE_PROD_ID12("ACCTON", "EN2216-PCMCIA-ETHERNET", 0xdfc6b5b2, 0x5542bfff),
1685 PCMCIA_DEVICE_PROD_ID12("Allied Telesis, K.K.", "CentreCOM LA100-PCM-T V2 100/10M LAN PC Card", 0xbb7fbdd7, 0xcd91cc68),
1686 PCMCIA_DEVICE_PROD_ID12("Allied Telesis K.K.", "LA100-PCM V2", 0x36634a66, 0xc6d05997),
1687 PCMCIA_DEVICE_PROD_ID12("Allied Telesis, K.K.", "CentreCOM LA-PCM_V2", 0xbb7fBdd7, 0x28e299f8),
1688 PCMCIA_DEVICE_PROD_ID12("Allied Telesis K.K.", "LA-PCM V3", 0x36634a66, 0x62241d96),
1689 PCMCIA_DEVICE_PROD_ID12("AmbiCom", "AMB8010", 0x5070a7f9, 0x82f96e96),
1690 PCMCIA_DEVICE_PROD_ID12("AmbiCom", "AMB8610", 0x5070a7f9, 0x86741224),
1691 PCMCIA_DEVICE_PROD_ID12("AmbiCom Inc", "AMB8002", 0x93b15570, 0x75ec3efb),
1692 PCMCIA_DEVICE_PROD_ID12("AmbiCom Inc", "AMB8002T", 0x93b15570, 0x461c5247),
1693 PCMCIA_DEVICE_PROD_ID12("AmbiCom Inc", "AMB8010", 0x93b15570, 0x82f96e96),
1694 PCMCIA_DEVICE_PROD_ID12("AnyCom", "ECO Ethernet", 0x578ba6e7, 0x0a9888c1),
1695 PCMCIA_DEVICE_PROD_ID12("AnyCom", "ECO Ethernet 10/100", 0x578ba6e7, 0x939fedbd),
1696 PCMCIA_DEVICE_PROD_ID12("AROWANA", "PCMCIA Ethernet LAN Card", 0x313adbc8, 0x08d9f190),
1697 PCMCIA_DEVICE_PROD_ID12("ASANTE", "FriendlyNet PC Card", 0x3a7ade0f, 0x41c64504),
1698 PCMCIA_DEVICE_PROD_ID12("Billionton", "LNT-10TB", 0x552ab682, 0xeeb1ba6a),
1699 PCMCIA_DEVICE_PROD_ID12("CF", "10Base-Ethernet", 0x44ebf863, 0x93ae4d79),
1700 PCMCIA_DEVICE_PROD_ID12("CNet", "CN40BC Ethernet", 0xbc477dde, 0xfba775a7),
1701 PCMCIA_DEVICE_PROD_ID12("COMPU-SHACK", "BASEline PCMCIA 10 MBit Ethernetadapter", 0xfa2e424d, 0xe9190d8a),
1702 PCMCIA_DEVICE_PROD_ID12("COMPU-SHACK", "FASTline PCMCIA 10/100 Fast-Ethernet", 0xfa2e424d, 0x3953d9b9),
1703 PCMCIA_DEVICE_PROD_ID12("CONTEC", "C-NET(PC)C-10L", 0x21cab552, 0xf6f90722),
1704 PCMCIA_DEVICE_PROD_ID12("corega", "FEther PCC-TXF", 0x0a21501a, 0xa51564a2),
1705 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-T", 0x5261440f, 0xfa9d85bd),
1706 PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d),
1707 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega Ether PCC-T", 0x5261440f, 0x6705fcaa),
1708 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FastEther PCC-TX", 0x5261440f, 0x485e85d9),
1709 PCMCIA_DEVICE_PROD_ID12("Corega,K.K.", "Ethernet LAN Card", 0x110d26d9, 0x9fd2f0a2),
1710 PCMCIA_DEVICE_PROD_ID12("corega,K.K.", "Ethernet LAN Card", 0x9791a90e, 0x9fd2f0a2),
1711 PCMCIA_DEVICE_PROD_ID12("CouplerlessPCMCIA", "100BASE", 0xee5af0ad, 0x7c2add04),
1712 PCMCIA_DEVICE_PROD_ID12("CyQ've", "ELA-010", 0x77008979, 0x9d8d445d),
1713 PCMCIA_DEVICE_PROD_ID12("CyQ've", "ELA-110E 10/100M LAN Card", 0x77008979, 0xfd184814),
1714 PCMCIA_DEVICE_PROD_ID12("DataTrek.", "NetCard ", 0x5cd66d9d, 0x84697ce0),
1715 PCMCIA_DEVICE_PROD_ID12("Dayna Communications, Inc.", "CommuniCard E", 0x0c629325, 0xb4e7dbaf),
1716 PCMCIA_DEVICE_PROD_ID12("Digicom", "Palladio LAN 10/100", 0x697403d8, 0xe160b995),
1717 PCMCIA_DEVICE_PROD_ID12("Digicom", "Palladio LAN 10/100 Dongless", 0x697403d8, 0xa6d3b233),
1718 PCMCIA_DEVICE_PROD_ID12("DIGITAL", "DEPCM-XX", 0x69616cb3, 0xe600e76e),
1719 PCMCIA_DEVICE_PROD_ID12("D-Link", "DE-650", 0x1a424a1c, 0xf28c8398),
1720 PCMCIA_DEVICE_PROD_ID12("D-Link", "DE-660", 0x1a424a1c, 0xd9a1d05b),
1721 PCMCIA_DEVICE_PROD_ID12("D-Link", "DE-660+", 0x1a424a1c, 0x50dcd0ec),
1722 PCMCIA_DEVICE_PROD_ID12("D-Link", "DFE-650", 0x1a424a1c, 0x0f0073f9),
1723 PCMCIA_DEVICE_PROD_ID12("Dual Speed", "10/100 PC Card", 0x725b842d, 0xf1efee84),
1724 PCMCIA_DEVICE_PROD_ID12("Dual Speed", "10/100 Port Attached PC Card", 0x725b842d, 0x2db1f8e9),
1725 PCMCIA_DEVICE_PROD_ID12("Dynalink", "L10BC", 0x55632fd5, 0xdc65f2b1),
1726 PCMCIA_DEVICE_PROD_ID12("DYNALINK", "L10BC", 0x6a26d1cf, 0xdc65f2b1),
1727 PCMCIA_DEVICE_PROD_ID12("DYNALINK", "L10C", 0x6a26d1cf, 0xc4f84efb),
1728 PCMCIA_DEVICE_PROD_ID12("E-CARD", "E-CARD", 0x6701da11, 0x6701da11),
1729 PCMCIA_DEVICE_PROD_ID12("EIGER Labs Inc.", "Ethernet 10BaseT card", 0x53c864c6, 0xedd059f6),
1730 PCMCIA_DEVICE_PROD_ID12("EIGER Labs Inc.", "Ethernet Combo card", 0x53c864c6, 0x929c486c),
1731 PCMCIA_DEVICE_PROD_ID12("Ethernet", "Adapter", 0x00b2e941, 0x4b0d829e),
1732 PCMCIA_DEVICE_PROD_ID12("Ethernet Adapter", "E2000 PCMCIA Ethernet", 0x96767301, 0x71fbbc61),
1733 PCMCIA_DEVICE_PROD_ID12("Ethernet PCMCIA adapter", "EP-210", 0x8dd86181, 0xf2b52517),
1734 PCMCIA_DEVICE_PROD_ID12("Fast Ethernet", "Adapter", 0xb4be14e3, 0x4b0d829e),
1735 PCMCIA_DEVICE_PROD_ID12("Grey Cell", "GCS2000", 0x2a151fac, 0xf00555cb),
1736 PCMCIA_DEVICE_PROD_ID12("Grey Cell", "GCS2220", 0x2a151fac, 0xc1b7e327),
1737 PCMCIA_DEVICE_PROD_ID12("GVC", "NIC-2000p", 0x76e171bd, 0x6eb1c947),
1738 PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "Ethernet", 0xe3736c88, 0x00b2e941),
1739 PCMCIA_DEVICE_PROD_ID12("IC-CARD", "IC-CARD", 0x60cb09a6, 0x60cb09a6),
1740 PCMCIA_DEVICE_PROD_ID12("IC-CARD+", "IC-CARD+", 0x93693494, 0x93693494),
1741 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCETTX", 0x547e66dc, 0x6fc5459b),
1742 PCMCIA_DEVICE_PROD_ID12("iPort", "10/100 Ethernet Card", 0x56c538d2, 0x11b0ffc0),
1743 PCMCIA_DEVICE_PROD_ID12("KANSAI ELECTRIC CO.,LTD", "KLA-PCM/T", 0xb18dc3b4, 0xcc51a956),
1744 PCMCIA_DEVICE_PROD_ID12("KCI", "PE520 PCMCIA Ethernet Adapter", 0xa89b87d3, 0x1eb88e64),
1745 PCMCIA_DEVICE_PROD_ID12("KINGMAX", "EN10T2T", 0x7bcb459a, 0xa5c81fa5),
1746 PCMCIA_DEVICE_PROD_ID12("Kingston", "KNE-PC2", 0x1128e633, 0xce2a89b3),
1747 PCMCIA_DEVICE_PROD_ID12("Kingston Technology Corp.", "EtheRx PC Card Ethernet Adapter", 0x313c7be3, 0x0afb54a2),
1748 PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-10/100CD", 0x1b7827b2, 0xcda71d1c),
1749 PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDF", 0x1b7827b2, 0xfec71e40),
1750 PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDL/T", 0x1b7827b2, 0x79fba4f7),
1751 PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDS", 0x1b7827b2, 0x931afaab),
1752 PCMCIA_DEVICE_PROD_ID12("Linksys", "Combo PCMCIA EthernetCard (EC2T)", 0x0733cc81, 0x32ee8c78),
1753 PCMCIA_DEVICE_PROD_ID12("LINKSYS", "E-CARD", 0xf7cb0b07, 0x6701da11),
1754 PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 Integrated PC Card (PCM100)", 0x0733cc81, 0x453c3f9d),
1755 PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100)", 0x0733cc81, 0x66c5a389),
1756 PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V2)", 0x0733cc81, 0x3a3b28e9),
1757 PCMCIA_DEVICE_PROD_ID12("Linksys", "HomeLink Phoneline + 10/100 Network PC Card (PCM100H1)", 0x733cc81, 0x7a3e5c3a),
1758 PCMCIA_DEVICE_PROD_ID12("Logitec", "LPM-LN100TX", 0x88fcdeda, 0x6d772737),
1759 PCMCIA_DEVICE_PROD_ID12("Logitec", "LPM-LN20T", 0x88fcdeda, 0x81090922),
1760 PCMCIA_DEVICE_PROD_ID12("LONGSHINE", "PCMCIA Ethernet Card", 0xf866b0b0, 0x6f6652e0),
1761 PCMCIA_DEVICE_PROD_ID12("MACNICA", "ME1-JEIDA", 0x20841b68, 0xaf8a3578),
1762 PCMCIA_DEVICE_PROD_ID12("Macsense", "MPC-10", 0xd830297f, 0xd265c307),
1763 PCMCIA_DEVICE_PROD_ID12("Matsushita Electric Industrial Co.,LTD.", "CF-VEL211", 0x44445376, 0x8ded41d4),
1764 PCMCIA_DEVICE_PROD_ID12("MAXTECH", "PCN2000", 0x78d64bc0, 0xca0ca4b8),
1765 PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC2-T", 0x481e0094, 0xa2eb0cf3),
1766 PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC2-TX", 0x481e0094, 0x41a6916c),
1767 PCMCIA_DEVICE_PROD_ID12("Microcom C.E.", "Travel Card LAN 10/100", 0x4b91cec7, 0xe70220d6),
1768 PCMCIA_DEVICE_PROD_ID12("Microdyne", "NE4200", 0x2e6da59b, 0x0478e472),
1769 PCMCIA_DEVICE_PROD_ID12("MIDORI ELEC.", "LT-PCMT", 0x648d55c1, 0xbde526c7),
1770 PCMCIA_DEVICE_PROD_ID12("National Semiconductor", "InfoMover 4100", 0x36e1191f, 0x60c229b9),
1771 PCMCIA_DEVICE_PROD_ID12("National Semiconductor", "InfoMover NE4100", 0x36e1191f, 0xa6617ec8),
1772 PCMCIA_DEVICE_PROD_ID12("NEC", "PC-9801N-J12", 0x18df0ba0, 0xbc912d76),
1773 PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA410TX", 0x9aa79dc3, 0x60e5bc0e),
1774 PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA411", 0x9aa79dc3, 0x40fad875),
1775 PCMCIA_DEVICE_PROD_ID12("Network Everywhere", "Fast Ethernet 10/100 PC Card", 0x820a67b6, 0x31ed1a5f),
1776 PCMCIA_DEVICE_PROD_ID12("NextCom K.K.", "Next Hawk", 0xaedaec74, 0xad050ef1),
1777 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100Mbps Ethernet Card", 0x281f1c5d, 0x6e41773b),
1778 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet", 0x281f1c5d, 0x00b2e941),
1779 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "ETHERNET", 0x281f1c5d, 0x3ff7175b),
1780 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet 10BaseT Card", 0x281f1c5d, 0x4de2f6c8),
1781 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet Card", 0x281f1c5d, 0x5e9d92c0),
1782 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet Combo card", 0x281f1c5d, 0x929c486c),
1783 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "ETHERNET V1.0", 0x281f1c5d, 0x4d8817c8),
1784 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FastEthernet", 0x281f1c5d, 0xfe871eeb),
1785 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Fast-Ethernet", 0x281f1c5d, 0x45f1f3b4),
1786 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FAST ETHERNET CARD", 0x281f1c5d, 0xec5dbca7),
1787 PCMCIA_DEVICE_PROD_ID12("PCMCIA LAN", "Ethernet", 0x7500e246, 0x00b2e941),
1788 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "LNT-10TN", 0x281f1c5d, 0xe707f641),
1789 PCMCIA_DEVICE_PROD_ID12("PCMCIAs", "ComboCard", 0xdcfe12d3, 0xcd8906cc),
1790 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "UE2212", 0x281f1c5d, 0xbf17199b),
1791 PCMCIA_DEVICE_PROD_ID12("PCMCIA", " Ethernet NE2000 Compatible", 0x281f1c5d, 0x42d5d7e1),
1792 PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10baseT 3.3V", 0xebf91155, 0x30074c80),
1793 PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10BaseT 3.3V", 0xebf91155, 0x7f5a4f50),
1794 PCMCIA_DEVICE_PROD_ID12("Psion Dacom", "Gold Card Ethernet", 0xf5f025c2, 0x3a30e110),
1795 PCMCIA_DEVICE_PROD_ID12("=RELIA==", "Ethernet", 0xcdd0644a, 0x00b2e941),
1796 PCMCIA_DEVICE_PROD_ID12("RP", "1625B Ethernet NE2000 Compatible", 0xe3e66e22, 0xb96150df),
1797 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP400 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4a7e2ae0),
1798 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP401 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4bcbd7fd),
1799 PCMCIA_DEVICE_PROD_ID12("RPTI LTD.", "EP400", 0xc53ac515, 0x81e39388),
1800 PCMCIA_DEVICE_PROD_ID12("SCM", "Ethernet Combo card", 0xbdc3b102, 0x929c486c),
1801 PCMCIA_DEVICE_PROD_ID12("Seiko Epson Corp.", "Ethernet", 0x09928730, 0x00b2e941),
1802 PCMCIA_DEVICE_PROD_ID12("SMC", "EZCard-10-PCMCIA", 0xc4f8b18b, 0xfb21d265),
1803 PCMCIA_DEVICE_PROD_ID12("Socket Communications Inc", "Socket EA PCMCIA LAN Adapter Revision D", 0xc70a4760, 0x2ade483e),
1804 PCMCIA_DEVICE_PROD_ID12("Socket Communications Inc", "Socket EA PCMCIA LAN Adapter Revision E", 0xc70a4760, 0x5dd978a8),
1805 PCMCIA_DEVICE_PROD_ID12("TDK", "LAK-CD031 for PCMCIA", 0x1eae9475, 0x0ed386fa),
1806 PCMCIA_DEVICE_PROD_ID12("Telecom Device K.K.", "SuperSocket RE450T", 0x466b05f0, 0x8b74bc4f),
1807 PCMCIA_DEVICE_PROD_ID12("Telecom Device K.K.", "SuperSocket RE550T", 0x466b05f0, 0x33c8db2a),
1808 PCMCIA_DEVICE_PROD_ID13("Hypertec", "EP401", 0x8787bec7, 0xf6e4a31e),
1809 PCMCIA_DEVICE_PROD_ID13("KingMax Technology Inc.", "Ethernet Card", 0x932b7189, 0x5e9d92c0),
1810 PCMCIA_DEVICE_PROD_ID13("LONGSHINE", "EP401", 0xf866b0b0, 0xf6e4a31e),
1811 PCMCIA_DEVICE_PROD_ID13("Xircom", "CFE-10", 0x2e3ee845, 0x22a49f89),
1812 PCMCIA_DEVICE_PROD_ID1("CyQ've 10 Base-T LAN CARD", 0x94faf360),
1813 PCMCIA_DEVICE_PROD_ID1("EP-210 PCMCIA LAN CARD.", 0x8850b4de),
1814 PCMCIA_DEVICE_PROD_ID1("ETHER-C16", 0x06a8514f),
1815 PCMCIA_DEVICE_PROD_ID1("IC-CARD", 0x60cb09a6),
1816 PCMCIA_DEVICE_PROD_ID1("NE2000 Compatible", 0x75b8ad5a),
1817 PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078),
1818 /* too generic! */
1819 /* PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100 Ethernet Card", 0x281f1c5d, 0x11b0ffc0), */
1820 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"),
1821 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"),
1822 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"),
1823 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"),
1824 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"),
1825 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"),
1826 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"),
1827 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "DP83903.cis"),
1828 PCMCIA_DEVICE_CIS_MANF_CARD(0xc00f, 0x0002, "LA-PCM.cis"),
1829 PCMCIA_DEVICE_CIS_PROD_ID12("KTI", "PE520 PLUS", 0xad180345, 0x9d58d392, "PE520.cis"),
1830 PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "NE2K.cis"),
1831 PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "PE-200.cis"),
1832 PCMCIA_DEVICE_CIS_PROD_ID12("TAMARACK", "Ethernet", 0xcf434fba, 0x00b2e941, "tamarack.cis"),
1833 PCMCIA_DEVICE_NULL
1834};
1835MODULE_DEVICE_TABLE(pcmcia, pcnet_ids);
1836
1638static struct pcmcia_driver pcnet_driver = { 1837static struct pcmcia_driver pcnet_driver = {
1639 .drv = { 1838 .drv = {
1640 .name = "pcnet_cs", 1839 .name = "pcnet_cs",
1641 }, 1840 },
1642 .attach = pcnet_attach, 1841 .attach = pcnet_attach,
1842 .event = pcnet_event,
1643 .detach = pcnet_detach, 1843 .detach = pcnet_detach,
1644 .owner = THIS_MODULE, 1844 .owner = THIS_MODULE,
1845 .id_table = pcnet_ids,
1645}; 1846};
1646 1847
1647static int __init init_pcnet_cs(void) 1848static int __init init_pcnet_cs(void)
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 85a152173148..d652e1eddb45 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -41,8 +41,8 @@
41#include <linux/ioport.h> 41#include <linux/ioport.h>
42#include <linux/ethtool.h> 42#include <linux/ethtool.h>
43#include <linux/mii.h> 43#include <linux/mii.h>
44#include <linux/jiffies.h>
44 45
45#include <pcmcia/version.h>
46#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
47#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
48#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
@@ -127,6 +127,12 @@ struct smc_private {
127 int rx_ovrn; 127 int rx_ovrn;
128}; 128};
129 129
130struct smc_cfg_mem {
131 tuple_t tuple;
132 cisparse_t parse;
133 u_char buf[255];
134};
135
130/* Special definitions for Megahertz multifunction cards */ 136/* Special definitions for Megahertz multifunction cards */
131#define MEGAHERTZ_ISR 0x0380 137#define MEGAHERTZ_ISR 0x0380
132 138
@@ -364,10 +370,6 @@ static dev_link_t *smc91c92_attach(void)
364 link->next = dev_list; 370 link->next = dev_list;
365 dev_list = link; 371 dev_list = link;
366 client_reg.dev_info = &dev_info; 372 client_reg.dev_info = &dev_info;
367 client_reg.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
368 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
369 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
370 client_reg.event_handler = &smc91c92_event;
371 client_reg.Version = 0x0210; 373 client_reg.Version = 0x0210;
372 client_reg.event_callback_args.client_data = link; 374 client_reg.event_callback_args.client_data = link;
373 ret = pcmcia_register_client(&link->handle, &client_reg); 375 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -498,14 +500,24 @@ static int mhz_mfc_config(dev_link_t *link)
498{ 500{
499 struct net_device *dev = link->priv; 501 struct net_device *dev = link->priv;
500 struct smc_private *smc = netdev_priv(dev); 502 struct smc_private *smc = netdev_priv(dev);
501 tuple_t tuple; 503 struct smc_cfg_mem *cfg_mem;
502 cisparse_t parse; 504 tuple_t *tuple;
503 u_char buf[255]; 505 cisparse_t *parse;
504 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 506 cistpl_cftable_entry_t *cf;
507 u_char *buf;
505 win_req_t req; 508 win_req_t req;
506 memreq_t mem; 509 memreq_t mem;
507 int i, k; 510 int i, k;
508 511
512 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
513 if (!cfg_mem)
514 return CS_OUT_OF_RESOURCE;
515
516 tuple = &cfg_mem->tuple;
517 parse = &cfg_mem->parse;
518 cf = &parse->cftable_entry;
519 buf = cfg_mem->buf;
520
509 link->conf.Attributes |= CONF_ENABLE_SPKR; 521 link->conf.Attributes |= CONF_ENABLE_SPKR;
510 link->conf.Status = CCSR_AUDIO_ENA; 522 link->conf.Status = CCSR_AUDIO_ENA;
511 link->irq.Attributes = 523 link->irq.Attributes =
@@ -514,12 +526,12 @@ static int mhz_mfc_config(dev_link_t *link)
514 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 526 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
515 link->io.NumPorts2 = 8; 527 link->io.NumPorts2 = 8;
516 528
517 tuple.Attributes = tuple.TupleOffset = 0; 529 tuple->Attributes = tuple->TupleOffset = 0;
518 tuple.TupleData = (cisdata_t *)buf; 530 tuple->TupleData = (cisdata_t *)buf;
519 tuple.TupleDataMax = sizeof(buf); 531 tuple->TupleDataMax = 255;
520 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 532 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
521 533
522 i = first_tuple(link->handle, &tuple, &parse); 534 i = first_tuple(link->handle, tuple, parse);
523 /* The Megahertz combo cards have modem-like CIS entries, so 535 /* The Megahertz combo cards have modem-like CIS entries, so
524 we have to explicitly try a bunch of port combinations. */ 536 we have to explicitly try a bunch of port combinations. */
525 while (i == CS_SUCCESS) { 537 while (i == CS_SUCCESS) {
@@ -532,10 +544,10 @@ static int mhz_mfc_config(dev_link_t *link)
532 if (i == CS_SUCCESS) break; 544 if (i == CS_SUCCESS) break;
533 } 545 }
534 if (i == CS_SUCCESS) break; 546 if (i == CS_SUCCESS) break;
535 i = next_tuple(link->handle, &tuple, &parse); 547 i = next_tuple(link->handle, tuple, parse);
536 } 548 }
537 if (i != CS_SUCCESS) 549 if (i != CS_SUCCESS)
538 return i; 550 goto free_cfg_mem;
539 dev->base_addr = link->io.BasePort1; 551 dev->base_addr = link->io.BasePort1;
540 552
541 /* Allocate a memory window, for accessing the ISR */ 553 /* Allocate a memory window, for accessing the ISR */
@@ -544,7 +556,7 @@ static int mhz_mfc_config(dev_link_t *link)
544 req.AccessSpeed = 0; 556 req.AccessSpeed = 0;
545 i = pcmcia_request_window(&link->handle, &req, &link->win); 557 i = pcmcia_request_window(&link->handle, &req, &link->win);
546 if (i != CS_SUCCESS) 558 if (i != CS_SUCCESS)
547 return i; 559 goto free_cfg_mem;
548 smc->base = ioremap(req.Base, req.Size); 560 smc->base = ioremap(req.Base, req.Size);
549 mem.CardOffset = mem.Page = 0; 561 mem.CardOffset = mem.Page = 0;
550 if (smc->manfid == MANFID_MOTOROLA) 562 if (smc->manfid == MANFID_MOTOROLA)
@@ -556,6 +568,8 @@ static int mhz_mfc_config(dev_link_t *link)
556 && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 568 && (smc->cardid == PRODID_MEGAHERTZ_EM3288))
557 mhz_3288_power(link); 569 mhz_3288_power(link);
558 570
571free_cfg_mem:
572 kfree(cfg_mem);
559 return i; 573 return i;
560} 574}
561 575
@@ -563,39 +577,61 @@ static int mhz_setup(dev_link_t *link)
563{ 577{
564 client_handle_t handle = link->handle; 578 client_handle_t handle = link->handle;
565 struct net_device *dev = link->priv; 579 struct net_device *dev = link->priv;
566 tuple_t tuple; 580 struct smc_cfg_mem *cfg_mem;
567 cisparse_t parse; 581 tuple_t *tuple;
568 u_char buf[255], *station_addr; 582 cisparse_t *parse;
583 u_char *buf, *station_addr;
584 int rc;
585
586 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
587 if (!cfg_mem)
588 return -1;
589
590 tuple = &cfg_mem->tuple;
591 parse = &cfg_mem->parse;
592 buf = cfg_mem->buf;
569 593
570 tuple.Attributes = tuple.TupleOffset = 0; 594 tuple->Attributes = tuple->TupleOffset = 0;
571 tuple.TupleData = buf; 595 tuple->TupleData = (cisdata_t *)buf;
572 tuple.TupleDataMax = sizeof(buf); 596 tuple->TupleDataMax = 255;
573 597
574 /* Read the station address from the CIS. It is stored as the last 598 /* Read the station address from the CIS. It is stored as the last
575 (fourth) string in the Version 1 Version/ID tuple. */ 599 (fourth) string in the Version 1 Version/ID tuple. */
576 tuple.DesiredTuple = CISTPL_VERS_1; 600 tuple->DesiredTuple = CISTPL_VERS_1;
577 if (first_tuple(handle, &tuple, &parse) != CS_SUCCESS) 601 if (first_tuple(handle, tuple, parse) != CS_SUCCESS) {
578 return -1; 602 rc = -1;
603 goto free_cfg_mem;
604 }
579 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ 605 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */
580 if (next_tuple(handle, &tuple, &parse) != CS_SUCCESS) 606 if (next_tuple(handle, tuple, parse) != CS_SUCCESS)
581 first_tuple(handle, &tuple, &parse); 607 first_tuple(handle, tuple, parse);
582 if (parse.version_1.ns > 3) { 608 if (parse->version_1.ns > 3) {
583 station_addr = parse.version_1.str + parse.version_1.ofs[3]; 609 station_addr = parse->version_1.str + parse->version_1.ofs[3];
584 if (cvt_ascii_address(dev, station_addr) == 0) 610 if (cvt_ascii_address(dev, station_addr) == 0) {
585 return 0; 611 rc = 0;
612 goto free_cfg_mem;
613 }
586 } 614 }
587 615
588 /* Another possibility: for the EM3288, in a special tuple */ 616 /* Another possibility: for the EM3288, in a special tuple */
589 tuple.DesiredTuple = 0x81; 617 tuple->DesiredTuple = 0x81;
590 if (pcmcia_get_first_tuple(handle, &tuple) != CS_SUCCESS) 618 if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) {
591 return -1; 619 rc = -1;
592 if (pcmcia_get_tuple_data(handle, &tuple) != CS_SUCCESS) 620 goto free_cfg_mem;
593 return -1; 621 }
622 if (pcmcia_get_tuple_data(handle, tuple) != CS_SUCCESS) {
623 rc = -1;
624 goto free_cfg_mem;
625 }
594 buf[12] = '\0'; 626 buf[12] = '\0';
595 if (cvt_ascii_address(dev, buf) == 0) 627 if (cvt_ascii_address(dev, buf) == 0) {
596 return 0; 628 rc = 0;
597 629 goto free_cfg_mem;
598 return -1; 630 }
631 rc = -1;
632free_cfg_mem:
633 kfree(cfg_mem);
634 return rc;
599} 635}
600 636
601/*====================================================================== 637/*======================================================================
@@ -665,19 +701,29 @@ static int mot_setup(dev_link_t *link)
665static int smc_config(dev_link_t *link) 701static int smc_config(dev_link_t *link)
666{ 702{
667 struct net_device *dev = link->priv; 703 struct net_device *dev = link->priv;
668 tuple_t tuple; 704 struct smc_cfg_mem *cfg_mem;
669 cisparse_t parse; 705 tuple_t *tuple;
670 u_char buf[255]; 706 cisparse_t *parse;
671 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 707 cistpl_cftable_entry_t *cf;
708 u_char *buf;
672 int i; 709 int i;
673 710
674 tuple.Attributes = tuple.TupleOffset = 0; 711 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
675 tuple.TupleData = (cisdata_t *)buf; 712 if (!cfg_mem)
676 tuple.TupleDataMax = sizeof(buf); 713 return CS_OUT_OF_RESOURCE;
677 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 714
715 tuple = &cfg_mem->tuple;
716 parse = &cfg_mem->parse;
717 cf = &parse->cftable_entry;
718 buf = cfg_mem->buf;
719
720 tuple->Attributes = tuple->TupleOffset = 0;
721 tuple->TupleData = (cisdata_t *)buf;
722 tuple->TupleDataMax = 255;
723 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
678 724
679 link->io.NumPorts1 = 16; 725 link->io.NumPorts1 = 16;
680 i = first_tuple(link->handle, &tuple, &parse); 726 i = first_tuple(link->handle, tuple, parse);
681 while (i != CS_NO_MORE_ITEMS) { 727 while (i != CS_NO_MORE_ITEMS) {
682 if (i == CS_SUCCESS) { 728 if (i == CS_SUCCESS) {
683 link->conf.ConfigIndex = cf->index; 729 link->conf.ConfigIndex = cf->index;
@@ -686,10 +732,12 @@ static int smc_config(dev_link_t *link)
686 i = pcmcia_request_io(link->handle, &link->io); 732 i = pcmcia_request_io(link->handle, &link->io);
687 if (i == CS_SUCCESS) break; 733 if (i == CS_SUCCESS) break;
688 } 734 }
689 i = next_tuple(link->handle, &tuple, &parse); 735 i = next_tuple(link->handle, tuple, parse);
690 } 736 }
691 if (i == CS_SUCCESS) 737 if (i == CS_SUCCESS)
692 dev->base_addr = link->io.BasePort1; 738 dev->base_addr = link->io.BasePort1;
739
740 kfree(cfg_mem);
693 return i; 741 return i;
694} 742}
695 743
@@ -697,41 +745,58 @@ static int smc_setup(dev_link_t *link)
697{ 745{
698 client_handle_t handle = link->handle; 746 client_handle_t handle = link->handle;
699 struct net_device *dev = link->priv; 747 struct net_device *dev = link->priv;
700 tuple_t tuple; 748 struct smc_cfg_mem *cfg_mem;
701 cisparse_t parse; 749 tuple_t *tuple;
750 cisparse_t *parse;
702 cistpl_lan_node_id_t *node_id; 751 cistpl_lan_node_id_t *node_id;
703 u_char buf[255], *station_addr; 752 u_char *buf, *station_addr;
704 int i; 753 int i, rc;
754
755 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
756 if (!cfg_mem)
757 return CS_OUT_OF_RESOURCE;
705 758
706 tuple.Attributes = tuple.TupleOffset = 0; 759 tuple = &cfg_mem->tuple;
707 tuple.TupleData = buf; 760 parse = &cfg_mem->parse;
708 tuple.TupleDataMax = sizeof(buf); 761 buf = cfg_mem->buf;
762
763 tuple->Attributes = tuple->TupleOffset = 0;
764 tuple->TupleData = (cisdata_t *)buf;
765 tuple->TupleDataMax = 255;
709 766
710 /* Check for a LAN function extension tuple */ 767 /* Check for a LAN function extension tuple */
711 tuple.DesiredTuple = CISTPL_FUNCE; 768 tuple->DesiredTuple = CISTPL_FUNCE;
712 i = first_tuple(handle, &tuple, &parse); 769 i = first_tuple(handle, tuple, parse);
713 while (i == CS_SUCCESS) { 770 while (i == CS_SUCCESS) {
714 if (parse.funce.type == CISTPL_FUNCE_LAN_NODE_ID) 771 if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID)
715 break; 772 break;
716 i = next_tuple(handle, &tuple, &parse); 773 i = next_tuple(handle, tuple, parse);
717 } 774 }
718 if (i == CS_SUCCESS) { 775 if (i == CS_SUCCESS) {
719 node_id = (cistpl_lan_node_id_t *)parse.funce.data; 776 node_id = (cistpl_lan_node_id_t *)parse->funce.data;
720 if (node_id->nb == 6) { 777 if (node_id->nb == 6) {
721 for (i = 0; i < 6; i++) 778 for (i = 0; i < 6; i++)
722 dev->dev_addr[i] = node_id->id[i]; 779 dev->dev_addr[i] = node_id->id[i];
723 return 0; 780 rc = 0;
781 goto free_cfg_mem;
724 } 782 }
725 } 783 }
726 /* Try the third string in the Version 1 Version/ID tuple. */ 784 /* Try the third string in the Version 1 Version/ID tuple. */
727 tuple.DesiredTuple = CISTPL_VERS_1; 785 tuple->DesiredTuple = CISTPL_VERS_1;
728 if (first_tuple(handle, &tuple, &parse) != CS_SUCCESS) 786 if (first_tuple(handle, tuple, parse) != CS_SUCCESS) {
729 return -1; 787 rc = -1;
730 station_addr = parse.version_1.str + parse.version_1.ofs[2]; 788 goto free_cfg_mem;
731 if (cvt_ascii_address(dev, station_addr) == 0) 789 }
732 return 0; 790 station_addr = parse->version_1.str + parse->version_1.ofs[2];
791 if (cvt_ascii_address(dev, station_addr) == 0) {
792 rc = 0;
793 goto free_cfg_mem;
794 }
733 795
734 return -1; 796 rc = -1;
797free_cfg_mem:
798 kfree(cfg_mem);
799 return rc;
735} 800}
736 801
737/*====================================================================*/ 802/*====================================================================*/
@@ -773,26 +838,36 @@ static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid)
773{ 838{
774 client_handle_t handle = link->handle; 839 client_handle_t handle = link->handle;
775 struct net_device *dev = link->priv; 840 struct net_device *dev = link->priv;
776 tuple_t tuple; 841 struct smc_cfg_mem *cfg_mem;
777 u_char buf[255]; 842 tuple_t *tuple;
778 int i; 843 u_char *buf;
844 int i, rc;
845
846 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
847 if (!cfg_mem)
848 return -1;
849
850 tuple = &cfg_mem->tuple;
851 buf = cfg_mem->buf;
779 852
780 tuple.Attributes = TUPLE_RETURN_COMMON; 853 tuple->Attributes = TUPLE_RETURN_COMMON;
781 tuple.TupleData = buf; 854 tuple->TupleData = (cisdata_t *)buf;
782 tuple.TupleDataMax = sizeof(buf); 855 tuple->TupleDataMax = 255;
783 tuple.TupleOffset = 0; 856 tuple->TupleOffset = 0;
784 857
785 /* Read the station address from tuple 0x90, subtuple 0x04 */ 858 /* Read the station address from tuple 0x90, subtuple 0x04 */
786 tuple.DesiredTuple = 0x90; 859 tuple->DesiredTuple = 0x90;
787 i = pcmcia_get_first_tuple(handle, &tuple); 860 i = pcmcia_get_first_tuple(handle, tuple);
788 while (i == CS_SUCCESS) { 861 while (i == CS_SUCCESS) {
789 i = pcmcia_get_tuple_data(handle, &tuple); 862 i = pcmcia_get_tuple_data(handle, tuple);
790 if ((i != CS_SUCCESS) || (buf[0] == 0x04)) 863 if ((i != CS_SUCCESS) || (buf[0] == 0x04))
791 break; 864 break;
792 i = pcmcia_get_next_tuple(handle, &tuple); 865 i = pcmcia_get_next_tuple(handle, tuple);
866 }
867 if (i != CS_SUCCESS) {
868 rc = -1;
869 goto free_cfg_mem;
793 } 870 }
794 if (i != CS_SUCCESS)
795 return -1;
796 for (i = 0; i < 6; i++) 871 for (i = 0; i < 6; i++)
797 dev->dev_addr[i] = buf[i+2]; 872 dev->dev_addr[i] = buf[i+2];
798 873
@@ -814,8 +889,10 @@ static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid)
814 inw(link->io.BasePort1 + OSITECH_AUI_PWR), 889 inw(link->io.BasePort1 + OSITECH_AUI_PWR),
815 inw(link->io.BasePort1 + OSITECH_RESET_ISR)); 890 inw(link->io.BasePort1 + OSITECH_RESET_ISR));
816 } 891 }
817 892 rc = 0;
818 return 0; 893free_cfg_mem:
894 kfree(cfg_mem);
895 return rc;
819} 896}
820 897
821/*====================================================================== 898/*======================================================================
@@ -887,9 +964,10 @@ static void smc91c92_config(dev_link_t *link)
887 client_handle_t handle = link->handle; 964 client_handle_t handle = link->handle;
888 struct net_device *dev = link->priv; 965 struct net_device *dev = link->priv;
889 struct smc_private *smc = netdev_priv(dev); 966 struct smc_private *smc = netdev_priv(dev);
890 tuple_t tuple; 967 struct smc_cfg_mem *cfg_mem;
891 cisparse_t parse; 968 tuple_t *tuple;
892 u_short buf[32]; 969 cisparse_t *parse;
970 u_char *buf;
893 char *name; 971 char *name;
894 int i, j, rev; 972 int i, j, rev;
895 kio_addr_t ioaddr; 973 kio_addr_t ioaddr;
@@ -897,21 +975,29 @@ static void smc91c92_config(dev_link_t *link)
897 975
898 DEBUG(0, "smc91c92_config(0x%p)\n", link); 976 DEBUG(0, "smc91c92_config(0x%p)\n", link);
899 977
900 tuple.Attributes = tuple.TupleOffset = 0; 978 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
901 tuple.TupleData = (cisdata_t *)buf; 979 if (!cfg_mem)
902 tuple.TupleDataMax = sizeof(buf); 980 goto config_failed;
903 981
904 tuple.DesiredTuple = CISTPL_CONFIG; 982 tuple = &cfg_mem->tuple;
905 i = first_tuple(handle, &tuple, &parse); 983 parse = &cfg_mem->parse;
906 CS_EXIT_TEST(i, ParseTuple, config_failed); 984 buf = cfg_mem->buf;
907 link->conf.ConfigBase = parse.config.base;
908 link->conf.Present = parse.config.rmask[0];
909 985
910 tuple.DesiredTuple = CISTPL_MANFID; 986 tuple->Attributes = tuple->TupleOffset = 0;
911 tuple.Attributes = TUPLE_RETURN_COMMON; 987 tuple->TupleData = (cisdata_t *)buf;
912 if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 988 tuple->TupleDataMax = 64;
913 smc->manfid = parse.manfid.manf; 989
914 smc->cardid = parse.manfid.card; 990 tuple->DesiredTuple = CISTPL_CONFIG;
991 i = first_tuple(handle, tuple, parse);
992 CS_EXIT_TEST(i, ParseTuple, config_failed);
993 link->conf.ConfigBase = parse->config.base;
994 link->conf.Present = parse->config.rmask[0];
995
996 tuple->DesiredTuple = CISTPL_MANFID;
997 tuple->Attributes = TUPLE_RETURN_COMMON;
998 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
999 smc->manfid = parse->manfid.manf;
1000 smc->cardid = parse->manfid.card;
915 } 1001 }
916 1002
917 /* Configure card */ 1003 /* Configure card */
@@ -1046,7 +1132,7 @@ static void smc91c92_config(dev_link_t *link)
1046 printk(KERN_NOTICE " No MII transceivers found!\n"); 1132 printk(KERN_NOTICE " No MII transceivers found!\n");
1047 } 1133 }
1048 } 1134 }
1049 1135 kfree(cfg_mem);
1050 return; 1136 return;
1051 1137
1052config_undo: 1138config_undo:
@@ -1054,6 +1140,7 @@ config_undo:
1054config_failed: /* CS_EXIT_TEST() calls jump to here... */ 1140config_failed: /* CS_EXIT_TEST() calls jump to here... */
1055 smc91c92_release(link); 1141 smc91c92_release(link);
1056 link->state &= ~DEV_CONFIG_PENDING; 1142 link->state &= ~DEV_CONFIG_PENDING;
1143 kfree(cfg_mem);
1057 1144
1058} /* smc91c92_config */ 1145} /* smc91c92_config */
1059 1146
@@ -2006,7 +2093,7 @@ static void media_check(u_long arg)
2006 } 2093 }
2007 2094
2008 /* Ignore collisions unless we've had no rx's recently */ 2095 /* Ignore collisions unless we've had no rx's recently */
2009 if (jiffies - dev->last_rx > HZ) { 2096 if (time_after(jiffies, dev->last_rx + HZ)) {
2010 if (smc->tx_err || (smc->media_status & EPH_16COL)) 2097 if (smc->tx_err || (smc->media_status & EPH_16COL))
2011 media |= EPH_16COL; 2098 media |= EPH_16COL;
2012 } 2099 }
@@ -2236,13 +2323,47 @@ static int smc_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
2236 return rc; 2323 return rc;
2237} 2324}
2238 2325
2326static struct pcmcia_device_id smc91c92_ids[] = {
2327 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0109, 0x0501),
2328 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0140, 0x000a),
2329 PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63),
2330 PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63),
2331 PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef),
2332 PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "XJEM1144/CCEM1144", "PCMCIA MODEM", 0xf510db04, 0x52d21e1e, 0xbd6c43ef),
2333 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Gateway 2000", "XJEM3336", 0xdd9989be, 0x662c394c),
2334 PCMCIA_PFC_DEVICE_PROD_ID12(0, "MEGAHERTZ", "XJEM1144/CCEM1144", 0xf510db04, 0x52d21e1e),
2335 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Ositech", "Trumpcard:Jack of Diamonds Modem+Ethernet", 0xc2f80cd, 0x656947b9),
2336 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Ositech", "Trumpcard:Jack of Hearts Modem+Ethernet", 0xc2f80cd, 0xdc9ba5ed),
2337 PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x016c, 0x0020),
2338 PCMCIA_DEVICE_MANF_CARD(0x016c, 0x0023),
2339 PCMCIA_DEVICE_PROD_ID123("BASICS by New Media Corporation", "Ethernet", "SMC91C94", 0x23c78a9d, 0x00b2e941, 0xcef397fb),
2340 PCMCIA_DEVICE_PROD_ID12("ARGOSY", "Fast Ethernet PCCard", 0x78f308dc, 0xdcea68bc),
2341 PCMCIA_DEVICE_PROD_ID12("dit Co., Ltd.", "PC Card-10/100BTX", 0xe59365c8, 0x6a2161d1),
2342 PCMCIA_DEVICE_PROD_ID12("DYNALINK", "L100C", 0x6a26d1cf, 0xc16ce9c5),
2343 PCMCIA_DEVICE_PROD_ID12("Farallon", "Farallon Enet", 0x58d93fc4, 0x244734e9),
2344 PCMCIA_DEVICE_PROD_ID12("Megahertz", "CC10BT/2", 0x33234748, 0x3c95b953),
2345 PCMCIA_DEVICE_PROD_ID12("MELCO/SMC", "LPC-TX", 0xa2cd8e6d, 0x42da662a),
2346 PCMCIA_DEVICE_PROD_ID12("Ositech", "Trumpcard:Four of Diamonds Ethernet", 0xc2f80cd, 0xb3466314),
2347 PCMCIA_DEVICE_PROD_ID12("Ositech", "Trumpcard:Seven of Diamonds Ethernet", 0xc2f80cd, 0x194b650a),
2348 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Fast Ethernet PCCard", 0x281f1c5d, 0xdcea68bc),
2349 PCMCIA_DEVICE_PROD_ID12("Psion", "10Mb Ethernet", 0x4ef00b21, 0x844be9e9),
2350 PCMCIA_DEVICE_PROD_ID12("SMC", "EtherEZ Ethernet 8020", 0xc4f8b18b, 0x4a0eeb2d),
2351 /* These conflict with other cards! */
2352 /* PCMCIA_DEVICE_MANF_CARD(0x0186, 0x0100), */
2353 /* PCMCIA_DEVICE_MANF_CARD(0x8a01, 0xc1ab), */
2354 PCMCIA_DEVICE_NULL,
2355};
2356MODULE_DEVICE_TABLE(pcmcia, smc91c92_ids);
2357
2239static struct pcmcia_driver smc91c92_cs_driver = { 2358static struct pcmcia_driver smc91c92_cs_driver = {
2240 .owner = THIS_MODULE, 2359 .owner = THIS_MODULE,
2241 .drv = { 2360 .drv = {
2242 .name = "smc91c92_cs", 2361 .name = "smc91c92_cs",
2243 }, 2362 },
2244 .attach = smc91c92_attach, 2363 .attach = smc91c92_attach,
2364 .event = smc91c92_event,
2245 .detach = smc91c92_detach, 2365 .detach = smc91c92_detach,
2366 .id_table = smc91c92_ids,
2246}; 2367};
2247 2368
2248static int __init init_smc91c92_cs(void) 2369static int __init init_smc91c92_cs(void)
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 58177d67ea12..ce143f08638a 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -81,7 +81,6 @@
81#include <linux/ioport.h> 81#include <linux/ioport.h>
82#include <linux/bitops.h> 82#include <linux/bitops.h>
83 83
84#include <pcmcia/version.h>
85#include <pcmcia/cs_types.h> 84#include <pcmcia/cs_types.h>
86#include <pcmcia/cs.h> 85#include <pcmcia/cs.h>
87#include <pcmcia/cistpl.h> 86#include <pcmcia/cistpl.h>
@@ -619,11 +618,6 @@ xirc2ps_attach(void)
619 link->next = dev_list; 618 link->next = dev_list;
620 dev_list = link; 619 dev_list = link;
621 client_reg.dev_info = &dev_info; 620 client_reg.dev_info = &dev_info;
622 client_reg.EventMask =
623 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
624 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
625 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
626 client_reg.event_handler = &xirc2ps_event;
627 client_reg.Version = 0x0210; 621 client_reg.Version = 0x0210;
628 client_reg.event_callback_args.client_data = link; 622 client_reg.event_callback_args.client_data = link;
629 if ((err = pcmcia_register_client(&link->handle, &client_reg))) { 623 if ((err = pcmcia_register_client(&link->handle, &client_reg))) {
@@ -1983,13 +1977,42 @@ do_stop(struct net_device *dev)
1983 return 0; 1977 return 0;
1984} 1978}
1985 1979
1980static struct pcmcia_device_id xirc2ps_ids[] = {
1981 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0089, 0x110a),
1982 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0138, 0x110a),
1983 PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "CEM28", 0x2e3ee845, 0x0ea978ea),
1984 PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "CEM33", 0x2e3ee845, 0x80609023),
1985 PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "CEM56", 0x2e3ee845, 0xa650c32a),
1986 PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "REM10", 0x2e3ee845, 0x76df1d29),
1987 PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "XEM5600", 0x2e3ee845, 0xf1403719),
1988 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Xircom", "CreditCard Ethernet+Modem II", 0x2e3ee845, 0xeca401bf),
1989 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x010a),
1990 PCMCIA_DEVICE_PROD_ID13("Toshiba Information Systems", "TPCENET", 0x1b3b94fe, 0xf381c1a2),
1991 PCMCIA_DEVICE_PROD_ID13("Xircom", "CE3-10/100", 0x2e3ee845, 0x0ec0ac37),
1992 PCMCIA_DEVICE_PROD_ID13("Xircom", "PS-CE2-10", 0x2e3ee845, 0x947d9073),
1993 PCMCIA_DEVICE_PROD_ID13("Xircom", "R2E-100BTX", 0x2e3ee845, 0x2464a6e3),
1994 PCMCIA_DEVICE_PROD_ID13("Xircom", "RE-10", 0x2e3ee845, 0x3e08d609),
1995 PCMCIA_DEVICE_PROD_ID13("Xircom", "XE2000", 0x2e3ee845, 0xf7188e46),
1996 PCMCIA_DEVICE_PROD_ID12("Compaq", "Ethernet LAN Card", 0x54f7c49c, 0x9fd2f0a2),
1997 PCMCIA_DEVICE_PROD_ID12("Compaq", "Netelligent 10/100 PC Card", 0x54f7c49c, 0xefe96769),
1998 PCMCIA_DEVICE_PROD_ID12("Intel", "EtherExpress(TM) PRO/100 PC Card Mobile Adapter16", 0x816cc815, 0x174397db),
1999 PCMCIA_DEVICE_PROD_ID12("Toshiba", "10/100 Ethernet PC Card", 0x44a09d9c, 0xb44deecf),
2000 /* also matches CFE-10 cards! */
2001 /* PCMCIA_DEVICE_MANF_CARD(0x0105, 0x010a), */
2002 PCMCIA_DEVICE_NULL,
2003};
2004MODULE_DEVICE_TABLE(pcmcia, xirc2ps_ids);
2005
2006
1986static struct pcmcia_driver xirc2ps_cs_driver = { 2007static struct pcmcia_driver xirc2ps_cs_driver = {
1987 .owner = THIS_MODULE, 2008 .owner = THIS_MODULE,
1988 .drv = { 2009 .drv = {
1989 .name = "xirc2ps_cs", 2010 .name = "xirc2ps_cs",
1990 }, 2011 },
1991 .attach = xirc2ps_attach, 2012 .attach = xirc2ps_attach,
2013 .event = xirc2ps_event,
1992 .detach = xirc2ps_detach, 2014 .detach = xirc2ps_detach,
2015 .id_table = xirc2ps_ids,
1993}; 2016};
1994 2017
1995static int __init 2018static int __init
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 13f114876965..113b68099216 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -850,7 +850,7 @@ static int pcnet32_phys_id(struct net_device *dev, u32 data)
850 if ((!data) || (data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))) 850 if ((!data) || (data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)))
851 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); 851 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
852 852
853 schedule_timeout(data * HZ); 853 msleep_interruptible(data * 1000);
854 del_timer_sync(&lp->blink_timer); 854 del_timer_sync(&lp->blink_timer);
855 855
856 /* Restore the original value of the bcrs */ 856 /* Restore the original value of the bcrs */
@@ -1602,7 +1602,7 @@ pcnet32_init_ring(struct net_device *dev)
1602 1602
1603 rmb(); 1603 rmb();
1604 if (lp->rx_dma_addr[i] == 0) 1604 if (lp->rx_dma_addr[i] == 0)
1605 lp->rx_dma_addr[i] = pci_map_single(lp->pci_dev, rx_skbuff->tail, 1605 lp->rx_dma_addr[i] = pci_map_single(lp->pci_dev, rx_skbuff->data,
1606 PKT_BUF_SZ-2, PCI_DMA_FROMDEVICE); 1606 PKT_BUF_SZ-2, PCI_DMA_FROMDEVICE);
1607 lp->rx_ring[i].base = (u32)le32_to_cpu(lp->rx_dma_addr[i]); 1607 lp->rx_ring[i].base = (u32)le32_to_cpu(lp->rx_dma_addr[i]);
1608 lp->rx_ring[i].buf_length = le16_to_cpu(2-PKT_BUF_SZ); 1608 lp->rx_ring[i].buf_length = le16_to_cpu(2-PKT_BUF_SZ);
@@ -1983,7 +1983,7 @@ pcnet32_rx(struct net_device *dev)
1983 lp->rx_skbuff[entry] = newskb; 1983 lp->rx_skbuff[entry] = newskb;
1984 newskb->dev = dev; 1984 newskb->dev = dev;
1985 lp->rx_dma_addr[entry] = 1985 lp->rx_dma_addr[entry] =
1986 pci_map_single(lp->pci_dev, newskb->tail, 1986 pci_map_single(lp->pci_dev, newskb->data,
1987 PKT_BUF_SZ-2, PCI_DMA_FROMDEVICE); 1987 PKT_BUF_SZ-2, PCI_DMA_FROMDEVICE);
1988 lp->rx_ring[entry].base = le32_to_cpu(lp->rx_dma_addr[entry]); 1988 lp->rx_ring[entry].base = le32_to_cpu(lp->rx_dma_addr[entry]);
1989 rx_in_place = 1; 1989 rx_in_place = 1;
@@ -2020,7 +2020,7 @@ pcnet32_rx(struct net_device *dev)
2020 PKT_BUF_SZ-2, 2020 PKT_BUF_SZ-2,
2021 PCI_DMA_FROMDEVICE); 2021 PCI_DMA_FROMDEVICE);
2022 eth_copy_and_sum(skb, 2022 eth_copy_and_sum(skb,
2023 (unsigned char *)(lp->rx_skbuff[entry]->tail), 2023 (unsigned char *)(lp->rx_skbuff[entry]->data),
2024 pkt_len,0); 2024 pkt_len,0);
2025 pci_dma_sync_single_for_device(lp->pci_dev, 2025 pci_dma_sync_single_for_device(lp->pci_dev,
2026 lp->rx_dma_addr[entry], 2026 lp->rx_dma_addr[entry],
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
new file mode 100644
index 000000000000..6a2fe3583478
--- /dev/null
+++ b/drivers/net/phy/Kconfig
@@ -0,0 +1,57 @@
1#
2# PHY Layer Configuration
3#
4
5menu "PHY device support"
6
7config PHYLIB
8 tristate "PHY Device support and infrastructure"
9 depends on NET_ETHERNET
10 help
11 Ethernet controllers are usually attached to PHY
12 devices. This option provides infrastructure for
13 managing PHY devices.
14
15config PHYCONTROL
16 bool " Support for automatically handling PHY state changes"
17 depends on PHYLIB
18 help
19 Adds code to perform all the work for keeping PHY link
20 state (speed/duplex/etc) up-to-date. Also handles
21 interrupts.
22
23comment "MII PHY device drivers"
24 depends on PHYLIB
25
26config MARVELL_PHY
27 tristate "Drivers for Marvell PHYs"
28 depends on PHYLIB
29 ---help---
30 Currently has a driver for the 88E1011S
31
32config DAVICOM_PHY
33 tristate "Drivers for Davicom PHYs"
34 depends on PHYLIB
35 ---help---
36 Currently supports dm9161e and dm9131
37
38config QSEMI_PHY
39 tristate "Drivers for Quality Semiconductor PHYs"
40 depends on PHYLIB
41 ---help---
42 Currently supports the qs6612
43
44config LXT_PHY
45 tristate "Drivers for the Intel LXT PHYs"
46 depends on PHYLIB
47 ---help---
48 Currently supports the lxt970, lxt971
49
50config CICADA_PHY
51 tristate "Drivers for the Cicada PHYs"
52 depends on PHYLIB
53 ---help---
54 Currently supports the cis8204
55
56endmenu
57
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
new file mode 100644
index 000000000000..e4116a5fbb4c
--- /dev/null
+++ b/drivers/net/phy/Makefile
@@ -0,0 +1,10 @@
1# Makefile for Linux PHY drivers
2
3libphy-objs := phy.o phy_device.o mdio_bus.o
4
5obj-$(CONFIG_PHYLIB) += libphy.o
6obj-$(CONFIG_MARVELL_PHY) += marvell.o
7obj-$(CONFIG_DAVICOM_PHY) += davicom.o
8obj-$(CONFIG_CICADA_PHY) += cicada.o
9obj-$(CONFIG_LXT_PHY) += lxt.o
10obj-$(CONFIG_QSEMI_PHY) += qsemi.o
diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c
new file mode 100644
index 000000000000..c47fb2ecd147
--- /dev/null
+++ b/drivers/net/phy/cicada.c
@@ -0,0 +1,134 @@
1/*
2 * drivers/net/phy/cicada.c
3 *
4 * Driver for Cicada PHYs
5 *
6 * Author: Andy Fleming
7 *
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16#include <linux/config.h>
17#include <linux/kernel.h>
18#include <linux/sched.h>
19#include <linux/string.h>
20#include <linux/errno.h>
21#include <linux/unistd.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/skbuff.h>
29#include <linux/spinlock.h>
30#include <linux/mm.h>
31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h>
34#include <linux/ethtool.h>
35#include <linux/phy.h>
36
37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/uaccess.h>
40
41/* Cicada Extended Control Register 1 */
42#define MII_CIS8201_EXT_CON1 0x17
43#define MII_CIS8201_EXTCON1_INIT 0x0000
44
45/* Cicada Interrupt Mask Register */
46#define MII_CIS8201_IMASK 0x19
47#define MII_CIS8201_IMASK_IEN 0x8000
48#define MII_CIS8201_IMASK_SPEED 0x4000
49#define MII_CIS8201_IMASK_LINK 0x2000
50#define MII_CIS8201_IMASK_DUPLEX 0x1000
51#define MII_CIS8201_IMASK_MASK 0xf000
52
53/* Cicada Interrupt Status Register */
54#define MII_CIS8201_ISTAT 0x1a
55#define MII_CIS8201_ISTAT_STATUS 0x8000
56#define MII_CIS8201_ISTAT_SPEED 0x4000
57#define MII_CIS8201_ISTAT_LINK 0x2000
58#define MII_CIS8201_ISTAT_DUPLEX 0x1000
59
60/* Cicada Auxiliary Control/Status Register */
61#define MII_CIS8201_AUX_CONSTAT 0x1c
62#define MII_CIS8201_AUXCONSTAT_INIT 0x0004
63#define MII_CIS8201_AUXCONSTAT_DUPLEX 0x0020
64#define MII_CIS8201_AUXCONSTAT_SPEED 0x0018
65#define MII_CIS8201_AUXCONSTAT_GBIT 0x0010
66#define MII_CIS8201_AUXCONSTAT_100 0x0008
67
68MODULE_DESCRIPTION("Cicadia PHY driver");
69MODULE_AUTHOR("Andy Fleming");
70MODULE_LICENSE("GPL");
71
72static int cis820x_config_init(struct phy_device *phydev)
73{
74 int err;
75
76 err = phy_write(phydev, MII_CIS8201_AUX_CONSTAT,
77 MII_CIS8201_AUXCONSTAT_INIT);
78
79 if (err < 0)
80 return err;
81
82 err = phy_write(phydev, MII_CIS8201_EXT_CON1,
83 MII_CIS8201_EXTCON1_INIT);
84
85 return err;
86}
87
88static int cis820x_ack_interrupt(struct phy_device *phydev)
89{
90 int err = phy_read(phydev, MII_CIS8201_ISTAT);
91
92 return (err < 0) ? err : 0;
93}
94
95static int cis820x_config_intr(struct phy_device *phydev)
96{
97 int err;
98
99 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
100 err = phy_write(phydev, MII_CIS8201_IMASK,
101 MII_CIS8201_IMASK_MASK);
102 else
103 err = phy_write(phydev, MII_CIS8201_IMASK, 0);
104
105 return err;
106}
107
108/* Cicada 820x */
109static struct phy_driver cis8204_driver = {
110 .phy_id = 0x000fc440,
111 .name = "Cicada Cis8204",
112 .phy_id_mask = 0x000fffc0,
113 .features = PHY_GBIT_FEATURES,
114 .flags = PHY_HAS_INTERRUPT,
115 .config_init = &cis820x_config_init,
116 .config_aneg = &genphy_config_aneg,
117 .read_status = &genphy_read_status,
118 .ack_interrupt = &cis820x_ack_interrupt,
119 .config_intr = &cis820x_config_intr,
120 .driver = { .owner = THIS_MODULE,},
121};
122
123static int __init cis8204_init(void)
124{
125 return phy_driver_register(&cis8204_driver);
126}
127
128static void __exit cis8204_exit(void)
129{
130 phy_driver_unregister(&cis8204_driver);
131}
132
133module_init(cis8204_init);
134module_exit(cis8204_exit);
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
new file mode 100644
index 000000000000..6caf499fae32
--- /dev/null
+++ b/drivers/net/phy/davicom.c
@@ -0,0 +1,195 @@
1/*
2 * drivers/net/phy/davicom.c
3 *
4 * Driver for Davicom PHYs
5 *
6 * Author: Andy Fleming
7 *
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16#include <linux/config.h>
17#include <linux/kernel.h>
18#include <linux/sched.h>
19#include <linux/string.h>
20#include <linux/errno.h>
21#include <linux/unistd.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/skbuff.h>
29#include <linux/spinlock.h>
30#include <linux/mm.h>
31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h>
34#include <linux/ethtool.h>
35#include <linux/phy.h>
36
37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/uaccess.h>
40
41#define MII_DM9161_SCR 0x10
42#define MII_DM9161_SCR_INIT 0x0610
43
44/* DM9161 Interrupt Register */
45#define MII_DM9161_INTR 0x15
46#define MII_DM9161_INTR_PEND 0x8000
47#define MII_DM9161_INTR_DPLX_MASK 0x0800
48#define MII_DM9161_INTR_SPD_MASK 0x0400
49#define MII_DM9161_INTR_LINK_MASK 0x0200
50#define MII_DM9161_INTR_MASK 0x0100
51#define MII_DM9161_INTR_DPLX_CHANGE 0x0010
52#define MII_DM9161_INTR_SPD_CHANGE 0x0008
53#define MII_DM9161_INTR_LINK_CHANGE 0x0004
54#define MII_DM9161_INTR_INIT 0x0000
55#define MII_DM9161_INTR_STOP \
56(MII_DM9161_INTR_DPLX_MASK | MII_DM9161_INTR_SPD_MASK \
57 | MII_DM9161_INTR_LINK_MASK | MII_DM9161_INTR_MASK)
58
59/* DM9161 10BT Configuration/Status */
60#define MII_DM9161_10BTCSR 0x12
61#define MII_DM9161_10BTCSR_INIT 0x7800
62
63MODULE_DESCRIPTION("Davicom PHY driver");
64MODULE_AUTHOR("Andy Fleming");
65MODULE_LICENSE("GPL");
66
67
68#define DM9161_DELAY 1
69static int dm9161_config_intr(struct phy_device *phydev)
70{
71 int temp;
72
73 temp = phy_read(phydev, MII_DM9161_INTR);
74
75 if (temp < 0)
76 return temp;
77
78 if(PHY_INTERRUPT_ENABLED == phydev->interrupts )
79 temp &= ~(MII_DM9161_INTR_STOP);
80 else
81 temp |= MII_DM9161_INTR_STOP;
82
83 temp = phy_write(phydev, MII_DM9161_INTR, temp);
84
85 return temp;
86}
87
88static int dm9161_config_aneg(struct phy_device *phydev)
89{
90 int err;
91
92 /* Isolate the PHY */
93 err = phy_write(phydev, MII_BMCR, BMCR_ISOLATE);
94
95 if (err < 0)
96 return err;
97
98 /* Configure the new settings */
99 err = genphy_config_aneg(phydev);
100
101 if (err < 0)
102 return err;
103
104 return 0;
105}
106
107static int dm9161_config_init(struct phy_device *phydev)
108{
109 int err;
110
111 /* Isolate the PHY */
112 err = phy_write(phydev, MII_BMCR, BMCR_ISOLATE);
113
114 if (err < 0)
115 return err;
116
117 /* Do not bypass the scrambler/descrambler */
118 err = phy_write(phydev, MII_DM9161_SCR, MII_DM9161_SCR_INIT);
119
120 if (err < 0)
121 return err;
122
123 /* Clear 10BTCSR to default */
124 err = phy_write(phydev, MII_DM9161_10BTCSR, MII_DM9161_10BTCSR_INIT);
125
126 if (err < 0)
127 return err;
128
129 /* Reconnect the PHY, and enable Autonegotiation */
130 err = phy_write(phydev, MII_BMCR, BMCR_ANENABLE);
131
132 if (err < 0)
133 return err;
134
135 return 0;
136}
137
138static int dm9161_ack_interrupt(struct phy_device *phydev)
139{
140 int err = phy_read(phydev, MII_DM9161_INTR);
141
142 return (err < 0) ? err : 0;
143}
144
145static struct phy_driver dm9161_driver = {
146 .phy_id = 0x0181b880,
147 .name = "Davicom DM9161E",
148 .phy_id_mask = 0x0ffffff0,
149 .features = PHY_BASIC_FEATURES,
150 .config_init = dm9161_config_init,
151 .config_aneg = dm9161_config_aneg,
152 .read_status = genphy_read_status,
153 .driver = { .owner = THIS_MODULE,},
154};
155
156static struct phy_driver dm9131_driver = {
157 .phy_id = 0x00181b80,
158 .name = "Davicom DM9131",
159 .phy_id_mask = 0x0ffffff0,
160 .features = PHY_BASIC_FEATURES,
161 .flags = PHY_HAS_INTERRUPT,
162 .config_aneg = genphy_config_aneg,
163 .read_status = genphy_read_status,
164 .ack_interrupt = dm9161_ack_interrupt,
165 .config_intr = dm9161_config_intr,
166 .driver = { .owner = THIS_MODULE,},
167};
168
169static int __init davicom_init(void)
170{
171 int ret;
172
173 ret = phy_driver_register(&dm9161_driver);
174 if (ret)
175 goto err1;
176
177 ret = phy_driver_register(&dm9131_driver);
178 if (ret)
179 goto err2;
180 return 0;
181
182 err2:
183 phy_driver_unregister(&dm9161_driver);
184 err1:
185 return ret;
186}
187
188static void __exit davicom_exit(void)
189{
190 phy_driver_unregister(&dm9161_driver);
191 phy_driver_unregister(&dm9131_driver);
192}
193
194module_init(davicom_init);
195module_exit(davicom_exit);
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
new file mode 100644
index 000000000000..4c840448ec86
--- /dev/null
+++ b/drivers/net/phy/lxt.c
@@ -0,0 +1,179 @@
1/*
2 * drivers/net/phy/lxt.c
3 *
4 * Driver for Intel LXT PHYs
5 *
6 * Author: Andy Fleming
7 *
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16#include <linux/config.h>
17#include <linux/kernel.h>
18#include <linux/sched.h>
19#include <linux/string.h>
20#include <linux/errno.h>
21#include <linux/unistd.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/skbuff.h>
29#include <linux/spinlock.h>
30#include <linux/mm.h>
31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h>
34#include <linux/ethtool.h>
35#include <linux/phy.h>
36
37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/uaccess.h>
40
41/* The Level one LXT970 is used by many boards */
42
43#define MII_LXT970_IER 17 /* Interrupt Enable Register */
44
45#define MII_LXT970_IER_IEN 0x0002
46
47#define MII_LXT970_ISR 18 /* Interrupt Status Register */
48
49#define MII_LXT970_CONFIG 19 /* Configuration Register */
50
51/* ------------------------------------------------------------------------- */
52/* The Level one LXT971 is used on some of my custom boards */
53
54/* register definitions for the 971 */
55#define MII_LXT971_IER 18 /* Interrupt Enable Register */
56#define MII_LXT971_IER_IEN 0x00f2
57
58#define MII_LXT971_ISR 19 /* Interrupt Status Register */
59
60
61MODULE_DESCRIPTION("Intel LXT PHY driver");
62MODULE_AUTHOR("Andy Fleming");
63MODULE_LICENSE("GPL");
64
65static int lxt970_ack_interrupt(struct phy_device *phydev)
66{
67 int err;
68
69 err = phy_read(phydev, MII_BMSR);
70
71 if (err < 0)
72 return err;
73
74 err = phy_read(phydev, MII_LXT970_ISR);
75
76 if (err < 0)
77 return err;
78
79 return 0;
80}
81
82static int lxt970_config_intr(struct phy_device *phydev)
83{
84 int err;
85
86 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
87 err = phy_write(phydev, MII_LXT970_IER, MII_LXT970_IER_IEN);
88 else
89 err = phy_write(phydev, MII_LXT970_IER, 0);
90
91 return err;
92}
93
94static int lxt970_config_init(struct phy_device *phydev)
95{
96 int err;
97
98 err = phy_write(phydev, MII_LXT970_CONFIG, 0);
99
100 return err;
101}
102
103
104static int lxt971_ack_interrupt(struct phy_device *phydev)
105{
106 int err = phy_read(phydev, MII_LXT971_ISR);
107
108 if (err < 0)
109 return err;
110
111 return 0;
112}
113
114static int lxt971_config_intr(struct phy_device *phydev)
115{
116 int err;
117
118 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
119 err = phy_write(phydev, MII_LXT971_IER, MII_LXT971_IER_IEN);
120 else
121 err = phy_write(phydev, MII_LXT971_IER, 0);
122
123 return err;
124}
125
126static struct phy_driver lxt970_driver = {
127 .phy_id = 0x07810000,
128 .name = "LXT970",
129 .phy_id_mask = 0x0fffffff,
130 .features = PHY_BASIC_FEATURES,
131 .flags = PHY_HAS_INTERRUPT,
132 .config_init = lxt970_config_init,
133 .config_aneg = genphy_config_aneg,
134 .read_status = genphy_read_status,
135 .ack_interrupt = lxt970_ack_interrupt,
136 .config_intr = lxt970_config_intr,
137 .driver = { .owner = THIS_MODULE,},
138};
139
140static struct phy_driver lxt971_driver = {
141 .phy_id = 0x0001378e,
142 .name = "LXT971",
143 .phy_id_mask = 0x0fffffff,
144 .features = PHY_BASIC_FEATURES,
145 .flags = PHY_HAS_INTERRUPT,
146 .config_aneg = genphy_config_aneg,
147 .read_status = genphy_read_status,
148 .ack_interrupt = lxt971_ack_interrupt,
149 .config_intr = lxt971_config_intr,
150 .driver = { .owner = THIS_MODULE,},
151};
152
153static int __init lxt_init(void)
154{
155 int ret;
156
157 ret = phy_driver_register(&lxt970_driver);
158 if (ret)
159 goto err1;
160
161 ret = phy_driver_register(&lxt971_driver);
162 if (ret)
163 goto err2;
164 return 0;
165
166 err2:
167 phy_driver_unregister(&lxt970_driver);
168 err1:
169 return ret;
170}
171
172static void __exit lxt_exit(void)
173{
174 phy_driver_unregister(&lxt970_driver);
175 phy_driver_unregister(&lxt971_driver);
176}
177
178module_init(lxt_init);
179module_exit(lxt_exit);
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
new file mode 100644
index 000000000000..4a72b025006b
--- /dev/null
+++ b/drivers/net/phy/marvell.c
@@ -0,0 +1,140 @@
1/*
2 * drivers/net/phy/marvell.c
3 *
4 * Driver for Marvell PHYs
5 *
6 * Author: Andy Fleming
7 *
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16#include <linux/config.h>
17#include <linux/kernel.h>
18#include <linux/sched.h>
19#include <linux/string.h>
20#include <linux/errno.h>
21#include <linux/unistd.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/skbuff.h>
29#include <linux/spinlock.h>
30#include <linux/mm.h>
31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h>
34#include <linux/ethtool.h>
35#include <linux/phy.h>
36
37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/uaccess.h>
40
41#define MII_M1011_IEVENT 0x13
42#define MII_M1011_IEVENT_CLEAR 0x0000
43
44#define MII_M1011_IMASK 0x12
45#define MII_M1011_IMASK_INIT 0x6400
46#define MII_M1011_IMASK_CLEAR 0x0000
47
48MODULE_DESCRIPTION("Marvell PHY driver");
49MODULE_AUTHOR("Andy Fleming");
50MODULE_LICENSE("GPL");
51
52static int marvell_ack_interrupt(struct phy_device *phydev)
53{
54 int err;
55
56 /* Clear the interrupts by reading the reg */
57 err = phy_read(phydev, MII_M1011_IEVENT);
58
59 if (err < 0)
60 return err;
61
62 return 0;
63}
64
65static int marvell_config_intr(struct phy_device *phydev)
66{
67 int err;
68
69 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
70 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
71 else
72 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
73
74 return err;
75}
76
77static int marvell_config_aneg(struct phy_device *phydev)
78{
79 int err;
80
81 /* The Marvell PHY has an errata which requires
82 * that certain registers get written in order
83 * to restart autonegotiation */
84 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
85
86 if (err < 0)
87 return err;
88
89 err = phy_write(phydev, 0x1d, 0x1f);
90 if (err < 0)
91 return err;
92
93 err = phy_write(phydev, 0x1e, 0x200c);
94 if (err < 0)
95 return err;
96
97 err = phy_write(phydev, 0x1d, 0x5);
98 if (err < 0)
99 return err;
100
101 err = phy_write(phydev, 0x1e, 0);
102 if (err < 0)
103 return err;
104
105 err = phy_write(phydev, 0x1e, 0x100);
106 if (err < 0)
107 return err;
108
109
110 err = genphy_config_aneg(phydev);
111
112 return err;
113}
114
115
116static struct phy_driver m88e1101_driver = {
117 .phy_id = 0x01410c00,
118 .phy_id_mask = 0xffffff00,
119 .name = "Marvell 88E1101",
120 .features = PHY_GBIT_FEATURES,
121 .flags = PHY_HAS_INTERRUPT,
122 .config_aneg = &marvell_config_aneg,
123 .read_status = &genphy_read_status,
124 .ack_interrupt = &marvell_ack_interrupt,
125 .config_intr = &marvell_config_intr,
126 .driver = { .owner = THIS_MODULE,},
127};
128
129static int __init marvell_init(void)
130{
131 return phy_driver_register(&m88e1101_driver);
132}
133
134static void __exit marvell_exit(void)
135{
136 phy_driver_unregister(&m88e1101_driver);
137}
138
139module_init(marvell_init);
140module_exit(marvell_exit);
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
new file mode 100644
index 000000000000..41f62c0c5fcb
--- /dev/null
+++ b/drivers/net/phy/mdio_bus.c
@@ -0,0 +1,176 @@
1/*
2 * drivers/net/phy/mdio_bus.c
3 *
4 * MDIO Bus interface
5 *
6 * Author: Andy Fleming
7 *
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16#include <linux/config.h>
17#include <linux/kernel.h>
18#include <linux/sched.h>
19#include <linux/string.h>
20#include <linux/errno.h>
21#include <linux/unistd.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/skbuff.h>
29#include <linux/spinlock.h>
30#include <linux/mm.h>
31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h>
34#include <linux/ethtool.h>
35#include <linux/phy.h>
36
37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/uaccess.h>
40
41/* mdiobus_register
42 *
43 * description: Called by a bus driver to bring up all the PHYs
44 * on a given bus, and attach them to the bus
45 */
46int mdiobus_register(struct mii_bus *bus)
47{
48 int i;
49 int err = 0;
50
51 spin_lock_init(&bus->mdio_lock);
52
53 if (NULL == bus || NULL == bus->name ||
54 NULL == bus->read ||
55 NULL == bus->write)
56 return -EINVAL;
57
58 if (bus->reset)
59 bus->reset(bus);
60
61 for (i = 0; i < PHY_MAX_ADDR; i++) {
62 struct phy_device *phydev;
63
64 phydev = get_phy_device(bus, i);
65
66 if (IS_ERR(phydev))
67 return PTR_ERR(phydev);
68
69 /* There's a PHY at this address
70 * We need to set:
71 * 1) IRQ
72 * 2) bus_id
73 * 3) parent
74 * 4) bus
75 * 5) mii_bus
76 * And, we need to register it */
77 if (phydev) {
78 phydev->irq = bus->irq[i];
79
80 phydev->dev.parent = bus->dev;
81 phydev->dev.bus = &mdio_bus_type;
82 sprintf(phydev->dev.bus_id, "phy%d:%d", bus->id, i);
83
84 phydev->bus = bus;
85
86 err = device_register(&phydev->dev);
87
88 if (err)
89 printk(KERN_ERR "phy %d failed to register\n",
90 i);
91 }
92
93 bus->phy_map[i] = phydev;
94 }
95
96 pr_info("%s: probed\n", bus->name);
97
98 return err;
99}
100EXPORT_SYMBOL(mdiobus_register);
101
102void mdiobus_unregister(struct mii_bus *bus)
103{
104 int i;
105
106 for (i = 0; i < PHY_MAX_ADDR; i++) {
107 if (bus->phy_map[i]) {
108 device_unregister(&bus->phy_map[i]->dev);
109 kfree(bus->phy_map[i]);
110 }
111 }
112}
113EXPORT_SYMBOL(mdiobus_unregister);
114
115/* mdio_bus_match
116 *
117 * description: Given a PHY device, and a PHY driver, return 1 if
118 * the driver supports the device. Otherwise, return 0
119 */
120static int mdio_bus_match(struct device *dev, struct device_driver *drv)
121{
122 struct phy_device *phydev = to_phy_device(dev);
123 struct phy_driver *phydrv = to_phy_driver(drv);
124
125 return (phydrv->phy_id == (phydev->phy_id & phydrv->phy_id_mask));
126}
127
128/* Suspend and resume. Copied from platform_suspend and
129 * platform_resume
130 */
131static int mdio_bus_suspend(struct device * dev, u32 state)
132{
133 int ret = 0;
134 struct device_driver *drv = dev->driver;
135
136 if (drv && drv->suspend) {
137 ret = drv->suspend(dev, state, SUSPEND_DISABLE);
138 if (ret == 0)
139 ret = drv->suspend(dev, state, SUSPEND_SAVE_STATE);
140 if (ret == 0)
141 ret = drv->suspend(dev, state, SUSPEND_POWER_DOWN);
142 }
143 return ret;
144}
145
146static int mdio_bus_resume(struct device * dev)
147{
148 int ret = 0;
149 struct device_driver *drv = dev->driver;
150
151 if (drv && drv->resume) {
152 ret = drv->resume(dev, RESUME_POWER_ON);
153 if (ret == 0)
154 ret = drv->resume(dev, RESUME_RESTORE_STATE);
155 if (ret == 0)
156 ret = drv->resume(dev, RESUME_ENABLE);
157 }
158 return ret;
159}
160
161struct bus_type mdio_bus_type = {
162 .name = "mdio_bus",
163 .match = mdio_bus_match,
164 .suspend = mdio_bus_suspend,
165 .resume = mdio_bus_resume,
166};
167
168int __init mdio_bus_init(void)
169{
170 return bus_register(&mdio_bus_type);
171}
172
173void __exit mdio_bus_exit(void)
174{
175 bus_unregister(&mdio_bus_type);
176}
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
new file mode 100644
index 000000000000..d9e11f93bf3a
--- /dev/null
+++ b/drivers/net/phy/phy.c
@@ -0,0 +1,871 @@
1/*
2 * drivers/net/phy/phy.c
3 *
4 * Framework for configuring and reading PHY devices
5 * Based on code in sungem_phy.c and gianfar_phy.c
6 *
7 * Author: Andy Fleming
8 *
9 * Copyright (c) 2004 Freescale Semiconductor, Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17#include <linux/config.h>
18#include <linux/kernel.h>
19#include <linux/sched.h>
20#include <linux/string.h>
21#include <linux/errno.h>
22#include <linux/unistd.h>
23#include <linux/slab.h>
24#include <linux/interrupt.h>
25#include <linux/init.h>
26#include <linux/delay.h>
27#include <linux/netdevice.h>
28#include <linux/etherdevice.h>
29#include <linux/skbuff.h>
30#include <linux/spinlock.h>
31#include <linux/mm.h>
32#include <linux/module.h>
33#include <linux/version.h>
34#include <linux/mii.h>
35#include <linux/ethtool.h>
36#include <linux/phy.h>
37
38#include <asm/io.h>
39#include <asm/irq.h>
40#include <asm/uaccess.h>
41
42/* Convenience function to print out the current phy status
43 */
44void phy_print_status(struct phy_device *phydev)
45{
46 pr_info("%s: Link is %s", phydev->dev.bus_id,
47 phydev->link ? "Up" : "Down");
48 if (phydev->link)
49 printk(" - %d/%s", phydev->speed,
50 DUPLEX_FULL == phydev->duplex ?
51 "Full" : "Half");
52
53 printk("\n");
54}
55EXPORT_SYMBOL(phy_print_status);
56
57
58/* Convenience functions for reading/writing a given PHY
59 * register. They MUST NOT be called from interrupt context,
60 * because the bus read/write functions may wait for an interrupt
61 * to conclude the operation. */
62int phy_read(struct phy_device *phydev, u16 regnum)
63{
64 int retval;
65 struct mii_bus *bus = phydev->bus;
66
67 spin_lock_bh(&bus->mdio_lock);
68 retval = bus->read(bus, phydev->addr, regnum);
69 spin_unlock_bh(&bus->mdio_lock);
70
71 return retval;
72}
73EXPORT_SYMBOL(phy_read);
74
75int phy_write(struct phy_device *phydev, u16 regnum, u16 val)
76{
77 int err;
78 struct mii_bus *bus = phydev->bus;
79
80 spin_lock_bh(&bus->mdio_lock);
81 err = bus->write(bus, phydev->addr, regnum, val);
82 spin_unlock_bh(&bus->mdio_lock);
83
84 return err;
85}
86EXPORT_SYMBOL(phy_write);
87
88
89int phy_clear_interrupt(struct phy_device *phydev)
90{
91 int err = 0;
92
93 if (phydev->drv->ack_interrupt)
94 err = phydev->drv->ack_interrupt(phydev);
95
96 return err;
97}
98
99
100int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
101{
102 int err = 0;
103
104 phydev->interrupts = interrupts;
105 if (phydev->drv->config_intr)
106 err = phydev->drv->config_intr(phydev);
107
108 return err;
109}
110
111
112/* phy_aneg_done
113 *
114 * description: Reads the status register and returns 0 either if
115 * auto-negotiation is incomplete, or if there was an error.
116 * Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
117 */
118static inline int phy_aneg_done(struct phy_device *phydev)
119{
120 int retval;
121
122 retval = phy_read(phydev, MII_BMSR);
123
124 return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);
125}
126
127/* A structure for mapping a particular speed and duplex
128 * combination to a particular SUPPORTED and ADVERTISED value */
129struct phy_setting {
130 int speed;
131 int duplex;
132 u32 setting;
133};
134
135/* A mapping of all SUPPORTED settings to speed/duplex */
136static struct phy_setting settings[] = {
137 {
138 .speed = 10000,
139 .duplex = DUPLEX_FULL,
140 .setting = SUPPORTED_10000baseT_Full,
141 },
142 {
143 .speed = SPEED_1000,
144 .duplex = DUPLEX_FULL,
145 .setting = SUPPORTED_1000baseT_Full,
146 },
147 {
148 .speed = SPEED_1000,
149 .duplex = DUPLEX_HALF,
150 .setting = SUPPORTED_1000baseT_Half,
151 },
152 {
153 .speed = SPEED_100,
154 .duplex = DUPLEX_FULL,
155 .setting = SUPPORTED_100baseT_Full,
156 },
157 {
158 .speed = SPEED_100,
159 .duplex = DUPLEX_HALF,
160 .setting = SUPPORTED_100baseT_Half,
161 },
162 {
163 .speed = SPEED_10,
164 .duplex = DUPLEX_FULL,
165 .setting = SUPPORTED_10baseT_Full,
166 },
167 {
168 .speed = SPEED_10,
169 .duplex = DUPLEX_HALF,
170 .setting = SUPPORTED_10baseT_Half,
171 },
172};
173
174#define MAX_NUM_SETTINGS (sizeof(settings)/sizeof(struct phy_setting))
175
176/* phy_find_setting
177 *
178 * description: Searches the settings array for the setting which
179 * matches the desired speed and duplex, and returns the index
180 * of that setting. Returns the index of the last setting if
181 * none of the others match.
182 */
183static inline int phy_find_setting(int speed, int duplex)
184{
185 int idx = 0;
186
187 while (idx < ARRAY_SIZE(settings) &&
188 (settings[idx].speed != speed ||
189 settings[idx].duplex != duplex))
190 idx++;
191
192 return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1;
193}
194
195/* phy_find_valid
196 * idx: The first index in settings[] to search
197 * features: A mask of the valid settings
198 *
199 * description: Returns the index of the first valid setting less
200 * than or equal to the one pointed to by idx, as determined by
201 * the mask in features. Returns the index of the last setting
202 * if nothing else matches.
203 */
204static inline int phy_find_valid(int idx, u32 features)
205{
206 while (idx < MAX_NUM_SETTINGS && !(settings[idx].setting & features))
207 idx++;
208
209 return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1;
210}
211
212/* phy_sanitize_settings
213 *
214 * description: Make sure the PHY is set to supported speeds and
215 * duplexes. Drop down by one in this order: 1000/FULL,
216 * 1000/HALF, 100/FULL, 100/HALF, 10/FULL, 10/HALF
217 */
218void phy_sanitize_settings(struct phy_device *phydev)
219{
220 u32 features = phydev->supported;
221 int idx;
222
223 /* Sanitize settings based on PHY capabilities */
224 if ((features & SUPPORTED_Autoneg) == 0)
225 phydev->autoneg = 0;
226
227 idx = phy_find_valid(phy_find_setting(phydev->speed, phydev->duplex),
228 features);
229
230 phydev->speed = settings[idx].speed;
231 phydev->duplex = settings[idx].duplex;
232}
233EXPORT_SYMBOL(phy_sanitize_settings);
234
235/* phy_ethtool_sset:
236 * A generic ethtool sset function. Handles all the details
237 *
238 * A few notes about parameter checking:
239 * - We don't set port or transceiver, so we don't care what they
240 * were set to.
241 * - phy_start_aneg() will make sure forced settings are sane, and
242 * choose the next best ones from the ones selected, so we don't
243 * care if ethtool tries to give us bad values
244 *
245 * A note about the PHYCONTROL Layer. If you turn off
246 * CONFIG_PHYCONTROL, you will need to read the PHY status
247 * registers after this function completes, and update your
248 * controller manually.
249 */
250int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
251{
252 if (cmd->phy_address != phydev->addr)
253 return -EINVAL;
254
255 /* We make sure that we don't pass unsupported
256 * values in to the PHY */
257 cmd->advertising &= phydev->supported;
258
259 /* Verify the settings we care about. */
260 if (cmd->autoneg != AUTONEG_ENABLE && cmd->autoneg != AUTONEG_DISABLE)
261 return -EINVAL;
262
263 if (cmd->autoneg == AUTONEG_ENABLE && cmd->advertising == 0)
264 return -EINVAL;
265
266 if (cmd->autoneg == AUTONEG_DISABLE
267 && ((cmd->speed != SPEED_1000
268 && cmd->speed != SPEED_100
269 && cmd->speed != SPEED_10)
270 || (cmd->duplex != DUPLEX_HALF
271 && cmd->duplex != DUPLEX_FULL)))
272 return -EINVAL;
273
274 phydev->autoneg = cmd->autoneg;
275
276 phydev->speed = cmd->speed;
277
278 phydev->advertising = cmd->advertising;
279
280 if (AUTONEG_ENABLE == cmd->autoneg)
281 phydev->advertising |= ADVERTISED_Autoneg;
282 else
283 phydev->advertising &= ~ADVERTISED_Autoneg;
284
285 phydev->duplex = cmd->duplex;
286
287 /* Restart the PHY */
288 phy_start_aneg(phydev);
289
290 return 0;
291}
292
293int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
294{
295 cmd->supported = phydev->supported;
296
297 cmd->advertising = phydev->advertising;
298
299 cmd->speed = phydev->speed;
300 cmd->duplex = phydev->duplex;
301 cmd->port = PORT_MII;
302 cmd->phy_address = phydev->addr;
303 cmd->transceiver = XCVR_EXTERNAL;
304 cmd->autoneg = phydev->autoneg;
305
306 return 0;
307}
308
309
310/* Note that this function is currently incompatible with the
311 * PHYCONTROL layer. It changes registers without regard to
312 * current state. Use at own risk
313 */
314int phy_mii_ioctl(struct phy_device *phydev,
315 struct mii_ioctl_data *mii_data, int cmd)
316{
317 u16 val = mii_data->val_in;
318
319 switch (cmd) {
320 case SIOCGMIIPHY:
321 mii_data->phy_id = phydev->addr;
322 break;
323 case SIOCGMIIREG:
324 mii_data->val_out = phy_read(phydev, mii_data->reg_num);
325 break;
326
327 case SIOCSMIIREG:
328 if (!capable(CAP_NET_ADMIN))
329 return -EPERM;
330
331 if (mii_data->phy_id == phydev->addr) {
332 switch(mii_data->reg_num) {
333 case MII_BMCR:
334 if (val & (BMCR_RESET|BMCR_ANENABLE))
335 phydev->autoneg = AUTONEG_DISABLE;
336 else
337 phydev->autoneg = AUTONEG_ENABLE;
338 if ((!phydev->autoneg) && (val & BMCR_FULLDPLX))
339 phydev->duplex = DUPLEX_FULL;
340 else
341 phydev->duplex = DUPLEX_HALF;
342 break;
343 case MII_ADVERTISE:
344 phydev->advertising = val;
345 break;
346 default:
347 /* do nothing */
348 break;
349 }
350 }
351
352 phy_write(phydev, mii_data->reg_num, val);
353
354 if (mii_data->reg_num == MII_BMCR
355 && val & BMCR_RESET
356 && phydev->drv->config_init)
357 phydev->drv->config_init(phydev);
358 break;
359 }
360
361 return 0;
362}
363
364/* phy_start_aneg
365 *
366 * description: Sanitizes the settings (if we're not
367 * autonegotiating them), and then calls the driver's
368 * config_aneg function. If the PHYCONTROL Layer is operating,
369 * we change the state to reflect the beginning of
370 * Auto-negotiation or forcing.
371 */
372int phy_start_aneg(struct phy_device *phydev)
373{
374 int err;
375
376 spin_lock(&phydev->lock);
377
378 if (AUTONEG_DISABLE == phydev->autoneg)
379 phy_sanitize_settings(phydev);
380
381 err = phydev->drv->config_aneg(phydev);
382
383#ifdef CONFIG_PHYCONTROL
384 if (err < 0)
385 goto out_unlock;
386
387 if (phydev->state != PHY_HALTED) {
388 if (AUTONEG_ENABLE == phydev->autoneg) {
389 phydev->state = PHY_AN;
390 phydev->link_timeout = PHY_AN_TIMEOUT;
391 } else {
392 phydev->state = PHY_FORCING;
393 phydev->link_timeout = PHY_FORCE_TIMEOUT;
394 }
395 }
396
397out_unlock:
398#endif
399 spin_unlock(&phydev->lock);
400 return err;
401}
402EXPORT_SYMBOL(phy_start_aneg);
403
404
405#ifdef CONFIG_PHYCONTROL
406static void phy_change(void *data);
407static void phy_timer(unsigned long data);
408
409/* phy_start_machine:
410 *
411 * description: The PHY infrastructure can run a state machine
412 * which tracks whether the PHY is starting up, negotiating,
413 * etc. This function starts the timer which tracks the state
414 * of the PHY. If you want to be notified when the state
415 * changes, pass in the callback, otherwise, pass NULL. If you
416 * want to maintain your own state machine, do not call this
417 * function. */
418void phy_start_machine(struct phy_device *phydev,
419 void (*handler)(struct net_device *))
420{
421 phydev->adjust_state = handler;
422
423 init_timer(&phydev->phy_timer);
424 phydev->phy_timer.function = &phy_timer;
425 phydev->phy_timer.data = (unsigned long) phydev;
426 mod_timer(&phydev->phy_timer, jiffies + HZ);
427}
428
429/* phy_stop_machine
430 *
431 * description: Stops the state machine timer, sets the state to
432 * UP (unless it wasn't up yet), and then frees the interrupt,
433 * if it is in use. This function must be called BEFORE
434 * phy_detach.
435 */
436void phy_stop_machine(struct phy_device *phydev)
437{
438 del_timer_sync(&phydev->phy_timer);
439
440 spin_lock(&phydev->lock);
441 if (phydev->state > PHY_UP)
442 phydev->state = PHY_UP;
443 spin_unlock(&phydev->lock);
444
445 if (phydev->irq != PHY_POLL)
446 phy_stop_interrupts(phydev);
447
448 phydev->adjust_state = NULL;
449}
450
451/* phy_force_reduction
452 *
453 * description: Reduces the speed/duplex settings by
454 * one notch. The order is so:
455 * 1000/FULL, 1000/HALF, 100/FULL, 100/HALF,
456 * 10/FULL, 10/HALF. The function bottoms out at 10/HALF.
457 */
458static void phy_force_reduction(struct phy_device *phydev)
459{
460 int idx;
461
462 idx = phy_find_setting(phydev->speed, phydev->duplex);
463
464 idx++;
465
466 idx = phy_find_valid(idx, phydev->supported);
467
468 phydev->speed = settings[idx].speed;
469 phydev->duplex = settings[idx].duplex;
470
471 pr_info("Trying %d/%s\n", phydev->speed,
472 DUPLEX_FULL == phydev->duplex ?
473 "FULL" : "HALF");
474}
475
476
477/* phy_error:
478 *
479 * Moves the PHY to the HALTED state in response to a read
480 * or write error, and tells the controller the link is down.
481 * Must not be called from interrupt context, or while the
482 * phydev->lock is held.
483 */
484void phy_error(struct phy_device *phydev)
485{
486 spin_lock(&phydev->lock);
487 phydev->state = PHY_HALTED;
488 spin_unlock(&phydev->lock);
489}
490
491/* phy_interrupt
492 *
493 * description: When a PHY interrupt occurs, the handler disables
494 * interrupts, and schedules a work task to clear the interrupt.
495 */
496static irqreturn_t phy_interrupt(int irq, void *phy_dat, struct pt_regs *regs)
497{
498 struct phy_device *phydev = phy_dat;
499
500 /* The MDIO bus is not allowed to be written in interrupt
501 * context, so we need to disable the irq here. A work
502 * queue will write the PHY to disable and clear the
503 * interrupt, and then reenable the irq line. */
504 disable_irq_nosync(irq);
505
506 schedule_work(&phydev->phy_queue);
507
508 return IRQ_HANDLED;
509}
510
511/* Enable the interrupts from the PHY side */
512int phy_enable_interrupts(struct phy_device *phydev)
513{
514 int err;
515
516 err = phy_clear_interrupt(phydev);
517
518 if (err < 0)
519 return err;
520
521 err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
522
523 return err;
524}
525EXPORT_SYMBOL(phy_enable_interrupts);
526
527/* Disable the PHY interrupts from the PHY side */
528int phy_disable_interrupts(struct phy_device *phydev)
529{
530 int err;
531
532 /* Disable PHY interrupts */
533 err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
534
535 if (err)
536 goto phy_err;
537
538 /* Clear the interrupt */
539 err = phy_clear_interrupt(phydev);
540
541 if (err)
542 goto phy_err;
543
544 return 0;
545
546phy_err:
547 phy_error(phydev);
548
549 return err;
550}
551EXPORT_SYMBOL(phy_disable_interrupts);
552
553/* phy_start_interrupts
554 *
555 * description: Request the interrupt for the given PHY. If
556 * this fails, then we set irq to PHY_POLL.
557 * Otherwise, we enable the interrupts in the PHY.
558 * Returns 0 on success.
559 * This should only be called with a valid IRQ number.
560 */
561int phy_start_interrupts(struct phy_device *phydev)
562{
563 int err = 0;
564
565 INIT_WORK(&phydev->phy_queue, phy_change, phydev);
566
567 if (request_irq(phydev->irq, phy_interrupt,
568 SA_SHIRQ,
569 "phy_interrupt",
570 phydev) < 0) {
571 printk(KERN_WARNING "%s: Can't get IRQ %d (PHY)\n",
572 phydev->bus->name,
573 phydev->irq);
574 phydev->irq = PHY_POLL;
575 return 0;
576 }
577
578 err = phy_enable_interrupts(phydev);
579
580 return err;
581}
582EXPORT_SYMBOL(phy_start_interrupts);
583
584int phy_stop_interrupts(struct phy_device *phydev)
585{
586 int err;
587
588 err = phy_disable_interrupts(phydev);
589
590 if (err)
591 phy_error(phydev);
592
593 free_irq(phydev->irq, phydev);
594
595 return err;
596}
597EXPORT_SYMBOL(phy_stop_interrupts);
598
599
600/* Scheduled by the phy_interrupt/timer to handle PHY changes */
601static void phy_change(void *data)
602{
603 int err;
604 struct phy_device *phydev = data;
605
606 err = phy_disable_interrupts(phydev);
607
608 if (err)
609 goto phy_err;
610
611 spin_lock(&phydev->lock);
612 if ((PHY_RUNNING == phydev->state) || (PHY_NOLINK == phydev->state))
613 phydev->state = PHY_CHANGELINK;
614 spin_unlock(&phydev->lock);
615
616 enable_irq(phydev->irq);
617
618 /* Reenable interrupts */
619 err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
620
621 if (err)
622 goto irq_enable_err;
623
624 return;
625
626irq_enable_err:
627 disable_irq(phydev->irq);
628phy_err:
629 phy_error(phydev);
630}
631
632/* Bring down the PHY link, and stop checking the status. */
633void phy_stop(struct phy_device *phydev)
634{
635 spin_lock(&phydev->lock);
636
637 if (PHY_HALTED == phydev->state)
638 goto out_unlock;
639
640 if (phydev->irq != PHY_POLL) {
641 /* Clear any pending interrupts */
642 phy_clear_interrupt(phydev);
643
644 /* Disable PHY Interrupts */
645 phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
646 }
647
648 phydev->state = PHY_HALTED;
649
650out_unlock:
651 spin_unlock(&phydev->lock);
652}
653
654
655/* phy_start
656 *
657 * description: Indicates the attached device's readiness to
658 * handle PHY-related work. Used during startup to start the
659 * PHY, and after a call to phy_stop() to resume operation.
660 * Also used to indicate the MDIO bus has cleared an error
661 * condition.
662 */
663void phy_start(struct phy_device *phydev)
664{
665 spin_lock(&phydev->lock);
666
667 switch (phydev->state) {
668 case PHY_STARTING:
669 phydev->state = PHY_PENDING;
670 break;
671 case PHY_READY:
672 phydev->state = PHY_UP;
673 break;
674 case PHY_HALTED:
675 phydev->state = PHY_RESUMING;
676 default:
677 break;
678 }
679 spin_unlock(&phydev->lock);
680}
681EXPORT_SYMBOL(phy_stop);
682EXPORT_SYMBOL(phy_start);
683
684/* PHY timer which handles the state machine */
685static void phy_timer(unsigned long data)
686{
687 struct phy_device *phydev = (struct phy_device *)data;
688 int needs_aneg = 0;
689 int err = 0;
690
691 spin_lock(&phydev->lock);
692
693 if (phydev->adjust_state)
694 phydev->adjust_state(phydev->attached_dev);
695
696 switch(phydev->state) {
697 case PHY_DOWN:
698 case PHY_STARTING:
699 case PHY_READY:
700 case PHY_PENDING:
701 break;
702 case PHY_UP:
703 needs_aneg = 1;
704
705 phydev->link_timeout = PHY_AN_TIMEOUT;
706
707 break;
708 case PHY_AN:
709 /* Check if negotiation is done. Break
710 * if there's an error */
711 err = phy_aneg_done(phydev);
712 if (err < 0)
713 break;
714
715 /* If auto-negotiation is done, we change to
716 * either RUNNING, or NOLINK */
717 if (err > 0) {
718 err = phy_read_status(phydev);
719
720 if (err)
721 break;
722
723 if (phydev->link) {
724 phydev->state = PHY_RUNNING;
725 netif_carrier_on(phydev->attached_dev);
726 } else {
727 phydev->state = PHY_NOLINK;
728 netif_carrier_off(phydev->attached_dev);
729 }
730
731 phydev->adjust_link(phydev->attached_dev);
732
733 } else if (0 == phydev->link_timeout--) {
734 /* The counter expired, so either we
735 * switch to forced mode, or the
736 * magic_aneg bit exists, and we try aneg
737 * again */
738 if (!(phydev->drv->flags & PHY_HAS_MAGICANEG)) {
739 int idx;
740
741 /* We'll start from the
742 * fastest speed, and work
743 * our way down */
744 idx = phy_find_valid(0,
745 phydev->supported);
746
747 phydev->speed = settings[idx].speed;
748 phydev->duplex = settings[idx].duplex;
749
750 phydev->autoneg = AUTONEG_DISABLE;
751 phydev->state = PHY_FORCING;
752 phydev->link_timeout =
753 PHY_FORCE_TIMEOUT;
754
755 pr_info("Trying %d/%s\n",
756 phydev->speed,
757 DUPLEX_FULL ==
758 phydev->duplex ?
759 "FULL" : "HALF");
760 }
761
762 needs_aneg = 1;
763 }
764 break;
765 case PHY_NOLINK:
766 err = phy_read_status(phydev);
767
768 if (err)
769 break;
770
771 if (phydev->link) {
772 phydev->state = PHY_RUNNING;
773 netif_carrier_on(phydev->attached_dev);
774 phydev->adjust_link(phydev->attached_dev);
775 }
776 break;
777 case PHY_FORCING:
778 err = phy_read_status(phydev);
779
780 if (err)
781 break;
782
783 if (phydev->link) {
784 phydev->state = PHY_RUNNING;
785 netif_carrier_on(phydev->attached_dev);
786 } else {
787 if (0 == phydev->link_timeout--) {
788 phy_force_reduction(phydev);
789 needs_aneg = 1;
790 }
791 }
792
793 phydev->adjust_link(phydev->attached_dev);
794 break;
795 case PHY_RUNNING:
796 /* Only register a CHANGE if we are
797 * polling */
798 if (PHY_POLL == phydev->irq)
799 phydev->state = PHY_CHANGELINK;
800 break;
801 case PHY_CHANGELINK:
802 err = phy_read_status(phydev);
803
804 if (err)
805 break;
806
807 if (phydev->link) {
808 phydev->state = PHY_RUNNING;
809 netif_carrier_on(phydev->attached_dev);
810 } else {
811 phydev->state = PHY_NOLINK;
812 netif_carrier_off(phydev->attached_dev);
813 }
814
815 phydev->adjust_link(phydev->attached_dev);
816
817 if (PHY_POLL != phydev->irq)
818 err = phy_config_interrupt(phydev,
819 PHY_INTERRUPT_ENABLED);
820 break;
821 case PHY_HALTED:
822 if (phydev->link) {
823 phydev->link = 0;
824 netif_carrier_off(phydev->attached_dev);
825 phydev->adjust_link(phydev->attached_dev);
826 }
827 break;
828 case PHY_RESUMING:
829
830 err = phy_clear_interrupt(phydev);
831
832 if (err)
833 break;
834
835 err = phy_config_interrupt(phydev,
836 PHY_INTERRUPT_ENABLED);
837
838 if (err)
839 break;
840
841 if (AUTONEG_ENABLE == phydev->autoneg) {
842 err = phy_aneg_done(phydev);
843 if (err < 0)
844 break;
845
846 /* err > 0 if AN is done.
847 * Otherwise, it's 0, and we're
848 * still waiting for AN */
849 if (err > 0) {
850 phydev->state = PHY_RUNNING;
851 } else {
852 phydev->state = PHY_AN;
853 phydev->link_timeout = PHY_AN_TIMEOUT;
854 }
855 } else
856 phydev->state = PHY_RUNNING;
857 break;
858 }
859
860 spin_unlock(&phydev->lock);
861
862 if (needs_aneg)
863 err = phy_start_aneg(phydev);
864
865 if (err < 0)
866 phy_error(phydev);
867
868 mod_timer(&phydev->phy_timer, jiffies + PHY_STATE_TIME * HZ);
869}
870
871#endif /* CONFIG_PHYCONTROL */
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
new file mode 100644
index 000000000000..33f7bdb5857c
--- /dev/null
+++ b/drivers/net/phy/phy_device.c
@@ -0,0 +1,696 @@
1/*
2 * drivers/net/phy/phy_device.c
3 *
4 * Framework for finding and configuring PHYs.
5 * Also contains generic PHY driver
6 *
7 * Author: Andy Fleming
8 *
9 * Copyright (c) 2004 Freescale Semiconductor, Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17#include <linux/config.h>
18#include <linux/kernel.h>
19#include <linux/sched.h>
20#include <linux/string.h>
21#include <linux/errno.h>
22#include <linux/unistd.h>
23#include <linux/slab.h>
24#include <linux/interrupt.h>
25#include <linux/init.h>
26#include <linux/delay.h>
27#include <linux/netdevice.h>
28#include <linux/etherdevice.h>
29#include <linux/skbuff.h>
30#include <linux/spinlock.h>
31#include <linux/mm.h>
32#include <linux/module.h>
33#include <linux/version.h>
34#include <linux/mii.h>
35#include <linux/ethtool.h>
36#include <linux/phy.h>
37
38#include <asm/io.h>
39#include <asm/irq.h>
40#include <asm/uaccess.h>
41
42static struct phy_driver genphy_driver;
43extern int mdio_bus_init(void);
44extern void mdio_bus_exit(void);
45
46/* get_phy_device
47 *
48 * description: Reads the ID registers of the PHY at addr on the
49 * bus, then allocates and returns the phy_device to
50 * represent it.
51 */
52struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
53{
54 int phy_reg;
55 u32 phy_id;
56 struct phy_device *dev = NULL;
57
58 /* Grab the bits from PHYIR1, and put them
59 * in the upper half */
60 phy_reg = bus->read(bus, addr, MII_PHYSID1);
61
62 if (phy_reg < 0)
63 return ERR_PTR(phy_reg);
64
65 phy_id = (phy_reg & 0xffff) << 16;
66
67 /* Grab the bits from PHYIR2, and put them in the lower half */
68 phy_reg = bus->read(bus, addr, MII_PHYSID2);
69
70 if (phy_reg < 0)
71 return ERR_PTR(phy_reg);
72
73 phy_id |= (phy_reg & 0xffff);
74
75 /* If the phy_id is all Fs, there is no device there */
76 if (0xffffffff == phy_id)
77 return NULL;
78
79 /* Otherwise, we allocate the device, and initialize the
80 * default values */
81 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
82
83 if (NULL == dev)
84 return ERR_PTR(-ENOMEM);
85
86 dev->speed = 0;
87 dev->duplex = -1;
88 dev->pause = dev->asym_pause = 0;
89 dev->link = 1;
90
91 dev->autoneg = AUTONEG_ENABLE;
92
93 dev->addr = addr;
94 dev->phy_id = phy_id;
95 dev->bus = bus;
96
97 dev->state = PHY_DOWN;
98
99 spin_lock_init(&dev->lock);
100
101 return dev;
102}
103
104#ifdef CONFIG_PHYCONTROL
105/* phy_prepare_link:
106 *
107 * description: Tells the PHY infrastructure to handle the
108 * gory details on monitoring link status (whether through
109 * polling or an interrupt), and to call back to the
110 * connected device driver when the link status changes.
111 * If you want to monitor your own link state, don't call
112 * this function */
113void phy_prepare_link(struct phy_device *phydev,
114 void (*handler)(struct net_device *))
115{
116 phydev->adjust_link = handler;
117}
118
119/* phy_connect:
120 *
121 * description: Convenience function for connecting ethernet
122 * devices to PHY devices. The default behavior is for
123 * the PHY infrastructure to handle everything, and only notify
124 * the connected driver when the link status changes. If you
125 * don't want, or can't use the provided functionality, you may
126 * choose to call only the subset of functions which provide
127 * the desired functionality.
128 */
129struct phy_device * phy_connect(struct net_device *dev, const char *phy_id,
130 void (*handler)(struct net_device *), u32 flags)
131{
132 struct phy_device *phydev;
133
134 phydev = phy_attach(dev, phy_id, flags);
135
136 if (IS_ERR(phydev))
137 return phydev;
138
139 phy_prepare_link(phydev, handler);
140
141 phy_start_machine(phydev, NULL);
142
143 if (phydev->irq > 0)
144 phy_start_interrupts(phydev);
145
146 return phydev;
147}
148EXPORT_SYMBOL(phy_connect);
149
150void phy_disconnect(struct phy_device *phydev)
151{
152 if (phydev->irq > 0)
153 phy_stop_interrupts(phydev);
154
155 phy_stop_machine(phydev);
156
157 phydev->adjust_link = NULL;
158
159 phy_detach(phydev);
160}
161EXPORT_SYMBOL(phy_disconnect);
162
163#endif /* CONFIG_PHYCONTROL */
164
165/* phy_attach:
166 *
167 * description: Called by drivers to attach to a particular PHY
168 * device. The phy_device is found, and properly hooked up
169 * to the phy_driver. If no driver is attached, then the
170 * genphy_driver is used. The phy_device is given a ptr to
171 * the attaching device, and given a callback for link status
172 * change. The phy_device is returned to the attaching
173 * driver.
174 */
175static int phy_compare_id(struct device *dev, void *data)
176{
177 return strcmp((char *)data, dev->bus_id) ? 0 : 1;
178}
179
180struct phy_device *phy_attach(struct net_device *dev,
181 const char *phy_id, u32 flags)
182{
183 struct bus_type *bus = &mdio_bus_type;
184 struct phy_device *phydev;
185 struct device *d;
186
187 /* Search the list of PHY devices on the mdio bus for the
188 * PHY with the requested name */
189 d = bus_find_device(bus, NULL, (void *)phy_id, phy_compare_id);
190
191 if (d) {
192 phydev = to_phy_device(d);
193 } else {
194 printk(KERN_ERR "%s not found\n", phy_id);
195 return ERR_PTR(-ENODEV);
196 }
197
198 /* Assume that if there is no driver, that it doesn't
199 * exist, and we should use the genphy driver. */
200 if (NULL == d->driver) {
201 int err;
202 down_write(&d->bus->subsys.rwsem);
203 d->driver = &genphy_driver.driver;
204
205 err = d->driver->probe(d);
206
207 if (err < 0)
208 return ERR_PTR(err);
209
210 device_bind_driver(d);
211 up_write(&d->bus->subsys.rwsem);
212 }
213
214 if (phydev->attached_dev) {
215 printk(KERN_ERR "%s: %s already attached\n",
216 dev->name, phy_id);
217 return ERR_PTR(-EBUSY);
218 }
219
220 phydev->attached_dev = dev;
221
222 phydev->dev_flags = flags;
223
224 return phydev;
225}
226EXPORT_SYMBOL(phy_attach);
227
228void phy_detach(struct phy_device *phydev)
229{
230 phydev->attached_dev = NULL;
231
232 /* If the device had no specific driver before (i.e. - it
233 * was using the generic driver), we unbind the device
234 * from the generic driver so that there's a chance a
235 * real driver could be loaded */
236 if (phydev->dev.driver == &genphy_driver.driver) {
237 down_write(&phydev->dev.bus->subsys.rwsem);
238 device_release_driver(&phydev->dev);
239 up_write(&phydev->dev.bus->subsys.rwsem);
240 }
241}
242EXPORT_SYMBOL(phy_detach);
243
244
245/* Generic PHY support and helper functions */
246
247/* genphy_config_advert
248 *
249 * description: Writes MII_ADVERTISE with the appropriate values,
250 * after sanitizing the values to make sure we only advertise
251 * what is supported
252 */
253int genphy_config_advert(struct phy_device *phydev)
254{
255 u32 advertise;
256 int adv;
257 int err;
258
259 /* Only allow advertising what
260 * this PHY supports */
261 phydev->advertising &= phydev->supported;
262 advertise = phydev->advertising;
263
264 /* Setup standard advertisement */
265 adv = phy_read(phydev, MII_ADVERTISE);
266
267 if (adv < 0)
268 return adv;
269
270 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP |
271 ADVERTISE_PAUSE_ASYM);
272 if (advertise & ADVERTISED_10baseT_Half)
273 adv |= ADVERTISE_10HALF;
274 if (advertise & ADVERTISED_10baseT_Full)
275 adv |= ADVERTISE_10FULL;
276 if (advertise & ADVERTISED_100baseT_Half)
277 adv |= ADVERTISE_100HALF;
278 if (advertise & ADVERTISED_100baseT_Full)
279 adv |= ADVERTISE_100FULL;
280 if (advertise & ADVERTISED_Pause)
281 adv |= ADVERTISE_PAUSE_CAP;
282 if (advertise & ADVERTISED_Asym_Pause)
283 adv |= ADVERTISE_PAUSE_ASYM;
284
285 err = phy_write(phydev, MII_ADVERTISE, adv);
286
287 if (err < 0)
288 return err;
289
290 /* Configure gigabit if it's supported */
291 if (phydev->supported & (SUPPORTED_1000baseT_Half |
292 SUPPORTED_1000baseT_Full)) {
293 adv = phy_read(phydev, MII_CTRL1000);
294
295 if (adv < 0)
296 return adv;
297
298 adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
299 if (advertise & SUPPORTED_1000baseT_Half)
300 adv |= ADVERTISE_1000HALF;
301 if (advertise & SUPPORTED_1000baseT_Full)
302 adv |= ADVERTISE_1000FULL;
303 err = phy_write(phydev, MII_CTRL1000, adv);
304
305 if (err < 0)
306 return err;
307 }
308
309 return adv;
310}
311EXPORT_SYMBOL(genphy_config_advert);
312
313/* genphy_setup_forced
314 *
315 * description: Configures MII_BMCR to force speed/duplex
316 * to the values in phydev. Assumes that the values are valid.
317 * Please see phy_sanitize_settings() */
318int genphy_setup_forced(struct phy_device *phydev)
319{
320 int ctl = BMCR_RESET;
321
322 phydev->pause = phydev->asym_pause = 0;
323
324 if (SPEED_1000 == phydev->speed)
325 ctl |= BMCR_SPEED1000;
326 else if (SPEED_100 == phydev->speed)
327 ctl |= BMCR_SPEED100;
328
329 if (DUPLEX_FULL == phydev->duplex)
330 ctl |= BMCR_FULLDPLX;
331
332 ctl = phy_write(phydev, MII_BMCR, ctl);
333
334 if (ctl < 0)
335 return ctl;
336
337 /* We just reset the device, so we'd better configure any
338 * settings the PHY requires to operate */
339 if (phydev->drv->config_init)
340 ctl = phydev->drv->config_init(phydev);
341
342 return ctl;
343}
344
345
346/* Enable and Restart Autonegotiation */
347int genphy_restart_aneg(struct phy_device *phydev)
348{
349 int ctl;
350
351 ctl = phy_read(phydev, MII_BMCR);
352
353 if (ctl < 0)
354 return ctl;
355
356 ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
357
358 /* Don't isolate the PHY if we're negotiating */
359 ctl &= ~(BMCR_ISOLATE);
360
361 ctl = phy_write(phydev, MII_BMCR, ctl);
362
363 return ctl;
364}
365
366
367/* genphy_config_aneg
368 *
369 * description: If auto-negotiation is enabled, we configure the
370 * advertising, and then restart auto-negotiation. If it is not
371 * enabled, then we write the BMCR
372 */
373int genphy_config_aneg(struct phy_device *phydev)
374{
375 int err = 0;
376
377 if (AUTONEG_ENABLE == phydev->autoneg) {
378 err = genphy_config_advert(phydev);
379
380 if (err < 0)
381 return err;
382
383 err = genphy_restart_aneg(phydev);
384 } else
385 err = genphy_setup_forced(phydev);
386
387 return err;
388}
389EXPORT_SYMBOL(genphy_config_aneg);
390
391/* genphy_update_link
392 *
393 * description: Update the value in phydev->link to reflect the
394 * current link value. In order to do this, we need to read
395 * the status register twice, keeping the second value
396 */
397int genphy_update_link(struct phy_device *phydev)
398{
399 int status;
400
401 /* Do a fake read */
402 status = phy_read(phydev, MII_BMSR);
403
404 if (status < 0)
405 return status;
406
407 /* Read link and autonegotiation status */
408 status = phy_read(phydev, MII_BMSR);
409
410 if (status < 0)
411 return status;
412
413 if ((status & BMSR_LSTATUS) == 0)
414 phydev->link = 0;
415 else
416 phydev->link = 1;
417
418 return 0;
419}
420
421/* genphy_read_status
422 *
423 * description: Check the link, then figure out the current state
424 * by comparing what we advertise with what the link partner
425 * advertises. Start by checking the gigabit possibilities,
426 * then move on to 10/100.
427 */
428int genphy_read_status(struct phy_device *phydev)
429{
430 int adv;
431 int err;
432 int lpa;
433 int lpagb = 0;
434
435 /* Update the link, but return if there
436 * was an error */
437 err = genphy_update_link(phydev);
438 if (err)
439 return err;
440
441 if (AUTONEG_ENABLE == phydev->autoneg) {
442 if (phydev->supported & (SUPPORTED_1000baseT_Half
443 | SUPPORTED_1000baseT_Full)) {
444 lpagb = phy_read(phydev, MII_STAT1000);
445
446 if (lpagb < 0)
447 return lpagb;
448
449 adv = phy_read(phydev, MII_CTRL1000);
450
451 if (adv < 0)
452 return adv;
453
454 lpagb &= adv << 2;
455 }
456
457 lpa = phy_read(phydev, MII_LPA);
458
459 if (lpa < 0)
460 return lpa;
461
462 adv = phy_read(phydev, MII_ADVERTISE);
463
464 if (adv < 0)
465 return adv;
466
467 lpa &= adv;
468
469 phydev->speed = SPEED_10;
470 phydev->duplex = DUPLEX_HALF;
471 phydev->pause = phydev->asym_pause = 0;
472
473 if (lpagb & (LPA_1000FULL | LPA_1000HALF)) {
474 phydev->speed = SPEED_1000;
475
476 if (lpagb & LPA_1000FULL)
477 phydev->duplex = DUPLEX_FULL;
478 } else if (lpa & (LPA_100FULL | LPA_100HALF)) {
479 phydev->speed = SPEED_100;
480
481 if (lpa & LPA_100FULL)
482 phydev->duplex = DUPLEX_FULL;
483 } else
484 if (lpa & LPA_10FULL)
485 phydev->duplex = DUPLEX_FULL;
486
487 if (phydev->duplex == DUPLEX_FULL){
488 phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
489 phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
490 }
491 } else {
492 int bmcr = phy_read(phydev, MII_BMCR);
493 if (bmcr < 0)
494 return bmcr;
495
496 if (bmcr & BMCR_FULLDPLX)
497 phydev->duplex = DUPLEX_FULL;
498 else
499 phydev->duplex = DUPLEX_HALF;
500
501 if (bmcr & BMCR_SPEED1000)
502 phydev->speed = SPEED_1000;
503 else if (bmcr & BMCR_SPEED100)
504 phydev->speed = SPEED_100;
505 else
506 phydev->speed = SPEED_10;
507
508 phydev->pause = phydev->asym_pause = 0;
509 }
510
511 return 0;
512}
513EXPORT_SYMBOL(genphy_read_status);
514
515static int genphy_config_init(struct phy_device *phydev)
516{
517 u32 val;
518 u32 features;
519
520 /* For now, I'll claim that the generic driver supports
521 * all possible port types */
522 features = (SUPPORTED_TP | SUPPORTED_MII
523 | SUPPORTED_AUI | SUPPORTED_FIBRE |
524 SUPPORTED_BNC);
525
526 /* Do we support autonegotiation? */
527 val = phy_read(phydev, MII_BMSR);
528
529 if (val < 0)
530 return val;
531
532 if (val & BMSR_ANEGCAPABLE)
533 features |= SUPPORTED_Autoneg;
534
535 if (val & BMSR_100FULL)
536 features |= SUPPORTED_100baseT_Full;
537 if (val & BMSR_100HALF)
538 features |= SUPPORTED_100baseT_Half;
539 if (val & BMSR_10FULL)
540 features |= SUPPORTED_10baseT_Full;
541 if (val & BMSR_10HALF)
542 features |= SUPPORTED_10baseT_Half;
543
544 if (val & BMSR_ESTATEN) {
545 val = phy_read(phydev, MII_ESTATUS);
546
547 if (val < 0)
548 return val;
549
550 if (val & ESTATUS_1000_TFULL)
551 features |= SUPPORTED_1000baseT_Full;
552 if (val & ESTATUS_1000_THALF)
553 features |= SUPPORTED_1000baseT_Half;
554 }
555
556 phydev->supported = features;
557 phydev->advertising = features;
558
559 return 0;
560}
561
562
563/* phy_probe
564 *
565 * description: Take care of setting up the phy_device structure,
566 * set the state to READY (the driver's init function should
567 * set it to STARTING if needed).
568 */
569static int phy_probe(struct device *dev)
570{
571 struct phy_device *phydev;
572 struct phy_driver *phydrv;
573 struct device_driver *drv;
574 int err = 0;
575
576 phydev = to_phy_device(dev);
577
578 /* Make sure the driver is held.
579 * XXX -- Is this correct? */
580 drv = get_driver(phydev->dev.driver);
581 phydrv = to_phy_driver(drv);
582 phydev->drv = phydrv;
583
584 /* Disable the interrupt if the PHY doesn't support it */
585 if (!(phydrv->flags & PHY_HAS_INTERRUPT))
586 phydev->irq = PHY_POLL;
587
588 spin_lock(&phydev->lock);
589
590 /* Start out supporting everything. Eventually,
591 * a controller will attach, and may modify one
592 * or both of these values */
593 phydev->supported = phydrv->features;
594 phydev->advertising = phydrv->features;
595
596 /* Set the state to READY by default */
597 phydev->state = PHY_READY;
598
599 if (phydev->drv->probe)
600 err = phydev->drv->probe(phydev);
601
602 spin_unlock(&phydev->lock);
603
604 if (err < 0)
605 return err;
606
607 if (phydev->drv->config_init)
608 err = phydev->drv->config_init(phydev);
609
610 return err;
611}
612
613static int phy_remove(struct device *dev)
614{
615 struct phy_device *phydev;
616
617 phydev = to_phy_device(dev);
618
619 spin_lock(&phydev->lock);
620 phydev->state = PHY_DOWN;
621 spin_unlock(&phydev->lock);
622
623 if (phydev->drv->remove)
624 phydev->drv->remove(phydev);
625
626 put_driver(dev->driver);
627 phydev->drv = NULL;
628
629 return 0;
630}
631
632int phy_driver_register(struct phy_driver *new_driver)
633{
634 int retval;
635
636 memset(&new_driver->driver, 0, sizeof(new_driver->driver));
637 new_driver->driver.name = new_driver->name;
638 new_driver->driver.bus = &mdio_bus_type;
639 new_driver->driver.probe = phy_probe;
640 new_driver->driver.remove = phy_remove;
641
642 retval = driver_register(&new_driver->driver);
643
644 if (retval) {
645 printk(KERN_ERR "%s: Error %d in registering driver\n",
646 new_driver->name, retval);
647
648 return retval;
649 }
650
651 pr_info("%s: Registered new driver\n", new_driver->name);
652
653 return 0;
654}
655EXPORT_SYMBOL(phy_driver_register);
656
657void phy_driver_unregister(struct phy_driver *drv)
658{
659 driver_unregister(&drv->driver);
660}
661EXPORT_SYMBOL(phy_driver_unregister);
662
663static struct phy_driver genphy_driver = {
664 .phy_id = 0xffffffff,
665 .phy_id_mask = 0xffffffff,
666 .name = "Generic PHY",
667 .config_init = genphy_config_init,
668 .features = 0,
669 .config_aneg = genphy_config_aneg,
670 .read_status = genphy_read_status,
671 .driver = {.owner= THIS_MODULE, },
672};
673
674static int __init phy_init(void)
675{
676 int rc;
677
678 rc = mdio_bus_init();
679 if (rc)
680 return rc;
681
682 rc = phy_driver_register(&genphy_driver);
683 if (rc)
684 mdio_bus_exit();
685
686 return rc;
687}
688
689static void __exit phy_exit(void)
690{
691 phy_driver_unregister(&genphy_driver);
692 mdio_bus_exit();
693}
694
695subsys_initcall(phy_init);
696module_exit(phy_exit);
diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c
new file mode 100644
index 000000000000..d461ba457631
--- /dev/null
+++ b/drivers/net/phy/qsemi.c
@@ -0,0 +1,143 @@
1/*
2 * drivers/net/phy/qsemi.c
3 *
4 * Driver for Quality Semiconductor PHYs
5 *
6 * Author: Andy Fleming
7 *
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16#include <linux/config.h>
17#include <linux/kernel.h>
18#include <linux/sched.h>
19#include <linux/string.h>
20#include <linux/errno.h>
21#include <linux/unistd.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/skbuff.h>
29#include <linux/spinlock.h>
30#include <linux/mm.h>
31#include <linux/module.h>
32#include <linux/version.h>
33#include <linux/mii.h>
34#include <linux/ethtool.h>
35#include <linux/phy.h>
36
37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/uaccess.h>
40
41/* ------------------------------------------------------------------------- */
42/* The Quality Semiconductor QS6612 is used on the RPX CLLF */
43
44/* register definitions */
45
46#define MII_QS6612_MCR 17 /* Mode Control Register */
47#define MII_QS6612_FTR 27 /* Factory Test Register */
48#define MII_QS6612_MCO 28 /* Misc. Control Register */
49#define MII_QS6612_ISR 29 /* Interrupt Source Register */
50#define MII_QS6612_IMR 30 /* Interrupt Mask Register */
51#define MII_QS6612_IMR_INIT 0x003a
52#define MII_QS6612_PCR 31 /* 100BaseTx PHY Control Reg. */
53
54#define QS6612_PCR_AN_COMPLETE 0x1000
55#define QS6612_PCR_RLBEN 0x0200
56#define QS6612_PCR_DCREN 0x0100
57#define QS6612_PCR_4B5BEN 0x0040
58#define QS6612_PCR_TX_ISOLATE 0x0020
59#define QS6612_PCR_MLT3_DIS 0x0002
60#define QS6612_PCR_SCRM_DESCRM 0x0001
61
62MODULE_DESCRIPTION("Quality Semiconductor PHY driver");
63MODULE_AUTHOR("Andy Fleming");
64MODULE_LICENSE("GPL");
65
66/* Returns 0, unless there's a write error */
67static int qs6612_config_init(struct phy_device *phydev)
68{
69 /* The PHY powers up isolated on the RPX,
70 * so send a command to allow operation.
71 * XXX - My docs indicate this should be 0x0940
72 * ...or something. The current value sets three
73 * reserved bits, bit 11, which specifies it should be
74 * set to one, bit 10, which specifies it should be set
75 * to 0, and bit 7, which doesn't specify. However, my
76 * docs are preliminary, and I will leave it like this
77 * until someone more knowledgable corrects me or it.
78 * -- Andy Fleming
79 */
80 return phy_write(phydev, MII_QS6612_PCR, 0x0dc0);
81}
82
83static int qs6612_ack_interrupt(struct phy_device *phydev)
84{
85 int err;
86
87 err = phy_read(phydev, MII_QS6612_ISR);
88
89 if (err < 0)
90 return err;
91
92 err = phy_read(phydev, MII_BMSR);
93
94 if (err < 0)
95 return err;
96
97 err = phy_read(phydev, MII_EXPANSION);
98
99 if (err < 0)
100 return err;
101
102 return 0;
103}
104
105static int qs6612_config_intr(struct phy_device *phydev)
106{
107 int err;
108 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
109 err = phy_write(phydev, MII_QS6612_IMR,
110 MII_QS6612_IMR_INIT);
111 else
112 err = phy_write(phydev, MII_QS6612_IMR, 0);
113
114 return err;
115
116}
117
118static struct phy_driver qs6612_driver = {
119 .phy_id = 0x00181440,
120 .name = "QS6612",
121 .phy_id_mask = 0xfffffff0,
122 .features = PHY_BASIC_FEATURES,
123 .flags = PHY_HAS_INTERRUPT,
124 .config_init = qs6612_config_init,
125 .config_aneg = genphy_config_aneg,
126 .read_status = genphy_read_status,
127 .ack_interrupt = qs6612_ack_interrupt,
128 .config_intr = qs6612_config_intr,
129 .driver = { .owner = THIS_MODULE,},
130};
131
132static int __init qs6612_init(void)
133{
134 return phy_driver_register(&qs6612_driver);
135}
136
137static void __exit qs6612_exit(void)
138{
139 phy_driver_unregister(&qs6612_driver);
140}
141
142module_init(qs6612_init);
143module_exit(qs6612_exit);
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index f4b62405d2e5..1bd22cd40c75 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -160,7 +160,7 @@ static struct net_device_stats *plip_get_stats(struct net_device *dev);
160static int plip_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); 160static int plip_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
161static int plip_preempt(void *handle); 161static int plip_preempt(void *handle);
162static void plip_wakeup(void *handle); 162static void plip_wakeup(void *handle);
163 163
164enum plip_connection_state { 164enum plip_connection_state {
165 PLIP_CN_NONE=0, 165 PLIP_CN_NONE=0,
166 PLIP_CN_RECEIVE, 166 PLIP_CN_RECEIVE,
@@ -231,8 +231,8 @@ struct net_local {
231 atomic_t kill_timer; 231 atomic_t kill_timer;
232 struct semaphore killed_timer_sem; 232 struct semaphore killed_timer_sem;
233}; 233};
234 234
235inline static void enable_parport_interrupts (struct net_device *dev) 235static inline void enable_parport_interrupts (struct net_device *dev)
236{ 236{
237 if (dev->irq != -1) 237 if (dev->irq != -1)
238 { 238 {
@@ -242,7 +242,7 @@ inline static void enable_parport_interrupts (struct net_device *dev)
242 } 242 }
243} 243}
244 244
245inline static void disable_parport_interrupts (struct net_device *dev) 245static inline void disable_parport_interrupts (struct net_device *dev)
246{ 246{
247 if (dev->irq != -1) 247 if (dev->irq != -1)
248 { 248 {
@@ -252,7 +252,7 @@ inline static void disable_parport_interrupts (struct net_device *dev)
252 } 252 }
253} 253}
254 254
255inline static void write_data (struct net_device *dev, unsigned char data) 255static inline void write_data (struct net_device *dev, unsigned char data)
256{ 256{
257 struct parport *port = 257 struct parport *port =
258 ((struct net_local *)dev->priv)->pardev->port; 258 ((struct net_local *)dev->priv)->pardev->port;
@@ -260,14 +260,14 @@ inline static void write_data (struct net_device *dev, unsigned char data)
260 port->ops->write_data (port, data); 260 port->ops->write_data (port, data);
261} 261}
262 262
263inline static unsigned char read_status (struct net_device *dev) 263static inline unsigned char read_status (struct net_device *dev)
264{ 264{
265 struct parport *port = 265 struct parport *port =
266 ((struct net_local *)dev->priv)->pardev->port; 266 ((struct net_local *)dev->priv)->pardev->port;
267 267
268 return port->ops->read_status (port); 268 return port->ops->read_status (port);
269} 269}
270 270
271/* Entry point of PLIP driver. 271/* Entry point of PLIP driver.
272 Probe the hardware, and register/initialize the driver. 272 Probe the hardware, and register/initialize the driver.
273 273
@@ -316,7 +316,7 @@ plip_init_netdev(struct net_device *dev)
316 316
317 spin_lock_init(&nl->lock); 317 spin_lock_init(&nl->lock);
318} 318}
319 319
320/* Bottom half handler for the delayed request. 320/* Bottom half handler for the delayed request.
321 This routine is kicked by do_timer(). 321 This routine is kicked by do_timer().
322 Request `plip_bh' to be invoked. */ 322 Request `plip_bh' to be invoked. */
@@ -471,7 +471,7 @@ plip_bh_timeout_error(struct net_device *dev, struct net_local *nl,
471 471
472 return TIMEOUT; 472 return TIMEOUT;
473} 473}
474 474
475static int 475static int
476plip_none(struct net_device *dev, struct net_local *nl, 476plip_none(struct net_device *dev, struct net_local *nl,
477 struct plip_local *snd, struct plip_local *rcv) 477 struct plip_local *snd, struct plip_local *rcv)
@@ -481,7 +481,7 @@ plip_none(struct net_device *dev, struct net_local *nl,
481 481
482/* PLIP_RECEIVE --- receive a byte(two nibbles) 482/* PLIP_RECEIVE --- receive a byte(two nibbles)
483 Returns OK on success, TIMEOUT on timeout */ 483 Returns OK on success, TIMEOUT on timeout */
484inline static int 484static inline int
485plip_receive(unsigned short nibble_timeout, struct net_device *dev, 485plip_receive(unsigned short nibble_timeout, struct net_device *dev,
486 enum plip_nibble_state *ns_p, unsigned char *data_p) 486 enum plip_nibble_state *ns_p, unsigned char *data_p)
487{ 487{
@@ -540,7 +540,7 @@ plip_receive(unsigned short nibble_timeout, struct net_device *dev,
540 * in far too many old systems not all even running Linux. 540 * in far too many old systems not all even running Linux.
541 */ 541 */
542 542
543static unsigned short plip_type_trans(struct sk_buff *skb, struct net_device *dev) 543static __be16 plip_type_trans(struct sk_buff *skb, struct net_device *dev)
544{ 544{
545 struct ethhdr *eth; 545 struct ethhdr *eth;
546 unsigned char *rawp; 546 unsigned char *rawp;
@@ -582,7 +582,6 @@ static unsigned short plip_type_trans(struct sk_buff *skb, struct net_device *de
582 return htons(ETH_P_802_2); 582 return htons(ETH_P_802_2);
583} 583}
584 584
585
586/* PLIP_RECEIVE_PACKET --- receive a packet */ 585/* PLIP_RECEIVE_PACKET --- receive a packet */
587static int 586static int
588plip_receive_packet(struct net_device *dev, struct net_local *nl, 587plip_receive_packet(struct net_device *dev, struct net_local *nl,
@@ -702,7 +701,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
702 701
703/* PLIP_SEND --- send a byte (two nibbles) 702/* PLIP_SEND --- send a byte (two nibbles)
704 Returns OK on success, TIMEOUT when timeout */ 703 Returns OK on success, TIMEOUT when timeout */
705inline static int 704static inline int
706plip_send(unsigned short nibble_timeout, struct net_device *dev, 705plip_send(unsigned short nibble_timeout, struct net_device *dev,
707 enum plip_nibble_state *ns_p, unsigned char data) 706 enum plip_nibble_state *ns_p, unsigned char data)
708{ 707{
@@ -902,7 +901,7 @@ plip_error(struct net_device *dev, struct net_local *nl,
902 901
903 return OK; 902 return OK;
904} 903}
905 904
906/* Handle the parallel port interrupts. */ 905/* Handle the parallel port interrupts. */
907static void 906static void
908plip_interrupt(int irq, void *dev_id, struct pt_regs * regs) 907plip_interrupt(int irq, void *dev_id, struct pt_regs * regs)
@@ -957,7 +956,7 @@ plip_interrupt(int irq, void *dev_id, struct pt_regs * regs)
957 956
958 spin_unlock_irq(&nl->lock); 957 spin_unlock_irq(&nl->lock);
959} 958}
960 959
961static int 960static int
962plip_tx_packet(struct sk_buff *skb, struct net_device *dev) 961plip_tx_packet(struct sk_buff *skb, struct net_device *dev)
963{ 962{
@@ -1238,7 +1237,7 @@ plip_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1238 } 1237 }
1239 return 0; 1238 return 0;
1240} 1239}
1241 1240
1242static int parport[PLIP_MAX] = { [0 ... PLIP_MAX-1] = -1 }; 1241static int parport[PLIP_MAX] = { [0 ... PLIP_MAX-1] = -1 };
1243static int timid; 1242static int timid;
1244 1243
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 33b9d79b1aad..59e8183c639e 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -364,7 +364,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
364 spin_lock_irqsave(&ap->recv_lock, flags); 364 spin_lock_irqsave(&ap->recv_lock, flags);
365 ppp_async_input(ap, buf, cflags, count); 365 ppp_async_input(ap, buf, cflags, count);
366 spin_unlock_irqrestore(&ap->recv_lock, flags); 366 spin_unlock_irqrestore(&ap->recv_lock, flags);
367 if (skb_queue_len(&ap->rqueue)) 367 if (!skb_queue_empty(&ap->rqueue))
368 tasklet_schedule(&ap->tsk); 368 tasklet_schedule(&ap->tsk);
369 ap_put(ap); 369 ap_put(ap);
370 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 370 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
@@ -1025,7 +1025,7 @@ static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,
1025 1025
1026static void __exit ppp_async_cleanup(void) 1026static void __exit ppp_async_cleanup(void)
1027{ 1027{
1028 if (tty_register_ldisc(N_PPP, NULL) != 0) 1028 if (tty_unregister_ldisc(N_PPP) != 0)
1029 printk(KERN_ERR "failed to unregister PPP line discipline\n"); 1029 printk(KERN_ERR "failed to unregister PPP line discipline\n");
1030} 1030}
1031 1031
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index ab726ab43798..a32668e88e09 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1237,8 +1237,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1237 pch = list_entry(list, struct channel, clist); 1237 pch = list_entry(list, struct channel, clist);
1238 navail += pch->avail = (pch->chan != NULL); 1238 navail += pch->avail = (pch->chan != NULL);
1239 if (pch->avail) { 1239 if (pch->avail) {
1240 if (skb_queue_len(&pch->file.xq) == 0 1240 if (skb_queue_empty(&pch->file.xq) ||
1241 || !pch->had_frag) { 1241 !pch->had_frag) {
1242 pch->avail = 2; 1242 pch->avail = 2;
1243 ++nfree; 1243 ++nfree;
1244 } 1244 }
@@ -1374,8 +1374,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1374 1374
1375 /* try to send it down the channel */ 1375 /* try to send it down the channel */
1376 chan = pch->chan; 1376 chan = pch->chan;
1377 if (skb_queue_len(&pch->file.xq) 1377 if (!skb_queue_empty(&pch->file.xq) ||
1378 || !chan->ops->start_xmit(chan, frag)) 1378 !chan->ops->start_xmit(chan, frag))
1379 skb_queue_tail(&pch->file.xq, frag); 1379 skb_queue_tail(&pch->file.xq, frag);
1380 pch->had_frag = 1; 1380 pch->had_frag = 1;
1381 p += flen; 1381 p += flen;
@@ -1412,7 +1412,7 @@ ppp_channel_push(struct channel *pch)
1412 1412
1413 spin_lock_bh(&pch->downl); 1413 spin_lock_bh(&pch->downl);
1414 if (pch->chan != 0) { 1414 if (pch->chan != 0) {
1415 while (skb_queue_len(&pch->file.xq) > 0) { 1415 while (!skb_queue_empty(&pch->file.xq)) {
1416 skb = skb_dequeue(&pch->file.xq); 1416 skb = skb_dequeue(&pch->file.xq);
1417 if (!pch->chan->ops->start_xmit(pch->chan, skb)) { 1417 if (!pch->chan->ops->start_xmit(pch->chan, skb)) {
1418 /* put the packet back and try again later */ 1418 /* put the packet back and try again later */
@@ -1426,7 +1426,7 @@ ppp_channel_push(struct channel *pch)
1426 } 1426 }
1427 spin_unlock_bh(&pch->downl); 1427 spin_unlock_bh(&pch->downl);
1428 /* see if there is anything from the attached unit to be sent */ 1428 /* see if there is anything from the attached unit to be sent */
1429 if (skb_queue_len(&pch->file.xq) == 0) { 1429 if (skb_queue_empty(&pch->file.xq)) {
1430 read_lock_bh(&pch->upl); 1430 read_lock_bh(&pch->upl);
1431 ppp = pch->ppp; 1431 ppp = pch->ppp;
1432 if (ppp != 0) 1432 if (ppp != 0)
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index 7d0150b4c629..4d51c0c8023d 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -406,7 +406,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
406 spin_lock_irqsave(&ap->recv_lock, flags); 406 spin_lock_irqsave(&ap->recv_lock, flags);
407 ppp_sync_input(ap, buf, cflags, count); 407 ppp_sync_input(ap, buf, cflags, count);
408 spin_unlock_irqrestore(&ap->recv_lock, flags); 408 spin_unlock_irqrestore(&ap->recv_lock, flags);
409 if (skb_queue_len(&ap->rqueue)) 409 if (!skb_queue_empty(&ap->rqueue))
410 tasklet_schedule(&ap->tsk); 410 tasklet_schedule(&ap->tsk);
411 sp_put(ap); 411 sp_put(ap);
412 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 412 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
@@ -793,7 +793,7 @@ err:
793static void __exit 793static void __exit
794ppp_sync_cleanup(void) 794ppp_sync_cleanup(void)
795{ 795{
796 if (tty_register_ldisc(N_SYNC_PPP, NULL) != 0) 796 if (tty_unregister_ldisc(N_SYNC_PPP) != 0)
797 printk(KERN_ERR "failed to unregister Sync PPP line discipline\n"); 797 printk(KERN_ERR "failed to unregister Sync PPP line discipline\n");
798} 798}
799 799
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index ce449fe90e6d..f0471d102e3c 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -187,6 +187,7 @@ static struct pci_device_id rtl8169_pci_tbl[] = {
187 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), }, 187 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), },
188 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), }, 188 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), },
189 { PCI_DEVICE(0x16ec, 0x0116), }, 189 { PCI_DEVICE(0x16ec, 0x0116), },
190 { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0024, },
190 {0,}, 191 {0,},
191}; 192};
192 193
@@ -1876,7 +1877,7 @@ static int rtl8169_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff,
1876 skb_reserve(skb, NET_IP_ALIGN); 1877 skb_reserve(skb, NET_IP_ALIGN);
1877 *sk_buff = skb; 1878 *sk_buff = skb;
1878 1879
1879 mapping = pci_map_single(pdev, skb->tail, rx_buf_sz, 1880 mapping = pci_map_single(pdev, skb->data, rx_buf_sz,
1880 PCI_DMA_FROMDEVICE); 1881 PCI_DMA_FROMDEVICE);
1881 1882
1882 rtl8169_map_to_asic(desc, mapping, rx_buf_sz); 1883 rtl8169_map_to_asic(desc, mapping, rx_buf_sz);
@@ -2336,7 +2337,7 @@ static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
2336 skb = dev_alloc_skb(pkt_size + NET_IP_ALIGN); 2337 skb = dev_alloc_skb(pkt_size + NET_IP_ALIGN);
2337 if (skb) { 2338 if (skb) {
2338 skb_reserve(skb, NET_IP_ALIGN); 2339 skb_reserve(skb, NET_IP_ALIGN);
2339 eth_copy_and_sum(skb, sk_buff[0]->tail, pkt_size, 0); 2340 eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0);
2340 *sk_buff = skb; 2341 *sk_buff = skb;
2341 rtl8169_mark_to_asic(desc, rx_buf_sz); 2342 rtl8169_mark_to_asic(desc, rx_buf_sz);
2342 ret = 0; 2343 ret = 0;
diff --git a/drivers/net/s2io-regs.h b/drivers/net/s2io-regs.h
index 7092ca6b277e..2234a8f05eb2 100644
--- a/drivers/net/s2io-regs.h
+++ b/drivers/net/s2io-regs.h
@@ -62,6 +62,7 @@ typedef struct _XENA_dev_config {
62#define ADAPTER_STATUS_RMAC_REMOTE_FAULT BIT(6) 62#define ADAPTER_STATUS_RMAC_REMOTE_FAULT BIT(6)
63#define ADAPTER_STATUS_RMAC_LOCAL_FAULT BIT(7) 63#define ADAPTER_STATUS_RMAC_LOCAL_FAULT BIT(7)
64#define ADAPTER_STATUS_RMAC_PCC_IDLE vBIT(0xFF,8,8) 64#define ADAPTER_STATUS_RMAC_PCC_IDLE vBIT(0xFF,8,8)
65#define ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE vBIT(0x0F,8,8)
65#define ADAPTER_STATUS_RC_PRC_QUIESCENT vBIT(0xFF,16,8) 66#define ADAPTER_STATUS_RC_PRC_QUIESCENT vBIT(0xFF,16,8)
66#define ADAPTER_STATUS_MC_DRAM_READY BIT(24) 67#define ADAPTER_STATUS_MC_DRAM_READY BIT(24)
67#define ADAPTER_STATUS_MC_QUEUES_READY BIT(25) 68#define ADAPTER_STATUS_MC_QUEUES_READY BIT(25)
@@ -77,21 +78,34 @@ typedef struct _XENA_dev_config {
77#define ADAPTER_ECC_EN BIT(55) 78#define ADAPTER_ECC_EN BIT(55)
78 79
79 u64 serr_source; 80 u64 serr_source;
80#define SERR_SOURCE_PIC BIT(0) 81#define SERR_SOURCE_PIC BIT(0)
81#define SERR_SOURCE_TXDMA BIT(1) 82#define SERR_SOURCE_TXDMA BIT(1)
82#define SERR_SOURCE_RXDMA BIT(2) 83#define SERR_SOURCE_RXDMA BIT(2)
83#define SERR_SOURCE_MAC BIT(3) 84#define SERR_SOURCE_MAC BIT(3)
84#define SERR_SOURCE_MC BIT(4) 85#define SERR_SOURCE_MC BIT(4)
85#define SERR_SOURCE_XGXS BIT(5) 86#define SERR_SOURCE_XGXS BIT(5)
86#define SERR_SOURCE_ANY (SERR_SOURCE_PIC | \ 87#define SERR_SOURCE_ANY (SERR_SOURCE_PIC | \
87 SERR_SOURCE_TXDMA | \ 88 SERR_SOURCE_TXDMA | \
88 SERR_SOURCE_RXDMA | \ 89 SERR_SOURCE_RXDMA | \
89 SERR_SOURCE_MAC | \ 90 SERR_SOURCE_MAC | \
90 SERR_SOURCE_MC | \ 91 SERR_SOURCE_MC | \
91 SERR_SOURCE_XGXS) 92 SERR_SOURCE_XGXS)
92 93
93 94 u64 pci_mode;
94 u8 unused_0[0x800 - 0x120]; 95#define GET_PCI_MODE(val) ((val & vBIT(0xF, 0, 4)) >> 60)
96#define PCI_MODE_PCI_33 0
97#define PCI_MODE_PCI_66 0x1
98#define PCI_MODE_PCIX_M1_66 0x2
99#define PCI_MODE_PCIX_M1_100 0x3
100#define PCI_MODE_PCIX_M1_133 0x4
101#define PCI_MODE_PCIX_M2_66 0x5
102#define PCI_MODE_PCIX_M2_100 0x6
103#define PCI_MODE_PCIX_M2_133 0x7
104#define PCI_MODE_UNSUPPORTED BIT(0)
105#define PCI_MODE_32_BITS BIT(8)
106#define PCI_MODE_UNKNOWN_MODE BIT(9)
107
108 u8 unused_0[0x800 - 0x128];
95 109
96/* PCI-X Controller registers */ 110/* PCI-X Controller registers */
97 u64 pic_int_status; 111 u64 pic_int_status;
@@ -153,7 +167,11 @@ typedef struct _XENA_dev_config {
153 u8 unused4[0x08]; 167 u8 unused4[0x08];
154 168
155 u64 gpio_int_reg; 169 u64 gpio_int_reg;
170#define GPIO_INT_REG_LINK_DOWN BIT(1)
171#define GPIO_INT_REG_LINK_UP BIT(2)
156 u64 gpio_int_mask; 172 u64 gpio_int_mask;
173#define GPIO_INT_MASK_LINK_DOWN BIT(1)
174#define GPIO_INT_MASK_LINK_UP BIT(2)
157 u64 gpio_alarms; 175 u64 gpio_alarms;
158 176
159 u8 unused5[0x38]; 177 u8 unused5[0x38];
@@ -223,19 +241,16 @@ typedef struct _XENA_dev_config {
223 u64 xmsi_data; 241 u64 xmsi_data;
224 242
225 u64 rx_mat; 243 u64 rx_mat;
244#define RX_MAT_SET(ring, msi) vBIT(msi, (8 * ring), 8)
226 245
227 u8 unused6[0x8]; 246 u8 unused6[0x8];
228 247
229 u64 tx_mat0_7; 248 u64 tx_mat0_n[0x8];
230 u64 tx_mat8_15; 249#define TX_MAT_SET(fifo, msi) vBIT(msi, (8 * fifo), 8)
231 u64 tx_mat16_23;
232 u64 tx_mat24_31;
233 u64 tx_mat32_39;
234 u64 tx_mat40_47;
235 u64 tx_mat48_55;
236 u64 tx_mat56_63;
237 250
238 u8 unused_1[0x10]; 251 u8 unused_1[0x8];
252 u64 stat_byte_cnt;
253#define STAT_BC(n) vBIT(n,4,12)
239 254
240 /* Automated statistics collection */ 255 /* Automated statistics collection */
241 u64 stat_cfg; 256 u64 stat_cfg;
@@ -246,6 +261,7 @@ typedef struct _XENA_dev_config {
246#define STAT_TRSF_PER(n) TBD 261#define STAT_TRSF_PER(n) TBD
247#define PER_SEC 0x208d5 262#define PER_SEC 0x208d5
248#define SET_UPDT_PERIOD(n) vBIT((PER_SEC*n),32,32) 263#define SET_UPDT_PERIOD(n) vBIT((PER_SEC*n),32,32)
264#define SET_UPDT_CLICKS(val) vBIT(val, 32, 32)
249 265
250 u64 stat_addr; 266 u64 stat_addr;
251 267
@@ -267,8 +283,15 @@ typedef struct _XENA_dev_config {
267 283
268 u64 gpio_control; 284 u64 gpio_control;
269#define GPIO_CTRL_GPIO_0 BIT(8) 285#define GPIO_CTRL_GPIO_0 BIT(8)
286 u64 misc_control;
287#define MISC_LINK_STABILITY_PRD(val) vBIT(val,29,3)
288
289 u8 unused7_1[0x240 - 0x208];
290
291 u64 wreq_split_mask;
292#define WREQ_SPLIT_MASK_SET_MASK(val) vBIT(val, 52, 12)
270 293
271 u8 unused7[0x600]; 294 u8 unused7_2[0x800 - 0x248];
272 295
273/* TxDMA registers */ 296/* TxDMA registers */
274 u64 txdma_int_status; 297 u64 txdma_int_status;
@@ -290,6 +313,7 @@ typedef struct _XENA_dev_config {
290 313
291 u64 pcc_err_reg; 314 u64 pcc_err_reg;
292#define PCC_FB_ECC_DB_ERR vBIT(0xFF, 16, 8) 315#define PCC_FB_ECC_DB_ERR vBIT(0xFF, 16, 8)
316#define PCC_ENABLE_FOUR vBIT(0x0F,0,8)
293 317
294 u64 pcc_err_mask; 318 u64 pcc_err_mask;
295 u64 pcc_err_alarm; 319 u64 pcc_err_alarm;
@@ -468,6 +492,7 @@ typedef struct _XENA_dev_config {
468#define PRC_CTRL_NO_SNOOP (BIT(22)|BIT(23)) 492#define PRC_CTRL_NO_SNOOP (BIT(22)|BIT(23))
469#define PRC_CTRL_NO_SNOOP_DESC BIT(22) 493#define PRC_CTRL_NO_SNOOP_DESC BIT(22)
470#define PRC_CTRL_NO_SNOOP_BUFF BIT(23) 494#define PRC_CTRL_NO_SNOOP_BUFF BIT(23)
495#define PRC_CTRL_BIMODAL_INTERRUPT BIT(37)
471#define PRC_CTRL_RXD_BACKOFF_INTERVAL(val) vBIT(val,40,24) 496#define PRC_CTRL_RXD_BACKOFF_INTERVAL(val) vBIT(val,40,24)
472 497
473 u64 prc_alarm_action; 498 u64 prc_alarm_action;
@@ -691,6 +716,10 @@ typedef struct _XENA_dev_config {
691#define MC_ERR_REG_MIRI_CRI_ERR_0 BIT(22) 716#define MC_ERR_REG_MIRI_CRI_ERR_0 BIT(22)
692#define MC_ERR_REG_MIRI_CRI_ERR_1 BIT(23) 717#define MC_ERR_REG_MIRI_CRI_ERR_1 BIT(23)
693#define MC_ERR_REG_SM_ERR BIT(31) 718#define MC_ERR_REG_SM_ERR BIT(31)
719#define MC_ERR_REG_ECC_ALL_SNG (BIT(6) | \
720 BIT(7) | BIT(17) | BIT(19))
721#define MC_ERR_REG_ECC_ALL_DBL (BIT(14) | \
722 BIT(15) | BIT(18) | BIT(20))
694 u64 mc_err_mask; 723 u64 mc_err_mask;
695 u64 mc_err_alarm; 724 u64 mc_err_alarm;
696 725
@@ -736,7 +765,19 @@ typedef struct _XENA_dev_config {
736 u64 mc_rldram_test_d1; 765 u64 mc_rldram_test_d1;
737 u8 unused24[0x300 - 0x288]; 766 u8 unused24[0x300 - 0x288];
738 u64 mc_rldram_test_d2; 767 u64 mc_rldram_test_d2;
739 u8 unused25[0x700 - 0x308]; 768
769 u8 unused24_1[0x360 - 0x308];
770 u64 mc_rldram_ctrl;
771#define MC_RLDRAM_ENABLE_ODT BIT(7)
772
773 u8 unused24_2[0x640 - 0x368];
774 u64 mc_rldram_ref_per_herc;
775#define MC_RLDRAM_SET_REF_PERIOD(val) vBIT(val, 0, 16)
776
777 u8 unused24_3[0x660 - 0x648];
778 u64 mc_rldram_mrs_herc;
779
780 u8 unused25[0x700 - 0x668];
740 u64 mc_debug_ctrl; 781 u64 mc_debug_ctrl;
741 782
742 u8 unused26[0x3000 - 0x2f08]; 783 u8 unused26[0x3000 - 0x2f08];
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 9c224eba057d..7ca78228b104 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -11,29 +11,28 @@
11 * See the file COPYING in this distribution for more information. 11 * See the file COPYING in this distribution for more information.
12 * 12 *
13 * Credits: 13 * Credits:
14 * Jeff Garzik : For pointing out the improper error condition 14 * Jeff Garzik : For pointing out the improper error condition
15 * check in the s2io_xmit routine and also some 15 * check in the s2io_xmit routine and also some
16 * issues in the Tx watch dog function. Also for 16 * issues in the Tx watch dog function. Also for
17 * patiently answering all those innumerable 17 * patiently answering all those innumerable
18 * questions regaring the 2.6 porting issues. 18 * questions regaring the 2.6 porting issues.
19 * Stephen Hemminger : Providing proper 2.6 porting mechanism for some 19 * Stephen Hemminger : Providing proper 2.6 porting mechanism for some
20 * macros available only in 2.6 Kernel. 20 * macros available only in 2.6 Kernel.
21 * Francois Romieu : For pointing out all code part that were 21 * Francois Romieu : For pointing out all code part that were
22 * deprecated and also styling related comments. 22 * deprecated and also styling related comments.
23 * Grant Grundler : For helping me get rid of some Architecture 23 * Grant Grundler : For helping me get rid of some Architecture
24 * dependent code. 24 * dependent code.
25 * Christopher Hellwig : Some more 2.6 specific issues in the driver. 25 * Christopher Hellwig : Some more 2.6 specific issues in the driver.
26 * 26 *
27 * The module loadable parameters that are supported by the driver and a brief 27 * The module loadable parameters that are supported by the driver and a brief
28 * explaination of all the variables. 28 * explaination of all the variables.
29 * rx_ring_num : This can be used to program the number of receive rings used 29 * rx_ring_num : This can be used to program the number of receive rings used
30 * in the driver. 30 * in the driver.
31 * rx_ring_len: This defines the number of descriptors each ring can have. This 31 * rx_ring_len: This defines the number of descriptors each ring can have. This
32 * is also an array of size 8. 32 * is also an array of size 8.
33 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver. 33 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver.
34 * tx_fifo_len: This too is an array of 8. Each element defines the number of 34 * tx_fifo_len: This too is an array of 8. Each element defines the number of
35 * Tx descriptors that can be associated with each corresponding FIFO. 35 * Tx descriptors that can be associated with each corresponding FIFO.
36 * in PCI Configuration space.
37 ************************************************************************/ 36 ************************************************************************/
38 37
39#include <linux/config.h> 38#include <linux/config.h>
@@ -42,6 +41,7 @@
42#include <linux/errno.h> 41#include <linux/errno.h>
43#include <linux/ioport.h> 42#include <linux/ioport.h>
44#include <linux/pci.h> 43#include <linux/pci.h>
44#include <linux/dma-mapping.h>
45#include <linux/kernel.h> 45#include <linux/kernel.h>
46#include <linux/netdevice.h> 46#include <linux/netdevice.h>
47#include <linux/etherdevice.h> 47#include <linux/etherdevice.h>
@@ -55,27 +55,39 @@
55#include <linux/ethtool.h> 55#include <linux/ethtool.h>
56#include <linux/version.h> 56#include <linux/version.h>
57#include <linux/workqueue.h> 57#include <linux/workqueue.h>
58#include <linux/if_vlan.h>
58 59
59#include <asm/io.h>
60#include <asm/system.h> 60#include <asm/system.h>
61#include <asm/uaccess.h> 61#include <asm/uaccess.h>
62#include <asm/io.h>
62 63
63/* local include */ 64/* local include */
64#include "s2io.h" 65#include "s2io.h"
65#include "s2io-regs.h" 66#include "s2io-regs.h"
66 67
67/* S2io Driver name & version. */ 68/* S2io Driver name & version. */
68static char s2io_driver_name[] = "s2io"; 69static char s2io_driver_name[] = "Neterion";
69static char s2io_driver_version[] = "Version 1.7.7.1"; 70static char s2io_driver_version[] = "Version 2.0.3.1";
71
72static inline int RXD_IS_UP2DT(RxD_t *rxdp)
73{
74 int ret;
75
76 ret = ((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
77 (GET_RXD_MARKER(rxdp->Control_2) != THE_RXD_MARK));
70 78
71/* 79 return ret;
80}
81
82/*
72 * Cards with following subsystem_id have a link state indication 83 * Cards with following subsystem_id have a link state indication
73 * problem, 600B, 600C, 600D, 640B, 640C and 640D. 84 * problem, 600B, 600C, 600D, 640B, 640C and 640D.
74 * macro below identifies these cards given the subsystem_id. 85 * macro below identifies these cards given the subsystem_id.
75 */ 86 */
76#define CARDS_WITH_FAULTY_LINK_INDICATORS(subid) \ 87#define CARDS_WITH_FAULTY_LINK_INDICATORS(dev_type, subid) \
77 (((subid >= 0x600B) && (subid <= 0x600D)) || \ 88 (dev_type == XFRAME_I_DEVICE) ? \
78 ((subid >= 0x640B) && (subid <= 0x640D))) ? 1 : 0 89 ((((subid >= 0x600B) && (subid <= 0x600D)) || \
90 ((subid >= 0x640B) && (subid <= 0x640D))) ? 1 : 0) : 0
79 91
80#define LINK_IS_UP(val64) (!(val64 & (ADAPTER_STATUS_RMAC_REMOTE_FAULT | \ 92#define LINK_IS_UP(val64) (!(val64 & (ADAPTER_STATUS_RMAC_REMOTE_FAULT | \
81 ADAPTER_STATUS_RMAC_LOCAL_FAULT))) 93 ADAPTER_STATUS_RMAC_LOCAL_FAULT)))
@@ -85,9 +97,12 @@ static char s2io_driver_version[] = "Version 1.7.7.1";
85static inline int rx_buffer_level(nic_t * sp, int rxb_size, int ring) 97static inline int rx_buffer_level(nic_t * sp, int rxb_size, int ring)
86{ 98{
87 int level = 0; 99 int level = 0;
88 if ((sp->pkt_cnt[ring] - rxb_size) > 16) { 100 mac_info_t *mac_control;
101
102 mac_control = &sp->mac_control;
103 if ((mac_control->rings[ring].pkt_cnt - rxb_size) > 16) {
89 level = LOW; 104 level = LOW;
90 if ((sp->pkt_cnt[ring] - rxb_size) < MAX_RXDS_PER_BLOCK) { 105 if (rxb_size <= MAX_RXDS_PER_BLOCK) {
91 level = PANIC; 106 level = PANIC;
92 } 107 }
93 } 108 }
@@ -144,6 +159,9 @@ static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
144 {"rmac_pause_cnt"}, 159 {"rmac_pause_cnt"},
145 {"rmac_accepted_ip"}, 160 {"rmac_accepted_ip"},
146 {"rmac_err_tcp"}, 161 {"rmac_err_tcp"},
162 {"\n DRIVER STATISTICS"},
163 {"single_bit_ecc_errs"},
164 {"double_bit_ecc_errs"},
147}; 165};
148 166
149#define S2IO_STAT_LEN sizeof(ethtool_stats_keys)/ ETH_GSTRING_LEN 167#define S2IO_STAT_LEN sizeof(ethtool_stats_keys)/ ETH_GSTRING_LEN
@@ -152,8 +170,37 @@ static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
152#define S2IO_TEST_LEN sizeof(s2io_gstrings) / ETH_GSTRING_LEN 170#define S2IO_TEST_LEN sizeof(s2io_gstrings) / ETH_GSTRING_LEN
153#define S2IO_STRINGS_LEN S2IO_TEST_LEN * ETH_GSTRING_LEN 171#define S2IO_STRINGS_LEN S2IO_TEST_LEN * ETH_GSTRING_LEN
154 172
173#define S2IO_TIMER_CONF(timer, handle, arg, exp) \
174 init_timer(&timer); \
175 timer.function = handle; \
176 timer.data = (unsigned long) arg; \
177 mod_timer(&timer, (jiffies + exp)) \
178
179/* Add the vlan */
180static void s2io_vlan_rx_register(struct net_device *dev,
181 struct vlan_group *grp)
182{
183 nic_t *nic = dev->priv;
184 unsigned long flags;
185
186 spin_lock_irqsave(&nic->tx_lock, flags);
187 nic->vlgrp = grp;
188 spin_unlock_irqrestore(&nic->tx_lock, flags);
189}
190
191/* Unregister the vlan */
192static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid)
193{
194 nic_t *nic = dev->priv;
195 unsigned long flags;
196
197 spin_lock_irqsave(&nic->tx_lock, flags);
198 if (nic->vlgrp)
199 nic->vlgrp->vlan_devices[vid] = NULL;
200 spin_unlock_irqrestore(&nic->tx_lock, flags);
201}
155 202
156/* 203/*
157 * Constants to be programmed into the Xena's registers, to configure 204 * Constants to be programmed into the Xena's registers, to configure
158 * the XAUI. 205 * the XAUI.
159 */ 206 */
@@ -161,7 +208,28 @@ static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
161#define SWITCH_SIGN 0xA5A5A5A5A5A5A5A5ULL 208#define SWITCH_SIGN 0xA5A5A5A5A5A5A5A5ULL
162#define END_SIGN 0x0 209#define END_SIGN 0x0
163 210
164static u64 default_mdio_cfg[] = { 211static u64 herc_act_dtx_cfg[] = {
212 /* Set address */
213 0x8000051536750000ULL, 0x80000515367500E0ULL,
214 /* Write data */
215 0x8000051536750004ULL, 0x80000515367500E4ULL,
216 /* Set address */
217 0x80010515003F0000ULL, 0x80010515003F00E0ULL,
218 /* Write data */
219 0x80010515003F0004ULL, 0x80010515003F00E4ULL,
220 /* Set address */
221 0x801205150D440000ULL, 0x801205150D4400E0ULL,
222 /* Write data */
223 0x801205150D440004ULL, 0x801205150D4400E4ULL,
224 /* Set address */
225 0x80020515F2100000ULL, 0x80020515F21000E0ULL,
226 /* Write data */
227 0x80020515F2100004ULL, 0x80020515F21000E4ULL,
228 /* Done */
229 END_SIGN
230};
231
232static u64 xena_mdio_cfg[] = {
165 /* Reset PMA PLL */ 233 /* Reset PMA PLL */
166 0xC001010000000000ULL, 0xC0010100000000E0ULL, 234 0xC001010000000000ULL, 0xC0010100000000E0ULL,
167 0xC0010100008000E4ULL, 235 0xC0010100008000E4ULL,
@@ -171,7 +239,7 @@ static u64 default_mdio_cfg[] = {
171 END_SIGN 239 END_SIGN
172}; 240};
173 241
174static u64 default_dtx_cfg[] = { 242static u64 xena_dtx_cfg[] = {
175 0x8000051500000000ULL, 0x80000515000000E0ULL, 243 0x8000051500000000ULL, 0x80000515000000E0ULL,
176 0x80000515D93500E4ULL, 0x8001051500000000ULL, 244 0x80000515D93500E4ULL, 0x8001051500000000ULL,
177 0x80010515000000E0ULL, 0x80010515001E00E4ULL, 245 0x80010515000000E0ULL, 0x80010515001E00E4ULL,
@@ -195,8 +263,7 @@ static u64 default_dtx_cfg[] = {
195 END_SIGN 263 END_SIGN
196}; 264};
197 265
198 266/*
199/*
200 * Constants for Fixing the MacAddress problem seen mostly on 267 * Constants for Fixing the MacAddress problem seen mostly on
201 * Alpha machines. 268 * Alpha machines.
202 */ 269 */
@@ -225,20 +292,25 @@ static unsigned int tx_fifo_len[MAX_TX_FIFOS] =
225static unsigned int rx_ring_num = 1; 292static unsigned int rx_ring_num = 1;
226static unsigned int rx_ring_sz[MAX_RX_RINGS] = 293static unsigned int rx_ring_sz[MAX_RX_RINGS] =
227 {[0 ...(MAX_RX_RINGS - 1)] = 0 }; 294 {[0 ...(MAX_RX_RINGS - 1)] = 0 };
228static unsigned int Stats_refresh_time = 4; 295static unsigned int rts_frm_len[MAX_RX_RINGS] =
296 {[0 ...(MAX_RX_RINGS - 1)] = 0 };
297static unsigned int use_continuous_tx_intrs = 1;
229static unsigned int rmac_pause_time = 65535; 298static unsigned int rmac_pause_time = 65535;
230static unsigned int mc_pause_threshold_q0q3 = 187; 299static unsigned int mc_pause_threshold_q0q3 = 187;
231static unsigned int mc_pause_threshold_q4q7 = 187; 300static unsigned int mc_pause_threshold_q4q7 = 187;
232static unsigned int shared_splits; 301static unsigned int shared_splits;
233static unsigned int tmac_util_period = 5; 302static unsigned int tmac_util_period = 5;
234static unsigned int rmac_util_period = 5; 303static unsigned int rmac_util_period = 5;
304static unsigned int bimodal = 0;
235#ifndef CONFIG_S2IO_NAPI 305#ifndef CONFIG_S2IO_NAPI
236static unsigned int indicate_max_pkts; 306static unsigned int indicate_max_pkts;
237#endif 307#endif
308/* Frequency of Rx desc syncs expressed as power of 2 */
309static unsigned int rxsync_frequency = 3;
238 310
239/* 311/*
240 * S2IO device table. 312 * S2IO device table.
241 * This table lists all the devices that this driver supports. 313 * This table lists all the devices that this driver supports.
242 */ 314 */
243static struct pci_device_id s2io_tbl[] __devinitdata = { 315static struct pci_device_id s2io_tbl[] __devinitdata = {
244 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN, 316 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN,
@@ -246,9 +318,9 @@ static struct pci_device_id s2io_tbl[] __devinitdata = {
246 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI, 318 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI,
247 PCI_ANY_ID, PCI_ANY_ID}, 319 PCI_ANY_ID, PCI_ANY_ID},
248 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_WIN, 320 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_WIN,
249 PCI_ANY_ID, PCI_ANY_ID}, 321 PCI_ANY_ID, PCI_ANY_ID},
250 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_UNI, 322 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_UNI,
251 PCI_ANY_ID, PCI_ANY_ID}, 323 PCI_ANY_ID, PCI_ANY_ID},
252 {0,} 324 {0,}
253}; 325};
254 326
@@ -267,8 +339,8 @@ static struct pci_driver s2io_driver = {
267/** 339/**
268 * init_shared_mem - Allocation and Initialization of Memory 340 * init_shared_mem - Allocation and Initialization of Memory
269 * @nic: Device private variable. 341 * @nic: Device private variable.
270 * Description: The function allocates all the memory areas shared 342 * Description: The function allocates all the memory areas shared
271 * between the NIC and the driver. This includes Tx descriptors, 343 * between the NIC and the driver. This includes Tx descriptors,
272 * Rx descriptors and the statistics block. 344 * Rx descriptors and the statistics block.
273 */ 345 */
274 346
@@ -278,11 +350,11 @@ static int init_shared_mem(struct s2io_nic *nic)
278 void *tmp_v_addr, *tmp_v_addr_next; 350 void *tmp_v_addr, *tmp_v_addr_next;
279 dma_addr_t tmp_p_addr, tmp_p_addr_next; 351 dma_addr_t tmp_p_addr, tmp_p_addr_next;
280 RxD_block_t *pre_rxd_blk = NULL; 352 RxD_block_t *pre_rxd_blk = NULL;
281 int i, j, blk_cnt; 353 int i, j, blk_cnt, rx_sz, tx_sz;
282 int lst_size, lst_per_page; 354 int lst_size, lst_per_page;
283 struct net_device *dev = nic->dev; 355 struct net_device *dev = nic->dev;
284#ifdef CONFIG_2BUFF_MODE 356#ifdef CONFIG_2BUFF_MODE
285 unsigned long tmp; 357 u64 tmp;
286 buffAdd_t *ba; 358 buffAdd_t *ba;
287#endif 359#endif
288 360
@@ -299,36 +371,41 @@ static int init_shared_mem(struct s2io_nic *nic)
299 size += config->tx_cfg[i].fifo_len; 371 size += config->tx_cfg[i].fifo_len;
300 } 372 }
301 if (size > MAX_AVAILABLE_TXDS) { 373 if (size > MAX_AVAILABLE_TXDS) {
302 DBG_PRINT(ERR_DBG, "%s: Total number of Tx FIFOs ", 374 DBG_PRINT(ERR_DBG, "%s: Requested TxDs too high, ",
303 dev->name); 375 __FUNCTION__);
304 DBG_PRINT(ERR_DBG, "exceeds the maximum value "); 376 DBG_PRINT(ERR_DBG, "Requested: %d, max supported: 8192\n", size);
305 DBG_PRINT(ERR_DBG, "that can be used\n");
306 return FAILURE; 377 return FAILURE;
307 } 378 }
308 379
309 lst_size = (sizeof(TxD_t) * config->max_txds); 380 lst_size = (sizeof(TxD_t) * config->max_txds);
381 tx_sz = lst_size * size;
310 lst_per_page = PAGE_SIZE / lst_size; 382 lst_per_page = PAGE_SIZE / lst_size;
311 383
312 for (i = 0; i < config->tx_fifo_num; i++) { 384 for (i = 0; i < config->tx_fifo_num; i++) {
313 int fifo_len = config->tx_cfg[i].fifo_len; 385 int fifo_len = config->tx_cfg[i].fifo_len;
314 int list_holder_size = fifo_len * sizeof(list_info_hold_t); 386 int list_holder_size = fifo_len * sizeof(list_info_hold_t);
315 nic->list_info[i] = kmalloc(list_holder_size, GFP_KERNEL); 387 mac_control->fifos[i].list_info = kmalloc(list_holder_size,
316 if (!nic->list_info[i]) { 388 GFP_KERNEL);
389 if (!mac_control->fifos[i].list_info) {
317 DBG_PRINT(ERR_DBG, 390 DBG_PRINT(ERR_DBG,
318 "Malloc failed for list_info\n"); 391 "Malloc failed for list_info\n");
319 return -ENOMEM; 392 return -ENOMEM;
320 } 393 }
321 memset(nic->list_info[i], 0, list_holder_size); 394 memset(mac_control->fifos[i].list_info, 0, list_holder_size);
322 } 395 }
323 for (i = 0; i < config->tx_fifo_num; i++) { 396 for (i = 0; i < config->tx_fifo_num; i++) {
324 int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, 397 int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
325 lst_per_page); 398 lst_per_page);
326 mac_control->tx_curr_put_info[i].offset = 0; 399 mac_control->fifos[i].tx_curr_put_info.offset = 0;
327 mac_control->tx_curr_put_info[i].fifo_len = 400 mac_control->fifos[i].tx_curr_put_info.fifo_len =
328 config->tx_cfg[i].fifo_len - 1; 401 config->tx_cfg[i].fifo_len - 1;
329 mac_control->tx_curr_get_info[i].offset = 0; 402 mac_control->fifos[i].tx_curr_get_info.offset = 0;
330 mac_control->tx_curr_get_info[i].fifo_len = 403 mac_control->fifos[i].tx_curr_get_info.fifo_len =
331 config->tx_cfg[i].fifo_len - 1; 404 config->tx_cfg[i].fifo_len - 1;
405 mac_control->fifos[i].fifo_no = i;
406 mac_control->fifos[i].nic = nic;
407 mac_control->fifos[i].max_txds = MAX_SKB_FRAGS;
408
332 for (j = 0; j < page_num; j++) { 409 for (j = 0; j < page_num; j++) {
333 int k = 0; 410 int k = 0;
334 dma_addr_t tmp_p; 411 dma_addr_t tmp_p;
@@ -344,16 +421,15 @@ static int init_shared_mem(struct s2io_nic *nic)
344 while (k < lst_per_page) { 421 while (k < lst_per_page) {
345 int l = (j * lst_per_page) + k; 422 int l = (j * lst_per_page) + k;
346 if (l == config->tx_cfg[i].fifo_len) 423 if (l == config->tx_cfg[i].fifo_len)
347 goto end_txd_alloc; 424 break;
348 nic->list_info[i][l].list_virt_addr = 425 mac_control->fifos[i].list_info[l].list_virt_addr =
349 tmp_v + (k * lst_size); 426 tmp_v + (k * lst_size);
350 nic->list_info[i][l].list_phy_addr = 427 mac_control->fifos[i].list_info[l].list_phy_addr =
351 tmp_p + (k * lst_size); 428 tmp_p + (k * lst_size);
352 k++; 429 k++;
353 } 430 }
354 } 431 }
355 } 432 }
356 end_txd_alloc:
357 433
358 /* Allocation and initialization of RXDs in Rings */ 434 /* Allocation and initialization of RXDs in Rings */
359 size = 0; 435 size = 0;
@@ -366,21 +442,26 @@ static int init_shared_mem(struct s2io_nic *nic)
366 return FAILURE; 442 return FAILURE;
367 } 443 }
368 size += config->rx_cfg[i].num_rxd; 444 size += config->rx_cfg[i].num_rxd;
369 nic->block_count[i] = 445 mac_control->rings[i].block_count =
370 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1); 446 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
371 nic->pkt_cnt[i] = 447 mac_control->rings[i].pkt_cnt =
372 config->rx_cfg[i].num_rxd - nic->block_count[i]; 448 config->rx_cfg[i].num_rxd - mac_control->rings[i].block_count;
373 } 449 }
450 size = (size * (sizeof(RxD_t)));
451 rx_sz = size;
374 452
375 for (i = 0; i < config->rx_ring_num; i++) { 453 for (i = 0; i < config->rx_ring_num; i++) {
376 mac_control->rx_curr_get_info[i].block_index = 0; 454 mac_control->rings[i].rx_curr_get_info.block_index = 0;
377 mac_control->rx_curr_get_info[i].offset = 0; 455 mac_control->rings[i].rx_curr_get_info.offset = 0;
378 mac_control->rx_curr_get_info[i].ring_len = 456 mac_control->rings[i].rx_curr_get_info.ring_len =
379 config->rx_cfg[i].num_rxd - 1; 457 config->rx_cfg[i].num_rxd - 1;
380 mac_control->rx_curr_put_info[i].block_index = 0; 458 mac_control->rings[i].rx_curr_put_info.block_index = 0;
381 mac_control->rx_curr_put_info[i].offset = 0; 459 mac_control->rings[i].rx_curr_put_info.offset = 0;
382 mac_control->rx_curr_put_info[i].ring_len = 460 mac_control->rings[i].rx_curr_put_info.ring_len =
383 config->rx_cfg[i].num_rxd - 1; 461 config->rx_cfg[i].num_rxd - 1;
462 mac_control->rings[i].nic = nic;
463 mac_control->rings[i].ring_no = i;
464
384 blk_cnt = 465 blk_cnt =
385 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1); 466 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
386 /* Allocating all the Rx blocks */ 467 /* Allocating all the Rx blocks */
@@ -394,32 +475,36 @@ static int init_shared_mem(struct s2io_nic *nic)
394 &tmp_p_addr); 475 &tmp_p_addr);
395 if (tmp_v_addr == NULL) { 476 if (tmp_v_addr == NULL) {
396 /* 477 /*
397 * In case of failure, free_shared_mem() 478 * In case of failure, free_shared_mem()
398 * is called, which should free any 479 * is called, which should free any
399 * memory that was alloced till the 480 * memory that was alloced till the
400 * failure happened. 481 * failure happened.
401 */ 482 */
402 nic->rx_blocks[i][j].block_virt_addr = 483 mac_control->rings[i].rx_blocks[j].block_virt_addr =
403 tmp_v_addr; 484 tmp_v_addr;
404 return -ENOMEM; 485 return -ENOMEM;
405 } 486 }
406 memset(tmp_v_addr, 0, size); 487 memset(tmp_v_addr, 0, size);
407 nic->rx_blocks[i][j].block_virt_addr = tmp_v_addr; 488 mac_control->rings[i].rx_blocks[j].block_virt_addr =
408 nic->rx_blocks[i][j].block_dma_addr = tmp_p_addr; 489 tmp_v_addr;
490 mac_control->rings[i].rx_blocks[j].block_dma_addr =
491 tmp_p_addr;
409 } 492 }
410 /* Interlinking all Rx Blocks */ 493 /* Interlinking all Rx Blocks */
411 for (j = 0; j < blk_cnt; j++) { 494 for (j = 0; j < blk_cnt; j++) {
412 tmp_v_addr = nic->rx_blocks[i][j].block_virt_addr; 495 tmp_v_addr =
496 mac_control->rings[i].rx_blocks[j].block_virt_addr;
413 tmp_v_addr_next = 497 tmp_v_addr_next =
414 nic->rx_blocks[i][(j + 1) % 498 mac_control->rings[i].rx_blocks[(j + 1) %
415 blk_cnt].block_virt_addr; 499 blk_cnt].block_virt_addr;
416 tmp_p_addr = nic->rx_blocks[i][j].block_dma_addr; 500 tmp_p_addr =
501 mac_control->rings[i].rx_blocks[j].block_dma_addr;
417 tmp_p_addr_next = 502 tmp_p_addr_next =
418 nic->rx_blocks[i][(j + 1) % 503 mac_control->rings[i].rx_blocks[(j + 1) %
419 blk_cnt].block_dma_addr; 504 blk_cnt].block_dma_addr;
420 505
421 pre_rxd_blk = (RxD_block_t *) tmp_v_addr; 506 pre_rxd_blk = (RxD_block_t *) tmp_v_addr;
422 pre_rxd_blk->reserved_1 = END_OF_BLOCK; /* last RxD 507 pre_rxd_blk->reserved_1 = END_OF_BLOCK; /* last RxD
423 * marker. 508 * marker.
424 */ 509 */
425#ifndef CONFIG_2BUFF_MODE 510#ifndef CONFIG_2BUFF_MODE
@@ -432,43 +517,43 @@ static int init_shared_mem(struct s2io_nic *nic)
432 } 517 }
433 518
434#ifdef CONFIG_2BUFF_MODE 519#ifdef CONFIG_2BUFF_MODE
435 /* 520 /*
436 * Allocation of Storages for buffer addresses in 2BUFF mode 521 * Allocation of Storages for buffer addresses in 2BUFF mode
437 * and the buffers as well. 522 * and the buffers as well.
438 */ 523 */
439 for (i = 0; i < config->rx_ring_num; i++) { 524 for (i = 0; i < config->rx_ring_num; i++) {
440 blk_cnt = 525 blk_cnt =
441 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1); 526 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
442 nic->ba[i] = kmalloc((sizeof(buffAdd_t *) * blk_cnt), 527 mac_control->rings[i].ba = kmalloc((sizeof(buffAdd_t *) * blk_cnt),
443 GFP_KERNEL); 528 GFP_KERNEL);
444 if (!nic->ba[i]) 529 if (!mac_control->rings[i].ba)
445 return -ENOMEM; 530 return -ENOMEM;
446 for (j = 0; j < blk_cnt; j++) { 531 for (j = 0; j < blk_cnt; j++) {
447 int k = 0; 532 int k = 0;
448 nic->ba[i][j] = kmalloc((sizeof(buffAdd_t) * 533 mac_control->rings[i].ba[j] = kmalloc((sizeof(buffAdd_t) *
449 (MAX_RXDS_PER_BLOCK + 1)), 534 (MAX_RXDS_PER_BLOCK + 1)),
450 GFP_KERNEL); 535 GFP_KERNEL);
451 if (!nic->ba[i][j]) 536 if (!mac_control->rings[i].ba[j])
452 return -ENOMEM; 537 return -ENOMEM;
453 while (k != MAX_RXDS_PER_BLOCK) { 538 while (k != MAX_RXDS_PER_BLOCK) {
454 ba = &nic->ba[i][j][k]; 539 ba = &mac_control->rings[i].ba[j][k];
455 540
456 ba->ba_0_org = kmalloc 541 ba->ba_0_org = (void *) kmalloc
457 (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); 542 (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL);
458 if (!ba->ba_0_org) 543 if (!ba->ba_0_org)
459 return -ENOMEM; 544 return -ENOMEM;
460 tmp = (unsigned long) ba->ba_0_org; 545 tmp = (u64) ba->ba_0_org;
461 tmp += ALIGN_SIZE; 546 tmp += ALIGN_SIZE;
462 tmp &= ~((unsigned long) ALIGN_SIZE); 547 tmp &= ~((u64) ALIGN_SIZE);
463 ba->ba_0 = (void *) tmp; 548 ba->ba_0 = (void *) tmp;
464 549
465 ba->ba_1_org = kmalloc 550 ba->ba_1_org = (void *) kmalloc
466 (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); 551 (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL);
467 if (!ba->ba_1_org) 552 if (!ba->ba_1_org)
468 return -ENOMEM; 553 return -ENOMEM;
469 tmp = (unsigned long) ba->ba_1_org; 554 tmp = (u64) ba->ba_1_org;
470 tmp += ALIGN_SIZE; 555 tmp += ALIGN_SIZE;
471 tmp &= ~((unsigned long) ALIGN_SIZE); 556 tmp &= ~((u64) ALIGN_SIZE);
472 ba->ba_1 = (void *) tmp; 557 ba->ba_1 = (void *) tmp;
473 k++; 558 k++;
474 } 559 }
@@ -482,9 +567,9 @@ static int init_shared_mem(struct s2io_nic *nic)
482 (nic->pdev, size, &mac_control->stats_mem_phy); 567 (nic->pdev, size, &mac_control->stats_mem_phy);
483 568
484 if (!mac_control->stats_mem) { 569 if (!mac_control->stats_mem) {
485 /* 570 /*
486 * In case of failure, free_shared_mem() is called, which 571 * In case of failure, free_shared_mem() is called, which
487 * should free any memory that was alloced till the 572 * should free any memory that was alloced till the
488 * failure happened. 573 * failure happened.
489 */ 574 */
490 return -ENOMEM; 575 return -ENOMEM;
@@ -494,15 +579,14 @@ static int init_shared_mem(struct s2io_nic *nic)
494 tmp_v_addr = mac_control->stats_mem; 579 tmp_v_addr = mac_control->stats_mem;
495 mac_control->stats_info = (StatInfo_t *) tmp_v_addr; 580 mac_control->stats_info = (StatInfo_t *) tmp_v_addr;
496 memset(tmp_v_addr, 0, size); 581 memset(tmp_v_addr, 0, size);
497
498 DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, 582 DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name,
499 (unsigned long long) tmp_p_addr); 583 (unsigned long long) tmp_p_addr);
500 584
501 return SUCCESS; 585 return SUCCESS;
502} 586}
503 587
504/** 588/**
505 * free_shared_mem - Free the allocated Memory 589 * free_shared_mem - Free the allocated Memory
506 * @nic: Device private variable. 590 * @nic: Device private variable.
507 * Description: This function is to free all memory locations allocated by 591 * Description: This function is to free all memory locations allocated by
508 * the init_shared_mem() function and return it to the kernel. 592 * the init_shared_mem() function and return it to the kernel.
@@ -532,15 +616,19 @@ static void free_shared_mem(struct s2io_nic *nic)
532 lst_per_page); 616 lst_per_page);
533 for (j = 0; j < page_num; j++) { 617 for (j = 0; j < page_num; j++) {
534 int mem_blks = (j * lst_per_page); 618 int mem_blks = (j * lst_per_page);
535 if (!nic->list_info[i][mem_blks].list_virt_addr) 619 if ((!mac_control->fifos[i].list_info) ||
620 (!mac_control->fifos[i].list_info[mem_blks].
621 list_virt_addr))
536 break; 622 break;
537 pci_free_consistent(nic->pdev, PAGE_SIZE, 623 pci_free_consistent(nic->pdev, PAGE_SIZE,
538 nic->list_info[i][mem_blks]. 624 mac_control->fifos[i].
625 list_info[mem_blks].
539 list_virt_addr, 626 list_virt_addr,
540 nic->list_info[i][mem_blks]. 627 mac_control->fifos[i].
628 list_info[mem_blks].
541 list_phy_addr); 629 list_phy_addr);
542 } 630 }
543 kfree(nic->list_info[i]); 631 kfree(mac_control->fifos[i].list_info);
544 } 632 }
545 633
546#ifndef CONFIG_2BUFF_MODE 634#ifndef CONFIG_2BUFF_MODE
@@ -549,10 +637,12 @@ static void free_shared_mem(struct s2io_nic *nic)
549 size = SIZE_OF_BLOCK; 637 size = SIZE_OF_BLOCK;
550#endif 638#endif
551 for (i = 0; i < config->rx_ring_num; i++) { 639 for (i = 0; i < config->rx_ring_num; i++) {
552 blk_cnt = nic->block_count[i]; 640 blk_cnt = mac_control->rings[i].block_count;
553 for (j = 0; j < blk_cnt; j++) { 641 for (j = 0; j < blk_cnt; j++) {
554 tmp_v_addr = nic->rx_blocks[i][j].block_virt_addr; 642 tmp_v_addr = mac_control->rings[i].rx_blocks[j].
555 tmp_p_addr = nic->rx_blocks[i][j].block_dma_addr; 643 block_virt_addr;
644 tmp_p_addr = mac_control->rings[i].rx_blocks[j].
645 block_dma_addr;
556 if (tmp_v_addr == NULL) 646 if (tmp_v_addr == NULL)
557 break; 647 break;
558 pci_free_consistent(nic->pdev, size, 648 pci_free_consistent(nic->pdev, size,
@@ -565,35 +655,21 @@ static void free_shared_mem(struct s2io_nic *nic)
565 for (i = 0; i < config->rx_ring_num; i++) { 655 for (i = 0; i < config->rx_ring_num; i++) {
566 blk_cnt = 656 blk_cnt =
567 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1); 657 config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
568 if (!nic->ba[i])
569 goto end_free;
570 for (j = 0; j < blk_cnt; j++) { 658 for (j = 0; j < blk_cnt; j++) {
571 int k = 0; 659 int k = 0;
572 if (!nic->ba[i][j]) { 660 if (!mac_control->rings[i].ba[j])
573 kfree(nic->ba[i]); 661 continue;
574 goto end_free;
575 }
576 while (k != MAX_RXDS_PER_BLOCK) { 662 while (k != MAX_RXDS_PER_BLOCK) {
577 buffAdd_t *ba = &nic->ba[i][j][k]; 663 buffAdd_t *ba = &mac_control->rings[i].ba[j][k];
578 if (!ba || !ba->ba_0_org || !ba->ba_1_org)
579 {
580 kfree(nic->ba[i]);
581 kfree(nic->ba[i][j]);
582 if(ba->ba_0_org)
583 kfree(ba->ba_0_org);
584 if(ba->ba_1_org)
585 kfree(ba->ba_1_org);
586 goto end_free;
587 }
588 kfree(ba->ba_0_org); 664 kfree(ba->ba_0_org);
589 kfree(ba->ba_1_org); 665 kfree(ba->ba_1_org);
590 k++; 666 k++;
591 } 667 }
592 kfree(nic->ba[i][j]); 668 kfree(mac_control->rings[i].ba[j]);
593 } 669 }
594 kfree(nic->ba[i]); 670 if (mac_control->rings[i].ba)
671 kfree(mac_control->rings[i].ba);
595 } 672 }
596end_free:
597#endif 673#endif
598 674
599 if (mac_control->stats_mem) { 675 if (mac_control->stats_mem) {
@@ -604,12 +680,93 @@ end_free:
604 } 680 }
605} 681}
606 682
607/** 683/**
608 * init_nic - Initialization of hardware 684 * s2io_verify_pci_mode -
685 */
686
687static int s2io_verify_pci_mode(nic_t *nic)
688{
689 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
690 register u64 val64 = 0;
691 int mode;
692
693 val64 = readq(&bar0->pci_mode);
694 mode = (u8)GET_PCI_MODE(val64);
695
696 if ( val64 & PCI_MODE_UNKNOWN_MODE)
697 return -1; /* Unknown PCI mode */
698 return mode;
699}
700
701
702/**
703 * s2io_print_pci_mode -
704 */
705static int s2io_print_pci_mode(nic_t *nic)
706{
707 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
708 register u64 val64 = 0;
709 int mode;
710 struct config_param *config = &nic->config;
711
712 val64 = readq(&bar0->pci_mode);
713 mode = (u8)GET_PCI_MODE(val64);
714
715 if ( val64 & PCI_MODE_UNKNOWN_MODE)
716 return -1; /* Unknown PCI mode */
717
718 if (val64 & PCI_MODE_32_BITS) {
719 DBG_PRINT(ERR_DBG, "%s: Device is on 32 bit ", nic->dev->name);
720 } else {
721 DBG_PRINT(ERR_DBG, "%s: Device is on 64 bit ", nic->dev->name);
722 }
723
724 switch(mode) {
725 case PCI_MODE_PCI_33:
726 DBG_PRINT(ERR_DBG, "33MHz PCI bus\n");
727 config->bus_speed = 33;
728 break;
729 case PCI_MODE_PCI_66:
730 DBG_PRINT(ERR_DBG, "66MHz PCI bus\n");
731 config->bus_speed = 133;
732 break;
733 case PCI_MODE_PCIX_M1_66:
734 DBG_PRINT(ERR_DBG, "66MHz PCIX(M1) bus\n");
735 config->bus_speed = 133; /* Herc doubles the clock rate */
736 break;
737 case PCI_MODE_PCIX_M1_100:
738 DBG_PRINT(ERR_DBG, "100MHz PCIX(M1) bus\n");
739 config->bus_speed = 200;
740 break;
741 case PCI_MODE_PCIX_M1_133:
742 DBG_PRINT(ERR_DBG, "133MHz PCIX(M1) bus\n");
743 config->bus_speed = 266;
744 break;
745 case PCI_MODE_PCIX_M2_66:
746 DBG_PRINT(ERR_DBG, "133MHz PCIX(M2) bus\n");
747 config->bus_speed = 133;
748 break;
749 case PCI_MODE_PCIX_M2_100:
750 DBG_PRINT(ERR_DBG, "200MHz PCIX(M2) bus\n");
751 config->bus_speed = 200;
752 break;
753 case PCI_MODE_PCIX_M2_133:
754 DBG_PRINT(ERR_DBG, "266MHz PCIX(M2) bus\n");
755 config->bus_speed = 266;
756 break;
757 default:
758 return -1; /* Unsupported bus speed */
759 }
760
761 return mode;
762}
763
764/**
765 * init_nic - Initialization of hardware
609 * @nic: device peivate variable 766 * @nic: device peivate variable
610 * Description: The function sequentially configures every block 767 * Description: The function sequentially configures every block
611 * of the H/W from their reset values. 768 * of the H/W from their reset values.
612 * Return Value: SUCCESS on success and 769 * Return Value: SUCCESS on success and
613 * '-1' on failure (endian settings incorrect). 770 * '-1' on failure (endian settings incorrect).
614 */ 771 */
615 772
@@ -625,21 +782,32 @@ static int init_nic(struct s2io_nic *nic)
625 struct config_param *config; 782 struct config_param *config;
626 int mdio_cnt = 0, dtx_cnt = 0; 783 int mdio_cnt = 0, dtx_cnt = 0;
627 unsigned long long mem_share; 784 unsigned long long mem_share;
785 int mem_size;
628 786
629 mac_control = &nic->mac_control; 787 mac_control = &nic->mac_control;
630 config = &nic->config; 788 config = &nic->config;
631 789
632 /* Initialize swapper control register */ 790 /* to set the swapper controle on the card */
633 if (s2io_set_swapper(nic)) { 791 if(s2io_set_swapper(nic)) {
634 DBG_PRINT(ERR_DBG,"ERROR: Setting Swapper failed\n"); 792 DBG_PRINT(ERR_DBG,"ERROR: Setting Swapper failed\n");
635 return -1; 793 return -1;
636 } 794 }
637 795
796 /*
797 * Herc requires EOI to be removed from reset before XGXS, so..
798 */
799 if (nic->device_type & XFRAME_II_DEVICE) {
800 val64 = 0xA500000000ULL;
801 writeq(val64, &bar0->sw_reset);
802 msleep(500);
803 val64 = readq(&bar0->sw_reset);
804 }
805
638 /* Remove XGXS from reset state */ 806 /* Remove XGXS from reset state */
639 val64 = 0; 807 val64 = 0;
640 writeq(val64, &bar0->sw_reset); 808 writeq(val64, &bar0->sw_reset);
641 val64 = readq(&bar0->sw_reset);
642 msleep(500); 809 msleep(500);
810 val64 = readq(&bar0->sw_reset);
643 811
644 /* Enable Receiving broadcasts */ 812 /* Enable Receiving broadcasts */
645 add = &bar0->mac_cfg; 813 add = &bar0->mac_cfg;
@@ -659,48 +827,58 @@ static int init_nic(struct s2io_nic *nic)
659 val64 = dev->mtu; 827 val64 = dev->mtu;
660 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len); 828 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
661 829
662 /* 830 /*
663 * Configuring the XAUI Interface of Xena. 831 * Configuring the XAUI Interface of Xena.
664 * *************************************** 832 * ***************************************
665 * To Configure the Xena's XAUI, one has to write a series 833 * To Configure the Xena's XAUI, one has to write a series
666 * of 64 bit values into two registers in a particular 834 * of 64 bit values into two registers in a particular
667 * sequence. Hence a macro 'SWITCH_SIGN' has been defined 835 * sequence. Hence a macro 'SWITCH_SIGN' has been defined
668 * which will be defined in the array of configuration values 836 * which will be defined in the array of configuration values
669 * (default_dtx_cfg & default_mdio_cfg) at appropriate places 837 * (xena_dtx_cfg & xena_mdio_cfg) at appropriate places
670 * to switch writing from one regsiter to another. We continue 838 * to switch writing from one regsiter to another. We continue
671 * writing these values until we encounter the 'END_SIGN' macro. 839 * writing these values until we encounter the 'END_SIGN' macro.
672 * For example, After making a series of 21 writes into 840 * For example, After making a series of 21 writes into
673 * dtx_control register the 'SWITCH_SIGN' appears and hence we 841 * dtx_control register the 'SWITCH_SIGN' appears and hence we
674 * start writing into mdio_control until we encounter END_SIGN. 842 * start writing into mdio_control until we encounter END_SIGN.
675 */ 843 */
676 while (1) { 844 if (nic->device_type & XFRAME_II_DEVICE) {
677 dtx_cfg: 845 while (herc_act_dtx_cfg[dtx_cnt] != END_SIGN) {
678 while (default_dtx_cfg[dtx_cnt] != END_SIGN) { 846 SPECIAL_REG_WRITE(herc_act_dtx_cfg[dtx_cnt],
679 if (default_dtx_cfg[dtx_cnt] == SWITCH_SIGN) {
680 dtx_cnt++;
681 goto mdio_cfg;
682 }
683 SPECIAL_REG_WRITE(default_dtx_cfg[dtx_cnt],
684 &bar0->dtx_control, UF); 847 &bar0->dtx_control, UF);
685 val64 = readq(&bar0->dtx_control); 848 if (dtx_cnt & 0x1)
849 msleep(1); /* Necessary!! */
686 dtx_cnt++; 850 dtx_cnt++;
687 } 851 }
688 mdio_cfg: 852 } else {
689 while (default_mdio_cfg[mdio_cnt] != END_SIGN) { 853 while (1) {
690 if (default_mdio_cfg[mdio_cnt] == SWITCH_SIGN) { 854 dtx_cfg:
855 while (xena_dtx_cfg[dtx_cnt] != END_SIGN) {
856 if (xena_dtx_cfg[dtx_cnt] == SWITCH_SIGN) {
857 dtx_cnt++;
858 goto mdio_cfg;
859 }
860 SPECIAL_REG_WRITE(xena_dtx_cfg[dtx_cnt],
861 &bar0->dtx_control, UF);
862 val64 = readq(&bar0->dtx_control);
863 dtx_cnt++;
864 }
865 mdio_cfg:
866 while (xena_mdio_cfg[mdio_cnt] != END_SIGN) {
867 if (xena_mdio_cfg[mdio_cnt] == SWITCH_SIGN) {
868 mdio_cnt++;
869 goto dtx_cfg;
870 }
871 SPECIAL_REG_WRITE(xena_mdio_cfg[mdio_cnt],
872 &bar0->mdio_control, UF);
873 val64 = readq(&bar0->mdio_control);
691 mdio_cnt++; 874 mdio_cnt++;
875 }
876 if ((xena_dtx_cfg[dtx_cnt] == END_SIGN) &&
877 (xena_mdio_cfg[mdio_cnt] == END_SIGN)) {
878 break;
879 } else {
692 goto dtx_cfg; 880 goto dtx_cfg;
693 } 881 }
694 SPECIAL_REG_WRITE(default_mdio_cfg[mdio_cnt],
695 &bar0->mdio_control, UF);
696 val64 = readq(&bar0->mdio_control);
697 mdio_cnt++;
698 }
699 if ((default_dtx_cfg[dtx_cnt] == END_SIGN) &&
700 (default_mdio_cfg[mdio_cnt] == END_SIGN)) {
701 break;
702 } else {
703 goto dtx_cfg;
704 } 882 }
705 } 883 }
706 884
@@ -747,12 +925,20 @@ static int init_nic(struct s2io_nic *nic)
747 val64 |= BIT(0); /* To enable the FIFO partition. */ 925 val64 |= BIT(0); /* To enable the FIFO partition. */
748 writeq(val64, &bar0->tx_fifo_partition_0); 926 writeq(val64, &bar0->tx_fifo_partition_0);
749 927
928 /*
929 * Disable 4 PCCs for Xena1, 2 and 3 as per H/W bug
930 * SXE-008 TRANSMIT DMA ARBITRATION ISSUE.
931 */
932 if ((nic->device_type == XFRAME_I_DEVICE) &&
933 (get_xena_rev_id(nic->pdev) < 4))
934 writeq(PCC_ENABLE_FOUR, &bar0->pcc_enable);
935
750 val64 = readq(&bar0->tx_fifo_partition_0); 936 val64 = readq(&bar0->tx_fifo_partition_0);
751 DBG_PRINT(INIT_DBG, "Fifo partition at: 0x%p is: 0x%llx\n", 937 DBG_PRINT(INIT_DBG, "Fifo partition at: 0x%p is: 0x%llx\n",
752 &bar0->tx_fifo_partition_0, (unsigned long long) val64); 938 &bar0->tx_fifo_partition_0, (unsigned long long) val64);
753 939
754 /* 940 /*
755 * Initialization of Tx_PA_CONFIG register to ignore packet 941 * Initialization of Tx_PA_CONFIG register to ignore packet
756 * integrity checking. 942 * integrity checking.
757 */ 943 */
758 val64 = readq(&bar0->tx_pa_cfg); 944 val64 = readq(&bar0->tx_pa_cfg);
@@ -769,85 +955,304 @@ static int init_nic(struct s2io_nic *nic)
769 } 955 }
770 writeq(val64, &bar0->rx_queue_priority); 956 writeq(val64, &bar0->rx_queue_priority);
771 957
772 /* 958 /*
773 * Allocating equal share of memory to all the 959 * Allocating equal share of memory to all the
774 * configured Rings. 960 * configured Rings.
775 */ 961 */
776 val64 = 0; 962 val64 = 0;
963 if (nic->device_type & XFRAME_II_DEVICE)
964 mem_size = 32;
965 else
966 mem_size = 64;
967
777 for (i = 0; i < config->rx_ring_num; i++) { 968 for (i = 0; i < config->rx_ring_num; i++) {
778 switch (i) { 969 switch (i) {
779 case 0: 970 case 0:
780 mem_share = (64 / config->rx_ring_num + 971 mem_share = (mem_size / config->rx_ring_num +
781 64 % config->rx_ring_num); 972 mem_size % config->rx_ring_num);
782 val64 |= RX_QUEUE_CFG_Q0_SZ(mem_share); 973 val64 |= RX_QUEUE_CFG_Q0_SZ(mem_share);
783 continue; 974 continue;
784 case 1: 975 case 1:
785 mem_share = (64 / config->rx_ring_num); 976 mem_share = (mem_size / config->rx_ring_num);
786 val64 |= RX_QUEUE_CFG_Q1_SZ(mem_share); 977 val64 |= RX_QUEUE_CFG_Q1_SZ(mem_share);
787 continue; 978 continue;
788 case 2: 979 case 2:
789 mem_share = (64 / config->rx_ring_num); 980 mem_share = (mem_size / config->rx_ring_num);
790 val64 |= RX_QUEUE_CFG_Q2_SZ(mem_share); 981 val64 |= RX_QUEUE_CFG_Q2_SZ(mem_share);
791 continue; 982 continue;
792 case 3: 983 case 3:
793 mem_share = (64 / config->rx_ring_num); 984 mem_share = (mem_size / config->rx_ring_num);
794 val64 |= RX_QUEUE_CFG_Q3_SZ(mem_share); 985 val64 |= RX_QUEUE_CFG_Q3_SZ(mem_share);
795 continue; 986 continue;
796 case 4: 987 case 4:
797 mem_share = (64 / config->rx_ring_num); 988 mem_share = (mem_size / config->rx_ring_num);
798 val64 |= RX_QUEUE_CFG_Q4_SZ(mem_share); 989 val64 |= RX_QUEUE_CFG_Q4_SZ(mem_share);
799 continue; 990 continue;
800 case 5: 991 case 5:
801 mem_share = (64 / config->rx_ring_num); 992 mem_share = (mem_size / config->rx_ring_num);
802 val64 |= RX_QUEUE_CFG_Q5_SZ(mem_share); 993 val64 |= RX_QUEUE_CFG_Q5_SZ(mem_share);
803 continue; 994 continue;
804 case 6: 995 case 6:
805 mem_share = (64 / config->rx_ring_num); 996 mem_share = (mem_size / config->rx_ring_num);
806 val64 |= RX_QUEUE_CFG_Q6_SZ(mem_share); 997 val64 |= RX_QUEUE_CFG_Q6_SZ(mem_share);
807 continue; 998 continue;
808 case 7: 999 case 7:
809 mem_share = (64 / config->rx_ring_num); 1000 mem_share = (mem_size / config->rx_ring_num);
810 val64 |= RX_QUEUE_CFG_Q7_SZ(mem_share); 1001 val64 |= RX_QUEUE_CFG_Q7_SZ(mem_share);
811 continue; 1002 continue;
812 } 1003 }
813 } 1004 }
814 writeq(val64, &bar0->rx_queue_cfg); 1005 writeq(val64, &bar0->rx_queue_cfg);
815 1006
816 /* 1007 /*
817 * Initializing the Tx round robin registers to 0. 1008 * Filling Tx round robin registers
818 * Filling Tx and Rx round robin registers as per the 1009 * as per the number of FIFOs
819 * number of FIFOs and Rings is still TODO.
820 */
821 writeq(0, &bar0->tx_w_round_robin_0);
822 writeq(0, &bar0->tx_w_round_robin_1);
823 writeq(0, &bar0->tx_w_round_robin_2);
824 writeq(0, &bar0->tx_w_round_robin_3);
825 writeq(0, &bar0->tx_w_round_robin_4);
826
827 /*
828 * TODO
829 * Disable Rx steering. Hard coding all packets be steered to
830 * Queue 0 for now.
831 */ 1010 */
832 val64 = 0x8080808080808080ULL; 1011 switch (config->tx_fifo_num) {
833 writeq(val64, &bar0->rts_qos_steering); 1012 case 1:
1013 val64 = 0x0000000000000000ULL;
1014 writeq(val64, &bar0->tx_w_round_robin_0);
1015 writeq(val64, &bar0->tx_w_round_robin_1);
1016 writeq(val64, &bar0->tx_w_round_robin_2);
1017 writeq(val64, &bar0->tx_w_round_robin_3);
1018 writeq(val64, &bar0->tx_w_round_robin_4);
1019 break;
1020 case 2:
1021 val64 = 0x0000010000010000ULL;
1022 writeq(val64, &bar0->tx_w_round_robin_0);
1023 val64 = 0x0100000100000100ULL;
1024 writeq(val64, &bar0->tx_w_round_robin_1);
1025 val64 = 0x0001000001000001ULL;
1026 writeq(val64, &bar0->tx_w_round_robin_2);
1027 val64 = 0x0000010000010000ULL;
1028 writeq(val64, &bar0->tx_w_round_robin_3);
1029 val64 = 0x0100000000000000ULL;
1030 writeq(val64, &bar0->tx_w_round_robin_4);
1031 break;
1032 case 3:
1033 val64 = 0x0001000102000001ULL;
1034 writeq(val64, &bar0->tx_w_round_robin_0);
1035 val64 = 0x0001020000010001ULL;
1036 writeq(val64, &bar0->tx_w_round_robin_1);
1037 val64 = 0x0200000100010200ULL;
1038 writeq(val64, &bar0->tx_w_round_robin_2);
1039 val64 = 0x0001000102000001ULL;
1040 writeq(val64, &bar0->tx_w_round_robin_3);
1041 val64 = 0x0001020000000000ULL;
1042 writeq(val64, &bar0->tx_w_round_robin_4);
1043 break;
1044 case 4:
1045 val64 = 0x0001020300010200ULL;
1046 writeq(val64, &bar0->tx_w_round_robin_0);
1047 val64 = 0x0100000102030001ULL;
1048 writeq(val64, &bar0->tx_w_round_robin_1);
1049 val64 = 0x0200010000010203ULL;
1050 writeq(val64, &bar0->tx_w_round_robin_2);
1051 val64 = 0x0001020001000001ULL;
1052 writeq(val64, &bar0->tx_w_round_robin_3);
1053 val64 = 0x0203000100000000ULL;
1054 writeq(val64, &bar0->tx_w_round_robin_4);
1055 break;
1056 case 5:
1057 val64 = 0x0001000203000102ULL;
1058 writeq(val64, &bar0->tx_w_round_robin_0);
1059 val64 = 0x0001020001030004ULL;
1060 writeq(val64, &bar0->tx_w_round_robin_1);
1061 val64 = 0x0001000203000102ULL;
1062 writeq(val64, &bar0->tx_w_round_robin_2);
1063 val64 = 0x0001020001030004ULL;
1064 writeq(val64, &bar0->tx_w_round_robin_3);
1065 val64 = 0x0001000000000000ULL;
1066 writeq(val64, &bar0->tx_w_round_robin_4);
1067 break;
1068 case 6:
1069 val64 = 0x0001020304000102ULL;
1070 writeq(val64, &bar0->tx_w_round_robin_0);
1071 val64 = 0x0304050001020001ULL;
1072 writeq(val64, &bar0->tx_w_round_robin_1);
1073 val64 = 0x0203000100000102ULL;
1074 writeq(val64, &bar0->tx_w_round_robin_2);
1075 val64 = 0x0304000102030405ULL;
1076 writeq(val64, &bar0->tx_w_round_robin_3);
1077 val64 = 0x0001000200000000ULL;
1078 writeq(val64, &bar0->tx_w_round_robin_4);
1079 break;
1080 case 7:
1081 val64 = 0x0001020001020300ULL;
1082 writeq(val64, &bar0->tx_w_round_robin_0);
1083 val64 = 0x0102030400010203ULL;
1084 writeq(val64, &bar0->tx_w_round_robin_1);
1085 val64 = 0x0405060001020001ULL;
1086 writeq(val64, &bar0->tx_w_round_robin_2);
1087 val64 = 0x0304050000010200ULL;
1088 writeq(val64, &bar0->tx_w_round_robin_3);
1089 val64 = 0x0102030000000000ULL;
1090 writeq(val64, &bar0->tx_w_round_robin_4);
1091 break;
1092 case 8:
1093 val64 = 0x0001020300040105ULL;
1094 writeq(val64, &bar0->tx_w_round_robin_0);
1095 val64 = 0x0200030106000204ULL;
1096 writeq(val64, &bar0->tx_w_round_robin_1);
1097 val64 = 0x0103000502010007ULL;
1098 writeq(val64, &bar0->tx_w_round_robin_2);
1099 val64 = 0x0304010002060500ULL;
1100 writeq(val64, &bar0->tx_w_round_robin_3);
1101 val64 = 0x0103020400000000ULL;
1102 writeq(val64, &bar0->tx_w_round_robin_4);
1103 break;
1104 }
1105
1106 /* Filling the Rx round robin registers as per the
1107 * number of Rings and steering based on QoS.
1108 */
1109 switch (config->rx_ring_num) {
1110 case 1:
1111 val64 = 0x8080808080808080ULL;
1112 writeq(val64, &bar0->rts_qos_steering);
1113 break;
1114 case 2:
1115 val64 = 0x0000010000010000ULL;
1116 writeq(val64, &bar0->rx_w_round_robin_0);
1117 val64 = 0x0100000100000100ULL;
1118 writeq(val64, &bar0->rx_w_round_robin_1);
1119 val64 = 0x0001000001000001ULL;
1120 writeq(val64, &bar0->rx_w_round_robin_2);
1121 val64 = 0x0000010000010000ULL;
1122 writeq(val64, &bar0->rx_w_round_robin_3);
1123 val64 = 0x0100000000000000ULL;
1124 writeq(val64, &bar0->rx_w_round_robin_4);
1125
1126 val64 = 0x8080808040404040ULL;
1127 writeq(val64, &bar0->rts_qos_steering);
1128 break;
1129 case 3:
1130 val64 = 0x0001000102000001ULL;
1131 writeq(val64, &bar0->rx_w_round_robin_0);
1132 val64 = 0x0001020000010001ULL;
1133 writeq(val64, &bar0->rx_w_round_robin_1);
1134 val64 = 0x0200000100010200ULL;
1135 writeq(val64, &bar0->rx_w_round_robin_2);
1136 val64 = 0x0001000102000001ULL;
1137 writeq(val64, &bar0->rx_w_round_robin_3);
1138 val64 = 0x0001020000000000ULL;
1139 writeq(val64, &bar0->rx_w_round_robin_4);
1140
1141 val64 = 0x8080804040402020ULL;
1142 writeq(val64, &bar0->rts_qos_steering);
1143 break;
1144 case 4:
1145 val64 = 0x0001020300010200ULL;
1146 writeq(val64, &bar0->rx_w_round_robin_0);
1147 val64 = 0x0100000102030001ULL;
1148 writeq(val64, &bar0->rx_w_round_robin_1);
1149 val64 = 0x0200010000010203ULL;
1150 writeq(val64, &bar0->rx_w_round_robin_2);
1151 val64 = 0x0001020001000001ULL;
1152 writeq(val64, &bar0->rx_w_round_robin_3);
1153 val64 = 0x0203000100000000ULL;
1154 writeq(val64, &bar0->rx_w_round_robin_4);
1155
1156 val64 = 0x8080404020201010ULL;
1157 writeq(val64, &bar0->rts_qos_steering);
1158 break;
1159 case 5:
1160 val64 = 0x0001000203000102ULL;
1161 writeq(val64, &bar0->rx_w_round_robin_0);
1162 val64 = 0x0001020001030004ULL;
1163 writeq(val64, &bar0->rx_w_round_robin_1);
1164 val64 = 0x0001000203000102ULL;
1165 writeq(val64, &bar0->rx_w_round_robin_2);
1166 val64 = 0x0001020001030004ULL;
1167 writeq(val64, &bar0->rx_w_round_robin_3);
1168 val64 = 0x0001000000000000ULL;
1169 writeq(val64, &bar0->rx_w_round_robin_4);
1170
1171 val64 = 0x8080404020201008ULL;
1172 writeq(val64, &bar0->rts_qos_steering);
1173 break;
1174 case 6:
1175 val64 = 0x0001020304000102ULL;
1176 writeq(val64, &bar0->rx_w_round_robin_0);
1177 val64 = 0x0304050001020001ULL;
1178 writeq(val64, &bar0->rx_w_round_robin_1);
1179 val64 = 0x0203000100000102ULL;
1180 writeq(val64, &bar0->rx_w_round_robin_2);
1181 val64 = 0x0304000102030405ULL;
1182 writeq(val64, &bar0->rx_w_round_robin_3);
1183 val64 = 0x0001000200000000ULL;
1184 writeq(val64, &bar0->rx_w_round_robin_4);
1185
1186 val64 = 0x8080404020100804ULL;
1187 writeq(val64, &bar0->rts_qos_steering);
1188 break;
1189 case 7:
1190 val64 = 0x0001020001020300ULL;
1191 writeq(val64, &bar0->rx_w_round_robin_0);
1192 val64 = 0x0102030400010203ULL;
1193 writeq(val64, &bar0->rx_w_round_robin_1);
1194 val64 = 0x0405060001020001ULL;
1195 writeq(val64, &bar0->rx_w_round_robin_2);
1196 val64 = 0x0304050000010200ULL;
1197 writeq(val64, &bar0->rx_w_round_robin_3);
1198 val64 = 0x0102030000000000ULL;
1199 writeq(val64, &bar0->rx_w_round_robin_4);
1200
1201 val64 = 0x8080402010080402ULL;
1202 writeq(val64, &bar0->rts_qos_steering);
1203 break;
1204 case 8:
1205 val64 = 0x0001020300040105ULL;
1206 writeq(val64, &bar0->rx_w_round_robin_0);
1207 val64 = 0x0200030106000204ULL;
1208 writeq(val64, &bar0->rx_w_round_robin_1);
1209 val64 = 0x0103000502010007ULL;
1210 writeq(val64, &bar0->rx_w_round_robin_2);
1211 val64 = 0x0304010002060500ULL;
1212 writeq(val64, &bar0->rx_w_round_robin_3);
1213 val64 = 0x0103020400000000ULL;
1214 writeq(val64, &bar0->rx_w_round_robin_4);
1215
1216 val64 = 0x8040201008040201ULL;
1217 writeq(val64, &bar0->rts_qos_steering);
1218 break;
1219 }
834 1220
835 /* UDP Fix */ 1221 /* UDP Fix */
836 val64 = 0; 1222 val64 = 0;
837 for (i = 1; i < 8; i++) 1223 for (i = 0; i < 8; i++)
1224 writeq(val64, &bar0->rts_frm_len_n[i]);
1225
1226 /* Set the default rts frame length for the rings configured */
1227 val64 = MAC_RTS_FRM_LEN_SET(dev->mtu+22);
1228 for (i = 0 ; i < config->rx_ring_num ; i++)
838 writeq(val64, &bar0->rts_frm_len_n[i]); 1229 writeq(val64, &bar0->rts_frm_len_n[i]);
839 1230
840 /* Set rts_frm_len register for fifo 0 */ 1231 /* Set the frame length for the configured rings
841 writeq(MAC_RTS_FRM_LEN_SET(dev->mtu + 22), 1232 * desired by the user
842 &bar0->rts_frm_len_n[0]); 1233 */
1234 for (i = 0; i < config->rx_ring_num; i++) {
1235 /* If rts_frm_len[i] == 0 then it is assumed that user not
1236 * specified frame length steering.
1237 * If the user provides the frame length then program
1238 * the rts_frm_len register for those values or else
1239 * leave it as it is.
1240 */
1241 if (rts_frm_len[i] != 0) {
1242 writeq(MAC_RTS_FRM_LEN_SET(rts_frm_len[i]),
1243 &bar0->rts_frm_len_n[i]);
1244 }
1245 }
843 1246
844 /* Enable statistics */ 1247 /* Program statistics memory */
845 writeq(mac_control->stats_mem_phy, &bar0->stat_addr); 1248 writeq(mac_control->stats_mem_phy, &bar0->stat_addr);
846 val64 = SET_UPDT_PERIOD(Stats_refresh_time) |
847 STAT_CFG_STAT_RO | STAT_CFG_STAT_EN;
848 writeq(val64, &bar0->stat_cfg);
849 1249
850 /* 1250 if (nic->device_type == XFRAME_II_DEVICE) {
1251 val64 = STAT_BC(0x320);
1252 writeq(val64, &bar0->stat_byte_cnt);
1253 }
1254
1255 /*
851 * Initializing the sampling rate for the device to calculate the 1256 * Initializing the sampling rate for the device to calculate the
852 * bandwidth utilization. 1257 * bandwidth utilization.
853 */ 1258 */
@@ -856,30 +1261,38 @@ static int init_nic(struct s2io_nic *nic)
856 writeq(val64, &bar0->mac_link_util); 1261 writeq(val64, &bar0->mac_link_util);
857 1262
858 1263
859 /* 1264 /*
860 * Initializing the Transmit and Receive Traffic Interrupt 1265 * Initializing the Transmit and Receive Traffic Interrupt
861 * Scheme. 1266 * Scheme.
862 */ 1267 */
863 /* TTI Initialization. Default Tx timer gets us about 1268 /*
1269 * TTI Initialization. Default Tx timer gets us about
864 * 250 interrupts per sec. Continuous interrupts are enabled 1270 * 250 interrupts per sec. Continuous interrupts are enabled
865 * by default. 1271 * by default.
866 */ 1272 */
867 val64 = TTI_DATA1_MEM_TX_TIMER_VAL(0x2078) | 1273 if (nic->device_type == XFRAME_II_DEVICE) {
868 TTI_DATA1_MEM_TX_URNG_A(0xA) | 1274 int count = (nic->config.bus_speed * 125)/2;
1275 val64 = TTI_DATA1_MEM_TX_TIMER_VAL(count);
1276 } else {
1277
1278 val64 = TTI_DATA1_MEM_TX_TIMER_VAL(0x2078);
1279 }
1280 val64 |= TTI_DATA1_MEM_TX_URNG_A(0xA) |
869 TTI_DATA1_MEM_TX_URNG_B(0x10) | 1281 TTI_DATA1_MEM_TX_URNG_B(0x10) |
870 TTI_DATA1_MEM_TX_URNG_C(0x30) | TTI_DATA1_MEM_TX_TIMER_AC_EN | 1282 TTI_DATA1_MEM_TX_URNG_C(0x30) | TTI_DATA1_MEM_TX_TIMER_AC_EN;
871 TTI_DATA1_MEM_TX_TIMER_CI_EN; 1283 if (use_continuous_tx_intrs)
1284 val64 |= TTI_DATA1_MEM_TX_TIMER_CI_EN;
872 writeq(val64, &bar0->tti_data1_mem); 1285 writeq(val64, &bar0->tti_data1_mem);
873 1286
874 val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) | 1287 val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) |
875 TTI_DATA2_MEM_TX_UFC_B(0x20) | 1288 TTI_DATA2_MEM_TX_UFC_B(0x20) |
876 TTI_DATA2_MEM_TX_UFC_C(0x40) | TTI_DATA2_MEM_TX_UFC_D(0x80); 1289 TTI_DATA2_MEM_TX_UFC_C(0x70) | TTI_DATA2_MEM_TX_UFC_D(0x80);
877 writeq(val64, &bar0->tti_data2_mem); 1290 writeq(val64, &bar0->tti_data2_mem);
878 1291
879 val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD; 1292 val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD;
880 writeq(val64, &bar0->tti_command_mem); 1293 writeq(val64, &bar0->tti_command_mem);
881 1294
882 /* 1295 /*
883 * Once the operation completes, the Strobe bit of the command 1296 * Once the operation completes, the Strobe bit of the command
884 * register will be reset. We poll for this particular condition 1297 * register will be reset. We poll for this particular condition
885 * We wait for a maximum of 500ms for the operation to complete, 1298 * We wait for a maximum of 500ms for the operation to complete,
@@ -900,52 +1313,97 @@ static int init_nic(struct s2io_nic *nic)
900 time++; 1313 time++;
901 } 1314 }
902 1315
903 /* RTI Initialization */ 1316 if (nic->config.bimodal) {
904 val64 = RTI_DATA1_MEM_RX_TIMER_VAL(0xFFF) | 1317 int k = 0;
905 RTI_DATA1_MEM_RX_URNG_A(0xA) | 1318 for (k = 0; k < config->rx_ring_num; k++) {
906 RTI_DATA1_MEM_RX_URNG_B(0x10) | 1319 val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD;
907 RTI_DATA1_MEM_RX_URNG_C(0x30) | RTI_DATA1_MEM_RX_TIMER_AC_EN; 1320 val64 |= TTI_CMD_MEM_OFFSET(0x38+k);
1321 writeq(val64, &bar0->tti_command_mem);
1322
1323 /*
1324 * Once the operation completes, the Strobe bit of the command
1325 * register will be reset. We poll for this particular condition
1326 * We wait for a maximum of 500ms for the operation to complete,
1327 * if it's not complete by then we return error.
1328 */
1329 time = 0;
1330 while (TRUE) {
1331 val64 = readq(&bar0->tti_command_mem);
1332 if (!(val64 & TTI_CMD_MEM_STROBE_NEW_CMD)) {
1333 break;
1334 }
1335 if (time > 10) {
1336 DBG_PRINT(ERR_DBG,
1337 "%s: TTI init Failed\n",
1338 dev->name);
1339 return -1;
1340 }
1341 time++;
1342 msleep(50);
1343 }
1344 }
1345 } else {
908 1346
909 writeq(val64, &bar0->rti_data1_mem); 1347 /* RTI Initialization */
1348 if (nic->device_type == XFRAME_II_DEVICE) {
1349 /*
1350 * Programmed to generate Apprx 500 Intrs per
1351 * second
1352 */
1353 int count = (nic->config.bus_speed * 125)/4;
1354 val64 = RTI_DATA1_MEM_RX_TIMER_VAL(count);
1355 } else {
1356 val64 = RTI_DATA1_MEM_RX_TIMER_VAL(0xFFF);
1357 }
1358 val64 |= RTI_DATA1_MEM_RX_URNG_A(0xA) |
1359 RTI_DATA1_MEM_RX_URNG_B(0x10) |
1360 RTI_DATA1_MEM_RX_URNG_C(0x30) | RTI_DATA1_MEM_RX_TIMER_AC_EN;
910 1361
911 val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) | 1362 writeq(val64, &bar0->rti_data1_mem);
912 RTI_DATA2_MEM_RX_UFC_B(0x2) |
913 RTI_DATA2_MEM_RX_UFC_C(0x40) | RTI_DATA2_MEM_RX_UFC_D(0x80);
914 writeq(val64, &bar0->rti_data2_mem);
915 1363
916 val64 = RTI_CMD_MEM_WE | RTI_CMD_MEM_STROBE_NEW_CMD; 1364 val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) |
917 writeq(val64, &bar0->rti_command_mem); 1365 RTI_DATA2_MEM_RX_UFC_B(0x2) |
1366 RTI_DATA2_MEM_RX_UFC_C(0x40) | RTI_DATA2_MEM_RX_UFC_D(0x80);
1367 writeq(val64, &bar0->rti_data2_mem);
918 1368
919 /* 1369 for (i = 0; i < config->rx_ring_num; i++) {
920 * Once the operation completes, the Strobe bit of the command 1370 val64 = RTI_CMD_MEM_WE | RTI_CMD_MEM_STROBE_NEW_CMD
921 * register will be reset. We poll for this particular condition 1371 | RTI_CMD_MEM_OFFSET(i);
922 * We wait for a maximum of 500ms for the operation to complete, 1372 writeq(val64, &bar0->rti_command_mem);
923 * if it's not complete by then we return error. 1373
924 */ 1374 /*
925 time = 0; 1375 * Once the operation completes, the Strobe bit of the
926 while (TRUE) { 1376 * command register will be reset. We poll for this
927 val64 = readq(&bar0->rti_command_mem); 1377 * particular condition. We wait for a maximum of 500ms
928 if (!(val64 & TTI_CMD_MEM_STROBE_NEW_CMD)) { 1378 * for the operation to complete, if it's not complete
929 break; 1379 * by then we return error.
930 } 1380 */
931 if (time > 10) { 1381 time = 0;
932 DBG_PRINT(ERR_DBG, "%s: RTI init Failed\n", 1382 while (TRUE) {
933 dev->name); 1383 val64 = readq(&bar0->rti_command_mem);
934 return -1; 1384 if (!(val64 & RTI_CMD_MEM_STROBE_NEW_CMD)) {
1385 break;
1386 }
1387 if (time > 10) {
1388 DBG_PRINT(ERR_DBG, "%s: RTI init Failed\n",
1389 dev->name);
1390 return -1;
1391 }
1392 time++;
1393 msleep(50);
1394 }
935 } 1395 }
936 time++;
937 msleep(50);
938 } 1396 }
939 1397
940 /* 1398 /*
941 * Initializing proper values as Pause threshold into all 1399 * Initializing proper values as Pause threshold into all
942 * the 8 Queues on Rx side. 1400 * the 8 Queues on Rx side.
943 */ 1401 */
944 writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q0q3); 1402 writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q0q3);
945 writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q4q7); 1403 writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q4q7);
946 1404
947 /* Disable RMAC PAD STRIPPING */ 1405 /* Disable RMAC PAD STRIPPING */
948 add = &bar0->mac_cfg; 1406 add = (void *) &bar0->mac_cfg;
949 val64 = readq(&bar0->mac_cfg); 1407 val64 = readq(&bar0->mac_cfg);
950 val64 &= ~(MAC_CFG_RMAC_STRIP_PAD); 1408 val64 &= ~(MAC_CFG_RMAC_STRIP_PAD);
951 writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key); 1409 writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key);
@@ -954,8 +1412,8 @@ static int init_nic(struct s2io_nic *nic)
954 writel((u32) (val64 >> 32), (add + 4)); 1412 writel((u32) (val64 >> 32), (add + 4));
955 val64 = readq(&bar0->mac_cfg); 1413 val64 = readq(&bar0->mac_cfg);
956 1414
957 /* 1415 /*
958 * Set the time value to be inserted in the pause frame 1416 * Set the time value to be inserted in the pause frame
959 * generated by xena. 1417 * generated by xena.
960 */ 1418 */
961 val64 = readq(&bar0->rmac_pause_cfg); 1419 val64 = readq(&bar0->rmac_pause_cfg);
@@ -963,7 +1421,7 @@ static int init_nic(struct s2io_nic *nic)
963 val64 |= RMAC_PAUSE_HG_PTIME(nic->mac_control.rmac_pause_time); 1421 val64 |= RMAC_PAUSE_HG_PTIME(nic->mac_control.rmac_pause_time);
964 writeq(val64, &bar0->rmac_pause_cfg); 1422 writeq(val64, &bar0->rmac_pause_cfg);
965 1423
966 /* 1424 /*
967 * Set the Threshold Limit for Generating the pause frame 1425 * Set the Threshold Limit for Generating the pause frame
968 * If the amount of data in any Queue exceeds ratio of 1426 * If the amount of data in any Queue exceeds ratio of
969 * (mac_control.mc_pause_threshold_q0q3 or q4q7)/256 1427 * (mac_control.mc_pause_threshold_q0q3 or q4q7)/256
@@ -987,25 +1445,54 @@ static int init_nic(struct s2io_nic *nic)
987 } 1445 }
988 writeq(val64, &bar0->mc_pause_thresh_q4q7); 1446 writeq(val64, &bar0->mc_pause_thresh_q4q7);
989 1447
990 /* 1448 /*
991 * TxDMA will stop Read request if the number of read split has 1449 * TxDMA will stop Read request if the number of read split has
992 * exceeded the limit pointed by shared_splits 1450 * exceeded the limit pointed by shared_splits
993 */ 1451 */
994 val64 = readq(&bar0->pic_control); 1452 val64 = readq(&bar0->pic_control);
995 val64 |= PIC_CNTL_SHARED_SPLITS(shared_splits); 1453 val64 |= PIC_CNTL_SHARED_SPLITS(shared_splits);
996 writeq(val64, &bar0->pic_control); 1454 writeq(val64, &bar0->pic_control);
997 1455
1456 /*
1457 * Programming the Herc to split every write transaction
1458 * that does not start on an ADB to reduce disconnects.
1459 */
1460 if (nic->device_type == XFRAME_II_DEVICE) {
1461 val64 = WREQ_SPLIT_MASK_SET_MASK(255);
1462 writeq(val64, &bar0->wreq_split_mask);
1463 }
1464
1465 /* Setting Link stability period to 64 ms */
1466 if (nic->device_type == XFRAME_II_DEVICE) {
1467 val64 = MISC_LINK_STABILITY_PRD(3);
1468 writeq(val64, &bar0->misc_control);
1469 }
1470
998 return SUCCESS; 1471 return SUCCESS;
999} 1472}
1473#define LINK_UP_DOWN_INTERRUPT 1
1474#define MAC_RMAC_ERR_TIMER 2
1000 1475
1001/** 1476#if defined(CONFIG_MSI_MODE) || defined(CONFIG_MSIX_MODE)
1002 * en_dis_able_nic_intrs - Enable or Disable the interrupts 1477#define s2io_link_fault_indication(x) MAC_RMAC_ERR_TIMER
1478#else
1479int s2io_link_fault_indication(nic_t *nic)
1480{
1481 if (nic->device_type == XFRAME_II_DEVICE)
1482 return LINK_UP_DOWN_INTERRUPT;
1483 else
1484 return MAC_RMAC_ERR_TIMER;
1485}
1486#endif
1487
1488/**
1489 * en_dis_able_nic_intrs - Enable or Disable the interrupts
1003 * @nic: device private variable, 1490 * @nic: device private variable,
1004 * @mask: A mask indicating which Intr block must be modified and, 1491 * @mask: A mask indicating which Intr block must be modified and,
1005 * @flag: A flag indicating whether to enable or disable the Intrs. 1492 * @flag: A flag indicating whether to enable or disable the Intrs.
1006 * Description: This function will either disable or enable the interrupts 1493 * Description: This function will either disable or enable the interrupts
1007 * depending on the flag argument. The mask argument can be used to 1494 * depending on the flag argument. The mask argument can be used to
1008 * enable/disable any Intr block. 1495 * enable/disable any Intr block.
1009 * Return Value: NONE. 1496 * Return Value: NONE.
1010 */ 1497 */
1011 1498
@@ -1023,20 +1510,31 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1023 temp64 = readq(&bar0->general_int_mask); 1510 temp64 = readq(&bar0->general_int_mask);
1024 temp64 &= ~((u64) val64); 1511 temp64 &= ~((u64) val64);
1025 writeq(temp64, &bar0->general_int_mask); 1512 writeq(temp64, &bar0->general_int_mask);
1026 /* 1513 /*
1027 * Disabled all PCIX, Flash, MDIO, IIC and GPIO 1514 * If Hercules adapter enable GPIO otherwise
1028 * interrupts for now. 1515 * disabled all PCIX, Flash, MDIO, IIC and GPIO
1029 * TODO 1516 * interrupts for now.
1517 * TODO
1030 */ 1518 */
1031 writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask); 1519 if (s2io_link_fault_indication(nic) ==
1032 /* 1520 LINK_UP_DOWN_INTERRUPT ) {
1521 temp64 = readq(&bar0->pic_int_mask);
1522 temp64 &= ~((u64) PIC_INT_GPIO);
1523 writeq(temp64, &bar0->pic_int_mask);
1524 temp64 = readq(&bar0->gpio_int_mask);
1525 temp64 &= ~((u64) GPIO_INT_MASK_LINK_UP);
1526 writeq(temp64, &bar0->gpio_int_mask);
1527 } else {
1528 writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask);
1529 }
1530 /*
1033 * No MSI Support is available presently, so TTI and 1531 * No MSI Support is available presently, so TTI and
1034 * RTI interrupts are also disabled. 1532 * RTI interrupts are also disabled.
1035 */ 1533 */
1036 } else if (flag == DISABLE_INTRS) { 1534 } else if (flag == DISABLE_INTRS) {
1037 /* 1535 /*
1038 * Disable PIC Intrs in the general 1536 * Disable PIC Intrs in the general
1039 * intr mask register 1537 * intr mask register
1040 */ 1538 */
1041 writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask); 1539 writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask);
1042 temp64 = readq(&bar0->general_int_mask); 1540 temp64 = readq(&bar0->general_int_mask);
@@ -1054,27 +1552,27 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1054 temp64 = readq(&bar0->general_int_mask); 1552 temp64 = readq(&bar0->general_int_mask);
1055 temp64 &= ~((u64) val64); 1553 temp64 &= ~((u64) val64);
1056 writeq(temp64, &bar0->general_int_mask); 1554 writeq(temp64, &bar0->general_int_mask);
1057 /* 1555 /*
1058 * Keep all interrupts other than PFC interrupt 1556 * Keep all interrupts other than PFC interrupt
1059 * and PCC interrupt disabled in DMA level. 1557 * and PCC interrupt disabled in DMA level.
1060 */ 1558 */
1061 val64 = DISABLE_ALL_INTRS & ~(TXDMA_PFC_INT_M | 1559 val64 = DISABLE_ALL_INTRS & ~(TXDMA_PFC_INT_M |
1062 TXDMA_PCC_INT_M); 1560 TXDMA_PCC_INT_M);
1063 writeq(val64, &bar0->txdma_int_mask); 1561 writeq(val64, &bar0->txdma_int_mask);
1064 /* 1562 /*
1065 * Enable only the MISC error 1 interrupt in PFC block 1563 * Enable only the MISC error 1 interrupt in PFC block
1066 */ 1564 */
1067 val64 = DISABLE_ALL_INTRS & (~PFC_MISC_ERR_1); 1565 val64 = DISABLE_ALL_INTRS & (~PFC_MISC_ERR_1);
1068 writeq(val64, &bar0->pfc_err_mask); 1566 writeq(val64, &bar0->pfc_err_mask);
1069 /* 1567 /*
1070 * Enable only the FB_ECC error interrupt in PCC block 1568 * Enable only the FB_ECC error interrupt in PCC block
1071 */ 1569 */
1072 val64 = DISABLE_ALL_INTRS & (~PCC_FB_ECC_ERR); 1570 val64 = DISABLE_ALL_INTRS & (~PCC_FB_ECC_ERR);
1073 writeq(val64, &bar0->pcc_err_mask); 1571 writeq(val64, &bar0->pcc_err_mask);
1074 } else if (flag == DISABLE_INTRS) { 1572 } else if (flag == DISABLE_INTRS) {
1075 /* 1573 /*
1076 * Disable TxDMA Intrs in the general intr mask 1574 * Disable TxDMA Intrs in the general intr mask
1077 * register 1575 * register
1078 */ 1576 */
1079 writeq(DISABLE_ALL_INTRS, &bar0->txdma_int_mask); 1577 writeq(DISABLE_ALL_INTRS, &bar0->txdma_int_mask);
1080 writeq(DISABLE_ALL_INTRS, &bar0->pfc_err_mask); 1578 writeq(DISABLE_ALL_INTRS, &bar0->pfc_err_mask);
@@ -1092,15 +1590,15 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1092 temp64 = readq(&bar0->general_int_mask); 1590 temp64 = readq(&bar0->general_int_mask);
1093 temp64 &= ~((u64) val64); 1591 temp64 &= ~((u64) val64);
1094 writeq(temp64, &bar0->general_int_mask); 1592 writeq(temp64, &bar0->general_int_mask);
1095 /* 1593 /*
1096 * All RxDMA block interrupts are disabled for now 1594 * All RxDMA block interrupts are disabled for now
1097 * TODO 1595 * TODO
1098 */ 1596 */
1099 writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask); 1597 writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask);
1100 } else if (flag == DISABLE_INTRS) { 1598 } else if (flag == DISABLE_INTRS) {
1101 /* 1599 /*
1102 * Disable RxDMA Intrs in the general intr mask 1600 * Disable RxDMA Intrs in the general intr mask
1103 * register 1601 * register
1104 */ 1602 */
1105 writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask); 1603 writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask);
1106 temp64 = readq(&bar0->general_int_mask); 1604 temp64 = readq(&bar0->general_int_mask);
@@ -1117,22 +1615,13 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1117 temp64 = readq(&bar0->general_int_mask); 1615 temp64 = readq(&bar0->general_int_mask);
1118 temp64 &= ~((u64) val64); 1616 temp64 &= ~((u64) val64);
1119 writeq(temp64, &bar0->general_int_mask); 1617 writeq(temp64, &bar0->general_int_mask);
1120 /* 1618 /*
1121 * All MAC block error interrupts are disabled for now 1619 * All MAC block error interrupts are disabled for now
1122 * except the link status change interrupt.
1123 * TODO 1620 * TODO
1124 */ 1621 */
1125 val64 = MAC_INT_STATUS_RMAC_INT;
1126 temp64 = readq(&bar0->mac_int_mask);
1127 temp64 &= ~((u64) val64);
1128 writeq(temp64, &bar0->mac_int_mask);
1129
1130 val64 = readq(&bar0->mac_rmac_err_mask);
1131 val64 &= ~((u64) RMAC_LINK_STATE_CHANGE_INT);
1132 writeq(val64, &bar0->mac_rmac_err_mask);
1133 } else if (flag == DISABLE_INTRS) { 1622 } else if (flag == DISABLE_INTRS) {
1134 /* 1623 /*
1135 * Disable MAC Intrs in the general intr mask register 1624 * Disable MAC Intrs in the general intr mask register
1136 */ 1625 */
1137 writeq(DISABLE_ALL_INTRS, &bar0->mac_int_mask); 1626 writeq(DISABLE_ALL_INTRS, &bar0->mac_int_mask);
1138 writeq(DISABLE_ALL_INTRS, 1627 writeq(DISABLE_ALL_INTRS,
@@ -1151,14 +1640,14 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1151 temp64 = readq(&bar0->general_int_mask); 1640 temp64 = readq(&bar0->general_int_mask);
1152 temp64 &= ~((u64) val64); 1641 temp64 &= ~((u64) val64);
1153 writeq(temp64, &bar0->general_int_mask); 1642 writeq(temp64, &bar0->general_int_mask);
1154 /* 1643 /*
1155 * All XGXS block error interrupts are disabled for now 1644 * All XGXS block error interrupts are disabled for now
1156 * TODO 1645 * TODO
1157 */ 1646 */
1158 writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask); 1647 writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask);
1159 } else if (flag == DISABLE_INTRS) { 1648 } else if (flag == DISABLE_INTRS) {
1160 /* 1649 /*
1161 * Disable MC Intrs in the general intr mask register 1650 * Disable MC Intrs in the general intr mask register
1162 */ 1651 */
1163 writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask); 1652 writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask);
1164 temp64 = readq(&bar0->general_int_mask); 1653 temp64 = readq(&bar0->general_int_mask);
@@ -1174,11 +1663,11 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1174 temp64 = readq(&bar0->general_int_mask); 1663 temp64 = readq(&bar0->general_int_mask);
1175 temp64 &= ~((u64) val64); 1664 temp64 &= ~((u64) val64);
1176 writeq(temp64, &bar0->general_int_mask); 1665 writeq(temp64, &bar0->general_int_mask);
1177 /* 1666 /*
1178 * All MC block error interrupts are disabled for now 1667 * Enable all MC Intrs.
1179 * TODO
1180 */ 1668 */
1181 writeq(DISABLE_ALL_INTRS, &bar0->mc_int_mask); 1669 writeq(0x0, &bar0->mc_int_mask);
1670 writeq(0x0, &bar0->mc_err_mask);
1182 } else if (flag == DISABLE_INTRS) { 1671 } else if (flag == DISABLE_INTRS) {
1183 /* 1672 /*
1184 * Disable MC Intrs in the general intr mask register 1673 * Disable MC Intrs in the general intr mask register
@@ -1198,14 +1687,14 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1198 temp64 = readq(&bar0->general_int_mask); 1687 temp64 = readq(&bar0->general_int_mask);
1199 temp64 &= ~((u64) val64); 1688 temp64 &= ~((u64) val64);
1200 writeq(temp64, &bar0->general_int_mask); 1689 writeq(temp64, &bar0->general_int_mask);
1201 /* 1690 /*
1202 * Enable all the Tx side interrupts 1691 * Enable all the Tx side interrupts
1203 * writing 0 Enables all 64 TX interrupt levels 1692 * writing 0 Enables all 64 TX interrupt levels
1204 */ 1693 */
1205 writeq(0x0, &bar0->tx_traffic_mask); 1694 writeq(0x0, &bar0->tx_traffic_mask);
1206 } else if (flag == DISABLE_INTRS) { 1695 } else if (flag == DISABLE_INTRS) {
1207 /* 1696 /*
1208 * Disable Tx Traffic Intrs in the general intr mask 1697 * Disable Tx Traffic Intrs in the general intr mask
1209 * register. 1698 * register.
1210 */ 1699 */
1211 writeq(DISABLE_ALL_INTRS, &bar0->tx_traffic_mask); 1700 writeq(DISABLE_ALL_INTRS, &bar0->tx_traffic_mask);
@@ -1225,8 +1714,8 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1225 /* writing 0 Enables all 8 RX interrupt levels */ 1714 /* writing 0 Enables all 8 RX interrupt levels */
1226 writeq(0x0, &bar0->rx_traffic_mask); 1715 writeq(0x0, &bar0->rx_traffic_mask);
1227 } else if (flag == DISABLE_INTRS) { 1716 } else if (flag == DISABLE_INTRS) {
1228 /* 1717 /*
1229 * Disable Rx Traffic Intrs in the general intr mask 1718 * Disable Rx Traffic Intrs in the general intr mask
1230 * register. 1719 * register.
1231 */ 1720 */
1232 writeq(DISABLE_ALL_INTRS, &bar0->rx_traffic_mask); 1721 writeq(DISABLE_ALL_INTRS, &bar0->rx_traffic_mask);
@@ -1237,24 +1726,66 @@ static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1237 } 1726 }
1238} 1727}
1239 1728
1240/** 1729static int check_prc_pcc_state(u64 val64, int flag, int rev_id, int herc)
1241 * verify_xena_quiescence - Checks whether the H/W is ready 1730{
1731 int ret = 0;
1732
1733 if (flag == FALSE) {
1734 if ((!herc && (rev_id >= 4)) || herc) {
1735 if (!(val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1736 ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1737 ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
1738 ret = 1;
1739 }
1740 }else {
1741 if (!(val64 & ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) &&
1742 ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1743 ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
1744 ret = 1;
1745 }
1746 }
1747 } else {
1748 if ((!herc && (rev_id >= 4)) || herc) {
1749 if (((val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) ==
1750 ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1751 (!(val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
1752 ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1753 ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
1754 ret = 1;
1755 }
1756 } else {
1757 if (((val64 & ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) ==
1758 ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) &&
1759 (!(val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
1760 ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1761 ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
1762 ret = 1;
1763 }
1764 }
1765 }
1766
1767 return ret;
1768}
1769/**
1770 * verify_xena_quiescence - Checks whether the H/W is ready
1242 * @val64 : Value read from adapter status register. 1771 * @val64 : Value read from adapter status register.
1243 * @flag : indicates if the adapter enable bit was ever written once 1772 * @flag : indicates if the adapter enable bit was ever written once
1244 * before. 1773 * before.
1245 * Description: Returns whether the H/W is ready to go or not. Depending 1774 * Description: Returns whether the H/W is ready to go or not. Depending
1246 * on whether adapter enable bit was written or not the comparison 1775 * on whether adapter enable bit was written or not the comparison
1247 * differs and the calling function passes the input argument flag to 1776 * differs and the calling function passes the input argument flag to
1248 * indicate this. 1777 * indicate this.
1249 * Return: 1 If xena is quiescence 1778 * Return: 1 If xena is quiescence
1250 * 0 If Xena is not quiescence 1779 * 0 If Xena is not quiescence
1251 */ 1780 */
1252 1781
1253static int verify_xena_quiescence(u64 val64, int flag) 1782static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag)
1254{ 1783{
1255 int ret = 0; 1784 int ret = 0, herc;
1256 u64 tmp64 = ~((u64) val64); 1785 u64 tmp64 = ~((u64) val64);
1786 int rev_id = get_xena_rev_id(sp->pdev);
1257 1787
1788 herc = (sp->device_type == XFRAME_II_DEVICE);
1258 if (! 1789 if (!
1259 (tmp64 & 1790 (tmp64 &
1260 (ADAPTER_STATUS_TDMA_READY | ADAPTER_STATUS_RDMA_READY | 1791 (ADAPTER_STATUS_TDMA_READY | ADAPTER_STATUS_RDMA_READY |
@@ -1262,25 +1793,7 @@ static int verify_xena_quiescence(u64 val64, int flag)
1262 ADAPTER_STATUS_PIC_QUIESCENT | ADAPTER_STATUS_MC_DRAM_READY | 1793 ADAPTER_STATUS_PIC_QUIESCENT | ADAPTER_STATUS_MC_DRAM_READY |
1263 ADAPTER_STATUS_MC_QUEUES_READY | ADAPTER_STATUS_M_PLL_LOCK | 1794 ADAPTER_STATUS_MC_QUEUES_READY | ADAPTER_STATUS_M_PLL_LOCK |
1264 ADAPTER_STATUS_P_PLL_LOCK))) { 1795 ADAPTER_STATUS_P_PLL_LOCK))) {
1265 if (flag == FALSE) { 1796 ret = check_prc_pcc_state(val64, flag, rev_id, herc);
1266 if (!(val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1267 ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1268 ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
1269
1270 ret = 1;
1271
1272 }
1273 } else {
1274 if (((val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) ==
1275 ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1276 (!(val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
1277 ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1278 ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
1279
1280 ret = 1;
1281
1282 }
1283 }
1284 } 1797 }
1285 1798
1286 return ret; 1799 return ret;
@@ -1289,12 +1802,12 @@ static int verify_xena_quiescence(u64 val64, int flag)
1289/** 1802/**
1290 * fix_mac_address - Fix for Mac addr problem on Alpha platforms 1803 * fix_mac_address - Fix for Mac addr problem on Alpha platforms
1291 * @sp: Pointer to device specifc structure 1804 * @sp: Pointer to device specifc structure
1292 * Description : 1805 * Description :
1293 * New procedure to clear mac address reading problems on Alpha platforms 1806 * New procedure to clear mac address reading problems on Alpha platforms
1294 * 1807 *
1295 */ 1808 */
1296 1809
1297static void fix_mac_address(nic_t * sp) 1810void fix_mac_address(nic_t * sp)
1298{ 1811{
1299 XENA_dev_config_t __iomem *bar0 = sp->bar0; 1812 XENA_dev_config_t __iomem *bar0 = sp->bar0;
1300 u64 val64; 1813 u64 val64;
@@ -1302,20 +1815,21 @@ static void fix_mac_address(nic_t * sp)
1302 1815
1303 while (fix_mac[i] != END_SIGN) { 1816 while (fix_mac[i] != END_SIGN) {
1304 writeq(fix_mac[i++], &bar0->gpio_control); 1817 writeq(fix_mac[i++], &bar0->gpio_control);
1818 udelay(10);
1305 val64 = readq(&bar0->gpio_control); 1819 val64 = readq(&bar0->gpio_control);
1306 } 1820 }
1307} 1821}
1308 1822
1309/** 1823/**
1310 * start_nic - Turns the device on 1824 * start_nic - Turns the device on
1311 * @nic : device private variable. 1825 * @nic : device private variable.
1312 * Description: 1826 * Description:
1313 * This function actually turns the device on. Before this function is 1827 * This function actually turns the device on. Before this function is
1314 * called,all Registers are configured from their reset states 1828 * called,all Registers are configured from their reset states
1315 * and shared memory is allocated but the NIC is still quiescent. On 1829 * and shared memory is allocated but the NIC is still quiescent. On
1316 * calling this function, the device interrupts are cleared and the NIC is 1830 * calling this function, the device interrupts are cleared and the NIC is
1317 * literally switched on by writing into the adapter control register. 1831 * literally switched on by writing into the adapter control register.
1318 * Return Value: 1832 * Return Value:
1319 * SUCCESS on success and -1 on failure. 1833 * SUCCESS on success and -1 on failure.
1320 */ 1834 */
1321 1835
@@ -1324,8 +1838,8 @@ static int start_nic(struct s2io_nic *nic)
1324 XENA_dev_config_t __iomem *bar0 = nic->bar0; 1838 XENA_dev_config_t __iomem *bar0 = nic->bar0;
1325 struct net_device *dev = nic->dev; 1839 struct net_device *dev = nic->dev;
1326 register u64 val64 = 0; 1840 register u64 val64 = 0;
1327 u16 interruptible, i; 1841 u16 interruptible;
1328 u16 subid; 1842 u16 subid, i;
1329 mac_info_t *mac_control; 1843 mac_info_t *mac_control;
1330 struct config_param *config; 1844 struct config_param *config;
1331 1845
@@ -1334,10 +1848,12 @@ static int start_nic(struct s2io_nic *nic)
1334 1848
1335 /* PRC Initialization and configuration */ 1849 /* PRC Initialization and configuration */
1336 for (i = 0; i < config->rx_ring_num; i++) { 1850 for (i = 0; i < config->rx_ring_num; i++) {
1337 writeq((u64) nic->rx_blocks[i][0].block_dma_addr, 1851 writeq((u64) mac_control->rings[i].rx_blocks[0].block_dma_addr,
1338 &bar0->prc_rxd0_n[i]); 1852 &bar0->prc_rxd0_n[i]);
1339 1853
1340 val64 = readq(&bar0->prc_ctrl_n[i]); 1854 val64 = readq(&bar0->prc_ctrl_n[i]);
1855 if (nic->config.bimodal)
1856 val64 |= PRC_CTRL_BIMODAL_INTERRUPT;
1341#ifndef CONFIG_2BUFF_MODE 1857#ifndef CONFIG_2BUFF_MODE
1342 val64 |= PRC_CTRL_RC_ENABLED; 1858 val64 |= PRC_CTRL_RC_ENABLED;
1343#else 1859#else
@@ -1353,7 +1869,7 @@ static int start_nic(struct s2io_nic *nic)
1353 writeq(val64, &bar0->rx_pa_cfg); 1869 writeq(val64, &bar0->rx_pa_cfg);
1354#endif 1870#endif
1355 1871
1356 /* 1872 /*
1357 * Enabling MC-RLDRAM. After enabling the device, we timeout 1873 * Enabling MC-RLDRAM. After enabling the device, we timeout
1358 * for around 100ms, which is approximately the time required 1874 * for around 100ms, which is approximately the time required
1359 * for the device to be ready for operation. 1875 * for the device to be ready for operation.
@@ -1363,27 +1879,27 @@ static int start_nic(struct s2io_nic *nic)
1363 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF); 1879 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF);
1364 val64 = readq(&bar0->mc_rldram_mrs); 1880 val64 = readq(&bar0->mc_rldram_mrs);
1365 1881
1366 msleep(100); /* Delay by around 100 ms. */ 1882 msleep(100); /* Delay by around 100 ms. */
1367 1883
1368 /* Enabling ECC Protection. */ 1884 /* Enabling ECC Protection. */
1369 val64 = readq(&bar0->adapter_control); 1885 val64 = readq(&bar0->adapter_control);
1370 val64 &= ~ADAPTER_ECC_EN; 1886 val64 &= ~ADAPTER_ECC_EN;
1371 writeq(val64, &bar0->adapter_control); 1887 writeq(val64, &bar0->adapter_control);
1372 1888
1373 /* 1889 /*
1374 * Clearing any possible Link state change interrupts that 1890 * Clearing any possible Link state change interrupts that
1375 * could have popped up just before Enabling the card. 1891 * could have popped up just before Enabling the card.
1376 */ 1892 */
1377 val64 = readq(&bar0->mac_rmac_err_reg); 1893 val64 = readq(&bar0->mac_rmac_err_reg);
1378 if (val64) 1894 if (val64)
1379 writeq(val64, &bar0->mac_rmac_err_reg); 1895 writeq(val64, &bar0->mac_rmac_err_reg);
1380 1896
1381 /* 1897 /*
1382 * Verify if the device is ready to be enabled, if so enable 1898 * Verify if the device is ready to be enabled, if so enable
1383 * it. 1899 * it.
1384 */ 1900 */
1385 val64 = readq(&bar0->adapter_status); 1901 val64 = readq(&bar0->adapter_status);
1386 if (!verify_xena_quiescence(val64, nic->device_enabled_once)) { 1902 if (!verify_xena_quiescence(nic, val64, nic->device_enabled_once)) {
1387 DBG_PRINT(ERR_DBG, "%s: device is not ready, ", dev->name); 1903 DBG_PRINT(ERR_DBG, "%s: device is not ready, ", dev->name);
1388 DBG_PRINT(ERR_DBG, "Adapter status reads: 0x%llx\n", 1904 DBG_PRINT(ERR_DBG, "Adapter status reads: 0x%llx\n",
1389 (unsigned long long) val64); 1905 (unsigned long long) val64);
@@ -1391,16 +1907,18 @@ static int start_nic(struct s2io_nic *nic)
1391 } 1907 }
1392 1908
1393 /* Enable select interrupts */ 1909 /* Enable select interrupts */
1394 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR | TX_MAC_INTR | 1910 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR;
1395 RX_MAC_INTR; 1911 interruptible |= TX_PIC_INTR | RX_PIC_INTR;
1912 interruptible |= TX_MAC_INTR | RX_MAC_INTR;
1913
1396 en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS); 1914 en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS);
1397 1915
1398 /* 1916 /*
1399 * With some switches, link might be already up at this point. 1917 * With some switches, link might be already up at this point.
1400 * Because of this weird behavior, when we enable laser, 1918 * Because of this weird behavior, when we enable laser,
1401 * we may not get link. We need to handle this. We cannot 1919 * we may not get link. We need to handle this. We cannot
1402 * figure out which switch is misbehaving. So we are forced to 1920 * figure out which switch is misbehaving. So we are forced to
1403 * make a global change. 1921 * make a global change.
1404 */ 1922 */
1405 1923
1406 /* Enabling Laser. */ 1924 /* Enabling Laser. */
@@ -1410,44 +1928,30 @@ static int start_nic(struct s2io_nic *nic)
1410 1928
1411 /* SXE-002: Initialize link and activity LED */ 1929 /* SXE-002: Initialize link and activity LED */
1412 subid = nic->pdev->subsystem_device; 1930 subid = nic->pdev->subsystem_device;
1413 if ((subid & 0xFF) >= 0x07) { 1931 if (((subid & 0xFF) >= 0x07) &&
1932 (nic->device_type == XFRAME_I_DEVICE)) {
1414 val64 = readq(&bar0->gpio_control); 1933 val64 = readq(&bar0->gpio_control);
1415 val64 |= 0x0000800000000000ULL; 1934 val64 |= 0x0000800000000000ULL;
1416 writeq(val64, &bar0->gpio_control); 1935 writeq(val64, &bar0->gpio_control);
1417 val64 = 0x0411040400000000ULL; 1936 val64 = 0x0411040400000000ULL;
1418 writeq(val64, (void __iomem *) bar0 + 0x2700); 1937 writeq(val64, (void __iomem *) ((u8 *) bar0 + 0x2700));
1419 } 1938 }
1420 1939
1421 /* 1940 /*
1422 * Don't see link state interrupts on certain switches, so 1941 * Don't see link state interrupts on certain switches, so
1423 * directly scheduling a link state task from here. 1942 * directly scheduling a link state task from here.
1424 */ 1943 */
1425 schedule_work(&nic->set_link_task); 1944 schedule_work(&nic->set_link_task);
1426 1945
1427 /*
1428 * Here we are performing soft reset on XGXS to
1429 * force link down. Since link is already up, we will get
1430 * link state change interrupt after this reset
1431 */
1432 SPECIAL_REG_WRITE(0x80010515001E0000ULL, &bar0->dtx_control, UF);
1433 val64 = readq(&bar0->dtx_control);
1434 udelay(50);
1435 SPECIAL_REG_WRITE(0x80010515001E00E0ULL, &bar0->dtx_control, UF);
1436 val64 = readq(&bar0->dtx_control);
1437 udelay(50);
1438 SPECIAL_REG_WRITE(0x80070515001F00E4ULL, &bar0->dtx_control, UF);
1439 val64 = readq(&bar0->dtx_control);
1440 udelay(50);
1441
1442 return SUCCESS; 1946 return SUCCESS;
1443} 1947}
1444 1948
1445/** 1949/**
1446 * free_tx_buffers - Free all queued Tx buffers 1950 * free_tx_buffers - Free all queued Tx buffers
1447 * @nic : device private variable. 1951 * @nic : device private variable.
1448 * Description: 1952 * Description:
1449 * Free all queued Tx buffers. 1953 * Free all queued Tx buffers.
1450 * Return Value: void 1954 * Return Value: void
1451*/ 1955*/
1452 1956
1453static void free_tx_buffers(struct s2io_nic *nic) 1957static void free_tx_buffers(struct s2io_nic *nic)
@@ -1458,39 +1962,61 @@ static void free_tx_buffers(struct s2io_nic *nic)
1458 int i, j; 1962 int i, j;
1459 mac_info_t *mac_control; 1963 mac_info_t *mac_control;
1460 struct config_param *config; 1964 struct config_param *config;
1461 int cnt = 0; 1965 int cnt = 0, frg_cnt;
1462 1966
1463 mac_control = &nic->mac_control; 1967 mac_control = &nic->mac_control;
1464 config = &nic->config; 1968 config = &nic->config;
1465 1969
1466 for (i = 0; i < config->tx_fifo_num; i++) { 1970 for (i = 0; i < config->tx_fifo_num; i++) {
1467 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { 1971 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) {
1468 txdp = (TxD_t *) nic->list_info[i][j]. 1972 txdp = (TxD_t *) mac_control->fifos[i].list_info[j].
1469 list_virt_addr; 1973 list_virt_addr;
1470 skb = 1974 skb =
1471 (struct sk_buff *) ((unsigned long) txdp-> 1975 (struct sk_buff *) ((unsigned long) txdp->
1472 Host_Control); 1976 Host_Control);
1473 if (skb == NULL) { 1977 if (skb == NULL) {
1474 memset(txdp, 0, sizeof(TxD_t)); 1978 memset(txdp, 0, sizeof(TxD_t) *
1979 config->max_txds);
1475 continue; 1980 continue;
1476 } 1981 }
1982 frg_cnt = skb_shinfo(skb)->nr_frags;
1983 pci_unmap_single(nic->pdev, (dma_addr_t)
1984 txdp->Buffer_Pointer,
1985 skb->len - skb->data_len,
1986 PCI_DMA_TODEVICE);
1987 if (frg_cnt) {
1988 TxD_t *temp;
1989 temp = txdp;
1990 txdp++;
1991 for (j = 0; j < frg_cnt; j++, txdp++) {
1992 skb_frag_t *frag =
1993 &skb_shinfo(skb)->frags[j];
1994 pci_unmap_page(nic->pdev,
1995 (dma_addr_t)
1996 txdp->
1997 Buffer_Pointer,
1998 frag->size,
1999 PCI_DMA_TODEVICE);
2000 }
2001 txdp = temp;
2002 }
1477 dev_kfree_skb(skb); 2003 dev_kfree_skb(skb);
1478 memset(txdp, 0, sizeof(TxD_t)); 2004 memset(txdp, 0, sizeof(TxD_t) * config->max_txds);
1479 cnt++; 2005 cnt++;
1480 } 2006 }
1481 DBG_PRINT(INTR_DBG, 2007 DBG_PRINT(INTR_DBG,
1482 "%s:forcibly freeing %d skbs on FIFO%d\n", 2008 "%s:forcibly freeing %d skbs on FIFO%d\n",
1483 dev->name, cnt, i); 2009 dev->name, cnt, i);
1484 mac_control->tx_curr_get_info[i].offset = 0; 2010 mac_control->fifos[i].tx_curr_get_info.offset = 0;
1485 mac_control->tx_curr_put_info[i].offset = 0; 2011 mac_control->fifos[i].tx_curr_put_info.offset = 0;
1486 } 2012 }
1487} 2013}
1488 2014
1489/** 2015/**
1490 * stop_nic - To stop the nic 2016 * stop_nic - To stop the nic
1491 * @nic ; device private variable. 2017 * @nic ; device private variable.
1492 * Description: 2018 * Description:
1493 * This function does exactly the opposite of what the start_nic() 2019 * This function does exactly the opposite of what the start_nic()
1494 * function does. This function is called to stop the device. 2020 * function does. This function is called to stop the device.
1495 * Return Value: 2021 * Return Value:
1496 * void. 2022 * void.
@@ -1508,8 +2034,9 @@ static void stop_nic(struct s2io_nic *nic)
1508 config = &nic->config; 2034 config = &nic->config;
1509 2035
1510 /* Disable all interrupts */ 2036 /* Disable all interrupts */
1511 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR | TX_MAC_INTR | 2037 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR;
1512 RX_MAC_INTR; 2038 interruptible |= TX_PIC_INTR | RX_PIC_INTR;
2039 interruptible |= TX_MAC_INTR | RX_MAC_INTR;
1513 en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS); 2040 en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS);
1514 2041
1515 /* Disable PRCs */ 2042 /* Disable PRCs */
@@ -1520,11 +2047,11 @@ static void stop_nic(struct s2io_nic *nic)
1520 } 2047 }
1521} 2048}
1522 2049
1523/** 2050/**
1524 * fill_rx_buffers - Allocates the Rx side skbs 2051 * fill_rx_buffers - Allocates the Rx side skbs
1525 * @nic: device private variable 2052 * @nic: device private variable
1526 * @ring_no: ring number 2053 * @ring_no: ring number
1527 * Description: 2054 * Description:
1528 * The function allocates Rx side skbs and puts the physical 2055 * The function allocates Rx side skbs and puts the physical
1529 * address of these buffers into the RxD buffer pointers, so that the NIC 2056 * address of these buffers into the RxD buffer pointers, so that the NIC
1530 * can DMA the received frame into these locations. 2057 * can DMA the received frame into these locations.
@@ -1532,8 +2059,8 @@ static void stop_nic(struct s2io_nic *nic)
1532 * 1. single buffer, 2059 * 1. single buffer,
1533 * 2. three buffer and 2060 * 2. three buffer and
1534 * 3. Five buffer modes. 2061 * 3. Five buffer modes.
1535 * Each mode defines how many fragments the received frame will be split 2062 * Each mode defines how many fragments the received frame will be split
1536 * up into by the NIC. The frame is split into L3 header, L4 Header, 2063 * up into by the NIC. The frame is split into L3 header, L4 Header,
1537 * L4 payload in three buffer mode and in 5 buffer mode, L4 payload itself 2064 * L4 payload in three buffer mode and in 5 buffer mode, L4 payload itself
1538 * is split into 3 fragments. As of now only single buffer mode is 2065 * is split into 3 fragments. As of now only single buffer mode is
1539 * supported. 2066 * supported.
@@ -1541,7 +2068,7 @@ static void stop_nic(struct s2io_nic *nic)
1541 * SUCCESS on success or an appropriate -ve value on failure. 2068 * SUCCESS on success or an appropriate -ve value on failure.
1542 */ 2069 */
1543 2070
1544static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) 2071int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1545{ 2072{
1546 struct net_device *dev = nic->dev; 2073 struct net_device *dev = nic->dev;
1547 struct sk_buff *skb; 2074 struct sk_buff *skb;
@@ -1549,34 +2076,35 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1549 int off, off1, size, block_no, block_no1; 2076 int off, off1, size, block_no, block_no1;
1550 int offset, offset1; 2077 int offset, offset1;
1551 u32 alloc_tab = 0; 2078 u32 alloc_tab = 0;
1552 u32 alloc_cnt = nic->pkt_cnt[ring_no] - 2079 u32 alloc_cnt;
1553 atomic_read(&nic->rx_bufs_left[ring_no]);
1554 mac_info_t *mac_control; 2080 mac_info_t *mac_control;
1555 struct config_param *config; 2081 struct config_param *config;
1556#ifdef CONFIG_2BUFF_MODE 2082#ifdef CONFIG_2BUFF_MODE
1557 RxD_t *rxdpnext; 2083 RxD_t *rxdpnext;
1558 int nextblk; 2084 int nextblk;
1559 unsigned long tmp; 2085 u64 tmp;
1560 buffAdd_t *ba; 2086 buffAdd_t *ba;
1561 dma_addr_t rxdpphys; 2087 dma_addr_t rxdpphys;
1562#endif 2088#endif
1563#ifndef CONFIG_S2IO_NAPI 2089#ifndef CONFIG_S2IO_NAPI
1564 unsigned long flags; 2090 unsigned long flags;
1565#endif 2091#endif
2092 RxD_t *first_rxdp = NULL;
1566 2093
1567 mac_control = &nic->mac_control; 2094 mac_control = &nic->mac_control;
1568 config = &nic->config; 2095 config = &nic->config;
1569 2096 alloc_cnt = mac_control->rings[ring_no].pkt_cnt -
2097 atomic_read(&nic->rx_bufs_left[ring_no]);
1570 size = dev->mtu + HEADER_ETHERNET_II_802_3_SIZE + 2098 size = dev->mtu + HEADER_ETHERNET_II_802_3_SIZE +
1571 HEADER_802_2_SIZE + HEADER_SNAP_SIZE; 2099 HEADER_802_2_SIZE + HEADER_SNAP_SIZE;
1572 2100
1573 while (alloc_tab < alloc_cnt) { 2101 while (alloc_tab < alloc_cnt) {
1574 block_no = mac_control->rx_curr_put_info[ring_no]. 2102 block_no = mac_control->rings[ring_no].rx_curr_put_info.
1575 block_index; 2103 block_index;
1576 block_no1 = mac_control->rx_curr_get_info[ring_no]. 2104 block_no1 = mac_control->rings[ring_no].rx_curr_get_info.
1577 block_index; 2105 block_index;
1578 off = mac_control->rx_curr_put_info[ring_no].offset; 2106 off = mac_control->rings[ring_no].rx_curr_put_info.offset;
1579 off1 = mac_control->rx_curr_get_info[ring_no].offset; 2107 off1 = mac_control->rings[ring_no].rx_curr_get_info.offset;
1580#ifndef CONFIG_2BUFF_MODE 2108#ifndef CONFIG_2BUFF_MODE
1581 offset = block_no * (MAX_RXDS_PER_BLOCK + 1) + off; 2109 offset = block_no * (MAX_RXDS_PER_BLOCK + 1) + off;
1582 offset1 = block_no1 * (MAX_RXDS_PER_BLOCK + 1) + off1; 2110 offset1 = block_no1 * (MAX_RXDS_PER_BLOCK + 1) + off1;
@@ -1585,7 +2113,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1585 offset1 = block_no1 * (MAX_RXDS_PER_BLOCK) + off1; 2113 offset1 = block_no1 * (MAX_RXDS_PER_BLOCK) + off1;
1586#endif 2114#endif
1587 2115
1588 rxdp = nic->rx_blocks[ring_no][block_no]. 2116 rxdp = mac_control->rings[ring_no].rx_blocks[block_no].
1589 block_virt_addr + off; 2117 block_virt_addr + off;
1590 if ((offset == offset1) && (rxdp->Host_Control)) { 2118 if ((offset == offset1) && (rxdp->Host_Control)) {
1591 DBG_PRINT(INTR_DBG, "%s: Get and Put", dev->name); 2119 DBG_PRINT(INTR_DBG, "%s: Get and Put", dev->name);
@@ -1594,15 +2122,15 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1594 } 2122 }
1595#ifndef CONFIG_2BUFF_MODE 2123#ifndef CONFIG_2BUFF_MODE
1596 if (rxdp->Control_1 == END_OF_BLOCK) { 2124 if (rxdp->Control_1 == END_OF_BLOCK) {
1597 mac_control->rx_curr_put_info[ring_no]. 2125 mac_control->rings[ring_no].rx_curr_put_info.
1598 block_index++; 2126 block_index++;
1599 mac_control->rx_curr_put_info[ring_no]. 2127 mac_control->rings[ring_no].rx_curr_put_info.
1600 block_index %= nic->block_count[ring_no]; 2128 block_index %= mac_control->rings[ring_no].block_count;
1601 block_no = mac_control->rx_curr_put_info 2129 block_no = mac_control->rings[ring_no].rx_curr_put_info.
1602 [ring_no].block_index; 2130 block_index;
1603 off++; 2131 off++;
1604 off %= (MAX_RXDS_PER_BLOCK + 1); 2132 off %= (MAX_RXDS_PER_BLOCK + 1);
1605 mac_control->rx_curr_put_info[ring_no].offset = 2133 mac_control->rings[ring_no].rx_curr_put_info.offset =
1606 off; 2134 off;
1607 rxdp = (RxD_t *) ((unsigned long) rxdp->Control_2); 2135 rxdp = (RxD_t *) ((unsigned long) rxdp->Control_2);
1608 DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n", 2136 DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n",
@@ -1610,30 +2138,30 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1610 } 2138 }
1611#ifndef CONFIG_S2IO_NAPI 2139#ifndef CONFIG_S2IO_NAPI
1612 spin_lock_irqsave(&nic->put_lock, flags); 2140 spin_lock_irqsave(&nic->put_lock, flags);
1613 nic->put_pos[ring_no] = 2141 mac_control->rings[ring_no].put_pos =
1614 (block_no * (MAX_RXDS_PER_BLOCK + 1)) + off; 2142 (block_no * (MAX_RXDS_PER_BLOCK + 1)) + off;
1615 spin_unlock_irqrestore(&nic->put_lock, flags); 2143 spin_unlock_irqrestore(&nic->put_lock, flags);
1616#endif 2144#endif
1617#else 2145#else
1618 if (rxdp->Host_Control == END_OF_BLOCK) { 2146 if (rxdp->Host_Control == END_OF_BLOCK) {
1619 mac_control->rx_curr_put_info[ring_no]. 2147 mac_control->rings[ring_no].rx_curr_put_info.
1620 block_index++; 2148 block_index++;
1621 mac_control->rx_curr_put_info[ring_no]. 2149 mac_control->rings[ring_no].rx_curr_put_info.block_index
1622 block_index %= nic->block_count[ring_no]; 2150 %= mac_control->rings[ring_no].block_count;
1623 block_no = mac_control->rx_curr_put_info 2151 block_no = mac_control->rings[ring_no].rx_curr_put_info
1624 [ring_no].block_index; 2152 .block_index;
1625 off = 0; 2153 off = 0;
1626 DBG_PRINT(INTR_DBG, "%s: block%d at: 0x%llx\n", 2154 DBG_PRINT(INTR_DBG, "%s: block%d at: 0x%llx\n",
1627 dev->name, block_no, 2155 dev->name, block_no,
1628 (unsigned long long) rxdp->Control_1); 2156 (unsigned long long) rxdp->Control_1);
1629 mac_control->rx_curr_put_info[ring_no].offset = 2157 mac_control->rings[ring_no].rx_curr_put_info.offset =
1630 off; 2158 off;
1631 rxdp = nic->rx_blocks[ring_no][block_no]. 2159 rxdp = mac_control->rings[ring_no].rx_blocks[block_no].
1632 block_virt_addr; 2160 block_virt_addr;
1633 } 2161 }
1634#ifndef CONFIG_S2IO_NAPI 2162#ifndef CONFIG_S2IO_NAPI
1635 spin_lock_irqsave(&nic->put_lock, flags); 2163 spin_lock_irqsave(&nic->put_lock, flags);
1636 nic->put_pos[ring_no] = (block_no * 2164 mac_control->rings[ring_no].put_pos = (block_no *
1637 (MAX_RXDS_PER_BLOCK + 1)) + off; 2165 (MAX_RXDS_PER_BLOCK + 1)) + off;
1638 spin_unlock_irqrestore(&nic->put_lock, flags); 2166 spin_unlock_irqrestore(&nic->put_lock, flags);
1639#endif 2167#endif
@@ -1645,27 +2173,27 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1645 if (rxdp->Control_2 & BIT(0)) 2173 if (rxdp->Control_2 & BIT(0))
1646#endif 2174#endif
1647 { 2175 {
1648 mac_control->rx_curr_put_info[ring_no]. 2176 mac_control->rings[ring_no].rx_curr_put_info.
1649 offset = off; 2177 offset = off;
1650 goto end; 2178 goto end;
1651 } 2179 }
1652#ifdef CONFIG_2BUFF_MODE 2180#ifdef CONFIG_2BUFF_MODE
1653 /* 2181 /*
1654 * RxDs Spanning cache lines will be replenished only 2182 * RxDs Spanning cache lines will be replenished only
1655 * if the succeeding RxD is also owned by Host. It 2183 * if the succeeding RxD is also owned by Host. It
1656 * will always be the ((8*i)+3) and ((8*i)+6) 2184 * will always be the ((8*i)+3) and ((8*i)+6)
1657 * descriptors for the 48 byte descriptor. The offending 2185 * descriptors for the 48 byte descriptor. The offending
1658 * decsriptor is of-course the 3rd descriptor. 2186 * decsriptor is of-course the 3rd descriptor.
1659 */ 2187 */
1660 rxdpphys = nic->rx_blocks[ring_no][block_no]. 2188 rxdpphys = mac_control->rings[ring_no].rx_blocks[block_no].
1661 block_dma_addr + (off * sizeof(RxD_t)); 2189 block_dma_addr + (off * sizeof(RxD_t));
1662 if (((u64) (rxdpphys)) % 128 > 80) { 2190 if (((u64) (rxdpphys)) % 128 > 80) {
1663 rxdpnext = nic->rx_blocks[ring_no][block_no]. 2191 rxdpnext = mac_control->rings[ring_no].rx_blocks[block_no].
1664 block_virt_addr + (off + 1); 2192 block_virt_addr + (off + 1);
1665 if (rxdpnext->Host_Control == END_OF_BLOCK) { 2193 if (rxdpnext->Host_Control == END_OF_BLOCK) {
1666 nextblk = (block_no + 1) % 2194 nextblk = (block_no + 1) %
1667 (nic->block_count[ring_no]); 2195 (mac_control->rings[ring_no].block_count);
1668 rxdpnext = nic->rx_blocks[ring_no] 2196 rxdpnext = mac_control->rings[ring_no].rx_blocks
1669 [nextblk].block_virt_addr; 2197 [nextblk].block_virt_addr;
1670 } 2198 }
1671 if (rxdpnext->Control_2 & BIT(0)) 2199 if (rxdpnext->Control_2 & BIT(0))
@@ -1681,6 +2209,10 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1681 if (!skb) { 2209 if (!skb) {
1682 DBG_PRINT(ERR_DBG, "%s: Out of ", dev->name); 2210 DBG_PRINT(ERR_DBG, "%s: Out of ", dev->name);
1683 DBG_PRINT(ERR_DBG, "memory to allocate SKBs\n"); 2211 DBG_PRINT(ERR_DBG, "memory to allocate SKBs\n");
2212 if (first_rxdp) {
2213 wmb();
2214 first_rxdp->Control_1 |= RXD_OWN_XENA;
2215 }
1684 return -ENOMEM; 2216 return -ENOMEM;
1685 } 2217 }
1686#ifndef CONFIG_2BUFF_MODE 2218#ifndef CONFIG_2BUFF_MODE
@@ -1691,18 +2223,17 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1691 rxdp->Control_2 &= (~MASK_BUFFER0_SIZE); 2223 rxdp->Control_2 &= (~MASK_BUFFER0_SIZE);
1692 rxdp->Control_2 |= SET_BUFFER0_SIZE(size); 2224 rxdp->Control_2 |= SET_BUFFER0_SIZE(size);
1693 rxdp->Host_Control = (unsigned long) (skb); 2225 rxdp->Host_Control = (unsigned long) (skb);
1694 rxdp->Control_1 |= RXD_OWN_XENA; 2226 if (alloc_tab & ((1 << rxsync_frequency) - 1))
2227 rxdp->Control_1 |= RXD_OWN_XENA;
1695 off++; 2228 off++;
1696 off %= (MAX_RXDS_PER_BLOCK + 1); 2229 off %= (MAX_RXDS_PER_BLOCK + 1);
1697 mac_control->rx_curr_put_info[ring_no].offset = off; 2230 mac_control->rings[ring_no].rx_curr_put_info.offset = off;
1698#else 2231#else
1699 ba = &nic->ba[ring_no][block_no][off]; 2232 ba = &mac_control->rings[ring_no].ba[block_no][off];
1700 skb_reserve(skb, BUF0_LEN); 2233 skb_reserve(skb, BUF0_LEN);
1701 tmp = (unsigned long) skb->data; 2234 tmp = ((unsigned long) skb->data & ALIGN_SIZE);
1702 tmp += ALIGN_SIZE; 2235 if (tmp)
1703 tmp &= ~ALIGN_SIZE; 2236 skb_reserve(skb, (ALIGN_SIZE + 1) - tmp);
1704 skb->data = (void *) tmp;
1705 skb->tail = (void *) tmp;
1706 2237
1707 memset(rxdp, 0, sizeof(RxD_t)); 2238 memset(rxdp, 0, sizeof(RxD_t));
1708 rxdp->Buffer2_ptr = pci_map_single 2239 rxdp->Buffer2_ptr = pci_map_single
@@ -1720,22 +2251,41 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
1720 rxdp->Control_2 |= SET_BUFFER1_SIZE(1); /* dummy. */ 2251 rxdp->Control_2 |= SET_BUFFER1_SIZE(1); /* dummy. */
1721 rxdp->Control_2 |= BIT(0); /* Set Buffer_Empty bit. */ 2252 rxdp->Control_2 |= BIT(0); /* Set Buffer_Empty bit. */
1722 rxdp->Host_Control = (u64) ((unsigned long) (skb)); 2253 rxdp->Host_Control = (u64) ((unsigned long) (skb));
1723 rxdp->Control_1 |= RXD_OWN_XENA; 2254 if (alloc_tab & ((1 << rxsync_frequency) - 1))
2255 rxdp->Control_1 |= RXD_OWN_XENA;
1724 off++; 2256 off++;
1725 mac_control->rx_curr_put_info[ring_no].offset = off; 2257 mac_control->rings[ring_no].rx_curr_put_info.offset = off;
1726#endif 2258#endif
2259 rxdp->Control_2 |= SET_RXD_MARKER;
2260
2261 if (!(alloc_tab & ((1 << rxsync_frequency) - 1))) {
2262 if (first_rxdp) {
2263 wmb();
2264 first_rxdp->Control_1 |= RXD_OWN_XENA;
2265 }
2266 first_rxdp = rxdp;
2267 }
1727 atomic_inc(&nic->rx_bufs_left[ring_no]); 2268 atomic_inc(&nic->rx_bufs_left[ring_no]);
1728 alloc_tab++; 2269 alloc_tab++;
1729 } 2270 }
1730 2271
1731 end: 2272 end:
2273 /* Transfer ownership of first descriptor to adapter just before
2274 * exiting. Before that, use memory barrier so that ownership
2275 * and other fields are seen by adapter correctly.
2276 */
2277 if (first_rxdp) {
2278 wmb();
2279 first_rxdp->Control_1 |= RXD_OWN_XENA;
2280 }
2281
1732 return SUCCESS; 2282 return SUCCESS;
1733} 2283}
1734 2284
1735/** 2285/**
1736 * free_rx_buffers - Frees all Rx buffers 2286 * free_rx_buffers - Frees all Rx buffers
1737 * @sp: device private variable. 2287 * @sp: device private variable.
1738 * Description: 2288 * Description:
1739 * This function will free all Rx buffers allocated by host. 2289 * This function will free all Rx buffers allocated by host.
1740 * Return Value: 2290 * Return Value:
1741 * NONE. 2291 * NONE.
@@ -1759,7 +2309,8 @@ static void free_rx_buffers(struct s2io_nic *sp)
1759 for (i = 0; i < config->rx_ring_num; i++) { 2309 for (i = 0; i < config->rx_ring_num; i++) {
1760 for (j = 0, blk = 0; j < config->rx_cfg[i].num_rxd; j++) { 2310 for (j = 0, blk = 0; j < config->rx_cfg[i].num_rxd; j++) {
1761 off = j % (MAX_RXDS_PER_BLOCK + 1); 2311 off = j % (MAX_RXDS_PER_BLOCK + 1);
1762 rxdp = sp->rx_blocks[i][blk].block_virt_addr + off; 2312 rxdp = mac_control->rings[i].rx_blocks[blk].
2313 block_virt_addr + off;
1763 2314
1764#ifndef CONFIG_2BUFF_MODE 2315#ifndef CONFIG_2BUFF_MODE
1765 if (rxdp->Control_1 == END_OF_BLOCK) { 2316 if (rxdp->Control_1 == END_OF_BLOCK) {
@@ -1794,7 +2345,7 @@ static void free_rx_buffers(struct s2io_nic *sp)
1794 HEADER_SNAP_SIZE, 2345 HEADER_SNAP_SIZE,
1795 PCI_DMA_FROMDEVICE); 2346 PCI_DMA_FROMDEVICE);
1796#else 2347#else
1797 ba = &sp->ba[i][blk][off]; 2348 ba = &mac_control->rings[i].ba[blk][off];
1798 pci_unmap_single(sp->pdev, (dma_addr_t) 2349 pci_unmap_single(sp->pdev, (dma_addr_t)
1799 rxdp->Buffer0_ptr, 2350 rxdp->Buffer0_ptr,
1800 BUF0_LEN, 2351 BUF0_LEN,
@@ -1814,10 +2365,10 @@ static void free_rx_buffers(struct s2io_nic *sp)
1814 } 2365 }
1815 memset(rxdp, 0, sizeof(RxD_t)); 2366 memset(rxdp, 0, sizeof(RxD_t));
1816 } 2367 }
1817 mac_control->rx_curr_put_info[i].block_index = 0; 2368 mac_control->rings[i].rx_curr_put_info.block_index = 0;
1818 mac_control->rx_curr_get_info[i].block_index = 0; 2369 mac_control->rings[i].rx_curr_get_info.block_index = 0;
1819 mac_control->rx_curr_put_info[i].offset = 0; 2370 mac_control->rings[i].rx_curr_put_info.offset = 0;
1820 mac_control->rx_curr_get_info[i].offset = 0; 2371 mac_control->rings[i].rx_curr_get_info.offset = 0;
1821 atomic_set(&sp->rx_bufs_left[i], 0); 2372 atomic_set(&sp->rx_bufs_left[i], 0);
1822 DBG_PRINT(INIT_DBG, "%s:Freed 0x%x Rx Buffers on ring%d\n", 2373 DBG_PRINT(INIT_DBG, "%s:Freed 0x%x Rx Buffers on ring%d\n",
1823 dev->name, buf_cnt, i); 2374 dev->name, buf_cnt, i);
@@ -1827,7 +2378,7 @@ static void free_rx_buffers(struct s2io_nic *sp)
1827/** 2378/**
1828 * s2io_poll - Rx interrupt handler for NAPI support 2379 * s2io_poll - Rx interrupt handler for NAPI support
1829 * @dev : pointer to the device structure. 2380 * @dev : pointer to the device structure.
1830 * @budget : The number of packets that were budgeted to be processed 2381 * @budget : The number of packets that were budgeted to be processed
1831 * during one pass through the 'Poll" function. 2382 * during one pass through the 'Poll" function.
1832 * Description: 2383 * Description:
1833 * Comes into picture only if NAPI support has been incorporated. It does 2384 * Comes into picture only if NAPI support has been incorporated. It does
@@ -1837,160 +2388,36 @@ static void free_rx_buffers(struct s2io_nic *sp)
1837 * 0 on success and 1 if there are No Rx packets to be processed. 2388 * 0 on success and 1 if there are No Rx packets to be processed.
1838 */ 2389 */
1839 2390
1840#ifdef CONFIG_S2IO_NAPI 2391#if defined(CONFIG_S2IO_NAPI)
1841static int s2io_poll(struct net_device *dev, int *budget) 2392static int s2io_poll(struct net_device *dev, int *budget)
1842{ 2393{
1843 nic_t *nic = dev->priv; 2394 nic_t *nic = dev->priv;
1844 XENA_dev_config_t __iomem *bar0 = nic->bar0; 2395 int pkt_cnt = 0, org_pkts_to_process;
1845 int pkts_to_process = *budget, pkt_cnt = 0;
1846 register u64 val64 = 0;
1847 rx_curr_get_info_t get_info, put_info;
1848 int i, get_block, put_block, get_offset, put_offset, ring_bufs;
1849#ifndef CONFIG_2BUFF_MODE
1850 u16 val16, cksum;
1851#endif
1852 struct sk_buff *skb;
1853 RxD_t *rxdp;
1854 mac_info_t *mac_control; 2396 mac_info_t *mac_control;
1855 struct config_param *config; 2397 struct config_param *config;
1856#ifdef CONFIG_2BUFF_MODE 2398 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
1857 buffAdd_t *ba; 2399 u64 val64;
1858#endif 2400 int i;
1859 2401
2402 atomic_inc(&nic->isr_cnt);
1860 mac_control = &nic->mac_control; 2403 mac_control = &nic->mac_control;
1861 config = &nic->config; 2404 config = &nic->config;
1862 2405
1863 if (pkts_to_process > dev->quota) 2406 nic->pkts_to_process = *budget;
1864 pkts_to_process = dev->quota; 2407 if (nic->pkts_to_process > dev->quota)
2408 nic->pkts_to_process = dev->quota;
2409 org_pkts_to_process = nic->pkts_to_process;
1865 2410
1866 val64 = readq(&bar0->rx_traffic_int); 2411 val64 = readq(&bar0->rx_traffic_int);
1867 writeq(val64, &bar0->rx_traffic_int); 2412 writeq(val64, &bar0->rx_traffic_int);
1868 2413
1869 for (i = 0; i < config->rx_ring_num; i++) { 2414 for (i = 0; i < config->rx_ring_num; i++) {
1870 get_info = mac_control->rx_curr_get_info[i]; 2415 rx_intr_handler(&mac_control->rings[i]);
1871 get_block = get_info.block_index; 2416 pkt_cnt = org_pkts_to_process - nic->pkts_to_process;
1872 put_info = mac_control->rx_curr_put_info[i]; 2417 if (!nic->pkts_to_process) {
1873 put_block = put_info.block_index; 2418 /* Quota for the current iteration has been met */
1874 ring_bufs = config->rx_cfg[i].num_rxd; 2419 goto no_rx;
1875 rxdp = nic->rx_blocks[i][get_block].block_virt_addr +
1876 get_info.offset;
1877#ifndef CONFIG_2BUFF_MODE
1878 get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
1879 get_info.offset;
1880 put_offset = (put_block * (MAX_RXDS_PER_BLOCK + 1)) +
1881 put_info.offset;
1882 while ((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
1883 (((get_offset + 1) % ring_bufs) != put_offset)) {
1884 if (--pkts_to_process < 0) {
1885 goto no_rx;
1886 }
1887 if (rxdp->Control_1 == END_OF_BLOCK) {
1888 rxdp =
1889 (RxD_t *) ((unsigned long) rxdp->
1890 Control_2);
1891 get_info.offset++;
1892 get_info.offset %=
1893 (MAX_RXDS_PER_BLOCK + 1);
1894 get_block++;
1895 get_block %= nic->block_count[i];
1896 mac_control->rx_curr_get_info[i].
1897 offset = get_info.offset;
1898 mac_control->rx_curr_get_info[i].
1899 block_index = get_block;
1900 continue;
1901 }
1902 get_offset =
1903 (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
1904 get_info.offset;
1905 skb =
1906 (struct sk_buff *) ((unsigned long) rxdp->
1907 Host_Control);
1908 if (skb == NULL) {
1909 DBG_PRINT(ERR_DBG, "%s: The skb is ",
1910 dev->name);
1911 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
1912 goto no_rx;
1913 }
1914 val64 = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
1915 val16 = (u16) (val64 >> 48);
1916 cksum = RXD_GET_L4_CKSUM(rxdp->Control_1);
1917 pci_unmap_single(nic->pdev, (dma_addr_t)
1918 rxdp->Buffer0_ptr,
1919 dev->mtu +
1920 HEADER_ETHERNET_II_802_3_SIZE +
1921 HEADER_802_2_SIZE +
1922 HEADER_SNAP_SIZE,
1923 PCI_DMA_FROMDEVICE);
1924 rx_osm_handler(nic, val16, rxdp, i);
1925 pkt_cnt++;
1926 get_info.offset++;
1927 get_info.offset %= (MAX_RXDS_PER_BLOCK + 1);
1928 rxdp =
1929 nic->rx_blocks[i][get_block].block_virt_addr +
1930 get_info.offset;
1931 mac_control->rx_curr_get_info[i].offset =
1932 get_info.offset;
1933 } 2420 }
1934#else
1935 get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
1936 get_info.offset;
1937 put_offset = (put_block * (MAX_RXDS_PER_BLOCK + 1)) +
1938 put_info.offset;
1939 while (((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
1940 !(rxdp->Control_2 & BIT(0))) &&
1941 (((get_offset + 1) % ring_bufs) != put_offset)) {
1942 if (--pkts_to_process < 0) {
1943 goto no_rx;
1944 }
1945 skb = (struct sk_buff *) ((unsigned long)
1946 rxdp->Host_Control);
1947 if (skb == NULL) {
1948 DBG_PRINT(ERR_DBG, "%s: The skb is ",
1949 dev->name);
1950 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
1951 goto no_rx;
1952 }
1953
1954 pci_unmap_single(nic->pdev, (dma_addr_t)
1955 rxdp->Buffer0_ptr,
1956 BUF0_LEN, PCI_DMA_FROMDEVICE);
1957 pci_unmap_single(nic->pdev, (dma_addr_t)
1958 rxdp->Buffer1_ptr,
1959 BUF1_LEN, PCI_DMA_FROMDEVICE);
1960 pci_unmap_single(nic->pdev, (dma_addr_t)
1961 rxdp->Buffer2_ptr,
1962 dev->mtu + BUF0_LEN + 4,
1963 PCI_DMA_FROMDEVICE);
1964 ba = &nic->ba[i][get_block][get_info.offset];
1965
1966 rx_osm_handler(nic, rxdp, i, ba);
1967
1968 get_info.offset++;
1969 mac_control->rx_curr_get_info[i].offset =
1970 get_info.offset;
1971 rxdp =
1972 nic->rx_blocks[i][get_block].block_virt_addr +
1973 get_info.offset;
1974
1975 if (get_info.offset &&
1976 (!(get_info.offset % MAX_RXDS_PER_BLOCK))) {
1977 get_info.offset = 0;
1978 mac_control->rx_curr_get_info[i].
1979 offset = get_info.offset;
1980 get_block++;
1981 get_block %= nic->block_count[i];
1982 mac_control->rx_curr_get_info[i].
1983 block_index = get_block;
1984 rxdp =
1985 nic->rx_blocks[i][get_block].
1986 block_virt_addr;
1987 }
1988 get_offset =
1989 (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
1990 get_info.offset;
1991 pkt_cnt++;
1992 }
1993#endif
1994 } 2421 }
1995 if (!pkt_cnt) 2422 if (!pkt_cnt)
1996 pkt_cnt = 1; 2423 pkt_cnt = 1;
@@ -2008,9 +2435,10 @@ static int s2io_poll(struct net_device *dev, int *budget)
2008 } 2435 }
2009 /* Re enable the Rx interrupts. */ 2436 /* Re enable the Rx interrupts. */
2010 en_dis_able_nic_intrs(nic, RX_TRAFFIC_INTR, ENABLE_INTRS); 2437 en_dis_able_nic_intrs(nic, RX_TRAFFIC_INTR, ENABLE_INTRS);
2438 atomic_dec(&nic->isr_cnt);
2011 return 0; 2439 return 0;
2012 2440
2013 no_rx: 2441no_rx:
2014 dev->quota -= pkt_cnt; 2442 dev->quota -= pkt_cnt;
2015 *budget -= pkt_cnt; 2443 *budget -= pkt_cnt;
2016 2444
@@ -2021,279 +2449,204 @@ static int s2io_poll(struct net_device *dev, int *budget)
2021 break; 2449 break;
2022 } 2450 }
2023 } 2451 }
2452 atomic_dec(&nic->isr_cnt);
2024 return 1; 2453 return 1;
2025} 2454}
2026#else 2455#endif
2027/** 2456
2457/**
2028 * rx_intr_handler - Rx interrupt handler 2458 * rx_intr_handler - Rx interrupt handler
2029 * @nic: device private variable. 2459 * @nic: device private variable.
2030 * Description: 2460 * Description:
2031 * If the interrupt is because of a received frame or if the 2461 * If the interrupt is because of a received frame or if the
2032 * receive ring contains fresh as yet un-processed frames,this function is 2462 * receive ring contains fresh as yet un-processed frames,this function is
2033 * called. It picks out the RxD at which place the last Rx processing had 2463 * called. It picks out the RxD at which place the last Rx processing had
2034 * stopped and sends the skb to the OSM's Rx handler and then increments 2464 * stopped and sends the skb to the OSM's Rx handler and then increments
2035 * the offset. 2465 * the offset.
2036 * Return Value: 2466 * Return Value:
2037 * NONE. 2467 * NONE.
2038 */ 2468 */
2039 2469static void rx_intr_handler(ring_info_t *ring_data)
2040static void rx_intr_handler(struct s2io_nic *nic)
2041{ 2470{
2471 nic_t *nic = ring_data->nic;
2042 struct net_device *dev = (struct net_device *) nic->dev; 2472 struct net_device *dev = (struct net_device *) nic->dev;
2043 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 2473 int get_block, get_offset, put_block, put_offset, ring_bufs;
2044 rx_curr_get_info_t get_info, put_info; 2474 rx_curr_get_info_t get_info, put_info;
2045 RxD_t *rxdp; 2475 RxD_t *rxdp;
2046 struct sk_buff *skb; 2476 struct sk_buff *skb;
2047#ifndef CONFIG_2BUFF_MODE 2477#ifndef CONFIG_S2IO_NAPI
2048 u16 val16, cksum; 2478 int pkt_cnt = 0;
2049#endif
2050 register u64 val64 = 0;
2051 int get_block, get_offset, put_block, put_offset, ring_bufs;
2052 int i, pkt_cnt = 0;
2053 mac_info_t *mac_control;
2054 struct config_param *config;
2055#ifdef CONFIG_2BUFF_MODE
2056 buffAdd_t *ba;
2057#endif 2479#endif
2480 spin_lock(&nic->rx_lock);
2481 if (atomic_read(&nic->card_state) == CARD_DOWN) {
2482 DBG_PRINT(ERR_DBG, "%s: %s going down for reset\n",
2483 __FUNCTION__, dev->name);
2484 spin_unlock(&nic->rx_lock);
2485 }
2058 2486
2059 mac_control = &nic->mac_control; 2487 get_info = ring_data->rx_curr_get_info;
2060 config = &nic->config; 2488 get_block = get_info.block_index;
2061 2489 put_info = ring_data->rx_curr_put_info;
2062 /* 2490 put_block = put_info.block_index;
2063 * rx_traffic_int reg is an R1 register, hence we read and write back 2491 ring_bufs = get_info.ring_len+1;
2064 * the samevalue in the register to clear it. 2492 rxdp = ring_data->rx_blocks[get_block].block_virt_addr +
2065 */
2066 val64 = readq(&bar0->rx_traffic_int);
2067 writeq(val64, &bar0->rx_traffic_int);
2068
2069 for (i = 0; i < config->rx_ring_num; i++) {
2070 get_info = mac_control->rx_curr_get_info[i];
2071 get_block = get_info.block_index;
2072 put_info = mac_control->rx_curr_put_info[i];
2073 put_block = put_info.block_index;
2074 ring_bufs = config->rx_cfg[i].num_rxd;
2075 rxdp = nic->rx_blocks[i][get_block].block_virt_addr +
2076 get_info.offset;
2077#ifndef CONFIG_2BUFF_MODE
2078 get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2079 get_info.offset; 2493 get_info.offset;
2080 spin_lock(&nic->put_lock); 2494 get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2081 put_offset = nic->put_pos[i]; 2495 get_info.offset;
2082 spin_unlock(&nic->put_lock); 2496#ifndef CONFIG_S2IO_NAPI
2083 while ((!(rxdp->Control_1 & RXD_OWN_XENA)) && 2497 spin_lock(&nic->put_lock);
2084 (((get_offset + 1) % ring_bufs) != put_offset)) { 2498 put_offset = ring_data->put_pos;
2085 if (rxdp->Control_1 == END_OF_BLOCK) { 2499 spin_unlock(&nic->put_lock);
2086 rxdp = (RxD_t *) ((unsigned long) 2500#else
2087 rxdp->Control_2); 2501 put_offset = (put_block * (MAX_RXDS_PER_BLOCK + 1)) +
2088 get_info.offset++; 2502 put_info.offset;
2089 get_info.offset %= 2503#endif
2090 (MAX_RXDS_PER_BLOCK + 1); 2504 while (RXD_IS_UP2DT(rxdp) &&
2091 get_block++; 2505 (((get_offset + 1) % ring_bufs) != put_offset)) {
2092 get_block %= nic->block_count[i]; 2506 skb = (struct sk_buff *) ((unsigned long)rxdp->Host_Control);
2093 mac_control->rx_curr_get_info[i]. 2507 if (skb == NULL) {
2094 offset = get_info.offset; 2508 DBG_PRINT(ERR_DBG, "%s: The skb is ",
2095 mac_control->rx_curr_get_info[i]. 2509 dev->name);
2096 block_index = get_block; 2510 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2097 continue; 2511 spin_unlock(&nic->rx_lock);
2098 } 2512 return;
2099 get_offset =
2100 (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2101 get_info.offset;
2102 skb = (struct sk_buff *) ((unsigned long)
2103 rxdp->Host_Control);
2104 if (skb == NULL) {
2105 DBG_PRINT(ERR_DBG, "%s: The skb is ",
2106 dev->name);
2107 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2108 return;
2109 }
2110 val64 = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
2111 val16 = (u16) (val64 >> 48);
2112 cksum = RXD_GET_L4_CKSUM(rxdp->Control_1);
2113 pci_unmap_single(nic->pdev, (dma_addr_t)
2114 rxdp->Buffer0_ptr,
2115 dev->mtu +
2116 HEADER_ETHERNET_II_802_3_SIZE +
2117 HEADER_802_2_SIZE +
2118 HEADER_SNAP_SIZE,
2119 PCI_DMA_FROMDEVICE);
2120 rx_osm_handler(nic, val16, rxdp, i);
2121 get_info.offset++;
2122 get_info.offset %= (MAX_RXDS_PER_BLOCK + 1);
2123 rxdp =
2124 nic->rx_blocks[i][get_block].block_virt_addr +
2125 get_info.offset;
2126 mac_control->rx_curr_get_info[i].offset =
2127 get_info.offset;
2128 pkt_cnt++;
2129 if ((indicate_max_pkts)
2130 && (pkt_cnt > indicate_max_pkts))
2131 break;
2132 } 2513 }
2514#ifndef CONFIG_2BUFF_MODE
2515 pci_unmap_single(nic->pdev, (dma_addr_t)
2516 rxdp->Buffer0_ptr,
2517 dev->mtu +
2518 HEADER_ETHERNET_II_802_3_SIZE +
2519 HEADER_802_2_SIZE +
2520 HEADER_SNAP_SIZE,
2521 PCI_DMA_FROMDEVICE);
2133#else 2522#else
2134 get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) + 2523 pci_unmap_single(nic->pdev, (dma_addr_t)
2524 rxdp->Buffer0_ptr,
2525 BUF0_LEN, PCI_DMA_FROMDEVICE);
2526 pci_unmap_single(nic->pdev, (dma_addr_t)
2527 rxdp->Buffer1_ptr,
2528 BUF1_LEN, PCI_DMA_FROMDEVICE);
2529 pci_unmap_single(nic->pdev, (dma_addr_t)
2530 rxdp->Buffer2_ptr,
2531 dev->mtu + BUF0_LEN + 4,
2532 PCI_DMA_FROMDEVICE);
2533#endif
2534 rx_osm_handler(ring_data, rxdp);
2535 get_info.offset++;
2536 ring_data->rx_curr_get_info.offset =
2135 get_info.offset; 2537 get_info.offset;
2136 spin_lock(&nic->put_lock); 2538 rxdp = ring_data->rx_blocks[get_block].block_virt_addr +
2137 put_offset = nic->put_pos[i]; 2539 get_info.offset;
2138 spin_unlock(&nic->put_lock); 2540 if (get_info.offset &&
2139 while (((!(rxdp->Control_1 & RXD_OWN_XENA)) && 2541 (!(get_info.offset % MAX_RXDS_PER_BLOCK))) {
2140 !(rxdp->Control_2 & BIT(0))) && 2542 get_info.offset = 0;
2141 (((get_offset + 1) % ring_bufs) != put_offset)) { 2543 ring_data->rx_curr_get_info.offset
2142 skb = (struct sk_buff *) ((unsigned long) 2544 = get_info.offset;
2143 rxdp->Host_Control); 2545 get_block++;
2144 if (skb == NULL) { 2546 get_block %= ring_data->block_count;
2145 DBG_PRINT(ERR_DBG, "%s: The skb is ", 2547 ring_data->rx_curr_get_info.block_index
2146 dev->name); 2548 = get_block;
2147 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n"); 2549 rxdp = ring_data->rx_blocks[get_block].block_virt_addr;
2148 return; 2550 }
2149 }
2150
2151 pci_unmap_single(nic->pdev, (dma_addr_t)
2152 rxdp->Buffer0_ptr,
2153 BUF0_LEN, PCI_DMA_FROMDEVICE);
2154 pci_unmap_single(nic->pdev, (dma_addr_t)
2155 rxdp->Buffer1_ptr,
2156 BUF1_LEN, PCI_DMA_FROMDEVICE);
2157 pci_unmap_single(nic->pdev, (dma_addr_t)
2158 rxdp->Buffer2_ptr,
2159 dev->mtu + BUF0_LEN + 4,
2160 PCI_DMA_FROMDEVICE);
2161 ba = &nic->ba[i][get_block][get_info.offset];
2162
2163 rx_osm_handler(nic, rxdp, i, ba);
2164
2165 get_info.offset++;
2166 mac_control->rx_curr_get_info[i].offset =
2167 get_info.offset;
2168 rxdp =
2169 nic->rx_blocks[i][get_block].block_virt_addr +
2170 get_info.offset;
2171 2551
2172 if (get_info.offset && 2552 get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2173 (!(get_info.offset % MAX_RXDS_PER_BLOCK))) {
2174 get_info.offset = 0;
2175 mac_control->rx_curr_get_info[i].
2176 offset = get_info.offset;
2177 get_block++;
2178 get_block %= nic->block_count[i];
2179 mac_control->rx_curr_get_info[i].
2180 block_index = get_block;
2181 rxdp =
2182 nic->rx_blocks[i][get_block].
2183 block_virt_addr;
2184 }
2185 get_offset =
2186 (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2187 get_info.offset; 2553 get_info.offset;
2188 pkt_cnt++; 2554#ifdef CONFIG_S2IO_NAPI
2189 if ((indicate_max_pkts) 2555 nic->pkts_to_process -= 1;
2190 && (pkt_cnt > indicate_max_pkts)) 2556 if (!nic->pkts_to_process)
2191 break; 2557 break;
2192 } 2558#else
2193#endif 2559 pkt_cnt++;
2194 if ((indicate_max_pkts) && (pkt_cnt > indicate_max_pkts)) 2560 if ((indicate_max_pkts) && (pkt_cnt > indicate_max_pkts))
2195 break; 2561 break;
2562#endif
2196 } 2563 }
2564 spin_unlock(&nic->rx_lock);
2197} 2565}
2198#endif 2566
2199/** 2567/**
2200 * tx_intr_handler - Transmit interrupt handler 2568 * tx_intr_handler - Transmit interrupt handler
2201 * @nic : device private variable 2569 * @nic : device private variable
2202 * Description: 2570 * Description:
2203 * If an interrupt was raised to indicate DMA complete of the 2571 * If an interrupt was raised to indicate DMA complete of the
2204 * Tx packet, this function is called. It identifies the last TxD 2572 * Tx packet, this function is called. It identifies the last TxD
2205 * whose buffer was freed and frees all skbs whose data have already 2573 * whose buffer was freed and frees all skbs whose data have already
2206 * DMA'ed into the NICs internal memory. 2574 * DMA'ed into the NICs internal memory.
2207 * Return Value: 2575 * Return Value:
2208 * NONE 2576 * NONE
2209 */ 2577 */
2210 2578
2211static void tx_intr_handler(struct s2io_nic *nic) 2579static void tx_intr_handler(fifo_info_t *fifo_data)
2212{ 2580{
2213 XENA_dev_config_t __iomem *bar0 = nic->bar0; 2581 nic_t *nic = fifo_data->nic;
2214 struct net_device *dev = (struct net_device *) nic->dev; 2582 struct net_device *dev = (struct net_device *) nic->dev;
2215 tx_curr_get_info_t get_info, put_info; 2583 tx_curr_get_info_t get_info, put_info;
2216 struct sk_buff *skb; 2584 struct sk_buff *skb;
2217 TxD_t *txdlp; 2585 TxD_t *txdlp;
2218 register u64 val64 = 0;
2219 int i;
2220 u16 j, frg_cnt; 2586 u16 j, frg_cnt;
2221 mac_info_t *mac_control;
2222 struct config_param *config;
2223 2587
2224 mac_control = &nic->mac_control; 2588 get_info = fifo_data->tx_curr_get_info;
2225 config = &nic->config; 2589 put_info = fifo_data->tx_curr_put_info;
2226 2590 txdlp = (TxD_t *) fifo_data->list_info[get_info.offset].
2227 /* 2591 list_virt_addr;
2228 * tx_traffic_int reg is an R1 register, hence we read and write 2592 while ((!(txdlp->Control_1 & TXD_LIST_OWN_XENA)) &&
2229 * back the samevalue in the register to clear it. 2593 (get_info.offset != put_info.offset) &&
2230 */ 2594 (txdlp->Host_Control)) {
2231 val64 = readq(&bar0->tx_traffic_int); 2595 /* Check for TxD errors */
2232 writeq(val64, &bar0->tx_traffic_int); 2596 if (txdlp->Control_1 & TXD_T_CODE) {
2597 unsigned long long err;
2598 err = txdlp->Control_1 & TXD_T_CODE;
2599 DBG_PRINT(ERR_DBG, "***TxD error %llx\n",
2600 err);
2601 }
2233 2602
2234 for (i = 0; i < config->tx_fifo_num; i++) { 2603 skb = (struct sk_buff *) ((unsigned long)
2235 get_info = mac_control->tx_curr_get_info[i]; 2604 txdlp->Host_Control);
2236 put_info = mac_control->tx_curr_put_info[i]; 2605 if (skb == NULL) {
2237 txdlp = (TxD_t *) nic->list_info[i][get_info.offset]. 2606 DBG_PRINT(ERR_DBG, "%s: Null skb ",
2238 list_virt_addr; 2607 __FUNCTION__);
2239 while ((!(txdlp->Control_1 & TXD_LIST_OWN_XENA)) && 2608 DBG_PRINT(ERR_DBG, "in Tx Free Intr\n");
2240 (get_info.offset != put_info.offset) && 2609 return;
2241 (txdlp->Host_Control)) { 2610 }
2242 /* Check for TxD errors */
2243 if (txdlp->Control_1 & TXD_T_CODE) {
2244 unsigned long long err;
2245 err = txdlp->Control_1 & TXD_T_CODE;
2246 DBG_PRINT(ERR_DBG, "***TxD error %llx\n",
2247 err);
2248 }
2249 2611
2250 skb = (struct sk_buff *) ((unsigned long) 2612 frg_cnt = skb_shinfo(skb)->nr_frags;
2251 txdlp->Host_Control); 2613 nic->tx_pkt_count++;
2252 if (skb == NULL) { 2614
2253 DBG_PRINT(ERR_DBG, "%s: Null skb ", 2615 pci_unmap_single(nic->pdev, (dma_addr_t)
2254 dev->name); 2616 txdlp->Buffer_Pointer,
2255 DBG_PRINT(ERR_DBG, "in Tx Free Intr\n"); 2617 skb->len - skb->data_len,
2256 return; 2618 PCI_DMA_TODEVICE);
2619 if (frg_cnt) {
2620 TxD_t *temp;
2621 temp = txdlp;
2622 txdlp++;
2623 for (j = 0; j < frg_cnt; j++, txdlp++) {
2624 skb_frag_t *frag =
2625 &skb_shinfo(skb)->frags[j];
2626 if (!txdlp->Buffer_Pointer)
2627 break;
2628 pci_unmap_page(nic->pdev,
2629 (dma_addr_t)
2630 txdlp->
2631 Buffer_Pointer,
2632 frag->size,
2633 PCI_DMA_TODEVICE);
2257 } 2634 }
2258 nic->tx_pkt_count++; 2635 txdlp = temp;
2259
2260 frg_cnt = skb_shinfo(skb)->nr_frags;
2261
2262 /* For unfragmented skb */
2263 pci_unmap_single(nic->pdev, (dma_addr_t)
2264 txdlp->Buffer_Pointer,
2265 skb->len - skb->data_len,
2266 PCI_DMA_TODEVICE);
2267 if (frg_cnt) {
2268 TxD_t *temp = txdlp;
2269 txdlp++;
2270 for (j = 0; j < frg_cnt; j++, txdlp++) {
2271 skb_frag_t *frag =
2272 &skb_shinfo(skb)->frags[j];
2273 pci_unmap_page(nic->pdev,
2274 (dma_addr_t)
2275 txdlp->
2276 Buffer_Pointer,
2277 frag->size,
2278 PCI_DMA_TODEVICE);
2279 }
2280 txdlp = temp;
2281 }
2282 memset(txdlp, 0,
2283 (sizeof(TxD_t) * config->max_txds));
2284
2285 /* Updating the statistics block */
2286 nic->stats.tx_packets++;
2287 nic->stats.tx_bytes += skb->len;
2288 dev_kfree_skb_irq(skb);
2289
2290 get_info.offset++;
2291 get_info.offset %= get_info.fifo_len + 1;
2292 txdlp = (TxD_t *) nic->list_info[i]
2293 [get_info.offset].list_virt_addr;
2294 mac_control->tx_curr_get_info[i].offset =
2295 get_info.offset;
2296 } 2636 }
2637 memset(txdlp, 0,
2638 (sizeof(TxD_t) * fifo_data->max_txds));
2639
2640 /* Updating the statistics block */
2641 nic->stats.tx_bytes += skb->len;
2642 dev_kfree_skb_irq(skb);
2643
2644 get_info.offset++;
2645 get_info.offset %= get_info.fifo_len + 1;
2646 txdlp = (TxD_t *) fifo_data->list_info
2647 [get_info.offset].list_virt_addr;
2648 fifo_data->tx_curr_get_info.offset =
2649 get_info.offset;
2297 } 2650 }
2298 2651
2299 spin_lock(&nic->tx_lock); 2652 spin_lock(&nic->tx_lock);
@@ -2302,13 +2655,13 @@ static void tx_intr_handler(struct s2io_nic *nic)
2302 spin_unlock(&nic->tx_lock); 2655 spin_unlock(&nic->tx_lock);
2303} 2656}
2304 2657
2305/** 2658/**
2306 * alarm_intr_handler - Alarm Interrrupt handler 2659 * alarm_intr_handler - Alarm Interrrupt handler
2307 * @nic: device private variable 2660 * @nic: device private variable
2308 * Description: If the interrupt was neither because of Rx packet or Tx 2661 * Description: If the interrupt was neither because of Rx packet or Tx
2309 * complete, this function is called. If the interrupt was to indicate 2662 * complete, this function is called. If the interrupt was to indicate
2310 * a loss of link, the OSM link status handler is invoked for any other 2663 * a loss of link, the OSM link status handler is invoked for any other
2311 * alarm interrupt the block that raised the interrupt is displayed 2664 * alarm interrupt the block that raised the interrupt is displayed
2312 * and a H/W reset is issued. 2665 * and a H/W reset is issued.
2313 * Return Value: 2666 * Return Value:
2314 * NONE 2667 * NONE
@@ -2321,10 +2674,32 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2321 register u64 val64 = 0, err_reg = 0; 2674 register u64 val64 = 0, err_reg = 0;
2322 2675
2323 /* Handling link status change error Intr */ 2676 /* Handling link status change error Intr */
2324 err_reg = readq(&bar0->mac_rmac_err_reg); 2677 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) {
2325 writeq(err_reg, &bar0->mac_rmac_err_reg); 2678 err_reg = readq(&bar0->mac_rmac_err_reg);
2326 if (err_reg & RMAC_LINK_STATE_CHANGE_INT) { 2679 writeq(err_reg, &bar0->mac_rmac_err_reg);
2327 schedule_work(&nic->set_link_task); 2680 if (err_reg & RMAC_LINK_STATE_CHANGE_INT) {
2681 schedule_work(&nic->set_link_task);
2682 }
2683 }
2684
2685 /* Handling Ecc errors */
2686 val64 = readq(&bar0->mc_err_reg);
2687 writeq(val64, &bar0->mc_err_reg);
2688 if (val64 & (MC_ERR_REG_ECC_ALL_SNG | MC_ERR_REG_ECC_ALL_DBL)) {
2689 if (val64 & MC_ERR_REG_ECC_ALL_DBL) {
2690 nic->mac_control.stats_info->sw_stat.
2691 double_ecc_errs++;
2692 DBG_PRINT(ERR_DBG, "%s: Device indicates ",
2693 dev->name);
2694 DBG_PRINT(ERR_DBG, "double ECC error!!\n");
2695 if (nic->device_type != XFRAME_II_DEVICE) {
2696 netif_stop_queue(dev);
2697 schedule_work(&nic->rst_timer_task);
2698 }
2699 } else {
2700 nic->mac_control.stats_info->sw_stat.
2701 single_ecc_errs++;
2702 }
2328 } 2703 }
2329 2704
2330 /* In case of a serious error, the device will be Reset. */ 2705 /* In case of a serious error, the device will be Reset. */
@@ -2339,7 +2714,7 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2339 /* 2714 /*
2340 * Also as mentioned in the latest Errata sheets if the PCC_FB_ECC 2715 * Also as mentioned in the latest Errata sheets if the PCC_FB_ECC
2341 * Error occurs, the adapter will be recycled by disabling the 2716 * Error occurs, the adapter will be recycled by disabling the
2342 * adapter enable bit and enabling it again after the device 2717 * adapter enable bit and enabling it again after the device
2343 * becomes Quiescent. 2718 * becomes Quiescent.
2344 */ 2719 */
2345 val64 = readq(&bar0->pcc_err_reg); 2720 val64 = readq(&bar0->pcc_err_reg);
@@ -2355,18 +2730,18 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2355 /* Other type of interrupts are not being handled now, TODO */ 2730 /* Other type of interrupts are not being handled now, TODO */
2356} 2731}
2357 2732
2358/** 2733/**
2359 * wait_for_cmd_complete - waits for a command to complete. 2734 * wait_for_cmd_complete - waits for a command to complete.
2360 * @sp : private member of the device structure, which is a pointer to the 2735 * @sp : private member of the device structure, which is a pointer to the
2361 * s2io_nic structure. 2736 * s2io_nic structure.
2362 * Description: Function that waits for a command to Write into RMAC 2737 * Description: Function that waits for a command to Write into RMAC
2363 * ADDR DATA registers to be completed and returns either success or 2738 * ADDR DATA registers to be completed and returns either success or
2364 * error depending on whether the command was complete or not. 2739 * error depending on whether the command was complete or not.
2365 * Return value: 2740 * Return value:
2366 * SUCCESS on success and FAILURE on failure. 2741 * SUCCESS on success and FAILURE on failure.
2367 */ 2742 */
2368 2743
2369static int wait_for_cmd_complete(nic_t * sp) 2744int wait_for_cmd_complete(nic_t * sp)
2370{ 2745{
2371 XENA_dev_config_t __iomem *bar0 = sp->bar0; 2746 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2372 int ret = FAILURE, cnt = 0; 2747 int ret = FAILURE, cnt = 0;
@@ -2386,29 +2761,32 @@ static int wait_for_cmd_complete(nic_t * sp)
2386 return ret; 2761 return ret;
2387} 2762}
2388 2763
2389/** 2764/**
2390 * s2io_reset - Resets the card. 2765 * s2io_reset - Resets the card.
2391 * @sp : private member of the device structure. 2766 * @sp : private member of the device structure.
2392 * Description: Function to Reset the card. This function then also 2767 * Description: Function to Reset the card. This function then also
2393 * restores the previously saved PCI configuration space registers as 2768 * restores the previously saved PCI configuration space registers as
2394 * the card reset also resets the configuration space. 2769 * the card reset also resets the configuration space.
2395 * Return value: 2770 * Return value:
2396 * void. 2771 * void.
2397 */ 2772 */
2398 2773
2399static void s2io_reset(nic_t * sp) 2774void s2io_reset(nic_t * sp)
2400{ 2775{
2401 XENA_dev_config_t __iomem *bar0 = sp->bar0; 2776 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2402 u64 val64; 2777 u64 val64;
2403 u16 subid; 2778 u16 subid, pci_cmd;
2779
2780 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */
2781 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd));
2404 2782
2405 val64 = SW_RESET_ALL; 2783 val64 = SW_RESET_ALL;
2406 writeq(val64, &bar0->sw_reset); 2784 writeq(val64, &bar0->sw_reset);
2407 2785
2408 /* 2786 /*
2409 * At this stage, if the PCI write is indeed completed, the 2787 * At this stage, if the PCI write is indeed completed, the
2410 * card is reset and so is the PCI Config space of the device. 2788 * card is reset and so is the PCI Config space of the device.
2411 * So a read cannot be issued at this stage on any of the 2789 * So a read cannot be issued at this stage on any of the
2412 * registers to ensure the write into "sw_reset" register 2790 * registers to ensure the write into "sw_reset" register
2413 * has gone through. 2791 * has gone through.
2414 * Question: Is there any system call that will explicitly force 2792 * Question: Is there any system call that will explicitly force
@@ -2419,42 +2797,72 @@ static void s2io_reset(nic_t * sp)
2419 */ 2797 */
2420 msleep(250); 2798 msleep(250);
2421 2799
2422 /* Restore the PCI state saved during initializarion. */ 2800 /* Restore the PCI state saved during initialization. */
2423 pci_restore_state(sp->pdev); 2801 pci_restore_state(sp->pdev);
2802 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
2803 pci_cmd);
2424 s2io_init_pci(sp); 2804 s2io_init_pci(sp);
2425 2805
2426 msleep(250); 2806 msleep(250);
2427 2807
2808 /* Set swapper to enable I/O register access */
2809 s2io_set_swapper(sp);
2810
2811 /* Clear certain PCI/PCI-X fields after reset */
2812 if (sp->device_type == XFRAME_II_DEVICE) {
2813 /* Clear parity err detect bit */
2814 pci_write_config_word(sp->pdev, PCI_STATUS, 0x8000);
2815
2816 /* Clearing PCIX Ecc status register */
2817 pci_write_config_dword(sp->pdev, 0x68, 0x7C);
2818
2819 /* Clearing PCI_STATUS error reflected here */
2820 writeq(BIT(62), &bar0->txpic_int_reg);
2821 }
2822
2823 /* Reset device statistics maintained by OS */
2824 memset(&sp->stats, 0, sizeof (struct net_device_stats));
2825
2428 /* SXE-002: Configure link and activity LED to turn it off */ 2826 /* SXE-002: Configure link and activity LED to turn it off */
2429 subid = sp->pdev->subsystem_device; 2827 subid = sp->pdev->subsystem_device;
2430 if ((subid & 0xFF) >= 0x07) { 2828 if (((subid & 0xFF) >= 0x07) &&
2829 (sp->device_type == XFRAME_I_DEVICE)) {
2431 val64 = readq(&bar0->gpio_control); 2830 val64 = readq(&bar0->gpio_control);
2432 val64 |= 0x0000800000000000ULL; 2831 val64 |= 0x0000800000000000ULL;
2433 writeq(val64, &bar0->gpio_control); 2832 writeq(val64, &bar0->gpio_control);
2434 val64 = 0x0411040400000000ULL; 2833 val64 = 0x0411040400000000ULL;
2435 writeq(val64, (void __iomem *) bar0 + 0x2700); 2834 writeq(val64, (void __iomem *) ((u8 *) bar0 + 0x2700));
2835 }
2836
2837 /*
2838 * Clear spurious ECC interrupts that would have occured on
2839 * XFRAME II cards after reset.
2840 */
2841 if (sp->device_type == XFRAME_II_DEVICE) {
2842 val64 = readq(&bar0->pcc_err_reg);
2843 writeq(val64, &bar0->pcc_err_reg);
2436 } 2844 }
2437 2845
2438 sp->device_enabled_once = FALSE; 2846 sp->device_enabled_once = FALSE;
2439} 2847}
2440 2848
2441/** 2849/**
2442 * s2io_set_swapper - to set the swapper controle on the card 2850 * s2io_set_swapper - to set the swapper controle on the card
2443 * @sp : private member of the device structure, 2851 * @sp : private member of the device structure,
2444 * pointer to the s2io_nic structure. 2852 * pointer to the s2io_nic structure.
2445 * Description: Function to set the swapper control on the card 2853 * Description: Function to set the swapper control on the card
2446 * correctly depending on the 'endianness' of the system. 2854 * correctly depending on the 'endianness' of the system.
2447 * Return value: 2855 * Return value:
2448 * SUCCESS on success and FAILURE on failure. 2856 * SUCCESS on success and FAILURE on failure.
2449 */ 2857 */
2450 2858
2451static int s2io_set_swapper(nic_t * sp) 2859int s2io_set_swapper(nic_t * sp)
2452{ 2860{
2453 struct net_device *dev = sp->dev; 2861 struct net_device *dev = sp->dev;
2454 XENA_dev_config_t __iomem *bar0 = sp->bar0; 2862 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2455 u64 val64, valt, valr; 2863 u64 val64, valt, valr;
2456 2864
2457 /* 2865 /*
2458 * Set proper endian settings and verify the same by reading 2866 * Set proper endian settings and verify the same by reading
2459 * the PIF Feed-back register. 2867 * the PIF Feed-back register.
2460 */ 2868 */
@@ -2506,8 +2914,9 @@ static int s2io_set_swapper(nic_t * sp)
2506 i++; 2914 i++;
2507 } 2915 }
2508 if(i == 4) { 2916 if(i == 4) {
2917 unsigned long long x = val64;
2509 DBG_PRINT(ERR_DBG, "Write failed, Xmsi_addr "); 2918 DBG_PRINT(ERR_DBG, "Write failed, Xmsi_addr ");
2510 DBG_PRINT(ERR_DBG, "reads:0x%llx\n",val64); 2919 DBG_PRINT(ERR_DBG, "reads:0x%llx\n", x);
2511 return FAILURE; 2920 return FAILURE;
2512 } 2921 }
2513 } 2922 }
@@ -2515,8 +2924,8 @@ static int s2io_set_swapper(nic_t * sp)
2515 val64 &= 0xFFFF000000000000ULL; 2924 val64 &= 0xFFFF000000000000ULL;
2516 2925
2517#ifdef __BIG_ENDIAN 2926#ifdef __BIG_ENDIAN
2518 /* 2927 /*
2519 * The device by default set to a big endian format, so a 2928 * The device by default set to a big endian format, so a
2520 * big endian driver need not set anything. 2929 * big endian driver need not set anything.
2521 */ 2930 */
2522 val64 |= (SWAPPER_CTRL_TXP_FE | 2931 val64 |= (SWAPPER_CTRL_TXP_FE |
@@ -2532,9 +2941,9 @@ static int s2io_set_swapper(nic_t * sp)
2532 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE); 2941 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
2533 writeq(val64, &bar0->swapper_ctrl); 2942 writeq(val64, &bar0->swapper_ctrl);
2534#else 2943#else
2535 /* 2944 /*
2536 * Initially we enable all bits to make it accessible by the 2945 * Initially we enable all bits to make it accessible by the
2537 * driver, then we selectively enable only those bits that 2946 * driver, then we selectively enable only those bits that
2538 * we want to set. 2947 * we want to set.
2539 */ 2948 */
2540 val64 |= (SWAPPER_CTRL_TXP_FE | 2949 val64 |= (SWAPPER_CTRL_TXP_FE |
@@ -2556,8 +2965,8 @@ static int s2io_set_swapper(nic_t * sp)
2556#endif 2965#endif
2557 val64 = readq(&bar0->swapper_ctrl); 2966 val64 = readq(&bar0->swapper_ctrl);
2558 2967
2559 /* 2968 /*
2560 * Verifying if endian settings are accurate by reading a 2969 * Verifying if endian settings are accurate by reading a
2561 * feedback register. 2970 * feedback register.
2562 */ 2971 */
2563 val64 = readq(&bar0->pif_rd_swapper_fb); 2972 val64 = readq(&bar0->pif_rd_swapper_fb);
@@ -2577,55 +2986,63 @@ static int s2io_set_swapper(nic_t * sp)
2577 * Functions defined below concern the OS part of the driver * 2986 * Functions defined below concern the OS part of the driver *
2578 * ********************************************************* */ 2987 * ********************************************************* */
2579 2988
2580/** 2989/**
2581 * s2io_open - open entry point of the driver 2990 * s2io_open - open entry point of the driver
2582 * @dev : pointer to the device structure. 2991 * @dev : pointer to the device structure.
2583 * Description: 2992 * Description:
2584 * This function is the open entry point of the driver. It mainly calls a 2993 * This function is the open entry point of the driver. It mainly calls a
2585 * function to allocate Rx buffers and inserts them into the buffer 2994 * function to allocate Rx buffers and inserts them into the buffer
2586 * descriptors and then enables the Rx part of the NIC. 2995 * descriptors and then enables the Rx part of the NIC.
2587 * Return value: 2996 * Return value:
2588 * 0 on success and an appropriate (-)ve integer as defined in errno.h 2997 * 0 on success and an appropriate (-)ve integer as defined in errno.h
2589 * file on failure. 2998 * file on failure.
2590 */ 2999 */
2591 3000
2592static int s2io_open(struct net_device *dev) 3001int s2io_open(struct net_device *dev)
2593{ 3002{
2594 nic_t *sp = dev->priv; 3003 nic_t *sp = dev->priv;
2595 int err = 0; 3004 int err = 0;
2596 3005
2597 /* 3006 /*
2598 * Make sure you have link off by default every time 3007 * Make sure you have link off by default every time
2599 * Nic is initialized 3008 * Nic is initialized
2600 */ 3009 */
2601 netif_carrier_off(dev); 3010 netif_carrier_off(dev);
2602 sp->last_link_state = LINK_DOWN; 3011 sp->last_link_state = 0;
2603 3012
2604 /* Initialize H/W and enable interrupts */ 3013 /* Initialize H/W and enable interrupts */
2605 if (s2io_card_up(sp)) { 3014 if (s2io_card_up(sp)) {
2606 DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n", 3015 DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n",
2607 dev->name); 3016 dev->name);
2608 return -ENODEV; 3017 err = -ENODEV;
3018 goto hw_init_failed;
2609 } 3019 }
2610 3020
2611 /* After proper initialization of H/W, register ISR */ 3021 /* After proper initialization of H/W, register ISR */
2612 err = request_irq((int) sp->irq, s2io_isr, SA_SHIRQ, 3022 err = request_irq((int) sp->pdev->irq, s2io_isr, SA_SHIRQ,
2613 sp->name, dev); 3023 sp->name, dev);
2614 if (err) { 3024 if (err) {
2615 s2io_reset(sp);
2616 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n", 3025 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n",
2617 dev->name); 3026 dev->name);
2618 return err; 3027 goto isr_registration_failed;
2619 } 3028 }
2620 3029
2621 if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) { 3030 if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) {
2622 DBG_PRINT(ERR_DBG, "Set Mac Address Failed\n"); 3031 DBG_PRINT(ERR_DBG, "Set Mac Address Failed\n");
2623 s2io_reset(sp); 3032 err = -ENODEV;
2624 return -ENODEV; 3033 goto setting_mac_address_failed;
2625 } 3034 }
2626 3035
2627 netif_start_queue(dev); 3036 netif_start_queue(dev);
2628 return 0; 3037 return 0;
3038
3039setting_mac_address_failed:
3040 free_irq(sp->pdev->irq, dev);
3041isr_registration_failed:
3042 del_timer_sync(&sp->alarm_timer);
3043 s2io_reset(sp);
3044hw_init_failed:
3045 return err;
2629} 3046}
2630 3047
2631/** 3048/**
@@ -2641,16 +3058,15 @@ static int s2io_open(struct net_device *dev)
2641 * file on failure. 3058 * file on failure.
2642 */ 3059 */
2643 3060
2644static int s2io_close(struct net_device *dev) 3061int s2io_close(struct net_device *dev)
2645{ 3062{
2646 nic_t *sp = dev->priv; 3063 nic_t *sp = dev->priv;
2647
2648 flush_scheduled_work(); 3064 flush_scheduled_work();
2649 netif_stop_queue(dev); 3065 netif_stop_queue(dev);
2650 /* Reset card, kill tasklet and free Tx and Rx buffers. */ 3066 /* Reset card, kill tasklet and free Tx and Rx buffers. */
2651 s2io_card_down(sp); 3067 s2io_card_down(sp);
2652 3068
2653 free_irq(dev->irq, dev); 3069 free_irq(sp->pdev->irq, dev);
2654 sp->device_close_flag = TRUE; /* Device is shut down. */ 3070 sp->device_close_flag = TRUE; /* Device is shut down. */
2655 return 0; 3071 return 0;
2656} 3072}
@@ -2668,7 +3084,7 @@ static int s2io_close(struct net_device *dev)
2668 * 0 on success & 1 on failure. 3084 * 0 on success & 1 on failure.
2669 */ 3085 */
2670 3086
2671static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) 3087int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2672{ 3088{
2673 nic_t *sp = dev->priv; 3089 nic_t *sp = dev->priv;
2674 u16 frg_cnt, frg_len, i, queue, queue_len, put_off, get_off; 3090 u16 frg_cnt, frg_len, i, queue, queue_len, put_off, get_off;
@@ -2679,29 +3095,39 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2679#ifdef NETIF_F_TSO 3095#ifdef NETIF_F_TSO
2680 int mss; 3096 int mss;
2681#endif 3097#endif
3098 u16 vlan_tag = 0;
3099 int vlan_priority = 0;
2682 mac_info_t *mac_control; 3100 mac_info_t *mac_control;
2683 struct config_param *config; 3101 struct config_param *config;
2684 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2685 3102
2686 mac_control = &sp->mac_control; 3103 mac_control = &sp->mac_control;
2687 config = &sp->config; 3104 config = &sp->config;
2688 3105
2689 DBG_PRINT(TX_DBG, "%s: In S2IO Tx routine\n", dev->name); 3106 DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name);
2690 spin_lock_irqsave(&sp->tx_lock, flags); 3107 spin_lock_irqsave(&sp->tx_lock, flags);
2691
2692 if (atomic_read(&sp->card_state) == CARD_DOWN) { 3108 if (atomic_read(&sp->card_state) == CARD_DOWN) {
2693 DBG_PRINT(ERR_DBG, "%s: Card going down for reset\n", 3109 DBG_PRINT(TX_DBG, "%s: Card going down for reset\n",
2694 dev->name); 3110 dev->name);
2695 spin_unlock_irqrestore(&sp->tx_lock, flags); 3111 spin_unlock_irqrestore(&sp->tx_lock, flags);
2696 return 1; 3112 dev_kfree_skb(skb);
3113 return 0;
2697 } 3114 }
2698 3115
2699 queue = 0; 3116 queue = 0;
2700 put_off = (u16) mac_control->tx_curr_put_info[queue].offset;
2701 get_off = (u16) mac_control->tx_curr_get_info[queue].offset;
2702 txdp = (TxD_t *) sp->list_info[queue][put_off].list_virt_addr;
2703 3117
2704 queue_len = mac_control->tx_curr_put_info[queue].fifo_len + 1; 3118 /* Get Fifo number to Transmit based on vlan priority */
3119 if (sp->vlgrp && vlan_tx_tag_present(skb)) {
3120 vlan_tag = vlan_tx_tag_get(skb);
3121 vlan_priority = vlan_tag >> 13;
3122 queue = config->fifo_mapping[vlan_priority];
3123 }
3124
3125 put_off = (u16) mac_control->fifos[queue].tx_curr_put_info.offset;
3126 get_off = (u16) mac_control->fifos[queue].tx_curr_get_info.offset;
3127 txdp = (TxD_t *) mac_control->fifos[queue].list_info[put_off].
3128 list_virt_addr;
3129
3130 queue_len = mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1;
2705 /* Avoid "put" pointer going beyond "get" pointer */ 3131 /* Avoid "put" pointer going beyond "get" pointer */
2706 if (txdp->Host_Control || (((put_off + 1) % queue_len) == get_off)) { 3132 if (txdp->Host_Control || (((put_off + 1) % queue_len) == get_off)) {
2707 DBG_PRINT(ERR_DBG, "Error in xmit, No free TXDs.\n"); 3133 DBG_PRINT(ERR_DBG, "Error in xmit, No free TXDs.\n");
@@ -2710,6 +3136,15 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2710 spin_unlock_irqrestore(&sp->tx_lock, flags); 3136 spin_unlock_irqrestore(&sp->tx_lock, flags);
2711 return 0; 3137 return 0;
2712 } 3138 }
3139
3140 /* A buffer with no data will be dropped */
3141 if (!skb->len) {
3142 DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name);
3143 dev_kfree_skb(skb);
3144 spin_unlock_irqrestore(&sp->tx_lock, flags);
3145 return 0;
3146 }
3147
2713#ifdef NETIF_F_TSO 3148#ifdef NETIF_F_TSO
2714 mss = skb_shinfo(skb)->tso_size; 3149 mss = skb_shinfo(skb)->tso_size;
2715 if (mss) { 3150 if (mss) {
@@ -2721,9 +3156,9 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2721 frg_cnt = skb_shinfo(skb)->nr_frags; 3156 frg_cnt = skb_shinfo(skb)->nr_frags;
2722 frg_len = skb->len - skb->data_len; 3157 frg_len = skb->len - skb->data_len;
2723 3158
2724 txdp->Host_Control = (unsigned long) skb;
2725 txdp->Buffer_Pointer = pci_map_single 3159 txdp->Buffer_Pointer = pci_map_single
2726 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); 3160 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
3161 txdp->Host_Control = (unsigned long) skb;
2727 if (skb->ip_summed == CHECKSUM_HW) { 3162 if (skb->ip_summed == CHECKSUM_HW) {
2728 txdp->Control_2 |= 3163 txdp->Control_2 |=
2729 (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN | 3164 (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN |
@@ -2732,6 +3167,11 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2732 3167
2733 txdp->Control_2 |= config->tx_intr_type; 3168 txdp->Control_2 |= config->tx_intr_type;
2734 3169
3170 if (sp->vlgrp && vlan_tx_tag_present(skb)) {
3171 txdp->Control_2 |= TXD_VLAN_ENABLE;
3172 txdp->Control_2 |= TXD_VLAN_TAG(vlan_tag);
3173 }
3174
2735 txdp->Control_1 |= (TXD_BUFFER0_SIZE(frg_len) | 3175 txdp->Control_1 |= (TXD_BUFFER0_SIZE(frg_len) |
2736 TXD_GATHER_CODE_FIRST); 3176 TXD_GATHER_CODE_FIRST);
2737 txdp->Control_1 |= TXD_LIST_OWN_XENA; 3177 txdp->Control_1 |= TXD_LIST_OWN_XENA;
@@ -2739,6 +3179,9 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2739 /* For fragmented SKB. */ 3179 /* For fragmented SKB. */
2740 for (i = 0; i < frg_cnt; i++) { 3180 for (i = 0; i < frg_cnt; i++) {
2741 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 3181 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
3182 /* A '0' length fragment will be ignored */
3183 if (!frag->size)
3184 continue;
2742 txdp++; 3185 txdp++;
2743 txdp->Buffer_Pointer = (u64) pci_map_page 3186 txdp->Buffer_Pointer = (u64) pci_map_page
2744 (sp->pdev, frag->page, frag->page_offset, 3187 (sp->pdev, frag->page, frag->page_offset,
@@ -2748,23 +3191,23 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2748 txdp->Control_1 |= TXD_GATHER_CODE_LAST; 3191 txdp->Control_1 |= TXD_GATHER_CODE_LAST;
2749 3192
2750 tx_fifo = mac_control->tx_FIFO_start[queue]; 3193 tx_fifo = mac_control->tx_FIFO_start[queue];
2751 val64 = sp->list_info[queue][put_off].list_phy_addr; 3194 val64 = mac_control->fifos[queue].list_info[put_off].list_phy_addr;
2752 writeq(val64, &tx_fifo->TxDL_Pointer); 3195 writeq(val64, &tx_fifo->TxDL_Pointer);
2753 3196
2754 val64 = (TX_FIFO_LAST_TXD_NUM(frg_cnt) | TX_FIFO_FIRST_LIST | 3197 val64 = (TX_FIFO_LAST_TXD_NUM(frg_cnt) | TX_FIFO_FIRST_LIST |
2755 TX_FIFO_LAST_LIST); 3198 TX_FIFO_LAST_LIST);
3199
2756#ifdef NETIF_F_TSO 3200#ifdef NETIF_F_TSO
2757 if (mss) 3201 if (mss)
2758 val64 |= TX_FIFO_SPECIAL_FUNC; 3202 val64 |= TX_FIFO_SPECIAL_FUNC;
2759#endif 3203#endif
2760 writeq(val64, &tx_fifo->List_Control); 3204 writeq(val64, &tx_fifo->List_Control);
2761 3205
2762 /* Perform a PCI read to flush previous writes */ 3206 mmiowb();
2763 val64 = readq(&bar0->general_int_status);
2764 3207
2765 put_off++; 3208 put_off++;
2766 put_off %= mac_control->tx_curr_put_info[queue].fifo_len + 1; 3209 put_off %= mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1;
2767 mac_control->tx_curr_put_info[queue].offset = put_off; 3210 mac_control->fifos[queue].tx_curr_put_info.offset = put_off;
2768 3211
2769 /* Avoid "put" pointer going beyond "get" pointer */ 3212 /* Avoid "put" pointer going beyond "get" pointer */
2770 if (((put_off + 1) % queue_len) == get_off) { 3213 if (((put_off + 1) % queue_len) == get_off) {
@@ -2780,18 +3223,74 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
2780 return 0; 3223 return 0;
2781} 3224}
2782 3225
3226static void
3227s2io_alarm_handle(unsigned long data)
3228{
3229 nic_t *sp = (nic_t *)data;
3230
3231 alarm_intr_handler(sp);
3232 mod_timer(&sp->alarm_timer, jiffies + HZ / 2);
3233}
3234
3235static void s2io_txpic_intr_handle(nic_t *sp)
3236{
3237 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3238 u64 val64;
3239
3240 val64 = readq(&bar0->pic_int_status);
3241 if (val64 & PIC_INT_GPIO) {
3242 val64 = readq(&bar0->gpio_int_reg);
3243 if ((val64 & GPIO_INT_REG_LINK_DOWN) &&
3244 (val64 & GPIO_INT_REG_LINK_UP)) {
3245 val64 |= GPIO_INT_REG_LINK_DOWN;
3246 val64 |= GPIO_INT_REG_LINK_UP;
3247 writeq(val64, &bar0->gpio_int_reg);
3248 goto masking;
3249 }
3250
3251 if (((sp->last_link_state == LINK_UP) &&
3252 (val64 & GPIO_INT_REG_LINK_DOWN)) ||
3253 ((sp->last_link_state == LINK_DOWN) &&
3254 (val64 & GPIO_INT_REG_LINK_UP))) {
3255 val64 = readq(&bar0->gpio_int_mask);
3256 val64 |= GPIO_INT_MASK_LINK_DOWN;
3257 val64 |= GPIO_INT_MASK_LINK_UP;
3258 writeq(val64, &bar0->gpio_int_mask);
3259 s2io_set_link((unsigned long)sp);
3260 }
3261masking:
3262 if (sp->last_link_state == LINK_UP) {
3263 /*enable down interrupt */
3264 val64 = readq(&bar0->gpio_int_mask);
3265 /* unmasks link down intr */
3266 val64 &= ~GPIO_INT_MASK_LINK_DOWN;
3267 /* masks link up intr */
3268 val64 |= GPIO_INT_MASK_LINK_UP;
3269 writeq(val64, &bar0->gpio_int_mask);
3270 } else {
3271 /*enable UP Interrupt */
3272 val64 = readq(&bar0->gpio_int_mask);
3273 /* unmasks link up interrupt */
3274 val64 &= ~GPIO_INT_MASK_LINK_UP;
3275 /* masks link down interrupt */
3276 val64 |= GPIO_INT_MASK_LINK_DOWN;
3277 writeq(val64, &bar0->gpio_int_mask);
3278 }
3279 }
3280}
3281
2783/** 3282/**
2784 * s2io_isr - ISR handler of the device . 3283 * s2io_isr - ISR handler of the device .
2785 * @irq: the irq of the device. 3284 * @irq: the irq of the device.
2786 * @dev_id: a void pointer to the dev structure of the NIC. 3285 * @dev_id: a void pointer to the dev structure of the NIC.
2787 * @pt_regs: pointer to the registers pushed on the stack. 3286 * @pt_regs: pointer to the registers pushed on the stack.
2788 * Description: This function is the ISR handler of the device. It 3287 * Description: This function is the ISR handler of the device. It
2789 * identifies the reason for the interrupt and calls the relevant 3288 * identifies the reason for the interrupt and calls the relevant
2790 * service routines. As a contongency measure, this ISR allocates the 3289 * service routines. As a contongency measure, this ISR allocates the
2791 * recv buffers, if their numbers are below the panic value which is 3290 * recv buffers, if their numbers are below the panic value which is
2792 * presently set to 25% of the original number of rcv buffers allocated. 3291 * presently set to 25% of the original number of rcv buffers allocated.
2793 * Return value: 3292 * Return value:
2794 * IRQ_HANDLED: will be returned if IRQ was handled by this routine 3293 * IRQ_HANDLED: will be returned if IRQ was handled by this routine
2795 * IRQ_NONE: will be returned if interrupt is not from our device 3294 * IRQ_NONE: will be returned if interrupt is not from our device
2796 */ 3295 */
2797static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs) 3296static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
@@ -2799,40 +3298,31 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
2799 struct net_device *dev = (struct net_device *) dev_id; 3298 struct net_device *dev = (struct net_device *) dev_id;
2800 nic_t *sp = dev->priv; 3299 nic_t *sp = dev->priv;
2801 XENA_dev_config_t __iomem *bar0 = sp->bar0; 3300 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2802#ifndef CONFIG_S2IO_NAPI 3301 int i;
2803 int i, ret; 3302 u64 reason = 0, val64;
2804#endif
2805 u64 reason = 0;
2806 mac_info_t *mac_control; 3303 mac_info_t *mac_control;
2807 struct config_param *config; 3304 struct config_param *config;
2808 3305
3306 atomic_inc(&sp->isr_cnt);
2809 mac_control = &sp->mac_control; 3307 mac_control = &sp->mac_control;
2810 config = &sp->config; 3308 config = &sp->config;
2811 3309
2812 /* 3310 /*
2813 * Identify the cause for interrupt and call the appropriate 3311 * Identify the cause for interrupt and call the appropriate
2814 * interrupt handler. Causes for the interrupt could be; 3312 * interrupt handler. Causes for the interrupt could be;
2815 * 1. Rx of packet. 3313 * 1. Rx of packet.
2816 * 2. Tx complete. 3314 * 2. Tx complete.
2817 * 3. Link down. 3315 * 3. Link down.
2818 * 4. Error in any functional blocks of the NIC. 3316 * 4. Error in any functional blocks of the NIC.
2819 */ 3317 */
2820 reason = readq(&bar0->general_int_status); 3318 reason = readq(&bar0->general_int_status);
2821 3319
2822 if (!reason) { 3320 if (!reason) {
2823 /* The interrupt was not raised by Xena. */ 3321 /* The interrupt was not raised by Xena. */
3322 atomic_dec(&sp->isr_cnt);
2824 return IRQ_NONE; 3323 return IRQ_NONE;
2825 } 3324 }
2826 3325
2827 /* If Intr is because of Tx Traffic */
2828 if (reason & GEN_INTR_TXTRAFFIC) {
2829 tx_intr_handler(sp);
2830 }
2831
2832 /* If Intr is because of an error */
2833 if (reason & (GEN_ERROR_INTR))
2834 alarm_intr_handler(sp);
2835
2836#ifdef CONFIG_S2IO_NAPI 3326#ifdef CONFIG_S2IO_NAPI
2837 if (reason & GEN_INTR_RXTRAFFIC) { 3327 if (reason & GEN_INTR_RXTRAFFIC) {
2838 if (netif_rx_schedule_prep(dev)) { 3328 if (netif_rx_schedule_prep(dev)) {
@@ -2844,17 +3334,43 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
2844#else 3334#else
2845 /* If Intr is because of Rx Traffic */ 3335 /* If Intr is because of Rx Traffic */
2846 if (reason & GEN_INTR_RXTRAFFIC) { 3336 if (reason & GEN_INTR_RXTRAFFIC) {
2847 rx_intr_handler(sp); 3337 /*
3338 * rx_traffic_int reg is an R1 register, writing all 1's
3339 * will ensure that the actual interrupt causing bit get's
3340 * cleared and hence a read can be avoided.
3341 */
3342 val64 = 0xFFFFFFFFFFFFFFFFULL;
3343 writeq(val64, &bar0->rx_traffic_int);
3344 for (i = 0; i < config->rx_ring_num; i++) {
3345 rx_intr_handler(&mac_control->rings[i]);
3346 }
2848 } 3347 }
2849#endif 3348#endif
2850 3349
2851 /* 3350 /* If Intr is because of Tx Traffic */
2852 * If the Rx buffer count is below the panic threshold then 3351 if (reason & GEN_INTR_TXTRAFFIC) {
2853 * reallocate the buffers from the interrupt handler itself, 3352 /*
3353 * tx_traffic_int reg is an R1 register, writing all 1's
3354 * will ensure that the actual interrupt causing bit get's
3355 * cleared and hence a read can be avoided.
3356 */
3357 val64 = 0xFFFFFFFFFFFFFFFFULL;
3358 writeq(val64, &bar0->tx_traffic_int);
3359
3360 for (i = 0; i < config->tx_fifo_num; i++)
3361 tx_intr_handler(&mac_control->fifos[i]);
3362 }
3363
3364 if (reason & GEN_INTR_TXPIC)
3365 s2io_txpic_intr_handle(sp);
3366 /*
3367 * If the Rx buffer count is below the panic threshold then
3368 * reallocate the buffers from the interrupt handler itself,
2854 * else schedule a tasklet to reallocate the buffers. 3369 * else schedule a tasklet to reallocate the buffers.
2855 */ 3370 */
2856#ifndef CONFIG_S2IO_NAPI 3371#ifndef CONFIG_S2IO_NAPI
2857 for (i = 0; i < config->rx_ring_num; i++) { 3372 for (i = 0; i < config->rx_ring_num; i++) {
3373 int ret;
2858 int rxb_size = atomic_read(&sp->rx_bufs_left[i]); 3374 int rxb_size = atomic_read(&sp->rx_bufs_left[i]);
2859 int level = rx_buffer_level(sp, rxb_size, i); 3375 int level = rx_buffer_level(sp, rxb_size, i);
2860 3376
@@ -2866,6 +3382,7 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
2866 dev->name); 3382 dev->name);
2867 DBG_PRINT(ERR_DBG, " in ISR!!\n"); 3383 DBG_PRINT(ERR_DBG, " in ISR!!\n");
2868 clear_bit(0, (&sp->tasklet_status)); 3384 clear_bit(0, (&sp->tasklet_status));
3385 atomic_dec(&sp->isr_cnt);
2869 return IRQ_HANDLED; 3386 return IRQ_HANDLED;
2870 } 3387 }
2871 clear_bit(0, (&sp->tasklet_status)); 3388 clear_bit(0, (&sp->tasklet_status));
@@ -2875,33 +3392,69 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
2875 } 3392 }
2876#endif 3393#endif
2877 3394
3395 atomic_dec(&sp->isr_cnt);
2878 return IRQ_HANDLED; 3396 return IRQ_HANDLED;
2879} 3397}
2880 3398
2881/** 3399/**
2882 * s2io_get_stats - Updates the device statistics structure. 3400 * s2io_updt_stats -
3401 */
3402static void s2io_updt_stats(nic_t *sp)
3403{
3404 XENA_dev_config_t __iomem *bar0 = sp->bar0;
3405 u64 val64;
3406 int cnt = 0;
3407
3408 if (atomic_read(&sp->card_state) == CARD_UP) {
3409 /* Apprx 30us on a 133 MHz bus */
3410 val64 = SET_UPDT_CLICKS(10) |
3411 STAT_CFG_ONE_SHOT_EN | STAT_CFG_STAT_EN;
3412 writeq(val64, &bar0->stat_cfg);
3413 do {
3414 udelay(100);
3415 val64 = readq(&bar0->stat_cfg);
3416 if (!(val64 & BIT(0)))
3417 break;
3418 cnt++;
3419 if (cnt == 5)
3420 break; /* Updt failed */
3421 } while(1);
3422 }
3423}
3424
3425/**
3426 * s2io_get_stats - Updates the device statistics structure.
2883 * @dev : pointer to the device structure. 3427 * @dev : pointer to the device structure.
2884 * Description: 3428 * Description:
2885 * This function updates the device statistics structure in the s2io_nic 3429 * This function updates the device statistics structure in the s2io_nic
2886 * structure and returns a pointer to the same. 3430 * structure and returns a pointer to the same.
2887 * Return value: 3431 * Return value:
2888 * pointer to the updated net_device_stats structure. 3432 * pointer to the updated net_device_stats structure.
2889 */ 3433 */
2890 3434
2891static struct net_device_stats *s2io_get_stats(struct net_device *dev) 3435struct net_device_stats *s2io_get_stats(struct net_device *dev)
2892{ 3436{
2893 nic_t *sp = dev->priv; 3437 nic_t *sp = dev->priv;
2894 mac_info_t *mac_control; 3438 mac_info_t *mac_control;
2895 struct config_param *config; 3439 struct config_param *config;
2896 3440
3441
2897 mac_control = &sp->mac_control; 3442 mac_control = &sp->mac_control;
2898 config = &sp->config; 3443 config = &sp->config;
2899 3444
2900 sp->stats.tx_errors = mac_control->stats_info->tmac_any_err_frms; 3445 /* Configure Stats for immediate updt */
2901 sp->stats.rx_errors = mac_control->stats_info->rmac_drop_frms; 3446 s2io_updt_stats(sp);
2902 sp->stats.multicast = mac_control->stats_info->rmac_vld_mcst_frms; 3447
3448 sp->stats.tx_packets =
3449 le32_to_cpu(mac_control->stats_info->tmac_frms);
3450 sp->stats.tx_errors =
3451 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms);
3452 sp->stats.rx_errors =
3453 le32_to_cpu(mac_control->stats_info->rmac_drop_frms);
3454 sp->stats.multicast =
3455 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms);
2903 sp->stats.rx_length_errors = 3456 sp->stats.rx_length_errors =
2904 mac_control->stats_info->rmac_long_frms; 3457 le32_to_cpu(mac_control->stats_info->rmac_long_frms);
2905 3458
2906 return (&sp->stats); 3459 return (&sp->stats);
2907} 3460}
@@ -2910,8 +3463,8 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
2910 * s2io_set_multicast - entry point for multicast address enable/disable. 3463 * s2io_set_multicast - entry point for multicast address enable/disable.
2911 * @dev : pointer to the device structure 3464 * @dev : pointer to the device structure
2912 * Description: 3465 * Description:
2913 * This function is a driver entry point which gets called by the kernel 3466 * This function is a driver entry point which gets called by the kernel
2914 * whenever multicast addresses must be enabled/disabled. This also gets 3467 * whenever multicast addresses must be enabled/disabled. This also gets
2915 * called to set/reset promiscuous mode. Depending on the deivce flag, we 3468 * called to set/reset promiscuous mode. Depending on the deivce flag, we
2916 * determine, if multicast address must be enabled or if promiscuous mode 3469 * determine, if multicast address must be enabled or if promiscuous mode
2917 * is to be disabled etc. 3470 * is to be disabled etc.
@@ -2949,6 +3502,8 @@ static void s2io_set_multicast(struct net_device *dev)
2949 /* Disable all Multicast addresses */ 3502 /* Disable all Multicast addresses */
2950 writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr), 3503 writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr),
2951 &bar0->rmac_addr_data0_mem); 3504 &bar0->rmac_addr_data0_mem);
3505 writeq(RMAC_ADDR_DATA1_MEM_MASK(0x0),
3506 &bar0->rmac_addr_data1_mem);
2952 val64 = RMAC_ADDR_CMD_MEM_WE | 3507 val64 = RMAC_ADDR_CMD_MEM_WE |
2953 RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | 3508 RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
2954 RMAC_ADDR_CMD_MEM_OFFSET(sp->all_multi_pos); 3509 RMAC_ADDR_CMD_MEM_OFFSET(sp->all_multi_pos);
@@ -3011,7 +3566,7 @@ static void s2io_set_multicast(struct net_device *dev)
3011 writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr), 3566 writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr),
3012 &bar0->rmac_addr_data0_mem); 3567 &bar0->rmac_addr_data0_mem);
3013 writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL), 3568 writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL),
3014 &bar0->rmac_addr_data1_mem); 3569 &bar0->rmac_addr_data1_mem);
3015 val64 = RMAC_ADDR_CMD_MEM_WE | 3570 val64 = RMAC_ADDR_CMD_MEM_WE |
3016 RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | 3571 RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3017 RMAC_ADDR_CMD_MEM_OFFSET 3572 RMAC_ADDR_CMD_MEM_OFFSET
@@ -3040,8 +3595,7 @@ static void s2io_set_multicast(struct net_device *dev)
3040 writeq(RMAC_ADDR_DATA0_MEM_ADDR(mac_addr), 3595 writeq(RMAC_ADDR_DATA0_MEM_ADDR(mac_addr),
3041 &bar0->rmac_addr_data0_mem); 3596 &bar0->rmac_addr_data0_mem);
3042 writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL), 3597 writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL),
3043 &bar0->rmac_addr_data1_mem); 3598 &bar0->rmac_addr_data1_mem);
3044
3045 val64 = RMAC_ADDR_CMD_MEM_WE | 3599 val64 = RMAC_ADDR_CMD_MEM_WE |
3046 RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | 3600 RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3047 RMAC_ADDR_CMD_MEM_OFFSET 3601 RMAC_ADDR_CMD_MEM_OFFSET
@@ -3060,12 +3614,12 @@ static void s2io_set_multicast(struct net_device *dev)
3060} 3614}
3061 3615
3062/** 3616/**
3063 * s2io_set_mac_addr - Programs the Xframe mac address 3617 * s2io_set_mac_addr - Programs the Xframe mac address
3064 * @dev : pointer to the device structure. 3618 * @dev : pointer to the device structure.
3065 * @addr: a uchar pointer to the new mac address which is to be set. 3619 * @addr: a uchar pointer to the new mac address which is to be set.
3066 * Description : This procedure will program the Xframe to receive 3620 * Description : This procedure will program the Xframe to receive
3067 * frames with new Mac Address 3621 * frames with new Mac Address
3068 * Return value: SUCCESS on success and an appropriate (-)ve integer 3622 * Return value: SUCCESS on success and an appropriate (-)ve integer
3069 * as defined in errno.h file on failure. 3623 * as defined in errno.h file on failure.
3070 */ 3624 */
3071 3625
@@ -3076,10 +3630,10 @@ int s2io_set_mac_addr(struct net_device *dev, u8 * addr)
3076 register u64 val64, mac_addr = 0; 3630 register u64 val64, mac_addr = 0;
3077 int i; 3631 int i;
3078 3632
3079 /* 3633 /*
3080 * Set the new MAC address as the new unicast filter and reflect this 3634 * Set the new MAC address as the new unicast filter and reflect this
3081 * change on the device address registered with the OS. It will be 3635 * change on the device address registered with the OS. It will be
3082 * at offset 0. 3636 * at offset 0.
3083 */ 3637 */
3084 for (i = 0; i < ETH_ALEN; i++) { 3638 for (i = 0; i < ETH_ALEN; i++) {
3085 mac_addr <<= 8; 3639 mac_addr <<= 8;
@@ -3103,12 +3657,12 @@ int s2io_set_mac_addr(struct net_device *dev, u8 * addr)
3103} 3657}
3104 3658
3105/** 3659/**
3106 * s2io_ethtool_sset - Sets different link parameters. 3660 * s2io_ethtool_sset - Sets different link parameters.
3107 * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. 3661 * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure.
3108 * @info: pointer to the structure with parameters given by ethtool to set 3662 * @info: pointer to the structure with parameters given by ethtool to set
3109 * link information. 3663 * link information.
3110 * Description: 3664 * Description:
3111 * The function sets different link parameters provided by the user onto 3665 * The function sets different link parameters provided by the user onto
3112 * the NIC. 3666 * the NIC.
3113 * Return value: 3667 * Return value:
3114 * 0 on success. 3668 * 0 on success.
@@ -3130,7 +3684,7 @@ static int s2io_ethtool_sset(struct net_device *dev,
3130} 3684}
3131 3685
3132/** 3686/**
3133 * s2io_ethtol_gset - Return link specific information. 3687 * s2io_ethtol_gset - Return link specific information.
3134 * @sp : private member of the device structure, pointer to the 3688 * @sp : private member of the device structure, pointer to the
3135 * s2io_nic structure. 3689 * s2io_nic structure.
3136 * @info : pointer to the structure with parameters given by ethtool 3690 * @info : pointer to the structure with parameters given by ethtool
@@ -3162,8 +3716,8 @@ static int s2io_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info)
3162} 3716}
3163 3717
3164/** 3718/**
3165 * s2io_ethtool_gdrvinfo - Returns driver specific information. 3719 * s2io_ethtool_gdrvinfo - Returns driver specific information.
3166 * @sp : private member of the device structure, which is a pointer to the 3720 * @sp : private member of the device structure, which is a pointer to the
3167 * s2io_nic structure. 3721 * s2io_nic structure.
3168 * @info : pointer to the structure with parameters given by ethtool to 3722 * @info : pointer to the structure with parameters given by ethtool to
3169 * return driver information. 3723 * return driver information.
@@ -3191,9 +3745,9 @@ static void s2io_ethtool_gdrvinfo(struct net_device *dev,
3191 3745
3192/** 3746/**
3193 * s2io_ethtool_gregs - dumps the entire space of Xfame into the buffer. 3747 * s2io_ethtool_gregs - dumps the entire space of Xfame into the buffer.
3194 * @sp: private member of the device structure, which is a pointer to the 3748 * @sp: private member of the device structure, which is a pointer to the
3195 * s2io_nic structure. 3749 * s2io_nic structure.
3196 * @regs : pointer to the structure with parameters given by ethtool for 3750 * @regs : pointer to the structure with parameters given by ethtool for
3197 * dumping the registers. 3751 * dumping the registers.
3198 * @reg_space: The input argumnet into which all the registers are dumped. 3752 * @reg_space: The input argumnet into which all the registers are dumped.
3199 * Description: 3753 * Description:
@@ -3222,11 +3776,11 @@ static void s2io_ethtool_gregs(struct net_device *dev,
3222 3776
3223/** 3777/**
3224 * s2io_phy_id - timer function that alternates adapter LED. 3778 * s2io_phy_id - timer function that alternates adapter LED.
3225 * @data : address of the private member of the device structure, which 3779 * @data : address of the private member of the device structure, which
3226 * is a pointer to the s2io_nic structure, provided as an u32. 3780 * is a pointer to the s2io_nic structure, provided as an u32.
3227 * Description: This is actually the timer function that alternates the 3781 * Description: This is actually the timer function that alternates the
3228 * adapter LED bit of the adapter control bit to set/reset every time on 3782 * adapter LED bit of the adapter control bit to set/reset every time on
3229 * invocation. The timer is set for 1/2 a second, hence tha NIC blinks 3783 * invocation. The timer is set for 1/2 a second, hence tha NIC blinks
3230 * once every second. 3784 * once every second.
3231*/ 3785*/
3232static void s2io_phy_id(unsigned long data) 3786static void s2io_phy_id(unsigned long data)
@@ -3237,7 +3791,8 @@ static void s2io_phy_id(unsigned long data)
3237 u16 subid; 3791 u16 subid;
3238 3792
3239 subid = sp->pdev->subsystem_device; 3793 subid = sp->pdev->subsystem_device;
3240 if ((subid & 0xFF) >= 0x07) { 3794 if ((sp->device_type == XFRAME_II_DEVICE) ||
3795 ((subid & 0xFF) >= 0x07)) {
3241 val64 = readq(&bar0->gpio_control); 3796 val64 = readq(&bar0->gpio_control);
3242 val64 ^= GPIO_CTRL_GPIO_0; 3797 val64 ^= GPIO_CTRL_GPIO_0;
3243 writeq(val64, &bar0->gpio_control); 3798 writeq(val64, &bar0->gpio_control);
@@ -3254,12 +3809,12 @@ static void s2io_phy_id(unsigned long data)
3254 * s2io_ethtool_idnic - To physically identify the nic on the system. 3809 * s2io_ethtool_idnic - To physically identify the nic on the system.
3255 * @sp : private member of the device structure, which is a pointer to the 3810 * @sp : private member of the device structure, which is a pointer to the
3256 * s2io_nic structure. 3811 * s2io_nic structure.
3257 * @id : pointer to the structure with identification parameters given by 3812 * @id : pointer to the structure with identification parameters given by
3258 * ethtool. 3813 * ethtool.
3259 * Description: Used to physically identify the NIC on the system. 3814 * Description: Used to physically identify the NIC on the system.
3260 * The Link LED will blink for a time specified by the user for 3815 * The Link LED will blink for a time specified by the user for
3261 * identification. 3816 * identification.
3262 * NOTE: The Link has to be Up to be able to blink the LED. Hence 3817 * NOTE: The Link has to be Up to be able to blink the LED. Hence
3263 * identification is possible only if it's link is up. 3818 * identification is possible only if it's link is up.
3264 * Return value: 3819 * Return value:
3265 * int , returns 0 on success 3820 * int , returns 0 on success
@@ -3274,7 +3829,8 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data)
3274 3829
3275 subid = sp->pdev->subsystem_device; 3830 subid = sp->pdev->subsystem_device;
3276 last_gpio_ctrl_val = readq(&bar0->gpio_control); 3831 last_gpio_ctrl_val = readq(&bar0->gpio_control);
3277 if ((subid & 0xFF) < 0x07) { 3832 if ((sp->device_type == XFRAME_I_DEVICE) &&
3833 ((subid & 0xFF) < 0x07)) {
3278 val64 = readq(&bar0->adapter_control); 3834 val64 = readq(&bar0->adapter_control);
3279 if (!(val64 & ADAPTER_CNTL_EN)) { 3835 if (!(val64 & ADAPTER_CNTL_EN)) {
3280 printk(KERN_ERR 3836 printk(KERN_ERR
@@ -3289,12 +3845,12 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data)
3289 } 3845 }
3290 mod_timer(&sp->id_timer, jiffies); 3846 mod_timer(&sp->id_timer, jiffies);
3291 if (data) 3847 if (data)
3292 msleep(data * 1000); 3848 msleep_interruptible(data * HZ);
3293 else 3849 else
3294 msleep(0xFFFFFFFF); 3850 msleep_interruptible(MAX_FLICKER_TIME);
3295 del_timer_sync(&sp->id_timer); 3851 del_timer_sync(&sp->id_timer);
3296 3852
3297 if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) { 3853 if (CARDS_WITH_FAULTY_LINK_INDICATORS(sp->device_type, subid)) {
3298 writeq(last_gpio_ctrl_val, &bar0->gpio_control); 3854 writeq(last_gpio_ctrl_val, &bar0->gpio_control);
3299 last_gpio_ctrl_val = readq(&bar0->gpio_control); 3855 last_gpio_ctrl_val = readq(&bar0->gpio_control);
3300 } 3856 }
@@ -3304,7 +3860,8 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data)
3304 3860
3305/** 3861/**
3306 * s2io_ethtool_getpause_data -Pause frame frame generation and reception. 3862 * s2io_ethtool_getpause_data -Pause frame frame generation and reception.
3307 * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. 3863 * @sp : private member of the device structure, which is a pointer to the
3864 * s2io_nic structure.
3308 * @ep : pointer to the structure with pause parameters given by ethtool. 3865 * @ep : pointer to the structure with pause parameters given by ethtool.
3309 * Description: 3866 * Description:
3310 * Returns the Pause frame generation and reception capability of the NIC. 3867 * Returns the Pause frame generation and reception capability of the NIC.
@@ -3328,7 +3885,7 @@ static void s2io_ethtool_getpause_data(struct net_device *dev,
3328 3885
3329/** 3886/**
3330 * s2io_ethtool_setpause_data - set/reset pause frame generation. 3887 * s2io_ethtool_setpause_data - set/reset pause frame generation.
3331 * @sp : private member of the device structure, which is a pointer to the 3888 * @sp : private member of the device structure, which is a pointer to the
3332 * s2io_nic structure. 3889 * s2io_nic structure.
3333 * @ep : pointer to the structure with pause parameters given by ethtool. 3890 * @ep : pointer to the structure with pause parameters given by ethtool.
3334 * Description: 3891 * Description:
@@ -3339,7 +3896,7 @@ static void s2io_ethtool_getpause_data(struct net_device *dev,
3339 */ 3896 */
3340 3897
3341static int s2io_ethtool_setpause_data(struct net_device *dev, 3898static int s2io_ethtool_setpause_data(struct net_device *dev,
3342 struct ethtool_pauseparam *ep) 3899 struct ethtool_pauseparam *ep)
3343{ 3900{
3344 u64 val64; 3901 u64 val64;
3345 nic_t *sp = dev->priv; 3902 nic_t *sp = dev->priv;
@@ -3360,13 +3917,13 @@ static int s2io_ethtool_setpause_data(struct net_device *dev,
3360 3917
3361/** 3918/**
3362 * read_eeprom - reads 4 bytes of data from user given offset. 3919 * read_eeprom - reads 4 bytes of data from user given offset.
3363 * @sp : private member of the device structure, which is a pointer to the 3920 * @sp : private member of the device structure, which is a pointer to the
3364 * s2io_nic structure. 3921 * s2io_nic structure.
3365 * @off : offset at which the data must be written 3922 * @off : offset at which the data must be written
3366 * @data : Its an output parameter where the data read at the given 3923 * @data : Its an output parameter where the data read at the given
3367 * offset is stored. 3924 * offset is stored.
3368 * Description: 3925 * Description:
3369 * Will read 4 bytes of data from the user given offset and return the 3926 * Will read 4 bytes of data from the user given offset and return the
3370 * read data. 3927 * read data.
3371 * NOTE: Will allow to read only part of the EEPROM visible through the 3928 * NOTE: Will allow to read only part of the EEPROM visible through the
3372 * I2C bus. 3929 * I2C bus.
@@ -3407,7 +3964,7 @@ static int read_eeprom(nic_t * sp, int off, u32 * data)
3407 * s2io_nic structure. 3964 * s2io_nic structure.
3408 * @off : offset at which the data must be written 3965 * @off : offset at which the data must be written
3409 * @data : The data that is to be written 3966 * @data : The data that is to be written
3410 * @cnt : Number of bytes of the data that are actually to be written into 3967 * @cnt : Number of bytes of the data that are actually to be written into
3411 * the Eeprom. (max of 3) 3968 * the Eeprom. (max of 3)
3412 * Description: 3969 * Description:
3413 * Actually writes the relevant part of the data value into the Eeprom 3970 * Actually writes the relevant part of the data value into the Eeprom
@@ -3444,7 +4001,7 @@ static int write_eeprom(nic_t * sp, int off, u32 data, int cnt)
3444/** 4001/**
3445 * s2io_ethtool_geeprom - reads the value stored in the Eeprom. 4002 * s2io_ethtool_geeprom - reads the value stored in the Eeprom.
3446 * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. 4003 * @sp : private member of the device structure, which is a pointer to the * s2io_nic structure.
3447 * @eeprom : pointer to the user level structure provided by ethtool, 4004 * @eeprom : pointer to the user level structure provided by ethtool,
3448 * containing all relevant information. 4005 * containing all relevant information.
3449 * @data_buf : user defined value to be written into Eeprom. 4006 * @data_buf : user defined value to be written into Eeprom.
3450 * Description: Reads the values stored in the Eeprom at given offset 4007 * Description: Reads the values stored in the Eeprom at given offset
@@ -3455,7 +4012,7 @@ static int write_eeprom(nic_t * sp, int off, u32 data, int cnt)
3455 */ 4012 */
3456 4013
3457static int s2io_ethtool_geeprom(struct net_device *dev, 4014static int s2io_ethtool_geeprom(struct net_device *dev,
3458 struct ethtool_eeprom *eeprom, u8 * data_buf) 4015 struct ethtool_eeprom *eeprom, u8 * data_buf)
3459{ 4016{
3460 u32 data, i, valid; 4017 u32 data, i, valid;
3461 nic_t *sp = dev->priv; 4018 nic_t *sp = dev->priv;
@@ -3480,7 +4037,7 @@ static int s2io_ethtool_geeprom(struct net_device *dev,
3480 * s2io_ethtool_seeprom - tries to write the user provided value in Eeprom 4037 * s2io_ethtool_seeprom - tries to write the user provided value in Eeprom
3481 * @sp : private member of the device structure, which is a pointer to the 4038 * @sp : private member of the device structure, which is a pointer to the
3482 * s2io_nic structure. 4039 * s2io_nic structure.
3483 * @eeprom : pointer to the user level structure provided by ethtool, 4040 * @eeprom : pointer to the user level structure provided by ethtool,
3484 * containing all relevant information. 4041 * containing all relevant information.
3485 * @data_buf ; user defined value to be written into Eeprom. 4042 * @data_buf ; user defined value to be written into Eeprom.
3486 * Description: 4043 * Description:
@@ -3528,8 +4085,8 @@ static int s2io_ethtool_seeprom(struct net_device *dev,
3528} 4085}
3529 4086
3530/** 4087/**
3531 * s2io_register_test - reads and writes into all clock domains. 4088 * s2io_register_test - reads and writes into all clock domains.
3532 * @sp : private member of the device structure, which is a pointer to the 4089 * @sp : private member of the device structure, which is a pointer to the
3533 * s2io_nic structure. 4090 * s2io_nic structure.
3534 * @data : variable that returns the result of each of the test conducted b 4091 * @data : variable that returns the result of each of the test conducted b
3535 * by the driver. 4092 * by the driver.
@@ -3546,8 +4103,8 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
3546 u64 val64 = 0; 4103 u64 val64 = 0;
3547 int fail = 0; 4104 int fail = 0;
3548 4105
3549 val64 = readq(&bar0->pcc_enable); 4106 val64 = readq(&bar0->pif_rd_swapper_fb);
3550 if (val64 != 0xff00000000000000ULL) { 4107 if (val64 != 0x123456789abcdefULL) {
3551 fail = 1; 4108 fail = 1;
3552 DBG_PRINT(INFO_DBG, "Read Test level 1 fails\n"); 4109 DBG_PRINT(INFO_DBG, "Read Test level 1 fails\n");
3553 } 4110 }
@@ -3591,13 +4148,13 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
3591} 4148}
3592 4149
3593/** 4150/**
3594 * s2io_eeprom_test - to verify that EEprom in the xena can be programmed. 4151 * s2io_eeprom_test - to verify that EEprom in the xena can be programmed.
3595 * @sp : private member of the device structure, which is a pointer to the 4152 * @sp : private member of the device structure, which is a pointer to the
3596 * s2io_nic structure. 4153 * s2io_nic structure.
3597 * @data:variable that returns the result of each of the test conducted by 4154 * @data:variable that returns the result of each of the test conducted by
3598 * the driver. 4155 * the driver.
3599 * Description: 4156 * Description:
3600 * Verify that EEPROM in the xena can be programmed using I2C_CONTROL 4157 * Verify that EEPROM in the xena can be programmed using I2C_CONTROL
3601 * register. 4158 * register.
3602 * Return value: 4159 * Return value:
3603 * 0 on success. 4160 * 0 on success.
@@ -3662,14 +4219,14 @@ static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
3662 4219
3663/** 4220/**
3664 * s2io_bist_test - invokes the MemBist test of the card . 4221 * s2io_bist_test - invokes the MemBist test of the card .
3665 * @sp : private member of the device structure, which is a pointer to the 4222 * @sp : private member of the device structure, which is a pointer to the
3666 * s2io_nic structure. 4223 * s2io_nic structure.
3667 * @data:variable that returns the result of each of the test conducted by 4224 * @data:variable that returns the result of each of the test conducted by
3668 * the driver. 4225 * the driver.
3669 * Description: 4226 * Description:
3670 * This invokes the MemBist test of the card. We give around 4227 * This invokes the MemBist test of the card. We give around
3671 * 2 secs time for the Test to complete. If it's still not complete 4228 * 2 secs time for the Test to complete. If it's still not complete
3672 * within this peiod, we consider that the test failed. 4229 * within this peiod, we consider that the test failed.
3673 * Return value: 4230 * Return value:
3674 * 0 on success and -1 on failure. 4231 * 0 on success and -1 on failure.
3675 */ 4232 */
@@ -3698,13 +4255,13 @@ static int s2io_bist_test(nic_t * sp, uint64_t * data)
3698} 4255}
3699 4256
3700/** 4257/**
3701 * s2io-link_test - verifies the link state of the nic 4258 * s2io-link_test - verifies the link state of the nic
3702 * @sp ; private member of the device structure, which is a pointer to the 4259 * @sp ; private member of the device structure, which is a pointer to the
3703 * s2io_nic structure. 4260 * s2io_nic structure.
3704 * @data: variable that returns the result of each of the test conducted by 4261 * @data: variable that returns the result of each of the test conducted by
3705 * the driver. 4262 * the driver.
3706 * Description: 4263 * Description:
3707 * The function verifies the link state of the NIC and updates the input 4264 * The function verifies the link state of the NIC and updates the input
3708 * argument 'data' appropriately. 4265 * argument 'data' appropriately.
3709 * Return value: 4266 * Return value:
3710 * 0 on success. 4267 * 0 on success.
@@ -3723,13 +4280,13 @@ static int s2io_link_test(nic_t * sp, uint64_t * data)
3723} 4280}
3724 4281
3725/** 4282/**
3726 * s2io_rldram_test - offline test for access to the RldRam chip on the NIC 4283 * s2io_rldram_test - offline test for access to the RldRam chip on the NIC
3727 * @sp - private member of the device structure, which is a pointer to the 4284 * @sp - private member of the device structure, which is a pointer to the
3728 * s2io_nic structure. 4285 * s2io_nic structure.
3729 * @data - variable that returns the result of each of the test 4286 * @data - variable that returns the result of each of the test
3730 * conducted by the driver. 4287 * conducted by the driver.
3731 * Description: 4288 * Description:
3732 * This is one of the offline test that tests the read and write 4289 * This is one of the offline test that tests the read and write
3733 * access to the RldRam chip on the NIC. 4290 * access to the RldRam chip on the NIC.
3734 * Return value: 4291 * Return value:
3735 * 0 on success. 4292 * 0 on success.
@@ -3834,7 +4391,7 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
3834 * s2io_nic structure. 4391 * s2io_nic structure.
3835 * @ethtest : pointer to a ethtool command specific structure that will be 4392 * @ethtest : pointer to a ethtool command specific structure that will be
3836 * returned to the user. 4393 * returned to the user.
3837 * @data : variable that returns the result of each of the test 4394 * @data : variable that returns the result of each of the test
3838 * conducted by the driver. 4395 * conducted by the driver.
3839 * Description: 4396 * Description:
3840 * This function conducts 6 tests ( 4 offline and 2 online) to determine 4397 * This function conducts 6 tests ( 4 offline and 2 online) to determine
@@ -3852,23 +4409,18 @@ static void s2io_ethtool_test(struct net_device *dev,
3852 4409
3853 if (ethtest->flags == ETH_TEST_FL_OFFLINE) { 4410 if (ethtest->flags == ETH_TEST_FL_OFFLINE) {
3854 /* Offline Tests. */ 4411 /* Offline Tests. */
3855 if (orig_state) { 4412 if (orig_state)
3856 s2io_close(sp->dev); 4413 s2io_close(sp->dev);
3857 s2io_set_swapper(sp);
3858 } else
3859 s2io_set_swapper(sp);
3860 4414
3861 if (s2io_register_test(sp, &data[0])) 4415 if (s2io_register_test(sp, &data[0]))
3862 ethtest->flags |= ETH_TEST_FL_FAILED; 4416 ethtest->flags |= ETH_TEST_FL_FAILED;
3863 4417
3864 s2io_reset(sp); 4418 s2io_reset(sp);
3865 s2io_set_swapper(sp);
3866 4419
3867 if (s2io_rldram_test(sp, &data[3])) 4420 if (s2io_rldram_test(sp, &data[3]))
3868 ethtest->flags |= ETH_TEST_FL_FAILED; 4421 ethtest->flags |= ETH_TEST_FL_FAILED;
3869 4422
3870 s2io_reset(sp); 4423 s2io_reset(sp);
3871 s2io_set_swapper(sp);
3872 4424
3873 if (s2io_eeprom_test(sp, &data[1])) 4425 if (s2io_eeprom_test(sp, &data[1]))
3874 ethtest->flags |= ETH_TEST_FL_FAILED; 4426 ethtest->flags |= ETH_TEST_FL_FAILED;
@@ -3911,61 +4463,111 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
3911 nic_t *sp = dev->priv; 4463 nic_t *sp = dev->priv;
3912 StatInfo_t *stat_info = sp->mac_control.stats_info; 4464 StatInfo_t *stat_info = sp->mac_control.stats_info;
3913 4465
3914 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_frms); 4466 s2io_updt_stats(sp);
3915 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_data_octets); 4467 tmp_stats[i++] =
4468 (u64)le32_to_cpu(stat_info->tmac_frms_oflow) << 32 |
4469 le32_to_cpu(stat_info->tmac_frms);
4470 tmp_stats[i++] =
4471 (u64)le32_to_cpu(stat_info->tmac_data_octets_oflow) << 32 |
4472 le32_to_cpu(stat_info->tmac_data_octets);
3916 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_drop_frms); 4473 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_drop_frms);
3917 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_mcst_frms); 4474 tmp_stats[i++] =
3918 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_bcst_frms); 4475 (u64)le32_to_cpu(stat_info->tmac_mcst_frms_oflow) << 32 |
4476 le32_to_cpu(stat_info->tmac_mcst_frms);
4477 tmp_stats[i++] =
4478 (u64)le32_to_cpu(stat_info->tmac_bcst_frms_oflow) << 32 |
4479 le32_to_cpu(stat_info->tmac_bcst_frms);
3919 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_pause_ctrl_frms); 4480 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_pause_ctrl_frms);
3920 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_any_err_frms); 4481 tmp_stats[i++] =
4482 (u64)le32_to_cpu(stat_info->tmac_any_err_frms_oflow) << 32 |
4483 le32_to_cpu(stat_info->tmac_any_err_frms);
3921 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_vld_ip_octets); 4484 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_vld_ip_octets);
3922 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_vld_ip); 4485 tmp_stats[i++] =
3923 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_drop_ip); 4486 (u64)le32_to_cpu(stat_info->tmac_vld_ip_oflow) << 32 |
3924 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_icmp); 4487 le32_to_cpu(stat_info->tmac_vld_ip);
3925 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_rst_tcp); 4488 tmp_stats[i++] =
4489 (u64)le32_to_cpu(stat_info->tmac_drop_ip_oflow) << 32 |
4490 le32_to_cpu(stat_info->tmac_drop_ip);
4491 tmp_stats[i++] =
4492 (u64)le32_to_cpu(stat_info->tmac_icmp_oflow) << 32 |
4493 le32_to_cpu(stat_info->tmac_icmp);
4494 tmp_stats[i++] =
4495 (u64)le32_to_cpu(stat_info->tmac_rst_tcp_oflow) << 32 |
4496 le32_to_cpu(stat_info->tmac_rst_tcp);
3926 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_tcp); 4497 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_tcp);
3927 tmp_stats[i++] = le32_to_cpu(stat_info->tmac_udp); 4498 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->tmac_udp_oflow) << 32 |
3928 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_vld_frms); 4499 le32_to_cpu(stat_info->tmac_udp);
3929 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_data_octets); 4500 tmp_stats[i++] =
4501 (u64)le32_to_cpu(stat_info->rmac_vld_frms_oflow) << 32 |
4502 le32_to_cpu(stat_info->rmac_vld_frms);
4503 tmp_stats[i++] =
4504 (u64)le32_to_cpu(stat_info->rmac_data_octets_oflow) << 32 |
4505 le32_to_cpu(stat_info->rmac_data_octets);
3930 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_fcs_err_frms); 4506 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_fcs_err_frms);
3931 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_drop_frms); 4507 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_drop_frms);
3932 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_vld_mcst_frms); 4508 tmp_stats[i++] =
3933 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_vld_bcst_frms); 4509 (u64)le32_to_cpu(stat_info->rmac_vld_mcst_frms_oflow) << 32 |
4510 le32_to_cpu(stat_info->rmac_vld_mcst_frms);
4511 tmp_stats[i++] =
4512 (u64)le32_to_cpu(stat_info->rmac_vld_bcst_frms_oflow) << 32 |
4513 le32_to_cpu(stat_info->rmac_vld_bcst_frms);
3934 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_in_rng_len_err_frms); 4514 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_in_rng_len_err_frms);
3935 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_long_frms); 4515 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_long_frms);
3936 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_pause_ctrl_frms); 4516 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_pause_ctrl_frms);
3937 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_discarded_frms); 4517 tmp_stats[i++] =
3938 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_usized_frms); 4518 (u64)le32_to_cpu(stat_info->rmac_discarded_frms_oflow) << 32 |
3939 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_osized_frms); 4519 le32_to_cpu(stat_info->rmac_discarded_frms);
3940 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_frag_frms); 4520 tmp_stats[i++] =
3941 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_jabber_frms); 4521 (u64)le32_to_cpu(stat_info->rmac_usized_frms_oflow) << 32 |
3942 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_ip); 4522 le32_to_cpu(stat_info->rmac_usized_frms);
4523 tmp_stats[i++] =
4524 (u64)le32_to_cpu(stat_info->rmac_osized_frms_oflow) << 32 |
4525 le32_to_cpu(stat_info->rmac_osized_frms);
4526 tmp_stats[i++] =
4527 (u64)le32_to_cpu(stat_info->rmac_frag_frms_oflow) << 32 |
4528 le32_to_cpu(stat_info->rmac_frag_frms);
4529 tmp_stats[i++] =
4530 (u64)le32_to_cpu(stat_info->rmac_jabber_frms_oflow) << 32 |
4531 le32_to_cpu(stat_info->rmac_jabber_frms);
4532 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_ip_oflow) << 32 |
4533 le32_to_cpu(stat_info->rmac_ip);
3943 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ip_octets); 4534 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ip_octets);
3944 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_hdr_err_ip); 4535 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_hdr_err_ip);
3945 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_drop_ip); 4536 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_drop_ip_oflow) << 32 |
3946 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_icmp); 4537 le32_to_cpu(stat_info->rmac_drop_ip);
4538 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_icmp_oflow) << 32 |
4539 le32_to_cpu(stat_info->rmac_icmp);
3947 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_tcp); 4540 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_tcp);
3948 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_udp); 4541 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_udp_oflow) << 32 |
3949 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_err_drp_udp); 4542 le32_to_cpu(stat_info->rmac_udp);
3950 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_pause_cnt); 4543 tmp_stats[i++] =
3951 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_accepted_ip); 4544 (u64)le32_to_cpu(stat_info->rmac_err_drp_udp_oflow) << 32 |
4545 le32_to_cpu(stat_info->rmac_err_drp_udp);
4546 tmp_stats[i++] =
4547 (u64)le32_to_cpu(stat_info->rmac_pause_cnt_oflow) << 32 |
4548 le32_to_cpu(stat_info->rmac_pause_cnt);
4549 tmp_stats[i++] =
4550 (u64)le32_to_cpu(stat_info->rmac_accepted_ip_oflow) << 32 |
4551 le32_to_cpu(stat_info->rmac_accepted_ip);
3952 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_err_tcp); 4552 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_err_tcp);
4553 tmp_stats[i++] = 0;
4554 tmp_stats[i++] = stat_info->sw_stat.single_ecc_errs;
4555 tmp_stats[i++] = stat_info->sw_stat.double_ecc_errs;
3953} 4556}
3954 4557
3955static int s2io_ethtool_get_regs_len(struct net_device *dev) 4558int s2io_ethtool_get_regs_len(struct net_device *dev)
3956{ 4559{
3957 return (XENA_REG_SPACE); 4560 return (XENA_REG_SPACE);
3958} 4561}
3959 4562
3960 4563
3961static u32 s2io_ethtool_get_rx_csum(struct net_device * dev) 4564u32 s2io_ethtool_get_rx_csum(struct net_device * dev)
3962{ 4565{
3963 nic_t *sp = dev->priv; 4566 nic_t *sp = dev->priv;
3964 4567
3965 return (sp->rx_csum); 4568 return (sp->rx_csum);
3966} 4569}
3967 4570int s2io_ethtool_set_rx_csum(struct net_device *dev, u32 data)
3968static int s2io_ethtool_set_rx_csum(struct net_device *dev, u32 data)
3969{ 4571{
3970 nic_t *sp = dev->priv; 4572 nic_t *sp = dev->priv;
3971 4573
@@ -3976,19 +4578,17 @@ static int s2io_ethtool_set_rx_csum(struct net_device *dev, u32 data)
3976 4578
3977 return 0; 4579 return 0;
3978} 4580}
3979 4581int s2io_get_eeprom_len(struct net_device *dev)
3980static int s2io_get_eeprom_len(struct net_device *dev)
3981{ 4582{
3982 return (XENA_EEPROM_SPACE); 4583 return (XENA_EEPROM_SPACE);
3983} 4584}
3984 4585
3985static int s2io_ethtool_self_test_count(struct net_device *dev) 4586int s2io_ethtool_self_test_count(struct net_device *dev)
3986{ 4587{
3987 return (S2IO_TEST_LEN); 4588 return (S2IO_TEST_LEN);
3988} 4589}
3989 4590void s2io_ethtool_get_strings(struct net_device *dev,
3990static void s2io_ethtool_get_strings(struct net_device *dev, 4591 u32 stringset, u8 * data)
3991 u32 stringset, u8 * data)
3992{ 4592{
3993 switch (stringset) { 4593 switch (stringset) {
3994 case ETH_SS_TEST: 4594 case ETH_SS_TEST:
@@ -3999,13 +4599,12 @@ static void s2io_ethtool_get_strings(struct net_device *dev,
3999 sizeof(ethtool_stats_keys)); 4599 sizeof(ethtool_stats_keys));
4000 } 4600 }
4001} 4601}
4002
4003static int s2io_ethtool_get_stats_count(struct net_device *dev) 4602static int s2io_ethtool_get_stats_count(struct net_device *dev)
4004{ 4603{
4005 return (S2IO_STAT_LEN); 4604 return (S2IO_STAT_LEN);
4006} 4605}
4007 4606
4008static int s2io_ethtool_op_set_tx_csum(struct net_device *dev, u32 data) 4607int s2io_ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
4009{ 4608{
4010 if (data) 4609 if (data)
4011 dev->features |= NETIF_F_IP_CSUM; 4610 dev->features |= NETIF_F_IP_CSUM;
@@ -4047,21 +4646,18 @@ static struct ethtool_ops netdev_ethtool_ops = {
4047}; 4646};
4048 4647
4049/** 4648/**
4050 * s2io_ioctl - Entry point for the Ioctl 4649 * s2io_ioctl - Entry point for the Ioctl
4051 * @dev : Device pointer. 4650 * @dev : Device pointer.
4052 * @ifr : An IOCTL specefic structure, that can contain a pointer to 4651 * @ifr : An IOCTL specefic structure, that can contain a pointer to
4053 * a proprietary structure used to pass information to the driver. 4652 * a proprietary structure used to pass information to the driver.
4054 * @cmd : This is used to distinguish between the different commands that 4653 * @cmd : This is used to distinguish between the different commands that
4055 * can be passed to the IOCTL functions. 4654 * can be passed to the IOCTL functions.
4056 * Description: 4655 * Description:
4057 * This function has support for ethtool, adding multiple MAC addresses on 4656 * Currently there are no special functionality supported in IOCTL, hence
4058 * the NIC and some DBG commands for the util tool. 4657 * function always return EOPNOTSUPPORTED
4059 * Return value:
4060 * Currently the IOCTL supports no operations, hence by default this
4061 * function returns OP NOT SUPPORTED value.
4062 */ 4658 */
4063 4659
4064static int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 4660int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
4065{ 4661{
4066 return -EOPNOTSUPP; 4662 return -EOPNOTSUPP;
4067} 4663}
@@ -4077,17 +4673,9 @@ static int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
4077 * file on failure. 4673 * file on failure.
4078 */ 4674 */
4079 4675
4080static int s2io_change_mtu(struct net_device *dev, int new_mtu) 4676int s2io_change_mtu(struct net_device *dev, int new_mtu)
4081{ 4677{
4082 nic_t *sp = dev->priv; 4678 nic_t *sp = dev->priv;
4083 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4084 register u64 val64;
4085
4086 if (netif_running(dev)) {
4087 DBG_PRINT(ERR_DBG, "%s: Must be stopped to ", dev->name);
4088 DBG_PRINT(ERR_DBG, "change its MTU \n");
4089 return -EBUSY;
4090 }
4091 4679
4092 if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) { 4680 if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) {
4093 DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n", 4681 DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n",
@@ -4095,11 +4683,22 @@ static int s2io_change_mtu(struct net_device *dev, int new_mtu)
4095 return -EPERM; 4683 return -EPERM;
4096 } 4684 }
4097 4685
4098 /* Set the new MTU into the PYLD register of the NIC */
4099 val64 = new_mtu;
4100 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
4101
4102 dev->mtu = new_mtu; 4686 dev->mtu = new_mtu;
4687 if (netif_running(dev)) {
4688 s2io_card_down(sp);
4689 netif_stop_queue(dev);
4690 if (s2io_card_up(sp)) {
4691 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",
4692 __FUNCTION__);
4693 }
4694 if (netif_queue_stopped(dev))
4695 netif_wake_queue(dev);
4696 } else { /* Device is down */
4697 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4698 u64 val64 = new_mtu;
4699
4700 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
4701 }
4103 4702
4104 return 0; 4703 return 0;
4105} 4704}
@@ -4109,9 +4708,9 @@ static int s2io_change_mtu(struct net_device *dev, int new_mtu)
4109 * @dev_adr : address of the device structure in dma_addr_t format. 4708 * @dev_adr : address of the device structure in dma_addr_t format.
4110 * Description: 4709 * Description:
4111 * This is the tasklet or the bottom half of the ISR. This is 4710 * This is the tasklet or the bottom half of the ISR. This is
4112 * an extension of the ISR which is scheduled by the scheduler to be run 4711 * an extension of the ISR which is scheduled by the scheduler to be run
4113 * when the load on the CPU is low. All low priority tasks of the ISR can 4712 * when the load on the CPU is low. All low priority tasks of the ISR can
4114 * be pushed into the tasklet. For now the tasklet is used only to 4713 * be pushed into the tasklet. For now the tasklet is used only to
4115 * replenish the Rx buffers in the Rx buffer descriptors. 4714 * replenish the Rx buffers in the Rx buffer descriptors.
4116 * Return value: 4715 * Return value:
4117 * void. 4716 * void.
@@ -4167,19 +4766,22 @@ static void s2io_set_link(unsigned long data)
4167 } 4766 }
4168 4767
4169 subid = nic->pdev->subsystem_device; 4768 subid = nic->pdev->subsystem_device;
4170 /* 4769 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) {
4171 * Allow a small delay for the NICs self initiated 4770 /*
4172 * cleanup to complete. 4771 * Allow a small delay for the NICs self initiated
4173 */ 4772 * cleanup to complete.
4174 msleep(100); 4773 */
4774 msleep(100);
4775 }
4175 4776
4176 val64 = readq(&bar0->adapter_status); 4777 val64 = readq(&bar0->adapter_status);
4177 if (verify_xena_quiescence(val64, nic->device_enabled_once)) { 4778 if (verify_xena_quiescence(nic, val64, nic->device_enabled_once)) {
4178 if (LINK_IS_UP(val64)) { 4779 if (LINK_IS_UP(val64)) {
4179 val64 = readq(&bar0->adapter_control); 4780 val64 = readq(&bar0->adapter_control);
4180 val64 |= ADAPTER_CNTL_EN; 4781 val64 |= ADAPTER_CNTL_EN;
4181 writeq(val64, &bar0->adapter_control); 4782 writeq(val64, &bar0->adapter_control);
4182 if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) { 4783 if (CARDS_WITH_FAULTY_LINK_INDICATORS(nic->device_type,
4784 subid)) {
4183 val64 = readq(&bar0->gpio_control); 4785 val64 = readq(&bar0->gpio_control);
4184 val64 |= GPIO_CTRL_GPIO_0; 4786 val64 |= GPIO_CTRL_GPIO_0;
4185 writeq(val64, &bar0->gpio_control); 4787 writeq(val64, &bar0->gpio_control);
@@ -4188,20 +4790,24 @@ static void s2io_set_link(unsigned long data)
4188 val64 |= ADAPTER_LED_ON; 4790 val64 |= ADAPTER_LED_ON;
4189 writeq(val64, &bar0->adapter_control); 4791 writeq(val64, &bar0->adapter_control);
4190 } 4792 }
4191 val64 = readq(&bar0->adapter_status); 4793 if (s2io_link_fault_indication(nic) ==
4192 if (!LINK_IS_UP(val64)) { 4794 MAC_RMAC_ERR_TIMER) {
4193 DBG_PRINT(ERR_DBG, "%s:", dev->name); 4795 val64 = readq(&bar0->adapter_status);
4194 DBG_PRINT(ERR_DBG, " Link down"); 4796 if (!LINK_IS_UP(val64)) {
4195 DBG_PRINT(ERR_DBG, "after "); 4797 DBG_PRINT(ERR_DBG, "%s:", dev->name);
4196 DBG_PRINT(ERR_DBG, "enabling "); 4798 DBG_PRINT(ERR_DBG, " Link down");
4197 DBG_PRINT(ERR_DBG, "device \n"); 4799 DBG_PRINT(ERR_DBG, "after ");
4800 DBG_PRINT(ERR_DBG, "enabling ");
4801 DBG_PRINT(ERR_DBG, "device \n");
4802 }
4198 } 4803 }
4199 if (nic->device_enabled_once == FALSE) { 4804 if (nic->device_enabled_once == FALSE) {
4200 nic->device_enabled_once = TRUE; 4805 nic->device_enabled_once = TRUE;
4201 } 4806 }
4202 s2io_link(nic, LINK_UP); 4807 s2io_link(nic, LINK_UP);
4203 } else { 4808 } else {
4204 if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) { 4809 if (CARDS_WITH_FAULTY_LINK_INDICATORS(nic->device_type,
4810 subid)) {
4205 val64 = readq(&bar0->gpio_control); 4811 val64 = readq(&bar0->gpio_control);
4206 val64 &= ~GPIO_CTRL_GPIO_0; 4812 val64 &= ~GPIO_CTRL_GPIO_0;
4207 writeq(val64, &bar0->gpio_control); 4813 writeq(val64, &bar0->gpio_control);
@@ -4224,9 +4830,11 @@ static void s2io_card_down(nic_t * sp)
4224 unsigned long flags; 4830 unsigned long flags;
4225 register u64 val64 = 0; 4831 register u64 val64 = 0;
4226 4832
4833 del_timer_sync(&sp->alarm_timer);
4227 /* If s2io_set_link task is executing, wait till it completes. */ 4834 /* If s2io_set_link task is executing, wait till it completes. */
4228 while (test_and_set_bit(0, &(sp->link_state))) 4835 while (test_and_set_bit(0, &(sp->link_state))) {
4229 msleep(50); 4836 msleep(50);
4837 }
4230 atomic_set(&sp->card_state, CARD_DOWN); 4838 atomic_set(&sp->card_state, CARD_DOWN);
4231 4839
4232 /* disable Tx and Rx traffic on the NIC */ 4840 /* disable Tx and Rx traffic on the NIC */
@@ -4238,7 +4846,7 @@ static void s2io_card_down(nic_t * sp)
4238 /* Check if the device is Quiescent and then Reset the NIC */ 4846 /* Check if the device is Quiescent and then Reset the NIC */
4239 do { 4847 do {
4240 val64 = readq(&bar0->adapter_status); 4848 val64 = readq(&bar0->adapter_status);
4241 if (verify_xena_quiescence(val64, sp->device_enabled_once)) { 4849 if (verify_xena_quiescence(sp, val64, sp->device_enabled_once)) {
4242 break; 4850 break;
4243 } 4851 }
4244 4852
@@ -4252,14 +4860,27 @@ static void s2io_card_down(nic_t * sp)
4252 break; 4860 break;
4253 } 4861 }
4254 } while (1); 4862 } while (1);
4255 spin_lock_irqsave(&sp->tx_lock, flags);
4256 s2io_reset(sp); 4863 s2io_reset(sp);
4257 4864
4258 /* Free all unused Tx and Rx buffers */ 4865 /* Waiting till all Interrupt handlers are complete */
4866 cnt = 0;
4867 do {
4868 msleep(10);
4869 if (!atomic_read(&sp->isr_cnt))
4870 break;
4871 cnt++;
4872 } while(cnt < 5);
4873
4874 spin_lock_irqsave(&sp->tx_lock, flags);
4875 /* Free all Tx buffers */
4259 free_tx_buffers(sp); 4876 free_tx_buffers(sp);
4877 spin_unlock_irqrestore(&sp->tx_lock, flags);
4878
4879 /* Free all Rx buffers */
4880 spin_lock_irqsave(&sp->rx_lock, flags);
4260 free_rx_buffers(sp); 4881 free_rx_buffers(sp);
4882 spin_unlock_irqrestore(&sp->rx_lock, flags);
4261 4883
4262 spin_unlock_irqrestore(&sp->tx_lock, flags);
4263 clear_bit(0, &(sp->link_state)); 4884 clear_bit(0, &(sp->link_state));
4264} 4885}
4265 4886
@@ -4277,8 +4898,8 @@ static int s2io_card_up(nic_t * sp)
4277 return -ENODEV; 4898 return -ENODEV;
4278 } 4899 }
4279 4900
4280 /* 4901 /*
4281 * Initializing the Rx buffers. For now we are considering only 1 4902 * Initializing the Rx buffers. For now we are considering only 1
4282 * Rx ring and initializing buffers into 30 Rx blocks 4903 * Rx ring and initializing buffers into 30 Rx blocks
4283 */ 4904 */
4284 mac_control = &sp->mac_control; 4905 mac_control = &sp->mac_control;
@@ -4312,16 +4933,18 @@ static int s2io_card_up(nic_t * sp)
4312 return -ENODEV; 4933 return -ENODEV;
4313 } 4934 }
4314 4935
4936 S2IO_TIMER_CONF(sp->alarm_timer, s2io_alarm_handle, sp, (HZ/2));
4937
4315 atomic_set(&sp->card_state, CARD_UP); 4938 atomic_set(&sp->card_state, CARD_UP);
4316 return 0; 4939 return 0;
4317} 4940}
4318 4941
4319/** 4942/**
4320 * s2io_restart_nic - Resets the NIC. 4943 * s2io_restart_nic - Resets the NIC.
4321 * @data : long pointer to the device private structure 4944 * @data : long pointer to the device private structure
4322 * Description: 4945 * Description:
4323 * This function is scheduled to be run by the s2io_tx_watchdog 4946 * This function is scheduled to be run by the s2io_tx_watchdog
4324 * function after 0.5 secs to reset the NIC. The idea is to reduce 4947 * function after 0.5 secs to reset the NIC. The idea is to reduce
4325 * the run time of the watch dog routine which is run holding a 4948 * the run time of the watch dog routine which is run holding a
4326 * spin lock. 4949 * spin lock.
4327 */ 4950 */
@@ -4339,10 +4962,11 @@ static void s2io_restart_nic(unsigned long data)
4339 netif_wake_queue(dev); 4962 netif_wake_queue(dev);
4340 DBG_PRINT(ERR_DBG, "%s: was reset by Tx watchdog timer\n", 4963 DBG_PRINT(ERR_DBG, "%s: was reset by Tx watchdog timer\n",
4341 dev->name); 4964 dev->name);
4965
4342} 4966}
4343 4967
4344/** 4968/**
4345 * s2io_tx_watchdog - Watchdog for transmit side. 4969 * s2io_tx_watchdog - Watchdog for transmit side.
4346 * @dev : Pointer to net device structure 4970 * @dev : Pointer to net device structure
4347 * Description: 4971 * Description:
4348 * This function is triggered if the Tx Queue is stopped 4972 * This function is triggered if the Tx Queue is stopped
@@ -4370,7 +4994,7 @@ static void s2io_tx_watchdog(struct net_device *dev)
4370 * @len : length of the packet 4994 * @len : length of the packet
4371 * @cksum : FCS checksum of the frame. 4995 * @cksum : FCS checksum of the frame.
4372 * @ring_no : the ring from which this RxD was extracted. 4996 * @ring_no : the ring from which this RxD was extracted.
4373 * Description: 4997 * Description:
4374 * This function is called by the Tx interrupt serivce routine to perform 4998 * This function is called by the Tx interrupt serivce routine to perform
4375 * some OS related operations on the SKB before passing it to the upper 4999 * some OS related operations on the SKB before passing it to the upper
4376 * layers. It mainly checks if the checksum is OK, if so adds it to the 5000 * layers. It mainly checks if the checksum is OK, if so adds it to the
@@ -4380,35 +5004,68 @@ static void s2io_tx_watchdog(struct net_device *dev)
4380 * Return value: 5004 * Return value:
4381 * SUCCESS on success and -1 on failure. 5005 * SUCCESS on success and -1 on failure.
4382 */ 5006 */
4383#ifndef CONFIG_2BUFF_MODE 5007static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp)
4384static int rx_osm_handler(nic_t * sp, u16 len, RxD_t * rxdp, int ring_no)
4385#else
4386static int rx_osm_handler(nic_t * sp, RxD_t * rxdp, int ring_no,
4387 buffAdd_t * ba)
4388#endif
4389{ 5008{
5009 nic_t *sp = ring_data->nic;
4390 struct net_device *dev = (struct net_device *) sp->dev; 5010 struct net_device *dev = (struct net_device *) sp->dev;
4391 struct sk_buff *skb = 5011 struct sk_buff *skb = (struct sk_buff *)
4392 (struct sk_buff *) ((unsigned long) rxdp->Host_Control); 5012 ((unsigned long) rxdp->Host_Control);
5013 int ring_no = ring_data->ring_no;
4393 u16 l3_csum, l4_csum; 5014 u16 l3_csum, l4_csum;
4394#ifdef CONFIG_2BUFF_MODE 5015#ifdef CONFIG_2BUFF_MODE
4395 int buf0_len, buf2_len; 5016 int buf0_len = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
5017 int buf2_len = RXD_GET_BUFFER2_SIZE(rxdp->Control_2);
5018 int get_block = ring_data->rx_curr_get_info.block_index;
5019 int get_off = ring_data->rx_curr_get_info.offset;
5020 buffAdd_t *ba = &ring_data->ba[get_block][get_off];
4396 unsigned char *buff; 5021 unsigned char *buff;
5022#else
5023 u16 len = (u16) ((RXD_GET_BUFFER0_SIZE(rxdp->Control_2)) >> 48);;
4397#endif 5024#endif
5025 skb->dev = dev;
5026 if (rxdp->Control_1 & RXD_T_CODE) {
5027 unsigned long long err = rxdp->Control_1 & RXD_T_CODE;
5028 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n",
5029 dev->name, err);
5030 dev_kfree_skb(skb);
5031 sp->stats.rx_crc_errors++;
5032 atomic_dec(&sp->rx_bufs_left[ring_no]);
5033 rxdp->Host_Control = 0;
5034 return 0;
5035 }
4398 5036
4399 l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1); 5037 /* Updating statistics */
4400 if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) && (sp->rx_csum)) { 5038 rxdp->Host_Control = 0;
5039 sp->rx_pkt_count++;
5040 sp->stats.rx_packets++;
5041#ifndef CONFIG_2BUFF_MODE
5042 sp->stats.rx_bytes += len;
5043#else
5044 sp->stats.rx_bytes += buf0_len + buf2_len;
5045#endif
5046
5047#ifndef CONFIG_2BUFF_MODE
5048 skb_put(skb, len);
5049#else
5050 buff = skb_push(skb, buf0_len);
5051 memcpy(buff, ba->ba_0, buf0_len);
5052 skb_put(skb, buf2_len);
5053#endif
5054
5055 if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) &&
5056 (sp->rx_csum)) {
5057 l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1);
4401 l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1); 5058 l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1);
4402 if ((l3_csum == L3_CKSUM_OK) && (l4_csum == L4_CKSUM_OK)) { 5059 if ((l3_csum == L3_CKSUM_OK) && (l4_csum == L4_CKSUM_OK)) {
4403 /* 5060 /*
4404 * NIC verifies if the Checksum of the received 5061 * NIC verifies if the Checksum of the received
4405 * frame is Ok or not and accordingly returns 5062 * frame is Ok or not and accordingly returns
4406 * a flag in the RxD. 5063 * a flag in the RxD.
4407 */ 5064 */
4408 skb->ip_summed = CHECKSUM_UNNECESSARY; 5065 skb->ip_summed = CHECKSUM_UNNECESSARY;
4409 } else { 5066 } else {
4410 /* 5067 /*
4411 * Packet with erroneous checksum, let the 5068 * Packet with erroneous checksum, let the
4412 * upper layers deal with it. 5069 * upper layers deal with it.
4413 */ 5070 */
4414 skb->ip_summed = CHECKSUM_NONE; 5071 skb->ip_summed = CHECKSUM_NONE;
@@ -4417,44 +5074,26 @@ static int rx_osm_handler(nic_t * sp, RxD_t * rxdp, int ring_no,
4417 skb->ip_summed = CHECKSUM_NONE; 5074 skb->ip_summed = CHECKSUM_NONE;
4418 } 5075 }
4419 5076
4420 if (rxdp->Control_1 & RXD_T_CODE) {
4421 unsigned long long err = rxdp->Control_1 & RXD_T_CODE;
4422 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n",
4423 dev->name, err);
4424 }
4425#ifdef CONFIG_2BUFF_MODE
4426 buf0_len = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
4427 buf2_len = RXD_GET_BUFFER2_SIZE(rxdp->Control_2);
4428#endif
4429
4430 skb->dev = dev;
4431#ifndef CONFIG_2BUFF_MODE
4432 skb_put(skb, len);
4433 skb->protocol = eth_type_trans(skb, dev);
4434#else
4435 buff = skb_push(skb, buf0_len);
4436 memcpy(buff, ba->ba_0, buf0_len);
4437 skb_put(skb, buf2_len);
4438 skb->protocol = eth_type_trans(skb, dev); 5077 skb->protocol = eth_type_trans(skb, dev);
4439#endif
4440
4441#ifdef CONFIG_S2IO_NAPI 5078#ifdef CONFIG_S2IO_NAPI
4442 netif_receive_skb(skb); 5079 if (sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2)) {
5080 /* Queueing the vlan frame to the upper layer */
5081 vlan_hwaccel_receive_skb(skb, sp->vlgrp,
5082 RXD_GET_VLAN_TAG(rxdp->Control_2));
5083 } else {
5084 netif_receive_skb(skb);
5085 }
4443#else 5086#else
4444 netif_rx(skb); 5087 if (sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2)) {
5088 /* Queueing the vlan frame to the upper layer */
5089 vlan_hwaccel_rx(skb, sp->vlgrp,
5090 RXD_GET_VLAN_TAG(rxdp->Control_2));
5091 } else {
5092 netif_rx(skb);
5093 }
4445#endif 5094#endif
4446
4447 dev->last_rx = jiffies; 5095 dev->last_rx = jiffies;
4448 sp->rx_pkt_count++;
4449 sp->stats.rx_packets++;
4450#ifndef CONFIG_2BUFF_MODE
4451 sp->stats.rx_bytes += len;
4452#else
4453 sp->stats.rx_bytes += buf0_len + buf2_len;
4454#endif
4455
4456 atomic_dec(&sp->rx_bufs_left[ring_no]); 5096 atomic_dec(&sp->rx_bufs_left[ring_no]);
4457 rxdp->Host_Control = 0;
4458 return SUCCESS; 5097 return SUCCESS;
4459} 5098}
4460 5099
@@ -4465,13 +5104,13 @@ static int rx_osm_handler(nic_t * sp, RxD_t * rxdp, int ring_no,
4465 * @link : inidicates whether link is UP/DOWN. 5104 * @link : inidicates whether link is UP/DOWN.
4466 * Description: 5105 * Description:
4467 * This function stops/starts the Tx queue depending on whether the link 5106 * This function stops/starts the Tx queue depending on whether the link
4468 * status of the NIC is is down or up. This is called by the Alarm 5107 * status of the NIC is is down or up. This is called by the Alarm
4469 * interrupt handler whenever a link change interrupt comes up. 5108 * interrupt handler whenever a link change interrupt comes up.
4470 * Return value: 5109 * Return value:
4471 * void. 5110 * void.
4472 */ 5111 */
4473 5112
4474static void s2io_link(nic_t * sp, int link) 5113void s2io_link(nic_t * sp, int link)
4475{ 5114{
4476 struct net_device *dev = (struct net_device *) sp->dev; 5115 struct net_device *dev = (struct net_device *) sp->dev;
4477 5116
@@ -4488,8 +5127,25 @@ static void s2io_link(nic_t * sp, int link)
4488} 5127}
4489 5128
4490/** 5129/**
4491 * s2io_init_pci -Initialization of PCI and PCI-X configuration registers . 5130 * get_xena_rev_id - to identify revision ID of xena.
4492 * @sp : private member of the device structure, which is a pointer to the 5131 * @pdev : PCI Dev structure
5132 * Description:
5133 * Function to identify the Revision ID of xena.
5134 * Return value:
5135 * returns the revision ID of the device.
5136 */
5137
5138int get_xena_rev_id(struct pci_dev *pdev)
5139{
5140 u8 id = 0;
5141 int ret;
5142 ret = pci_read_config_byte(pdev, PCI_REVISION_ID, (u8 *) & id);
5143 return id;
5144}
5145
5146/**
5147 * s2io_init_pci -Initialization of PCI and PCI-X configuration registers .
5148 * @sp : private member of the device structure, which is a pointer to the
4493 * s2io_nic structure. 5149 * s2io_nic structure.
4494 * Description: 5150 * Description:
4495 * This function initializes a few of the PCI and PCI-X configuration registers 5151 * This function initializes a few of the PCI and PCI-X configuration registers
@@ -4500,15 +5156,15 @@ static void s2io_link(nic_t * sp, int link)
4500 5156
4501static void s2io_init_pci(nic_t * sp) 5157static void s2io_init_pci(nic_t * sp)
4502{ 5158{
4503 u16 pci_cmd = 0; 5159 u16 pci_cmd = 0, pcix_cmd = 0;
4504 5160
4505 /* Enable Data Parity Error Recovery in PCI-X command register. */ 5161 /* Enable Data Parity Error Recovery in PCI-X command register. */
4506 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, 5162 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4507 &(sp->pcix_cmd)); 5163 &(pcix_cmd));
4508 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER, 5164 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4509 (sp->pcix_cmd | 1)); 5165 (pcix_cmd | 1));
4510 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, 5166 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4511 &(sp->pcix_cmd)); 5167 &(pcix_cmd));
4512 5168
4513 /* Set the PErr Response bit in PCI command register. */ 5169 /* Set the PErr Response bit in PCI command register. */
4514 pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd); 5170 pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
@@ -4516,53 +5172,43 @@ static void s2io_init_pci(nic_t * sp)
4516 (pci_cmd | PCI_COMMAND_PARITY)); 5172 (pci_cmd | PCI_COMMAND_PARITY));
4517 pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd); 5173 pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
4518 5174
4519 /* Set MMRB count to 1024 in PCI-X Command register. */
4520 sp->pcix_cmd &= 0xFFF3;
4521 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER, (sp->pcix_cmd | (0x1 << 2))); /* MMRBC 1K */
4522 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4523 &(sp->pcix_cmd));
4524
4525 /* Setting Maximum outstanding splits based on system type. */
4526 sp->pcix_cmd &= 0xFF8F;
4527
4528 sp->pcix_cmd |= XENA_MAX_OUTSTANDING_SPLITS(0x1); /* 2 splits. */
4529 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4530 sp->pcix_cmd);
4531 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4532 &(sp->pcix_cmd));
4533 /* Forcibly disabling relaxed ordering capability of the card. */ 5175 /* Forcibly disabling relaxed ordering capability of the card. */
4534 sp->pcix_cmd &= 0xfffd; 5176 pcix_cmd &= 0xfffd;
4535 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER, 5177 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4536 sp->pcix_cmd); 5178 pcix_cmd);
4537 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, 5179 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4538 &(sp->pcix_cmd)); 5180 &(pcix_cmd));
4539} 5181}
4540 5182
4541MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>"); 5183MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>");
4542MODULE_LICENSE("GPL"); 5184MODULE_LICENSE("GPL");
4543module_param(tx_fifo_num, int, 0); 5185module_param(tx_fifo_num, int, 0);
4544module_param_array(tx_fifo_len, int, NULL, 0);
4545module_param(rx_ring_num, int, 0); 5186module_param(rx_ring_num, int, 0);
4546module_param_array(rx_ring_sz, int, NULL, 0); 5187module_param_array(tx_fifo_len, uint, NULL, 0);
4547module_param(Stats_refresh_time, int, 0); 5188module_param_array(rx_ring_sz, uint, NULL, 0);
5189module_param_array(rts_frm_len, uint, NULL, 0);
5190module_param(use_continuous_tx_intrs, int, 1);
4548module_param(rmac_pause_time, int, 0); 5191module_param(rmac_pause_time, int, 0);
4549module_param(mc_pause_threshold_q0q3, int, 0); 5192module_param(mc_pause_threshold_q0q3, int, 0);
4550module_param(mc_pause_threshold_q4q7, int, 0); 5193module_param(mc_pause_threshold_q4q7, int, 0);
4551module_param(shared_splits, int, 0); 5194module_param(shared_splits, int, 0);
4552module_param(tmac_util_period, int, 0); 5195module_param(tmac_util_period, int, 0);
4553module_param(rmac_util_period, int, 0); 5196module_param(rmac_util_period, int, 0);
5197module_param(bimodal, bool, 0);
4554#ifndef CONFIG_S2IO_NAPI 5198#ifndef CONFIG_S2IO_NAPI
4555module_param(indicate_max_pkts, int, 0); 5199module_param(indicate_max_pkts, int, 0);
4556#endif 5200#endif
5201module_param(rxsync_frequency, int, 0);
5202
4557/** 5203/**
4558 * s2io_init_nic - Initialization of the adapter . 5204 * s2io_init_nic - Initialization of the adapter .
4559 * @pdev : structure containing the PCI related information of the device. 5205 * @pdev : structure containing the PCI related information of the device.
4560 * @pre: List of PCI devices supported by the driver listed in s2io_tbl. 5206 * @pre: List of PCI devices supported by the driver listed in s2io_tbl.
4561 * Description: 5207 * Description:
4562 * The function initializes an adapter identified by the pci_dec structure. 5208 * The function initializes an adapter identified by the pci_dec structure.
4563 * All OS related initialization including memory and device structure and 5209 * All OS related initialization including memory and device structure and
4564 * initlaization of the device private variable is done. Also the swapper 5210 * initlaization of the device private variable is done. Also the swapper
4565 * control register is initialized to enable read and write into the I/O 5211 * control register is initialized to enable read and write into the I/O
4566 * registers of the device. 5212 * registers of the device.
4567 * Return value: 5213 * Return value:
4568 * returns 0 on success and negative on failure. 5214 * returns 0 on success and negative on failure.
@@ -4573,7 +5219,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4573{ 5219{
4574 nic_t *sp; 5220 nic_t *sp;
4575 struct net_device *dev; 5221 struct net_device *dev;
4576 char *dev_name = "S2IO 10GE NIC";
4577 int i, j, ret; 5222 int i, j, ret;
4578 int dma_flag = FALSE; 5223 int dma_flag = FALSE;
4579 u32 mac_up, mac_down; 5224 u32 mac_up, mac_down;
@@ -4582,10 +5227,11 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4582 u16 subid; 5227 u16 subid;
4583 mac_info_t *mac_control; 5228 mac_info_t *mac_control;
4584 struct config_param *config; 5229 struct config_param *config;
5230 int mode;
4585 5231
4586 5232#ifdef CONFIG_S2IO_NAPI
4587 DBG_PRINT(ERR_DBG, "Loading S2IO driver with %s\n", 5233 DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n");
4588 s2io_driver_version); 5234#endif
4589 5235
4590 if ((ret = pci_enable_device(pdev))) { 5236 if ((ret = pci_enable_device(pdev))) {
4591 DBG_PRINT(ERR_DBG, 5237 DBG_PRINT(ERR_DBG,
@@ -4593,19 +5239,18 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4593 return ret; 5239 return ret;
4594 } 5240 }
4595 5241
4596 if (!pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) { 5242 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
4597 DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 64bit DMA\n"); 5243 DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 64bit DMA\n");
4598 dma_flag = TRUE; 5244 dma_flag = TRUE;
4599
4600 if (pci_set_consistent_dma_mask 5245 if (pci_set_consistent_dma_mask
4601 (pdev, 0xffffffffffffffffULL)) { 5246 (pdev, DMA_64BIT_MASK)) {
4602 DBG_PRINT(ERR_DBG, 5247 DBG_PRINT(ERR_DBG,
4603 "Unable to obtain 64bit DMA for \ 5248 "Unable to obtain 64bit DMA for \
4604 consistent allocations\n"); 5249 consistent allocations\n");
4605 pci_disable_device(pdev); 5250 pci_disable_device(pdev);
4606 return -ENOMEM; 5251 return -ENOMEM;
4607 } 5252 }
4608 } else if (!pci_set_dma_mask(pdev, 0xffffffffUL)) { 5253 } else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
4609 DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 32bit DMA\n"); 5254 DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 32bit DMA\n");
4610 } else { 5255 } else {
4611 pci_disable_device(pdev); 5256 pci_disable_device(pdev);
@@ -4636,34 +5281,41 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4636 memset(sp, 0, sizeof(nic_t)); 5281 memset(sp, 0, sizeof(nic_t));
4637 sp->dev = dev; 5282 sp->dev = dev;
4638 sp->pdev = pdev; 5283 sp->pdev = pdev;
4639 sp->vendor_id = pdev->vendor;
4640 sp->device_id = pdev->device;
4641 sp->high_dma_flag = dma_flag; 5284 sp->high_dma_flag = dma_flag;
4642 sp->irq = pdev->irq;
4643 sp->device_enabled_once = FALSE; 5285 sp->device_enabled_once = FALSE;
4644 strcpy(sp->name, dev_name); 5286
5287 if ((pdev->device == PCI_DEVICE_ID_HERC_WIN) ||
5288 (pdev->device == PCI_DEVICE_ID_HERC_UNI))
5289 sp->device_type = XFRAME_II_DEVICE;
5290 else
5291 sp->device_type = XFRAME_I_DEVICE;
4645 5292
4646 /* Initialize some PCI/PCI-X fields of the NIC. */ 5293 /* Initialize some PCI/PCI-X fields of the NIC. */
4647 s2io_init_pci(sp); 5294 s2io_init_pci(sp);
4648 5295
4649 /* 5296 /*
4650 * Setting the device configuration parameters. 5297 * Setting the device configuration parameters.
4651 * Most of these parameters can be specified by the user during 5298 * Most of these parameters can be specified by the user during
4652 * module insertion as they are module loadable parameters. If 5299 * module insertion as they are module loadable parameters. If
4653 * these parameters are not not specified during load time, they 5300 * these parameters are not not specified during load time, they
4654 * are initialized with default values. 5301 * are initialized with default values.
4655 */ 5302 */
4656 mac_control = &sp->mac_control; 5303 mac_control = &sp->mac_control;
4657 config = &sp->config; 5304 config = &sp->config;
4658 5305
4659 /* Tx side parameters. */ 5306 /* Tx side parameters. */
4660 tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */ 5307 if (tx_fifo_len[0] == 0)
5308 tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */
4661 config->tx_fifo_num = tx_fifo_num; 5309 config->tx_fifo_num = tx_fifo_num;
4662 for (i = 0; i < MAX_TX_FIFOS; i++) { 5310 for (i = 0; i < MAX_TX_FIFOS; i++) {
4663 config->tx_cfg[i].fifo_len = tx_fifo_len[i]; 5311 config->tx_cfg[i].fifo_len = tx_fifo_len[i];
4664 config->tx_cfg[i].fifo_priority = i; 5312 config->tx_cfg[i].fifo_priority = i;
4665 } 5313 }
4666 5314
5315 /* mapping the QoS priority to the configured fifos */
5316 for (i = 0; i < MAX_TX_FIFOS; i++)
5317 config->fifo_mapping[i] = fifo_map[config->tx_fifo_num][i];
5318
4667 config->tx_intr_type = TXD_INT_TYPE_UTILZ; 5319 config->tx_intr_type = TXD_INT_TYPE_UTILZ;
4668 for (i = 0; i < config->tx_fifo_num; i++) { 5320 for (i = 0; i < config->tx_fifo_num; i++) {
4669 config->tx_cfg[i].f_no_snoop = 5321 config->tx_cfg[i].f_no_snoop =
@@ -4676,7 +5328,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4676 config->max_txds = MAX_SKB_FRAGS; 5328 config->max_txds = MAX_SKB_FRAGS;
4677 5329
4678 /* Rx side parameters. */ 5330 /* Rx side parameters. */
4679 rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */ 5331 if (rx_ring_sz[0] == 0)
5332 rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */
4680 config->rx_ring_num = rx_ring_num; 5333 config->rx_ring_num = rx_ring_num;
4681 for (i = 0; i < MAX_RX_RINGS; i++) { 5334 for (i = 0; i < MAX_RX_RINGS; i++) {
4682 config->rx_cfg[i].num_rxd = rx_ring_sz[i] * 5335 config->rx_cfg[i].num_rxd = rx_ring_sz[i] *
@@ -4700,10 +5353,13 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4700 for (i = 0; i < config->rx_ring_num; i++) 5353 for (i = 0; i < config->rx_ring_num; i++)
4701 atomic_set(&sp->rx_bufs_left[i], 0); 5354 atomic_set(&sp->rx_bufs_left[i], 0);
4702 5355
5356 /* Initialize the number of ISRs currently running */
5357 atomic_set(&sp->isr_cnt, 0);
5358
4703 /* initialize the shared memory used by the NIC and the host */ 5359 /* initialize the shared memory used by the NIC and the host */
4704 if (init_shared_mem(sp)) { 5360 if (init_shared_mem(sp)) {
4705 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", 5361 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n",
4706 dev->name); 5362 __FUNCTION__);
4707 ret = -ENOMEM; 5363 ret = -ENOMEM;
4708 goto mem_alloc_failed; 5364 goto mem_alloc_failed;
4709 } 5365 }
@@ -4744,13 +5400,17 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4744 dev->do_ioctl = &s2io_ioctl; 5400 dev->do_ioctl = &s2io_ioctl;
4745 dev->change_mtu = &s2io_change_mtu; 5401 dev->change_mtu = &s2io_change_mtu;
4746 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 5402 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
5403 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
5404 dev->vlan_rx_register = s2io_vlan_rx_register;
5405 dev->vlan_rx_kill_vid = (void *)s2io_vlan_rx_kill_vid;
5406
4747 /* 5407 /*
4748 * will use eth_mac_addr() for dev->set_mac_address 5408 * will use eth_mac_addr() for dev->set_mac_address
4749 * mac address will be set every time dev->open() is called 5409 * mac address will be set every time dev->open() is called
4750 */ 5410 */
4751#ifdef CONFIG_S2IO_NAPI 5411#if defined(CONFIG_S2IO_NAPI)
4752 dev->poll = s2io_poll; 5412 dev->poll = s2io_poll;
4753 dev->weight = 90; 5413 dev->weight = 32;
4754#endif 5414#endif
4755 5415
4756 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; 5416 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
@@ -4777,22 +5437,28 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4777 goto set_swap_failed; 5437 goto set_swap_failed;
4778 } 5438 }
4779 5439
4780 /* Fix for all "FFs" MAC address problems observed on Alpha platforms */ 5440 /* Verify if the Herc works on the slot its placed into */
4781 fix_mac_address(sp); 5441 if (sp->device_type & XFRAME_II_DEVICE) {
4782 s2io_reset(sp); 5442 mode = s2io_verify_pci_mode(sp);
5443 if (mode < 0) {
5444 DBG_PRINT(ERR_DBG, "%s: ", __FUNCTION__);
5445 DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode\n");
5446 ret = -EBADSLT;
5447 goto set_swap_failed;
5448 }
5449 }
4783 5450
4784 /* 5451 /* Not needed for Herc */
4785 * Setting swapper control on the NIC, so the MAC address can be read. 5452 if (sp->device_type & XFRAME_I_DEVICE) {
4786 */ 5453 /*
4787 if (s2io_set_swapper(sp)) { 5454 * Fix for all "FFs" MAC address problems observed on
4788 DBG_PRINT(ERR_DBG, 5455 * Alpha platforms
4789 "%s: S2IO: swapper settings are wrong\n", 5456 */
4790 dev->name); 5457 fix_mac_address(sp);
4791 ret = -EAGAIN; 5458 s2io_reset(sp);
4792 goto set_swap_failed;
4793 } 5459 }
4794 5460
4795 /* 5461 /*
4796 * MAC address initialization. 5462 * MAC address initialization.
4797 * For now only one mac address will be read and used. 5463 * For now only one mac address will be read and used.
4798 */ 5464 */
@@ -4815,37 +5481,28 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4815 sp->def_mac_addr[0].mac_addr[5] = (u8) (mac_down >> 16); 5481 sp->def_mac_addr[0].mac_addr[5] = (u8) (mac_down >> 16);
4816 sp->def_mac_addr[0].mac_addr[4] = (u8) (mac_down >> 24); 5482 sp->def_mac_addr[0].mac_addr[4] = (u8) (mac_down >> 24);
4817 5483
4818 DBG_PRINT(INIT_DBG,
4819 "DEFAULT MAC ADDR:0x%02x-%02x-%02x-%02x-%02x-%02x\n",
4820 sp->def_mac_addr[0].mac_addr[0],
4821 sp->def_mac_addr[0].mac_addr[1],
4822 sp->def_mac_addr[0].mac_addr[2],
4823 sp->def_mac_addr[0].mac_addr[3],
4824 sp->def_mac_addr[0].mac_addr[4],
4825 sp->def_mac_addr[0].mac_addr[5]);
4826
4827 /* Set the factory defined MAC address initially */ 5484 /* Set the factory defined MAC address initially */
4828 dev->addr_len = ETH_ALEN; 5485 dev->addr_len = ETH_ALEN;
4829 memcpy(dev->dev_addr, sp->def_mac_addr, ETH_ALEN); 5486 memcpy(dev->dev_addr, sp->def_mac_addr, ETH_ALEN);
4830 5487
4831 /* 5488 /*
4832 * Initialize the tasklet status and link state flags 5489 * Initialize the tasklet status and link state flags
4833 * and the card statte parameter 5490 * and the card state parameter
4834 */ 5491 */
4835 atomic_set(&(sp->card_state), 0); 5492 atomic_set(&(sp->card_state), 0);
4836 sp->tasklet_status = 0; 5493 sp->tasklet_status = 0;
4837 sp->link_state = 0; 5494 sp->link_state = 0;
4838 5495
4839
4840 /* Initialize spinlocks */ 5496 /* Initialize spinlocks */
4841 spin_lock_init(&sp->tx_lock); 5497 spin_lock_init(&sp->tx_lock);
4842#ifndef CONFIG_S2IO_NAPI 5498#ifndef CONFIG_S2IO_NAPI
4843 spin_lock_init(&sp->put_lock); 5499 spin_lock_init(&sp->put_lock);
4844#endif 5500#endif
5501 spin_lock_init(&sp->rx_lock);
4845 5502
4846 /* 5503 /*
4847 * SXE-002: Configure link and activity LED to init state 5504 * SXE-002: Configure link and activity LED to init state
4848 * on driver load. 5505 * on driver load.
4849 */ 5506 */
4850 subid = sp->pdev->subsystem_device; 5507 subid = sp->pdev->subsystem_device;
4851 if ((subid & 0xFF) >= 0x07) { 5508 if ((subid & 0xFF) >= 0x07) {
@@ -4865,13 +5522,61 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4865 goto register_failed; 5522 goto register_failed;
4866 } 5523 }
4867 5524
4868 /* 5525 if (sp->device_type & XFRAME_II_DEVICE) {
4869 * Make Link state as off at this point, when the Link change 5526 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ",
4870 * interrupt comes the state will be automatically changed to 5527 dev->name);
5528 DBG_PRINT(ERR_DBG, "(rev %d), Driver %s\n",
5529 get_xena_rev_id(sp->pdev),
5530 s2io_driver_version);
5531 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
5532 sp->def_mac_addr[0].mac_addr[0],
5533 sp->def_mac_addr[0].mac_addr[1],
5534 sp->def_mac_addr[0].mac_addr[2],
5535 sp->def_mac_addr[0].mac_addr[3],
5536 sp->def_mac_addr[0].mac_addr[4],
5537 sp->def_mac_addr[0].mac_addr[5]);
5538 mode = s2io_print_pci_mode(sp);
5539 if (mode < 0) {
5540 DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode ");
5541 ret = -EBADSLT;
5542 goto set_swap_failed;
5543 }
5544 } else {
5545 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ",
5546 dev->name);
5547 DBG_PRINT(ERR_DBG, "(rev %d), Driver %s\n",
5548 get_xena_rev_id(sp->pdev),
5549 s2io_driver_version);
5550 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
5551 sp->def_mac_addr[0].mac_addr[0],
5552 sp->def_mac_addr[0].mac_addr[1],
5553 sp->def_mac_addr[0].mac_addr[2],
5554 sp->def_mac_addr[0].mac_addr[3],
5555 sp->def_mac_addr[0].mac_addr[4],
5556 sp->def_mac_addr[0].mac_addr[5]);
5557 }
5558
5559 /* Initialize device name */
5560 strcpy(sp->name, dev->name);
5561 if (sp->device_type & XFRAME_II_DEVICE)
5562 strcat(sp->name, ": Neterion Xframe II 10GbE adapter");
5563 else
5564 strcat(sp->name, ": Neterion Xframe I 10GbE adapter");
5565
5566 /* Initialize bimodal Interrupts */
5567 sp->config.bimodal = bimodal;
5568 if (!(sp->device_type & XFRAME_II_DEVICE) && bimodal) {
5569 sp->config.bimodal = 0;
5570 DBG_PRINT(ERR_DBG,"%s:Bimodal intr not supported by Xframe I\n",
5571 dev->name);
5572 }
5573
5574 /*
5575 * Make Link state as off at this point, when the Link change
5576 * interrupt comes the state will be automatically changed to
4871 * the right state. 5577 * the right state.
4872 */ 5578 */
4873 netif_carrier_off(dev); 5579 netif_carrier_off(dev);
4874 sp->last_link_state = LINK_DOWN;
4875 5580
4876 return 0; 5581 return 0;
4877 5582
@@ -4892,11 +5597,11 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
4892} 5597}
4893 5598
4894/** 5599/**
4895 * s2io_rem_nic - Free the PCI device 5600 * s2io_rem_nic - Free the PCI device
4896 * @pdev: structure containing the PCI related information of the device. 5601 * @pdev: structure containing the PCI related information of the device.
4897 * Description: This function is called by the Pci subsystem to release a 5602 * Description: This function is called by the Pci subsystem to release a
4898 * PCI device and free up all resource held up by the device. This could 5603 * PCI device and free up all resource held up by the device. This could
4899 * be in response to a Hot plug event or when the driver is to be removed 5604 * be in response to a Hot plug event or when the driver is to be removed
4900 * from memory. 5605 * from memory.
4901 */ 5606 */
4902 5607
@@ -4920,7 +5625,6 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev)
4920 pci_disable_device(pdev); 5625 pci_disable_device(pdev);
4921 pci_release_regions(pdev); 5626 pci_release_regions(pdev);
4922 pci_set_drvdata(pdev, NULL); 5627 pci_set_drvdata(pdev, NULL);
4923
4924 free_netdev(dev); 5628 free_netdev(dev);
4925} 5629}
4926 5630
@@ -4936,11 +5640,11 @@ int __init s2io_starter(void)
4936} 5640}
4937 5641
4938/** 5642/**
4939 * s2io_closer - Cleanup routine for the driver 5643 * s2io_closer - Cleanup routine for the driver
4940 * Description: This function is the cleanup routine for the driver. It unregist * ers the driver. 5644 * Description: This function is the cleanup routine for the driver. It unregist * ers the driver.
4941 */ 5645 */
4942 5646
4943static void s2io_closer(void) 5647void s2io_closer(void)
4944{ 5648{
4945 pci_unregister_driver(&s2io_driver); 5649 pci_unregister_driver(&s2io_driver);
4946 DBG_PRINT(INIT_DBG, "cleanup done\n"); 5650 DBG_PRINT(INIT_DBG, "cleanup done\n");
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 1711c8c3dc99..5d9270730ca2 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -31,6 +31,9 @@
31#define SUCCESS 0 31#define SUCCESS 0
32#define FAILURE -1 32#define FAILURE -1
33 33
34/* Maximum time to flicker LED when asked to identify NIC using ethtool */
35#define MAX_FLICKER_TIME 60000 /* 60 Secs */
36
34/* Maximum outstanding splits to be configured into xena. */ 37/* Maximum outstanding splits to be configured into xena. */
35typedef enum xena_max_outstanding_splits { 38typedef enum xena_max_outstanding_splits {
36 XENA_ONE_SPLIT_TRANSACTION = 0, 39 XENA_ONE_SPLIT_TRANSACTION = 0,
@@ -45,10 +48,10 @@ typedef enum xena_max_outstanding_splits {
45#define XENA_MAX_OUTSTANDING_SPLITS(n) (n << 4) 48#define XENA_MAX_OUTSTANDING_SPLITS(n) (n << 4)
46 49
47/* OS concerned variables and constants */ 50/* OS concerned variables and constants */
48#define WATCH_DOG_TIMEOUT 5*HZ 51#define WATCH_DOG_TIMEOUT 15*HZ
49#define EFILL 0x1234 52#define EFILL 0x1234
50#define ALIGN_SIZE 127 53#define ALIGN_SIZE 127
51#define PCIX_COMMAND_REGISTER 0x62 54#define PCIX_COMMAND_REGISTER 0x62
52 55
53/* 56/*
54 * Debug related variables. 57 * Debug related variables.
@@ -61,7 +64,7 @@ typedef enum xena_max_outstanding_splits {
61#define INTR_DBG 4 64#define INTR_DBG 4
62 65
63/* Global variable that defines the present debug level of the driver. */ 66/* Global variable that defines the present debug level of the driver. */
64static int debug_level = ERR_DBG; /* Default level. */ 67int debug_level = ERR_DBG; /* Default level. */
65 68
66/* DEBUG message print. */ 69/* DEBUG message print. */
67#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) 70#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args)
@@ -71,6 +74,12 @@ static int debug_level = ERR_DBG; /* Default level. */
71#define L4_CKSUM_OK 0xFFFF 74#define L4_CKSUM_OK 0xFFFF
72#define S2IO_JUMBO_SIZE 9600 75#define S2IO_JUMBO_SIZE 9600
73 76
77/* Driver statistics maintained by driver */
78typedef struct {
79 unsigned long long single_ecc_errs;
80 unsigned long long double_ecc_errs;
81} swStat_t;
82
74/* The statistics block of Xena */ 83/* The statistics block of Xena */
75typedef struct stat_block { 84typedef struct stat_block {
76/* Tx MAC statistics counters. */ 85/* Tx MAC statistics counters. */
@@ -186,12 +195,90 @@ typedef struct stat_block {
186 u32 rxd_rd_cnt; 195 u32 rxd_rd_cnt;
187 u32 rxf_wr_cnt; 196 u32 rxf_wr_cnt;
188 u32 txf_rd_cnt; 197 u32 txf_rd_cnt;
198
199/* Tx MAC statistics overflow counters. */
200 u32 tmac_data_octets_oflow;
201 u32 tmac_frms_oflow;
202 u32 tmac_bcst_frms_oflow;
203 u32 tmac_mcst_frms_oflow;
204 u32 tmac_ucst_frms_oflow;
205 u32 tmac_ttl_octets_oflow;
206 u32 tmac_any_err_frms_oflow;
207 u32 tmac_nucst_frms_oflow;
208 u64 tmac_vlan_frms;
209 u32 tmac_drop_ip_oflow;
210 u32 tmac_vld_ip_oflow;
211 u32 tmac_rst_tcp_oflow;
212 u32 tmac_icmp_oflow;
213 u32 tpa_unknown_protocol;
214 u32 tmac_udp_oflow;
215 u32 reserved_10;
216 u32 tpa_parse_failure;
217
218/* Rx MAC Statistics overflow counters. */
219 u32 rmac_data_octets_oflow;
220 u32 rmac_vld_frms_oflow;
221 u32 rmac_vld_bcst_frms_oflow;
222 u32 rmac_vld_mcst_frms_oflow;
223 u32 rmac_accepted_ucst_frms_oflow;
224 u32 rmac_ttl_octets_oflow;
225 u32 rmac_discarded_frms_oflow;
226 u32 rmac_accepted_nucst_frms_oflow;
227 u32 rmac_usized_frms_oflow;
228 u32 rmac_drop_events_oflow;
229 u32 rmac_frag_frms_oflow;
230 u32 rmac_osized_frms_oflow;
231 u32 rmac_ip_oflow;
232 u32 rmac_jabber_frms_oflow;
233 u32 rmac_icmp_oflow;
234 u32 rmac_drop_ip_oflow;
235 u32 rmac_err_drp_udp_oflow;
236 u32 rmac_udp_oflow;
237 u32 reserved_11;
238 u32 rmac_pause_cnt_oflow;
239 u64 rmac_ttl_1519_4095_frms;
240 u64 rmac_ttl_4096_8191_frms;
241 u64 rmac_ttl_8192_max_frms;
242 u64 rmac_ttl_gt_max_frms;
243 u64 rmac_osized_alt_frms;
244 u64 rmac_jabber_alt_frms;
245 u64 rmac_gt_max_alt_frms;
246 u64 rmac_vlan_frms;
247 u32 rmac_len_discard;
248 u32 rmac_fcs_discard;
249 u32 rmac_pf_discard;
250 u32 rmac_da_discard;
251 u32 rmac_red_discard;
252 u32 rmac_rts_discard;
253 u32 reserved_12;
254 u32 rmac_ingm_full_discard;
255 u32 reserved_13;
256 u32 rmac_accepted_ip_oflow;
257 u32 reserved_14;
258 u32 link_fault_cnt;
259 swStat_t sw_stat;
189} StatInfo_t; 260} StatInfo_t;
190 261
191/* Structures representing different init time configuration 262/*
263 * Structures representing different init time configuration
192 * parameters of the NIC. 264 * parameters of the NIC.
193 */ 265 */
194 266
267#define MAX_TX_FIFOS 8
268#define MAX_RX_RINGS 8
269
270/* FIFO mappings for all possible number of fifos configured */
271int fifo_map[][MAX_TX_FIFOS] = {
272 {0, 0, 0, 0, 0, 0, 0, 0},
273 {0, 0, 0, 0, 1, 1, 1, 1},
274 {0, 0, 0, 1, 1, 1, 2, 2},
275 {0, 0, 1, 1, 2, 2, 3, 3},
276 {0, 0, 1, 1, 2, 2, 3, 4},
277 {0, 0, 1, 1, 2, 3, 4, 5},
278 {0, 0, 1, 2, 3, 4, 5, 6},
279 {0, 1, 2, 3, 4, 5, 6, 7},
280};
281
195/* Maintains Per FIFO related information. */ 282/* Maintains Per FIFO related information. */
196typedef struct tx_fifo_config { 283typedef struct tx_fifo_config {
197#define MAX_AVAILABLE_TXDS 8192 284#define MAX_AVAILABLE_TXDS 8192
@@ -237,14 +324,14 @@ typedef struct rx_ring_config {
237#define NO_SNOOP_RXD_BUFFER 0x02 324#define NO_SNOOP_RXD_BUFFER 0x02
238} rx_ring_config_t; 325} rx_ring_config_t;
239 326
240/* This structure provides contains values of the tunable parameters 327/* This structure provides contains values of the tunable parameters
241 * of the H/W 328 * of the H/W
242 */ 329 */
243struct config_param { 330struct config_param {
244/* Tx Side */ 331/* Tx Side */
245 u32 tx_fifo_num; /*Number of Tx FIFOs */ 332 u32 tx_fifo_num; /*Number of Tx FIFOs */
246#define MAX_TX_FIFOS 8
247 333
334 u8 fifo_mapping[MAX_TX_FIFOS];
248 tx_fifo_config_t tx_cfg[MAX_TX_FIFOS]; /*Per-Tx FIFO config */ 335 tx_fifo_config_t tx_cfg[MAX_TX_FIFOS]; /*Per-Tx FIFO config */
249 u32 max_txds; /*Max no. of Tx buffer descriptor per TxDL */ 336 u32 max_txds; /*Max no. of Tx buffer descriptor per TxDL */
250 u64 tx_intr_type; 337 u64 tx_intr_type;
@@ -252,10 +339,10 @@ struct config_param {
252 339
253/* Rx Side */ 340/* Rx Side */
254 u32 rx_ring_num; /*Number of receive rings */ 341 u32 rx_ring_num; /*Number of receive rings */
255#define MAX_RX_RINGS 8
256#define MAX_RX_BLOCKS_PER_RING 150 342#define MAX_RX_BLOCKS_PER_RING 150
257 343
258 rx_ring_config_t rx_cfg[MAX_RX_RINGS]; /*Per-Rx Ring config */ 344 rx_ring_config_t rx_cfg[MAX_RX_RINGS]; /*Per-Rx Ring config */
345 u8 bimodal; /*Flag for setting bimodal interrupts*/
259 346
260#define HEADER_ETHERNET_II_802_3_SIZE 14 347#define HEADER_ETHERNET_II_802_3_SIZE 14
261#define HEADER_802_2_SIZE 3 348#define HEADER_802_2_SIZE 3
@@ -269,6 +356,7 @@ struct config_param {
269#define MAX_PYLD_JUMBO 9600 356#define MAX_PYLD_JUMBO 9600
270#define MAX_MTU_JUMBO (MAX_PYLD_JUMBO+18) 357#define MAX_MTU_JUMBO (MAX_PYLD_JUMBO+18)
271#define MAX_MTU_JUMBO_VLAN (MAX_PYLD_JUMBO+22) 358#define MAX_MTU_JUMBO_VLAN (MAX_PYLD_JUMBO+22)
359 u16 bus_speed;
272}; 360};
273 361
274/* Structure representing MAC Addrs */ 362/* Structure representing MAC Addrs */
@@ -277,7 +365,7 @@ typedef struct mac_addr {
277} macaddr_t; 365} macaddr_t;
278 366
279/* Structure that represent every FIFO element in the BAR1 367/* Structure that represent every FIFO element in the BAR1
280 * Address location. 368 * Address location.
281 */ 369 */
282typedef struct _TxFIFO_element { 370typedef struct _TxFIFO_element {
283 u64 TxDL_Pointer; 371 u64 TxDL_Pointer;
@@ -339,6 +427,7 @@ typedef struct _RxD_t {
339#define RXD_FRAME_PROTO vBIT(0xFFFF,24,8) 427#define RXD_FRAME_PROTO vBIT(0xFFFF,24,8)
340#define RXD_FRAME_PROTO_IPV4 BIT(27) 428#define RXD_FRAME_PROTO_IPV4 BIT(27)
341#define RXD_FRAME_PROTO_IPV6 BIT(28) 429#define RXD_FRAME_PROTO_IPV6 BIT(28)
430#define RXD_FRAME_IP_FRAG BIT(29)
342#define RXD_FRAME_PROTO_TCP BIT(30) 431#define RXD_FRAME_PROTO_TCP BIT(30)
343#define RXD_FRAME_PROTO_UDP BIT(31) 432#define RXD_FRAME_PROTO_UDP BIT(31)
344#define TCP_OR_UDP_FRAME (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP) 433#define TCP_OR_UDP_FRAME (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP)
@@ -346,11 +435,15 @@ typedef struct _RxD_t {
346#define RXD_GET_L4_CKSUM(val) ((u16)(val) & 0xFFFF) 435#define RXD_GET_L4_CKSUM(val) ((u16)(val) & 0xFFFF)
347 436
348 u64 Control_2; 437 u64 Control_2;
438#define THE_RXD_MARK 0x3
439#define SET_RXD_MARKER vBIT(THE_RXD_MARK, 0, 2)
440#define GET_RXD_MARKER(ctrl) ((ctrl & SET_RXD_MARKER) >> 62)
441
349#ifndef CONFIG_2BUFF_MODE 442#ifndef CONFIG_2BUFF_MODE
350#define MASK_BUFFER0_SIZE vBIT(0xFFFF,0,16) 443#define MASK_BUFFER0_SIZE vBIT(0x3FFF,2,14)
351#define SET_BUFFER0_SIZE(val) vBIT(val,0,16) 444#define SET_BUFFER0_SIZE(val) vBIT(val,2,14)
352#else 445#else
353#define MASK_BUFFER0_SIZE vBIT(0xFF,0,16) 446#define MASK_BUFFER0_SIZE vBIT(0xFF,2,14)
354#define MASK_BUFFER1_SIZE vBIT(0xFFFF,16,16) 447#define MASK_BUFFER1_SIZE vBIT(0xFFFF,16,16)
355#define MASK_BUFFER2_SIZE vBIT(0xFFFF,32,16) 448#define MASK_BUFFER2_SIZE vBIT(0xFFFF,32,16)
356#define SET_BUFFER0_SIZE(val) vBIT(val,8,8) 449#define SET_BUFFER0_SIZE(val) vBIT(val,8,8)
@@ -363,7 +456,7 @@ typedef struct _RxD_t {
363#define SET_NUM_TAG(val) vBIT(val,16,32) 456#define SET_NUM_TAG(val) vBIT(val,16,32)
364 457
365#ifndef CONFIG_2BUFF_MODE 458#ifndef CONFIG_2BUFF_MODE
366#define RXD_GET_BUFFER0_SIZE(Control_2) (u64)((Control_2 & vBIT(0xFFFF,0,16))) 459#define RXD_GET_BUFFER0_SIZE(Control_2) (u64)((Control_2 & vBIT(0x3FFF,2,14)))
367#else 460#else
368#define RXD_GET_BUFFER0_SIZE(Control_2) (u8)((Control_2 & MASK_BUFFER0_SIZE) \ 461#define RXD_GET_BUFFER0_SIZE(Control_2) (u8)((Control_2 & MASK_BUFFER0_SIZE) \
369 >> 48) 462 >> 48)
@@ -382,7 +475,7 @@ typedef struct _RxD_t {
382#endif 475#endif
383} RxD_t; 476} RxD_t;
384 477
385/* Structure that represents the Rx descriptor block which contains 478/* Structure that represents the Rx descriptor block which contains
386 * 128 Rx descriptors. 479 * 128 Rx descriptors.
387 */ 480 */
388#ifndef CONFIG_2BUFF_MODE 481#ifndef CONFIG_2BUFF_MODE
@@ -392,11 +485,11 @@ typedef struct _RxD_block {
392 485
393 u64 reserved_0; 486 u64 reserved_0;
394#define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL 487#define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL
395 u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last 488 u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last
396 * Rxd in this blk */ 489 * Rxd in this blk */
397 u64 reserved_2_pNext_RxD_block; /* Logical ptr to next */ 490 u64 reserved_2_pNext_RxD_block; /* Logical ptr to next */
398 u64 pNext_RxD_Blk_physical; /* Buff0_ptr.In a 32 bit arch 491 u64 pNext_RxD_Blk_physical; /* Buff0_ptr.In a 32 bit arch
399 * the upper 32 bits should 492 * the upper 32 bits should
400 * be 0 */ 493 * be 0 */
401} RxD_block_t; 494} RxD_block_t;
402#else 495#else
@@ -405,13 +498,13 @@ typedef struct _RxD_block {
405 RxD_t rxd[MAX_RXDS_PER_BLOCK]; 498 RxD_t rxd[MAX_RXDS_PER_BLOCK];
406 499
407#define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL 500#define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL
408 u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last Rxd 501 u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last Rxd
409 * in this blk */ 502 * in this blk */
410 u64 pNext_RxD_Blk_physical; /* Phy ponter to next blk. */ 503 u64 pNext_RxD_Blk_physical; /* Phy ponter to next blk. */
411} RxD_block_t; 504} RxD_block_t;
412#define SIZE_OF_BLOCK 4096 505#define SIZE_OF_BLOCK 4096
413 506
414/* Structure to hold virtual addresses of Buf0 and Buf1 in 507/* Structure to hold virtual addresses of Buf0 and Buf1 in
415 * 2buf mode. */ 508 * 2buf mode. */
416typedef struct bufAdd { 509typedef struct bufAdd {
417 void *ba_0_org; 510 void *ba_0_org;
@@ -423,8 +516,8 @@ typedef struct bufAdd {
423 516
424/* Structure which stores all the MAC control parameters */ 517/* Structure which stores all the MAC control parameters */
425 518
426/* This structure stores the offset of the RxD in the ring 519/* This structure stores the offset of the RxD in the ring
427 * from which the Rx Interrupt processor can start picking 520 * from which the Rx Interrupt processor can start picking
428 * up the RxDs for processing. 521 * up the RxDs for processing.
429 */ 522 */
430typedef struct _rx_curr_get_info_t { 523typedef struct _rx_curr_get_info_t {
@@ -436,7 +529,7 @@ typedef struct _rx_curr_get_info_t {
436typedef rx_curr_get_info_t rx_curr_put_info_t; 529typedef rx_curr_get_info_t rx_curr_put_info_t;
437 530
438/* This structure stores the offset of the TxDl in the FIFO 531/* This structure stores the offset of the TxDl in the FIFO
439 * from which the Tx Interrupt processor can start picking 532 * from which the Tx Interrupt processor can start picking
440 * up the TxDLs for send complete interrupt processing. 533 * up the TxDLs for send complete interrupt processing.
441 */ 534 */
442typedef struct { 535typedef struct {
@@ -446,32 +539,96 @@ typedef struct {
446 539
447typedef tx_curr_get_info_t tx_curr_put_info_t; 540typedef tx_curr_get_info_t tx_curr_put_info_t;
448 541
449/* Infomation related to the Tx and Rx FIFOs and Rings of Xena 542/* Structure that holds the Phy and virt addresses of the Blocks */
450 * is maintained in this structure. 543typedef struct rx_block_info {
451 */ 544 RxD_t *block_virt_addr;
452typedef struct mac_info { 545 dma_addr_t block_dma_addr;
453/* rx side stuff */ 546} rx_block_info_t;
454 /* Put pointer info which indictes which RxD has to be replenished 547
548/* pre declaration of the nic structure */
549typedef struct s2io_nic nic_t;
550
551/* Ring specific structure */
552typedef struct ring_info {
553 /* The ring number */
554 int ring_no;
555
556 /*
557 * Place holders for the virtual and physical addresses of
558 * all the Rx Blocks
559 */
560 rx_block_info_t rx_blocks[MAX_RX_BLOCKS_PER_RING];
561 int block_count;
562 int pkt_cnt;
563
564 /*
565 * Put pointer info which indictes which RxD has to be replenished
455 * with a new buffer. 566 * with a new buffer.
456 */ 567 */
457 rx_curr_put_info_t rx_curr_put_info[MAX_RX_RINGS]; 568 rx_curr_put_info_t rx_curr_put_info;
458 569
459 /* Get pointer info which indictes which is the last RxD that was 570 /*
571 * Get pointer info which indictes which is the last RxD that was
460 * processed by the driver. 572 * processed by the driver.
461 */ 573 */
462 rx_curr_get_info_t rx_curr_get_info[MAX_RX_RINGS]; 574 rx_curr_get_info_t rx_curr_get_info;
463 575
464 u16 rmac_pause_time; 576#ifndef CONFIG_S2IO_NAPI
465 u16 mc_pause_threshold_q0q3; 577 /* Index to the absolute position of the put pointer of Rx ring */
466 u16 mc_pause_threshold_q4q7; 578 int put_pos;
579#endif
580
581#ifdef CONFIG_2BUFF_MODE
582 /* Buffer Address store. */
583 buffAdd_t **ba;
584#endif
585 nic_t *nic;
586} ring_info_t;
467 587
588/* Fifo specific structure */
589typedef struct fifo_info {
590 /* FIFO number */
591 int fifo_no;
592
593 /* Maximum TxDs per TxDL */
594 int max_txds;
595
596 /* Place holder of all the TX List's Phy and Virt addresses. */
597 list_info_hold_t *list_info;
598
599 /*
600 * Current offset within the tx FIFO where driver would write
601 * new Tx frame
602 */
603 tx_curr_put_info_t tx_curr_put_info;
604
605 /*
606 * Current offset within tx FIFO from where the driver would start freeing
607 * the buffers
608 */
609 tx_curr_get_info_t tx_curr_get_info;
610
611 nic_t *nic;
612}fifo_info_t;
613
614/* Infomation related to the Tx and Rx FIFOs and Rings of Xena
615 * is maintained in this structure.
616 */
617typedef struct mac_info {
468/* tx side stuff */ 618/* tx side stuff */
469 /* logical pointer of start of each Tx FIFO */ 619 /* logical pointer of start of each Tx FIFO */
470 TxFIFO_element_t __iomem *tx_FIFO_start[MAX_TX_FIFOS]; 620 TxFIFO_element_t __iomem *tx_FIFO_start[MAX_TX_FIFOS];
471 621
472/* Current offset within tx_FIFO_start, where driver would write new Tx frame*/ 622 /* Fifo specific structure */
473 tx_curr_put_info_t tx_curr_put_info[MAX_TX_FIFOS]; 623 fifo_info_t fifos[MAX_TX_FIFOS];
474 tx_curr_get_info_t tx_curr_get_info[MAX_TX_FIFOS]; 624
625/* rx side stuff */
626 /* Ring specific structure */
627 ring_info_t rings[MAX_RX_RINGS];
628
629 u16 rmac_pause_time;
630 u16 mc_pause_threshold_q0q3;
631 u16 mc_pause_threshold_q4q7;
475 632
476 void *stats_mem; /* orignal pointer to allocated mem */ 633 void *stats_mem; /* orignal pointer to allocated mem */
477 dma_addr_t stats_mem_phy; /* Physical address of the stat block */ 634 dma_addr_t stats_mem_phy; /* Physical address of the stat block */
@@ -485,12 +642,6 @@ typedef struct {
485 int usage_cnt; 642 int usage_cnt;
486} usr_addr_t; 643} usr_addr_t;
487 644
488/* Structure that holds the Phy and virt addresses of the Blocks */
489typedef struct rx_block_info {
490 RxD_t *block_virt_addr;
491 dma_addr_t block_dma_addr;
492} rx_block_info_t;
493
494/* Default Tunable parameters of the NIC. */ 645/* Default Tunable parameters of the NIC. */
495#define DEFAULT_FIFO_LEN 4096 646#define DEFAULT_FIFO_LEN 4096
496#define SMALL_RXD_CNT 30 * (MAX_RXDS_PER_BLOCK+1) 647#define SMALL_RXD_CNT 30 * (MAX_RXDS_PER_BLOCK+1)
@@ -499,7 +650,20 @@ typedef struct rx_block_info {
499#define LARGE_BLK_CNT 100 650#define LARGE_BLK_CNT 100
500 651
501/* Structure representing one instance of the NIC */ 652/* Structure representing one instance of the NIC */
502typedef struct s2io_nic { 653struct s2io_nic {
654#ifdef CONFIG_S2IO_NAPI
655 /*
656 * Count of packets to be processed in a given iteration, it will be indicated
657 * by the quota field of the device structure when NAPI is enabled.
658 */
659 int pkts_to_process;
660#endif
661 struct net_device *dev;
662 mac_info_t mac_control;
663 struct config_param config;
664 struct pci_dev *pdev;
665 void __iomem *bar0;
666 void __iomem *bar1;
503#define MAX_MAC_SUPPORTED 16 667#define MAX_MAC_SUPPORTED 16
504#define MAX_SUPPORTED_MULTICASTS MAX_MAC_SUPPORTED 668#define MAX_SUPPORTED_MULTICASTS MAX_MAC_SUPPORTED
505 669
@@ -507,33 +671,20 @@ typedef struct s2io_nic {
507 macaddr_t pre_mac_addr[MAX_MAC_SUPPORTED]; 671 macaddr_t pre_mac_addr[MAX_MAC_SUPPORTED];
508 672
509 struct net_device_stats stats; 673 struct net_device_stats stats;
510 void __iomem *bar0;
511 void __iomem *bar1;
512 struct config_param config;
513 mac_info_t mac_control;
514 int high_dma_flag; 674 int high_dma_flag;
515 int device_close_flag; 675 int device_close_flag;
516 int device_enabled_once; 676 int device_enabled_once;
517 677
518 char name[32]; 678 char name[50];
519 struct tasklet_struct task; 679 struct tasklet_struct task;
520 volatile unsigned long tasklet_status; 680 volatile unsigned long tasklet_status;
521 struct timer_list timer;
522 struct net_device *dev;
523 struct pci_dev *pdev;
524 681
525 u16 vendor_id; 682 /* Timer that handles I/O errors/exceptions */
526 u16 device_id; 683 struct timer_list alarm_timer;
527 u16 ccmd; 684
528 u32 cbar0_1; 685 /* Space to back up the PCI config space */
529 u32 cbar0_2; 686 u32 config_space[256 / sizeof(u32)];
530 u32 cbar1_1; 687
531 u32 cbar1_2;
532 u32 cirq;
533 u8 cache_line;
534 u32 rom_expansion;
535 u16 pcix_cmd;
536 u32 irq;
537 atomic_t rx_bufs_left[MAX_RX_RINGS]; 688 atomic_t rx_bufs_left[MAX_RX_RINGS];
538 689
539 spinlock_t tx_lock; 690 spinlock_t tx_lock;
@@ -558,27 +709,11 @@ typedef struct s2io_nic {
558 u16 tx_err_count; 709 u16 tx_err_count;
559 u16 rx_err_count; 710 u16 rx_err_count;
560 711
561#ifndef CONFIG_S2IO_NAPI
562 /* Index to the absolute position of the put pointer of Rx ring. */
563 int put_pos[MAX_RX_RINGS];
564#endif
565
566 /*
567 * Place holders for the virtual and physical addresses of
568 * all the Rx Blocks
569 */
570 rx_block_info_t rx_blocks[MAX_RX_RINGS][MAX_RX_BLOCKS_PER_RING];
571 int block_count[MAX_RX_RINGS];
572 int pkt_cnt[MAX_RX_RINGS];
573
574 /* Place holder of all the TX List's Phy and Virt addresses. */
575 list_info_hold_t *list_info[MAX_TX_FIFOS];
576
577 /* Id timer, used to blink NIC to physically identify NIC. */ 712 /* Id timer, used to blink NIC to physically identify NIC. */
578 struct timer_list id_timer; 713 struct timer_list id_timer;
579 714
580 /* Restart timer, used to restart NIC if the device is stuck and 715 /* Restart timer, used to restart NIC if the device is stuck and
581 * a schedule task that will set the correct Link state once the 716 * a schedule task that will set the correct Link state once the
582 * NIC's PHY has stabilized after a state change. 717 * NIC's PHY has stabilized after a state change.
583 */ 718 */
584#ifdef INIT_TQUEUE 719#ifdef INIT_TQUEUE
@@ -589,12 +724,12 @@ typedef struct s2io_nic {
589 struct work_struct set_link_task; 724 struct work_struct set_link_task;
590#endif 725#endif
591 726
592 /* Flag that can be used to turn on or turn off the Rx checksum 727 /* Flag that can be used to turn on or turn off the Rx checksum
593 * offload feature. 728 * offload feature.
594 */ 729 */
595 int rx_csum; 730 int rx_csum;
596 731
597 /* after blink, the adapter must be restored with original 732 /* after blink, the adapter must be restored with original
598 * values. 733 * values.
599 */ 734 */
600 u64 adapt_ctrl_org; 735 u64 adapt_ctrl_org;
@@ -604,16 +739,19 @@ typedef struct s2io_nic {
604#define LINK_DOWN 1 739#define LINK_DOWN 1
605#define LINK_UP 2 740#define LINK_UP 2
606 741
607#ifdef CONFIG_2BUFF_MODE
608 /* Buffer Address store. */
609 buffAdd_t **ba[MAX_RX_RINGS];
610#endif
611 int task_flag; 742 int task_flag;
612#define CARD_DOWN 1 743#define CARD_DOWN 1
613#define CARD_UP 2 744#define CARD_UP 2
614 atomic_t card_state; 745 atomic_t card_state;
615 volatile unsigned long link_state; 746 volatile unsigned long link_state;
616} nic_t; 747 struct vlan_group *vlgrp;
748#define XFRAME_I_DEVICE 1
749#define XFRAME_II_DEVICE 2
750 u8 device_type;
751
752 spinlock_t rx_lock;
753 atomic_t isr_cnt;
754};
617 755
618#define RESET_ERROR 1; 756#define RESET_ERROR 1;
619#define CMD_ERROR 2; 757#define CMD_ERROR 2;
@@ -622,9 +760,10 @@ typedef struct s2io_nic {
622#ifndef readq 760#ifndef readq
623static inline u64 readq(void __iomem *addr) 761static inline u64 readq(void __iomem *addr)
624{ 762{
625 u64 ret = readl(addr + 4); 763 u64 ret = 0;
626 ret <<= 32; 764 ret = readl(addr + 4);
627 ret |= readl(addr); 765 (u64) ret <<= 32;
766 (u64) ret |= readl(addr);
628 767
629 return ret; 768 return ret;
630} 769}
@@ -637,10 +776,10 @@ static inline void writeq(u64 val, void __iomem *addr)
637 writel((u32) (val >> 32), (addr + 4)); 776 writel((u32) (val >> 32), (addr + 4));
638} 777}
639 778
640/* In 32 bit modes, some registers have to be written in a 779/* In 32 bit modes, some registers have to be written in a
641 * particular order to expect correct hardware operation. The 780 * particular order to expect correct hardware operation. The
642 * macro SPECIAL_REG_WRITE is used to perform such ordered 781 * macro SPECIAL_REG_WRITE is used to perform such ordered
643 * writes. Defines UF (Upper First) and LF (Lower First) will 782 * writes. Defines UF (Upper First) and LF (Lower First) will
644 * be used to specify the required write order. 783 * be used to specify the required write order.
645 */ 784 */
646#define UF 1 785#define UF 1
@@ -716,6 +855,7 @@ static inline void SPECIAL_REG_WRITE(u64 val, void __iomem *addr, int order)
716#define PCC_FB_ECC_ERR vBIT(0xff, 16, 8) /* Interrupt to indicate 855#define PCC_FB_ECC_ERR vBIT(0xff, 16, 8) /* Interrupt to indicate
717 PCC_FB_ECC Error. */ 856 PCC_FB_ECC Error. */
718 857
858#define RXD_GET_VLAN_TAG(Control_2) (u16)(Control_2 & MASK_VLAN_TAG)
719/* 859/*
720 * Prototype declaration. 860 * Prototype declaration.
721 */ 861 */
@@ -725,36 +865,30 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev);
725static int init_shared_mem(struct s2io_nic *sp); 865static int init_shared_mem(struct s2io_nic *sp);
726static void free_shared_mem(struct s2io_nic *sp); 866static void free_shared_mem(struct s2io_nic *sp);
727static int init_nic(struct s2io_nic *nic); 867static int init_nic(struct s2io_nic *nic);
728#ifndef CONFIG_S2IO_NAPI 868static void rx_intr_handler(ring_info_t *ring_data);
729static void rx_intr_handler(struct s2io_nic *sp); 869static void tx_intr_handler(fifo_info_t *fifo_data);
730#endif
731static void tx_intr_handler(struct s2io_nic *sp);
732static void alarm_intr_handler(struct s2io_nic *sp); 870static void alarm_intr_handler(struct s2io_nic *sp);
733 871
734static int s2io_starter(void); 872static int s2io_starter(void);
735static void s2io_closer(void); 873void s2io_closer(void);
736static void s2io_tx_watchdog(struct net_device *dev); 874static void s2io_tx_watchdog(struct net_device *dev);
737static void s2io_tasklet(unsigned long dev_addr); 875static void s2io_tasklet(unsigned long dev_addr);
738static void s2io_set_multicast(struct net_device *dev); 876static void s2io_set_multicast(struct net_device *dev);
739#ifndef CONFIG_2BUFF_MODE 877static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp);
740static int rx_osm_handler(nic_t * sp, u16 len, RxD_t * rxdp, int ring_no); 878void s2io_link(nic_t * sp, int link);
741#else 879void s2io_reset(nic_t * sp);
742static int rx_osm_handler(nic_t * sp, RxD_t * rxdp, int ring_no, 880#if defined(CONFIG_S2IO_NAPI)
743 buffAdd_t * ba);
744#endif
745static void s2io_link(nic_t * sp, int link);
746static void s2io_reset(nic_t * sp);
747#ifdef CONFIG_S2IO_NAPI
748static int s2io_poll(struct net_device *dev, int *budget); 881static int s2io_poll(struct net_device *dev, int *budget);
749#endif 882#endif
750static void s2io_init_pci(nic_t * sp); 883static void s2io_init_pci(nic_t * sp);
751static int s2io_set_mac_addr(struct net_device *dev, u8 * addr); 884int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
885static void s2io_alarm_handle(unsigned long data);
752static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs); 886static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs);
753static int verify_xena_quiescence(u64 val64, int flag); 887static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
754static struct ethtool_ops netdev_ethtool_ops; 888static struct ethtool_ops netdev_ethtool_ops;
755static void s2io_set_link(unsigned long data); 889static void s2io_set_link(unsigned long data);
756static int s2io_set_swapper(nic_t * sp); 890int s2io_set_swapper(nic_t * sp);
757static void s2io_card_down(nic_t * nic); 891static void s2io_card_down(nic_t *nic);
758static int s2io_card_up(nic_t * nic); 892static int s2io_card_up(nic_t *nic);
759 893int get_xena_rev_id(struct pci_dev *pdev);
760#endif /* _S2IO_H */ 894#endif /* _S2IO_H */
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index e15369c8d165..d6388e1533f0 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -90,7 +90,6 @@ static int sb1000_close(struct net_device *dev);
90 90
91 91
92/* SB1000 hardware routines to be used during open/configuration phases */ 92/* SB1000 hardware routines to be used during open/configuration phases */
93static inline void nicedelay(unsigned long usecs);
94static inline int card_wait_for_busy_clear(const int ioaddr[], 93static inline int card_wait_for_busy_clear(const int ioaddr[],
95 const char* name); 94 const char* name);
96static inline int card_wait_for_ready(const int ioaddr[], const char* name, 95static inline int card_wait_for_ready(const int ioaddr[], const char* name,
@@ -254,13 +253,6 @@ static struct pnp_driver sb1000_driver = {
254 253
255static const int TimeOutJiffies = (875 * HZ) / 100; 254static const int TimeOutJiffies = (875 * HZ) / 100;
256 255
257static inline void nicedelay(unsigned long usecs)
258{
259 current->state = TASK_INTERRUPTIBLE;
260 schedule_timeout(HZ);
261 return;
262}
263
264/* Card Wait For Busy Clear (cannot be used during an interrupt) */ 256/* Card Wait For Busy Clear (cannot be used during an interrupt) */
265static inline int 257static inline int
266card_wait_for_busy_clear(const int ioaddr[], const char* name) 258card_wait_for_busy_clear(const int ioaddr[], const char* name)
@@ -475,7 +467,7 @@ sb1000_reset(const int ioaddr[], const char* name)
475 udelay(1000); 467 udelay(1000);
476 outb(0x0, port); 468 outb(0x0, port);
477 inb(port); 469 inb(port);
478 nicedelay(60000); 470 ssleep(1);
479 outb(0x4, port); 471 outb(0x4, port);
480 inb(port); 472 inb(port);
481 udelay(1000); 473 udelay(1000);
@@ -537,7 +529,7 @@ sb1000_activate(const int ioaddr[], const char* name)
537 const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00}; 529 const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00};
538 const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00}; 530 const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};
539 531
540 nicedelay(50000); 532 ssleep(1);
541 if ((status = card_send_command(ioaddr, name, Command0, st))) 533 if ((status = card_send_command(ioaddr, name, Command0, st)))
542 return status; 534 return status;
543 if ((status = card_send_command(ioaddr, name, Command1, st))) 535 if ((status = card_send_command(ioaddr, name, Command1, st)))
@@ -944,7 +936,7 @@ sb1000_open(struct net_device *dev)
944 /* initialize sb1000 */ 936 /* initialize sb1000 */
945 if ((status = sb1000_reset(ioaddr, name))) 937 if ((status = sb1000_reset(ioaddr, name)))
946 return status; 938 return status;
947 nicedelay(200000); 939 ssleep(1);
948 if ((status = sb1000_check_CRC(ioaddr, name))) 940 if ((status = sb1000_check_CRC(ioaddr, name)))
949 return status; 941 return status;
950 942
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index fd2e7c374906..7abd55a4fb21 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -963,11 +963,11 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
963 /* 963 /*
964 * Do not interrupt per DMA transfer. 964 * Do not interrupt per DMA transfer.
965 */ 965 */
966 dsc->dscr_a = virt_to_phys(sb_new->tail) | 966 dsc->dscr_a = virt_to_phys(sb_new->data) |
967 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) | 967 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) |
968 0; 968 0;
969#else 969#else
970 dsc->dscr_a = virt_to_phys(sb_new->tail) | 970 dsc->dscr_a = virt_to_phys(sb_new->data) |
971 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) | 971 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) |
972 M_DMA_DSCRA_INTERRUPT; 972 M_DMA_DSCRA_INTERRUPT;
973#endif 973#endif
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c
index 20edeb345792..3ad0b6751f6f 100644
--- a/drivers/net/shaper.c
+++ b/drivers/net/shaper.c
@@ -135,10 +135,8 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
135{ 135{
136 struct shaper *shaper = dev->priv; 136 struct shaper *shaper = dev->priv;
137 struct sk_buff *ptr; 137 struct sk_buff *ptr;
138 138
139 if (down_trylock(&shaper->sem)) 139 spin_lock(&shaper->lock);
140 return -1;
141
142 ptr=shaper->sendq.prev; 140 ptr=shaper->sendq.prev;
143 141
144 /* 142 /*
@@ -232,7 +230,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
232 shaper->stats.collisions++; 230 shaper->stats.collisions++;
233 } 231 }
234 shaper_kick(shaper); 232 shaper_kick(shaper);
235 up(&shaper->sem); 233 spin_unlock(&shaper->lock);
236 return 0; 234 return 0;
237} 235}
238 236
@@ -271,11 +269,9 @@ static void shaper_timer(unsigned long data)
271{ 269{
272 struct shaper *shaper = (struct shaper *)data; 270 struct shaper *shaper = (struct shaper *)data;
273 271
274 if (!down_trylock(&shaper->sem)) { 272 spin_lock(&shaper->lock);
275 shaper_kick(shaper); 273 shaper_kick(shaper);
276 up(&shaper->sem); 274 spin_unlock(&shaper->lock);
277 } else
278 mod_timer(&shaper->timer, jiffies);
279} 275}
280 276
281/* 277/*
@@ -332,21 +328,6 @@ static void shaper_kick(struct shaper *shaper)
332 328
333 329
334/* 330/*
335 * Flush the shaper queues on a closedown
336 */
337
338static void shaper_flush(struct shaper *shaper)
339{
340 struct sk_buff *skb;
341
342 down(&shaper->sem);
343 while((skb=skb_dequeue(&shaper->sendq))!=NULL)
344 dev_kfree_skb(skb);
345 shaper_kick(shaper);
346 up(&shaper->sem);
347}
348
349/*
350 * Bring the interface up. We just disallow this until a 331 * Bring the interface up. We just disallow this until a
351 * bind. 332 * bind.
352 */ 333 */
@@ -375,7 +356,15 @@ static int shaper_open(struct net_device *dev)
375static int shaper_close(struct net_device *dev) 356static int shaper_close(struct net_device *dev)
376{ 357{
377 struct shaper *shaper=dev->priv; 358 struct shaper *shaper=dev->priv;
378 shaper_flush(shaper); 359 struct sk_buff *skb;
360
361 while ((skb = skb_dequeue(&shaper->sendq)) != NULL)
362 dev_kfree_skb(skb);
363
364 spin_lock_bh(&shaper->lock);
365 shaper_kick(shaper);
366 spin_unlock_bh(&shaper->lock);
367
379 del_timer_sync(&shaper->timer); 368 del_timer_sync(&shaper->timer);
380 return 0; 369 return 0;
381} 370}
@@ -576,6 +565,7 @@ static void shaper_init_priv(struct net_device *dev)
576 init_timer(&sh->timer); 565 init_timer(&sh->timer);
577 sh->timer.function=shaper_timer; 566 sh->timer.function=shaper_timer;
578 sh->timer.data=(unsigned long)sh; 567 sh->timer.data=(unsigned long)sh;
568 spin_lock_init(&sh->lock);
579} 569}
580 570
581/* 571/*
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index 3107aed0fb51..23b713c700b3 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -66,6 +66,7 @@
66#include <linux/ethtool.h> 66#include <linux/ethtool.h>
67#include <linux/crc32.h> 67#include <linux/crc32.h>
68#include <linux/bitops.h> 68#include <linux/bitops.h>
69#include <linux/dma-mapping.h>
69 70
70#include <asm/processor.h> /* Processor type for cache alignment. */ 71#include <asm/processor.h> /* Processor type for cache alignment. */
71#include <asm/io.h> 72#include <asm/io.h>
@@ -93,8 +94,6 @@ static int sis900_debug = -1; /* Use SIS900_DEF_MSG as value */
93 94
94/* Time in jiffies before concluding the transmitter is hung. */ 95/* Time in jiffies before concluding the transmitter is hung. */
95#define TX_TIMEOUT (4*HZ) 96#define TX_TIMEOUT (4*HZ)
96/* SiS 900 is capable of 32 bits BM DMA */
97#define SIS900_DMA_MASK 0xffffffff
98 97
99enum { 98enum {
100 SIS_900 = 0, 99 SIS_900 = 0,
@@ -414,7 +413,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
414 ret = pci_enable_device(pci_dev); 413 ret = pci_enable_device(pci_dev);
415 if(ret) return ret; 414 if(ret) return ret;
416 415
417 i = pci_set_dma_mask(pci_dev, SIS900_DMA_MASK); 416 i = pci_set_dma_mask(pci_dev, DMA_32BIT_MASK);
418 if(i){ 417 if(i){
419 printk(KERN_ERR "sis900.c: architecture does not support" 418 printk(KERN_ERR "sis900.c: architecture does not support"
420 "32bit PCI busmaster DMA\n"); 419 "32bit PCI busmaster DMA\n");
@@ -1155,7 +1154,7 @@ sis900_init_rx_ring(struct net_device *net_dev)
1155 sis_priv->rx_skbuff[i] = skb; 1154 sis_priv->rx_skbuff[i] = skb;
1156 sis_priv->rx_ring[i].cmdsts = RX_BUF_SIZE; 1155 sis_priv->rx_ring[i].cmdsts = RX_BUF_SIZE;
1157 sis_priv->rx_ring[i].bufptr = pci_map_single(sis_priv->pci_dev, 1156 sis_priv->rx_ring[i].bufptr = pci_map_single(sis_priv->pci_dev,
1158 skb->tail, RX_BUF_SIZE, PCI_DMA_FROMDEVICE); 1157 skb->data, RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
1159 } 1158 }
1160 sis_priv->dirty_rx = (unsigned int) (i - NUM_RX_DESC); 1159 sis_priv->dirty_rx = (unsigned int) (i - NUM_RX_DESC);
1161 1160
@@ -1777,7 +1776,7 @@ static int sis900_rx(struct net_device *net_dev)
1777 sis_priv->rx_skbuff[entry] = skb; 1776 sis_priv->rx_skbuff[entry] = skb;
1778 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; 1777 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE;
1779 sis_priv->rx_ring[entry].bufptr = 1778 sis_priv->rx_ring[entry].bufptr =
1780 pci_map_single(sis_priv->pci_dev, skb->tail, 1779 pci_map_single(sis_priv->pci_dev, skb->data,
1781 RX_BUF_SIZE, PCI_DMA_FROMDEVICE); 1780 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
1782 sis_priv->dirty_rx++; 1781 sis_priv->dirty_rx++;
1783 } 1782 }
@@ -1810,7 +1809,7 @@ static int sis900_rx(struct net_device *net_dev)
1810 sis_priv->rx_skbuff[entry] = skb; 1809 sis_priv->rx_skbuff[entry] = skb;
1811 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; 1810 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE;
1812 sis_priv->rx_ring[entry].bufptr = 1811 sis_priv->rx_ring[entry].bufptr =
1813 pci_map_single(sis_priv->pci_dev, skb->tail, 1812 pci_map_single(sis_priv->pci_dev, skb->data,
1814 RX_BUF_SIZE, PCI_DMA_FROMDEVICE); 1813 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
1815 } 1814 }
1816 } 1815 }
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 1ccb2989001c..6ee4771addf1 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -112,6 +112,7 @@
112#include <linux/moduleparam.h> 112#include <linux/moduleparam.h>
113#include <linux/init.h> 113#include <linux/init.h>
114#include <linux/proc_fs.h> 114#include <linux/proc_fs.h>
115#include <linux/dma-mapping.h>
115 116
116#include "h/skdrv1st.h" 117#include "h/skdrv1st.h"
117#include "h/skdrv2nd.h" 118#include "h/skdrv2nd.h"
@@ -4912,8 +4913,8 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4912 goto out; 4913 goto out;
4913 4914
4914 /* Configure DMA attributes. */ 4915 /* Configure DMA attributes. */
4915 if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL) && 4916 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
4916 pci_set_dma_mask(pdev, (u64) 0xffffffff)) 4917 pci_set_dma_mask(pdev, DMA_32BIT_MASK))
4917 goto out_disable_device; 4918 goto out_disable_device;
4918 4919
4919 4920
@@ -5132,6 +5133,84 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
5132 kfree(pAC); 5133 kfree(pAC);
5133} 5134}
5134 5135
5136#ifdef CONFIG_PM
5137static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
5138{
5139 struct net_device *dev = pci_get_drvdata(pdev);
5140 DEV_NET *pNet = netdev_priv(dev);
5141 SK_AC *pAC = pNet->pAC;
5142 struct net_device *otherdev = pAC->dev[1];
5143
5144 if (netif_running(dev)) {
5145 netif_carrier_off(dev);
5146 DoPrintInterfaceChange = SK_FALSE;
5147 SkDrvDeInitAdapter(pAC, 0); /* performs SkGeClose */
5148 netif_device_detach(dev);
5149 }
5150 if (otherdev != dev) {
5151 if (netif_running(otherdev)) {
5152 netif_carrier_off(otherdev);
5153 DoPrintInterfaceChange = SK_FALSE;
5154 SkDrvDeInitAdapter(pAC, 1); /* performs SkGeClose */
5155 netif_device_detach(otherdev);
5156 }
5157 }
5158
5159 pci_save_state(pdev);
5160 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
5161 if (pAC->AllocFlag & SK_ALLOC_IRQ) {
5162 free_irq(dev->irq, dev);
5163 }
5164 pci_disable_device(pdev);
5165 pci_set_power_state(pdev, pci_choose_state(pdev, state));
5166
5167 return 0;
5168}
5169
5170static int skge_resume(struct pci_dev *pdev)
5171{
5172 struct net_device *dev = pci_get_drvdata(pdev);
5173 DEV_NET *pNet = netdev_priv(dev);
5174 SK_AC *pAC = pNet->pAC;
5175 struct net_device *otherdev = pAC->dev[1];
5176 int ret;
5177
5178 pci_set_power_state(pdev, PCI_D0);
5179 pci_restore_state(pdev);
5180 pci_enable_device(pdev);
5181 pci_set_master(pdev);
5182 if (pAC->GIni.GIMacsFound == 2)
5183 ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
5184 else
5185 ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, pAC->Name, dev);
5186 if (ret) {
5187 printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq);
5188 pAC->AllocFlag &= ~SK_ALLOC_IRQ;
5189 dev->irq = 0;
5190 pci_disable_device(pdev);
5191 return -EBUSY;
5192 }
5193
5194 netif_device_attach(dev);
5195 if (netif_running(dev)) {
5196 DoPrintInterfaceChange = SK_FALSE;
5197 SkDrvInitAdapter(pAC, 0); /* first device */
5198 }
5199 if (otherdev != dev) {
5200 netif_device_attach(otherdev);
5201 if (netif_running(otherdev)) {
5202 DoPrintInterfaceChange = SK_FALSE;
5203 SkDrvInitAdapter(pAC, 1); /* second device */
5204 }
5205 }
5206
5207 return 0;
5208}
5209#else
5210#define skge_suspend NULL
5211#define skge_resume NULL
5212#endif
5213
5135static struct pci_device_id skge_pci_tbl[] = { 5214static struct pci_device_id skge_pci_tbl[] = {
5136 { PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 5215 { PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5137 { PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 5216 { PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
@@ -5157,6 +5236,8 @@ static struct pci_driver skge_driver = {
5157 .id_table = skge_pci_tbl, 5236 .id_table = skge_pci_tbl,
5158 .probe = skge_probe_one, 5237 .probe = skge_probe_one,
5159 .remove = __devexit_p(skge_remove_one), 5238 .remove = __devexit_p(skge_remove_one),
5239 .suspend = skge_suspend,
5240 .resume = skge_resume,
5160}; 5241};
5161 5242
5162static int __init skge_init(void) 5243static int __init skge_init(void)
diff --git a/drivers/net/sk98lin/skgeinit.c b/drivers/net/sk98lin/skgeinit.c
index df4483429a77..6cb49dd02251 100644
--- a/drivers/net/sk98lin/skgeinit.c
+++ b/drivers/net/sk98lin/skgeinit.c
@@ -2016,7 +2016,7 @@ SK_IOC IoC) /* IO context */
2016 * we set the PHY to coma mode and switch to D3 power state. 2016 * we set the PHY to coma mode and switch to D3 power state.
2017 */ 2017 */
2018 if (pAC->GIni.GIYukonLite && 2018 if (pAC->GIni.GIYukonLite &&
2019 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 2019 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2020 2020
2021 /* for all ports switch PHY to coma mode */ 2021 /* for all ports switch PHY to coma mode */
2022 for (i = 0; i < pAC->GIni.GIMacsFound; i++) { 2022 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
diff --git a/drivers/net/sk98lin/skxmac2.c b/drivers/net/sk98lin/skxmac2.c
index 94a09deecb32..42d2d963150a 100644
--- a/drivers/net/sk98lin/skxmac2.c
+++ b/drivers/net/sk98lin/skxmac2.c
@@ -1065,7 +1065,7 @@ int Port) /* Port Index (MAC_1 + n) */
1065 1065
1066 /* WA code for COMA mode */ 1066 /* WA code for COMA mode */
1067 if (pAC->GIni.GIYukonLite && 1067 if (pAC->GIni.GIYukonLite &&
1068 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 1068 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
1069 1069
1070 SK_IN32(IoC, B2_GP_IO, &DWord); 1070 SK_IN32(IoC, B2_GP_IO, &DWord);
1071 1071
@@ -1110,7 +1110,7 @@ int Port) /* Port Index (MAC_1 + n) */
1110 1110
1111 /* WA code for COMA mode */ 1111 /* WA code for COMA mode */
1112 if (pAC->GIni.GIYukonLite && 1112 if (pAC->GIni.GIYukonLite &&
1113 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 1113 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
1114 1114
1115 SK_IN32(IoC, B2_GP_IO, &DWord); 1115 SK_IN32(IoC, B2_GP_IO, &DWord);
1116 1116
@@ -2126,7 +2126,7 @@ SK_U8 Mode) /* low power mode */
2126 int Ret = 0; 2126 int Ret = 0;
2127 2127
2128 if (pAC->GIni.GIYukonLite && 2128 if (pAC->GIni.GIYukonLite &&
2129 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 2129 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2130 2130
2131 /* save current power mode */ 2131 /* save current power mode */
2132 LastMode = pAC->GIni.GP[Port].PPhyPowerState; 2132 LastMode = pAC->GIni.GP[Port].PPhyPowerState;
@@ -2253,7 +2253,7 @@ int Port) /* Port Index (e.g. MAC_1) */
2253 int Ret = 0; 2253 int Ret = 0;
2254 2254
2255 if (pAC->GIni.GIYukonLite && 2255 if (pAC->GIni.GIYukonLite &&
2256 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 2256 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2257 2257
2258 /* save current power mode */ 2258 /* save current power mode */
2259 LastMode = pAC->GIni.GP[Port].PPhyPowerState; 2259 LastMode = pAC->GIni.GP[Port].PPhyPowerState;
diff --git a/drivers/net/skfp/Makefile b/drivers/net/skfp/Makefile
index 6cfccfb7889f..cb23580fcffa 100644
--- a/drivers/net/skfp/Makefile
+++ b/drivers/net/skfp/Makefile
@@ -6,8 +6,8 @@ obj-$(CONFIG_SKFP) += skfp.o
6 6
7skfp-objs := skfddi.o hwmtm.o fplustm.o smt.o cfm.o \ 7skfp-objs := skfddi.o hwmtm.o fplustm.o smt.o cfm.o \
8 ecm.o pcmplc.o pmf.o queue.o rmt.o \ 8 ecm.o pcmplc.o pmf.o queue.o rmt.o \
9 smtdef.o smtinit.o smttimer.o srf.o lnkstat.o \ 9 smtdef.o smtinit.o smttimer.o srf.o hwt.o \
10 smtparse.o hwt.o drvfbi.o ess.o 10 drvfbi.o ess.o
11 11
12# NOTE: 12# NOTE:
13# Compiling this driver produces some warnings (and some more are 13# Compiling this driver produces some warnings (and some more are
diff --git a/drivers/net/skfp/drvfbi.c b/drivers/net/skfp/drvfbi.c
index 052e841ba187..5b475833f645 100644
--- a/drivers/net/skfp/drvfbi.c
+++ b/drivers/net/skfp/drvfbi.c
@@ -105,8 +105,8 @@ extern int AIX_vpdReadByte() ;
105#endif 105#endif
106 106
107 107
108/* Prototypes of local functions. */ 108/* Prototype of a local function. */
109void smt_stop_watchdog(struct s_smc *smc); 109static void smt_stop_watchdog(struct s_smc *smc);
110 110
111#ifdef MCA 111#ifdef MCA
112static int read_card_id() ; 112static int read_card_id() ;
@@ -631,7 +631,7 @@ void plc_clear_irq(struct s_smc *smc, int p)
631 * LED_Y_OFF just switch yellow LED off 631 * LED_Y_OFF just switch yellow LED off
632 * LED_Y_ON just switch yello LED on 632 * LED_Y_ON just switch yello LED on
633 */ 633 */
634void led_indication(struct s_smc *smc, int led_event) 634static void led_indication(struct s_smc *smc, int led_event)
635{ 635{
636 /* use smc->hw.mac_ring_is_up == TRUE 636 /* use smc->hw.mac_ring_is_up == TRUE
637 * as indication for Ring Operational 637 * as indication for Ring Operational
@@ -764,122 +764,6 @@ void llc_recover_tx(struct s_smc *smc)
764#endif 764#endif
765} 765}
766 766
767/*--------------------------- DMA init ----------------------------*/
768#ifdef ISA
769
770/*
771 * init DMA
772 */
773void init_dma(struct s_smc *smc, int dma)
774{
775 SK_UNUSED(smc) ;
776
777 /*
778 * set cascade mode,
779 * clear mask bit (enable DMA cannal)
780 */
781 if (dma > 3) {
782 outp(0xd6,(dma & 0x03) | 0xc0) ;
783 outp(0xd4, dma & 0x03) ;
784 }
785 else {
786 outp(0x0b,(dma & 0x03) | 0xc0) ;
787 outp(0x0a,dma & 0x03) ;
788 }
789}
790
791/*
792 * disable DMA
793 */
794void dis_dma(struct s_smc *smc, int dma)
795{
796 SK_UNUSED(smc) ;
797
798 /*
799 * set mask bit (disable DMA cannal)
800 */
801 if (dma > 3) {
802 outp(0xd4,(dma & 0x03) | 0x04) ;
803 }
804 else {
805 outp(0x0a,(dma & 0x03) | 0x04) ;
806 }
807}
808
809#endif /* ISA */
810
811#ifdef EISA
812
813/*arrays with io addresses of dma controller length and address registers*/
814static const int cntr[8] = { 0x001,0x003,0x005,0x007,0,0x0c6,0x0ca,0x0ce } ;
815static const int base[8] = { 0x000,0x002,0x004,0x006,0,0x0c4,0x0c8,0x0cc } ;
816static const int page[8] = { 0x087,0x083,0x081,0x082,0,0x08b,0x089,0x08a } ;
817
818void init_dma(struct s_smc *smc, int dma)
819{
820 /*
821 * extended mode register
822 * 32 bit IO
823 * type c
824 * TC output
825 * disable stop
826 */
827
828 /* mode read (write) demand */
829 smc->hw.dma_rmode = (dma & 3) | 0x08 | 0x0 ;
830 smc->hw.dma_wmode = (dma & 3) | 0x04 | 0x0 ;
831
832 /* 32 bit IO's, burst DMA mode (type "C") */
833 smc->hw.dma_emode = (dma & 3) | 0x08 | 0x30 ;
834
835 outp((dma < 4) ? 0x40b : 0x4d6,smc->hw.dma_emode) ;
836
837 /* disable chaining */
838 outp((dma < 4) ? 0x40a : 0x4d4,(dma&3)) ;
839
840 /*load dma controller addresses for fast access during set dma*/
841 smc->hw.dma_base_word_count = cntr[smc->hw.dma];
842 smc->hw.dma_base_address = base[smc->hw.dma];
843 smc->hw.dma_base_address_page = page[smc->hw.dma];
844
845}
846
847void dis_dma(struct s_smc *smc, int dma)
848{
849 SK_UNUSED(smc) ;
850
851 outp((dma < 4) ? 0x0a : 0xd4,(dma&3)|4) ;/* mask bit */
852}
853#endif /* EISA */
854
855#ifdef MCA
856void init_dma(struct s_smc *smc, int dma)
857{
858 SK_UNUSED(smc) ;
859 SK_UNUSED(dma) ;
860}
861
862void dis_dma(struct s_smc *smc, int dma)
863{
864 SK_UNUSED(smc) ;
865 SK_UNUSED(dma) ;
866}
867#endif
868
869#ifdef PCI
870void init_dma(struct s_smc *smc, int dma)
871{
872 SK_UNUSED(smc) ;
873 SK_UNUSED(dma) ;
874}
875
876void dis_dma(struct s_smc *smc, int dma)
877{
878 SK_UNUSED(smc) ;
879 SK_UNUSED(dma) ;
880}
881#endif
882
883#ifdef MULT_OEM 767#ifdef MULT_OEM
884static int is_equal_num(char comp1[], char comp2[], int num) 768static int is_equal_num(char comp1[], char comp2[], int num)
885{ 769{
@@ -1407,7 +1291,7 @@ void smt_start_watchdog(struct s_smc *smc)
1407#endif /* DEBUG */ 1291#endif /* DEBUG */
1408} 1292}
1409 1293
1410void smt_stop_watchdog(struct s_smc *smc) 1294static void smt_stop_watchdog(struct s_smc *smc)
1411{ 1295{
1412 SK_UNUSED(smc) ; /* Make LINT happy. */ 1296 SK_UNUSED(smc) ; /* Make LINT happy. */
1413#ifndef DEBUG 1297#ifndef DEBUG
@@ -1422,104 +1306,6 @@ void smt_stop_watchdog(struct s_smc *smc)
1422} 1306}
1423 1307
1424#ifdef PCI 1308#ifdef PCI
1425static char get_rom_byte(struct s_smc *smc, u_short addr)
1426{
1427 GET_PAGE(addr) ;
1428 return (READ_PROM(ADDR(B2_FDP))) ;
1429}
1430
1431/*
1432 * ROM image defines
1433 */
1434#define ROM_SIG_1 0
1435#define ROM_SIG_2 1
1436#define PCI_DATA_1 0x18
1437#define PCI_DATA_2 0x19
1438
1439/*
1440 * PCI data structure defines
1441 */
1442#define VPD_DATA_1 0x08
1443#define VPD_DATA_2 0x09
1444#define IMAGE_LEN_1 0x10
1445#define IMAGE_LEN_2 0x11
1446#define CODE_TYPE 0x14
1447#define INDICATOR 0x15
1448
1449/*
1450 * BEGIN_MANUAL_ENTRY(mac_drv_vpd_read)
1451 * mac_drv_vpd_read(smc,buf,size,image)
1452 *
1453 * function DOWNCALL (FDDIWARE)
1454 * reads the VPD data of the FPROM and writes it into the
1455 * buffer
1456 *
1457 * para buf points to the buffer for the VPD data
1458 * size size of the VPD data buffer
1459 * image boot image; code type of the boot image
1460 * image = 0 Intel x86, PC-AT compatible
1461 * 1 OPENBOOT standard for PCI
1462 * 2-FF reserved
1463 *
1464 * returns len number of VPD data bytes read form the FPROM
1465 * <0 number of read bytes
1466 * >0 error: data invalid
1467 *
1468 * END_MANUAL_ENTRY
1469 */
1470int mac_drv_vpd_read(struct s_smc *smc, char *buf, int size, char image)
1471{
1472 u_short ibase ;
1473 u_short pci_base ;
1474 u_short vpd ;
1475 int len ;
1476
1477 len = 0 ;
1478 ibase = 0 ;
1479 /*
1480 * as long images defined
1481 */
1482 while (get_rom_byte(smc,ibase+ROM_SIG_1) == 0x55 &&
1483 (u_char) get_rom_byte(smc,ibase+ROM_SIG_2) == 0xaa) {
1484 /*
1485 * get the pointer to the PCI data structure
1486 */
1487 pci_base = ibase + get_rom_byte(smc,ibase+PCI_DATA_1) +
1488 (get_rom_byte(smc,ibase+PCI_DATA_2) << 8) ;
1489
1490 if (image == get_rom_byte(smc,pci_base+CODE_TYPE)) {
1491 /*
1492 * we have the right image, read the VPD data
1493 */
1494 vpd = ibase + get_rom_byte(smc,pci_base+VPD_DATA_1) +
1495 (get_rom_byte(smc,pci_base+VPD_DATA_2) << 8) ;
1496 if (vpd == ibase) {
1497 break ; /* no VPD data */
1498 }
1499 for (len = 0; len < size; len++,buf++,vpd++) {
1500 *buf = get_rom_byte(smc,vpd) ;
1501 }
1502 break ;
1503 }
1504 else {
1505 /*
1506 * try the next image
1507 */
1508 if (get_rom_byte(smc,pci_base+INDICATOR) & 0x80) {
1509 break ; /* this was the last image */
1510 }
1511 ibase = ibase + get_rom_byte(smc,ibase+IMAGE_LEN_1) +
1512 (get_rom_byte(smc,ibase+IMAGE_LEN_2) << 8) ;
1513 }
1514 }
1515
1516 return(len) ;
1517}
1518
1519void mac_drv_pci_fix(struct s_smc *smc, u_long fix_value)
1520{
1521 smc->hw.pci_fix_value = fix_value ;
1522}
1523 1309
1524void mac_do_pci_fix(struct s_smc *smc) 1310void mac_do_pci_fix(struct s_smc *smc)
1525{ 1311{
diff --git a/drivers/net/skfp/ess.c b/drivers/net/skfp/ess.c
index fd39b4b2ef7d..62b01328c496 100644
--- a/drivers/net/skfp/ess.c
+++ b/drivers/net/skfp/ess.c
@@ -102,7 +102,7 @@ void ess_timer_poll(struct s_smc *smc);
102void ess_para_change(struct s_smc *smc); 102void ess_para_change(struct s_smc *smc);
103int ess_raf_received_pack(struct s_smc *smc, SMbuf *mb, struct smt_header *sm, 103int ess_raf_received_pack(struct s_smc *smc, SMbuf *mb, struct smt_header *sm,
104 int fs); 104 int fs);
105int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead); 105static int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead);
106 106
107 107
108/* 108/*
@@ -375,7 +375,7 @@ int ess_raf_received_pack(struct s_smc *smc, SMbuf *mb, struct smt_header *sm,
375 * determines the synchronous bandwidth, set the TSYNC register and the 375 * determines the synchronous bandwidth, set the TSYNC register and the
376 * mib variables SBAPayload, SBAOverhead and fddiMACT-NEG. 376 * mib variables SBAPayload, SBAOverhead and fddiMACT-NEG.
377 */ 377 */
378int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead) 378static int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead)
379{ 379{
380 /* 380 /*
381 * determine the synchronous bandwidth (sync_bw) in bytes per T-NEG, 381 * determine the synchronous bandwidth (sync_bw) in bytes per T-NEG,
diff --git a/drivers/net/skfp/fplustm.c b/drivers/net/skfp/fplustm.c
index 76e78442fc24..a2ed47f1cc70 100644
--- a/drivers/net/skfp/fplustm.c
+++ b/drivers/net/skfp/fplustm.c
@@ -1117,30 +1117,6 @@ void mac_clear_multicast(struct s_smc *smc)
1117/* 1117/*
1118 BEGIN_MANUAL_ENTRY(if,func;others;2) 1118 BEGIN_MANUAL_ENTRY(if,func;others;2)
1119 1119
1120 int mac_set_func_addr(smc,f_addr)
1121 struct s_smc *smc ;
1122 u_long f_addr ;
1123
1124Function DOWNCALL (SMT, fplustm.c)
1125 Set a Token-Ring functional address, the address will
1126 be activated after calling mac_update_multicast()
1127
1128Para f_addr functional bits in non-canonical format
1129
1130Returns 0: always success
1131
1132 END_MANUAL_ENTRY()
1133 */
1134int mac_set_func_addr(struct s_smc *smc, u_long f_addr)
1135{
1136 smc->hw.fp.func_addr = f_addr ;
1137 return(0) ;
1138}
1139
1140
1141/*
1142 BEGIN_MANUAL_ENTRY(if,func;others;2)
1143
1144 int mac_add_multicast(smc,addr,can) 1120 int mac_add_multicast(smc,addr,can)
1145 struct s_smc *smc ; 1121 struct s_smc *smc ;
1146 struct fddi_addr *addr ; 1122 struct fddi_addr *addr ;
@@ -1203,52 +1179,6 @@ int mac_add_multicast(struct s_smc *smc, struct fddi_addr *addr, int can)
1203} 1179}
1204 1180
1205/* 1181/*
1206 BEGIN_MANUAL_ENTRY(if,func;others;2)
1207
1208 void mac_del_multicast(smc,addr,can)
1209 struct s_smc *smc ;
1210 struct fddi_addr *addr ;
1211 int can ;
1212
1213Function DOWNCALL (SMT, fplustm.c)
1214 Delete an entry from the multicast table
1215
1216Para addr pointer to a multicast address
1217 can = 0: the multicast address has the physical format
1218 = 1: the multicast address has the canonical format
1219 | 0x80 permanent
1220
1221 END_MANUAL_ENTRY()
1222 */
1223void mac_del_multicast(struct s_smc *smc, struct fddi_addr *addr, int can)
1224{
1225 SK_LOC_DECL(struct fddi_addr,own) ;
1226 struct s_fpmc *tb ;
1227
1228 if (!(tb = mac_get_mc_table(smc,addr,&own,1,can & ~0x80)))
1229 return ;
1230 /*
1231 * permanent addresses must be deleted with perm bit
1232 * and vice versa
1233 */
1234 if (( tb->perm && (can & 0x80)) ||
1235 (!tb->perm && !(can & 0x80))) {
1236 /*
1237 * delete it
1238 */
1239 if (tb->n) {
1240 tb->n-- ;
1241 if (tb->perm) {
1242 smc->hw.fp.smt_slots_used-- ;
1243 }
1244 else {
1245 smc->hw.fp.os_slots_used-- ;
1246 }
1247 }
1248 }
1249}
1250
1251/*
1252 * mode 1182 * mode
1253 */ 1183 */
1254 1184
diff --git a/drivers/net/skfp/h/cmtdef.h b/drivers/net/skfp/h/cmtdef.h
index 603982debc71..f2f771d8be76 100644
--- a/drivers/net/skfp/h/cmtdef.h
+++ b/drivers/net/skfp/h/cmtdef.h
@@ -507,7 +507,6 @@ void pcm_status_state(struct s_smc *smc, int np, int *type, int *state,
507 int *remote, int *mac); 507 int *remote, int *mac);
508void plc_config_mux(struct s_smc *smc, int mux); 508void plc_config_mux(struct s_smc *smc, int mux);
509void sm_lem_evaluate(struct s_smc *smc); 509void sm_lem_evaluate(struct s_smc *smc);
510void smt_clear_una_dna(struct s_smc *smc);
511void mac_update_counter(struct s_smc *smc); 510void mac_update_counter(struct s_smc *smc);
512void sm_pm_ls_latch(struct s_smc *smc, int phy, int on_off); 511void sm_pm_ls_latch(struct s_smc *smc, int phy, int on_off);
513void sm_ma_control(struct s_smc *smc, int mode); 512void sm_ma_control(struct s_smc *smc, int mode);
@@ -541,11 +540,9 @@ void smt_timer_poll(struct s_smc *smc);
541u_long smt_get_time(void); 540u_long smt_get_time(void);
542u_long smt_get_tid(struct s_smc *smc); 541u_long smt_get_tid(struct s_smc *smc);
543void smt_timer_done(struct s_smc *smc); 542void smt_timer_done(struct s_smc *smc);
544void smt_set_defaults(struct s_smc *smc);
545void smt_fixup_mib(struct s_smc *smc); 543void smt_fixup_mib(struct s_smc *smc);
546void smt_reset_defaults(struct s_smc *smc, int level); 544void smt_reset_defaults(struct s_smc *smc, int level);
547void smt_agent_task(struct s_smc *smc); 545void smt_agent_task(struct s_smc *smc);
548void smt_please_reconnect(struct s_smc *smc, int reconn_time);
549int smt_check_para(struct s_smc *smc, struct smt_header *sm, 546int smt_check_para(struct s_smc *smc, struct smt_header *sm,
550 const u_short list[]); 547 const u_short list[]);
551void driver_get_bia(struct s_smc *smc, struct fddi_addr *bia_addr); 548void driver_get_bia(struct s_smc *smc, struct fddi_addr *bia_addr);
@@ -568,7 +565,6 @@ int pcm_get_s_port(struct s_smc *smc);
568int pcm_rooted_station(struct s_smc *smc); 565int pcm_rooted_station(struct s_smc *smc);
569int cfm_get_mac_input(struct s_smc *smc); 566int cfm_get_mac_input(struct s_smc *smc);
570int cfm_get_mac_output(struct s_smc *smc); 567int cfm_get_mac_output(struct s_smc *smc);
571int port_to_mib(struct s_smc *smc, int p);
572int cem_build_path(struct s_smc *smc, char *to, int path_index); 568int cem_build_path(struct s_smc *smc, char *to, int path_index);
573int sm_mac_get_tx_state(struct s_smc *smc); 569int sm_mac_get_tx_state(struct s_smc *smc);
574char *get_pcmstate(struct s_smc *smc, int np); 570char *get_pcmstate(struct s_smc *smc, int np);
@@ -580,8 +576,6 @@ void smt_send_frame(struct s_smc *smc, SMbuf *mb, int fc, int local);
580void smt_set_timestamp(struct s_smc *smc, u_char *p); 576void smt_set_timestamp(struct s_smc *smc, u_char *p);
581void mac_set_rx_mode(struct s_smc *smc, int mode); 577void mac_set_rx_mode(struct s_smc *smc, int mode);
582int mac_add_multicast(struct s_smc *smc, struct fddi_addr *addr, int can); 578int mac_add_multicast(struct s_smc *smc, struct fddi_addr *addr, int can);
583int mac_set_func_addr(struct s_smc *smc, u_long f_addr);
584void mac_del_multicast(struct s_smc *smc, struct fddi_addr *addr, int can);
585void mac_update_multicast(struct s_smc *smc); 579void mac_update_multicast(struct s_smc *smc);
586void mac_clear_multicast(struct s_smc *smc); 580void mac_clear_multicast(struct s_smc *smc);
587void set_formac_tsync(struct s_smc *smc, long sync_bw); 581void set_formac_tsync(struct s_smc *smc, long sync_bw);
@@ -599,7 +593,6 @@ void plc_irq(struct s_smc *smc, int np, unsigned int cmd);
599int smt_set_mac_opvalues(struct s_smc *smc); 593int smt_set_mac_opvalues(struct s_smc *smc);
600 594
601#ifdef TAG_MODE 595#ifdef TAG_MODE
602void mac_drv_pci_fix(struct s_smc *smc, u_long fix_value);
603void mac_do_pci_fix(struct s_smc *smc); 596void mac_do_pci_fix(struct s_smc *smc);
604void mac_drv_clear_tx_queue(struct s_smc *smc); 597void mac_drv_clear_tx_queue(struct s_smc *smc);
605void mac_drv_repair_descr(struct s_smc *smc); 598void mac_drv_repair_descr(struct s_smc *smc);
diff --git a/drivers/net/skfp/h/hwmtm.h b/drivers/net/skfp/h/hwmtm.h
index 4e360af07d77..1a606d4bfe5e 100644
--- a/drivers/net/skfp/h/hwmtm.h
+++ b/drivers/net/skfp/h/hwmtm.h
@@ -262,31 +262,6 @@ struct os_debug {
262 (smc)->hw.fp.tx_q[queue].tx_curr_put 262 (smc)->hw.fp.tx_q[queue].tx_curr_put
263 263
264/* 264/*
265 * BEGIN_MANUAL_ENTRY(HWM_TX_CHECK)
266 * void HWM_TX_CHECK(smc,frame_status,low_water)
267 *
268 * function MACRO (hardware module, hwmtm.h)
269 * This macro is invoked by the OS-specific before it left it's
270 * driver_send function. This macro calls mac_drv_clear_txd
271 * if the free TxDs of the current transmit queue is equal or
272 * lower than the given low water mark.
273 *
274 * para frame_status status of the frame, see design description
275 * low_water low water mark of free TxD's
276 *
277 * END_MANUAL_ENTRY
278 */
279#ifndef HWM_NO_FLOW_CTL
280#define HWM_TX_CHECK(smc,frame_status,low_water) {\
281 if ((low_water)>=(smc)->hw.fp.tx_q[(frame_status)&QUEUE_A0].tx_free) {\
282 mac_drv_clear_txd(smc) ;\
283 }\
284}
285#else
286#define HWM_TX_CHECK(smc,frame_status,low_water) mac_drv_clear_txd(smc)
287#endif
288
289/*
290 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FRAG_LEN) 265 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FRAG_LEN)
291 * int HWM_GET_RX_FRAG_LEN(rxd) 266 * int HWM_GET_RX_FRAG_LEN(rxd)
292 * 267 *
diff --git a/drivers/net/skfp/h/osdef1st.h b/drivers/net/skfp/h/osdef1st.h
index 5359eb53008d..763ca18cbea8 100644
--- a/drivers/net/skfp/h/osdef1st.h
+++ b/drivers/net/skfp/h/osdef1st.h
@@ -20,6 +20,8 @@
20// HWM (HardWare Module) Definitions 20// HWM (HardWare Module) Definitions
21// ----------------------- 21// -----------------------
22 22
23#include <asm/byteorder.h>
24
23#ifdef __LITTLE_ENDIAN 25#ifdef __LITTLE_ENDIAN
24#define LITTLE_ENDIAN 26#define LITTLE_ENDIAN
25#else 27#else
diff --git a/drivers/net/skfp/hwmtm.c b/drivers/net/skfp/hwmtm.c
index 18d429021edb..438f424e6361 100644
--- a/drivers/net/skfp/hwmtm.c
+++ b/drivers/net/skfp/hwmtm.c
@@ -86,6 +86,7 @@ static u_long repair_txd_ring(struct s_smc *smc, struct s_smt_tx_queue *queue);
86static u_long repair_rxd_ring(struct s_smc *smc, struct s_smt_rx_queue *queue); 86static u_long repair_rxd_ring(struct s_smc *smc, struct s_smt_rx_queue *queue);
87static SMbuf* get_llc_rx(struct s_smc *smc); 87static SMbuf* get_llc_rx(struct s_smc *smc);
88static SMbuf* get_txd_mb(struct s_smc *smc); 88static SMbuf* get_txd_mb(struct s_smc *smc);
89static void mac_drv_clear_txd(struct s_smc *smc);
89 90
90/* 91/*
91 ------------------------------------------------------------- 92 -------------------------------------------------------------
@@ -146,7 +147,6 @@ extern int mac_drv_rx_init(struct s_smc *smc, int len, int fc, char *look_ahead,
146*/ 147*/
147void process_receive(struct s_smc *smc); 148void process_receive(struct s_smc *smc);
148void fddi_isr(struct s_smc *smc); 149void fddi_isr(struct s_smc *smc);
149void mac_drv_clear_txd(struct s_smc *smc);
150void smt_free_mbuf(struct s_smc *smc, SMbuf *mb); 150void smt_free_mbuf(struct s_smc *smc, SMbuf *mb);
151void init_driver_fplus(struct s_smc *smc); 151void init_driver_fplus(struct s_smc *smc);
152void mac_drv_rx_mode(struct s_smc *smc, int mode); 152void mac_drv_rx_mode(struct s_smc *smc, int mode);
@@ -158,7 +158,6 @@ void hwm_tx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
158void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len, 158void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
159 int frame_status); 159 int frame_status);
160 160
161int mac_drv_rx_frag(struct s_smc *smc, void far *virt, int len);
162int mac_drv_init(struct s_smc *smc); 161int mac_drv_init(struct s_smc *smc);
163int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count, int frame_len, 162int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count, int frame_len,
164 int frame_status); 163 int frame_status);
@@ -1448,35 +1447,6 @@ void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
1448 NDD_TRACE("RHfE",r,AIX_REVERSE(r->rxd_rbadr),0) ; 1447 NDD_TRACE("RHfE",r,AIX_REVERSE(r->rxd_rbadr),0) ;
1449} 1448}
1450 1449
1451#ifndef NDIS_OS2
1452/*
1453 * BEGIN_MANUAL_ENTRY(mac_drv_rx_frag)
1454 * int mac_drv_rx_frag(smc,virt,len)
1455 *
1456 * function DOWNCALL (hwmtm.c)
1457 * mac_drv_rx_frag fills the fragment with a part of the frame.
1458 *
1459 * para virt the virtual address of the fragment
1460 * len the length in bytes of the fragment
1461 *
1462 * return 0: success code, no errors possible
1463 *
1464 * END_MANUAL_ENTRY
1465 */
1466int mac_drv_rx_frag(struct s_smc *smc, void far *virt, int len)
1467{
1468 NDD_TRACE("RHSB",virt,len,smc->os.hwm.r.mb_pos) ;
1469
1470 DB_RX("receive from queue: len/virt: = %d/%x",len,virt,4) ;
1471 memcpy((char far *)virt,smc->os.hwm.r.mb_pos,len) ;
1472 smc->os.hwm.r.mb_pos += len ;
1473
1474 NDD_TRACE("RHSE",smc->os.hwm.r.mb_pos,0,0) ;
1475 return(0) ;
1476}
1477#endif
1478
1479
1480/* 1450/*
1481 * BEGINN_MANUAL_ENTRY(mac_drv_clear_rx_queue) 1451 * BEGINN_MANUAL_ENTRY(mac_drv_clear_rx_queue)
1482 * 1452 *
@@ -1978,7 +1948,7 @@ void smt_send_mbuf(struct s_smc *smc, SMbuf *mb, int fc)
1978 * 1948 *
1979 * END_MANUAL_ENTRY 1949 * END_MANUAL_ENTRY
1980 */ 1950 */
1981void mac_drv_clear_txd(struct s_smc *smc) 1951static void mac_drv_clear_txd(struct s_smc *smc)
1982{ 1952{
1983 struct s_smt_tx_queue *queue ; 1953 struct s_smt_tx_queue *queue ;
1984 struct s_smt_fp_txd volatile *t1 ; 1954 struct s_smt_fp_txd volatile *t1 ;
diff --git a/drivers/net/skfp/lnkstat.c b/drivers/net/skfp/lnkstat.c
deleted file mode 100644
index 00a248044f86..000000000000
--- a/drivers/net/skfp/lnkstat.c
+++ /dev/null
@@ -1,204 +0,0 @@
1/******************************************************************************
2 *
3 * (C)Copyright 1998,1999 SysKonnect,
4 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
5 *
6 * See the file "skfddi.c" for further information.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The information in this file is provided "AS IS" without warranty.
14 *
15 ******************************************************************************/
16
17/*
18 IBM FDDI read error log function
19*/
20
21#include "h/types.h"
22#include "h/fddi.h"
23#include "h/smc.h"
24#include "h/lnkstat.h"
25
26#ifndef lint
27static const char ID_sccs[] = "@(#)lnkstat.c 1.8 97/04/11 (C) SK " ;
28#endif
29
30#ifdef sun
31#define _far
32#endif
33
34#define EL_IS_OK(x,l) ((((int)&(((struct s_error_log *)0)->x)) + \
35 sizeof(er->x)) <= l)
36
37/*
38 BEGIN_MANUAL_ENTRY(if,func;others;11)
39
40 u_long smt_get_error_word(smc)
41 struct s_smc *smc ;
42
43Function DOWNCALL (SMT, lnkstat.c)
44 This functions returns the SMT error work for AIX events.
45
46Return smt_error_word These bits are supported:
47
48 SMT_ERL_ALC == [PS/PA].fddiPORTLerFlag
49 SMT_ERL_BLC == [PB].fddiPORTLerFlag
50 SMT_ERL_NCC == fddiMACNotCopiedFlag
51 SMT_ERL_FEC == fddiMACFrameErrorFlag
52
53 END_MANUAL_ENTRY()
54 */
55u_long smt_get_error_word(struct s_smc *smc)
56{
57 u_long st;
58
59 /*
60 * smt error word low
61 */
62 st = 0 ;
63 if (smc->s.sas == SMT_SAS) {
64 if (smc->mib.p[PS].fddiPORTLerFlag)
65 st |= SMT_ERL_ALC ;
66 }
67 else {
68 if (smc->mib.p[PA].fddiPORTLerFlag)
69 st |= SMT_ERL_ALC ;
70 if (smc->mib.p[PB].fddiPORTLerFlag)
71 st |= SMT_ERL_BLC ;
72 }
73 if (smc->mib.m[MAC0].fddiMACNotCopiedFlag)
74 st |= SMT_ERL_NCC ; /* not copied condition */
75 if (smc->mib.m[MAC0].fddiMACFrameErrorFlag)
76 st |= SMT_ERL_FEC ; /* frame error condition */
77
78 return st;
79}
80
81/*
82 BEGIN_MANUAL_ENTRY(if,func;others;11)
83
84 u_long smt_get_event_word(smc)
85 struct s_smc *smc ;
86
87Function DOWNCALL (SMT, lnkstat.c)
88 This functions returns the SMT event work for AIX events.
89
90Return smt_event_word always 0
91
92 END_MANUAL_ENTRY()
93 */
94u_long smt_get_event_word(struct s_smc *smc)
95{
96 return (u_long) 0;
97}
98
99/*
100 BEGIN_MANUAL_ENTRY(if,func;others;11)
101
102 u_long smt_get_port_event_word(smc)
103 struct s_smc *smc ;
104
105Function DOWNCALL (SMT, lnkstat.c)
106 This functions returns the SMT port event work for AIX events.
107
108Return smt_port_event_word always 0
109
110 END_MANUAL_ENTRY()
111 */
112u_long smt_get_port_event_word(struct s_smc *smc)
113{
114 return (u_long) 0;
115}
116
117/*
118 BEGIN_MANUAL_ENTRY(if,func;others;11)
119
120 u_long smt_read_errorlog(smc,p,len)
121 struct s_smc *smc ;
122 char _far *p ;
123 int len ;
124
125Function DOWNCALL (SMT, lnkstat.c)
126 This functions returns the SMT error log field for AIX events.
127
128Para p pointer to the error log field
129 len len of the error log field
130
131Return len used len of the error log field
132
133 END_MANUAL_ENTRY()
134 */
135int smt_read_errorlog(struct s_smc *smc, char _far *p, int len)
136{
137 int i ;
138 int st ;
139 struct s_error_log _far *er ;
140
141 er = (struct s_error_log _far *) p ;
142 if (len > sizeof(struct s_error_log))
143 len = sizeof(struct s_error_log) ;
144 for (i = 0 ; i < len ; i++)
145 *p++ = 0 ;
146 /*
147 * set count
148 */
149 if (EL_IS_OK(set_count_high,len)) {
150 er->set_count_low = (u_short)smc->mib.fddiSMTSetCount.count ;
151 er->set_count_high =
152 (u_short)(smc->mib.fddiSMTSetCount.count >> 16L) ;
153 }
154 /*
155 * aci
156 */
157 if (EL_IS_OK(aci_id_code,len)) {
158 er->aci_id_code = 0 ;
159 }
160 /*
161 * purge counter is missed frames; 16 bits only
162 */
163 if (EL_IS_OK(purge_frame_counter,len)) {
164 if (smc->mib.m[MAC0].fddiMACCopied_Ct > 0xffff)
165 er->purge_frame_counter = 0xffff ;
166 else
167 er->purge_frame_counter =
168 (u_short)smc->mib.m[MAC0].fddiMACCopied_Ct ;
169 }
170 /*
171 * CMT and RMT state machines
172 */
173 if (EL_IS_OK(ecm_state,len))
174 er->ecm_state = smc->mib.fddiSMTECMState ;
175
176 if (EL_IS_OK(pcm_b_state,len)) {
177 if (smc->s.sas == SMT_SAS) {
178 er->pcm_a_state = smc->y[PS].mib->fddiPORTPCMState ;
179 er->pcm_b_state = 0 ;
180 }
181 else {
182 er->pcm_a_state = smc->y[PA].mib->fddiPORTPCMState ;
183 er->pcm_b_state = smc->y[PB].mib->fddiPORTPCMState ;
184 }
185 }
186 if (EL_IS_OK(cfm_state,len))
187 er->cfm_state = smc->mib.fddiSMTCF_State ;
188 if (EL_IS_OK(rmt_state,len))
189 er->rmt_state = smc->mib.m[MAC0].fddiMACRMTState ;
190
191 /*
192 * smt error word low (we only need the low order 16 bits.)
193 */
194
195 st = smt_get_error_word(smc) & 0xffff ;
196
197 if (EL_IS_OK(smt_error_low,len))
198 er->smt_error_low = st ;
199
200 if (EL_IS_OK(ucode_version_level,len))
201 er->ucode_version_level = 0x0101 ;
202 return(len) ;
203}
204
diff --git a/drivers/net/skfp/pcmplc.c b/drivers/net/skfp/pcmplc.c
index 571f055c096b..cd0aa4c151b0 100644
--- a/drivers/net/skfp/pcmplc.c
+++ b/drivers/net/skfp/pcmplc.c
@@ -1861,13 +1861,6 @@ void plc_irq(struct s_smc *smc, int np, unsigned int cmd)
1861#endif 1861#endif
1862} 1862}
1863 1863
1864void pcm_set_lct_short(struct s_smc *smc, int n)
1865{
1866 if (n <= 0 || n > 1000)
1867 return ;
1868 smc->s.lct_short = n ;
1869}
1870
1871#ifdef DEBUG 1864#ifdef DEBUG
1872/* 1865/*
1873 * fill state struct 1866 * fill state struct
diff --git a/drivers/net/skfp/pmf.c b/drivers/net/skfp/pmf.c
index f2b446d8b0bf..efc639c013fd 100644
--- a/drivers/net/skfp/pmf.c
+++ b/drivers/net/skfp/pmf.c
@@ -36,12 +36,13 @@ static int smt_authorize(struct s_smc *smc, struct smt_header *sm);
36static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm); 36static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm);
37static const struct s_p_tab* smt_get_ptab(u_short para); 37static const struct s_p_tab* smt_get_ptab(u_short para);
38static int smt_mib_phys(struct s_smc *smc); 38static int smt_mib_phys(struct s_smc *smc);
39int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index, int local, 39static int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index,
40 int set); 40 int local, int set);
41void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para, 41void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para,
42 int index, int local); 42 int index, int local);
43static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req, 43static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req,
44 int set, int local); 44 int set, int local);
45static int port_to_mib(struct s_smc *smc, int p);
45 46
46#define MOFFSS(e) ((int)&(((struct fddi_mib *)0)->e)) 47#define MOFFSS(e) ((int)&(((struct fddi_mib *)0)->e))
47#define MOFFSA(e) ((int) (((struct fddi_mib *)0)->e)) 48#define MOFFSA(e) ((int) (((struct fddi_mib *)0)->e))
@@ -1078,8 +1079,8 @@ wrong_error:
1078/* 1079/*
1079 * set parameter 1080 * set parameter
1080 */ 1081 */
1081int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index, int local, 1082static int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index,
1082 int set) 1083 int local, int set)
1083{ 1084{
1084#define IFSET(x) if (set) (x) 1085#define IFSET(x) if (set) (x)
1085 1086
@@ -1549,7 +1550,7 @@ static int smt_mib_phys(struct s_smc *smc)
1549#endif 1550#endif
1550} 1551}
1551 1552
1552int port_to_mib(struct s_smc *smc, int p) 1553static int port_to_mib(struct s_smc *smc, int p)
1553{ 1554{
1554#ifdef CONCENTRATOR 1555#ifdef CONCENTRATOR
1555 SK_UNUSED(smc) ; 1556 SK_UNUSED(smc) ;
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index c88aad6edd74..4b5ed2c63177 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -149,7 +149,6 @@ extern void hwm_rx_frag(struct s_smc *smc, char far * virt, u_long phys,
149extern void mac_drv_rx_mode(struct s_smc *smc, int mode); 149extern void mac_drv_rx_mode(struct s_smc *smc, int mode);
150extern void mac_drv_clear_rx_queue(struct s_smc *smc); 150extern void mac_drv_clear_rx_queue(struct s_smc *smc);
151extern void enable_tx_irq(struct s_smc *smc, u_short queue); 151extern void enable_tx_irq(struct s_smc *smc, u_short queue);
152extern void mac_drv_clear_txd(struct s_smc *smc);
153 152
154static struct pci_device_id skfddi_pci_tbl[] = { 153static struct pci_device_id skfddi_pci_tbl[] = {
155 { PCI_VENDOR_ID_SK, PCI_DEVICE_ID_SK_FP, PCI_ANY_ID, PCI_ANY_ID, }, 154 { PCI_VENDOR_ID_SK, PCI_DEVICE_ID_SK_FP, PCI_ANY_ID, PCI_ANY_ID, },
diff --git a/drivers/net/skfp/smt.c b/drivers/net/skfp/smt.c
index 71935eaf9d4e..f17c05cbe44b 100644
--- a/drivers/net/skfp/smt.c
+++ b/drivers/net/skfp/smt.c
@@ -86,7 +86,7 @@ static void smt_send_sif_config(struct s_smc *smc, struct fddi_addr *dest,
86static void smt_send_sif_operation(struct s_smc *smc, struct fddi_addr *dest, 86static void smt_send_sif_operation(struct s_smc *smc, struct fddi_addr *dest,
87 u_long tid, int local); 87 u_long tid, int local);
88#ifdef LITTLE_ENDIAN 88#ifdef LITTLE_ENDIAN
89static void smt_string_swap(void); 89static void smt_string_swap(char *data, const char *format, int len);
90#endif 90#endif
91static void smt_add_frame_len(SMbuf *mb, int len); 91static void smt_add_frame_len(SMbuf *mb, int len);
92static void smt_fill_una(struct s_smc *smc, struct smt_p_una *una); 92static void smt_fill_una(struct s_smc *smc, struct smt_p_una *una);
@@ -110,7 +110,7 @@ static void smt_fill_setcount(struct s_smc *smc, struct smt_p_setcount *setcount
110static void smt_fill_echo(struct s_smc *smc, struct smt_p_echo *echo, u_long seed, 110static void smt_fill_echo(struct s_smc *smc, struct smt_p_echo *echo, u_long seed,
111 int len); 111 int len);
112 112
113void smt_clear_una_dna(struct s_smc *smc); 113static void smt_clear_una_dna(struct s_smc *smc);
114static void smt_clear_old_una_dna(struct s_smc *smc); 114static void smt_clear_old_una_dna(struct s_smc *smc);
115#ifdef CONCENTRATOR 115#ifdef CONCENTRATOR
116static int entity_to_index(void); 116static int entity_to_index(void);
@@ -118,7 +118,7 @@ static int entity_to_index(void);
118static void update_dac(struct s_smc *smc, int report); 118static void update_dac(struct s_smc *smc, int report);
119static int div_ratio(u_long upper, u_long lower); 119static int div_ratio(u_long upper, u_long lower);
120#ifdef USE_CAN_ADDR 120#ifdef USE_CAN_ADDR
121void hwm_conv_can(struct s_smc *smc, char *data, int len); 121static void hwm_conv_can(struct s_smc *smc, char *data, int len);
122#else 122#else
123#define hwm_conv_can(smc,data,len) 123#define hwm_conv_can(smc,data,len)
124#endif 124#endif
@@ -216,24 +216,6 @@ void smt_agent_task(struct s_smc *smc)
216 DB_SMT("SMT agent task\n",0,0) ; 216 DB_SMT("SMT agent task\n",0,0) ;
217} 217}
218 218
219void smt_please_reconnect(struct s_smc *smc, int reconn_time)
220/* struct s_smc *smc; Pointer to SMT context */
221/* int reconn_time; Wait for reconnect time in seconds */
222{
223 /*
224 * The please reconnect variable is used as a timer.
225 * It is decremented each time smt_event is called.
226 * This happens every second or when smt_force_irq is called.
227 * Note: smt_force_irq () is called on some packet receives and
228 * when a multicast address is changed. Since nothing
229 * is received during the disconnect and the multicast
230 * address changes can be viewed as not very often and
231 * the timer runs out close to its given value
232 * (reconn_time).
233 */
234 smc->sm.please_reconnect = reconn_time ;
235}
236
237#ifndef SMT_REAL_TOKEN_CT 219#ifndef SMT_REAL_TOKEN_CT
238void smt_emulate_token_ct(struct s_smc *smc, int mac_index) 220void smt_emulate_token_ct(struct s_smc *smc, int mac_index)
239{ 221{
@@ -1574,7 +1556,7 @@ static void smt_fill_echo(struct s_smc *smc, struct smt_p_echo *echo, u_long see
1574 * clear DNA and UNA 1556 * clear DNA and UNA
1575 * called from CFM if configuration changes 1557 * called from CFM if configuration changes
1576 */ 1558 */
1577void smt_clear_una_dna(struct s_smc *smc) 1559static void smt_clear_una_dna(struct s_smc *smc)
1578{ 1560{
1579 smc->mib.m[MAC0].fddiMACUpstreamNbr = SMT_Unknown ; 1561 smc->mib.m[MAC0].fddiMACUpstreamNbr = SMT_Unknown ;
1580 smc->mib.m[MAC0].fddiMACDownstreamNbr = SMT_Unknown ; 1562 smc->mib.m[MAC0].fddiMACDownstreamNbr = SMT_Unknown ;
@@ -2058,30 +2040,10 @@ int smt_action(struct s_smc *smc, int class, int code, int index)
2058} 2040}
2059 2041
2060/* 2042/*
2061 * change tneg
2062 * set T_Req in MIB (Path Attribute)
2063 * calculate new values for MAC
2064 * if change required
2065 * disconnect
2066 * set reconnect
2067 * end
2068 */
2069void smt_change_t_neg(struct s_smc *smc, u_long tneg)
2070{
2071 smc->mib.a[PATH0].fddiPATHMaxT_Req = tneg ;
2072
2073 if (smt_set_mac_opvalues(smc)) {
2074 RS_SET(smc,RS_EVENT) ;
2075 smc->sm.please_reconnect = 1 ;
2076 queue_event(smc,EVENT_ECM,EC_DISCONNECT) ;
2077 }
2078}
2079
2080/*
2081 * canonical conversion of <len> bytes beginning form *data 2043 * canonical conversion of <len> bytes beginning form *data
2082 */ 2044 */
2083#ifdef USE_CAN_ADDR 2045#ifdef USE_CAN_ADDR
2084void hwm_conv_can(struct s_smc *smc, char *data, int len) 2046static void hwm_conv_can(struct s_smc *smc, char *data, int len)
2085{ 2047{
2086 int i ; 2048 int i ;
2087 2049
diff --git a/drivers/net/skfp/smtdef.c b/drivers/net/skfp/smtdef.c
index 5a0c8db816d8..4e07ff7073f1 100644
--- a/drivers/net/skfp/smtdef.c
+++ b/drivers/net/skfp/smtdef.c
@@ -76,11 +76,6 @@ void smt_reset_defaults(struct s_smc *smc, int level);
76static void smt_init_mib(struct s_smc *smc, int level); 76static void smt_init_mib(struct s_smc *smc, int level);
77static int set_min_max(int maxflag, u_long mib, u_long limit, u_long *oper); 77static int set_min_max(int maxflag, u_long mib, u_long limit, u_long *oper);
78 78
79void smt_set_defaults(struct s_smc *smc)
80{
81 smt_reset_defaults(smc,0) ;
82}
83
84#define MS2BCLK(x) ((x)*12500L) 79#define MS2BCLK(x) ((x)*12500L)
85#define US2BCLK(x) ((x)*1250L) 80#define US2BCLK(x) ((x)*1250L)
86 81
diff --git a/drivers/net/skfp/smtparse.c b/drivers/net/skfp/smtparse.c
deleted file mode 100644
index d5779e414dbe..000000000000
--- a/drivers/net/skfp/smtparse.c
+++ /dev/null
@@ -1,467 +0,0 @@
1/******************************************************************************
2 *
3 * (C)Copyright 1998,1999 SysKonnect,
4 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
5 *
6 * See the file "skfddi.c" for further information.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The information in this file is provided "AS IS" without warranty.
14 *
15 ******************************************************************************/
16
17
18/*
19 parser for SMT parameters
20*/
21
22#include "h/types.h"
23#include "h/fddi.h"
24#include "h/smc.h"
25#include "h/smt_p.h"
26
27#define KERNEL
28#include "h/smtstate.h"
29
30#ifndef lint
31static const char ID_sccs[] = "@(#)smtparse.c 1.12 98/10/06 (C) SK " ;
32#endif
33
34#ifdef sun
35#define _far
36#endif
37
38/*
39 * convert to BCLK units
40 */
41#define MS2BCLK(x) ((x)*12500L)
42#define US2BCLK(x) ((x/10)*125L)
43
44/*
45 * parameter table
46 */
47static struct s_ptab {
48 char *pt_name ;
49 u_short pt_num ;
50 u_short pt_type ;
51 u_long pt_min ;
52 u_long pt_max ;
53} ptab[] = {
54 { "PMFPASSWD",0, 0 } ,
55 { "USERDATA",1, 0 } ,
56 { "LERCUTOFFA",2, 1, 4, 15 } ,
57 { "LERCUTOFFB",3, 1, 4, 15 } ,
58 { "LERALARMA",4, 1, 4, 15 } ,
59 { "LERALARMB",5, 1, 4, 15 } ,
60 { "TMAX",6, 1, 5, 165 } ,
61 { "TMIN",7, 1, 5, 165 } ,
62 { "TREQ",8, 1, 5, 165 } ,
63 { "TVX",9, 1, 2500, 10000 } ,
64#ifdef ESS
65 { "SBAPAYLOAD",10, 1, 0, 1562 } ,
66 { "SBAOVERHEAD",11, 1, 50, 5000 } ,
67 { "MAXTNEG",12, 1, 5, 165 } ,
68 { "MINSEGMENTSIZE",13, 1, 0, 4478 } ,
69 { "SBACATEGORY",14, 1, 0, 0xffff } ,
70 { "SYNCHTXMODE",15, 0 } ,
71#endif
72#ifdef SBA
73 { "SBACOMMAND",16, 0 } ,
74 { "SBAAVAILABLE",17, 1, 0, 100 } ,
75#endif
76 { NULL }
77} ;
78
79/* Define maximum string size for values and keybuffer */
80#define MAX_VAL 40
81
82/*
83 * local function declarations
84 */
85static u_long parse_num(int type, char _far *value, char *v, u_long mn,
86 u_long mx, int scale);
87static int parse_word(char *buf, char _far *text);
88
89#ifdef SIM
90#define DB_MAIN(a,b,c) printf(a,b,c)
91#else
92#define DB_MAIN(a,b,c)
93#endif
94
95/*
96 * BEGIN_MANUAL_ENTRY()
97 *
98 * int smt_parse_arg(struct s_smc *,char _far *keyword,int type,
99 char _far *value)
100 *
101 * parse SMT parameter
102 * *keyword
103 * pointer to keyword, must be \0, \n or \r terminated
104 * *value pointer to value, either char * or u_long *
105 * if char *
106 * pointer to value, must be \0, \n or \r terminated
107 * if u_long *
108 * contains binary value
109 *
110 * type 0: integer
111 * 1: string
112 * return
113 * 0 parameter parsed ok
114 * != 0 error
115 * NOTE:
116 * function can be called with DS != SS
117 *
118 *
119 * END_MANUAL_ENTRY()
120 */
121int smt_parse_arg(struct s_smc *smc, char _far *keyword, int type,
122 char _far *value)
123{
124 char keybuf[MAX_VAL+1];
125 char valbuf[MAX_VAL+1];
126 char c ;
127 char *p ;
128 char *v ;
129 char *d ;
130 u_long val = 0 ;
131 struct s_ptab *pt ;
132 int st ;
133 int i ;
134
135 /*
136 * parse keyword
137 */
138 if ((st = parse_word(keybuf,keyword)))
139 return(st) ;
140 /*
141 * parse value if given as string
142 */
143 if (type == 1) {
144 if ((st = parse_word(valbuf,value)))
145 return(st) ;
146 }
147 /*
148 * search in table
149 */
150 st = 0 ;
151 for (pt = ptab ; (v = pt->pt_name) ; pt++) {
152 for (p = keybuf ; (c = *p) ; p++,v++) {
153 if (c != *v)
154 break ;
155 }
156 if (!c && !*v)
157 break ;
158 }
159 if (!v)
160 return(-1) ;
161#if 0
162 printf("=>%s<==>%s<=\n",pt->pt_name,valbuf) ;
163#endif
164 /*
165 * set value in MIB
166 */
167 if (pt->pt_type)
168 val = parse_num(type,value,valbuf,pt->pt_min,pt->pt_max,1) ;
169 switch (pt->pt_num) {
170 case 0 :
171 v = valbuf ;
172 d = (char *) smc->mib.fddiPRPMFPasswd ;
173 for (i = 0 ; i < (signed)sizeof(smc->mib.fddiPRPMFPasswd) ; i++)
174 *d++ = *v++ ;
175 DB_MAIN("SET %s = %s\n",pt->pt_name,smc->mib.fddiPRPMFPasswd) ;
176 break ;
177 case 1 :
178 v = valbuf ;
179 d = (char *) smc->mib.fddiSMTUserData ;
180 for (i = 0 ; i < (signed)sizeof(smc->mib.fddiSMTUserData) ; i++)
181 *d++ = *v++ ;
182 DB_MAIN("SET %s = %s\n",pt->pt_name,smc->mib.fddiSMTUserData) ;
183 break ;
184 case 2 :
185 smc->mib.p[PA].fddiPORTLer_Cutoff = (u_char) val ;
186 DB_MAIN("SET %s = %d\n",
187 pt->pt_name,smc->mib.p[PA].fddiPORTLer_Cutoff) ;
188 break ;
189 case 3 :
190 smc->mib.p[PB].fddiPORTLer_Cutoff = (u_char) val ;
191 DB_MAIN("SET %s = %d\n",
192 pt->pt_name,smc->mib.p[PB].fddiPORTLer_Cutoff) ;
193 break ;
194 case 4 :
195 smc->mib.p[PA].fddiPORTLer_Alarm = (u_char) val ;
196 DB_MAIN("SET %s = %d\n",
197 pt->pt_name,smc->mib.p[PA].fddiPORTLer_Alarm) ;
198 break ;
199 case 5 :
200 smc->mib.p[PB].fddiPORTLer_Alarm = (u_char) val ;
201 DB_MAIN("SET %s = %d\n",
202 pt->pt_name,smc->mib.p[PB].fddiPORTLer_Alarm) ;
203 break ;
204 case 6 : /* TMAX */
205 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
206 smc->mib.a[PATH0].fddiPATHT_MaxLowerBound =
207 (u_long) -MS2BCLK((long)val) ;
208 break ;
209 case 7 : /* TMIN */
210 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
211 smc->mib.m[MAC0].fddiMACT_Min =
212 (u_long) -MS2BCLK((long)val) ;
213 break ;
214 case 8 : /* TREQ */
215 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
216 smc->mib.a[PATH0].fddiPATHMaxT_Req =
217 (u_long) -MS2BCLK((long)val) ;
218 break ;
219 case 9 : /* TVX */
220 DB_MAIN("SET %s = %d \n",pt->pt_name,val) ;
221 smc->mib.a[PATH0].fddiPATHTVXLowerBound =
222 (u_long) -US2BCLK((long)val) ;
223 break ;
224#ifdef ESS
225 case 10 : /* SBAPAYLOAD */
226 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
227 if (smc->mib.fddiESSPayload != val) {
228 smc->ess.raf_act_timer_poll = TRUE ;
229 smc->mib.fddiESSPayload = val ;
230 }
231 break ;
232 case 11 : /* SBAOVERHEAD */
233 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
234 smc->mib.fddiESSOverhead = val ;
235 break ;
236 case 12 : /* MAXTNEG */
237 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
238 smc->mib.fddiESSMaxTNeg = (u_long) -MS2BCLK((long)val) ;
239 break ;
240 case 13 : /* MINSEGMENTSIZE */
241 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
242 smc->mib.fddiESSMinSegmentSize = val ;
243 break ;
244 case 14 : /* SBACATEGORY */
245 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
246 smc->mib.fddiESSCategory =
247 (smc->mib.fddiESSCategory & 0xffff) |
248 ((u_long)(val << 16)) ;
249 break ;
250 case 15 : /* SYNCHTXMODE */
251 /* do not use memcmp(valbuf,"ALL",3) because DS != SS */
252 if (valbuf[0] == 'A' && valbuf[1] == 'L' && valbuf[2] == 'L') {
253 smc->mib.fddiESSSynchTxMode = TRUE ;
254 DB_MAIN("SET %s = %s\n",pt->pt_name,valbuf) ;
255 }
256 /* if (!memcmp(valbuf,"SPLIT",5)) { */
257 if (valbuf[0] == 'S' && valbuf[1] == 'P' && valbuf[2] == 'L' &&
258 valbuf[3] == 'I' && valbuf[4] == 'T') {
259 DB_MAIN("SET %s = %s\n",pt->pt_name,valbuf) ;
260 smc->mib.fddiESSSynchTxMode = FALSE ;
261 }
262 break ;
263#endif
264#ifdef SBA
265 case 16 : /* SBACOMMAND */
266 /* if (!memcmp(valbuf,"START",5)) { */
267 if (valbuf[0] == 'S' && valbuf[1] == 'T' && valbuf[2] == 'A' &&
268 valbuf[3] == 'R' && valbuf[4] == 'T') {
269 DB_MAIN("SET %s = %s\n",pt->pt_name,valbuf) ;
270 smc->mib.fddiSBACommand = SB_START ;
271 }
272 /* if (!memcmp(valbuf,"STOP",4)) { */
273 if (valbuf[0] == 'S' && valbuf[1] == 'T' && valbuf[2] == 'O' &&
274 valbuf[3] == 'P') {
275 DB_MAIN("SET %s = %s\n",pt->pt_name,valbuf) ;
276 smc->mib.fddiSBACommand = SB_STOP ;
277 }
278 break ;
279 case 17 : /* SBAAVAILABLE */
280 DB_MAIN("SET %s = %d\n",pt->pt_name,val) ;
281 smc->mib.fddiSBAAvailable = (u_char) val ;
282 break ;
283#endif
284 }
285 return(0) ;
286}
287
288static int parse_word(char *buf, char _far *text)
289{
290 char c ;
291 char *p ;
292 int p_len ;
293 int quote ;
294 int i ;
295 int ok ;
296
297 /*
298 * skip leading white space
299 */
300 p = buf ;
301 for (i = 0 ; i < MAX_VAL ; i++)
302 *p++ = 0 ;
303 p = buf ;
304 p_len = 0 ;
305 ok = 0 ;
306 while ( (c = *text++) && (c != '\n') && (c != '\r')) {
307 if ((c != ' ') && (c != '\t')) {
308 ok = 1 ;
309 break ;
310 }
311 }
312 if (!ok)
313 return(-1) ;
314 if (c == '"') {
315 quote = 1 ;
316 }
317 else {
318 quote = 0 ;
319 text-- ;
320 }
321 /*
322 * parse valbuf
323 */
324 ok = 0 ;
325 while (!ok && p_len < MAX_VAL-1 && (c = *text++) && (c != '\n')
326 && (c != '\r')) {
327 switch (quote) {
328 case 0 :
329 if ((c == ' ') || (c == '\t') || (c == '=')) {
330 ok = 1 ;
331 break ;
332 }
333 *p++ = c ;
334 p_len++ ;
335 break ;
336 case 2 :
337 *p++ = c ;
338 p_len++ ;
339 quote = 1 ;
340 break ;
341 case 1 :
342 switch (c) {
343 case '"' :
344 ok = 1 ;
345 break ;
346 case '\\' :
347 quote = 2 ;
348 break ;
349 default :
350 *p++ = c ;
351 p_len++ ;
352 }
353 }
354 }
355 *p++ = 0 ;
356 for (p = buf ; (c = *p) ; p++) {
357 if (c >= 'a' && c <= 'z')
358 *p = c + 'A' - 'a' ;
359 }
360 return(0) ;
361}
362
363static u_long parse_num(int type, char _far *value, char *v, u_long mn,
364 u_long mx, int scale)
365{
366 u_long x = 0 ;
367 char c ;
368
369 if (type == 0) { /* integer */
370 u_long _far *l ;
371 u_long u1 ;
372
373 l = (u_long _far *) value ;
374 u1 = *l ;
375 /*
376 * if the value is negative take the lower limit
377 */
378 if ((long)u1 < 0) {
379 if (- ((long)u1) > (long) mx) {
380 u1 = 0 ;
381 }
382 else {
383 u1 = (u_long) - ((long)u1) ;
384 }
385 }
386 x = u1 ;
387 }
388 else { /* string */
389 int sign = 0 ;
390
391 if (*v == '-') {
392 sign = 1 ;
393 }
394 while ((c = *v++) && (c >= '0') && (c <= '9')) {
395 x = x * 10 + c - '0' ;
396 }
397 if (scale == 10) {
398 x *= 10 ;
399 if (c == '.') {
400 if ((c = *v++) && (c >= '0') && (c <= '9')) {
401 x += c - '0' ;
402 }
403 }
404 }
405 if (sign)
406 x = (u_long) - ((long)x) ;
407 }
408 /*
409 * if the value is negative
410 * and the absolute value is outside the limits
411 * take the lower limit
412 * else
413 * take the absoute value
414 */
415 if ((long)x < 0) {
416 if (- ((long)x) > (long) mx) {
417 x = 0 ;
418 }
419 else {
420 x = (u_long) - ((long)x) ;
421 }
422 }
423 if (x < mn)
424 return(mn) ;
425 else if (x > mx)
426 return(mx) ;
427 return(x) ;
428}
429
430#if 0
431struct s_smc SMC ;
432main()
433{
434 char *p ;
435 char *v ;
436 char buf[100] ;
437 int toggle = 0 ;
438
439 while (gets(buf)) {
440 p = buf ;
441 while (*p && ((*p == ' ') || (*p == '\t')))
442 p++ ;
443
444 while (*p && ((*p != ' ') && (*p != '\t')))
445 p++ ;
446
447 v = p ;
448 while (*v && ((*v == ' ') || (*v == '\t')))
449 v++ ;
450 if ((*v >= '0') && (*v <= '9')) {
451 toggle = !toggle ;
452 if (toggle) {
453 u_long l ;
454 l = atol(v) ;
455 smt_parse_arg(&SMC,buf,0,(char _far *)&l) ;
456 }
457 else
458 smt_parse_arg(&SMC,buf,1,(char _far *)p) ;
459 }
460 else {
461 smt_parse_arg(&SMC,buf,1,(char _far *)p) ;
462 }
463 }
464 exit(0) ;
465}
466#endif
467
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 30e8d589d167..d7c98515fdfd 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -7,7 +7,7 @@
7 * of the original driver such as link fail-over and link management because 7 * of the original driver such as link fail-over and link management because
8 * those should be done at higher levels. 8 * those should be done at higher levels.
9 * 9 *
10 * Copyright (C) 2004, Stephen Hemminger <shemminger@osdl.org> 10 * Copyright (C) 2004, 2005 Stephen Hemminger <shemminger@osdl.org>
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
@@ -42,19 +42,20 @@
42#include "skge.h" 42#include "skge.h"
43 43
44#define DRV_NAME "skge" 44#define DRV_NAME "skge"
45#define DRV_VERSION "0.6" 45#define DRV_VERSION "0.9"
46#define PFX DRV_NAME " " 46#define PFX DRV_NAME " "
47 47
48#define DEFAULT_TX_RING_SIZE 128 48#define DEFAULT_TX_RING_SIZE 128
49#define DEFAULT_RX_RING_SIZE 512 49#define DEFAULT_RX_RING_SIZE 512
50#define MAX_TX_RING_SIZE 1024 50#define MAX_TX_RING_SIZE 1024
51#define MAX_RX_RING_SIZE 4096 51#define MAX_RX_RING_SIZE 4096
52#define RX_COPY_THRESHOLD 128
53#define RX_BUF_SIZE 1536
52#define PHY_RETRIES 1000 54#define PHY_RETRIES 1000
53#define ETH_JUMBO_MTU 9000 55#define ETH_JUMBO_MTU 9000
54#define TX_WATCHDOG (5 * HZ) 56#define TX_WATCHDOG (5 * HZ)
55#define NAPI_WEIGHT 64 57#define NAPI_WEIGHT 64
56#define BLINK_HZ (HZ/4) 58#define BLINK_MS 250
57#define LINK_POLL_HZ (HZ/10)
58 59
59MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver"); 60MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver");
60MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>"); 61MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>");
@@ -70,28 +71,16 @@ module_param(debug, int, 0);
70MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 71MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
71 72
72static const struct pci_device_id skge_id_table[] = { 73static const struct pci_device_id skge_id_table[] = {
73 { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940, 74 { PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940) },
74 PCI_ANY_ID, PCI_ANY_ID }, 75 { PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940B) },
75 { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940B, 76 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) },
76 PCI_ANY_ID, PCI_ANY_ID }, 77 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) },
77 { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE, 78 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T), },
78 PCI_ANY_ID, PCI_ANY_ID }, 79 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) },
79 { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU, 80 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */
80 PCI_ANY_ID, PCI_ANY_ID }, 81 { PCI_DEVICE(PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD) },
81 { PCI_VENDOR_ID_SYSKONNECT, 0x9E00, /* SK-9Exx */ 82 { PCI_DEVICE(PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1064) },
82 PCI_ANY_ID, PCI_ANY_ID }, 83 { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0015, },
83 { PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T,
84 PCI_ANY_ID, PCI_ANY_ID },
85 { PCI_VENDOR_ID_MARVELL, 0x4320, /* Gigabit Ethernet Controller */
86 PCI_ANY_ID, PCI_ANY_ID },
87 { PCI_VENDOR_ID_MARVELL, 0x5005, /* Marvell (11ab), Belkin */
88 PCI_ANY_ID, PCI_ANY_ID },
89 { PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD,
90 PCI_ANY_ID, PCI_ANY_ID },
91 { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1032,
92 PCI_ANY_ID, PCI_ANY_ID },
93 { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1064,
94 PCI_ANY_ID, PCI_ANY_ID },
95 { 0 } 84 { 0 }
96}; 85};
97MODULE_DEVICE_TABLE(pci, skge_id_table); 86MODULE_DEVICE_TABLE(pci, skge_id_table);
@@ -99,19 +88,22 @@ MODULE_DEVICE_TABLE(pci, skge_id_table);
99static int skge_up(struct net_device *dev); 88static int skge_up(struct net_device *dev);
100static int skge_down(struct net_device *dev); 89static int skge_down(struct net_device *dev);
101static void skge_tx_clean(struct skge_port *skge); 90static void skge_tx_clean(struct skge_port *skge);
102static void skge_xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val); 91static void xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
103static void skge_gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val); 92static void gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
104static void genesis_get_stats(struct skge_port *skge, u64 *data); 93static void genesis_get_stats(struct skge_port *skge, u64 *data);
105static void yukon_get_stats(struct skge_port *skge, u64 *data); 94static void yukon_get_stats(struct skge_port *skge, u64 *data);
106static void yukon_init(struct skge_hw *hw, int port); 95static void yukon_init(struct skge_hw *hw, int port);
107static void yukon_reset(struct skge_hw *hw, int port); 96static void yukon_reset(struct skge_hw *hw, int port);
108static void genesis_mac_init(struct skge_hw *hw, int port); 97static void genesis_mac_init(struct skge_hw *hw, int port);
109static void genesis_reset(struct skge_hw *hw, int port); 98static void genesis_reset(struct skge_hw *hw, int port);
99static void genesis_link_up(struct skge_port *skge);
110 100
101/* Avoid conditionals by using array */
111static const int txqaddr[] = { Q_XA1, Q_XA2 }; 102static const int txqaddr[] = { Q_XA1, Q_XA2 };
112static const int rxqaddr[] = { Q_R1, Q_R2 }; 103static const int rxqaddr[] = { Q_R1, Q_R2 };
113static const u32 rxirqmask[] = { IS_R1_F, IS_R2_F }; 104static const u32 rxirqmask[] = { IS_R1_F, IS_R2_F };
114static const u32 txirqmask[] = { IS_XA1_F, IS_XA2_F }; 105static const u32 txirqmask[] = { IS_XA1_F, IS_XA2_F };
106static const u32 portirqmask[] = { IS_PORT_1, IS_PORT_2 };
115 107
116/* Don't need to look at whole 16K. 108/* Don't need to look at whole 16K.
117 * last interesting register is descriptor poll timer. 109 * last interesting register is descriptor poll timer.
@@ -154,7 +146,7 @@ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs,
154static int wol_supported(const struct skge_hw *hw) 146static int wol_supported(const struct skge_hw *hw)
155{ 147{
156 return !((hw->chip_id == CHIP_ID_GENESIS || 148 return !((hw->chip_id == CHIP_ID_GENESIS ||
157 (hw->chip_id == CHIP_ID_YUKON && chip_rev(hw) == 0))); 149 (hw->chip_id == CHIP_ID_YUKON && hw->chip_rev == 0)));
158} 150}
159 151
160static void skge_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 152static void skge_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
@@ -170,7 +162,7 @@ static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
170 struct skge_port *skge = netdev_priv(dev); 162 struct skge_port *skge = netdev_priv(dev);
171 struct skge_hw *hw = skge->hw; 163 struct skge_hw *hw = skge->hw;
172 164
173 if(wol->wolopts != WAKE_MAGIC && wol->wolopts != 0) 165 if (wol->wolopts != WAKE_MAGIC && wol->wolopts != 0)
174 return -EOPNOTSUPP; 166 return -EOPNOTSUPP;
175 167
176 if (wol->wolopts == WAKE_MAGIC && !wol_supported(hw)) 168 if (wol->wolopts == WAKE_MAGIC && !wol_supported(hw))
@@ -190,6 +182,36 @@ static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
190 return 0; 182 return 0;
191} 183}
192 184
185/* Determine supported/adverised modes based on hardware.
186 * Note: ethtoool ADVERTISED_xxx == SUPPORTED_xxx
187 */
188static u32 skge_supported_modes(const struct skge_hw *hw)
189{
190 u32 supported;
191
192 if (hw->copper) {
193 supported = SUPPORTED_10baseT_Half
194 | SUPPORTED_10baseT_Full
195 | SUPPORTED_100baseT_Half
196 | SUPPORTED_100baseT_Full
197 | SUPPORTED_1000baseT_Half
198 | SUPPORTED_1000baseT_Full
199 | SUPPORTED_Autoneg| SUPPORTED_TP;
200
201 if (hw->chip_id == CHIP_ID_GENESIS)
202 supported &= ~(SUPPORTED_10baseT_Half
203 | SUPPORTED_10baseT_Full
204 | SUPPORTED_100baseT_Half
205 | SUPPORTED_100baseT_Full);
206
207 else if (hw->chip_id == CHIP_ID_YUKON)
208 supported &= ~SUPPORTED_1000baseT_Half;
209 } else
210 supported = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE
211 | SUPPORTED_Autoneg;
212
213 return supported;
214}
193 215
194static int skge_get_settings(struct net_device *dev, 216static int skge_get_settings(struct net_device *dev,
195 struct ethtool_cmd *ecmd) 217 struct ethtool_cmd *ecmd)
@@ -198,38 +220,13 @@ static int skge_get_settings(struct net_device *dev,
198 struct skge_hw *hw = skge->hw; 220 struct skge_hw *hw = skge->hw;
199 221
200 ecmd->transceiver = XCVR_INTERNAL; 222 ecmd->transceiver = XCVR_INTERNAL;
223 ecmd->supported = skge_supported_modes(hw);
201 224
202 if (iscopper(hw)) { 225 if (hw->copper) {
203 if (hw->chip_id == CHIP_ID_GENESIS)
204 ecmd->supported = SUPPORTED_1000baseT_Full
205 | SUPPORTED_1000baseT_Half
206 | SUPPORTED_Autoneg | SUPPORTED_TP;
207 else {
208 ecmd->supported = SUPPORTED_10baseT_Half
209 | SUPPORTED_10baseT_Full
210 | SUPPORTED_100baseT_Half
211 | SUPPORTED_100baseT_Full
212 | SUPPORTED_1000baseT_Half
213 | SUPPORTED_1000baseT_Full
214 | SUPPORTED_Autoneg| SUPPORTED_TP;
215
216 if (hw->chip_id == CHIP_ID_YUKON)
217 ecmd->supported &= ~SUPPORTED_1000baseT_Half;
218
219 else if (hw->chip_id == CHIP_ID_YUKON_FE)
220 ecmd->supported &= ~(SUPPORTED_1000baseT_Half
221 | SUPPORTED_1000baseT_Full);
222 }
223
224 ecmd->port = PORT_TP; 226 ecmd->port = PORT_TP;
225 ecmd->phy_address = hw->phy_addr; 227 ecmd->phy_address = hw->phy_addr;
226 } else { 228 } else
227 ecmd->supported = SUPPORTED_1000baseT_Full
228 | SUPPORTED_FIBRE
229 | SUPPORTED_Autoneg;
230
231 ecmd->port = PORT_FIBRE; 229 ecmd->port = PORT_FIBRE;
232 }
233 230
234 ecmd->advertising = skge->advertising; 231 ecmd->advertising = skge->advertising;
235 ecmd->autoneg = skge->autoneg; 232 ecmd->autoneg = skge->autoneg;
@@ -238,65 +235,57 @@ static int skge_get_settings(struct net_device *dev,
238 return 0; 235 return 0;
239} 236}
240 237
241static u32 skge_modes(const struct skge_hw *hw)
242{
243 u32 modes = ADVERTISED_Autoneg
244 | ADVERTISED_1000baseT_Full | ADVERTISED_1000baseT_Half
245 | ADVERTISED_100baseT_Full | ADVERTISED_100baseT_Half
246 | ADVERTISED_10baseT_Full | ADVERTISED_10baseT_Half;
247
248 if (iscopper(hw)) {
249 modes |= ADVERTISED_TP;
250 switch(hw->chip_id) {
251 case CHIP_ID_GENESIS:
252 modes &= ~(ADVERTISED_100baseT_Full
253 | ADVERTISED_100baseT_Half
254 | ADVERTISED_10baseT_Full
255 | ADVERTISED_10baseT_Half);
256 break;
257
258 case CHIP_ID_YUKON:
259 modes &= ~ADVERTISED_1000baseT_Half;
260 break;
261
262 case CHIP_ID_YUKON_FE:
263 modes &= ~(ADVERTISED_1000baseT_Half|ADVERTISED_1000baseT_Full);
264 break;
265 }
266 } else {
267 modes |= ADVERTISED_FIBRE;
268 modes &= ~ADVERTISED_1000baseT_Half;
269 }
270 return modes;
271}
272
273static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) 238static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
274{ 239{
275 struct skge_port *skge = netdev_priv(dev); 240 struct skge_port *skge = netdev_priv(dev);
276 const struct skge_hw *hw = skge->hw; 241 const struct skge_hw *hw = skge->hw;
242 u32 supported = skge_supported_modes(hw);
277 243
278 if (ecmd->autoneg == AUTONEG_ENABLE) { 244 if (ecmd->autoneg == AUTONEG_ENABLE) {
279 if (ecmd->advertising & skge_modes(hw)) 245 ecmd->advertising = supported;
280 return -EINVAL; 246 skge->duplex = -1;
247 skge->speed = -1;
281 } else { 248 } else {
282 switch(ecmd->speed) { 249 u32 setting;
250
251 switch (ecmd->speed) {
283 case SPEED_1000: 252 case SPEED_1000:
284 if (hw->chip_id == CHIP_ID_YUKON_FE) 253 if (ecmd->duplex == DUPLEX_FULL)
254 setting = SUPPORTED_1000baseT_Full;
255 else if (ecmd->duplex == DUPLEX_HALF)
256 setting = SUPPORTED_1000baseT_Half;
257 else
285 return -EINVAL; 258 return -EINVAL;
286 break; 259 break;
287 case SPEED_100: 260 case SPEED_100:
261 if (ecmd->duplex == DUPLEX_FULL)
262 setting = SUPPORTED_100baseT_Full;
263 else if (ecmd->duplex == DUPLEX_HALF)
264 setting = SUPPORTED_100baseT_Half;
265 else
266 return -EINVAL;
267 break;
268
288 case SPEED_10: 269 case SPEED_10:
289 if (iscopper(hw) || hw->chip_id == CHIP_ID_GENESIS) 270 if (ecmd->duplex == DUPLEX_FULL)
271 setting = SUPPORTED_10baseT_Full;
272 else if (ecmd->duplex == DUPLEX_HALF)
273 setting = SUPPORTED_10baseT_Half;
274 else
290 return -EINVAL; 275 return -EINVAL;
291 break; 276 break;
292 default: 277 default:
293 return -EINVAL; 278 return -EINVAL;
294 } 279 }
280
281 if ((setting & supported) == 0)
282 return -EINVAL;
283
284 skge->speed = ecmd->speed;
285 skge->duplex = ecmd->duplex;
295 } 286 }
296 287
297 skge->autoneg = ecmd->autoneg; 288 skge->autoneg = ecmd->autoneg;
298 skge->speed = ecmd->speed;
299 skge->duplex = ecmd->duplex;
300 skge->advertising = ecmd->advertising; 289 skge->advertising = ecmd->advertising;
301 290
302 if (netif_running(dev)) { 291 if (netif_running(dev)) {
@@ -393,7 +382,7 @@ static void skge_get_strings(struct net_device *dev, u32 stringset, u8 *data)
393{ 382{
394 int i; 383 int i;
395 384
396 switch(stringset) { 385 switch (stringset) {
397 case ETH_SS_STATS: 386 case ETH_SS_STATS:
398 for (i = 0; i < ARRAY_SIZE(skge_stats); i++) 387 for (i = 0; i < ARRAY_SIZE(skge_stats); i++)
399 memcpy(data + i * ETH_GSTRING_LEN, 388 memcpy(data + i * ETH_GSTRING_LEN,
@@ -511,14 +500,6 @@ static int skge_set_rx_csum(struct net_device *dev, u32 data)
511 return 0; 500 return 0;
512} 501}
513 502
514/* Only Yukon II supports TSO (not implemented yet) */
515static int skge_set_tso(struct net_device *dev, u32 data)
516{
517 if (data)
518 return -EOPNOTSUPP;
519 return 0;
520}
521
522static void skge_get_pauseparam(struct net_device *dev, 503static void skge_get_pauseparam(struct net_device *dev,
523 struct ethtool_pauseparam *ecmd) 504 struct ethtool_pauseparam *ecmd)
524{ 505{
@@ -540,9 +521,9 @@ static int skge_set_pauseparam(struct net_device *dev,
540 skge->autoneg = ecmd->autoneg; 521 skge->autoneg = ecmd->autoneg;
541 if (ecmd->rx_pause && ecmd->tx_pause) 522 if (ecmd->rx_pause && ecmd->tx_pause)
542 skge->flow_control = FLOW_MODE_SYMMETRIC; 523 skge->flow_control = FLOW_MODE_SYMMETRIC;
543 else if(ecmd->rx_pause && !ecmd->tx_pause) 524 else if (ecmd->rx_pause && !ecmd->tx_pause)
544 skge->flow_control = FLOW_MODE_REM_SEND; 525 skge->flow_control = FLOW_MODE_REM_SEND;
545 else if(!ecmd->rx_pause && ecmd->tx_pause) 526 else if (!ecmd->rx_pause && ecmd->tx_pause)
546 skge->flow_control = FLOW_MODE_LOC_SEND; 527 skge->flow_control = FLOW_MODE_LOC_SEND;
547 else 528 else
548 skge->flow_control = FLOW_MODE_NONE; 529 skge->flow_control = FLOW_MODE_NONE;
@@ -559,8 +540,6 @@ static inline u32 hwkhz(const struct skge_hw *hw)
559{ 540{
560 if (hw->chip_id == CHIP_ID_GENESIS) 541 if (hw->chip_id == CHIP_ID_GENESIS)
561 return 53215; /* or: 53.125 MHz */ 542 return 53215; /* or: 53.125 MHz */
562 else if (hw->chip_id == CHIP_ID_YUKON_EC)
563 return 125000; /* or: 125.000 MHz */
564 else 543 else
565 return 78215; /* or: 78.125 MHz */ 544 return 78215; /* or: 78.125 MHz */
566} 545}
@@ -640,107 +619,98 @@ static int skge_set_coalesce(struct net_device *dev,
640 return 0; 619 return 0;
641} 620}
642 621
643static void skge_led_on(struct skge_hw *hw, int port) 622enum led_mode { LED_MODE_OFF, LED_MODE_ON, LED_MODE_TST };
623static void skge_led(struct skge_port *skge, enum led_mode mode)
644{ 624{
625 struct skge_hw *hw = skge->hw;
626 int port = skge->port;
627
628 spin_lock_bh(&hw->phy_lock);
645 if (hw->chip_id == CHIP_ID_GENESIS) { 629 if (hw->chip_id == CHIP_ID_GENESIS) {
646 skge_write8(hw, SKGEMAC_REG(port, LNK_LED_REG), LINKLED_ON); 630 switch (mode) {
647 skge_write8(hw, B0_LED, LED_STAT_ON); 631 case LED_MODE_OFF:
632 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF);
633 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
634 skge_write32(hw, SK_REG(port, RX_LED_VAL), 0);
635 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF);
636 break;
648 637
649 skge_write8(hw, SKGEMAC_REG(port, RX_LED_TST), LED_T_ON); 638 case LED_MODE_ON:
650 skge_write32(hw, SKGEMAC_REG(port, RX_LED_VAL), 100); 639 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_ON);
651 skge_write8(hw, SKGEMAC_REG(port, RX_LED_CTRL), LED_START); 640 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_LINKSYNC_ON);
641
642 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
643 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_START);
652 644
653 switch (hw->phy_type) {
654 case SK_PHY_BCOM:
655 skge_xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL,
656 PHY_B_PEC_LED_ON);
657 break; 645 break;
658 case SK_PHY_LONE: 646
659 skge_xm_phy_write(hw, port, PHY_LONE_LED_CFG, 647 case LED_MODE_TST:
660 0x0800); 648 skge_write8(hw, SK_REG(port, RX_LED_TST), LED_T_ON);
649 skge_write32(hw, SK_REG(port, RX_LED_VAL), 100);
650 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
651
652 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON);
661 break; 653 break;
662 default:
663 skge_write8(hw, SKGEMAC_REG(port, TX_LED_TST), LED_T_ON);
664 skge_write32(hw, SKGEMAC_REG(port, TX_LED_VAL), 100);
665 skge_write8(hw, SKGEMAC_REG(port, TX_LED_CTRL), LED_START);
666 } 654 }
667 } else { 655 } else {
668 skge_gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); 656 switch (mode) {
669 skge_gm_phy_write(hw, port, PHY_MARV_LED_OVER, 657 case LED_MODE_OFF:
670 PHY_M_LED_MO_DUP(MO_LED_ON) | 658 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
671 PHY_M_LED_MO_10(MO_LED_ON) | 659 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
672 PHY_M_LED_MO_100(MO_LED_ON) | 660 PHY_M_LED_MO_DUP(MO_LED_OFF) |
673 PHY_M_LED_MO_1000(MO_LED_ON) | 661 PHY_M_LED_MO_10(MO_LED_OFF) |
674 PHY_M_LED_MO_RX(MO_LED_ON)); 662 PHY_M_LED_MO_100(MO_LED_OFF) |
675 } 663 PHY_M_LED_MO_1000(MO_LED_OFF) |
676} 664 PHY_M_LED_MO_RX(MO_LED_OFF));
677
678static void skge_led_off(struct skge_hw *hw, int port)
679{
680 if (hw->chip_id == CHIP_ID_GENESIS) {
681 skge_write8(hw, SKGEMAC_REG(port, LNK_LED_REG), LINKLED_OFF);
682 skge_write8(hw, B0_LED, LED_STAT_OFF);
683
684 skge_write32(hw, SKGEMAC_REG(port, RX_LED_VAL), 0);
685 skge_write8(hw, SKGEMAC_REG(port, RX_LED_CTRL), LED_T_OFF);
686
687 switch (hw->phy_type) {
688 case SK_PHY_BCOM:
689 skge_xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL,
690 PHY_B_PEC_LED_OFF);
691 break; 665 break;
692 case SK_PHY_LONE: 666 case LED_MODE_ON:
693 skge_xm_phy_write(hw, port, PHY_LONE_LED_CFG, 667 gm_phy_write(hw, port, PHY_MARV_LED_CTRL,
694 PHY_L_LC_LEDT); 668 PHY_M_LED_PULS_DUR(PULS_170MS) |
669 PHY_M_LED_BLINK_RT(BLINK_84MS) |
670 PHY_M_LEDC_TX_CTRL |
671 PHY_M_LEDC_DP_CTRL);
672
673 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
674 PHY_M_LED_MO_RX(MO_LED_OFF) |
675 (skge->speed == SPEED_100 ?
676 PHY_M_LED_MO_100(MO_LED_ON) : 0));
695 break; 677 break;
696 default: 678 case LED_MODE_TST:
697 skge_write32(hw, SKGEMAC_REG(port, TX_LED_VAL), 0); 679 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
698 skge_write8(hw, SKGEMAC_REG(port, TX_LED_CTRL), LED_T_OFF); 680 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
681 PHY_M_LED_MO_DUP(MO_LED_ON) |
682 PHY_M_LED_MO_10(MO_LED_ON) |
683 PHY_M_LED_MO_100(MO_LED_ON) |
684 PHY_M_LED_MO_1000(MO_LED_ON) |
685 PHY_M_LED_MO_RX(MO_LED_ON));
699 } 686 }
700 } else {
701 skge_gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
702 skge_gm_phy_write(hw, port, PHY_MARV_LED_OVER,
703 PHY_M_LED_MO_DUP(MO_LED_OFF) |
704 PHY_M_LED_MO_10(MO_LED_OFF) |
705 PHY_M_LED_MO_100(MO_LED_OFF) |
706 PHY_M_LED_MO_1000(MO_LED_OFF) |
707 PHY_M_LED_MO_RX(MO_LED_OFF));
708 } 687 }
709} 688 spin_unlock_bh(&hw->phy_lock);
710
711static void skge_blink_timer(unsigned long data)
712{
713 struct skge_port *skge = (struct skge_port *) data;
714 struct skge_hw *hw = skge->hw;
715 unsigned long flags;
716
717 spin_lock_irqsave(&hw->phy_lock, flags);
718 if (skge->blink_on)
719 skge_led_on(hw, skge->port);
720 else
721 skge_led_off(hw, skge->port);
722 spin_unlock_irqrestore(&hw->phy_lock, flags);
723
724 skge->blink_on = !skge->blink_on;
725 mod_timer(&skge->led_blink, jiffies + BLINK_HZ);
726} 689}
727 690
728/* blink LED's for finding board */ 691/* blink LED's for finding board */
729static int skge_phys_id(struct net_device *dev, u32 data) 692static int skge_phys_id(struct net_device *dev, u32 data)
730{ 693{
731 struct skge_port *skge = netdev_priv(dev); 694 struct skge_port *skge = netdev_priv(dev);
695 unsigned long ms;
696 enum led_mode mode = LED_MODE_TST;
732 697
733 if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) 698 if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
734 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); 699 ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT / HZ) * 1000;
700 else
701 ms = data * 1000;
735 702
736 /* start blinking */ 703 while (ms > 0) {
737 skge->blink_on = 1; 704 skge_led(skge, mode);
738 mod_timer(&skge->led_blink, jiffies+1); 705 mode ^= LED_MODE_TST;
739 706
740 msleep_interruptible(data * 1000); 707 if (msleep_interruptible(BLINK_MS))
741 del_timer_sync(&skge->led_blink); 708 break;
709 ms -= BLINK_MS;
710 }
742 711
743 skge_led_off(skge->hw, skge->port); 712 /* back to regular LED state */
713 skge_led(skge, netif_running(dev) ? LED_MODE_ON : LED_MODE_OFF);
744 714
745 return 0; 715 return 0;
746} 716}
@@ -763,8 +733,6 @@ static struct ethtool_ops skge_ethtool_ops = {
763 .set_pauseparam = skge_set_pauseparam, 733 .set_pauseparam = skge_set_pauseparam,
764 .get_coalesce = skge_get_coalesce, 734 .get_coalesce = skge_get_coalesce,
765 .set_coalesce = skge_set_coalesce, 735 .set_coalesce = skge_set_coalesce,
766 .get_tso = ethtool_op_get_tso,
767 .set_tso = skge_set_tso,
768 .get_sg = ethtool_op_get_sg, 736 .get_sg = ethtool_op_get_sg,
769 .set_sg = skge_set_sg, 737 .set_sg = skge_set_sg,
770 .get_tx_csum = ethtool_op_get_tx_csum, 738 .get_tx_csum = ethtool_op_get_tx_csum,
@@ -793,6 +761,7 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u64 base)
793 761
794 for (i = 0, e = ring->start, d = vaddr; i < ring->count; i++, e++, d++) { 762 for (i = 0, e = ring->start, d = vaddr; i < ring->count; i++, e++, d++) {
795 e->desc = d; 763 e->desc = d;
764 e->skb = NULL;
796 if (i == ring->count - 1) { 765 if (i == ring->count - 1) {
797 e->next = ring->start; 766 e->next = ring->start;
798 d->next_offset = base; 767 d->next_offset = base;
@@ -806,24 +775,23 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u64 base)
806 return 0; 775 return 0;
807} 776}
808 777
809/* Setup buffer for receiving */ 778static struct sk_buff *skge_rx_alloc(struct net_device *dev, unsigned int size)
810static inline int skge_rx_alloc(struct skge_port *skge,
811 struct skge_element *e)
812{ 779{
813 unsigned long bufsize = skge->netdev->mtu + ETH_HLEN; /* VLAN? */ 780 struct sk_buff *skb = dev_alloc_skb(size);
814 struct skge_rx_desc *rd = e->desc;
815 struct sk_buff *skb;
816 u64 map;
817 781
818 skb = dev_alloc_skb(bufsize + NET_IP_ALIGN); 782 if (likely(skb)) {
819 if (unlikely(!skb)) { 783 skb->dev = dev;
820 printk(KERN_DEBUG PFX "%s: out of memory for receive\n", 784 skb_reserve(skb, NET_IP_ALIGN);
821 skge->netdev->name);
822 return -ENOMEM;
823 } 785 }
786 return skb;
787}
824 788
825 skb->dev = skge->netdev; 789/* Allocate and setup a new buffer for receiving */
826 skb_reserve(skb, NET_IP_ALIGN); 790static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
791 struct sk_buff *skb, unsigned int bufsize)
792{
793 struct skge_rx_desc *rd = e->desc;
794 u64 map;
827 795
828 map = pci_map_single(skge->hw->pdev, skb->data, bufsize, 796 map = pci_map_single(skge->hw->pdev, skb->data, bufsize,
829 PCI_DMA_FROMDEVICE); 797 PCI_DMA_FROMDEVICE);
@@ -841,59 +809,76 @@ static inline int skge_rx_alloc(struct skge_port *skge,
841 rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | bufsize; 809 rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | bufsize;
842 pci_unmap_addr_set(e, mapaddr, map); 810 pci_unmap_addr_set(e, mapaddr, map);
843 pci_unmap_len_set(e, maplen, bufsize); 811 pci_unmap_len_set(e, maplen, bufsize);
844 return 0;
845} 812}
846 813
847/* Free all unused buffers in receive ring, assumes receiver stopped */ 814/* Resume receiving using existing skb,
815 * Note: DMA address is not changed by chip.
816 * MTU not changed while receiver active.
817 */
818static void skge_rx_reuse(struct skge_element *e, unsigned int size)
819{
820 struct skge_rx_desc *rd = e->desc;
821
822 rd->csum2 = 0;
823 rd->csum2_start = ETH_HLEN;
824
825 wmb();
826
827 rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | size;
828}
829
830
831/* Free all buffers in receive ring, assumes receiver stopped */
848static void skge_rx_clean(struct skge_port *skge) 832static void skge_rx_clean(struct skge_port *skge)
849{ 833{
850 struct skge_hw *hw = skge->hw; 834 struct skge_hw *hw = skge->hw;
851 struct skge_ring *ring = &skge->rx_ring; 835 struct skge_ring *ring = &skge->rx_ring;
852 struct skge_element *e; 836 struct skge_element *e;
853 837
854 for (e = ring->to_clean; e != ring->to_use; e = e->next) { 838 e = ring->start;
839 do {
855 struct skge_rx_desc *rd = e->desc; 840 struct skge_rx_desc *rd = e->desc;
856 rd->control = 0; 841 rd->control = 0;
857 842 if (e->skb) {
858 pci_unmap_single(hw->pdev, 843 pci_unmap_single(hw->pdev,
859 pci_unmap_addr(e, mapaddr), 844 pci_unmap_addr(e, mapaddr),
860 pci_unmap_len(e, maplen), 845 pci_unmap_len(e, maplen),
861 PCI_DMA_FROMDEVICE); 846 PCI_DMA_FROMDEVICE);
862 dev_kfree_skb(e->skb); 847 dev_kfree_skb(e->skb);
863 e->skb = NULL; 848 e->skb = NULL;
864 } 849 }
865 ring->to_clean = e; 850 } while ((e = e->next) != ring->start);
866} 851}
867 852
853
868/* Allocate buffers for receive ring 854/* Allocate buffers for receive ring
869 * For receive: to_use is refill location 855 * For receive: to_clean is next received frame.
870 * to_clean is next received frame.
871 *
872 * if (to_use == to_clean)
873 * then ring all frames in ring need buffers
874 * if (to_use->next == to_clean)
875 * then ring all frames in ring have buffers
876 */ 856 */
877static int skge_rx_fill(struct skge_port *skge) 857static int skge_rx_fill(struct skge_port *skge)
878{ 858{
879 struct skge_ring *ring = &skge->rx_ring; 859 struct skge_ring *ring = &skge->rx_ring;
880 struct skge_element *e; 860 struct skge_element *e;
881 int ret = 0; 861 unsigned int bufsize = skge->rx_buf_size;
882 862
883 for (e = ring->to_use; e->next != ring->to_clean; e = e->next) { 863 e = ring->start;
884 if (skge_rx_alloc(skge, e)) { 864 do {
885 ret = 1; 865 struct sk_buff *skb = skge_rx_alloc(skge->netdev, bufsize);
886 break;
887 }
888 866
889 } 867 if (!skb)
890 ring->to_use = e; 868 return -ENOMEM;
869
870 skge_rx_setup(skge, e, skb, bufsize);
871 } while ( (e = e->next) != ring->start);
891 872
892 return ret; 873 ring->to_clean = ring->start;
874 return 0;
893} 875}
894 876
895static void skge_link_up(struct skge_port *skge) 877static void skge_link_up(struct skge_port *skge)
896{ 878{
879 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG),
880 LED_BLK_OFF|LED_SYNC_OFF|LED_ON);
881
897 netif_carrier_on(skge->netdev); 882 netif_carrier_on(skge->netdev);
898 if (skge->tx_avail > MAX_SKB_FRAGS + 1) 883 if (skge->tx_avail > MAX_SKB_FRAGS + 1)
899 netif_wake_queue(skge->netdev); 884 netif_wake_queue(skge->netdev);
@@ -912,6 +897,7 @@ static void skge_link_up(struct skge_port *skge)
912 897
913static void skge_link_down(struct skge_port *skge) 898static void skge_link_down(struct skge_port *skge)
914{ 899{
900 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
915 netif_carrier_off(skge->netdev); 901 netif_carrier_off(skge->netdev);
916 netif_stop_queue(skge->netdev); 902 netif_stop_queue(skge->netdev);
917 903
@@ -919,50 +905,50 @@ static void skge_link_down(struct skge_port *skge)
919 printk(KERN_INFO PFX "%s: Link is down.\n", skge->netdev->name); 905 printk(KERN_INFO PFX "%s: Link is down.\n", skge->netdev->name);
920} 906}
921 907
922static u16 skge_xm_phy_read(struct skge_hw *hw, int port, u16 reg) 908static u16 xm_phy_read(struct skge_hw *hw, int port, u16 reg)
923{ 909{
924 int i; 910 int i;
925 u16 v; 911 u16 v;
926 912
927 skge_xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr); 913 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr);
928 v = skge_xm_read16(hw, port, XM_PHY_DATA); 914 v = xm_read16(hw, port, XM_PHY_DATA);
929 if (hw->phy_type != SK_PHY_XMAC) {
930 for (i = 0; i < PHY_RETRIES; i++) {
931 udelay(1);
932 if (skge_xm_read16(hw, port, XM_MMU_CMD)
933 & XM_MMU_PHY_RDY)
934 goto ready;
935 }
936 915
937 printk(KERN_WARNING PFX "%s: phy read timed out\n", 916 /* Need to wait for external PHY */
938 hw->dev[port]->name); 917 for (i = 0; i < PHY_RETRIES; i++) {
939 return 0; 918 udelay(1);
940 ready: 919 if (xm_read16(hw, port, XM_MMU_CMD)
941 v = skge_xm_read16(hw, port, XM_PHY_DATA); 920 & XM_MMU_PHY_RDY)
921 goto ready;
942 } 922 }
943 923
924 printk(KERN_WARNING PFX "%s: phy read timed out\n",
925 hw->dev[port]->name);
926 return 0;
927 ready:
928 v = xm_read16(hw, port, XM_PHY_DATA);
929
944 return v; 930 return v;
945} 931}
946 932
947static void skge_xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val) 933static void xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val)
948{ 934{
949 int i; 935 int i;
950 936
951 skge_xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr); 937 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr);
952 for (i = 0; i < PHY_RETRIES; i++) { 938 for (i = 0; i < PHY_RETRIES; i++) {
953 if (!(skge_xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_BUSY)) 939 if (!(xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_BUSY))
954 goto ready; 940 goto ready;
955 cpu_relax(); 941 udelay(1);
956 } 942 }
957 printk(KERN_WARNING PFX "%s: phy write failed to come ready\n", 943 printk(KERN_WARNING PFX "%s: phy write failed to come ready\n",
958 hw->dev[port]->name); 944 hw->dev[port]->name);
959 945
960 946
961 ready: 947 ready:
962 skge_xm_write16(hw, port, XM_PHY_DATA, val); 948 xm_write16(hw, port, XM_PHY_DATA, val);
963 for (i = 0; i < PHY_RETRIES; i++) { 949 for (i = 0; i < PHY_RETRIES; i++) {
964 udelay(1); 950 udelay(1);
965 if (!(skge_xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_BUSY)) 951 if (!(xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_BUSY))
966 return; 952 return;
967 } 953 }
968 printk(KERN_WARNING PFX "%s: phy write timed out\n", 954 printk(KERN_WARNING PFX "%s: phy write timed out\n",
@@ -999,34 +985,112 @@ static void genesis_init(struct skge_hw *hw)
999 985
1000static void genesis_reset(struct skge_hw *hw, int port) 986static void genesis_reset(struct skge_hw *hw, int port)
1001{ 987{
1002 int i; 988 const u8 zero[8] = { 0 };
1003 u64 zero = 0;
1004 989
1005 /* reset the statistics module */ 990 /* reset the statistics module */
1006 skge_xm_write32(hw, port, XM_GP_PORT, XM_GP_RES_STAT); 991 xm_write32(hw, port, XM_GP_PORT, XM_GP_RES_STAT);
1007 skge_xm_write16(hw, port, XM_IMSK, 0xffff); /* disable XMAC IRQs */ 992 xm_write16(hw, port, XM_IMSK, 0xffff); /* disable XMAC IRQs */
1008 skge_xm_write32(hw, port, XM_MODE, 0); /* clear Mode Reg */ 993 xm_write32(hw, port, XM_MODE, 0); /* clear Mode Reg */
1009 skge_xm_write16(hw, port, XM_TX_CMD, 0); /* reset TX CMD Reg */ 994 xm_write16(hw, port, XM_TX_CMD, 0); /* reset TX CMD Reg */
1010 skge_xm_write16(hw, port, XM_RX_CMD, 0); /* reset RX CMD Reg */ 995 xm_write16(hw, port, XM_RX_CMD, 0); /* reset RX CMD Reg */
1011 996
1012 /* disable all PHY IRQs */ 997 /* disable Broadcom PHY IRQ */
1013 if (hw->phy_type == SK_PHY_BCOM) 998 xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff);
1014 skge_xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff);
1015 999
1016 skge_xm_outhash(hw, port, XM_HSM, (u8 *) &zero); 1000 xm_outhash(hw, port, XM_HSM, zero);
1017 for (i = 0; i < 15; i++)
1018 skge_xm_outaddr(hw, port, XM_EXM(i), (u8 *) &zero);
1019 skge_xm_outhash(hw, port, XM_SRC_CHK, (u8 *) &zero);
1020} 1001}
1021 1002
1022 1003
1023static void genesis_mac_init(struct skge_hw *hw, int port) 1004/* Convert mode to MII values */
1005static const u16 phy_pause_map[] = {
1006 [FLOW_MODE_NONE] = 0,
1007 [FLOW_MODE_LOC_SEND] = PHY_AN_PAUSE_ASYM,
1008 [FLOW_MODE_SYMMETRIC] = PHY_AN_PAUSE_CAP,
1009 [FLOW_MODE_REM_SEND] = PHY_AN_PAUSE_CAP | PHY_AN_PAUSE_ASYM,
1010};
1011
1012
1013/* Check status of Broadcom phy link */
1014static void bcom_check_link(struct skge_hw *hw, int port)
1024{ 1015{
1025 struct skge_port *skge = netdev_priv(hw->dev[port]); 1016 struct net_device *dev = hw->dev[port];
1017 struct skge_port *skge = netdev_priv(dev);
1018 u16 status;
1019
1020 /* read twice because of latch */
1021 (void) xm_phy_read(hw, port, PHY_BCOM_STAT);
1022 status = xm_phy_read(hw, port, PHY_BCOM_STAT);
1023
1024 pr_debug("bcom_check_link status=0x%x\n", status);
1025
1026 if ((status & PHY_ST_LSYNC) == 0) {
1027 u16 cmd = xm_read16(hw, port, XM_MMU_CMD);
1028 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1029 xm_write16(hw, port, XM_MMU_CMD, cmd);
1030 /* dummy read to ensure writing */
1031 (void) xm_read16(hw, port, XM_MMU_CMD);
1032
1033 if (netif_carrier_ok(dev))
1034 skge_link_down(skge);
1035 } else {
1036 if (skge->autoneg == AUTONEG_ENABLE &&
1037 (status & PHY_ST_AN_OVER)) {
1038 u16 lpa = xm_phy_read(hw, port, PHY_BCOM_AUNE_LP);
1039 u16 aux = xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
1040
1041 if (lpa & PHY_B_AN_RF) {
1042 printk(KERN_NOTICE PFX "%s: remote fault\n",
1043 dev->name);
1044 return;
1045 }
1046
1047 /* Check Duplex mismatch */
1048 switch (aux & PHY_B_AS_AN_RES_MSK) {
1049 case PHY_B_RES_1000FD:
1050 skge->duplex = DUPLEX_FULL;
1051 break;
1052 case PHY_B_RES_1000HD:
1053 skge->duplex = DUPLEX_HALF;
1054 break;
1055 default:
1056 printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
1057 dev->name);
1058 return;
1059 }
1060
1061
1062 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1063 switch (aux & PHY_B_AS_PAUSE_MSK) {
1064 case PHY_B_AS_PAUSE_MSK:
1065 skge->flow_control = FLOW_MODE_SYMMETRIC;
1066 break;
1067 case PHY_B_AS_PRR:
1068 skge->flow_control = FLOW_MODE_REM_SEND;
1069 break;
1070 case PHY_B_AS_PRT:
1071 skge->flow_control = FLOW_MODE_LOC_SEND;
1072 break;
1073 default:
1074 skge->flow_control = FLOW_MODE_NONE;
1075 }
1076
1077 skge->speed = SPEED_1000;
1078 }
1079
1080 if (!netif_carrier_ok(dev))
1081 genesis_link_up(skge);
1082 }
1083}
1084
1085/* Broadcom 5400 only supports giagabit! SysKonnect did not put an additional
1086 * Phy on for 100 or 10Mbit operation
1087 */
1088static void bcom_phy_init(struct skge_port *skge, int jumbo)
1089{
1090 struct skge_hw *hw = skge->hw;
1091 int port = skge->port;
1026 int i; 1092 int i;
1027 u32 r; 1093 u16 id1, r, ext, ctl;
1028 u16 id1;
1029 u16 ctrl1, ctrl2, ctrl3, ctrl4, ctrl5;
1030 1094
1031 /* magic workaround patterns for Broadcom */ 1095 /* magic workaround patterns for Broadcom */
1032 static const struct { 1096 static const struct {
@@ -1042,84 +1106,168 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1042 { 0x17, 0x0013 }, { 0x15, 0x0A04 }, { 0x18, 0x0420 }, 1106 { 0x17, 0x0013 }, { 0x15, 0x0A04 }, { 0x18, 0x0420 },
1043 }; 1107 };
1044 1108
1109 pr_debug("bcom_phy_init\n");
1110
1111 /* read Id from external PHY (all have the same address) */
1112 id1 = xm_phy_read(hw, port, PHY_XMAC_ID1);
1113
1114 /* Optimize MDIO transfer by suppressing preamble. */
1115 r = xm_read16(hw, port, XM_MMU_CMD);
1116 r |= XM_MMU_NO_PRE;
1117 xm_write16(hw, port, XM_MMU_CMD,r);
1045 1118
1046 /* initialize Rx, Tx and Link LED */ 1119 switch (id1) {
1047 skge_write8(hw, SKGEMAC_REG(port, LNK_LED_REG), LINKLED_ON); 1120 case PHY_BCOM_ID1_C0:
1048 skge_write8(hw, SKGEMAC_REG(port, LNK_LED_REG), LINKLED_LINKSYNC_ON); 1121 /*
1122 * Workaround BCOM Errata for the C0 type.
1123 * Write magic patterns to reserved registers.
1124 */
1125 for (i = 0; i < ARRAY_SIZE(C0hack); i++)
1126 xm_phy_write(hw, port,
1127 C0hack[i].reg, C0hack[i].val);
1049 1128
1050 skge_write8(hw, SKGEMAC_REG(port, RX_LED_CTRL), LED_START); 1129 break;
1051 skge_write8(hw, SKGEMAC_REG(port, TX_LED_CTRL), LED_START); 1130 case PHY_BCOM_ID1_A1:
1131 /*
1132 * Workaround BCOM Errata for the A1 type.
1133 * Write magic patterns to reserved registers.
1134 */
1135 for (i = 0; i < ARRAY_SIZE(A1hack); i++)
1136 xm_phy_write(hw, port,
1137 A1hack[i].reg, A1hack[i].val);
1138 break;
1139 }
1140
1141 /*
1142 * Workaround BCOM Errata (#10523) for all BCom PHYs.
1143 * Disable Power Management after reset.
1144 */
1145 r = xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL);
1146 r |= PHY_B_AC_DIS_PM;
1147 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL, r);
1148
1149 /* Dummy read */
1150 xm_read16(hw, port, XM_ISRC);
1151
1152 ext = PHY_B_PEC_EN_LTR; /* enable tx led */
1153 ctl = PHY_CT_SP1000; /* always 1000mbit */
1154
1155 if (skge->autoneg == AUTONEG_ENABLE) {
1156 /*
1157 * Workaround BCOM Errata #1 for the C5 type.
1158 * 1000Base-T Link Acquisition Failure in Slave Mode
1159 * Set Repeater/DTE bit 10 of the 1000Base-T Control Register
1160 */
1161 u16 adv = PHY_B_1000C_RD;
1162 if (skge->advertising & ADVERTISED_1000baseT_Half)
1163 adv |= PHY_B_1000C_AHD;
1164 if (skge->advertising & ADVERTISED_1000baseT_Full)
1165 adv |= PHY_B_1000C_AFD;
1166 xm_phy_write(hw, port, PHY_BCOM_1000T_CTRL, adv);
1167
1168 ctl |= PHY_CT_ANE | PHY_CT_RE_CFG;
1169 } else {
1170 if (skge->duplex == DUPLEX_FULL)
1171 ctl |= PHY_CT_DUP_MD;
1172 /* Force to slave */
1173 xm_phy_write(hw, port, PHY_BCOM_1000T_CTRL, PHY_B_1000C_MSE);
1174 }
1175
1176 /* Set autonegotiation pause parameters */
1177 xm_phy_write(hw, port, PHY_BCOM_AUNE_ADV,
1178 phy_pause_map[skge->flow_control] | PHY_AN_CSMA);
1179
1180 /* Handle Jumbo frames */
1181 if (jumbo) {
1182 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
1183 PHY_B_AC_TX_TST | PHY_B_AC_LONG_PACK);
1184
1185 ext |= PHY_B_PEC_HIGH_LA;
1186
1187 }
1188
1189 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, ext);
1190 xm_phy_write(hw, port, PHY_BCOM_CTRL, ctl);
1191
1192 /* Use link status change interrrupt */
1193 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
1194
1195 bcom_check_link(hw, port);
1196}
1197
1198static void genesis_mac_init(struct skge_hw *hw, int port)
1199{
1200 struct net_device *dev = hw->dev[port];
1201 struct skge_port *skge = netdev_priv(dev);
1202 int jumbo = hw->dev[port]->mtu > ETH_DATA_LEN;
1203 int i;
1204 u32 r;
1205 const u8 zero[6] = { 0 };
1206
1207 /* Clear MIB counters */
1208 xm_write16(hw, port, XM_STAT_CMD,
1209 XM_SC_CLR_RXC | XM_SC_CLR_TXC);
1210 /* Clear two times according to Errata #3 */
1211 xm_write16(hw, port, XM_STAT_CMD,
1212 XM_SC_CLR_RXC | XM_SC_CLR_TXC);
1052 1213
1053 /* Unreset the XMAC. */ 1214 /* Unreset the XMAC. */
1054 skge_write16(hw, SKGEMAC_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST); 1215 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
1055 1216
1056 /* 1217 /*
1057 * Perform additional initialization for external PHYs, 1218 * Perform additional initialization for external PHYs,
1058 * namely for the 1000baseTX cards that use the XMAC's 1219 * namely for the 1000baseTX cards that use the XMAC's
1059 * GMII mode. 1220 * GMII mode.
1060 */ 1221 */
1061 spin_lock_bh(&hw->phy_lock); 1222 /* Take external Phy out of reset */
1062 if (hw->phy_type != SK_PHY_XMAC) { 1223 r = skge_read32(hw, B2_GP_IO);
1063 /* Take PHY out of reset. */ 1224 if (port == 0)
1064 r = skge_read32(hw, B2_GP_IO); 1225 r |= GP_DIR_0|GP_IO_0;
1065 if (port == 0) 1226 else
1066 r |= GP_DIR_0|GP_IO_0; 1227 r |= GP_DIR_2|GP_IO_2;
1067 else
1068 r |= GP_DIR_2|GP_IO_2;
1069
1070 skge_write32(hw, B2_GP_IO, r);
1071 skge_read32(hw, B2_GP_IO);
1072
1073 /* Enable GMII mode on the XMAC. */
1074 skge_xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
1075
1076 id1 = skge_xm_phy_read(hw, port, PHY_XMAC_ID1);
1077
1078 /* Optimize MDIO transfer by suppressing preamble. */
1079 skge_xm_write16(hw, port, XM_MMU_CMD,
1080 skge_xm_read16(hw, port, XM_MMU_CMD)
1081 | XM_MMU_NO_PRE);
1082
1083 if (id1 == PHY_BCOM_ID1_C0) {
1084 /*
1085 * Workaround BCOM Errata for the C0 type.
1086 * Write magic patterns to reserved registers.
1087 */
1088 for (i = 0; i < ARRAY_SIZE(C0hack); i++)
1089 skge_xm_phy_write(hw, port,
1090 C0hack[i].reg, C0hack[i].val);
1091
1092 } else if (id1 == PHY_BCOM_ID1_A1) {
1093 /*
1094 * Workaround BCOM Errata for the A1 type.
1095 * Write magic patterns to reserved registers.
1096 */
1097 for (i = 0; i < ARRAY_SIZE(A1hack); i++)
1098 skge_xm_phy_write(hw, port,
1099 A1hack[i].reg, A1hack[i].val);
1100 }
1101 1228
1102 /* 1229 skge_write32(hw, B2_GP_IO, r);
1103 * Workaround BCOM Errata (#10523) for all BCom PHYs. 1230 skge_read32(hw, B2_GP_IO);
1104 * Disable Power Management after reset.
1105 */
1106 r = skge_xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL);
1107 skge_xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL, r | PHY_B_AC_DIS_PM);
1108 }
1109 1231
1110 /* Dummy read */ 1232 /* Enable GMII interfac */
1111 skge_xm_read16(hw, port, XM_ISRC); 1233 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
1234
1235 bcom_phy_init(skge, jumbo);
1112 1236
1113 r = skge_xm_read32(hw, port, XM_MODE); 1237 /* Set Station Address */
1114 skge_xm_write32(hw, port, XM_MODE, r|XM_MD_CSA); 1238 xm_outaddr(hw, port, XM_SA, dev->dev_addr);
1239
1240 /* We don't use match addresses so clear */
1241 for (i = 1; i < 16; i++)
1242 xm_outaddr(hw, port, XM_EXM(i), zero);
1243
1244 /* configure Rx High Water Mark (XM_RX_HI_WM) */
1245 xm_write16(hw, port, XM_RX_HI_WM, 1450);
1115 1246
1116 /* We don't need the FCS appended to the packet. */ 1247 /* We don't need the FCS appended to the packet. */
1117 r = skge_xm_read16(hw, port, XM_RX_CMD); 1248 r = XM_RX_LENERR_OK | XM_RX_STRIP_FCS;
1118 skge_xm_write16(hw, port, XM_RX_CMD, r | XM_RX_STRIP_FCS); 1249 if (jumbo)
1250 r |= XM_RX_BIG_PK_OK;
1251
1252 if (skge->duplex == DUPLEX_HALF) {
1253 /*
1254 * If in manual half duplex mode the other side might be in
1255 * full duplex mode, so ignore if a carrier extension is not seen
1256 * on frames received
1257 */
1258 r |= XM_RX_DIS_CEXT;
1259 }
1260 xm_write16(hw, port, XM_RX_CMD, r);
1261
1119 1262
1120 /* We want short frames padded to 60 bytes. */ 1263 /* We want short frames padded to 60 bytes. */
1121 r = skge_xm_read16(hw, port, XM_TX_CMD); 1264 xm_write16(hw, port, XM_TX_CMD, XM_TX_AUTO_PAD);
1122 skge_xm_write16(hw, port, XM_TX_CMD, r | XM_TX_AUTO_PAD); 1265
1266 /*
1267 * Bump up the transmit threshold. This helps hold off transmit
1268 * underruns when we're blasting traffic from both ports at once.
1269 */
1270 xm_write16(hw, port, XM_TX_THR, 512);
1123 1271
1124 /* 1272 /*
1125 * Enable the reception of all error frames. This is is 1273 * Enable the reception of all error frames. This is is
@@ -1135,19 +1283,22 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1135 * case the XMAC will start transfering frames out of the 1283 * case the XMAC will start transfering frames out of the
1136 * RX FIFO as soon as the FIFO threshold is reached. 1284 * RX FIFO as soon as the FIFO threshold is reached.
1137 */ 1285 */
1138 r = skge_xm_read32(hw, port, XM_MODE); 1286 xm_write32(hw, port, XM_MODE, XM_DEF_MODE);
1139 skge_xm_write32(hw, port, XM_MODE,
1140 XM_MD_RX_CRCE|XM_MD_RX_LONG|XM_MD_RX_RUNT|
1141 XM_MD_RX_ERR|XM_MD_RX_IRLE);
1142 1287
1143 skge_xm_outaddr(hw, port, XM_SA, hw->dev[port]->dev_addr);
1144 skge_xm_outaddr(hw, port, XM_EXM(0), hw->dev[port]->dev_addr);
1145 1288
1146 /* 1289 /*
1147 * Bump up the transmit threshold. This helps hold off transmit 1290 * Initialize the Receive Counter Event Mask (XM_RX_EV_MSK)
1148 * underruns when we're blasting traffic from both ports at once. 1291 * - Enable all bits excepting 'Octets Rx OK Low CntOv'
1292 * and 'Octets Rx OK Hi Cnt Ov'.
1149 */ 1293 */
1150 skge_xm_write16(hw, port, XM_TX_THR, 512); 1294 xm_write32(hw, port, XM_RX_EV_MSK, XMR_DEF_MSK);
1295
1296 /*
1297 * Initialize the Transmit Counter Event Mask (XM_TX_EV_MSK)
1298 * - Enable all bits excepting 'Octets Tx OK Low CntOv'
1299 * and 'Octets Tx OK Hi Cnt Ov'.
1300 */
1301 xm_write32(hw, port, XM_TX_EV_MSK, XMT_DEF_MSK);
1151 1302
1152 /* Configure MAC arbiter */ 1303 /* Configure MAC arbiter */
1153 skge_write16(hw, B3_MA_TO_CTRL, MA_RST_CLR); 1304 skge_write16(hw, B3_MA_TO_CTRL, MA_RST_CLR);
@@ -1164,137 +1315,30 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1164 skge_write8(hw, B3_MA_RCINI_TX2, 0); 1315 skge_write8(hw, B3_MA_RCINI_TX2, 0);
1165 1316
1166 /* Configure Rx MAC FIFO */ 1317 /* Configure Rx MAC FIFO */
1167 skge_write8(hw, SKGEMAC_REG(port, RX_MFF_CTRL2), MFF_RST_CLR); 1318 skge_write8(hw, SK_REG(port, RX_MFF_CTRL2), MFF_RST_CLR);
1168 skge_write16(hw, SKGEMAC_REG(port, RX_MFF_CTRL1), MFF_ENA_TIM_PAT); 1319 skge_write16(hw, SK_REG(port, RX_MFF_CTRL1), MFF_ENA_TIM_PAT);
1169 skge_write8(hw, SKGEMAC_REG(port, RX_MFF_CTRL2), MFF_ENA_OP_MD); 1320 skge_write8(hw, SK_REG(port, RX_MFF_CTRL2), MFF_ENA_OP_MD);
1170 1321
1171 /* Configure Tx MAC FIFO */ 1322 /* Configure Tx MAC FIFO */
1172 skge_write8(hw, SKGEMAC_REG(port, TX_MFF_CTRL2), MFF_RST_CLR); 1323 skge_write8(hw, SK_REG(port, TX_MFF_CTRL2), MFF_RST_CLR);
1173 skge_write16(hw, SKGEMAC_REG(port, TX_MFF_CTRL1), MFF_TX_CTRL_DEF); 1324 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_TX_CTRL_DEF);
1174 skge_write8(hw, SKGEMAC_REG(port, TX_MFF_CTRL2), MFF_ENA_OP_MD); 1325 skge_write8(hw, SK_REG(port, TX_MFF_CTRL2), MFF_ENA_OP_MD);
1175 1326
1176 if (hw->dev[port]->mtu > ETH_DATA_LEN) { 1327 if (jumbo) {
1177 /* Enable frame flushing if jumbo frames used */ 1328 /* Enable frame flushing if jumbo frames used */
1178 skge_write16(hw, SKGEMAC_REG(port,RX_MFF_CTRL1), MFF_ENA_FLUSH); 1329 skge_write16(hw, SK_REG(port,RX_MFF_CTRL1), MFF_ENA_FLUSH);
1179 } else { 1330 } else {
1180 /* enable timeout timers if normal frames */ 1331 /* enable timeout timers if normal frames */
1181 skge_write16(hw, B3_PA_CTRL, 1332 skge_write16(hw, B3_PA_CTRL,
1182 port == 0 ? PA_ENA_TO_TX1 : PA_ENA_TO_TX2); 1333 (port == 0) ? PA_ENA_TO_TX1 : PA_ENA_TO_TX2);
1183 } 1334 }
1184
1185
1186 r = skge_xm_read16(hw, port, XM_RX_CMD);
1187 if (hw->dev[port]->mtu > ETH_DATA_LEN)
1188 skge_xm_write16(hw, port, XM_RX_CMD, r | XM_RX_BIG_PK_OK);
1189 else
1190 skge_xm_write16(hw, port, XM_RX_CMD, r & ~(XM_RX_BIG_PK_OK));
1191
1192 switch (hw->phy_type) {
1193 case SK_PHY_XMAC:
1194 if (skge->autoneg == AUTONEG_ENABLE) {
1195 ctrl1 = PHY_X_AN_FD | PHY_X_AN_HD;
1196
1197 switch (skge->flow_control) {
1198 case FLOW_MODE_NONE:
1199 ctrl1 |= PHY_X_P_NO_PAUSE;
1200 break;
1201 case FLOW_MODE_LOC_SEND:
1202 ctrl1 |= PHY_X_P_ASYM_MD;
1203 break;
1204 case FLOW_MODE_SYMMETRIC:
1205 ctrl1 |= PHY_X_P_SYM_MD;
1206 break;
1207 case FLOW_MODE_REM_SEND:
1208 ctrl1 |= PHY_X_P_BOTH_MD;
1209 break;
1210 }
1211
1212 skge_xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl1);
1213 ctrl2 = PHY_CT_ANE | PHY_CT_RE_CFG;
1214 } else {
1215 ctrl2 = 0;
1216 if (skge->duplex == DUPLEX_FULL)
1217 ctrl2 |= PHY_CT_DUP_MD;
1218 }
1219
1220 skge_xm_phy_write(hw, port, PHY_XMAC_CTRL, ctrl2);
1221 break;
1222
1223 case SK_PHY_BCOM:
1224 ctrl1 = PHY_CT_SP1000;
1225 ctrl2 = 0;
1226 ctrl3 = PHY_SEL_TYPE;
1227 ctrl4 = PHY_B_PEC_EN_LTR;
1228 ctrl5 = PHY_B_AC_TX_TST;
1229
1230 if (skge->autoneg == AUTONEG_ENABLE) {
1231 /*
1232 * Workaround BCOM Errata #1 for the C5 type.
1233 * 1000Base-T Link Acquisition Failure in Slave Mode
1234 * Set Repeater/DTE bit 10 of the 1000Base-T Control Register
1235 */
1236 ctrl2 |= PHY_B_1000C_RD;
1237 if (skge->advertising & ADVERTISED_1000baseT_Half)
1238 ctrl2 |= PHY_B_1000C_AHD;
1239 if (skge->advertising & ADVERTISED_1000baseT_Full)
1240 ctrl2 |= PHY_B_1000C_AFD;
1241
1242 /* Set Flow-control capabilities */
1243 switch (skge->flow_control) {
1244 case FLOW_MODE_NONE:
1245 ctrl3 |= PHY_B_P_NO_PAUSE;
1246 break;
1247 case FLOW_MODE_LOC_SEND:
1248 ctrl3 |= PHY_B_P_ASYM_MD;
1249 break;
1250 case FLOW_MODE_SYMMETRIC:
1251 ctrl3 |= PHY_B_P_SYM_MD;
1252 break;
1253 case FLOW_MODE_REM_SEND:
1254 ctrl3 |= PHY_B_P_BOTH_MD;
1255 break;
1256 }
1257
1258 /* Restart Auto-negotiation */
1259 ctrl1 |= PHY_CT_ANE | PHY_CT_RE_CFG;
1260 } else {
1261 if (skge->duplex == DUPLEX_FULL)
1262 ctrl1 |= PHY_CT_DUP_MD;
1263
1264 ctrl2 |= PHY_B_1000C_MSE; /* set it to Slave */
1265 }
1266
1267 skge_xm_phy_write(hw, port, PHY_BCOM_1000T_CTRL, ctrl2);
1268 skge_xm_phy_write(hw, port, PHY_BCOM_AUNE_ADV, ctrl3);
1269
1270 if (skge->netdev->mtu > ETH_DATA_LEN) {
1271 ctrl4 |= PHY_B_PEC_HIGH_LA;
1272 ctrl5 |= PHY_B_AC_LONG_PACK;
1273
1274 skge_xm_phy_write(hw, port,PHY_BCOM_AUX_CTRL, ctrl5);
1275 }
1276
1277 skge_xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, ctrl4);
1278 skge_xm_phy_write(hw, port, PHY_BCOM_CTRL, ctrl1);
1279 break;
1280 }
1281 spin_unlock_bh(&hw->phy_lock);
1282
1283 /* Clear MIB counters */
1284 skge_xm_write16(hw, port, XM_STAT_CMD,
1285 XM_SC_CLR_RXC | XM_SC_CLR_TXC);
1286 /* Clear two times according to Errata #3 */
1287 skge_xm_write16(hw, port, XM_STAT_CMD,
1288 XM_SC_CLR_RXC | XM_SC_CLR_TXC);
1289
1290 /* Start polling for link status */
1291 mod_timer(&skge->link_check, jiffies + LINK_POLL_HZ);
1292} 1335}
1293 1336
1294static void genesis_stop(struct skge_port *skge) 1337static void genesis_stop(struct skge_port *skge)
1295{ 1338{
1296 struct skge_hw *hw = skge->hw; 1339 struct skge_hw *hw = skge->hw;
1297 int port = skge->port; 1340 int port = skge->port;
1341 u32 reg;
1298 1342
1299 /* Clear Tx packet arbiter timeout IRQ */ 1343 /* Clear Tx packet arbiter timeout IRQ */
1300 skge_write16(hw, B3_PA_CTRL, 1344 skge_write16(hw, B3_PA_CTRL,
@@ -1304,33 +1348,30 @@ static void genesis_stop(struct skge_port *skge)
1304 * If the transfer stucks at the MAC the STOP command will not 1348 * If the transfer stucks at the MAC the STOP command will not
1305 * terminate if we don't flush the XMAC's transmit FIFO ! 1349 * terminate if we don't flush the XMAC's transmit FIFO !
1306 */ 1350 */
1307 skge_xm_write32(hw, port, XM_MODE, 1351 xm_write32(hw, port, XM_MODE,
1308 skge_xm_read32(hw, port, XM_MODE)|XM_MD_FTF); 1352 xm_read32(hw, port, XM_MODE)|XM_MD_FTF);
1309 1353
1310 1354
1311 /* Reset the MAC */ 1355 /* Reset the MAC */
1312 skge_write16(hw, SKGEMAC_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST); 1356 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST);
1313 1357
1314 /* For external PHYs there must be special handling */ 1358 /* For external PHYs there must be special handling */
1315 if (hw->phy_type != SK_PHY_XMAC) { 1359 reg = skge_read32(hw, B2_GP_IO);
1316 u32 reg = skge_read32(hw, B2_GP_IO); 1360 if (port == 0) {
1317 1361 reg |= GP_DIR_0;
1318 if (port == 0) { 1362 reg &= ~GP_IO_0;
1319 reg |= GP_DIR_0; 1363 } else {
1320 reg &= ~GP_IO_0; 1364 reg |= GP_DIR_2;
1321 } else { 1365 reg &= ~GP_IO_2;
1322 reg |= GP_DIR_2;
1323 reg &= ~GP_IO_2;
1324 }
1325 skge_write32(hw, B2_GP_IO, reg);
1326 skge_read32(hw, B2_GP_IO);
1327 } 1366 }
1367 skge_write32(hw, B2_GP_IO, reg);
1368 skge_read32(hw, B2_GP_IO);
1328 1369
1329 skge_xm_write16(hw, port, XM_MMU_CMD, 1370 xm_write16(hw, port, XM_MMU_CMD,
1330 skge_xm_read16(hw, port, XM_MMU_CMD) 1371 xm_read16(hw, port, XM_MMU_CMD)
1331 & ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX)); 1372 & ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX));
1332 1373
1333 skge_xm_read16(hw, port, XM_MMU_CMD); 1374 xm_read16(hw, port, XM_MMU_CMD);
1334} 1375}
1335 1376
1336 1377
@@ -1341,11 +1382,11 @@ static void genesis_get_stats(struct skge_port *skge, u64 *data)
1341 int i; 1382 int i;
1342 unsigned long timeout = jiffies + HZ; 1383 unsigned long timeout = jiffies + HZ;
1343 1384
1344 skge_xm_write16(hw, port, 1385 xm_write16(hw, port,
1345 XM_STAT_CMD, XM_SC_SNP_TXC | XM_SC_SNP_RXC); 1386 XM_STAT_CMD, XM_SC_SNP_TXC | XM_SC_SNP_RXC);
1346 1387
1347 /* wait for update to complete */ 1388 /* wait for update to complete */
1348 while (skge_xm_read16(hw, port, XM_STAT_CMD) 1389 while (xm_read16(hw, port, XM_STAT_CMD)
1349 & (XM_SC_SNP_TXC | XM_SC_SNP_RXC)) { 1390 & (XM_SC_SNP_TXC | XM_SC_SNP_RXC)) {
1350 if (time_after(jiffies, timeout)) 1391 if (time_after(jiffies, timeout))
1351 break; 1392 break;
@@ -1353,68 +1394,60 @@ static void genesis_get_stats(struct skge_port *skge, u64 *data)
1353 } 1394 }
1354 1395
1355 /* special case for 64 bit octet counter */ 1396 /* special case for 64 bit octet counter */
1356 data[0] = (u64) skge_xm_read32(hw, port, XM_TXO_OK_HI) << 32 1397 data[0] = (u64) xm_read32(hw, port, XM_TXO_OK_HI) << 32
1357 | skge_xm_read32(hw, port, XM_TXO_OK_LO); 1398 | xm_read32(hw, port, XM_TXO_OK_LO);
1358 data[1] = (u64) skge_xm_read32(hw, port, XM_RXO_OK_HI) << 32 1399 data[1] = (u64) xm_read32(hw, port, XM_RXO_OK_HI) << 32
1359 | skge_xm_read32(hw, port, XM_RXO_OK_LO); 1400 | xm_read32(hw, port, XM_RXO_OK_LO);
1360 1401
1361 for (i = 2; i < ARRAY_SIZE(skge_stats); i++) 1402 for (i = 2; i < ARRAY_SIZE(skge_stats); i++)
1362 data[i] = skge_xm_read32(hw, port, skge_stats[i].xmac_offset); 1403 data[i] = xm_read32(hw, port, skge_stats[i].xmac_offset);
1363} 1404}
1364 1405
1365static void genesis_mac_intr(struct skge_hw *hw, int port) 1406static void genesis_mac_intr(struct skge_hw *hw, int port)
1366{ 1407{
1367 struct skge_port *skge = netdev_priv(hw->dev[port]); 1408 struct skge_port *skge = netdev_priv(hw->dev[port]);
1368 u16 status = skge_xm_read16(hw, port, XM_ISRC); 1409 u16 status = xm_read16(hw, port, XM_ISRC);
1369 1410
1370 pr_debug("genesis_intr status %x\n", status); 1411 if (netif_msg_intr(skge))
1371 if (hw->phy_type == SK_PHY_XMAC) { 1412 printk(KERN_DEBUG PFX "%s: mac interrupt status 0x%x\n",
1372 /* LInk down, start polling for state change */ 1413 skge->netdev->name, status);
1373 if (status & XM_IS_INP_ASS) {
1374 skge_xm_write16(hw, port, XM_IMSK,
1375 skge_xm_read16(hw, port, XM_IMSK) | XM_IS_INP_ASS);
1376 mod_timer(&skge->link_check, jiffies + LINK_POLL_HZ);
1377 }
1378 else if (status & XM_IS_AND)
1379 mod_timer(&skge->link_check, jiffies + LINK_POLL_HZ);
1380 }
1381 1414
1382 if (status & XM_IS_TXF_UR) { 1415 if (status & XM_IS_TXF_UR) {
1383 skge_xm_write32(hw, port, XM_MODE, XM_MD_FTF); 1416 xm_write32(hw, port, XM_MODE, XM_MD_FTF);
1384 ++skge->net_stats.tx_fifo_errors; 1417 ++skge->net_stats.tx_fifo_errors;
1385 } 1418 }
1386 if (status & XM_IS_RXF_OV) { 1419 if (status & XM_IS_RXF_OV) {
1387 skge_xm_write32(hw, port, XM_MODE, XM_MD_FRF); 1420 xm_write32(hw, port, XM_MODE, XM_MD_FRF);
1388 ++skge->net_stats.rx_fifo_errors; 1421 ++skge->net_stats.rx_fifo_errors;
1389 } 1422 }
1390} 1423}
1391 1424
1392static void skge_gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val) 1425static void gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val)
1393{ 1426{
1394 int i; 1427 int i;
1395 1428
1396 skge_gma_write16(hw, port, GM_SMI_DATA, val); 1429 gma_write16(hw, port, GM_SMI_DATA, val);
1397 skge_gma_write16(hw, port, GM_SMI_CTRL, 1430 gma_write16(hw, port, GM_SMI_CTRL,
1398 GM_SMI_CT_PHY_AD(hw->phy_addr) | GM_SMI_CT_REG_AD(reg)); 1431 GM_SMI_CT_PHY_AD(hw->phy_addr) | GM_SMI_CT_REG_AD(reg));
1399 for (i = 0; i < PHY_RETRIES; i++) { 1432 for (i = 0; i < PHY_RETRIES; i++) {
1400 udelay(1); 1433 udelay(1);
1401 1434
1402 if (!(skge_gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY)) 1435 if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY))
1403 break; 1436 break;
1404 } 1437 }
1405} 1438}
1406 1439
1407static u16 skge_gm_phy_read(struct skge_hw *hw, int port, u16 reg) 1440static u16 gm_phy_read(struct skge_hw *hw, int port, u16 reg)
1408{ 1441{
1409 int i; 1442 int i;
1410 1443
1411 skge_gma_write16(hw, port, GM_SMI_CTRL, 1444 gma_write16(hw, port, GM_SMI_CTRL,
1412 GM_SMI_CT_PHY_AD(hw->phy_addr) 1445 GM_SMI_CT_PHY_AD(hw->phy_addr)
1413 | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD); 1446 | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD);
1414 1447
1415 for (i = 0; i < PHY_RETRIES; i++) { 1448 for (i = 0; i < PHY_RETRIES; i++) {
1416 udelay(1); 1449 udelay(1);
1417 if (skge_gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) 1450 if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL)
1418 goto ready; 1451 goto ready;
1419 } 1452 }
1420 1453
@@ -1422,24 +1455,7 @@ static u16 skge_gm_phy_read(struct skge_hw *hw, int port, u16 reg)
1422 hw->dev[port]->name); 1455 hw->dev[port]->name);
1423 return 0; 1456 return 0;
1424 ready: 1457 ready:
1425 return skge_gma_read16(hw, port, GM_SMI_DATA); 1458 return gma_read16(hw, port, GM_SMI_DATA);
1426}
1427
1428static void genesis_link_down(struct skge_port *skge)
1429{
1430 struct skge_hw *hw = skge->hw;
1431 int port = skge->port;
1432
1433 pr_debug("genesis_link_down\n");
1434
1435 skge_xm_write16(hw, port, XM_MMU_CMD,
1436 skge_xm_read16(hw, port, XM_MMU_CMD)
1437 & ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX));
1438
1439 /* dummy read to ensure writing */
1440 (void) skge_xm_read16(hw, port, XM_MMU_CMD);
1441
1442 skge_link_down(skge);
1443} 1459}
1444 1460
1445static void genesis_link_up(struct skge_port *skge) 1461static void genesis_link_up(struct skge_port *skge)
@@ -1450,7 +1466,7 @@ static void genesis_link_up(struct skge_port *skge)
1450 u32 mode, msk; 1466 u32 mode, msk;
1451 1467
1452 pr_debug("genesis_link_up\n"); 1468 pr_debug("genesis_link_up\n");
1453 cmd = skge_xm_read16(hw, port, XM_MMU_CMD); 1469 cmd = xm_read16(hw, port, XM_MMU_CMD);
1454 1470
1455 /* 1471 /*
1456 * enabling pause frame reception is required for 1000BT 1472 * enabling pause frame reception is required for 1000BT
@@ -1458,14 +1474,15 @@ static void genesis_link_up(struct skge_port *skge)
1458 */ 1474 */
1459 if (skge->flow_control == FLOW_MODE_NONE || 1475 if (skge->flow_control == FLOW_MODE_NONE ||
1460 skge->flow_control == FLOW_MODE_LOC_SEND) 1476 skge->flow_control == FLOW_MODE_LOC_SEND)
1477 /* Disable Pause Frame Reception */
1461 cmd |= XM_MMU_IGN_PF; 1478 cmd |= XM_MMU_IGN_PF;
1462 else 1479 else
1463 /* Enable Pause Frame Reception */ 1480 /* Enable Pause Frame Reception */
1464 cmd &= ~XM_MMU_IGN_PF; 1481 cmd &= ~XM_MMU_IGN_PF;
1465 1482
1466 skge_xm_write16(hw, port, XM_MMU_CMD, cmd); 1483 xm_write16(hw, port, XM_MMU_CMD, cmd);
1467 1484
1468 mode = skge_xm_read32(hw, port, XM_MODE); 1485 mode = xm_read32(hw, port, XM_MODE);
1469 if (skge->flow_control == FLOW_MODE_SYMMETRIC || 1486 if (skge->flow_control == FLOW_MODE_SYMMETRIC ||
1470 skge->flow_control == FLOW_MODE_LOC_SEND) { 1487 skge->flow_control == FLOW_MODE_LOC_SEND) {
1471 /* 1488 /*
@@ -1479,10 +1496,10 @@ static void genesis_link_up(struct skge_port *skge)
1479 /* XM_PAUSE_DA = '010000C28001' (default) */ 1496 /* XM_PAUSE_DA = '010000C28001' (default) */
1480 /* XM_MAC_PTIME = 0xffff (maximum) */ 1497 /* XM_MAC_PTIME = 0xffff (maximum) */
1481 /* remember this value is defined in big endian (!) */ 1498 /* remember this value is defined in big endian (!) */
1482 skge_xm_write16(hw, port, XM_MAC_PTIME, 0xffff); 1499 xm_write16(hw, port, XM_MAC_PTIME, 0xffff);
1483 1500
1484 mode |= XM_PAUSE_MODE; 1501 mode |= XM_PAUSE_MODE;
1485 skge_write16(hw, SKGEMAC_REG(port, RX_MFF_CTRL1), MFF_ENA_PAUSE); 1502 skge_write16(hw, SK_REG(port, RX_MFF_CTRL1), MFF_ENA_PAUSE);
1486 } else { 1503 } else {
1487 /* 1504 /*
1488 * disable pause frame generation is required for 1000BT 1505 * disable pause frame generation is required for 1000BT
@@ -1491,125 +1508,68 @@ static void genesis_link_up(struct skge_port *skge)
1491 /* Disable Pause Mode in Mode Register */ 1508 /* Disable Pause Mode in Mode Register */
1492 mode &= ~XM_PAUSE_MODE; 1509 mode &= ~XM_PAUSE_MODE;
1493 1510
1494 skge_write16(hw, SKGEMAC_REG(port, RX_MFF_CTRL1), MFF_DIS_PAUSE); 1511 skge_write16(hw, SK_REG(port, RX_MFF_CTRL1), MFF_DIS_PAUSE);
1495 } 1512 }
1496 1513
1497 skge_xm_write32(hw, port, XM_MODE, mode); 1514 xm_write32(hw, port, XM_MODE, mode);
1498 1515
1499 msk = XM_DEF_MSK; 1516 msk = XM_DEF_MSK;
1500 if (hw->phy_type != SK_PHY_XMAC) 1517 /* disable GP0 interrupt bit for external Phy */
1501 msk |= XM_IS_INP_ASS; /* disable GP0 interrupt bit */ 1518 msk |= XM_IS_INP_ASS;
1502 1519
1503 skge_xm_write16(hw, port, XM_IMSK, msk); 1520 xm_write16(hw, port, XM_IMSK, msk);
1504 skge_xm_read16(hw, port, XM_ISRC); 1521 xm_read16(hw, port, XM_ISRC);
1505 1522
1506 /* get MMU Command Reg. */ 1523 /* get MMU Command Reg. */
1507 cmd = skge_xm_read16(hw, port, XM_MMU_CMD); 1524 cmd = xm_read16(hw, port, XM_MMU_CMD);
1508 if (hw->phy_type != SK_PHY_XMAC && skge->duplex == DUPLEX_FULL) 1525 if (skge->duplex == DUPLEX_FULL)
1509 cmd |= XM_MMU_GMII_FD; 1526 cmd |= XM_MMU_GMII_FD;
1510 1527
1511 if (hw->phy_type == SK_PHY_BCOM) { 1528 /*
1512 /* 1529 * Workaround BCOM Errata (#10523) for all BCom Phys
1513 * Workaround BCOM Errata (#10523) for all BCom Phys 1530 * Enable Power Management after link up
1514 * Enable Power Management after link up 1531 */
1515 */ 1532 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
1516 skge_xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL, 1533 xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL)
1517 skge_xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL) 1534 & ~PHY_B_AC_DIS_PM);
1518 & ~PHY_B_AC_DIS_PM); 1535 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
1519 skge_xm_phy_write(hw, port, PHY_BCOM_INT_MASK,
1520 PHY_B_DEF_MSK);
1521 }
1522 1536
1523 /* enable Rx/Tx */ 1537 /* enable Rx/Tx */
1524 skge_xm_write16(hw, port, XM_MMU_CMD, 1538 xm_write16(hw, port, XM_MMU_CMD,
1525 cmd | XM_MMU_ENA_RX | XM_MMU_ENA_TX); 1539 cmd | XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1526 skge_link_up(skge); 1540 skge_link_up(skge);
1527} 1541}
1528 1542
1529 1543
1530static void genesis_bcom_intr(struct skge_port *skge) 1544static inline void bcom_phy_intr(struct skge_port *skge)
1531{ 1545{
1532 struct skge_hw *hw = skge->hw; 1546 struct skge_hw *hw = skge->hw;
1533 int port = skge->port; 1547 int port = skge->port;
1534 u16 stat = skge_xm_phy_read(hw, port, PHY_BCOM_INT_STAT); 1548 u16 isrc;
1549
1550 isrc = xm_phy_read(hw, port, PHY_BCOM_INT_STAT);
1551 if (netif_msg_intr(skge))
1552 printk(KERN_DEBUG PFX "%s: phy interrupt status 0x%x\n",
1553 skge->netdev->name, isrc);
1535 1554
1536 pr_debug("genesis_bcom intr stat=%x\n", stat); 1555 if (isrc & PHY_B_IS_PSE)
1556 printk(KERN_ERR PFX "%s: uncorrectable pair swap error\n",
1557 hw->dev[port]->name);
1537 1558
1538 /* Workaround BCom Errata: 1559 /* Workaround BCom Errata:
1539 * enable and disable loopback mode if "NO HCD" occurs. 1560 * enable and disable loopback mode if "NO HCD" occurs.
1540 */ 1561 */
1541 if (stat & PHY_B_IS_NO_HDCL) { 1562 if (isrc & PHY_B_IS_NO_HDCL) {
1542 u16 ctrl = skge_xm_phy_read(hw, port, PHY_BCOM_CTRL); 1563 u16 ctrl = xm_phy_read(hw, port, PHY_BCOM_CTRL);
1543 skge_xm_phy_write(hw, port, PHY_BCOM_CTRL, 1564 xm_phy_write(hw, port, PHY_BCOM_CTRL,
1544 ctrl | PHY_CT_LOOP); 1565 ctrl | PHY_CT_LOOP);
1545 skge_xm_phy_write(hw, port, PHY_BCOM_CTRL, 1566 xm_phy_write(hw, port, PHY_BCOM_CTRL,
1546 ctrl & ~PHY_CT_LOOP); 1567 ctrl & ~PHY_CT_LOOP);
1547 } 1568 }
1548 1569
1549 stat = skge_xm_phy_read(hw, port, PHY_BCOM_STAT); 1570 if (isrc & (PHY_B_IS_AN_PR | PHY_B_IS_LST_CHANGE))
1550 if (stat & (PHY_B_IS_AN_PR | PHY_B_IS_LST_CHANGE)) { 1571 bcom_check_link(hw, port);
1551 u16 aux = skge_xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
1552 if ( !(aux & PHY_B_AS_LS) && netif_carrier_ok(skge->netdev))
1553 genesis_link_down(skge);
1554
1555 else if (stat & PHY_B_IS_LST_CHANGE) {
1556 if (aux & PHY_B_AS_AN_C) {
1557 switch (aux & PHY_B_AS_AN_RES_MSK) {
1558 case PHY_B_RES_1000FD:
1559 skge->duplex = DUPLEX_FULL;
1560 break;
1561 case PHY_B_RES_1000HD:
1562 skge->duplex = DUPLEX_HALF;
1563 break;
1564 }
1565
1566 switch (aux & PHY_B_AS_PAUSE_MSK) {
1567 case PHY_B_AS_PAUSE_MSK:
1568 skge->flow_control = FLOW_MODE_SYMMETRIC;
1569 break;
1570 case PHY_B_AS_PRR:
1571 skge->flow_control = FLOW_MODE_REM_SEND;
1572 break;
1573 case PHY_B_AS_PRT:
1574 skge->flow_control = FLOW_MODE_LOC_SEND;
1575 break;
1576 default:
1577 skge->flow_control = FLOW_MODE_NONE;
1578 }
1579 skge->speed = SPEED_1000;
1580 }
1581 genesis_link_up(skge);
1582 }
1583 else
1584 mod_timer(&skge->link_check, jiffies + LINK_POLL_HZ);
1585 }
1586}
1587
1588/* Perodic poll of phy status to check for link transistion */
1589static void skge_link_timer(unsigned long __arg)
1590{
1591 struct skge_port *skge = (struct skge_port *) __arg;
1592 struct skge_hw *hw = skge->hw;
1593 int port = skge->port;
1594
1595 if (hw->chip_id != CHIP_ID_GENESIS || !netif_running(skge->netdev))
1596 return;
1597
1598 spin_lock_bh(&hw->phy_lock);
1599 if (hw->phy_type == SK_PHY_BCOM)
1600 genesis_bcom_intr(skge);
1601 else {
1602 int i;
1603 for (i = 0; i < 3; i++)
1604 if (skge_xm_read16(hw, port, XM_ISRC) & XM_IS_INP_ASS)
1605 break;
1606 1572
1607 if (i == 3)
1608 mod_timer(&skge->link_check, jiffies + LINK_POLL_HZ);
1609 else
1610 genesis_link_up(skge);
1611 }
1612 spin_unlock_bh(&hw->phy_lock);
1613} 1573}
1614 1574
1615/* Marvell Phy Initailization */ 1575/* Marvell Phy Initailization */
@@ -1617,38 +1577,33 @@ static void yukon_init(struct skge_hw *hw, int port)
1617{ 1577{
1618 struct skge_port *skge = netdev_priv(hw->dev[port]); 1578 struct skge_port *skge = netdev_priv(hw->dev[port]);
1619 u16 ctrl, ct1000, adv; 1579 u16 ctrl, ct1000, adv;
1620 u16 ledctrl, ledover;
1621 1580
1622 pr_debug("yukon_init\n"); 1581 pr_debug("yukon_init\n");
1623 if (skge->autoneg == AUTONEG_ENABLE) { 1582 if (skge->autoneg == AUTONEG_ENABLE) {
1624 u16 ectrl = skge_gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); 1583 u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL);
1625 1584
1626 ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | 1585 ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK |
1627 PHY_M_EC_MAC_S_MSK); 1586 PHY_M_EC_MAC_S_MSK);
1628 ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ); 1587 ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ);
1629 1588
1630 /* on PHY 88E1111 there is a change for downshift control */ 1589 ectrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
1631 if (hw->chip_id == CHIP_ID_YUKON_EC)
1632 ectrl |= PHY_M_EC_M_DSC_2(0) | PHY_M_EC_DOWN_S_ENA;
1633 else
1634 ectrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
1635 1590
1636 skge_gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, ectrl); 1591 gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, ectrl);
1637 } 1592 }
1638 1593
1639 ctrl = skge_gm_phy_read(hw, port, PHY_MARV_CTRL); 1594 ctrl = gm_phy_read(hw, port, PHY_MARV_CTRL);
1640 if (skge->autoneg == AUTONEG_DISABLE) 1595 if (skge->autoneg == AUTONEG_DISABLE)
1641 ctrl &= ~PHY_CT_ANE; 1596 ctrl &= ~PHY_CT_ANE;
1642 1597
1643 ctrl |= PHY_CT_RESET; 1598 ctrl |= PHY_CT_RESET;
1644 skge_gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl); 1599 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
1645 1600
1646 ctrl = 0; 1601 ctrl = 0;
1647 ct1000 = 0; 1602 ct1000 = 0;
1648 adv = PHY_SEL_TYPE; 1603 adv = PHY_AN_CSMA;
1649 1604
1650 if (skge->autoneg == AUTONEG_ENABLE) { 1605 if (skge->autoneg == AUTONEG_ENABLE) {
1651 if (iscopper(hw)) { 1606 if (hw->copper) {
1652 if (skge->advertising & ADVERTISED_1000baseT_Full) 1607 if (skge->advertising & ADVERTISED_1000baseT_Full)
1653 ct1000 |= PHY_M_1000C_AFD; 1608 ct1000 |= PHY_M_1000C_AFD;
1654 if (skge->advertising & ADVERTISED_1000baseT_Half) 1609 if (skge->advertising & ADVERTISED_1000baseT_Half)
@@ -1661,41 +1616,12 @@ static void yukon_init(struct skge_hw *hw, int port)
1661 adv |= PHY_M_AN_10_FD; 1616 adv |= PHY_M_AN_10_FD;
1662 if (skge->advertising & ADVERTISED_10baseT_Half) 1617 if (skge->advertising & ADVERTISED_10baseT_Half)
1663 adv |= PHY_M_AN_10_HD; 1618 adv |= PHY_M_AN_10_HD;
1664 1619 } else /* special defines for FIBER (88E1011S only) */
1665 /* Set Flow-control capabilities */
1666 switch (skge->flow_control) {
1667 case FLOW_MODE_NONE:
1668 adv |= PHY_B_P_NO_PAUSE;
1669 break;
1670 case FLOW_MODE_LOC_SEND:
1671 adv |= PHY_B_P_ASYM_MD;
1672 break;
1673 case FLOW_MODE_SYMMETRIC:
1674 adv |= PHY_B_P_SYM_MD;
1675 break;
1676 case FLOW_MODE_REM_SEND:
1677 adv |= PHY_B_P_BOTH_MD;
1678 break;
1679 }
1680 } else { /* special defines for FIBER (88E1011S only) */
1681 adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD; 1620 adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD;
1682 1621
1683 /* Set Flow-control capabilities */ 1622 /* Set Flow-control capabilities */
1684 switch (skge->flow_control) { 1623 adv |= phy_pause_map[skge->flow_control];
1685 case FLOW_MODE_NONE: 1624
1686 adv |= PHY_M_P_NO_PAUSE_X;
1687 break;
1688 case FLOW_MODE_LOC_SEND:
1689 adv |= PHY_M_P_ASYM_MD_X;
1690 break;
1691 case FLOW_MODE_SYMMETRIC:
1692 adv |= PHY_M_P_SYM_MD_X;
1693 break;
1694 case FLOW_MODE_REM_SEND:
1695 adv |= PHY_M_P_BOTH_MD_X;
1696 break;
1697 }
1698 }
1699 /* Restart Auto-negotiation */ 1625 /* Restart Auto-negotiation */
1700 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG; 1626 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
1701 } else { 1627 } else {
@@ -1717,62 +1643,28 @@ static void yukon_init(struct skge_hw *hw, int port)
1717 ctrl |= PHY_CT_RESET; 1643 ctrl |= PHY_CT_RESET;
1718 } 1644 }
1719 1645
1720 if (hw->chip_id != CHIP_ID_YUKON_FE) 1646 gm_phy_write(hw, port, PHY_MARV_1000T_CTRL, ct1000);
1721 skge_gm_phy_write(hw, port, PHY_MARV_1000T_CTRL, ct1000);
1722
1723 skge_gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, adv);
1724 skge_gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
1725
1726 /* Setup Phy LED's */
1727 ledctrl = PHY_M_LED_PULS_DUR(PULS_170MS);
1728 ledover = 0;
1729
1730 if (hw->chip_id == CHIP_ID_YUKON_FE) {
1731 /* on 88E3082 these bits are at 11..9 (shifted left) */
1732 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) << 1;
1733
1734 skge_gm_phy_write(hw, port, PHY_MARV_FE_LED_PAR,
1735 ((skge_gm_phy_read(hw, port, PHY_MARV_FE_LED_PAR)
1736
1737 & ~PHY_M_FELP_LED1_MSK)
1738 | PHY_M_FELP_LED1_CTRL(LED_PAR_CTRL_ACT_BL)));
1739 } else {
1740 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
1741 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
1742
1743 /* turn off the Rx LED (LED_RX) */
1744 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
1745 }
1746
1747 /* disable blink mode (LED_DUPLEX) on collisions */
1748 ctrl |= PHY_M_LEDC_DP_CTRL;
1749 skge_gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
1750
1751 if (skge->autoneg == AUTONEG_DISABLE || skge->speed == SPEED_100) {
1752 /* turn on 100 Mbps LED (LED_LINK100) */
1753 ledover |= PHY_M_LED_MO_100(MO_LED_ON);
1754 }
1755 1647
1756 if (ledover) 1648 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, adv);
1757 skge_gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); 1649 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
1758 1650
1759 /* Enable phy interrupt on autonegotiation complete (or link up) */ 1651 /* Enable phy interrupt on autonegotiation complete (or link up) */
1760 if (skge->autoneg == AUTONEG_ENABLE) 1652 if (skge->autoneg == AUTONEG_ENABLE)
1761 skge_gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL); 1653 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_MSK);
1762 else 1654 else
1763 skge_gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); 1655 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_DEF_MSK);
1764} 1656}
1765 1657
1766static void yukon_reset(struct skge_hw *hw, int port) 1658static void yukon_reset(struct skge_hw *hw, int port)
1767{ 1659{
1768 skge_gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);/* disable PHY IRQs */ 1660 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);/* disable PHY IRQs */
1769 skge_gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */ 1661 gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */
1770 skge_gma_write16(hw, port, GM_MC_ADDR_H2, 0); 1662 gma_write16(hw, port, GM_MC_ADDR_H2, 0);
1771 skge_gma_write16(hw, port, GM_MC_ADDR_H3, 0); 1663 gma_write16(hw, port, GM_MC_ADDR_H3, 0);
1772 skge_gma_write16(hw, port, GM_MC_ADDR_H4, 0); 1664 gma_write16(hw, port, GM_MC_ADDR_H4, 0);
1773 1665
1774 skge_gma_write16(hw, port, GM_RX_CTRL, 1666 gma_write16(hw, port, GM_RX_CTRL,
1775 skge_gma_read16(hw, port, GM_RX_CTRL) 1667 gma_read16(hw, port, GM_RX_CTRL)
1776 | GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); 1668 | GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
1777} 1669}
1778 1670
@@ -1785,17 +1677,17 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1785 1677
1786 /* WA code for COMA mode -- set PHY reset */ 1678 /* WA code for COMA mode -- set PHY reset */
1787 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1679 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1788 chip_rev(hw) == CHIP_REV_YU_LITE_A3) 1680 hw->chip_rev >= CHIP_REV_YU_LITE_A3)
1789 skge_write32(hw, B2_GP_IO, 1681 skge_write32(hw, B2_GP_IO,
1790 (skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9)); 1682 (skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9));
1791 1683
1792 /* hard reset */ 1684 /* hard reset */
1793 skge_write32(hw, SKGEMAC_REG(port, GPHY_CTRL), GPC_RST_SET); 1685 skge_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
1794 skge_write32(hw, SKGEMAC_REG(port, GMAC_CTRL), GMC_RST_SET); 1686 skge_write32(hw, SK_REG(port, GMAC_CTRL), GMC_RST_SET);
1795 1687
1796 /* WA code for COMA mode -- clear PHY reset */ 1688 /* WA code for COMA mode -- clear PHY reset */
1797 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1689 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1798 chip_rev(hw) == CHIP_REV_YU_LITE_A3) 1690 hw->chip_rev >= CHIP_REV_YU_LITE_A3)
1799 skge_write32(hw, B2_GP_IO, 1691 skge_write32(hw, B2_GP_IO,
1800 (skge_read32(hw, B2_GP_IO) | GP_DIR_9) 1692 (skge_read32(hw, B2_GP_IO) | GP_DIR_9)
1801 & ~GP_IO_9); 1693 & ~GP_IO_9);
@@ -1803,16 +1695,16 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1803 /* Set hardware config mode */ 1695 /* Set hardware config mode */
1804 reg = GPC_INT_POL_HI | GPC_DIS_FC | GPC_DIS_SLEEP | 1696 reg = GPC_INT_POL_HI | GPC_DIS_FC | GPC_DIS_SLEEP |
1805 GPC_ENA_XC | GPC_ANEG_ADV_ALL_M | GPC_ENA_PAUSE; 1697 GPC_ENA_XC | GPC_ANEG_ADV_ALL_M | GPC_ENA_PAUSE;
1806 reg |= iscopper(hw) ? GPC_HWCFG_GMII_COP : GPC_HWCFG_GMII_FIB; 1698 reg |= hw->copper ? GPC_HWCFG_GMII_COP : GPC_HWCFG_GMII_FIB;
1807 1699
1808 /* Clear GMC reset */ 1700 /* Clear GMC reset */
1809 skge_write32(hw, SKGEMAC_REG(port, GPHY_CTRL), reg | GPC_RST_SET); 1701 skge_write32(hw, SK_REG(port, GPHY_CTRL), reg | GPC_RST_SET);
1810 skge_write32(hw, SKGEMAC_REG(port, GPHY_CTRL), reg | GPC_RST_CLR); 1702 skge_write32(hw, SK_REG(port, GPHY_CTRL), reg | GPC_RST_CLR);
1811 skge_write32(hw, SKGEMAC_REG(port, GMAC_CTRL), GMC_PAUSE_ON | GMC_RST_CLR); 1703 skge_write32(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON | GMC_RST_CLR);
1812 if (skge->autoneg == AUTONEG_DISABLE) { 1704 if (skge->autoneg == AUTONEG_DISABLE) {
1813 reg = GM_GPCR_AU_ALL_DIS; 1705 reg = GM_GPCR_AU_ALL_DIS;
1814 skge_gma_write16(hw, port, GM_GP_CTRL, 1706 gma_write16(hw, port, GM_GP_CTRL,
1815 skge_gma_read16(hw, port, GM_GP_CTRL) | reg); 1707 gma_read16(hw, port, GM_GP_CTRL) | reg);
1816 1708
1817 switch (skge->speed) { 1709 switch (skge->speed) {
1818 case SPEED_1000: 1710 case SPEED_1000:
@@ -1828,7 +1720,7 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1828 reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL; 1720 reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL;
1829 switch (skge->flow_control) { 1721 switch (skge->flow_control) {
1830 case FLOW_MODE_NONE: 1722 case FLOW_MODE_NONE:
1831 skge_write32(hw, SKGEMAC_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 1723 skge_write32(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
1832 reg |= GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; 1724 reg |= GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
1833 break; 1725 break;
1834 case FLOW_MODE_LOC_SEND: 1726 case FLOW_MODE_LOC_SEND:
@@ -1836,33 +1728,31 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1836 reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; 1728 reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
1837 } 1729 }
1838 1730
1839 skge_gma_write16(hw, port, GM_GP_CTRL, reg); 1731 gma_write16(hw, port, GM_GP_CTRL, reg);
1840 skge_read16(hw, GMAC_IRQ_SRC); 1732 skge_read16(hw, GMAC_IRQ_SRC);
1841 1733
1842 spin_lock_bh(&hw->phy_lock);
1843 yukon_init(hw, port); 1734 yukon_init(hw, port);
1844 spin_unlock_bh(&hw->phy_lock);
1845 1735
1846 /* MIB clear */ 1736 /* MIB clear */
1847 reg = skge_gma_read16(hw, port, GM_PHY_ADDR); 1737 reg = gma_read16(hw, port, GM_PHY_ADDR);
1848 skge_gma_write16(hw, port, GM_PHY_ADDR, reg | GM_PAR_MIB_CLR); 1738 gma_write16(hw, port, GM_PHY_ADDR, reg | GM_PAR_MIB_CLR);
1849 1739
1850 for (i = 0; i < GM_MIB_CNT_SIZE; i++) 1740 for (i = 0; i < GM_MIB_CNT_SIZE; i++)
1851 skge_gma_read16(hw, port, GM_MIB_CNT_BASE + 8*i); 1741 gma_read16(hw, port, GM_MIB_CNT_BASE + 8*i);
1852 skge_gma_write16(hw, port, GM_PHY_ADDR, reg); 1742 gma_write16(hw, port, GM_PHY_ADDR, reg);
1853 1743
1854 /* transmit control */ 1744 /* transmit control */
1855 skge_gma_write16(hw, port, GM_TX_CTRL, TX_COL_THR(TX_COL_DEF)); 1745 gma_write16(hw, port, GM_TX_CTRL, TX_COL_THR(TX_COL_DEF));
1856 1746
1857 /* receive control reg: unicast + multicast + no FCS */ 1747 /* receive control reg: unicast + multicast + no FCS */
1858 skge_gma_write16(hw, port, GM_RX_CTRL, 1748 gma_write16(hw, port, GM_RX_CTRL,
1859 GM_RXCR_UCF_ENA | GM_RXCR_CRC_DIS | GM_RXCR_MCF_ENA); 1749 GM_RXCR_UCF_ENA | GM_RXCR_CRC_DIS | GM_RXCR_MCF_ENA);
1860 1750
1861 /* transmit flow control */ 1751 /* transmit flow control */
1862 skge_gma_write16(hw, port, GM_TX_FLOW_CTRL, 0xffff); 1752 gma_write16(hw, port, GM_TX_FLOW_CTRL, 0xffff);
1863 1753
1864 /* transmit parameter */ 1754 /* transmit parameter */
1865 skge_gma_write16(hw, port, GM_TX_PARAM, 1755 gma_write16(hw, port, GM_TX_PARAM,
1866 TX_JAM_LEN_VAL(TX_JAM_LEN_DEF) | 1756 TX_JAM_LEN_VAL(TX_JAM_LEN_DEF) |
1867 TX_JAM_IPG_VAL(TX_JAM_IPG_DEF) | 1757 TX_JAM_IPG_VAL(TX_JAM_IPG_DEF) |
1868 TX_IPG_JAM_DATA(TX_IPG_JAM_DEF)); 1758 TX_IPG_JAM_DATA(TX_IPG_JAM_DEF));
@@ -1872,33 +1762,38 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1872 if (hw->dev[port]->mtu > 1500) 1762 if (hw->dev[port]->mtu > 1500)
1873 reg |= GM_SMOD_JUMBO_ENA; 1763 reg |= GM_SMOD_JUMBO_ENA;
1874 1764
1875 skge_gma_write16(hw, port, GM_SERIAL_MODE, reg); 1765 gma_write16(hw, port, GM_SERIAL_MODE, reg);
1876 1766
1877 /* physical address: used for pause frames */ 1767 /* physical address: used for pause frames */
1878 skge_gm_set_addr(hw, port, GM_SRC_ADDR_1L, addr); 1768 gma_set_addr(hw, port, GM_SRC_ADDR_1L, addr);
1879 /* virtual address for data */ 1769 /* virtual address for data */
1880 skge_gm_set_addr(hw, port, GM_SRC_ADDR_2L, addr); 1770 gma_set_addr(hw, port, GM_SRC_ADDR_2L, addr);
1881 1771
1882 /* enable interrupt mask for counter overflows */ 1772 /* enable interrupt mask for counter overflows */
1883 skge_gma_write16(hw, port, GM_TX_IRQ_MSK, 0); 1773 gma_write16(hw, port, GM_TX_IRQ_MSK, 0);
1884 skge_gma_write16(hw, port, GM_RX_IRQ_MSK, 0); 1774 gma_write16(hw, port, GM_RX_IRQ_MSK, 0);
1885 skge_gma_write16(hw, port, GM_TR_IRQ_MSK, 0); 1775 gma_write16(hw, port, GM_TR_IRQ_MSK, 0);
1886 1776
1887 /* Initialize Mac Fifo */ 1777 /* Initialize Mac Fifo */
1888 1778
1889 /* Configure Rx MAC FIFO */ 1779 /* Configure Rx MAC FIFO */
1890 skge_write16(hw, SKGEMAC_REG(port, RX_GMF_FL_MSK), RX_FF_FL_DEF_MSK); 1780 skge_write16(hw, SK_REG(port, RX_GMF_FL_MSK), RX_FF_FL_DEF_MSK);
1891 reg = GMF_OPER_ON | GMF_RX_F_FL_ON; 1781 reg = GMF_OPER_ON | GMF_RX_F_FL_ON;
1892 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1782 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1893 chip_rev(hw) == CHIP_REV_YU_LITE_A3) 1783 hw->chip_rev >= CHIP_REV_YU_LITE_A3)
1894 reg &= ~GMF_RX_F_FL_ON; 1784 reg &= ~GMF_RX_F_FL_ON;
1895 skge_write8(hw, SKGEMAC_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR); 1785 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR);
1896 skge_write16(hw, SKGEMAC_REG(port, RX_GMF_CTRL_T), reg); 1786 skge_write16(hw, SK_REG(port, RX_GMF_CTRL_T), reg);
1897 skge_write16(hw, SKGEMAC_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF); 1787 /*
1788 * because Pause Packet Truncation in GMAC is not working
1789 * we have to increase the Flush Threshold to 64 bytes
1790 * in order to flush pause packets in Rx FIFO on Yukon-1
1791 */
1792 skge_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF+1);
1898 1793
1899 /* Configure Tx MAC FIFO */ 1794 /* Configure Tx MAC FIFO */
1900 skge_write8(hw, SKGEMAC_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR); 1795 skge_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR);
1901 skge_write16(hw, SKGEMAC_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); 1796 skge_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
1902} 1797}
1903 1798
1904static void yukon_stop(struct skge_port *skge) 1799static void yukon_stop(struct skge_port *skge)
@@ -1907,19 +1802,19 @@ static void yukon_stop(struct skge_port *skge)
1907 int port = skge->port; 1802 int port = skge->port;
1908 1803
1909 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1804 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1910 chip_rev(hw) == CHIP_REV_YU_LITE_A3) { 1805 hw->chip_rev >= CHIP_REV_YU_LITE_A3) {
1911 skge_write32(hw, B2_GP_IO, 1806 skge_write32(hw, B2_GP_IO,
1912 skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9); 1807 skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9);
1913 } 1808 }
1914 1809
1915 skge_gma_write16(hw, port, GM_GP_CTRL, 1810 gma_write16(hw, port, GM_GP_CTRL,
1916 skge_gma_read16(hw, port, GM_GP_CTRL) 1811 gma_read16(hw, port, GM_GP_CTRL)
1917 & ~(GM_GPCR_RX_ENA|GM_GPCR_RX_ENA)); 1812 & ~(GM_GPCR_TX_ENA|GM_GPCR_RX_ENA));
1918 skge_gma_read16(hw, port, GM_GP_CTRL); 1813 gma_read16(hw, port, GM_GP_CTRL);
1919 1814
1920 /* set GPHY Control reset */ 1815 /* set GPHY Control reset */
1921 skge_gma_write32(hw, port, GPHY_CTRL, GPC_RST_SET); 1816 skge_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
1922 skge_gma_write32(hw, port, GMAC_CTRL, GMC_RST_SET); 1817 skge_write32(hw, SK_REG(port, GMAC_CTRL), GMC_RST_SET);
1923} 1818}
1924 1819
1925static void yukon_get_stats(struct skge_port *skge, u64 *data) 1820static void yukon_get_stats(struct skge_port *skge, u64 *data)
@@ -1928,39 +1823,41 @@ static void yukon_get_stats(struct skge_port *skge, u64 *data)
1928 int port = skge->port; 1823 int port = skge->port;
1929 int i; 1824 int i;
1930 1825
1931 data[0] = (u64) skge_gma_read32(hw, port, GM_TXO_OK_HI) << 32 1826 data[0] = (u64) gma_read32(hw, port, GM_TXO_OK_HI) << 32
1932 | skge_gma_read32(hw, port, GM_TXO_OK_LO); 1827 | gma_read32(hw, port, GM_TXO_OK_LO);
1933 data[1] = (u64) skge_gma_read32(hw, port, GM_RXO_OK_HI) << 32 1828 data[1] = (u64) gma_read32(hw, port, GM_RXO_OK_HI) << 32
1934 | skge_gma_read32(hw, port, GM_RXO_OK_LO); 1829 | gma_read32(hw, port, GM_RXO_OK_LO);
1935 1830
1936 for (i = 2; i < ARRAY_SIZE(skge_stats); i++) 1831 for (i = 2; i < ARRAY_SIZE(skge_stats); i++)
1937 data[i] = skge_gma_read32(hw, port, 1832 data[i] = gma_read32(hw, port,
1938 skge_stats[i].gma_offset); 1833 skge_stats[i].gma_offset);
1939} 1834}
1940 1835
1941static void yukon_mac_intr(struct skge_hw *hw, int port) 1836static void yukon_mac_intr(struct skge_hw *hw, int port)
1942{ 1837{
1943 struct skge_port *skge = netdev_priv(hw->dev[port]); 1838 struct net_device *dev = hw->dev[port];
1944 u8 status = skge_read8(hw, SKGEMAC_REG(port, GMAC_IRQ_SRC)); 1839 struct skge_port *skge = netdev_priv(dev);
1840 u8 status = skge_read8(hw, SK_REG(port, GMAC_IRQ_SRC));
1841
1842 if (netif_msg_intr(skge))
1843 printk(KERN_DEBUG PFX "%s: mac interrupt status 0x%x\n",
1844 dev->name, status);
1945 1845
1946 pr_debug("yukon_intr status %x\n", status);
1947 if (status & GM_IS_RX_FF_OR) { 1846 if (status & GM_IS_RX_FF_OR) {
1948 ++skge->net_stats.rx_fifo_errors; 1847 ++skge->net_stats.rx_fifo_errors;
1949 skge_gma_write8(hw, port, RX_GMF_CTRL_T, GMF_CLI_RX_FO); 1848 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO);
1950 } 1849 }
1850
1951 if (status & GM_IS_TX_FF_UR) { 1851 if (status & GM_IS_TX_FF_UR) {
1952 ++skge->net_stats.tx_fifo_errors; 1852 ++skge->net_stats.tx_fifo_errors;
1953 skge_gma_write8(hw, port, TX_GMF_CTRL_T, GMF_CLI_TX_FU); 1853 skge_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU);
1954 } 1854 }
1955 1855
1956} 1856}
1957 1857
1958static u16 yukon_speed(const struct skge_hw *hw, u16 aux) 1858static u16 yukon_speed(const struct skge_hw *hw, u16 aux)
1959{ 1859{
1960 if (hw->chip_id == CHIP_ID_YUKON_FE) 1860 switch (aux & PHY_M_PS_SPEED_MSK) {
1961 return (aux & PHY_M_PS_SPEED_100) ? SPEED_100 : SPEED_10;
1962
1963 switch(aux & PHY_M_PS_SPEED_MSK) {
1964 case PHY_M_PS_SPEED_1000: 1861 case PHY_M_PS_SPEED_1000:
1965 return SPEED_1000; 1862 return SPEED_1000;
1966 case PHY_M_PS_SPEED_100: 1863 case PHY_M_PS_SPEED_100:
@@ -1981,15 +1878,15 @@ static void yukon_link_up(struct skge_port *skge)
1981 /* Enable Transmit FIFO Underrun */ 1878 /* Enable Transmit FIFO Underrun */
1982 skge_write8(hw, GMAC_IRQ_MSK, GMAC_DEF_MSK); 1879 skge_write8(hw, GMAC_IRQ_MSK, GMAC_DEF_MSK);
1983 1880
1984 reg = skge_gma_read16(hw, port, GM_GP_CTRL); 1881 reg = gma_read16(hw, port, GM_GP_CTRL);
1985 if (skge->duplex == DUPLEX_FULL || skge->autoneg == AUTONEG_ENABLE) 1882 if (skge->duplex == DUPLEX_FULL || skge->autoneg == AUTONEG_ENABLE)
1986 reg |= GM_GPCR_DUP_FULL; 1883 reg |= GM_GPCR_DUP_FULL;
1987 1884
1988 /* enable Rx/Tx */ 1885 /* enable Rx/Tx */
1989 reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA; 1886 reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA;
1990 skge_gma_write16(hw, port, GM_GP_CTRL, reg); 1887 gma_write16(hw, port, GM_GP_CTRL, reg);
1991 1888
1992 skge_gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); 1889 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_DEF_MSK);
1993 skge_link_up(skge); 1890 skge_link_up(skge);
1994} 1891}
1995 1892
@@ -1997,18 +1894,19 @@ static void yukon_link_down(struct skge_port *skge)
1997{ 1894{
1998 struct skge_hw *hw = skge->hw; 1895 struct skge_hw *hw = skge->hw;
1999 int port = skge->port; 1896 int port = skge->port;
1897 u16 ctrl;
2000 1898
2001 pr_debug("yukon_link_down\n"); 1899 pr_debug("yukon_link_down\n");
2002 skge_gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0); 1900 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
2003 skge_gm_phy_write(hw, port, GM_GP_CTRL, 1901
2004 skge_gm_phy_read(hw, port, GM_GP_CTRL) 1902 ctrl = gma_read16(hw, port, GM_GP_CTRL);
2005 & ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA)); 1903 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
1904 gma_write16(hw, port, GM_GP_CTRL, ctrl);
2006 1905
2007 if (hw->chip_id != CHIP_ID_YUKON_FE && 1906 if (skge->flow_control == FLOW_MODE_REM_SEND) {
2008 skge->flow_control == FLOW_MODE_REM_SEND) {
2009 /* restore Asymmetric Pause bit */ 1907 /* restore Asymmetric Pause bit */
2010 skge_gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, 1908 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV,
2011 skge_gm_phy_read(hw, port, 1909 gm_phy_read(hw, port,
2012 PHY_MARV_AUNE_ADV) 1910 PHY_MARV_AUNE_ADV)
2013 | PHY_M_AN_ASP); 1911 | PHY_M_AN_ASP);
2014 1912
@@ -2027,20 +1925,21 @@ static void yukon_phy_intr(struct skge_port *skge)
2027 const char *reason = NULL; 1925 const char *reason = NULL;
2028 u16 istatus, phystat; 1926 u16 istatus, phystat;
2029 1927
2030 istatus = skge_gm_phy_read(hw, port, PHY_MARV_INT_STAT); 1928 istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
2031 phystat = skge_gm_phy_read(hw, port, PHY_MARV_PHY_STAT); 1929 phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
2032 pr_debug("yukon phy intr istat=%x phy_stat=%x\n", istatus, phystat); 1930
1931 if (netif_msg_intr(skge))
1932 printk(KERN_DEBUG PFX "%s: phy interrupt status 0x%x 0x%x\n",
1933 skge->netdev->name, istatus, phystat);
2033 1934
2034 if (istatus & PHY_M_IS_AN_COMPL) { 1935 if (istatus & PHY_M_IS_AN_COMPL) {
2035 if (skge_gm_phy_read(hw, port, PHY_MARV_AUNE_LP) 1936 if (gm_phy_read(hw, port, PHY_MARV_AUNE_LP)
2036 & PHY_M_AN_RF) { 1937 & PHY_M_AN_RF) {
2037 reason = "remote fault"; 1938 reason = "remote fault";
2038 goto failed; 1939 goto failed;
2039 } 1940 }
2040 1941
2041 if (!(hw->chip_id == CHIP_ID_YUKON_FE || hw->chip_id == CHIP_ID_YUKON_EC) 1942 if (gm_phy_read(hw, port, PHY_MARV_1000T_STAT) & PHY_B_1000S_MSF) {
2042 && (skge_gm_phy_read(hw, port, PHY_MARV_1000T_STAT)
2043 & PHY_B_1000S_MSF)) {
2044 reason = "master/slave fault"; 1943 reason = "master/slave fault";
2045 goto failed; 1944 goto failed;
2046 } 1945 }
@@ -2054,10 +1953,6 @@ static void yukon_phy_intr(struct skge_port *skge)
2054 ? DUPLEX_FULL : DUPLEX_HALF; 1953 ? DUPLEX_FULL : DUPLEX_HALF;
2055 skge->speed = yukon_speed(hw, phystat); 1954 skge->speed = yukon_speed(hw, phystat);
2056 1955
2057 /* Tx & Rx Pause Enabled bits are at 9..8 */
2058 if (hw->chip_id == CHIP_ID_YUKON_XL)
2059 phystat >>= 6;
2060
2061 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 1956 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
2062 switch (phystat & PHY_M_PS_PAUSE_MSK) { 1957 switch (phystat & PHY_M_PS_PAUSE_MSK) {
2063 case PHY_M_PS_PAUSE_MSK: 1958 case PHY_M_PS_PAUSE_MSK:
@@ -2075,9 +1970,9 @@ static void yukon_phy_intr(struct skge_port *skge)
2075 1970
2076 if (skge->flow_control == FLOW_MODE_NONE || 1971 if (skge->flow_control == FLOW_MODE_NONE ||
2077 (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF)) 1972 (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF))
2078 skge_write8(hw, SKGEMAC_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 1973 skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
2079 else 1974 else
2080 skge_write8(hw, SKGEMAC_REG(port, GMAC_CTRL), GMC_PAUSE_ON); 1975 skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON);
2081 yukon_link_up(skge); 1976 yukon_link_up(skge);
2082 return; 1977 return;
2083 } 1978 }
@@ -2161,6 +2056,12 @@ static int skge_up(struct net_device *dev)
2161 if (netif_msg_ifup(skge)) 2056 if (netif_msg_ifup(skge))
2162 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); 2057 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
2163 2058
2059 if (dev->mtu > RX_BUF_SIZE)
2060 skge->rx_buf_size = dev->mtu + ETH_HLEN + NET_IP_ALIGN;
2061 else
2062 skge->rx_buf_size = RX_BUF_SIZE;
2063
2064
2164 rx_size = skge->rx_ring.count * sizeof(struct skge_rx_desc); 2065 rx_size = skge->rx_ring.count * sizeof(struct skge_rx_desc);
2165 tx_size = skge->tx_ring.count * sizeof(struct skge_tx_desc); 2066 tx_size = skge->tx_ring.count * sizeof(struct skge_tx_desc);
2166 skge->mem_size = tx_size + rx_size; 2067 skge->mem_size = tx_size + rx_size;
@@ -2173,7 +2074,8 @@ static int skge_up(struct net_device *dev)
2173 if ((err = skge_ring_alloc(&skge->rx_ring, skge->mem, skge->dma))) 2074 if ((err = skge_ring_alloc(&skge->rx_ring, skge->mem, skge->dma)))
2174 goto free_pci_mem; 2075 goto free_pci_mem;
2175 2076
2176 if (skge_rx_fill(skge)) 2077 err = skge_rx_fill(skge);
2078 if (err)
2177 goto free_rx_ring; 2079 goto free_rx_ring;
2178 2080
2179 if ((err = skge_ring_alloc(&skge->tx_ring, skge->mem + rx_size, 2081 if ((err = skge_ring_alloc(&skge->tx_ring, skge->mem + rx_size,
@@ -2182,14 +2084,20 @@ static int skge_up(struct net_device *dev)
2182 2084
2183 skge->tx_avail = skge->tx_ring.count - 1; 2085 skge->tx_avail = skge->tx_ring.count - 1;
2184 2086
2087 /* Enable IRQ from port */
2088 hw->intr_mask |= portirqmask[port];
2089 skge_write32(hw, B0_IMSK, hw->intr_mask);
2090
2185 /* Initialze MAC */ 2091 /* Initialze MAC */
2092 spin_lock_bh(&hw->phy_lock);
2186 if (hw->chip_id == CHIP_ID_GENESIS) 2093 if (hw->chip_id == CHIP_ID_GENESIS)
2187 genesis_mac_init(hw, port); 2094 genesis_mac_init(hw, port);
2188 else 2095 else
2189 yukon_mac_init(hw, port); 2096 yukon_mac_init(hw, port);
2097 spin_unlock_bh(&hw->phy_lock);
2190 2098
2191 /* Configure RAMbuffers */ 2099 /* Configure RAMbuffers */
2192 chunk = hw->ram_size / (isdualport(hw) ? 4 : 2); 2100 chunk = hw->ram_size / ((hw->ports + 1)*2);
2193 ram_addr = hw->ram_offset + 2 * chunk * port; 2101 ram_addr = hw->ram_offset + 2 * chunk * port;
2194 2102
2195 skge_ramset(hw, rxqaddr[port], ram_addr, chunk); 2103 skge_ramset(hw, rxqaddr[port], ram_addr, chunk);
@@ -2202,6 +2110,7 @@ static int skge_up(struct net_device *dev)
2202 /* Start receiver BMU */ 2110 /* Start receiver BMU */
2203 wmb(); 2111 wmb();
2204 skge_write8(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_START | CSR_IRQ_CL_F); 2112 skge_write8(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_START | CSR_IRQ_CL_F);
2113 skge_led(skge, LED_MODE_ON);
2205 2114
2206 pr_debug("skge_up completed\n"); 2115 pr_debug("skge_up completed\n");
2207 return 0; 2116 return 0;
@@ -2226,9 +2135,6 @@ static int skge_down(struct net_device *dev)
2226 2135
2227 netif_stop_queue(dev); 2136 netif_stop_queue(dev);
2228 2137
2229 del_timer_sync(&skge->led_blink);
2230 del_timer_sync(&skge->link_check);
2231
2232 /* Stop transmitter */ 2138 /* Stop transmitter */
2233 skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP); 2139 skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP);
2234 skge_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), 2140 skge_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL),
@@ -2240,12 +2146,12 @@ static int skge_down(struct net_device *dev)
2240 yukon_stop(skge); 2146 yukon_stop(skge);
2241 2147
2242 /* Disable Force Sync bit and Enable Alloc bit */ 2148 /* Disable Force Sync bit and Enable Alloc bit */
2243 skge_write8(hw, SKGEMAC_REG(port, TXA_CTRL), 2149 skge_write8(hw, SK_REG(port, TXA_CTRL),
2244 TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC); 2150 TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
2245 2151
2246 /* Stop Interval Timer and Limit Counter of Tx Arbiter */ 2152 /* Stop Interval Timer and Limit Counter of Tx Arbiter */
2247 skge_write32(hw, SKGEMAC_REG(port, TXA_ITI_INI), 0L); 2153 skge_write32(hw, SK_REG(port, TXA_ITI_INI), 0L);
2248 skge_write32(hw, SKGEMAC_REG(port, TXA_LIM_INI), 0L); 2154 skge_write32(hw, SK_REG(port, TXA_LIM_INI), 0L);
2249 2155
2250 /* Reset PCI FIFO */ 2156 /* Reset PCI FIFO */
2251 skge_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_SET_RESET); 2157 skge_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_SET_RESET);
@@ -2260,17 +2166,14 @@ static int skge_down(struct net_device *dev)
2260 skge_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_SET_RESET); 2166 skge_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_SET_RESET);
2261 2167
2262 if (hw->chip_id == CHIP_ID_GENESIS) { 2168 if (hw->chip_id == CHIP_ID_GENESIS) {
2263 skge_write8(hw, SKGEMAC_REG(port, TX_MFF_CTRL2), MFF_RST_SET); 2169 skge_write8(hw, SK_REG(port, TX_MFF_CTRL2), MFF_RST_SET);
2264 skge_write8(hw, SKGEMAC_REG(port, RX_MFF_CTRL2), MFF_RST_SET); 2170 skge_write8(hw, SK_REG(port, RX_MFF_CTRL2), MFF_RST_SET);
2265 skge_write8(hw, SKGEMAC_REG(port, TX_LED_CTRL), LED_STOP);
2266 skge_write8(hw, SKGEMAC_REG(port, RX_LED_CTRL), LED_STOP);
2267 } else { 2171 } else {
2268 skge_write8(hw, SKGEMAC_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); 2172 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
2269 skge_write8(hw, SKGEMAC_REG(port, TX_GMF_CTRL_T), GMF_RST_SET); 2173 skge_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
2270 } 2174 }
2271 2175
2272 /* turn off led's */ 2176 skge_led(skge, LED_MODE_OFF);
2273 skge_write16(hw, B0_LED, LED_STAT_OFF);
2274 2177
2275 skge_tx_clean(skge); 2178 skge_tx_clean(skge);
2276 skge_rx_clean(skge); 2179 skge_rx_clean(skge);
@@ -2299,10 +2202,10 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2299 2202
2300 local_irq_save(flags); 2203 local_irq_save(flags);
2301 if (!spin_trylock(&skge->tx_lock)) { 2204 if (!spin_trylock(&skge->tx_lock)) {
2302 /* Collision - tell upper layer to requeue */ 2205 /* Collision - tell upper layer to requeue */
2303 local_irq_restore(flags); 2206 local_irq_restore(flags);
2304 return NETDEV_TX_LOCKED; 2207 return NETDEV_TX_LOCKED;
2305 } 2208 }
2306 2209
2307 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) { 2210 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) {
2308 netif_stop_queue(dev); 2211 netif_stop_queue(dev);
@@ -2333,7 +2236,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2333 * does. Looks like hardware is wrong? 2236 * does. Looks like hardware is wrong?
2334 */ 2237 */
2335 if (ip->protocol == IPPROTO_UDP 2238 if (ip->protocol == IPPROTO_UDP
2336 && chip_rev(hw) == 0 && hw->chip_id == CHIP_ID_YUKON) 2239 && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON)
2337 control = BMU_TCP_CHECK; 2240 control = BMU_TCP_CHECK;
2338 else 2241 else
2339 control = BMU_UDP_CHECK; 2242 control = BMU_UDP_CHECK;
@@ -2394,6 +2297,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2394 2297
2395static inline void skge_tx_free(struct skge_hw *hw, struct skge_element *e) 2298static inline void skge_tx_free(struct skge_hw *hw, struct skge_element *e)
2396{ 2299{
2300 /* This ring element can be skb or fragment */
2397 if (e->skb) { 2301 if (e->skb) {
2398 pci_unmap_single(hw->pdev, 2302 pci_unmap_single(hw->pdev,
2399 pci_unmap_addr(e, mapaddr), 2303 pci_unmap_addr(e, mapaddr),
@@ -2438,16 +2342,17 @@ static void skge_tx_timeout(struct net_device *dev)
2438static int skge_change_mtu(struct net_device *dev, int new_mtu) 2342static int skge_change_mtu(struct net_device *dev, int new_mtu)
2439{ 2343{
2440 int err = 0; 2344 int err = 0;
2345 int running = netif_running(dev);
2441 2346
2442 if(new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) 2347 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
2443 return -EINVAL; 2348 return -EINVAL;
2444 2349
2445 dev->mtu = new_mtu;
2446 2350
2447 if (netif_running(dev)) { 2351 if (running)
2448 skge_down(dev); 2352 skge_down(dev);
2353 dev->mtu = new_mtu;
2354 if (running)
2449 skge_up(dev); 2355 skge_up(dev);
2450 }
2451 2356
2452 return err; 2357 return err;
2453} 2358}
@@ -2462,7 +2367,9 @@ static void genesis_set_multicast(struct net_device *dev)
2462 u32 mode; 2367 u32 mode;
2463 u8 filter[8]; 2368 u8 filter[8];
2464 2369
2465 mode = skge_xm_read32(hw, port, XM_MODE); 2370 pr_debug("genesis_set_multicast flags=%x count=%d\n", dev->flags, dev->mc_count);
2371
2372 mode = xm_read32(hw, port, XM_MODE);
2466 mode |= XM_MD_ENA_HASH; 2373 mode |= XM_MD_ENA_HASH;
2467 if (dev->flags & IFF_PROMISC) 2374 if (dev->flags & IFF_PROMISC)
2468 mode |= XM_MD_ENA_PROM; 2375 mode |= XM_MD_ENA_PROM;
@@ -2473,17 +2380,16 @@ static void genesis_set_multicast(struct net_device *dev)
2473 memset(filter, 0xff, sizeof(filter)); 2380 memset(filter, 0xff, sizeof(filter));
2474 else { 2381 else {
2475 memset(filter, 0, sizeof(filter)); 2382 memset(filter, 0, sizeof(filter));
2476 for(i = 0; list && i < count; i++, list = list->next) { 2383 for (i = 0; list && i < count; i++, list = list->next) {
2477 u32 crc = crc32_le(~0, list->dmi_addr, ETH_ALEN); 2384 u32 crc, bit;
2478 u8 bit = 63 - (crc & 63); 2385 crc = ether_crc_le(ETH_ALEN, list->dmi_addr);
2479 2386 bit = ~crc & 0x3f;
2480 filter[bit/8] |= 1 << (bit%8); 2387 filter[bit/8] |= 1 << (bit%8);
2481 } 2388 }
2482 } 2389 }
2483 2390
2484 skge_xm_outhash(hw, port, XM_HSM, filter); 2391 xm_write32(hw, port, XM_MODE, mode);
2485 2392 xm_outhash(hw, port, XM_HSM, filter);
2486 skge_xm_write32(hw, port, XM_MODE, mode);
2487} 2393}
2488 2394
2489static void yukon_set_multicast(struct net_device *dev) 2395static void yukon_set_multicast(struct net_device *dev)
@@ -2497,7 +2403,7 @@ static void yukon_set_multicast(struct net_device *dev)
2497 2403
2498 memset(filter, 0, sizeof(filter)); 2404 memset(filter, 0, sizeof(filter));
2499 2405
2500 reg = skge_gma_read16(hw, port, GM_RX_CTRL); 2406 reg = gma_read16(hw, port, GM_RX_CTRL);
2501 reg |= GM_RXCR_UCF_ENA; 2407 reg |= GM_RXCR_UCF_ENA;
2502 2408
2503 if (dev->flags & IFF_PROMISC) /* promiscious */ 2409 if (dev->flags & IFF_PROMISC) /* promiscious */
@@ -2510,23 +2416,23 @@ static void yukon_set_multicast(struct net_device *dev)
2510 int i; 2416 int i;
2511 reg |= GM_RXCR_MCF_ENA; 2417 reg |= GM_RXCR_MCF_ENA;
2512 2418
2513 for(i = 0; list && i < dev->mc_count; i++, list = list->next) { 2419 for (i = 0; list && i < dev->mc_count; i++, list = list->next) {
2514 u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f; 2420 u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f;
2515 filter[bit/8] |= 1 << (bit%8); 2421 filter[bit/8] |= 1 << (bit%8);
2516 } 2422 }
2517 } 2423 }
2518 2424
2519 2425
2520 skge_gma_write16(hw, port, GM_MC_ADDR_H1, 2426 gma_write16(hw, port, GM_MC_ADDR_H1,
2521 (u16)filter[0] | ((u16)filter[1] << 8)); 2427 (u16)filter[0] | ((u16)filter[1] << 8));
2522 skge_gma_write16(hw, port, GM_MC_ADDR_H2, 2428 gma_write16(hw, port, GM_MC_ADDR_H2,
2523 (u16)filter[2] | ((u16)filter[3] << 8)); 2429 (u16)filter[2] | ((u16)filter[3] << 8));
2524 skge_gma_write16(hw, port, GM_MC_ADDR_H3, 2430 gma_write16(hw, port, GM_MC_ADDR_H3,
2525 (u16)filter[4] | ((u16)filter[5] << 8)); 2431 (u16)filter[4] | ((u16)filter[5] << 8));
2526 skge_gma_write16(hw, port, GM_MC_ADDR_H4, 2432 gma_write16(hw, port, GM_MC_ADDR_H4,
2527 (u16)filter[6] | ((u16)filter[7] << 8)); 2433 (u16)filter[6] | ((u16)filter[7] << 8));
2528 2434
2529 skge_gma_write16(hw, port, GM_RX_CTRL, reg); 2435 gma_write16(hw, port, GM_RX_CTRL, reg);
2530} 2436}
2531 2437
2532static inline int bad_phy_status(const struct skge_hw *hw, u32 status) 2438static inline int bad_phy_status(const struct skge_hw *hw, u32 status)
@@ -2545,28 +2451,76 @@ static void skge_rx_error(struct skge_port *skge, int slot,
2545 printk(KERN_DEBUG PFX "%s: rx err, slot %d control 0x%x status 0x%x\n", 2451 printk(KERN_DEBUG PFX "%s: rx err, slot %d control 0x%x status 0x%x\n",
2546 skge->netdev->name, slot, control, status); 2452 skge->netdev->name, slot, control, status);
2547 2453
2548 if ((control & (BMU_EOF|BMU_STF)) != (BMU_STF|BMU_EOF) 2454 if ((control & (BMU_EOF|BMU_STF)) != (BMU_STF|BMU_EOF))
2549 || (control & BMU_BBC) > skge->netdev->mtu + VLAN_ETH_HLEN)
2550 skge->net_stats.rx_length_errors++; 2455 skge->net_stats.rx_length_errors++;
2551 else { 2456 else if (skge->hw->chip_id == CHIP_ID_GENESIS) {
2552 if (skge->hw->chip_id == CHIP_ID_GENESIS) { 2457 if (status & (XMR_FS_RUNT|XMR_FS_LNG_ERR))
2553 if (status & (XMR_FS_RUNT|XMR_FS_LNG_ERR)) 2458 skge->net_stats.rx_length_errors++;
2554 skge->net_stats.rx_length_errors++; 2459 if (status & XMR_FS_FRA_ERR)
2555 if (status & XMR_FS_FRA_ERR) 2460 skge->net_stats.rx_frame_errors++;
2556 skge->net_stats.rx_frame_errors++; 2461 if (status & XMR_FS_FCS_ERR)
2557 if (status & XMR_FS_FCS_ERR) 2462 skge->net_stats.rx_crc_errors++;
2558 skge->net_stats.rx_crc_errors++; 2463 } else {
2559 } else { 2464 if (status & (GMR_FS_LONG_ERR|GMR_FS_UN_SIZE))
2560 if (status & (GMR_FS_LONG_ERR|GMR_FS_UN_SIZE)) 2465 skge->net_stats.rx_length_errors++;
2561 skge->net_stats.rx_length_errors++; 2466 if (status & GMR_FS_FRAGMENT)
2562 if (status & GMR_FS_FRAGMENT) 2467 skge->net_stats.rx_frame_errors++;
2563 skge->net_stats.rx_frame_errors++; 2468 if (status & GMR_FS_CRC_ERR)
2564 if (status & GMR_FS_CRC_ERR) 2469 skge->net_stats.rx_crc_errors++;
2565 skge->net_stats.rx_crc_errors++; 2470 }
2471}
2472
2473/* Get receive buffer from descriptor.
2474 * Handles copy of small buffers and reallocation failures
2475 */
2476static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
2477 struct skge_element *e,
2478 unsigned int len)
2479{
2480 struct sk_buff *nskb, *skb;
2481
2482 if (len < RX_COPY_THRESHOLD) {
2483 nskb = skge_rx_alloc(skge->netdev, len + NET_IP_ALIGN);
2484 if (unlikely(!nskb))
2485 return NULL;
2486
2487 pci_dma_sync_single_for_cpu(skge->hw->pdev,
2488 pci_unmap_addr(e, mapaddr),
2489 len, PCI_DMA_FROMDEVICE);
2490 memcpy(nskb->data, e->skb->data, len);
2491 pci_dma_sync_single_for_device(skge->hw->pdev,
2492 pci_unmap_addr(e, mapaddr),
2493 len, PCI_DMA_FROMDEVICE);
2494
2495 if (skge->rx_csum) {
2496 struct skge_rx_desc *rd = e->desc;
2497 nskb->csum = le16_to_cpu(rd->csum2);
2498 nskb->ip_summed = CHECKSUM_HW;
2499 }
2500 skge_rx_reuse(e, skge->rx_buf_size);
2501 return nskb;
2502 } else {
2503 nskb = skge_rx_alloc(skge->netdev, skge->rx_buf_size);
2504 if (unlikely(!nskb))
2505 return NULL;
2506
2507 pci_unmap_single(skge->hw->pdev,
2508 pci_unmap_addr(e, mapaddr),
2509 pci_unmap_len(e, maplen),
2510 PCI_DMA_FROMDEVICE);
2511 skb = e->skb;
2512 if (skge->rx_csum) {
2513 struct skge_rx_desc *rd = e->desc;
2514 skb->csum = le16_to_cpu(rd->csum2);
2515 skb->ip_summed = CHECKSUM_HW;
2566 } 2516 }
2517
2518 skge_rx_setup(skge, e, nskb, skge->rx_buf_size);
2519 return skb;
2567 } 2520 }
2568} 2521}
2569 2522
2523
2570static int skge_poll(struct net_device *dev, int *budget) 2524static int skge_poll(struct net_device *dev, int *budget)
2571{ 2525{
2572 struct skge_port *skge = netdev_priv(dev); 2526 struct skge_port *skge = netdev_priv(dev);
@@ -2575,13 +2529,12 @@ static int skge_poll(struct net_device *dev, int *budget)
2575 struct skge_element *e; 2529 struct skge_element *e;
2576 unsigned int to_do = min(dev->quota, *budget); 2530 unsigned int to_do = min(dev->quota, *budget);
2577 unsigned int work_done = 0; 2531 unsigned int work_done = 0;
2578 int done;
2579 static const u32 irqmask[] = { IS_PORT_1, IS_PORT_2 };
2580 2532
2581 for (e = ring->to_clean; e != ring->to_use && work_done < to_do; 2533 pr_debug("skge_poll\n");
2582 e = e->next) { 2534
2535 for (e = ring->to_clean; work_done < to_do; e = e->next) {
2583 struct skge_rx_desc *rd = e->desc; 2536 struct skge_rx_desc *rd = e->desc;
2584 struct sk_buff *skb = e->skb; 2537 struct sk_buff *skb;
2585 u32 control, len, status; 2538 u32 control, len, status;
2586 2539
2587 rmb(); 2540 rmb();
@@ -2590,19 +2543,12 @@ static int skge_poll(struct net_device *dev, int *budget)
2590 break; 2543 break;
2591 2544
2592 len = control & BMU_BBC; 2545 len = control & BMU_BBC;
2593 e->skb = NULL;
2594
2595 pci_unmap_single(hw->pdev,
2596 pci_unmap_addr(e, mapaddr),
2597 pci_unmap_len(e, maplen),
2598 PCI_DMA_FROMDEVICE);
2599
2600 status = rd->status; 2546 status = rd->status;
2601 if ((control & (BMU_EOF|BMU_STF)) != (BMU_STF|BMU_EOF) 2547
2602 || len > dev->mtu + VLAN_ETH_HLEN 2548 if (unlikely((control & (BMU_EOF|BMU_STF)) != (BMU_STF|BMU_EOF)
2603 || bad_phy_status(hw, status)) { 2549 || bad_phy_status(hw, status))) {
2604 skge_rx_error(skge, e - ring->start, control, status); 2550 skge_rx_error(skge, e - ring->start, control, status);
2605 dev_kfree_skb(skb); 2551 skge_rx_reuse(e, skge->rx_buf_size);
2606 continue; 2552 continue;
2607 } 2553 }
2608 2554
@@ -2610,43 +2556,37 @@ static int skge_poll(struct net_device *dev, int *budget)
2610 printk(KERN_DEBUG PFX "%s: rx slot %td status 0x%x len %d\n", 2556 printk(KERN_DEBUG PFX "%s: rx slot %td status 0x%x len %d\n",
2611 dev->name, e - ring->start, rd->status, len); 2557 dev->name, e - ring->start, rd->status, len);
2612 2558
2613 skb_put(skb, len); 2559 skb = skge_rx_get(skge, e, len);
2614 skb->protocol = eth_type_trans(skb, dev); 2560 if (likely(skb)) {
2561 skb_put(skb, len);
2562 skb->protocol = eth_type_trans(skb, dev);
2615 2563
2616 if (skge->rx_csum) { 2564 dev->last_rx = jiffies;
2617 skb->csum = le16_to_cpu(rd->csum2); 2565 netif_receive_skb(skb);
2618 skb->ip_summed = CHECKSUM_HW;
2619 }
2620
2621 dev->last_rx = jiffies;
2622 netif_receive_skb(skb);
2623 2566
2624 ++work_done; 2567 ++work_done;
2568 } else
2569 skge_rx_reuse(e, skge->rx_buf_size);
2625 } 2570 }
2626 ring->to_clean = e; 2571 ring->to_clean = e;
2627 2572
2628 *budget -= work_done;
2629 dev->quota -= work_done;
2630 done = work_done < to_do;
2631
2632 if (skge_rx_fill(skge))
2633 done = 0;
2634
2635 /* restart receiver */ 2573 /* restart receiver */
2636 wmb(); 2574 wmb();
2637 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), 2575 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR),
2638 CSR_START | CSR_IRQ_CL_F); 2576 CSR_START | CSR_IRQ_CL_F);
2639 2577
2640 if (done) { 2578 *budget -= work_done;
2641 local_irq_disable(); 2579 dev->quota -= work_done;
2642 hw->intr_mask |= irqmask[skge->port];
2643 /* Order is important since data can get interrupted */
2644 skge_write32(hw, B0_IMSK, hw->intr_mask);
2645 __netif_rx_complete(dev);
2646 local_irq_enable();
2647 }
2648 2580
2649 return !done; 2581 if (work_done >= to_do)
2582 return 1; /* not done */
2583
2584 local_irq_disable();
2585 __netif_rx_complete(dev);
2586 hw->intr_mask |= portirqmask[skge->port];
2587 skge_write32(hw, B0_IMSK, hw->intr_mask);
2588 local_irq_enable();
2589 return 0;
2650} 2590}
2651 2591
2652static inline void skge_tx_intr(struct net_device *dev) 2592static inline void skge_tx_intr(struct net_device *dev)
@@ -2657,7 +2597,7 @@ static inline void skge_tx_intr(struct net_device *dev)
2657 struct skge_element *e; 2597 struct skge_element *e;
2658 2598
2659 spin_lock(&skge->tx_lock); 2599 spin_lock(&skge->tx_lock);
2660 for(e = ring->to_clean; e != ring->to_use; e = e->next) { 2600 for (e = ring->to_clean; e != ring->to_use; e = e->next) {
2661 struct skge_tx_desc *td = e->desc; 2601 struct skge_tx_desc *td = e->desc;
2662 u32 control; 2602 u32 control;
2663 2603
@@ -2683,19 +2623,25 @@ static inline void skge_tx_intr(struct net_device *dev)
2683 spin_unlock(&skge->tx_lock); 2623 spin_unlock(&skge->tx_lock);
2684} 2624}
2685 2625
2626/* Parity errors seem to happen when Genesis is connected to a switch
2627 * with no other ports present. Heartbeat error??
2628 */
2686static void skge_mac_parity(struct skge_hw *hw, int port) 2629static void skge_mac_parity(struct skge_hw *hw, int port)
2687{ 2630{
2688 printk(KERN_ERR PFX "%s: mac data parity error\n", 2631 struct net_device *dev = hw->dev[port];
2689 hw->dev[port] ? hw->dev[port]->name 2632
2690 : (port == 0 ? "(port A)": "(port B")); 2633 if (dev) {
2634 struct skge_port *skge = netdev_priv(dev);
2635 ++skge->net_stats.tx_heartbeat_errors;
2636 }
2691 2637
2692 if (hw->chip_id == CHIP_ID_GENESIS) 2638 if (hw->chip_id == CHIP_ID_GENESIS)
2693 skge_write16(hw, SKGEMAC_REG(port, TX_MFF_CTRL1), 2639 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1),
2694 MFF_CLR_PERR); 2640 MFF_CLR_PERR);
2695 else 2641 else
2696 /* HW-Bug #8: cleared by GMF_CLI_TX_FC instead of GMF_CLI_TX_PE */ 2642 /* HW-Bug #8: cleared by GMF_CLI_TX_FC instead of GMF_CLI_TX_PE */
2697 skge_write8(hw, SKGEMAC_REG(port, TX_GMF_CTRL_T), 2643 skge_write8(hw, SK_REG(port, TX_GMF_CTRL_T),
2698 (hw->chip_id == CHIP_ID_YUKON && chip_rev(hw) == 0) 2644 (hw->chip_id == CHIP_ID_YUKON && hw->chip_rev == 0)
2699 ? GMF_CLI_TX_FC : GMF_CLI_TX_PE); 2645 ? GMF_CLI_TX_FC : GMF_CLI_TX_PE);
2700} 2646}
2701 2647
@@ -2703,16 +2649,16 @@ static void skge_pci_clear(struct skge_hw *hw)
2703{ 2649{
2704 u16 status; 2650 u16 status;
2705 2651
2706 status = skge_read16(hw, SKGEPCI_REG(PCI_STATUS)); 2652 pci_read_config_word(hw->pdev, PCI_STATUS, &status);
2707 skge_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2653 skge_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2708 skge_write16(hw, SKGEPCI_REG(PCI_STATUS), 2654 pci_write_config_word(hw->pdev, PCI_STATUS,
2709 status | PCI_STATUS_ERROR_BITS); 2655 status | PCI_STATUS_ERROR_BITS);
2710 skge_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 2656 skge_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2711} 2657}
2712 2658
2713static void skge_mac_intr(struct skge_hw *hw, int port) 2659static void skge_mac_intr(struct skge_hw *hw, int port)
2714{ 2660{
2715 if (hw->chip_id == CHIP_ID_GENESIS) 2661 if (hw->chip_id == CHIP_ID_GENESIS)
2716 genesis_mac_intr(hw, port); 2662 genesis_mac_intr(hw, port);
2717 else 2663 else
2718 yukon_mac_intr(hw, port); 2664 yukon_mac_intr(hw, port);
@@ -2726,25 +2672,13 @@ static void skge_error_irq(struct skge_hw *hw)
2726 if (hw->chip_id == CHIP_ID_GENESIS) { 2672 if (hw->chip_id == CHIP_ID_GENESIS) {
2727 /* clear xmac errors */ 2673 /* clear xmac errors */
2728 if (hwstatus & (IS_NO_STAT_M1|IS_NO_TIST_M1)) 2674 if (hwstatus & (IS_NO_STAT_M1|IS_NO_TIST_M1))
2729 skge_write16(hw, SKGEMAC_REG(0, RX_MFF_CTRL1), MFF_CLR_INSTAT); 2675 skge_write16(hw, SK_REG(0, RX_MFF_CTRL1), MFF_CLR_INSTAT);
2730 if (hwstatus & (IS_NO_STAT_M2|IS_NO_TIST_M2)) 2676 if (hwstatus & (IS_NO_STAT_M2|IS_NO_TIST_M2))
2731 skge_write16(hw, SKGEMAC_REG(0, RX_MFF_CTRL2), MFF_CLR_INSTAT); 2677 skge_write16(hw, SK_REG(0, RX_MFF_CTRL2), MFF_CLR_INSTAT);
2732 } else { 2678 } else {
2733 /* Timestamp (unused) overflow */ 2679 /* Timestamp (unused) overflow */
2734 if (hwstatus & IS_IRQ_TIST_OV) 2680 if (hwstatus & IS_IRQ_TIST_OV)
2735 skge_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ); 2681 skge_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ);
2736
2737 if (hwstatus & IS_IRQ_SENSOR) {
2738 /* no sensors on 32-bit Yukon */
2739 if (!(skge_read16(hw, B0_CTST) & CS_BUS_SLOT_SZ)) {
2740 printk(KERN_ERR PFX "ignoring bogus sensor interrups\n");
2741 skge_write32(hw, B0_HWE_IMSK,
2742 IS_ERR_MSK & ~IS_IRQ_SENSOR);
2743 } else
2744 printk(KERN_WARNING PFX "sensor interrupt\n");
2745 }
2746
2747
2748 } 2682 }
2749 2683
2750 if (hwstatus & IS_RAM_RD_PAR) { 2684 if (hwstatus & IS_RAM_RD_PAR) {
@@ -2775,9 +2709,10 @@ static void skge_error_irq(struct skge_hw *hw)
2775 2709
2776 skge_pci_clear(hw); 2710 skge_pci_clear(hw);
2777 2711
2712 /* if error still set then just ignore it */
2778 hwstatus = skge_read32(hw, B0_HWE_ISRC); 2713 hwstatus = skge_read32(hw, B0_HWE_ISRC);
2779 if (hwstatus & IS_IRQ_STAT) { 2714 if (hwstatus & IS_IRQ_STAT) {
2780 printk(KERN_WARNING PFX "IRQ status %x: still set ignoring hardware errors\n", 2715 pr_debug("IRQ status %x: still set ignoring hardware errors\n",
2781 hwstatus); 2716 hwstatus);
2782 hw->intr_mask &= ~IS_HW_ERR; 2717 hw->intr_mask &= ~IS_HW_ERR;
2783 } 2718 }
@@ -2803,8 +2738,8 @@ static void skge_extirq(unsigned long data)
2803 2738
2804 if (hw->chip_id != CHIP_ID_GENESIS) 2739 if (hw->chip_id != CHIP_ID_GENESIS)
2805 yukon_phy_intr(skge); 2740 yukon_phy_intr(skge);
2806 else if (hw->phy_type == SK_PHY_BCOM) 2741 else
2807 genesis_bcom_intr(skge); 2742 bcom_phy_intr(skge);
2808 } 2743 }
2809 } 2744 }
2810 spin_unlock(&hw->phy_lock); 2745 spin_unlock(&hw->phy_lock);
@@ -2824,19 +2759,14 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
2824 return IRQ_NONE; 2759 return IRQ_NONE;
2825 2760
2826 status &= hw->intr_mask; 2761 status &= hw->intr_mask;
2827 2762 if (status & IS_R1_F) {
2828 if ((status & IS_R1_F) && netif_rx_schedule_prep(hw->dev[0])) {
2829 status &= ~IS_R1_F;
2830 hw->intr_mask &= ~IS_R1_F; 2763 hw->intr_mask &= ~IS_R1_F;
2831 skge_write32(hw, B0_IMSK, hw->intr_mask); 2764 netif_rx_schedule(hw->dev[0]);
2832 __netif_rx_schedule(hw->dev[0]);
2833 } 2765 }
2834 2766
2835 if ((status & IS_R2_F) && netif_rx_schedule_prep(hw->dev[1])) { 2767 if (status & IS_R2_F) {
2836 status &= ~IS_R2_F;
2837 hw->intr_mask &= ~IS_R2_F; 2768 hw->intr_mask &= ~IS_R2_F;
2838 skge_write32(hw, B0_IMSK, hw->intr_mask); 2769 netif_rx_schedule(hw->dev[1]);
2839 __netif_rx_schedule(hw->dev[1]);
2840 } 2770 }
2841 2771
2842 if (status & IS_XA1_F) 2772 if (status & IS_XA1_F)
@@ -2845,9 +2775,27 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
2845 if (status & IS_XA2_F) 2775 if (status & IS_XA2_F)
2846 skge_tx_intr(hw->dev[1]); 2776 skge_tx_intr(hw->dev[1]);
2847 2777
2778 if (status & IS_PA_TO_RX1) {
2779 struct skge_port *skge = netdev_priv(hw->dev[0]);
2780 ++skge->net_stats.rx_over_errors;
2781 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX1);
2782 }
2783
2784 if (status & IS_PA_TO_RX2) {
2785 struct skge_port *skge = netdev_priv(hw->dev[1]);
2786 ++skge->net_stats.rx_over_errors;
2787 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX2);
2788 }
2789
2790 if (status & IS_PA_TO_TX1)
2791 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX1);
2792
2793 if (status & IS_PA_TO_TX2)
2794 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX2);
2795
2848 if (status & IS_MAC1) 2796 if (status & IS_MAC1)
2849 skge_mac_intr(hw, 0); 2797 skge_mac_intr(hw, 0);
2850 2798
2851 if (status & IS_MAC2) 2799 if (status & IS_MAC2)
2852 skge_mac_intr(hw, 1); 2800 skge_mac_intr(hw, 1);
2853 2801
@@ -2859,8 +2807,7 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
2859 tasklet_schedule(&hw->ext_tasklet); 2807 tasklet_schedule(&hw->ext_tasklet);
2860 } 2808 }
2861 2809
2862 if (status) 2810 skge_write32(hw, B0_IMSK, hw->intr_mask);
2863 skge_write32(hw, B0_IMSK, hw->intr_mask);
2864 2811
2865 return IRQ_HANDLED; 2812 return IRQ_HANDLED;
2866} 2813}
@@ -2904,9 +2851,6 @@ static const struct {
2904 { CHIP_ID_YUKON, "Yukon" }, 2851 { CHIP_ID_YUKON, "Yukon" },
2905 { CHIP_ID_YUKON_LITE, "Yukon-Lite"}, 2852 { CHIP_ID_YUKON_LITE, "Yukon-Lite"},
2906 { CHIP_ID_YUKON_LP, "Yukon-LP"}, 2853 { CHIP_ID_YUKON_LP, "Yukon-LP"},
2907 { CHIP_ID_YUKON_XL, "Yukon-2 XL"},
2908 { CHIP_ID_YUKON_EC, "YUKON-2 EC"},
2909 { CHIP_ID_YUKON_FE, "YUKON-2 FE"},
2910}; 2854};
2911 2855
2912static const char *skge_board_name(const struct skge_hw *hw) 2856static const char *skge_board_name(const struct skge_hw *hw)
@@ -2930,8 +2874,8 @@ static const char *skge_board_name(const struct skge_hw *hw)
2930static int skge_reset(struct skge_hw *hw) 2874static int skge_reset(struct skge_hw *hw)
2931{ 2875{
2932 u16 ctst; 2876 u16 ctst;
2933 u8 t8; 2877 u8 t8, mac_cfg, pmd_type, phy_type;
2934 int i, ports; 2878 int i;
2935 2879
2936 ctst = skge_read16(hw, B0_CTST); 2880 ctst = skge_read16(hw, B0_CTST);
2937 2881
@@ -2949,21 +2893,19 @@ static int skge_reset(struct skge_hw *hw)
2949 ctst & (CS_CLK_RUN_HOT|CS_CLK_RUN_RST|CS_CLK_RUN_ENA)); 2893 ctst & (CS_CLK_RUN_HOT|CS_CLK_RUN_RST|CS_CLK_RUN_ENA));
2950 2894
2951 hw->chip_id = skge_read8(hw, B2_CHIP_ID); 2895 hw->chip_id = skge_read8(hw, B2_CHIP_ID);
2952 hw->phy_type = skge_read8(hw, B2_E_1) & 0xf; 2896 phy_type = skge_read8(hw, B2_E_1) & 0xf;
2953 hw->pmd_type = skge_read8(hw, B2_PMD_TYP); 2897 pmd_type = skge_read8(hw, B2_PMD_TYP);
2898 hw->copper = (pmd_type == 'T' || pmd_type == '1');
2954 2899
2955 switch(hw->chip_id) { 2900 switch (hw->chip_id) {
2956 case CHIP_ID_GENESIS: 2901 case CHIP_ID_GENESIS:
2957 switch (hw->phy_type) { 2902 switch (phy_type) {
2958 case SK_PHY_XMAC:
2959 hw->phy_addr = PHY_ADDR_XMAC;
2960 break;
2961 case SK_PHY_BCOM: 2903 case SK_PHY_BCOM:
2962 hw->phy_addr = PHY_ADDR_BCOM; 2904 hw->phy_addr = PHY_ADDR_BCOM;
2963 break; 2905 break;
2964 default: 2906 default:
2965 printk(KERN_ERR PFX "%s: unsupported phy type 0x%x\n", 2907 printk(KERN_ERR PFX "%s: unsupported phy type 0x%x\n",
2966 pci_name(hw->pdev), hw->phy_type); 2908 pci_name(hw->pdev), phy_type);
2967 return -EOPNOTSUPP; 2909 return -EOPNOTSUPP;
2968 } 2910 }
2969 break; 2911 break;
@@ -2971,13 +2913,10 @@ static int skge_reset(struct skge_hw *hw)
2971 case CHIP_ID_YUKON: 2913 case CHIP_ID_YUKON:
2972 case CHIP_ID_YUKON_LITE: 2914 case CHIP_ID_YUKON_LITE:
2973 case CHIP_ID_YUKON_LP: 2915 case CHIP_ID_YUKON_LP:
2974 if (hw->phy_type < SK_PHY_MARV_COPPER && hw->pmd_type != 'S') 2916 if (phy_type < SK_PHY_MARV_COPPER && pmd_type != 'S')
2975 hw->phy_type = SK_PHY_MARV_COPPER; 2917 hw->copper = 1;
2976 2918
2977 hw->phy_addr = PHY_ADDR_MARV; 2919 hw->phy_addr = PHY_ADDR_MARV;
2978 if (!iscopper(hw))
2979 hw->phy_type = SK_PHY_MARV_FIBER;
2980
2981 break; 2920 break;
2982 2921
2983 default: 2922 default:
@@ -2986,8 +2925,9 @@ static int skge_reset(struct skge_hw *hw)
2986 return -EOPNOTSUPP; 2925 return -EOPNOTSUPP;
2987 } 2926 }
2988 2927
2989 hw->mac_cfg = skge_read8(hw, B2_MAC_CFG); 2928 mac_cfg = skge_read8(hw, B2_MAC_CFG);
2990 ports = isdualport(hw) ? 2 : 1; 2929 hw->ports = (mac_cfg & CFG_SNG_MAC) ? 1 : 2;
2930 hw->chip_rev = (mac_cfg & CFG_CHIP_R_MSK) >> 4;
2991 2931
2992 /* read the adapters RAM size */ 2932 /* read the adapters RAM size */
2993 t8 = skge_read8(hw, B2_E_0); 2933 t8 = skge_read8(hw, B2_E_0);
@@ -3004,15 +2944,23 @@ static int skge_reset(struct skge_hw *hw)
3004 else 2944 else
3005 hw->ram_size = t8 * 4096; 2945 hw->ram_size = t8 * 4096;
3006 2946
2947 hw->intr_mask = IS_HW_ERR | IS_EXT_REG;
3007 if (hw->chip_id == CHIP_ID_GENESIS) 2948 if (hw->chip_id == CHIP_ID_GENESIS)
3008 genesis_init(hw); 2949 genesis_init(hw);
3009 else { 2950 else {
3010 /* switch power to VCC (WA for VAUX problem) */ 2951 /* switch power to VCC (WA for VAUX problem) */
3011 skge_write8(hw, B0_POWER_CTRL, 2952 skge_write8(hw, B0_POWER_CTRL,
3012 PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_OFF | PC_VCC_ON); 2953 PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_OFF | PC_VCC_ON);
3013 for (i = 0; i < ports; i++) { 2954 /* avoid boards with stuck Hardware error bits */
3014 skge_write16(hw, SKGEMAC_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET); 2955 if ((skge_read32(hw, B0_ISRC) & IS_HW_ERR) &&
3015 skge_write16(hw, SKGEMAC_REG(i, GMAC_LINK_CTRL), GMLC_RST_CLR); 2956 (skge_read32(hw, B0_HWE_ISRC) & IS_IRQ_SENSOR)) {
2957 printk(KERN_WARNING PFX "stuck hardware sensor bit\n");
2958 hw->intr_mask &= ~IS_HW_ERR;
2959 }
2960
2961 for (i = 0; i < hw->ports; i++) {
2962 skge_write16(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET);
2963 skge_write16(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_CLR);
3016 } 2964 }
3017 } 2965 }
3018 2966
@@ -3022,8 +2970,8 @@ static int skge_reset(struct skge_hw *hw)
3022 skge_write8(hw, B0_LED, LED_STAT_ON); 2970 skge_write8(hw, B0_LED, LED_STAT_ON);
3023 2971
3024 /* enable the Tx Arbiters */ 2972 /* enable the Tx Arbiters */
3025 for (i = 0; i < ports; i++) 2973 for (i = 0; i < hw->ports; i++)
3026 skge_write8(hw, SKGEMAC_REG(i, TXA_CTRL), TXA_ENA_ARB); 2974 skge_write8(hw, SK_REG(i, TXA_CTRL), TXA_ENA_ARB);
3027 2975
3028 /* Initialize ram interface */ 2976 /* Initialize ram interface */
3029 skge_write16(hw, B3_RI_CTRL, RI_RST_CLR); 2977 skge_write16(hw, B3_RI_CTRL, RI_RST_CLR);
@@ -3050,16 +2998,13 @@ static int skge_reset(struct skge_hw *hw)
3050 skge_write32(hw, B2_IRQM_INI, skge_usecs2clk(hw, 100)); 2998 skge_write32(hw, B2_IRQM_INI, skge_usecs2clk(hw, 100));
3051 skge_write32(hw, B2_IRQM_CTRL, TIM_START); 2999 skge_write32(hw, B2_IRQM_CTRL, TIM_START);
3052 3000
3053 hw->intr_mask = IS_HW_ERR | IS_EXT_REG | IS_PORT_1;
3054 if (isdualport(hw))
3055 hw->intr_mask |= IS_PORT_2;
3056 skge_write32(hw, B0_IMSK, hw->intr_mask); 3001 skge_write32(hw, B0_IMSK, hw->intr_mask);
3057 3002
3058 if (hw->chip_id != CHIP_ID_GENESIS) 3003 if (hw->chip_id != CHIP_ID_GENESIS)
3059 skge_write8(hw, GMAC_IRQ_MSK, 0); 3004 skge_write8(hw, GMAC_IRQ_MSK, 0);
3060 3005
3061 spin_lock_bh(&hw->phy_lock); 3006 spin_lock_bh(&hw->phy_lock);
3062 for (i = 0; i < ports; i++) { 3007 for (i = 0; i < hw->ports; i++) {
3063 if (hw->chip_id == CHIP_ID_GENESIS) 3008 if (hw->chip_id == CHIP_ID_GENESIS)
3064 genesis_reset(hw, i); 3009 genesis_reset(hw, i);
3065 else 3010 else
@@ -3071,7 +3016,8 @@ static int skge_reset(struct skge_hw *hw)
3071} 3016}
3072 3017
3073/* Initialize network device */ 3018/* Initialize network device */
3074static struct net_device *skge_devinit(struct skge_hw *hw, int port) 3019static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3020 int highmem)
3075{ 3021{
3076 struct skge_port *skge; 3022 struct skge_port *skge;
3077 struct net_device *dev = alloc_etherdev(sizeof(*skge)); 3023 struct net_device *dev = alloc_etherdev(sizeof(*skge));
@@ -3104,6 +3050,8 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port)
3104#endif 3050#endif
3105 dev->irq = hw->pdev->irq; 3051 dev->irq = hw->pdev->irq;
3106 dev->features = NETIF_F_LLTX; 3052 dev->features = NETIF_F_LLTX;
3053 if (highmem)
3054 dev->features |= NETIF_F_HIGHDMA;
3107 3055
3108 skge = netdev_priv(dev); 3056 skge = netdev_priv(dev);
3109 skge->netdev = dev; 3057 skge->netdev = dev;
@@ -3117,7 +3065,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port)
3117 skge->flow_control = FLOW_MODE_SYMMETRIC; 3065 skge->flow_control = FLOW_MODE_SYMMETRIC;
3118 skge->duplex = -1; 3066 skge->duplex = -1;
3119 skge->speed = -1; 3067 skge->speed = -1;
3120 skge->advertising = skge_modes(hw); 3068 skge->advertising = skge_supported_modes(hw);
3121 3069
3122 hw->dev[port] = dev; 3070 hw->dev[port] = dev;
3123 3071
@@ -3125,14 +3073,6 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port)
3125 3073
3126 spin_lock_init(&skge->tx_lock); 3074 spin_lock_init(&skge->tx_lock);
3127 3075
3128 init_timer(&skge->link_check);
3129 skge->link_check.function = skge_link_timer;
3130 skge->link_check.data = (unsigned long) skge;
3131
3132 init_timer(&skge->led_blink);
3133 skge->led_blink.function = skge_blink_timer;
3134 skge->led_blink.data = (unsigned long) skge;
3135
3136 if (hw->chip_id != CHIP_ID_GENESIS) { 3076 if (hw->chip_id != CHIP_ID_GENESIS) {
3137 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3077 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
3138 skge->rx_csum = 1; 3078 skge->rx_csum = 1;
@@ -3232,14 +3172,11 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3232 3172
3233 printk(KERN_INFO PFX "addr 0x%lx irq %d chip %s rev %d\n", 3173 printk(KERN_INFO PFX "addr 0x%lx irq %d chip %s rev %d\n",
3234 pci_resource_start(pdev, 0), pdev->irq, 3174 pci_resource_start(pdev, 0), pdev->irq,
3235 skge_board_name(hw), chip_rev(hw)); 3175 skge_board_name(hw), hw->chip_rev);
3236 3176
3237 if ((dev = skge_devinit(hw, 0)) == NULL) 3177 if ((dev = skge_devinit(hw, 0, using_dac)) == NULL)
3238 goto err_out_led_off; 3178 goto err_out_led_off;
3239 3179
3240 if (using_dac)
3241 dev->features |= NETIF_F_HIGHDMA;
3242
3243 if ((err = register_netdev(dev))) { 3180 if ((err = register_netdev(dev))) {
3244 printk(KERN_ERR PFX "%s: cannot register net device\n", 3181 printk(KERN_ERR PFX "%s: cannot register net device\n",
3245 pci_name(pdev)); 3182 pci_name(pdev));
@@ -3248,10 +3185,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3248 3185
3249 skge_show_addr(dev); 3186 skge_show_addr(dev);
3250 3187
3251 if (isdualport(hw) && (dev1 = skge_devinit(hw, 1))) { 3188 if (hw->ports > 1 && (dev1 = skge_devinit(hw, 1, using_dac))) {
3252 if (using_dac)
3253 dev1->features |= NETIF_F_HIGHDMA;
3254
3255 if (register_netdev(dev1) == 0) 3189 if (register_netdev(dev1) == 0)
3256 skge_show_addr(dev1); 3190 skge_show_addr(dev1);
3257 else { 3191 else {
@@ -3288,7 +3222,7 @@ static void __devexit skge_remove(struct pci_dev *pdev)
3288 struct skge_hw *hw = pci_get_drvdata(pdev); 3222 struct skge_hw *hw = pci_get_drvdata(pdev);
3289 struct net_device *dev0, *dev1; 3223 struct net_device *dev0, *dev1;
3290 3224
3291 if(!hw) 3225 if (!hw)
3292 return; 3226 return;
3293 3227
3294 if ((dev1 = hw->dev[1])) 3228 if ((dev1 = hw->dev[1]))
@@ -3311,12 +3245,12 @@ static void __devexit skge_remove(struct pci_dev *pdev)
3311} 3245}
3312 3246
3313#ifdef CONFIG_PM 3247#ifdef CONFIG_PM
3314static int skge_suspend(struct pci_dev *pdev, u32 state) 3248static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
3315{ 3249{
3316 struct skge_hw *hw = pci_get_drvdata(pdev); 3250 struct skge_hw *hw = pci_get_drvdata(pdev);
3317 int i, wol = 0; 3251 int i, wol = 0;
3318 3252
3319 for(i = 0; i < 2; i++) { 3253 for (i = 0; i < 2; i++) {
3320 struct net_device *dev = hw->dev[i]; 3254 struct net_device *dev = hw->dev[i];
3321 3255
3322 if (dev) { 3256 if (dev) {
@@ -3331,7 +3265,7 @@ static int skge_suspend(struct pci_dev *pdev, u32 state)
3331 } 3265 }
3332 3266
3333 pci_save_state(pdev); 3267 pci_save_state(pdev);
3334 pci_enable_wake(pdev, state, wol); 3268 pci_enable_wake(pdev, pci_choose_state(pdev, state), wol);
3335 pci_disable_device(pdev); 3269 pci_disable_device(pdev);
3336 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3270 pci_set_power_state(pdev, pci_choose_state(pdev, state));
3337 3271
@@ -3349,11 +3283,11 @@ static int skge_resume(struct pci_dev *pdev)
3349 3283
3350 skge_reset(hw); 3284 skge_reset(hw);
3351 3285
3352 for(i = 0; i < 2; i++) { 3286 for (i = 0; i < 2; i++) {
3353 struct net_device *dev = hw->dev[i]; 3287 struct net_device *dev = hw->dev[i];
3354 if (dev) { 3288 if (dev) {
3355 netif_device_attach(dev); 3289 netif_device_attach(dev);
3356 if(netif_running(dev)) 3290 if (netif_running(dev))
3357 skge_up(dev); 3291 skge_up(dev);
3358 } 3292 }
3359 } 3293 }
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 36c62b68fab4..f1680beb8e68 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -7,31 +7,7 @@
7/* PCI config registers */ 7/* PCI config registers */
8#define PCI_DEV_REG1 0x40 8#define PCI_DEV_REG1 0x40
9#define PCI_DEV_REG2 0x44 9#define PCI_DEV_REG2 0x44
10#ifndef PCI_VPD 10#define PCI_REV_DESC 0x4
11#define PCI_VPD 0x50
12#endif
13
14/* PCI_OUR_REG_2 32 bit Our Register 2 */
15enum {
16 PCI_VPD_WR_THR = 0xff<<24, /* Bit 31..24: VPD Write Threshold */
17 PCI_DEV_SEL = 0x7f<<17, /* Bit 23..17: EEPROM Device Select */
18 PCI_VPD_ROM_SZ = 7 <<14, /* Bit 16..14: VPD ROM Size */
19 /* Bit 13..12: reserved */
20 PCI_EN_DUMMY_RD = 1<<3, /* Enable Dummy Read */
21 PCI_REV_DESC = 1<<2, /* Reverse Desc. Bytes */
22 PCI_USEDATA64 = 1<<0, /* Use 64Bit Data bus ext */
23};
24
25/* PCI_VPD_ADR_REG 16 bit VPD Address Register */
26enum {
27 PCI_VPD_FLAG = 1<<15, /* starts VPD rd/wr cycle */
28 PCI_VPD_ADR_MSK =0x7fffL, /* Bit 14.. 0: VPD Address Mask */
29 VPD_RES_ID = 0x82,
30 VPD_RES_READ = 0x90,
31 VPD_RES_WRITE = 0x81,
32 VPD_RES_END = 0x78,
33};
34
35 11
36#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \ 12#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \
37 PCI_STATUS_SIG_SYSTEM_ERROR | \ 13 PCI_STATUS_SIG_SYSTEM_ERROR | \
@@ -39,7 +15,6 @@ enum {
39 PCI_STATUS_REC_TARGET_ABORT | \ 15 PCI_STATUS_REC_TARGET_ABORT | \
40 PCI_STATUS_PARITY) 16 PCI_STATUS_PARITY)
41 17
42
43enum csr_regs { 18enum csr_regs {
44 B0_RAP = 0x0000, 19 B0_RAP = 0x0000,
45 B0_CTST = 0x0004, 20 B0_CTST = 0x0004,
@@ -229,15 +204,16 @@ enum {
229 IS_XA2_F = 1<<1, /* Q_XA2 End of Frame */ 204 IS_XA2_F = 1<<1, /* Q_XA2 End of Frame */
230 IS_XA2_C = 1<<0, /* Q_XA2 Encoding Error */ 205 IS_XA2_C = 1<<0, /* Q_XA2 Encoding Error */
231 206
232 IS_PORT_1 = IS_XA1_F| IS_R1_F| IS_MAC1, 207 IS_TO_PORT1 = IS_PA_TO_RX1 | IS_PA_TO_TX1,
233 IS_PORT_2 = IS_XA2_F| IS_R2_F| IS_MAC2, 208 IS_TO_PORT2 = IS_PA_TO_RX2 | IS_PA_TO_TX2,
209
210 IS_PORT_1 = IS_XA1_F| IS_R1_F | IS_TO_PORT1 | IS_MAC1,
211 IS_PORT_2 = IS_XA2_F| IS_R2_F | IS_TO_PORT2 | IS_MAC2,
234}; 212};
235 213
236 214
237/* B2_IRQM_HWE_MSK 32 bit IRQ Moderation HW Error Mask */ 215/* B2_IRQM_HWE_MSK 32 bit IRQ Moderation HW Error Mask */
238enum { 216enum {
239 IS_ERR_MSK = 0x00003fff,/* All Error bits */
240
241 IS_IRQ_TIST_OV = 1<<13, /* Time Stamp Timer Overflow (YUKON only) */ 217 IS_IRQ_TIST_OV = 1<<13, /* Time Stamp Timer Overflow (YUKON only) */
242 IS_IRQ_SENSOR = 1<<12, /* IRQ from Sensor (YUKON only) */ 218 IS_IRQ_SENSOR = 1<<12, /* IRQ from Sensor (YUKON only) */
243 IS_IRQ_MST_ERR = 1<<11, /* IRQ master error detected */ 219 IS_IRQ_MST_ERR = 1<<11, /* IRQ master error detected */
@@ -252,6 +228,12 @@ enum {
252 IS_M2_PAR_ERR = 1<<2, /* MAC 2 Parity Error */ 228 IS_M2_PAR_ERR = 1<<2, /* MAC 2 Parity Error */
253 IS_R1_PAR_ERR = 1<<1, /* Queue R1 Parity Error */ 229 IS_R1_PAR_ERR = 1<<1, /* Queue R1 Parity Error */
254 IS_R2_PAR_ERR = 1<<0, /* Queue R2 Parity Error */ 230 IS_R2_PAR_ERR = 1<<0, /* Queue R2 Parity Error */
231
232 IS_ERR_MSK = IS_IRQ_MST_ERR | IS_IRQ_STAT
233 | IS_NO_STAT_M1 | IS_NO_STAT_M2
234 | IS_RAM_RD_PAR | IS_RAM_WR_PAR
235 | IS_M1_PAR_ERR | IS_M2_PAR_ERR
236 | IS_R1_PAR_ERR | IS_R2_PAR_ERR,
255}; 237};
256 238
257/* B2_TST_CTRL1 8 bit Test Control Register 1 */ 239/* B2_TST_CTRL1 8 bit Test Control Register 1 */
@@ -288,14 +270,6 @@ enum {
288 CHIP_REV_YU_LITE_A3 = 7, /* Chip Rev. for YUKON-Lite A3 */ 270 CHIP_REV_YU_LITE_A3 = 7, /* Chip Rev. for YUKON-Lite A3 */
289}; 271};
290 272
291/* B2_LD_TEST 8 bit EPROM loader test register */
292enum {
293 LD_T_ON = 1<<3, /* Loader Test mode on */
294 LD_T_OFF = 1<<2, /* Loader Test mode off */
295 LD_T_STEP = 1<<1, /* Decrement FPROM addr. Counter */
296 LD_START = 1<<0, /* Start loading FPROM */
297};
298
299/* B2_TI_CTRL 8 bit Timer control */ 273/* B2_TI_CTRL 8 bit Timer control */
300/* B2_IRQM_CTRL 8 bit IRQ Moderation Timer Control */ 274/* B2_IRQM_CTRL 8 bit IRQ Moderation Timer Control */
301enum { 275enum {
@@ -313,16 +287,6 @@ enum {
313 TIM_T_STEP = 1<<0, /* Test step */ 287 TIM_T_STEP = 1<<0, /* Test step */
314}; 288};
315 289
316/* B28_DPT_INI 32 bit Descriptor Poll Timer Init Val */
317/* B28_DPT_VAL 32 bit Descriptor Poll Timer Curr Val */
318/* B28_DPT_CTRL 8 bit Descriptor Poll Timer Ctrl Reg */
319enum {
320 DPT_MSK = 0x00ffffffL, /* Bit 23.. 0: Desc Poll Timer Bits */
321
322 DPT_START = 1<<1, /* Start Descriptor Poll Timer */
323 DPT_STOP = 1<<0, /* Stop Descriptor Poll Timer */
324};
325
326/* B2_GP_IO 32 bit General Purpose I/O Register */ 290/* B2_GP_IO 32 bit General Purpose I/O Register */
327enum { 291enum {
328 GP_DIR_9 = 1<<25, /* IO_9 direct, 0=In/1=Out */ 292 GP_DIR_9 = 1<<25, /* IO_9 direct, 0=In/1=Out */
@@ -348,30 +312,6 @@ enum {
348 GP_IO_0 = 1<<0, /* IO_0 pin */ 312 GP_IO_0 = 1<<0, /* IO_0 pin */
349}; 313};
350 314
351/* Rx/Tx Path related Arbiter Test Registers */
352/* B3_MA_TO_TEST 16 bit MAC Arbiter Timeout Test Reg */
353/* B3_MA_RC_TEST 16 bit MAC Arbiter Recovery Test Reg */
354/* B3_PA_TEST 16 bit Packet Arbiter Test Register */
355/* Bit 15, 11, 7, and 3 are reserved in B3_PA_TEST */
356enum {
357 TX2_T_EV = 1<<15,/* TX2 Timeout/Recv Event occured */
358 TX2_T_ON = 1<<14,/* TX2 Timeout/Recv Timer Test On */
359 TX2_T_OFF = 1<<13,/* TX2 Timeout/Recv Timer Tst Off */
360 TX2_T_STEP = 1<<12,/* TX2 Timeout/Recv Timer Step */
361 TX1_T_EV = 1<<11,/* TX1 Timeout/Recv Event occured */
362 TX1_T_ON = 1<<10,/* TX1 Timeout/Recv Timer Test On */
363 TX1_T_OFF = 1<<9, /* TX1 Timeout/Recv Timer Tst Off */
364 TX1_T_STEP = 1<<8, /* TX1 Timeout/Recv Timer Step */
365 RX2_T_EV = 1<<7, /* RX2 Timeout/Recv Event occured */
366 RX2_T_ON = 1<<6, /* RX2 Timeout/Recv Timer Test On */
367 RX2_T_OFF = 1<<5, /* RX2 Timeout/Recv Timer Tst Off */
368 RX2_T_STEP = 1<<4, /* RX2 Timeout/Recv Timer Step */
369 RX1_T_EV = 1<<3, /* RX1 Timeout/Recv Event occured */
370 RX1_T_ON = 1<<2, /* RX1 Timeout/Recv Timer Test On */
371 RX1_T_OFF = 1<<1, /* RX1 Timeout/Recv Timer Tst Off */
372 RX1_T_STEP = 1<<0, /* RX1 Timeout/Recv Timer Step */
373};
374
375/* Descriptor Bit Definition */ 315/* Descriptor Bit Definition */
376/* TxCtrl Transmit Buffer Control Field */ 316/* TxCtrl Transmit Buffer Control Field */
377/* RxCtrl Receive Buffer Control Field */ 317/* RxCtrl Receive Buffer Control Field */
@@ -428,14 +368,6 @@ enum {
428 RI_RST_SET = 1<<0, /* Set RAM Interface Reset */ 368 RI_RST_SET = 1<<0, /* Set RAM Interface Reset */
429}; 369};
430 370
431/* B3_RI_TEST 8 bit RAM Iface Test Register */
432enum {
433 RI_T_EV = 1<<3, /* Timeout Event occured */
434 RI_T_ON = 1<<2, /* Timeout Timer Test On */
435 RI_T_OFF = 1<<1, /* Timeout Timer Test Off */
436 RI_T_STEP = 1<<0, /* Timeout Timer Step */
437};
438
439/* MAC Arbiter Registers */ 371/* MAC Arbiter Registers */
440/* B3_MA_TO_CTRL 16 bit MAC Arbiter Timeout Ctrl Reg */ 372/* B3_MA_TO_CTRL 16 bit MAC Arbiter Timeout Ctrl Reg */
441enum { 373enum {
@@ -452,19 +384,6 @@ enum {
452#define SK_PKT_TO_MAX 0xffff /* Maximum value */ 384#define SK_PKT_TO_MAX 0xffff /* Maximum value */
453#define SK_RI_TO_53 36 /* RAM interface timeout */ 385#define SK_RI_TO_53 36 /* RAM interface timeout */
454 386
455
456/* B3_MA_RC_CTRL 16 bit MAC Arbiter Recovery Ctrl Reg */
457enum {
458 MA_ENA_REC_TX2 = 1<<7, /* Enable Recovery Timer TX2 */
459 MA_DIS_REC_TX2 = 1<<6, /* Disable Recovery Timer TX2 */
460 MA_ENA_REC_TX1 = 1<<5, /* Enable Recovery Timer TX1 */
461 MA_DIS_REC_TX1 = 1<<4, /* Disable Recovery Timer TX1 */
462 MA_ENA_REC_RX2 = 1<<3, /* Enable Recovery Timer RX2 */
463 MA_DIS_REC_RX2 = 1<<2, /* Disable Recovery Timer RX2 */
464 MA_ENA_REC_RX1 = 1<<1, /* Enable Recovery Timer RX1 */
465 MA_DIS_REC_RX1 = 1<<0, /* Disable Recovery Timer RX1 */
466};
467
468/* Packet Arbiter Registers */ 387/* Packet Arbiter Registers */
469/* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */ 388/* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */
470enum { 389enum {
@@ -488,7 +407,7 @@ enum {
488 PA_ENA_TO_TX1 | PA_ENA_TO_TX2) 407 PA_ENA_TO_TX1 | PA_ENA_TO_TX2)
489 408
490 409
491/* Transmit Arbiter Registers MAC 1 and 2, use MR_ADDR() to access */ 410/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */
492/* TXA_ITI_INI 32 bit Tx Arb Interval Timer Init Val */ 411/* TXA_ITI_INI 32 bit Tx Arb Interval Timer Init Val */
493/* TXA_ITI_VAL 32 bit Tx Arb Interval Timer Value */ 412/* TXA_ITI_VAL 32 bit Tx Arb Interval Timer Value */
494/* TXA_LIM_INI 32 bit Tx Arb Limit Counter Init Val */ 413/* TXA_LIM_INI 32 bit Tx Arb Limit Counter Init Val */
@@ -511,7 +430,7 @@ enum {
511/* 430/*
512 * Bank 4 - 5 431 * Bank 4 - 5
513 */ 432 */
514/* Transmit Arbiter Registers MAC 1 and 2, use MR_ADDR() to access */ 433/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */
515enum { 434enum {
516 TXA_ITI_INI = 0x0200,/* 32 bit Tx Arb Interval Timer Init Val*/ 435 TXA_ITI_INI = 0x0200,/* 32 bit Tx Arb Interval Timer Init Val*/
517 TXA_ITI_VAL = 0x0204,/* 32 bit Tx Arb Interval Timer Value */ 436 TXA_ITI_VAL = 0x0204,/* 32 bit Tx Arb Interval Timer Value */
@@ -537,7 +456,7 @@ enum {
537 456
538/* Queue Register Offsets, use Q_ADDR() to access */ 457/* Queue Register Offsets, use Q_ADDR() to access */
539enum { 458enum {
540 B8_Q_REGS = 0x0400, /* base of Queue registers */ 459 B8_Q_REGS = 0x0400, /* base of Queue registers */
541 Q_D = 0x00, /* 8*32 bit Current Descriptor */ 460 Q_D = 0x00, /* 8*32 bit Current Descriptor */
542 Q_DA_L = 0x20, /* 32 bit Current Descriptor Address Low dWord */ 461 Q_DA_L = 0x20, /* 32 bit Current Descriptor Address Low dWord */
543 Q_DA_H = 0x24, /* 32 bit Current Descriptor Address High dWord */ 462 Q_DA_H = 0x24, /* 32 bit Current Descriptor Address High dWord */
@@ -618,8 +537,7 @@ enum {
618enum { 537enum {
619 PHY_ADDR_XMAC = 0<<8, 538 PHY_ADDR_XMAC = 0<<8,
620 PHY_ADDR_BCOM = 1<<8, 539 PHY_ADDR_BCOM = 1<<8,
621 PHY_ADDR_LONE = 3<<8, 540
622 PHY_ADDR_NAT = 0<<8,
623/* GPHY address (bits 15..11 of SMI control reg) */ 541/* GPHY address (bits 15..11 of SMI control reg) */
624 PHY_ADDR_MARV = 0, 542 PHY_ADDR_MARV = 0,
625}; 543};
@@ -986,7 +904,7 @@ enum {
986 LINKLED_BLINK_OFF = 0x10, 904 LINKLED_BLINK_OFF = 0x10,
987 LINKLED_BLINK_ON = 0x20, 905 LINKLED_BLINK_ON = 0x20,
988}; 906};
989 907
990/* GMAC and GPHY Control Registers (YUKON only) */ 908/* GMAC and GPHY Control Registers (YUKON only) */
991enum { 909enum {
992 GMAC_CTRL = 0x0f00,/* 32 bit GMAC Control Reg */ 910 GMAC_CTRL = 0x0f00,/* 32 bit GMAC Control Reg */
@@ -1151,54 +1069,6 @@ enum {
1151 PHY_MARV_FE_SPEC_2 = 0x1c,/* 16 bit r/w Specific Control Reg. 2 */ 1069 PHY_MARV_FE_SPEC_2 = 0x1c,/* 16 bit r/w Specific Control Reg. 2 */
1152}; 1070};
1153 1071
1154/* Level One-PHY Registers, indirect addressed over XMAC */
1155enum {
1156 PHY_LONE_CTRL = 0x00,/* 16 bit r/w PHY Control Register */
1157 PHY_LONE_STAT = 0x01,/* 16 bit r/o PHY Status Register */
1158 PHY_LONE_ID0 = 0x02,/* 16 bit r/o PHY ID0 Register */
1159 PHY_LONE_ID1 = 0x03,/* 16 bit r/o PHY ID1 Register */
1160 PHY_LONE_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */
1161 PHY_LONE_AUNE_LP = 0x05,/* 16 bit r/o Link Part Ability Reg */
1162 PHY_LONE_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */
1163 PHY_LONE_NEPG = 0x07,/* 16 bit r/w Next Page Register */
1164 PHY_LONE_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner */
1165 /* Level One-specific registers */
1166 PHY_LONE_1000T_CTRL = 0x09,/* 16 bit r/w 1000Base-T Control Reg */
1167 PHY_LONE_1000T_STAT = 0x0a,/* 16 bit r/o 1000Base-T Status Reg */
1168 PHY_LONE_EXT_STAT = 0x0f,/* 16 bit r/o Extended Status Reg */
1169 PHY_LONE_PORT_CFG = 0x10,/* 16 bit r/w Port Configuration Reg*/
1170 PHY_LONE_Q_STAT = 0x11,/* 16 bit r/o Quick Status Reg */
1171 PHY_LONE_INT_ENAB = 0x12,/* 16 bit r/w Interrupt Enable Reg */
1172 PHY_LONE_INT_STAT = 0x13,/* 16 bit r/o Interrupt Status Reg */
1173 PHY_LONE_LED_CFG = 0x14,/* 16 bit r/w LED Configuration Reg */
1174 PHY_LONE_PORT_CTRL = 0x15,/* 16 bit r/w Port Control Reg */
1175 PHY_LONE_CIM = 0x16,/* 16 bit r/o CIM Reg */
1176};
1177
1178/* National-PHY Registers, indirect addressed over XMAC */
1179enum {
1180 PHY_NAT_CTRL = 0x00,/* 16 bit r/w PHY Control Register */
1181 PHY_NAT_STAT = 0x01,/* 16 bit r/w PHY Status Register */
1182 PHY_NAT_ID0 = 0x02,/* 16 bit r/o PHY ID0 Register */
1183 PHY_NAT_ID1 = 0x03,/* 16 bit r/o PHY ID1 Register */
1184 PHY_NAT_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */
1185 PHY_NAT_AUNE_LP = 0x05,/* 16 bit r/o Link Partner Ability Reg */
1186 PHY_NAT_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */
1187 PHY_NAT_NEPG = 0x07,/* 16 bit r/w Next Page Register */
1188 PHY_NAT_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner Reg */
1189 /* National-specific registers */
1190 PHY_NAT_1000T_CTRL = 0x09,/* 16 bit r/w 1000Base-T Control Reg */
1191 PHY_NAT_1000T_STAT = 0x0a,/* 16 bit r/o 1000Base-T Status Reg */
1192 PHY_NAT_EXT_STAT = 0x0f,/* 16 bit r/o Extended Status Register */
1193 PHY_NAT_EXT_CTRL1 = 0x10,/* 16 bit r/o Extended Control Reg1 */
1194 PHY_NAT_Q_STAT1 = 0x11,/* 16 bit r/o Quick Status Reg1 */
1195 PHY_NAT_10B_OP = 0x12,/* 16 bit r/o 10Base-T Operations Reg */
1196 PHY_NAT_EXT_CTRL2 = 0x13,/* 16 bit r/o Extended Control Reg1 */
1197 PHY_NAT_Q_STAT2 = 0x14,/* 16 bit r/o Quick Status Reg2 */
1198
1199 PHY_NAT_PHY_ADDR = 0x19,/* 16 bit r/o PHY Address Register */
1200};
1201
1202enum { 1072enum {
1203 PHY_CT_RESET = 1<<15, /* Bit 15: (sc) clear all PHY related regs */ 1073 PHY_CT_RESET = 1<<15, /* Bit 15: (sc) clear all PHY related regs */
1204 PHY_CT_LOOP = 1<<14, /* Bit 14: enable Loopback over PHY */ 1074 PHY_CT_LOOP = 1<<14, /* Bit 14: enable Loopback over PHY */
@@ -1253,8 +1123,29 @@ enum {
1253 PHY_MARV_ID1_Y2 = 0x0C91, /* Yukon-2 (PHY 88E1112) */ 1123 PHY_MARV_ID1_Y2 = 0x0C91, /* Yukon-2 (PHY 88E1112) */
1254}; 1124};
1255 1125
1126/* Advertisement register bits */
1256enum { 1127enum {
1257 PHY_AN_NXT_PG = 1<<15, /* Bit 15: Request Next Page */ 1128 PHY_AN_NXT_PG = 1<<15, /* Bit 15: Request Next Page */
1129 PHY_AN_ACK = 1<<14, /* Bit 14: (ro) Acknowledge Received */
1130 PHY_AN_RF = 1<<13, /* Bit 13: Remote Fault Bits */
1131
1132 PHY_AN_PAUSE_ASYM = 1<<11,/* Bit 11: Try for asymmetric */
1133 PHY_AN_PAUSE_CAP = 1<<10, /* Bit 10: Try for pause */
1134 PHY_AN_100BASE4 = 1<<9, /* Bit 9: Try for 100mbps 4k packets */
1135 PHY_AN_100FULL = 1<<8, /* Bit 8: Try for 100mbps full-duplex */
1136 PHY_AN_100HALF = 1<<7, /* Bit 7: Try for 100mbps half-duplex */
1137 PHY_AN_10FULL = 1<<6, /* Bit 6: Try for 10mbps full-duplex */
1138 PHY_AN_10HALF = 1<<5, /* Bit 5: Try for 10mbps half-duplex */
1139 PHY_AN_CSMA = 1<<0, /* Bit 0: Only selector supported */
1140 PHY_AN_SEL = 0x1f, /* Bit 4..0: Selector Field, 00001=Ethernet*/
1141 PHY_AN_FULL = PHY_AN_100FULL | PHY_AN_10FULL | PHY_AN_CSMA,
1142 PHY_AN_ALL = PHY_AN_10HALF | PHY_AN_10FULL |
1143 PHY_AN_100HALF | PHY_AN_100FULL,
1144};
1145
1146/* Xmac Specific */
1147enum {
1148 PHY_X_AN_NXT_PG = 1<<15, /* Bit 15: Request Next Page */
1258 PHY_X_AN_ACK = 1<<14, /* Bit 14: (ro) Acknowledge Received */ 1149 PHY_X_AN_ACK = 1<<14, /* Bit 14: (ro) Acknowledge Received */
1259 PHY_X_AN_RFB = 3<<12,/* Bit 13..12: Remote Fault Bits */ 1150 PHY_X_AN_RFB = 3<<12,/* Bit 13..12: Remote Fault Bits */
1260 1151
@@ -1263,82 +1154,6 @@ enum {
1263 PHY_X_AN_FD = 1<<5, /* Bit 5: Full Duplex */ 1154 PHY_X_AN_FD = 1<<5, /* Bit 5: Full Duplex */
1264}; 1155};
1265 1156
1266enum {
1267 PHY_B_AN_RF = 1<<13, /* Bit 13: Remote Fault */
1268
1269 PHY_B_AN_ASP = 1<<11, /* Bit 11: Asymmetric Pause */
1270 PHY_B_AN_PC = 1<<10, /* Bit 10: Pause Capable */
1271 PHY_B_AN_SEL = 0x1f, /* Bit 4..0: Selector Field, 00001=Ethernet*/
1272};
1273
1274enum {
1275 PHY_L_AN_RF = 1<<13, /* Bit 13: Remote Fault */
1276 /* Bit 12: reserved */
1277 PHY_L_AN_ASP = 1<<11, /* Bit 11: Asymmetric Pause */
1278 PHY_L_AN_PC = 1<<10, /* Bit 10: Pause Capable */
1279
1280 PHY_L_AN_SEL = 0x1f, /* Bit 4..0: Selector Field, 00001=Ethernet*/
1281};
1282
1283/* PHY_NAT_AUNE_ADV 16 bit r/w Auto-Negotiation Advertisement */
1284/* PHY_NAT_AUNE_LP 16 bit r/o Link Partner Ability Reg *****/
1285/* PHY_AN_NXT_PG (see XMAC) Bit 15: Request Next Page */
1286enum {
1287 PHY_N_AN_RF = 1<<13, /* Bit 13: Remote Fault */
1288
1289 PHY_N_AN_100F = 1<<11, /* Bit 11: 100Base-T2 FD Support */
1290 PHY_N_AN_100H = 1<<10, /* Bit 10: 100Base-T2 HD Support */
1291
1292 PHY_N_AN_SEL = 0x1f, /* Bit 4..0: Selector Field, 00001=Ethernet*/
1293};
1294
1295/* field type definition for PHY_x_AN_SEL */
1296enum {
1297 PHY_SEL_TYPE = 1, /* 00001 = Ethernet */
1298};
1299
1300enum {
1301 PHY_ANE_LP_NP = 1<<3, /* Bit 3: Link Partner can Next Page */
1302 PHY_ANE_LOC_NP = 1<<2, /* Bit 2: Local PHY can Next Page */
1303 PHY_ANE_RX_PG = 1<<1, /* Bit 1: Page Received */
1304};
1305
1306enum {
1307 PHY_ANE_PAR_DF = 1<<4, /* Bit 4: Parallel Detection Fault */
1308
1309 PHY_ANE_LP_CAP = 1<<0, /* Bit 0: Link Partner Auto-Neg. Cap. */
1310};
1311
1312enum {
1313 PHY_NP_MORE = 1<<15, /* Bit 15: More, Next Pages to follow */
1314 PHY_NP_ACK1 = 1<<14, /* Bit 14: (ro) Ack1, for receiving a message */
1315 PHY_NP_MSG_VAL = 1<<13, /* Bit 13: Message Page valid */
1316 PHY_NP_ACK2 = 1<<12, /* Bit 12: Ack2, comply with msg content */
1317 PHY_NP_TOG = 1<<11, /* Bit 11: Toggle Bit, ensure sync */
1318 PHY_NP_MSG = 0x07ff, /* Bit 10..0: Message from/to Link Partner */
1319};
1320
1321enum {
1322 PHY_X_EX_FD = 1<<15, /* Bit 15: Device Supports Full Duplex */
1323 PHY_X_EX_HD = 1<<14, /* Bit 14: Device Supports Half Duplex */
1324};
1325
1326enum {
1327 PHY_X_RS_PAUSE = 3<<7,/* Bit 8..7: selected Pause Mode */
1328 PHY_X_RS_HD = 1<<6, /* Bit 6: Half Duplex Mode selected */
1329 PHY_X_RS_FD = 1<<5, /* Bit 5: Full Duplex Mode selected */
1330 PHY_X_RS_ABLMIS = 1<<4, /* Bit 4: duplex or pause cap mismatch */
1331 PHY_X_RS_PAUMIS = 1<<3, /* Bit 3: pause capability mismatch */
1332};
1333
1334/** Remote Fault Bits (PHY_X_AN_RFB) encoding */
1335enum {
1336 X_RFB_OK = 0<<12,/* Bit 13..12 No errors, Link OK */
1337 X_RFB_LF = 1<<12, /* Bit 13..12 Link Failure */
1338 X_RFB_OFF = 2<<12,/* Bit 13..12 Offline */
1339 X_RFB_AN_ERR = 3<<12,/* Bit 13..12 Auto-Negotiation Error */
1340};
1341
1342/* Pause Bits (PHY_X_AN_PAUSE and PHY_X_RS_PAUSE) encoding */ 1157/* Pause Bits (PHY_X_AN_PAUSE and PHY_X_RS_PAUSE) encoding */
1343enum { 1158enum {
1344 PHY_X_P_NO_PAUSE = 0<<7,/* Bit 8..7: no Pause Mode */ 1159 PHY_X_P_NO_PAUSE = 0<<7,/* Bit 8..7: no Pause Mode */
@@ -1418,6 +1233,16 @@ enum {
1418 PHY_B_PES_MLT3_ER = 1<<0, /* Bit 0: MLT3 code Error */ 1233 PHY_B_PES_MLT3_ER = 1<<0, /* Bit 0: MLT3 code Error */
1419}; 1234};
1420 1235
1236/* PHY_BCOM_AUNE_ADV 16 bit r/w Auto-Negotiation Advertisement *****/
1237/* PHY_BCOM_AUNE_LP 16 bit r/o Link Partner Ability Reg *****/
1238enum {
1239 PHY_B_AN_RF = 1<<13, /* Bit 13: Remote Fault */
1240
1241 PHY_B_AN_ASP = 1<<11, /* Bit 11: Asymmetric Pause */
1242 PHY_B_AN_PC = 1<<10, /* Bit 10: Pause Capable */
1243};
1244
1245
1421/***** PHY_BCOM_FC_CTR 16 bit r/w False Carrier Counter *****/ 1246/***** PHY_BCOM_FC_CTR 16 bit r/w False Carrier Counter *****/
1422enum { 1247enum {
1423 PHY_B_FC_CTR = 0xff, /* Bit 7..0: False Carrier Counter */ 1248 PHY_B_FC_CTR = 0xff, /* Bit 7..0: False Carrier Counter */
@@ -1478,7 +1303,9 @@ enum {
1478 PHY_B_IS_LST_CHANGE = 1<<1, /* Bit 1: Link Status Changed */ 1303 PHY_B_IS_LST_CHANGE = 1<<1, /* Bit 1: Link Status Changed */
1479 PHY_B_IS_CRC_ER = 1<<0, /* Bit 0: CRC Error */ 1304 PHY_B_IS_CRC_ER = 1<<0, /* Bit 0: CRC Error */
1480}; 1305};
1481#define PHY_B_DEF_MSK (~(PHY_B_IS_AN_PR | PHY_B_IS_LST_CHANGE)) 1306#define PHY_B_DEF_MSK \
1307 (~(PHY_B_IS_PSE | PHY_B_IS_AN_PR | PHY_B_IS_DUP_CHANGE | \
1308 PHY_B_IS_LSP_CHANGE | PHY_B_IS_LST_CHANGE))
1482 1309
1483/* Pause Bits (PHY_B_AN_ASP and PHY_B_AN_PC) encoding */ 1310/* Pause Bits (PHY_B_AN_ASP and PHY_B_AN_PC) encoding */
1484enum { 1311enum {
@@ -1495,166 +1322,6 @@ enum {
1495 PHY_B_RES_1000HD = 6<<8,/* Bit 10..8: 1000Base-T Half Dup. */ 1322 PHY_B_RES_1000HD = 6<<8,/* Bit 10..8: 1000Base-T Half Dup. */
1496}; 1323};
1497 1324
1498/*
1499 * Level One-Specific
1500 */
1501/***** PHY_LONE_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/
1502enum {
1503 PHY_L_1000C_TEST = 7<<13,/* Bit 15..13: Test Modes */
1504 PHY_L_1000C_MSE = 1<<12, /* Bit 12: Master/Slave Enable */
1505 PHY_L_1000C_MSC = 1<<11, /* Bit 11: M/S Configuration */
1506 PHY_L_1000C_RD = 1<<10, /* Bit 10: Repeater/DTE */
1507 PHY_L_1000C_AFD = 1<<9, /* Bit 9: Advertise Full Duplex */
1508 PHY_L_1000C_AHD = 1<<8, /* Bit 8: Advertise Half Duplex */
1509};
1510
1511/***** PHY_LONE_1000T_STAT 16 bit r/o 1000Base-T Status Reg *****/
1512enum {
1513 PHY_L_1000S_MSF = 1<<15, /* Bit 15: Master/Slave Fault */
1514 PHY_L_1000S_MSR = 1<<14, /* Bit 14: Master/Slave Result */
1515 PHY_L_1000S_LRS = 1<<13, /* Bit 13: Local Receiver Status */
1516 PHY_L_1000S_RRS = 1<<12, /* Bit 12: Remote Receiver Status */
1517 PHY_L_1000S_LP_FD = 1<<11, /* Bit 11: Link Partner can FD */
1518 PHY_L_1000S_LP_HD = 1<<10, /* Bit 10: Link Partner can HD */
1519
1520 PHY_L_1000S_IEC = 0xff, /* Bit 7..0: Idle Error Count */
1521
1522/***** PHY_LONE_EXT_STAT 16 bit r/o Extended Status Register *****/
1523 PHY_L_ES_X_FD_CAP = 1<<15, /* Bit 15: 1000Base-X FD capable */
1524 PHY_L_ES_X_HD_CAP = 1<<14, /* Bit 14: 1000Base-X HD capable */
1525 PHY_L_ES_T_FD_CAP = 1<<13, /* Bit 13: 1000Base-T FD capable */
1526 PHY_L_ES_T_HD_CAP = 1<<12, /* Bit 12: 1000Base-T HD capable */
1527};
1528
1529/***** PHY_LONE_PORT_CFG 16 bit r/w Port Configuration Reg *****/
1530enum {
1531 PHY_L_PC_REP_MODE = 1<<15, /* Bit 15: Repeater Mode */
1532
1533 PHY_L_PC_TX_DIS = 1<<13, /* Bit 13: Tx output Disabled */
1534 PHY_L_PC_BY_SCR = 1<<12, /* Bit 12: Bypass Scrambler */
1535 PHY_L_PC_BY_45 = 1<<11, /* Bit 11: Bypass 4B5B-Decoder */
1536 PHY_L_PC_JAB_DIS = 1<<10, /* Bit 10: Jabber Disabled */
1537 PHY_L_PC_SQE = 1<<9, /* Bit 9: Enable Heartbeat */
1538 PHY_L_PC_TP_LOOP = 1<<8, /* Bit 8: TP Loopback */
1539 PHY_L_PC_SSS = 1<<7, /* Bit 7: Smart Speed Selection */
1540 PHY_L_PC_FIFO_SIZE = 1<<6, /* Bit 6: FIFO Size */
1541 PHY_L_PC_PRE_EN = 1<<5, /* Bit 5: Preamble Enable */
1542 PHY_L_PC_CIM = 1<<4, /* Bit 4: Carrier Integrity Mon */
1543 PHY_L_PC_10_SER = 1<<3, /* Bit 3: Use Serial Output */
1544 PHY_L_PC_ANISOL = 1<<2, /* Bit 2: Unisolate Port */
1545 PHY_L_PC_TEN_BIT = 1<<1, /* Bit 1: 10bit iface mode on */
1546 PHY_L_PC_ALTCLOCK = 1<<0, /* Bit 0: (ro) ALTCLOCK Mode on */
1547};
1548
1549/***** PHY_LONE_Q_STAT 16 bit r/o Quick Status Reg *****/
1550enum {
1551 PHY_L_QS_D_RATE = 3<<14,/* Bit 15..14: Data Rate */
1552 PHY_L_QS_TX_STAT = 1<<13, /* Bit 13: Transmitting */
1553 PHY_L_QS_RX_STAT = 1<<12, /* Bit 12: Receiving */
1554 PHY_L_QS_COL_STAT = 1<<11, /* Bit 11: Collision */
1555 PHY_L_QS_L_STAT = 1<<10, /* Bit 10: Link is up */
1556 PHY_L_QS_DUP_MOD = 1<<9, /* Bit 9: Full/Half Duplex */
1557 PHY_L_QS_AN = 1<<8, /* Bit 8: AutoNeg is On */
1558 PHY_L_QS_AN_C = 1<<7, /* Bit 7: AN is Complete */
1559 PHY_L_QS_LLE = 7<<4,/* Bit 6..4: Line Length Estim. */
1560 PHY_L_QS_PAUSE = 1<<3, /* Bit 3: LP advertised Pause */
1561 PHY_L_QS_AS_PAUSE = 1<<2, /* Bit 2: LP adv. asym. Pause */
1562 PHY_L_QS_ISOLATE = 1<<1, /* Bit 1: CIM Isolated */
1563 PHY_L_QS_EVENT = 1<<0, /* Bit 0: Event has occurred */
1564};
1565
1566/***** PHY_LONE_INT_ENAB 16 bit r/w Interrupt Enable Reg *****/
1567/***** PHY_LONE_INT_STAT 16 bit r/o Interrupt Status Reg *****/
1568enum {
1569 PHY_L_IS_AN_F = 1<<13, /* Bit 13: Auto-Negotiation fault */
1570 PHY_L_IS_CROSS = 1<<11, /* Bit 11: Crossover used */
1571 PHY_L_IS_POL = 1<<10, /* Bit 10: Polarity correct. used */
1572 PHY_L_IS_SS = 1<<9, /* Bit 9: Smart Speed Downgrade */
1573 PHY_L_IS_CFULL = 1<<8, /* Bit 8: Counter Full */
1574 PHY_L_IS_AN_C = 1<<7, /* Bit 7: AutoNeg Complete */
1575 PHY_L_IS_SPEED = 1<<6, /* Bit 6: Speed Changed */
1576 PHY_L_IS_DUP = 1<<5, /* Bit 5: Duplex Changed */
1577 PHY_L_IS_LS = 1<<4, /* Bit 4: Link Status Changed */
1578 PHY_L_IS_ISOL = 1<<3, /* Bit 3: Isolate Occured */
1579 PHY_L_IS_MDINT = 1<<2, /* Bit 2: (ro) STAT: MII Int Pending */
1580 PHY_L_IS_INTEN = 1<<1, /* Bit 1: ENAB: Enable IRQs */
1581 PHY_L_IS_FORCE = 1<<0, /* Bit 0: ENAB: Force Interrupt */
1582};
1583
1584/* int. mask */
1585#define PHY_L_DEF_MSK (PHY_L_IS_LS | PHY_L_IS_ISOL | PHY_L_IS_INTEN)
1586
1587/***** PHY_LONE_LED_CFG 16 bit r/w LED Configuration Reg *****/
1588enum {
1589 PHY_L_LC_LEDC = 3<<14,/* Bit 15..14: Col/Blink/On/Off */
1590 PHY_L_LC_LEDR = 3<<12,/* Bit 13..12: Rx/Blink/On/Off */
1591 PHY_L_LC_LEDT = 3<<10,/* Bit 11..10: Tx/Blink/On/Off */
1592 PHY_L_LC_LEDG = 3<<8,/* Bit 9..8: Giga/Blink/On/Off */
1593 PHY_L_LC_LEDS = 3<<6,/* Bit 7..6: 10-100/Blink/On/Off */
1594 PHY_L_LC_LEDL = 3<<4,/* Bit 5..4: Link/Blink/On/Off */
1595 PHY_L_LC_LEDF = 3<<2,/* Bit 3..2: Duplex/Blink/On/Off */
1596 PHY_L_LC_PSTRECH= 1<<1, /* Bit 1: Strech LED Pulses */
1597 PHY_L_LC_FREQ = 1<<0, /* Bit 0: 30/100 ms */
1598};
1599
1600/***** PHY_LONE_PORT_CTRL 16 bit r/w Port Control Reg *****/
1601enum {
1602 PHY_L_PC_TX_TCLK = 1<<15, /* Bit 15: Enable TX_TCLK */
1603 PHY_L_PC_ALT_NP = 1<<13, /* Bit 14: Alternate Next Page */
1604 PHY_L_PC_GMII_ALT= 1<<12, /* Bit 13: Alternate GMII driver */
1605 PHY_L_PC_TEN_CRS = 1<<10, /* Bit 10: Extend CRS*/
1606};
1607
1608/***** PHY_LONE_CIM 16 bit r/o CIM Reg *****/
1609enum {
1610 PHY_L_CIM_ISOL = 0xff<<8,/* Bit 15..8: Isolate Count */
1611 PHY_L_CIM_FALSE_CAR = 0xff, /* Bit 7..0: False Carrier Count */
1612};
1613
1614/*
1615 * Pause Bits (PHY_L_AN_ASP and PHY_L_AN_PC) encoding
1616 */
1617enum {
1618 PHY_L_P_NO_PAUSE= 0<<10,/* Bit 11..10: no Pause Mode */
1619 PHY_L_P_SYM_MD = 1<<10, /* Bit 11..10: symmetric Pause Mode */
1620 PHY_L_P_ASYM_MD = 2<<10,/* Bit 11..10: asymmetric Pause Mode */
1621 PHY_L_P_BOTH_MD = 3<<10,/* Bit 11..10: both Pause Mode */
1622};
1623
1624/*
1625 * National-Specific
1626 */
1627/***** PHY_NAT_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/
1628enum {
1629 PHY_N_1000C_TEST= 7<<13,/* Bit 15..13: Test Modes */
1630 PHY_N_1000C_MSE = 1<<12, /* Bit 12: Master/Slave Enable */
1631 PHY_N_1000C_MSC = 1<<11, /* Bit 11: M/S Configuration */
1632 PHY_N_1000C_RD = 1<<10, /* Bit 10: Repeater/DTE */
1633 PHY_N_1000C_AFD = 1<<9, /* Bit 9: Advertise Full Duplex */
1634 PHY_N_1000C_AHD = 1<<8, /* Bit 8: Advertise Half Duplex */
1635 PHY_N_1000C_APC = 1<<7, /* Bit 7: Asymmetric Pause Cap. */};
1636
1637
1638/***** PHY_NAT_1000T_STAT 16 bit r/o 1000Base-T Status Reg *****/
1639enum {
1640 PHY_N_1000S_MSF = 1<<15, /* Bit 15: Master/Slave Fault */
1641 PHY_N_1000S_MSR = 1<<14, /* Bit 14: Master/Slave Result */
1642 PHY_N_1000S_LRS = 1<<13, /* Bit 13: Local Receiver Status */
1643 PHY_N_1000S_RRS = 1<<12, /* Bit 12: Remote Receiver Status*/
1644 PHY_N_1000S_LP_FD= 1<<11, /* Bit 11: Link Partner can FD */
1645 PHY_N_1000S_LP_HD= 1<<10, /* Bit 10: Link Partner can HD */
1646 PHY_N_1000C_LP_APC= 1<<9, /* Bit 9: LP Asym. Pause Cap. */
1647 PHY_N_1000S_IEC = 0xff, /* Bit 7..0: Idle Error Count */
1648};
1649
1650/***** PHY_NAT_EXT_STAT 16 bit r/o Extended Status Register *****/
1651enum {
1652 PHY_N_ES_X_FD_CAP= 1<<15, /* Bit 15: 1000Base-X FD capable */
1653 PHY_N_ES_X_HD_CAP= 1<<14, /* Bit 14: 1000Base-X HD capable */
1654 PHY_N_ES_T_FD_CAP= 1<<13, /* Bit 13: 1000Base-T FD capable */
1655 PHY_N_ES_T_HD_CAP= 1<<12, /* Bit 12: 1000Base-T HD capable */
1656};
1657
1658/** Marvell-Specific */ 1325/** Marvell-Specific */
1659enum { 1326enum {
1660 PHY_M_AN_NXT_PG = 1<<15, /* Request Next Page */ 1327 PHY_M_AN_NXT_PG = 1<<15, /* Request Next Page */
@@ -1718,7 +1385,7 @@ enum {
1718 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ 1385 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */
1719}; 1386};
1720 1387
1721#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) 1388#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK)
1722 1389
1723enum { 1390enum {
1724 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ 1391 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */
@@ -1786,10 +1453,12 @@ enum {
1786 PHY_M_IS_DTE_CHANGE = 1<<2, /* DTE Power Det. Status Changed */ 1453 PHY_M_IS_DTE_CHANGE = 1<<2, /* DTE Power Det. Status Changed */
1787 PHY_M_IS_POL_CHANGE = 1<<1, /* Polarity Changed */ 1454 PHY_M_IS_POL_CHANGE = 1<<1, /* Polarity Changed */
1788 PHY_M_IS_JABBER = 1<<0, /* Jabber */ 1455 PHY_M_IS_JABBER = 1<<0, /* Jabber */
1789};
1790 1456
1791#define PHY_M_DEF_MSK ( PHY_M_IS_AN_ERROR | PHY_M_IS_LSP_CHANGE | \ 1457 PHY_M_IS_DEF_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_LSP_CHANGE |
1792 PHY_M_IS_LST_CHANGE | PHY_M_IS_FIFO_ERROR) 1458 PHY_M_IS_LST_CHANGE | PHY_M_IS_FIFO_ERROR,
1459
1460 PHY_M_IS_AN_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_AN_COMPL,
1461};
1793 1462
1794/***** PHY_MARV_EXT_CTRL 16 bit r/w Ext. PHY Specific Ctrl *****/ 1463/***** PHY_MARV_EXT_CTRL 16 bit r/w Ext. PHY Specific Ctrl *****/
1795enum { 1464enum {
@@ -1846,7 +1515,7 @@ enum {
1846 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ 1515 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */
1847}; 1516};
1848 1517
1849#define PHY_M_LED_PULS_DUR(x) ( ((x)<<12) & PHY_M_LEDC_PULS_MSK) 1518#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK)
1850 1519
1851enum { 1520enum {
1852 PULS_NO_STR = 0,/* no pulse stretching */ 1521 PULS_NO_STR = 0,/* no pulse stretching */
@@ -1859,7 +1528,7 @@ enum {
1859 PULS_1300MS = 7,/* 1.3 s to 2.7 s */ 1528 PULS_1300MS = 7,/* 1.3 s to 2.7 s */
1860}; 1529};
1861 1530
1862#define PHY_M_LED_BLINK_RT(x) ( ((x)<<8) & PHY_M_LEDC_BL_R_MSK) 1531#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK)
1863 1532
1864enum { 1533enum {
1865 BLINK_42MS = 0,/* 42 ms */ 1534 BLINK_42MS = 0,/* 42 ms */
@@ -1939,9 +1608,9 @@ enum {
1939 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */ 1608 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */
1940}; 1609};
1941 1610
1942#define PHY_M_FELP_LED2_CTRL(x) ( ((x)<<8) & PHY_M_FELP_LED2_MSK) 1611#define PHY_M_FELP_LED2_CTRL(x) (((x)<<8) & PHY_M_FELP_LED2_MSK)
1943#define PHY_M_FELP_LED1_CTRL(x) ( ((x)<<4) & PHY_M_FELP_LED1_MSK) 1612#define PHY_M_FELP_LED1_CTRL(x) (((x)<<4) & PHY_M_FELP_LED1_MSK)
1944#define PHY_M_FELP_LED0_CTRL(x) ( ((x)<<0) & PHY_M_FELP_LED0_MSK) 1613#define PHY_M_FELP_LED0_CTRL(x) (((x)<<0) & PHY_M_FELP_LED0_MSK)
1945 1614
1946enum { 1615enum {
1947 LED_PAR_CTRL_COLX = 0x00, 1616 LED_PAR_CTRL_COLX = 0x00,
@@ -1977,7 +1646,7 @@ enum {
1977 PHY_M_MAC_MD_COPPER = 5,/* Copper only */ 1646 PHY_M_MAC_MD_COPPER = 5,/* Copper only */
1978 PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */ 1647 PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */
1979}; 1648};
1980#define PHY_M_MAC_MODE_SEL(x) ( ((x)<<7) & PHY_M_MAC_MD_MSK) 1649#define PHY_M_MAC_MODE_SEL(x) (((x)<<7) & PHY_M_MAC_MD_MSK)
1981 1650
1982/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ 1651/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/
1983enum { 1652enum {
@@ -1987,10 +1656,10 @@ enum {
1987 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */ 1656 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */
1988}; 1657};
1989 1658
1990#define PHY_M_LEDC_LOS_CTRL(x) ( ((x)<<12) & PHY_M_LEDC_LOS_MSK) 1659#define PHY_M_LEDC_LOS_CTRL(x) (((x)<<12) & PHY_M_LEDC_LOS_MSK)
1991#define PHY_M_LEDC_INIT_CTRL(x) ( ((x)<<8) & PHY_M_LEDC_INIT_MSK) 1660#define PHY_M_LEDC_INIT_CTRL(x) (((x)<<8) & PHY_M_LEDC_INIT_MSK)
1992#define PHY_M_LEDC_STA1_CTRL(x) ( ((x)<<4) & PHY_M_LEDC_STA1_MSK) 1661#define PHY_M_LEDC_STA1_CTRL(x) (((x)<<4) & PHY_M_LEDC_STA1_MSK)
1993#define PHY_M_LEDC_STA0_CTRL(x) ( ((x)<<0) & PHY_M_LEDC_STA0_MSK) 1662#define PHY_M_LEDC_STA0_CTRL(x) (((x)<<0) & PHY_M_LEDC_STA0_MSK)
1994 1663
1995/* GMAC registers */ 1664/* GMAC registers */
1996/* Port Registers */ 1665/* Port Registers */
@@ -2105,7 +1774,7 @@ enum {
2105 GM_GPSR_FC_RX_DIS = 1<<2, /* Bit 2: Rx Flow-Control Mode Disabled */ 1774 GM_GPSR_FC_RX_DIS = 1<<2, /* Bit 2: Rx Flow-Control Mode Disabled */
2106 GM_GPSR_PROM_EN = 1<<1, /* Bit 1: Promiscuous Mode Enabled */ 1775 GM_GPSR_PROM_EN = 1<<1, /* Bit 1: Promiscuous Mode Enabled */
2107}; 1776};
2108 1777
2109/* GM_GP_CTRL 16 bit r/w General Purpose Control Register */ 1778/* GM_GP_CTRL 16 bit r/w General Purpose Control Register */
2110enum { 1779enum {
2111 GM_GPCR_PROM_ENA = 1<<14, /* Bit 14: Enable Promiscuous Mode */ 1780 GM_GPCR_PROM_ENA = 1<<14, /* Bit 14: Enable Promiscuous Mode */
@@ -2127,7 +1796,7 @@ enum {
2127 1796
2128#define GM_GPCR_SPEED_1000 (GM_GPCR_GIGS_ENA | GM_GPCR_SPEED_100) 1797#define GM_GPCR_SPEED_1000 (GM_GPCR_GIGS_ENA | GM_GPCR_SPEED_100)
2129#define GM_GPCR_AU_ALL_DIS (GM_GPCR_AU_DUP_DIS | GM_GPCR_AU_FCT_DIS|GM_GPCR_AU_SPD_DIS) 1798#define GM_GPCR_AU_ALL_DIS (GM_GPCR_AU_DUP_DIS | GM_GPCR_AU_FCT_DIS|GM_GPCR_AU_SPD_DIS)
2130 1799
2131/* GM_TX_CTRL 16 bit r/w Transmit Control Register */ 1800/* GM_TX_CTRL 16 bit r/w Transmit Control Register */
2132enum { 1801enum {
2133 GM_TXCR_FORCE_JAM = 1<<15, /* Bit 15: Force Jam / Flow-Control */ 1802 GM_TXCR_FORCE_JAM = 1<<15, /* Bit 15: Force Jam / Flow-Control */
@@ -2138,7 +1807,7 @@ enum {
2138 1807
2139#define TX_COL_THR(x) (((x)<<10) & GM_TXCR_COL_THR_MSK) 1808#define TX_COL_THR(x) (((x)<<10) & GM_TXCR_COL_THR_MSK)
2140#define TX_COL_DEF 0x04 1809#define TX_COL_DEF 0x04
2141 1810
2142/* GM_RX_CTRL 16 bit r/w Receive Control Register */ 1811/* GM_RX_CTRL 16 bit r/w Receive Control Register */
2143enum { 1812enum {
2144 GM_RXCR_UCF_ENA = 1<<15, /* Bit 15: Enable Unicast filtering */ 1813 GM_RXCR_UCF_ENA = 1<<15, /* Bit 15: Enable Unicast filtering */
@@ -2146,7 +1815,7 @@ enum {
2146 GM_RXCR_CRC_DIS = 1<<13, /* Bit 13: Remove 4-byte CRC */ 1815 GM_RXCR_CRC_DIS = 1<<13, /* Bit 13: Remove 4-byte CRC */
2147 GM_RXCR_PASS_FC = 1<<12, /* Bit 12: Pass FC packets to FIFO */ 1816 GM_RXCR_PASS_FC = 1<<12, /* Bit 12: Pass FC packets to FIFO */
2148}; 1817};
2149 1818
2150/* GM_TX_PARAM 16 bit r/w Transmit Parameter Register */ 1819/* GM_TX_PARAM 16 bit r/w Transmit Parameter Register */
2151enum { 1820enum {
2152 GM_TXPA_JAMLEN_MSK = 0x03<<14, /* Bit 15..14: Jam Length */ 1821 GM_TXPA_JAMLEN_MSK = 0x03<<14, /* Bit 15..14: Jam Length */
@@ -2171,7 +1840,7 @@ enum {
2171 GM_SMOD_JUMBO_ENA = 1<<8, /* Bit 8: Enable Jumbo (Max. Frame Len) */ 1840 GM_SMOD_JUMBO_ENA = 1<<8, /* Bit 8: Enable Jumbo (Max. Frame Len) */
2172 GM_SMOD_IPG_MSK = 0x1f /* Bit 4..0: Inter-Packet Gap (IPG) */ 1841 GM_SMOD_IPG_MSK = 0x1f /* Bit 4..0: Inter-Packet Gap (IPG) */
2173}; 1842};
2174 1843
2175#define DATA_BLIND_VAL(x) (((x)<<11) & GM_SMOD_DATABL_MSK) 1844#define DATA_BLIND_VAL(x) (((x)<<11) & GM_SMOD_DATABL_MSK)
2176#define DATA_BLIND_DEF 0x04 1845#define DATA_BLIND_DEF 0x04
2177 1846
@@ -2186,7 +1855,7 @@ enum {
2186 GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */ 1855 GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */
2187 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ 1856 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */
2188}; 1857};
2189 1858
2190#define GM_SMI_CT_PHY_AD(x) (((x)<<11) & GM_SMI_CT_PHY_A_MSK) 1859#define GM_SMI_CT_PHY_AD(x) (((x)<<11) & GM_SMI_CT_PHY_A_MSK)
2191#define GM_SMI_CT_REG_AD(x) (((x)<<6) & GM_SMI_CT_REG_A_MSK) 1860#define GM_SMI_CT_REG_AD(x) (((x)<<6) & GM_SMI_CT_REG_A_MSK)
2192 1861
@@ -2195,7 +1864,7 @@ enum {
2195 GM_PAR_MIB_CLR = 1<<5, /* Bit 5: Set MIB Clear Counter Mode */ 1864 GM_PAR_MIB_CLR = 1<<5, /* Bit 5: Set MIB Clear Counter Mode */
2196 GM_PAR_MIB_TST = 1<<4, /* Bit 4: MIB Load Counter (Test Mode) */ 1865 GM_PAR_MIB_TST = 1<<4, /* Bit 4: MIB Load Counter (Test Mode) */
2197}; 1866};
2198 1867
2199/* Receive Frame Status Encoding */ 1868/* Receive Frame Status Encoding */
2200enum { 1869enum {
2201 GMR_FS_LEN = 0xffff<<16, /* Bit 31..16: Rx Frame Length */ 1870 GMR_FS_LEN = 0xffff<<16, /* Bit 31..16: Rx Frame Length */
@@ -2217,12 +1886,12 @@ enum {
2217/* 1886/*
2218 * GMR_FS_ANY_ERR (analogous to XMR_FS_ANY_ERR) 1887 * GMR_FS_ANY_ERR (analogous to XMR_FS_ANY_ERR)
2219 */ 1888 */
2220 GMR_FS_ANY_ERR = GMR_FS_CRC_ERR | GMR_FS_LONG_ERR | 1889 GMR_FS_ANY_ERR = GMR_FS_CRC_ERR | GMR_FS_LONG_ERR |
2221 GMR_FS_MII_ERR | GMR_FS_BAD_FC | GMR_FS_GOOD_FC | 1890 GMR_FS_MII_ERR | GMR_FS_BAD_FC | GMR_FS_GOOD_FC |
2222 GMR_FS_JABBER, 1891 GMR_FS_JABBER,
2223/* Rx GMAC FIFO Flush Mask (default) */ 1892/* Rx GMAC FIFO Flush Mask (default) */
2224 RX_FF_FL_DEF_MSK = GMR_FS_CRC_ERR | GMR_FS_RX_FF_OV |GMR_FS_MII_ERR | 1893 RX_FF_FL_DEF_MSK = GMR_FS_CRC_ERR | GMR_FS_RX_FF_OV |GMR_FS_MII_ERR |
2225 GMR_FS_BAD_FC | GMR_FS_GOOD_FC | GMR_FS_UN_SIZE | 1894 GMR_FS_BAD_FC | GMR_FS_GOOD_FC | GMR_FS_UN_SIZE |
2226 GMR_FS_JABBER, 1895 GMR_FS_JABBER,
2227}; 1896};
2228 1897
@@ -2540,10 +2209,6 @@ enum {
2540}; 2209};
2541 2210
2542 2211
2543/* XM_PHY_ADDR 16 bit r/w PHY Address Register */
2544#define XM_PHY_ADDR_SZ 0x1f /* Bit 4..0: PHY Address bits */
2545
2546
2547/* XM_GP_PORT 32 bit r/w General Purpose Port Register */ 2212/* XM_GP_PORT 32 bit r/w General Purpose Port Register */
2548enum { 2213enum {
2549 XM_GP_ANIP = 1<<6, /* Bit 6: (ro) Auto-Neg. in progress */ 2214 XM_GP_ANIP = 1<<6, /* Bit 6: (ro) Auto-Neg. in progress */
@@ -2662,8 +2327,8 @@ enum {
2662}; 2327};
2663 2328
2664#define XM_PAUSE_MODE (XM_MD_SPOE_E | XM_MD_SPOL_I | XM_MD_SPOH_I) 2329#define XM_PAUSE_MODE (XM_MD_SPOE_E | XM_MD_SPOL_I | XM_MD_SPOH_I)
2665#define XM_DEF_MODE (XM_MD_RX_RUNT | XM_MD_RX_IRLE | XM_MD_RX_LONG |\ 2330#define XM_DEF_MODE (XM_MD_RX_RUNT | XM_MD_RX_IRLE | XM_MD_RX_LONG |\
2666 XM_MD_RX_CRCE | XM_MD_RX_ERR | XM_MD_CSA | XM_MD_CAA) 2331 XM_MD_RX_CRCE | XM_MD_RX_ERR | XM_MD_CSA)
2667 2332
2668/* XM_STAT_CMD 16 bit r/w Statistics Command Register */ 2333/* XM_STAT_CMD 16 bit r/w Statistics Command Register */
2669enum { 2334enum {
@@ -2793,41 +2458,26 @@ struct skge_hw {
2793 u32 intr_mask; 2458 u32 intr_mask;
2794 struct net_device *dev[2]; 2459 struct net_device *dev[2];
2795 2460
2796 u8 mac_cfg;
2797 u8 chip_id; 2461 u8 chip_id;
2798 u8 phy_type; 2462 u8 chip_rev;
2799 u8 pmd_type; 2463 u8 copper;
2800 u16 phy_addr; 2464 u8 ports;
2801 2465
2802 u32 ram_size; 2466 u32 ram_size;
2803 u32 ram_offset; 2467 u32 ram_offset;
2804 2468 u16 phy_addr;
2469
2805 struct tasklet_struct ext_tasklet; 2470 struct tasklet_struct ext_tasklet;
2806 spinlock_t phy_lock; 2471 spinlock_t phy_lock;
2807}; 2472};
2808 2473
2809static inline int isdualport(const struct skge_hw *hw)
2810{
2811 return !(hw->mac_cfg & CFG_SNG_MAC);
2812}
2813
2814static inline u8 chip_rev(const struct skge_hw *hw)
2815{
2816 return (hw->mac_cfg & CFG_CHIP_R_MSK) >> 4;
2817}
2818
2819static inline int iscopper(const struct skge_hw *hw)
2820{
2821 return (hw->pmd_type == 'T');
2822}
2823
2824enum { 2474enum {
2825 FLOW_MODE_NONE = 0, /* No Flow-Control */ 2475 FLOW_MODE_NONE = 0, /* No Flow-Control */
2826 FLOW_MODE_LOC_SEND = 1, /* Local station sends PAUSE */ 2476 FLOW_MODE_LOC_SEND = 1, /* Local station sends PAUSE */
2827 FLOW_MODE_REM_SEND = 2, /* Symmetric or just remote */ 2477 FLOW_MODE_REM_SEND = 2, /* Symmetric or just remote */
2828 FLOW_MODE_SYMMETRIC = 3, /* Both stations may send PAUSE */ 2478 FLOW_MODE_SYMMETRIC = 3, /* Both stations may send PAUSE */
2829}; 2479};
2830 2480
2831struct skge_port { 2481struct skge_port {
2832 u32 msg_enable; 2482 u32 msg_enable;
2833 struct skge_hw *hw; 2483 struct skge_hw *hw;
@@ -2853,9 +2503,7 @@ struct skge_port {
2853 void *mem; /* PCI memory for rings */ 2503 void *mem; /* PCI memory for rings */
2854 dma_addr_t dma; 2504 dma_addr_t dma;
2855 unsigned long mem_size; 2505 unsigned long mem_size;
2856 2506 unsigned int rx_buf_size;
2857 struct timer_list link_check;
2858 struct timer_list led_blink;
2859}; 2507};
2860 2508
2861 2509
@@ -2863,7 +2511,6 @@ struct skge_port {
2863static inline u32 skge_read32(const struct skge_hw *hw, int reg) 2511static inline u32 skge_read32(const struct skge_hw *hw, int reg)
2864{ 2512{
2865 return readl(hw->regs + reg); 2513 return readl(hw->regs + reg);
2866
2867} 2514}
2868 2515
2869static inline u16 skge_read16(const struct skge_hw *hw, int reg) 2516static inline u16 skge_read16(const struct skge_hw *hw, int reg)
@@ -2892,114 +2539,76 @@ static inline void skge_write8(const struct skge_hw *hw, int reg, u8 val)
2892} 2539}
2893 2540
2894/* MAC Related Registers inside the device. */ 2541/* MAC Related Registers inside the device. */
2895#define SKGEMAC_REG(port,reg) (((port)<<7)+(reg)) 2542#define SK_REG(port,reg) (((port)<<7)+(reg))
2896 2543#define SK_XMAC_REG(port, reg) \
2897/* PCI config space can be accessed via memory mapped space */
2898#define SKGEPCI_REG(reg) ((reg)+ 0x380)
2899
2900#define SKGEXM_REG(port, reg) \
2901 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1) 2544 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1)
2902 2545
2903static inline u32 skge_xm_read32(const struct skge_hw *hw, int port, int reg) 2546static inline u32 xm_read32(const struct skge_hw *hw, int port, int reg)
2904{
2905 return skge_read32(hw, SKGEXM_REG(port,reg));
2906}
2907
2908static inline u16 skge_xm_read16(const struct skge_hw *hw, int port, int reg)
2909{ 2547{
2910 return skge_read16(hw, SKGEXM_REG(port,reg)); 2548 u32 v;
2549 v = skge_read16(hw, SK_XMAC_REG(port, reg));
2550 v |= (u32)skge_read16(hw, SK_XMAC_REG(port, reg+2)) << 16;
2551 return v;
2911} 2552}
2912 2553
2913static inline u8 skge_xm_read8(const struct skge_hw *hw, int port, int reg) 2554static inline u16 xm_read16(const struct skge_hw *hw, int port, int reg)
2914{ 2555{
2915 return skge_read8(hw, SKGEXM_REG(port,reg)); 2556 return skge_read16(hw, SK_XMAC_REG(port,reg));
2916} 2557}
2917 2558
2918static inline void skge_xm_write32(const struct skge_hw *hw, int port, int r, u32 v) 2559static inline void xm_write32(const struct skge_hw *hw, int port, int r, u32 v)
2919{ 2560{
2920 skge_write32(hw, SKGEXM_REG(port,r), v); 2561 skge_write16(hw, SK_XMAC_REG(port,r), v & 0xffff);
2562 skge_write16(hw, SK_XMAC_REG(port,r+2), v >> 16);
2921} 2563}
2922 2564
2923static inline void skge_xm_write16(const struct skge_hw *hw, int port, int r, u16 v) 2565static inline void xm_write16(const struct skge_hw *hw, int port, int r, u16 v)
2924{ 2566{
2925 skge_write16(hw, SKGEXM_REG(port,r), v); 2567 skge_write16(hw, SK_XMAC_REG(port,r), v);
2926} 2568}
2927 2569
2928static inline void skge_xm_write8(const struct skge_hw *hw, int port, int r, u8 v) 2570static inline void xm_outhash(const struct skge_hw *hw, int port, int reg,
2929{
2930 skge_write8(hw, SKGEXM_REG(port,r), v);
2931}
2932
2933static inline void skge_xm_outhash(const struct skge_hw *hw, int port, int reg,
2934 const u8 *hash) 2571 const u8 *hash)
2935{ 2572{
2936 skge_xm_write16(hw, port, reg, 2573 xm_write16(hw, port, reg, (u16)hash[0] | ((u16)hash[1] << 8));
2937 (u16)hash[0] | ((u16)hash[1] << 8)); 2574 xm_write16(hw, port, reg+2, (u16)hash[2] | ((u16)hash[3] << 8));
2938 skge_xm_write16(hw, port, reg+2, 2575 xm_write16(hw, port, reg+4, (u16)hash[4] | ((u16)hash[5] << 8));
2939 (u16)hash[2] | ((u16)hash[3] << 8)); 2576 xm_write16(hw, port, reg+6, (u16)hash[6] | ((u16)hash[7] << 8));
2940 skge_xm_write16(hw, port, reg+4,
2941 (u16)hash[4] | ((u16)hash[5] << 8));
2942 skge_xm_write16(hw, port, reg+6,
2943 (u16)hash[6] | ((u16)hash[7] << 8));
2944} 2577}
2945 2578
2946static inline void skge_xm_outaddr(const struct skge_hw *hw, int port, int reg, 2579static inline void xm_outaddr(const struct skge_hw *hw, int port, int reg,
2947 const u8 *addr) 2580 const u8 *addr)
2948{ 2581{
2949 skge_xm_write16(hw, port, reg, 2582 xm_write16(hw, port, reg, (u16)addr[0] | ((u16)addr[1] << 8));
2950 (u16)addr[0] | ((u16)addr[1] << 8)); 2583 xm_write16(hw, port, reg+2, (u16)addr[2] | ((u16)addr[3] << 8));
2951 skge_xm_write16(hw, port, reg, 2584 xm_write16(hw, port, reg+4, (u16)addr[4] | ((u16)addr[5] << 8));
2952 (u16)addr[2] | ((u16)addr[3] << 8));
2953 skge_xm_write16(hw, port, reg,
2954 (u16)addr[4] | ((u16)addr[5] << 8));
2955}
2956
2957
2958#define SKGEGMA_REG(port,reg) \
2959 ((reg) + BASE_GMAC_1 + \
2960 (port) * (BASE_GMAC_2-BASE_GMAC_1))
2961
2962static inline u16 skge_gma_read16(const struct skge_hw *hw, int port, int reg)
2963{
2964 return skge_read16(hw, SKGEGMA_REG(port,reg));
2965}
2966
2967static inline u32 skge_gma_read32(const struct skge_hw *hw, int port, int reg)
2968{
2969 return (u32) skge_read16(hw, SKGEGMA_REG(port,reg))
2970 | ((u32)skge_read16(hw, SKGEGMA_REG(port,reg+4)) << 16);
2971} 2585}
2972 2586
2973static inline u8 skge_gma_read8(const struct skge_hw *hw, int port, int reg) 2587#define SK_GMAC_REG(port,reg) \
2974{ 2588 (BASE_GMAC_1 + (port) * (BASE_GMAC_2-BASE_GMAC_1) + (reg))
2975 return skge_read8(hw, SKGEGMA_REG(port,reg));
2976}
2977 2589
2978static inline void skge_gma_write16(const struct skge_hw *hw, int port, int r, u16 v) 2590static inline u16 gma_read16(const struct skge_hw *hw, int port, int reg)
2979{ 2591{
2980 skge_write16(hw, SKGEGMA_REG(port,r), v); 2592 return skge_read16(hw, SK_GMAC_REG(port,reg));
2981} 2593}
2982 2594
2983static inline void skge_gma_write32(const struct skge_hw *hw, int port, int r, u32 v) 2595static inline u32 gma_read32(const struct skge_hw *hw, int port, int reg)
2984{ 2596{
2985 skge_write16(hw, SKGEGMA_REG(port, r), (u16) v); 2597 return (u32) skge_read16(hw, SK_GMAC_REG(port,reg))
2986 skge_write32(hw, SKGEGMA_REG(port, r+4), (u16)(v >> 16)); 2598 | ((u32)skge_read16(hw, SK_GMAC_REG(port,reg+4)) << 16);
2987} 2599}
2988 2600
2989static inline void skge_gma_write8(const struct skge_hw *hw, int port, int r, u8 v) 2601static inline void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
2990{ 2602{
2991 skge_write8(hw, SKGEGMA_REG(port,r), v); 2603 skge_write16(hw, SK_GMAC_REG(port,r), v);
2992} 2604}
2993 2605
2994static inline void skge_gm_set_addr(struct skge_hw *hw, int port, int reg, 2606static inline void gma_set_addr(struct skge_hw *hw, int port, int reg,
2995 const u8 *addr) 2607 const u8 *addr)
2996{ 2608{
2997 skge_gma_write16(hw, port, reg, 2609 gma_write16(hw, port, reg, (u16) addr[0] | ((u16) addr[1] << 8));
2998 (u16) addr[0] | ((u16) addr[1] << 8)); 2610 gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8));
2999 skge_gma_write16(hw, port, reg+4, 2611 gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8));
3000 (u16) addr[2] | ((u16) addr[3] << 8));
3001 skge_gma_write16(hw, port, reg+8,
3002 (u16) addr[4] | ((u16) addr[5] << 8));
3003} 2612}
3004 2613
3005#endif 2614#endif
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 8f7841c0374d..404ea4297e32 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -74,6 +74,7 @@
74#include <linux/rtnetlink.h> 74#include <linux/rtnetlink.h>
75#include <linux/if_arp.h> 75#include <linux/if_arp.h>
76#include <linux/if_slip.h> 76#include <linux/if_slip.h>
77#include <linux/delay.h>
77#include <linux/init.h> 78#include <linux/init.h>
78#include "slip.h" 79#include "slip.h"
79#ifdef CONFIG_INET 80#ifdef CONFIG_INET
@@ -198,18 +199,12 @@ err_exit:
198static void 199static void
199sl_free_bufs(struct slip *sl) 200sl_free_bufs(struct slip *sl)
200{ 201{
201 void * tmp;
202
203 /* Free all SLIP frame buffers. */ 202 /* Free all SLIP frame buffers. */
204 tmp = xchg(&sl->rbuff, NULL); 203 kfree(xchg(&sl->rbuff, NULL));
205 kfree(tmp); 204 kfree(xchg(&sl->xbuff, NULL));
206 tmp = xchg(&sl->xbuff, NULL);
207 kfree(tmp);
208#ifdef SL_INCLUDE_CSLIP 205#ifdef SL_INCLUDE_CSLIP
209 tmp = xchg(&sl->cbuff, NULL); 206 kfree(xchg(&sl->cbuff, NULL));
210 kfree(tmp); 207 slhc_free(xchg(&sl->slcomp, NULL));
211 if ((tmp = xchg(&sl->slcomp, NULL)) != NULL)
212 slhc_free(tmp);
213#endif 208#endif
214} 209}
215 210
@@ -1389,10 +1384,8 @@ static void __exit slip_exit(void)
1389 /* First of all: check for active disciplines and hangup them. 1384 /* First of all: check for active disciplines and hangup them.
1390 */ 1385 */
1391 do { 1386 do {
1392 if (busy) { 1387 if (busy)
1393 set_current_state(TASK_INTERRUPTIBLE); 1388 msleep_interruptible(100);
1394 schedule_timeout(HZ / 10);
1395 }
1396 1389
1397 busy = 0; 1390 busy = 0;
1398 for (i = 0; i < slip_maxdev; i++) { 1391 for (i = 0; i < slip_maxdev; i++) {
@@ -1430,7 +1423,7 @@ static void __exit slip_exit(void)
1430 kfree(slip_devs); 1423 kfree(slip_devs);
1431 slip_devs = NULL; 1424 slip_devs = NULL;
1432 1425
1433 if ((i = tty_register_ldisc(N_SLIP, NULL))) 1426 if ((i = tty_unregister_ldisc(N_SLIP)))
1434 { 1427 {
1435 printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i); 1428 printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i);
1436 } 1429 }
diff --git a/drivers/net/smc-mca.c b/drivers/net/smc-mca.c
index 990201f42ba0..f00c476064f0 100644
--- a/drivers/net/smc-mca.c
+++ b/drivers/net/smc-mca.c
@@ -49,7 +49,6 @@
49#include <asm/system.h> 49#include <asm/system.h>
50 50
51#include "8390.h" 51#include "8390.h"
52#include "smc-mca.h"
53 52
54#define DRV_NAME "smc-mca" 53#define DRV_NAME "smc-mca"
55 54
@@ -100,6 +99,63 @@ module_param_array(ultra_irq, int, NULL, 0);
100MODULE_PARM_DESC(ultra_io, "SMC Ultra/EtherEZ MCA I/O base address(es)"); 99MODULE_PARM_DESC(ultra_io, "SMC Ultra/EtherEZ MCA I/O base address(es)");
101MODULE_PARM_DESC(ultra_irq, "SMC Ultra/EtherEZ MCA IRQ number(s)"); 100MODULE_PARM_DESC(ultra_irq, "SMC Ultra/EtherEZ MCA IRQ number(s)");
102 101
102static const struct {
103 unsigned int base_addr;
104} addr_table[] = {
105 { 0x0800 },
106 { 0x1800 },
107 { 0x2800 },
108 { 0x3800 },
109 { 0x4800 },
110 { 0x5800 },
111 { 0x6800 },
112 { 0x7800 },
113 { 0x8800 },
114 { 0x9800 },
115 { 0xa800 },
116 { 0xb800 },
117 { 0xc800 },
118 { 0xd800 },
119 { 0xe800 },
120 { 0xf800 }
121};
122
123#define MEM_MASK 64
124
125static const struct {
126 unsigned char mem_index;
127 unsigned long mem_start;
128 unsigned char num_pages;
129} mem_table[] = {
130 { 16, 0x0c0000, 40 },
131 { 18, 0x0c4000, 40 },
132 { 20, 0x0c8000, 40 },
133 { 22, 0x0cc000, 40 },
134 { 24, 0x0d0000, 40 },
135 { 26, 0x0d4000, 40 },
136 { 28, 0x0d8000, 40 },
137 { 30, 0x0dc000, 40 },
138 {144, 0xfc0000, 40 },
139 {148, 0xfc8000, 40 },
140 {154, 0xfd0000, 40 },
141 {156, 0xfd8000, 40 },
142 { 0, 0x0c0000, 20 },
143 { 1, 0x0c2000, 20 },
144 { 2, 0x0c4000, 20 },
145 { 3, 0x0c6000, 20 }
146};
147
148#define IRQ_MASK 243
149static const struct {
150 unsigned char new_irq;
151 unsigned char old_irq;
152} irq_table[] = {
153 { 3, 3 },
154 { 4, 4 },
155 { 10, 10 },
156 { 14, 15 }
157};
158
103static short smc_mca_adapter_ids[] __initdata = { 159static short smc_mca_adapter_ids[] __initdata = {
104 0x61c8, 160 0x61c8,
105 0x61c9, 161 0x61c9,
@@ -126,7 +182,7 @@ static char *smc_mca_adapter_names[] __initdata = {
126 182
127static int ultra_found = 0; 183static int ultra_found = 0;
128 184
129int __init ultramca_probe(struct device *gen_dev) 185static int __init ultramca_probe(struct device *gen_dev)
130{ 186{
131 unsigned short ioaddr; 187 unsigned short ioaddr;
132 struct net_device *dev; 188 struct net_device *dev;
diff --git a/drivers/net/smc-mca.h b/drivers/net/smc-mca.h
deleted file mode 100644
index ac50117a7e84..000000000000
--- a/drivers/net/smc-mca.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * djweis weisd3458@uni.edu
3 * most of this file was taken from ps2esdi.h
4 */
5
6struct {
7 unsigned int base_addr;
8} addr_table[] = {
9 { 0x0800 },
10 { 0x1800 },
11 { 0x2800 },
12 { 0x3800 },
13 { 0x4800 },
14 { 0x5800 },
15 { 0x6800 },
16 { 0x7800 },
17 { 0x8800 },
18 { 0x9800 },
19 { 0xa800 },
20 { 0xb800 },
21 { 0xc800 },
22 { 0xd800 },
23 { 0xe800 },
24 { 0xf800 }
25};
26
27#define MEM_MASK 64
28
29struct {
30 unsigned char mem_index;
31 unsigned long mem_start;
32 unsigned char num_pages;
33} mem_table[] = {
34 { 16, 0x0c0000, 40 },
35 { 18, 0x0c4000, 40 },
36 { 20, 0x0c8000, 40 },
37 { 22, 0x0cc000, 40 },
38 { 24, 0x0d0000, 40 },
39 { 26, 0x0d4000, 40 },
40 { 28, 0x0d8000, 40 },
41 { 30, 0x0dc000, 40 },
42 {144, 0xfc0000, 40 },
43 {148, 0xfc8000, 40 },
44 {154, 0xfd0000, 40 },
45 {156, 0xfd8000, 40 },
46 { 0, 0x0c0000, 20 },
47 { 1, 0x0c2000, 20 },
48 { 2, 0x0c4000, 20 },
49 { 3, 0x0c6000, 20 }
50};
51
52#define IRQ_MASK 243
53struct {
54 unsigned char new_irq;
55 unsigned char old_irq;
56} irq_table[] = {
57 { 3, 3 },
58 { 4, 4 },
59 { 10, 10 },
60 { 14, 15 }
61};
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index b564c677c6d2..ba8593ac3f8a 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -68,6 +68,7 @@ static const char version[] =
68#include <linux/etherdevice.h> 68#include <linux/etherdevice.h>
69 69
70#include <asm/io.h> 70#include <asm/io.h>
71#include <asm/irq.h>
71#include <asm/system.h> 72#include <asm/system.h>
72 73
73#include "8390.h" 74#include "8390.h"
@@ -194,12 +195,7 @@ struct net_device * __init ultra_probe(int unit)
194 err = do_ultra_probe(dev); 195 err = do_ultra_probe(dev);
195 if (err) 196 if (err)
196 goto out; 197 goto out;
197 err = register_netdev(dev);
198 if (err)
199 goto out1;
200 return dev; 198 return dev;
201out1:
202 cleanup_card(dev);
203out: 199out:
204 free_netdev(dev); 200 free_netdev(dev);
205 return ERR_PTR(err); 201 return ERR_PTR(err);
@@ -325,6 +321,9 @@ static int __init ultra_probe1(struct net_device *dev, int ioaddr)
325#endif 321#endif
326 NS8390_init(dev, 0); 322 NS8390_init(dev, 0);
327 323
324 retval = register_netdev(dev);
325 if (retval)
326 goto out;
328 return 0; 327 return 0;
329out: 328out:
330 release_region(ioaddr, ULTRA_IO_EXTENT); 329 release_region(ioaddr, ULTRA_IO_EXTENT);
@@ -583,11 +582,8 @@ init_module(void)
583 dev->irq = irq[this_dev]; 582 dev->irq = irq[this_dev];
584 dev->base_addr = io[this_dev]; 583 dev->base_addr = io[this_dev];
585 if (do_ultra_probe(dev) == 0) { 584 if (do_ultra_probe(dev) == 0) {
586 if (register_netdev(dev) == 0) { 585 dev_ultra[found++] = dev;
587 dev_ultra[found++] = dev; 586 continue;
588 continue;
589 }
590 cleanup_card(dev);
591 } 587 }
592 free_netdev(dev); 588 free_netdev(dev);
593 printk(KERN_WARNING "smc-ultra.c: No SMC Ultra card found (i/o = 0x%x).\n", io[this_dev]); 589 printk(KERN_WARNING "smc-ultra.c: No SMC Ultra card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index fd80048f7f7a..1438fdd20826 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -315,15 +315,25 @@ static void smc_reset(struct net_device *dev)
315 struct smc_local *lp = netdev_priv(dev); 315 struct smc_local *lp = netdev_priv(dev);
316 void __iomem *ioaddr = lp->base; 316 void __iomem *ioaddr = lp->base;
317 unsigned int ctl, cfg; 317 unsigned int ctl, cfg;
318 struct sk_buff *pending_skb;
318 319
319 DBG(2, "%s: %s\n", dev->name, __FUNCTION__); 320 DBG(2, "%s: %s\n", dev->name, __FUNCTION__);
320 321
321 /* Disable all interrupts */ 322 /* Disable all interrupts, block TX tasklet */
322 spin_lock(&lp->lock); 323 spin_lock(&lp->lock);
323 SMC_SELECT_BANK(2); 324 SMC_SELECT_BANK(2);
324 SMC_SET_INT_MASK(0); 325 SMC_SET_INT_MASK(0);
326 pending_skb = lp->pending_tx_skb;
327 lp->pending_tx_skb = NULL;
325 spin_unlock(&lp->lock); 328 spin_unlock(&lp->lock);
326 329
330 /* free any pending tx skb */
331 if (pending_skb) {
332 dev_kfree_skb(pending_skb);
333 lp->stats.tx_errors++;
334 lp->stats.tx_aborted_errors++;
335 }
336
327 /* 337 /*
328 * This resets the registers mostly to defaults, but doesn't 338 * This resets the registers mostly to defaults, but doesn't
329 * affect EEPROM. That seems unnecessary 339 * affect EEPROM. That seems unnecessary
@@ -389,14 +399,6 @@ static void smc_reset(struct net_device *dev)
389 SMC_SELECT_BANK(2); 399 SMC_SELECT_BANK(2);
390 SMC_SET_MMU_CMD(MC_RESET); 400 SMC_SET_MMU_CMD(MC_RESET);
391 SMC_WAIT_MMU_BUSY(); 401 SMC_WAIT_MMU_BUSY();
392
393 /* clear anything saved */
394 if (lp->pending_tx_skb != NULL) {
395 dev_kfree_skb (lp->pending_tx_skb);
396 lp->pending_tx_skb = NULL;
397 lp->stats.tx_errors++;
398 lp->stats.tx_aborted_errors++;
399 }
400} 402}
401 403
402/* 404/*
@@ -440,6 +442,7 @@ static void smc_shutdown(struct net_device *dev)
440{ 442{
441 struct smc_local *lp = netdev_priv(dev); 443 struct smc_local *lp = netdev_priv(dev);
442 void __iomem *ioaddr = lp->base; 444 void __iomem *ioaddr = lp->base;
445 struct sk_buff *pending_skb;
443 446
444 DBG(2, "%s: %s\n", CARDNAME, __FUNCTION__); 447 DBG(2, "%s: %s\n", CARDNAME, __FUNCTION__);
445 448
@@ -447,7 +450,11 @@ static void smc_shutdown(struct net_device *dev)
447 spin_lock(&lp->lock); 450 spin_lock(&lp->lock);
448 SMC_SELECT_BANK(2); 451 SMC_SELECT_BANK(2);
449 SMC_SET_INT_MASK(0); 452 SMC_SET_INT_MASK(0);
453 pending_skb = lp->pending_tx_skb;
454 lp->pending_tx_skb = NULL;
450 spin_unlock(&lp->lock); 455 spin_unlock(&lp->lock);
456 if (pending_skb)
457 dev_kfree_skb(pending_skb);
451 458
452 /* and tell the card to stay away from that nasty outside world */ 459 /* and tell the card to stay away from that nasty outside world */
453 SMC_SELECT_BANK(0); 460 SMC_SELECT_BANK(0);
@@ -627,7 +634,12 @@ static void smc_hardware_send_pkt(unsigned long data)
627 } 634 }
628 635
629 skb = lp->pending_tx_skb; 636 skb = lp->pending_tx_skb;
637 if (unlikely(!skb)) {
638 smc_special_unlock(&lp->lock);
639 return;
640 }
630 lp->pending_tx_skb = NULL; 641 lp->pending_tx_skb = NULL;
642
631 packet_no = SMC_GET_AR(); 643 packet_no = SMC_GET_AR();
632 if (unlikely(packet_no & AR_FAILED)) { 644 if (unlikely(packet_no & AR_FAILED)) {
633 printk("%s: Memory allocation failed.\n", dev->name); 645 printk("%s: Memory allocation failed.\n", dev->name);
@@ -702,7 +714,6 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
702 DBG(3, "%s: %s\n", dev->name, __FUNCTION__); 714 DBG(3, "%s: %s\n", dev->name, __FUNCTION__);
703 715
704 BUG_ON(lp->pending_tx_skb != NULL); 716 BUG_ON(lp->pending_tx_skb != NULL);
705 lp->pending_tx_skb = skb;
706 717
707 /* 718 /*
708 * The MMU wants the number of pages to be the number of 256 bytes 719 * The MMU wants the number of pages to be the number of 256 bytes
@@ -718,7 +729,6 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
718 numPages = ((skb->len & ~1) + (6 - 1)) >> 8; 729 numPages = ((skb->len & ~1) + (6 - 1)) >> 8;
719 if (unlikely(numPages > 7)) { 730 if (unlikely(numPages > 7)) {
720 printk("%s: Far too big packet error.\n", dev->name); 731 printk("%s: Far too big packet error.\n", dev->name);
721 lp->pending_tx_skb = NULL;
722 lp->stats.tx_errors++; 732 lp->stats.tx_errors++;
723 lp->stats.tx_dropped++; 733 lp->stats.tx_dropped++;
724 dev_kfree_skb(skb); 734 dev_kfree_skb(skb);
@@ -745,6 +755,7 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
745 755
746 smc_special_unlock(&lp->lock); 756 smc_special_unlock(&lp->lock);
747 757
758 lp->pending_tx_skb = skb;
748 if (!poll_count) { 759 if (!poll_count) {
749 /* oh well, wait until the chip finds memory later */ 760 /* oh well, wait until the chip finds memory later */
750 netif_stop_queue(dev); 761 netif_stop_queue(dev);
@@ -1062,7 +1073,7 @@ static void smc_phy_powerdown(struct net_device *dev)
1062 above). linkwatch_event() also wants the netlink semaphore. 1073 above). linkwatch_event() also wants the netlink semaphore.
1063 */ 1074 */
1064 while(lp->work_pending) 1075 while(lp->work_pending)
1065 schedule(); 1076 yield();
1066 1077
1067 bmcr = smc_phy_read(dev, phy, MII_BMCR); 1078 bmcr = smc_phy_read(dev, phy, MII_BMCR);
1068 smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN); 1079 smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN);
@@ -1606,14 +1617,8 @@ static int smc_close(struct net_device *dev)
1606 1617
1607 /* clear everything */ 1618 /* clear everything */
1608 smc_shutdown(dev); 1619 smc_shutdown(dev);
1609 1620 tasklet_kill(&lp->tx_task);
1610 smc_phy_powerdown(dev); 1621 smc_phy_powerdown(dev);
1611
1612 if (lp->pending_tx_skb) {
1613 dev_kfree_skb(lp->pending_tx_skb);
1614 lp->pending_tx_skb = NULL;
1615 }
1616
1617 return 0; 1622 return 0;
1618} 1623}
1619 1624
@@ -1993,7 +1998,7 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr)
1993 if (retval) 1998 if (retval)
1994 goto err_out; 1999 goto err_out;
1995 2000
1996 set_irq_type(dev->irq, IRQT_RISING); 2001 set_irq_type(dev->irq, SMC_IRQ_TRIGGER_TYPE);
1997 2002
1998#ifdef SMC_USE_PXA_DMA 2003#ifdef SMC_USE_PXA_DMA
1999 { 2004 {
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 946528e6b742..a9b06b8d8e3f 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -182,6 +182,16 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
182#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) 182#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
183#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) 183#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
184 184
185#include <asm/mach-types.h>
186#include <asm/arch/cpu.h>
187
188#define SMC_IRQ_TRIGGER_TYPE (( \
189 machine_is_omap_h2() \
190 || machine_is_omap_h3() \
191 || (machine_is_omap_innovator() && !cpu_is_omap1510()) \
192 ) ? IRQT_FALLING : IRQT_RISING)
193
194
185#elif defined(CONFIG_SH_SH4202_MICRODEV) 195#elif defined(CONFIG_SH_SH4202_MICRODEV)
186 196
187#define SMC_CAN_USE_8BIT 0 197#define SMC_CAN_USE_8BIT 0
@@ -300,6 +310,9 @@ static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
300 310
301#endif 311#endif
302 312
313#ifndef SMC_IRQ_TRIGGER_TYPE
314#define SMC_IRQ_TRIGGER_TYPE IRQT_RISING
315#endif
303 316
304#ifdef SMC_USE_PXA_DMA 317#ifdef SMC_USE_PXA_DMA
305/* 318/*
diff --git a/drivers/net/sonic.c b/drivers/net/sonic.c
index cdc9cc873e06..90b818a8de6e 100644
--- a/drivers/net/sonic.c
+++ b/drivers/net/sonic.c
@@ -1,6 +1,11 @@
1/* 1/*
2 * sonic.c 2 * sonic.c
3 * 3 *
4 * (C) 2005 Finn Thain
5 *
6 * Converted to DMA API, added zero-copy buffer handling, and
7 * (from the mac68k project) introduced dhd's support for 16-bit cards.
8 *
4 * (C) 1996,1998 by Thomas Bogendoerfer (tsbogend@alpha.franken.de) 9 * (C) 1996,1998 by Thomas Bogendoerfer (tsbogend@alpha.franken.de)
5 * 10 *
6 * This driver is based on work from Andreas Busse, but most of 11 * This driver is based on work from Andreas Busse, but most of
@@ -9,12 +14,23 @@
9 * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de) 14 * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
10 * 15 *
11 * Core code included by system sonic drivers 16 * Core code included by system sonic drivers
17 *
18 * And... partially rewritten again by David Huggins-Daines in order
19 * to cope with screwed up Macintosh NICs that may or may not use
20 * 16-bit DMA.
21 *
22 * (C) 1999 David Huggins-Daines <dhd@debian.org>
23 *
12 */ 24 */
13 25
14/* 26/*
15 * Sources: Olivetti M700-10 Risc Personal Computer hardware handbook, 27 * Sources: Olivetti M700-10 Risc Personal Computer hardware handbook,
16 * National Semiconductors data sheet for the DP83932B Sonic Ethernet 28 * National Semiconductors data sheet for the DP83932B Sonic Ethernet
17 * controller, and the files "8390.c" and "skeleton.c" in this directory. 29 * controller, and the files "8390.c" and "skeleton.c" in this directory.
30 *
31 * Additional sources: Nat Semi data sheet for the DP83932C and Nat Semi
32 * Application Note AN-746, the files "lance.c" and "ibmlana.c". See also
33 * the NetBSD file "sys/arch/mac68k/dev/if_sn.c".
18 */ 34 */
19 35
20 36
@@ -28,6 +44,9 @@
28 */ 44 */
29static int sonic_open(struct net_device *dev) 45static int sonic_open(struct net_device *dev)
30{ 46{
47 struct sonic_local *lp = netdev_priv(dev);
48 int i;
49
31 if (sonic_debug > 2) 50 if (sonic_debug > 2)
32 printk("sonic_open: initializing sonic driver.\n"); 51 printk("sonic_open: initializing sonic driver.\n");
33 52
@@ -40,14 +59,59 @@ static int sonic_open(struct net_device *dev)
40 * This means that during execution of the handler interrupt are disabled 59 * This means that during execution of the handler interrupt are disabled
41 * covering another bug otherwise corrupting data. This doesn't mean 60 * covering another bug otherwise corrupting data. This doesn't mean
42 * this glue works ok under all situations. 61 * this glue works ok under all situations.
62 *
63 * Note (dhd): this also appears to prevent lockups on the Macintrash
64 * when more than one Ethernet card is installed (knock on wood)
65 *
66 * Note (fthain): whether the above is still true is anyones guess. Certainly
67 * the buffer handling algorithms will not tolerate re-entrance without some
68 * mutual exclusion added. Anyway, the memcpy has now been eliminated from the
69 * rx code to make this a faster "fast interrupt".
43 */ 70 */
44// if (sonic_request_irq(dev->irq, &sonic_interrupt, 0, "sonic", dev)) { 71 if (request_irq(dev->irq, &sonic_interrupt, SONIC_IRQ_FLAG, "sonic", dev)) {
45 if (sonic_request_irq(dev->irq, &sonic_interrupt, SA_INTERRUPT, 72 printk(KERN_ERR "\n%s: unable to get IRQ %d .\n", dev->name, dev->irq);
46 "sonic", dev)) {
47 printk("\n%s: unable to get IRQ %d .\n", dev->name, dev->irq);
48 return -EAGAIN; 73 return -EAGAIN;
49 } 74 }
50 75
76 for (i = 0; i < SONIC_NUM_RRS; i++) {
77 struct sk_buff *skb = dev_alloc_skb(SONIC_RBSIZE + 2);
78 if (skb == NULL) {
79 while(i > 0) { /* free any that were allocated successfully */
80 i--;
81 dev_kfree_skb(lp->rx_skb[i]);
82 lp->rx_skb[i] = NULL;
83 }
84 printk(KERN_ERR "%s: couldn't allocate receive buffers\n",
85 dev->name);
86 return -ENOMEM;
87 }
88 skb->dev = dev;
89 /* align IP header unless DMA requires otherwise */
90 if (SONIC_BUS_SCALE(lp->dma_bitmode) == 2)
91 skb_reserve(skb, 2);
92 lp->rx_skb[i] = skb;
93 }
94
95 for (i = 0; i < SONIC_NUM_RRS; i++) {
96 dma_addr_t laddr = dma_map_single(lp->device, skb_put(lp->rx_skb[i], SONIC_RBSIZE),
97 SONIC_RBSIZE, DMA_FROM_DEVICE);
98 if (!laddr) {
99 while(i > 0) { /* free any that were mapped successfully */
100 i--;
101 dma_unmap_single(lp->device, lp->rx_laddr[i], SONIC_RBSIZE, DMA_FROM_DEVICE);
102 lp->rx_laddr[i] = (dma_addr_t)0;
103 }
104 for (i = 0; i < SONIC_NUM_RRS; i++) {
105 dev_kfree_skb(lp->rx_skb[i]);
106 lp->rx_skb[i] = NULL;
107 }
108 printk(KERN_ERR "%s: couldn't map rx DMA buffers\n",
109 dev->name);
110 return -ENOMEM;
111 }
112 lp->rx_laddr[i] = laddr;
113 }
114
51 /* 115 /*
52 * Initialize the SONIC 116 * Initialize the SONIC
53 */ 117 */
@@ -67,7 +131,8 @@ static int sonic_open(struct net_device *dev)
67 */ 131 */
68static int sonic_close(struct net_device *dev) 132static int sonic_close(struct net_device *dev)
69{ 133{
70 unsigned int base_addr = dev->base_addr; 134 struct sonic_local *lp = netdev_priv(dev);
135 int i;
71 136
72 if (sonic_debug > 2) 137 if (sonic_debug > 2)
73 printk("sonic_close\n"); 138 printk("sonic_close\n");
@@ -77,20 +142,56 @@ static int sonic_close(struct net_device *dev)
77 /* 142 /*
78 * stop the SONIC, disable interrupts 143 * stop the SONIC, disable interrupts
79 */ 144 */
80 SONIC_WRITE(SONIC_ISR, 0x7fff);
81 SONIC_WRITE(SONIC_IMR, 0); 145 SONIC_WRITE(SONIC_IMR, 0);
146 SONIC_WRITE(SONIC_ISR, 0x7fff);
82 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST); 147 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
83 148
84 sonic_free_irq(dev->irq, dev); /* release the IRQ */ 149 /* unmap and free skbs that haven't been transmitted */
150 for (i = 0; i < SONIC_NUM_TDS; i++) {
151 if(lp->tx_laddr[i]) {
152 dma_unmap_single(lp->device, lp->tx_laddr[i], lp->tx_len[i], DMA_TO_DEVICE);
153 lp->tx_laddr[i] = (dma_addr_t)0;
154 }
155 if(lp->tx_skb[i]) {
156 dev_kfree_skb(lp->tx_skb[i]);
157 lp->tx_skb[i] = NULL;
158 }
159 }
160
161 /* unmap and free the receive buffers */
162 for (i = 0; i < SONIC_NUM_RRS; i++) {
163 if(lp->rx_laddr[i]) {
164 dma_unmap_single(lp->device, lp->rx_laddr[i], SONIC_RBSIZE, DMA_FROM_DEVICE);
165 lp->rx_laddr[i] = (dma_addr_t)0;
166 }
167 if(lp->rx_skb[i]) {
168 dev_kfree_skb(lp->rx_skb[i]);
169 lp->rx_skb[i] = NULL;
170 }
171 }
172
173 free_irq(dev->irq, dev); /* release the IRQ */
85 174
86 return 0; 175 return 0;
87} 176}
88 177
89static void sonic_tx_timeout(struct net_device *dev) 178static void sonic_tx_timeout(struct net_device *dev)
90{ 179{
91 struct sonic_local *lp = (struct sonic_local *) dev->priv; 180 struct sonic_local *lp = netdev_priv(dev);
92 printk("%s: transmit timed out.\n", dev->name); 181 int i;
93 182 /* Stop the interrupts for this */
183 SONIC_WRITE(SONIC_IMR, 0);
184 /* We could resend the original skbs. Easier to re-initialise. */
185 for (i = 0; i < SONIC_NUM_TDS; i++) {
186 if(lp->tx_laddr[i]) {
187 dma_unmap_single(lp->device, lp->tx_laddr[i], lp->tx_len[i], DMA_TO_DEVICE);
188 lp->tx_laddr[i] = (dma_addr_t)0;
189 }
190 if(lp->tx_skb[i]) {
191 dev_kfree_skb(lp->tx_skb[i]);
192 lp->tx_skb[i] = NULL;
193 }
194 }
94 /* Try to restart the adaptor. */ 195 /* Try to restart the adaptor. */
95 sonic_init(dev); 196 sonic_init(dev);
96 lp->stats.tx_errors++; 197 lp->stats.tx_errors++;
@@ -100,60 +201,92 @@ static void sonic_tx_timeout(struct net_device *dev)
100 201
101/* 202/*
102 * transmit packet 203 * transmit packet
204 *
205 * Appends new TD during transmission thus avoiding any TX interrupts
206 * until we run out of TDs.
207 * This routine interacts closely with the ISR in that it may,
208 * set tx_skb[i]
209 * reset the status flags of the new TD
210 * set and reset EOL flags
211 * stop the tx queue
212 * The ISR interacts with this routine in various ways. It may,
213 * reset tx_skb[i]
214 * test the EOL and status flags of the TDs
215 * wake the tx queue
216 * Concurrently with all of this, the SONIC is potentially writing to
217 * the status flags of the TDs.
218 * Until some mutual exclusion is added, this code will not work with SMP. However,
219 * MIPS Jazz machines and m68k Macs were all uni-processor machines.
103 */ 220 */
221
104static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) 222static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
105{ 223{
106 struct sonic_local *lp = (struct sonic_local *) dev->priv; 224 struct sonic_local *lp = netdev_priv(dev);
107 unsigned int base_addr = dev->base_addr; 225 dma_addr_t laddr;
108 unsigned int laddr; 226 int length;
109 int entry, length; 227 int entry = lp->next_tx;
110
111 netif_stop_queue(dev);
112 228
113 if (sonic_debug > 2) 229 if (sonic_debug > 2)
114 printk("sonic_send_packet: skb=%p, dev=%p\n", skb, dev); 230 printk("sonic_send_packet: skb=%p, dev=%p\n", skb, dev);
115 231
232 length = skb->len;
233 if (length < ETH_ZLEN) {
234 skb = skb_padto(skb, ETH_ZLEN);
235 if (skb == NULL)
236 return 0;
237 length = ETH_ZLEN;
238 }
239
116 /* 240 /*
117 * Map the packet data into the logical DMA address space 241 * Map the packet data into the logical DMA address space
118 */ 242 */
119 if ((laddr = vdma_alloc(CPHYSADDR(skb->data), skb->len)) == ~0UL) { 243
120 printk("%s: no VDMA entry for transmit available.\n", 244 laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE);
121 dev->name); 245 if (!laddr) {
246 printk(KERN_ERR "%s: failed to map tx DMA buffer.\n", dev->name);
122 dev_kfree_skb(skb); 247 dev_kfree_skb(skb);
123 netif_start_queue(dev);
124 return 1; 248 return 1;
125 } 249 }
126 entry = lp->cur_tx & SONIC_TDS_MASK; 250
251 sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
252 sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */
253 sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
254 sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
255 sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
256 sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
257 sonic_tda_put(dev, entry, SONIC_TD_LINK,
258 sonic_tda_get(dev, entry, SONIC_TD_LINK) | SONIC_EOL);
259
260 /*
261 * Must set tx_skb[entry] only after clearing status, and
262 * before clearing EOL and before stopping queue
263 */
264 wmb();
265 lp->tx_len[entry] = length;
127 lp->tx_laddr[entry] = laddr; 266 lp->tx_laddr[entry] = laddr;
128 lp->tx_skb[entry] = skb; 267 lp->tx_skb[entry] = skb;
129 268
130 length = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; 269 wmb();
131 flush_cache_all(); 270 sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK,
271 sonic_tda_get(dev, lp->eol_tx, SONIC_TD_LINK) & ~SONIC_EOL);
272 lp->eol_tx = entry;
132 273
133 /* 274 lp->next_tx = (entry + 1) & SONIC_TDS_MASK;
134 * Setup the transmit descriptor and issue the transmit command. 275 if (lp->tx_skb[lp->next_tx] != NULL) {
135 */ 276 /* The ring is full, the ISR has yet to process the next TD. */
136 lp->tda[entry].tx_status = 0; /* clear status */ 277 if (sonic_debug > 3)
137 lp->tda[entry].tx_frag_count = 1; /* single fragment */ 278 printk("%s: stopping queue\n", dev->name);
138 lp->tda[entry].tx_pktsize = length; /* length of packet */ 279 netif_stop_queue(dev);
139 lp->tda[entry].tx_frag_ptr_l = laddr & 0xffff; 280 /* after this packet, wait for ISR to free up some TDAs */
140 lp->tda[entry].tx_frag_ptr_h = laddr >> 16; 281 } else netif_start_queue(dev);
141 lp->tda[entry].tx_frag_size = length;
142 lp->cur_tx++;
143 lp->stats.tx_bytes += length;
144 282
145 if (sonic_debug > 2) 283 if (sonic_debug > 2)
146 printk("sonic_send_packet: issueing Tx command\n"); 284 printk("sonic_send_packet: issuing Tx command\n");
147 285
148 SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP); 286 SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
149 287
150 dev->trans_start = jiffies; 288 dev->trans_start = jiffies;
151 289
152 if (lp->cur_tx < lp->dirty_tx + SONIC_NUM_TDS)
153 netif_start_queue(dev);
154 else
155 lp->tx_full = 1;
156
157 return 0; 290 return 0;
158} 291}
159 292
@@ -164,175 +297,199 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
164static irqreturn_t sonic_interrupt(int irq, void *dev_id, struct pt_regs *regs) 297static irqreturn_t sonic_interrupt(int irq, void *dev_id, struct pt_regs *regs)
165{ 298{
166 struct net_device *dev = (struct net_device *) dev_id; 299 struct net_device *dev = (struct net_device *) dev_id;
167 unsigned int base_addr = dev->base_addr; 300 struct sonic_local *lp = netdev_priv(dev);
168 struct sonic_local *lp;
169 int status; 301 int status;
170 302
171 if (dev == NULL) { 303 if (dev == NULL) {
172 printk("sonic_interrupt: irq %d for unknown device.\n", irq); 304 printk(KERN_ERR "sonic_interrupt: irq %d for unknown device.\n", irq);
173 return IRQ_NONE; 305 return IRQ_NONE;
174 } 306 }
175 307
176 lp = (struct sonic_local *) dev->priv; 308 if (!(status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT))
177 309 return IRQ_NONE;
178 status = SONIC_READ(SONIC_ISR);
179 SONIC_WRITE(SONIC_ISR, 0x7fff); /* clear all bits */
180
181 if (sonic_debug > 2)
182 printk("sonic_interrupt: ISR=%x\n", status);
183
184 if (status & SONIC_INT_PKTRX) {
185 sonic_rx(dev); /* got packet(s) */
186 }
187
188 if (status & SONIC_INT_TXDN) {
189 int dirty_tx = lp->dirty_tx;
190
191 while (dirty_tx < lp->cur_tx) {
192 int entry = dirty_tx & SONIC_TDS_MASK;
193 int status = lp->tda[entry].tx_status;
194 310
195 if (sonic_debug > 3) 311 do {
196 printk 312 if (status & SONIC_INT_PKTRX) {
197 ("sonic_interrupt: status %d, cur_tx %d, dirty_tx %d\n", 313 if (sonic_debug > 2)
198 status, lp->cur_tx, lp->dirty_tx); 314 printk("%s: packet rx\n", dev->name);
315 sonic_rx(dev); /* got packet(s) */
316 SONIC_WRITE(SONIC_ISR, SONIC_INT_PKTRX); /* clear the interrupt */
317 }
199 318
200 if (status == 0) { 319 if (status & SONIC_INT_TXDN) {
201 /* It still hasn't been Txed, kick the sonic again */ 320 int entry = lp->cur_tx;
202 SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP); 321 int td_status;
203 break; 322 int freed_some = 0;
204 }
205 323
206 /* put back EOL and free descriptor */ 324 /* At this point, cur_tx is the index of a TD that is one of:
207 lp->tda[entry].tx_frag_count = 0; 325 * unallocated/freed (status set & tx_skb[entry] clear)
208 lp->tda[entry].tx_status = 0; 326 * allocated and sent (status set & tx_skb[entry] set )
209 327 * allocated and not yet sent (status clear & tx_skb[entry] set )
210 if (status & 0x0001) 328 * still being allocated by sonic_send_packet (status clear & tx_skb[entry] clear)
211 lp->stats.tx_packets++; 329 */
212 else {
213 lp->stats.tx_errors++;
214 if (status & 0x0642)
215 lp->stats.tx_aborted_errors++;
216 if (status & 0x0180)
217 lp->stats.tx_carrier_errors++;
218 if (status & 0x0020)
219 lp->stats.tx_window_errors++;
220 if (status & 0x0004)
221 lp->stats.tx_fifo_errors++;
222 }
223 330
224 /* We must free the original skb */ 331 if (sonic_debug > 2)
225 if (lp->tx_skb[entry]) { 332 printk("%s: tx done\n", dev->name);
333
334 while (lp->tx_skb[entry] != NULL) {
335 if ((td_status = sonic_tda_get(dev, entry, SONIC_TD_STATUS)) == 0)
336 break;
337
338 if (td_status & 0x0001) {
339 lp->stats.tx_packets++;
340 lp->stats.tx_bytes += sonic_tda_get(dev, entry, SONIC_TD_PKTSIZE);
341 } else {
342 lp->stats.tx_errors++;
343 if (td_status & 0x0642)
344 lp->stats.tx_aborted_errors++;
345 if (td_status & 0x0180)
346 lp->stats.tx_carrier_errors++;
347 if (td_status & 0x0020)
348 lp->stats.tx_window_errors++;
349 if (td_status & 0x0004)
350 lp->stats.tx_fifo_errors++;
351 }
352
353 /* We must free the original skb */
226 dev_kfree_skb_irq(lp->tx_skb[entry]); 354 dev_kfree_skb_irq(lp->tx_skb[entry]);
227 lp->tx_skb[entry] = 0; 355 lp->tx_skb[entry] = NULL;
356 /* and unmap DMA buffer */
357 dma_unmap_single(lp->device, lp->tx_laddr[entry], lp->tx_len[entry], DMA_TO_DEVICE);
358 lp->tx_laddr[entry] = (dma_addr_t)0;
359 freed_some = 1;
360
361 if (sonic_tda_get(dev, entry, SONIC_TD_LINK) & SONIC_EOL) {
362 entry = (entry + 1) & SONIC_TDS_MASK;
363 break;
364 }
365 entry = (entry + 1) & SONIC_TDS_MASK;
228 } 366 }
229 /* and the VDMA address */
230 vdma_free(lp->tx_laddr[entry]);
231 dirty_tx++;
232 }
233 367
234 if (lp->tx_full 368 if (freed_some || lp->tx_skb[entry] == NULL)
235 && dirty_tx + SONIC_NUM_TDS > lp->cur_tx + 2) { 369 netif_wake_queue(dev); /* The ring is no longer full */
236 /* The ring is no longer full, clear tbusy. */ 370 lp->cur_tx = entry;
237 lp->tx_full = 0; 371 SONIC_WRITE(SONIC_ISR, SONIC_INT_TXDN); /* clear the interrupt */
238 netif_wake_queue(dev);
239 } 372 }
240 373
241 lp->dirty_tx = dirty_tx; 374 /*
242 } 375 * check error conditions
376 */
377 if (status & SONIC_INT_RFO) {
378 if (sonic_debug > 1)
379 printk("%s: rx fifo overrun\n", dev->name);
380 lp->stats.rx_fifo_errors++;
381 SONIC_WRITE(SONIC_ISR, SONIC_INT_RFO); /* clear the interrupt */
382 }
383 if (status & SONIC_INT_RDE) {
384 if (sonic_debug > 1)
385 printk("%s: rx descriptors exhausted\n", dev->name);
386 lp->stats.rx_dropped++;
387 SONIC_WRITE(SONIC_ISR, SONIC_INT_RDE); /* clear the interrupt */
388 }
389 if (status & SONIC_INT_RBAE) {
390 if (sonic_debug > 1)
391 printk("%s: rx buffer area exceeded\n", dev->name);
392 lp->stats.rx_dropped++;
393 SONIC_WRITE(SONIC_ISR, SONIC_INT_RBAE); /* clear the interrupt */
394 }
243 395
244 /* 396 /* counter overruns; all counters are 16bit wide */
245 * check error conditions 397 if (status & SONIC_INT_FAE) {
246 */ 398 lp->stats.rx_frame_errors += 65536;
247 if (status & SONIC_INT_RFO) { 399 SONIC_WRITE(SONIC_ISR, SONIC_INT_FAE); /* clear the interrupt */
248 printk("%s: receive fifo underrun\n", dev->name); 400 }
249 lp->stats.rx_fifo_errors++; 401 if (status & SONIC_INT_CRC) {
250 } 402 lp->stats.rx_crc_errors += 65536;
251 if (status & SONIC_INT_RDE) { 403 SONIC_WRITE(SONIC_ISR, SONIC_INT_CRC); /* clear the interrupt */
252 printk("%s: receive descriptors exhausted\n", dev->name); 404 }
253 lp->stats.rx_dropped++; 405 if (status & SONIC_INT_MP) {
254 } 406 lp->stats.rx_missed_errors += 65536;
255 if (status & SONIC_INT_RBE) { 407 SONIC_WRITE(SONIC_ISR, SONIC_INT_MP); /* clear the interrupt */
256 printk("%s: receive buffer exhausted\n", dev->name); 408 }
257 lp->stats.rx_dropped++;
258 }
259 if (status & SONIC_INT_RBAE) {
260 printk("%s: receive buffer area exhausted\n", dev->name);
261 lp->stats.rx_dropped++;
262 }
263 409
264 /* counter overruns; all counters are 16bit wide */ 410 /* transmit error */
265 if (status & SONIC_INT_FAE) 411 if (status & SONIC_INT_TXER) {
266 lp->stats.rx_frame_errors += 65536; 412 if ((SONIC_READ(SONIC_TCR) & SONIC_TCR_FU) && (sonic_debug > 2))
267 if (status & SONIC_INT_CRC) 413 printk(KERN_ERR "%s: tx fifo underrun\n", dev->name);
268 lp->stats.rx_crc_errors += 65536; 414 SONIC_WRITE(SONIC_ISR, SONIC_INT_TXER); /* clear the interrupt */
269 if (status & SONIC_INT_MP) 415 }
270 lp->stats.rx_missed_errors += 65536;
271 416
272 /* transmit error */ 417 /* bus retry */
273 if (status & SONIC_INT_TXER) 418 if (status & SONIC_INT_BR) {
274 lp->stats.tx_errors++; 419 printk(KERN_ERR "%s: Bus retry occurred! Device interrupt disabled.\n",
420 dev->name);
421 /* ... to help debug DMA problems causing endless interrupts. */
422 /* Bounce the eth interface to turn on the interrupt again. */
423 SONIC_WRITE(SONIC_IMR, 0);
424 SONIC_WRITE(SONIC_ISR, SONIC_INT_BR); /* clear the interrupt */
425 }
275 426
276 /* 427 /* load CAM done */
277 * clear interrupt bits and return 428 if (status & SONIC_INT_LCD)
278 */ 429 SONIC_WRITE(SONIC_ISR, SONIC_INT_LCD); /* clear the interrupt */
279 SONIC_WRITE(SONIC_ISR, status); 430 } while((status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT));
280 return IRQ_HANDLED; 431 return IRQ_HANDLED;
281} 432}
282 433
283/* 434/*
284 * We have a good packet(s), get it/them out of the buffers. 435 * We have a good packet(s), pass it/them up the network stack.
285 */ 436 */
286static void sonic_rx(struct net_device *dev) 437static void sonic_rx(struct net_device *dev)
287{ 438{
288 unsigned int base_addr = dev->base_addr; 439 struct sonic_local *lp = netdev_priv(dev);
289 struct sonic_local *lp = (struct sonic_local *) dev->priv;
290 sonic_rd_t *rd = &lp->rda[lp->cur_rx & SONIC_RDS_MASK];
291 int status; 440 int status;
292 441 int entry = lp->cur_rx;
293 while (rd->in_use == 0) { 442
294 struct sk_buff *skb; 443 while (sonic_rda_get(dev, entry, SONIC_RD_IN_USE) == 0) {
444 struct sk_buff *used_skb;
445 struct sk_buff *new_skb;
446 dma_addr_t new_laddr;
447 u16 bufadr_l;
448 u16 bufadr_h;
295 int pkt_len; 449 int pkt_len;
296 unsigned char *pkt_ptr;
297 450
298 status = rd->rx_status; 451 status = sonic_rda_get(dev, entry, SONIC_RD_STATUS);
299 if (sonic_debug > 3)
300 printk("status %x, cur_rx %d, cur_rra %x\n",
301 status, lp->cur_rx, lp->cur_rra);
302 if (status & SONIC_RCR_PRX) { 452 if (status & SONIC_RCR_PRX) {
303 pkt_len = rd->rx_pktlen;
304 pkt_ptr =
305 (char *)
306 sonic_chiptomem((rd->rx_pktptr_h << 16) +
307 rd->rx_pktptr_l);
308
309 if (sonic_debug > 3)
310 printk
311 ("pktptr %p (rba %p) h:%x l:%x, bsize h:%x l:%x\n",
312 pkt_ptr, lp->rba, rd->rx_pktptr_h,
313 rd->rx_pktptr_l,
314 SONIC_READ(SONIC_RBWC1),
315 SONIC_READ(SONIC_RBWC0));
316
317 /* Malloc up new buffer. */ 453 /* Malloc up new buffer. */
318 skb = dev_alloc_skb(pkt_len + 2); 454 new_skb = dev_alloc_skb(SONIC_RBSIZE + 2);
319 if (skb == NULL) { 455 if (new_skb == NULL) {
320 printk 456 printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name);
321 ("%s: Memory squeeze, dropping packet.\n", 457 lp->stats.rx_dropped++;
322 dev->name); 458 break;
459 }
460 new_skb->dev = dev;
461 /* provide 16 byte IP header alignment unless DMA requires otherwise */
462 if(SONIC_BUS_SCALE(lp->dma_bitmode) == 2)
463 skb_reserve(new_skb, 2);
464
465 new_laddr = dma_map_single(lp->device, skb_put(new_skb, SONIC_RBSIZE),
466 SONIC_RBSIZE, DMA_FROM_DEVICE);
467 if (!new_laddr) {
468 dev_kfree_skb(new_skb);
469 printk(KERN_ERR "%s: Failed to map rx buffer, dropping packet.\n", dev->name);
323 lp->stats.rx_dropped++; 470 lp->stats.rx_dropped++;
324 break; 471 break;
325 } 472 }
326 skb->dev = dev; 473
327 skb_reserve(skb, 2); /* 16 byte align */ 474 /* now we have a new skb to replace it, pass the used one up the stack */
328 skb_put(skb, pkt_len); /* Make room */ 475 dma_unmap_single(lp->device, lp->rx_laddr[entry], SONIC_RBSIZE, DMA_FROM_DEVICE);
329 eth_copy_and_sum(skb, pkt_ptr, pkt_len, 0); 476 used_skb = lp->rx_skb[entry];
330 skb->protocol = eth_type_trans(skb, dev); 477 pkt_len = sonic_rda_get(dev, entry, SONIC_RD_PKTLEN);
331 netif_rx(skb); /* pass the packet to upper layers */ 478 skb_trim(used_skb, pkt_len);
479 used_skb->protocol = eth_type_trans(used_skb, dev);
480 netif_rx(used_skb);
332 dev->last_rx = jiffies; 481 dev->last_rx = jiffies;
333 lp->stats.rx_packets++; 482 lp->stats.rx_packets++;
334 lp->stats.rx_bytes += pkt_len; 483 lp->stats.rx_bytes += pkt_len;
335 484
485 /* and insert the new skb */
486 lp->rx_laddr[entry] = new_laddr;
487 lp->rx_skb[entry] = new_skb;
488
489 bufadr_l = (unsigned long)new_laddr & 0xffff;
490 bufadr_h = (unsigned long)new_laddr >> 16;
491 sonic_rra_put(dev, entry, SONIC_RR_BUFADR_L, bufadr_l);
492 sonic_rra_put(dev, entry, SONIC_RR_BUFADR_H, bufadr_h);
336 } else { 493 } else {
337 /* This should only happen, if we enable accepting broken packets. */ 494 /* This should only happen, if we enable accepting broken packets. */
338 lp->stats.rx_errors++; 495 lp->stats.rx_errors++;
@@ -341,29 +498,35 @@ static void sonic_rx(struct net_device *dev)
341 if (status & SONIC_RCR_CRCR) 498 if (status & SONIC_RCR_CRCR)
342 lp->stats.rx_crc_errors++; 499 lp->stats.rx_crc_errors++;
343 } 500 }
344
345 rd->in_use = 1;
346 rd = &lp->rda[(++lp->cur_rx) & SONIC_RDS_MASK];
347 /* now give back the buffer to the receive buffer area */
348 if (status & SONIC_RCR_LPKT) { 501 if (status & SONIC_RCR_LPKT) {
349 /* 502 /*
350 * this was the last packet out of the current receice buffer 503 * this was the last packet out of the current receive buffer
351 * give the buffer back to the SONIC 504 * give the buffer back to the SONIC
352 */ 505 */
353 lp->cur_rra += sizeof(sonic_rr_t); 506 lp->cur_rwp += SIZEOF_SONIC_RR * SONIC_BUS_SCALE(lp->dma_bitmode);
354 if (lp->cur_rra > 507 if (lp->cur_rwp >= lp->rra_end) lp->cur_rwp = lp->rra_laddr & 0xffff;
355 (lp->rra_laddr + 508 SONIC_WRITE(SONIC_RWP, lp->cur_rwp);
356 (SONIC_NUM_RRS - 509 if (SONIC_READ(SONIC_ISR) & SONIC_INT_RBE) {
357 1) * sizeof(sonic_rr_t))) lp->cur_rra = 510 if (sonic_debug > 2)
358 lp->rra_laddr; 511 printk("%s: rx buffer exhausted\n", dev->name);
359 SONIC_WRITE(SONIC_RWP, lp->cur_rra & 0xffff); 512 SONIC_WRITE(SONIC_ISR, SONIC_INT_RBE); /* clear the flag */
513 }
360 } else 514 } else
361 printk 515 printk(KERN_ERR "%s: rx desc without RCR_LPKT. Shouldn't happen !?\n",
362 ("%s: rx desc without RCR_LPKT. Shouldn't happen !?\n",
363 dev->name); 516 dev->name);
517 /*
518 * give back the descriptor
519 */
520 sonic_rda_put(dev, entry, SONIC_RD_LINK,
521 sonic_rda_get(dev, entry, SONIC_RD_LINK) | SONIC_EOL);
522 sonic_rda_put(dev, entry, SONIC_RD_IN_USE, 1);
523 sonic_rda_put(dev, lp->eol_rx, SONIC_RD_LINK,
524 sonic_rda_get(dev, lp->eol_rx, SONIC_RD_LINK) & ~SONIC_EOL);
525 lp->eol_rx = entry;
526 lp->cur_rx = entry = (entry + 1) & SONIC_RDS_MASK;
364 } 527 }
365 /* 528 /*
366 * If any worth-while packets have been received, dev_rint() 529 * If any worth-while packets have been received, netif_rx()
367 * has done a mark_bh(NET_BH) for us and will work on them 530 * has done a mark_bh(NET_BH) for us and will work on them
368 * when we get to the bottom-half routine. 531 * when we get to the bottom-half routine.
369 */ 532 */
@@ -376,8 +539,7 @@ static void sonic_rx(struct net_device *dev)
376 */ 539 */
377static struct net_device_stats *sonic_get_stats(struct net_device *dev) 540static struct net_device_stats *sonic_get_stats(struct net_device *dev)
378{ 541{
379 struct sonic_local *lp = (struct sonic_local *) dev->priv; 542 struct sonic_local *lp = netdev_priv(dev);
380 unsigned int base_addr = dev->base_addr;
381 543
382 /* read the tally counter from the SONIC and reset them */ 544 /* read the tally counter from the SONIC and reset them */
383 lp->stats.rx_crc_errors += SONIC_READ(SONIC_CRCT); 545 lp->stats.rx_crc_errors += SONIC_READ(SONIC_CRCT);
@@ -396,8 +558,7 @@ static struct net_device_stats *sonic_get_stats(struct net_device *dev)
396 */ 558 */
397static void sonic_multicast_list(struct net_device *dev) 559static void sonic_multicast_list(struct net_device *dev)
398{ 560{
399 struct sonic_local *lp = (struct sonic_local *) dev->priv; 561 struct sonic_local *lp = netdev_priv(dev);
400 unsigned int base_addr = dev->base_addr;
401 unsigned int rcr; 562 unsigned int rcr;
402 struct dev_mc_list *dmi = dev->mc_list; 563 struct dev_mc_list *dmi = dev->mc_list;
403 unsigned char *addr; 564 unsigned char *addr;
@@ -413,20 +574,15 @@ static void sonic_multicast_list(struct net_device *dev)
413 rcr |= SONIC_RCR_AMC; 574 rcr |= SONIC_RCR_AMC;
414 } else { 575 } else {
415 if (sonic_debug > 2) 576 if (sonic_debug > 2)
416 printk 577 printk("sonic_multicast_list: mc_count %d\n", dev->mc_count);
417 ("sonic_multicast_list: mc_count %d\n", 578 sonic_set_cam_enable(dev, 1); /* always enable our own address */
418 dev->mc_count);
419 lp->cda.cam_enable = 1; /* always enable our own address */
420 for (i = 1; i <= dev->mc_count; i++) { 579 for (i = 1; i <= dev->mc_count; i++) {
421 addr = dmi->dmi_addr; 580 addr = dmi->dmi_addr;
422 dmi = dmi->next; 581 dmi = dmi->next;
423 lp->cda.cam_desc[i].cam_cap0 = 582 sonic_cda_put(dev, i, SONIC_CD_CAP0, addr[1] << 8 | addr[0]);
424 addr[1] << 8 | addr[0]; 583 sonic_cda_put(dev, i, SONIC_CD_CAP1, addr[3] << 8 | addr[2]);
425 lp->cda.cam_desc[i].cam_cap1 = 584 sonic_cda_put(dev, i, SONIC_CD_CAP2, addr[5] << 8 | addr[4]);
426 addr[3] << 8 | addr[2]; 585 sonic_set_cam_enable(dev, sonic_get_cam_enable(dev) | (1 << i));
427 lp->cda.cam_desc[i].cam_cap2 =
428 addr[5] << 8 | addr[4];
429 lp->cda.cam_enable |= (1 << i);
430 } 586 }
431 SONIC_WRITE(SONIC_CDC, 16); 587 SONIC_WRITE(SONIC_CDC, 16);
432 /* issue Load CAM command */ 588 /* issue Load CAM command */
@@ -447,19 +603,16 @@ static void sonic_multicast_list(struct net_device *dev)
447 */ 603 */
448static int sonic_init(struct net_device *dev) 604static int sonic_init(struct net_device *dev)
449{ 605{
450 unsigned int base_addr = dev->base_addr;
451 unsigned int cmd; 606 unsigned int cmd;
452 struct sonic_local *lp = (struct sonic_local *) dev->priv; 607 struct sonic_local *lp = netdev_priv(dev);
453 unsigned int rra_start;
454 unsigned int rra_end;
455 int i; 608 int i;
456 609
457 /* 610 /*
458 * put the Sonic into software-reset mode and 611 * put the Sonic into software-reset mode and
459 * disable all interrupts 612 * disable all interrupts
460 */ 613 */
461 SONIC_WRITE(SONIC_ISR, 0x7fff);
462 SONIC_WRITE(SONIC_IMR, 0); 614 SONIC_WRITE(SONIC_IMR, 0);
615 SONIC_WRITE(SONIC_ISR, 0x7fff);
463 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST); 616 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
464 617
465 /* 618 /*
@@ -475,34 +628,32 @@ static int sonic_init(struct net_device *dev)
475 if (sonic_debug > 2) 628 if (sonic_debug > 2)
476 printk("sonic_init: initialize receive resource area\n"); 629 printk("sonic_init: initialize receive resource area\n");
477 630
478 rra_start = lp->rra_laddr & 0xffff;
479 rra_end =
480 (rra_start + (SONIC_NUM_RRS * sizeof(sonic_rr_t))) & 0xffff;
481
482 for (i = 0; i < SONIC_NUM_RRS; i++) { 631 for (i = 0; i < SONIC_NUM_RRS; i++) {
483 lp->rra[i].rx_bufadr_l = 632 u16 bufadr_l = (unsigned long)lp->rx_laddr[i] & 0xffff;
484 (lp->rba_laddr + i * SONIC_RBSIZE) & 0xffff; 633 u16 bufadr_h = (unsigned long)lp->rx_laddr[i] >> 16;
485 lp->rra[i].rx_bufadr_h = 634 sonic_rra_put(dev, i, SONIC_RR_BUFADR_L, bufadr_l);
486 (lp->rba_laddr + i * SONIC_RBSIZE) >> 16; 635 sonic_rra_put(dev, i, SONIC_RR_BUFADR_H, bufadr_h);
487 lp->rra[i].rx_bufsize_l = SONIC_RBSIZE >> 1; 636 sonic_rra_put(dev, i, SONIC_RR_BUFSIZE_L, SONIC_RBSIZE >> 1);
488 lp->rra[i].rx_bufsize_h = 0; 637 sonic_rra_put(dev, i, SONIC_RR_BUFSIZE_H, 0);
489 } 638 }
490 639
491 /* initialize all RRA registers */ 640 /* initialize all RRA registers */
492 SONIC_WRITE(SONIC_RSA, rra_start); 641 lp->rra_end = (lp->rra_laddr + SONIC_NUM_RRS * SIZEOF_SONIC_RR *
493 SONIC_WRITE(SONIC_REA, rra_end); 642 SONIC_BUS_SCALE(lp->dma_bitmode)) & 0xffff;
494 SONIC_WRITE(SONIC_RRP, rra_start); 643 lp->cur_rwp = (lp->rra_laddr + (SONIC_NUM_RRS - 1) * SIZEOF_SONIC_RR *
495 SONIC_WRITE(SONIC_RWP, rra_end); 644 SONIC_BUS_SCALE(lp->dma_bitmode)) & 0xffff;
645
646 SONIC_WRITE(SONIC_RSA, lp->rra_laddr & 0xffff);
647 SONIC_WRITE(SONIC_REA, lp->rra_end);
648 SONIC_WRITE(SONIC_RRP, lp->rra_laddr & 0xffff);
649 SONIC_WRITE(SONIC_RWP, lp->cur_rwp);
496 SONIC_WRITE(SONIC_URRA, lp->rra_laddr >> 16); 650 SONIC_WRITE(SONIC_URRA, lp->rra_laddr >> 16);
497 SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE - 2) >> 1); 651 SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE >> 1) - (lp->dma_bitmode ? 2 : 1));
498
499 lp->cur_rra =
500 lp->rra_laddr + (SONIC_NUM_RRS - 1) * sizeof(sonic_rr_t);
501 652
502 /* load the resource pointers */ 653 /* load the resource pointers */
503 if (sonic_debug > 3) 654 if (sonic_debug > 3)
504 printk("sonic_init: issueing RRRA command\n"); 655 printk("sonic_init: issuing RRRA command\n");
505 656
506 SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA); 657 SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA);
507 i = 0; 658 i = 0;
508 while (i++ < 100) { 659 while (i++ < 100) {
@@ -511,27 +662,30 @@ static int sonic_init(struct net_device *dev)
511 } 662 }
512 663
513 if (sonic_debug > 2) 664 if (sonic_debug > 2)
514 printk("sonic_init: status=%x\n", SONIC_READ(SONIC_CMD)); 665 printk("sonic_init: status=%x i=%d\n", SONIC_READ(SONIC_CMD), i);
515 666
516 /* 667 /*
517 * Initialize the receive descriptors so that they 668 * Initialize the receive descriptors so that they
518 * become a circular linked list, ie. let the last 669 * become a circular linked list, ie. let the last
519 * descriptor point to the first again. 670 * descriptor point to the first again.
520 */ 671 */
521 if (sonic_debug > 2) 672 if (sonic_debug > 2)
522 printk("sonic_init: initialize receive descriptors\n"); 673 printk("sonic_init: initialize receive descriptors\n");
523 for (i = 0; i < SONIC_NUM_RDS; i++) { 674 for (i=0; i<SONIC_NUM_RDS; i++) {
524 lp->rda[i].rx_status = 0; 675 sonic_rda_put(dev, i, SONIC_RD_STATUS, 0);
525 lp->rda[i].rx_pktlen = 0; 676 sonic_rda_put(dev, i, SONIC_RD_PKTLEN, 0);
526 lp->rda[i].rx_pktptr_l = 0; 677 sonic_rda_put(dev, i, SONIC_RD_PKTPTR_L, 0);
527 lp->rda[i].rx_pktptr_h = 0; 678 sonic_rda_put(dev, i, SONIC_RD_PKTPTR_H, 0);
528 lp->rda[i].rx_seqno = 0; 679 sonic_rda_put(dev, i, SONIC_RD_SEQNO, 0);
529 lp->rda[i].in_use = 1; 680 sonic_rda_put(dev, i, SONIC_RD_IN_USE, 1);
530 lp->rda[i].link = 681 sonic_rda_put(dev, i, SONIC_RD_LINK,
531 lp->rda_laddr + (i + 1) * sizeof(sonic_rd_t); 682 lp->rda_laddr +
683 ((i+1) * SIZEOF_SONIC_RD * SONIC_BUS_SCALE(lp->dma_bitmode)));
532 } 684 }
533 /* fix last descriptor */ 685 /* fix last descriptor */
534 lp->rda[SONIC_NUM_RDS - 1].link = lp->rda_laddr; 686 sonic_rda_put(dev, SONIC_NUM_RDS - 1, SONIC_RD_LINK,
687 (lp->rda_laddr & 0xffff) | SONIC_EOL);
688 lp->eol_rx = SONIC_NUM_RDS - 1;
535 lp->cur_rx = 0; 689 lp->cur_rx = 0;
536 SONIC_WRITE(SONIC_URDA, lp->rda_laddr >> 16); 690 SONIC_WRITE(SONIC_URDA, lp->rda_laddr >> 16);
537 SONIC_WRITE(SONIC_CRDA, lp->rda_laddr & 0xffff); 691 SONIC_WRITE(SONIC_CRDA, lp->rda_laddr & 0xffff);
@@ -542,34 +696,34 @@ static int sonic_init(struct net_device *dev)
542 if (sonic_debug > 2) 696 if (sonic_debug > 2)
543 printk("sonic_init: initialize transmit descriptors\n"); 697 printk("sonic_init: initialize transmit descriptors\n");
544 for (i = 0; i < SONIC_NUM_TDS; i++) { 698 for (i = 0; i < SONIC_NUM_TDS; i++) {
545 lp->tda[i].tx_status = 0; 699 sonic_tda_put(dev, i, SONIC_TD_STATUS, 0);
546 lp->tda[i].tx_config = 0; 700 sonic_tda_put(dev, i, SONIC_TD_CONFIG, 0);
547 lp->tda[i].tx_pktsize = 0; 701 sonic_tda_put(dev, i, SONIC_TD_PKTSIZE, 0);
548 lp->tda[i].tx_frag_count = 0; 702 sonic_tda_put(dev, i, SONIC_TD_FRAG_COUNT, 0);
549 lp->tda[i].link = 703 sonic_tda_put(dev, i, SONIC_TD_LINK,
550 (lp->tda_laddr + 704 (lp->tda_laddr & 0xffff) +
551 (i + 1) * sizeof(sonic_td_t)) | SONIC_END_OF_LINKS; 705 (i + 1) * SIZEOF_SONIC_TD * SONIC_BUS_SCALE(lp->dma_bitmode));
706 lp->tx_skb[i] = NULL;
552 } 707 }
553 lp->tda[SONIC_NUM_TDS - 1].link = 708 /* fix last descriptor */
554 (lp->tda_laddr & 0xffff) | SONIC_END_OF_LINKS; 709 sonic_tda_put(dev, SONIC_NUM_TDS - 1, SONIC_TD_LINK,
710 (lp->tda_laddr & 0xffff));
555 711
556 SONIC_WRITE(SONIC_UTDA, lp->tda_laddr >> 16); 712 SONIC_WRITE(SONIC_UTDA, lp->tda_laddr >> 16);
557 SONIC_WRITE(SONIC_CTDA, lp->tda_laddr & 0xffff); 713 SONIC_WRITE(SONIC_CTDA, lp->tda_laddr & 0xffff);
558 lp->cur_tx = lp->dirty_tx = 0; 714 lp->cur_tx = lp->next_tx = 0;
559 715 lp->eol_tx = SONIC_NUM_TDS - 1;
716
560 /* 717 /*
561 * put our own address to CAM desc[0] 718 * put our own address to CAM desc[0]
562 */ 719 */
563 lp->cda.cam_desc[0].cam_cap0 = 720 sonic_cda_put(dev, 0, SONIC_CD_CAP0, dev->dev_addr[1] << 8 | dev->dev_addr[0]);
564 dev->dev_addr[1] << 8 | dev->dev_addr[0]; 721 sonic_cda_put(dev, 0, SONIC_CD_CAP1, dev->dev_addr[3] << 8 | dev->dev_addr[2]);
565 lp->cda.cam_desc[0].cam_cap1 = 722 sonic_cda_put(dev, 0, SONIC_CD_CAP2, dev->dev_addr[5] << 8 | dev->dev_addr[4]);
566 dev->dev_addr[3] << 8 | dev->dev_addr[2]; 723 sonic_set_cam_enable(dev, 1);
567 lp->cda.cam_desc[0].cam_cap2 =
568 dev->dev_addr[5] << 8 | dev->dev_addr[4];
569 lp->cda.cam_enable = 1;
570 724
571 for (i = 0; i < 16; i++) 725 for (i = 0; i < 16; i++)
572 lp->cda.cam_desc[i].cam_entry_pointer = i; 726 sonic_cda_put(dev, i, SONIC_CD_ENTRY_POINTER, i);
573 727
574 /* 728 /*
575 * initialize CAM registers 729 * initialize CAM registers
@@ -588,8 +742,8 @@ static int sonic_init(struct net_device *dev)
588 break; 742 break;
589 } 743 }
590 if (sonic_debug > 2) { 744 if (sonic_debug > 2) {
591 printk("sonic_init: CMD=%x, ISR=%x\n", 745 printk("sonic_init: CMD=%x, ISR=%x\n, i=%d",
592 SONIC_READ(SONIC_CMD), SONIC_READ(SONIC_ISR)); 746 SONIC_READ(SONIC_CMD), SONIC_READ(SONIC_ISR), i);
593 } 747 }
594 748
595 /* 749 /*
@@ -604,7 +758,7 @@ static int sonic_init(struct net_device *dev)
604 758
605 cmd = SONIC_READ(SONIC_CMD); 759 cmd = SONIC_READ(SONIC_CMD);
606 if ((cmd & SONIC_CR_RXEN) == 0 || (cmd & SONIC_CR_STP) == 0) 760 if ((cmd & SONIC_CR_RXEN) == 0 || (cmd & SONIC_CR_STP) == 0)
607 printk("sonic_init: failed, status=%x\n", cmd); 761 printk(KERN_ERR "sonic_init: failed, status=%x\n", cmd);
608 762
609 if (sonic_debug > 2) 763 if (sonic_debug > 2)
610 printk("sonic_init: new status=%x\n", 764 printk("sonic_init: new status=%x\n",
diff --git a/drivers/net/sonic.h b/drivers/net/sonic.h
index c4a6d58e4afb..cede969a8baa 100644
--- a/drivers/net/sonic.h
+++ b/drivers/net/sonic.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Helpfile for sonic.c 2 * Header file for sonic.c
3 * 3 *
4 * (C) Waldorf Electronics, Germany 4 * (C) Waldorf Electronics, Germany
5 * Written by Andreas Busse 5 * Written by Andreas Busse
@@ -9,10 +9,16 @@
9 * and pad structure members must be exchanged. Also, the structures 9 * and pad structure members must be exchanged. Also, the structures
10 * need to be changed accordingly to the bus size. 10 * need to be changed accordingly to the bus size.
11 * 11 *
12 * 981229 MSch: did just that for the 68k Mac port (32 bit, big endian), 12 * 981229 MSch: did just that for the 68k Mac port (32 bit, big endian)
13 * see CONFIG_MACSONIC branch below.
14 * 13 *
14 * 990611 David Huggins-Daines <dhd@debian.org>: This machine abstraction
15 * does not cope with 16-bit bus sizes very well. Therefore I have
16 * rewritten it with ugly macros and evil inlines.
17 *
18 * 050625 Finn Thain: introduced more 32-bit cards and dhd's support
19 * for 16-bit cards (from the mac68k project).
15 */ 20 */
21
16#ifndef SONIC_H 22#ifndef SONIC_H
17#define SONIC_H 23#define SONIC_H
18 24
@@ -83,6 +89,7 @@
83/* 89/*
84 * Error counters 90 * Error counters
85 */ 91 */
92
86#define SONIC_CRCT 0x2c 93#define SONIC_CRCT 0x2c
87#define SONIC_FAET 0x2d 94#define SONIC_FAET 0x2d
88#define SONIC_MPT 0x2e 95#define SONIC_MPT 0x2e
@@ -182,14 +189,14 @@
182 189
183#define SONIC_INT_BR 0x4000 190#define SONIC_INT_BR 0x4000
184#define SONIC_INT_HBL 0x2000 191#define SONIC_INT_HBL 0x2000
185#define SONIC_INT_LCD 0x1000 192#define SONIC_INT_LCD 0x1000
186#define SONIC_INT_PINT 0x0800 193#define SONIC_INT_PINT 0x0800
187#define SONIC_INT_PKTRX 0x0400 194#define SONIC_INT_PKTRX 0x0400
188#define SONIC_INT_TXDN 0x0200 195#define SONIC_INT_TXDN 0x0200
189#define SONIC_INT_TXER 0x0100 196#define SONIC_INT_TXER 0x0100
190#define SONIC_INT_TC 0x0080 197#define SONIC_INT_TC 0x0080
191#define SONIC_INT_RDE 0x0040 198#define SONIC_INT_RDE 0x0040
192#define SONIC_INT_RBE 0x0020 199#define SONIC_INT_RBE 0x0020
193#define SONIC_INT_RBAE 0x0010 200#define SONIC_INT_RBAE 0x0010
194#define SONIC_INT_CRC 0x0008 201#define SONIC_INT_CRC 0x0008
195#define SONIC_INT_FAE 0x0004 202#define SONIC_INT_FAE 0x0004
@@ -201,224 +208,61 @@
201 * The interrupts we allow. 208 * The interrupts we allow.
202 */ 209 */
203 210
204#define SONIC_IMR_DEFAULT (SONIC_INT_BR | \ 211#define SONIC_IMR_DEFAULT ( SONIC_INT_BR | \
205 SONIC_INT_LCD | \ 212 SONIC_INT_LCD | \
206 SONIC_INT_PINT | \ 213 SONIC_INT_RFO | \
207 SONIC_INT_PKTRX | \ 214 SONIC_INT_PKTRX | \
208 SONIC_INT_TXDN | \ 215 SONIC_INT_TXDN | \
209 SONIC_INT_TXER | \ 216 SONIC_INT_TXER | \
210 SONIC_INT_RDE | \ 217 SONIC_INT_RDE | \
211 SONIC_INT_RBE | \
212 SONIC_INT_RBAE | \ 218 SONIC_INT_RBAE | \
213 SONIC_INT_CRC | \ 219 SONIC_INT_CRC | \
214 SONIC_INT_FAE | \ 220 SONIC_INT_FAE | \
215 SONIC_INT_MP) 221 SONIC_INT_MP)
216 222
217 223
218#define SONIC_END_OF_LINKS 0x0001 224#define SONIC_EOL 0x0001
219
220
221#ifdef CONFIG_MACSONIC
222/*
223 * Big endian like structures on 680x0 Macs
224 */
225
226typedef struct {
227 u32 rx_bufadr_l; /* receive buffer ptr */
228 u32 rx_bufadr_h;
229
230 u32 rx_bufsize_l; /* no. of words in the receive buffer */
231 u32 rx_bufsize_h;
232} sonic_rr_t;
233
234/*
235 * Sonic receive descriptor. Receive descriptors are
236 * kept in a linked list of these structures.
237 */
238
239typedef struct {
240 SREGS_PAD(pad0);
241 u16 rx_status; /* status after reception of a packet */
242 SREGS_PAD(pad1);
243 u16 rx_pktlen; /* length of the packet incl. CRC */
244
245 /*
246 * Pointers to the location in the receive buffer area (RBA)
247 * where the packet resides. A packet is always received into
248 * a contiguous piece of memory.
249 */
250 SREGS_PAD(pad2);
251 u16 rx_pktptr_l;
252 SREGS_PAD(pad3);
253 u16 rx_pktptr_h;
254
255 SREGS_PAD(pad4);
256 u16 rx_seqno; /* sequence no. */
257
258 SREGS_PAD(pad5);
259 u16 link; /* link to next RDD (end if EOL bit set) */
260
261 /*
262 * Owner of this descriptor, 0= driver, 1=sonic
263 */
264
265 SREGS_PAD(pad6);
266 u16 in_use;
267
268 caddr_t rda_next; /* pointer to next RD */
269} sonic_rd_t;
270
271
272/*
273 * Describes a Transmit Descriptor
274 */
275typedef struct {
276 SREGS_PAD(pad0);
277 u16 tx_status; /* status after transmission of a packet */
278 SREGS_PAD(pad1);
279 u16 tx_config; /* transmit configuration for this packet */
280 SREGS_PAD(pad2);
281 u16 tx_pktsize; /* size of the packet to be transmitted */
282 SREGS_PAD(pad3);
283 u16 tx_frag_count; /* no. of fragments */
284
285 SREGS_PAD(pad4);
286 u16 tx_frag_ptr_l;
287 SREGS_PAD(pad5);
288 u16 tx_frag_ptr_h;
289 SREGS_PAD(pad6);
290 u16 tx_frag_size;
291
292 SREGS_PAD(pad7);
293 u16 link; /* ptr to next descriptor */
294} sonic_td_t;
295
296
297/*
298 * Describes an entry in the CAM Descriptor Area.
299 */
300
301typedef struct {
302 SREGS_PAD(pad0);
303 u16 cam_entry_pointer;
304 SREGS_PAD(pad1);
305 u16 cam_cap0;
306 SREGS_PAD(pad2);
307 u16 cam_cap1;
308 SREGS_PAD(pad3);
309 u16 cam_cap2;
310} sonic_cd_t;
311
312#define CAM_DESCRIPTORS 16 225#define CAM_DESCRIPTORS 16
313 226
314 227/* Offsets in the various DMA buffers accessed by the SONIC */
315typedef struct { 228
316 sonic_cd_t cam_desc[CAM_DESCRIPTORS]; 229#define SONIC_BITMODE16 0
317 SREGS_PAD(pad); 230#define SONIC_BITMODE32 1
318 u16 cam_enable; 231#define SONIC_BUS_SCALE(bitmode) ((bitmode) ? 4 : 2)
319} sonic_cda_t; 232/* Note! These are all measured in bus-size units, so use SONIC_BUS_SCALE */
320 233#define SIZEOF_SONIC_RR 4
321#else /* original declarations, little endian 32 bit */ 234#define SONIC_RR_BUFADR_L 0
322 235#define SONIC_RR_BUFADR_H 1
323/* 236#define SONIC_RR_BUFSIZE_L 2
324 * structure definitions 237#define SONIC_RR_BUFSIZE_H 3
325 */ 238
326 239#define SIZEOF_SONIC_RD 7
327typedef struct { 240#define SONIC_RD_STATUS 0
328 u32 rx_bufadr_l; /* receive buffer ptr */ 241#define SONIC_RD_PKTLEN 1
329 u32 rx_bufadr_h; 242#define SONIC_RD_PKTPTR_L 2
330 243#define SONIC_RD_PKTPTR_H 3
331 u32 rx_bufsize_l; /* no. of words in the receive buffer */ 244#define SONIC_RD_SEQNO 4
332 u32 rx_bufsize_h; 245#define SONIC_RD_LINK 5
333} sonic_rr_t; 246#define SONIC_RD_IN_USE 6
334 247
335/* 248#define SIZEOF_SONIC_TD 8
336 * Sonic receive descriptor. Receive descriptors are 249#define SONIC_TD_STATUS 0
337 * kept in a linked list of these structures. 250#define SONIC_TD_CONFIG 1
338 */ 251#define SONIC_TD_PKTSIZE 2
339 252#define SONIC_TD_FRAG_COUNT 3
340typedef struct { 253#define SONIC_TD_FRAG_PTR_L 4
341 u16 rx_status; /* status after reception of a packet */ 254#define SONIC_TD_FRAG_PTR_H 5
342 SREGS_PAD(pad0); 255#define SONIC_TD_FRAG_SIZE 6
343 u16 rx_pktlen; /* length of the packet incl. CRC */ 256#define SONIC_TD_LINK 7
344 SREGS_PAD(pad1); 257
345 258#define SIZEOF_SONIC_CD 4
346 /* 259#define SONIC_CD_ENTRY_POINTER 0
347 * Pointers to the location in the receive buffer area (RBA) 260#define SONIC_CD_CAP0 1
348 * where the packet resides. A packet is always received into 261#define SONIC_CD_CAP1 2
349 * a contiguous piece of memory. 262#define SONIC_CD_CAP2 3
350 */ 263
351 u16 rx_pktptr_l; 264#define SIZEOF_SONIC_CDA ((CAM_DESCRIPTORS * SIZEOF_SONIC_CD) + 1)
352 SREGS_PAD(pad2); 265#define SONIC_CDA_CAM_ENABLE (CAM_DESCRIPTORS * SIZEOF_SONIC_CD)
353 u16 rx_pktptr_h;
354 SREGS_PAD(pad3);
355
356 u16 rx_seqno; /* sequence no. */
357 SREGS_PAD(pad4);
358
359 u16 link; /* link to next RDD (end if EOL bit set) */
360 SREGS_PAD(pad5);
361
362 /*
363 * Owner of this descriptor, 0= driver, 1=sonic
364 */
365
366 u16 in_use;
367 SREGS_PAD(pad6);
368
369 caddr_t rda_next; /* pointer to next RD */
370} sonic_rd_t;
371
372
373/*
374 * Describes a Transmit Descriptor
375 */
376typedef struct {
377 u16 tx_status; /* status after transmission of a packet */
378 SREGS_PAD(pad0);
379 u16 tx_config; /* transmit configuration for this packet */
380 SREGS_PAD(pad1);
381 u16 tx_pktsize; /* size of the packet to be transmitted */
382 SREGS_PAD(pad2);
383 u16 tx_frag_count; /* no. of fragments */
384 SREGS_PAD(pad3);
385
386 u16 tx_frag_ptr_l;
387 SREGS_PAD(pad4);
388 u16 tx_frag_ptr_h;
389 SREGS_PAD(pad5);
390 u16 tx_frag_size;
391 SREGS_PAD(pad6);
392
393 u16 link; /* ptr to next descriptor */
394 SREGS_PAD(pad7);
395} sonic_td_t;
396
397
398/*
399 * Describes an entry in the CAM Descriptor Area.
400 */
401
402typedef struct {
403 u16 cam_entry_pointer;
404 SREGS_PAD(pad0);
405 u16 cam_cap0;
406 SREGS_PAD(pad1);
407 u16 cam_cap1;
408 SREGS_PAD(pad2);
409 u16 cam_cap2;
410 SREGS_PAD(pad3);
411} sonic_cd_t;
412
413#define CAM_DESCRIPTORS 16
414
415
416typedef struct {
417 sonic_cd_t cam_desc[CAM_DESCRIPTORS];
418 u16 cam_enable;
419 SREGS_PAD(pad);
420} sonic_cda_t;
421#endif /* endianness */
422 266
423/* 267/*
424 * Some tunables for the buffer areas. Power of 2 is required 268 * Some tunables for the buffer areas. Power of 2 is required
@@ -426,44 +270,60 @@ typedef struct {
426 * 270 *
427 * MSch: use more buffer space for the slow m68k Macs! 271 * MSch: use more buffer space for the slow m68k Macs!
428 */ 272 */
429#ifdef CONFIG_MACSONIC 273#define SONIC_NUM_RRS 16 /* number of receive resources */
430#define SONIC_NUM_RRS 32 /* number of receive resources */ 274#define SONIC_NUM_RDS SONIC_NUM_RRS /* number of receive descriptors */
431#define SONIC_NUM_RDS SONIC_NUM_RRS /* number of receive descriptors */ 275#define SONIC_NUM_TDS 16 /* number of transmit descriptors */
432#define SONIC_NUM_TDS 32 /* number of transmit descriptors */
433#else
434#define SONIC_NUM_RRS 16 /* number of receive resources */
435#define SONIC_NUM_RDS SONIC_NUM_RRS /* number of receive descriptors */
436#define SONIC_NUM_TDS 16 /* number of transmit descriptors */
437#endif
438#define SONIC_RBSIZE 1520 /* size of one resource buffer */
439 276
440#define SONIC_RDS_MASK (SONIC_NUM_RDS-1) 277#define SONIC_RDS_MASK (SONIC_NUM_RDS-1)
441#define SONIC_TDS_MASK (SONIC_NUM_TDS-1) 278#define SONIC_TDS_MASK (SONIC_NUM_TDS-1)
442 279
280#define SONIC_RBSIZE 1520 /* size of one resource buffer */
281
282/* Again, measured in bus size units! */
283#define SIZEOF_SONIC_DESC (SIZEOF_SONIC_CDA \
284 + (SIZEOF_SONIC_TD * SONIC_NUM_TDS) \
285 + (SIZEOF_SONIC_RD * SONIC_NUM_RDS) \
286 + (SIZEOF_SONIC_RR * SONIC_NUM_RRS))
443 287
444/* Information that need to be kept for each board. */ 288/* Information that need to be kept for each board. */
445struct sonic_local { 289struct sonic_local {
446 sonic_cda_t cda; /* virtual CPU address of CDA */ 290 /* Bus size. 0 == 16 bits, 1 == 32 bits. */
447 sonic_td_t tda[SONIC_NUM_TDS]; /* transmit descriptor area */ 291 int dma_bitmode;
448 sonic_rr_t rra[SONIC_NUM_RRS]; /* receive resource area */ 292 /* Register offset within the longword (independent of endianness,
449 sonic_rd_t rda[SONIC_NUM_RDS]; /* receive descriptor area */ 293 and varies from one type of Macintosh SONIC to another
450 struct sk_buff *tx_skb[SONIC_NUM_TDS]; /* skbuffs for packets to transmit */ 294 (Aarrgh)) */
451 unsigned int tx_laddr[SONIC_NUM_TDS]; /* logical DMA address fro skbuffs */ 295 int reg_offset;
452 unsigned char *rba; /* start of receive buffer areas */ 296 void *descriptors;
453 unsigned int cda_laddr; /* logical DMA address of CDA */ 297 /* Crud. These areas have to be within the same 64K. Therefore
454 unsigned int tda_laddr; /* logical DMA address of TDA */ 298 we allocate a desriptors page, and point these to places within it. */
455 unsigned int rra_laddr; /* logical DMA address of RRA */ 299 void *cda; /* CAM descriptor area */
456 unsigned int rda_laddr; /* logical DMA address of RDA */ 300 void *tda; /* Transmit descriptor area */
457 unsigned int rba_laddr; /* logical DMA address of RBA */ 301 void *rra; /* Receive resource area */
458 unsigned int cur_rra; /* current indexes to resource areas */ 302 void *rda; /* Receive descriptor area */
303 struct sk_buff* volatile rx_skb[SONIC_NUM_RRS]; /* packets to be received */
304 struct sk_buff* volatile tx_skb[SONIC_NUM_TDS]; /* packets to be transmitted */
305 unsigned int tx_len[SONIC_NUM_TDS]; /* lengths of tx DMA mappings */
306 /* Logical DMA addresses on MIPS, bus addresses on m68k
307 * (so "laddr" is a bit misleading) */
308 dma_addr_t descriptors_laddr;
309 u32 cda_laddr; /* logical DMA address of CDA */
310 u32 tda_laddr; /* logical DMA address of TDA */
311 u32 rra_laddr; /* logical DMA address of RRA */
312 u32 rda_laddr; /* logical DMA address of RDA */
313 dma_addr_t rx_laddr[SONIC_NUM_RRS]; /* logical DMA addresses of rx skbuffs */
314 dma_addr_t tx_laddr[SONIC_NUM_TDS]; /* logical DMA addresses of tx skbuffs */
315 unsigned int rra_end;
316 unsigned int cur_rwp;
459 unsigned int cur_rx; 317 unsigned int cur_rx;
460 unsigned int cur_tx; 318 unsigned int cur_tx; /* first unacked transmit packet */
461 unsigned int dirty_tx; /* last unacked transmit packet */ 319 unsigned int eol_rx;
462 char tx_full; 320 unsigned int eol_tx; /* last unacked transmit packet */
321 unsigned int next_tx; /* next free TD */
322 struct device *device; /* generic device */
463 struct net_device_stats stats; 323 struct net_device_stats stats;
464}; 324};
465 325
466#define TX_TIMEOUT 6 326#define TX_TIMEOUT (3 * HZ)
467 327
468/* Index to functions, as function prototypes. */ 328/* Index to functions, as function prototypes. */
469 329
@@ -477,6 +337,114 @@ static void sonic_multicast_list(struct net_device *dev);
477static int sonic_init(struct net_device *dev); 337static int sonic_init(struct net_device *dev);
478static void sonic_tx_timeout(struct net_device *dev); 338static void sonic_tx_timeout(struct net_device *dev);
479 339
340/* Internal inlines for reading/writing DMA buffers. Note that bus
341 size and endianness matter here, whereas they don't for registers,
342 as far as we can tell. */
343/* OpenBSD calls this "SWO". I'd like to think that sonic_buf_put()
344 is a much better name. */
345static inline void sonic_buf_put(void* base, int bitmode,
346 int offset, __u16 val)
347{
348 if (bitmode)
349#ifdef __BIG_ENDIAN
350 ((__u16 *) base + (offset*2))[1] = val;
351#else
352 ((__u16 *) base + (offset*2))[0] = val;
353#endif
354 else
355 ((__u16 *) base)[offset] = val;
356}
357
358static inline __u16 sonic_buf_get(void* base, int bitmode,
359 int offset)
360{
361 if (bitmode)
362#ifdef __BIG_ENDIAN
363 return ((volatile __u16 *) base + (offset*2))[1];
364#else
365 return ((volatile __u16 *) base + (offset*2))[0];
366#endif
367 else
368 return ((volatile __u16 *) base)[offset];
369}
370
371/* Inlines that you should actually use for reading/writing DMA buffers */
372static inline void sonic_cda_put(struct net_device* dev, int entry,
373 int offset, __u16 val)
374{
375 struct sonic_local* lp = (struct sonic_local *) dev->priv;
376 sonic_buf_put(lp->cda, lp->dma_bitmode,
377 (entry * SIZEOF_SONIC_CD) + offset, val);
378}
379
380static inline __u16 sonic_cda_get(struct net_device* dev, int entry,
381 int offset)
382{
383 struct sonic_local* lp = (struct sonic_local *) dev->priv;
384 return sonic_buf_get(lp->cda, lp->dma_bitmode,
385 (entry * SIZEOF_SONIC_CD) + offset);
386}
387
388static inline void sonic_set_cam_enable(struct net_device* dev, __u16 val)
389{
390 struct sonic_local* lp = (struct sonic_local *) dev->priv;
391 sonic_buf_put(lp->cda, lp->dma_bitmode, SONIC_CDA_CAM_ENABLE, val);
392}
393
394static inline __u16 sonic_get_cam_enable(struct net_device* dev)
395{
396 struct sonic_local* lp = (struct sonic_local *) dev->priv;
397 return sonic_buf_get(lp->cda, lp->dma_bitmode, SONIC_CDA_CAM_ENABLE);
398}
399
400static inline void sonic_tda_put(struct net_device* dev, int entry,
401 int offset, __u16 val)
402{
403 struct sonic_local* lp = (struct sonic_local *) dev->priv;
404 sonic_buf_put(lp->tda, lp->dma_bitmode,
405 (entry * SIZEOF_SONIC_TD) + offset, val);
406}
407
408static inline __u16 sonic_tda_get(struct net_device* dev, int entry,
409 int offset)
410{
411 struct sonic_local* lp = (struct sonic_local *) dev->priv;
412 return sonic_buf_get(lp->tda, lp->dma_bitmode,
413 (entry * SIZEOF_SONIC_TD) + offset);
414}
415
416static inline void sonic_rda_put(struct net_device* dev, int entry,
417 int offset, __u16 val)
418{
419 struct sonic_local* lp = (struct sonic_local *) dev->priv;
420 sonic_buf_put(lp->rda, lp->dma_bitmode,
421 (entry * SIZEOF_SONIC_RD) + offset, val);
422}
423
424static inline __u16 sonic_rda_get(struct net_device* dev, int entry,
425 int offset)
426{
427 struct sonic_local* lp = (struct sonic_local *) dev->priv;
428 return sonic_buf_get(lp->rda, lp->dma_bitmode,
429 (entry * SIZEOF_SONIC_RD) + offset);
430}
431
432static inline void sonic_rra_put(struct net_device* dev, int entry,
433 int offset, __u16 val)
434{
435 struct sonic_local* lp = (struct sonic_local *) dev->priv;
436 sonic_buf_put(lp->rra, lp->dma_bitmode,
437 (entry * SIZEOF_SONIC_RR) + offset, val);
438}
439
440static inline __u16 sonic_rra_get(struct net_device* dev, int entry,
441 int offset)
442{
443 struct sonic_local* lp = (struct sonic_local *) dev->priv;
444 return sonic_buf_get(lp->rra, lp->dma_bitmode,
445 (entry * SIZEOF_SONIC_RR) + offset);
446}
447
480static const char *version = 448static const char *version =
481 "sonic.c:v0.92 20.9.98 tsbogend@alpha.franken.de\n"; 449 "sonic.c:v0.92 20.9.98 tsbogend@alpha.franken.de\n";
482 450
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 12e2b6826fa3..88b89dc95c77 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -1286,7 +1286,7 @@ static void init_ring(struct net_device *dev)
1286 np->rx_info[i].skb = skb; 1286 np->rx_info[i].skb = skb;
1287 if (skb == NULL) 1287 if (skb == NULL)
1288 break; 1288 break;
1289 np->rx_info[i].mapping = pci_map_single(np->pci_dev, skb->tail, np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1289 np->rx_info[i].mapping = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1290 skb->dev = dev; /* Mark as being used by this device. */ 1290 skb->dev = dev; /* Mark as being used by this device. */
1291 /* Grrr, we cannot offset to correctly align the IP header. */ 1291 /* Grrr, we cannot offset to correctly align the IP header. */
1292 np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid); 1292 np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid);
@@ -1572,7 +1572,7 @@ static int __netdev_rx(struct net_device *dev, int *quota)
1572 pci_dma_sync_single_for_cpu(np->pci_dev, 1572 pci_dma_sync_single_for_cpu(np->pci_dev,
1573 np->rx_info[entry].mapping, 1573 np->rx_info[entry].mapping,
1574 pkt_len, PCI_DMA_FROMDEVICE); 1574 pkt_len, PCI_DMA_FROMDEVICE);
1575 eth_copy_and_sum(skb, np->rx_info[entry].skb->tail, pkt_len, 0); 1575 eth_copy_and_sum(skb, np->rx_info[entry].skb->data, pkt_len, 0);
1576 pci_dma_sync_single_for_device(np->pci_dev, 1576 pci_dma_sync_single_for_device(np->pci_dev,
1577 np->rx_info[entry].mapping, 1577 np->rx_info[entry].mapping,
1578 pkt_len, PCI_DMA_FROMDEVICE); 1578 pkt_len, PCI_DMA_FROMDEVICE);
@@ -1696,7 +1696,7 @@ static void refill_rx_ring(struct net_device *dev)
1696 if (skb == NULL) 1696 if (skb == NULL)
1697 break; /* Better luck next round. */ 1697 break; /* Better luck next round. */
1698 np->rx_info[entry].mapping = 1698 np->rx_info[entry].mapping =
1699 pci_map_single(np->pci_dev, skb->tail, np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1699 pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1700 skb->dev = dev; /* Mark as being used by this device. */ 1700 skb->dev = dev; /* Mark as being used by this device. */
1701 np->rx_ring[entry].rxaddr = 1701 np->rx_ring[entry].rxaddr =
1702 cpu_to_dma(np->rx_info[entry].mapping | RxDescValid); 1702 cpu_to_dma(np->rx_info[entry].mapping | RxDescValid);
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 08cb7177a175..d500a5771dbc 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -1028,7 +1028,7 @@ static void init_ring(struct net_device *dev)
1028 skb->dev = dev; /* Mark as being used by this device. */ 1028 skb->dev = dev; /* Mark as being used by this device. */
1029 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1029 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1030 np->rx_ring[i].frag[0].addr = cpu_to_le32( 1030 np->rx_ring[i].frag[0].addr = cpu_to_le32(
1031 pci_map_single(np->pci_dev, skb->tail, np->rx_buf_sz, 1031 pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz,
1032 PCI_DMA_FROMDEVICE)); 1032 PCI_DMA_FROMDEVICE));
1033 np->rx_ring[i].frag[0].length = cpu_to_le32(np->rx_buf_sz | LastFrag); 1033 np->rx_ring[i].frag[0].length = cpu_to_le32(np->rx_buf_sz | LastFrag);
1034 } 1034 }
@@ -1341,7 +1341,7 @@ static void rx_poll(unsigned long data)
1341 np->rx_buf_sz, 1341 np->rx_buf_sz,
1342 PCI_DMA_FROMDEVICE); 1342 PCI_DMA_FROMDEVICE);
1343 1343
1344 eth_copy_and_sum(skb, np->rx_skbuff[entry]->tail, pkt_len, 0); 1344 eth_copy_and_sum(skb, np->rx_skbuff[entry]->data, pkt_len, 0);
1345 pci_dma_sync_single_for_device(np->pci_dev, 1345 pci_dma_sync_single_for_device(np->pci_dev,
1346 desc->frag[0].addr, 1346 desc->frag[0].addr,
1347 np->rx_buf_sz, 1347 np->rx_buf_sz,
@@ -1400,7 +1400,7 @@ static void refill_rx (struct net_device *dev)
1400 skb->dev = dev; /* Mark as being used by this device. */ 1400 skb->dev = dev; /* Mark as being used by this device. */
1401 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1401 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1402 np->rx_ring[entry].frag[0].addr = cpu_to_le32( 1402 np->rx_ring[entry].frag[0].addr = cpu_to_le32(
1403 pci_map_single(np->pci_dev, skb->tail, 1403 pci_map_single(np->pci_dev, skb->data,
1404 np->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1404 np->rx_buf_sz, PCI_DMA_FROMDEVICE));
1405 } 1405 }
1406 /* Perhaps we need not reset this field. */ 1406 /* Perhaps we need not reset this field. */
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 5cd50fd53c12..2608e7a3d214 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -44,6 +44,7 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/errno.h> 45#include <linux/errno.h>
46#include <linux/pci.h> 46#include <linux/pci.h>
47#include <linux/dma-mapping.h>
47#include <linux/netdevice.h> 48#include <linux/netdevice.h>
48#include <linux/etherdevice.h> 49#include <linux/etherdevice.h>
49#include <linux/skbuff.h> 50#include <linux/skbuff.h>
@@ -2989,10 +2990,10 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
2989 */ 2990 */
2990 if (pdev->vendor == PCI_VENDOR_ID_SUN && 2991 if (pdev->vendor == PCI_VENDOR_ID_SUN &&
2991 pdev->device == PCI_DEVICE_ID_SUN_GEM && 2992 pdev->device == PCI_DEVICE_ID_SUN_GEM &&
2992 !pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) { 2993 !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
2993 pci_using_dac = 1; 2994 pci_using_dac = 1;
2994 } else { 2995 } else {
2995 err = pci_set_dma_mask(pdev, (u64) 0xffffffff); 2996 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
2996 if (err) { 2997 if (err) {
2997 printk(KERN_ERR PFX "No usable DMA configuration, " 2998 printk(KERN_ERR PFX "No usable DMA configuration, "
2998 "aborting.\n"); 2999 "aborting.\n");
@@ -3078,7 +3079,9 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3078 gp->phy_mii.dev = dev; 3079 gp->phy_mii.dev = dev;
3079 gp->phy_mii.mdio_read = _phy_read; 3080 gp->phy_mii.mdio_read = _phy_read;
3080 gp->phy_mii.mdio_write = _phy_write; 3081 gp->phy_mii.mdio_write = _phy_write;
3081 3082#ifdef CONFIG_PPC_PMAC
3083 gp->phy_mii.platform_data = gp->of_node;
3084#endif
3082 /* By default, we start with autoneg */ 3085 /* By default, we start with autoneg */
3083 gp->want_autoneg = 1; 3086 gp->want_autoneg = 1;
3084 3087
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index 0fca414d3657..d3ddb41d6e5c 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -32,6 +32,10 @@
32#include <linux/ethtool.h> 32#include <linux/ethtool.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34 34
35#ifdef CONFIG_PPC_PMAC
36#include <asm/prom.h>
37#endif
38
35#include "sungem_phy.h" 39#include "sungem_phy.h"
36 40
37/* Link modes of the BCM5400 PHY */ 41/* Link modes of the BCM5400 PHY */
@@ -281,10 +285,12 @@ static int bcm5411_suspend(struct mii_phy* phy)
281static int bcm5421_init(struct mii_phy* phy) 285static int bcm5421_init(struct mii_phy* phy)
282{ 286{
283 u16 data; 287 u16 data;
284 int rev; 288 unsigned int id;
285 289
286 rev = phy_read(phy, MII_PHYSID2) & 0x000f; 290 id = (phy_read(phy, MII_PHYSID1) << 16 | phy_read(phy, MII_PHYSID2));
287 if (rev == 0) { 291
292 /* Revision 0 of 5421 needs some fixups */
293 if (id == 0x002060e0) {
288 /* This is borrowed from MacOS 294 /* This is borrowed from MacOS
289 */ 295 */
290 phy_write(phy, 0x18, 0x1007); 296 phy_write(phy, 0x18, 0x1007);
@@ -297,21 +303,28 @@ static int bcm5421_init(struct mii_phy* phy)
297 data = phy_read(phy, 0x15); 303 data = phy_read(phy, 0x15);
298 phy_write(phy, 0x15, data | 0x0200); 304 phy_write(phy, 0x15, data | 0x0200);
299 } 305 }
300#if 0
301 /* This has to be verified before I enable it */
302 /* Enable automatic low-power */
303 phy_write(phy, 0x1c, 0x9002);
304 phy_write(phy, 0x1c, 0xa821);
305 phy_write(phy, 0x1c, 0x941d);
306#endif
307 return 0;
308}
309 306
310static int bcm5421k2_init(struct mii_phy* phy) 307 /* Pick up some init code from OF for K2 version */
311{ 308 if ((id & 0xfffffff0) == 0x002062e0) {
312 /* Init code borrowed from OF */ 309 phy_write(phy, 4, 0x01e1);
313 phy_write(phy, 4, 0x01e1); 310 phy_write(phy, 9, 0x0300);
314 phy_write(phy, 9, 0x0300); 311 }
312
313 /* Check if we can enable automatic low power */
314#ifdef CONFIG_PPC_PMAC
315 if (phy->platform_data) {
316 struct device_node *np = of_get_parent(phy->platform_data);
317 int can_low_power = 1;
318 if (np == NULL || get_property(np, "no-autolowpower", NULL))
319 can_low_power = 0;
320 if (can_low_power) {
321 /* Enable automatic low-power */
322 phy_write(phy, 0x1c, 0x9002);
323 phy_write(phy, 0x1c, 0xa821);
324 phy_write(phy, 0x1c, 0x941d);
325 }
326 }
327#endif /* CONFIG_PPC_PMAC */
315 328
316 return 0; 329 return 0;
317} 330}
@@ -762,7 +775,7 @@ static struct mii_phy_def bcm5421_phy_def = {
762 775
763/* Broadcom BCM 5421 built-in K2 */ 776/* Broadcom BCM 5421 built-in K2 */
764static struct mii_phy_ops bcm5421k2_phy_ops = { 777static struct mii_phy_ops bcm5421k2_phy_ops = {
765 .init = bcm5421k2_init, 778 .init = bcm5421_init,
766 .suspend = bcm5411_suspend, 779 .suspend = bcm5411_suspend,
767 .setup_aneg = bcm54xx_setup_aneg, 780 .setup_aneg = bcm54xx_setup_aneg,
768 .setup_forced = bcm54xx_setup_forced, 781 .setup_forced = bcm54xx_setup_forced,
@@ -779,6 +792,25 @@ static struct mii_phy_def bcm5421k2_phy_def = {
779 .ops = &bcm5421k2_phy_ops 792 .ops = &bcm5421k2_phy_ops
780}; 793};
781 794
795/* Broadcom BCM 5462 built-in Vesta */
796static struct mii_phy_ops bcm5462V_phy_ops = {
797 .init = bcm5421_init,
798 .suspend = bcm5411_suspend,
799 .setup_aneg = bcm54xx_setup_aneg,
800 .setup_forced = bcm54xx_setup_forced,
801 .poll_link = genmii_poll_link,
802 .read_link = bcm54xx_read_link,
803};
804
805static struct mii_phy_def bcm5462V_phy_def = {
806 .phy_id = 0x002060d0,
807 .phy_id_mask = 0xfffffff0,
808 .name = "BCM5462-Vesta",
809 .features = MII_GBIT_FEATURES,
810 .magic_aneg = 1,
811 .ops = &bcm5462V_phy_ops
812};
813
782/* Marvell 88E1101 (Apple seem to deal with 2 different revs, 814/* Marvell 88E1101 (Apple seem to deal with 2 different revs,
783 * I masked out the 8 last bits to get both, but some specs 815 * I masked out the 8 last bits to get both, but some specs
784 * would be useful here) --BenH. 816 * would be useful here) --BenH.
@@ -824,6 +856,7 @@ static struct mii_phy_def* mii_phy_table[] = {
824 &bcm5411_phy_def, 856 &bcm5411_phy_def,
825 &bcm5421_phy_def, 857 &bcm5421_phy_def,
826 &bcm5421k2_phy_def, 858 &bcm5421k2_phy_def,
859 &bcm5462V_phy_def,
827 &marvell_phy_def, 860 &marvell_phy_def,
828 &genmii_phy_def, 861 &genmii_phy_def,
829 NULL 862 NULL
diff --git a/drivers/net/sungem_phy.h b/drivers/net/sungem_phy.h
index 822cb58174ea..430544496c52 100644
--- a/drivers/net/sungem_phy.h
+++ b/drivers/net/sungem_phy.h
@@ -43,9 +43,10 @@ struct mii_phy
43 int pause; 43 int pause;
44 44
45 /* Provided by host chip */ 45 /* Provided by host chip */
46 struct net_device* dev; 46 struct net_device *dev;
47 int (*mdio_read) (struct net_device *dev, int mii_id, int reg); 47 int (*mdio_read) (struct net_device *dev, int mii_id, int reg);
48 void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val); 48 void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val);
49 void *platform_data;
49}; 50};
50 51
51/* Pass in a struct mii_phy with dev, mdio_read and mdio_write 52/* Pass in a struct mii_phy with dev, mdio_read and mdio_write
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index a0b8848049c9..6d4ab1e333b5 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -66,8 +66,8 @@
66 66
67#define DRV_MODULE_NAME "tg3" 67#define DRV_MODULE_NAME "tg3"
68#define PFX DRV_MODULE_NAME ": " 68#define PFX DRV_MODULE_NAME ": "
69#define DRV_MODULE_VERSION "3.31" 69#define DRV_MODULE_VERSION "3.37"
70#define DRV_MODULE_RELDATE "June 8, 2005" 70#define DRV_MODULE_RELDATE "August 25, 2005"
71 71
72#define TG3_DEF_MAC_MODE 0 72#define TG3_DEF_MAC_MODE 0
73#define TG3_DEF_RX_MODE 0 73#define TG3_DEF_RX_MODE 0
@@ -90,7 +90,7 @@
90/* hardware minimum and maximum for a single frame's data payload */ 90/* hardware minimum and maximum for a single frame's data payload */
91#define TG3_MIN_MTU 60 91#define TG3_MIN_MTU 60
92#define TG3_MAX_MTU(tp) \ 92#define TG3_MAX_MTU(tp) \
93 (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ? 9000 : 1500) 93 ((tp->tg3_flags2 & TG3_FLG2_JUMBO_CAPABLE) ? 9000 : 1500)
94 94
95/* These numbers seem to be hard coded in the NIC firmware somehow. 95/* These numbers seem to be hard coded in the NIC firmware somehow.
96 * You can't change the ring sizes, but you can change where you place 96 * You can't change the ring sizes, but you can change where you place
@@ -221,6 +221,10 @@ static struct pci_device_id tg3_pci_tbl[] = {
221 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 221 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
222 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753F, 222 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753F,
223 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 223 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
224 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780,
225 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
226 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5780S,
227 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
224 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5781, 228 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5781,
225 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 229 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
226 { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX, 230 { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX,
@@ -337,12 +341,10 @@ static struct {
337static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val) 341static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val)
338{ 342{
339 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0) { 343 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0) {
340 unsigned long flags; 344 spin_lock_bh(&tp->indirect_lock);
341
342 spin_lock_irqsave(&tp->indirect_lock, flags);
343 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off); 345 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off);
344 pci_write_config_dword(tp->pdev, TG3PCI_REG_DATA, val); 346 pci_write_config_dword(tp->pdev, TG3PCI_REG_DATA, val);
345 spin_unlock_irqrestore(&tp->indirect_lock, flags); 347 spin_unlock_bh(&tp->indirect_lock);
346 } else { 348 } else {
347 writel(val, tp->regs + off); 349 writel(val, tp->regs + off);
348 if ((tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) != 0) 350 if ((tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) != 0)
@@ -353,12 +355,10 @@ static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val)
353static void _tw32_flush(struct tg3 *tp, u32 off, u32 val) 355static void _tw32_flush(struct tg3 *tp, u32 off, u32 val)
354{ 356{
355 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0) { 357 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0) {
356 unsigned long flags; 358 spin_lock_bh(&tp->indirect_lock);
357
358 spin_lock_irqsave(&tp->indirect_lock, flags);
359 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off); 359 pci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off);
360 pci_write_config_dword(tp->pdev, TG3PCI_REG_DATA, val); 360 pci_write_config_dword(tp->pdev, TG3PCI_REG_DATA, val);
361 spin_unlock_irqrestore(&tp->indirect_lock, flags); 361 spin_unlock_bh(&tp->indirect_lock);
362 } else { 362 } else {
363 void __iomem *dest = tp->regs + off; 363 void __iomem *dest = tp->regs + off;
364 writel(val, dest); 364 writel(val, dest);
@@ -398,28 +398,24 @@ static inline void _tw32_tx_mbox(struct tg3 *tp, u32 off, u32 val)
398 398
399static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val) 399static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
400{ 400{
401 unsigned long flags; 401 spin_lock_bh(&tp->indirect_lock);
402
403 spin_lock_irqsave(&tp->indirect_lock, flags);
404 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off); 402 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
405 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val); 403 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val);
406 404
407 /* Always leave this as zero. */ 405 /* Always leave this as zero. */
408 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0); 406 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
409 spin_unlock_irqrestore(&tp->indirect_lock, flags); 407 spin_unlock_bh(&tp->indirect_lock);
410} 408}
411 409
412static void tg3_read_mem(struct tg3 *tp, u32 off, u32 *val) 410static void tg3_read_mem(struct tg3 *tp, u32 off, u32 *val)
413{ 411{
414 unsigned long flags; 412 spin_lock_bh(&tp->indirect_lock);
415
416 spin_lock_irqsave(&tp->indirect_lock, flags);
417 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off); 413 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
418 pci_read_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val); 414 pci_read_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val);
419 415
420 /* Always leave this as zero. */ 416 /* Always leave this as zero. */
421 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0); 417 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
422 spin_unlock_irqrestore(&tp->indirect_lock, flags); 418 spin_unlock_bh(&tp->indirect_lock);
423} 419}
424 420
425static void tg3_disable_ints(struct tg3 *tp) 421static void tg3_disable_ints(struct tg3 *tp)
@@ -438,12 +434,14 @@ static inline void tg3_cond_int(struct tg3 *tp)
438 434
439static void tg3_enable_ints(struct tg3 *tp) 435static void tg3_enable_ints(struct tg3 *tp)
440{ 436{
437 tp->irq_sync = 0;
438 wmb();
439
441 tw32(TG3PCI_MISC_HOST_CTRL, 440 tw32(TG3PCI_MISC_HOST_CTRL,
442 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); 441 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT));
443 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 442 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
444 (tp->last_tag << 24)); 443 (tp->last_tag << 24));
445 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 444 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
446
447 tg3_cond_int(tp); 445 tg3_cond_int(tp);
448} 446}
449 447
@@ -492,6 +490,7 @@ static void tg3_restart_ints(struct tg3 *tp)
492 490
493static inline void tg3_netif_stop(struct tg3 *tp) 491static inline void tg3_netif_stop(struct tg3 *tp)
494{ 492{
493 tp->dev->trans_start = jiffies; /* prevent tx timeout */
495 netif_poll_disable(tp->dev); 494 netif_poll_disable(tp->dev);
496 netif_tx_disable(tp->dev); 495 netif_tx_disable(tp->dev);
497} 496}
@@ -504,7 +503,8 @@ static inline void tg3_netif_start(struct tg3 *tp)
504 * (such as after tg3_init_hw) 503 * (such as after tg3_init_hw)
505 */ 504 */
506 netif_poll_enable(tp->dev); 505 netif_poll_enable(tp->dev);
507 tg3_cond_int(tp); 506 tp->hw_status->status |= SD_STATUS_UPDATED;
507 tg3_enable_ints(tp);
508} 508}
509 509
510static void tg3_switch_clocks(struct tg3 *tp) 510static void tg3_switch_clocks(struct tg3 *tp)
@@ -512,6 +512,9 @@ static void tg3_switch_clocks(struct tg3 *tp)
512 u32 clock_ctrl = tr32(TG3PCI_CLOCK_CTRL); 512 u32 clock_ctrl = tr32(TG3PCI_CLOCK_CTRL);
513 u32 orig_clock_ctrl; 513 u32 orig_clock_ctrl;
514 514
515 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780)
516 return;
517
515 orig_clock_ctrl = clock_ctrl; 518 orig_clock_ctrl = clock_ctrl;
516 clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN | 519 clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN |
517 CLOCK_CTRL_CLKRUN_OENABLE | 520 CLOCK_CTRL_CLKRUN_OENABLE |
@@ -911,7 +914,7 @@ out:
911 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { 914 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
912 /* Cannot do read-modify-write on 5401 */ 915 /* Cannot do read-modify-write on 5401 */
913 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); 916 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20);
914 } else if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 917 } else if (tp->tg3_flags2 & TG3_FLG2_JUMBO_CAPABLE) {
915 u32 phy_reg; 918 u32 phy_reg;
916 919
917 /* Set bit 14 with read-modify-write to preserve other bits */ 920 /* Set bit 14 with read-modify-write to preserve other bits */
@@ -923,7 +926,7 @@ out:
923 /* Set phy register 0x10 bit 0 to high fifo elasticity to support 926 /* Set phy register 0x10 bit 0 to high fifo elasticity to support
924 * jumbo frames transmission. 927 * jumbo frames transmission.
925 */ 928 */
926 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 929 if (tp->tg3_flags2 & TG3_FLG2_JUMBO_CAPABLE) {
927 u32 phy_reg; 930 u32 phy_reg;
928 931
929 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) 932 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg))
@@ -1097,7 +1100,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1097 tp->link_config.orig_autoneg = tp->link_config.autoneg; 1100 tp->link_config.orig_autoneg = tp->link_config.autoneg;
1098 } 1101 }
1099 1102
1100 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) { 1103 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES)) {
1101 tp->link_config.speed = SPEED_10; 1104 tp->link_config.speed = SPEED_10;
1102 tp->link_config.duplex = DUPLEX_HALF; 1105 tp->link_config.duplex = DUPLEX_HALF;
1103 tp->link_config.autoneg = AUTONEG_ENABLE; 1106 tp->link_config.autoneg = AUTONEG_ENABLE;
@@ -1149,6 +1152,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1149 CLOCK_CTRL_ALTCLK | 1152 CLOCK_CTRL_ALTCLK |
1150 CLOCK_CTRL_PWRDOWN_PLL133); 1153 CLOCK_CTRL_PWRDOWN_PLL133);
1151 udelay(40); 1154 udelay(40);
1155 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) {
1156 /* do nothing */
1152 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 1157 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
1153 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { 1158 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) {
1154 u32 newbits1, newbits2; 1159 u32 newbits1, newbits2;
@@ -1242,6 +1247,25 @@ static void tg3_setup_flow_control(struct tg3 *tp, u32 local_adv, u32 remote_adv
1242 u32 old_tx_mode = tp->tx_mode; 1247 u32 old_tx_mode = tp->tx_mode;
1243 1248
1244 if (tp->tg3_flags & TG3_FLAG_PAUSE_AUTONEG) { 1249 if (tp->tg3_flags & TG3_FLAG_PAUSE_AUTONEG) {
1250
1251 /* Convert 1000BaseX flow control bits to 1000BaseT
1252 * bits before resolving flow control.
1253 */
1254 if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
1255 local_adv &= ~(ADVERTISE_PAUSE_CAP |
1256 ADVERTISE_PAUSE_ASYM);
1257 remote_adv &= ~(LPA_PAUSE_CAP | LPA_PAUSE_ASYM);
1258
1259 if (local_adv & ADVERTISE_1000XPAUSE)
1260 local_adv |= ADVERTISE_PAUSE_CAP;
1261 if (local_adv & ADVERTISE_1000XPSE_ASYM)
1262 local_adv |= ADVERTISE_PAUSE_ASYM;
1263 if (remote_adv & LPA_1000XPAUSE)
1264 remote_adv |= LPA_PAUSE_CAP;
1265 if (remote_adv & LPA_1000XPAUSE_ASYM)
1266 remote_adv |= LPA_PAUSE_ASYM;
1267 }
1268
1245 if (local_adv & ADVERTISE_PAUSE_CAP) { 1269 if (local_adv & ADVERTISE_PAUSE_CAP) {
1246 if (local_adv & ADVERTISE_PAUSE_ASYM) { 1270 if (local_adv & ADVERTISE_PAUSE_ASYM) {
1247 if (remote_adv & LPA_PAUSE_CAP) 1271 if (remote_adv & LPA_PAUSE_CAP)
@@ -2502,12 +2526,226 @@ static int tg3_setup_fiber_phy(struct tg3 *tp, int force_reset)
2502 return 0; 2526 return 0;
2503} 2527}
2504 2528
2529static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
2530{
2531 int current_link_up, err = 0;
2532 u32 bmsr, bmcr;
2533 u16 current_speed;
2534 u8 current_duplex;
2535
2536 tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2537 tw32_f(MAC_MODE, tp->mac_mode);
2538 udelay(40);
2539
2540 tw32(MAC_EVENT, 0);
2541
2542 tw32_f(MAC_STATUS,
2543 (MAC_STATUS_SYNC_CHANGED |
2544 MAC_STATUS_CFG_CHANGED |
2545 MAC_STATUS_MI_COMPLETION |
2546 MAC_STATUS_LNKSTATE_CHANGED));
2547 udelay(40);
2548
2549 if (force_reset)
2550 tg3_phy_reset(tp);
2551
2552 current_link_up = 0;
2553 current_speed = SPEED_INVALID;
2554 current_duplex = DUPLEX_INVALID;
2555
2556 err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2557 err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2558
2559 err |= tg3_readphy(tp, MII_BMCR, &bmcr);
2560
2561 if ((tp->link_config.autoneg == AUTONEG_ENABLE) && !force_reset &&
2562 (tp->tg3_flags2 & TG3_FLG2_PARALLEL_DETECT)) {
2563 /* do nothing, just check for link up at the end */
2564 } else if (tp->link_config.autoneg == AUTONEG_ENABLE) {
2565 u32 adv, new_adv;
2566
2567 err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
2568 new_adv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
2569 ADVERTISE_1000XPAUSE |
2570 ADVERTISE_1000XPSE_ASYM |
2571 ADVERTISE_SLCT);
2572
2573 /* Always advertise symmetric PAUSE just like copper */
2574 new_adv |= ADVERTISE_1000XPAUSE;
2575
2576 if (tp->link_config.advertising & ADVERTISED_1000baseT_Half)
2577 new_adv |= ADVERTISE_1000XHALF;
2578 if (tp->link_config.advertising & ADVERTISED_1000baseT_Full)
2579 new_adv |= ADVERTISE_1000XFULL;
2580
2581 if ((new_adv != adv) || !(bmcr & BMCR_ANENABLE)) {
2582 tg3_writephy(tp, MII_ADVERTISE, new_adv);
2583 bmcr |= BMCR_ANENABLE | BMCR_ANRESTART;
2584 tg3_writephy(tp, MII_BMCR, bmcr);
2585
2586 tw32_f(MAC_EVENT, MAC_EVENT_LNKSTATE_CHANGED);
2587 tp->tg3_flags2 |= TG3_FLG2_PHY_JUST_INITTED;
2588 tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT;
2589
2590 return err;
2591 }
2592 } else {
2593 u32 new_bmcr;
2594
2595 bmcr &= ~BMCR_SPEED1000;
2596 new_bmcr = bmcr & ~(BMCR_ANENABLE | BMCR_FULLDPLX);
2597
2598 if (tp->link_config.duplex == DUPLEX_FULL)
2599 new_bmcr |= BMCR_FULLDPLX;
2600
2601 if (new_bmcr != bmcr) {
2602 /* BMCR_SPEED1000 is a reserved bit that needs
2603 * to be set on write.
2604 */
2605 new_bmcr |= BMCR_SPEED1000;
2606
2607 /* Force a linkdown */
2608 if (netif_carrier_ok(tp->dev)) {
2609 u32 adv;
2610
2611 err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
2612 adv &= ~(ADVERTISE_1000XFULL |
2613 ADVERTISE_1000XHALF |
2614 ADVERTISE_SLCT);
2615 tg3_writephy(tp, MII_ADVERTISE, adv);
2616 tg3_writephy(tp, MII_BMCR, bmcr |
2617 BMCR_ANRESTART |
2618 BMCR_ANENABLE);
2619 udelay(10);
2620 netif_carrier_off(tp->dev);
2621 }
2622 tg3_writephy(tp, MII_BMCR, new_bmcr);
2623 bmcr = new_bmcr;
2624 err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2625 err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2626 tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT;
2627 }
2628 }
2629
2630 if (bmsr & BMSR_LSTATUS) {
2631 current_speed = SPEED_1000;
2632 current_link_up = 1;
2633 if (bmcr & BMCR_FULLDPLX)
2634 current_duplex = DUPLEX_FULL;
2635 else
2636 current_duplex = DUPLEX_HALF;
2637
2638 if (bmcr & BMCR_ANENABLE) {
2639 u32 local_adv, remote_adv, common;
2640
2641 err |= tg3_readphy(tp, MII_ADVERTISE, &local_adv);
2642 err |= tg3_readphy(tp, MII_LPA, &remote_adv);
2643 common = local_adv & remote_adv;
2644 if (common & (ADVERTISE_1000XHALF |
2645 ADVERTISE_1000XFULL)) {
2646 if (common & ADVERTISE_1000XFULL)
2647 current_duplex = DUPLEX_FULL;
2648 else
2649 current_duplex = DUPLEX_HALF;
2650
2651 tg3_setup_flow_control(tp, local_adv,
2652 remote_adv);
2653 }
2654 else
2655 current_link_up = 0;
2656 }
2657 }
2658
2659 tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX;
2660 if (tp->link_config.active_duplex == DUPLEX_HALF)
2661 tp->mac_mode |= MAC_MODE_HALF_DUPLEX;
2662
2663 tw32_f(MAC_MODE, tp->mac_mode);
2664 udelay(40);
2665
2666 tw32_f(MAC_EVENT, MAC_EVENT_LNKSTATE_CHANGED);
2667
2668 tp->link_config.active_speed = current_speed;
2669 tp->link_config.active_duplex = current_duplex;
2670
2671 if (current_link_up != netif_carrier_ok(tp->dev)) {
2672 if (current_link_up)
2673 netif_carrier_on(tp->dev);
2674 else {
2675 netif_carrier_off(tp->dev);
2676 tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT;
2677 }
2678 tg3_link_report(tp);
2679 }
2680 return err;
2681}
2682
2683static void tg3_serdes_parallel_detect(struct tg3 *tp)
2684{
2685 if (tp->tg3_flags2 & TG3_FLG2_PHY_JUST_INITTED) {
2686 /* Give autoneg time to complete. */
2687 tp->tg3_flags2 &= ~TG3_FLG2_PHY_JUST_INITTED;
2688 return;
2689 }
2690 if (!netif_carrier_ok(tp->dev) &&
2691 (tp->link_config.autoneg == AUTONEG_ENABLE)) {
2692 u32 bmcr;
2693
2694 tg3_readphy(tp, MII_BMCR, &bmcr);
2695 if (bmcr & BMCR_ANENABLE) {
2696 u32 phy1, phy2;
2697
2698 /* Select shadow register 0x1f */
2699 tg3_writephy(tp, 0x1c, 0x7c00);
2700 tg3_readphy(tp, 0x1c, &phy1);
2701
2702 /* Select expansion interrupt status register */
2703 tg3_writephy(tp, 0x17, 0x0f01);
2704 tg3_readphy(tp, 0x15, &phy2);
2705 tg3_readphy(tp, 0x15, &phy2);
2706
2707 if ((phy1 & 0x10) && !(phy2 & 0x20)) {
2708 /* We have signal detect and not receiving
2709 * config code words, link is up by parallel
2710 * detection.
2711 */
2712
2713 bmcr &= ~BMCR_ANENABLE;
2714 bmcr |= BMCR_SPEED1000 | BMCR_FULLDPLX;
2715 tg3_writephy(tp, MII_BMCR, bmcr);
2716 tp->tg3_flags2 |= TG3_FLG2_PARALLEL_DETECT;
2717 }
2718 }
2719 }
2720 else if (netif_carrier_ok(tp->dev) &&
2721 (tp->link_config.autoneg == AUTONEG_ENABLE) &&
2722 (tp->tg3_flags2 & TG3_FLG2_PARALLEL_DETECT)) {
2723 u32 phy2;
2724
2725 /* Select expansion interrupt status register */
2726 tg3_writephy(tp, 0x17, 0x0f01);
2727 tg3_readphy(tp, 0x15, &phy2);
2728 if (phy2 & 0x20) {
2729 u32 bmcr;
2730
2731 /* Config code words received, turn on autoneg. */
2732 tg3_readphy(tp, MII_BMCR, &bmcr);
2733 tg3_writephy(tp, MII_BMCR, bmcr | BMCR_ANENABLE);
2734
2735 tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT;
2736
2737 }
2738 }
2739}
2740
2505static int tg3_setup_phy(struct tg3 *tp, int force_reset) 2741static int tg3_setup_phy(struct tg3 *tp, int force_reset)
2506{ 2742{
2507 int err; 2743 int err;
2508 2744
2509 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { 2745 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) {
2510 err = tg3_setup_fiber_phy(tp, force_reset); 2746 err = tg3_setup_fiber_phy(tp, force_reset);
2747 } else if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
2748 err = tg3_setup_fiber_mii_phy(tp, force_reset);
2511 } else { 2749 } else {
2512 err = tg3_setup_copper_phy(tp, force_reset); 2750 err = tg3_setup_copper_phy(tp, force_reset);
2513 } 2751 }
@@ -2578,7 +2816,7 @@ static void tg3_tx(struct tg3 *tp)
2578 sw_idx = NEXT_TX(sw_idx); 2816 sw_idx = NEXT_TX(sw_idx);
2579 } 2817 }
2580 2818
2581 dev_kfree_skb_irq(skb); 2819 dev_kfree_skb(skb);
2582 } 2820 }
2583 2821
2584 tp->tx_cons = sw_idx; 2822 tp->tx_cons = sw_idx;
@@ -2616,7 +2854,7 @@ static int tg3_alloc_rx_skb(struct tg3 *tp, u32 opaque_key,
2616 map = &tp->rx_std_buffers[dest_idx]; 2854 map = &tp->rx_std_buffers[dest_idx];
2617 if (src_idx >= 0) 2855 if (src_idx >= 0)
2618 src_map = &tp->rx_std_buffers[src_idx]; 2856 src_map = &tp->rx_std_buffers[src_idx];
2619 skb_size = RX_PKT_BUF_SZ; 2857 skb_size = tp->rx_pkt_buf_sz;
2620 break; 2858 break;
2621 2859
2622 case RXD_OPAQUE_RING_JUMBO: 2860 case RXD_OPAQUE_RING_JUMBO:
@@ -2884,11 +3122,8 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2884{ 3122{
2885 struct tg3 *tp = netdev_priv(netdev); 3123 struct tg3 *tp = netdev_priv(netdev);
2886 struct tg3_hw_status *sblk = tp->hw_status; 3124 struct tg3_hw_status *sblk = tp->hw_status;
2887 unsigned long flags;
2888 int done; 3125 int done;
2889 3126
2890 spin_lock_irqsave(&tp->lock, flags);
2891
2892 /* handle link change and other phy events */ 3127 /* handle link change and other phy events */
2893 if (!(tp->tg3_flags & 3128 if (!(tp->tg3_flags &
2894 (TG3_FLAG_USE_LINKCHG_REG | 3129 (TG3_FLAG_USE_LINKCHG_REG |
@@ -2896,7 +3131,9 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2896 if (sblk->status & SD_STATUS_LINK_CHG) { 3131 if (sblk->status & SD_STATUS_LINK_CHG) {
2897 sblk->status = SD_STATUS_UPDATED | 3132 sblk->status = SD_STATUS_UPDATED |
2898 (sblk->status & ~SD_STATUS_LINK_CHG); 3133 (sblk->status & ~SD_STATUS_LINK_CHG);
3134 spin_lock(&tp->lock);
2899 tg3_setup_phy(tp, 0); 3135 tg3_setup_phy(tp, 0);
3136 spin_unlock(&tp->lock);
2900 } 3137 }
2901 } 3138 }
2902 3139
@@ -2907,8 +3144,6 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2907 spin_unlock(&tp->tx_lock); 3144 spin_unlock(&tp->tx_lock);
2908 } 3145 }
2909 3146
2910 spin_unlock_irqrestore(&tp->lock, flags);
2911
2912 /* run RX thread, within the bounds set by NAPI. 3147 /* run RX thread, within the bounds set by NAPI.
2913 * All RX "locking" is done by ensuring outside 3148 * All RX "locking" is done by ensuring outside
2914 * code synchronizes with dev->poll() 3149 * code synchronizes with dev->poll()
@@ -2929,19 +3164,54 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2929 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 3164 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
2930 tp->last_tag = sblk->status_tag; 3165 tp->last_tag = sblk->status_tag;
2931 rmb(); 3166 rmb();
3167 sblk->status &= ~SD_STATUS_UPDATED;
2932 3168
2933 /* if no more work, tell net stack and NIC we're done */ 3169 /* if no more work, tell net stack and NIC we're done */
2934 done = !tg3_has_work(tp); 3170 done = !tg3_has_work(tp);
2935 if (done) { 3171 if (done) {
2936 spin_lock_irqsave(&tp->lock, flags); 3172 spin_lock(&tp->lock);
2937 __netif_rx_complete(netdev); 3173 netif_rx_complete(netdev);
2938 tg3_restart_ints(tp); 3174 tg3_restart_ints(tp);
2939 spin_unlock_irqrestore(&tp->lock, flags); 3175 spin_unlock(&tp->lock);
2940 } 3176 }
2941 3177
2942 return (done ? 0 : 1); 3178 return (done ? 0 : 1);
2943} 3179}
2944 3180
3181static void tg3_irq_quiesce(struct tg3 *tp)
3182{
3183 BUG_ON(tp->irq_sync);
3184
3185 tp->irq_sync = 1;
3186 smp_mb();
3187
3188 synchronize_irq(tp->pdev->irq);
3189}
3190
3191static inline int tg3_irq_sync(struct tg3 *tp)
3192{
3193 return tp->irq_sync;
3194}
3195
3196/* Fully shutdown all tg3 driver activity elsewhere in the system.
3197 * If irq_sync is non-zero, then the IRQ handler must be synchronized
3198 * with as well. Most of the time, this is not necessary except when
3199 * shutting down the device.
3200 */
3201static inline void tg3_full_lock(struct tg3 *tp, int irq_sync)
3202{
3203 if (irq_sync)
3204 tg3_irq_quiesce(tp);
3205 spin_lock_bh(&tp->lock);
3206 spin_lock(&tp->tx_lock);
3207}
3208
3209static inline void tg3_full_unlock(struct tg3 *tp)
3210{
3211 spin_unlock(&tp->tx_lock);
3212 spin_unlock_bh(&tp->lock);
3213}
3214
2945/* MSI ISR - No need to check for interrupt sharing and no need to 3215/* MSI ISR - No need to check for interrupt sharing and no need to
2946 * flush status block and interrupt mailbox. PCI ordering rules 3216 * flush status block and interrupt mailbox. PCI ordering rules
2947 * guarantee that MSI will arrive after the status block. 3217 * guarantee that MSI will arrive after the status block.
@@ -2951,9 +3221,6 @@ static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
2951 struct net_device *dev = dev_id; 3221 struct net_device *dev = dev_id;
2952 struct tg3 *tp = netdev_priv(dev); 3222 struct tg3 *tp = netdev_priv(dev);
2953 struct tg3_hw_status *sblk = tp->hw_status; 3223 struct tg3_hw_status *sblk = tp->hw_status;
2954 unsigned long flags;
2955
2956 spin_lock_irqsave(&tp->lock, flags);
2957 3224
2958 /* 3225 /*
2959 * Writing any value to intr-mbox-0 clears PCI INTA# and 3226 * Writing any value to intr-mbox-0 clears PCI INTA# and
@@ -2964,6 +3231,9 @@ static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
2964 */ 3231 */
2965 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001); 3232 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
2966 tp->last_tag = sblk->status_tag; 3233 tp->last_tag = sblk->status_tag;
3234 rmb();
3235 if (tg3_irq_sync(tp))
3236 goto out;
2967 sblk->status &= ~SD_STATUS_UPDATED; 3237 sblk->status &= ~SD_STATUS_UPDATED;
2968 if (likely(tg3_has_work(tp))) 3238 if (likely(tg3_has_work(tp)))
2969 netif_rx_schedule(dev); /* schedule NAPI poll */ 3239 netif_rx_schedule(dev); /* schedule NAPI poll */
@@ -2972,9 +3242,7 @@ static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
2972 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 3242 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2973 tp->last_tag << 24); 3243 tp->last_tag << 24);
2974 } 3244 }
2975 3245out:
2976 spin_unlock_irqrestore(&tp->lock, flags);
2977
2978 return IRQ_RETVAL(1); 3246 return IRQ_RETVAL(1);
2979} 3247}
2980 3248
@@ -2983,11 +3251,8 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2983 struct net_device *dev = dev_id; 3251 struct net_device *dev = dev_id;
2984 struct tg3 *tp = netdev_priv(dev); 3252 struct tg3 *tp = netdev_priv(dev);
2985 struct tg3_hw_status *sblk = tp->hw_status; 3253 struct tg3_hw_status *sblk = tp->hw_status;
2986 unsigned long flags;
2987 unsigned int handled = 1; 3254 unsigned int handled = 1;
2988 3255
2989 spin_lock_irqsave(&tp->lock, flags);
2990
2991 /* In INTx mode, it is possible for the interrupt to arrive at 3256 /* In INTx mode, it is possible for the interrupt to arrive at
2992 * the CPU before the status block posted prior to the interrupt. 3257 * the CPU before the status block posted prior to the interrupt.
2993 * Reading the PCI State register will confirm whether the 3258 * Reading the PCI State register will confirm whether the
@@ -3004,6 +3269,8 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3004 */ 3269 */
3005 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 3270 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3006 0x00000001); 3271 0x00000001);
3272 if (tg3_irq_sync(tp))
3273 goto out;
3007 sblk->status &= ~SD_STATUS_UPDATED; 3274 sblk->status &= ~SD_STATUS_UPDATED;
3008 if (likely(tg3_has_work(tp))) 3275 if (likely(tg3_has_work(tp)))
3009 netif_rx_schedule(dev); /* schedule NAPI poll */ 3276 netif_rx_schedule(dev); /* schedule NAPI poll */
@@ -3018,9 +3285,7 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3018 } else { /* shared interrupt */ 3285 } else { /* shared interrupt */
3019 handled = 0; 3286 handled = 0;
3020 } 3287 }
3021 3288out:
3022 spin_unlock_irqrestore(&tp->lock, flags);
3023
3024 return IRQ_RETVAL(handled); 3289 return IRQ_RETVAL(handled);
3025} 3290}
3026 3291
@@ -3029,11 +3294,8 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *r
3029 struct net_device *dev = dev_id; 3294 struct net_device *dev = dev_id;
3030 struct tg3 *tp = netdev_priv(dev); 3295 struct tg3 *tp = netdev_priv(dev);
3031 struct tg3_hw_status *sblk = tp->hw_status; 3296 struct tg3_hw_status *sblk = tp->hw_status;
3032 unsigned long flags;
3033 unsigned int handled = 1; 3297 unsigned int handled = 1;
3034 3298
3035 spin_lock_irqsave(&tp->lock, flags);
3036
3037 /* In INTx mode, it is possible for the interrupt to arrive at 3299 /* In INTx mode, it is possible for the interrupt to arrive at
3038 * the CPU before the status block posted prior to the interrupt. 3300 * the CPU before the status block posted prior to the interrupt.
3039 * Reading the PCI State register will confirm whether the 3301 * Reading the PCI State register will confirm whether the
@@ -3051,6 +3313,9 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *r
3051 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 3313 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3052 0x00000001); 3314 0x00000001);
3053 tp->last_tag = sblk->status_tag; 3315 tp->last_tag = sblk->status_tag;
3316 rmb();
3317 if (tg3_irq_sync(tp))
3318 goto out;
3054 sblk->status &= ~SD_STATUS_UPDATED; 3319 sblk->status &= ~SD_STATUS_UPDATED;
3055 if (likely(tg3_has_work(tp))) 3320 if (likely(tg3_has_work(tp)))
3056 netif_rx_schedule(dev); /* schedule NAPI poll */ 3321 netif_rx_schedule(dev); /* schedule NAPI poll */
@@ -3065,9 +3330,7 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *r
3065 } else { /* shared interrupt */ 3330 } else { /* shared interrupt */
3066 handled = 0; 3331 handled = 0;
3067 } 3332 }
3068 3333out:
3069 spin_unlock_irqrestore(&tp->lock, flags);
3070
3071 return IRQ_RETVAL(handled); 3334 return IRQ_RETVAL(handled);
3072} 3335}
3073 3336
@@ -3106,8 +3369,7 @@ static void tg3_reset_task(void *_data)
3106 3369
3107 tg3_netif_stop(tp); 3370 tg3_netif_stop(tp);
3108 3371
3109 spin_lock_irq(&tp->lock); 3372 tg3_full_lock(tp, 1);
3110 spin_lock(&tp->tx_lock);
3111 3373
3112 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER; 3374 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER;
3113 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; 3375 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER;
@@ -3117,8 +3379,7 @@ static void tg3_reset_task(void *_data)
3117 3379
3118 tg3_netif_start(tp); 3380 tg3_netif_start(tp);
3119 3381
3120 spin_unlock(&tp->tx_lock); 3382 tg3_full_unlock(tp);
3121 spin_unlock_irq(&tp->lock);
3122 3383
3123 if (restart_timer) 3384 if (restart_timer)
3124 mod_timer(&tp->timer, jiffies + 1); 3385 mod_timer(&tp->timer, jiffies + 1);
@@ -3224,39 +3485,21 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3224 unsigned int i; 3485 unsigned int i;
3225 u32 len, entry, base_flags, mss; 3486 u32 len, entry, base_flags, mss;
3226 int would_hit_hwbug; 3487 int would_hit_hwbug;
3227 unsigned long flags;
3228 3488
3229 len = skb_headlen(skb); 3489 len = skb_headlen(skb);
3230 3490
3231 /* No BH disabling for tx_lock here. We are running in BH disabled 3491 /* No BH disabling for tx_lock here. We are running in BH disabled
3232 * context and TX reclaim runs via tp->poll inside of a software 3492 * context and TX reclaim runs via tp->poll inside of a software
3233 * interrupt. Rejoice! 3493 * interrupt. Furthermore, IRQ processing runs lockless so we have
3234 * 3494 * no IRQ context deadlocks to worry about either. Rejoice!
3235 * Actually, things are not so simple. If we are to take a hw
3236 * IRQ here, we can deadlock, consider:
3237 *
3238 * CPU1 CPU2
3239 * tg3_start_xmit
3240 * take tp->tx_lock
3241 * tg3_timer
3242 * take tp->lock
3243 * tg3_interrupt
3244 * spin on tp->lock
3245 * spin on tp->tx_lock
3246 *
3247 * So we really do need to disable interrupts when taking
3248 * tx_lock here.
3249 */ 3495 */
3250 local_irq_save(flags); 3496 if (!spin_trylock(&tp->tx_lock))
3251 if (!spin_trylock(&tp->tx_lock)) {
3252 local_irq_restore(flags);
3253 return NETDEV_TX_LOCKED; 3497 return NETDEV_TX_LOCKED;
3254 }
3255 3498
3256 /* This is a hard error, log it. */ 3499 /* This is a hard error, log it. */
3257 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { 3500 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) {
3258 netif_stop_queue(dev); 3501 netif_stop_queue(dev);
3259 spin_unlock_irqrestore(&tp->tx_lock, flags); 3502 spin_unlock(&tp->tx_lock);
3260 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n", 3503 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n",
3261 dev->name); 3504 dev->name);
3262 return NETDEV_TX_BUSY; 3505 return NETDEV_TX_BUSY;
@@ -3421,7 +3664,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3421 3664
3422out_unlock: 3665out_unlock:
3423 mmiowb(); 3666 mmiowb();
3424 spin_unlock_irqrestore(&tp->tx_lock, flags); 3667 spin_unlock(&tp->tx_lock);
3425 3668
3426 dev->trans_start = jiffies; 3669 dev->trans_start = jiffies;
3427 3670
@@ -3433,10 +3676,18 @@ static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp,
3433{ 3676{
3434 dev->mtu = new_mtu; 3677 dev->mtu = new_mtu;
3435 3678
3436 if (new_mtu > ETH_DATA_LEN) 3679 if (new_mtu > ETH_DATA_LEN) {
3437 tp->tg3_flags |= TG3_FLAG_JUMBO_ENABLE; 3680 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) {
3438 else 3681 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
3439 tp->tg3_flags &= ~TG3_FLAG_JUMBO_ENABLE; 3682 ethtool_op_set_tso(dev, 0);
3683 }
3684 else
3685 tp->tg3_flags |= TG3_FLAG_JUMBO_RING_ENABLE;
3686 } else {
3687 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780)
3688 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
3689 tp->tg3_flags &= ~TG3_FLAG_JUMBO_RING_ENABLE;
3690 }
3440} 3691}
3441 3692
3442static int tg3_change_mtu(struct net_device *dev, int new_mtu) 3693static int tg3_change_mtu(struct net_device *dev, int new_mtu)
@@ -3455,8 +3706,8 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu)
3455 } 3706 }
3456 3707
3457 tg3_netif_stop(tp); 3708 tg3_netif_stop(tp);
3458 spin_lock_irq(&tp->lock); 3709
3459 spin_lock(&tp->tx_lock); 3710 tg3_full_lock(tp, 1);
3460 3711
3461 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 3712 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
3462 3713
@@ -3466,8 +3717,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu)
3466 3717
3467 tg3_netif_start(tp); 3718 tg3_netif_start(tp);
3468 3719
3469 spin_unlock(&tp->tx_lock); 3720 tg3_full_unlock(tp);
3470 spin_unlock_irq(&tp->lock);
3471 3721
3472 return 0; 3722 return 0;
3473} 3723}
@@ -3491,7 +3741,7 @@ static void tg3_free_rings(struct tg3 *tp)
3491 continue; 3741 continue;
3492 pci_unmap_single(tp->pdev, 3742 pci_unmap_single(tp->pdev,
3493 pci_unmap_addr(rxp, mapping), 3743 pci_unmap_addr(rxp, mapping),
3494 RX_PKT_BUF_SZ - tp->rx_offset, 3744 tp->rx_pkt_buf_sz - tp->rx_offset,
3495 PCI_DMA_FROMDEVICE); 3745 PCI_DMA_FROMDEVICE);
3496 dev_kfree_skb_any(rxp->skb); 3746 dev_kfree_skb_any(rxp->skb);
3497 rxp->skb = NULL; 3747 rxp->skb = NULL;
@@ -3564,6 +3814,11 @@ static void tg3_init_rings(struct tg3 *tp)
3564 memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp)); 3814 memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));
3565 memset(tp->tx_ring, 0, TG3_TX_RING_BYTES); 3815 memset(tp->tx_ring, 0, TG3_TX_RING_BYTES);
3566 3816
3817 tp->rx_pkt_buf_sz = RX_PKT_BUF_SZ;
3818 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) &&
3819 (tp->dev->mtu > ETH_DATA_LEN))
3820 tp->rx_pkt_buf_sz = RX_JUMBO_PKT_BUF_SZ;
3821
3567 /* Initialize invariants of the rings, we only set this 3822 /* Initialize invariants of the rings, we only set this
3568 * stuff once. This works because the card does not 3823 * stuff once. This works because the card does not
3569 * write into the rx buffer posting rings. 3824 * write into the rx buffer posting rings.
@@ -3572,14 +3827,14 @@ static void tg3_init_rings(struct tg3 *tp)
3572 struct tg3_rx_buffer_desc *rxd; 3827 struct tg3_rx_buffer_desc *rxd;
3573 3828
3574 rxd = &tp->rx_std[i]; 3829 rxd = &tp->rx_std[i];
3575 rxd->idx_len = (RX_PKT_BUF_SZ - tp->rx_offset - 64) 3830 rxd->idx_len = (tp->rx_pkt_buf_sz - tp->rx_offset - 64)
3576 << RXD_LEN_SHIFT; 3831 << RXD_LEN_SHIFT;
3577 rxd->type_flags = (RXD_FLAG_END << RXD_FLAGS_SHIFT); 3832 rxd->type_flags = (RXD_FLAG_END << RXD_FLAGS_SHIFT);
3578 rxd->opaque = (RXD_OPAQUE_RING_STD | 3833 rxd->opaque = (RXD_OPAQUE_RING_STD |
3579 (i << RXD_OPAQUE_INDEX_SHIFT)); 3834 (i << RXD_OPAQUE_INDEX_SHIFT));
3580 } 3835 }
3581 3836
3582 if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) { 3837 if (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) {
3583 for (i = 0; i < TG3_RX_JUMBO_RING_SIZE; i++) { 3838 for (i = 0; i < TG3_RX_JUMBO_RING_SIZE; i++) {
3584 struct tg3_rx_buffer_desc *rxd; 3839 struct tg3_rx_buffer_desc *rxd;
3585 3840
@@ -3600,7 +3855,7 @@ static void tg3_init_rings(struct tg3 *tp)
3600 break; 3855 break;
3601 } 3856 }
3602 3857
3603 if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) { 3858 if (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) {
3604 for (i = 0; i < tp->rx_jumbo_pending; i++) { 3859 for (i = 0; i < tp->rx_jumbo_pending; i++) {
3605 if (tg3_alloc_rx_skb(tp, RXD_OPAQUE_RING_JUMBO, 3860 if (tg3_alloc_rx_skb(tp, RXD_OPAQUE_RING_JUMBO,
3606 -1, i) < 0) 3861 -1, i) < 0)
@@ -4056,7 +4311,30 @@ static int tg3_chip_reset(struct tg3 *tp)
4056 val &= ~PCIX_CAPS_RELAXED_ORDERING; 4311 val &= ~PCIX_CAPS_RELAXED_ORDERING;
4057 pci_write_config_dword(tp->pdev, TG3PCI_X_CAPS, val); 4312 pci_write_config_dword(tp->pdev, TG3PCI_X_CAPS, val);
4058 4313
4059 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE); 4314 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) {
4315 u32 val;
4316
4317 /* Chip reset on 5780 will reset MSI enable bit,
4318 * so need to restore it.
4319 */
4320 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
4321 u16 ctrl;
4322
4323 pci_read_config_word(tp->pdev,
4324 tp->msi_cap + PCI_MSI_FLAGS,
4325 &ctrl);
4326 pci_write_config_word(tp->pdev,
4327 tp->msi_cap + PCI_MSI_FLAGS,
4328 ctrl | PCI_MSI_FLAGS_ENABLE);
4329 val = tr32(MSGINT_MODE);
4330 tw32(MSGINT_MODE, val | MSGINT_MODE_ENABLE);
4331 }
4332
4333 val = tr32(MEMARB_MODE);
4334 tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE);
4335
4336 } else
4337 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
4060 4338
4061 if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A3) { 4339 if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A3) {
4062 tg3_stop_fw(tp); 4340 tg3_stop_fw(tp);
@@ -4082,6 +4360,9 @@ static int tg3_chip_reset(struct tg3 *tp)
4082 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { 4360 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) {
4083 tp->mac_mode = MAC_MODE_PORT_MODE_TBI; 4361 tp->mac_mode = MAC_MODE_PORT_MODE_TBI;
4084 tw32_f(MAC_MODE, tp->mac_mode); 4362 tw32_f(MAC_MODE, tp->mac_mode);
4363 } else if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
4364 tp->mac_mode = MAC_MODE_PORT_MODE_GMII;
4365 tw32_f(MAC_MODE, tp->mac_mode);
4085 } else 4366 } else
4086 tw32_f(MAC_MODE, 0); 4367 tw32_f(MAC_MODE, 0);
4087 udelay(40); 4368 udelay(40);
@@ -5088,9 +5369,9 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p)
5088 5369
5089 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 5370 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
5090 5371
5091 spin_lock_irq(&tp->lock); 5372 spin_lock_bh(&tp->lock);
5092 __tg3_set_mac_addr(tp); 5373 __tg3_set_mac_addr(tp);
5093 spin_unlock_irq(&tp->lock); 5374 spin_unlock_bh(&tp->lock);
5094 5375
5095 return 0; 5376 return 0;
5096} 5377}
@@ -5117,7 +5398,7 @@ static void tg3_set_bdinfo(struct tg3 *tp, u32 bdinfo_addr,
5117} 5398}
5118 5399
5119static void __tg3_set_rx_mode(struct net_device *); 5400static void __tg3_set_rx_mode(struct net_device *);
5120static void tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec) 5401static void __tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec)
5121{ 5402{
5122 tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs); 5403 tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs);
5123 tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs); 5404 tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs);
@@ -5245,7 +5526,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5245 } 5526 }
5246#endif 5527#endif
5247 5528
5248 if (!(tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE)) { 5529 if (tp->dev->mtu <= ETH_DATA_LEN) {
5249 tw32(BUFMGR_MB_RDMA_LOW_WATER, 5530 tw32(BUFMGR_MB_RDMA_LOW_WATER,
5250 tp->bufmgr_config.mbuf_read_dma_low_water); 5531 tp->bufmgr_config.mbuf_read_dma_low_water);
5251 tw32(BUFMGR_MB_MACRX_LOW_WATER, 5532 tw32(BUFMGR_MB_MACRX_LOW_WATER,
@@ -5320,7 +5601,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5320 /* Setup replenish threshold. */ 5601 /* Setup replenish threshold. */
5321 tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8); 5602 tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
5322 5603
5323 if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) { 5604 if (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) {
5324 tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH, 5605 tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH,
5325 ((u64) tp->rx_jumbo_mapping >> 32)); 5606 ((u64) tp->rx_jumbo_mapping >> 32));
5326 tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW, 5607 tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
@@ -5381,7 +5662,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5381 tw32_rx_mbox(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW, 5662 tw32_rx_mbox(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW,
5382 tp->rx_std_ptr); 5663 tp->rx_std_ptr);
5383 5664
5384 tp->rx_jumbo_ptr = (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) ? 5665 tp->rx_jumbo_ptr = (tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) ?
5385 tp->rx_jumbo_pending : 0; 5666 tp->rx_jumbo_pending : 0;
5386 tw32_rx_mbox(MAILBOX_RCV_JUMBO_PROD_IDX + TG3_64BIT_REG_LOW, 5667 tw32_rx_mbox(MAILBOX_RCV_JUMBO_PROD_IDX + TG3_64BIT_REG_LOW,
5387 tp->rx_jumbo_ptr); 5668 tp->rx_jumbo_ptr);
@@ -5460,7 +5741,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5460 udelay(10); 5741 udelay(10);
5461 } 5742 }
5462 5743
5463 tg3_set_coalesce(tp, &tp->coal); 5744 __tg3_set_coalesce(tp, &tp->coal);
5464 5745
5465 /* set status block DMA address */ 5746 /* set status block DMA address */
5466 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 5747 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
@@ -5683,7 +5964,8 @@ static int tg3_reset_hw(struct tg3 *tp)
5683 tw32(MAC_RCV_RULE_1, 0x86000004 & RCV_RULE_DISABLE_MASK); 5964 tw32(MAC_RCV_RULE_1, 0x86000004 & RCV_RULE_DISABLE_MASK);
5684 tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK); 5965 tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK);
5685 5966
5686 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) 5967 if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) &&
5968 (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5780))
5687 limit = 8; 5969 limit = 8;
5688 else 5970 else
5689 limit = 16; 5971 limit = 16;
@@ -5727,9 +6009,6 @@ static int tg3_reset_hw(struct tg3 *tp)
5727 6009
5728 tg3_write_sig_post_reset(tp, RESET_KIND_INIT); 6010 tg3_write_sig_post_reset(tp, RESET_KIND_INIT);
5729 6011
5730 if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE)
5731 tg3_enable_ints(tp);
5732
5733 return 0; 6012 return 0;
5734} 6013}
5735 6014
@@ -5802,10 +6081,8 @@ static void tg3_periodic_fetch_stats(struct tg3 *tp)
5802static void tg3_timer(unsigned long __opaque) 6081static void tg3_timer(unsigned long __opaque)
5803{ 6082{
5804 struct tg3 *tp = (struct tg3 *) __opaque; 6083 struct tg3 *tp = (struct tg3 *) __opaque;
5805 unsigned long flags;
5806 6084
5807 spin_lock_irqsave(&tp->lock, flags); 6085 spin_lock(&tp->lock);
5808 spin_lock(&tp->tx_lock);
5809 6086
5810 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) { 6087 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
5811 /* All of this garbage is because when using non-tagged 6088 /* All of this garbage is because when using non-tagged
@@ -5822,8 +6099,7 @@ static void tg3_timer(unsigned long __opaque)
5822 6099
5823 if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 6100 if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
5824 tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER; 6101 tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER;
5825 spin_unlock(&tp->tx_lock); 6102 spin_unlock(&tp->lock);
5826 spin_unlock_irqrestore(&tp->lock, flags);
5827 schedule_work(&tp->reset_task); 6103 schedule_work(&tp->reset_task);
5828 return; 6104 return;
5829 } 6105 }
@@ -5871,7 +6147,8 @@ static void tg3_timer(unsigned long __opaque)
5871 udelay(40); 6147 udelay(40);
5872 tg3_setup_phy(tp, 0); 6148 tg3_setup_phy(tp, 0);
5873 } 6149 }
5874 } 6150 } else if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES)
6151 tg3_serdes_parallel_detect(tp);
5875 6152
5876 tp->timer_counter = tp->timer_multiplier; 6153 tp->timer_counter = tp->timer_multiplier;
5877 } 6154 }
@@ -5891,8 +6168,7 @@ static void tg3_timer(unsigned long __opaque)
5891 tp->asf_counter = tp->asf_multiplier; 6168 tp->asf_counter = tp->asf_multiplier;
5892 } 6169 }
5893 6170
5894 spin_unlock(&tp->tx_lock); 6171 spin_unlock(&tp->lock);
5895 spin_unlock_irqrestore(&tp->lock, flags);
5896 6172
5897 tp->timer.expires = jiffies + tp->timer_offset; 6173 tp->timer.expires = jiffies + tp->timer_offset;
5898 add_timer(&tp->timer); 6174 add_timer(&tp->timer);
@@ -6007,14 +6283,12 @@ static int tg3_test_msi(struct tg3 *tp)
6007 /* Need to reset the chip because the MSI cycle may have terminated 6283 /* Need to reset the chip because the MSI cycle may have terminated
6008 * with Master Abort. 6284 * with Master Abort.
6009 */ 6285 */
6010 spin_lock_irq(&tp->lock); 6286 tg3_full_lock(tp, 1);
6011 spin_lock(&tp->tx_lock);
6012 6287
6013 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 6288 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
6014 err = tg3_init_hw(tp); 6289 err = tg3_init_hw(tp);
6015 6290
6016 spin_unlock(&tp->tx_lock); 6291 tg3_full_unlock(tp);
6017 spin_unlock_irq(&tp->lock);
6018 6292
6019 if (err) 6293 if (err)
6020 free_irq(tp->pdev->irq, dev); 6294 free_irq(tp->pdev->irq, dev);
@@ -6027,14 +6301,12 @@ static int tg3_open(struct net_device *dev)
6027 struct tg3 *tp = netdev_priv(dev); 6301 struct tg3 *tp = netdev_priv(dev);
6028 int err; 6302 int err;
6029 6303
6030 spin_lock_irq(&tp->lock); 6304 tg3_full_lock(tp, 0);
6031 spin_lock(&tp->tx_lock);
6032 6305
6033 tg3_disable_ints(tp); 6306 tg3_disable_ints(tp);
6034 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; 6307 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
6035 6308
6036 spin_unlock(&tp->tx_lock); 6309 tg3_full_unlock(tp);
6037 spin_unlock_irq(&tp->lock);
6038 6310
6039 /* The placement of this call is tied 6311 /* The placement of this call is tied
6040 * to the setup and use of Host TX descriptors. 6312 * to the setup and use of Host TX descriptors.
@@ -6081,8 +6353,7 @@ static int tg3_open(struct net_device *dev)
6081 return err; 6353 return err;
6082 } 6354 }
6083 6355
6084 spin_lock_irq(&tp->lock); 6356 tg3_full_lock(tp, 0);
6085 spin_lock(&tp->tx_lock);
6086 6357
6087 err = tg3_init_hw(tp); 6358 err = tg3_init_hw(tp);
6088 if (err) { 6359 if (err) {
@@ -6106,8 +6377,7 @@ static int tg3_open(struct net_device *dev)
6106 tp->timer.function = tg3_timer; 6377 tp->timer.function = tg3_timer;
6107 } 6378 }
6108 6379
6109 spin_unlock(&tp->tx_lock); 6380 tg3_full_unlock(tp);
6110 spin_unlock_irq(&tp->lock);
6111 6381
6112 if (err) { 6382 if (err) {
6113 free_irq(tp->pdev->irq, dev); 6383 free_irq(tp->pdev->irq, dev);
@@ -6123,8 +6393,7 @@ static int tg3_open(struct net_device *dev)
6123 err = tg3_test_msi(tp); 6393 err = tg3_test_msi(tp);
6124 6394
6125 if (err) { 6395 if (err) {
6126 spin_lock_irq(&tp->lock); 6396 tg3_full_lock(tp, 0);
6127 spin_lock(&tp->tx_lock);
6128 6397
6129 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { 6398 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6130 pci_disable_msi(tp->pdev); 6399 pci_disable_msi(tp->pdev);
@@ -6134,22 +6403,19 @@ static int tg3_open(struct net_device *dev)
6134 tg3_free_rings(tp); 6403 tg3_free_rings(tp);
6135 tg3_free_consistent(tp); 6404 tg3_free_consistent(tp);
6136 6405
6137 spin_unlock(&tp->tx_lock); 6406 tg3_full_unlock(tp);
6138 spin_unlock_irq(&tp->lock);
6139 6407
6140 return err; 6408 return err;
6141 } 6409 }
6142 } 6410 }
6143 6411
6144 spin_lock_irq(&tp->lock); 6412 tg3_full_lock(tp, 0);
6145 spin_lock(&tp->tx_lock);
6146 6413
6147 add_timer(&tp->timer); 6414 add_timer(&tp->timer);
6148 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; 6415 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
6149 tg3_enable_ints(tp); 6416 tg3_enable_ints(tp);
6150 6417
6151 spin_unlock(&tp->tx_lock); 6418 tg3_full_unlock(tp);
6152 spin_unlock_irq(&tp->lock);
6153 6419
6154 netif_start_queue(dev); 6420 netif_start_queue(dev);
6155 6421
@@ -6395,8 +6661,7 @@ static int tg3_close(struct net_device *dev)
6395 6661
6396 del_timer_sync(&tp->timer); 6662 del_timer_sync(&tp->timer);
6397 6663
6398 spin_lock_irq(&tp->lock); 6664 tg3_full_lock(tp, 1);
6399 spin_lock(&tp->tx_lock);
6400#if 0 6665#if 0
6401 tg3_dump_state(tp); 6666 tg3_dump_state(tp);
6402#endif 6667#endif
@@ -6410,8 +6675,7 @@ static int tg3_close(struct net_device *dev)
6410 TG3_FLAG_GOT_SERDES_FLOWCTL); 6675 TG3_FLAG_GOT_SERDES_FLOWCTL);
6411 netif_carrier_off(tp->dev); 6676 netif_carrier_off(tp->dev);
6412 6677
6413 spin_unlock(&tp->tx_lock); 6678 tg3_full_unlock(tp);
6414 spin_unlock_irq(&tp->lock);
6415 6679
6416 free_irq(tp->pdev->irq, dev); 6680 free_irq(tp->pdev->irq, dev);
6417 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { 6681 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
@@ -6448,16 +6712,15 @@ static unsigned long calc_crc_errors(struct tg3 *tp)
6448 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) && 6712 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) &&
6449 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 6713 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
6450 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) { 6714 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) {
6451 unsigned long flags;
6452 u32 val; 6715 u32 val;
6453 6716
6454 spin_lock_irqsave(&tp->lock, flags); 6717 spin_lock_bh(&tp->lock);
6455 if (!tg3_readphy(tp, 0x1e, &val)) { 6718 if (!tg3_readphy(tp, 0x1e, &val)) {
6456 tg3_writephy(tp, 0x1e, val | 0x8000); 6719 tg3_writephy(tp, 0x1e, val | 0x8000);
6457 tg3_readphy(tp, 0x14, &val); 6720 tg3_readphy(tp, 0x14, &val);
6458 } else 6721 } else
6459 val = 0; 6722 val = 0;
6460 spin_unlock_irqrestore(&tp->lock, flags); 6723 spin_unlock_bh(&tp->lock);
6461 6724
6462 tp->phy_crc_errors += val; 6725 tp->phy_crc_errors += val;
6463 6726
@@ -6719,11 +6982,9 @@ static void tg3_set_rx_mode(struct net_device *dev)
6719{ 6982{
6720 struct tg3 *tp = netdev_priv(dev); 6983 struct tg3 *tp = netdev_priv(dev);
6721 6984
6722 spin_lock_irq(&tp->lock); 6985 tg3_full_lock(tp, 0);
6723 spin_lock(&tp->tx_lock);
6724 __tg3_set_rx_mode(dev); 6986 __tg3_set_rx_mode(dev);
6725 spin_unlock(&tp->tx_lock); 6987 tg3_full_unlock(tp);
6726 spin_unlock_irq(&tp->lock);
6727} 6988}
6728 6989
6729#define TG3_REGDUMP_LEN (32 * 1024) 6990#define TG3_REGDUMP_LEN (32 * 1024)
@@ -6745,8 +7006,7 @@ static void tg3_get_regs(struct net_device *dev,
6745 7006
6746 memset(p, 0, TG3_REGDUMP_LEN); 7007 memset(p, 0, TG3_REGDUMP_LEN);
6747 7008
6748 spin_lock_irq(&tp->lock); 7009 tg3_full_lock(tp, 0);
6749 spin_lock(&tp->tx_lock);
6750 7010
6751#define __GET_REG32(reg) (*(p)++ = tr32(reg)) 7011#define __GET_REG32(reg) (*(p)++ = tr32(reg))
6752#define GET_REG32_LOOP(base,len) \ 7012#define GET_REG32_LOOP(base,len) \
@@ -6796,8 +7056,7 @@ do { p = (u32 *)(orig_p + (reg)); \
6796#undef GET_REG32_LOOP 7056#undef GET_REG32_LOOP
6797#undef GET_REG32_1 7057#undef GET_REG32_1
6798 7058
6799 spin_unlock(&tp->tx_lock); 7059 tg3_full_unlock(tp);
6800 spin_unlock_irq(&tp->lock);
6801} 7060}
6802 7061
6803static int tg3_get_eeprom_len(struct net_device *dev) 7062static int tg3_get_eeprom_len(struct net_device *dev)
@@ -6973,8 +7232,7 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
6973 return -EINVAL; 7232 return -EINVAL;
6974 } 7233 }
6975 7234
6976 spin_lock_irq(&tp->lock); 7235 tg3_full_lock(tp, 0);
6977 spin_lock(&tp->tx_lock);
6978 7236
6979 tp->link_config.autoneg = cmd->autoneg; 7237 tp->link_config.autoneg = cmd->autoneg;
6980 if (cmd->autoneg == AUTONEG_ENABLE) { 7238 if (cmd->autoneg == AUTONEG_ENABLE) {
@@ -6990,8 +7248,7 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
6990 if (netif_running(dev)) 7248 if (netif_running(dev))
6991 tg3_setup_phy(tp, 1); 7249 tg3_setup_phy(tp, 1);
6992 7250
6993 spin_unlock(&tp->tx_lock); 7251 tg3_full_unlock(tp);
6994 spin_unlock_irq(&tp->lock);
6995 7252
6996 return 0; 7253 return 0;
6997} 7254}
@@ -7027,12 +7284,12 @@ static int tg3_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
7027 !(tp->tg3_flags & TG3_FLAG_SERDES_WOL_CAP)) 7284 !(tp->tg3_flags & TG3_FLAG_SERDES_WOL_CAP))
7028 return -EINVAL; 7285 return -EINVAL;
7029 7286
7030 spin_lock_irq(&tp->lock); 7287 spin_lock_bh(&tp->lock);
7031 if (wol->wolopts & WAKE_MAGIC) 7288 if (wol->wolopts & WAKE_MAGIC)
7032 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 7289 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
7033 else 7290 else
7034 tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE; 7291 tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE;
7035 spin_unlock_irq(&tp->lock); 7292 spin_unlock_bh(&tp->lock);
7036 7293
7037 return 0; 7294 return 0;
7038} 7295}
@@ -7072,7 +7329,7 @@ static int tg3_nway_reset(struct net_device *dev)
7072 if (!netif_running(dev)) 7329 if (!netif_running(dev))
7073 return -EAGAIN; 7330 return -EAGAIN;
7074 7331
7075 spin_lock_irq(&tp->lock); 7332 spin_lock_bh(&tp->lock);
7076 r = -EINVAL; 7333 r = -EINVAL;
7077 tg3_readphy(tp, MII_BMCR, &bmcr); 7334 tg3_readphy(tp, MII_BMCR, &bmcr);
7078 if (!tg3_readphy(tp, MII_BMCR, &bmcr) && 7335 if (!tg3_readphy(tp, MII_BMCR, &bmcr) &&
@@ -7080,7 +7337,7 @@ static int tg3_nway_reset(struct net_device *dev)
7080 tg3_writephy(tp, MII_BMCR, bmcr | BMCR_ANRESTART); 7337 tg3_writephy(tp, MII_BMCR, bmcr | BMCR_ANRESTART);
7081 r = 0; 7338 r = 0;
7082 } 7339 }
7083 spin_unlock_irq(&tp->lock); 7340 spin_unlock_bh(&tp->lock);
7084 7341
7085 return r; 7342 return r;
7086} 7343}
@@ -7102,17 +7359,19 @@ static void tg3_get_ringparam(struct net_device *dev, struct ethtool_ringparam *
7102static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering) 7359static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
7103{ 7360{
7104 struct tg3 *tp = netdev_priv(dev); 7361 struct tg3 *tp = netdev_priv(dev);
7362 int irq_sync = 0;
7105 7363
7106 if ((ering->rx_pending > TG3_RX_RING_SIZE - 1) || 7364 if ((ering->rx_pending > TG3_RX_RING_SIZE - 1) ||
7107 (ering->rx_jumbo_pending > TG3_RX_JUMBO_RING_SIZE - 1) || 7365 (ering->rx_jumbo_pending > TG3_RX_JUMBO_RING_SIZE - 1) ||
7108 (ering->tx_pending > TG3_TX_RING_SIZE - 1)) 7366 (ering->tx_pending > TG3_TX_RING_SIZE - 1))
7109 return -EINVAL; 7367 return -EINVAL;
7110 7368
7111 if (netif_running(dev)) 7369 if (netif_running(dev)) {
7112 tg3_netif_stop(tp); 7370 tg3_netif_stop(tp);
7371 irq_sync = 1;
7372 }
7113 7373
7114 spin_lock_irq(&tp->lock); 7374 tg3_full_lock(tp, irq_sync);
7115 spin_lock(&tp->tx_lock);
7116 7375
7117 tp->rx_pending = ering->rx_pending; 7376 tp->rx_pending = ering->rx_pending;
7118 7377
@@ -7128,8 +7387,7 @@ static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *e
7128 tg3_netif_start(tp); 7387 tg3_netif_start(tp);
7129 } 7388 }
7130 7389
7131 spin_unlock(&tp->tx_lock); 7390 tg3_full_unlock(tp);
7132 spin_unlock_irq(&tp->lock);
7133 7391
7134 return 0; 7392 return 0;
7135} 7393}
@@ -7146,12 +7404,15 @@ static void tg3_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam
7146static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause) 7404static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
7147{ 7405{
7148 struct tg3 *tp = netdev_priv(dev); 7406 struct tg3 *tp = netdev_priv(dev);
7407 int irq_sync = 0;
7149 7408
7150 if (netif_running(dev)) 7409 if (netif_running(dev)) {
7151 tg3_netif_stop(tp); 7410 tg3_netif_stop(tp);
7411 irq_sync = 1;
7412 }
7413
7414 tg3_full_lock(tp, irq_sync);
7152 7415
7153 spin_lock_irq(&tp->lock);
7154 spin_lock(&tp->tx_lock);
7155 if (epause->autoneg) 7416 if (epause->autoneg)
7156 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; 7417 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG;
7157 else 7418 else
@@ -7170,8 +7431,8 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam
7170 tg3_init_hw(tp); 7431 tg3_init_hw(tp);
7171 tg3_netif_start(tp); 7432 tg3_netif_start(tp);
7172 } 7433 }
7173 spin_unlock(&tp->tx_lock); 7434
7174 spin_unlock_irq(&tp->lock); 7435 tg3_full_unlock(tp);
7175 7436
7176 return 0; 7437 return 0;
7177} 7438}
@@ -7192,12 +7453,12 @@ static int tg3_set_rx_csum(struct net_device *dev, u32 data)
7192 return 0; 7453 return 0;
7193 } 7454 }
7194 7455
7195 spin_lock_irq(&tp->lock); 7456 spin_lock_bh(&tp->lock);
7196 if (data) 7457 if (data)
7197 tp->tg3_flags |= TG3_FLAG_RX_CHECKSUMS; 7458 tp->tg3_flags |= TG3_FLAG_RX_CHECKSUMS;
7198 else 7459 else
7199 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS; 7460 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS;
7200 spin_unlock_irq(&tp->lock); 7461 spin_unlock_bh(&tp->lock);
7201 7462
7202 return 0; 7463 return 0;
7203} 7464}
@@ -7604,10 +7865,6 @@ static int tg3_test_loopback(struct tg3 *tp)
7604 7865
7605 err = -EIO; 7866 err = -EIO;
7606 7867
7607 tg3_abort_hw(tp, 1);
7608
7609 /* Clearing this flag to keep interrupts disabled */
7610 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
7611 tg3_reset_hw(tp); 7868 tg3_reset_hw(tp);
7612 7869
7613 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) | 7870 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
@@ -7716,11 +7973,14 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
7716 data[1] = 1; 7973 data[1] = 1;
7717 } 7974 }
7718 if (etest->flags & ETH_TEST_FL_OFFLINE) { 7975 if (etest->flags & ETH_TEST_FL_OFFLINE) {
7719 if (netif_running(dev)) 7976 int irq_sync = 0;
7977
7978 if (netif_running(dev)) {
7720 tg3_netif_stop(tp); 7979 tg3_netif_stop(tp);
7980 irq_sync = 1;
7981 }
7721 7982
7722 spin_lock_irq(&tp->lock); 7983 tg3_full_lock(tp, irq_sync);
7723 spin_lock(&tp->tx_lock);
7724 7984
7725 tg3_halt(tp, RESET_KIND_SUSPEND, 1); 7985 tg3_halt(tp, RESET_KIND_SUSPEND, 1);
7726 tg3_nvram_lock(tp); 7986 tg3_nvram_lock(tp);
@@ -7742,14 +8002,14 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
7742 data[4] = 1; 8002 data[4] = 1;
7743 } 8003 }
7744 8004
7745 spin_unlock(&tp->tx_lock); 8005 tg3_full_unlock(tp);
7746 spin_unlock_irq(&tp->lock); 8006
7747 if (tg3_test_interrupt(tp) != 0) { 8007 if (tg3_test_interrupt(tp) != 0) {
7748 etest->flags |= ETH_TEST_FL_FAILED; 8008 etest->flags |= ETH_TEST_FL_FAILED;
7749 data[5] = 1; 8009 data[5] = 1;
7750 } 8010 }
7751 spin_lock_irq(&tp->lock); 8011
7752 spin_lock(&tp->tx_lock); 8012 tg3_full_lock(tp, 0);
7753 8013
7754 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 8014 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
7755 if (netif_running(dev)) { 8015 if (netif_running(dev)) {
@@ -7757,8 +8017,8 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
7757 tg3_init_hw(tp); 8017 tg3_init_hw(tp);
7758 tg3_netif_start(tp); 8018 tg3_netif_start(tp);
7759 } 8019 }
7760 spin_unlock(&tp->tx_lock); 8020
7761 spin_unlock_irq(&tp->lock); 8021 tg3_full_unlock(tp);
7762 } 8022 }
7763} 8023}
7764 8024
@@ -7779,9 +8039,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
7779 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 8039 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
7780 break; /* We have no PHY */ 8040 break; /* We have no PHY */
7781 8041
7782 spin_lock_irq(&tp->lock); 8042 spin_lock_bh(&tp->lock);
7783 err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval); 8043 err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval);
7784 spin_unlock_irq(&tp->lock); 8044 spin_unlock_bh(&tp->lock);
7785 8045
7786 data->val_out = mii_regval; 8046 data->val_out = mii_regval;
7787 8047
@@ -7795,9 +8055,9 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
7795 if (!capable(CAP_NET_ADMIN)) 8055 if (!capable(CAP_NET_ADMIN))
7796 return -EPERM; 8056 return -EPERM;
7797 8057
7798 spin_lock_irq(&tp->lock); 8058 spin_lock_bh(&tp->lock);
7799 err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in); 8059 err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in);
7800 spin_unlock_irq(&tp->lock); 8060 spin_unlock_bh(&tp->lock);
7801 8061
7802 return err; 8062 return err;
7803 8063
@@ -7813,28 +8073,24 @@ static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
7813{ 8073{
7814 struct tg3 *tp = netdev_priv(dev); 8074 struct tg3 *tp = netdev_priv(dev);
7815 8075
7816 spin_lock_irq(&tp->lock); 8076 tg3_full_lock(tp, 0);
7817 spin_lock(&tp->tx_lock);
7818 8077
7819 tp->vlgrp = grp; 8078 tp->vlgrp = grp;
7820 8079
7821 /* Update RX_MODE_KEEP_VLAN_TAG bit in RX_MODE register. */ 8080 /* Update RX_MODE_KEEP_VLAN_TAG bit in RX_MODE register. */
7822 __tg3_set_rx_mode(dev); 8081 __tg3_set_rx_mode(dev);
7823 8082
7824 spin_unlock(&tp->tx_lock); 8083 tg3_full_unlock(tp);
7825 spin_unlock_irq(&tp->lock);
7826} 8084}
7827 8085
7828static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) 8086static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
7829{ 8087{
7830 struct tg3 *tp = netdev_priv(dev); 8088 struct tg3 *tp = netdev_priv(dev);
7831 8089
7832 spin_lock_irq(&tp->lock); 8090 tg3_full_lock(tp, 0);
7833 spin_lock(&tp->tx_lock);
7834 if (tp->vlgrp) 8091 if (tp->vlgrp)
7835 tp->vlgrp->vlan_devices[vid] = NULL; 8092 tp->vlgrp->vlan_devices[vid] = NULL;
7836 spin_unlock(&tp->tx_lock); 8093 tg3_full_unlock(tp);
7837 spin_unlock_irq(&tp->lock);
7838} 8094}
7839#endif 8095#endif
7840 8096
@@ -7846,6 +8102,60 @@ static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
7846 return 0; 8102 return 0;
7847} 8103}
7848 8104
8105static int tg3_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
8106{
8107 struct tg3 *tp = netdev_priv(dev);
8108 u32 max_rxcoal_tick_int = 0, max_txcoal_tick_int = 0;
8109 u32 max_stat_coal_ticks = 0, min_stat_coal_ticks = 0;
8110
8111 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
8112 max_rxcoal_tick_int = MAX_RXCOAL_TICK_INT;
8113 max_txcoal_tick_int = MAX_TXCOAL_TICK_INT;
8114 max_stat_coal_ticks = MAX_STAT_COAL_TICKS;
8115 min_stat_coal_ticks = MIN_STAT_COAL_TICKS;
8116 }
8117
8118 if ((ec->rx_coalesce_usecs > MAX_RXCOL_TICKS) ||
8119 (ec->tx_coalesce_usecs > MAX_TXCOL_TICKS) ||
8120 (ec->rx_max_coalesced_frames > MAX_RXMAX_FRAMES) ||
8121 (ec->tx_max_coalesced_frames > MAX_TXMAX_FRAMES) ||
8122 (ec->rx_coalesce_usecs_irq > max_rxcoal_tick_int) ||
8123 (ec->tx_coalesce_usecs_irq > max_txcoal_tick_int) ||
8124 (ec->rx_max_coalesced_frames_irq > MAX_RXCOAL_MAXF_INT) ||
8125 (ec->tx_max_coalesced_frames_irq > MAX_TXCOAL_MAXF_INT) ||
8126 (ec->stats_block_coalesce_usecs > max_stat_coal_ticks) ||
8127 (ec->stats_block_coalesce_usecs < min_stat_coal_ticks))
8128 return -EINVAL;
8129
8130 /* No rx interrupts will be generated if both are zero */
8131 if ((ec->rx_coalesce_usecs == 0) &&
8132 (ec->rx_max_coalesced_frames == 0))
8133 return -EINVAL;
8134
8135 /* No tx interrupts will be generated if both are zero */
8136 if ((ec->tx_coalesce_usecs == 0) &&
8137 (ec->tx_max_coalesced_frames == 0))
8138 return -EINVAL;
8139
8140 /* Only copy relevant parameters, ignore all others. */
8141 tp->coal.rx_coalesce_usecs = ec->rx_coalesce_usecs;
8142 tp->coal.tx_coalesce_usecs = ec->tx_coalesce_usecs;
8143 tp->coal.rx_max_coalesced_frames = ec->rx_max_coalesced_frames;
8144 tp->coal.tx_max_coalesced_frames = ec->tx_max_coalesced_frames;
8145 tp->coal.rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq;
8146 tp->coal.tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq;
8147 tp->coal.rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq;
8148 tp->coal.tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq;
8149 tp->coal.stats_block_coalesce_usecs = ec->stats_block_coalesce_usecs;
8150
8151 if (netif_running(dev)) {
8152 tg3_full_lock(tp, 0);
8153 __tg3_set_coalesce(tp, &tp->coal);
8154 tg3_full_unlock(tp);
8155 }
8156 return 0;
8157}
8158
7849static struct ethtool_ops tg3_ethtool_ops = { 8159static struct ethtool_ops tg3_ethtool_ops = {
7850 .get_settings = tg3_get_settings, 8160 .get_settings = tg3_get_settings,
7851 .set_settings = tg3_set_settings, 8161 .set_settings = tg3_set_settings,
@@ -7881,6 +8191,7 @@ static struct ethtool_ops tg3_ethtool_ops = {
7881 .get_stats_count = tg3_get_stats_count, 8191 .get_stats_count = tg3_get_stats_count,
7882 .get_ethtool_stats = tg3_get_ethtool_stats, 8192 .get_ethtool_stats = tg3_get_ethtool_stats,
7883 .get_coalesce = tg3_get_coalesce, 8193 .get_coalesce = tg3_get_coalesce,
8194 .set_coalesce = tg3_set_coalesce,
7884}; 8195};
7885 8196
7886static void __devinit tg3_get_eeprom_size(struct tg3 *tp) 8197static void __devinit tg3_get_eeprom_size(struct tg3 *tp)
@@ -8539,8 +8850,12 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
8539 eeprom_phy_id = 0; 8850 eeprom_phy_id = 0;
8540 8851
8541 tp->phy_id = eeprom_phy_id; 8852 tp->phy_id = eeprom_phy_id;
8542 if (eeprom_phy_serdes) 8853 if (eeprom_phy_serdes) {
8543 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 8854 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780)
8855 tp->tg3_flags2 |= TG3_FLG2_MII_SERDES;
8856 else
8857 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
8858 }
8544 8859
8545 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) 8860 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
8546 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK | 8861 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK |
@@ -8653,6 +8968,8 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
8653 tp->phy_id = hw_phy_id; 8968 tp->phy_id = hw_phy_id;
8654 if (hw_phy_id_masked == PHY_ID_BCM8002) 8969 if (hw_phy_id_masked == PHY_ID_BCM8002)
8655 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 8970 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
8971 else
8972 tp->tg3_flags2 &= ~TG3_FLG2_PHY_SERDES;
8656 } else { 8973 } else {
8657 if (tp->phy_id != PHY_ID_INVALID) { 8974 if (tp->phy_id != PHY_ID_INVALID) {
8658 /* Do nothing, phy ID already set up in 8975 /* Do nothing, phy ID already set up in
@@ -8675,7 +8992,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
8675 } 8992 }
8676 } 8993 }
8677 8994
8678 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) && 8995 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) &&
8679 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) { 8996 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
8680 u32 bmsr, adv_reg, tg3_ctrl; 8997 u32 bmsr, adv_reg, tg3_ctrl;
8681 8998
@@ -8728,7 +9045,7 @@ skip_phy_reset:
8728 err = tg3_init_5401phy_dsp(tp); 9045 err = tg3_init_5401phy_dsp(tp);
8729 } 9046 }
8730 9047
8731 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 9048 if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES)
8732 tp->link_config.advertising = 9049 tp->link_config.advertising =
8733 (ADVERTISED_1000baseT_Half | 9050 (ADVERTISED_1000baseT_Half |
8734 ADVERTISED_1000baseT_Full | 9051 ADVERTISED_1000baseT_Full |
@@ -8898,6 +9215,10 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8898 if (tp->pci_chip_rev_id == CHIPREV_ID_5752_A0_HW) 9215 if (tp->pci_chip_rev_id == CHIPREV_ID_5752_A0_HW)
8899 tp->pci_chip_rev_id = CHIPREV_ID_5752_A0; 9216 tp->pci_chip_rev_id = CHIPREV_ID_5752_A0;
8900 9217
9218 /* Find msi capability. */
9219 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780)
9220 tp->msi_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_MSI);
9221
8901 /* Initialize misc host control in PCI block. */ 9222 /* Initialize misc host control in PCI block. */
8902 tp->misc_host_ctrl |= (misc_ctrl_reg & 9223 tp->misc_host_ctrl |= (misc_ctrl_reg &
8903 MISC_HOST_CTRL_CHIPREV); 9224 MISC_HOST_CTRL_CHIPREV);
@@ -8913,7 +9234,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8913 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff; 9234 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff;
8914 9235
8915 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || 9236 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
8916 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 9237 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
9238 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780)
8917 tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; 9239 tp->tg3_flags2 |= TG3_FLG2_5750_PLUS;
8918 9240
8919 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) || 9241 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) ||
@@ -8923,6 +9245,11 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8923 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) 9245 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
8924 tp->tg3_flags2 |= TG3_FLG2_HW_TSO; 9246 tp->tg3_flags2 |= TG3_FLG2_HW_TSO;
8925 9247
9248 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
9249 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 &&
9250 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752)
9251 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE;
9252
8926 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 9253 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0)
8927 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 9254 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
8928 9255
@@ -9049,8 +9376,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9049 /* Derive initial jumbo mode from MTU assigned in 9376 /* Derive initial jumbo mode from MTU assigned in
9050 * ether_setup() via the alloc_etherdev() call 9377 * ether_setup() via the alloc_etherdev() call
9051 */ 9378 */
9052 if (tp->dev->mtu > ETH_DATA_LEN) 9379 if (tp->dev->mtu > ETH_DATA_LEN &&
9053 tp->tg3_flags |= TG3_FLAG_JUMBO_ENABLE; 9380 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5780)
9381 tp->tg3_flags |= TG3_FLAG_JUMBO_RING_ENABLE;
9054 9382
9055 /* Determine WakeOnLan speed to use. */ 9383 /* Determine WakeOnLan speed to use. */
9056 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 9384 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
@@ -9066,7 +9394,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9066 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) || 9394 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
9067 ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) && 9395 ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
9068 (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) && 9396 (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) &&
9069 (tp->pci_chip_rev_id != CHIPREV_ID_5705_A1))) 9397 (tp->pci_chip_rev_id != CHIPREV_ID_5705_A1)) ||
9398 (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES))
9070 tp->tg3_flags2 |= TG3_FLG2_NO_ETH_WIRE_SPEED; 9399 tp->tg3_flags2 |= TG3_FLG2_NO_ETH_WIRE_SPEED;
9071 9400
9072 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5703_AX || 9401 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5703_AX ||
@@ -9275,8 +9604,9 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
9275#endif 9604#endif
9276 9605
9277 mac_offset = 0x7c; 9606 mac_offset = 0x7c;
9278 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 && 9607 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 &&
9279 !(tp->tg3_flags & TG3_FLG2_SUN_570X)) { 9608 !(tp->tg3_flags & TG3_FLG2_SUN_570X)) ||
9609 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) {
9280 if (tr32(TG3PCI_DUAL_MAC_CTRL) & DUAL_MAC_CTRL_ID) 9610 if (tr32(TG3PCI_DUAL_MAC_CTRL) & DUAL_MAC_CTRL_ID)
9281 mac_offset = 0xcc; 9611 mac_offset = 0xcc;
9282 if (tg3_nvram_lock(tp)) 9612 if (tg3_nvram_lock(tp))
@@ -9590,6 +9920,9 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
9590 9920
9591 /* Set bit 23 to enable PCIX hw bug fix */ 9921 /* Set bit 23 to enable PCIX hw bug fix */
9592 tp->dma_rwctrl |= 0x009f0000; 9922 tp->dma_rwctrl |= 0x009f0000;
9923 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) {
9924 /* 5780 always in PCIX mode */
9925 tp->dma_rwctrl |= 0x00144000;
9593 } else { 9926 } else {
9594 tp->dma_rwctrl |= 0x001b000f; 9927 tp->dma_rwctrl |= 0x001b000f;
9595 } 9928 }
@@ -9743,19 +10076,35 @@ static void __devinit tg3_init_link_config(struct tg3 *tp)
9743 10076
9744static void __devinit tg3_init_bufmgr_config(struct tg3 *tp) 10077static void __devinit tg3_init_bufmgr_config(struct tg3 *tp)
9745{ 10078{
9746 tp->bufmgr_config.mbuf_read_dma_low_water = 10079 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
9747 DEFAULT_MB_RDMA_LOW_WATER; 10080 tp->bufmgr_config.mbuf_read_dma_low_water =
9748 tp->bufmgr_config.mbuf_mac_rx_low_water = 10081 DEFAULT_MB_RDMA_LOW_WATER_5705;
9749 DEFAULT_MB_MACRX_LOW_WATER; 10082 tp->bufmgr_config.mbuf_mac_rx_low_water =
9750 tp->bufmgr_config.mbuf_high_water = 10083 DEFAULT_MB_MACRX_LOW_WATER_5705;
9751 DEFAULT_MB_HIGH_WATER; 10084 tp->bufmgr_config.mbuf_high_water =
10085 DEFAULT_MB_HIGH_WATER_5705;
9752 10086
9753 tp->bufmgr_config.mbuf_read_dma_low_water_jumbo = 10087 tp->bufmgr_config.mbuf_read_dma_low_water_jumbo =
9754 DEFAULT_MB_RDMA_LOW_WATER_JUMBO; 10088 DEFAULT_MB_RDMA_LOW_WATER_JUMBO_5780;
9755 tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo = 10089 tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo =
9756 DEFAULT_MB_MACRX_LOW_WATER_JUMBO; 10090 DEFAULT_MB_MACRX_LOW_WATER_JUMBO_5780;
9757 tp->bufmgr_config.mbuf_high_water_jumbo = 10091 tp->bufmgr_config.mbuf_high_water_jumbo =
9758 DEFAULT_MB_HIGH_WATER_JUMBO; 10092 DEFAULT_MB_HIGH_WATER_JUMBO_5780;
10093 } else {
10094 tp->bufmgr_config.mbuf_read_dma_low_water =
10095 DEFAULT_MB_RDMA_LOW_WATER;
10096 tp->bufmgr_config.mbuf_mac_rx_low_water =
10097 DEFAULT_MB_MACRX_LOW_WATER;
10098 tp->bufmgr_config.mbuf_high_water =
10099 DEFAULT_MB_HIGH_WATER;
10100
10101 tp->bufmgr_config.mbuf_read_dma_low_water_jumbo =
10102 DEFAULT_MB_RDMA_LOW_WATER_JUMBO;
10103 tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo =
10104 DEFAULT_MB_MACRX_LOW_WATER_JUMBO;
10105 tp->bufmgr_config.mbuf_high_water_jumbo =
10106 DEFAULT_MB_HIGH_WATER_JUMBO;
10107 }
9759 10108
9760 tp->bufmgr_config.dma_low_water = DEFAULT_DMA_LOW_WATER; 10109 tp->bufmgr_config.dma_low_water = DEFAULT_DMA_LOW_WATER;
9761 tp->bufmgr_config.dma_high_water = DEFAULT_DMA_HIGH_WATER; 10110 tp->bufmgr_config.dma_high_water = DEFAULT_DMA_HIGH_WATER;
@@ -9773,6 +10122,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp)
9773 case PHY_ID_BCM5705: return "5705"; 10122 case PHY_ID_BCM5705: return "5705";
9774 case PHY_ID_BCM5750: return "5750"; 10123 case PHY_ID_BCM5750: return "5750";
9775 case PHY_ID_BCM5752: return "5752"; 10124 case PHY_ID_BCM5752: return "5752";
10125 case PHY_ID_BCM5780: return "5780";
9776 case PHY_ID_BCM8002: return "8002/serdes"; 10126 case PHY_ID_BCM8002: return "8002/serdes";
9777 case 0: return "serdes"; 10127 case 0: return "serdes";
9778 default: return "unknown"; 10128 default: return "unknown";
@@ -9825,6 +10175,12 @@ static void __devinit tg3_init_coal(struct tg3 *tp)
9825 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS; 10175 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS;
9826 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS; 10176 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS;
9827 } 10177 }
10178
10179 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
10180 ec->rx_coalesce_usecs_irq = 0;
10181 ec->tx_coalesce_usecs_irq = 0;
10182 ec->stats_block_coalesce_usecs = 0;
10183 }
9828} 10184}
9829 10185
9830static int __devinit tg3_init_one(struct pci_dev *pdev, 10186static int __devinit tg3_init_one(struct pci_dev *pdev,
@@ -9962,8 +10318,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
9962 10318
9963 tg3_init_link_config(tp); 10319 tg3_init_link_config(tp);
9964 10320
9965 tg3_init_bufmgr_config(tp);
9966
9967 tp->rx_pending = TG3_DEF_RX_RING_PENDING; 10321 tp->rx_pending = TG3_DEF_RX_RING_PENDING;
9968 tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING; 10322 tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING;
9969 tp->tx_pending = TG3_DEF_TX_RING_PENDING; 10323 tp->tx_pending = TG3_DEF_TX_RING_PENDING;
@@ -9992,14 +10346,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
9992 goto err_out_iounmap; 10346 goto err_out_iounmap;
9993 } 10347 }
9994 10348
9995 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { 10349 tg3_init_bufmgr_config(tp);
9996 tp->bufmgr_config.mbuf_read_dma_low_water =
9997 DEFAULT_MB_RDMA_LOW_WATER_5705;
9998 tp->bufmgr_config.mbuf_mac_rx_low_water =
9999 DEFAULT_MB_MACRX_LOW_WATER_5705;
10000 tp->bufmgr_config.mbuf_high_water =
10001 DEFAULT_MB_HIGH_WATER_5705;
10002 }
10003 10350
10004#if TG3_TSO_SUPPORT != 0 10351#if TG3_TSO_SUPPORT != 0
10005 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { 10352 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
@@ -10074,6 +10421,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10074 10421
10075 tg3_init_coal(tp); 10422 tg3_init_coal(tp);
10076 10423
10424 /* Now that we have fully setup the chip, save away a snapshot
10425 * of the PCI config space. We need to restore this after
10426 * GRC_MISC_CFG core clock resets and some resume events.
10427 */
10428 pci_save_state(tp->pdev);
10429
10077 err = register_netdev(dev); 10430 err = register_netdev(dev);
10078 if (err) { 10431 if (err) {
10079 printk(KERN_ERR PFX "Cannot register net device, " 10432 printk(KERN_ERR PFX "Cannot register net device, "
@@ -10083,12 +10436,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10083 10436
10084 pci_set_drvdata(pdev, dev); 10437 pci_set_drvdata(pdev, dev);
10085 10438
10086 /* Now that we have fully setup the chip, save away a snapshot
10087 * of the PCI config space. We need to restore this after
10088 * GRC_MISC_CFG core clock resets and some resume events.
10089 */
10090 pci_save_state(tp->pdev);
10091
10092 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (PCI%s:%s:%s) %sBaseT Ethernet ", 10439 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (PCI%s:%s:%s) %sBaseT Ethernet ",
10093 dev->name, 10440 dev->name,
10094 tp->board_part_number, 10441 tp->board_part_number,
@@ -10165,24 +10512,19 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
10165 10512
10166 del_timer_sync(&tp->timer); 10513 del_timer_sync(&tp->timer);
10167 10514
10168 spin_lock_irq(&tp->lock); 10515 tg3_full_lock(tp, 1);
10169 spin_lock(&tp->tx_lock);
10170 tg3_disable_ints(tp); 10516 tg3_disable_ints(tp);
10171 spin_unlock(&tp->tx_lock); 10517 tg3_full_unlock(tp);
10172 spin_unlock_irq(&tp->lock);
10173 10518
10174 netif_device_detach(dev); 10519 netif_device_detach(dev);
10175 10520
10176 spin_lock_irq(&tp->lock); 10521 tg3_full_lock(tp, 0);
10177 spin_lock(&tp->tx_lock);
10178 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 10522 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
10179 spin_unlock(&tp->tx_lock); 10523 tg3_full_unlock(tp);
10180 spin_unlock_irq(&tp->lock);
10181 10524
10182 err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); 10525 err = tg3_set_power_state(tp, pci_choose_state(pdev, state));
10183 if (err) { 10526 if (err) {
10184 spin_lock_irq(&tp->lock); 10527 tg3_full_lock(tp, 0);
10185 spin_lock(&tp->tx_lock);
10186 10528
10187 tg3_init_hw(tp); 10529 tg3_init_hw(tp);
10188 10530
@@ -10192,8 +10534,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
10192 netif_device_attach(dev); 10534 netif_device_attach(dev);
10193 tg3_netif_start(tp); 10535 tg3_netif_start(tp);
10194 10536
10195 spin_unlock(&tp->tx_lock); 10537 tg3_full_unlock(tp);
10196 spin_unlock_irq(&tp->lock);
10197 } 10538 }
10198 10539
10199 return err; 10540 return err;
@@ -10216,20 +10557,16 @@ static int tg3_resume(struct pci_dev *pdev)
10216 10557
10217 netif_device_attach(dev); 10558 netif_device_attach(dev);
10218 10559
10219 spin_lock_irq(&tp->lock); 10560 tg3_full_lock(tp, 0);
10220 spin_lock(&tp->tx_lock);
10221 10561
10222 tg3_init_hw(tp); 10562 tg3_init_hw(tp);
10223 10563
10224 tp->timer.expires = jiffies + tp->timer_offset; 10564 tp->timer.expires = jiffies + tp->timer_offset;
10225 add_timer(&tp->timer); 10565 add_timer(&tp->timer);
10226 10566
10227 tg3_enable_ints(tp);
10228
10229 tg3_netif_start(tp); 10567 tg3_netif_start(tp);
10230 10568
10231 spin_unlock(&tp->tx_lock); 10569 tg3_full_unlock(tp);
10232 spin_unlock_irq(&tp->lock);
10233 10570
10234 return 0; 10571 return 0;
10235} 10572}
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 993f84c93dc4..5c4433c147fa 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -136,6 +136,7 @@
136#define ASIC_REV_5705 0x03 136#define ASIC_REV_5705 0x03
137#define ASIC_REV_5750 0x04 137#define ASIC_REV_5750 0x04
138#define ASIC_REV_5752 0x06 138#define ASIC_REV_5752 0x06
139#define ASIC_REV_5780 0x08
139#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) 140#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
140#define CHIPREV_5700_AX 0x70 141#define CHIPREV_5700_AX 0x70
141#define CHIPREV_5700_BX 0x71 142#define CHIPREV_5700_BX 0x71
@@ -879,31 +880,41 @@
879#define LOW_RXCOL_TICKS_CLRTCKS 0x00000014 880#define LOW_RXCOL_TICKS_CLRTCKS 0x00000014
880#define DEFAULT_RXCOL_TICKS 0x00000048 881#define DEFAULT_RXCOL_TICKS 0x00000048
881#define HIGH_RXCOL_TICKS 0x00000096 882#define HIGH_RXCOL_TICKS 0x00000096
883#define MAX_RXCOL_TICKS 0x000003ff
882#define HOSTCC_TXCOL_TICKS 0x00003c0c 884#define HOSTCC_TXCOL_TICKS 0x00003c0c
883#define LOW_TXCOL_TICKS 0x00000096 885#define LOW_TXCOL_TICKS 0x00000096
884#define LOW_TXCOL_TICKS_CLRTCKS 0x00000048 886#define LOW_TXCOL_TICKS_CLRTCKS 0x00000048
885#define DEFAULT_TXCOL_TICKS 0x0000012c 887#define DEFAULT_TXCOL_TICKS 0x0000012c
886#define HIGH_TXCOL_TICKS 0x00000145 888#define HIGH_TXCOL_TICKS 0x00000145
889#define MAX_TXCOL_TICKS 0x000003ff
887#define HOSTCC_RXMAX_FRAMES 0x00003c10 890#define HOSTCC_RXMAX_FRAMES 0x00003c10
888#define LOW_RXMAX_FRAMES 0x00000005 891#define LOW_RXMAX_FRAMES 0x00000005
889#define DEFAULT_RXMAX_FRAMES 0x00000008 892#define DEFAULT_RXMAX_FRAMES 0x00000008
890#define HIGH_RXMAX_FRAMES 0x00000012 893#define HIGH_RXMAX_FRAMES 0x00000012
894#define MAX_RXMAX_FRAMES 0x000000ff
891#define HOSTCC_TXMAX_FRAMES 0x00003c14 895#define HOSTCC_TXMAX_FRAMES 0x00003c14
892#define LOW_TXMAX_FRAMES 0x00000035 896#define LOW_TXMAX_FRAMES 0x00000035
893#define DEFAULT_TXMAX_FRAMES 0x0000004b 897#define DEFAULT_TXMAX_FRAMES 0x0000004b
894#define HIGH_TXMAX_FRAMES 0x00000052 898#define HIGH_TXMAX_FRAMES 0x00000052
899#define MAX_TXMAX_FRAMES 0x000000ff
895#define HOSTCC_RXCOAL_TICK_INT 0x00003c18 900#define HOSTCC_RXCOAL_TICK_INT 0x00003c18
896#define DEFAULT_RXCOAL_TICK_INT 0x00000019 901#define DEFAULT_RXCOAL_TICK_INT 0x00000019
897#define DEFAULT_RXCOAL_TICK_INT_CLRTCKS 0x00000014 902#define DEFAULT_RXCOAL_TICK_INT_CLRTCKS 0x00000014
903#define MAX_RXCOAL_TICK_INT 0x000003ff
898#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c 904#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c
899#define DEFAULT_TXCOAL_TICK_INT 0x00000019 905#define DEFAULT_TXCOAL_TICK_INT 0x00000019
900#define DEFAULT_TXCOAL_TICK_INT_CLRTCKS 0x00000014 906#define DEFAULT_TXCOAL_TICK_INT_CLRTCKS 0x00000014
907#define MAX_TXCOAL_TICK_INT 0x000003ff
901#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20 908#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20
902#define DEFAULT_RXCOAL_MAXF_INT 0x00000005 909#define DEFAULT_RXCOAL_MAXF_INT 0x00000005
910#define MAX_RXCOAL_MAXF_INT 0x000000ff
903#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24 911#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24
904#define DEFAULT_TXCOAL_MAXF_INT 0x00000005 912#define DEFAULT_TXCOAL_MAXF_INT 0x00000005
913#define MAX_TXCOAL_MAXF_INT 0x000000ff
905#define HOSTCC_STAT_COAL_TICKS 0x00003c28 914#define HOSTCC_STAT_COAL_TICKS 0x00003c28
906#define DEFAULT_STAT_COAL_TICKS 0x000f4240 915#define DEFAULT_STAT_COAL_TICKS 0x000f4240
916#define MAX_STAT_COAL_TICKS 0xd693d400
917#define MIN_STAT_COAL_TICKS 0x00000064
907/* 0x3c2c --> 0x3c30 unused */ 918/* 0x3c2c --> 0x3c30 unused */
908#define HOSTCC_STATS_BLK_HOST_ADDR 0x00003c30 /* 64-bit */ 919#define HOSTCC_STATS_BLK_HOST_ADDR 0x00003c30 /* 64-bit */
909#define HOSTCC_STATUS_BLK_HOST_ADDR 0x00003c38 /* 64-bit */ 920#define HOSTCC_STATUS_BLK_HOST_ADDR 0x00003c38 /* 64-bit */
@@ -974,14 +985,17 @@
974#define DEFAULT_MB_RDMA_LOW_WATER 0x00000050 985#define DEFAULT_MB_RDMA_LOW_WATER 0x00000050
975#define DEFAULT_MB_RDMA_LOW_WATER_5705 0x00000000 986#define DEFAULT_MB_RDMA_LOW_WATER_5705 0x00000000
976#define DEFAULT_MB_RDMA_LOW_WATER_JUMBO 0x00000130 987#define DEFAULT_MB_RDMA_LOW_WATER_JUMBO 0x00000130
988#define DEFAULT_MB_RDMA_LOW_WATER_JUMBO_5780 0x00000000
977#define BUFMGR_MB_MACRX_LOW_WATER 0x00004414 989#define BUFMGR_MB_MACRX_LOW_WATER 0x00004414
978#define DEFAULT_MB_MACRX_LOW_WATER 0x00000020 990#define DEFAULT_MB_MACRX_LOW_WATER 0x00000020
979#define DEFAULT_MB_MACRX_LOW_WATER_5705 0x00000010 991#define DEFAULT_MB_MACRX_LOW_WATER_5705 0x00000010
980#define DEFAULT_MB_MACRX_LOW_WATER_JUMBO 0x00000098 992#define DEFAULT_MB_MACRX_LOW_WATER_JUMBO 0x00000098
993#define DEFAULT_MB_MACRX_LOW_WATER_JUMBO_5780 0x0000004b
981#define BUFMGR_MB_HIGH_WATER 0x00004418 994#define BUFMGR_MB_HIGH_WATER 0x00004418
982#define DEFAULT_MB_HIGH_WATER 0x00000060 995#define DEFAULT_MB_HIGH_WATER 0x00000060
983#define DEFAULT_MB_HIGH_WATER_5705 0x00000060 996#define DEFAULT_MB_HIGH_WATER_5705 0x00000060
984#define DEFAULT_MB_HIGH_WATER_JUMBO 0x0000017c 997#define DEFAULT_MB_HIGH_WATER_JUMBO 0x0000017c
998#define DEFAULT_MB_HIGH_WATER_JUMBO_5780 0x00000096
985#define BUFMGR_RX_MB_ALLOC_REQ 0x0000441c 999#define BUFMGR_RX_MB_ALLOC_REQ 0x0000441c
986#define BUFMGR_MB_ALLOC_BIT 0x10000000 1000#define BUFMGR_MB_ALLOC_BIT 0x10000000
987#define BUFMGR_RX_MB_ALLOC_RESP 0x00004420 1001#define BUFMGR_RX_MB_ALLOC_RESP 0x00004420
@@ -2006,17 +2020,31 @@ struct tg3_ethtool_stats {
2006struct tg3 { 2020struct tg3 {
2007 /* begin "general, frequently-used members" cacheline section */ 2021 /* begin "general, frequently-used members" cacheline section */
2008 2022
2023 /* If the IRQ handler (which runs lockless) needs to be
2024 * quiesced, the following bitmask state is used. The
2025 * SYNC flag is set by non-IRQ context code to initiate
2026 * the quiescence.
2027 *
2028 * When the IRQ handler notices that SYNC is set, it
2029 * disables interrupts and returns.
2030 *
2031 * When all outstanding IRQ handlers have returned after
2032 * the SYNC flag has been set, the setter can be assured
2033 * that interrupts will no longer get run.
2034 *
2035 * In this way all SMP driver locks are never acquired
2036 * in hw IRQ context, only sw IRQ context or lower.
2037 */
2038 unsigned int irq_sync;
2039
2009 /* SMP locking strategy: 2040 /* SMP locking strategy:
2010 * 2041 *
2011 * lock: Held during all operations except TX packet 2042 * lock: Held during all operations except TX packet
2012 * processing. 2043 * processing.
2013 * 2044 *
2014 * tx_lock: Held during tg3_start_xmit{,_4gbug} and tg3_tx 2045 * tx_lock: Held during tg3_start_xmit and tg3_tx
2015 * 2046 *
2016 * If you want to shut up all asynchronous processing you must 2047 * Both of these locks are to be held with BH safety.
2017 * acquire both locks, 'lock' taken before 'tx_lock'. IRQs must
2018 * be disabled to take 'lock' but only softirq disabling is
2019 * necessary for acquisition of 'tx_lock'.
2020 */ 2048 */
2021 spinlock_t lock; 2049 spinlock_t lock;
2022 spinlock_t indirect_lock; 2050 spinlock_t indirect_lock;
@@ -2063,6 +2091,8 @@ struct tg3 {
2063 struct tg3_rx_buffer_desc *rx_rcb; 2091 struct tg3_rx_buffer_desc *rx_rcb;
2064 dma_addr_t rx_rcb_mapping; 2092 dma_addr_t rx_rcb_mapping;
2065 2093
2094 u32 rx_pkt_buf_sz;
2095
2066 /* begin "everything else" cacheline(s) section */ 2096 /* begin "everything else" cacheline(s) section */
2067 struct net_device_stats net_stats; 2097 struct net_device_stats net_stats;
2068 struct net_device_stats net_stats_prev; 2098 struct net_device_stats net_stats_prev;
@@ -2100,7 +2130,7 @@ struct tg3 {
2100#define TG3_FLAG_NO_TX_PSEUDO_CSUM 0x00100000 2130#define TG3_FLAG_NO_TX_PSEUDO_CSUM 0x00100000
2101#define TG3_FLAG_NO_RX_PSEUDO_CSUM 0x00200000 2131#define TG3_FLAG_NO_RX_PSEUDO_CSUM 0x00200000
2102#define TG3_FLAG_SERDES_WOL_CAP 0x00400000 2132#define TG3_FLAG_SERDES_WOL_CAP 0x00400000
2103#define TG3_FLAG_JUMBO_ENABLE 0x00800000 2133#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000
2104#define TG3_FLAG_10_100_ONLY 0x01000000 2134#define TG3_FLAG_10_100_ONLY 0x01000000
2105#define TG3_FLAG_PAUSE_AUTONEG 0x02000000 2135#define TG3_FLAG_PAUSE_AUTONEG 0x02000000
2106#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000 2136#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000
@@ -2130,6 +2160,11 @@ struct tg3 {
2130#define TG3_FLG2_5750_PLUS 0x00080000 2160#define TG3_FLG2_5750_PLUS 0x00080000
2131#define TG3_FLG2_PROTECTED_NVRAM 0x00100000 2161#define TG3_FLG2_PROTECTED_NVRAM 0x00100000
2132#define TG3_FLG2_USING_MSI 0x00200000 2162#define TG3_FLG2_USING_MSI 0x00200000
2163#define TG3_FLG2_JUMBO_CAPABLE 0x00400000
2164#define TG3_FLG2_MII_SERDES 0x00800000
2165#define TG3_FLG2_ANY_SERDES (TG3_FLG2_PHY_SERDES | \
2166 TG3_FLG2_MII_SERDES)
2167#define TG3_FLG2_PARALLEL_DETECT 0x01000000
2133 2168
2134 u32 split_mode_max_reqs; 2169 u32 split_mode_max_reqs;
2135#define SPLIT_MODE_5704_MAX_REQ 3 2170#define SPLIT_MODE_5704_MAX_REQ 3
@@ -2163,6 +2198,7 @@ struct tg3 {
2163 u8 pci_bist; 2198 u8 pci_bist;
2164 2199
2165 int pm_cap; 2200 int pm_cap;
2201 int msi_cap;
2166 2202
2167 /* PHY info */ 2203 /* PHY info */
2168 u32 phy_id; 2204 u32 phy_id;
@@ -2176,6 +2212,7 @@ struct tg3 {
2176#define PHY_ID_BCM5705 0x600081a0 2212#define PHY_ID_BCM5705 0x600081a0
2177#define PHY_ID_BCM5750 0x60008180 2213#define PHY_ID_BCM5750 0x60008180
2178#define PHY_ID_BCM5752 0x60008100 2214#define PHY_ID_BCM5752 0x60008100
2215#define PHY_ID_BCM5780 0x60008350
2179#define PHY_ID_BCM8002 0x60010140 2216#define PHY_ID_BCM8002 0x60010140
2180#define PHY_ID_INVALID 0xffffffff 2217#define PHY_ID_INVALID 0xffffffff
2181#define PHY_ID_REV_MASK 0x0000000f 2218#define PHY_ID_REV_MASK 0x0000000f
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index cf31c0629852..942fae0f2130 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -171,6 +171,7 @@
171#include <linux/ioport.h> 171#include <linux/ioport.h>
172#include <linux/eisa.h> 172#include <linux/eisa.h>
173#include <linux/pci.h> 173#include <linux/pci.h>
174#include <linux/dma-mapping.h>
174#include <linux/netdevice.h> 175#include <linux/netdevice.h>
175#include <linux/etherdevice.h> 176#include <linux/etherdevice.h>
176#include <linux/delay.h> 177#include <linux/delay.h>
@@ -566,7 +567,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
566 567
567 priv->adapter = &board_info[ent->driver_data]; 568 priv->adapter = &board_info[ent->driver_data];
568 569
569 rc = pci_set_dma_mask(pdev, 0xFFFFFFFF); 570 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
570 if (rc) { 571 if (rc) {
571 printk(KERN_ERR "TLAN: No suitable PCI mapping available.\n"); 572 printk(KERN_ERR "TLAN: No suitable PCI mapping available.\n");
572 goto err_out_free_dev; 573 goto err_out_free_dev;
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 0d1dcf421771..41e0cd8f4786 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -276,7 +276,8 @@ static void xl_ee_write(struct net_device *dev, int ee_addr, u16 ee_value)
276 return ; 276 return ;
277} 277}
278 278
279int __devinit xl_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 279static int __devinit xl_probe(struct pci_dev *pdev,
280 const struct pci_device_id *ent)
280{ 281{
281 struct net_device *dev ; 282 struct net_device *dev ;
282 struct xl_private *xl_priv ; 283 struct xl_private *xl_priv ;
diff --git a/drivers/net/tokenring/3c359_microcode.h b/drivers/net/tokenring/3c359_microcode.h
index 81354afa3d34..0400c029c077 100644
--- a/drivers/net/tokenring/3c359_microcode.h
+++ b/drivers/net/tokenring/3c359_microcode.h
@@ -22,7 +22,7 @@
22 22
23static int mc_size = 24880 ; 23static int mc_size = 24880 ;
24 24
25u8 microcode[] = { 25static const u8 microcode[] = {
26 0xfe,0x3a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 26 0xfe,0x3a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
diff --git a/drivers/net/tokenring/Kconfig b/drivers/net/tokenring/Kconfig
index 23d0fa4bbceb..e4cfc80b283b 100644
--- a/drivers/net/tokenring/Kconfig
+++ b/drivers/net/tokenring/Kconfig
@@ -84,7 +84,7 @@ config 3C359
84 84
85config TMS380TR 85config TMS380TR
86 tristate "Generic TMS380 Token Ring ISA/PCI adapter support" 86 tristate "Generic TMS380 Token Ring ISA/PCI adapter support"
87 depends on TR && (PCI || ISA) 87 depends on TR && (PCI || ISA && ISA_DMA_API || MCA)
88 select FW_LOADER 88 select FW_LOADER
89 ---help--- 89 ---help---
90 This driver provides generic support for token ring adapters 90 This driver provides generic support for token ring adapters
@@ -158,7 +158,7 @@ config ABYSS
158 158
159config MADGEMC 159config MADGEMC
160 tristate "Madge Smart 16/4 Ringnode MicroChannel" 160 tristate "Madge Smart 16/4 Ringnode MicroChannel"
161 depends on TR && TMS380TR && MCA_LEGACY 161 depends on TR && TMS380TR && MCA
162 help 162 help
163 This tms380 module supports the Madge Smart 16/4 MC16 and MC32 163 This tms380 module supports the Madge Smart 16/4 MC16 and MC32
164 MicroChannel adapters. 164 MicroChannel adapters.
diff --git a/drivers/net/tokenring/abyss.c b/drivers/net/tokenring/abyss.c
index bd4a2bccf867..9345e68c451e 100644
--- a/drivers/net/tokenring/abyss.c
+++ b/drivers/net/tokenring/abyss.c
@@ -139,7 +139,7 @@ static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_
139 */ 139 */
140 dev->base_addr += 0x10; 140 dev->base_addr += 0x10;
141 141
142 ret = tmsdev_init(dev, PCI_MAX_ADDRESS, pdev); 142 ret = tmsdev_init(dev, &pdev->dev);
143 if (ret) { 143 if (ret) {
144 printk("%s: unable to get memory for dev->priv.\n", 144 printk("%s: unable to get memory for dev->priv.\n",
145 dev->name); 145 dev->name);
@@ -468,14 +468,3 @@ static void __exit abyss_rmmod (void)
468module_init(abyss_init); 468module_init(abyss_init);
469module_exit(abyss_rmmod); 469module_exit(abyss_rmmod);
470 470
471
472/*
473 * Local variables:
474 * compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c abyss.c"
475 * alt-compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c abyss.c"
476 * c-set-style "K&R"
477 * c-indent-level: 8
478 * c-basic-offset: 8
479 * tab-width: 8
480 * End:
481 */
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index 3873917a9c22..e7b001017b9a 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -151,7 +151,7 @@ static char version[] __initdata =
151 151
152/* this allows displaying full adapter information */ 152/* this allows displaying full adapter information */
153 153
154char *channel_def[] __devinitdata = { "ISA", "MCA", "ISA P&P" }; 154static char *channel_def[] __devinitdata = { "ISA", "MCA", "ISA P&P" };
155 155
156static char pcchannelid[] __devinitdata = { 156static char pcchannelid[] __devinitdata = {
157 0x05, 0x00, 0x04, 0x09, 157 0x05, 0x00, 0x04, 0x09,
@@ -171,7 +171,7 @@ static char mcchannelid[] __devinitdata = {
171 0x03, 0x08, 0x02, 0x00 171 0x03, 0x08, 0x02, 0x00
172}; 172};
173 173
174char __devinit *adapter_def(char type) 174static char __devinit *adapter_def(char type)
175{ 175{
176 switch (type) { 176 switch (type) {
177 case 0xF: return "PC Adapter | PC Adapter II | Adapter/A"; 177 case 0xF: return "PC Adapter | PC Adapter II | Adapter/A";
@@ -184,7 +184,7 @@ char __devinit *adapter_def(char type)
184 184
185#define TRC_INIT 0x01 /* Trace initialization & PROBEs */ 185#define TRC_INIT 0x01 /* Trace initialization & PROBEs */
186#define TRC_INITV 0x02 /* verbose init trace points */ 186#define TRC_INITV 0x02 /* verbose init trace points */
187unsigned char ibmtr_debug_trace = 0; 187static unsigned char ibmtr_debug_trace = 0;
188 188
189static int ibmtr_probe(struct net_device *dev); 189static int ibmtr_probe(struct net_device *dev);
190static int ibmtr_probe1(struct net_device *dev, int ioaddr); 190static int ibmtr_probe1(struct net_device *dev, int ioaddr);
@@ -192,20 +192,20 @@ static unsigned char get_sram_size(struct tok_info *adapt_info);
192static int trdev_init(struct net_device *dev); 192static int trdev_init(struct net_device *dev);
193static int tok_open(struct net_device *dev); 193static int tok_open(struct net_device *dev);
194static int tok_init_card(struct net_device *dev); 194static int tok_init_card(struct net_device *dev);
195void tok_open_adapter(unsigned long dev_addr); 195static void tok_open_adapter(unsigned long dev_addr);
196static void open_sap(unsigned char type, struct net_device *dev); 196static void open_sap(unsigned char type, struct net_device *dev);
197static void tok_set_multicast_list(struct net_device *dev); 197static void tok_set_multicast_list(struct net_device *dev);
198static int tok_send_packet(struct sk_buff *skb, struct net_device *dev); 198static int tok_send_packet(struct sk_buff *skb, struct net_device *dev);
199static int tok_close(struct net_device *dev); 199static int tok_close(struct net_device *dev);
200irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs); 200static irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs);
201static void initial_tok_int(struct net_device *dev); 201static void initial_tok_int(struct net_device *dev);
202static void tr_tx(struct net_device *dev); 202static void tr_tx(struct net_device *dev);
203static void tr_rx(struct net_device *dev); 203static void tr_rx(struct net_device *dev);
204void ibmtr_reset_timer(struct timer_list*tmr,struct net_device *dev); 204static void ibmtr_reset_timer(struct timer_list*tmr,struct net_device *dev);
205static void tok_rerun(unsigned long dev_addr); 205static void tok_rerun(unsigned long dev_addr);
206void ibmtr_readlog(struct net_device *dev); 206static void ibmtr_readlog(struct net_device *dev);
207static struct net_device_stats *tok_get_stats(struct net_device *dev); 207static struct net_device_stats *tok_get_stats(struct net_device *dev);
208int ibmtr_change_mtu(struct net_device *dev, int mtu); 208static int ibmtr_change_mtu(struct net_device *dev, int mtu);
209static void find_turbo_adapters(int *iolist); 209static void find_turbo_adapters(int *iolist);
210 210
211static int ibmtr_portlist[IBMTR_MAX_ADAPTERS+1] __devinitdata = { 211static int ibmtr_portlist[IBMTR_MAX_ADAPTERS+1] __devinitdata = {
@@ -928,7 +928,7 @@ static int tok_open(struct net_device *dev)
928#define DLC_MAX_SAP_OFST 32 928#define DLC_MAX_SAP_OFST 32
929#define DLC_MAX_STA_OFST 33 929#define DLC_MAX_STA_OFST 33
930 930
931void tok_open_adapter(unsigned long dev_addr) 931static void tok_open_adapter(unsigned long dev_addr)
932{ 932{
933 struct net_device *dev = (struct net_device *) dev_addr; 933 struct net_device *dev = (struct net_device *) dev_addr;
934 struct tok_info *ti; 934 struct tok_info *ti;
@@ -1099,7 +1099,7 @@ static void __iomem *map_address(struct tok_info *ti, unsigned index, __u8 *page
1099 return ti->sram_virt + index; 1099 return ti->sram_virt + index;
1100} 1100}
1101 1101
1102void dir_open_adapter (struct net_device *dev) 1102static void dir_open_adapter (struct net_device *dev)
1103{ 1103{
1104 struct tok_info *ti = (struct tok_info *) dev->priv; 1104 struct tok_info *ti = (struct tok_info *) dev->priv;
1105 unsigned char ret_code; 1105 unsigned char ret_code;
@@ -1172,7 +1172,7 @@ void dir_open_adapter (struct net_device *dev)
1172 1172
1173/******************************************************************************/ 1173/******************************************************************************/
1174 1174
1175irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1175static irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1176{ 1176{
1177 unsigned char status; 1177 unsigned char status;
1178 /* unsigned char status_even ; */ 1178 /* unsigned char status_even ; */
@@ -1840,7 +1840,7 @@ static void tr_rx(struct net_device *dev)
1840 1840
1841/*****************************************************************************/ 1841/*****************************************************************************/
1842 1842
1843void ibmtr_reset_timer(struct timer_list *tmr, struct net_device *dev) 1843static void ibmtr_reset_timer(struct timer_list *tmr, struct net_device *dev)
1844{ 1844{
1845 tmr->expires = jiffies + TR_RETRY_INTERVAL; 1845 tmr->expires = jiffies + TR_RETRY_INTERVAL;
1846 tmr->data = (unsigned long) dev; 1846 tmr->data = (unsigned long) dev;
@@ -1872,7 +1872,7 @@ void tok_rerun(unsigned long dev_addr){
1872 1872
1873/*****************************************************************************/ 1873/*****************************************************************************/
1874 1874
1875void ibmtr_readlog(struct net_device *dev) 1875static void ibmtr_readlog(struct net_device *dev)
1876{ 1876{
1877 struct tok_info *ti; 1877 struct tok_info *ti;
1878 1878
@@ -1905,7 +1905,7 @@ static struct net_device_stats *tok_get_stats(struct net_device *dev)
1905 1905
1906/*****************************************************************************/ 1906/*****************************************************************************/
1907 1907
1908int ibmtr_change_mtu(struct net_device *dev, int mtu) 1908static int ibmtr_change_mtu(struct net_device *dev, int mtu)
1909{ 1909{
1910 struct tok_info *ti = (struct tok_info *) dev->priv; 1910 struct tok_info *ti = (struct tok_info *) dev->priv;
1911 1911
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 99e0b03b69a8..97712c3c4e07 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -118,6 +118,7 @@
118#include <linux/stddef.h> 118#include <linux/stddef.h>
119#include <linux/init.h> 119#include <linux/init.h>
120#include <linux/pci.h> 120#include <linux/pci.h>
121#include <linux/dma-mapping.h>
121#include <linux/spinlock.h> 122#include <linux/spinlock.h>
122#include <linux/version.h> 123#include <linux/version.h>
123#include <linux/bitops.h> 124#include <linux/bitops.h>
@@ -257,7 +258,7 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
257#endif 258#endif
258#endif 259#endif
259 260
260 rc = pci_set_dma_mask(pdev, 0xFFFFFFFFULL); 261 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
261 if (rc) { 262 if (rc) {
262 printk(KERN_ERR "%s: No suitable PCI mapping available.\n", 263 printk(KERN_ERR "%s: No suitable PCI mapping available.\n",
263 dev->name); 264 dev->name);
@@ -454,8 +455,7 @@ static int streamer_reset(struct net_device *dev)
454 writew(readw(streamer_mmio + BCTL) | BCTL_SOFTRESET, streamer_mmio + BCTL); 455 writew(readw(streamer_mmio + BCTL) | BCTL_SOFTRESET, streamer_mmio + BCTL);
455 t = jiffies; 456 t = jiffies;
456 /* Hold soft reset bit for a while */ 457 /* Hold soft reset bit for a while */
457 current->state = TASK_UNINTERRUPTIBLE; 458 ssleep(1);
458 schedule_timeout(HZ);
459 459
460 writew(readw(streamer_mmio + BCTL) & ~BCTL_SOFTRESET, 460 writew(readw(streamer_mmio + BCTL) & ~BCTL_SOFTRESET,
461 streamer_mmio + BCTL); 461 streamer_mmio + BCTL);
@@ -511,8 +511,7 @@ static int streamer_reset(struct net_device *dev)
511 writew(SISR_MI, streamer_mmio + SISR_MASK_SUM); 511 writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
512 512
513 while (!((readw(streamer_mmio + SISR)) & SISR_SRB_REPLY)) { 513 while (!((readw(streamer_mmio + SISR)) & SISR_SRB_REPLY)) {
514 current->state = TASK_INTERRUPTIBLE; 514 msleep_interruptible(100);
515 schedule_timeout(HZ/10);
516 if (jiffies - t > 40 * HZ) { 515 if (jiffies - t > 40 * HZ) {
517 printk(KERN_ERR 516 printk(KERN_ERR
518 "IBM PCI tokenring card not responding\n"); 517 "IBM PCI tokenring card not responding\n");
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index cfae2bbf2167..3a25d191ea4a 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -20,7 +20,7 @@
20static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n"; 20static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n";
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/mca-legacy.h> 23#include <linux/mca.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
@@ -38,9 +38,7 @@ static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n";
38#define MADGEMC_IO_EXTENT 32 38#define MADGEMC_IO_EXTENT 32
39#define MADGEMC_SIF_OFFSET 0x08 39#define MADGEMC_SIF_OFFSET 0x08
40 40
41struct madgemc_card { 41struct card_info {
42 struct net_device *dev;
43
44 /* 42 /*
45 * These are read from the BIA ROM. 43 * These are read from the BIA ROM.
46 */ 44 */
@@ -57,16 +55,12 @@ struct madgemc_card {
57 unsigned int arblevel:4; 55 unsigned int arblevel:4;
58 unsigned int ringspeed:2; /* 0 = 4mb, 1 = 16, 2 = Auto/none */ 56 unsigned int ringspeed:2; /* 0 = 4mb, 1 = 16, 2 = Auto/none */
59 unsigned int cabletype:1; /* 0 = RJ45, 1 = DB9 */ 57 unsigned int cabletype:1; /* 0 = RJ45, 1 = DB9 */
60
61 struct madgemc_card *next;
62}; 58};
63static struct madgemc_card *madgemc_card_list;
64
65 59
66static int madgemc_open(struct net_device *dev); 60static int madgemc_open(struct net_device *dev);
67static int madgemc_close(struct net_device *dev); 61static int madgemc_close(struct net_device *dev);
68static int madgemc_chipset_init(struct net_device *dev); 62static int madgemc_chipset_init(struct net_device *dev);
69static void madgemc_read_rom(struct madgemc_card *card); 63static void madgemc_read_rom(struct net_device *dev, struct card_info *card);
70static unsigned short madgemc_setnselout_pins(struct net_device *dev); 64static unsigned short madgemc_setnselout_pins(struct net_device *dev);
71static void madgemc_setcabletype(struct net_device *dev, int type); 65static void madgemc_setcabletype(struct net_device *dev, int type);
72 66
@@ -151,261 +145,237 @@ static void madgemc_sifwritew(struct net_device *dev, unsigned short val, unsign
151 145
152 146
153 147
154static int __init madgemc_probe(void) 148static int __devinit madgemc_probe(struct device *device)
155{ 149{
156 static int versionprinted; 150 static int versionprinted;
157 struct net_device *dev; 151 struct net_device *dev;
158 struct net_local *tp; 152 struct net_local *tp;
159 struct madgemc_card *card; 153 struct card_info *card;
160 int i,slot = 0; 154 struct mca_device *mdev = to_mca_device(device);
161 __u8 posreg[4]; 155 int ret = 0, i = 0;
162 156
163 if (!MCA_bus) 157 if (versionprinted++ == 0)
164 return -1; 158 printk("%s", version);
165 159
166 while (slot != MCA_NOTFOUND) { 160 if(mca_device_claimed(mdev))
167 /* 161 return -EBUSY;
168 * Currently we only support the MC16/32 (MCA ID 002d) 162 mca_device_set_claim(mdev, 1);
169 */ 163
170 slot = mca_find_unused_adapter(0x002d, slot); 164 dev = alloc_trdev(sizeof(struct net_local));
171 if (slot == MCA_NOTFOUND) 165 if (!dev) {
172 break; 166 printk("madgemc: unable to allocate dev space\n");
173 167 mca_device_set_claim(mdev, 0);
174 /* 168 ret = -ENOMEM;
175 * If we get here, we have an adapter. 169 goto getout;
176 */ 170 }
177 if (versionprinted++ == 0)
178 printk("%s", version);
179
180 dev = alloc_trdev(sizeof(struct net_local));
181 if (dev == NULL) {
182 printk("madgemc: unable to allocate dev space\n");
183 if (madgemc_card_list)
184 return 0;
185 return -1;
186 }
187 171
188 SET_MODULE_OWNER(dev); 172 SET_MODULE_OWNER(dev);
189 dev->dma = 0; 173 dev->dma = 0;
190 174
191 /* 175 card = kmalloc(sizeof(struct card_info), GFP_KERNEL);
192 * Fetch MCA config registers 176 if (card==NULL) {
193 */ 177 printk("madgemc: unable to allocate card struct\n");
194 for(i=0;i<4;i++) 178 ret = -ENOMEM;
195 posreg[i] = mca_read_stored_pos(slot, i+2); 179 goto getout1;
196 180 }
197 card = kmalloc(sizeof(struct madgemc_card), GFP_KERNEL); 181
198 if (card==NULL) { 182 /*
199 printk("madgemc: unable to allocate card struct\n"); 183 * Parse configuration information. This all comes
200 free_netdev(dev); 184 * directly from the publicly available @002d.ADF.
201 if (madgemc_card_list) 185 * Get it from Madge or your local ADF library.
202 return 0; 186 */
203 return -1; 187
204 } 188 /*
205 card->dev = dev; 189 * Base address
206 190 */
207 /* 191 dev->base_addr = 0x0a20 +
208 * Parse configuration information. This all comes 192 ((mdev->pos[2] & MC16_POS2_ADDR2)?0x0400:0) +
209 * directly from the publicly available @002d.ADF. 193 ((mdev->pos[0] & MC16_POS0_ADDR1)?0x1000:0) +
210 * Get it from Madge or your local ADF library. 194 ((mdev->pos[3] & MC16_POS3_ADDR3)?0x2000:0);
211 */ 195
212 196 /*
213 /* 197 * Interrupt line
214 * Base address 198 */
215 */ 199 switch(mdev->pos[0] >> 6) { /* upper two bits */
216 dev->base_addr = 0x0a20 +
217 ((posreg[2] & MC16_POS2_ADDR2)?0x0400:0) +
218 ((posreg[0] & MC16_POS0_ADDR1)?0x1000:0) +
219 ((posreg[3] & MC16_POS3_ADDR3)?0x2000:0);
220
221 /*
222 * Interrupt line
223 */
224 switch(posreg[0] >> 6) { /* upper two bits */
225 case 0x1: dev->irq = 3; break; 200 case 0x1: dev->irq = 3; break;
226 case 0x2: dev->irq = 9; break; /* IRQ 2 = IRQ 9 */ 201 case 0x2: dev->irq = 9; break; /* IRQ 2 = IRQ 9 */
227 case 0x3: dev->irq = 10; break; 202 case 0x3: dev->irq = 10; break;
228 default: dev->irq = 0; break; 203 default: dev->irq = 0; break;
229 } 204 }
230 205
231 if (dev->irq == 0) { 206 if (dev->irq == 0) {
232 printk("%s: invalid IRQ\n", dev->name); 207 printk("%s: invalid IRQ\n", dev->name);
233 goto getout1; 208 ret = -EBUSY;
234 } 209 goto getout2;
210 }
235 211
236 if (!request_region(dev->base_addr, MADGEMC_IO_EXTENT, 212 if (!request_region(dev->base_addr, MADGEMC_IO_EXTENT,
237 "madgemc")) { 213 "madgemc")) {
238 printk(KERN_INFO "madgemc: unable to setup Smart MC in slot %d because of I/O base conflict at 0x%04lx\n", slot, dev->base_addr); 214 printk(KERN_INFO "madgemc: unable to setup Smart MC in slot %d because of I/O base conflict at 0x%04lx\n", mdev->slot, dev->base_addr);
239 dev->base_addr += MADGEMC_SIF_OFFSET;
240 goto getout1;
241 }
242 dev->base_addr += MADGEMC_SIF_OFFSET; 215 dev->base_addr += MADGEMC_SIF_OFFSET;
216 ret = -EBUSY;
217 goto getout2;
218 }
219 dev->base_addr += MADGEMC_SIF_OFFSET;
220
221 /*
222 * Arbitration Level
223 */
224 card->arblevel = ((mdev->pos[0] >> 1) & 0x7) + 8;
225
226 /*
227 * Burst mode and Fairness
228 */
229 card->burstmode = ((mdev->pos[2] >> 6) & 0x3);
230 card->fairness = ((mdev->pos[2] >> 4) & 0x1);
231
232 /*
233 * Ring Speed
234 */
235 if ((mdev->pos[1] >> 2)&0x1)
236 card->ringspeed = 2; /* not selected */
237 else if ((mdev->pos[2] >> 5) & 0x1)
238 card->ringspeed = 1; /* 16Mb */
239 else
240 card->ringspeed = 0; /* 4Mb */
241
242 /*
243 * Cable type
244 */
245 if ((mdev->pos[1] >> 6)&0x1)
246 card->cabletype = 1; /* STP/DB9 */
247 else
248 card->cabletype = 0; /* UTP/RJ-45 */
249
250
251 /*
252 * ROM Info. This requires us to actually twiddle
253 * bits on the card, so we must ensure above that
254 * the base address is free of conflict (request_region above).
255 */
256 madgemc_read_rom(dev, card);
243 257
244 /* 258 if (card->manid != 0x4d) { /* something went wrong */
245 * Arbitration Level 259 printk(KERN_INFO "%s: Madge MC ROM read failed (unknown manufacturer ID %02x)\n", dev->name, card->manid);
246 */ 260 goto getout3;
247 card->arblevel = ((posreg[0] >> 1) & 0x7) + 8; 261 }
248
249 /*
250 * Burst mode and Fairness
251 */
252 card->burstmode = ((posreg[2] >> 6) & 0x3);
253 card->fairness = ((posreg[2] >> 4) & 0x1);
254
255 /*
256 * Ring Speed
257 */
258 if ((posreg[1] >> 2)&0x1)
259 card->ringspeed = 2; /* not selected */
260 else if ((posreg[2] >> 5) & 0x1)
261 card->ringspeed = 1; /* 16Mb */
262 else
263 card->ringspeed = 0; /* 4Mb */
264
265 /*
266 * Cable type
267 */
268 if ((posreg[1] >> 6)&0x1)
269 card->cabletype = 1; /* STP/DB9 */
270 else
271 card->cabletype = 0; /* UTP/RJ-45 */
272
273
274 /*
275 * ROM Info. This requires us to actually twiddle
276 * bits on the card, so we must ensure above that
277 * the base address is free of conflict (request_region above).
278 */
279 madgemc_read_rom(card);
280
281 if (card->manid != 0x4d) { /* something went wrong */
282 printk(KERN_INFO "%s: Madge MC ROM read failed (unknown manufacturer ID %02x)\n", dev->name, card->manid);
283 goto getout;
284 }
285 262
286 if ((card->cardtype != 0x08) && (card->cardtype != 0x0d)) { 263 if ((card->cardtype != 0x08) && (card->cardtype != 0x0d)) {
287 printk(KERN_INFO "%s: Madge MC ROM read failed (unknown card ID %02x)\n", dev->name, card->cardtype); 264 printk(KERN_INFO "%s: Madge MC ROM read failed (unknown card ID %02x)\n", dev->name, card->cardtype);
288 goto getout; 265 ret = -EIO;
289 } 266 goto getout3;
267 }
290 268
291 /* All cards except Rev 0 and 1 MC16's have 256kb of RAM */ 269 /* All cards except Rev 0 and 1 MC16's have 256kb of RAM */
292 if ((card->cardtype == 0x08) && (card->cardrev <= 0x01)) 270 if ((card->cardtype == 0x08) && (card->cardrev <= 0x01))
293 card->ramsize = 128; 271 card->ramsize = 128;
294 else 272 else
295 card->ramsize = 256; 273 card->ramsize = 256;
296 274
297 printk("%s: %s Rev %d at 0x%04lx IRQ %d\n", 275 printk("%s: %s Rev %d at 0x%04lx IRQ %d\n",
298 dev->name, 276 dev->name,
299 (card->cardtype == 0x08)?MADGEMC16_CARDNAME: 277 (card->cardtype == 0x08)?MADGEMC16_CARDNAME:
300 MADGEMC32_CARDNAME, card->cardrev, 278 MADGEMC32_CARDNAME, card->cardrev,
301 dev->base_addr, dev->irq); 279 dev->base_addr, dev->irq);
302 280
303 if (card->cardtype == 0x0d) 281 if (card->cardtype == 0x0d)
304 printk("%s: Warning: MC32 support is experimental and highly untested\n", dev->name); 282 printk("%s: Warning: MC32 support is experimental and highly untested\n", dev->name);
305 283
306 if (card->ringspeed==2) { /* Unknown */ 284 if (card->ringspeed==2) { /* Unknown */
307 printk("%s: Warning: Ring speed not set in POS -- Please run the reference disk and set it!\n", dev->name); 285 printk("%s: Warning: Ring speed not set in POS -- Please run the reference disk and set it!\n", dev->name);
308 card->ringspeed = 1; /* default to 16mb */ 286 card->ringspeed = 1; /* default to 16mb */
309 } 287 }
310 288
311 printk("%s: RAM Size: %dKB\n", dev->name, card->ramsize); 289 printk("%s: RAM Size: %dKB\n", dev->name, card->ramsize);
312 290
313 printk("%s: Ring Speed: %dMb/sec on %s\n", dev->name, 291 printk("%s: Ring Speed: %dMb/sec on %s\n", dev->name,
314 (card->ringspeed)?16:4, 292 (card->ringspeed)?16:4,
315 card->cabletype?"STP/DB9":"UTP/RJ-45"); 293 card->cabletype?"STP/DB9":"UTP/RJ-45");
316 printk("%s: Arbitration Level: %d\n", dev->name, 294 printk("%s: Arbitration Level: %d\n", dev->name,
317 card->arblevel); 295 card->arblevel);
318 296
319 printk("%s: Burst Mode: ", dev->name); 297 printk("%s: Burst Mode: ", dev->name);
320 switch(card->burstmode) { 298 switch(card->burstmode) {
321 case 0: printk("Cycle steal"); break; 299 case 0: printk("Cycle steal"); break;
322 case 1: printk("Limited burst"); break; 300 case 1: printk("Limited burst"); break;
323 case 2: printk("Delayed release"); break; 301 case 2: printk("Delayed release"); break;
324 case 3: printk("Immediate release"); break; 302 case 3: printk("Immediate release"); break;
325 } 303 }
326 printk(" (%s)\n", (card->fairness)?"Unfair":"Fair"); 304 printk(" (%s)\n", (card->fairness)?"Unfair":"Fair");
327
328
329 /*
330 * Enable SIF before we assign the interrupt handler,
331 * just in case we get spurious interrupts that need
332 * handling.
333 */
334 outb(0, dev->base_addr + MC_CONTROL_REG0); /* sanity */
335 madgemc_setsifsel(dev, 1);
336 if (request_irq(dev->irq, madgemc_interrupt, SA_SHIRQ,
337 "madgemc", dev))
338 goto getout;
339
340 madgemc_chipset_init(dev); /* enables interrupts! */
341 madgemc_setcabletype(dev, card->cabletype);
342 305
343 /* Setup MCA structures */
344 mca_set_adapter_name(slot, (card->cardtype == 0x08)?MADGEMC16_CARDNAME:MADGEMC32_CARDNAME);
345 mca_set_adapter_procfn(slot, madgemc_mcaproc, dev);
346 mca_mark_as_used(slot);
347 306
348 printk("%s: Ring Station Address: ", dev->name); 307 /*
349 printk("%2.2x", dev->dev_addr[0]); 308 * Enable SIF before we assign the interrupt handler,
350 for (i = 1; i < 6; i++) 309 * just in case we get spurious interrupts that need
351 printk(":%2.2x", dev->dev_addr[i]); 310 * handling.
352 printk("\n"); 311 */
353 312 outb(0, dev->base_addr + MC_CONTROL_REG0); /* sanity */
354 /* XXX is ISA_MAX_ADDRESS correct here? */ 313 madgemc_setsifsel(dev, 1);
355 if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) { 314 if (request_irq(dev->irq, madgemc_interrupt, SA_SHIRQ,
356 printk("%s: unable to get memory for dev->priv.\n", 315 "madgemc", dev)) {
357 dev->name); 316 ret = -EBUSY;
358 release_region(dev->base_addr-MADGEMC_SIF_OFFSET, 317 goto getout3;
359 MADGEMC_IO_EXTENT); 318 }
360 319
361 kfree(card); 320 madgemc_chipset_init(dev); /* enables interrupts! */
362 tmsdev_term(dev); 321 madgemc_setcabletype(dev, card->cabletype);
363 free_netdev(dev); 322
364 if (madgemc_card_list) 323 /* Setup MCA structures */
365 return 0; 324 mca_device_set_name(mdev, (card->cardtype == 0x08)?MADGEMC16_CARDNAME:MADGEMC32_CARDNAME);
366 return -1; 325 mca_set_adapter_procfn(mdev->slot, madgemc_mcaproc, dev);
367 } 326
368 tp = netdev_priv(dev); 327 printk("%s: Ring Station Address: ", dev->name);
369 328 printk("%2.2x", dev->dev_addr[0]);
370 /* 329 for (i = 1; i < 6; i++)
371 * The MC16 is physically a 32bit card. However, Madge 330 printk(":%2.2x", dev->dev_addr[i]);
372 * insists on calling it 16bit, so I'll assume here that 331 printk("\n");
373 * they know what they're talking about. Cut off DMA 332
374 * at 16mb. 333 if (tmsdev_init(dev, device)) {
375 */ 334 printk("%s: unable to get memory for dev->priv.\n",
376 tp->setnselout = madgemc_setnselout_pins; 335 dev->name);
377 tp->sifwriteb = madgemc_sifwriteb; 336 ret = -ENOMEM;
378 tp->sifreadb = madgemc_sifreadb; 337 goto getout4;
379 tp->sifwritew = madgemc_sifwritew;
380 tp->sifreadw = madgemc_sifreadw;
381 tp->DataRate = (card->ringspeed)?SPEED_16:SPEED_4;
382
383 memcpy(tp->ProductID, "Madge MCA 16/4 ", PROD_ID_SIZE + 1);
384
385 dev->open = madgemc_open;
386 dev->stop = madgemc_close;
387
388 if (register_netdev(dev) == 0) {
389 /* Enlist in the card list */
390 card->next = madgemc_card_list;
391 madgemc_card_list = card;
392 slot++;
393 continue; /* successful, try to find another */
394 }
395
396 free_irq(dev->irq, dev);
397 getout:
398 release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
399 MADGEMC_IO_EXTENT);
400 getout1:
401 kfree(card);
402 free_netdev(dev);
403 slot++;
404 } 338 }
339 tp = netdev_priv(dev);
340
341 /*
342 * The MC16 is physically a 32bit card. However, Madge
343 * insists on calling it 16bit, so I'll assume here that
344 * they know what they're talking about. Cut off DMA
345 * at 16mb.
346 */
347 tp->setnselout = madgemc_setnselout_pins;
348 tp->sifwriteb = madgemc_sifwriteb;
349 tp->sifreadb = madgemc_sifreadb;
350 tp->sifwritew = madgemc_sifwritew;
351 tp->sifreadw = madgemc_sifreadw;
352 tp->DataRate = (card->ringspeed)?SPEED_16:SPEED_4;
353
354 memcpy(tp->ProductID, "Madge MCA 16/4 ", PROD_ID_SIZE + 1);
405 355
406 if (madgemc_card_list) 356 dev->open = madgemc_open;
357 dev->stop = madgemc_close;
358
359 tp->tmspriv = card;
360 dev_set_drvdata(device, dev);
361
362 if (register_netdev(dev) == 0)
407 return 0; 363 return 0;
408 return -1; 364
365 dev_set_drvdata(device, NULL);
366 ret = -ENOMEM;
367getout4:
368 free_irq(dev->irq, dev);
369getout3:
370 release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
371 MADGEMC_IO_EXTENT);
372getout2:
373 kfree(card);
374getout1:
375 free_netdev(dev);
376getout:
377 mca_device_set_claim(mdev, 0);
378 return ret;
409} 379}
410 380
411/* 381/*
@@ -625,7 +595,7 @@ static int madgemc_chipset_init(struct net_device *dev)
625/* 595/*
626 * Disable the board, and put back into power-up state. 596 * Disable the board, and put back into power-up state.
627 */ 597 */
628void madgemc_chipset_close(struct net_device *dev) 598static void madgemc_chipset_close(struct net_device *dev)
629{ 599{
630 /* disable interrupts */ 600 /* disable interrupts */
631 madgemc_setint(dev, 0); 601 madgemc_setint(dev, 0);
@@ -664,12 +634,12 @@ void madgemc_chipset_close(struct net_device *dev)
664 * is complete. 634 * is complete.
665 * 635 *
666 */ 636 */
667static void madgemc_read_rom(struct madgemc_card *card) 637static void madgemc_read_rom(struct net_device *dev, struct card_info *card)
668{ 638{
669 unsigned long ioaddr; 639 unsigned long ioaddr;
670 unsigned char reg0, reg1, tmpreg0, i; 640 unsigned char reg0, reg1, tmpreg0, i;
671 641
672 ioaddr = card->dev->base_addr; 642 ioaddr = dev->base_addr;
673 643
674 reg0 = inb(ioaddr + MC_CONTROL_REG0); 644 reg0 = inb(ioaddr + MC_CONTROL_REG0);
675 reg1 = inb(ioaddr + MC_CONTROL_REG1); 645 reg1 = inb(ioaddr + MC_CONTROL_REG1);
@@ -686,9 +656,9 @@ static void madgemc_read_rom(struct madgemc_card *card)
686 outb(tmpreg0 | MC_CONTROL_REG0_PAGE, ioaddr + MC_CONTROL_REG0); 656 outb(tmpreg0 | MC_CONTROL_REG0_PAGE, ioaddr + MC_CONTROL_REG0);
687 657
688 /* Read BIA */ 658 /* Read BIA */
689 card->dev->addr_len = 6; 659 dev->addr_len = 6;
690 for (i = 0; i < 6; i++) 660 for (i = 0; i < 6; i++)
691 card->dev->dev_addr[i] = inb(ioaddr + MC_ROM_BIA_START + i); 661 dev->dev_addr[i] = inb(ioaddr + MC_ROM_BIA_START + i);
692 662
693 /* Restore original register values */ 663 /* Restore original register values */
694 outb(reg0, ioaddr + MC_CONTROL_REG0); 664 outb(reg0, ioaddr + MC_CONTROL_REG0);
@@ -721,14 +691,10 @@ static int madgemc_close(struct net_device *dev)
721static int madgemc_mcaproc(char *buf, int slot, void *d) 691static int madgemc_mcaproc(char *buf, int slot, void *d)
722{ 692{
723 struct net_device *dev = (struct net_device *)d; 693 struct net_device *dev = (struct net_device *)d;
724 struct madgemc_card *curcard = madgemc_card_list; 694 struct net_local *tp = dev->priv;
695 struct card_info *curcard = tp->tmspriv;
725 int len = 0; 696 int len = 0;
726 697
727 while (curcard) { /* search for card struct */
728 if (curcard->dev == dev)
729 break;
730 curcard = curcard->next;
731 }
732 len += sprintf(buf+len, "-------\n"); 698 len += sprintf(buf+len, "-------\n");
733 if (curcard) { 699 if (curcard) {
734 struct net_local *tp = netdev_priv(dev); 700 struct net_local *tp = netdev_priv(dev);
@@ -763,38 +729,57 @@ static int madgemc_mcaproc(char *buf, int slot, void *d)
763 return len; 729 return len;
764} 730}
765 731
766static void __exit madgemc_exit(void) 732static int __devexit madgemc_remove(struct device *device)
767{ 733{
768 struct net_device *dev; 734 struct net_device *dev = dev_get_drvdata(device);
769 struct madgemc_card *this_card; 735 struct net_local *tp;
770 736 struct card_info *card;
771 while (madgemc_card_list) { 737
772 dev = madgemc_card_list->dev; 738 if (!dev)
773 unregister_netdev(dev); 739 BUG();
774 release_region(dev->base_addr-MADGEMC_SIF_OFFSET, MADGEMC_IO_EXTENT); 740
775 free_irq(dev->irq, dev); 741 tp = dev->priv;
776 tmsdev_term(dev); 742 card = tp->tmspriv;
777 free_netdev(dev); 743 kfree(card);
778 this_card = madgemc_card_list; 744 tp->tmspriv = NULL;
779 madgemc_card_list = this_card->next; 745
780 kfree(this_card); 746 unregister_netdev(dev);
781 } 747 release_region(dev->base_addr-MADGEMC_SIF_OFFSET, MADGEMC_IO_EXTENT);
748 free_irq(dev->irq, dev);
749 tmsdev_term(dev);
750 free_netdev(dev);
751 dev_set_drvdata(device, NULL);
752
753 return 0;
754}
755
756static short madgemc_adapter_ids[] __initdata = {
757 0x002d,
758 0x0000
759};
760
761static struct mca_driver madgemc_driver = {
762 .id_table = madgemc_adapter_ids,
763 .driver = {
764 .name = "madgemc",
765 .bus = &mca_bus_type,
766 .probe = madgemc_probe,
767 .remove = __devexit_p(madgemc_remove),
768 },
769};
770
771static int __init madgemc_init (void)
772{
773 return mca_register_driver (&madgemc_driver);
782} 774}
783 775
784module_init(madgemc_probe); 776static void __exit madgemc_exit (void)
777{
778 mca_unregister_driver (&madgemc_driver);
779}
780
781module_init(madgemc_init);
785module_exit(madgemc_exit); 782module_exit(madgemc_exit);
786 783
787MODULE_LICENSE("GPL"); 784MODULE_LICENSE("GPL");
788 785
789
790/*
791 * Local variables:
792 * compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c madgemc.c"
793 * alt-compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c madgemc.c"
794 * c-set-style "K&R"
795 * c-indent-level: 8
796 * c-basic-offset: 8
797 * tab-width: 8
798 * End:
799 */
800
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index 675b063508e3..eb1423ede75c 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -62,8 +62,7 @@ static int dmalist[] __initdata = {
62}; 62};
63 63
64static char cardname[] = "Proteon 1392\0"; 64static char cardname[] = "Proteon 1392\0";
65 65static u64 dma_mask = ISA_MAX_ADDRESS;
66struct net_device *proteon_probe(int unit);
67static int proteon_open(struct net_device *dev); 66static int proteon_open(struct net_device *dev);
68static void proteon_read_eeprom(struct net_device *dev); 67static void proteon_read_eeprom(struct net_device *dev);
69static unsigned short proteon_setnselout_pins(struct net_device *dev); 68static unsigned short proteon_setnselout_pins(struct net_device *dev);
@@ -116,7 +115,7 @@ nodev:
116 return -ENODEV; 115 return -ENODEV;
117} 116}
118 117
119static int __init setup_card(struct net_device *dev) 118static int __init setup_card(struct net_device *dev, struct device *pdev)
120{ 119{
121 struct net_local *tp; 120 struct net_local *tp;
122 static int versionprinted; 121 static int versionprinted;
@@ -137,7 +136,7 @@ static int __init setup_card(struct net_device *dev)
137 } 136 }
138 } 137 }
139 if (err) 138 if (err)
140 goto out4; 139 goto out5;
141 140
142 /* At this point we have found a valid card. */ 141 /* At this point we have found a valid card. */
143 142
@@ -145,14 +144,15 @@ static int __init setup_card(struct net_device *dev)
145 printk(KERN_DEBUG "%s", version); 144 printk(KERN_DEBUG "%s", version);
146 145
147 err = -EIO; 146 err = -EIO;
148 if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) 147 pdev->dma_mask = &dma_mask;
148 if (tmsdev_init(dev, pdev))
149 goto out4; 149 goto out4;
150 150
151 dev->base_addr &= ~3; 151 dev->base_addr &= ~3;
152 152
153 proteon_read_eeprom(dev); 153 proteon_read_eeprom(dev);
154 154
155 printk(KERN_DEBUG "%s: Ring Station Address: ", dev->name); 155 printk(KERN_DEBUG "proteon.c: Ring Station Address: ");
156 printk("%2.2x", dev->dev_addr[0]); 156 printk("%2.2x", dev->dev_addr[0]);
157 for (j = 1; j < 6; j++) 157 for (j = 1; j < 6; j++)
158 printk(":%2.2x", dev->dev_addr[j]); 158 printk(":%2.2x", dev->dev_addr[j]);
@@ -185,7 +185,7 @@ static int __init setup_card(struct net_device *dev)
185 185
186 if(irqlist[j] == 0) 186 if(irqlist[j] == 0)
187 { 187 {
188 printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name); 188 printk(KERN_INFO "proteon.c: AutoSelect no IRQ available\n");
189 goto out3; 189 goto out3;
190 } 190 }
191 } 191 }
@@ -196,15 +196,15 @@ static int __init setup_card(struct net_device *dev)
196 break; 196 break;
197 if (irqlist[j] == 0) 197 if (irqlist[j] == 0)
198 { 198 {
199 printk(KERN_INFO "%s: Illegal IRQ %d specified\n", 199 printk(KERN_INFO "proteon.c: Illegal IRQ %d specified\n",
200 dev->name, dev->irq); 200 dev->irq);
201 goto out3; 201 goto out3;
202 } 202 }
203 if (request_irq(dev->irq, tms380tr_interrupt, 0, 203 if (request_irq(dev->irq, tms380tr_interrupt, 0,
204 cardname, dev)) 204 cardname, dev))
205 { 205 {
206 printk(KERN_INFO "%s: Selected IRQ %d not available\n", 206 printk(KERN_INFO "proteon.c: Selected IRQ %d not available\n",
207 dev->name, dev->irq); 207 dev->irq);
208 goto out3; 208 goto out3;
209 } 209 }
210 } 210 }
@@ -220,7 +220,7 @@ static int __init setup_card(struct net_device *dev)
220 220
221 if(dmalist[j] == 0) 221 if(dmalist[j] == 0)
222 { 222 {
223 printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name); 223 printk(KERN_INFO "proteon.c: AutoSelect no DMA available\n");
224 goto out2; 224 goto out2;
225 } 225 }
226 } 226 }
@@ -231,25 +231,25 @@ static int __init setup_card(struct net_device *dev)
231 break; 231 break;
232 if (dmalist[j] == 0) 232 if (dmalist[j] == 0)
233 { 233 {
234 printk(KERN_INFO "%s: Illegal DMA %d specified\n", 234 printk(KERN_INFO "proteon.c: Illegal DMA %d specified\n",
235 dev->name, dev->dma); 235 dev->dma);
236 goto out2; 236 goto out2;
237 } 237 }
238 if (request_dma(dev->dma, cardname)) 238 if (request_dma(dev->dma, cardname))
239 { 239 {
240 printk(KERN_INFO "%s: Selected DMA %d not available\n", 240 printk(KERN_INFO "proteon.c: Selected DMA %d not available\n",
241 dev->name, dev->dma); 241 dev->dma);
242 goto out2; 242 goto out2;
243 } 243 }
244 } 244 }
245 245
246 printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
247 dev->name, dev->base_addr, dev->irq, dev->dma);
248
249 err = register_netdev(dev); 246 err = register_netdev(dev);
250 if (err) 247 if (err)
251 goto out; 248 goto out;
252 249
250 printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
251 dev->name, dev->base_addr, dev->irq, dev->dma);
252
253 return 0; 253 return 0;
254out: 254out:
255 free_dma(dev->dma); 255 free_dma(dev->dma);
@@ -258,34 +258,11 @@ out2:
258out3: 258out3:
259 tmsdev_term(dev); 259 tmsdev_term(dev);
260out4: 260out4:
261 release_region(dev->base_addr, PROTEON_IO_EXTENT); 261 release_region(dev->base_addr, PROTEON_IO_EXTENT);
262out5:
262 return err; 263 return err;
263} 264}
264 265
265struct net_device * __init proteon_probe(int unit)
266{
267 struct net_device *dev = alloc_trdev(sizeof(struct net_local));
268 int err = 0;
269
270 if (!dev)
271 return ERR_PTR(-ENOMEM);
272
273 if (unit >= 0) {
274 sprintf(dev->name, "tr%d", unit);
275 netdev_boot_setup_check(dev);
276 }
277
278 err = setup_card(dev);
279 if (err)
280 goto out;
281
282 return dev;
283
284out:
285 free_netdev(dev);
286 return ERR_PTR(err);
287}
288
289/* 266/*
290 * Reads MAC address from adapter RAM, which should've read it from 267 * Reads MAC address from adapter RAM, which should've read it from
291 * the onboard ROM. 268 * the onboard ROM.
@@ -352,8 +329,6 @@ static int proteon_open(struct net_device *dev)
352 return tms380tr_open(dev); 329 return tms380tr_open(dev);
353} 330}
354 331
355#ifdef MODULE
356
357#define ISATR_MAX_ADAPTERS 3 332#define ISATR_MAX_ADAPTERS 3
358 333
359static int io[ISATR_MAX_ADAPTERS]; 334static int io[ISATR_MAX_ADAPTERS];
@@ -366,13 +341,23 @@ module_param_array(io, int, NULL, 0);
366module_param_array(irq, int, NULL, 0); 341module_param_array(irq, int, NULL, 0);
367module_param_array(dma, int, NULL, 0); 342module_param_array(dma, int, NULL, 0);
368 343
369static struct net_device *proteon_dev[ISATR_MAX_ADAPTERS]; 344static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS];
370 345
371int init_module(void) 346static struct device_driver proteon_driver = {
347 .name = "proteon",
348 .bus = &platform_bus_type,
349};
350
351static int __init proteon_init(void)
372{ 352{
373 struct net_device *dev; 353 struct net_device *dev;
354 struct platform_device *pdev;
374 int i, num = 0, err = 0; 355 int i, num = 0, err = 0;
375 356
357 err = driver_register(&proteon_driver);
358 if (err)
359 return err;
360
376 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { 361 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
377 dev = alloc_trdev(sizeof(struct net_local)); 362 dev = alloc_trdev(sizeof(struct net_local));
378 if (!dev) 363 if (!dev)
@@ -381,11 +366,15 @@ int init_module(void)
381 dev->base_addr = io[i]; 366 dev->base_addr = io[i];
382 dev->irq = irq[i]; 367 dev->irq = irq[i];
383 dev->dma = dma[i]; 368 dev->dma = dma[i];
384 err = setup_card(dev); 369 pdev = platform_device_register_simple("proteon",
370 i, NULL, 0);
371 err = setup_card(dev, &pdev->dev);
385 if (!err) { 372 if (!err) {
386 proteon_dev[i] = dev; 373 proteon_dev[i] = pdev;
374 dev_set_drvdata(&pdev->dev, dev);
387 ++num; 375 ++num;
388 } else { 376 } else {
377 platform_device_unregister(pdev);
389 free_netdev(dev); 378 free_netdev(dev);
390 } 379 }
391 } 380 }
@@ -399,34 +388,28 @@ int init_module(void)
399 return (0); 388 return (0);
400} 389}
401 390
402void cleanup_module(void) 391static void __exit proteon_cleanup(void)
403{ 392{
393 struct net_device *dev;
404 int i; 394 int i;
405 395
406 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { 396 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
407 struct net_device *dev = proteon_dev[i]; 397 struct platform_device *pdev = proteon_dev[i];
408 398
409 if (!dev) 399 if (!pdev)
410 continue; 400 continue;
411 401 dev = dev_get_drvdata(&pdev->dev);
412 unregister_netdev(dev); 402 unregister_netdev(dev);
413 release_region(dev->base_addr, PROTEON_IO_EXTENT); 403 release_region(dev->base_addr, PROTEON_IO_EXTENT);
414 free_irq(dev->irq, dev); 404 free_irq(dev->irq, dev);
415 free_dma(dev->dma); 405 free_dma(dev->dma);
416 tmsdev_term(dev); 406 tmsdev_term(dev);
417 free_netdev(dev); 407 free_netdev(dev);
408 dev_set_drvdata(&pdev->dev, NULL);
409 platform_device_unregister(pdev);
418 } 410 }
411 driver_unregister(&proteon_driver);
419} 412}
420#endif /* MODULE */
421 413
422 414module_init(proteon_init);
423/* 415module_exit(proteon_cleanup);
424 * Local variables:
425 * compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c proteon.c"
426 * alt-compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c proteon.c"
427 * c-set-style "K&R"
428 * c-indent-level: 8
429 * c-basic-offset: 8
430 * tab-width: 8
431 * End:
432 */
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index 3fab54a26466..3c7c66204f74 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -68,8 +68,7 @@ static int dmalist[] __initdata = {
68}; 68};
69 69
70static char isa_cardname[] = "SK NET TR 4/16 ISA\0"; 70static char isa_cardname[] = "SK NET TR 4/16 ISA\0";
71 71static u64 dma_mask = ISA_MAX_ADDRESS;
72struct net_device *sk_isa_probe(int unit);
73static int sk_isa_open(struct net_device *dev); 72static int sk_isa_open(struct net_device *dev);
74static void sk_isa_read_eeprom(struct net_device *dev); 73static void sk_isa_read_eeprom(struct net_device *dev);
75static unsigned short sk_isa_setnselout_pins(struct net_device *dev); 74static unsigned short sk_isa_setnselout_pins(struct net_device *dev);
@@ -133,7 +132,7 @@ static int __init sk_isa_probe1(struct net_device *dev, int ioaddr)
133 return 0; 132 return 0;
134} 133}
135 134
136static int __init setup_card(struct net_device *dev) 135static int __init setup_card(struct net_device *dev, struct device *pdev)
137{ 136{
138 struct net_local *tp; 137 struct net_local *tp;
139 static int versionprinted; 138 static int versionprinted;
@@ -154,7 +153,7 @@ static int __init setup_card(struct net_device *dev)
154 } 153 }
155 } 154 }
156 if (err) 155 if (err)
157 goto out4; 156 goto out5;
158 157
159 /* At this point we have found a valid card. */ 158 /* At this point we have found a valid card. */
160 159
@@ -162,14 +161,15 @@ static int __init setup_card(struct net_device *dev)
162 printk(KERN_DEBUG "%s", version); 161 printk(KERN_DEBUG "%s", version);
163 162
164 err = -EIO; 163 err = -EIO;
165 if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) 164 pdev->dma_mask = &dma_mask;
165 if (tmsdev_init(dev, pdev))
166 goto out4; 166 goto out4;
167 167
168 dev->base_addr &= ~3; 168 dev->base_addr &= ~3;
169 169
170 sk_isa_read_eeprom(dev); 170 sk_isa_read_eeprom(dev);
171 171
172 printk(KERN_DEBUG "%s: Ring Station Address: ", dev->name); 172 printk(KERN_DEBUG "skisa.c: Ring Station Address: ");
173 printk("%2.2x", dev->dev_addr[0]); 173 printk("%2.2x", dev->dev_addr[0]);
174 for (j = 1; j < 6; j++) 174 for (j = 1; j < 6; j++)
175 printk(":%2.2x", dev->dev_addr[j]); 175 printk(":%2.2x", dev->dev_addr[j]);
@@ -202,7 +202,7 @@ static int __init setup_card(struct net_device *dev)
202 202
203 if(irqlist[j] == 0) 203 if(irqlist[j] == 0)
204 { 204 {
205 printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name); 205 printk(KERN_INFO "skisa.c: AutoSelect no IRQ available\n");
206 goto out3; 206 goto out3;
207 } 207 }
208 } 208 }
@@ -213,15 +213,15 @@ static int __init setup_card(struct net_device *dev)
213 break; 213 break;
214 if (irqlist[j] == 0) 214 if (irqlist[j] == 0)
215 { 215 {
216 printk(KERN_INFO "%s: Illegal IRQ %d specified\n", 216 printk(KERN_INFO "skisa.c: Illegal IRQ %d specified\n",
217 dev->name, dev->irq); 217 dev->irq);
218 goto out3; 218 goto out3;
219 } 219 }
220 if (request_irq(dev->irq, tms380tr_interrupt, 0, 220 if (request_irq(dev->irq, tms380tr_interrupt, 0,
221 isa_cardname, dev)) 221 isa_cardname, dev))
222 { 222 {
223 printk(KERN_INFO "%s: Selected IRQ %d not available\n", 223 printk(KERN_INFO "skisa.c: Selected IRQ %d not available\n",
224 dev->name, dev->irq); 224 dev->irq);
225 goto out3; 225 goto out3;
226 } 226 }
227 } 227 }
@@ -237,7 +237,7 @@ static int __init setup_card(struct net_device *dev)
237 237
238 if(dmalist[j] == 0) 238 if(dmalist[j] == 0)
239 { 239 {
240 printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name); 240 printk(KERN_INFO "skisa.c: AutoSelect no DMA available\n");
241 goto out2; 241 goto out2;
242 } 242 }
243 } 243 }
@@ -248,25 +248,25 @@ static int __init setup_card(struct net_device *dev)
248 break; 248 break;
249 if (dmalist[j] == 0) 249 if (dmalist[j] == 0)
250 { 250 {
251 printk(KERN_INFO "%s: Illegal DMA %d specified\n", 251 printk(KERN_INFO "skisa.c: Illegal DMA %d specified\n",
252 dev->name, dev->dma); 252 dev->dma);
253 goto out2; 253 goto out2;
254 } 254 }
255 if (request_dma(dev->dma, isa_cardname)) 255 if (request_dma(dev->dma, isa_cardname))
256 { 256 {
257 printk(KERN_INFO "%s: Selected DMA %d not available\n", 257 printk(KERN_INFO "skisa.c: Selected DMA %d not available\n",
258 dev->name, dev->dma); 258 dev->dma);
259 goto out2; 259 goto out2;
260 } 260 }
261 } 261 }
262 262
263 printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
264 dev->name, dev->base_addr, dev->irq, dev->dma);
265
266 err = register_netdev(dev); 263 err = register_netdev(dev);
267 if (err) 264 if (err)
268 goto out; 265 goto out;
269 266
267 printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
268 dev->name, dev->base_addr, dev->irq, dev->dma);
269
270 return 0; 270 return 0;
271out: 271out:
272 free_dma(dev->dma); 272 free_dma(dev->dma);
@@ -275,33 +275,11 @@ out2:
275out3: 275out3:
276 tmsdev_term(dev); 276 tmsdev_term(dev);
277out4: 277out4:
278 release_region(dev->base_addr, SK_ISA_IO_EXTENT); 278 release_region(dev->base_addr, SK_ISA_IO_EXTENT);
279out5:
279 return err; 280 return err;
280} 281}
281 282
282struct net_device * __init sk_isa_probe(int unit)
283{
284 struct net_device *dev = alloc_trdev(sizeof(struct net_local));
285 int err = 0;
286
287 if (!dev)
288 return ERR_PTR(-ENOMEM);
289
290 if (unit >= 0) {
291 sprintf(dev->name, "tr%d", unit);
292 netdev_boot_setup_check(dev);
293 }
294
295 err = setup_card(dev);
296 if (err)
297 goto out;
298
299 return dev;
300out:
301 free_netdev(dev);
302 return ERR_PTR(err);
303}
304
305/* 283/*
306 * Reads MAC address from adapter RAM, which should've read it from 284 * Reads MAC address from adapter RAM, which should've read it from
307 * the onboard ROM. 285 * the onboard ROM.
@@ -361,8 +339,6 @@ static int sk_isa_open(struct net_device *dev)
361 return tms380tr_open(dev); 339 return tms380tr_open(dev);
362} 340}
363 341
364#ifdef MODULE
365
366#define ISATR_MAX_ADAPTERS 3 342#define ISATR_MAX_ADAPTERS 3
367 343
368static int io[ISATR_MAX_ADAPTERS]; 344static int io[ISATR_MAX_ADAPTERS];
@@ -375,13 +351,23 @@ module_param_array(io, int, NULL, 0);
375module_param_array(irq, int, NULL, 0); 351module_param_array(irq, int, NULL, 0);
376module_param_array(dma, int, NULL, 0); 352module_param_array(dma, int, NULL, 0);
377 353
378static struct net_device *sk_isa_dev[ISATR_MAX_ADAPTERS]; 354static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS];
355
356static struct device_driver sk_isa_driver = {
357 .name = "skisa",
358 .bus = &platform_bus_type,
359};
379 360
380int init_module(void) 361static int __init sk_isa_init(void)
381{ 362{
382 struct net_device *dev; 363 struct net_device *dev;
364 struct platform_device *pdev;
383 int i, num = 0, err = 0; 365 int i, num = 0, err = 0;
384 366
367 err = driver_register(&sk_isa_driver);
368 if (err)
369 return err;
370
385 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { 371 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
386 dev = alloc_trdev(sizeof(struct net_local)); 372 dev = alloc_trdev(sizeof(struct net_local));
387 if (!dev) 373 if (!dev)
@@ -390,12 +376,15 @@ int init_module(void)
390 dev->base_addr = io[i]; 376 dev->base_addr = io[i];
391 dev->irq = irq[i]; 377 dev->irq = irq[i];
392 dev->dma = dma[i]; 378 dev->dma = dma[i];
393 err = setup_card(dev); 379 pdev = platform_device_register_simple("skisa",
394 380 i, NULL, 0);
381 err = setup_card(dev, &pdev->dev);
395 if (!err) { 382 if (!err) {
396 sk_isa_dev[i] = dev; 383 sk_isa_dev[i] = pdev;
384 dev_set_drvdata(&sk_isa_dev[i]->dev, dev);
397 ++num; 385 ++num;
398 } else { 386 } else {
387 platform_device_unregister(pdev);
399 free_netdev(dev); 388 free_netdev(dev);
400 } 389 }
401 } 390 }
@@ -409,34 +398,28 @@ int init_module(void)
409 return (0); 398 return (0);
410} 399}
411 400
412void cleanup_module(void) 401static void __exit sk_isa_cleanup(void)
413{ 402{
403 struct net_device *dev;
414 int i; 404 int i;
415 405
416 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { 406 for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
417 struct net_device *dev = sk_isa_dev[i]; 407 struct platform_device *pdev = sk_isa_dev[i];
418 408
419 if (!dev) 409 if (!pdev)
420 continue; 410 continue;
421 411 dev = dev_get_drvdata(&pdev->dev);
422 unregister_netdev(dev); 412 unregister_netdev(dev);
423 release_region(dev->base_addr, SK_ISA_IO_EXTENT); 413 release_region(dev->base_addr, SK_ISA_IO_EXTENT);
424 free_irq(dev->irq, dev); 414 free_irq(dev->irq, dev);
425 free_dma(dev->dma); 415 free_dma(dev->dma);
426 tmsdev_term(dev); 416 tmsdev_term(dev);
427 free_netdev(dev); 417 free_netdev(dev);
418 dev_set_drvdata(&pdev->dev, NULL);
419 platform_device_unregister(pdev);
428 } 420 }
421 driver_unregister(&sk_isa_driver);
429} 422}
430#endif /* MODULE */
431 423
432 424module_init(sk_isa_init);
433/* 425module_exit(sk_isa_cleanup);
434 * Local variables:
435 * compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c skisa.c"
436 * alt-compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c skisa.c"
437 * c-set-style "K&R"
438 * c-indent-level: 8
439 * c-basic-offset: 8
440 * tab-width: 8
441 * End:
442 */
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 5c8aeacb8318..67d2b596ce22 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -77,7 +77,7 @@ static int ringspeed;
77 77
78/* SMC Name of the Adapter. */ 78/* SMC Name of the Adapter. */
79static char smctr_name[] = "SMC TokenCard"; 79static char smctr_name[] = "SMC TokenCard";
80char *smctr_model = "Unknown"; 80static char *smctr_model = "Unknown";
81 81
82/* Use 0 for production, 1 for verification, 2 for debug, and 82/* Use 0 for production, 1 for verification, 2 for debug, and
83 * 3 for very verbose debug. 83 * 3 for very verbose debug.
diff --git a/drivers/net/tokenring/smctr_firmware.h b/drivers/net/tokenring/smctr_firmware.h
index 53f2cbc817c9..48994b043b7c 100644
--- a/drivers/net/tokenring/smctr_firmware.h
+++ b/drivers/net/tokenring/smctr_firmware.h
@@ -21,7 +21,7 @@
21 21
22#if defined(CONFIG_SMCTR) || defined(CONFIG_SMCTR_MODULE) 22#if defined(CONFIG_SMCTR) || defined(CONFIG_SMCTR_MODULE)
23 23
24unsigned char smctr_code[] = { 24static const unsigned char smctr_code[] = {
25 0x0BC, 0x01D, 0x012, 0x03B, 0x063, 0x0B4, 0x0E9, 0x000, 25 0x0BC, 0x01D, 0x012, 0x03B, 0x063, 0x0B4, 0x0E9, 0x000,
26 0x000, 0x01F, 0x000, 0x001, 0x001, 0x000, 0x002, 0x005, 26 0x000, 0x01F, 0x000, 0x001, 0x001, 0x000, 0x002, 0x005,
27 0x001, 0x000, 0x006, 0x003, 0x001, 0x000, 0x004, 0x009, 27 0x001, 0x000, 0x006, 0x003, 0x001, 0x000, 0x004, 0x009,
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index df43b449e429..2e39bf1f7462 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -62,6 +62,7 @@
62 * normal operation. 62 * normal operation.
63 * 30-Dec-02 JF Removed incorrect __init from 63 * 30-Dec-02 JF Removed incorrect __init from
64 * tms380tr_init_card. 64 * tms380tr_init_card.
65 * 22-Jul-05 JF Converted to dma-mapping.
65 * 66 *
66 * To do: 67 * To do:
67 * 1. Multi/Broadcast packet handling (this may have fixed itself) 68 * 1. Multi/Broadcast packet handling (this may have fixed itself)
@@ -89,7 +90,7 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
89#include <linux/time.h> 90#include <linux/time.h>
90#include <linux/errno.h> 91#include <linux/errno.h>
91#include <linux/init.h> 92#include <linux/init.h>
92#include <linux/pci.h> 93#include <linux/dma-mapping.h>
93#include <linux/delay.h> 94#include <linux/delay.h>
94#include <linux/netdevice.h> 95#include <linux/netdevice.h>
95#include <linux/etherdevice.h> 96#include <linux/etherdevice.h>
@@ -114,8 +115,6 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
114#endif 115#endif
115static unsigned int tms380tr_debug = TMS380TR_DEBUG; 116static unsigned int tms380tr_debug = TMS380TR_DEBUG;
116 117
117static struct device tms_device;
118
119/* Index to functions, as function prototypes. 118/* Index to functions, as function prototypes.
120 * Alphabetical by function name. 119 * Alphabetical by function name.
121 */ 120 */
@@ -434,7 +433,7 @@ static void tms380tr_init_net_local(struct net_device *dev)
434 skb_put(tp->Rpl[i].Skb, tp->MaxPacketSize); 433 skb_put(tp->Rpl[i].Skb, tp->MaxPacketSize);
435 434
436 /* data unreachable for DMA ? then use local buffer */ 435 /* data unreachable for DMA ? then use local buffer */
437 dmabuf = pci_map_single(tp->pdev, tp->Rpl[i].Skb->data, tp->MaxPacketSize, PCI_DMA_FROMDEVICE); 436 dmabuf = dma_map_single(tp->pdev, tp->Rpl[i].Skb->data, tp->MaxPacketSize, DMA_FROM_DEVICE);
438 if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit)) 437 if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit))
439 { 438 {
440 tp->Rpl[i].SkbStat = SKB_DATA_COPY; 439 tp->Rpl[i].SkbStat = SKB_DATA_COPY;
@@ -638,10 +637,10 @@ static int tms380tr_hardware_send_packet(struct sk_buff *skb, struct net_device
638 /* Is buffer reachable for Busmaster-DMA? */ 637 /* Is buffer reachable for Busmaster-DMA? */
639 638
640 length = skb->len; 639 length = skb->len;
641 dmabuf = pci_map_single(tp->pdev, skb->data, length, PCI_DMA_TODEVICE); 640 dmabuf = dma_map_single(tp->pdev, skb->data, length, DMA_TO_DEVICE);
642 if(tp->dmalimit && (dmabuf + length > tp->dmalimit)) { 641 if(tp->dmalimit && (dmabuf + length > tp->dmalimit)) {
643 /* Copy frame to local buffer */ 642 /* Copy frame to local buffer */
644 pci_unmap_single(tp->pdev, dmabuf, length, PCI_DMA_TODEVICE); 643 dma_unmap_single(tp->pdev, dmabuf, length, DMA_TO_DEVICE);
645 dmabuf = 0; 644 dmabuf = 0;
646 i = tp->TplFree->TPLIndex; 645 i = tp->TplFree->TPLIndex;
647 buf = tp->LocalTxBuffers[i]; 646 buf = tp->LocalTxBuffers[i];
@@ -1284,9 +1283,7 @@ static int tms380tr_reset_adapter(struct net_device *dev)
1284 unsigned short count, c, count2; 1283 unsigned short count, c, count2;
1285 const struct firmware *fw_entry = NULL; 1284 const struct firmware *fw_entry = NULL;
1286 1285
1287 strncpy(tms_device.bus_id,dev->name, BUS_ID_SIZE); 1286 if (request_firmware(&fw_entry, "tms380tr.bin", tp->pdev) != 0) {
1288
1289 if (request_firmware(&fw_entry, "tms380tr.bin", &tms_device) != 0) {
1290 printk(KERN_ALERT "%s: firmware %s is missing, cannot start.\n", 1287 printk(KERN_ALERT "%s: firmware %s is missing, cannot start.\n",
1291 dev->name, "tms380tr.bin"); 1288 dev->name, "tms380tr.bin");
1292 return (-1); 1289 return (-1);
@@ -2021,7 +2018,7 @@ static void tms380tr_cancel_tx_queue(struct net_local* tp)
2021 2018
2022 printk(KERN_INFO "Cancel tx (%08lXh).\n", (unsigned long)tpl); 2019 printk(KERN_INFO "Cancel tx (%08lXh).\n", (unsigned long)tpl);
2023 if (tpl->DMABuff) 2020 if (tpl->DMABuff)
2024 pci_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, PCI_DMA_TODEVICE); 2021 dma_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, DMA_TO_DEVICE);
2025 dev_kfree_skb_any(tpl->Skb); 2022 dev_kfree_skb_any(tpl->Skb);
2026 } 2023 }
2027 2024
@@ -2090,7 +2087,7 @@ static void tms380tr_tx_status_irq(struct net_device *dev)
2090 2087
2091 tp->MacStat.tx_packets++; 2088 tp->MacStat.tx_packets++;
2092 if (tpl->DMABuff) 2089 if (tpl->DMABuff)
2093 pci_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, PCI_DMA_TODEVICE); 2090 dma_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, DMA_TO_DEVICE);
2094 dev_kfree_skb_irq(tpl->Skb); 2091 dev_kfree_skb_irq(tpl->Skb);
2095 tpl->BusyFlag = 0; /* "free" TPL */ 2092 tpl->BusyFlag = 0; /* "free" TPL */
2096 } 2093 }
@@ -2209,7 +2206,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
2209 tp->MacStat.rx_errors++; 2206 tp->MacStat.rx_errors++;
2210 } 2207 }
2211 if (rpl->DMABuff) 2208 if (rpl->DMABuff)
2212 pci_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, PCI_DMA_TODEVICE); 2209 dma_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, DMA_TO_DEVICE);
2213 rpl->DMABuff = 0; 2210 rpl->DMABuff = 0;
2214 2211
2215 /* Allocate new skb for rpl */ 2212 /* Allocate new skb for rpl */
@@ -2227,7 +2224,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
2227 skb_put(rpl->Skb, tp->MaxPacketSize); 2224 skb_put(rpl->Skb, tp->MaxPacketSize);
2228 2225
2229 /* Data unreachable for DMA ? then use local buffer */ 2226 /* Data unreachable for DMA ? then use local buffer */
2230 dmabuf = pci_map_single(tp->pdev, rpl->Skb->data, tp->MaxPacketSize, PCI_DMA_FROMDEVICE); 2227 dmabuf = dma_map_single(tp->pdev, rpl->Skb->data, tp->MaxPacketSize, DMA_FROM_DEVICE);
2231 if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit)) 2228 if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit))
2232 { 2229 {
2233 rpl->SkbStat = SKB_DATA_COPY; 2230 rpl->SkbStat = SKB_DATA_COPY;
@@ -2332,23 +2329,26 @@ void tmsdev_term(struct net_device *dev)
2332 struct net_local *tp; 2329 struct net_local *tp;
2333 2330
2334 tp = netdev_priv(dev); 2331 tp = netdev_priv(dev);
2335 pci_unmap_single(tp->pdev, tp->dmabuffer, sizeof(struct net_local), 2332 dma_unmap_single(tp->pdev, tp->dmabuffer, sizeof(struct net_local),
2336 PCI_DMA_BIDIRECTIONAL); 2333 DMA_BIDIRECTIONAL);
2337} 2334}
2338 2335
2339int tmsdev_init(struct net_device *dev, unsigned long dmalimit, 2336int tmsdev_init(struct net_device *dev, struct device *pdev)
2340 struct pci_dev *pdev)
2341{ 2337{
2342 struct net_local *tms_local; 2338 struct net_local *tms_local;
2343 2339
2344 memset(dev->priv, 0, sizeof(struct net_local)); 2340 memset(dev->priv, 0, sizeof(struct net_local));
2345 tms_local = netdev_priv(dev); 2341 tms_local = netdev_priv(dev);
2346 init_waitqueue_head(&tms_local->wait_for_tok_int); 2342 init_waitqueue_head(&tms_local->wait_for_tok_int);
2347 tms_local->dmalimit = dmalimit; 2343 if (pdev->dma_mask)
2344 tms_local->dmalimit = *pdev->dma_mask;
2345 else
2346 return -ENOMEM;
2348 tms_local->pdev = pdev; 2347 tms_local->pdev = pdev;
2349 tms_local->dmabuffer = pci_map_single(pdev, (void *)tms_local, 2348 tms_local->dmabuffer = dma_map_single(pdev, (void *)tms_local,
2350 sizeof(struct net_local), PCI_DMA_BIDIRECTIONAL); 2349 sizeof(struct net_local), DMA_BIDIRECTIONAL);
2351 if (tms_local->dmabuffer + sizeof(struct net_local) > dmalimit) 2350 if (tms_local->dmabuffer + sizeof(struct net_local) >
2351 tms_local->dmalimit)
2352 { 2352 {
2353 printk(KERN_INFO "%s: Memory not accessible for DMA\n", 2353 printk(KERN_INFO "%s: Memory not accessible for DMA\n",
2354 dev->name); 2354 dev->name);
@@ -2370,8 +2370,6 @@ int tmsdev_init(struct net_device *dev, unsigned long dmalimit,
2370 return 0; 2370 return 0;
2371} 2371}
2372 2372
2373#ifdef MODULE
2374
2375EXPORT_SYMBOL(tms380tr_open); 2373EXPORT_SYMBOL(tms380tr_open);
2376EXPORT_SYMBOL(tms380tr_close); 2374EXPORT_SYMBOL(tms380tr_close);
2377EXPORT_SYMBOL(tms380tr_interrupt); 2375EXPORT_SYMBOL(tms380tr_interrupt);
@@ -2379,7 +2377,9 @@ EXPORT_SYMBOL(tmsdev_init);
2379EXPORT_SYMBOL(tmsdev_term); 2377EXPORT_SYMBOL(tmsdev_term);
2380EXPORT_SYMBOL(tms380tr_wait); 2378EXPORT_SYMBOL(tms380tr_wait);
2381 2379
2382struct module *TMS380_module = NULL; 2380#ifdef MODULE
2381
2382static struct module *TMS380_module = NULL;
2383 2383
2384int init_module(void) 2384int init_module(void)
2385{ 2385{
@@ -2397,14 +2397,3 @@ void cleanup_module(void)
2397 2397
2398MODULE_LICENSE("GPL"); 2398MODULE_LICENSE("GPL");
2399 2399
2400
2401/*
2402 * Local variables:
2403 * compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c tms380tr.c"
2404 * alt-compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c tms380tr.c"
2405 * c-set-style "K&R"
2406 * c-indent-level: 8
2407 * c-basic-offset: 8
2408 * tab-width: 8
2409 * End:
2410 */
diff --git a/drivers/net/tokenring/tms380tr.h b/drivers/net/tokenring/tms380tr.h
index f2c5ba0f37a5..30452c67bb68 100644
--- a/drivers/net/tokenring/tms380tr.h
+++ b/drivers/net/tokenring/tms380tr.h
@@ -17,8 +17,7 @@
17int tms380tr_open(struct net_device *dev); 17int tms380tr_open(struct net_device *dev);
18int tms380tr_close(struct net_device *dev); 18int tms380tr_close(struct net_device *dev);
19irqreturn_t tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs); 19irqreturn_t tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
20int tmsdev_init(struct net_device *dev, unsigned long dmalimit, 20int tmsdev_init(struct net_device *dev, struct device *pdev);
21 struct pci_dev *pdev);
22void tmsdev_term(struct net_device *dev); 21void tmsdev_term(struct net_device *dev);
23void tms380tr_wait(unsigned long time); 22void tms380tr_wait(unsigned long time);
24 23
@@ -719,7 +718,7 @@ struct s_TPL { /* Transmit Parameter List (align on even word boundaries) */
719 struct sk_buff *Skb; 718 struct sk_buff *Skb;
720 unsigned char TPLIndex; 719 unsigned char TPLIndex;
721 volatile unsigned char BusyFlag;/* Flag: TPL busy? */ 720 volatile unsigned char BusyFlag;/* Flag: TPL busy? */
722 dma_addr_t DMABuff; /* DMA IO bus address from pci_map */ 721 dma_addr_t DMABuff; /* DMA IO bus address from dma_map */
723}; 722};
724 723
725/* ---------------------Receive Functions-------------------------------* 724/* ---------------------Receive Functions-------------------------------*
@@ -1060,7 +1059,7 @@ struct s_RPL { /* Receive Parameter List */
1060 struct sk_buff *Skb; 1059 struct sk_buff *Skb;
1061 SKB_STAT SkbStat; 1060 SKB_STAT SkbStat;
1062 int RPLIndex; 1061 int RPLIndex;
1063 dma_addr_t DMABuff; /* DMA IO bus address from pci_map */ 1062 dma_addr_t DMABuff; /* DMA IO bus address from dma_map */
1064}; 1063};
1065 1064
1066/* Information that need to be kept for each board. */ 1065/* Information that need to be kept for each board. */
@@ -1091,7 +1090,7 @@ typedef struct net_local {
1091 RPL *RplTail; 1090 RPL *RplTail;
1092 unsigned char LocalRxBuffers[RPL_NUM][DEFAULT_PACKET_SIZE]; 1091 unsigned char LocalRxBuffers[RPL_NUM][DEFAULT_PACKET_SIZE];
1093 1092
1094 struct pci_dev *pdev; 1093 struct device *pdev;
1095 int DataRate; 1094 int DataRate;
1096 unsigned char ScbInUse; 1095 unsigned char ScbInUse;
1097 unsigned short CMDqueue; 1096 unsigned short CMDqueue;
diff --git a/drivers/net/tokenring/tmspci.c b/drivers/net/tokenring/tmspci.c
index 37ddb5c2bec3..ab47c0547a3b 100644
--- a/drivers/net/tokenring/tmspci.c
+++ b/drivers/net/tokenring/tmspci.c
@@ -100,7 +100,7 @@ static int __devinit tms_pci_attach(struct pci_dev *pdev, const struct pci_devic
100 unsigned int pci_irq_line; 100 unsigned int pci_irq_line;
101 unsigned long pci_ioaddr; 101 unsigned long pci_ioaddr;
102 struct card_info *cardinfo = &card_info_table[ent->driver_data]; 102 struct card_info *cardinfo = &card_info_table[ent->driver_data];
103 103
104 if (versionprinted++ == 0) 104 if (versionprinted++ == 0)
105 printk("%s", version); 105 printk("%s", version);
106 106
@@ -143,7 +143,7 @@ static int __devinit tms_pci_attach(struct pci_dev *pdev, const struct pci_devic
143 printk(":%2.2x", dev->dev_addr[i]); 143 printk(":%2.2x", dev->dev_addr[i]);
144 printk("\n"); 144 printk("\n");
145 145
146 ret = tmsdev_init(dev, PCI_MAX_ADDRESS, pdev); 146 ret = tmsdev_init(dev, &pdev->dev);
147 if (ret) { 147 if (ret) {
148 printk("%s: unable to get memory for dev->priv.\n", dev->name); 148 printk("%s: unable to get memory for dev->priv.\n", dev->name);
149 goto err_out_irq; 149 goto err_out_irq;
@@ -254,14 +254,3 @@ static void __exit tms_pci_rmmod (void)
254module_init(tms_pci_init); 254module_init(tms_pci_init);
255module_exit(tms_pci_rmmod); 255module_exit(tms_pci_rmmod);
256 256
257
258/*
259 * Local variables:
260 * compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c tmspci.c"
261 * alt-compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer -I/usr/src/linux/drivers/net/tokenring/ -c tmspci.c"
262 * c-set-style "K&R"
263 * c-indent-level: 8
264 * c-basic-offset: 8
265 * tab-width: 8
266 * End:
267 */
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index dd357dd8c370..fc353e348f9a 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -446,13 +446,13 @@ static void de_rx (struct de_private *de)
446 446
447 mapping = 447 mapping =
448 de->rx_skb[rx_tail].mapping = 448 de->rx_skb[rx_tail].mapping =
449 pci_map_single(de->pdev, copy_skb->tail, 449 pci_map_single(de->pdev, copy_skb->data,
450 buflen, PCI_DMA_FROMDEVICE); 450 buflen, PCI_DMA_FROMDEVICE);
451 de->rx_skb[rx_tail].skb = copy_skb; 451 de->rx_skb[rx_tail].skb = copy_skb;
452 } else { 452 } else {
453 pci_dma_sync_single_for_cpu(de->pdev, mapping, len, PCI_DMA_FROMDEVICE); 453 pci_dma_sync_single_for_cpu(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
454 skb_reserve(copy_skb, RX_OFFSET); 454 skb_reserve(copy_skb, RX_OFFSET);
455 memcpy(skb_put(copy_skb, len), skb->tail, len); 455 memcpy(skb_put(copy_skb, len), skb->data, len);
456 456
457 pci_dma_sync_single_for_device(de->pdev, mapping, len, PCI_DMA_FROMDEVICE); 457 pci_dma_sync_single_for_device(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
458 458
@@ -1269,7 +1269,7 @@ static int de_refill_rx (struct de_private *de)
1269 skb->dev = de->dev; 1269 skb->dev = de->dev;
1270 1270
1271 de->rx_skb[i].mapping = pci_map_single(de->pdev, 1271 de->rx_skb[i].mapping = pci_map_single(de->pdev,
1272 skb->tail, de->rx_buf_sz, PCI_DMA_FROMDEVICE); 1272 skb->data, de->rx_buf_sz, PCI_DMA_FROMDEVICE);
1273 de->rx_skb[i].skb = skb; 1273 de->rx_skb[i].skb = skb;
1274 1274
1275 de->rx_ring[i].opts1 = cpu_to_le32(DescOwn); 1275 de->rx_ring[i].opts1 = cpu_to_le32(DescOwn);
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index e25f33df223e..74e9075d9c48 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -78,6 +78,7 @@
78#include <linux/slab.h> 78#include <linux/slab.h>
79#include <linux/interrupt.h> 79#include <linux/interrupt.h>
80#include <linux/pci.h> 80#include <linux/pci.h>
81#include <linux/dma-mapping.h>
81#include <linux/init.h> 82#include <linux/init.h>
82#include <linux/netdevice.h> 83#include <linux/netdevice.h>
83#include <linux/etherdevice.h> 84#include <linux/etherdevice.h>
@@ -354,7 +355,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
354 SET_MODULE_OWNER(dev); 355 SET_MODULE_OWNER(dev);
355 SET_NETDEV_DEV(dev, &pdev->dev); 356 SET_NETDEV_DEV(dev, &pdev->dev);
356 357
357 if (pci_set_dma_mask(pdev, 0xffffffff)) { 358 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
358 printk(KERN_WARNING DRV_NAME ": 32-bit PCI DMA not available.\n"); 359 printk(KERN_WARNING DRV_NAME ": 32-bit PCI DMA not available.\n");
359 err = -ENODEV; 360 err = -ENODEV;
360 goto err_out_free; 361 goto err_out_free;
@@ -743,11 +744,6 @@ static irqreturn_t dmfe_interrupt(int irq, void *dev_id, struct pt_regs *regs)
743 744
744 DMFE_DBUG(0, "dmfe_interrupt()", 0); 745 DMFE_DBUG(0, "dmfe_interrupt()", 0);
745 746
746 if (!dev) {
747 DMFE_DBUG(1, "dmfe_interrupt() without DEVICE arg", 0);
748 return IRQ_NONE;
749 }
750
751 spin_lock_irqsave(&db->lock, flags); 747 spin_lock_irqsave(&db->lock, flags);
752 748
753 /* Got DM910X status */ 749 /* Got DM910X status */
@@ -949,8 +945,8 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
949 945
950 /* Received Packet CRC check need or not */ 946 /* Received Packet CRC check need or not */
951 if ( (db->dm910x_chk_mode & 1) && 947 if ( (db->dm910x_chk_mode & 1) &&
952 (cal_CRC(skb->tail, rxlen, 1) != 948 (cal_CRC(skb->data, rxlen, 1) !=
953 (*(u32 *) (skb->tail+rxlen) ))) { /* FIXME (?) */ 949 (*(u32 *) (skb->data+rxlen) ))) { /* FIXME (?) */
954 /* Found a error received packet */ 950 /* Found a error received packet */
955 dmfe_reuse_skb(db, rxptr->rx_skb_ptr); 951 dmfe_reuse_skb(db, rxptr->rx_skb_ptr);
956 db->dm910x_chk_mode = 3; 952 db->dm910x_chk_mode = 3;
@@ -963,7 +959,7 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
963 /* size less than COPY_SIZE, allocate a rxlen SKB */ 959 /* size less than COPY_SIZE, allocate a rxlen SKB */
964 skb->dev = dev; 960 skb->dev = dev;
965 skb_reserve(skb, 2); /* 16byte align */ 961 skb_reserve(skb, 2); /* 16byte align */
966 memcpy(skb_put(skb, rxlen), rxptr->rx_skb_ptr->tail, rxlen); 962 memcpy(skb_put(skb, rxlen), rxptr->rx_skb_ptr->data, rxlen);
967 dmfe_reuse_skb(db, rxptr->rx_skb_ptr); 963 dmfe_reuse_skb(db, rxptr->rx_skb_ptr);
968 } else { 964 } else {
969 skb->dev = dev; 965 skb->dev = dev;
@@ -1256,7 +1252,7 @@ static void dmfe_reuse_skb(struct dmfe_board_info *db, struct sk_buff * skb)
1256 1252
1257 if (!(rxptr->rdes0 & cpu_to_le32(0x80000000))) { 1253 if (!(rxptr->rdes0 & cpu_to_le32(0x80000000))) {
1258 rxptr->rx_skb_ptr = skb; 1254 rxptr->rx_skb_ptr = skb;
1259 rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->tail, RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) ); 1255 rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->data, RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) );
1260 wmb(); 1256 wmb();
1261 rxptr->rdes0 = cpu_to_le32(0x80000000); 1257 rxptr->rdes0 = cpu_to_le32(0x80000000);
1262 db->rx_avail_cnt++; 1258 db->rx_avail_cnt++;
@@ -1467,7 +1463,7 @@ static void allocate_rx_buffer(struct dmfe_board_info *db)
1467 if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL ) 1463 if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL )
1468 break; 1464 break;
1469 rxptr->rx_skb_ptr = skb; /* FIXME (?) */ 1465 rxptr->rx_skb_ptr = skb; /* FIXME (?) */
1470 rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->tail, RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) ); 1466 rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->data, RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) );
1471 wmb(); 1467 wmb();
1472 rxptr->rdes0 = cpu_to_le32(0x80000000); 1468 rxptr->rdes0 = cpu_to_le32(0x80000000);
1473 rxptr = rxptr->next_rx_desc; 1469 rxptr = rxptr->next_rx_desc;
@@ -1806,7 +1802,7 @@ static void dmfe_parse_srom(struct dmfe_board_info * db)
1806 if ( ( (int) srom[18] & 0xff) == SROM_V41_CODE) { 1802 if ( ( (int) srom[18] & 0xff) == SROM_V41_CODE) {
1807 /* SROM V4.01 */ 1803 /* SROM V4.01 */
1808 /* Get NIC support media mode */ 1804 /* Get NIC support media mode */
1809 db->NIC_capability = le16_to_cpup(srom + 34); 1805 db->NIC_capability = le16_to_cpup((__le16 *)srom + 34/2);
1810 db->PHY_reg4 = 0; 1806 db->PHY_reg4 = 0;
1811 for (tmp_reg = 1; tmp_reg < 0x10; tmp_reg <<= 1) { 1807 for (tmp_reg = 1; tmp_reg < 0x10; tmp_reg <<= 1) {
1812 switch( db->NIC_capability & tmp_reg ) { 1808 switch( db->NIC_capability & tmp_reg ) {
@@ -1818,7 +1814,8 @@ static void dmfe_parse_srom(struct dmfe_board_info * db)
1818 } 1814 }
1819 1815
1820 /* Media Mode Force or not check */ 1816 /* Media Mode Force or not check */
1821 dmfe_mode = le32_to_cpup(srom + 34) & le32_to_cpup(srom + 36); 1817 dmfe_mode = le32_to_cpup((__le32 *)srom + 34/4) &
1818 le32_to_cpup((__le32 *)srom + 36/4);
1822 switch(dmfe_mode) { 1819 switch(dmfe_mode) {
1823 case 0x4: dmfe_media_mode = DMFE_100MHF; break; /* 100MHF */ 1820 case 0x4: dmfe_media_mode = DMFE_100MHF; break; /* 100MHF */
1824 case 0x2: dmfe_media_mode = DMFE_10MFD; break; /* 10MFD */ 1821 case 0x2: dmfe_media_mode = DMFE_10MFD; break; /* 10MFD */
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index ac5bf49ff60f..fbd9ab60b052 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -63,6 +63,22 @@ static struct eeprom_fixup eeprom_fixups[] __devinitdata = {
63 */ 63 */
64 { 0x1e00, 0x0000, 0x000b, 0x8f01, 0x0103, 0x0300, 0x0821, 0x000, 0x0001, 0x0000, 0x01e1 } 64 { 0x1e00, 0x0000, 0x000b, 0x8f01, 0x0103, 0x0300, 0x0821, 0x000, 0x0001, 0x0000, 0x01e1 }
65 }, 65 },
66 {"Cobalt Microserver", 0, 0x10, 0xE0, {0x1e00, /* 0 == controller #, 1e == offset */
67 0x0000, /* 0 == high offset, 0 == gap */
68 0x0800, /* Default Autoselect */
69 0x8001, /* 1 leaf, extended type, bogus len */
70 0x0003, /* Type 3 (MII), PHY #0 */
71 0x0400, /* 0 init instr, 4 reset instr */
72 0x0801, /* Set control mode, GP0 output */
73 0x0000, /* Drive GP0 Low (RST is active low) */
74 0x0800, /* control mode, GP0 input (undriven) */
75 0x0000, /* clear control mode */
76 0x7800, /* 100TX FDX + HDX, 10bT FDX + HDX */
77 0x01e0, /* Advertise all above */
78 0x5000, /* FDX all above */
79 0x1800, /* Set fast TTM in 100bt modes */
80 0x0000, /* PHY cannot be unplugged */
81 }},
66 {NULL}}; 82 {NULL}};
67 83
68 84
diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
index afb5cda9d8e1..bb3558164a5b 100644
--- a/drivers/net/tulip/interrupt.c
+++ b/drivers/net/tulip/interrupt.c
@@ -78,7 +78,7 @@ int tulip_refill_rx(struct net_device *dev)
78 if (skb == NULL) 78 if (skb == NULL)
79 break; 79 break;
80 80
81 mapping = pci_map_single(tp->pdev, skb->tail, PKT_BUF_SZ, 81 mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
82 PCI_DMA_FROMDEVICE); 82 PCI_DMA_FROMDEVICE);
83 tp->rx_buffers[entry].mapping = mapping; 83 tp->rx_buffers[entry].mapping = mapping;
84 84
@@ -199,12 +199,12 @@ int tulip_poll(struct net_device *dev, int *budget)
199 tp->rx_buffers[entry].mapping, 199 tp->rx_buffers[entry].mapping,
200 pkt_len, PCI_DMA_FROMDEVICE); 200 pkt_len, PCI_DMA_FROMDEVICE);
201#if ! defined(__alpha__) 201#if ! defined(__alpha__)
202 eth_copy_and_sum(skb, tp->rx_buffers[entry].skb->tail, 202 eth_copy_and_sum(skb, tp->rx_buffers[entry].skb->data,
203 pkt_len, 0); 203 pkt_len, 0);
204 skb_put(skb, pkt_len); 204 skb_put(skb, pkt_len);
205#else 205#else
206 memcpy(skb_put(skb, pkt_len), 206 memcpy(skb_put(skb, pkt_len),
207 tp->rx_buffers[entry].skb->tail, 207 tp->rx_buffers[entry].skb->data,
208 pkt_len); 208 pkt_len);
209#endif 209#endif
210 pci_dma_sync_single_for_device(tp->pdev, 210 pci_dma_sync_single_for_device(tp->pdev,
@@ -423,12 +423,12 @@ static int tulip_rx(struct net_device *dev)
423 tp->rx_buffers[entry].mapping, 423 tp->rx_buffers[entry].mapping,
424 pkt_len, PCI_DMA_FROMDEVICE); 424 pkt_len, PCI_DMA_FROMDEVICE);
425#if ! defined(__alpha__) 425#if ! defined(__alpha__)
426 eth_copy_and_sum(skb, tp->rx_buffers[entry].skb->tail, 426 eth_copy_and_sum(skb, tp->rx_buffers[entry].skb->data,
427 pkt_len, 0); 427 pkt_len, 0);
428 skb_put(skb, pkt_len); 428 skb_put(skb, pkt_len);
429#else 429#else
430 memcpy(skb_put(skb, pkt_len), 430 memcpy(skb_put(skb, pkt_len),
431 tp->rx_buffers[entry].skb->tail, 431 tp->rx_buffers[entry].skb->data,
432 pkt_len); 432 pkt_len);
433#endif 433#endif
434 pci_dma_sync_single_for_device(tp->pdev, 434 pci_dma_sync_single_for_device(tp->pdev,
diff --git a/drivers/net/tulip/media.c b/drivers/net/tulip/media.c
index 919c40cd635c..e26c31f944bf 100644
--- a/drivers/net/tulip/media.c
+++ b/drivers/net/tulip/media.c
@@ -400,6 +400,9 @@ void tulip_select_media(struct net_device *dev, int startup)
400 } 400 }
401 401
402 tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0); 402 tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
403
404 mdelay(1);
405
403 return; 406 return;
404} 407}
405 408
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index e0ae3ed6e578..d45d8f56e5b4 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -242,6 +242,7 @@ static struct pci_device_id tulip_pci_tbl[] = {
242 { 0x10b9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ULI526X }, /* ALi 1563 integrated ethernet */ 242 { 0x10b9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ULI526X }, /* ALi 1563 integrated ethernet */
243 { 0x10b9, 0x5263, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ULI526X }, /* ALi 1563 integrated ethernet */ 243 { 0x10b9, 0x5263, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ULI526X }, /* ALi 1563 integrated ethernet */
244 { 0x10b7, 0x9300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* 3Com 3CSOHO100B-TX */ 244 { 0x10b7, 0x9300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* 3Com 3CSOHO100B-TX */
245 { 0x14ea, 0xab08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* Planex FNW-3602-TX */
245 { } /* terminate list */ 246 { } /* terminate list */
246}; 247};
247MODULE_DEVICE_TABLE(pci, tulip_pci_tbl); 248MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
@@ -624,7 +625,7 @@ static void tulip_init_ring(struct net_device *dev)
624 tp->rx_buffers[i].skb = skb; 625 tp->rx_buffers[i].skb = skb;
625 if (skb == NULL) 626 if (skb == NULL)
626 break; 627 break;
627 mapping = pci_map_single(tp->pdev, skb->tail, 628 mapping = pci_map_single(tp->pdev, skb->data,
628 PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 629 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
629 tp->rx_buffers[i].mapping = mapping; 630 tp->rx_buffers[i].mapping = mapping;
630 skb->dev = dev; /* Mark as being used by this device. */ 631 skb->dev = dev; /* Mark as being used by this device. */
@@ -1514,8 +1515,8 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1514 (PCI_SLOT(pdev->devfn) == 12))) { 1515 (PCI_SLOT(pdev->devfn) == 12))) {
1515 /* Cobalt MAC address in first EEPROM locations. */ 1516 /* Cobalt MAC address in first EEPROM locations. */
1516 sa_offset = 0; 1517 sa_offset = 0;
1517 /* No media table either */ 1518 /* Ensure our media table fixup get's applied */
1518 tp->flags &= ~HAS_MEDIA_TABLE; 1519 memcpy(ee_data + 16, ee_data, 8);
1519 } 1520 }
1520#endif 1521#endif
1521#ifdef CONFIG_GSC 1522#ifdef CONFIG_GSC
@@ -1756,11 +1757,19 @@ static int tulip_suspend (struct pci_dev *pdev, pm_message_t state)
1756{ 1757{
1757 struct net_device *dev = pci_get_drvdata(pdev); 1758 struct net_device *dev = pci_get_drvdata(pdev);
1758 1759
1759 if (dev && netif_running (dev) && netif_device_present (dev)) { 1760 if (!dev)
1760 netif_device_detach (dev); 1761 return -EINVAL;
1761 tulip_down (dev); 1762
1762 /* pci_power_off(pdev, -1); */ 1763 if (netif_running(dev))
1763 } 1764 tulip_down(dev);
1765
1766 netif_device_detach(dev);
1767 free_irq(dev->irq, dev);
1768
1769 pci_save_state(pdev);
1770 pci_disable_device(pdev);
1771 pci_set_power_state(pdev, pci_choose_state(pdev, state));
1772
1764 return 0; 1773 return 0;
1765} 1774}
1766 1775
@@ -1768,15 +1777,26 @@ static int tulip_suspend (struct pci_dev *pdev, pm_message_t state)
1768static int tulip_resume(struct pci_dev *pdev) 1777static int tulip_resume(struct pci_dev *pdev)
1769{ 1778{
1770 struct net_device *dev = pci_get_drvdata(pdev); 1779 struct net_device *dev = pci_get_drvdata(pdev);
1780 int retval;
1771 1781
1772 if (dev && netif_running (dev) && !netif_device_present (dev)) { 1782 if (!dev)
1773#if 1 1783 return -EINVAL;
1774 pci_enable_device (pdev); 1784
1775#endif 1785 pci_set_power_state(pdev, PCI_D0);
1776 /* pci_power_on(pdev); */ 1786 pci_restore_state(pdev);
1777 tulip_up (dev); 1787
1778 netif_device_attach (dev); 1788 pci_enable_device(pdev);
1789
1790 if ((retval = request_irq(dev->irq, &tulip_interrupt, SA_SHIRQ, dev->name, dev))) {
1791 printk (KERN_ERR "tulip: request_irq failed in resume\n");
1792 return retval;
1779 } 1793 }
1794
1795 netif_device_attach(dev);
1796
1797 if (netif_running(dev))
1798 tulip_up(dev);
1799
1780 return 0; 1800 return 0;
1781} 1801}
1782 1802
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index caff2f590165..5b1af3986abf 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -121,6 +121,7 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
121#include <linux/slab.h> 121#include <linux/slab.h>
122#include <linux/interrupt.h> 122#include <linux/interrupt.h>
123#include <linux/pci.h> 123#include <linux/pci.h>
124#include <linux/dma-mapping.h>
124#include <linux/netdevice.h> 125#include <linux/netdevice.h>
125#include <linux/etherdevice.h> 126#include <linux/etherdevice.h>
126#include <linux/skbuff.h> 127#include <linux/skbuff.h>
@@ -394,7 +395,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
394 395
395 irq = pdev->irq; 396 irq = pdev->irq;
396 397
397 if (pci_set_dma_mask(pdev,0xFFFFffff)) { 398 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
398 printk(KERN_WARNING "Winbond-840: Device %s disabled due to DMA limitations.\n", 399 printk(KERN_WARNING "Winbond-840: Device %s disabled due to DMA limitations.\n",
399 pci_name(pdev)); 400 pci_name(pdev));
400 return -EIO; 401 return -EIO;
@@ -848,7 +849,7 @@ static void init_rxtx_rings(struct net_device *dev)
848 if (skb == NULL) 849 if (skb == NULL)
849 break; 850 break;
850 skb->dev = dev; /* Mark as being used by this device. */ 851 skb->dev = dev; /* Mark as being used by this device. */
851 np->rx_addr[i] = pci_map_single(np->pci_dev,skb->tail, 852 np->rx_addr[i] = pci_map_single(np->pci_dev,skb->data,
852 skb->len,PCI_DMA_FROMDEVICE); 853 skb->len,PCI_DMA_FROMDEVICE);
853 854
854 np->rx_ring[i].buffer1 = np->rx_addr[i]; 855 np->rx_ring[i].buffer1 = np->rx_addr[i];
@@ -1268,7 +1269,7 @@ static int netdev_rx(struct net_device *dev)
1268 pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry], 1269 pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry],
1269 np->rx_skbuff[entry]->len, 1270 np->rx_skbuff[entry]->len,
1270 PCI_DMA_FROMDEVICE); 1271 PCI_DMA_FROMDEVICE);
1271 eth_copy_and_sum(skb, np->rx_skbuff[entry]->tail, pkt_len, 0); 1272 eth_copy_and_sum(skb, np->rx_skbuff[entry]->data, pkt_len, 0);
1272 skb_put(skb, pkt_len); 1273 skb_put(skb, pkt_len);
1273 pci_dma_sync_single_for_device(np->pci_dev,np->rx_addr[entry], 1274 pci_dma_sync_single_for_device(np->pci_dev,np->rx_addr[entry],
1274 np->rx_skbuff[entry]->len, 1275 np->rx_skbuff[entry]->len,
@@ -1314,7 +1315,7 @@ static int netdev_rx(struct net_device *dev)
1314 break; /* Better luck next round. */ 1315 break; /* Better luck next round. */
1315 skb->dev = dev; /* Mark as being used by this device. */ 1316 skb->dev = dev; /* Mark as being used by this device. */
1316 np->rx_addr[entry] = pci_map_single(np->pci_dev, 1317 np->rx_addr[entry] = pci_map_single(np->pci_dev,
1317 skb->tail, 1318 skb->data,
1318 skb->len, PCI_DMA_FROMDEVICE); 1319 skb->len, PCI_DMA_FROMDEVICE);
1319 np->rx_ring[entry].buffer1 = np->rx_addr[entry]; 1320 np->rx_ring[entry].buffer1 = np->rx_addr[entry];
1320 } 1321 }
diff --git a/drivers/net/tulip/xircom_tulip_cb.c b/drivers/net/tulip/xircom_tulip_cb.c
index b8a9b395c5ea..887d7245fe7b 100644
--- a/drivers/net/tulip/xircom_tulip_cb.c
+++ b/drivers/net/tulip/xircom_tulip_cb.c
@@ -899,7 +899,7 @@ static void xircom_init_ring(struct net_device *dev)
899 break; 899 break;
900 skb->dev = dev; /* Mark as being used by this device. */ 900 skb->dev = dev; /* Mark as being used by this device. */
901 tp->rx_ring[i].status = Rx0DescOwned; /* Owned by Xircom chip */ 901 tp->rx_ring[i].status = Rx0DescOwned; /* Owned by Xircom chip */
902 tp->rx_ring[i].buffer1 = virt_to_bus(skb->tail); 902 tp->rx_ring[i].buffer1 = virt_to_bus(skb->data);
903 } 903 }
904 tp->dirty_rx = (unsigned int)(i - RX_RING_SIZE); 904 tp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
905 905
@@ -1291,7 +1291,7 @@ xircom_rx(struct net_device *dev)
1291 if (skb == NULL) 1291 if (skb == NULL)
1292 break; 1292 break;
1293 skb->dev = dev; /* Mark as being used by this device. */ 1293 skb->dev = dev; /* Mark as being used by this device. */
1294 tp->rx_ring[entry].buffer1 = virt_to_bus(skb->tail); 1294 tp->rx_ring[entry].buffer1 = virt_to_bus(skb->data);
1295 work_done++; 1295 work_done++;
1296 } 1296 }
1297 tp->rx_ring[entry].status = Rx0DescOwned; 1297 tp->rx_ring[entry].status = Rx0DescOwned;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7bfee366297b..effab0b9adca 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -215,7 +215,7 @@ static unsigned int tun_chr_poll(struct file *file, poll_table * wait)
215 215
216 poll_wait(file, &tun->read_wait, wait); 216 poll_wait(file, &tun->read_wait, wait);
217 217
218 if (skb_queue_len(&tun->readq)) 218 if (!skb_queue_empty(&tun->readq))
219 mask |= POLLIN | POLLRDNORM; 219 mask |= POLLIN | POLLRDNORM;
220 220
221 return mask; 221 return mask;
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 8f3392989a06..ecfa6f8805ce 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -1661,7 +1661,7 @@ typhoon_alloc_rx_skb(struct typhoon *tp, u32 idx)
1661#endif 1661#endif
1662 1662
1663 skb->dev = tp->dev; 1663 skb->dev = tp->dev;
1664 dma_addr = pci_map_single(tp->pdev, skb->tail, 1664 dma_addr = pci_map_single(tp->pdev, skb->data,
1665 PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 1665 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
1666 1666
1667 /* Since no card does 64 bit DAC, the high bits will never 1667 /* Since no card does 64 bit DAC, the high bits will never
@@ -1721,7 +1721,7 @@ typhoon_rx(struct typhoon *tp, struct basic_ring *rxRing, volatile u32 * ready,
1721 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, 1721 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr,
1722 PKT_BUF_SZ, 1722 PKT_BUF_SZ,
1723 PCI_DMA_FROMDEVICE); 1723 PCI_DMA_FROMDEVICE);
1724 eth_copy_and_sum(new_skb, skb->tail, pkt_len, 0); 1724 eth_copy_and_sum(new_skb, skb->data, pkt_len, 0);
1725 pci_dma_sync_single_for_device(tp->pdev, dma_addr, 1725 pci_dma_sync_single_for_device(tp->pdev, dma_addr,
1726 PKT_BUF_SZ, 1726 PKT_BUF_SZ,
1727 PCI_DMA_FROMDEVICE); 1727 PCI_DMA_FROMDEVICE);
@@ -1906,9 +1906,9 @@ typhoon_sleep(struct typhoon *tp, pci_power_t state, u16 events)
1906 */ 1906 */
1907 netif_carrier_off(tp->dev); 1907 netif_carrier_off(tp->dev);
1908 1908
1909 pci_enable_wake(tp->pdev, pci_choose_state(pdev, state), 1); 1909 pci_enable_wake(tp->pdev, state, 1);
1910 pci_disable_device(pdev); 1910 pci_disable_device(pdev);
1911 return pci_set_power_state(pdev, pci_choose_state(pdev, state)); 1911 return pci_set_power_state(pdev, state);
1912} 1912}
1913 1913
1914static int 1914static int
@@ -2274,7 +2274,7 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state)
2274 goto need_resume; 2274 goto need_resume;
2275 } 2275 }
2276 2276
2277 if(typhoon_sleep(tp, state, tp->wol_events) < 0) { 2277 if(typhoon_sleep(tp, pci_choose_state(pdev, state), tp->wol_events) < 0) {
2278 printk(KERN_ERR "%s: unable to put card to sleep\n", dev->name); 2278 printk(KERN_ERR "%s: unable to put card to sleep\n", dev->name);
2279 goto need_resume; 2279 goto need_resume;
2280 } 2280 }
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 7b57d552094a..fc7738ffbfff 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -186,6 +186,7 @@ static const int multicast_filter_limit = 32;
186#include <linux/slab.h> 186#include <linux/slab.h>
187#include <linux/interrupt.h> 187#include <linux/interrupt.h>
188#include <linux/pci.h> 188#include <linux/pci.h>
189#include <linux/dma-mapping.h>
189#include <linux/netdevice.h> 190#include <linux/netdevice.h>
190#include <linux/etherdevice.h> 191#include <linux/etherdevice.h>
191#include <linux/skbuff.h> 192#include <linux/skbuff.h>
@@ -506,7 +507,7 @@ static struct net_device_stats *rhine_get_stats(struct net_device *dev);
506static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 507static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
507static struct ethtool_ops netdev_ethtool_ops; 508static struct ethtool_ops netdev_ethtool_ops;
508static int rhine_close(struct net_device *dev); 509static int rhine_close(struct net_device *dev);
509static void rhine_shutdown (struct device *gdev); 510static void rhine_shutdown (struct pci_dev *pdev);
510 511
511#define RHINE_WAIT_FOR(condition) do { \ 512#define RHINE_WAIT_FOR(condition) do { \
512 int i=1024; \ 513 int i=1024; \
@@ -740,7 +741,7 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
740 goto err_out; 741 goto err_out;
741 742
742 /* this should always be supported */ 743 /* this should always be supported */
743 rc = pci_set_dma_mask(pdev, 0xffffffff); 744 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
744 if (rc) { 745 if (rc) {
745 printk(KERN_ERR "32-bit PCI DMA addresses not supported by " 746 printk(KERN_ERR "32-bit PCI DMA addresses not supported by "
746 "the card!?\n"); 747 "the card!?\n");
@@ -989,7 +990,7 @@ static void alloc_rbufs(struct net_device *dev)
989 skb->dev = dev; /* Mark as being used by this device. */ 990 skb->dev = dev; /* Mark as being used by this device. */
990 991
991 rp->rx_skbuff_dma[i] = 992 rp->rx_skbuff_dma[i] =
992 pci_map_single(rp->pdev, skb->tail, rp->rx_buf_sz, 993 pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz,
993 PCI_DMA_FROMDEVICE); 994 PCI_DMA_FROMDEVICE);
994 995
995 rp->rx_ring[i].addr = cpu_to_le32(rp->rx_skbuff_dma[i]); 996 rp->rx_ring[i].addr = cpu_to_le32(rp->rx_skbuff_dma[i]);
@@ -1397,7 +1398,7 @@ static void rhine_tx(struct net_device *dev)
1397 while (rp->dirty_tx != rp->cur_tx) { 1398 while (rp->dirty_tx != rp->cur_tx) {
1398 txstatus = le32_to_cpu(rp->tx_ring[entry].tx_status); 1399 txstatus = le32_to_cpu(rp->tx_ring[entry].tx_status);
1399 if (debug > 6) 1400 if (debug > 6)
1400 printk(KERN_DEBUG " Tx scavenge %d status %8.8x.\n", 1401 printk(KERN_DEBUG "Tx scavenge %d status %8.8x.\n",
1401 entry, txstatus); 1402 entry, txstatus);
1402 if (txstatus & DescOwn) 1403 if (txstatus & DescOwn)
1403 break; 1404 break;
@@ -1468,7 +1469,7 @@ static void rhine_rx(struct net_device *dev)
1468 int data_size = desc_status >> 16; 1469 int data_size = desc_status >> 16;
1469 1470
1470 if (debug > 4) 1471 if (debug > 4)
1471 printk(KERN_DEBUG " rhine_rx() status is %8.8x.\n", 1472 printk(KERN_DEBUG "rhine_rx() status is %8.8x.\n",
1472 desc_status); 1473 desc_status);
1473 if (--boguscnt < 0) 1474 if (--boguscnt < 0)
1474 break; 1475 break;
@@ -1486,7 +1487,7 @@ static void rhine_rx(struct net_device *dev)
1486 } else if (desc_status & RxErr) { 1487 } else if (desc_status & RxErr) {
1487 /* There was a error. */ 1488 /* There was a error. */
1488 if (debug > 2) 1489 if (debug > 2)
1489 printk(KERN_DEBUG " rhine_rx() Rx " 1490 printk(KERN_DEBUG "rhine_rx() Rx "
1490 "error was %8.8x.\n", 1491 "error was %8.8x.\n",
1491 desc_status); 1492 desc_status);
1492 rp->stats.rx_errors++; 1493 rp->stats.rx_errors++;
@@ -1517,7 +1518,7 @@ static void rhine_rx(struct net_device *dev)
1517 PCI_DMA_FROMDEVICE); 1518 PCI_DMA_FROMDEVICE);
1518 1519
1519 eth_copy_and_sum(skb, 1520 eth_copy_and_sum(skb,
1520 rp->rx_skbuff[entry]->tail, 1521 rp->rx_skbuff[entry]->data,
1521 pkt_len, 0); 1522 pkt_len, 0);
1522 skb_put(skb, pkt_len); 1523 skb_put(skb, pkt_len);
1523 pci_dma_sync_single_for_device(rp->pdev, 1524 pci_dma_sync_single_for_device(rp->pdev,
@@ -1560,7 +1561,7 @@ static void rhine_rx(struct net_device *dev)
1560 break; /* Better luck next round. */ 1561 break; /* Better luck next round. */
1561 skb->dev = dev; /* Mark as being used by this device. */ 1562 skb->dev = dev; /* Mark as being used by this device. */
1562 rp->rx_skbuff_dma[entry] = 1563 rp->rx_skbuff_dma[entry] =
1563 pci_map_single(rp->pdev, skb->tail, 1564 pci_map_single(rp->pdev, skb->data,
1564 rp->rx_buf_sz, 1565 rp->rx_buf_sz,
1565 PCI_DMA_FROMDEVICE); 1566 PCI_DMA_FROMDEVICE);
1566 rp->rx_ring[entry].addr = cpu_to_le32(rp->rx_skbuff_dma[entry]); 1567 rp->rx_ring[entry].addr = cpu_to_le32(rp->rx_skbuff_dma[entry]);
@@ -1894,9 +1895,8 @@ static void __devexit rhine_remove_one(struct pci_dev *pdev)
1894 pci_set_drvdata(pdev, NULL); 1895 pci_set_drvdata(pdev, NULL);
1895} 1896}
1896 1897
1897static void rhine_shutdown (struct device *gendev) 1898static void rhine_shutdown (struct pci_dev *pdev)
1898{ 1899{
1899 struct pci_dev *pdev = to_pci_dev(gendev);
1900 struct net_device *dev = pci_get_drvdata(pdev); 1900 struct net_device *dev = pci_get_drvdata(pdev);
1901 struct rhine_private *rp = netdev_priv(dev); 1901 struct rhine_private *rp = netdev_priv(dev);
1902 void __iomem *ioaddr = rp->base; 1902 void __iomem *ioaddr = rp->base;
@@ -1955,7 +1955,7 @@ static int rhine_suspend(struct pci_dev *pdev, pm_message_t state)
1955 pci_save_state(pdev); 1955 pci_save_state(pdev);
1956 1956
1957 spin_lock_irqsave(&rp->lock, flags); 1957 spin_lock_irqsave(&rp->lock, flags);
1958 rhine_shutdown(&pdev->dev); 1958 rhine_shutdown(pdev);
1959 spin_unlock_irqrestore(&rp->lock, flags); 1959 spin_unlock_irqrestore(&rp->lock, flags);
1960 1960
1961 free_irq(dev->irq, dev); 1961 free_irq(dev->irq, dev);
@@ -2009,9 +2009,7 @@ static struct pci_driver rhine_driver = {
2009 .suspend = rhine_suspend, 2009 .suspend = rhine_suspend,
2010 .resume = rhine_resume, 2010 .resume = rhine_resume,
2011#endif /* CONFIG_PM */ 2011#endif /* CONFIG_PM */
2012 .driver = { 2012 .shutdown = rhine_shutdown,
2013 .shutdown = rhine_shutdown,
2014 }
2015}; 2013};
2016 2014
2017 2015
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 15e710283493..abc5cee6eedc 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -1335,7 +1335,7 @@ static inline int velocity_rx_copy(struct sk_buff **rx_skb, int pkt_size,
1335 if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) 1335 if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN)
1336 skb_reserve(new_skb, 2); 1336 skb_reserve(new_skb, 2);
1337 1337
1338 memcpy(new_skb->data, rx_skb[0]->tail, pkt_size); 1338 memcpy(new_skb->data, rx_skb[0]->data, pkt_size);
1339 *rx_skb = new_skb; 1339 *rx_skb = new_skb;
1340 ret = 0; 1340 ret = 0;
1341 } 1341 }
@@ -1456,9 +1456,9 @@ static int velocity_alloc_rx_buf(struct velocity_info *vptr, int idx)
1456 * Do the gymnastics to get the buffer head for data at 1456 * Do the gymnastics to get the buffer head for data at
1457 * 64byte alignment. 1457 * 64byte alignment.
1458 */ 1458 */
1459 skb_reserve(rd_info->skb, (unsigned long) rd_info->skb->tail & 63); 1459 skb_reserve(rd_info->skb, (unsigned long) rd_info->skb->data & 63);
1460 rd_info->skb->dev = vptr->dev; 1460 rd_info->skb->dev = vptr->dev;
1461 rd_info->skb_dma = pci_map_single(vptr->pdev, rd_info->skb->tail, vptr->rx_buf_sz, PCI_DMA_FROMDEVICE); 1461 rd_info->skb_dma = pci_map_single(vptr->pdev, rd_info->skb->data, vptr->rx_buf_sz, PCI_DMA_FROMDEVICE);
1462 1462
1463 /* 1463 /*
1464 * Fill in the descriptor to match 1464 * Fill in the descriptor to match
diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h
index 1b70b7c97580..d9a774b91ddc 100644
--- a/drivers/net/via-velocity.h
+++ b/drivers/net/via-velocity.h
@@ -1414,7 +1414,7 @@ static inline void mac_get_cam(struct mac_regs __iomem * regs, int idx, u8 *addr
1414 * the rest of the logic from the result of sleep/wakeup 1414 * the rest of the logic from the result of sleep/wakeup
1415 */ 1415 */
1416 1416
1417inline static void mac_wol_reset(struct mac_regs __iomem * regs) 1417static inline void mac_wol_reset(struct mac_regs __iomem * regs)
1418{ 1418{
1419 1419
1420 /* Turn off SWPTAG right after leaving power mode */ 1420 /* Turn off SWPTAG right after leaving power mode */
@@ -1811,7 +1811,7 @@ struct velocity_info {
1811 * CHECK ME: locking 1811 * CHECK ME: locking
1812 */ 1812 */
1813 1813
1814inline static int velocity_get_ip(struct velocity_info *vptr) 1814static inline int velocity_get_ip(struct velocity_info *vptr)
1815{ 1815{
1816 struct in_device *in_dev = (struct in_device *) vptr->dev->ip_ptr; 1816 struct in_device *in_dev = (struct in_device *) vptr->dev->ip_ptr;
1817 struct in_ifaddr *ifa; 1817 struct in_ifaddr *ifa;
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 66b94668ddd8..18c27e1e7884 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -435,7 +435,7 @@ config VENDOR_SANGOMA
435 the driver to support. 435 the driver to support.
436 436
437 If you have one or more of these cards, say M to this option; 437 If you have one or more of these cards, say M to this option;
438 and read <file:Documentation/networking/wanpipe.txt>. 438 and read <file:Documentation/networking/wan-router.txt>.
439 439
440 To compile this driver as a module, choose M here: the 440 To compile this driver as a module, choose M here: the
441 module will be called wanpipe. 441 module will be called wanpipe.
diff --git a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c
index 6e74af62ca08..9e56fc346ba4 100644
--- a/drivers/net/wan/cycx_drv.c
+++ b/drivers/net/wan/cycx_drv.c
@@ -56,7 +56,7 @@
56#include <linux/sched.h> /* for jiffies, HZ, etc. */ 56#include <linux/sched.h> /* for jiffies, HZ, etc. */
57#include <linux/cycx_drv.h> /* API definitions */ 57#include <linux/cycx_drv.h> /* API definitions */
58#include <linux/cycx_cfm.h> /* CYCX firmware module definitions */ 58#include <linux/cycx_cfm.h> /* CYCX firmware module definitions */
59#include <linux/delay.h> /* udelay */ 59#include <linux/delay.h> /* udelay, msleep_interruptible */
60#include <asm/io.h> /* read[wl], write[wl], ioremap, iounmap */ 60#include <asm/io.h> /* read[wl], write[wl], ioremap, iounmap */
61 61
62#define MOD_VERSION 0 62#define MOD_VERSION 0
@@ -74,7 +74,6 @@ static int reset_cyc2x(void __iomem *addr);
74static int detect_cyc2x(void __iomem *addr); 74static int detect_cyc2x(void __iomem *addr);
75 75
76/* Miscellaneous functions */ 76/* Miscellaneous functions */
77static void delay_cycx(int sec);
78static int get_option_index(long *optlist, long optval); 77static int get_option_index(long *optlist, long optval);
79static u16 checksum(u8 *buf, u32 len); 78static u16 checksum(u8 *buf, u32 len);
80 79
@@ -259,7 +258,7 @@ static int memory_exists(void __iomem *addr)
259 if (readw(addr + 0x10) == TEST_PATTERN) 258 if (readw(addr + 0x10) == TEST_PATTERN)
260 return 1; 259 return 1;
261 260
262 delay_cycx(1); 261 msleep_interruptible(1 * 1000);
263 } 262 }
264 263
265 return 0; 264 return 0;
@@ -316,7 +315,7 @@ static void cycx_reset_boot(void __iomem *addr, u8 *code, u32 len)
316 315
317 /* 80186 was in hold, go */ 316 /* 80186 was in hold, go */
318 writeb(0, addr + START_CPU); 317 writeb(0, addr + START_CPU);
319 delay_cycx(1); 318 msleep_interruptible(1 * 1000);
320} 319}
321 320
322/* Load data.bin file through boot (reset) interface. */ 321/* Load data.bin file through boot (reset) interface. */
@@ -462,13 +461,13 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len)
462 cycx_reset_boot(hw->dpmbase, reset_image, img_hdr->reset_size); 461 cycx_reset_boot(hw->dpmbase, reset_image, img_hdr->reset_size);
463 /* reset is waiting for boot */ 462 /* reset is waiting for boot */
464 writew(GEN_POWER_ON, pt_cycld); 463 writew(GEN_POWER_ON, pt_cycld);
465 delay_cycx(1); 464 msleep_interruptible(1 * 1000);
466 465
467 for (j = 0 ; j < 3 ; j++) 466 for (j = 0 ; j < 3 ; j++)
468 if (!readw(pt_cycld)) 467 if (!readw(pt_cycld))
469 goto reset_loaded; 468 goto reset_loaded;
470 else 469 else
471 delay_cycx(1); 470 msleep_interruptible(1 * 1000);
472 } 471 }
473 472
474 printk(KERN_ERR "%s: reset not started.\n", modname); 473 printk(KERN_ERR "%s: reset not started.\n", modname);
@@ -495,7 +494,7 @@ reset_loaded:
495 494
496 /* Arthur Ganzert's tip: wait a while after the firmware loading... 495 /* Arthur Ganzert's tip: wait a while after the firmware loading...
497 seg abr 26 17:17:12 EST 1999 - acme */ 496 seg abr 26 17:17:12 EST 1999 - acme */
498 delay_cycx(7); 497 msleep_interruptible(7 * 1000);
499 printk(KERN_INFO "%s: firmware loaded!\n", modname); 498 printk(KERN_INFO "%s: firmware loaded!\n", modname);
500 499
501 /* enable interrupts */ 500 /* enable interrupts */
@@ -547,20 +546,13 @@ static int get_option_index(long *optlist, long optval)
547static int reset_cyc2x(void __iomem *addr) 546static int reset_cyc2x(void __iomem *addr)
548{ 547{
549 writeb(0, addr + RST_ENABLE); 548 writeb(0, addr + RST_ENABLE);
550 delay_cycx(2); 549 msleep_interruptible(2 * 1000);
551 writeb(0, addr + RST_DISABLE); 550 writeb(0, addr + RST_DISABLE);
552 delay_cycx(2); 551 msleep_interruptible(2 * 1000);
553 552
554 return memory_exists(addr); 553 return memory_exists(addr);
555} 554}
556 555
557/* Delay */
558static void delay_cycx(int sec)
559{
560 set_current_state(TASK_INTERRUPTIBLE);
561 schedule_timeout(sec * HZ);
562}
563
564/* Calculate 16-bit CRC using CCITT polynomial. */ 556/* Calculate 16-bit CRC using CCITT polynomial. */
565static u16 checksum(u8 *buf, u32 len) 557static u16 checksum(u8 *buf, u32 len)
566{ 558{
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 7575b799ce53..2c83cca34b86 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -861,8 +861,7 @@ fst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,
861/* 861/*
862 * Mark it for our own raw sockets interface 862 * Mark it for our own raw sockets interface
863 */ 863 */
864static unsigned short farsync_type_trans(struct sk_buff *skb, 864static __be16 farsync_type_trans(struct sk_buff *skb, struct net_device *dev)
865 struct net_device *dev)
866{ 865{
867 skb->dev = dev; 866 skb->dev = dev;
868 skb->mac.raw = skb->data; 867 skb->mac.raw = skb->data;
@@ -981,6 +980,7 @@ fst_issue_cmd(struct fst_port_info *port, unsigned short cmd)
981 /* Wait for any previous command to complete */ 980 /* Wait for any previous command to complete */
982 while (mbval > NAK) { 981 while (mbval > NAK) {
983 spin_unlock_irqrestore(&card->card_lock, flags); 982 spin_unlock_irqrestore(&card->card_lock, flags);
983 set_current_state(TASK_UNINTERRUPTIBLE);
984 schedule_timeout(1); 984 schedule_timeout(1);
985 spin_lock_irqsave(&card->card_lock, flags); 985 spin_lock_irqsave(&card->card_lock, flags);
986 986
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index c1b6896d7007..48c03c11cd9a 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -72,7 +72,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
72 } 72 }
73 skb_reserve(skb, 4); 73 skb_reserve(skb, 4);
74 cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0); 74 cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0);
75 data = (cisco_packet*)skb->tail; 75 data = (cisco_packet*)skb->data;
76 76
77 data->type = htonl(type); 77 data->type = htonl(type);
78 data->par1 = htonl(par1); 78 data->par1 = htonl(par1);
@@ -91,8 +91,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
91 91
92 92
93 93
94static unsigned short cisco_type_trans(struct sk_buff *skb, 94static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev)
95 struct net_device *dev)
96{ 95{
97 hdlc_header *data = (hdlc_header*)skb->data; 96 hdlc_header *data = (hdlc_header*)skb->data;
98 97
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 7cd6195a2e46..b81263eaede0 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -66,8 +66,7 @@ static void ppp_close(struct net_device *dev)
66 66
67 67
68 68
69static unsigned short ppp_type_trans(struct sk_buff *skb, 69static __be16 ppp_type_trans(struct sk_buff *skb, struct net_device *dev)
70 struct net_device *dev)
71{ 70{
72 return __constant_htons(ETH_P_WAN_PPP); 71 return __constant_htons(ETH_P_WAN_PPP);
73} 72}
diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c
index c41fb70b6929..9456d31cb1c1 100644
--- a/drivers/net/wan/hdlc_raw.c
+++ b/drivers/net/wan/hdlc_raw.c
@@ -24,8 +24,7 @@
24#include <linux/hdlc.h> 24#include <linux/hdlc.h>
25 25
26 26
27static unsigned short raw_type_trans(struct sk_buff *skb, 27static __be16 raw_type_trans(struct sk_buff *skb, struct net_device *dev)
28 struct net_device *dev)
29{ 28{
30 return __constant_htons(ETH_P_IP); 29 return __constant_htons(ETH_P_IP);
31} 30}
diff --git a/drivers/net/wan/sdla_fr.c b/drivers/net/wan/sdla_fr.c
index 2efccb0554c0..c5f5e62aab8b 100644
--- a/drivers/net/wan/sdla_fr.c
+++ b/drivers/net/wan/sdla_fr.c
@@ -152,6 +152,7 @@
152#include <asm/io.h> /* for inb(), outb(), etc. */ 152#include <asm/io.h> /* for inb(), outb(), etc. */
153#include <linux/time.h> /* for do_gettimeofday */ 153#include <linux/time.h> /* for do_gettimeofday */
154#include <linux/in.h> /* sockaddr_in */ 154#include <linux/in.h> /* sockaddr_in */
155#include <linux/jiffies.h> /* time_after() macro */
155#include <asm/errno.h> 156#include <asm/errno.h>
156 157
157#include <linux/ip.h> 158#include <linux/ip.h>
@@ -773,7 +774,7 @@ static int update(struct wan_device* wandev)
773 for(;;) { 774 for(;;) {
774 if(card->u.f.update_comms_stats == 0) 775 if(card->u.f.update_comms_stats == 0)
775 break; 776 break;
776 if ((jiffies - timeout) > (1 * HZ)){ 777 if (time_after(jiffies, timeout + 1 * HZ)){
777 card->u.f.update_comms_stats = 0; 778 card->u.f.update_comms_stats = 0;
778 return -EAGAIN; 779 return -EAGAIN;
779 } 780 }
@@ -4799,7 +4800,7 @@ static void trigger_unconfig_fr(struct net_device *dev)
4799{ 4800{
4800 fr_channel_t *chan = dev->priv; 4801 fr_channel_t *chan = dev->priv;
4801 volatile sdla_t *card = chan->card; 4802 volatile sdla_t *card = chan->card;
4802 u32 timeout; 4803 unsigned long timeout;
4803 fr508_flags_t* flags = card->flags; 4804 fr508_flags_t* flags = card->flags;
4804 int reset_critical=0; 4805 int reset_critical=0;
4805 4806
@@ -4821,7 +4822,7 @@ static void trigger_unconfig_fr(struct net_device *dev)
4821 if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG)) 4822 if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG))
4822 break; 4823 break;
4823 4824
4824 if ((jiffies - timeout) > (1 * HZ)){ 4825 if (time_after(jiffies, timeout + 1 * HZ)){
4825 card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG; 4826 card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG;
4826 printk(KERN_INFO "%s: Failed to delete DLCI %i\n", 4827 printk(KERN_INFO "%s: Failed to delete DLCI %i\n",
4827 card->devname,chan->dlci); 4828 card->devname,chan->dlci);
diff --git a/drivers/net/wan/sdla_ft1.c b/drivers/net/wan/sdla_ft1.c
index 5e3124856eb0..9d6528a50f7b 100644
--- a/drivers/net/wan/sdla_ft1.c
+++ b/drivers/net/wan/sdla_ft1.c
@@ -29,6 +29,7 @@
29#include <linux/wanrouter.h> /* WAN router definitions */ 29#include <linux/wanrouter.h> /* WAN router definitions */
30#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ 30#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
31#include <linux/if_arp.h> /* ARPHRD_* defines */ 31#include <linux/if_arp.h> /* ARPHRD_* defines */
32#include <linux/jiffies.h> /* time_after() macro */
32 33
33#include <linux/inetdevice.h> 34#include <linux/inetdevice.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
@@ -164,7 +165,7 @@ int wpft1_init (sdla_t* card, wandev_conf_t* conf)
164 165
165 timeout = jiffies; 166 timeout = jiffies;
166 while (mb->return_code != 'I') /* Wait 1s for board to initialize */ 167 while (mb->return_code != 'I') /* Wait 1s for board to initialize */
167 if ((jiffies - timeout) > 1*HZ) break; 168 if (time_after(jiffies, timeout + 1*HZ)) break;
168 169
169 if (mb->return_code != 'I') { 170 if (mb->return_code != 'I') {
170 printk(KERN_INFO 171 printk(KERN_INFO
diff --git a/drivers/net/wan/sdla_ppp.c b/drivers/net/wan/sdla_ppp.c
index 1761cb68ab48..a4b489cccbbf 100644
--- a/drivers/net/wan/sdla_ppp.c
+++ b/drivers/net/wan/sdla_ppp.c
@@ -101,6 +101,7 @@
101#include <linux/if_arp.h> /* ARPHRD_* defines */ 101#include <linux/if_arp.h> /* ARPHRD_* defines */
102#include <asm/byteorder.h> /* htons(), etc. */ 102#include <asm/byteorder.h> /* htons(), etc. */
103#include <linux/in.h> /* sockaddr_in */ 103#include <linux/in.h> /* sockaddr_in */
104#include <linux/jiffies.h> /* time_after() macro */
104 105
105 106
106#include <asm/uaccess.h> 107#include <asm/uaccess.h>
@@ -482,7 +483,7 @@ static int update(struct wan_device *wandev)
482 if(ppp_priv_area->update_comms_stats == 0){ 483 if(ppp_priv_area->update_comms_stats == 0){
483 break; 484 break;
484 } 485 }
485 if ((jiffies - timeout) > (1 * HZ)){ 486 if (time_after(jiffies, timeout + 1 * HZ)){
486 ppp_priv_area->update_comms_stats = 0; 487 ppp_priv_area->update_comms_stats = 0;
487 ppp_priv_area->timer_int_enabled &= 488 ppp_priv_area->timer_int_enabled &=
488 ~TMR_INT_ENABLED_UPDATE; 489 ~TMR_INT_ENABLED_UPDATE;
diff --git a/drivers/net/wan/sdla_x25.c b/drivers/net/wan/sdla_x25.c
index 3a93d2fd4fbf..8a95d61a2f8f 100644
--- a/drivers/net/wan/sdla_x25.c
+++ b/drivers/net/wan/sdla_x25.c
@@ -91,6 +91,7 @@
91#include <linux/wanrouter.h> /* WAN router definitions */ 91#include <linux/wanrouter.h> /* WAN router definitions */
92#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ 92#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
93#include <linux/workqueue.h> 93#include <linux/workqueue.h>
94#include <linux/jiffies.h> /* time_after() macro */
94#include <asm/byteorder.h> /* htons(), etc. */ 95#include <asm/byteorder.h> /* htons(), etc. */
95#include <asm/atomic.h> 96#include <asm/atomic.h>
96#include <linux/delay.h> /* Experimental delay */ 97#include <linux/delay.h> /* Experimental delay */
@@ -867,7 +868,7 @@ static int update(struct wan_device* wandev)
867 if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){ 868 if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){
868 break; 869 break;
869 } 870 }
870 if ((jiffies-timeout) > 1*HZ){ 871 if (time_after(jiffies, timeout + 1*HZ)){
871 card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE; 872 card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE;
872 return -EAGAIN; 873 return -EAGAIN;
873 } 874 }
diff --git a/drivers/net/wan/wanpipe_multppp.c b/drivers/net/wan/wanpipe_multppp.c
index 6aa6987d96cb..812a1183c502 100644
--- a/drivers/net/wan/wanpipe_multppp.c
+++ b/drivers/net/wan/wanpipe_multppp.c
@@ -26,6 +26,7 @@
26#include <linux/wanrouter.h> /* WAN router definitions */ 26#include <linux/wanrouter.h> /* WAN router definitions */
27#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ 27#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
28#include <linux/if_arp.h> /* ARPHRD_* defines */ 28#include <linux/if_arp.h> /* ARPHRD_* defines */
29#include <linux/jiffies.h> /* time_after() macro */
29 30
30#include <linux/in.h> /* sockaddr_in */ 31#include <linux/in.h> /* sockaddr_in */
31#include <linux/inet.h> 32#include <linux/inet.h>
@@ -270,9 +271,9 @@ int wsppp_init (sdla_t* card, wandev_conf_t* conf)
270 ready to accept commands. We expect this to be completed in less 271 ready to accept commands. We expect this to be completed in less
271 than 1 second. */ 272 than 1 second. */
272 273
273 timeout = jiffies; 274 timeout = jiffies + 1 * HZ;
274 while (mb->return_code != 'I') /* Wait 1s for board to initialize */ 275 while (mb->return_code != 'I') /* Wait 1s for board to initialize */
275 if ((jiffies - timeout) > 1*HZ) break; 276 if (time_after(jiffies, timeout)) break;
276 277
277 if (mb->return_code != 'I') { 278 if (mb->return_code != 'I') {
278 printk(KERN_INFO 279 printk(KERN_INFO
@@ -493,11 +494,11 @@ static int update(struct wan_device* wandev)
493 chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE; 494 chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE;
494 495
495 /* wait a maximum of 1 second for the statistics to be updated */ 496 /* wait a maximum of 1 second for the statistics to be updated */
496 timeout = jiffies; 497 timeout = jiffies + 1 * HZ;
497 for(;;) { 498 for(;;) {
498 if(chdlc_priv_area->update_comms_stats == 0) 499 if(chdlc_priv_area->update_comms_stats == 0)
499 break; 500 break;
500 if ((jiffies - timeout) > (1 * HZ)){ 501 if (time_after(jiffies, timeout)){
501 chdlc_priv_area->update_comms_stats = 0; 502 chdlc_priv_area->update_comms_stats = 0;
502 chdlc_priv_area->timer_int_enabled &= 503 chdlc_priv_area->timer_int_enabled &=
503 ~TMR_INT_ENABLED_UPDATE; 504 ~TMR_INT_ENABLED_UPDATE;
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index 1e7b47704ad9..9c1e10602f2b 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -26,6 +26,7 @@
26#include <linux/netdevice.h> 26#include <linux/netdevice.h>
27#include <linux/hdlc.h> 27#include <linux/hdlc.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/dma-mapping.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/delay.h> 31#include <asm/delay.h>
31 32
@@ -624,8 +625,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
624 /* FIXME when PCI/DMA subsystems are fixed. 625 /* FIXME when PCI/DMA subsystems are fixed.
625 We set both dma_mask and consistent_dma_mask back to 32 bits 626 We set both dma_mask and consistent_dma_mask back to 32 bits
626 to indicate the card can do 32-bit DMA addressing */ 627 to indicate the card can do 32-bit DMA addressing */
627 if (pci_set_consistent_dma_mask(pdev, 0xFFFFFFFF) || 628 if (pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK) ||
628 pci_set_dma_mask(pdev, 0xFFFFFFFF)) { 629 pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
629 printk(KERN_ERR "wanXL: No usable DMA configuration\n"); 630 printk(KERN_ERR "wanXL: No usable DMA configuration\n");
630 wanxl_pci_remove_one(pdev); 631 wanxl_pci_remove_one(pdev);
631 return -EIO; 632 return -EIO;
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 1c540d825551..bdf672c48182 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -829,7 +829,7 @@ static void __exit exit_x25_asy(void)
829 } 829 }
830 830
831 kfree(x25_asy_devs); 831 kfree(x25_asy_devs);
832 tty_register_ldisc(N_X25, NULL); 832 tty_unregister_ldisc(N_X25);
833} 833}
834 834
835module_init(init_x25_asy); 835module_init(init_x25_asy);
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index 1f05d9bd05e4..b03feae459fc 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -149,12 +149,7 @@ struct net_device * __init wd_probe(int unit)
149 err = do_wd_probe(dev); 149 err = do_wd_probe(dev);
150 if (err) 150 if (err)
151 goto out; 151 goto out;
152 err = register_netdev(dev);
153 if (err)
154 goto out1;
155 return dev; 152 return dev;
156out1:
157 cleanup_card(dev);
158out: 153out:
159 free_netdev(dev); 154 free_netdev(dev);
160 return ERR_PTR(err); 155 return ERR_PTR(err);
@@ -164,6 +159,7 @@ out:
164static int __init wd_probe1(struct net_device *dev, int ioaddr) 159static int __init wd_probe1(struct net_device *dev, int ioaddr)
165{ 160{
166 int i; 161 int i;
162 int err;
167 int checksum = 0; 163 int checksum = 0;
168 int ancient = 0; /* An old card without config registers. */ 164 int ancient = 0; /* An old card without config registers. */
169 int word16 = 0; /* 0 = 8 bit, 1 = 16 bit */ 165 int word16 = 0; /* 0 = 8 bit, 1 = 16 bit */
@@ -356,7 +352,10 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr)
356 outb(inb(ioaddr+4)|0x80, ioaddr+4); 352 outb(inb(ioaddr+4)|0x80, ioaddr+4);
357#endif 353#endif
358 354
359 return 0; 355 err = register_netdev(dev);
356 if (err)
357 free_irq(dev->irq, dev);
358 return err;
360} 359}
361 360
362static int 361static int
@@ -527,11 +526,8 @@ init_module(void)
527 dev->mem_start = mem[this_dev]; 526 dev->mem_start = mem[this_dev];
528 dev->mem_end = mem_end[this_dev]; 527 dev->mem_end = mem_end[this_dev];
529 if (do_wd_probe(dev) == 0) { 528 if (do_wd_probe(dev) == 0) {
530 if (register_netdev(dev) == 0) { 529 dev_wd[found++] = dev;
531 dev_wd[found++] = dev; 530 continue;
532 continue;
533 }
534 cleanup_card(dev);
535 } 531 }
536 free_netdev(dev); 532 free_netdev(dev);
537 printk(KERN_WARNING "wd.c: No wd80x3 card found (i/o = 0x%x).\n", io[this_dev]); 533 printk(KERN_WARNING "wd.c: No wd80x3 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 1d3231cc471a..ec3f75a030d2 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -270,7 +270,7 @@ config PCMCIA_HERMES
270 270
271config AIRO_CS 271config AIRO_CS
272 tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards" 272 tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards"
273 depends on NET_RADIO && PCMCIA 273 depends on NET_RADIO && PCMCIA && (BROKEN || !M32R)
274 ---help--- 274 ---help---
275 This is the standard Linux driver to support Cisco/Aironet PCMCIA 275 This is the standard Linux driver to support Cisco/Aironet PCMCIA
276 802.11 wireless cards. This driver is the same as the Aironet 276 802.11 wireless cards. This driver is the same as the Aironet
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index fb10a2db63ad..df20adcd0730 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -900,7 +900,7 @@ typedef struct aironet_ioctl {
900 unsigned char __user *data; // d-data 900 unsigned char __user *data; // d-data
901} aironet_ioctl; 901} aironet_ioctl;
902 902
903static char *swversion = "2.1"; 903static char swversion[] = "2.1";
904#endif /* CISCO_EXT */ 904#endif /* CISCO_EXT */
905 905
906#define NUM_MODULES 2 906#define NUM_MODULES 2
@@ -1209,7 +1209,7 @@ struct airo_info {
1209 unsigned char __iomem *pciaux; 1209 unsigned char __iomem *pciaux;
1210 unsigned char *shared; 1210 unsigned char *shared;
1211 dma_addr_t shared_dma; 1211 dma_addr_t shared_dma;
1212 int power; 1212 pm_message_t power;
1213 SsidRid *SSID; 1213 SsidRid *SSID;
1214 APListRid *APList; 1214 APListRid *APList;
1215#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE 1215#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE
@@ -2374,7 +2374,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
2374 /* 2374 /*
2375 * Clean out tx queue 2375 * Clean out tx queue
2376 */ 2376 */
2377 if (test_bit(FLAG_MPI, &ai->flags) && skb_queue_len (&ai->txq) > 0) { 2377 if (test_bit(FLAG_MPI, &ai->flags) && !skb_queue_empty(&ai->txq)) {
2378 struct sk_buff *skb = NULL; 2378 struct sk_buff *skb = NULL;
2379 for (;(skb = skb_dequeue(&ai->txq));) 2379 for (;(skb = skb_dequeue(&ai->txq));)
2380 dev_kfree_skb(skb); 2380 dev_kfree_skb(skb);
@@ -2918,7 +2918,7 @@ static int airo_thread(void *data) {
2918 flush_signals(current); 2918 flush_signals(current);
2919 2919
2920 /* make swsusp happy with our thread */ 2920 /* make swsusp happy with our thread */
2921 try_to_freeze(PF_FREEZE); 2921 try_to_freeze();
2922 2922
2923 if (test_bit(JOB_DIE, &ai->flags)) 2923 if (test_bit(JOB_DIE, &ai->flags))
2924 break; 2924 break;
@@ -3287,7 +3287,7 @@ exitrx:
3287 if (status & EV_TXEXC) 3287 if (status & EV_TXEXC)
3288 get_tx_error(apriv, -1); 3288 get_tx_error(apriv, -1);
3289 spin_lock_irqsave(&apriv->aux_lock, flags); 3289 spin_lock_irqsave(&apriv->aux_lock, flags);
3290 if (skb_queue_len (&apriv->txq)) { 3290 if (!skb_queue_empty(&apriv->txq)) {
3291 spin_unlock_irqrestore(&apriv->aux_lock,flags); 3291 spin_unlock_irqrestore(&apriv->aux_lock,flags);
3292 mpi_send_packet (dev); 3292 mpi_send_packet (dev);
3293 } else { 3293 } else {
@@ -5013,7 +5013,7 @@ static void proc_SSID_on_close( struct inode *inode, struct file *file ) {
5013 enable_MAC(ai, &rsp, 1); 5013 enable_MAC(ai, &rsp, 1);
5014} 5014}
5015 5015
5016inline static u8 hexVal(char c) { 5016static inline u8 hexVal(char c) {
5017 if (c>='0' && c<='9') return c -= '0'; 5017 if (c>='0' && c<='9') return c -= '0';
5018 if (c>='a' && c<='f') return c -= 'a'-10; 5018 if (c>='a' && c<='f') return c -= 'a'-10;
5019 if (c>='A' && c<='F') return c -= 'A'-10; 5019 if (c>='A' && c<='F') return c -= 'A'-10;
@@ -5499,9 +5499,9 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
5499 cmd.cmd=HOSTSLEEP; 5499 cmd.cmd=HOSTSLEEP;
5500 issuecommand(ai, &cmd, &rsp); 5500 issuecommand(ai, &cmd, &rsp);
5501 5501
5502 pci_enable_wake(pdev, state, 1); 5502 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
5503 pci_save_state(pdev); 5503 pci_save_state(pdev);
5504 return pci_set_power_state(pdev, state); 5504 return pci_set_power_state(pdev, pci_choose_state(pdev, state));
5505} 5505}
5506 5506
5507static int airo_pci_resume(struct pci_dev *pdev) 5507static int airo_pci_resume(struct pci_dev *pdev)
@@ -5512,7 +5512,7 @@ static int airo_pci_resume(struct pci_dev *pdev)
5512 5512
5513 pci_set_power_state(pdev, 0); 5513 pci_set_power_state(pdev, 0);
5514 pci_restore_state(pdev); 5514 pci_restore_state(pdev);
5515 pci_enable_wake(pdev, ai->power, 0); 5515 pci_enable_wake(pdev, pci_choose_state(pdev, ai->power), 0);
5516 5516
5517 if (ai->power > 1) { 5517 if (ai->power > 1) {
5518 reset_card(dev, 0); 5518 reset_card(dev, 0);
@@ -5541,7 +5541,7 @@ static int airo_pci_resume(struct pci_dev *pdev)
5541 } 5541 }
5542 writeConfigRid(ai, 0); 5542 writeConfigRid(ai, 0);
5543 enable_MAC(ai, &rsp, 0); 5543 enable_MAC(ai, &rsp, 0);
5544 ai->power = 0; 5544 ai->power = PMSG_ON;
5545 netif_device_attach(dev); 5545 netif_device_attach(dev);
5546 netif_wake_queue(dev); 5546 netif_wake_queue(dev);
5547 enable_interrupts(ai); 5547 enable_interrupts(ai);
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index fbf53af6cda4..bf25584d68d3 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -33,7 +33,6 @@
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/netdevice.h> 34#include <linux/netdevice.h>
35 35
36#include <pcmcia/version.h>
37#include <pcmcia/cs_types.h> 36#include <pcmcia/cs_types.h>
38#include <pcmcia/cs.h> 37#include <pcmcia/cs.h>
39#include <pcmcia/cistpl.h> 38#include <pcmcia/cistpl.h>
@@ -210,11 +209,6 @@ static dev_link_t *airo_attach(void)
210 link->next = dev_list; 209 link->next = dev_list;
211 dev_list = link; 210 dev_list = link;
212 client_reg.dev_info = &dev_info; 211 client_reg.dev_info = &dev_info;
213 client_reg.EventMask =
214 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
215 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
216 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
217 client_reg.event_handler = &airo_event;
218 client_reg.Version = 0x0210; 212 client_reg.Version = 0x0210;
219 client_reg.event_callback_args.client_data = link; 213 client_reg.event_callback_args.client_data = link;
220 ret = pcmcia_register_client(&link->handle, &client_reg); 214 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -559,13 +553,24 @@ static int airo_event(event_t event, int priority,
559 return 0; 553 return 0;
560} /* airo_event */ 554} /* airo_event */
561 555
556static struct pcmcia_device_id airo_ids[] = {
557 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a),
558 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005),
559 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0007),
560 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x0007),
561 PCMCIA_DEVICE_NULL,
562};
563MODULE_DEVICE_TABLE(pcmcia, airo_ids);
564
562static struct pcmcia_driver airo_driver = { 565static struct pcmcia_driver airo_driver = {
563 .owner = THIS_MODULE, 566 .owner = THIS_MODULE,
564 .drv = { 567 .drv = {
565 .name = "airo_cs", 568 .name = "airo_cs",
566 }, 569 },
567 .attach = airo_attach, 570 .attach = airo_attach,
571 .event = airo_event,
568 .detach = airo_detach, 572 .detach = airo_detach,
573 .id_table = airo_ids,
569}; 574};
570 575
571static int airo_cs_init(void) 576static int airo_cs_init(void)
diff --git a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
index b4f4bd7956a2..9d496703c465 100644
--- a/drivers/net/wireless/airport.c
+++ b/drivers/net/wireless/airport.c
@@ -184,7 +184,7 @@ static int airport_hard_reset(struct orinoco_private *priv)
184} 184}
185 185
186static int 186static int
187airport_attach(struct macio_dev *mdev, const struct of_match *match) 187airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
188{ 188{
189 struct orinoco_private *priv; 189 struct orinoco_private *priv;
190 struct net_device *dev; 190 struct net_device *dev;
@@ -266,16 +266,16 @@ MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
266MODULE_DESCRIPTION("Driver for the Apple Airport wireless card."); 266MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
267MODULE_LICENSE("Dual MPL/GPL"); 267MODULE_LICENSE("Dual MPL/GPL");
268 268
269static struct of_match airport_match[] = 269static struct of_device_id airport_match[] =
270{ 270{
271 { 271 {
272 .name = "radio", 272 .name = "radio",
273 .type = OF_ANY_MATCH,
274 .compatible = OF_ANY_MATCH
275 }, 273 },
276 {}, 274 {},
277}; 275};
278 276
277MODULE_DEVICE_TABLE (of, airport_match);
278
279static struct macio_driver airport_driver = 279static struct macio_driver airport_driver =
280{ 280{
281 .name = DRIVER_NAME, 281 .name = DRIVER_NAME,
diff --git a/drivers/net/wireless/arlan-main.c b/drivers/net/wireless/arlan-main.c
index 4f304c6e693a..0e1ac338cac1 100644
--- a/drivers/net/wireless/arlan-main.c
+++ b/drivers/net/wireless/arlan-main.c
@@ -33,8 +33,6 @@ static int arlan_EEPROM_bad;
33 33
34#ifdef ARLAN_DEBUGGING 34#ifdef ARLAN_DEBUGGING
35 35
36static int arlan_entry_debug;
37static int arlan_exit_debug;
38static int testMemory = testMemoryUNKNOWN; 36static int testMemory = testMemoryUNKNOWN;
39static int irq = irqUNKNOWN; 37static int irq = irqUNKNOWN;
40static int txScrambled = 1; 38static int txScrambled = 1;
@@ -43,15 +41,13 @@ static int mdebug;
43module_param(irq, int, 0); 41module_param(irq, int, 0);
44module_param(mdebug, int, 0); 42module_param(mdebug, int, 0);
45module_param(testMemory, int, 0); 43module_param(testMemory, int, 0);
46module_param(arlan_entry_debug, int, 0);
47module_param(arlan_exit_debug, int, 0);
48module_param(txScrambled, int, 0); 44module_param(txScrambled, int, 0);
49MODULE_PARM_DESC(irq, "(unused)"); 45MODULE_PARM_DESC(irq, "(unused)");
50MODULE_PARM_DESC(testMemory, "(unused)"); 46MODULE_PARM_DESC(testMemory, "(unused)");
51MODULE_PARM_DESC(mdebug, "Arlan multicast debugging (0-1)"); 47MODULE_PARM_DESC(mdebug, "Arlan multicast debugging (0-1)");
52#endif 48#endif
53 49
54module_param(arlan_debug, int, 0); 50module_param_named(debug, arlan_debug, int, 0);
55module_param(spreadingCode, int, 0); 51module_param(spreadingCode, int, 0);
56module_param(channelNumber, int, 0); 52module_param(channelNumber, int, 0);
57module_param(channelSet, int, 0); 53module_param(channelSet, int, 0);
@@ -63,17 +59,19 @@ module_param(keyStart, int, 0);
63module_param(tx_delay_ms, int, 0); 59module_param(tx_delay_ms, int, 0);
64module_param(retries, int, 0); 60module_param(retries, int, 0);
65module_param(tx_queue_len, int, 0); 61module_param(tx_queue_len, int, 0);
66module_param(arlan_EEPROM_bad, int, 0); 62module_param_named(EEPROM_bad, arlan_EEPROM_bad, int, 0);
67MODULE_PARM_DESC(arlan_debug, "Arlan debug enable (0-1)"); 63MODULE_PARM_DESC(debug, "Arlan debug enable (0-1)");
68MODULE_PARM_DESC(retries, "Arlan maximum packet retransmisions"); 64MODULE_PARM_DESC(retries, "Arlan maximum packet retransmisions");
69#ifdef ARLAN_ENTRY_EXIT_DEBUGGING 65#ifdef ARLAN_ENTRY_EXIT_DEBUGGING
70MODULE_PARM_DESC(arlan_entry_debug, "Arlan driver function entry debugging"); 66static int arlan_entry_debug;
71MODULE_PARM_DESC(arlan_exit_debug, "Arlan driver function exit debugging"); 67static int arlan_exit_debug;
72MODULE_PARM_DESC(arlan_entry_and_exit_debug, "Arlan driver function entry and exit debugging"); 68static int arlan_entry_and_exit_debug;
73#else 69module_param_named(entry_debug, arlan_entry_debug, int, 0);
74MODULE_PARM_DESC(arlan_entry_debug, "(ignored)"); 70module_param_named(exit_debug, arlan_exit_debug, int, 0);
75MODULE_PARM_DESC(arlan_exit_debug, "(ignored)"); 71module_param_named(entry_and_exit_debug, arlan_entry_and_exit_debug, int, 0);
76MODULE_PARM_DESC(arlan_entry_and_exit_debug, "(ignored)"); 72MODULE_PARM_DESC(entry_debug, "Arlan driver function entry debugging");
73MODULE_PARM_DESC(exit_debug, "Arlan driver function exit debugging");
74MODULE_PARM_DESC(entry_and_exit_debug, "Arlan driver function entry and exit debugging");
77#endif 75#endif
78 76
79struct arlan_conf_stru arlan_conf[MAX_ARLANS]; 77struct arlan_conf_stru arlan_conf[MAX_ARLANS];
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index a4ed28d9c783..ff031a3985b3 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -43,7 +43,6 @@
43#include <linux/moduleparam.h> 43#include <linux/moduleparam.h>
44#include <linux/device.h> 44#include <linux/device.h>
45 45
46#include <pcmcia/version.h>
47#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
@@ -218,11 +217,6 @@ static dev_link_t *atmel_attach(void)
218 link->next = dev_list; 217 link->next = dev_list;
219 dev_list = link; 218 dev_list = link;
220 client_reg.dev_info = &dev_info; 219 client_reg.dev_info = &dev_info;
221 client_reg.EventMask =
222 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
223 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
224 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
225 client_reg.event_handler = &atmel_event;
226 client_reg.Version = 0x0210; 220 client_reg.Version = 0x0210;
227 client_reg.event_callback_args.client_data = link; 221 client_reg.event_callback_args.client_data = link;
228 ret = pcmcia_register_client(&link->handle, &client_reg); 222 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -646,13 +640,36 @@ static int atmel_event(event_t event, int priority,
646} /* atmel_event */ 640} /* atmel_event */
647 641
648/*====================================================================*/ 642/*====================================================================*/
643static struct pcmcia_device_id atmel_ids[] = {
644 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0620),
645 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0696),
646 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3302),
647 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0007),
648 PCMCIA_DEVICE_PROD_ID12("11WAVE", "11WP611AL-E", 0x9eb2da1f, 0xc9a0d3f9),
649 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C502AR", 0xabda4164, 0x41b37e1f),
650 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504", 0xabda4164, 0x5040670a),
651 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504A", 0xabda4164, 0xe15ed87f),
652 PCMCIA_DEVICE_PROD_ID12("BT", "Voyager 1020 Laptop Adapter", 0xae49b86a, 0x1e957cd5),
653 PCMCIA_DEVICE_PROD_ID12("CNet", "CNWLC 11Mbps Wireless PC Card V-5", 0xbc477dde, 0x502fae6b),
654 PCMCIA_DEVICE_PROD_ID12("IEEE 802.11b", "Wireless LAN PC Card", 0x5b878724, 0x122f1df6),
655 PCMCIA_DEVICE_PROD_ID12("OEM", "11Mbps Wireless LAN PC Card V-3", 0xfea54c90, 0x1c5b0f68),
656 PCMCIA_DEVICE_PROD_ID12("SMC", "2632W", 0xc4f8b18b, 0x30f38774),
657 PCMCIA_DEVICE_PROD_ID12("SMC", "2632W-V2", 0xc4f8b18b, 0x172d1377),
658 PCMCIA_DEVICE_PROD_ID12("Wireless", "PC", 0xa407ecdd, 0x556e4d7e),
659 PCMCIA_DEVICE_PROD_ID12("WLAN", "802.11b PC CARD", 0x575c516c, 0xb1f6dbc4),
660 PCMCIA_DEVICE_NULL
661};
662MODULE_DEVICE_TABLE(pcmcia, atmel_ids);
663
649static struct pcmcia_driver atmel_driver = { 664static struct pcmcia_driver atmel_driver = {
650 .owner = THIS_MODULE, 665 .owner = THIS_MODULE,
651 .drv = { 666 .drv = {
652 .name = "atmel_cs", 667 .name = "atmel_cs",
653 }, 668 },
654 .attach = atmel_attach, 669 .attach = atmel_attach,
655 .detach = atmel_detach, 670 .event = atmel_event,
671 .detach = atmel_detach,
672 .id_table = atmel_ids,
656}; 673};
657 674
658static int atmel_cs_init(void) 675static int atmel_cs_init(void)
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 382241e7edbb..5f507c49907b 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -62,7 +62,6 @@
62#endif /* WIRELESS_EXT > 12 */ 62#endif /* WIRELESS_EXT > 12 */
63#endif 63#endif
64 64
65#include <pcmcia/version.h>
66#include <pcmcia/cs_types.h> 65#include <pcmcia/cs_types.h>
67#include <pcmcia/cs.h> 66#include <pcmcia/cs.h>
68#include <pcmcia/cistpl.h> 67#include <pcmcia/cistpl.h>
@@ -491,11 +490,6 @@ static dev_link_t *netwave_attach(void)
491 link->next = dev_list; 490 link->next = dev_list;
492 dev_list = link; 491 dev_list = link;
493 client_reg.dev_info = &dev_info; 492 client_reg.dev_info = &dev_info;
494 client_reg.EventMask =
495 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
496 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
497 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
498 client_reg.event_handler = &netwave_event;
499 client_reg.Version = 0x0210; 493 client_reg.Version = 0x0210;
500 client_reg.event_callback_args.client_data = link; 494 client_reg.event_callback_args.client_data = link;
501 ret = pcmcia_register_client(&link->handle, &client_reg); 495 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1668,13 +1662,21 @@ static int netwave_close(struct net_device *dev) {
1668 return 0; 1662 return 0;
1669} 1663}
1670 1664
1665static struct pcmcia_device_id netwave_ids[] = {
1666 PCMCIA_DEVICE_PROD_ID12("Xircom", "CreditCard Netwave", 0x2e3ee845, 0x54e28a28),
1667 PCMCIA_DEVICE_NULL,
1668};
1669MODULE_DEVICE_TABLE(pcmcia, netwave_ids);
1670
1671static struct pcmcia_driver netwave_driver = { 1671static struct pcmcia_driver netwave_driver = {
1672 .owner = THIS_MODULE, 1672 .owner = THIS_MODULE,
1673 .drv = { 1673 .drv = {
1674 .name = "netwave_cs", 1674 .name = "netwave_cs",
1675 }, 1675 },
1676 .attach = netwave_attach, 1676 .attach = netwave_attach,
1677 .event = netwave_event,
1677 .detach = netwave_detach, 1678 .detach = netwave_detach,
1679 .id_table = netwave_ids,
1678}; 1680};
1679 1681
1680static int __init init_netwave_cs(void) 1682static int __init init_netwave_cs(void)
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index b1078baa1d5e..9c2d07cde010 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -46,382 +46,9 @@
46 * under either the MPL or the GPL. */ 46 * under either the MPL or the GPL. */
47 47
48/* 48/*
49 * v0.01 -> v0.02 - 21/3/2001 - Jean II
50 * o Allow to use regular ethX device name instead of dldwdX
51 * o Warning on IBSS with ESSID=any for firmware 6.06
52 * o Put proper range.throughput values (optimistic)
53 * o IWSPY support (IOCTL and stat gather in Rx path)
54 * o Allow setting frequency in Ad-Hoc mode
55 * o Disable WEP setting if !has_wep to work on old firmware
56 * o Fix txpower range
57 * o Start adding support for Samsung/Compaq firmware
58 *
59 * v0.02 -> v0.03 - 23/3/2001 - Jean II
60 * o Start adding Symbol support - need to check all that
61 * o Fix Prism2/Symbol WEP to accept 128 bits keys
62 * o Add Symbol WEP (add authentication type)
63 * o Add Prism2/Symbol rate
64 * o Add PM timeout (holdover duration)
65 * o Enable "iwconfig eth0 key off" and friends (toggle flags)
66 * o Enable "iwconfig eth0 power unicast/all" (toggle flags)
67 * o Try with an Intel card. It report firmware 1.01, behave like
68 * an antiquated firmware, however on windows it says 2.00. Yuck !
69 * o Workaround firmware bug in allocate buffer (Intel 1.01)
70 * o Finish external renaming to orinoco...
71 * o Testing with various Wavelan firmwares
72 *
73 * v0.03 -> v0.04 - 30/3/2001 - Jean II
74 * o Update to Wireless 11 -> add retry limit/lifetime support
75 * o Tested with a D-Link DWL 650 card, fill in firmware support
76 * o Warning on Vcc mismatch (D-Link 3.3v card in Lucent 5v only slot)
77 * o Fixed the Prism2 WEP bugs that I introduced in v0.03 :-(
78 * It works on D-Link *only* after a tcpdump. Weird...
79 * And still doesn't work on Intel card. Grrrr...
80 * o Update the mode after a setport3
81 * o Add preamble setting for Symbol cards (not yet enabled)
82 * o Don't complain as much about Symbol cards...
83 *
84 * v0.04 -> v0.04b - 22/4/2001 - David Gibson
85 * o Removed the 'eth' parameter - always use ethXX as the
86 * interface name instead of dldwdXX. The other was racy
87 * anyway.
88 * o Clean up RID definitions in hermes.h, other cleanups
89 *
90 * v0.04b -> v0.04c - 24/4/2001 - Jean II
91 * o Tim Hurley <timster AT seiki.bliztech.com> reported a D-Link card
92 * with vendor 02 and firmware 0.08. Added in the capabilities...
93 * o Tested Lucent firmware 7.28, everything works...
94 *
95 * v0.04c -> v0.05 - 3/5/2001 - Benjamin Herrenschmidt
96 * o Spin-off Pcmcia code. This file is renamed orinoco.c,
97 * and orinoco_cs.c now contains only the Pcmcia specific stuff
98 * o Add Airport driver support on top of orinoco.c (see airport.c)
99 *
100 * v0.05 -> v0.05a - 4/5/2001 - Jean II
101 * o Revert to old Pcmcia code to fix breakage of Ben's changes...
102 *
103 * v0.05a -> v0.05b - 4/5/2001 - Jean II
104 * o add module parameter 'ignore_cis_vcc' for D-Link @ 5V
105 * o D-Link firmware doesn't support multicast. We just print a few
106 * error messages, but otherwise everything works...
107 * o For David : set/getport3 works fine, just upgrade iwpriv...
108 *
109 * v0.05b -> v0.05c - 5/5/2001 - Benjamin Herrenschmidt
110 * o Adapt airport.c to latest changes in orinoco.c
111 * o Remove deferred power enabling code
112 *
113 * v0.05c -> v0.05d - 5/5/2001 - Jean II
114 * o Workaround to SNAP decapsulate frame from Linksys AP
115 * original patch from : Dong Liu <dliu AT research.bell-labs.com>
116 * (note : the memcmp bug was mine - fixed)
117 * o Remove set_retry stuff, no firmware support it (bloat--).
118 *
119 * v0.05d -> v0.06 - 25/5/2001 - Jean II
120 * Original patch from "Hong Lin" <alin AT redhat.com>,
121 * "Ian Kinner" <ikinner AT redhat.com>
122 * and "David Smith" <dsmith AT redhat.com>
123 * o Init of priv->tx_rate_ctrl in firmware specific section.
124 * o Prism2/Symbol rate, upto should be 0xF and not 0x15. Doh !
125 * o Spectrum card always need cor_reset (for every reset)
126 * o Fix cor_reset to not lose bit 7 in the register
127 * o flush_stale_links to remove zombie Pcmcia instances
128 * o Ack previous hermes event before reset
129 * Me (with my little hands)
130 * o Allow orinoco.c to call cor_reset via priv->card_reset_handler
131 * o Add priv->need_card_reset to toggle this feature
132 * o Fix various buglets when setting WEP in Symbol firmware
133 * Now, encryption is fully functional on Symbol cards. Youpi !
134 *
135 * v0.06 -> v0.06b - 25/5/2001 - Jean II
136 * o IBSS on Symbol use port_mode = 4. Please don't ask...
137 *
138 * v0.06b -> v0.06c - 29/5/2001 - Jean II
139 * o Show first spy address in /proc/net/wireless for IBSS mode as well
140 *
141 * v0.06c -> v0.06d - 6/7/2001 - David Gibson
142 * o Change a bunch of KERN_INFO messages to KERN_DEBUG, as per Linus'
143 * wishes to reduce the number of unnecessary messages.
144 * o Removed bogus message on CRC error.
145 * o Merged fixes for v0.08 Prism 2 firmware from William Waghorn
146 * <willwaghorn AT yahoo.co.uk>
147 * o Slight cleanup/re-arrangement of firmware detection code.
148 *
149 * v0.06d -> v0.06e - 1/8/2001 - David Gibson
150 * o Removed some redundant global initializers (orinoco_cs.c).
151 * o Added some module metadata
152 *
153 * v0.06e -> v0.06f - 14/8/2001 - David Gibson
154 * o Wording fix to license
155 * o Added a 'use_alternate_encaps' module parameter for APs which need an
156 * oui of 00:00:00. We really need a better way of handling this, but
157 * the module flag is better than nothing for now.
158 *
159 * v0.06f -> v0.07 - 20/8/2001 - David Gibson
160 * o Removed BAP error retries from hermes_bap_seek(). For Tx we now
161 * let the upper layers handle the retry, we retry explicitly in the
162 * Rx path, but don't make as much noise about it.
163 * o Firmware detection cleanups.
164 *
165 * v0.07 -> v0.07a - 1/10/3001 - Jean II
166 * o Add code to read Symbol firmware revision, inspired by latest code
167 * in Spectrum24 by Lee John Keyser-Allen - Thanks Lee !
168 * o Thanks to Jared Valentine <hidden AT xmission.com> for "providing" me
169 * a 3Com card with a recent firmware, fill out Symbol firmware
170 * capabilities of latest rev (2.20), as well as older Symbol cards.
171 * o Disable Power Management in newer Symbol firmware, the API
172 * has changed (documentation needed).
173 *
174 * v0.07a -> v0.08 - 3/10/2001 - David Gibson
175 * o Fixed a possible buffer overrun found by the Stanford checker (in
176 * dldwd_ioctl_setiwencode()). Can only be called by root anyway, so not
177 * a big problem.
178 * o Turned has_big_wep on for Intersil cards. That's not true for all of
179 * them but we should at least let the capable ones try.
180 * o Wait for BUSY to clear at the beginning of hermes_bap_seek(). I
181 * realized that my assumption that the driver's serialization
182 * would prevent the BAP being busy on entry was possibly false, because
183 * things other than seeks may make the BAP busy.
184 * o Use "alternate" (oui 00:00:00) encapsulation by default.
185 * Setting use_old_encaps will mimic the old behaviour, but I think we
186 * will be able to eliminate this.
187 * o Don't try to make __initdata const (the version string). This can't
188 * work because of the way the __initdata sectioning works.
189 * o Added MODULE_LICENSE tags.
190 * o Support for PLX (transparent PCMCIA->PCI bridge) cards.
191 * o Changed to using the new type-fascist min/max.
192 *
193 * v0.08 -> v0.08a - 9/10/2001 - David Gibson
194 * o Inserted some missing acknowledgements/info into the Changelog.
195 * o Fixed some bugs in the normalization of signal level reporting.
196 * o Fixed bad bug in WEP key handling on Intersil and Symbol firmware,
197 * which led to an instant crash on big-endian machines.
198 *
199 * v0.08a -> v0.08b - 20/11/2001 - David Gibson
200 * o Lots of cleanup and bugfixes in orinoco_plx.c
201 * o Cleanup to handling of Tx rate setting.
202 * o Removed support for old encapsulation method.
203 * o Removed old "dldwd" names.
204 * o Split RID constants into a new file hermes_rid.h
205 * o Renamed RID constants to match linux-wlan-ng and prism2.o
206 * o Bugfixes in hermes.c
207 * o Poke the PLX's INTCSR register, so it actually starts
208 * generating interrupts. These cards might actually work now.
209 * o Update to wireless extensions v12 (Jean II)
210 * o Support for tallies and inquire command (Jean II)
211 * o Airport updates for newer PPC kernels (BenH)
212 *
213 * v0.08b -> v0.09 - 21/12/2001 - David Gibson
214 * o Some new PCI IDs for PLX cards.
215 * o Removed broken attempt to do ALLMULTI reception. Just use
216 * promiscuous mode instead
217 * o Preliminary work for list-AP (Jean II)
218 * o Airport updates from (BenH)
219 * o Eliminated racy hw_ready stuff
220 * o Fixed generation of fake events in irq handler. This should
221 * finally kill the EIO problems (Jean II & dgibson)
222 * o Fixed breakage of bitrate set/get on Agere firmware (Jean II)
223 *
224 * v0.09 -> v0.09a - 2/1/2002 - David Gibson
225 * o Fixed stupid mistake in multicast list handling, triggering
226 * a BUG()
227 *
228 * v0.09a -> v0.09b - 16/1/2002 - David Gibson
229 * o Fixed even stupider mistake in new interrupt handling, which
230 * seriously broke things on big-endian machines.
231 * o Removed a bunch of redundant includes and exports.
232 * o Removed a redundant MOD_{INC,DEC}_USE_COUNT pair in airport.c
233 * o Don't attempt to do hardware level multicast reception on
234 * Intersil firmware, just go promisc instead.
235 * o Typo fixed in hermes_issue_cmd()
236 * o Eliminated WIRELESS_SPY #ifdefs
237 * o Status code reported on Tx exceptions
238 * o Moved netif_wake_queue() from ALLOC interrupts to TX and TXEXC
239 * interrupts, which should fix the timeouts we're seeing.
240 *
241 * v0.09b -> v0.10 - 25 Feb 2002 - David Gibson
242 * o Removed nested structures used for header parsing, so the
243 * driver should now work without hackery on ARM
244 * o Fix for WEP handling on Intersil (Hawk Newton)
245 * o Eliminated the /proc/hermes/ethXX/regs debugging file. It
246 * was never very useful.
247 * o Make Rx errors less noisy.
248 *
249 * v0.10 -> v0.11 - 5 Apr 2002 - David Gibson
250 * o Laid the groundwork in hermes.[ch] for devices which map
251 * into PCI memory space rather than IO space.
252 * o Fixed bug in multicast handling (cleared multicast list when
253 * leaving promiscuous mode).
254 * o Relegated Tx error messages to debug.
255 * o Cleaned up / corrected handling of allocation lengths.
256 * o Set OWNSSID in IBSS mode for WinXP interoperability (jimc).
257 * o Change to using alloc_etherdev() for structure allocations.
258 * o Check for and drop undersized packets.
259 * o Fixed a race in stopping/waking the queue. This should fix
260 * the timeout problems (Pavel Roskin)
261 * o Reverted to netif_wake_queue() on the ALLOC event.
262 * o Fixes for recent Symbol firmwares which lack AP density
263 * (Pavel Roskin).
264 *
265 * v0.11 -> v0.11a - 29 Apr 2002 - David Gibson
266 * o Handle different register spacing, necessary for Prism 2.5
267 * PCI adaptors (Steve Hill).
268 * o Cleaned up initialization of card structures in orinoco_cs
269 * and airport. Removed card->priv field.
270 * o Make response structure optional for hermes_docmd_wait()
271 * Pavel Roskin)
272 * o Added PCI id for Nortel emobility to orinoco_plx.c.
273 * o Cleanup to handling of Symbol's allocation bug. (Pavel Roskin)
274 * o Cleanups to firmware capability detection.
275 * o Arrange for orinoco_pci.c to override firmware detection.
276 * We should be able to support the PCI Intersil cards now.
277 * o Cleanup handling of reset_cor and hard_reset (Pavel Roskin).
278 * o Remove erroneous use of USER_BAP in the TxExc handler (Jouni
279 * Malinen).
280 * o Makefile changes for better integration into David Hinds
281 * pcmcia-cs package.
282 *
283 * v0.11a -> v0.11b - 1 May 2002 - David Gibson
284 * o Better error reporting in orinoco_plx_init_one()
285 * o Fixed multiple bad kfree() bugs introduced by the
286 * alloc_orinocodev() changes.
287 *
288 * v0.11b -> v0.12 - 19 Jun 2002 - David Gibson
289 * o Support changing the MAC address.
290 * o Correct display of Intersil firmware revision numbers.
291 * o Entirely revised locking scheme. Should be both simpler and
292 * better.
293 * o Merged some common code in orinoco_plx, orinoco_pci and
294 * airport by creating orinoco_default_{open,stop,reset}()
295 * which are used as the dev->open, dev->stop, priv->reset
296 * callbacks if none are specified when alloc_orinocodev() is
297 * called.
298 * o Removed orinoco_plx_interrupt() and orinoco_pci_interrupt().
299 * They didn't do anything.
300 *
301 * v0.12 -> v0.12a - 4 Jul 2002 - David Gibson
302 * o Some rearrangement of code.
303 * o Numerous fixups to locking and rest handling, particularly
304 * for PCMCIA.
305 * o This allows open and stop net_device methods to be in
306 * orinoco.c now, rather than in the init modules.
307 * o In orinoco_cs.c link->priv now points to the struct
308 * net_device not to the struct orinoco_private.
309 * o Added a check for undersized SNAP frames, which could cause
310 * crashes.
311 *
312 * v0.12a -> v0.12b - 11 Jul 2002 - David Gibson
313 * o Fix hw->num_init testing code, so num_init is actually
314 * incremented.
315 * o Fix very stupid bug in orinoco_cs which broke compile with
316 * CONFIG_SMP.
317 * o Squashed a warning.
318 *
319 * v0.12b -> v0.12c - 26 Jul 2002 - David Gibson
320 * o Change to C9X style designated initializers.
321 * o Add support for 3Com AirConnect PCI.
322 * o No longer ignore the hard_reset argument to
323 * alloc_orinocodev(). Oops.
324 *
325 * v0.12c -> v0.13beta1 - 13 Sep 2002 - David Gibson
326 * o Revert the broken 0.12* locking scheme and go to a new yet
327 * simpler scheme.
328 * o Do firmware resets only in orinoco_init() and when waking
329 * the card from hard sleep.
330 *
331 * v0.13beta1 -> v0.13 - 27 Sep 2002 - David Gibson
332 * o Re-introduced full resets (via schedule_task()) on Tx
333 * timeout.
334 *
335 * v0.13 -> v0.13a - 30 Sep 2002 - David Gibson
336 * o Minor cleanups to info frame handling. Add basic support
337 * for linkstatus info frames.
338 * o Include required kernel headers in orinoco.h, to avoid
339 * compile problems.
340 *
341 * v0.13a -> v0.13b - 10 Feb 2003 - David Gibson
342 * o Implemented hard reset for Airport cards
343 * o Experimental suspend/resume implementation for orinoco_pci
344 * o Abolished /proc debugging support, replaced with a debugging
345 * iwpriv. Now it's ugly and simple instead of ugly and complex.
346 * o Bugfix in hermes.c if the firmware returned a record length
347 * of 0, we could go clobbering memory.
348 * o Bugfix in orinoco_stop() - it used to fail if hw_unavailable
349 * was set, which was usually true on PCMCIA hot removes.
350 * o Track LINKSTATUS messages, silently drop Tx packets before
351 * we are connected (avoids confusing the firmware), and only
352 * give LINKSTATUS printk()s if the status has changed.
353 *
354 * v0.13b -> v0.13c - 11 Mar 2003 - David Gibson
355 * o Cleanup: use dev instead of priv in various places.
356 * o Bug fix: Don't ReleaseConfiguration on RESET_PHYSICAL event
357 * if we're in the middle of a (driver initiated) hard reset.
358 * o Bug fix: ETH_ZLEN is supposed to include the header
359 * (Dionysus Blazakis & Manish Karir)
360 * o Convert to using workqueues instead of taskqueues (and
361 * backwards compatibility macros for pre 2.5.41 kernels).
362 * o Drop redundant (I think...) MOD_{INC,DEC}_USE_COUNT in
363 * airport.c
364 * o New orinoco_tmd.c init module from Joerg Dorchain for
365 * TMD7160 based PCI to PCMCIA bridges (similar to
366 * orinoco_plx.c).
367 *
368 * v0.13c -> v0.13d - 22 Apr 2003 - David Gibson
369 * o Make hw_unavailable a counter, rather than just a flag, this
370 * is necessary to avoid some races (such as a card being
371 * removed in the middle of orinoco_reset().
372 * o Restore Release/RequestConfiguration in the PCMCIA event handler
373 * when dealing with a driver initiated hard reset. This is
374 * necessary to prevent hangs due to a spurious interrupt while
375 * the reset is in progress.
376 * o Clear the 802.11 header when transmitting, even though we
377 * don't use it. This fixes a long standing bug on some
378 * firmwares, which seem to get confused if that isn't done.
379 * o Be less eager to de-encapsulate SNAP frames, only do so if
380 * the OUI is 00:00:00 or 00:00:f8, leave others alone. The old
381 * behaviour broke CDP (Cisco Discovery Protocol).
382 * o Use dev instead of priv for free_irq() as well as
383 * request_irq() (oops).
384 * o Attempt to reset rather than giving up if we get too many
385 * IRQs.
386 * o Changed semantics of __orinoco_down() so it can be called
387 * safely with hw_unavailable set. It also now clears the
388 * linkstatus (since we're going to have to reassociate).
389 *
390 * v0.13d -> v0.13e - 12 May 2003 - David Gibson
391 * o Support for post-2.5.68 return values from irq handler.
392 * o Fixed bug where underlength packets would be double counted
393 * in the rx_dropped statistics.
394 * o Provided a module parameter to suppress linkstatus messages.
395 *
396 * v0.13e -> v0.14alpha1 - 30 Sep 2003 - David Gibson
397 * o Replaced priv->connected logic with netif_carrier_on/off()
398 * calls.
399 * o Remove has_ibss_any and never set the CREATEIBSS RID when
400 * the ESSID is empty. Too many firmwares break if we do.
401 * o 2.6 merges: Replace pdev->slot_name with pci_name(), remove
402 * __devinitdata from PCI ID tables, use free_netdev().
403 * o Enabled shared-key authentication for Agere firmware (from
404 * Robert J. Moore <Robert.J.Moore AT allanbank.com>
405 * o Move netif_wake_queue() (back) to the Tx completion from the
406 * ALLOC event. This seems to prevent/mitigate the rolling
407 * error -110 problems at least on some Intersil firmwares.
408 * Theoretically reduces performance, but I can't measure it.
409 * Patch from Andrew Tridgell <tridge AT samba.org>
410 *
411 * v0.14alpha1 -> v0.14alpha2 - 20 Oct 2003 - David Gibson
412 * o Correctly turn off shared-key authentication when requested
413 * (bugfix from Robert J. Moore).
414 * o Correct airport sleep interfaces for current 2.6 kernels.
415 * o Add code for key change without disabling/enabling the MAC
416 * port. This is supposed to allow 802.1x to work sanely, but
417 * doesn't seem to yet.
418 *
419 * TODO 49 * TODO
420 * o New wireless extensions API (patch from Moustafa
421 * Youssef, updated by Jim Carter and Pavel Roskin).
422 * o Handle de-encapsulation within network layer, provide 802.11 50 * o Handle de-encapsulation within network layer, provide 802.11
423 * headers (patch from Thomas 'Dent' Mirlacher) 51 * headers (patch from Thomas 'Dent' Mirlacher)
424 * o RF monitor mode support
425 * o Fix possible races in SPY handling. 52 * o Fix possible races in SPY handling.
426 * o Disconnect wireless extensions from fundamental configuration. 53 * o Disconnect wireless extensions from fundamental configuration.
427 * o (maybe) Software WEP support (patch from Stano Meduna). 54 * o (maybe) Software WEP support (patch from Stano Meduna).
@@ -462,7 +89,10 @@
462#include <linux/netdevice.h> 89#include <linux/netdevice.h>
463#include <linux/if_arp.h> 90#include <linux/if_arp.h>
464#include <linux/etherdevice.h> 91#include <linux/etherdevice.h>
92#include <linux/ethtool.h>
465#include <linux/wireless.h> 93#include <linux/wireless.h>
94#include <net/iw_handler.h>
95#include <net/ieee80211.h>
466 96
467#include <asm/uaccess.h> 97#include <asm/uaccess.h>
468#include <asm/io.h> 98#include <asm/io.h>
@@ -496,6 +126,10 @@ static int ignore_disconnect; /* = 0 */
496module_param(ignore_disconnect, int, 0644); 126module_param(ignore_disconnect, int, 0644);
497MODULE_PARM_DESC(ignore_disconnect, "Don't report lost link to the network layer"); 127MODULE_PARM_DESC(ignore_disconnect, "Don't report lost link to the network layer");
498 128
129static int force_monitor; /* = 0 */
130module_param(force_monitor, int, 0644);
131MODULE_PARM_DESC(force_monitor, "Allow monitor mode for all firmware versions");
132
499/********************************************************************/ 133/********************************************************************/
500/* Compile time configuration and compatibility stuff */ 134/* Compile time configuration and compatibility stuff */
501/********************************************************************/ 135/********************************************************************/
@@ -511,6 +145,10 @@ MODULE_PARM_DESC(ignore_disconnect, "Don't report lost link to the network layer
511/* Internal constants */ 145/* Internal constants */
512/********************************************************************/ 146/********************************************************************/
513 147
148/* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
149static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
150#define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
151
514#define ORINOCO_MIN_MTU 256 152#define ORINOCO_MIN_MTU 256
515#define ORINOCO_MAX_MTU (IEEE802_11_DATA_LEN - ENCAPS_OVERHEAD) 153#define ORINOCO_MAX_MTU (IEEE802_11_DATA_LEN - ENCAPS_OVERHEAD)
516 154
@@ -537,6 +175,11 @@ MODULE_PARM_DESC(ignore_disconnect, "Don't report lost link to the network layer
537 | HERMES_EV_WTERR | HERMES_EV_INFO \ 175 | HERMES_EV_WTERR | HERMES_EV_INFO \
538 | HERMES_EV_INFDROP ) 176 | HERMES_EV_INFDROP )
539 177
178#define MAX_RID_LEN 1024
179
180static const struct iw_handler_def orinoco_handler_def;
181static struct ethtool_ops orinoco_ethtool_ops;
182
540/********************************************************************/ 183/********************************************************************/
541/* Data tables */ 184/* Data tables */
542/********************************************************************/ 185/********************************************************************/
@@ -571,26 +214,45 @@ static struct {
571/* Data types */ 214/* Data types */
572/********************************************************************/ 215/********************************************************************/
573 216
574struct header_struct { 217/* Used in Event handling.
575 /* 802.3 */ 218 * We avoid nested structres as they break on ARM -- Moustafa */
576 u8 dest[ETH_ALEN]; 219struct hermes_tx_descriptor_802_11 {
577 u8 src[ETH_ALEN]; 220 /* hermes_tx_descriptor */
578 u16 len; 221 u16 status;
579 /* 802.2 */ 222 u16 reserved1;
223 u16 reserved2;
224 u32 sw_support;
225 u8 retry_count;
226 u8 tx_rate;
227 u16 tx_control;
228
229 /* ieee802_11_hdr */
230 u16 frame_ctl;
231 u16 duration_id;
232 u8 addr1[ETH_ALEN];
233 u8 addr2[ETH_ALEN];
234 u8 addr3[ETH_ALEN];
235 u16 seq_ctl;
236 u8 addr4[ETH_ALEN];
237 u16 data_len;
238
239 /* ethhdr */
240 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
241 unsigned char h_source[ETH_ALEN]; /* source ether addr */
242 unsigned short h_proto; /* packet type ID field */
243
244 /* p8022_hdr */
580 u8 dsap; 245 u8 dsap;
581 u8 ssap; 246 u8 ssap;
582 u8 ctrl; 247 u8 ctrl;
583 /* SNAP */
584 u8 oui[3]; 248 u8 oui[3];
249
585 u16 ethertype; 250 u16 ethertype;
586} __attribute__ ((packed)); 251} __attribute__ ((packed));
587 252
588/* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */ 253/* Rx frame header except compatibility 802.3 header */
589u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
590
591#define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
592
593struct hermes_rx_descriptor { 254struct hermes_rx_descriptor {
255 /* Control */
594 u16 status; 256 u16 status;
595 u32 time; 257 u32 time;
596 u8 silence; 258 u8 silence;
@@ -598,13 +260,24 @@ struct hermes_rx_descriptor {
598 u8 rate; 260 u8 rate;
599 u8 rxflow; 261 u8 rxflow;
600 u32 reserved; 262 u32 reserved;
263
264 /* 802.11 header */
265 u16 frame_ctl;
266 u16 duration_id;
267 u8 addr1[ETH_ALEN];
268 u8 addr2[ETH_ALEN];
269 u8 addr3[ETH_ALEN];
270 u16 seq_ctl;
271 u8 addr4[ETH_ALEN];
272
273 /* Data length */
274 u16 data_len;
601} __attribute__ ((packed)); 275} __attribute__ ((packed));
602 276
603/********************************************************************/ 277/********************************************************************/
604/* Function prototypes */ 278/* Function prototypes */
605/********************************************************************/ 279/********************************************************************/
606 280
607static int orinoco_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
608static int __orinoco_program_rids(struct net_device *dev); 281static int __orinoco_program_rids(struct net_device *dev);
609static void __orinoco_set_multicast_list(struct net_device *dev); 282static void __orinoco_set_multicast_list(struct net_device *dev);
610 283
@@ -628,6 +301,10 @@ static inline void set_port_type(struct orinoco_private *priv)
628 priv->createibss = 1; 301 priv->createibss = 1;
629 } 302 }
630 break; 303 break;
304 case IW_MODE_MONITOR:
305 priv->port_type = 3;
306 priv->createibss = 0;
307 break;
631 default: 308 default:
632 printk(KERN_ERR "%s: Invalid priv->iw_mode in set_port_type()\n", 309 printk(KERN_ERR "%s: Invalid priv->iw_mode in set_port_type()\n",
633 priv->ndev->name); 310 priv->ndev->name);
@@ -814,7 +491,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
814 return 1; 491 return 1;
815 } 492 }
816 493
817 if (! netif_carrier_ok(dev)) { 494 if (! netif_carrier_ok(dev) || (priv->iw_mode == IW_MODE_MONITOR)) {
818 /* Oops, the firmware hasn't established a connection, 495 /* Oops, the firmware hasn't established a connection,
819 silently drop the packet (this seems to be the 496 silently drop the packet (this seems to be the
820 safest approach). */ 497 safest approach). */
@@ -951,26 +628,55 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
951 struct orinoco_private *priv = netdev_priv(dev); 628 struct orinoco_private *priv = netdev_priv(dev);
952 struct net_device_stats *stats = &priv->stats; 629 struct net_device_stats *stats = &priv->stats;
953 u16 fid = hermes_read_regn(hw, TXCOMPLFID); 630 u16 fid = hermes_read_regn(hw, TXCOMPLFID);
954 struct hermes_tx_descriptor desc; 631 struct hermes_tx_descriptor_802_11 hdr;
955 int err = 0; 632 int err = 0;
956 633
957 if (fid == DUMMY_FID) 634 if (fid == DUMMY_FID)
958 return; /* Nothing's really happened */ 635 return; /* Nothing's really happened */
959 636
960 err = hermes_bap_pread(hw, IRQ_BAP, &desc, sizeof(desc), fid, 0); 637 /* Read the frame header */
638 err = hermes_bap_pread(hw, IRQ_BAP, &hdr,
639 sizeof(struct hermes_tx_descriptor) +
640 sizeof(struct ieee80211_hdr),
641 fid, 0);
642
643 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
644 stats->tx_errors++;
645
961 if (err) { 646 if (err) {
962 printk(KERN_WARNING "%s: Unable to read descriptor on Tx error " 647 printk(KERN_WARNING "%s: Unable to read descriptor on Tx error "
963 "(FID=%04X error %d)\n", 648 "(FID=%04X error %d)\n",
964 dev->name, fid, err); 649 dev->name, fid, err);
965 } else { 650 return;
966 DEBUG(1, "%s: Tx error, status %d\n",
967 dev->name, le16_to_cpu(desc.status));
968 } 651 }
969 652
970 stats->tx_errors++; 653 DEBUG(1, "%s: Tx error, err %d (FID=%04X)\n", dev->name,
654 err, fid);
655
656 /* We produce a TXDROP event only for retry or lifetime
657 * exceeded, because that's the only status that really mean
658 * that this particular node went away.
659 * Other errors means that *we* screwed up. - Jean II */
660 hdr.status = le16_to_cpu(hdr.status);
661 if (hdr.status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) {
662 union iwreq_data wrqu;
663
664 /* Copy 802.11 dest address.
665 * We use the 802.11 header because the frame may
666 * not be 802.3 or may be mangled...
667 * In Ad-Hoc mode, it will be the node address.
668 * In managed mode, it will be most likely the AP addr
669 * User space will figure out how to convert it to
670 * whatever it needs (IP address or else).
671 * - Jean II */
672 memcpy(wrqu.addr.sa_data, hdr.addr1, ETH_ALEN);
673 wrqu.addr.sa_family = ARPHRD_ETHER;
674
675 /* Send event to user space */
676 wireless_send_event(dev, IWEVTXDROP, &wrqu, NULL);
677 }
971 678
972 netif_wake_queue(dev); 679 netif_wake_queue(dev);
973 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
974} 680}
975 681
976static void orinoco_tx_timeout(struct net_device *dev) 682static void orinoco_tx_timeout(struct net_device *dev)
@@ -1047,18 +753,127 @@ static void orinoco_stat_gather(struct net_device *dev,
1047 } 753 }
1048} 754}
1049 755
756/*
757 * orinoco_rx_monitor - handle received monitor frames.
758 *
759 * Arguments:
760 * dev network device
761 * rxfid received FID
762 * desc rx descriptor of the frame
763 *
764 * Call context: interrupt
765 */
766static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
767 struct hermes_rx_descriptor *desc)
768{
769 u32 hdrlen = 30; /* return full header by default */
770 u32 datalen = 0;
771 u16 fc;
772 int err;
773 int len;
774 struct sk_buff *skb;
775 struct orinoco_private *priv = netdev_priv(dev);
776 struct net_device_stats *stats = &priv->stats;
777 hermes_t *hw = &priv->hw;
778
779 len = le16_to_cpu(desc->data_len);
780
781 /* Determine the size of the header and the data */
782 fc = le16_to_cpu(desc->frame_ctl);
783 switch (fc & IEEE80211_FCTL_FTYPE) {
784 case IEEE80211_FTYPE_DATA:
785 if ((fc & IEEE80211_FCTL_TODS)
786 && (fc & IEEE80211_FCTL_FROMDS))
787 hdrlen = 30;
788 else
789 hdrlen = 24;
790 datalen = len;
791 break;
792 case IEEE80211_FTYPE_MGMT:
793 hdrlen = 24;
794 datalen = len;
795 break;
796 case IEEE80211_FTYPE_CTL:
797 switch (fc & IEEE80211_FCTL_STYPE) {
798 case IEEE80211_STYPE_PSPOLL:
799 case IEEE80211_STYPE_RTS:
800 case IEEE80211_STYPE_CFEND:
801 case IEEE80211_STYPE_CFENDACK:
802 hdrlen = 16;
803 break;
804 case IEEE80211_STYPE_CTS:
805 case IEEE80211_STYPE_ACK:
806 hdrlen = 10;
807 break;
808 }
809 break;
810 default:
811 /* Unknown frame type */
812 break;
813 }
814
815 /* sanity check the length */
816 if (datalen > IEEE80211_DATA_LEN + 12) {
817 printk(KERN_DEBUG "%s: oversized monitor frame, "
818 "data length = %d\n", dev->name, datalen);
819 err = -EIO;
820 stats->rx_length_errors++;
821 goto update_stats;
822 }
823
824 skb = dev_alloc_skb(hdrlen + datalen);
825 if (!skb) {
826 printk(KERN_WARNING "%s: Cannot allocate skb for monitor frame\n",
827 dev->name);
828 err = -ENOMEM;
829 goto drop;
830 }
831
832 /* Copy the 802.11 header to the skb */
833 memcpy(skb_put(skb, hdrlen), &(desc->frame_ctl), hdrlen);
834 skb->mac.raw = skb->data;
835
836 /* If any, copy the data from the card to the skb */
837 if (datalen > 0) {
838 err = hermes_bap_pread(hw, IRQ_BAP, skb_put(skb, datalen),
839 ALIGN(datalen, 2), rxfid,
840 HERMES_802_2_OFFSET);
841 if (err) {
842 printk(KERN_ERR "%s: error %d reading monitor frame\n",
843 dev->name, err);
844 goto drop;
845 }
846 }
847
848 skb->dev = dev;
849 skb->ip_summed = CHECKSUM_NONE;
850 skb->pkt_type = PACKET_OTHERHOST;
851 skb->protocol = __constant_htons(ETH_P_802_2);
852
853 dev->last_rx = jiffies;
854 stats->rx_packets++;
855 stats->rx_bytes += skb->len;
856
857 netif_rx(skb);
858 return;
859
860 drop:
861 dev_kfree_skb_irq(skb);
862 update_stats:
863 stats->rx_errors++;
864 stats->rx_dropped++;
865}
866
1050static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw) 867static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
1051{ 868{
1052 struct orinoco_private *priv = netdev_priv(dev); 869 struct orinoco_private *priv = netdev_priv(dev);
1053 struct net_device_stats *stats = &priv->stats; 870 struct net_device_stats *stats = &priv->stats;
1054 struct iw_statistics *wstats = &priv->wstats; 871 struct iw_statistics *wstats = &priv->wstats;
1055 struct sk_buff *skb = NULL; 872 struct sk_buff *skb = NULL;
1056 u16 rxfid, status; 873 u16 rxfid, status, fc;
1057 int length, data_len, data_off; 874 int length;
1058 char *p;
1059 struct hermes_rx_descriptor desc; 875 struct hermes_rx_descriptor desc;
1060 struct header_struct hdr; 876 struct ethhdr *hdr;
1061 struct ethhdr *eh;
1062 int err; 877 int err;
1063 878
1064 rxfid = hermes_read_regn(hw, RXFID); 879 rxfid = hermes_read_regn(hw, RXFID);
@@ -1068,53 +883,46 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
1068 if (err) { 883 if (err) {
1069 printk(KERN_ERR "%s: error %d reading Rx descriptor. " 884 printk(KERN_ERR "%s: error %d reading Rx descriptor. "
1070 "Frame dropped.\n", dev->name, err); 885 "Frame dropped.\n", dev->name, err);
1071 stats->rx_errors++; 886 goto update_stats;
1072 goto drop;
1073 } 887 }
1074 888
1075 status = le16_to_cpu(desc.status); 889 status = le16_to_cpu(desc.status);
1076 890
1077 if (status & HERMES_RXSTAT_ERR) { 891 if (status & HERMES_RXSTAT_BADCRC) {
1078 if (status & HERMES_RXSTAT_UNDECRYPTABLE) { 892 DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n",
1079 wstats->discard.code++; 893 dev->name);
1080 DEBUG(1, "%s: Undecryptable frame on Rx. Frame dropped.\n", 894 stats->rx_crc_errors++;
1081 dev->name); 895 goto update_stats;
1082 } else {
1083 stats->rx_crc_errors++;
1084 DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n", dev->name);
1085 }
1086 stats->rx_errors++;
1087 goto drop;
1088 } 896 }
1089 897
1090 /* For now we ignore the 802.11 header completely, assuming 898 /* Handle frames in monitor mode */
1091 that the card's firmware has handled anything vital */ 899 if (priv->iw_mode == IW_MODE_MONITOR) {
900 orinoco_rx_monitor(dev, rxfid, &desc);
901 return;
902 }
1092 903
1093 err = hermes_bap_pread(hw, IRQ_BAP, &hdr, sizeof(hdr), 904 if (status & HERMES_RXSTAT_UNDECRYPTABLE) {
1094 rxfid, HERMES_802_3_OFFSET); 905 DEBUG(1, "%s: Undecryptable frame on Rx. Frame dropped.\n",
1095 if (err) { 906 dev->name);
1096 printk(KERN_ERR "%s: error %d reading frame header. " 907 wstats->discard.code++;
1097 "Frame dropped.\n", dev->name, err); 908 goto update_stats;
1098 stats->rx_errors++;
1099 goto drop;
1100 } 909 }
1101 910
1102 length = ntohs(hdr.len); 911 length = le16_to_cpu(desc.data_len);
1103 912 fc = le16_to_cpu(desc.frame_ctl);
913
1104 /* Sanity checks */ 914 /* Sanity checks */
1105 if (length < 3) { /* No for even an 802.2 LLC header */ 915 if (length < 3) { /* No for even an 802.2 LLC header */
1106 /* At least on Symbol firmware with PCF we get quite a 916 /* At least on Symbol firmware with PCF we get quite a
1107 lot of these legitimately - Poll frames with no 917 lot of these legitimately - Poll frames with no
1108 data. */ 918 data. */
1109 stats->rx_dropped++; 919 return;
1110 goto drop;
1111 } 920 }
1112 if (length > IEEE802_11_DATA_LEN) { 921 if (length > IEEE802_11_DATA_LEN) {
1113 printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n", 922 printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n",
1114 dev->name, length); 923 dev->name, length);
1115 stats->rx_length_errors++; 924 stats->rx_length_errors++;
1116 stats->rx_errors++; 925 goto update_stats;
1117 goto drop;
1118 } 926 }
1119 927
1120 /* We need space for the packet data itself, plus an ethernet 928 /* We need space for the packet data itself, plus an ethernet
@@ -1126,60 +934,53 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
1126 if (!skb) { 934 if (!skb) {
1127 printk(KERN_WARNING "%s: Can't allocate skb for Rx\n", 935 printk(KERN_WARNING "%s: Can't allocate skb for Rx\n",
1128 dev->name); 936 dev->name);
1129 goto drop; 937 goto update_stats;
1130 } 938 }
1131 939
1132 skb_reserve(skb, 2); /* This way the IP header is aligned */ 940 /* We'll prepend the header, so reserve space for it. The worst
941 case is no decapsulation, when 802.3 header is prepended and
942 nothing is removed. 2 is for aligning the IP header. */
943 skb_reserve(skb, ETH_HLEN + 2);
944
945 err = hermes_bap_pread(hw, IRQ_BAP, skb_put(skb, length),
946 ALIGN(length, 2), rxfid,
947 HERMES_802_2_OFFSET);
948 if (err) {
949 printk(KERN_ERR "%s: error %d reading frame. "
950 "Frame dropped.\n", dev->name, err);
951 goto drop;
952 }
1133 953
1134 /* Handle decapsulation 954 /* Handle decapsulation
1135 * In most cases, the firmware tell us about SNAP frames. 955 * In most cases, the firmware tell us about SNAP frames.
1136 * For some reason, the SNAP frames sent by LinkSys APs 956 * For some reason, the SNAP frames sent by LinkSys APs
1137 * are not properly recognised by most firmwares. 957 * are not properly recognised by most firmwares.
1138 * So, check ourselves */ 958 * So, check ourselves */
1139 if (((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_1042) || 959 if (length >= ENCAPS_OVERHEAD &&
1140 ((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_TUNNEL) || 960 (((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_1042) ||
1141 is_ethersnap(&hdr)) { 961 ((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_TUNNEL) ||
962 is_ethersnap(skb->data))) {
1142 /* These indicate a SNAP within 802.2 LLC within 963 /* These indicate a SNAP within 802.2 LLC within
1143 802.11 frame which we'll need to de-encapsulate to 964 802.11 frame which we'll need to de-encapsulate to
1144 the original EthernetII frame. */ 965 the original EthernetII frame. */
1145 966 hdr = (struct ethhdr *)skb_push(skb, ETH_HLEN - ENCAPS_OVERHEAD);
1146 if (length < ENCAPS_OVERHEAD) { /* No room for full LLC+SNAP */
1147 stats->rx_length_errors++;
1148 goto drop;
1149 }
1150
1151 /* Remove SNAP header, reconstruct EthernetII frame */
1152 data_len = length - ENCAPS_OVERHEAD;
1153 data_off = HERMES_802_3_OFFSET + sizeof(hdr);
1154
1155 eh = (struct ethhdr *)skb_put(skb, ETH_HLEN);
1156
1157 memcpy(eh, &hdr, 2 * ETH_ALEN);
1158 eh->h_proto = hdr.ethertype;
1159 } else { 967 } else {
1160 /* All other cases indicate a genuine 802.3 frame. No 968 /* 802.3 frame - prepend 802.3 header as is */
1161 decapsulation needed. We just throw the whole 969 hdr = (struct ethhdr *)skb_push(skb, ETH_HLEN);
1162 thing in, and hope the protocol layer can deal with 970 hdr->h_proto = htons(length);
1163 it as 802.3 */
1164 data_len = length;
1165 data_off = HERMES_802_3_OFFSET;
1166 /* FIXME: we re-read from the card data we already read here */
1167 }
1168
1169 p = skb_put(skb, data_len);
1170 err = hermes_bap_pread(hw, IRQ_BAP, p, ALIGN(data_len, 2),
1171 rxfid, data_off);
1172 if (err) {
1173 printk(KERN_ERR "%s: error %d reading frame. "
1174 "Frame dropped.\n", dev->name, err);
1175 stats->rx_errors++;
1176 goto drop;
1177 } 971 }
972 memcpy(hdr->h_dest, desc.addr1, ETH_ALEN);
973 if (fc & IEEE80211_FCTL_FROMDS)
974 memcpy(hdr->h_source, desc.addr3, ETH_ALEN);
975 else
976 memcpy(hdr->h_source, desc.addr2, ETH_ALEN);
1178 977
1179 dev->last_rx = jiffies; 978 dev->last_rx = jiffies;
1180 skb->dev = dev; 979 skb->dev = dev;
1181 skb->protocol = eth_type_trans(skb, dev); 980 skb->protocol = eth_type_trans(skb, dev);
1182 skb->ip_summed = CHECKSUM_NONE; 981 skb->ip_summed = CHECKSUM_NONE;
982 if (fc & IEEE80211_FCTL_TODS)
983 skb->pkt_type = PACKET_OTHERHOST;
1183 984
1184 /* Process the wireless stats if needed */ 985 /* Process the wireless stats if needed */
1185 orinoco_stat_gather(dev, skb, &desc); 986 orinoco_stat_gather(dev, skb, &desc);
@@ -1192,11 +993,10 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
1192 return; 993 return;
1193 994
1194 drop: 995 drop:
996 dev_kfree_skb_irq(skb);
997 update_stats:
998 stats->rx_errors++;
1195 stats->rx_dropped++; 999 stats->rx_dropped++;
1196
1197 if (skb)
1198 dev_kfree_skb_irq(skb);
1199 return;
1200} 1000}
1201 1001
1202/********************************************************************/ 1002/********************************************************************/
@@ -1240,6 +1040,99 @@ static void print_linkstatus(struct net_device *dev, u16 status)
1240 dev->name, s, status); 1040 dev->name, s, status);
1241} 1041}
1242 1042
1043/* Search scan results for requested BSSID, join it if found */
1044static void orinoco_join_ap(struct net_device *dev)
1045{
1046 struct orinoco_private *priv = netdev_priv(dev);
1047 struct hermes *hw = &priv->hw;
1048 int err;
1049 unsigned long flags;
1050 struct join_req {
1051 u8 bssid[ETH_ALEN];
1052 u16 channel;
1053 } __attribute__ ((packed)) req;
1054 const int atom_len = offsetof(struct prism2_scan_apinfo, atim);
1055 struct prism2_scan_apinfo *atom;
1056 int offset = 4;
1057 u8 *buf;
1058 u16 len;
1059
1060 /* Allocate buffer for scan results */
1061 buf = kmalloc(MAX_SCAN_LEN, GFP_KERNEL);
1062 if (! buf)
1063 return;
1064
1065 if (orinoco_lock(priv, &flags) != 0)
1066 goto out;
1067
1068 /* Sanity checks in case user changed something in the meantime */
1069 if (! priv->bssid_fixed)
1070 goto out;
1071
1072 if (strlen(priv->desired_essid) == 0)
1073 goto out;
1074
1075 /* Read scan results from the firmware */
1076 err = hermes_read_ltv(hw, USER_BAP,
1077 HERMES_RID_SCANRESULTSTABLE,
1078 MAX_SCAN_LEN, &len, buf);
1079 if (err) {
1080 printk(KERN_ERR "%s: Cannot read scan results\n",
1081 dev->name);
1082 goto out;
1083 }
1084
1085 len = HERMES_RECLEN_TO_BYTES(len);
1086
1087 /* Go through the scan results looking for the channel of the AP
1088 * we were requested to join */
1089 for (; offset + atom_len <= len; offset += atom_len) {
1090 atom = (struct prism2_scan_apinfo *) (buf + offset);
1091 if (memcmp(&atom->bssid, priv->desired_bssid, ETH_ALEN) == 0)
1092 goto found;
1093 }
1094
1095 DEBUG(1, "%s: Requested AP not found in scan results\n",
1096 dev->name);
1097 goto out;
1098
1099 found:
1100 memcpy(req.bssid, priv->desired_bssid, ETH_ALEN);
1101 req.channel = atom->channel; /* both are little-endian */
1102 err = HERMES_WRITE_RECORD(hw, USER_BAP, HERMES_RID_CNFJOINREQUEST,
1103 &req);
1104 if (err)
1105 printk(KERN_ERR "%s: Error issuing join request\n", dev->name);
1106
1107 out:
1108 kfree(buf);
1109 orinoco_unlock(priv, &flags);
1110}
1111
1112/* Send new BSSID to userspace */
1113static void orinoco_send_wevents(struct net_device *dev)
1114{
1115 struct orinoco_private *priv = netdev_priv(dev);
1116 struct hermes *hw = &priv->hw;
1117 union iwreq_data wrqu;
1118 int err;
1119 unsigned long flags;
1120
1121 if (orinoco_lock(priv, &flags) != 0)
1122 return;
1123
1124 err = hermes_read_ltv(hw, IRQ_BAP, HERMES_RID_CURRENTBSSID,
1125 ETH_ALEN, NULL, wrqu.ap_addr.sa_data);
1126 if (err != 0)
1127 return;
1128
1129 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1130
1131 /* Send event to user space */
1132 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
1133 orinoco_unlock(priv, &flags);
1134}
1135
1243static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) 1136static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1244{ 1137{
1245 struct orinoco_private *priv = netdev_priv(dev); 1138 struct orinoco_private *priv = netdev_priv(dev);
@@ -1307,6 +1200,9 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1307 u16 newstatus; 1200 u16 newstatus;
1308 int connected; 1201 int connected;
1309 1202
1203 if (priv->iw_mode == IW_MODE_MONITOR)
1204 break;
1205
1310 if (len != sizeof(linkstatus)) { 1206 if (len != sizeof(linkstatus)) {
1311 printk(KERN_WARNING "%s: Unexpected size for linkstatus frame (%d bytes)\n", 1207 printk(KERN_WARNING "%s: Unexpected size for linkstatus frame (%d bytes)\n",
1312 dev->name, len); 1208 dev->name, len);
@@ -1319,6 +1215,15 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1319 break; 1215 break;
1320 newstatus = le16_to_cpu(linkstatus.linkstatus); 1216 newstatus = le16_to_cpu(linkstatus.linkstatus);
1321 1217
1218 /* Symbol firmware uses "out of range" to signal that
1219 * the hostscan frame can be requested. */
1220 if (newstatus == HERMES_LINKSTATUS_AP_OUT_OF_RANGE &&
1221 priv->firmware_type == FIRMWARE_TYPE_SYMBOL &&
1222 priv->has_hostscan && priv->scan_inprogress) {
1223 hermes_inquire(hw, HERMES_INQ_HOSTSCAN_SYMBOL);
1224 break;
1225 }
1226
1322 connected = (newstatus == HERMES_LINKSTATUS_CONNECTED) 1227 connected = (newstatus == HERMES_LINKSTATUS_CONNECTED)
1323 || (newstatus == HERMES_LINKSTATUS_AP_CHANGE) 1228 || (newstatus == HERMES_LINKSTATUS_AP_CHANGE)
1324 || (newstatus == HERMES_LINKSTATUS_AP_IN_RANGE); 1229 || (newstatus == HERMES_LINKSTATUS_AP_IN_RANGE);
@@ -1328,12 +1233,89 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1328 else if (!ignore_disconnect) 1233 else if (!ignore_disconnect)
1329 netif_carrier_off(dev); 1234 netif_carrier_off(dev);
1330 1235
1331 if (newstatus != priv->last_linkstatus) 1236 if (newstatus != priv->last_linkstatus) {
1237 priv->last_linkstatus = newstatus;
1332 print_linkstatus(dev, newstatus); 1238 print_linkstatus(dev, newstatus);
1239 /* The info frame contains only one word which is the
1240 * status (see hermes.h). The status is pretty boring
1241 * in itself, that's why we export the new BSSID...
1242 * Jean II */
1243 schedule_work(&priv->wevent_work);
1244 }
1245 }
1246 break;
1247 case HERMES_INQ_SCAN:
1248 if (!priv->scan_inprogress && priv->bssid_fixed &&
1249 priv->firmware_type == FIRMWARE_TYPE_INTERSIL) {
1250 schedule_work(&priv->join_work);
1251 break;
1252 }
1253 /* fall through */
1254 case HERMES_INQ_HOSTSCAN:
1255 case HERMES_INQ_HOSTSCAN_SYMBOL: {
1256 /* Result of a scanning. Contains information about
1257 * cells in the vicinity - Jean II */
1258 union iwreq_data wrqu;
1259 unsigned char *buf;
1260
1261 /* Sanity check */
1262 if (len > 4096) {
1263 printk(KERN_WARNING "%s: Scan results too large (%d bytes)\n",
1264 dev->name, len);
1265 break;
1266 }
1333 1267
1334 priv->last_linkstatus = newstatus; 1268 /* We are a strict producer. If the previous scan results
1269 * have not been consumed, we just have to drop this
1270 * frame. We can't remove the previous results ourselves,
1271 * that would be *very* racy... Jean II */
1272 if (priv->scan_result != NULL) {
1273 printk(KERN_WARNING "%s: Previous scan results not consumed, dropping info frame.\n", dev->name);
1274 break;
1275 }
1276
1277 /* Allocate buffer for results */
1278 buf = kmalloc(len, GFP_ATOMIC);
1279 if (buf == NULL)
1280 /* No memory, so can't printk()... */
1281 break;
1282
1283 /* Read scan data */
1284 err = hermes_bap_pread(hw, IRQ_BAP, (void *) buf, len,
1285 infofid, sizeof(info));
1286 if (err)
1287 break;
1288
1289#ifdef ORINOCO_DEBUG
1290 {
1291 int i;
1292 printk(KERN_DEBUG "Scan result [%02X", buf[0]);
1293 for(i = 1; i < (len * 2); i++)
1294 printk(":%02X", buf[i]);
1295 printk("]\n");
1296 }
1297#endif /* ORINOCO_DEBUG */
1298
1299 /* Allow the clients to access the results */
1300 priv->scan_len = len;
1301 priv->scan_result = buf;
1302
1303 /* Send an empty event to user space.
1304 * We don't send the received data on the event because
1305 * it would require us to do complex transcoding, and
1306 * we want to minimise the work done in the irq handler
1307 * Use a request to extract the data - Jean II */
1308 wrqu.data.length = 0;
1309 wrqu.data.flags = 0;
1310 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
1335 } 1311 }
1336 break; 1312 break;
1313 case HERMES_INQ_SEC_STAT_AGERE:
1314 /* Security status (Agere specific) */
1315 /* Ignore this frame for now */
1316 if (priv->firmware_type == FIRMWARE_TYPE_AGERE)
1317 break;
1318 /* fall through */
1337 default: 1319 default:
1338 printk(KERN_DEBUG "%s: Unknown information frame received: " 1320 printk(KERN_DEBUG "%s: Unknown information frame received: "
1339 "type 0x%04x, length %d\n", dev->name, type, len); 1321 "type 0x%04x, length %d\n", dev->name, type, len);
@@ -1470,6 +1452,36 @@ static int __orinoco_hw_set_bitrate(struct orinoco_private *priv)
1470 return err; 1452 return err;
1471} 1453}
1472 1454
1455/* Set fixed AP address */
1456static int __orinoco_hw_set_wap(struct orinoco_private *priv)
1457{
1458 int roaming_flag;
1459 int err = 0;
1460 hermes_t *hw = &priv->hw;
1461
1462 switch (priv->firmware_type) {
1463 case FIRMWARE_TYPE_AGERE:
1464 /* not supported */
1465 break;
1466 case FIRMWARE_TYPE_INTERSIL:
1467 if (priv->bssid_fixed)
1468 roaming_flag = 2;
1469 else
1470 roaming_flag = 1;
1471
1472 err = hermes_write_wordrec(hw, USER_BAP,
1473 HERMES_RID_CNFROAMINGMODE,
1474 roaming_flag);
1475 break;
1476 case FIRMWARE_TYPE_SYMBOL:
1477 err = HERMES_WRITE_RECORD(hw, USER_BAP,
1478 HERMES_RID_CNFMANDATORYBSSID_SYMBOL,
1479 &priv->desired_bssid);
1480 break;
1481 }
1482 return err;
1483}
1484
1473/* Change the WEP keys and/or the current keys. Can be called 1485/* Change the WEP keys and/or the current keys. Can be called
1474 * either from __orinoco_hw_setup_wep() or directly from 1486 * either from __orinoco_hw_setup_wep() or directly from
1475 * orinoco_ioctl_setiwencode(). In the later case the association 1487 * orinoco_ioctl_setiwencode(). In the later case the association
@@ -1655,6 +1667,13 @@ static int __orinoco_program_rids(struct net_device *dev)
1655 } 1667 }
1656 } 1668 }
1657 1669
1670 /* Set the desired BSSID */
1671 err = __orinoco_hw_set_wap(priv);
1672 if (err) {
1673 printk(KERN_ERR "%s: Error %d setting AP address\n",
1674 dev->name, err);
1675 return err;
1676 }
1658 /* Set the desired ESSID */ 1677 /* Set the desired ESSID */
1659 idbuf.len = cpu_to_le16(strlen(priv->desired_essid)); 1678 idbuf.len = cpu_to_le16(strlen(priv->desired_essid));
1660 memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val)); 1679 memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val));
@@ -1793,6 +1812,20 @@ static int __orinoco_program_rids(struct net_device *dev)
1793 } 1812 }
1794 } 1813 }
1795 1814
1815 if (priv->iw_mode == IW_MODE_MONITOR) {
1816 /* Enable monitor mode */
1817 dev->type = ARPHRD_IEEE80211;
1818 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
1819 HERMES_TEST_MONITOR, 0, NULL);
1820 } else {
1821 /* Disable monitor mode */
1822 dev->type = ARPHRD_ETHER;
1823 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
1824 HERMES_TEST_STOP, 0, NULL);
1825 }
1826 if (err)
1827 return err;
1828
1796 /* Set promiscuity / multicast*/ 1829 /* Set promiscuity / multicast*/
1797 priv->promiscuous = 0; 1830 priv->promiscuous = 0;
1798 priv->mc_count = 0; 1831 priv->mc_count = 0;
@@ -1869,55 +1902,6 @@ __orinoco_set_multicast_list(struct net_device *dev)
1869 dev->flags &= ~IFF_PROMISC; 1902 dev->flags &= ~IFF_PROMISC;
1870} 1903}
1871 1904
1872static int orinoco_reconfigure(struct net_device *dev)
1873{
1874 struct orinoco_private *priv = netdev_priv(dev);
1875 struct hermes *hw = &priv->hw;
1876 unsigned long flags;
1877 int err = 0;
1878
1879 if (priv->broken_disableport) {
1880 schedule_work(&priv->reset_work);
1881 return 0;
1882 }
1883
1884 if (orinoco_lock(priv, &flags) != 0)
1885 return -EBUSY;
1886
1887 err = hermes_disable_port(hw, 0);
1888 if (err) {
1889 printk(KERN_WARNING "%s: Unable to disable port while reconfiguring card\n",
1890 dev->name);
1891 priv->broken_disableport = 1;
1892 goto out;
1893 }
1894
1895 err = __orinoco_program_rids(dev);
1896 if (err) {
1897 printk(KERN_WARNING "%s: Unable to reconfigure card\n",
1898 dev->name);
1899 goto out;
1900 }
1901
1902 err = hermes_enable_port(hw, 0);
1903 if (err) {
1904 printk(KERN_WARNING "%s: Unable to enable port while reconfiguring card\n",
1905 dev->name);
1906 goto out;
1907 }
1908
1909 out:
1910 if (err) {
1911 printk(KERN_WARNING "%s: Resetting instead...\n", dev->name);
1912 schedule_work(&priv->reset_work);
1913 err = 0;
1914 }
1915
1916 orinoco_unlock(priv, &flags);
1917 return err;
1918
1919}
1920
1921/* This must be called from user context, without locks held - use 1905/* This must be called from user context, without locks held - use
1922 * schedule_work() */ 1906 * schedule_work() */
1923static void orinoco_reset(struct net_device *dev) 1907static void orinoco_reset(struct net_device *dev)
@@ -1946,6 +1930,11 @@ static void orinoco_reset(struct net_device *dev)
1946 1930
1947 orinoco_unlock(priv, &flags); 1931 orinoco_unlock(priv, &flags);
1948 1932
1933 /* Scanning support: Cleanup of driver struct */
1934 kfree(priv->scan_result);
1935 priv->scan_result = NULL;
1936 priv->scan_inprogress = 0;
1937
1949 if (priv->hard_reset) { 1938 if (priv->hard_reset) {
1950 err = (*priv->hard_reset)(priv); 1939 err = (*priv->hard_reset)(priv);
1951 if (err) { 1940 if (err) {
@@ -2184,6 +2173,8 @@ static int determine_firmware(struct net_device *dev)
2184 priv->has_mwo = (firmver >= 0x60000); 2173 priv->has_mwo = (firmver >= 0x60000);
2185 priv->has_pm = (firmver >= 0x40020); /* Don't work in 7.52 ? */ 2174 priv->has_pm = (firmver >= 0x40020); /* Don't work in 7.52 ? */
2186 priv->ibss_port = 1; 2175 priv->ibss_port = 1;
2176 priv->has_hostscan = (firmver >= 0x8000a);
2177 priv->broken_monitor = (firmver >= 0x80000);
2187 2178
2188 /* Tested with Agere firmware : 2179 /* Tested with Agere firmware :
2189 * 1.16 ; 4.08 ; 4.52 ; 6.04 ; 6.16 ; 7.28 => Jean II 2180 * 1.16 ; 4.08 ; 4.52 ; 6.04 ; 6.16 ; 7.28 => Jean II
@@ -2229,6 +2220,8 @@ static int determine_firmware(struct net_device *dev)
2229 priv->ibss_port = 4; 2220 priv->ibss_port = 4;
2230 priv->broken_disableport = (firmver == 0x25013) || 2221 priv->broken_disableport = (firmver == 0x25013) ||
2231 (firmver >= 0x30000 && firmver <= 0x31000); 2222 (firmver >= 0x30000 && firmver <= 0x31000);
2223 priv->has_hostscan = (firmver >= 0x31001) ||
2224 (firmver >= 0x29057 && firmver < 0x30000);
2232 /* Tested with Intel firmware : 0x20015 => Jean II */ 2225 /* Tested with Intel firmware : 0x20015 => Jean II */
2233 /* Tested with 3Com firmware : 0x15012 & 0x22001 => Jean II */ 2226 /* Tested with 3Com firmware : 0x15012 & 0x22001 => Jean II */
2234 break; 2227 break;
@@ -2248,6 +2241,7 @@ static int determine_firmware(struct net_device *dev)
2248 priv->has_ibss = (firmver >= 0x000700); /* FIXME */ 2241 priv->has_ibss = (firmver >= 0x000700); /* FIXME */
2249 priv->has_big_wep = priv->has_wep = (firmver >= 0x000800); 2242 priv->has_big_wep = priv->has_wep = (firmver >= 0x000800);
2250 priv->has_pm = (firmver >= 0x000700); 2243 priv->has_pm = (firmver >= 0x000700);
2244 priv->has_hostscan = (firmver >= 0x010301);
2251 2245
2252 if (firmver >= 0x000800) 2246 if (firmver >= 0x000800)
2253 priv->ibss_port = 0; 2247 priv->ibss_port = 0;
@@ -2456,8 +2450,9 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2456 dev->tx_timeout = orinoco_tx_timeout; 2450 dev->tx_timeout = orinoco_tx_timeout;
2457 dev->watchdog_timeo = HZ; /* 1 second timeout */ 2451 dev->watchdog_timeo = HZ; /* 1 second timeout */
2458 dev->get_stats = orinoco_get_stats; 2452 dev->get_stats = orinoco_get_stats;
2453 dev->ethtool_ops = &orinoco_ethtool_ops;
2459 dev->get_wireless_stats = orinoco_get_wireless_stats; 2454 dev->get_wireless_stats = orinoco_get_wireless_stats;
2460 dev->do_ioctl = orinoco_ioctl; 2455 dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def;
2461 dev->change_mtu = orinoco_change_mtu; 2456 dev->change_mtu = orinoco_change_mtu;
2462 dev->set_multicast_list = orinoco_set_multicast_list; 2457 dev->set_multicast_list = orinoco_set_multicast_list;
2463 /* we use the default eth_mac_addr for setting the MAC addr */ 2458 /* we use the default eth_mac_addr for setting the MAC addr */
@@ -2473,6 +2468,8 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2473 * before anything else touches the 2468 * before anything else touches the
2474 * hardware */ 2469 * hardware */
2475 INIT_WORK(&priv->reset_work, (void (*)(void *))orinoco_reset, dev); 2470 INIT_WORK(&priv->reset_work, (void (*)(void *))orinoco_reset, dev);
2471 INIT_WORK(&priv->join_work, (void (*)(void *))orinoco_join_ap, dev);
2472 INIT_WORK(&priv->wevent_work, (void (*)(void *))orinoco_send_wevents, dev);
2476 2473
2477 netif_carrier_off(dev); 2474 netif_carrier_off(dev);
2478 priv->last_linkstatus = 0xffff; 2475 priv->last_linkstatus = 0xffff;
@@ -2483,6 +2480,9 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2483 2480
2484void free_orinocodev(struct net_device *dev) 2481void free_orinocodev(struct net_device *dev)
2485{ 2482{
2483 struct orinoco_private *priv = netdev_priv(dev);
2484
2485 kfree(priv->scan_result);
2486 free_netdev(dev); 2486 free_netdev(dev);
2487} 2487}
2488 2488
@@ -2490,24 +2490,6 @@ void free_orinocodev(struct net_device *dev)
2490/* Wireless extensions */ 2490/* Wireless extensions */
2491/********************************************************************/ 2491/********************************************************************/
2492 2492
2493static int orinoco_hw_get_bssid(struct orinoco_private *priv,
2494 char buf[ETH_ALEN])
2495{
2496 hermes_t *hw = &priv->hw;
2497 int err = 0;
2498 unsigned long flags;
2499
2500 if (orinoco_lock(priv, &flags) != 0)
2501 return -EBUSY;
2502
2503 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
2504 ETH_ALEN, NULL, buf);
2505
2506 orinoco_unlock(priv, &flags);
2507
2508 return err;
2509}
2510
2511static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, 2493static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
2512 char buf[IW_ESSID_MAX_SIZE+1]) 2494 char buf[IW_ESSID_MAX_SIZE+1])
2513{ 2495{
@@ -2633,140 +2615,271 @@ static int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
2633 return 0; 2615 return 0;
2634} 2616}
2635 2617
2636static int orinoco_ioctl_getiwrange(struct net_device *dev, struct iw_point *rrq) 2618static int orinoco_ioctl_getname(struct net_device *dev,
2619 struct iw_request_info *info,
2620 char *name,
2621 char *extra)
2637{ 2622{
2638 struct orinoco_private *priv = netdev_priv(dev); 2623 struct orinoco_private *priv = netdev_priv(dev);
2639 int err = 0;
2640 int mode;
2641 struct iw_range range;
2642 int numrates; 2624 int numrates;
2643 int i, k; 2625 int err;
2626
2627 err = orinoco_hw_get_bitratelist(priv, &numrates, NULL, 0);
2628
2629 if (!err && (numrates > 2))
2630 strcpy(name, "IEEE 802.11b");
2631 else
2632 strcpy(name, "IEEE 802.11-DS");
2633
2634 return 0;
2635}
2636
2637static int orinoco_ioctl_setwap(struct net_device *dev,
2638 struct iw_request_info *info,
2639 struct sockaddr *ap_addr,
2640 char *extra)
2641{
2642 struct orinoco_private *priv = netdev_priv(dev);
2643 int err = -EINPROGRESS; /* Call commit handler */
2644 unsigned long flags; 2644 unsigned long flags;
2645 static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2646 static const u8 any_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2645 2647
2646 TRACE_ENTER(dev->name); 2648 if (orinoco_lock(priv, &flags) != 0)
2649 return -EBUSY;
2650
2651 /* Enable automatic roaming - no sanity checks are needed */
2652 if (memcmp(&ap_addr->sa_data, off_addr, ETH_ALEN) == 0 ||
2653 memcmp(&ap_addr->sa_data, any_addr, ETH_ALEN) == 0) {
2654 priv->bssid_fixed = 0;
2655 memset(priv->desired_bssid, 0, ETH_ALEN);
2656
2657 /* "off" means keep existing connection */
2658 if (ap_addr->sa_data[0] == 0) {
2659 __orinoco_hw_set_wap(priv);
2660 err = 0;
2661 }
2662 goto out;
2663 }
2664
2665 if (priv->firmware_type == FIRMWARE_TYPE_AGERE) {
2666 printk(KERN_WARNING "%s: Lucent/Agere firmware doesn't "
2667 "support manual roaming\n",
2668 dev->name);
2669 err = -EOPNOTSUPP;
2670 goto out;
2671 }
2672
2673 if (priv->iw_mode != IW_MODE_INFRA) {
2674 printk(KERN_WARNING "%s: Manual roaming supported only in "
2675 "managed mode\n", dev->name);
2676 err = -EOPNOTSUPP;
2677 goto out;
2678 }
2679
2680 /* Intersil firmware hangs without Desired ESSID */
2681 if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL &&
2682 strlen(priv->desired_essid) == 0) {
2683 printk(KERN_WARNING "%s: Desired ESSID must be set for "
2684 "manual roaming\n", dev->name);
2685 err = -EOPNOTSUPP;
2686 goto out;
2687 }
2688
2689 /* Finally, enable manual roaming */
2690 priv->bssid_fixed = 1;
2691 memcpy(priv->desired_bssid, &ap_addr->sa_data, ETH_ALEN);
2692
2693 out:
2694 orinoco_unlock(priv, &flags);
2695 return err;
2696}
2697
2698static int orinoco_ioctl_getwap(struct net_device *dev,
2699 struct iw_request_info *info,
2700 struct sockaddr *ap_addr,
2701 char *extra)
2702{
2703 struct orinoco_private *priv = netdev_priv(dev);
2704
2705 hermes_t *hw = &priv->hw;
2706 int err = 0;
2707 unsigned long flags;
2708
2709 if (orinoco_lock(priv, &flags) != 0)
2710 return -EBUSY;
2711
2712 ap_addr->sa_family = ARPHRD_ETHER;
2713 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
2714 ETH_ALEN, NULL, ap_addr->sa_data);
2715
2716 orinoco_unlock(priv, &flags);
2717
2718 return err;
2719}
2647 2720
2648 if (!access_ok(VERIFY_WRITE, rrq->pointer, sizeof(range))) 2721static int orinoco_ioctl_setmode(struct net_device *dev,
2649 return -EFAULT; 2722 struct iw_request_info *info,
2723 u32 *mode,
2724 char *extra)
2725{
2726 struct orinoco_private *priv = netdev_priv(dev);
2727 int err = -EINPROGRESS; /* Call commit handler */
2728 unsigned long flags;
2650 2729
2651 rrq->length = sizeof(range); 2730 if (priv->iw_mode == *mode)
2731 return 0;
2652 2732
2653 if (orinoco_lock(priv, &flags) != 0) 2733 if (orinoco_lock(priv, &flags) != 0)
2654 return -EBUSY; 2734 return -EBUSY;
2655 2735
2656 mode = priv->iw_mode; 2736 switch (*mode) {
2737 case IW_MODE_ADHOC:
2738 if (!priv->has_ibss && !priv->has_port3)
2739 err = -EOPNOTSUPP;
2740 break;
2741
2742 case IW_MODE_INFRA:
2743 break;
2744
2745 case IW_MODE_MONITOR:
2746 if (priv->broken_monitor && !force_monitor) {
2747 printk(KERN_WARNING "%s: Monitor mode support is "
2748 "buggy in this firmware, not enabling\n",
2749 dev->name);
2750 err = -EOPNOTSUPP;
2751 }
2752 break;
2753
2754 default:
2755 err = -EOPNOTSUPP;
2756 break;
2757 }
2758
2759 if (err == -EINPROGRESS) {
2760 priv->iw_mode = *mode;
2761 set_port_type(priv);
2762 }
2763
2657 orinoco_unlock(priv, &flags); 2764 orinoco_unlock(priv, &flags);
2658 2765
2659 memset(&range, 0, sizeof(range)); 2766 return err;
2767}
2768
2769static int orinoco_ioctl_getmode(struct net_device *dev,
2770 struct iw_request_info *info,
2771 u32 *mode,
2772 char *extra)
2773{
2774 struct orinoco_private *priv = netdev_priv(dev);
2775
2776 *mode = priv->iw_mode;
2777 return 0;
2778}
2779
2780static int orinoco_ioctl_getiwrange(struct net_device *dev,
2781 struct iw_request_info *info,
2782 struct iw_point *rrq,
2783 char *extra)
2784{
2785 struct orinoco_private *priv = netdev_priv(dev);
2786 int err = 0;
2787 struct iw_range *range = (struct iw_range *) extra;
2788 int numrates;
2789 int i, k;
2790
2791 TRACE_ENTER(dev->name);
2660 2792
2661 /* Much of this shamelessly taken from wvlan_cs.c. No idea 2793 rrq->length = sizeof(struct iw_range);
2662 * what it all means -dgibson */ 2794 memset(range, 0, sizeof(struct iw_range));
2663 range.we_version_compiled = WIRELESS_EXT;
2664 range.we_version_source = 11;
2665 2795
2666 range.min_nwid = range.max_nwid = 0; /* We don't use nwids */ 2796 range->we_version_compiled = WIRELESS_EXT;
2797 range->we_version_source = 14;
2667 2798
2668 /* Set available channels/frequencies */ 2799 /* Set available channels/frequencies */
2669 range.num_channels = NUM_CHANNELS; 2800 range->num_channels = NUM_CHANNELS;
2670 k = 0; 2801 k = 0;
2671 for (i = 0; i < NUM_CHANNELS; i++) { 2802 for (i = 0; i < NUM_CHANNELS; i++) {
2672 if (priv->channel_mask & (1 << i)) { 2803 if (priv->channel_mask & (1 << i)) {
2673 range.freq[k].i = i + 1; 2804 range->freq[k].i = i + 1;
2674 range.freq[k].m = channel_frequency[i] * 100000; 2805 range->freq[k].m = channel_frequency[i] * 100000;
2675 range.freq[k].e = 1; 2806 range->freq[k].e = 1;
2676 k++; 2807 k++;
2677 } 2808 }
2678 2809
2679 if (k >= IW_MAX_FREQUENCIES) 2810 if (k >= IW_MAX_FREQUENCIES)
2680 break; 2811 break;
2681 } 2812 }
2682 range.num_frequency = k; 2813 range->num_frequency = k;
2814 range->sensitivity = 3;
2683 2815
2684 range.sensitivity = 3; 2816 if (priv->has_wep) {
2817 range->max_encoding_tokens = ORINOCO_MAX_KEYS;
2818 range->encoding_size[0] = SMALL_KEY_SIZE;
2819 range->num_encoding_sizes = 1;
2685 2820
2686 if ((mode == IW_MODE_ADHOC) && (priv->spy_number == 0)){ 2821 if (priv->has_big_wep) {
2822 range->encoding_size[1] = LARGE_KEY_SIZE;
2823 range->num_encoding_sizes = 2;
2824 }
2825 }
2826
2827 if ((priv->iw_mode == IW_MODE_ADHOC) && (priv->spy_number == 0)){
2687 /* Quality stats meaningless in ad-hoc mode */ 2828 /* Quality stats meaningless in ad-hoc mode */
2688 range.max_qual.qual = 0;
2689 range.max_qual.level = 0;
2690 range.max_qual.noise = 0;
2691 range.avg_qual.qual = 0;
2692 range.avg_qual.level = 0;
2693 range.avg_qual.noise = 0;
2694 } else { 2829 } else {
2695 range.max_qual.qual = 0x8b - 0x2f; 2830 range->max_qual.qual = 0x8b - 0x2f;
2696 range.max_qual.level = 0x2f - 0x95 - 1; 2831 range->max_qual.level = 0x2f - 0x95 - 1;
2697 range.max_qual.noise = 0x2f - 0x95 - 1; 2832 range->max_qual.noise = 0x2f - 0x95 - 1;
2698 /* Need to get better values */ 2833 /* Need to get better values */
2699 range.avg_qual.qual = 0x24; 2834 range->avg_qual.qual = 0x24;
2700 range.avg_qual.level = 0xC2; 2835 range->avg_qual.level = 0xC2;
2701 range.avg_qual.noise = 0x9E; 2836 range->avg_qual.noise = 0x9E;
2702 } 2837 }
2703 2838
2704 err = orinoco_hw_get_bitratelist(priv, &numrates, 2839 err = orinoco_hw_get_bitratelist(priv, &numrates,
2705 range.bitrate, IW_MAX_BITRATES); 2840 range->bitrate, IW_MAX_BITRATES);
2706 if (err) 2841 if (err)
2707 return err; 2842 return err;
2708 range.num_bitrates = numrates; 2843 range->num_bitrates = numrates;
2709 2844
2710 /* Set an indication of the max TCP throughput in bit/s that we can 2845 /* Set an indication of the max TCP throughput in bit/s that we can
2711 * expect using this interface. May be use for QoS stuff... 2846 * expect using this interface. May be use for QoS stuff...
2712 * Jean II */ 2847 * Jean II */
2713 if(numrates > 2) 2848 if (numrates > 2)
2714 range.throughput = 5 * 1000 * 1000; /* ~5 Mb/s */ 2849 range->throughput = 5 * 1000 * 1000; /* ~5 Mb/s */
2715 else 2850 else
2716 range.throughput = 1.5 * 1000 * 1000; /* ~1.5 Mb/s */ 2851 range->throughput = 1.5 * 1000 * 1000; /* ~1.5 Mb/s */
2717 2852
2718 range.min_rts = 0; 2853 range->min_rts = 0;
2719 range.max_rts = 2347; 2854 range->max_rts = 2347;
2720 range.min_frag = 256; 2855 range->min_frag = 256;
2721 range.max_frag = 2346; 2856 range->max_frag = 2346;
2722 2857
2723 if (orinoco_lock(priv, &flags) != 0) 2858 range->min_pmp = 0;
2724 return -EBUSY; 2859 range->max_pmp = 65535000;
2725 if (priv->has_wep) { 2860 range->min_pmt = 0;
2726 range.max_encoding_tokens = ORINOCO_MAX_KEYS; 2861 range->max_pmt = 65535 * 1000; /* ??? */
2727 2862 range->pmp_flags = IW_POWER_PERIOD;
2728 range.encoding_size[0] = SMALL_KEY_SIZE; 2863 range->pmt_flags = IW_POWER_TIMEOUT;
2729 range.num_encoding_sizes = 1; 2864 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
2730 2865
2731 if (priv->has_big_wep) { 2866 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
2732 range.encoding_size[1] = LARGE_KEY_SIZE; 2867 range->retry_flags = IW_RETRY_LIMIT;
2733 range.num_encoding_sizes = 2; 2868 range->r_time_flags = IW_RETRY_LIFETIME;
2734 } 2869 range->min_retry = 0;
2735 } else { 2870 range->max_retry = 65535; /* ??? */
2736 range.num_encoding_sizes = 0; 2871 range->min_r_time = 0;
2737 range.max_encoding_tokens = 0; 2872 range->max_r_time = 65535 * 1000; /* ??? */
2738 }
2739 orinoco_unlock(priv, &flags);
2740
2741 range.min_pmp = 0;
2742 range.max_pmp = 65535000;
2743 range.min_pmt = 0;
2744 range.max_pmt = 65535 * 1000; /* ??? */
2745 range.pmp_flags = IW_POWER_PERIOD;
2746 range.pmt_flags = IW_POWER_TIMEOUT;
2747 range.pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
2748
2749 range.num_txpower = 1;
2750 range.txpower[0] = 15; /* 15dBm */
2751 range.txpower_capa = IW_TXPOW_DBM;
2752
2753 range.retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
2754 range.retry_flags = IW_RETRY_LIMIT;
2755 range.r_time_flags = IW_RETRY_LIFETIME;
2756 range.min_retry = 0;
2757 range.max_retry = 65535; /* ??? */
2758 range.min_r_time = 0;
2759 range.max_r_time = 65535 * 1000; /* ??? */
2760
2761 if (copy_to_user(rrq->pointer, &range, sizeof(range)))
2762 return -EFAULT;
2763 2873
2764 TRACE_EXIT(dev->name); 2874 TRACE_EXIT(dev->name);
2765 2875
2766 return 0; 2876 return 0;
2767} 2877}
2768 2878
2769static int orinoco_ioctl_setiwencode(struct net_device *dev, struct iw_point *erq) 2879static int orinoco_ioctl_setiwencode(struct net_device *dev,
2880 struct iw_request_info *info,
2881 struct iw_point *erq,
2882 char *keybuf)
2770{ 2883{
2771 struct orinoco_private *priv = netdev_priv(dev); 2884 struct orinoco_private *priv = netdev_priv(dev);
2772 int index = (erq->flags & IW_ENCODE_INDEX) - 1; 2885 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
@@ -2774,8 +2887,7 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev, struct iw_point *er
2774 int enable = priv->wep_on; 2887 int enable = priv->wep_on;
2775 int restricted = priv->wep_restrict; 2888 int restricted = priv->wep_restrict;
2776 u16 xlen = 0; 2889 u16 xlen = 0;
2777 int err = 0; 2890 int err = -EINPROGRESS; /* Call commit handler */
2778 char keybuf[ORINOCO_MAX_KEY_SIZE];
2779 unsigned long flags; 2891 unsigned long flags;
2780 2892
2781 if (! priv->has_wep) 2893 if (! priv->has_wep)
@@ -2788,9 +2900,6 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev, struct iw_point *er
2788 2900
2789 if ( (erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep ) 2901 if ( (erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep )
2790 return -E2BIG; 2902 return -E2BIG;
2791
2792 if (copy_from_user(keybuf, erq->pointer, erq->length))
2793 return -EFAULT;
2794 } 2903 }
2795 2904
2796 if (orinoco_lock(priv, &flags) != 0) 2905 if (orinoco_lock(priv, &flags) != 0)
@@ -2864,12 +2973,14 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev, struct iw_point *er
2864 return err; 2973 return err;
2865} 2974}
2866 2975
2867static int orinoco_ioctl_getiwencode(struct net_device *dev, struct iw_point *erq) 2976static int orinoco_ioctl_getiwencode(struct net_device *dev,
2977 struct iw_request_info *info,
2978 struct iw_point *erq,
2979 char *keybuf)
2868{ 2980{
2869 struct orinoco_private *priv = netdev_priv(dev); 2981 struct orinoco_private *priv = netdev_priv(dev);
2870 int index = (erq->flags & IW_ENCODE_INDEX) - 1; 2982 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
2871 u16 xlen = 0; 2983 u16 xlen = 0;
2872 char keybuf[ORINOCO_MAX_KEY_SIZE];
2873 unsigned long flags; 2984 unsigned long flags;
2874 2985
2875 if (! priv->has_wep) 2986 if (! priv->has_wep)
@@ -2898,51 +3009,47 @@ static int orinoco_ioctl_getiwencode(struct net_device *dev, struct iw_point *er
2898 memcpy(keybuf, priv->keys[index].data, ORINOCO_MAX_KEY_SIZE); 3009 memcpy(keybuf, priv->keys[index].data, ORINOCO_MAX_KEY_SIZE);
2899 3010
2900 orinoco_unlock(priv, &flags); 3011 orinoco_unlock(priv, &flags);
2901
2902 if (erq->pointer) {
2903 if (copy_to_user(erq->pointer, keybuf, xlen))
2904 return -EFAULT;
2905 }
2906
2907 return 0; 3012 return 0;
2908} 3013}
2909 3014
2910static int orinoco_ioctl_setessid(struct net_device *dev, struct iw_point *erq) 3015static int orinoco_ioctl_setessid(struct net_device *dev,
3016 struct iw_request_info *info,
3017 struct iw_point *erq,
3018 char *essidbuf)
2911{ 3019{
2912 struct orinoco_private *priv = netdev_priv(dev); 3020 struct orinoco_private *priv = netdev_priv(dev);
2913 char essidbuf[IW_ESSID_MAX_SIZE+1];
2914 unsigned long flags; 3021 unsigned long flags;
2915 3022
2916 /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it 3023 /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it
2917 * anyway... - Jean II */ 3024 * anyway... - Jean II */
2918 3025
2919 memset(&essidbuf, 0, sizeof(essidbuf)); 3026 /* Hum... Should not use Wireless Extension constant (may change),
2920 3027 * should use our own... - Jean II */
2921 if (erq->flags) { 3028 if (erq->length > IW_ESSID_MAX_SIZE)
2922 /* iwconfig includes the NUL in the specified length */ 3029 return -E2BIG;
2923 if (erq->length > IW_ESSID_MAX_SIZE+1)
2924 return -E2BIG;
2925
2926 if (copy_from_user(&essidbuf, erq->pointer, erq->length))
2927 return -EFAULT;
2928
2929 essidbuf[IW_ESSID_MAX_SIZE] = '\0';
2930 }
2931 3030
2932 if (orinoco_lock(priv, &flags) != 0) 3031 if (orinoco_lock(priv, &flags) != 0)
2933 return -EBUSY; 3032 return -EBUSY;
2934 3033
2935 memcpy(priv->desired_essid, essidbuf, sizeof(priv->desired_essid)); 3034 /* NULL the string (for NULL termination & ESSID = ANY) - Jean II */
3035 memset(priv->desired_essid, 0, sizeof(priv->desired_essid));
3036
3037 /* If not ANY, get the new ESSID */
3038 if (erq->flags) {
3039 memcpy(priv->desired_essid, essidbuf, erq->length);
3040 }
2936 3041
2937 orinoco_unlock(priv, &flags); 3042 orinoco_unlock(priv, &flags);
2938 3043
2939 return 0; 3044 return -EINPROGRESS; /* Call commit handler */
2940} 3045}
2941 3046
2942static int orinoco_ioctl_getessid(struct net_device *dev, struct iw_point *erq) 3047static int orinoco_ioctl_getessid(struct net_device *dev,
3048 struct iw_request_info *info,
3049 struct iw_point *erq,
3050 char *essidbuf)
2943{ 3051{
2944 struct orinoco_private *priv = netdev_priv(dev); 3052 struct orinoco_private *priv = netdev_priv(dev);
2945 char essidbuf[IW_ESSID_MAX_SIZE+1];
2946 int active; 3053 int active;
2947 int err = 0; 3054 int err = 0;
2948 unsigned long flags; 3055 unsigned long flags;
@@ -2956,51 +3063,46 @@ static int orinoco_ioctl_getessid(struct net_device *dev, struct iw_point *erq)
2956 } else { 3063 } else {
2957 if (orinoco_lock(priv, &flags) != 0) 3064 if (orinoco_lock(priv, &flags) != 0)
2958 return -EBUSY; 3065 return -EBUSY;
2959 memcpy(essidbuf, priv->desired_essid, sizeof(essidbuf)); 3066 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE + 1);
2960 orinoco_unlock(priv, &flags); 3067 orinoco_unlock(priv, &flags);
2961 } 3068 }
2962 3069
2963 erq->flags = 1; 3070 erq->flags = 1;
2964 erq->length = strlen(essidbuf) + 1; 3071 erq->length = strlen(essidbuf) + 1;
2965 if (erq->pointer)
2966 if (copy_to_user(erq->pointer, essidbuf, erq->length))
2967 return -EFAULT;
2968 3072
2969 TRACE_EXIT(dev->name); 3073 TRACE_EXIT(dev->name);
2970 3074
2971 return 0; 3075 return 0;
2972} 3076}
2973 3077
2974static int orinoco_ioctl_setnick(struct net_device *dev, struct iw_point *nrq) 3078static int orinoco_ioctl_setnick(struct net_device *dev,
3079 struct iw_request_info *info,
3080 struct iw_point *nrq,
3081 char *nickbuf)
2975{ 3082{
2976 struct orinoco_private *priv = netdev_priv(dev); 3083 struct orinoco_private *priv = netdev_priv(dev);
2977 char nickbuf[IW_ESSID_MAX_SIZE+1];
2978 unsigned long flags; 3084 unsigned long flags;
2979 3085
2980 if (nrq->length > IW_ESSID_MAX_SIZE) 3086 if (nrq->length > IW_ESSID_MAX_SIZE)
2981 return -E2BIG; 3087 return -E2BIG;
2982 3088
2983 memset(nickbuf, 0, sizeof(nickbuf));
2984
2985 if (copy_from_user(nickbuf, nrq->pointer, nrq->length))
2986 return -EFAULT;
2987
2988 nickbuf[nrq->length] = '\0';
2989
2990 if (orinoco_lock(priv, &flags) != 0) 3089 if (orinoco_lock(priv, &flags) != 0)
2991 return -EBUSY; 3090 return -EBUSY;
2992 3091
2993 memcpy(priv->nick, nickbuf, sizeof(priv->nick)); 3092 memset(priv->nick, 0, sizeof(priv->nick));
3093 memcpy(priv->nick, nickbuf, nrq->length);
2994 3094
2995 orinoco_unlock(priv, &flags); 3095 orinoco_unlock(priv, &flags);
2996 3096
2997 return 0; 3097 return -EINPROGRESS; /* Call commit handler */
2998} 3098}
2999 3099
3000static int orinoco_ioctl_getnick(struct net_device *dev, struct iw_point *nrq) 3100static int orinoco_ioctl_getnick(struct net_device *dev,
3101 struct iw_request_info *info,
3102 struct iw_point *nrq,
3103 char *nickbuf)
3001{ 3104{
3002 struct orinoco_private *priv = netdev_priv(dev); 3105 struct orinoco_private *priv = netdev_priv(dev);
3003 char nickbuf[IW_ESSID_MAX_SIZE+1];
3004 unsigned long flags; 3106 unsigned long flags;
3005 3107
3006 if (orinoco_lock(priv, &flags) != 0) 3108 if (orinoco_lock(priv, &flags) != 0)
@@ -3011,23 +3113,22 @@ static int orinoco_ioctl_getnick(struct net_device *dev, struct iw_point *nrq)
3011 3113
3012 nrq->length = strlen(nickbuf)+1; 3114 nrq->length = strlen(nickbuf)+1;
3013 3115
3014 if (copy_to_user(nrq->pointer, nickbuf, sizeof(nickbuf)))
3015 return -EFAULT;
3016
3017 return 0; 3116 return 0;
3018} 3117}
3019 3118
3020static int orinoco_ioctl_setfreq(struct net_device *dev, struct iw_freq *frq) 3119static int orinoco_ioctl_setfreq(struct net_device *dev,
3120 struct iw_request_info *info,
3121 struct iw_freq *frq,
3122 char *extra)
3021{ 3123{
3022 struct orinoco_private *priv = netdev_priv(dev); 3124 struct orinoco_private *priv = netdev_priv(dev);
3023 int chan = -1; 3125 int chan = -1;
3024 unsigned long flags; 3126 unsigned long flags;
3127 int err = -EINPROGRESS; /* Call commit handler */
3025 3128
3026 /* We can only use this in Ad-Hoc demo mode to set the operating 3129 /* In infrastructure mode the AP sets the channel */
3027 * frequency, or in IBSS mode to set the frequency where the IBSS 3130 if (priv->iw_mode == IW_MODE_INFRA)
3028 * will be created - Jean II */ 3131 return -EBUSY;
3029 if (priv->iw_mode != IW_MODE_ADHOC)
3030 return -EOPNOTSUPP;
3031 3132
3032 if ( (frq->e == 0) && (frq->m <= 1000) ) { 3133 if ( (frq->e == 0) && (frq->m <= 1000) ) {
3033 /* Setting by channel number */ 3134 /* Setting by channel number */
@@ -3051,13 +3152,44 @@ static int orinoco_ioctl_setfreq(struct net_device *dev, struct iw_freq *frq)
3051 3152
3052 if (orinoco_lock(priv, &flags) != 0) 3153 if (orinoco_lock(priv, &flags) != 0)
3053 return -EBUSY; 3154 return -EBUSY;
3155
3054 priv->channel = chan; 3156 priv->channel = chan;
3157 if (priv->iw_mode == IW_MODE_MONITOR) {
3158 /* Fast channel change - no commit if successful */
3159 hermes_t *hw = &priv->hw;
3160 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
3161 HERMES_TEST_SET_CHANNEL,
3162 chan, NULL);
3163 }
3055 orinoco_unlock(priv, &flags); 3164 orinoco_unlock(priv, &flags);
3056 3165
3166 return err;
3167}
3168
3169static int orinoco_ioctl_getfreq(struct net_device *dev,
3170 struct iw_request_info *info,
3171 struct iw_freq *frq,
3172 char *extra)
3173{
3174 struct orinoco_private *priv = netdev_priv(dev);
3175 int tmp;
3176
3177 /* Locking done in there */
3178 tmp = orinoco_hw_get_freq(priv);
3179 if (tmp < 0) {
3180 return tmp;
3181 }
3182
3183 frq->m = tmp;
3184 frq->e = 1;
3185
3057 return 0; 3186 return 0;
3058} 3187}
3059 3188
3060static int orinoco_ioctl_getsens(struct net_device *dev, struct iw_param *srq) 3189static int orinoco_ioctl_getsens(struct net_device *dev,
3190 struct iw_request_info *info,
3191 struct iw_param *srq,
3192 char *extra)
3061{ 3193{
3062 struct orinoco_private *priv = netdev_priv(dev); 3194 struct orinoco_private *priv = netdev_priv(dev);
3063 hermes_t *hw = &priv->hw; 3195 hermes_t *hw = &priv->hw;
@@ -3083,7 +3215,10 @@ static int orinoco_ioctl_getsens(struct net_device *dev, struct iw_param *srq)
3083 return 0; 3215 return 0;
3084} 3216}
3085 3217
3086static int orinoco_ioctl_setsens(struct net_device *dev, struct iw_param *srq) 3218static int orinoco_ioctl_setsens(struct net_device *dev,
3219 struct iw_request_info *info,
3220 struct iw_param *srq,
3221 char *extra)
3087{ 3222{
3088 struct orinoco_private *priv = netdev_priv(dev); 3223 struct orinoco_private *priv = netdev_priv(dev);
3089 int val = srq->value; 3224 int val = srq->value;
@@ -3100,10 +3235,13 @@ static int orinoco_ioctl_setsens(struct net_device *dev, struct iw_param *srq)
3100 priv->ap_density = val; 3235 priv->ap_density = val;
3101 orinoco_unlock(priv, &flags); 3236 orinoco_unlock(priv, &flags);
3102 3237
3103 return 0; 3238 return -EINPROGRESS; /* Call commit handler */
3104} 3239}
3105 3240
3106static int orinoco_ioctl_setrts(struct net_device *dev, struct iw_param *rrq) 3241static int orinoco_ioctl_setrts(struct net_device *dev,
3242 struct iw_request_info *info,
3243 struct iw_param *rrq,
3244 char *extra)
3107{ 3245{
3108 struct orinoco_private *priv = netdev_priv(dev); 3246 struct orinoco_private *priv = netdev_priv(dev);
3109 int val = rrq->value; 3247 int val = rrq->value;
@@ -3121,13 +3259,30 @@ static int orinoco_ioctl_setrts(struct net_device *dev, struct iw_param *rrq)
3121 priv->rts_thresh = val; 3259 priv->rts_thresh = val;
3122 orinoco_unlock(priv, &flags); 3260 orinoco_unlock(priv, &flags);
3123 3261
3262 return -EINPROGRESS; /* Call commit handler */
3263}
3264
3265static int orinoco_ioctl_getrts(struct net_device *dev,
3266 struct iw_request_info *info,
3267 struct iw_param *rrq,
3268 char *extra)
3269{
3270 struct orinoco_private *priv = netdev_priv(dev);
3271
3272 rrq->value = priv->rts_thresh;
3273 rrq->disabled = (rrq->value == 2347);
3274 rrq->fixed = 1;
3275
3124 return 0; 3276 return 0;
3125} 3277}
3126 3278
3127static int orinoco_ioctl_setfrag(struct net_device *dev, struct iw_param *frq) 3279static int orinoco_ioctl_setfrag(struct net_device *dev,
3280 struct iw_request_info *info,
3281 struct iw_param *frq,
3282 char *extra)
3128{ 3283{
3129 struct orinoco_private *priv = netdev_priv(dev); 3284 struct orinoco_private *priv = netdev_priv(dev);
3130 int err = 0; 3285 int err = -EINPROGRESS; /* Call commit handler */
3131 unsigned long flags; 3286 unsigned long flags;
3132 3287
3133 if (orinoco_lock(priv, &flags) != 0) 3288 if (orinoco_lock(priv, &flags) != 0)
@@ -3159,11 +3314,14 @@ static int orinoco_ioctl_setfrag(struct net_device *dev, struct iw_param *frq)
3159 return err; 3314 return err;
3160} 3315}
3161 3316
3162static int orinoco_ioctl_getfrag(struct net_device *dev, struct iw_param *frq) 3317static int orinoco_ioctl_getfrag(struct net_device *dev,
3318 struct iw_request_info *info,
3319 struct iw_param *frq,
3320 char *extra)
3163{ 3321{
3164 struct orinoco_private *priv = netdev_priv(dev); 3322 struct orinoco_private *priv = netdev_priv(dev);
3165 hermes_t *hw = &priv->hw; 3323 hermes_t *hw = &priv->hw;
3166 int err = 0; 3324 int err;
3167 u16 val; 3325 u16 val;
3168 unsigned long flags; 3326 unsigned long flags;
3169 3327
@@ -3196,10 +3354,12 @@ static int orinoco_ioctl_getfrag(struct net_device *dev, struct iw_param *frq)
3196 return err; 3354 return err;
3197} 3355}
3198 3356
3199static int orinoco_ioctl_setrate(struct net_device *dev, struct iw_param *rrq) 3357static int orinoco_ioctl_setrate(struct net_device *dev,
3358 struct iw_request_info *info,
3359 struct iw_param *rrq,
3360 char *extra)
3200{ 3361{
3201 struct orinoco_private *priv = netdev_priv(dev); 3362 struct orinoco_private *priv = netdev_priv(dev);
3202 int err = 0;
3203 int ratemode = -1; 3363 int ratemode = -1;
3204 int bitrate; /* 100s of kilobits */ 3364 int bitrate; /* 100s of kilobits */
3205 int i; 3365 int i;
@@ -3235,10 +3395,13 @@ static int orinoco_ioctl_setrate(struct net_device *dev, struct iw_param *rrq)
3235 priv->bitratemode = ratemode; 3395 priv->bitratemode = ratemode;
3236 orinoco_unlock(priv, &flags); 3396 orinoco_unlock(priv, &flags);
3237 3397
3238 return err; 3398 return -EINPROGRESS;
3239} 3399}
3240 3400
3241static int orinoco_ioctl_getrate(struct net_device *dev, struct iw_param *rrq) 3401static int orinoco_ioctl_getrate(struct net_device *dev,
3402 struct iw_request_info *info,
3403 struct iw_param *rrq,
3404 char *extra)
3242{ 3405{
3243 struct orinoco_private *priv = netdev_priv(dev); 3406 struct orinoco_private *priv = netdev_priv(dev);
3244 hermes_t *hw = &priv->hw; 3407 hermes_t *hw = &priv->hw;
@@ -3303,10 +3466,13 @@ static int orinoco_ioctl_getrate(struct net_device *dev, struct iw_param *rrq)
3303 return err; 3466 return err;
3304} 3467}
3305 3468
3306static int orinoco_ioctl_setpower(struct net_device *dev, struct iw_param *prq) 3469static int orinoco_ioctl_setpower(struct net_device *dev,
3470 struct iw_request_info *info,
3471 struct iw_param *prq,
3472 char *extra)
3307{ 3473{
3308 struct orinoco_private *priv = netdev_priv(dev); 3474 struct orinoco_private *priv = netdev_priv(dev);
3309 int err = 0; 3475 int err = -EINPROGRESS; /* Call commit handler */
3310 unsigned long flags; 3476 unsigned long flags;
3311 3477
3312 if (orinoco_lock(priv, &flags) != 0) 3478 if (orinoco_lock(priv, &flags) != 0)
@@ -3355,7 +3521,10 @@ static int orinoco_ioctl_setpower(struct net_device *dev, struct iw_param *prq)
3355 return err; 3521 return err;
3356} 3522}
3357 3523
3358static int orinoco_ioctl_getpower(struct net_device *dev, struct iw_param *prq) 3524static int orinoco_ioctl_getpower(struct net_device *dev,
3525 struct iw_request_info *info,
3526 struct iw_param *prq,
3527 char *extra)
3359{ 3528{
3360 struct orinoco_private *priv = netdev_priv(dev); 3529 struct orinoco_private *priv = netdev_priv(dev);
3361 hermes_t *hw = &priv->hw; 3530 hermes_t *hw = &priv->hw;
@@ -3403,7 +3572,10 @@ static int orinoco_ioctl_getpower(struct net_device *dev, struct iw_param *prq)
3403 return err; 3572 return err;
3404} 3573}
3405 3574
3406static int orinoco_ioctl_getretry(struct net_device *dev, struct iw_param *rrq) 3575static int orinoco_ioctl_getretry(struct net_device *dev,
3576 struct iw_request_info *info,
3577 struct iw_param *rrq,
3578 char *extra)
3407{ 3579{
3408 struct orinoco_private *priv = netdev_priv(dev); 3580 struct orinoco_private *priv = netdev_priv(dev);
3409 hermes_t *hw = &priv->hw; 3581 hermes_t *hw = &priv->hw;
@@ -3454,10 +3626,38 @@ static int orinoco_ioctl_getretry(struct net_device *dev, struct iw_param *rrq)
3454 return err; 3626 return err;
3455} 3627}
3456 3628
3457static int orinoco_ioctl_setibssport(struct net_device *dev, struct iwreq *wrq) 3629static int orinoco_ioctl_reset(struct net_device *dev,
3630 struct iw_request_info *info,
3631 void *wrqu,
3632 char *extra)
3458{ 3633{
3459 struct orinoco_private *priv = netdev_priv(dev); 3634 struct orinoco_private *priv = netdev_priv(dev);
3460 int val = *( (int *) wrq->u.name ); 3635
3636 if (! capable(CAP_NET_ADMIN))
3637 return -EPERM;
3638
3639 if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) {
3640 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
3641
3642 /* Firmware reset */
3643 orinoco_reset(dev);
3644 } else {
3645 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
3646
3647 schedule_work(&priv->reset_work);
3648 }
3649
3650 return 0;
3651}
3652
3653static int orinoco_ioctl_setibssport(struct net_device *dev,
3654 struct iw_request_info *info,
3655 void *wrqu,
3656 char *extra)
3657
3658{
3659 struct orinoco_private *priv = netdev_priv(dev);
3660 int val = *( (int *) extra );
3461 unsigned long flags; 3661 unsigned long flags;
3462 3662
3463 if (orinoco_lock(priv, &flags) != 0) 3663 if (orinoco_lock(priv, &flags) != 0)
@@ -3469,28 +3669,28 @@ static int orinoco_ioctl_setibssport(struct net_device *dev, struct iwreq *wrq)
3469 set_port_type(priv); 3669 set_port_type(priv);
3470 3670
3471 orinoco_unlock(priv, &flags); 3671 orinoco_unlock(priv, &flags);
3472 return 0; 3672 return -EINPROGRESS; /* Call commit handler */
3473} 3673}
3474 3674
3475static int orinoco_ioctl_getibssport(struct net_device *dev, struct iwreq *wrq) 3675static int orinoco_ioctl_getibssport(struct net_device *dev,
3676 struct iw_request_info *info,
3677 void *wrqu,
3678 char *extra)
3476{ 3679{
3477 struct orinoco_private *priv = netdev_priv(dev); 3680 struct orinoco_private *priv = netdev_priv(dev);
3478 int *val = (int *)wrq->u.name; 3681 int *val = (int *) extra;
3479 unsigned long flags;
3480
3481 if (orinoco_lock(priv, &flags) != 0)
3482 return -EBUSY;
3483 3682
3484 *val = priv->ibss_port; 3683 *val = priv->ibss_port;
3485 orinoco_unlock(priv, &flags);
3486
3487 return 0; 3684 return 0;
3488} 3685}
3489 3686
3490static int orinoco_ioctl_setport3(struct net_device *dev, struct iwreq *wrq) 3687static int orinoco_ioctl_setport3(struct net_device *dev,
3688 struct iw_request_info *info,
3689 void *wrqu,
3690 char *extra)
3491{ 3691{
3492 struct orinoco_private *priv = netdev_priv(dev); 3692 struct orinoco_private *priv = netdev_priv(dev);
3493 int val = *( (int *) wrq->u.name ); 3693 int val = *( (int *) extra );
3494 int err = 0; 3694 int err = 0;
3495 unsigned long flags; 3695 unsigned long flags;
3496 3696
@@ -3519,51 +3719,131 @@ static int orinoco_ioctl_setport3(struct net_device *dev, struct iwreq *wrq)
3519 err = -EINVAL; 3719 err = -EINVAL;
3520 } 3720 }
3521 3721
3522 if (! err) 3722 if (! err) {
3523 /* Actually update the mode we are using */ 3723 /* Actually update the mode we are using */
3524 set_port_type(priv); 3724 set_port_type(priv);
3725 err = -EINPROGRESS;
3726 }
3525 3727
3526 orinoco_unlock(priv, &flags); 3728 orinoco_unlock(priv, &flags);
3527 3729
3528 return err; 3730 return err;
3529} 3731}
3530 3732
3531static int orinoco_ioctl_getport3(struct net_device *dev, struct iwreq *wrq) 3733static int orinoco_ioctl_getport3(struct net_device *dev,
3734 struct iw_request_info *info,
3735 void *wrqu,
3736 char *extra)
3737{
3738 struct orinoco_private *priv = netdev_priv(dev);
3739 int *val = (int *) extra;
3740
3741 *val = priv->prefer_port3;
3742 return 0;
3743}
3744
3745static int orinoco_ioctl_setpreamble(struct net_device *dev,
3746 struct iw_request_info *info,
3747 void *wrqu,
3748 char *extra)
3532{ 3749{
3533 struct orinoco_private *priv = netdev_priv(dev); 3750 struct orinoco_private *priv = netdev_priv(dev);
3534 int *val = (int *)wrq->u.name;
3535 unsigned long flags; 3751 unsigned long flags;
3752 int val;
3753
3754 if (! priv->has_preamble)
3755 return -EOPNOTSUPP;
3756
3757 /* 802.11b has recently defined some short preamble.
3758 * Basically, the Phy header has been reduced in size.
3759 * This increase performance, especially at high rates
3760 * (the preamble is transmitted at 1Mb/s), unfortunately
3761 * this give compatibility troubles... - Jean II */
3762 val = *( (int *) extra );
3536 3763
3537 if (orinoco_lock(priv, &flags) != 0) 3764 if (orinoco_lock(priv, &flags) != 0)
3538 return -EBUSY; 3765 return -EBUSY;
3539 3766
3540 *val = priv->prefer_port3; 3767 if (val)
3768 priv->preamble = 1;
3769 else
3770 priv->preamble = 0;
3771
3541 orinoco_unlock(priv, &flags); 3772 orinoco_unlock(priv, &flags);
3773
3774 return -EINPROGRESS; /* Call commit handler */
3775}
3776
3777static int orinoco_ioctl_getpreamble(struct net_device *dev,
3778 struct iw_request_info *info,
3779 void *wrqu,
3780 char *extra)
3781{
3782 struct orinoco_private *priv = netdev_priv(dev);
3783 int *val = (int *) extra;
3784
3785 if (! priv->has_preamble)
3786 return -EOPNOTSUPP;
3787
3788 *val = priv->preamble;
3542 return 0; 3789 return 0;
3543} 3790}
3544 3791
3792/* ioctl interface to hermes_read_ltv()
3793 * To use with iwpriv, pass the RID as the token argument, e.g.
3794 * iwpriv get_rid [0xfc00]
3795 * At least Wireless Tools 25 is required to use iwpriv.
3796 * For Wireless Tools 25 and 26 append "dummy" are the end. */
3797static int orinoco_ioctl_getrid(struct net_device *dev,
3798 struct iw_request_info *info,
3799 struct iw_point *data,
3800 char *extra)
3801{
3802 struct orinoco_private *priv = netdev_priv(dev);
3803 hermes_t *hw = &priv->hw;
3804 int rid = data->flags;
3805 u16 length;
3806 int err;
3807 unsigned long flags;
3808
3809 /* It's a "get" function, but we don't want users to access the
3810 * WEP key and other raw firmware data */
3811 if (! capable(CAP_NET_ADMIN))
3812 return -EPERM;
3813
3814 if (rid < 0xfc00 || rid > 0xffff)
3815 return -EINVAL;
3816
3817 if (orinoco_lock(priv, &flags) != 0)
3818 return -EBUSY;
3819
3820 err = hermes_read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
3821 extra);
3822 if (err)
3823 goto out;
3824
3825 data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length),
3826 MAX_RID_LEN);
3827
3828 out:
3829 orinoco_unlock(priv, &flags);
3830 return err;
3831}
3832
3545/* Spy is used for link quality/strength measurements in Ad-Hoc mode 3833/* Spy is used for link quality/strength measurements in Ad-Hoc mode
3546 * Jean II */ 3834 * Jean II */
3547static int orinoco_ioctl_setspy(struct net_device *dev, struct iw_point *srq) 3835static int orinoco_ioctl_setspy(struct net_device *dev,
3836 struct iw_request_info *info,
3837 struct iw_point *srq,
3838 char *extra)
3839
3548{ 3840{
3549 struct orinoco_private *priv = netdev_priv(dev); 3841 struct orinoco_private *priv = netdev_priv(dev);
3550 struct sockaddr address[IW_MAX_SPY]; 3842 struct sockaddr *address = (struct sockaddr *) extra;
3551 int number = srq->length; 3843 int number = srq->length;
3552 int i; 3844 int i;
3553 int err = 0;
3554 unsigned long flags; 3845 unsigned long flags;
3555 3846
3556 /* Check the number of addresses */
3557 if (number > IW_MAX_SPY)
3558 return -E2BIG;
3559
3560 /* Get the data in the driver */
3561 if (srq->pointer) {
3562 if (copy_from_user(address, srq->pointer,
3563 sizeof(struct sockaddr) * number))
3564 return -EFAULT;
3565 }
3566
3567 /* Make sure nobody mess with the structure while we do */ 3847 /* Make sure nobody mess with the structure while we do */
3568 if (orinoco_lock(priv, &flags) != 0) 3848 if (orinoco_lock(priv, &flags) != 0)
3569 return -EBUSY; 3849 return -EBUSY;
@@ -3587,14 +3867,17 @@ static int orinoco_ioctl_setspy(struct net_device *dev, struct iw_point *srq)
3587 /* Now, let the others play */ 3867 /* Now, let the others play */
3588 orinoco_unlock(priv, &flags); 3868 orinoco_unlock(priv, &flags);
3589 3869
3590 return err; 3870 /* Do NOT call commit handler */
3871 return 0;
3591} 3872}
3592 3873
3593static int orinoco_ioctl_getspy(struct net_device *dev, struct iw_point *srq) 3874static int orinoco_ioctl_getspy(struct net_device *dev,
3875 struct iw_request_info *info,
3876 struct iw_point *srq,
3877 char *extra)
3594{ 3878{
3595 struct orinoco_private *priv = netdev_priv(dev); 3879 struct orinoco_private *priv = netdev_priv(dev);
3596 struct sockaddr address[IW_MAX_SPY]; 3880 struct sockaddr *address = (struct sockaddr *) extra;
3597 struct iw_quality spy_stat[IW_MAX_SPY];
3598 int number; 3881 int number;
3599 int i; 3882 int i;
3600 unsigned long flags; 3883 unsigned long flags;
@@ -3603,7 +3886,12 @@ static int orinoco_ioctl_getspy(struct net_device *dev, struct iw_point *srq)
3603 return -EBUSY; 3886 return -EBUSY;
3604 3887
3605 number = priv->spy_number; 3888 number = priv->spy_number;
3606 if ((number > 0) && (srq->pointer)) { 3889 /* Create address struct */
3890 for (i = 0; i < number; i++) {
3891 memcpy(address[i].sa_data, priv->spy_address[i], ETH_ALEN);
3892 address[i].sa_family = AF_UNIX;
3893 }
3894 if (number > 0) {
3607 /* Create address struct */ 3895 /* Create address struct */
3608 for (i = 0; i < number; i++) { 3896 for (i = 0; i < number; i++) {
3609 memcpy(address[i].sa_data, priv->spy_address[i], 3897 memcpy(address[i].sa_data, priv->spy_address[i],
@@ -3614,344 +3902,503 @@ static int orinoco_ioctl_getspy(struct net_device *dev, struct iw_point *srq)
3614 /* In theory, we should disable irqs while copying the stats 3902 /* In theory, we should disable irqs while copying the stats
3615 * because the rx path might update it in the middle... 3903 * because the rx path might update it in the middle...
3616 * Bah, who care ? - Jean II */ 3904 * Bah, who care ? - Jean II */
3617 memcpy(&spy_stat, priv->spy_stat, 3905 memcpy(extra + (sizeof(struct sockaddr) * number),
3618 sizeof(struct iw_quality) * IW_MAX_SPY); 3906 priv->spy_stat, sizeof(struct iw_quality) * number);
3619 for (i=0; i < number; i++)
3620 priv->spy_stat[i].updated = 0;
3621 } 3907 }
3908 /* Reset updated flags. */
3909 for (i = 0; i < number; i++)
3910 priv->spy_stat[i].updated = 0;
3622 3911
3623 orinoco_unlock(priv, &flags); 3912 orinoco_unlock(priv, &flags);
3624 3913
3625 /* Push stuff to user space */
3626 srq->length = number; 3914 srq->length = number;
3627 if(copy_to_user(srq->pointer, address,
3628 sizeof(struct sockaddr) * number))
3629 return -EFAULT;
3630 if(copy_to_user(srq->pointer + (sizeof(struct sockaddr)*number),
3631 &spy_stat, sizeof(struct iw_quality) * number))
3632 return -EFAULT;
3633 3915
3634 return 0; 3916 return 0;
3635} 3917}
3636 3918
3637static int 3919/* Trigger a scan (look for other cells in the vicinity */
3638orinoco_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 3920static int orinoco_ioctl_setscan(struct net_device *dev,
3921 struct iw_request_info *info,
3922 struct iw_param *srq,
3923 char *extra)
3639{ 3924{
3640 struct orinoco_private *priv = netdev_priv(dev); 3925 struct orinoco_private *priv = netdev_priv(dev);
3641 struct iwreq *wrq = (struct iwreq *)rq; 3926 hermes_t *hw = &priv->hw;
3642 int err = 0; 3927 int err = 0;
3643 int tmp;
3644 int changed = 0;
3645 unsigned long flags; 3928 unsigned long flags;
3646 3929
3647 TRACE_ENTER(dev->name); 3930 /* Note : you may have realised that, as this is a SET operation,
3931 * this is priviledged and therefore a normal user can't
3932 * perform scanning.
3933 * This is not an error, while the device perform scanning,
3934 * traffic doesn't flow, so it's a perfect DoS...
3935 * Jean II */
3648 3936
3649 /* In theory, we could allow most of the the SET stuff to be 3937 if (orinoco_lock(priv, &flags) != 0)
3650 * done. In practice, the lapse of time at startup when the 3938 return -EBUSY;
3651 * card is not ready is very short, so why bother... Note
3652 * that netif_device_present is different from up/down
3653 * (ifconfig), when the device is not yet up, it is usually
3654 * already ready... Jean II */
3655 if (! netif_device_present(dev))
3656 return -ENODEV;
3657 3939
3658 switch (cmd) { 3940 /* Scanning with port 0 disabled would fail */
3659 case SIOCGIWNAME: 3941 if (!netif_running(dev)) {
3660 strcpy(wrq->u.name, "IEEE 802.11-DS"); 3942 err = -ENETDOWN;
3661 break; 3943 goto out;
3662 3944 }
3663 case SIOCGIWAP:
3664 wrq->u.ap_addr.sa_family = ARPHRD_ETHER;
3665 err = orinoco_hw_get_bssid(priv, wrq->u.ap_addr.sa_data);
3666 break;
3667 3945
3668 case SIOCGIWRANGE: 3946 /* In monitor mode, the scan results are always empty.
3669 err = orinoco_ioctl_getiwrange(dev, &wrq->u.data); 3947 * Probe responses are passed to the driver as received
3670 break; 3948 * frames and could be processed in software. */
3949 if (priv->iw_mode == IW_MODE_MONITOR) {
3950 err = -EOPNOTSUPP;
3951 goto out;
3952 }
3671 3953
3672 case SIOCSIWMODE: 3954 /* Note : because we don't lock out the irq handler, the way
3673 if (orinoco_lock(priv, &flags) != 0) 3955 * we access scan variables in priv is critical.
3674 return -EBUSY; 3956 * o scan_inprogress : not touched by irq handler
3675 switch (wrq->u.mode) { 3957 * o scan_mode : not touched by irq handler
3676 case IW_MODE_ADHOC: 3958 * o scan_result : irq is strict producer, non-irq is strict
3677 if (! (priv->has_ibss || priv->has_port3) ) 3959 * consumer.
3678 err = -EINVAL; 3960 * o scan_len : synchronised with scan_result
3679 else { 3961 * Before modifying anything on those variables, please think hard !
3680 priv->iw_mode = IW_MODE_ADHOC; 3962 * Jean II */
3681 changed = 1;
3682 }
3683 break;
3684 3963
3685 case IW_MODE_INFRA: 3964 /* If there is still some left-over scan results, get rid of it */
3686 priv->iw_mode = IW_MODE_INFRA; 3965 if (priv->scan_result != NULL) {
3687 changed = 1; 3966 /* What's likely is that a client did crash or was killed
3688 break; 3967 * between triggering the scan request and reading the
3968 * results, so we need to reset everything.
3969 * Some clients that are too slow may suffer from that...
3970 * Jean II */
3971 kfree(priv->scan_result);
3972 priv->scan_result = NULL;
3973 }
3689 3974
3690 default: 3975 /* Save flags */
3691 err = -EINVAL; 3976 priv->scan_mode = srq->flags;
3692 break;
3693 }
3694 set_port_type(priv);
3695 orinoco_unlock(priv, &flags);
3696 break;
3697 3977
3698 case SIOCGIWMODE: 3978 /* Always trigger scanning, even if it's in progress.
3699 if (orinoco_lock(priv, &flags) != 0) 3979 * This way, if the info frame get lost, we will recover somewhat
3700 return -EBUSY; 3980 * gracefully - Jean II */
3701 wrq->u.mode = priv->iw_mode;
3702 orinoco_unlock(priv, &flags);
3703 break;
3704 3981
3705 case SIOCSIWENCODE: 3982 if (priv->has_hostscan) {
3706 err = orinoco_ioctl_setiwencode(dev, &wrq->u.encoding); 3983 switch (priv->firmware_type) {
3707 if (! err) 3984 case FIRMWARE_TYPE_SYMBOL:
3708 changed = 1; 3985 err = hermes_write_wordrec(hw, USER_BAP,
3986 HERMES_RID_CNFHOSTSCAN_SYMBOL,
3987 HERMES_HOSTSCAN_SYMBOL_ONCE |
3988 HERMES_HOSTSCAN_SYMBOL_BCAST);
3989 break;
3990 case FIRMWARE_TYPE_INTERSIL: {
3991 u16 req[3];
3992
3993 req[0] = cpu_to_le16(0x3fff); /* All channels */
3994 req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */
3995 req[2] = 0; /* Any ESSID */
3996 err = HERMES_WRITE_RECORD(hw, USER_BAP,
3997 HERMES_RID_CNFHOSTSCAN, &req);
3998 }
3709 break; 3999 break;
4000 case FIRMWARE_TYPE_AGERE:
4001 err = hermes_write_wordrec(hw, USER_BAP,
4002 HERMES_RID_CNFSCANSSID_AGERE,
4003 0); /* Any ESSID */
4004 if (err)
4005 break;
3710 4006
3711 case SIOCGIWENCODE: 4007 err = hermes_inquire(hw, HERMES_INQ_SCAN);
3712 if (! capable(CAP_NET_ADMIN)) {
3713 err = -EPERM;
3714 break; 4008 break;
3715 } 4009 }
4010 } else
4011 err = hermes_inquire(hw, HERMES_INQ_SCAN);
3716 4012
3717 err = orinoco_ioctl_getiwencode(dev, &wrq->u.encoding); 4013 /* One more client */
3718 break; 4014 if (! err)
3719 4015 priv->scan_inprogress = 1;
3720 case SIOCSIWESSID:
3721 err = orinoco_ioctl_setessid(dev, &wrq->u.essid);
3722 if (! err)
3723 changed = 1;
3724 break;
3725 4016
3726 case SIOCGIWESSID: 4017 out:
3727 err = orinoco_ioctl_getessid(dev, &wrq->u.essid); 4018 orinoco_unlock(priv, &flags);
3728 break; 4019 return err;
4020}
3729 4021
3730 case SIOCSIWNICKN: 4022/* Translate scan data returned from the card to a card independant
3731 err = orinoco_ioctl_setnick(dev, &wrq->u.data); 4023 * format that the Wireless Tools will understand - Jean II */
3732 if (! err) 4024static inline int orinoco_translate_scan(struct net_device *dev,
3733 changed = 1; 4025 char *buffer,
3734 break; 4026 char *scan,
4027 int scan_len)
4028{
4029 struct orinoco_private *priv = netdev_priv(dev);
4030 int offset; /* In the scan data */
4031 union hermes_scan_info *atom;
4032 int atom_len;
4033 u16 capabilities;
4034 u16 channel;
4035 struct iw_event iwe; /* Temporary buffer */
4036 char * current_ev = buffer;
4037 char * end_buf = buffer + IW_SCAN_MAX_DATA;
3735 4038
3736 case SIOCGIWNICKN: 4039 switch (priv->firmware_type) {
3737 err = orinoco_ioctl_getnick(dev, &wrq->u.data); 4040 case FIRMWARE_TYPE_AGERE:
4041 atom_len = sizeof(struct agere_scan_apinfo);
4042 offset = 0;
3738 break; 4043 break;
3739 4044 case FIRMWARE_TYPE_SYMBOL:
3740 case SIOCGIWFREQ: 4045 /* Lack of documentation necessitates this hack.
3741 tmp = orinoco_hw_get_freq(priv); 4046 * Different firmwares have 68 or 76 byte long atoms.
3742 if (tmp < 0) { 4047 * We try modulo first. If the length divides by both,
3743 err = tmp; 4048 * we check what would be the channel in the second
3744 } else { 4049 * frame for a 68-byte atom. 76-byte atoms have 0 there.
3745 wrq->u.freq.m = tmp; 4050 * Valid channel cannot be 0. */
3746 wrq->u.freq.e = 1; 4051 if (scan_len % 76)
3747 } 4052 atom_len = 68;
4053 else if (scan_len % 68)
4054 atom_len = 76;
4055 else if (scan_len >= 1292 && scan[68] == 0)
4056 atom_len = 76;
4057 else
4058 atom_len = 68;
4059 offset = 0;
3748 break; 4060 break;
3749 4061 case FIRMWARE_TYPE_INTERSIL:
3750 case SIOCSIWFREQ: 4062 offset = 4;
3751 err = orinoco_ioctl_setfreq(dev, &wrq->u.freq); 4063 if (priv->has_hostscan)
3752 if (! err) 4064 atom_len = scan[0] + (scan[1] << 8);
3753 changed = 1; 4065 else
4066 atom_len = offsetof(struct prism2_scan_apinfo, atim);
3754 break; 4067 break;
4068 default:
4069 return 0;
4070 }
3755 4071
3756 case SIOCGIWSENS: 4072 /* Check that we got an whole number of atoms */
3757 err = orinoco_ioctl_getsens(dev, &wrq->u.sens); 4073 if ((scan_len - offset) % atom_len) {
3758 break; 4074 printk(KERN_ERR "%s: Unexpected scan data length %d, "
4075 "atom_len %d, offset %d\n", dev->name, scan_len,
4076 atom_len, offset);
4077 return 0;
4078 }
3759 4079
3760 case SIOCSIWSENS: 4080 /* Read the entries one by one */
3761 err = orinoco_ioctl_setsens(dev, &wrq->u.sens); 4081 for (; offset + atom_len <= scan_len; offset += atom_len) {
3762 if (! err) 4082 /* Get next atom */
3763 changed = 1; 4083 atom = (union hermes_scan_info *) (scan + offset);
3764 break; 4084
4085 /* First entry *MUST* be the AP MAC address */
4086 iwe.cmd = SIOCGIWAP;
4087 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
4088 memcpy(iwe.u.ap_addr.sa_data, atom->a.bssid, ETH_ALEN);
4089 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
4090
4091 /* Other entries will be displayed in the order we give them */
4092
4093 /* Add the ESSID */
4094 iwe.u.data.length = le16_to_cpu(atom->a.essid_len);
4095 if (iwe.u.data.length > 32)
4096 iwe.u.data.length = 32;
4097 iwe.cmd = SIOCGIWESSID;
4098 iwe.u.data.flags = 1;
4099 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, atom->a.essid);
4100
4101 /* Add mode */
4102 iwe.cmd = SIOCGIWMODE;
4103 capabilities = le16_to_cpu(atom->a.capabilities);
4104 if (capabilities & 0x3) {
4105 if (capabilities & 0x1)
4106 iwe.u.mode = IW_MODE_MASTER;
4107 else
4108 iwe.u.mode = IW_MODE_ADHOC;
4109 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
4110 }
3765 4111
3766 case SIOCGIWRTS: 4112 channel = atom->s.channel;
3767 wrq->u.rts.value = priv->rts_thresh; 4113 if ( (channel >= 1) && (channel <= NUM_CHANNELS) ) {
3768 wrq->u.rts.disabled = (wrq->u.rts.value == 2347); 4114 /* Add frequency */
3769 wrq->u.rts.fixed = 1; 4115 iwe.cmd = SIOCGIWFREQ;
3770 break; 4116 iwe.u.freq.m = channel_frequency[channel-1] * 100000;
4117 iwe.u.freq.e = 1;
4118 current_ev = iwe_stream_add_event(current_ev, end_buf,
4119 &iwe, IW_EV_FREQ_LEN);
4120 }
3771 4121
3772 case SIOCSIWRTS: 4122 /* Add quality statistics */
3773 err = orinoco_ioctl_setrts(dev, &wrq->u.rts); 4123 iwe.cmd = IWEVQUAL;
3774 if (! err) 4124 iwe.u.qual.updated = 0x10; /* no link quality */
3775 changed = 1; 4125 iwe.u.qual.level = (__u8) le16_to_cpu(atom->a.level) - 0x95;
3776 break; 4126 iwe.u.qual.noise = (__u8) le16_to_cpu(atom->a.noise) - 0x95;
4127 /* Wireless tools prior to 27.pre22 will show link quality
4128 * anyway, so we provide a reasonable value. */
4129 if (iwe.u.qual.level > iwe.u.qual.noise)
4130 iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise;
4131 else
4132 iwe.u.qual.qual = 0;
4133 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
3777 4134
3778 case SIOCSIWFRAG: 4135 /* Add encryption capability */
3779 err = orinoco_ioctl_setfrag(dev, &wrq->u.frag); 4136 iwe.cmd = SIOCGIWENCODE;
3780 if (! err) 4137 if (capabilities & 0x10)
3781 changed = 1; 4138 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
3782 break; 4139 else
4140 iwe.u.data.flags = IW_ENCODE_DISABLED;
4141 iwe.u.data.length = 0;
4142 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, atom->a.essid);
4143
4144 /* Bit rate is not available in Lucent/Agere firmwares */
4145 if (priv->firmware_type != FIRMWARE_TYPE_AGERE) {
4146 char * current_val = current_ev + IW_EV_LCP_LEN;
4147 int i;
4148 int step;
4149
4150 if (priv->firmware_type == FIRMWARE_TYPE_SYMBOL)
4151 step = 2;
4152 else
4153 step = 1;
4154
4155 iwe.cmd = SIOCGIWRATE;
4156 /* Those two flags are ignored... */
4157 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
4158 /* Max 10 values */
4159 for (i = 0; i < 10; i += step) {
4160 /* NULL terminated */
4161 if (atom->p.rates[i] == 0x0)
4162 break;
4163 /* Bit rate given in 500 kb/s units (+ 0x80) */
4164 iwe.u.bitrate.value = ((atom->p.rates[i] & 0x7f) * 500000);
4165 current_val = iwe_stream_add_value(current_ev, current_val,
4166 end_buf, &iwe,
4167 IW_EV_PARAM_LEN);
4168 }
4169 /* Check if we added any event */
4170 if ((current_val - current_ev) > IW_EV_LCP_LEN)
4171 current_ev = current_val;
4172 }
3783 4173
3784 case SIOCGIWFRAG: 4174 /* The other data in the scan result are not really
3785 err = orinoco_ioctl_getfrag(dev, &wrq->u.frag); 4175 * interesting, so for now drop it - Jean II */
3786 break; 4176 }
4177 return current_ev - buffer;
4178}
3787 4179
3788 case SIOCSIWRATE: 4180/* Return results of a scan */
3789 err = orinoco_ioctl_setrate(dev, &wrq->u.bitrate); 4181static int orinoco_ioctl_getscan(struct net_device *dev,
3790 if (! err) 4182 struct iw_request_info *info,
3791 changed = 1; 4183 struct iw_point *srq,
3792 break; 4184 char *extra)
4185{
4186 struct orinoco_private *priv = netdev_priv(dev);
4187 int err = 0;
4188 unsigned long flags;
3793 4189
3794 case SIOCGIWRATE: 4190 if (orinoco_lock(priv, &flags) != 0)
3795 err = orinoco_ioctl_getrate(dev, &wrq->u.bitrate); 4191 return -EBUSY;
3796 break;
3797 4192
3798 case SIOCSIWPOWER: 4193 /* If no results yet, ask to try again later */
3799 err = orinoco_ioctl_setpower(dev, &wrq->u.power); 4194 if (priv->scan_result == NULL) {
3800 if (! err) 4195 if (priv->scan_inprogress)
3801 changed = 1; 4196 /* Important note : we don't want to block the caller
3802 break; 4197 * until results are ready for various reasons.
4198 * First, managing wait queues is complex and racy.
4199 * Second, we grab some rtnetlink lock before comming
4200 * here (in dev_ioctl()).
4201 * Third, we generate an Wireless Event, so the
4202 * caller can wait itself on that - Jean II */
4203 err = -EAGAIN;
4204 else
4205 /* Client error, no scan results...
4206 * The caller need to restart the scan. */
4207 err = -ENODATA;
4208 } else {
4209 /* We have some results to push back to user space */
4210
4211 /* Translate to WE format */
4212 srq->length = orinoco_translate_scan(dev, extra,
4213 priv->scan_result,
4214 priv->scan_len);
4215
4216 /* Return flags */
4217 srq->flags = (__u16) priv->scan_mode;
4218
4219 /* Results are here, so scan no longer in progress */
4220 priv->scan_inprogress = 0;
4221
4222 /* In any case, Scan results will be cleaned up in the
4223 * reset function and when exiting the driver.
4224 * The person triggering the scanning may never come to
4225 * pick the results, so we need to do it in those places.
4226 * Jean II */
4227
4228#ifdef SCAN_SINGLE_READ
4229 /* If you enable this option, only one client (the first
4230 * one) will be able to read the result (and only one
4231 * time). If there is multiple concurent clients that
4232 * want to read scan results, this behavior is not
4233 * advisable - Jean II */
4234 kfree(priv->scan_result);
4235 priv->scan_result = NULL;
4236#endif /* SCAN_SINGLE_READ */
4237 /* Here, if too much time has elapsed since last scan,
4238 * we may want to clean up scan results... - Jean II */
4239 }
4240
4241 orinoco_unlock(priv, &flags);
4242 return err;
4243}
3803 4244
3804 case SIOCGIWPOWER: 4245/* Commit handler, called after set operations */
3805 err = orinoco_ioctl_getpower(dev, &wrq->u.power); 4246static int orinoco_ioctl_commit(struct net_device *dev,
3806 break; 4247 struct iw_request_info *info,
4248 void *wrqu,
4249 char *extra)
4250{
4251 struct orinoco_private *priv = netdev_priv(dev);
4252 struct hermes *hw = &priv->hw;
4253 unsigned long flags;
4254 int err = 0;
3807 4255
3808 case SIOCGIWTXPOW: 4256 if (!priv->open)
3809 /* The card only supports one tx power, so this is easy */ 4257 return 0;
3810 wrq->u.txpower.value = 15; /* dBm */
3811 wrq->u.txpower.fixed = 1;
3812 wrq->u.txpower.disabled = 0;
3813 wrq->u.txpower.flags = IW_TXPOW_DBM;
3814 break;
3815 4258
3816 case SIOCSIWRETRY: 4259 if (priv->broken_disableport) {
3817 err = -EOPNOTSUPP; 4260 orinoco_reset(dev);
3818 break; 4261 return 0;
4262 }
3819 4263
3820 case SIOCGIWRETRY: 4264 if (orinoco_lock(priv, &flags) != 0)
3821 err = orinoco_ioctl_getretry(dev, &wrq->u.retry); 4265 return err;
3822 break;
3823 4266
3824 case SIOCSIWSPY: 4267 err = hermes_disable_port(hw, 0);
3825 err = orinoco_ioctl_setspy(dev, &wrq->u.data); 4268 if (err) {
3826 break; 4269 printk(KERN_WARNING "%s: Unable to disable port "
4270 "while reconfiguring card\n", dev->name);
4271 priv->broken_disableport = 1;
4272 goto out;
4273 }
3827 4274
3828 case SIOCGIWSPY: 4275 err = __orinoco_program_rids(dev);
3829 err = orinoco_ioctl_getspy(dev, &wrq->u.data); 4276 if (err) {
3830 break; 4277 printk(KERN_WARNING "%s: Unable to reconfigure card\n",
4278 dev->name);
4279 goto out;
4280 }
3831 4281
3832 case SIOCGIWPRIV: 4282 err = hermes_enable_port(hw, 0);
3833 if (wrq->u.data.pointer) { 4283 if (err) {
3834 struct iw_priv_args privtab[] = { 4284 printk(KERN_WARNING "%s: Unable to enable port while reconfiguring card\n",
3835 { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" }, 4285 dev->name);
3836 { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" }, 4286 goto out;
3837 { SIOCIWFIRSTPRIV + 0x2, 4287 }
3838 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3839 0, "set_port3" },
3840 { SIOCIWFIRSTPRIV + 0x3, 0,
3841 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3842 "get_port3" },
3843 { SIOCIWFIRSTPRIV + 0x4,
3844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3845 0, "set_preamble" },
3846 { SIOCIWFIRSTPRIV + 0x5, 0,
3847 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3848 "get_preamble" },
3849 { SIOCIWFIRSTPRIV + 0x6,
3850 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3851 0, "set_ibssport" },
3852 { SIOCIWFIRSTPRIV + 0x7, 0,
3853 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3854 "get_ibssport" },
3855 };
3856
3857 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
3858 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
3859 err = -EFAULT;
3860 }
3861 break;
3862
3863 case SIOCIWFIRSTPRIV + 0x0: /* force_reset */
3864 case SIOCIWFIRSTPRIV + 0x1: /* card_reset */
3865 if (! capable(CAP_NET_ADMIN)) {
3866 err = -EPERM;
3867 break;
3868 }
3869
3870 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
3871 4288
4289 out:
4290 if (err) {
4291 printk(KERN_WARNING "%s: Resetting instead...\n", dev->name);
3872 schedule_work(&priv->reset_work); 4292 schedule_work(&priv->reset_work);
3873 break; 4293 err = 0;
3874 4294 }
3875 case SIOCIWFIRSTPRIV + 0x2: /* set_port3 */
3876 if (! capable(CAP_NET_ADMIN)) {
3877 err = -EPERM;
3878 break;
3879 }
3880
3881 err = orinoco_ioctl_setport3(dev, wrq);
3882 if (! err)
3883 changed = 1;
3884 break;
3885 4295
3886 case SIOCIWFIRSTPRIV + 0x3: /* get_port3 */ 4296 orinoco_unlock(priv, &flags);
3887 err = orinoco_ioctl_getport3(dev, wrq); 4297 return err;
3888 break; 4298}
3889 4299
3890 case SIOCIWFIRSTPRIV + 0x4: /* set_preamble */ 4300static const struct iw_priv_args orinoco_privtab[] = {
3891 if (! capable(CAP_NET_ADMIN)) { 4301 { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" },
3892 err = -EPERM; 4302 { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
3893 break; 4303 { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3894 } 4304 0, "set_port3" },
4305 { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4306 "get_port3" },
4307 { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4308 0, "set_preamble" },
4309 { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4310 "get_preamble" },
4311 { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4312 0, "set_ibssport" },
4313 { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4314 "get_ibssport" },
4315 { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN,
4316 "get_rid" },
4317};
3895 4318
3896 /* 802.11b has recently defined some short preamble.
3897 * Basically, the Phy header has been reduced in size.
3898 * This increase performance, especially at high rates
3899 * (the preamble is transmitted at 1Mb/s), unfortunately
3900 * this give compatibility troubles... - Jean II */
3901 if(priv->has_preamble) {
3902 int val = *( (int *) wrq->u.name );
3903
3904 if (orinoco_lock(priv, &flags) != 0)
3905 return -EBUSY;
3906 if (val)
3907 priv->preamble = 1;
3908 else
3909 priv->preamble = 0;
3910 orinoco_unlock(priv, &flags);
3911 changed = 1;
3912 } else
3913 err = -EOPNOTSUPP;
3914 break;
3915 4319
3916 case SIOCIWFIRSTPRIV + 0x5: /* get_preamble */ 4320/*
3917 if(priv->has_preamble) { 4321 * Structures to export the Wireless Handlers
3918 int *val = (int *)wrq->u.name; 4322 */
3919 4323
3920 if (orinoco_lock(priv, &flags) != 0) 4324static const iw_handler orinoco_handler[] = {
3921 return -EBUSY; 4325 [SIOCSIWCOMMIT-SIOCIWFIRST] = (iw_handler) orinoco_ioctl_commit,
3922 *val = priv->preamble; 4326 [SIOCGIWNAME -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getname,
3923 orinoco_unlock(priv, &flags); 4327 [SIOCSIWFREQ -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setfreq,
3924 } else 4328 [SIOCGIWFREQ -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getfreq,
3925 err = -EOPNOTSUPP; 4329 [SIOCSIWMODE -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setmode,
3926 break; 4330 [SIOCGIWMODE -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getmode,
3927 case SIOCIWFIRSTPRIV + 0x6: /* set_ibssport */ 4331 [SIOCSIWSENS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setsens,
3928 if (! capable(CAP_NET_ADMIN)) { 4332 [SIOCGIWSENS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getsens,
3929 err = -EPERM; 4333 [SIOCGIWRANGE -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getiwrange,
3930 break; 4334 [SIOCSIWSPY -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setspy,
3931 } 4335 [SIOCGIWSPY -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getspy,
4336 [SIOCSIWAP -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setwap,
4337 [SIOCGIWAP -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getwap,
4338 [SIOCSIWSCAN -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setscan,
4339 [SIOCGIWSCAN -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getscan,
4340 [SIOCSIWESSID -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setessid,
4341 [SIOCGIWESSID -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getessid,
4342 [SIOCSIWNICKN -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setnick,
4343 [SIOCGIWNICKN -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getnick,
4344 [SIOCSIWRATE -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setrate,
4345 [SIOCGIWRATE -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getrate,
4346 [SIOCSIWRTS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setrts,
4347 [SIOCGIWRTS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getrts,
4348 [SIOCSIWFRAG -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setfrag,
4349 [SIOCGIWFRAG -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getfrag,
4350 [SIOCGIWRETRY -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getretry,
4351 [SIOCSIWENCODE-SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setiwencode,
4352 [SIOCGIWENCODE-SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getiwencode,
4353 [SIOCSIWPOWER -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setpower,
4354 [SIOCGIWPOWER -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getpower,
4355};
3932 4356
3933 err = orinoco_ioctl_setibssport(dev, wrq);
3934 if (! err)
3935 changed = 1;
3936 break;
3937 4357
3938 case SIOCIWFIRSTPRIV + 0x7: /* get_ibssport */ 4358/*
3939 err = orinoco_ioctl_getibssport(dev, wrq); 4359 Added typecasting since we no longer use iwreq_data -- Moustafa
3940 break; 4360 */
4361static const iw_handler orinoco_private_handler[] = {
4362 [0] = (iw_handler) orinoco_ioctl_reset,
4363 [1] = (iw_handler) orinoco_ioctl_reset,
4364 [2] = (iw_handler) orinoco_ioctl_setport3,
4365 [3] = (iw_handler) orinoco_ioctl_getport3,
4366 [4] = (iw_handler) orinoco_ioctl_setpreamble,
4367 [5] = (iw_handler) orinoco_ioctl_getpreamble,
4368 [6] = (iw_handler) orinoco_ioctl_setibssport,
4369 [7] = (iw_handler) orinoco_ioctl_getibssport,
4370 [9] = (iw_handler) orinoco_ioctl_getrid,
4371};
3941 4372
3942 default: 4373static const struct iw_handler_def orinoco_handler_def = {
3943 err = -EOPNOTSUPP; 4374 .num_standard = ARRAY_SIZE(orinoco_handler),
3944 } 4375 .num_private = ARRAY_SIZE(orinoco_private_handler),
3945 4376 .num_private_args = ARRAY_SIZE(orinoco_privtab),
3946 if (! err && changed && netif_running(dev)) { 4377 .standard = orinoco_handler,
3947 err = orinoco_reconfigure(dev); 4378 .private = orinoco_private_handler,
3948 } 4379 .private_args = orinoco_privtab,
4380};
3949 4381
3950 TRACE_EXIT(dev->name); 4382static void orinoco_get_drvinfo(struct net_device *dev,
4383 struct ethtool_drvinfo *info)
4384{
4385 struct orinoco_private *priv = netdev_priv(dev);
3951 4386
3952 return err; 4387 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
4388 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
4389 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1);
4390 if (dev->class_dev.dev)
4391 strncpy(info->bus_info, dev->class_dev.dev->bus_id,
4392 sizeof(info->bus_info) - 1);
4393 else
4394 snprintf(info->bus_info, sizeof(info->bus_info) - 1,
4395 "PCMCIA %p", priv->hw.iobase);
3953} 4396}
3954 4397
4398static struct ethtool_ops orinoco_ethtool_ops = {
4399 .get_drvinfo = orinoco_get_drvinfo,
4400 .get_link = ethtool_op_get_link,
4401};
3955 4402
3956/********************************************************************/ 4403/********************************************************************/
3957/* Debugging */ 4404/* Debugging */
diff --git a/drivers/net/wireless/orinoco.h b/drivers/net/wireless/orinoco.h
index f749b50d1088..2f213a7103fe 100644
--- a/drivers/net/wireless/orinoco.h
+++ b/drivers/net/wireless/orinoco.h
@@ -7,7 +7,7 @@
7#ifndef _ORINOCO_H 7#ifndef _ORINOCO_H
8#define _ORINOCO_H 8#define _ORINOCO_H
9 9
10#define DRIVER_VERSION "0.14alpha2" 10#define DRIVER_VERSION "0.15rc2"
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
@@ -22,6 +22,8 @@
22 22
23#define WIRELESS_SPY // enable iwspy support 23#define WIRELESS_SPY // enable iwspy support
24 24
25#define MAX_SCAN_LEN 4096
26
25#define ORINOCO_MAX_KEY_SIZE 14 27#define ORINOCO_MAX_KEY_SIZE 14
26#define ORINOCO_MAX_KEYS 4 28#define ORINOCO_MAX_KEYS 4
27 29
@@ -30,6 +32,20 @@ struct orinoco_key {
30 char data[ORINOCO_MAX_KEY_SIZE]; 32 char data[ORINOCO_MAX_KEY_SIZE];
31} __attribute__ ((packed)); 33} __attribute__ ((packed));
32 34
35struct header_struct {
36 /* 802.3 */
37 u8 dest[ETH_ALEN];
38 u8 src[ETH_ALEN];
39 u16 len;
40 /* 802.2 */
41 u8 dsap;
42 u8 ssap;
43 u8 ctrl;
44 /* SNAP */
45 u8 oui[3];
46 u16 ethertype;
47} __attribute__ ((packed));
48
33typedef enum { 49typedef enum {
34 FIRMWARE_TYPE_AGERE, 50 FIRMWARE_TYPE_AGERE,
35 FIRMWARE_TYPE_INTERSIL, 51 FIRMWARE_TYPE_INTERSIL,
@@ -48,6 +64,8 @@ struct orinoco_private {
48 /* driver state */ 64 /* driver state */
49 int open; 65 int open;
50 u16 last_linkstatus; 66 u16 last_linkstatus;
67 struct work_struct join_work;
68 struct work_struct wevent_work;
51 69
52 /* Net device stuff */ 70 /* Net device stuff */
53 struct net_device *ndev; 71 struct net_device *ndev;
@@ -74,7 +92,9 @@ struct orinoco_private {
74 unsigned int has_pm:1; 92 unsigned int has_pm:1;
75 unsigned int has_preamble:1; 93 unsigned int has_preamble:1;
76 unsigned int has_sensitivity:1; 94 unsigned int has_sensitivity:1;
95 unsigned int has_hostscan:1;
77 unsigned int broken_disableport:1; 96 unsigned int broken_disableport:1;
97 unsigned int broken_monitor:1;
78 98
79 /* Configuration paramaters */ 99 /* Configuration paramaters */
80 u32 iw_mode; 100 u32 iw_mode;
@@ -84,6 +104,8 @@ struct orinoco_private {
84 int bitratemode; 104 int bitratemode;
85 char nick[IW_ESSID_MAX_SIZE+1]; 105 char nick[IW_ESSID_MAX_SIZE+1];
86 char desired_essid[IW_ESSID_MAX_SIZE+1]; 106 char desired_essid[IW_ESSID_MAX_SIZE+1];
107 char desired_bssid[ETH_ALEN];
108 int bssid_fixed;
87 u16 frag_thresh, mwo_robust; 109 u16 frag_thresh, mwo_robust;
88 u16 channel; 110 u16 channel;
89 u16 ap_density, rts_thresh; 111 u16 ap_density, rts_thresh;
@@ -98,6 +120,12 @@ struct orinoco_private {
98 /* Configuration dependent variables */ 120 /* Configuration dependent variables */
99 int port_type, createibss; 121 int port_type, createibss;
100 int promiscuous, mc_count; 122 int promiscuous, mc_count;
123
124 /* Scanning support */
125 int scan_inprogress; /* Scan pending... */
126 u32 scan_mode; /* Type of scan done */
127 char * scan_result; /* Result of previous scan */
128 int scan_len; /* Lenght of result */
101}; 129};
102 130
103#ifdef ORINOCO_DEBUG 131#ifdef ORINOCO_DEBUG
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 74a8227256aa..1cc1492083c9 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -31,7 +31,6 @@
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/wireless.h> 32#include <linux/wireless.h>
33 33
34#include <pcmcia/version.h>
35#include <pcmcia/cs_types.h> 34#include <pcmcia/cs_types.h>
36#include <pcmcia/cs.h> 35#include <pcmcia/cs.h>
37#include <pcmcia/cistpl.h> 36#include <pcmcia/cistpl.h>
@@ -186,11 +185,6 @@ orinoco_cs_attach(void)
186 dev_list = link; 185 dev_list = link;
187 186
188 client_reg.dev_info = &dev_info; 187 client_reg.dev_info = &dev_info;
189 client_reg.EventMask =
190 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
191 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
192 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
193 client_reg.event_handler = &orinoco_cs_event;
194 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 188 client_reg.Version = 0x0210; /* FIXME: what does this mean? */
195 client_reg.event_callback_args.client_data = link; 189 client_reg.event_callback_args.client_data = link;
196 190
@@ -608,13 +602,63 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
608 " (David Gibson <hermes@gibson.dropbear.id.au>, " 602 " (David Gibson <hermes@gibson.dropbear.id.au>, "
609 "Pavel Roskin <proski@gnu.org>, et al)"; 603 "Pavel Roskin <proski@gnu.org>, et al)";
610 604
605static struct pcmcia_device_id orinoco_cs_ids[] = {
606 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
607 PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001),
608 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
609 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
610 PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a),
611 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002),
612 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001),
613 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305),
614 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613),
615 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002),
616 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673),
617 PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002),
618 PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002),
619 PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001),
620 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
621 PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021),
622 PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002),
623 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
624 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
625 PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3),
626 PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0),
627 PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5),
628 PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169),
629 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3),
630 PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90),
631 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584),
632 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9),
633 PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac),
634 PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab),
635 PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3),
636 PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c),
637 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18),
638 PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a),
639 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410),
640 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3),
641 PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01),
642 PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a),
643 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1),
644 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264),
645 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9),
646 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26),
647 PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b),
648 PCMCIA_DEVICE_PROD_ID1("Symbol Technologies", 0x3f02b4d6),
649 PCMCIA_DEVICE_NULL,
650};
651MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids);
652
611static struct pcmcia_driver orinoco_driver = { 653static struct pcmcia_driver orinoco_driver = {
612 .owner = THIS_MODULE, 654 .owner = THIS_MODULE,
613 .drv = { 655 .drv = {
614 .name = DRIVER_NAME, 656 .name = DRIVER_NAME,
615 }, 657 },
616 .attach = orinoco_cs_attach, 658 .attach = orinoco_cs_attach,
659 .event = orinoco_cs_event,
617 .detach = orinoco_cs_detach, 660 .detach = orinoco_cs_detach,
661 .id_table = orinoco_cs_ids,
618}; 662};
619 663
620static int __init 664static int __init
diff --git a/drivers/net/wireless/prism54/isl_38xx.c b/drivers/net/wireless/prism54/isl_38xx.c
index 4481ec18c5a0..adc7499136dc 100644
--- a/drivers/net/wireless/prism54/isl_38xx.c
+++ b/drivers/net/wireless/prism54/isl_38xx.c
@@ -112,10 +112,10 @@ isl38xx_handle_wakeup(isl38xx_control_block *control_block,
112void 112void
113isl38xx_trigger_device(int asleep, void __iomem *device_base) 113isl38xx_trigger_device(int asleep, void __iomem *device_base)
114{ 114{
115 struct timeval current_time;
116 u32 reg, counter = 0; 115 u32 reg, counter = 0;
117 116
118#if VERBOSE > SHOW_ERROR_MESSAGES 117#if VERBOSE > SHOW_ERROR_MESSAGES
118 struct timeval current_time;
119 DEBUG(SHOW_FUNCTION_CALLS, "isl38xx trigger device\n"); 119 DEBUG(SHOW_FUNCTION_CALLS, "isl38xx trigger device\n");
120#endif 120#endif
121 121
@@ -126,11 +126,11 @@ isl38xx_trigger_device(int asleep, void __iomem *device_base)
126 do_gettimeofday(&current_time); 126 do_gettimeofday(&current_time);
127 DEBUG(SHOW_TRACING, "%08li.%08li Device wakeup triggered\n", 127 DEBUG(SHOW_TRACING, "%08li.%08li Device wakeup triggered\n",
128 current_time.tv_sec, (long)current_time.tv_usec); 128 current_time.tv_sec, (long)current_time.tv_usec);
129#endif
130 129
131 DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n", 130 DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n",
132 current_time.tv_sec, (long)current_time.tv_usec, 131 current_time.tv_sec, (long)current_time.tv_usec,
133 readl(device_base + ISL38XX_CTRL_STAT_REG)); 132 readl(device_base + ISL38XX_CTRL_STAT_REG));
133#endif
134 udelay(ISL38XX_WRITEIO_DELAY); 134 udelay(ISL38XX_WRITEIO_DELAY);
135 135
136 reg = readl(device_base + ISL38XX_INT_IDENT_REG); 136 reg = readl(device_base + ISL38XX_INT_IDENT_REG);
@@ -148,10 +148,12 @@ isl38xx_trigger_device(int asleep, void __iomem *device_base)
148 counter++; 148 counter++;
149 } 149 }
150 150
151#if VERBOSE > SHOW_ERROR_MESSAGES
151 DEBUG(SHOW_TRACING, 152 DEBUG(SHOW_TRACING,
152 "%08li.%08li Device register read %08x\n", 153 "%08li.%08li Device register read %08x\n",
153 current_time.tv_sec, (long)current_time.tv_usec, 154 current_time.tv_sec, (long)current_time.tv_usec,
154 readl(device_base + ISL38XX_CTRL_STAT_REG)); 155 readl(device_base + ISL38XX_CTRL_STAT_REG));
156#endif
155 udelay(ISL38XX_WRITEIO_DELAY); 157 udelay(ISL38XX_WRITEIO_DELAY);
156 158
157#if VERBOSE > SHOW_ERROR_MESSAGES 159#if VERBOSE > SHOW_ERROR_MESSAGES
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 6e5bda56b8f8..0e0ba614259a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -46,7 +46,6 @@
46#include <linux/skbuff.h> 46#include <linux/skbuff.h>
47#include <linux/ethtool.h> 47#include <linux/ethtool.h>
48 48
49#include <pcmcia/version.h>
50#include <pcmcia/cs_types.h> 49#include <pcmcia/cs_types.h>
51#include <pcmcia/cs.h> 50#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
@@ -393,11 +392,6 @@ static dev_link_t *ray_attach(void)
393 link->next = dev_list; 392 link->next = dev_list;
394 dev_list = link; 393 dev_list = link;
395 client_reg.dev_info = &dev_info; 394 client_reg.dev_info = &dev_info;
396 client_reg.EventMask =
397 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
398 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
399 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
400 client_reg.event_handler = &ray_event;
401 client_reg.Version = 0x0210; 395 client_reg.Version = 0x0210;
402 client_reg.event_callback_args.client_data = link; 396 client_reg.event_callback_args.client_data = link;
403 397
@@ -2904,13 +2898,21 @@ static int write_int(struct file *file, const char __user *buffer, unsigned long
2904} 2898}
2905#endif 2899#endif
2906 2900
2901static struct pcmcia_device_id ray_ids[] = {
2902 PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000),
2903 PCMCIA_DEVICE_NULL,
2904};
2905MODULE_DEVICE_TABLE(pcmcia, ray_ids);
2906
2907static struct pcmcia_driver ray_driver = { 2907static struct pcmcia_driver ray_driver = {
2908 .owner = THIS_MODULE, 2908 .owner = THIS_MODULE,
2909 .drv = { 2909 .drv = {
2910 .name = "ray_cs", 2910 .name = "ray_cs",
2911 }, 2911 },
2912 .attach = ray_attach, 2912 .attach = ray_attach,
2913 .event = ray_event,
2913 .detach = ray_detach, 2914 .detach = ray_detach,
2915 .id_table = ray_ids,
2914}; 2916};
2915 2917
2916static int __init init_ray_cs(void) 2918static int __init init_ray_cs(void)
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index ec8cf29ffced..6c42b573a95a 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -2828,7 +2828,7 @@ static void __exit strip_exit_driver(void)
2828 /* Unregister with the /proc/net file here. */ 2828 /* Unregister with the /proc/net file here. */
2829 proc_net_remove("strip"); 2829 proc_net_remove("strip");
2830 2830
2831 if ((i = tty_register_ldisc(N_STRIP, NULL))) 2831 if ((i = tty_unregister_ldisc(N_STRIP)))
2832 printk(KERN_ERR "STRIP: can't unregister line discipline (err = %d)\n", i); 2832 printk(KERN_ERR "STRIP: can't unregister line discipline (err = %d)\n", i);
2833 2833
2834 printk(signoff); 2834 printk(signoff);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index ec8329788e49..f6130a53b796 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4684,12 +4684,6 @@ wavelan_attach(void)
4684 4684
4685 /* Register with Card Services */ 4685 /* Register with Card Services */
4686 client_reg.dev_info = &dev_info; 4686 client_reg.dev_info = &dev_info;
4687 client_reg.EventMask =
4688 CS_EVENT_REGISTRATION_COMPLETE |
4689 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
4690 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
4691 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
4692 client_reg.event_handler = &wavelan_event;
4693 client_reg.Version = 0x0210; 4687 client_reg.Version = 0x0210;
4694 client_reg.event_callback_args.client_data = link; 4688 client_reg.event_callback_args.client_data = link;
4695 4689
@@ -4889,13 +4883,24 @@ wavelan_event(event_t event, /* The event received */
4889 return 0; 4883 return 0;
4890} 4884}
4891 4885
4886static struct pcmcia_device_id wavelan_ids[] = {
4887 PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975),
4888 PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06),
4889 PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/PCMCIA", 0x23eb9949, 0x1bc50975),
4890 PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/PCMCIA", 0x24358cd4, 0x1bc50975),
4891 PCMCIA_DEVICE_NULL,
4892};
4893MODULE_DEVICE_TABLE(pcmcia, wavelan_ids);
4894
4892static struct pcmcia_driver wavelan_driver = { 4895static struct pcmcia_driver wavelan_driver = {
4893 .owner = THIS_MODULE, 4896 .owner = THIS_MODULE,
4894 .drv = { 4897 .drv = {
4895 .name = "wavelan_cs", 4898 .name = "wavelan_cs",
4896 }, 4899 },
4897 .attach = wavelan_attach, 4900 .attach = wavelan_attach,
4901 .event = wavelan_event,
4898 .detach = wavelan_detach, 4902 .detach = wavelan_detach,
4903 .id_table = wavelan_ids,
4899}; 4904};
4900 4905
4901static int __init 4906static int __init
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index ea2ef8dddb92..677ff71883cb 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -452,7 +452,6 @@
452#include <pcmcia/cistpl.h> 452#include <pcmcia/cistpl.h>
453#include <pcmcia/cisreg.h> 453#include <pcmcia/cisreg.h>
454#include <pcmcia/ds.h> 454#include <pcmcia/ds.h>
455#include <pcmcia/version.h>
456 455
457/* Wavelan declarations */ 456/* Wavelan declarations */
458#include "i82593.h" /* Definitions for the Intel chip */ 457#include "i82593.h" /* Definitions for the Intel chip */
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 1433e5aaf1b4..dd902126d018 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -49,7 +49,6 @@
49 49
50#include <net/iw_handler.h> 50#include <net/iw_handler.h>
51 51
52#include <pcmcia/version.h>
53#include <pcmcia/cs_types.h> 52#include <pcmcia/cs_types.h>
54#include <pcmcia/cs.h> 53#include <pcmcia/cs.h>
55#include <pcmcia/cistpl.h> 54#include <pcmcia/cistpl.h>
@@ -2005,13 +2004,6 @@ static dev_link_t *wl3501_attach(void)
2005 link->next = wl3501_dev_list; 2004 link->next = wl3501_dev_list;
2006 wl3501_dev_list = link; 2005 wl3501_dev_list = link;
2007 client_reg.dev_info = &wl3501_dev_info; 2006 client_reg.dev_info = &wl3501_dev_info;
2008 client_reg.EventMask = CS_EVENT_CARD_INSERTION |
2009 CS_EVENT_RESET_PHYSICAL |
2010 CS_EVENT_CARD_RESET |
2011 CS_EVENT_CARD_REMOVAL |
2012 CS_EVENT_PM_SUSPEND |
2013 CS_EVENT_PM_RESUME;
2014 client_reg.event_handler = wl3501_event;
2015 client_reg.Version = 0x0210; 2007 client_reg.Version = 0x0210;
2016 client_reg.event_callback_args.client_data = link; 2008 client_reg.event_callback_args.client_data = link;
2017 ret = pcmcia_register_client(&link->handle, &client_reg); 2009 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -2239,13 +2231,21 @@ static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
2239 return 0; 2231 return 0;
2240} 2232}
2241 2233
2234static struct pcmcia_device_id wl3501_ids[] = {
2235 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
2236 PCMCIA_DEVICE_NULL
2237};
2238MODULE_DEVICE_TABLE(pcmcia, wl3501_ids);
2239
2242static struct pcmcia_driver wl3501_driver = { 2240static struct pcmcia_driver wl3501_driver = {
2243 .owner = THIS_MODULE, 2241 .owner = THIS_MODULE,
2244 .drv = { 2242 .drv = {
2245 .name = "wl3501_cs", 2243 .name = "wl3501_cs",
2246 }, 2244 },
2247 .attach = wl3501_attach, 2245 .attach = wl3501_attach,
2248 .detach = wl3501_detach, 2246 .event = wl3501_event,
2247 .detach = wl3501_detach,
2248 .id_table = wl3501_ids,
2249}; 2249};
2250 2250
2251static int __init wl3501_init_module(void) 2251static int __init wl3501_init_module(void)
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index 9da925430109..1c2506535f7e 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -786,7 +786,7 @@ static void yellowfin_init_ring(struct net_device *dev)
786 skb->dev = dev; /* Mark as being used by this device. */ 786 skb->dev = dev; /* Mark as being used by this device. */
787 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 787 skb_reserve(skb, 2); /* 16 byte align the IP header. */
788 yp->rx_ring[i].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 788 yp->rx_ring[i].addr = cpu_to_le32(pci_map_single(yp->pci_dev,
789 skb->tail, yp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 789 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE));
790 } 790 }
791 yp->rx_ring[i-1].dbdma_cmd = cpu_to_le32(CMD_STOP); 791 yp->rx_ring[i-1].dbdma_cmd = cpu_to_le32(CMD_STOP);
792 yp->dirty_rx = (unsigned int)(i - RX_RING_SIZE); 792 yp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
@@ -1111,7 +1111,7 @@ static int yellowfin_rx(struct net_device *dev)
1111 pci_dma_sync_single_for_cpu(yp->pci_dev, desc->addr, 1111 pci_dma_sync_single_for_cpu(yp->pci_dev, desc->addr,
1112 yp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1112 yp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1113 desc_status = le32_to_cpu(desc->result_status) >> 16; 1113 desc_status = le32_to_cpu(desc->result_status) >> 16;
1114 buf_addr = rx_skb->tail; 1114 buf_addr = rx_skb->data;
1115 data_size = (le32_to_cpu(desc->dbdma_cmd) - 1115 data_size = (le32_to_cpu(desc->dbdma_cmd) -
1116 le32_to_cpu(desc->result_status)) & 0xffff; 1116 le32_to_cpu(desc->result_status)) & 0xffff;
1117 frame_status = le16_to_cpu(get_unaligned((s16*)&(buf_addr[data_size - 2]))); 1117 frame_status = le16_to_cpu(get_unaligned((s16*)&(buf_addr[data_size - 2])));
@@ -1185,7 +1185,7 @@ static int yellowfin_rx(struct net_device *dev)
1185 break; 1185 break;
1186 skb->dev = dev; 1186 skb->dev = dev;
1187 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1187 skb_reserve(skb, 2); /* 16 byte align the IP header */
1188 eth_copy_and_sum(skb, rx_skb->tail, pkt_len, 0); 1188 eth_copy_and_sum(skb, rx_skb->data, pkt_len, 0);
1189 skb_put(skb, pkt_len); 1189 skb_put(skb, pkt_len);
1190 pci_dma_sync_single_for_device(yp->pci_dev, desc->addr, 1190 pci_dma_sync_single_for_device(yp->pci_dev, desc->addr,
1191 yp->rx_buf_sz, 1191 yp->rx_buf_sz,
@@ -1211,7 +1211,7 @@ static int yellowfin_rx(struct net_device *dev)
1211 skb->dev = dev; /* Mark as being used by this device. */ 1211 skb->dev = dev; /* Mark as being used by this device. */
1212 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1212 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1213 yp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 1213 yp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev,
1214 skb->tail, yp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1214 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE));
1215 } 1215 }
1216 yp->rx_ring[entry].dbdma_cmd = cpu_to_le32(CMD_STOP); 1216 yp->rx_ring[entry].dbdma_cmd = cpu_to_le32(CMD_STOP);
1217 yp->rx_ring[entry].result_status = 0; /* Clear complete bit. */ 1217 yp->rx_ring[entry].result_status = 0; /* Clear complete bit. */