aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firmware/iscsi_ibft.c7
-rw-r--r--drivers/infiniband/core/sysfs.c10
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c23
-rw-r--r--drivers/infiniband/hw/nes/nes.c17
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c31
-rw-r--r--drivers/infiniband/hw/nes/nes_nic.c10
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c5
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h23
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c8
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c25
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c70
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c8
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c31
-rw-r--r--drivers/isdn/i4l/isdn_net.c127
-rw-r--r--drivers/isdn/i4l/isdn_net.h43
-rw-r--r--drivers/media/dvb/b2c2/flexcop.c2
-rw-r--r--drivers/media/dvb/bt8xx/dst.c4
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c3
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c5
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c3
-rw-r--r--drivers/message/fusion/mptlan.c12
-rw-r--r--drivers/net/3c501.c3
-rw-r--r--drivers/net/3c503.c3
-rw-r--r--drivers/net/3c505.c51
-rw-r--r--drivers/net/3c507.c4
-rw-r--r--drivers/net/3c509.c6
-rw-r--r--drivers/net/3c515.c5
-rw-r--r--drivers/net/3c523.c40
-rw-r--r--drivers/net/3c527.c4
-rw-r--r--drivers/net/3c59x.c13
-rw-r--r--drivers/net/7990.c1
-rw-r--r--drivers/net/8139cp.c6
-rw-r--r--drivers/net/8139too.c6
-rw-r--r--drivers/net/82596.c14
-rw-r--r--drivers/net/Kconfig28
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/a2065.c5
-rw-r--r--drivers/net/ac3200.c5
-rw-r--r--drivers/net/acenic.c6
-rw-r--r--drivers/net/amd8111e.c6
-rw-r--r--drivers/net/apne.c3
-rw-r--r--drivers/net/appletalk/cops.c1
-rw-r--r--drivers/net/appletalk/ipddp.c6
-rw-r--r--drivers/net/appletalk/ltpc.c13
-rw-r--r--drivers/net/arcnet/arc-rawmode.c5
-rw-r--r--drivers/net/arcnet/arc-rimi.c16
-rw-r--r--drivers/net/arcnet/arcnet.c32
-rw-r--r--drivers/net/arcnet/capmode.c7
-rw-r--r--drivers/net/arcnet/com20020-isa.c4
-rw-r--r--drivers/net/arcnet/com20020-pci.c2
-rw-r--r--drivers/net/arcnet/com20020.c10
-rw-r--r--drivers/net/arcnet/com90io.c4
-rw-r--r--drivers/net/arcnet/com90xx.c10
-rw-r--r--drivers/net/arcnet/rfc1051.c9
-rw-r--r--drivers/net/arcnet/rfc1201.c14
-rw-r--r--drivers/net/ariadne.c21
-rw-r--r--drivers/net/arm/am79c961a.c7
-rw-r--r--drivers/net/arm/at91_ether.c11
-rw-r--r--drivers/net/arm/ep93xx_eth.c2
-rw-r--r--drivers/net/arm/ether1.c5
-rw-r--r--drivers/net/arm/ether3.c5
-rw-r--r--drivers/net/arm/etherh.c5
-rw-r--r--drivers/net/arm/ixp4xx_eth.c1
-rw-r--r--drivers/net/at1700.c4
-rw-r--r--drivers/net/atarilance.c52
-rw-r--r--drivers/net/atl1e/atl1e_main.c7
-rw-r--r--drivers/net/atlx/atl1.c70
-rw-r--r--drivers/net/atlx/atl1.h4
-rw-r--r--drivers/net/atlx/atl2.c64
-rw-r--r--drivers/net/atlx/atl2.h1
-rw-r--r--drivers/net/atlx/atlx.c13
-rw-r--r--drivers/net/atp.c8
-rw-r--r--drivers/net/au1000_eth.c49
-rw-r--r--drivers/net/ax88796.c9
-rw-r--r--drivers/net/b44.c6
-rw-r--r--drivers/net/bfin_mac.c1
-rw-r--r--drivers/net/bmac.c7
-rw-r--r--drivers/net/bnx2.c37
-rw-r--r--drivers/net/bnx2.h35
-rw-r--r--drivers/net/bnx2x_main.c16
-rw-r--r--drivers/net/bonding/Makefile3
-rw-r--r--drivers/net/bonding/bond_3ad.c333
-rw-r--r--drivers/net/bonding/bond_3ad.h10
-rw-r--r--drivers/net/bonding/bond_alb.c17
-rw-r--r--drivers/net/bonding/bond_ipv6.c218
-rw-r--r--drivers/net/bonding/bond_main.c164
-rw-r--r--drivers/net/bonding/bond_sysfs.c128
-rw-r--r--drivers/net/bonding/bonding.h39
-rw-r--r--drivers/net/cassini.c6
-rw-r--r--drivers/net/chelsio/cxgb2.c60
-rw-r--r--drivers/net/chelsio/sge.c3
-rw-r--r--drivers/net/cpmac.c5
-rw-r--r--drivers/net/cris/eth_v10.c4
-rw-r--r--drivers/net/cs89x0.c14
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c69
-rw-r--r--drivers/net/cxgb3/sge.c1
-rw-r--r--drivers/net/de600.c4
-rw-r--r--drivers/net/de620.c9
-rw-r--r--drivers/net/declance.c7
-rw-r--r--drivers/net/defxx.c3
-rw-r--r--drivers/net/depca.c47
-rw-r--r--drivers/net/dl2k.c6
-rw-r--r--drivers/net/dm9000.c40
-rw-r--r--drivers/net/e100.c22
-rw-r--r--drivers/net/e1000/e1000_main.c21
-rw-r--r--drivers/net/e1000e/82571.c6
-rw-r--r--drivers/net/e1000e/defines.h7
-rw-r--r--drivers/net/e1000e/hw.h1
-rw-r--r--drivers/net/e1000e/netdev.c16
-rw-r--r--drivers/net/eepro.c8
-rw-r--r--drivers/net/eepro100.c2401
-rw-r--r--drivers/net/eexpress.c1
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c1
-rw-r--r--drivers/net/ehea/ehea_qmr.c10
-rw-r--r--drivers/net/enc28j60.c19
-rw-r--r--drivers/net/enic/enic_main.c1
-rw-r--r--drivers/net/enic/enic_res.c7
-rw-r--r--drivers/net/enic/vnic_dev.c10
-rw-r--r--drivers/net/epic100.c50
-rw-r--r--drivers/net/es3210.c9
-rw-r--r--drivers/net/eth16i.c3
-rw-r--r--drivers/net/ewrk3.c8
-rw-r--r--drivers/net/fealnx.c6
-rw-r--r--drivers/net/fec.c6
-rw-r--r--drivers/net/fec_mpc52xx.c3
-rw-r--r--drivers/net/forcedeth.c13
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c5
-rw-r--r--drivers/net/gianfar.c8
-rw-r--r--drivers/net/hamachi.c6
-rw-r--r--drivers/net/hamradio/6pack.c1
-rw-r--r--drivers/net/hamradio/baycom_epp.c1
-rw-r--r--drivers/net/hamradio/bpqether.c8
-rw-r--r--drivers/net/hamradio/dmascc.c1
-rw-r--r--drivers/net/hamradio/hdlcdrv.c1
-rw-r--r--drivers/net/hamradio/mkiss.c1
-rw-r--r--drivers/net/hamradio/scc.c1
-rw-r--r--drivers/net/hamradio/yam.c1
-rw-r--r--drivers/net/hp-plus.c3
-rw-r--r--drivers/net/hp.c3
-rw-r--r--drivers/net/hp100.c7
-rw-r--r--drivers/net/hydra.c5
-rw-r--r--drivers/net/ibm_newemac/core.c11
-rw-r--r--drivers/net/ibmlana.c6
-rw-r--r--drivers/net/ibmveth.c40
-rw-r--r--drivers/net/igb/igb_ethtool.c4
-rw-r--r--drivers/net/igb/igb_main.c8
-rw-r--r--drivers/net/ioc3-eth.c13
-rw-r--r--drivers/net/ipg.c9
-rw-r--r--drivers/net/irda/ali-ircc.c17
-rw-r--r--drivers/net/irda/au1k_ir.c1
-rw-r--r--drivers/net/irda/donauboe.c8
-rw-r--r--drivers/net/irda/irda-usb.c15
-rw-r--r--drivers/net/irda/kingsun-sir.c1
-rw-r--r--drivers/net/irda/ks959-sir.c1
-rw-r--r--drivers/net/irda/ksdazzle-sir.c1
-rw-r--r--drivers/net/irda/mcs7780.c1
-rw-r--r--drivers/net/irda/nsc-ircc.c17
-rw-r--r--drivers/net/irda/pxaficp_ir.c4
-rw-r--r--drivers/net/irda/sa1100_ir.c28
-rw-r--r--drivers/net/irda/sir_dev.c12
-rw-r--r--drivers/net/irda/stir4200.c1
-rw-r--r--drivers/net/irda/via-ircc.c16
-rw-r--r--drivers/net/irda/vlsi_ir.c37
-rw-r--r--drivers/net/irda/w83977af_ir.c15
-rw-r--r--drivers/net/isa-skeleton.c4
-rw-r--r--drivers/net/iseries_veth.c14
-rw-r--r--drivers/net/ixgb/ixgb_main.c4
-rw-r--r--drivers/net/ixgbe/ixgbe.h1
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c12
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c33
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c52
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.c68
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.h7
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h6
-rw-r--r--drivers/net/ixp2000/ixpdev.c2
-rw-r--r--drivers/net/jazzsonic.c4
-rw-r--r--drivers/net/jme.c13
-rw-r--r--drivers/net/korina.c1
-rw-r--r--drivers/net/lance.c4
-rw-r--r--drivers/net/lib82596.c14
-rw-r--r--drivers/net/lib8390.c1
-rw-r--r--drivers/net/lne390.c5
-rw-r--r--drivers/net/loopback.c15
-rw-r--r--drivers/net/lp486e.c29
-rw-r--r--drivers/net/mac89x0.c5
-rw-r--r--drivers/net/macb.c8
-rw-r--r--drivers/net/mace.c34
-rw-r--r--drivers/net/macmace.c6
-rw-r--r--drivers/net/macsonic.c9
-rw-r--r--drivers/net/macvlan.c26
-rw-r--r--drivers/net/meth.c4
-rw-r--r--drivers/net/mlx4/en_rx.c2
-rw-r--r--drivers/net/mlx4/mcg.c23
-rw-r--r--drivers/net/mlx4/mlx4_en.h8
-rw-r--r--drivers/net/mv643xx_eth.c7
-rw-r--r--drivers/net/mvme147.c9
-rw-r--r--drivers/net/myri10ge/myri10ge.c5
-rw-r--r--drivers/net/myri_sbus.c25
-rw-r--r--drivers/net/natsemi.c6
-rw-r--r--drivers/net/ne-h8300.c3
-rw-r--r--drivers/net/ne.c3
-rw-r--r--drivers/net/ne2.c6
-rw-r--r--drivers/net/ne2k-pci.c7
-rw-r--r--drivers/net/ne3210.c5
-rw-r--r--drivers/net/netconsole.c9
-rw-r--r--drivers/net/netx-eth.c1
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c2
-rw-r--r--drivers/net/netxen/netxen_nic_init.c2
-rw-r--r--drivers/net/netxen/netxen_nic_main.c12
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c7
-rw-r--r--drivers/net/ni5010.c6
-rw-r--r--drivers/net/ni52.c37
-rw-r--r--drivers/net/ni65.c1
-rw-r--r--drivers/net/niu.c6
-rw-r--r--drivers/net/ns83820.c6
-rw-r--r--drivers/net/pasemi_mac.c8
-rw-r--r--drivers/net/pasemi_mac_ethtool.c4
-rw-r--r--drivers/net/pci-skeleton.c6
-rw-r--r--drivers/net/pcmcia/3c574_cs.c6
-rw-r--r--drivers/net/pcmcia/3c589_cs.c6
-rw-r--r--drivers/net/pcmcia/axnet_cs.c6
-rw-r--r--drivers/net/pcmcia/com20020_cs.c6
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c79
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c6
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c3
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c5
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c6
-rw-r--r--drivers/net/pcnet32.c4
-rw-r--r--drivers/net/phy/Kconfig7
-rw-r--r--drivers/net/phy/Makefile2
-rw-r--r--drivers/net/phy/broadcom.c195
-rw-r--r--drivers/net/phy/mdio-gpio.c296
-rw-r--r--drivers/net/phy/mdio-ofgpio.c204
-rw-r--r--drivers/net/phy/mdio_bus.c4
-rw-r--r--drivers/net/phy/phy.c2
-rw-r--r--drivers/net/phy/phy_device.c4
-rw-r--r--drivers/net/phy/smsc.c28
-rw-r--r--drivers/net/plip.c9
-rw-r--r--drivers/net/ppp_generic.c1
-rw-r--r--drivers/net/pppoe.c5
-rw-r--r--drivers/net/ps3_gelic_net.c6
-rw-r--r--drivers/net/ps3_gelic_wireless.c37
-rw-r--r--drivers/net/ps3_gelic_wireless.h4
-rw-r--r--drivers/net/qla3xxx.c11
-rw-r--r--drivers/net/qlge/qlge_main.c12
-rw-r--r--drivers/net/r6040.c1
-rw-r--r--drivers/net/r8169.c1
-rw-r--r--drivers/net/rionet.c31
-rw-r--r--drivers/net/rrunner.c4
-rw-r--r--drivers/net/s2io.c89
-rw-r--r--drivers/net/sb1000.c1
-rw-r--r--drivers/net/sb1250-mac.c5
-rw-r--r--drivers/net/sc92031.c1
-rw-r--r--drivers/net/seeq8005.c4
-rw-r--r--drivers/net/sfc/Kconfig8
-rw-r--r--drivers/net/sfc/Makefile1
-rw-r--r--drivers/net/sfc/boards.c136
-rw-r--r--drivers/net/sfc/efx.c47
-rw-r--r--drivers/net/sfc/efx.h10
-rw-r--r--drivers/net/sfc/enum.h4
-rw-r--r--drivers/net/sfc/ethtool.c15
-rw-r--r--drivers/net/sfc/falcon.c23
-rw-r--r--drivers/net/sfc/falcon_hwdefs.h1
-rw-r--r--drivers/net/sfc/mdio_10g.c35
-rw-r--r--drivers/net/sfc/mdio_10g.h7
-rw-r--r--drivers/net/sfc/mtd.c268
-rw-r--r--drivers/net/sfc/net_driver.h8
-rw-r--r--drivers/net/sfc/rx.c2
-rw-r--r--drivers/net/sfc/sfe4001.c116
-rw-r--r--drivers/net/sfc/spi.h34
-rw-r--r--drivers/net/sfc/tenxpress.c18
-rw-r--r--drivers/net/sfc/workarounds.h2
-rw-r--r--drivers/net/sfc/xfp_phy.c9
-rw-r--r--drivers/net/sgiseeq.c7
-rw-r--r--drivers/net/sh_eth.c3
-rw-r--r--drivers/net/sis190.c7
-rw-r--r--drivers/net/sis900.c70
-rw-r--r--drivers/net/skfp/skfddi.c2
-rw-r--r--drivers/net/skge.c44
-rw-r--r--drivers/net/sky2.c5
-rw-r--r--drivers/net/slip.c1
-rw-r--r--drivers/net/smc-mca.c5
-rw-r--r--drivers/net/smc-ultra.c5
-rw-r--r--drivers/net/smc-ultra32.c5
-rw-r--r--drivers/net/smc911x.c2
-rw-r--r--drivers/net/smc9194.c11
-rw-r--r--drivers/net/smc91x.c8
-rw-r--r--drivers/net/smsc911x.c2091
-rw-r--r--drivers/net/smsc911x.h394
-rw-r--r--drivers/net/sonic.c1
-rw-r--r--drivers/net/sonic.h20
-rw-r--r--drivers/net/spider_net_ethtool.c8
-rw-r--r--drivers/net/starfire.c14
-rw-r--r--drivers/net/sun3_82586.c38
-rw-r--r--drivers/net/sun3lance.c10
-rw-r--r--drivers/net/sunbmac.c20
-rw-r--r--drivers/net/sundance.c6
-rw-r--r--drivers/net/sungem.c59
-rw-r--r--drivers/net/sunhme.c31
-rw-r--r--drivers/net/sunlance.c7
-rw-r--r--drivers/net/sunqe.c15
-rw-r--r--drivers/net/sunvnet.c5
-rw-r--r--drivers/net/tc35815.c23
-rw-r--r--drivers/net/tehuti.c39
-rw-r--r--drivers/net/tg3.c372
-rw-r--r--drivers/net/tg3.h111
-rw-r--r--drivers/net/tlan.c2
-rw-r--r--drivers/net/tokenring/3c359.c2
-rw-r--r--drivers/net/tokenring/abyss.c4
-rw-r--r--drivers/net/tokenring/ibmtr.c11
-rw-r--r--drivers/net/tokenring/lanstreamer.c36
-rw-r--r--drivers/net/tokenring/madgemc.c10
-rw-r--r--drivers/net/tokenring/olympic.c52
-rw-r--r--drivers/net/tokenring/proteon.c5
-rw-r--r--drivers/net/tokenring/skisa.c5
-rw-r--r--drivers/net/tokenring/smctr.c2
-rw-r--r--drivers/net/tokenring/tms380tr.c15
-rw-r--r--drivers/net/tokenring/tmspci.c5
-rw-r--r--drivers/net/tsi108_eth.c6
-rw-r--r--drivers/net/tulip/de2104x.c50
-rw-r--r--drivers/net/tulip/de4x5.c17
-rw-r--r--drivers/net/tulip/dmfe.c7
-rw-r--r--drivers/net/tulip/eeprom.c2
-rw-r--r--drivers/net/tulip/interrupt.c2
-rw-r--r--drivers/net/tulip/tulip_core.c11
-rw-r--r--drivers/net/tulip/uli526x.c8
-rw-r--r--drivers/net/tulip/winbond-840.c16
-rw-r--r--drivers/net/tulip/xircom_cb.c4
-rw-r--r--drivers/net/tun.c6
-rw-r--r--drivers/net/typhoon.c8
-rw-r--r--drivers/net/ucc_geth.c6
-rw-r--r--drivers/net/usb/catc.c2
-rw-r--r--drivers/net/usb/mcs7830.c4
-rw-r--r--drivers/net/usb/pegasus.c41
-rw-r--r--drivers/net/usb/smsc95xx.c4
-rw-r--r--drivers/net/usb/usbnet.c5
-rw-r--r--drivers/net/veth.c16
-rw-r--r--drivers/net/via-rhine.c6
-rw-r--r--drivers/net/via-velocity.c2
-rw-r--r--drivers/net/virtio_net.c193
-rw-r--r--drivers/net/wan/cosa.c1
-rw-r--r--drivers/net/wan/cycx_x25.c2
-rw-r--r--drivers/net/wan/dlci.c37
-rw-r--r--drivers/net/wan/dscc4.c4
-rw-r--r--drivers/net/wan/farsync.c2
-rw-r--r--drivers/net/wan/hd6457x.c1
-rw-r--r--drivers/net/wan/hostess_sv11.c1
-rw-r--r--drivers/net/wan/lapbether.c3
-rw-r--r--drivers/net/wan/lmc/lmc_main.c1
-rw-r--r--drivers/net/wan/lmc/lmc_proto.c1
-rw-r--r--drivers/net/wan/pc300too.c2
-rw-r--r--drivers/net/wan/pci200syn.c2
-rw-r--r--drivers/net/wan/sbni.c2
-rw-r--r--drivers/net/wan/sdla.c48
-rw-r--r--drivers/net/wan/sealevel.c1
-rw-r--r--drivers/net/wan/syncppp.c4
-rw-r--r--drivers/net/wan/wanxl.c1
-rw-r--r--drivers/net/wan/x25_asy.c32
-rw-r--r--drivers/net/wd.c5
-rw-r--r--drivers/net/wireless/Kconfig1
-rw-r--r--drivers/net/wireless/Makefile9
-rw-r--r--drivers/net/wireless/adm8211.c52
-rw-r--r--drivers/net/wireless/adm8211.h2
-rw-r--r--drivers/net/wireless/airo.c241
-rw-r--r--drivers/net/wireless/arlan-main.c27
-rw-r--r--drivers/net/wireless/ath5k/ath5k.h89
-rw-r--r--drivers/net/wireless/ath5k/base.c131
-rw-r--r--drivers/net/wireless/ath5k/dma.c190
-rw-r--r--drivers/net/wireless/ath5k/initvals.c8
-rw-r--r--drivers/net/wireless/ath5k/pcu.c184
-rw-r--r--drivers/net/wireless/ath5k/phy.c5
-rw-r--r--drivers/net/wireless/ath5k/qcu.c37
-rw-r--r--drivers/net/wireless/ath5k/reg.h15
-rw-r--r--drivers/net/wireless/ath5k/reset.c3
-rw-r--r--drivers/net/wireless/ath9k/Makefile4
-rw-r--r--drivers/net/wireless/ath9k/ani.c854
-rw-r--r--drivers/net/wireless/ath9k/ath9k.h389
-rw-r--r--drivers/net/wireless/ath9k/beacon.c42
-rw-r--r--drivers/net/wireless/ath9k/calib.c930
-rw-r--r--drivers/net/wireless/ath9k/core.c486
-rw-r--r--drivers/net/wireless/ath9k/core.h165
-rw-r--r--drivers/net/wireless/ath9k/eeprom.c1605
-rw-r--r--drivers/net/wireless/ath9k/hw.c8496
-rw-r--r--drivers/net/wireless/ath9k/hw.h2
-rw-r--r--drivers/net/wireless/ath9k/mac.c1031
-rw-r--r--drivers/net/wireless/ath9k/main.c549
-rw-r--r--drivers/net/wireless/ath9k/phy.c10
-rw-r--r--drivers/net/wireless/ath9k/rc.c145
-rw-r--r--drivers/net/wireless/ath9k/rc.h1
-rw-r--r--drivers/net/wireless/ath9k/recv.c537
-rw-r--r--drivers/net/wireless/ath9k/xmit.c1037
-rw-r--r--drivers/net/wireless/atmel.c77
-rw-r--r--drivers/net/wireless/b43/b43.h1
-rw-r--r--drivers/net/wireless/b43/dma.c4
-rw-r--r--drivers/net/wireless/b43/main.c227
-rw-r--r--drivers/net/wireless/b43/pio.c3
-rw-r--r--drivers/net/wireless/b43/xmit.c60
-rw-r--r--drivers/net/wireless/b43/xmit.h5
-rw-r--r--drivers/net/wireless/b43legacy/dma.c48
-rw-r--r--drivers/net/wireless/b43legacy/main.c100
-rw-r--r--drivers/net/wireless/b43legacy/pio.c31
-rw-r--r--drivers/net/wireless/b43legacy/xmit.c26
-rw-r--r--drivers/net/wireless/b43legacy/xmit.h2
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_rx.c62
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_tx.c15
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c241
-rw-r--r--drivers/net/wireless/hostap/hostap_common.h13
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c10
-rw-r--r--drivers/net/wireless/hostap/hostap_info.c16
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c16
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c26
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_proc.c15
-rw-r--r--drivers/net/wireless/hostap/hostap_wlan.h2
-rw-r--r--drivers/net/wireless/ipw2100.c53
-rw-r--r--drivers/net/wireless/ipw2200.c415
-rw-r--r--drivers/net/wireless/ipw2200.h1
-rw-r--r--drivers/net/wireless/iwlwifi/Kconfig2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-commands.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-io.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c76
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c74
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-hw.h148
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c140
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000-hw.h39
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c284
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c104
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c604
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h197
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c186
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h66
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fh.h60
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-helpers.h107
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-prph.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rfkill.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c129
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c100
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c359
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c217
-rw-r--r--drivers/net/wireless/libertas/assoc.c69
-rw-r--r--drivers/net/wireless/libertas/cmd.c14
-rw-r--r--drivers/net/wireless/libertas/debugfs.c11
-rw-r--r--drivers/net/wireless/libertas/decl.h4
-rw-r--r--drivers/net/wireless/libertas/defs.h2
-rw-r--r--drivers/net/wireless/libertas/dev.h7
-rw-r--r--drivers/net/wireless/libertas/ethtool.c12
-rw-r--r--drivers/net/wireless/libertas/main.c75
-rw-r--r--drivers/net/wireless/libertas/persistcfg.c18
-rw-r--r--drivers/net/wireless/libertas/scan.c105
-rw-r--r--drivers/net/wireless/libertas/scan.h4
-rw-r--r--drivers/net/wireless/libertas/tx.c2
-rw-r--r--drivers/net/wireless/libertas/types.h5
-rw-r--r--drivers/net/wireless/libertas/wext.c80
-rw-r--r--drivers/net/wireless/libertas_tf/cmd.c5
-rw-r--r--drivers/net/wireless/libertas_tf/if_usb.c2
-rw-r--r--drivers/net/wireless/libertas_tf/main.c8
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c288
-rw-r--r--drivers/net/wireless/netwave_cs.c6
-rw-r--r--drivers/net/wireless/orinoco/Makefile12
-rw-r--r--drivers/net/wireless/orinoco/airport.c (renamed from drivers/net/wireless/airport.c)0
-rw-r--r--drivers/net/wireless/orinoco/hermes.c (renamed from drivers/net/wireless/hermes.c)0
-rw-r--r--drivers/net/wireless/orinoco/hermes.h (renamed from drivers/net/wireless/hermes.h)0
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.c (renamed from drivers/net/wireless/hermes_dld.c)0
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.h (renamed from drivers/net/wireless/hermes_dld.h)0
-rw-r--r--drivers/net/wireless/orinoco/hermes_rid.h (renamed from drivers/net/wireless/hermes_rid.h)0
-rw-r--r--drivers/net/wireless/orinoco/orinoco.c (renamed from drivers/net/wireless/orinoco.c)83
-rw-r--r--drivers/net/wireless/orinoco/orinoco.h (renamed from drivers/net/wireless/orinoco.h)5
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c (renamed from drivers/net/wireless/orinoco_cs.c)2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_nortel.c (renamed from drivers/net/wireless/orinoco_nortel.c)0
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.c (renamed from drivers/net/wireless/orinoco_pci.c)0
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.h (renamed from drivers/net/wireless/orinoco_pci.h)0
-rw-r--r--drivers/net/wireless/orinoco/orinoco_plx.c (renamed from drivers/net/wireless/orinoco_plx.c)0
-rw-r--r--drivers/net/wireless/orinoco/orinoco_tmd.c (renamed from drivers/net/wireless/orinoco_tmd.c)0
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c (renamed from drivers/net/wireless/spectrum_cs.c)2
-rw-r--r--drivers/net/wireless/p54/p54.h52
-rw-r--r--drivers/net/wireless/p54/p54common.c1160
-rw-r--r--drivers/net/wireless/p54/p54common.h316
-rw-r--r--drivers/net/wireless/p54/p54pci.c33
-rw-r--r--drivers/net/wireless/p54/p54usb.c98
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c24
-rw-r--r--drivers/net/wireless/ray_cs.c10
-rw-r--r--drivers/net/wireless/rndis_wlan.c95
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c194
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c234
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c139
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h43
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c176
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00debug.c47
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00debug.h13
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c38
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c20
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.h8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c24
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.h9
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c260
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c245
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.h2
-rw-r--r--drivers/net/wireless/rtl8180_dev.c36
-rw-r--r--drivers/net/wireless/rtl8187.h1
-rw-r--r--drivers/net/wireless/rtl8187_dev.c133
-rw-r--r--drivers/net/wireless/rtl8187_rtl8225.c391
-rw-r--r--drivers/net/wireless/strip.c2
-rw-r--r--drivers/net/wireless/wavelan.c122
-rw-r--r--drivers/net/wireless/wavelan_cs.c39
-rw-r--r--drivers/net/wireless/wl3501.h4
-rw-r--r--drivers/net/wireless/wl3501_cs.c11
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c4
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c44
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c2
-rw-r--r--drivers/net/xen-netfront.c1
-rw-r--r--drivers/net/xtsonic.c6
-rw-r--r--drivers/net/yellowfin.c14
-rw-r--r--drivers/net/znet.c28
-rw-r--r--drivers/net/zorro8390.c7
-rw-r--r--drivers/s390/net/qeth_l2_main.c18
-rw-r--r--drivers/scsi/iscsi_tcp.c4
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c3
-rw-r--r--drivers/usb/atm/cxacru.c4
-rw-r--r--drivers/usb/atm/usbatm.c5
-rw-r--r--drivers/usb/gadget/u_ether.c6
-rw-r--r--drivers/uwb/wlp/eda.c38
542 files changed, 19631 insertions, 19129 deletions
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index 4353414a0b77..3ab3e4a41d67 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -284,15 +284,12 @@ static ssize_t sprintf_ipaddr(char *buf, u8 *ip)
284 /* 284 /*
285 * IPV4 285 * IPV4
286 */ 286 */
287 str += sprintf(buf, NIPQUAD_FMT, ip[12], 287 str += sprintf(buf, "%pI4", ip + 12);
288 ip[13], ip[14], ip[15]);
289 } else { 288 } else {
290 /* 289 /*
291 * IPv6 290 * IPv6
292 */ 291 */
293 str += sprintf(str, NIP6_FMT, ntohs(ip[0]), ntohs(ip[1]), 292 str += sprintf(str, "%pI6", ip);
294 ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]),
295 ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7]));
296 } 293 }
297 str += sprintf(str, "\n"); 294 str += sprintf(str, "\n");
298 return str - buf; 295 return str - buf;
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 4d1042115598..4f4d1bb9f069 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -262,15 +262,7 @@ static ssize_t show_port_gid(struct ib_port *p, struct port_attribute *attr,
262 if (ret) 262 if (ret)
263 return ret; 263 return ret;
264 264
265 return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", 265 return sprintf(buf, "%pI6\n", gid.raw);
266 be16_to_cpu(((__be16 *) gid.raw)[0]),
267 be16_to_cpu(((__be16 *) gid.raw)[1]),
268 be16_to_cpu(((__be16 *) gid.raw)[2]),
269 be16_to_cpu(((__be16 *) gid.raw)[3]),
270 be16_to_cpu(((__be16 *) gid.raw)[4]),
271 be16_to_cpu(((__be16 *) gid.raw)[5]),
272 be16_to_cpu(((__be16 *) gid.raw)[6]),
273 be16_to_cpu(((__be16 *) gid.raw)[7]));
274} 266}
275 267
276static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr, 268static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index 3f5f94879208..d4c81053e439 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -87,17 +87,7 @@ static int find_mgm(struct mthca_dev *dev,
87 } 87 }
88 88
89 if (0) 89 if (0)
90 mthca_dbg(dev, "Hash for %04x:%04x:%04x:%04x:" 90 mthca_dbg(dev, "Hash for %pI6 is %04x\n", gid, *hash);
91 "%04x:%04x:%04x:%04x is %04x\n",
92 be16_to_cpu(((__be16 *) gid)[0]),
93 be16_to_cpu(((__be16 *) gid)[1]),
94 be16_to_cpu(((__be16 *) gid)[2]),
95 be16_to_cpu(((__be16 *) gid)[3]),
96 be16_to_cpu(((__be16 *) gid)[4]),
97 be16_to_cpu(((__be16 *) gid)[5]),
98 be16_to_cpu(((__be16 *) gid)[6]),
99 be16_to_cpu(((__be16 *) gid)[7]),
100 *hash);
101 91
102 *index = *hash; 92 *index = *hash;
103 *prev = -1; 93 *prev = -1;
@@ -264,16 +254,7 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
264 goto out; 254 goto out;
265 255
266 if (index == -1) { 256 if (index == -1) {
267 mthca_err(dev, "MGID %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x " 257 mthca_err(dev, "MGID %pI6 not found\n", gid->raw);
268 "not found\n",
269 be16_to_cpu(((__be16 *) gid->raw)[0]),
270 be16_to_cpu(((__be16 *) gid->raw)[1]),
271 be16_to_cpu(((__be16 *) gid->raw)[2]),
272 be16_to_cpu(((__be16 *) gid->raw)[3]),
273 be16_to_cpu(((__be16 *) gid->raw)[4]),
274 be16_to_cpu(((__be16 *) gid->raw)[5]),
275 be16_to_cpu(((__be16 *) gid->raw)[6]),
276 be16_to_cpu(((__be16 *) gid->raw)[7]));
277 err = -EINVAL; 258 err = -EINVAL;
278 goto out; 259 goto out;
279 } 260 }
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index aa1dc41f04c8..b9611ade9eab 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -142,14 +142,9 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
142 struct nes_device *nesdev; 142 struct nes_device *nesdev;
143 struct net_device *netdev; 143 struct net_device *netdev;
144 struct nes_vnic *nesvnic; 144 struct nes_vnic *nesvnic;
145 unsigned int addr; 145
146 unsigned int mask; 146 nes_debug(NES_DBG_NETDEV, "nes_inetaddr_event: ip address %pI4, netmask %pI4.\n",
147 147 &ifa->ifa_address, &ifa->ifa_mask);
148 addr = ntohl(ifa->ifa_address);
149 mask = ntohl(ifa->ifa_mask);
150 nes_debug(NES_DBG_NETDEV, "nes_inetaddr_event: ip address " NIPQUAD_FMT
151 ", netmask " NIPQUAD_FMT ".\n",
152 HIPQUAD(addr), HIPQUAD(mask));
153 list_for_each_entry(nesdev, &nes_dev_list, list) { 148 list_for_each_entry(nesdev, &nes_dev_list, list) {
154 nes_debug(NES_DBG_NETDEV, "Nesdev list entry = 0x%p. (%s)\n", 149 nes_debug(NES_DBG_NETDEV, "Nesdev list entry = 0x%p. (%s)\n",
155 nesdev, nesdev->netdev[0]->name); 150 nesdev, nesdev->netdev[0]->name);
@@ -360,10 +355,8 @@ struct ib_qp *nes_get_qp(struct ib_device *device, int qpn)
360 */ 355 */
361static void nes_print_macaddr(struct net_device *netdev) 356static void nes_print_macaddr(struct net_device *netdev)
362{ 357{
363 DECLARE_MAC_BUF(mac); 358 nes_debug(NES_DBG_INIT, "%s: %pM, IRQ %u\n",
364 359 netdev->name, netdev->dev_addr, netdev->irq);
365 nes_debug(NES_DBG_INIT, "%s: %s, IRQ %u\n",
366 netdev->name, print_mac(mac, netdev->dev_addr), netdev->irq);
367} 360}
368 361
369/** 362/**
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 2caf9da81ad5..2854a6f7fdfe 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -823,8 +823,8 @@ static struct nes_cm_node *find_node(struct nes_cm_core *cm_core,
823 /* get a handle on the hte */ 823 /* get a handle on the hte */
824 hte = &cm_core->connected_nodes; 824 hte = &cm_core->connected_nodes;
825 825
826 nes_debug(NES_DBG_CM, "Searching for an owner node: " NIPQUAD_FMT ":%x from core %p->%p\n", 826 nes_debug(NES_DBG_CM, "Searching for an owner node: %pI4:%x from core %p->%p\n",
827 HIPQUAD(loc_addr), loc_port, cm_core, hte); 827 &loc_addr, loc_port, cm_core, hte);
828 828
829 /* walk list and find cm_node associated with this session ID */ 829 /* walk list and find cm_node associated with this session ID */
830 spin_lock_irqsave(&cm_core->ht_lock, flags); 830 spin_lock_irqsave(&cm_core->ht_lock, flags);
@@ -873,8 +873,8 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
873 } 873 }
874 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags); 874 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
875 875
876 nes_debug(NES_DBG_CM, "Unable to find listener for " NIPQUAD_FMT ":%x\n", 876 nes_debug(NES_DBG_CM, "Unable to find listener for %pI4:%x\n",
877 HIPQUAD(dst_addr), dst_port); 877 &dst_addr, dst_port);
878 878
879 /* no listener */ 879 /* no listener */
880 return NULL; 880 return NULL;
@@ -1027,7 +1027,6 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip)
1027 struct flowi fl; 1027 struct flowi fl;
1028 struct neighbour *neigh; 1028 struct neighbour *neigh;
1029 int rc = -1; 1029 int rc = -1;
1030 DECLARE_MAC_BUF(mac);
1031 1030
1032 memset(&fl, 0, sizeof fl); 1031 memset(&fl, 0, sizeof fl);
1033 fl.nl_u.ip4_u.daddr = htonl(dst_ip); 1032 fl.nl_u.ip4_u.daddr = htonl(dst_ip);
@@ -1041,8 +1040,8 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip)
1041 if (neigh) { 1040 if (neigh) {
1042 if (neigh->nud_state & NUD_VALID) { 1041 if (neigh->nud_state & NUD_VALID) {
1043 nes_debug(NES_DBG_CM, "Neighbor MAC address for 0x%08X" 1042 nes_debug(NES_DBG_CM, "Neighbor MAC address for 0x%08X"
1044 " is %s, Gateway is 0x%08X \n", dst_ip, 1043 " is %pM, Gateway is 0x%08X \n", dst_ip,
1045 print_mac(mac, neigh->ha), ntohl(rt->rt_gateway)); 1044 neigh->ha, ntohl(rt->rt_gateway));
1046 nes_manage_arp_cache(nesvnic->netdev, neigh->ha, 1045 nes_manage_arp_cache(nesvnic->netdev, neigh->ha,
1047 dst_ip, NES_ARP_ADD); 1046 dst_ip, NES_ARP_ADD);
1048 rc = nes_arp_table(nesvnic->nesdev, dst_ip, NULL, 1047 rc = nes_arp_table(nesvnic->nesdev, dst_ip, NULL,
@@ -1071,7 +1070,6 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
1071 int arpindex = 0; 1070 int arpindex = 0;
1072 struct nes_device *nesdev; 1071 struct nes_device *nesdev;
1073 struct nes_adapter *nesadapter; 1072 struct nes_adapter *nesadapter;
1074 DECLARE_MAC_BUF(mac);
1075 1073
1076 /* create an hte and cm_node for this instance */ 1074 /* create an hte and cm_node for this instance */
1077 cm_node = kzalloc(sizeof(*cm_node), GFP_ATOMIC); 1075 cm_node = kzalloc(sizeof(*cm_node), GFP_ATOMIC);
@@ -1084,10 +1082,9 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
1084 cm_node->loc_port = cm_info->loc_port; 1082 cm_node->loc_port = cm_info->loc_port;
1085 cm_node->rem_port = cm_info->rem_port; 1083 cm_node->rem_port = cm_info->rem_port;
1086 cm_node->send_write0 = send_first; 1084 cm_node->send_write0 = send_first;
1087 nes_debug(NES_DBG_CM, "Make node addresses : loc = " NIPQUAD_FMT 1085 nes_debug(NES_DBG_CM, "Make node addresses : loc = %pI4:%x, rem = %pI4:%x\n",
1088 ":%x, rem = " NIPQUAD_FMT ":%x\n", 1086 &cm_node->loc_addr, cm_node->loc_port,
1089 HIPQUAD(cm_node->loc_addr), cm_node->loc_port, 1087 &cm_node->rem_addr, cm_node->rem_port);
1090 HIPQUAD(cm_node->rem_addr), cm_node->rem_port);
1091 cm_node->listener = listener; 1088 cm_node->listener = listener;
1092 cm_node->netdev = nesvnic->netdev; 1089 cm_node->netdev = nesvnic->netdev;
1093 cm_node->cm_id = cm_info->cm_id; 1090 cm_node->cm_id = cm_info->cm_id;
@@ -1137,8 +1134,8 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
1137 1134
1138 /* copy the mac addr to node context */ 1135 /* copy the mac addr to node context */
1139 memcpy(cm_node->rem_mac, nesadapter->arp_table[arpindex].mac_addr, ETH_ALEN); 1136 memcpy(cm_node->rem_mac, nesadapter->arp_table[arpindex].mac_addr, ETH_ALEN);
1140 nes_debug(NES_DBG_CM, "Remote mac addr from arp table: %s\n", 1137 nes_debug(NES_DBG_CM, "Remote mac addr from arp table: %pM\n",
1141 print_mac(mac, cm_node->rem_mac)); 1138 cm_node->rem_mac);
1142 1139
1143 add_hte_node(cm_core, cm_node); 1140 add_hte_node(cm_core, cm_node);
1144 atomic_inc(&cm_nodes_created); 1141 atomic_inc(&cm_nodes_created);
@@ -2068,10 +2065,8 @@ static void mini_cm_recv_pkt(struct nes_cm_core *cm_core,
2068 nfo.rem_addr = ntohl(iph->saddr); 2065 nfo.rem_addr = ntohl(iph->saddr);
2069 nfo.rem_port = ntohs(tcph->source); 2066 nfo.rem_port = ntohs(tcph->source);
2070 2067
2071 nes_debug(NES_DBG_CM, "Received packet: dest=" NIPQUAD_FMT 2068 nes_debug(NES_DBG_CM, "Received packet: dest=%pI4:0x%04X src=%pI4:0x%04X\n",
2072 ":0x%04X src=" NIPQUAD_FMT ":0x%04X\n", 2069 &iph->daddr, tcph->dest, &iph->saddr, tcph->source);
2073 NIPQUAD(iph->daddr), tcph->dest,
2074 NIPQUAD(iph->saddr), tcph->source);
2075 2070
2076 do { 2071 do {
2077 cm_node = find_node(cm_core, 2072 cm_node = find_node(cm_core,
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 730358637bb6..3c96203e0d91 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -797,14 +797,13 @@ static int nes_netdev_set_mac_address(struct net_device *netdev, void *p)
797 int i; 797 int i;
798 u32 macaddr_low; 798 u32 macaddr_low;
799 u16 macaddr_high; 799 u16 macaddr_high;
800 DECLARE_MAC_BUF(mac);
801 800
802 if (!is_valid_ether_addr(mac_addr->sa_data)) 801 if (!is_valid_ether_addr(mac_addr->sa_data))
803 return -EADDRNOTAVAIL; 802 return -EADDRNOTAVAIL;
804 803
805 memcpy(netdev->dev_addr, mac_addr->sa_data, netdev->addr_len); 804 memcpy(netdev->dev_addr, mac_addr->sa_data, netdev->addr_len);
806 printk(PFX "%s: Address length = %d, Address = %s\n", 805 printk(PFX "%s: Address length = %d, Address = %pM\n",
807 __func__, netdev->addr_len, print_mac(mac, mac_addr->sa_data)); 806 __func__, netdev->addr_len, mac_addr->sa_data);
808 macaddr_high = ((u16)netdev->dev_addr[0]) << 8; 807 macaddr_high = ((u16)netdev->dev_addr[0]) << 8;
809 macaddr_high += (u16)netdev->dev_addr[1]; 808 macaddr_high += (u16)netdev->dev_addr[1];
810 macaddr_low = ((u32)netdev->dev_addr[2]) << 24; 809 macaddr_low = ((u32)netdev->dev_addr[2]) << 24;
@@ -909,9 +908,8 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
909 if (mc_index >= max_pft_entries_avaiable) 908 if (mc_index >= max_pft_entries_avaiable)
910 break; 909 break;
911 if (multicast_addr) { 910 if (multicast_addr) {
912 DECLARE_MAC_BUF(mac); 911 nes_debug(NES_DBG_NIC_RX, "Assigning MC Address %pM to register 0x%04X nic_idx=%d\n",
913 nes_debug(NES_DBG_NIC_RX, "Assigning MC Address %s to register 0x%04X nic_idx=%d\n", 912 multicast_addr->dmi_addr,
914 print_mac(mac, multicast_addr->dmi_addr),
915 perfect_filter_register_address+(mc_index * 8), 913 perfect_filter_register_address+(mc_index * 8),
916 mc_nic_index); 914 mc_nic_index);
917 macaddr_high = ((u16)multicast_addr->dmi_addr[0]) << 8; 915 macaddr_high = ((u16)multicast_addr->dmi_addr[0]) << 8;
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index fb8cbd71a2ef..9f16f7a89efc 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -679,9 +679,8 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
679 679
680 /* DELETE or RESOLVE */ 680 /* DELETE or RESOLVE */
681 if (arp_index == nesadapter->arp_table_size) { 681 if (arp_index == nesadapter->arp_table_size) {
682 nes_debug(NES_DBG_NETDEV, "MAC for " NIPQUAD_FMT " not in ARP table - cannot %s\n", 682 nes_debug(NES_DBG_NETDEV, "MAC for %pI4 not in ARP table - cannot %s\n",
683 HIPQUAD(ip_addr), 683 &ip_addr, action == NES_ARP_RESOLVE ? "resolve" : "delete");
684 action == NES_ARP_RESOLVE ? "resolve" : "delete");
685 return -1; 684 return -1;
686 } 685 }
687 686
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index e0c7dfabf2b4..753a983a5fdc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -732,29 +732,6 @@ extern int ipoib_debug_level;
732 do { (void) (priv); } while (0) 732 do { (void) (priv); } while (0)
733#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 733#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
734 734
735
736#define IPOIB_GID_FMT "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:" \
737 "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x"
738
739#define IPOIB_GID_RAW_ARG(gid) ((u8 *)(gid))[0], \
740 ((u8 *)(gid))[1], \
741 ((u8 *)(gid))[2], \
742 ((u8 *)(gid))[3], \
743 ((u8 *)(gid))[4], \
744 ((u8 *)(gid))[5], \
745 ((u8 *)(gid))[6], \
746 ((u8 *)(gid))[7], \
747 ((u8 *)(gid))[8], \
748 ((u8 *)(gid))[9], \
749 ((u8 *)(gid))[10],\
750 ((u8 *)(gid))[11],\
751 ((u8 *)(gid))[12],\
752 ((u8 *)(gid))[13],\
753 ((u8 *)(gid))[14],\
754 ((u8 *)(gid))[15]
755
756#define IPOIB_GID_ARG(gid) IPOIB_GID_RAW_ARG((gid).raw)
757
758#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff) 735#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
759 736
760#endif /* _IPOIB_H */ 737#endif /* _IPOIB_H */
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 7b14c2c39500..47d588ba2a7f 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -1128,8 +1128,8 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
1128 goto err_send_cm; 1128 goto err_send_cm;
1129 } 1129 }
1130 1130
1131 ipoib_dbg(priv, "Request connection 0x%x for gid " IPOIB_GID_FMT " qpn 0x%x\n", 1131 ipoib_dbg(priv, "Request connection 0x%x for gid %pI6 qpn 0x%x\n",
1132 p->qp->qp_num, IPOIB_GID_ARG(pathrec->dgid), qpn); 1132 p->qp->qp_num, pathrec->dgid.raw, qpn);
1133 1133
1134 return 0; 1134 return 0;
1135 1135
@@ -1276,8 +1276,8 @@ void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)
1276 if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) { 1276 if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) {
1277 list_move(&tx->list, &priv->cm.reap_list); 1277 list_move(&tx->list, &priv->cm.reap_list);
1278 queue_work(ipoib_workqueue, &priv->cm.reap_task); 1278 queue_work(ipoib_workqueue, &priv->cm.reap_task);
1279 ipoib_dbg(priv, "Reap connection for gid " IPOIB_GID_FMT "\n", 1279 ipoib_dbg(priv, "Reap connection for gid %pI6\n",
1280 IPOIB_GID_ARG(tx->neigh->dgid)); 1280 tx->neigh->dgid.raw);
1281 tx->neigh = NULL; 1281 tx->neigh = NULL;
1282 } 1282 }
1283} 1283}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 85257f6b9576..19e06bc38b39 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -360,9 +360,9 @@ void ipoib_mark_paths_invalid(struct net_device *dev)
360 spin_lock_irq(&priv->lock); 360 spin_lock_irq(&priv->lock);
361 361
362 list_for_each_entry_safe(path, tp, &priv->path_list, list) { 362 list_for_each_entry_safe(path, tp, &priv->path_list, list) {
363 ipoib_dbg(priv, "mark path LID 0x%04x GID " IPOIB_GID_FMT " invalid\n", 363 ipoib_dbg(priv, "mark path LID 0x%04x GID %pI6 invalid\n",
364 be16_to_cpu(path->pathrec.dlid), 364 be16_to_cpu(path->pathrec.dlid),
365 IPOIB_GID_ARG(path->pathrec.dgid)); 365 path->pathrec.dgid.raw);
366 path->valid = 0; 366 path->valid = 0;
367 } 367 }
368 368
@@ -414,11 +414,11 @@ static void path_rec_completion(int status,
414 unsigned long flags; 414 unsigned long flags;
415 415
416 if (!status) 416 if (!status)
417 ipoib_dbg(priv, "PathRec LID 0x%04x for GID " IPOIB_GID_FMT "\n", 417 ipoib_dbg(priv, "PathRec LID 0x%04x for GID %pI6\n",
418 be16_to_cpu(pathrec->dlid), IPOIB_GID_ARG(pathrec->dgid)); 418 be16_to_cpu(pathrec->dlid), pathrec->dgid.raw);
419 else 419 else
420 ipoib_dbg(priv, "PathRec status %d for GID " IPOIB_GID_FMT "\n", 420 ipoib_dbg(priv, "PathRec status %d for GID %pI6\n",
421 status, IPOIB_GID_ARG(path->pathrec.dgid)); 421 status, path->pathrec.dgid.raw);
422 422
423 skb_queue_head_init(&skqueue); 423 skb_queue_head_init(&skqueue);
424 424
@@ -528,8 +528,8 @@ static int path_rec_start(struct net_device *dev,
528{ 528{
529 struct ipoib_dev_priv *priv = netdev_priv(dev); 529 struct ipoib_dev_priv *priv = netdev_priv(dev);
530 530
531 ipoib_dbg(priv, "Start path record lookup for " IPOIB_GID_FMT "\n", 531 ipoib_dbg(priv, "Start path record lookup for %pI6\n",
532 IPOIB_GID_ARG(path->pathrec.dgid)); 532 path->pathrec.dgid.raw);
533 533
534 init_completion(&path->done); 534 init_completion(&path->done);
535 535
@@ -766,12 +766,11 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
766 766
767 if ((be16_to_cpup((__be16 *) skb->data) != ETH_P_ARP) && 767 if ((be16_to_cpup((__be16 *) skb->data) != ETH_P_ARP) &&
768 (be16_to_cpup((__be16 *) skb->data) != ETH_P_RARP)) { 768 (be16_to_cpup((__be16 *) skb->data) != ETH_P_RARP)) {
769 ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x " 769 ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x %pI6\n",
770 IPOIB_GID_FMT "\n",
771 skb->dst ? "neigh" : "dst", 770 skb->dst ? "neigh" : "dst",
772 be16_to_cpup((__be16 *) skb->data), 771 be16_to_cpup((__be16 *) skb->data),
773 IPOIB_QPN(phdr->hwaddr), 772 IPOIB_QPN(phdr->hwaddr),
774 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4)); 773 phdr->hwaddr + 4);
775 dev_kfree_skb_any(skb); 774 dev_kfree_skb_any(skb);
776 ++dev->stats.tx_dropped; 775 ++dev->stats.tx_dropped;
777 return NETDEV_TX_OK; 776 return NETDEV_TX_OK;
@@ -847,9 +846,9 @@ static void ipoib_neigh_cleanup(struct neighbour *n)
847 else 846 else
848 return; 847 return;
849 ipoib_dbg(priv, 848 ipoib_dbg(priv,
850 "neigh_cleanup for %06x " IPOIB_GID_FMT "\n", 849 "neigh_cleanup for %06x %pI6\n",
851 IPOIB_QPN(n->ha), 850 IPOIB_QPN(n->ha),
852 IPOIB_GID_RAW_ARG(n->ha + 4)); 851 n->ha + 4);
853 852
854 spin_lock_irqsave(&priv->lock, flags); 853 spin_lock_irqsave(&priv->lock, flags);
855 854
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index d9d1223c3fd5..a2eb3b9789eb 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -71,9 +71,8 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
71 struct ipoib_neigh *neigh, *tmp; 71 struct ipoib_neigh *neigh, *tmp;
72 int tx_dropped = 0; 72 int tx_dropped = 0;
73 73
74 ipoib_dbg_mcast(netdev_priv(dev), 74 ipoib_dbg_mcast(netdev_priv(dev), "deleting multicast group %pI6\n",
75 "deleting multicast group " IPOIB_GID_FMT "\n", 75 mcast->mcmember.mgid.raw);
76 IPOIB_GID_ARG(mcast->mcmember.mgid));
77 76
78 spin_lock_irq(&priv->lock); 77 spin_lock_irq(&priv->lock);
79 78
@@ -205,9 +204,8 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
205 204
206 if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) { 205 if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
207 if (test_and_set_bit(IPOIB_MCAST_FLAG_ATTACHED, &mcast->flags)) { 206 if (test_and_set_bit(IPOIB_MCAST_FLAG_ATTACHED, &mcast->flags)) {
208 ipoib_warn(priv, "multicast group " IPOIB_GID_FMT 207 ipoib_warn(priv, "multicast group %pI6 already attached\n",
209 " already attached\n", 208 mcast->mcmember.mgid.raw);
210 IPOIB_GID_ARG(mcast->mcmember.mgid));
211 209
212 return 0; 210 return 0;
213 } 211 }
@@ -215,9 +213,8 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
215 ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid), 213 ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid),
216 &mcast->mcmember.mgid, set_qkey); 214 &mcast->mcmember.mgid, set_qkey);
217 if (ret < 0) { 215 if (ret < 0) {
218 ipoib_warn(priv, "couldn't attach QP to multicast group " 216 ipoib_warn(priv, "couldn't attach QP to multicast group %pI6\n",
219 IPOIB_GID_FMT "\n", 217 mcast->mcmember.mgid.raw);
220 IPOIB_GID_ARG(mcast->mcmember.mgid));
221 218
222 clear_bit(IPOIB_MCAST_FLAG_ATTACHED, &mcast->flags); 219 clear_bit(IPOIB_MCAST_FLAG_ATTACHED, &mcast->flags);
223 return ret; 220 return ret;
@@ -248,9 +245,8 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
248 mcast->ah = ah; 245 mcast->ah = ah;
249 spin_unlock_irq(&priv->lock); 246 spin_unlock_irq(&priv->lock);
250 247
251 ipoib_dbg_mcast(priv, "MGID " IPOIB_GID_FMT 248 ipoib_dbg_mcast(priv, "MGID %pI6 AV %p, LID 0x%04x, SL %d\n",
252 " AV %p, LID 0x%04x, SL %d\n", 249 mcast->mcmember.mgid.raw,
253 IPOIB_GID_ARG(mcast->mcmember.mgid),
254 mcast->ah->ah, 250 mcast->ah->ah,
255 be16_to_cpu(mcast->mcmember.mlid), 251 be16_to_cpu(mcast->mcmember.mlid),
256 mcast->mcmember.sl); 252 mcast->mcmember.sl);
@@ -295,9 +291,8 @@ ipoib_mcast_sendonly_join_complete(int status,
295 291
296 if (status) { 292 if (status) {
297 if (mcast->logcount++ < 20) 293 if (mcast->logcount++ < 20)
298 ipoib_dbg_mcast(netdev_priv(dev), "multicast join failed for " 294 ipoib_dbg_mcast(netdev_priv(dev), "multicast join failed for %pI6, status %d\n",
299 IPOIB_GID_FMT ", status %d\n", 295 mcast->mcmember.mgid.raw, status);
300 IPOIB_GID_ARG(mcast->mcmember.mgid), status);
301 296
302 /* Flush out any queued packets */ 297 /* Flush out any queued packets */
303 netif_tx_lock_bh(dev); 298 netif_tx_lock_bh(dev);
@@ -356,9 +351,8 @@ static int ipoib_mcast_sendonly_join(struct ipoib_mcast *mcast)
356 ipoib_warn(priv, "ib_sa_join_multicast failed (ret = %d)\n", 351 ipoib_warn(priv, "ib_sa_join_multicast failed (ret = %d)\n",
357 ret); 352 ret);
358 } else { 353 } else {
359 ipoib_dbg_mcast(priv, "no multicast record for " IPOIB_GID_FMT 354 ipoib_dbg_mcast(priv, "no multicast record for %pI6, starting join\n",
360 ", starting join\n", 355 mcast->mcmember.mgid.raw);
361 IPOIB_GID_ARG(mcast->mcmember.mgid));
362 } 356 }
363 357
364 return ret; 358 return ret;
@@ -386,9 +380,8 @@ static int ipoib_mcast_join_complete(int status,
386 struct net_device *dev = mcast->dev; 380 struct net_device *dev = mcast->dev;
387 struct ipoib_dev_priv *priv = netdev_priv(dev); 381 struct ipoib_dev_priv *priv = netdev_priv(dev);
388 382
389 ipoib_dbg_mcast(priv, "join completion for " IPOIB_GID_FMT 383 ipoib_dbg_mcast(priv, "join completion for %pI6 (status %d)\n",
390 " (status %d)\n", 384 mcast->mcmember.mgid.raw, status);
391 IPOIB_GID_ARG(mcast->mcmember.mgid), status);
392 385
393 /* We trap for port events ourselves. */ 386 /* We trap for port events ourselves. */
394 if (status == -ENETRESET) 387 if (status == -ENETRESET)
@@ -417,15 +410,11 @@ static int ipoib_mcast_join_complete(int status,
417 410
418 if (mcast->logcount++ < 20) { 411 if (mcast->logcount++ < 20) {
419 if (status == -ETIMEDOUT) { 412 if (status == -ETIMEDOUT) {
420 ipoib_dbg_mcast(priv, "multicast join failed for " IPOIB_GID_FMT 413 ipoib_dbg_mcast(priv, "multicast join failed for %pI6, status %d\n",
421 ", status %d\n", 414 mcast->mcmember.mgid.raw, status);
422 IPOIB_GID_ARG(mcast->mcmember.mgid),
423 status);
424 } else { 415 } else {
425 ipoib_warn(priv, "multicast join failed for " 416 ipoib_warn(priv, "multicast join failed for %pI6, status %d\n",
426 IPOIB_GID_FMT ", status %d\n", 417 mcast->mcmember.mgid.raw, status);
427 IPOIB_GID_ARG(mcast->mcmember.mgid),
428 status);
429 } 418 }
430 } 419 }
431 420
@@ -457,8 +446,7 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
457 ib_sa_comp_mask comp_mask; 446 ib_sa_comp_mask comp_mask;
458 int ret = 0; 447 int ret = 0;
459 448
460 ipoib_dbg_mcast(priv, "joining MGID " IPOIB_GID_FMT "\n", 449 ipoib_dbg_mcast(priv, "joining MGID %pI6\n", mcast->mcmember.mgid.raw);
461 IPOIB_GID_ARG(mcast->mcmember.mgid));
462 450
463 rec.mgid = mcast->mcmember.mgid; 451 rec.mgid = mcast->mcmember.mgid;
464 rec.port_gid = priv->local_gid; 452 rec.port_gid = priv->local_gid;
@@ -643,8 +631,8 @@ static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
643 ib_sa_free_multicast(mcast->mc); 631 ib_sa_free_multicast(mcast->mc);
644 632
645 if (test_and_clear_bit(IPOIB_MCAST_FLAG_ATTACHED, &mcast->flags)) { 633 if (test_and_clear_bit(IPOIB_MCAST_FLAG_ATTACHED, &mcast->flags)) {
646 ipoib_dbg_mcast(priv, "leaving MGID " IPOIB_GID_FMT "\n", 634 ipoib_dbg_mcast(priv, "leaving MGID %pI6\n",
647 IPOIB_GID_ARG(mcast->mcmember.mgid)); 635 mcast->mcmember.mgid.raw);
648 636
649 /* Remove ourselves from the multicast group */ 637 /* Remove ourselves from the multicast group */
650 ret = ib_detach_mcast(priv->qp, &mcast->mcmember.mgid, 638 ret = ib_detach_mcast(priv->qp, &mcast->mcmember.mgid,
@@ -675,8 +663,8 @@ void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb)
675 mcast = __ipoib_mcast_find(dev, mgid); 663 mcast = __ipoib_mcast_find(dev, mgid);
676 if (!mcast) { 664 if (!mcast) {
677 /* Let's create a new send only group now */ 665 /* Let's create a new send only group now */
678 ipoib_dbg_mcast(priv, "setting up send only multicast group for " 666 ipoib_dbg_mcast(priv, "setting up send only multicast group for %pI6\n",
679 IPOIB_GID_FMT "\n", IPOIB_GID_RAW_ARG(mgid)); 667 mgid);
680 668
681 mcast = ipoib_mcast_alloc(dev, 0); 669 mcast = ipoib_mcast_alloc(dev, 0);
682 if (!mcast) { 670 if (!mcast) {
@@ -809,14 +797,14 @@ void ipoib_mcast_restart_task(struct work_struct *work)
809 /* ignore group which is directly joined by userspace */ 797 /* ignore group which is directly joined by userspace */
810 if (test_bit(IPOIB_FLAG_UMCAST, &priv->flags) && 798 if (test_bit(IPOIB_FLAG_UMCAST, &priv->flags) &&
811 !ib_sa_get_mcmember_rec(priv->ca, priv->port, &mgid, &rec)) { 799 !ib_sa_get_mcmember_rec(priv->ca, priv->port, &mgid, &rec)) {
812 ipoib_dbg_mcast(priv, "ignoring multicast entry for mgid " 800 ipoib_dbg_mcast(priv, "ignoring multicast entry for mgid %pI6\n",
813 IPOIB_GID_FMT "\n", IPOIB_GID_ARG(mgid)); 801 mgid.raw);
814 continue; 802 continue;
815 } 803 }
816 804
817 /* Not found or send-only group, let's add a new entry */ 805 /* Not found or send-only group, let's add a new entry */
818 ipoib_dbg_mcast(priv, "adding multicast entry for mgid " 806 ipoib_dbg_mcast(priv, "adding multicast entry for mgid %pI6\n",
819 IPOIB_GID_FMT "\n", IPOIB_GID_ARG(mgid)); 807 mgid.raw);
820 808
821 nmcast = ipoib_mcast_alloc(dev, 0); 809 nmcast = ipoib_mcast_alloc(dev, 0);
822 if (!nmcast) { 810 if (!nmcast) {
@@ -849,8 +837,8 @@ void ipoib_mcast_restart_task(struct work_struct *work)
849 list_for_each_entry_safe(mcast, tmcast, &priv->multicast_list, list) { 837 list_for_each_entry_safe(mcast, tmcast, &priv->multicast_list, list) {
850 if (!test_bit(IPOIB_MCAST_FLAG_FOUND, &mcast->flags) && 838 if (!test_bit(IPOIB_MCAST_FLAG_FOUND, &mcast->flags) &&
851 !test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) { 839 !test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
852 ipoib_dbg_mcast(priv, "deleting multicast group " IPOIB_GID_FMT "\n", 840 ipoib_dbg_mcast(priv, "deleting multicast group %pI6\n",
853 IPOIB_GID_ARG(mcast->mcmember.mgid)); 841 mcast->mcmember.mgid.raw);
854 842
855 rb_erase(&mcast->rb_node, &priv->multicast_tree); 843 rb_erase(&mcast->rb_node, &priv->multicast_tree);
856 844
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 26ff6214a81f..e418b960e334 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -515,14 +515,14 @@ int iser_connect(struct iser_conn *ib_conn,
515 struct sockaddr *src, *dst; 515 struct sockaddr *src, *dst;
516 int err = 0; 516 int err = 0;
517 517
518 sprintf(ib_conn->name,"%d.%d.%d.%d:%d", 518 sprintf(ib_conn->name, "%pI4:%d",
519 NIPQUAD(dst_addr->sin_addr.s_addr), dst_addr->sin_port); 519 &dst_addr->sin_addr.s_addr, dst_addr->sin_port);
520 520
521 /* the device is known only --after-- address resolution */ 521 /* the device is known only --after-- address resolution */
522 ib_conn->device = NULL; 522 ib_conn->device = NULL;
523 523
524 iser_err("connecting to: %d.%d.%d.%d, port 0x%x\n", 524 iser_err("connecting to: %pI4, port 0x%x\n",
525 NIPQUAD(dst_addr->sin_addr), dst_addr->sin_port); 525 &dst_addr->sin_addr, dst_addr->sin_port);
526 526
527 ib_conn->state = ISER_CONN_PENDING; 527 ib_conn->state = ISER_CONN_PENDING;
528 528
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 5b8b533f2908..7c13db885bf6 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1514,15 +1514,7 @@ static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
1514 target->state == SRP_TARGET_REMOVED) 1514 target->state == SRP_TARGET_REMOVED)
1515 return -ENODEV; 1515 return -ENODEV;
1516 1516
1517 return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", 1517 return sprintf(buf, "%pI6\n", target->path.dgid.raw);
1518 be16_to_cpu(((__be16 *) target->path.dgid.raw)[0]),
1519 be16_to_cpu(((__be16 *) target->path.dgid.raw)[1]),
1520 be16_to_cpu(((__be16 *) target->path.dgid.raw)[2]),
1521 be16_to_cpu(((__be16 *) target->path.dgid.raw)[3]),
1522 be16_to_cpu(((__be16 *) target->path.dgid.raw)[4]),
1523 be16_to_cpu(((__be16 *) target->path.dgid.raw)[5]),
1524 be16_to_cpu(((__be16 *) target->path.dgid.raw)[6]),
1525 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
1526} 1518}
1527 1519
1528static ssize_t show_orig_dgid(struct device *dev, 1520static ssize_t show_orig_dgid(struct device *dev,
@@ -1534,15 +1526,7 @@ static ssize_t show_orig_dgid(struct device *dev,
1534 target->state == SRP_TARGET_REMOVED) 1526 target->state == SRP_TARGET_REMOVED)
1535 return -ENODEV; 1527 return -ENODEV;
1536 1528
1537 return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", 1529 return sprintf(buf, "%pI6\n", target->orig_dgid);
1538 be16_to_cpu(target->orig_dgid[0]),
1539 be16_to_cpu(target->orig_dgid[1]),
1540 be16_to_cpu(target->orig_dgid[2]),
1541 be16_to_cpu(target->orig_dgid[3]),
1542 be16_to_cpu(target->orig_dgid[4]),
1543 be16_to_cpu(target->orig_dgid[5]),
1544 be16_to_cpu(target->orig_dgid[6]),
1545 be16_to_cpu(target->orig_dgid[7]));
1546} 1530}
1547 1531
1548static ssize_t show_zero_req_lim(struct device *dev, 1532static ssize_t show_zero_req_lim(struct device *dev,
@@ -1883,19 +1867,12 @@ static ssize_t srp_create_target(struct device *dev,
1883 1867
1884 shost_printk(KERN_DEBUG, target->scsi_host, PFX 1868 shost_printk(KERN_DEBUG, target->scsi_host, PFX
1885 "new target: id_ext %016llx ioc_guid %016llx pkey %04x " 1869 "new target: id_ext %016llx ioc_guid %016llx pkey %04x "
1886 "service_id %016llx dgid %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", 1870 "service_id %016llx dgid %pI6\n",
1887 (unsigned long long) be64_to_cpu(target->id_ext), 1871 (unsigned long long) be64_to_cpu(target->id_ext),
1888 (unsigned long long) be64_to_cpu(target->ioc_guid), 1872 (unsigned long long) be64_to_cpu(target->ioc_guid),
1889 be16_to_cpu(target->path.pkey), 1873 be16_to_cpu(target->path.pkey),
1890 (unsigned long long) be64_to_cpu(target->service_id), 1874 (unsigned long long) be64_to_cpu(target->service_id),
1891 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[0]), 1875 target->path.dgid.raw);
1892 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[2]),
1893 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[4]),
1894 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[6]),
1895 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[8]),
1896 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[10]),
1897 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[12]),
1898 (int) be16_to_cpu(*(__be16 *) &target->path.dgid.raw[14]));
1899 1876
1900 ret = srp_create_target_ib(target); 1877 ret = srp_create_target_ib(target);
1901 if (ret) 1878 if (ret)
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 1bfc55d7a26c..ad17a47ecc06 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -890,15 +890,15 @@ isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp)
890 proto = ETH_P_IP; 890 proto = ETH_P_IP;
891 switch (lp->p_encap) { 891 switch (lp->p_encap) {
892 case ISDN_NET_ENCAP_IPTYP: 892 case ISDN_NET_ENCAP_IPTYP:
893 proto = ntohs(*(unsigned short *) &buf[0]); 893 proto = ntohs(*(__be16 *)&buf[0]);
894 p = &buf[2]; 894 p = &buf[2];
895 break; 895 break;
896 case ISDN_NET_ENCAP_ETHER: 896 case ISDN_NET_ENCAP_ETHER:
897 proto = ntohs(*(unsigned short *) &buf[12]); 897 proto = ntohs(*(__be16 *)&buf[12]);
898 p = &buf[14]; 898 p = &buf[14];
899 break; 899 break;
900 case ISDN_NET_ENCAP_CISCOHDLC: 900 case ISDN_NET_ENCAP_CISCOHDLC:
901 proto = ntohs(*(unsigned short *) &buf[2]); 901 proto = ntohs(*(__be16 *)&buf[2]);
902 p = &buf[4]; 902 p = &buf[4];
903 break; 903 break;
904#ifdef CONFIG_ISDN_PPP 904#ifdef CONFIG_ISDN_PPP
@@ -942,18 +942,12 @@ isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp)
942 strcpy(addinfo, " IDP"); 942 strcpy(addinfo, " IDP");
943 break; 943 break;
944 } 944 }
945 printk(KERN_INFO 945 printk(KERN_INFO "OPEN: %pI4 -> %pI4%s\n",
946 "OPEN: %d.%d.%d.%d -> %d.%d.%d.%d%s\n", 946 p + 12, p + 16, addinfo);
947
948 p[12], p[13], p[14], p[15],
949 p[16], p[17], p[18], p[19],
950 addinfo);
951 break; 947 break;
952 case ETH_P_ARP: 948 case ETH_P_ARP:
953 printk(KERN_INFO 949 printk(KERN_INFO "OPEN: ARP %pI4 -> *.*.*.* ?%pI4\n",
954 "OPEN: ARP %d.%d.%d.%d -> *.*.*.* ?%d.%d.%d.%d\n", 950 p + 14, p + 24);
955 p[14], p[15], p[16], p[17],
956 p[24], p[25], p[26], p[27]);
957 break; 951 break;
958 } 952 }
959} 953}
@@ -1539,15 +1533,16 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data)
1539 p = skb_put(skb, 4 + 14); 1533 p = skb_put(skb, 4 + 14);
1540 1534
1541 /* cisco header */ 1535 /* cisco header */
1542 p += put_u8 (p, CISCO_ADDR_UNICAST); 1536 *(u8 *)(p + 0) = CISCO_ADDR_UNICAST;
1543 p += put_u8 (p, CISCO_CTRL); 1537 *(u8 *)(p + 1) = CISCO_CTRL;
1544 p += put_u16(p, CISCO_TYPE_SLARP); 1538 *(__be16 *)(p + 2) = cpu_to_be16(CISCO_TYPE_SLARP);
1545 1539
1546 /* slarp keepalive */ 1540 /* slarp keepalive */
1547 p += put_u32(p, CISCO_SLARP_KEEPALIVE); 1541 *(__be32 *)(p + 4) = cpu_to_be32(CISCO_SLARP_KEEPALIVE);
1548 p += put_u32(p, lp->cisco_myseq); 1542 *(__be32 *)(p + 8) = cpu_to_be32(lp->cisco_myseq);
1549 p += put_u32(p, lp->cisco_yourseq); 1543 *(__be32 *)(p + 12) = cpu_to_be32(lp->cisco_yourseq);
1550 p += put_u16(p, 0xffff); // reliablity, always 0xffff 1544 *(__be16 *)(p + 16) = cpu_to_be16(0xffff); // reliablity, always 0xffff
1545 p += 18;
1551 1546
1552 isdn_net_write_super(lp, skb); 1547 isdn_net_write_super(lp, skb);
1553 1548
@@ -1569,15 +1564,16 @@ isdn_net_ciscohdlck_slarp_send_request(isdn_net_local *lp)
1569 p = skb_put(skb, 4 + 14); 1564 p = skb_put(skb, 4 + 14);
1570 1565
1571 /* cisco header */ 1566 /* cisco header */
1572 p += put_u8 (p, CISCO_ADDR_UNICAST); 1567 *(u8 *)(p + 0) = CISCO_ADDR_UNICAST;
1573 p += put_u8 (p, CISCO_CTRL); 1568 *(u8 *)(p + 1) = CISCO_CTRL;
1574 p += put_u16(p, CISCO_TYPE_SLARP); 1569 *(__be16 *)(p + 2) = cpu_to_be16(CISCO_TYPE_SLARP);
1575 1570
1576 /* slarp request */ 1571 /* slarp request */
1577 p += put_u32(p, CISCO_SLARP_REQUEST); 1572 *(__be32 *)(p + 4) = cpu_to_be32(CISCO_SLARP_REQUEST);
1578 p += put_u32(p, 0); // address 1573 *(__be32 *)(p + 8) = cpu_to_be32(0); // address
1579 p += put_u32(p, 0); // netmask 1574 *(__be32 *)(p + 12) = cpu_to_be32(0); // netmask
1580 p += put_u16(p, 0); // unused 1575 *(__be16 *)(p + 16) = cpu_to_be16(0); // unused
1576 p += 18;
1581 1577
1582 isdn_net_write_super(lp, skb); 1578 isdn_net_write_super(lp, skb);
1583} 1579}
@@ -1634,18 +1630,17 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp)
1634 p = skb_put(skb, 4 + 14); 1630 p = skb_put(skb, 4 + 14);
1635 1631
1636 /* cisco header */ 1632 /* cisco header */
1637 p += put_u8 (p, CISCO_ADDR_UNICAST); 1633 *(u8 *)(p + 0) = CISCO_ADDR_UNICAST;
1638 p += put_u8 (p, CISCO_CTRL); 1634 *(u8 *)(p + 1) = CISCO_CTRL;
1639 p += put_u16(p, CISCO_TYPE_SLARP); 1635 *(__be16 *)(p + 2) = cpu_to_be16(CISCO_TYPE_SLARP);
1640 1636
1641 /* slarp reply, send own ip/netmask; if values are nonsense remote 1637 /* slarp reply, send own ip/netmask; if values are nonsense remote
1642 * should think we are unable to provide it with an address via SLARP */ 1638 * should think we are unable to provide it with an address via SLARP */
1643 p += put_u32(p, CISCO_SLARP_REPLY); 1639 *(__be32 *)(p + 4) = cpu_to_be32(CISCO_SLARP_REPLY);
1644 *(__be32 *)p = addr; // address 1640 *(__be32 *)(p + 8) = addr; // address
1645 p += 4; 1641 *(__be32 *)(p + 12) = mask; // netmask
1646 *(__be32 *)p = mask; // netmask 1642 *(__be16 *)(p + 16) = cpu_to_be16(0); // unused
1647 p += 4; 1643 p += 18;
1648 p += put_u16(p, 0); // unused
1649 1644
1650 isdn_net_write_super(lp, skb); 1645 isdn_net_write_super(lp, skb);
1651} 1646}
@@ -1656,44 +1651,39 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb)
1656 unsigned char *p; 1651 unsigned char *p;
1657 int period; 1652 int period;
1658 u32 code; 1653 u32 code;
1659 u32 my_seq, addr; 1654 u32 my_seq;
1660 u32 your_seq, mask; 1655 u32 your_seq;
1661 u32 local; 1656 __be32 local;
1657 __be32 *addr, *mask;
1662 u16 unused; 1658 u16 unused;
1663 1659
1664 if (skb->len < 14) 1660 if (skb->len < 14)
1665 return; 1661 return;
1666 1662
1667 p = skb->data; 1663 p = skb->data;
1668 p += get_u32(p, &code); 1664 code = be32_to_cpup((__be32 *)p);
1669 1665 p += 4;
1666
1670 switch (code) { 1667 switch (code) {
1671 case CISCO_SLARP_REQUEST: 1668 case CISCO_SLARP_REQUEST:
1672 lp->cisco_yourseq = 0; 1669 lp->cisco_yourseq = 0;
1673 isdn_net_ciscohdlck_slarp_send_reply(lp); 1670 isdn_net_ciscohdlck_slarp_send_reply(lp);
1674 break; 1671 break;
1675 case CISCO_SLARP_REPLY: 1672 case CISCO_SLARP_REPLY:
1676 addr = ntohl(*(u32 *)p); 1673 addr = (__be32 *)p;
1677 mask = ntohl(*(u32 *)(p+4)); 1674 mask = (__be32 *)(p + 4);
1678 if (mask != 0xfffffffc) 1675 if (*mask != cpu_to_be32(0xfffffffc))
1679 goto slarp_reply_out; 1676 goto slarp_reply_out;
1680 if ((addr & 3) == 0 || (addr & 3) == 3) 1677 if ((*addr & cpu_to_be32(3)) == cpu_to_be32(0) ||
1678 (*addr & cpu_to_be32(3)) == cpu_to_be32(3))
1681 goto slarp_reply_out; 1679 goto slarp_reply_out;
1682 local = addr ^ 3; 1680 local = *addr ^ cpu_to_be32(3);
1683 printk(KERN_INFO "%s: got slarp reply: " 1681 printk(KERN_INFO "%s: got slarp reply: remote ip: %pI4, local ip: %pI4 mask: %pI4\n",
1684 "remote ip: %d.%d.%d.%d, " 1682 lp->netdev->dev->name, addr, &local, mask);
1685 "local ip: %d.%d.%d.%d "
1686 "mask: %d.%d.%d.%d\n",
1687 lp->netdev->dev->name,
1688 HIPQUAD(addr),
1689 HIPQUAD(local),
1690 HIPQUAD(mask));
1691 break; 1683 break;
1692 slarp_reply_out: 1684 slarp_reply_out:
1693 printk(KERN_INFO "%s: got invalid slarp " 1685 printk(KERN_INFO "%s: got invalid slarp reply (%pI4/%pI4) - ignored\n",
1694 "reply (%d.%d.%d.%d/%d.%d.%d.%d) " 1686 lp->netdev->dev->name, addr, mask);
1695 "- ignored\n", lp->netdev->dev->name,
1696 HIPQUAD(addr), HIPQUAD(mask));
1697 break; 1687 break;
1698 case CISCO_SLARP_KEEPALIVE: 1688 case CISCO_SLARP_KEEPALIVE:
1699 period = (int)((jiffies - lp->cisco_last_slarp_in 1689 period = (int)((jiffies - lp->cisco_last_slarp_in
@@ -1707,9 +1697,10 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb)
1707 lp->cisco_keepalive_period); 1697 lp->cisco_keepalive_period);
1708 } 1698 }
1709 lp->cisco_last_slarp_in = jiffies; 1699 lp->cisco_last_slarp_in = jiffies;
1710 p += get_u32(p, &my_seq); 1700 my_seq = be32_to_cpup((__be32 *)(p + 0));
1711 p += get_u32(p, &your_seq); 1701 your_seq = be32_to_cpup((__be32 *)(p + 4));
1712 p += get_u16(p, &unused); 1702 unused = be16_to_cpup((__be16 *)(p + 8));
1703 p += 10;
1713 lp->cisco_yourseq = my_seq; 1704 lp->cisco_yourseq = my_seq;
1714 lp->cisco_mineseen = your_seq; 1705 lp->cisco_mineseen = your_seq;
1715 break; 1706 break;
@@ -1728,9 +1719,10 @@ isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb)
1728 goto out_free; 1719 goto out_free;
1729 1720
1730 p = skb->data; 1721 p = skb->data;
1731 p += get_u8 (p, &addr); 1722 addr = *(u8 *)(p + 0);
1732 p += get_u8 (p, &ctrl); 1723 ctrl = *(u8 *)(p + 1);
1733 p += get_u16(p, &type); 1724 type = be16_to_cpup((__be16 *)(p + 2));
1725 p += 4;
1734 skb_pull(skb, 4); 1726 skb_pull(skb, 4);
1735 1727
1736 if (addr != CISCO_ADDR_UNICAST && addr != CISCO_ADDR_BROADCAST) { 1728 if (addr != CISCO_ADDR_UNICAST && addr != CISCO_ADDR_BROADCAST) {
@@ -1918,9 +1910,10 @@ static int isdn_net_header(struct sk_buff *skb, struct net_device *dev,
1918 case ISDN_NET_ENCAP_CISCOHDLC: 1910 case ISDN_NET_ENCAP_CISCOHDLC:
1919 case ISDN_NET_ENCAP_CISCOHDLCK: 1911 case ISDN_NET_ENCAP_CISCOHDLCK:
1920 p = skb_push(skb, 4); 1912 p = skb_push(skb, 4);
1921 p += put_u8 (p, CISCO_ADDR_UNICAST); 1913 *(u8 *)(p + 0) = CISCO_ADDR_UNICAST;
1922 p += put_u8 (p, CISCO_CTRL); 1914 *(u8 *)(p + 1) = CISCO_CTRL;
1923 p += put_u16(p, type); 1915 *(__be16 *)(p + 2) = cpu_to_be16(type);
1916 p += 4;
1924 len = 4; 1917 len = 4;
1925 break; 1918 break;
1926#ifdef CONFIG_ISDN_X25 1919#ifdef CONFIG_ISDN_X25
diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h
index be4949715d55..2a6c370ea87f 100644
--- a/drivers/isdn/i4l/isdn_net.h
+++ b/drivers/isdn/i4l/isdn_net.h
@@ -145,46 +145,3 @@ static __inline__ void isdn_net_rm_from_bundle(isdn_net_local *lp)
145 spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags); 145 spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags);
146} 146}
147 147
148static inline int
149put_u8(unsigned char *p, u8 x)
150{
151 *p = x;
152 return 1;
153}
154
155static inline int
156put_u16(unsigned char *p, u16 x)
157{
158 *((u16 *)p) = htons(x);
159 return 2;
160}
161
162static inline int
163put_u32(unsigned char *p, u32 x)
164{
165 *((u32 *)p) = htonl(x);
166 return 4;
167}
168
169static inline int
170get_u8(unsigned char *p, u8 *x)
171{
172 *x = *p;
173 return 1;
174}
175
176static inline int
177get_u16(unsigned char *p, u16 *x)
178{
179 *x = ntohs(*((u16 *)p));
180 return 2;
181}
182
183static inline int
184get_u32(unsigned char *p, u32 *x)
185{
186 *x = ntohl(*((u32 *)p));
187 return 4;
188}
189
190
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c
index 5f79c8dc3836..676413a915b4 100644
--- a/drivers/media/dvb/b2c2/flexcop.c
+++ b/drivers/media/dvb/b2c2/flexcop.c
@@ -270,7 +270,7 @@ int flexcop_device_initialize(struct flexcop_device *fc)
270 /* do the MAC address reading after initializing the dvb_adapter */ 270 /* do the MAC address reading after initializing the dvb_adapter */
271 if (fc->get_mac_addr(fc, 0) == 0) { 271 if (fc->get_mac_addr(fc, 0) == 0) {
272 u8 *b = fc->dvb_adapter.proposed_mac; 272 u8 *b = fc->dvb_adapter.proposed_mac;
273 info("MAC address = %02x:%02x:%02x:%02x:%02x:%02x", b[0],b[1],b[2],b[3],b[4],b[5]); 273 info("MAC address = %pM", b);
274 flexcop_set_mac_filter(fc,b); 274 flexcop_set_mac_filter(fc,b);
275 flexcop_mac_filter_ctrl(fc,1); 275 flexcop_mac_filter_ctrl(fc,1);
276 } else 276 } else
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index aa3db57d32d9..29e8f1546ab6 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -917,9 +917,7 @@ static int dst_get_mac(struct dst_state *state)
917 } 917 }
918 memset(&state->mac_address, '\0', 8); 918 memset(&state->mac_address, '\0', 8);
919 memcpy(&state->mac_address, &state->rxbuffer, 6); 919 memcpy(&state->mac_address, &state->rxbuffer, 6);
920 dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]", 920 dprintk(verbose, DST_ERROR, 1, "MAC Address=[%pM]", state->mac_address);
921 state->mac_address[0], state->mac_address[1], state->mac_address[2],
922 state->mac_address[4], state->mac_address[5], state->mac_address[6]);
923 921
924 return 0; 922 return 0;
925} 923}
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index 14e627ef6465..d15984e599bc 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -697,8 +697,7 @@ static void __devinit dm1105dvb_read_mac(struct dm1105dvb *dm1105dvb, u8 *mac)
697 }; 697 };
698 698
699 dm1105_i2c_xfer(&dm1105dvb->i2c_adap, msg , 2); 699 dm1105_i2c_xfer(&dm1105dvb->i2c_adap, msg , 2);
700 dev_info(&dm1105dvb->pdev->dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n", 700 dev_info(&dm1105dvb->pdev->dev, "MAC %pM\n", mac);
701 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
702} 701}
703 702
704static int __devinit dm1105_probe(struct pci_dev *pdev, 703static int __devinit dm1105_probe(struct pci_dev *pdev,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
index ce8cd0c5d831..8a7d87bcd1d9 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
@@ -91,10 +91,7 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums)
91 91
92 if (adap->dev->props.read_mac_address) { 92 if (adap->dev->props.read_mac_address) {
93 if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0) 93 if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0)
94 info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",adap->dvb_adap.proposed_mac[0], 94 info("MAC address: %pM",adap->dvb_adap.proposed_mac);
95 adap->dvb_adap.proposed_mac[1], adap->dvb_adap.proposed_mac[2],
96 adap->dvb_adap.proposed_mac[3], adap->dvb_adap.proposed_mac[4],
97 adap->dvb_adap.proposed_mac[5]);
98 else 95 else
99 err("MAC address reading failed."); 96 err("MAC address reading failed.");
100 } 97 }
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index a9653c63f4db..d101b304e9b0 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -560,8 +560,7 @@ static void __devinit pluto_read_mac(struct pluto *pluto, u8 *mac)
560 mac[4] = (val >> 8) & 0xff; 560 mac[4] = (val >> 8) & 0xff;
561 mac[5] = (val >> 0) & 0xff; 561 mac[5] = (val >> 0) & 0xff;
562 562
563 dev_info(&pluto->pdev->dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n", 563 dev_info(&pluto->pdev->dev, "MAC %pM\n", mac);
564 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
565} 564}
566 565
567static int __devinit pluto_read_serial(struct pluto *pluto) 566static int __devinit pluto_read_serial(struct pluto *pluto)
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 603ffd008c73..eeef0bd077f4 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -1427,11 +1427,9 @@ mptlan_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1427 printk(KERN_INFO MYNAM ": %s: Fusion MPT LAN device " 1427 printk(KERN_INFO MYNAM ": %s: Fusion MPT LAN device "
1428 "registered as '%s'\n", ioc->name, dev->name); 1428 "registered as '%s'\n", ioc->name, dev->name);
1429 printk(KERN_INFO MYNAM ": %s/%s: " 1429 printk(KERN_INFO MYNAM ": %s/%s: "
1430 "LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n", 1430 "LanAddr = %pM\n",
1431 IOC_AND_NETDEV_NAMES_s_s(dev), 1431 IOC_AND_NETDEV_NAMES_s_s(dev),
1432 dev->dev_addr[0], dev->dev_addr[1], 1432 dev->dev_addr);
1433 dev->dev_addr[2], dev->dev_addr[3],
1434 dev->dev_addr[4], dev->dev_addr[5]);
1435 1433
1436 ioc->netdev = dev; 1434 ioc->netdev = dev;
1437 1435
@@ -1516,9 +1514,8 @@ mpt_lan_type_trans(struct sk_buff *skb, struct net_device *dev)
1516 1514
1517 printk (KERN_WARNING MYNAM ": %s: WARNING - Broadcast swap F/W bug detected!\n", 1515 printk (KERN_WARNING MYNAM ": %s: WARNING - Broadcast swap F/W bug detected!\n",
1518 NETDEV_PTR_TO_IOC_NAME_s(dev)); 1516 NETDEV_PTR_TO_IOC_NAME_s(dev));
1519 printk (KERN_WARNING MYNAM ": Please update sender @ MAC_addr = %02x:%02x:%02x:%02x:%02x:%02x\n", 1517 printk (KERN_WARNING MYNAM ": Please update sender @ MAC_addr = %pM\n",
1520 fch->saddr[0], fch->saddr[1], fch->saddr[2], 1518 fch->saddr);
1521 fch->saddr[3], fch->saddr[4], fch->saddr[5]);
1522 } 1519 }
1523 1520
1524 if (*fch->daddr & 1) { 1521 if (*fch->daddr & 1) {
@@ -1537,7 +1534,6 @@ mpt_lan_type_trans(struct sk_buff *skb, struct net_device *dev)
1537 1534
1538 fcllc = (struct fcllc *)skb->data; 1535 fcllc = (struct fcllc *)skb->data;
1539 1536
1540
1541 /* Strip the SNAP header from ARP packets since we don't 1537 /* Strip the SNAP header from ARP packets since we don't
1542 * pass them through to the 802.2/SNAP layers. 1538 * pass them through to the 802.2/SNAP layers.
1543 */ 1539 */
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c
index 7d15e7c6bcad..3d1318a3e688 100644
--- a/drivers/net/3c501.c
+++ b/drivers/net/3c501.c
@@ -297,8 +297,8 @@ static int __init el1_probe1(struct net_device *dev, int ioaddr)
297 if (el_debug) 297 if (el_debug)
298 printk(KERN_DEBUG "%s", version); 298 printk(KERN_DEBUG "%s", version);
299 299
300 memset(dev->priv, 0, sizeof(struct net_local));
301 lp = netdev_priv(dev); 300 lp = netdev_priv(dev);
301 memset(lp, 0, sizeof(struct net_local));
302 spin_lock_init(&lp->lock); 302 spin_lock_init(&lp->lock);
303 303
304 /* 304 /*
@@ -725,7 +725,6 @@ static void el_receive(struct net_device *dev)
725 insb(DATAPORT, skb_put(skb, pkt_len), pkt_len); 725 insb(DATAPORT, skb_put(skb, pkt_len), pkt_len);
726 skb->protocol = eth_type_trans(skb, dev); 726 skb->protocol = eth_type_trans(skb, dev);
727 netif_rx(skb); 727 netif_rx(skb);
728 dev->last_rx = jiffies;
729 dev->stats.rx_packets++; 728 dev->stats.rx_packets++;
730 dev->stats.rx_bytes += pkt_len; 729 dev->stats.rx_bytes += pkt_len;
731 } 730 }
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index 900b0ffdcc68..95bd95f1f99e 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -177,7 +177,6 @@ el2_probe1(struct net_device *dev, int ioaddr)
177 int i, iobase_reg, membase_reg, saved_406, wordlength, retval; 177 int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
178 static unsigned version_printed; 178 static unsigned version_printed;
179 unsigned long vendor_id; 179 unsigned long vendor_id;
180 DECLARE_MAC_BUF(mac);
181 180
182 if (!request_region(ioaddr, EL2_IO_EXTENT, DRV_NAME)) 181 if (!request_region(ioaddr, EL2_IO_EXTENT, DRV_NAME))
183 return -EBUSY; 182 return -EBUSY;
@@ -228,7 +227,7 @@ el2_probe1(struct net_device *dev, int ioaddr)
228 /* Retrieve and print the ethernet address. */ 227 /* Retrieve and print the ethernet address. */
229 for (i = 0; i < 6; i++) 228 for (i = 0; i < 6; i++)
230 dev->dev_addr[i] = inb(ioaddr + i); 229 dev->dev_addr[i] = inb(ioaddr + i);
231 printk("%s", print_mac(mac, dev->dev_addr)); 230 printk("%pM", dev->dev_addr);
232 231
233 /* Map the 8390 back into the window. */ 232 /* Map the 8390 back into the window. */
234 outb(ECNTRL_THIN, ioaddr + 0x406); 233 outb(ECNTRL_THIN, ioaddr + 0x406);
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index a424869707a5..6124605bef05 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -203,10 +203,10 @@ static inline int inb_command(unsigned int base_addr)
203static inline void outb_control(unsigned char val, struct net_device *dev) 203static inline void outb_control(unsigned char val, struct net_device *dev)
204{ 204{
205 outb(val, dev->base_addr + PORT_CONTROL); 205 outb(val, dev->base_addr + PORT_CONTROL);
206 ((elp_device *)(dev->priv))->hcr_val = val; 206 ((elp_device *)(netdev_priv(dev)))->hcr_val = val;
207} 207}
208 208
209#define HCR_VAL(x) (((elp_device *)((x)->priv))->hcr_val) 209#define HCR_VAL(x) (((elp_device *)(netdev_priv(x)))->hcr_val)
210 210
211static inline void outb_command(unsigned char val, unsigned int base_addr) 211static inline void outb_command(unsigned char val, unsigned int base_addr)
212{ 212{
@@ -247,7 +247,7 @@ static inline int get_status(unsigned int base_addr)
247 247
248static inline void set_hsf(struct net_device *dev, int hsf) 248static inline void set_hsf(struct net_device *dev, int hsf)
249{ 249{
250 elp_device *adapter = dev->priv; 250 elp_device *adapter = netdev_priv(dev);
251 unsigned long flags; 251 unsigned long flags;
252 252
253 spin_lock_irqsave(&adapter->lock, flags); 253 spin_lock_irqsave(&adapter->lock, flags);
@@ -260,7 +260,7 @@ static bool start_receive(struct net_device *, pcb_struct *);
260static inline void adapter_reset(struct net_device *dev) 260static inline void adapter_reset(struct net_device *dev)
261{ 261{
262 unsigned long timeout; 262 unsigned long timeout;
263 elp_device *adapter = dev->priv; 263 elp_device *adapter = netdev_priv(dev);
264 unsigned char orig_hcr = adapter->hcr_val; 264 unsigned char orig_hcr = adapter->hcr_val;
265 265
266 outb_control(0, dev); 266 outb_control(0, dev);
@@ -293,7 +293,7 @@ static inline void adapter_reset(struct net_device *dev)
293 */ 293 */
294static inline void check_3c505_dma(struct net_device *dev) 294static inline void check_3c505_dma(struct net_device *dev)
295{ 295{
296 elp_device *adapter = dev->priv; 296 elp_device *adapter = netdev_priv(dev);
297 if (adapter->dmaing && time_after(jiffies, adapter->current_dma.start_time + 10)) { 297 if (adapter->dmaing && time_after(jiffies, adapter->current_dma.start_time + 10)) {
298 unsigned long flags, f; 298 unsigned long flags, f;
299 printk(KERN_ERR "%s: DMA %s timed out, %d bytes left\n", dev->name, adapter->current_dma.direction ? "download" : "upload", get_dma_residue(dev->dma)); 299 printk(KERN_ERR "%s: DMA %s timed out, %d bytes left\n", dev->name, adapter->current_dma.direction ? "download" : "upload", get_dma_residue(dev->dma));
@@ -340,7 +340,7 @@ static inline bool send_pcb_fast(unsigned int base_addr, unsigned char byte)
340/* Check to see if the receiver needs restarting, and kick it if so */ 340/* Check to see if the receiver needs restarting, and kick it if so */
341static inline void prime_rx(struct net_device *dev) 341static inline void prime_rx(struct net_device *dev)
342{ 342{
343 elp_device *adapter = dev->priv; 343 elp_device *adapter = netdev_priv(dev);
344 while (adapter->rx_active < ELP_RX_PCBS && netif_running(dev)) { 344 while (adapter->rx_active < ELP_RX_PCBS && netif_running(dev)) {
345 if (!start_receive(dev, &adapter->itx_pcb)) 345 if (!start_receive(dev, &adapter->itx_pcb))
346 break; 346 break;
@@ -375,7 +375,7 @@ static bool send_pcb(struct net_device *dev, pcb_struct * pcb)
375{ 375{
376 int i; 376 int i;
377 unsigned long timeout; 377 unsigned long timeout;
378 elp_device *adapter = dev->priv; 378 elp_device *adapter = netdev_priv(dev);
379 unsigned long flags; 379 unsigned long flags;
380 380
381 check_3c505_dma(dev); 381 check_3c505_dma(dev);
@@ -463,7 +463,7 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
463 unsigned long timeout; 463 unsigned long timeout;
464 unsigned long flags; 464 unsigned long flags;
465 465
466 elp_device *adapter = dev->priv; 466 elp_device *adapter = netdev_priv(dev);
467 467
468 set_hsf(dev, 0); 468 set_hsf(dev, 0);
469 469
@@ -543,7 +543,7 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
543static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb) 543static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb)
544{ 544{
545 bool status; 545 bool status;
546 elp_device *adapter = dev->priv; 546 elp_device *adapter = netdev_priv(dev);
547 547
548 if (elp_debug >= 3) 548 if (elp_debug >= 3)
549 printk(KERN_DEBUG "%s: restarting receiver\n", dev->name); 549 printk(KERN_DEBUG "%s: restarting receiver\n", dev->name);
@@ -571,7 +571,7 @@ static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb)
571static void receive_packet(struct net_device *dev, int len) 571static void receive_packet(struct net_device *dev, int len)
572{ 572{
573 int rlen; 573 int rlen;
574 elp_device *adapter = dev->priv; 574 elp_device *adapter = netdev_priv(dev);
575 void *target; 575 void *target;
576 struct sk_buff *skb; 576 struct sk_buff *skb;
577 unsigned long flags; 577 unsigned long flags;
@@ -638,13 +638,10 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id)
638 int len; 638 int len;
639 int dlen; 639 int dlen;
640 int icount = 0; 640 int icount = 0;
641 struct net_device *dev; 641 struct net_device *dev = dev_id;
642 elp_device *adapter; 642 elp_device *adapter = netdev_priv(dev);
643 unsigned long timeout; 643 unsigned long timeout;
644 644
645 dev = dev_id;
646 adapter = (elp_device *) dev->priv;
647
648 spin_lock(&adapter->lock); 645 spin_lock(&adapter->lock);
649 646
650 do { 647 do {
@@ -672,7 +669,6 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id)
672 skb->protocol = eth_type_trans(skb,dev); 669 skb->protocol = eth_type_trans(skb,dev);
673 dev->stats.rx_bytes += skb->len; 670 dev->stats.rx_bytes += skb->len;
674 netif_rx(skb); 671 netif_rx(skb);
675 dev->last_rx = jiffies;
676 } 672 }
677 } 673 }
678 adapter->dmaing = 0; 674 adapter->dmaing = 0;
@@ -838,11 +834,9 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id)
838 834
839static int elp_open(struct net_device *dev) 835static int elp_open(struct net_device *dev)
840{ 836{
841 elp_device *adapter; 837 elp_device *adapter = netdev_priv(dev);
842 int retval; 838 int retval;
843 839
844 adapter = dev->priv;
845
846 if (elp_debug >= 3) 840 if (elp_debug >= 3)
847 printk(KERN_DEBUG "%s: request to open device\n", dev->name); 841 printk(KERN_DEBUG "%s: request to open device\n", dev->name);
848 842
@@ -971,7 +965,7 @@ static int elp_open(struct net_device *dev)
971 965
972static bool send_packet(struct net_device *dev, struct sk_buff *skb) 966static bool send_packet(struct net_device *dev, struct sk_buff *skb)
973{ 967{
974 elp_device *adapter = dev->priv; 968 elp_device *adapter = netdev_priv(dev);
975 unsigned long target; 969 unsigned long target;
976 unsigned long flags; 970 unsigned long flags;
977 971
@@ -1062,7 +1056,7 @@ static void elp_timeout(struct net_device *dev)
1062static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev) 1056static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev)
1063{ 1057{
1064 unsigned long flags; 1058 unsigned long flags;
1065 elp_device *adapter = dev->priv; 1059 elp_device *adapter = netdev_priv(dev);
1066 1060
1067 spin_lock_irqsave(&adapter->lock, flags); 1061 spin_lock_irqsave(&adapter->lock, flags);
1068 check_3c505_dma(dev); 1062 check_3c505_dma(dev);
@@ -1104,7 +1098,7 @@ static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev)
1104 1098
1105static struct net_device_stats *elp_get_stats(struct net_device *dev) 1099static struct net_device_stats *elp_get_stats(struct net_device *dev)
1106{ 1100{
1107 elp_device *adapter = (elp_device *) dev->priv; 1101 elp_device *adapter = netdev_priv(dev);
1108 1102
1109 if (elp_debug >= 3) 1103 if (elp_debug >= 3)
1110 printk(KERN_DEBUG "%s: request for stats\n", dev->name); 1104 printk(KERN_DEBUG "%s: request for stats\n", dev->name);
@@ -1166,9 +1160,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
1166 1160
1167static int elp_close(struct net_device *dev) 1161static int elp_close(struct net_device *dev)
1168{ 1162{
1169 elp_device *adapter; 1163 elp_device *adapter = netdev_priv(dev);
1170
1171 adapter = dev->priv;
1172 1164
1173 if (elp_debug >= 3) 1165 if (elp_debug >= 3)
1174 printk(KERN_DEBUG "%s: request to close device\n", dev->name); 1166 printk(KERN_DEBUG "%s: request to close device\n", dev->name);
@@ -1209,7 +1201,7 @@ static int elp_close(struct net_device *dev)
1209 1201
1210static void elp_set_mc_list(struct net_device *dev) 1202static void elp_set_mc_list(struct net_device *dev)
1211{ 1203{
1212 elp_device *adapter = (elp_device *) dev->priv; 1204 elp_device *adapter = netdev_priv(dev);
1213 struct dev_mc_list *dmi = dev->mc_list; 1205 struct dev_mc_list *dmi = dev->mc_list;
1214 int i; 1206 int i;
1215 unsigned long flags; 1207 unsigned long flags;
@@ -1380,12 +1372,11 @@ static int __init elp_autodetect(struct net_device *dev)
1380 1372
1381static int __init elplus_setup(struct net_device *dev) 1373static int __init elplus_setup(struct net_device *dev)
1382{ 1374{
1383 elp_device *adapter = dev->priv; 1375 elp_device *adapter = netdev_priv(dev);
1384 int i, tries, tries1, okay; 1376 int i, tries, tries1, okay;
1385 unsigned long timeout; 1377 unsigned long timeout;
1386 unsigned long cookie = 0; 1378 unsigned long cookie = 0;
1387 int err = -ENODEV; 1379 int err = -ENODEV;
1388 DECLARE_MAC_BUF(mac);
1389 1380
1390 /* 1381 /*
1391 * setup adapter structure 1382 * setup adapter structure
@@ -1522,9 +1513,9 @@ static int __init elplus_setup(struct net_device *dev)
1522 * print remainder of startup message 1513 * print remainder of startup message
1523 */ 1514 */
1524 printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, " 1515 printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, "
1525 "addr %s, ", 1516 "addr %pM, ",
1526 dev->name, dev->base_addr, dev->irq, dev->dma, 1517 dev->name, dev->base_addr, dev->irq, dev->dma,
1527 print_mac(mac, dev->dev_addr)); 1518 dev->dev_addr);
1528 1519
1529 /* 1520 /*
1530 * read more information from the adapter 1521 * read more information from the adapter
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c
index 030c147211ba..b8585ecd1d78 100644
--- a/drivers/net/3c507.c
+++ b/drivers/net/3c507.c
@@ -357,7 +357,6 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
357 static unsigned char init_ID_done, version_printed; 357 static unsigned char init_ID_done, version_printed;
358 int i, irq, irqval, retval; 358 int i, irq, irqval, retval;
359 struct net_local *lp; 359 struct net_local *lp;
360 DECLARE_MAC_BUF(mac);
361 360
362 if (init_ID_done == 0) { 361 if (init_ID_done == 0) {
363 ushort lrs_state = 0xff; 362 ushort lrs_state = 0xff;
@@ -405,7 +404,7 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
405 outb(0x01, ioaddr + MISC_CTRL); 404 outb(0x01, ioaddr + MISC_CTRL);
406 for (i = 0; i < 6; i++) 405 for (i = 0; i < 6; i++)
407 dev->dev_addr[i] = inb(ioaddr + i); 406 dev->dev_addr[i] = inb(ioaddr + i);
408 printk(" %s", print_mac(mac, dev->dev_addr)); 407 printk(" %pM", dev->dev_addr);
409 408
410 if (mem_start) 409 if (mem_start)
411 net_debug = mem_start & 7; 410 net_debug = mem_start & 7;
@@ -866,7 +865,6 @@ static void el16_rx(struct net_device *dev)
866 865
867 skb->protocol=eth_type_trans(skb,dev); 866 skb->protocol=eth_type_trans(skb,dev);
868 netif_rx(skb); 867 netif_rx(skb);
869 dev->last_rx = jiffies;
870 dev->stats.rx_packets++; 868 dev->stats.rx_packets++;
871 dev->stats.rx_bytes += pkt_len; 869 dev->stats.rx_bytes += pkt_len;
872 } 870 }
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index c7a4f3bcc2bc..535c234286ea 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -541,7 +541,6 @@ static int __devinit el3_common_init(struct net_device *dev)
541{ 541{
542 struct el3_private *lp = netdev_priv(dev); 542 struct el3_private *lp = netdev_priv(dev);
543 int err; 543 int err;
544 DECLARE_MAC_BUF(mac);
545 const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"}; 544 const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
546 545
547 spin_lock_init(&lp->lock); 546 spin_lock_init(&lp->lock);
@@ -575,9 +574,9 @@ static int __devinit el3_common_init(struct net_device *dev)
575 } 574 }
576 575
577 printk(KERN_INFO "%s: 3c5x9 found at %#3.3lx, %s port, " 576 printk(KERN_INFO "%s: 3c5x9 found at %#3.3lx, %s port, "
578 "address %s, IRQ %d.\n", 577 "address %pM, IRQ %d.\n",
579 dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)], 578 dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)],
580 print_mac(mac, dev->dev_addr), dev->irq); 579 dev->dev_addr, dev->irq);
581 580
582 if (el3_debug > 0) 581 if (el3_debug > 0)
583 printk(KERN_INFO "%s", version); 582 printk(KERN_INFO "%s", version);
@@ -1075,7 +1074,6 @@ el3_rx(struct net_device *dev)
1075 outw(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */ 1074 outw(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */
1076 skb->protocol = eth_type_trans(skb,dev); 1075 skb->protocol = eth_type_trans(skb,dev);
1077 netif_rx(skb); 1076 netif_rx(skb);
1078 dev->last_rx = jiffies;
1079 dev->stats.rx_bytes += pkt_len; 1077 dev->stats.rx_bytes += pkt_len;
1080 dev->stats.rx_packets++; 1078 dev->stats.rx_packets++;
1081 continue; 1079 continue;
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index a0f8b6e2d0af..7f995008a45c 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -570,7 +570,6 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
570 unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */ 570 unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */
571 int i; 571 int i;
572 int irq; 572 int irq;
573 DECLARE_MAC_BUF(mac);
574 573
575#ifdef __ISAPNP__ 574#ifdef __ISAPNP__
576 if (idev) { 575 if (idev) {
@@ -636,7 +635,7 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
636 checksum = (checksum ^ (checksum >> 8)) & 0xff; 635 checksum = (checksum ^ (checksum >> 8)) & 0xff;
637 if (checksum != 0x00) 636 if (checksum != 0x00)
638 printk(" ***INVALID CHECKSUM %4.4x*** ", checksum); 637 printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);
639 printk(" %s", print_mac(mac, dev->dev_addr)); 638 printk(" %pM", dev->dev_addr);
640 if (eeprom[16] == 0x11c7) { /* Corkscrew */ 639 if (eeprom[16] == 0x11c7) { /* Corkscrew */
641 if (request_dma(dev->dma, "3c515")) { 640 if (request_dma(dev->dma, "3c515")) {
642 printk(", DMA %d allocation failed", dev->dma); 641 printk(", DMA %d allocation failed", dev->dma);
@@ -1302,7 +1301,6 @@ static int corkscrew_rx(struct net_device *dev)
1302 outw(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */ 1301 outw(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */
1303 skb->protocol = eth_type_trans(skb, dev); 1302 skb->protocol = eth_type_trans(skb, dev);
1304 netif_rx(skb); 1303 netif_rx(skb);
1305 dev->last_rx = jiffies;
1306 dev->stats.rx_packets++; 1304 dev->stats.rx_packets++;
1307 dev->stats.rx_bytes += pkt_len; 1305 dev->stats.rx_bytes += pkt_len;
1308 /* Wait a limited time to go to next packet. */ 1306 /* Wait a limited time to go to next packet. */
@@ -1389,7 +1387,6 @@ static int boomerang_rx(struct net_device *dev)
1389 } 1387 }
1390 skb->protocol = eth_type_trans(skb, dev); 1388 skb->protocol = eth_type_trans(skb, dev);
1391 netif_rx(skb); 1389 netif_rx(skb);
1392 dev->last_rx = jiffies;
1393 dev->stats.rx_packets++; 1390 dev->stats.rx_packets++;
1394 } 1391 }
1395 entry = (++vp->cur_rx) % RX_RING_SIZE; 1392 entry = (++vp->cur_rx) % RX_RING_SIZE;
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index e2ce41d3828e..59ea2910bcac 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -308,7 +308,7 @@ static int elmc_open(struct net_device *dev)
308 308
309static int __init check586(struct net_device *dev, unsigned long where, unsigned size) 309static int __init check586(struct net_device *dev, unsigned long where, unsigned size)
310{ 310{
311 struct priv *p = (struct priv *) dev->priv; 311 struct priv *p = netdev_priv(dev);
312 char *iscp_addrs[2]; 312 char *iscp_addrs[2];
313 int i = 0; 313 int i = 0;
314 314
@@ -349,7 +349,7 @@ static int __init check586(struct net_device *dev, unsigned long where, unsigned
349 349
350void alloc586(struct net_device *dev) 350void alloc586(struct net_device *dev)
351{ 351{
352 struct priv *p = (struct priv *) dev->priv; 352 struct priv *p = netdev_priv(dev);
353 353
354 elmc_id_reset586(); 354 elmc_id_reset586();
355 DELAY(2); 355 DELAY(2);
@@ -383,7 +383,6 @@ static int elmc_getinfo(char *buf, int slot, void *d)
383{ 383{
384 int len = 0; 384 int len = 0;
385 struct net_device *dev = d; 385 struct net_device *dev = d;
386 DECLARE_MAC_BUF(mac);
387 386
388 if (dev == NULL) 387 if (dev == NULL)
389 return len; 388 return len;
@@ -398,8 +397,8 @@ static int elmc_getinfo(char *buf, int slot, void *d)
398 len += sprintf(buf + len, "Transceiver: %s\n", dev->if_port ? 397 len += sprintf(buf + len, "Transceiver: %s\n", dev->if_port ?
399 "External" : "Internal"); 398 "External" : "Internal");
400 len += sprintf(buf + len, "Device: %s\n", dev->name); 399 len += sprintf(buf + len, "Device: %s\n", dev->name);
401 len += sprintf(buf + len, "Hardware Address: %s\n", 400 len += sprintf(buf + len, "Hardware Address: %pM\n",
402 print_mac(mac, dev->dev_addr)); 401 dev->dev_addr);
403 402
404 return len; 403 return len;
405} /* elmc_getinfo() */ 404} /* elmc_getinfo() */
@@ -416,8 +415,7 @@ static int __init do_elmc_probe(struct net_device *dev)
416 int i = 0; 415 int i = 0;
417 unsigned int size = 0; 416 unsigned int size = 0;
418 int retval; 417 int retval;
419 struct priv *pr = dev->priv; 418 struct priv *pr = netdev_priv(dev);
420 DECLARE_MAC_BUF(mac);
421 419
422 if (MCA_bus == 0) { 420 if (MCA_bus == 0) {
423 return -ENODEV; 421 return -ENODEV;
@@ -543,8 +541,8 @@ static int __init do_elmc_probe(struct net_device *dev)
543 for (i = 0; i < 6; i++) 541 for (i = 0; i < 6; i++)
544 dev->dev_addr[i] = inb(dev->base_addr + i); 542 dev->dev_addr[i] = inb(dev->base_addr + i);
545 543
546 printk(KERN_INFO "%s: hardware address %s\n", 544 printk(KERN_INFO "%s: hardware address %pM\n",
547 dev->name, print_mac(mac, dev->dev_addr)); 545 dev->name, dev->dev_addr);
548 546
549 dev->open = &elmc_open; 547 dev->open = &elmc_open;
550 dev->stop = &elmc_close; 548 dev->stop = &elmc_close;
@@ -580,7 +578,8 @@ err_out:
580 578
581static void cleanup_card(struct net_device *dev) 579static void cleanup_card(struct net_device *dev)
582{ 580{
583 mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot, NULL, NULL); 581 mca_set_adapter_procfn(((struct priv *)netdev_priv(dev))->slot,
582 NULL, NULL);
584 release_region(dev->base_addr, ELMC_IO_EXTENT); 583 release_region(dev->base_addr, ELMC_IO_EXTENT);
585} 584}
586 585
@@ -616,7 +615,7 @@ static int init586(struct net_device *dev)
616 void *ptr; 615 void *ptr;
617 unsigned long s; 616 unsigned long s;
618 int i, result = 0; 617 int i, result = 0;
619 struct priv *p = (struct priv *) dev->priv; 618 struct priv *p = netdev_priv(dev);
620 volatile struct configure_cmd_struct *cfg_cmd; 619 volatile struct configure_cmd_struct *cfg_cmd;
621 volatile struct iasetup_cmd_struct *ias_cmd; 620 volatile struct iasetup_cmd_struct *ias_cmd;
622 volatile struct tdr_cmd_struct *tdr_cmd; 621 volatile struct tdr_cmd_struct *tdr_cmd;
@@ -852,7 +851,7 @@ static void *alloc_rfa(struct net_device *dev, void *ptr)
852 volatile struct rfd_struct *rfd = (struct rfd_struct *) ptr; 851 volatile struct rfd_struct *rfd = (struct rfd_struct *) ptr;
853 volatile struct rbd_struct *rbd; 852 volatile struct rbd_struct *rbd;
854 int i; 853 int i;
855 struct priv *p = (struct priv *) dev->priv; 854 struct priv *p = netdev_priv(dev);
856 855
857 memset((char *) rfd, 0, sizeof(struct rfd_struct) * p->num_recv_buffs); 856 memset((char *) rfd, 0, sizeof(struct rfd_struct) * p->num_recv_buffs);
858 p->rfd_first = rfd; 857 p->rfd_first = rfd;
@@ -913,7 +912,7 @@ elmc_interrupt(int irq, void *dev_id)
913 } 912 }
914 /* reading ELMC_CTRL also clears the INT bit. */ 913 /* reading ELMC_CTRL also clears the INT bit. */
915 914
916 p = (struct priv *) dev->priv; 915 p = netdev_priv(dev);
917 916
918 while ((stat = p->scb->status & STAT_MASK)) 917 while ((stat = p->scb->status & STAT_MASK))
919 { 918 {
@@ -969,7 +968,7 @@ static void elmc_rcv_int(struct net_device *dev)
969 unsigned short totlen; 968 unsigned short totlen;
970 struct sk_buff *skb; 969 struct sk_buff *skb;
971 struct rbd_struct *rbd; 970 struct rbd_struct *rbd;
972 struct priv *p = (struct priv *) dev->priv; 971 struct priv *p = netdev_priv(dev);
973 972
974 for (; (status = p->rfd_top->status) & STAT_COMPL;) { 973 for (; (status = p->rfd_top->status) & STAT_COMPL;) {
975 rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset); 974 rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
@@ -985,7 +984,6 @@ static void elmc_rcv_int(struct net_device *dev)
985 skb_copy_to_linear_data(skb, (char *) p->base+(unsigned long) rbd->buffer,totlen); 984 skb_copy_to_linear_data(skb, (char *) p->base+(unsigned long) rbd->buffer,totlen);
986 skb->protocol = eth_type_trans(skb, dev); 985 skb->protocol = eth_type_trans(skb, dev);
987 netif_rx(skb); 986 netif_rx(skb);
988 dev->last_rx = jiffies;
989 dev->stats.rx_packets++; 987 dev->stats.rx_packets++;
990 dev->stats.rx_bytes += totlen; 988 dev->stats.rx_bytes += totlen;
991 } else { 989 } else {
@@ -1013,7 +1011,7 @@ static void elmc_rcv_int(struct net_device *dev)
1013 1011
1014static void elmc_rnr_int(struct net_device *dev) 1012static void elmc_rnr_int(struct net_device *dev)
1015{ 1013{
1016 struct priv *p = (struct priv *) dev->priv; 1014 struct priv *p = netdev_priv(dev);
1017 1015
1018 dev->stats.rx_errors++; 1016 dev->stats.rx_errors++;
1019 1017
@@ -1036,7 +1034,7 @@ static void elmc_rnr_int(struct net_device *dev)
1036static void elmc_xmt_int(struct net_device *dev) 1034static void elmc_xmt_int(struct net_device *dev)
1037{ 1035{
1038 int status; 1036 int status;
1039 struct priv *p = (struct priv *) dev->priv; 1037 struct priv *p = netdev_priv(dev);
1040 1038
1041 status = p->xmit_cmds[p->xmit_last]->cmd_status; 1039 status = p->xmit_cmds[p->xmit_last]->cmd_status;
1042 if (!(status & STAT_COMPL)) { 1040 if (!(status & STAT_COMPL)) {
@@ -1079,7 +1077,7 @@ static void elmc_xmt_int(struct net_device *dev)
1079 1077
1080static void startrecv586(struct net_device *dev) 1078static void startrecv586(struct net_device *dev)
1081{ 1079{
1082 struct priv *p = (struct priv *) dev->priv; 1080 struct priv *p = netdev_priv(dev);
1083 1081
1084 p->scb->rfa_offset = make16(p->rfd_first); 1082 p->scb->rfa_offset = make16(p->rfd_first);
1085 p->scb->cmd = RUC_START; 1083 p->scb->cmd = RUC_START;
@@ -1093,7 +1091,7 @@ static void startrecv586(struct net_device *dev)
1093 1091
1094static void elmc_timeout(struct net_device *dev) 1092static void elmc_timeout(struct net_device *dev)
1095{ 1093{
1096 struct priv *p = (struct priv *) dev->priv; 1094 struct priv *p = netdev_priv(dev);
1097 /* COMMAND-UNIT active? */ 1095 /* COMMAND-UNIT active? */
1098 if (p->scb->status & CU_ACTIVE) { 1096 if (p->scb->status & CU_ACTIVE) {
1099#ifdef DEBUG 1097#ifdef DEBUG
@@ -1129,7 +1127,7 @@ static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev)
1129#ifndef NO_NOPCOMMANDS 1127#ifndef NO_NOPCOMMANDS
1130 int next_nop; 1128 int next_nop;
1131#endif 1129#endif
1132 struct priv *p = (struct priv *) dev->priv; 1130 struct priv *p = netdev_priv(dev);
1133 1131
1134 netif_stop_queue(dev); 1132 netif_stop_queue(dev);
1135 1133
@@ -1200,7 +1198,7 @@ static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev)
1200 1198
1201static struct net_device_stats *elmc_get_stats(struct net_device *dev) 1199static struct net_device_stats *elmc_get_stats(struct net_device *dev)
1202{ 1200{
1203 struct priv *p = (struct priv *) dev->priv; 1201 struct priv *p = netdev_priv(dev);
1204 unsigned short crc, aln, rsc, ovrn; 1202 unsigned short crc, aln, rsc, ovrn;
1205 1203
1206 crc = p->scb->crc_errs; /* get error-statistic from the ni82586 */ 1204 crc = p->scb->crc_errs; /* get error-statistic from the ni82586 */
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index abc84f765973..2df3af3b9b20 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -335,7 +335,6 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
335 "82586 initialisation failure", 335 "82586 initialisation failure",
336 "Adapter list configuration error" 336 "Adapter list configuration error"
337 }; 337 };
338 DECLARE_MAC_BUF(mac);
339 338
340 /* Time to play MCA games */ 339 /* Time to play MCA games */
341 340
@@ -405,7 +404,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
405 dev->dev_addr[i] = mca_read_pos(slot,3); 404 dev->dev_addr[i] = mca_read_pos(slot,3);
406 } 405 }
407 406
408 printk("%s: Address %s", dev->name, print_mac(mac, dev->dev_addr)); 407 printk("%s: Address %pM", dev->name, dev->dev_addr);
409 408
410 mca_write_pos(slot, 6, 0); 409 mca_write_pos(slot, 6, 0);
411 mca_write_pos(slot, 7, 0); 410 mca_write_pos(slot, 7, 0);
@@ -1187,7 +1186,6 @@ static void mc32_rx_ring(struct net_device *dev)
1187 } 1186 }
1188 1187
1189 skb->protocol=eth_type_trans(skb,dev); 1188 skb->protocol=eth_type_trans(skb,dev);
1190 dev->last_rx = jiffies;
1191 dev->stats.rx_packets++; 1189 dev->stats.rx_packets++;
1192 dev->stats.rx_bytes += length; 1190 dev->stats.rx_bytes += length;
1193 netif_rx(skb); 1191 netif_rx(skb);
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 9ba295d9dd97..665e7fdf27a1 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -803,7 +803,7 @@ static int vortex_suspend(struct pci_dev *pdev, pm_message_t state)
803{ 803{
804 struct net_device *dev = pci_get_drvdata(pdev); 804 struct net_device *dev = pci_get_drvdata(pdev);
805 805
806 if (dev && dev->priv) { 806 if (dev && netdev_priv(dev)) {
807 if (netif_running(dev)) { 807 if (netif_running(dev)) {
808 netif_device_detach(dev); 808 netif_device_detach(dev);
809 vortex_down(dev, 1); 809 vortex_down(dev, 1);
@@ -1013,7 +1013,6 @@ static int __devinit vortex_probe1(struct device *gendev,
1013 const char *print_name = "3c59x"; 1013 const char *print_name = "3c59x";
1014 struct pci_dev *pdev = NULL; 1014 struct pci_dev *pdev = NULL;
1015 struct eisa_device *edev = NULL; 1015 struct eisa_device *edev = NULL;
1016 DECLARE_MAC_BUF(mac);
1017 1016
1018 if (!printed_version) { 1017 if (!printed_version) {
1019 printk (version); 1018 printk (version);
@@ -1026,7 +1025,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1026 } 1025 }
1027 1026
1028 if ((edev = DEVICE_EISA(gendev))) { 1027 if ((edev = DEVICE_EISA(gendev))) {
1029 print_name = edev->dev.bus_id; 1028 print_name = dev_name(&edev->dev);
1030 } 1029 }
1031 } 1030 }
1032 1031
@@ -1206,7 +1205,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1206 ((__be16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]); 1205 ((__be16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]);
1207 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 1206 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
1208 if (print_info) 1207 if (print_info)
1209 printk(" %s", print_mac(mac, dev->dev_addr)); 1208 printk(" %pM", dev->dev_addr);
1210 /* Unfortunately an all zero eeprom passes the checksum and this 1209 /* Unfortunately an all zero eeprom passes the checksum and this
1211 gets found in the wild in failure cases. Crypto is hard 8) */ 1210 gets found in the wild in failure cases. Crypto is hard 8) */
1212 if (!is_valid_ether_addr(dev->dev_addr)) { 1211 if (!is_valid_ether_addr(dev->dev_addr)) {
@@ -2447,7 +2446,6 @@ static int vortex_rx(struct net_device *dev)
2447 iowrite16(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */ 2446 iowrite16(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */
2448 skb->protocol = eth_type_trans(skb, dev); 2447 skb->protocol = eth_type_trans(skb, dev);
2449 netif_rx(skb); 2448 netif_rx(skb);
2450 dev->last_rx = jiffies;
2451 dev->stats.rx_packets++; 2449 dev->stats.rx_packets++;
2452 /* Wait a limited time to go to next packet. */ 2450 /* Wait a limited time to go to next packet. */
2453 for (i = 200; i >= 0; i--) 2451 for (i = 200; i >= 0; i--)
@@ -2530,7 +2528,6 @@ boomerang_rx(struct net_device *dev)
2530 } 2528 }
2531 } 2529 }
2532 netif_rx(skb); 2530 netif_rx(skb);
2533 dev->last_rx = jiffies;
2534 dev->stats.rx_packets++; 2531 dev->stats.rx_packets++;
2535 } 2532 }
2536 entry = (++vp->cur_rx) % RX_RING_SIZE; 2533 entry = (++vp->cur_rx) % RX_RING_SIZE;
@@ -2886,7 +2883,7 @@ static void vortex_get_drvinfo(struct net_device *dev,
2886 strcpy(info->bus_info, pci_name(VORTEX_PCI(vp))); 2883 strcpy(info->bus_info, pci_name(VORTEX_PCI(vp)));
2887 } else { 2884 } else {
2888 if (VORTEX_EISA(vp)) 2885 if (VORTEX_EISA(vp))
2889 sprintf(info->bus_info, vp->gendev->bus_id); 2886 sprintf(info->bus_info, dev_name(vp->gendev));
2890 else 2887 else
2891 sprintf(info->bus_info, "EISA 0x%lx %d", 2888 sprintf(info->bus_info, "EISA 0x%lx %d",
2892 dev->base_addr, dev->irq); 2889 dev->base_addr, dev->irq);
@@ -3217,7 +3214,7 @@ static void __exit vortex_eisa_cleanup(void)
3217#endif 3214#endif
3218 3215
3219 if (compaq_net_device) { 3216 if (compaq_net_device) {
3220 vp = compaq_net_device->priv; 3217 vp = netdev_priv(compaq_net_device);
3221 ioaddr = ioport_map(compaq_net_device->base_addr, 3218 ioaddr = ioport_map(compaq_net_device->base_addr,
3222 VORTEX_TOTAL_SIZE); 3219 VORTEX_TOTAL_SIZE);
3223 3220
diff --git a/drivers/net/7990.c b/drivers/net/7990.c
index ad6b8a5b6574..7a331acc34ad 100644
--- a/drivers/net/7990.c
+++ b/drivers/net/7990.c
@@ -336,7 +336,6 @@ static int lance_rx (struct net_device *dev)
336 len); 336 len);
337 skb->protocol = eth_type_trans (skb, dev); 337 skb->protocol = eth_type_trans (skb, dev);
338 netif_rx (skb); 338 netif_rx (skb);
339 dev->last_rx = jiffies;
340 dev->stats.rx_packets++; 339 dev->stats.rx_packets++;
341 dev->stats.rx_bytes += len; 340 dev->stats.rx_bytes += len;
342 } 341 }
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 9ba1f0b46429..664bd73645cb 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -457,7 +457,6 @@ static inline void cp_rx_skb (struct cp_private *cp, struct sk_buff *skb,
457 457
458 cp->dev->stats.rx_packets++; 458 cp->dev->stats.rx_packets++;
459 cp->dev->stats.rx_bytes += skb->len; 459 cp->dev->stats.rx_bytes += skb->len;
460 cp->dev->last_rx = jiffies;
461 460
462#if CP_VLAN_TAG_USED 461#if CP_VLAN_TAG_USED
463 if (cp->vlgrp && (desc->opts2 & cpu_to_le32(RxVlanTagged))) { 462 if (cp->vlgrp && (desc->opts2 & cpu_to_le32(RxVlanTagged))) {
@@ -1826,7 +1825,6 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1826 void __iomem *regs; 1825 void __iomem *regs;
1827 resource_size_t pciaddr; 1826 resource_size_t pciaddr;
1828 unsigned int addr_len, i, pci_using_dac; 1827 unsigned int addr_len, i, pci_using_dac;
1829 DECLARE_MAC_BUF(mac);
1830 1828
1831#ifndef MODULE 1829#ifndef MODULE
1832 static int version_printed; 1830 static int version_printed;
@@ -1967,10 +1965,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1967 goto err_out_iomap; 1965 goto err_out_iomap;
1968 1966
1969 printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, " 1967 printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
1970 "%s, IRQ %d\n", 1968 "%pM, IRQ %d\n",
1971 dev->name, 1969 dev->name,
1972 dev->base_addr, 1970 dev->base_addr,
1973 print_mac(mac, dev->dev_addr), 1971 dev->dev_addr,
1974 dev->irq); 1972 dev->irq);
1975 1973
1976 pci_set_drvdata(pdev, dev); 1974 pci_set_drvdata(pdev, dev);
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 63f906b04899..37456ada44cf 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -925,7 +925,6 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
925 int i, addr_len, option; 925 int i, addr_len, option;
926 void __iomem *ioaddr; 926 void __iomem *ioaddr;
927 static int board_idx = -1; 927 static int board_idx = -1;
928 DECLARE_MAC_BUF(mac);
929 928
930 assert (pdev != NULL); 929 assert (pdev != NULL);
931 assert (ent != NULL); 930 assert (ent != NULL);
@@ -1024,11 +1023,11 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1024 pci_set_drvdata (pdev, dev); 1023 pci_set_drvdata (pdev, dev);
1025 1024
1026 printk (KERN_INFO "%s: %s at 0x%lx, " 1025 printk (KERN_INFO "%s: %s at 0x%lx, "
1027 "%s, IRQ %d\n", 1026 "%pM, IRQ %d\n",
1028 dev->name, 1027 dev->name,
1029 board_info[ent->driver_data].name, 1028 board_info[ent->driver_data].name,
1030 dev->base_addr, 1029 dev->base_addr,
1031 print_mac(mac, dev->dev_addr), 1030 dev->dev_addr,
1032 dev->irq); 1031 dev->irq);
1033 1032
1034 printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n", 1033 printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n",
@@ -2026,7 +2025,6 @@ no_early_rx:
2026 2025
2027 skb->protocol = eth_type_trans (skb, dev); 2026 skb->protocol = eth_type_trans (skb, dev);
2028 2027
2029 dev->last_rx = jiffies;
2030 dev->stats.rx_bytes += pkt_size; 2028 dev->stats.rx_bytes += pkt_size;
2031 dev->stats.rx_packets++; 2029 dev->stats.rx_packets++;
2032 2030
diff --git a/drivers/net/82596.c b/drivers/net/82596.c
index da292e647eb1..717fe2f7c66a 100644
--- a/drivers/net/82596.c
+++ b/drivers/net/82596.c
@@ -841,7 +841,6 @@ memory_squeeze:
841 pkt_len); 841 pkt_len);
842#endif 842#endif
843 netif_rx(skb); 843 netif_rx(skb);
844 dev->last_rx = jiffies;
845 dev->stats.rx_packets++; 844 dev->stats.rx_packets++;
846 dev->stats.rx_bytes+=pkt_len; 845 dev->stats.rx_bytes+=pkt_len;
847 } 846 }
@@ -1116,12 +1115,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
1116 1115
1117static void print_eth(unsigned char *add, char *str) 1116static void print_eth(unsigned char *add, char *str)
1118{ 1117{
1119 DECLARE_MAC_BUF(mac); 1118 printk(KERN_DEBUG "i596 0x%p, %pM --> %pM %02X%02X, %s\n",
1120 DECLARE_MAC_BUF(mac2); 1119 add, add + 6, add, add[12], add[13], str);
1121
1122 printk(KERN_DEBUG "i596 0x%p, %s --> %s %02X%02X, %s\n",
1123 add, print_mac(mac, add + 6), print_mac(mac2, add),
1124 add[12], add[13], str);
1125} 1120}
1126 1121
1127static int io = 0x300; 1122static int io = 0x300;
@@ -1544,7 +1539,6 @@ static void set_multicast_list(struct net_device *dev)
1544 struct dev_mc_list *dmi; 1539 struct dev_mc_list *dmi;
1545 unsigned char *cp; 1540 unsigned char *cp;
1546 struct mc_cmd *cmd; 1541 struct mc_cmd *cmd;
1547 DECLARE_MAC_BUF(mac);
1548 1542
1549 if (wait_cfg(dev, &lp->mc_cmd.cmd, 1000, "multicast list change request timed out")) 1543 if (wait_cfg(dev, &lp->mc_cmd.cmd, 1000, "multicast list change request timed out"))
1550 return; 1544 return;
@@ -1555,8 +1549,8 @@ static void set_multicast_list(struct net_device *dev)
1555 for (dmi = dev->mc_list; cnt && dmi != NULL; dmi = dmi->next, cnt--, cp += 6) { 1549 for (dmi = dev->mc_list; cnt && dmi != NULL; dmi = dmi->next, cnt--, cp += 6) {
1556 memcpy(cp, dmi->dmi_addr, 6); 1550 memcpy(cp, dmi->dmi_addr, 6);
1557 if (i596_debug > 1) 1551 if (i596_debug > 1)
1558 DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %s\n", 1552 DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %pM\n",
1559 dev->name, print_mac(mac, cp))); 1553 dev->name, cp));
1560 } 1554 }
1561 i596_add_cmd(dev, &cmd->cmd); 1555 i596_add_cmd(dev, &cmd->cmd);
1562 } 1556 }
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 11f143f4adf6..732ea834d50d 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -61,6 +61,7 @@ config DUMMY
61config BONDING 61config BONDING
62 tristate "Bonding driver support" 62 tristate "Bonding driver support"
63 depends on INET 63 depends on INET
64 depends on IPV6 || IPV6=n
64 ---help--- 65 ---help---
65 Say 'Y' or 'M' if you wish to be able to 'bond' multiple Ethernet 66 Say 'Y' or 'M' if you wish to be able to 'bond' multiple Ethernet
66 Channels together. This is called 'Etherchannel' by Cisco, 67 Channels together. This is called 'Etherchannel' by Cisco,
@@ -978,6 +979,20 @@ config SMC911X
978 called smc911x. If you want to compile it as a module, say M 979 called smc911x. If you want to compile it as a module, say M
979 here and read <file:Documentation/kbuild/modules.txt> 980 here and read <file:Documentation/kbuild/modules.txt>
980 981
982config SMSC911X
983 tristate "SMSC LAN911x/LAN921x families embedded ethernet support"
984 depends on ARM || SUPERH
985 select CRC32
986 select MII
987 select PHYLIB
988 ---help---
989 Say Y here if you want support for SMSC LAN911x and LAN921x families
990 of ethernet controllers.
991
992 To compile this driver as a module, choose M here and read
993 <file:Documentation/networking/net-modules.txt>. The module
994 will be called smsc911x.
995
981config NET_VENDOR_RACAL 996config NET_VENDOR_RACAL
982 bool "Racal-Interlan (Micom) NI cards" 997 bool "Racal-Interlan (Micom) NI cards"
983 depends on ISA 998 depends on ISA
@@ -1414,19 +1429,6 @@ config TC35815
1414 depends on NET_PCI && PCI && MIPS 1429 depends on NET_PCI && PCI && MIPS
1415 select PHYLIB 1430 select PHYLIB
1416 1431
1417config EEPRO100
1418 tristate "EtherExpressPro/100 support (eepro100, original Becker driver)"
1419 depends on NET_PCI && PCI
1420 select MII
1421 help
1422 If you have an Intel EtherExpress PRO/100 PCI network (Ethernet)
1423 card, say Y and read the Ethernet-HOWTO, available from
1424 <http://www.tldp.org/docs.html#howto>.
1425
1426 To compile this driver as a module, choose M here. The module
1427 will be called eepro100.
1428
1429
1430config E100 1432config E100
1431 tristate "Intel(R) PRO/100+ support" 1433 tristate "Intel(R) PRO/100+ support"
1432 depends on NET_PCI && PCI 1434 depends on NET_PCI && PCI
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index f19acf8b9220..e06829aa75b0 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -53,7 +53,6 @@ obj-$(CONFIG_VORTEX) += 3c59x.o
53obj-$(CONFIG_TYPHOON) += typhoon.o 53obj-$(CONFIG_TYPHOON) += typhoon.o
54obj-$(CONFIG_NE2K_PCI) += ne2k-pci.o 8390.o 54obj-$(CONFIG_NE2K_PCI) += ne2k-pci.o 8390.o
55obj-$(CONFIG_PCNET32) += pcnet32.o 55obj-$(CONFIG_PCNET32) += pcnet32.o
56obj-$(CONFIG_EEPRO100) += eepro100.o
57obj-$(CONFIG_E100) += e100.o 56obj-$(CONFIG_E100) += e100.o
58obj-$(CONFIG_TLAN) += tlan.o 57obj-$(CONFIG_TLAN) += tlan.o
59obj-$(CONFIG_EPIC100) += epic100.o 58obj-$(CONFIG_EPIC100) += epic100.o
@@ -220,6 +219,7 @@ obj-$(CONFIG_S2IO) += s2io.o
220obj-$(CONFIG_MYRI10GE) += myri10ge/ 219obj-$(CONFIG_MYRI10GE) += myri10ge/
221obj-$(CONFIG_SMC91X) += smc91x.o 220obj-$(CONFIG_SMC91X) += smc91x.o
222obj-$(CONFIG_SMC911X) += smc911x.o 221obj-$(CONFIG_SMC911X) += smc911x.o
222obj-$(CONFIG_SMSC911X) += smsc911x.o
223obj-$(CONFIG_BFIN_MAC) += bfin_mac.o 223obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
224obj-$(CONFIG_DM9000) += dm9000.o 224obj-$(CONFIG_DM9000) += dm9000.o
225obj-$(CONFIG_PASEMI_MAC) += pasemi_mac_driver.o 225obj-$(CONFIG_PASEMI_MAC) += pasemi_mac_driver.o
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index 9c0837435b68..7a60bdd9a242 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -324,7 +324,6 @@ static int lance_rx (struct net_device *dev)
324 len); 324 len);
325 skb->protocol = eth_type_trans (skb, dev); 325 skb->protocol = eth_type_trans (skb, dev);
326 netif_rx (skb); 326 netif_rx (skb);
327 dev->last_rx = jiffies;
328 dev->stats.rx_packets++; 327 dev->stats.rx_packets++;
329 dev->stats.rx_bytes += len; 328 dev->stats.rx_bytes += len;
330 } 329 }
@@ -710,7 +709,6 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
710 unsigned long board, base_addr, mem_start; 709 unsigned long board, base_addr, mem_start;
711 struct resource *r1, *r2; 710 struct resource *r1, *r2;
712 int err; 711 int err;
713 DECLARE_MAC_BUF(mac);
714 712
715 board = z->resource.start; 713 board = z->resource.start;
716 base_addr = board+A2065_LANCE; 714 base_addr = board+A2065_LANCE;
@@ -787,8 +785,7 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
787 zorro_set_drvdata(z, dev); 785 zorro_set_drvdata(z, dev);
788 786
789 printk(KERN_INFO "%s: A2065 at 0x%08lx, Ethernet Address " 787 printk(KERN_INFO "%s: A2065 at 0x%08lx, Ethernet Address "
790 "%s\n", dev->name, board, 788 "%pM\n", dev->name, board, dev->dev_addr);
791 print_mac(mac, dev->dev_addr));
792 789
793 return 0; 790 return 0;
794} 791}
diff --git a/drivers/net/ac3200.c b/drivers/net/ac3200.c
index b1448637107f..071a851a2ea1 100644
--- a/drivers/net/ac3200.c
+++ b/drivers/net/ac3200.c
@@ -146,7 +146,6 @@ out:
146static int __init ac_probe1(int ioaddr, struct net_device *dev) 146static int __init ac_probe1(int ioaddr, struct net_device *dev)
147{ 147{
148 int i, retval; 148 int i, retval;
149 DECLARE_MAC_BUF(mac);
150 149
151 if (!request_region(ioaddr, AC_IO_EXTENT, DRV_NAME)) 150 if (!request_region(ioaddr, AC_IO_EXTENT, DRV_NAME))
152 return -EBUSY; 151 return -EBUSY;
@@ -171,8 +170,8 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
171 for (i = 0; i < 6; i++) 170 for (i = 0; i < 6; i++)
172 dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i); 171 dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i);
173 172
174 printk(KERN_DEBUG "AC3200 in EISA slot %d, node %s", 173 printk(KERN_DEBUG "AC3200 in EISA slot %d, node %pM",
175 ioaddr/0x1000, print_mac(mac, dev->dev_addr)); 174 ioaddr/0x1000, dev->dev_addr);
176#if 0 175#if 0
177 /* Check the vendor ID/prefix. Redundant after checking the EISA ID */ 176 /* Check the vendor ID/prefix. Redundant after checking the EISA ID */
178 if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0 177 if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 66de80b64b92..109eb7ccff30 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -466,7 +466,7 @@ static int __devinit acenic_probe_one(struct pci_dev *pdev,
466 466
467 SET_NETDEV_DEV(dev, &pdev->dev); 467 SET_NETDEV_DEV(dev, &pdev->dev);
468 468
469 ap = dev->priv; 469 ap = netdev_priv(dev);
470 ap->pdev = pdev; 470 ap->pdev = pdev;
471 ap->name = pci_name(pdev); 471 ap->name = pci_name(pdev);
472 472
@@ -892,7 +892,6 @@ static int __devinit ace_init(struct net_device *dev)
892 int board_idx, ecode = 0; 892 int board_idx, ecode = 0;
893 short i; 893 short i;
894 unsigned char cache_size; 894 unsigned char cache_size;
895 DECLARE_MAC_BUF(mac);
896 895
897 ap = netdev_priv(dev); 896 ap = netdev_priv(dev);
898 regs = ap->regs; 897 regs = ap->regs;
@@ -1019,7 +1018,7 @@ static int __devinit ace_init(struct net_device *dev)
1019 dev->dev_addr[4] = (mac2 >> 8) & 0xff; 1018 dev->dev_addr[4] = (mac2 >> 8) & 0xff;
1020 dev->dev_addr[5] = mac2 & 0xff; 1019 dev->dev_addr[5] = mac2 & 0xff;
1021 1020
1022 printk("MAC: %s\n", print_mac(mac, dev->dev_addr)); 1021 printk("MAC: %pM\n", dev->dev_addr);
1023 1022
1024 /* 1023 /*
1025 * Looks like this is necessary to deal with on all architectures, 1024 * Looks like this is necessary to deal with on all architectures,
@@ -2034,7 +2033,6 @@ static void ace_rx_int(struct net_device *dev, u32 rxretprd, u32 rxretcsm)
2034#endif 2033#endif
2035 netif_rx(skb); 2034 netif_rx(skb);
2036 2035
2037 dev->last_rx = jiffies;
2038 dev->stats.rx_packets++; 2036 dev->stats.rx_packets++;
2039 dev->stats.rx_bytes += retdesc->size; 2037 dev->stats.rx_bytes += retdesc->size;
2040 2038
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index 07a6697e3635..0bc4f54d5db9 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -809,7 +809,6 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
809 lp->coal_conf.rx_packets++; 809 lp->coal_conf.rx_packets++;
810 lp->coal_conf.rx_bytes += pkt_len; 810 lp->coal_conf.rx_bytes += pkt_len;
811 num_rx_pkt++; 811 num_rx_pkt++;
812 dev->last_rx = jiffies;
813 812
814 err_next_pkt: 813 err_next_pkt:
815 lp->rx_ring[rx_index].buff_phy_addr 814 lp->rx_ring[rx_index].buff_phy_addr
@@ -1821,7 +1820,6 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
1821 unsigned long reg_addr,reg_len; 1820 unsigned long reg_addr,reg_len;
1822 struct amd8111e_priv* lp; 1821 struct amd8111e_priv* lp;
1823 struct net_device* dev; 1822 struct net_device* dev;
1824 DECLARE_MAC_BUF(mac);
1825 1823
1826 err = pci_enable_device(pdev); 1824 err = pci_enable_device(pdev);
1827 if(err){ 1825 if(err){
@@ -1963,8 +1961,8 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
1963 chip_version = (readl(lp->mmio + CHIPID) & 0xf0000000)>>28; 1961 chip_version = (readl(lp->mmio + CHIPID) & 0xf0000000)>>28;
1964 printk(KERN_INFO "%s: AMD-8111e Driver Version: %s\n", 1962 printk(KERN_INFO "%s: AMD-8111e Driver Version: %s\n",
1965 dev->name,MODULE_VERS); 1963 dev->name,MODULE_VERS);
1966 printk(KERN_INFO "%s: [ Rev %x ] PCI 10/100BaseT Ethernet %s\n", 1964 printk(KERN_INFO "%s: [ Rev %x ] PCI 10/100BaseT Ethernet %pM\n",
1967 dev->name, chip_version, print_mac(mac, dev->dev_addr)); 1965 dev->name, chip_version, dev->dev_addr);
1968 if (lp->ext_phy_id) 1966 if (lp->ext_phy_id)
1969 printk(KERN_INFO "%s: Found MII PHY ID 0x%08x at address 0x%02x\n", 1967 printk(KERN_INFO "%s: Found MII PHY ID 0x%08x at address 0x%02x\n",
1970 dev->name, lp->ext_phy_id, lp->ext_phy_addr); 1968 dev->name, lp->ext_phy_id, lp->ext_phy_addr);
diff --git a/drivers/net/apne.c b/drivers/net/apne.c
index 867f6fff543c..7426f6940630 100644
--- a/drivers/net/apne.c
+++ b/drivers/net/apne.c
@@ -207,7 +207,6 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
207 int neX000, ctron; 207 int neX000, ctron;
208#endif 208#endif
209 static unsigned version_printed; 209 static unsigned version_printed;
210 DECLARE_MAC_BUF(mac);
211 210
212 if (ei_debug && version_printed++ == 0) 211 if (ei_debug && version_printed++ == 0)
213 printk(version); 212 printk(version);
@@ -323,7 +322,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
323 for(i = 0; i < ETHER_ADDR_LEN; i++) 322 for(i = 0; i < ETHER_ADDR_LEN; i++)
324 dev->dev_addr[i] = SA_prom[i]; 323 dev->dev_addr[i] = SA_prom[i];
325 324
326 printk(" %s\n", print_mac(mac, dev->dev_addr)); 325 printk(" %pM\n", dev->dev_addr);
327 326
328 printk("%s: %s found.\n", dev->name, name); 327 printk("%s: %s found.\n", dev->name, name);
329 328
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 735fc9476403..0c4e3c5ac49c 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -851,7 +851,6 @@ static void cops_rx(struct net_device *dev)
851 851
852 /* Send packet to a higher place. */ 852 /* Send packet to a higher place. */
853 netif_rx(skb); 853 netif_rx(skb);
854 dev->last_rx = jiffies;
855} 854}
856 855
857static void cops_timeout(struct net_device *dev) 856static void cops_timeout(struct net_device *dev)
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index 1071144edd66..9a0be9b2eaad 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -108,7 +108,7 @@ static struct net_device * __init ipddp_init(void)
108 */ 108 */
109static struct net_device_stats *ipddp_get_stats(struct net_device *dev) 109static struct net_device_stats *ipddp_get_stats(struct net_device *dev)
110{ 110{
111 return dev->priv; 111 return netdev_priv(dev);
112} 112}
113 113
114/* 114/*
@@ -170,8 +170,8 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
170 170
171 skb->protocol = htons(ETH_P_ATALK); /* Protocol has changed */ 171 skb->protocol = htons(ETH_P_ATALK); /* Protocol has changed */
172 172
173 ((struct net_device_stats *) dev->priv)->tx_packets++; 173 ((struct net_device_stats *) netdev_priv(dev))->tx_packets++;
174 ((struct net_device_stats *) dev->priv)->tx_bytes+=skb->len; 174 ((struct net_device_stats *) netdev_priv(dev))->tx_bytes += skb->len;
175 175
176 if(aarp_send_ddp(rt->dev, skb, &rt->at, NULL) < 0) 176 if(aarp_send_ddp(rt->dev, skb, &rt->at, NULL) < 0)
177 dev_kfree_skb(skb); 177 dev_kfree_skb(skb);
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index fef5560bc7a2..dc4d49605603 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -726,7 +726,8 @@ static int sendup_buffer (struct net_device *dev)
726 int dnode, snode, llaptype, len; 726 int dnode, snode, llaptype, len;
727 int sklen; 727 int sklen;
728 struct sk_buff *skb; 728 struct sk_buff *skb;
729 struct net_device_stats *stats = &((struct ltpc_private *)dev->priv)->stats; 729 struct ltpc_private *ltpc_priv = netdev_priv(dev);
730 struct net_device_stats *stats = &ltpc_priv->stats;
730 struct lt_rcvlap *ltc = (struct lt_rcvlap *) ltdmacbuf; 731 struct lt_rcvlap *ltc = (struct lt_rcvlap *) ltdmacbuf;
731 732
732 if (ltc->command != LT_RCVLAP) { 733 if (ltc->command != LT_RCVLAP) {
@@ -783,7 +784,6 @@ static int sendup_buffer (struct net_device *dev)
783 784
784 /* toss it onwards */ 785 /* toss it onwards */
785 netif_rx(skb); 786 netif_rx(skb);
786 dev->last_rx = jiffies;
787 return 0; 787 return 0;
788} 788}
789 789
@@ -823,7 +823,8 @@ static int ltpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
823{ 823{
824 struct sockaddr_at *sa = (struct sockaddr_at *) &ifr->ifr_addr; 824 struct sockaddr_at *sa = (struct sockaddr_at *) &ifr->ifr_addr;
825 /* we'll keep the localtalk node address in dev->pa_addr */ 825 /* we'll keep the localtalk node address in dev->pa_addr */
826 struct atalk_addr *aa = &((struct ltpc_private *)dev->priv)->my_addr; 826 struct ltpc_private *ltpc_priv = netdev_priv(dev);
827 struct atalk_addr *aa = &ltpc_priv->my_addr;
827 struct lt_init c; 828 struct lt_init c;
828 int ltflags; 829 int ltflags;
829 830
@@ -904,7 +905,8 @@ static int ltpc_xmit(struct sk_buff *skb, struct net_device *dev)
904 * and skb->len is the length of the ddp data + ddp header 905 * and skb->len is the length of the ddp data + ddp header
905 */ 906 */
906 907
907 struct net_device_stats *stats = &((struct ltpc_private *)dev->priv)->stats; 908 struct ltpc_private *ltpc_priv = netdev_priv(dev);
909 struct net_device_stats *stats = &ltpc_priv->stats;
908 910
909 int i; 911 int i;
910 struct lt_sendlap cbuf; 912 struct lt_sendlap cbuf;
@@ -943,7 +945,8 @@ static int ltpc_xmit(struct sk_buff *skb, struct net_device *dev)
943 945
944static struct net_device_stats *ltpc_get_stats(struct net_device *dev) 946static struct net_device_stats *ltpc_get_stats(struct net_device *dev)
945{ 947{
946 struct net_device_stats *stats = &((struct ltpc_private *) dev->priv)->stats; 948 struct ltpc_private *ltpc_priv = netdev_priv(dev);
949 struct net_device_stats *stats = &ltpc_priv->stats;
947 return stats; 950 return stats;
948} 951}
949 952
diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index e0a18e7c73cb..3ff9affb1a91 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -87,7 +87,7 @@ MODULE_LICENSE("GPL");
87static void rx(struct net_device *dev, int bufnum, 87static void rx(struct net_device *dev, int bufnum,
88 struct archdr *pkthdr, int length) 88 struct archdr *pkthdr, int length)
89{ 89{
90 struct arcnet_local *lp = dev->priv; 90 struct arcnet_local *lp = netdev_priv(dev);
91 struct sk_buff *skb; 91 struct sk_buff *skb;
92 struct archdr *pkt = pkthdr; 92 struct archdr *pkt = pkthdr;
93 int ofs; 93 int ofs;
@@ -125,7 +125,6 @@ static void rx(struct net_device *dev, int bufnum,
125 skb->protocol = __constant_htons(ETH_P_ARCNET); 125 skb->protocol = __constant_htons(ETH_P_ARCNET);
126; 126;
127 netif_rx(skb); 127 netif_rx(skb);
128 dev->last_rx = jiffies;
129} 128}
130 129
131 130
@@ -168,7 +167,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
168static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length, 167static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
169 int bufnum) 168 int bufnum)
170{ 169{
171 struct arcnet_local *lp = dev->priv; 170 struct arcnet_local *lp = netdev_priv(dev);
172 struct arc_hardware *hard = &pkt->hard; 171 struct arc_hardware *hard = &pkt->hard;
173 int ofs; 172 int ofs;
174 173
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 8c8d6c453c45..e3082a9350fc 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -194,7 +194,7 @@ static int __init arcrimi_found(struct net_device *dev)
194 194
195 /* initialize the rest of the device structure. */ 195 /* initialize the rest of the device structure. */
196 196
197 lp = dev->priv; 197 lp = netdev_priv(dev);
198 lp->card_name = "RIM I"; 198 lp->card_name = "RIM I";
199 lp->hw.command = arcrimi_command; 199 lp->hw.command = arcrimi_command;
200 lp->hw.status = arcrimi_status; 200 lp->hw.status = arcrimi_status;
@@ -260,7 +260,7 @@ err_free_irq:
260 */ 260 */
261static int arcrimi_reset(struct net_device *dev, int really_reset) 261static int arcrimi_reset(struct net_device *dev, int really_reset)
262{ 262{
263 struct arcnet_local *lp = dev->priv; 263 struct arcnet_local *lp = netdev_priv(dev);
264 void __iomem *ioaddr = lp->mem_start + 0x800; 264 void __iomem *ioaddr = lp->mem_start + 0x800;
265 265
266 BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS()); 266 BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS());
@@ -281,7 +281,7 @@ static int arcrimi_reset(struct net_device *dev, int really_reset)
281 281
282static void arcrimi_setmask(struct net_device *dev, int mask) 282static void arcrimi_setmask(struct net_device *dev, int mask)
283{ 283{
284 struct arcnet_local *lp = dev->priv; 284 struct arcnet_local *lp = netdev_priv(dev);
285 void __iomem *ioaddr = lp->mem_start + 0x800; 285 void __iomem *ioaddr = lp->mem_start + 0x800;
286 286
287 AINTMASK(mask); 287 AINTMASK(mask);
@@ -289,7 +289,7 @@ static void arcrimi_setmask(struct net_device *dev, int mask)
289 289
290static int arcrimi_status(struct net_device *dev) 290static int arcrimi_status(struct net_device *dev)
291{ 291{
292 struct arcnet_local *lp = dev->priv; 292 struct arcnet_local *lp = netdev_priv(dev);
293 void __iomem *ioaddr = lp->mem_start + 0x800; 293 void __iomem *ioaddr = lp->mem_start + 0x800;
294 294
295 return ASTATUS(); 295 return ASTATUS();
@@ -297,7 +297,7 @@ static int arcrimi_status(struct net_device *dev)
297 297
298static void arcrimi_command(struct net_device *dev, int cmd) 298static void arcrimi_command(struct net_device *dev, int cmd)
299{ 299{
300 struct arcnet_local *lp = dev->priv; 300 struct arcnet_local *lp = netdev_priv(dev);
301 void __iomem *ioaddr = lp->mem_start + 0x800; 301 void __iomem *ioaddr = lp->mem_start + 0x800;
302 302
303 ACOMMAND(cmd); 303 ACOMMAND(cmd);
@@ -306,7 +306,7 @@ static void arcrimi_command(struct net_device *dev, int cmd)
306static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset, 306static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
307 void *buf, int count) 307 void *buf, int count)
308{ 308{
309 struct arcnet_local *lp = dev->priv; 309 struct arcnet_local *lp = netdev_priv(dev);
310 void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset; 310 void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
311 TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count)); 311 TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
312} 312}
@@ -315,7 +315,7 @@ static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
315static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offset, 315static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offset,
316 void *buf, int count) 316 void *buf, int count)
317{ 317{
318 struct arcnet_local *lp = dev->priv; 318 struct arcnet_local *lp = netdev_priv(dev);
319 void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset; 319 void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
320 TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count)); 320 TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
321} 321}
@@ -361,7 +361,7 @@ static int __init arc_rimi_init(void)
361static void __exit arc_rimi_exit(void) 361static void __exit arc_rimi_exit(void)
362{ 362{
363 struct net_device *dev = my_dev; 363 struct net_device *dev = my_dev;
364 struct arcnet_local *lp = dev->priv; 364 struct arcnet_local *lp = netdev_priv(dev);
365 365
366 unregister_netdev(dev); 366 unregister_netdev(dev);
367 iounmap(lp->mem_start); 367 iounmap(lp->mem_start);
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index a5b07691e466..6b53e5ed125c 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -181,7 +181,7 @@ EXPORT_SYMBOL(arcnet_dump_skb);
181static void arcnet_dump_packet(struct net_device *dev, int bufnum, 181static void arcnet_dump_packet(struct net_device *dev, int bufnum,
182 char *desc, int take_arcnet_lock) 182 char *desc, int take_arcnet_lock)
183{ 183{
184 struct arcnet_local *lp = dev->priv; 184 struct arcnet_local *lp = netdev_priv(dev);
185 int i, length; 185 int i, length;
186 unsigned long flags = 0; 186 unsigned long flags = 0;
187 static uint8_t buf[512]; 187 static uint8_t buf[512];
@@ -247,7 +247,7 @@ void arcnet_unregister_proto(struct ArcProto *proto)
247 */ 247 */
248static void release_arcbuf(struct net_device *dev, int bufnum) 248static void release_arcbuf(struct net_device *dev, int bufnum)
249{ 249{
250 struct arcnet_local *lp = dev->priv; 250 struct arcnet_local *lp = netdev_priv(dev);
251 int i; 251 int i;
252 252
253 lp->buf_queue[lp->first_free_buf++] = bufnum; 253 lp->buf_queue[lp->first_free_buf++] = bufnum;
@@ -269,7 +269,7 @@ static void release_arcbuf(struct net_device *dev, int bufnum)
269 */ 269 */
270static int get_arcbuf(struct net_device *dev) 270static int get_arcbuf(struct net_device *dev)
271{ 271{
272 struct arcnet_local *lp = dev->priv; 272 struct arcnet_local *lp = netdev_priv(dev);
273 int buf = -1, i; 273 int buf = -1, i;
274 274
275 if (!atomic_dec_and_test(&lp->buf_lock)) { 275 if (!atomic_dec_and_test(&lp->buf_lock)) {
@@ -357,7 +357,7 @@ struct net_device *alloc_arcdev(char *name)
357 dev = alloc_netdev(sizeof(struct arcnet_local), 357 dev = alloc_netdev(sizeof(struct arcnet_local),
358 name && *name ? name : "arc%d", arcdev_setup); 358 name && *name ? name : "arc%d", arcdev_setup);
359 if(dev) { 359 if(dev) {
360 struct arcnet_local *lp = (struct arcnet_local *) dev->priv; 360 struct arcnet_local *lp = netdev_priv(dev);
361 spin_lock_init(&lp->lock); 361 spin_lock_init(&lp->lock);
362 } 362 }
363 363
@@ -374,7 +374,7 @@ struct net_device *alloc_arcdev(char *name)
374 */ 374 */
375static int arcnet_open(struct net_device *dev) 375static int arcnet_open(struct net_device *dev)
376{ 376{
377 struct arcnet_local *lp = dev->priv; 377 struct arcnet_local *lp = netdev_priv(dev);
378 int count, newmtu, error; 378 int count, newmtu, error;
379 379
380 BUGMSG(D_INIT,"opened."); 380 BUGMSG(D_INIT,"opened.");
@@ -474,7 +474,7 @@ static int arcnet_open(struct net_device *dev)
474/* The inverse routine to arcnet_open - shuts down the card. */ 474/* The inverse routine to arcnet_open - shuts down the card. */
475static int arcnet_close(struct net_device *dev) 475static int arcnet_close(struct net_device *dev)
476{ 476{
477 struct arcnet_local *lp = dev->priv; 477 struct arcnet_local *lp = netdev_priv(dev);
478 478
479 netif_stop_queue(dev); 479 netif_stop_queue(dev);
480 480
@@ -556,7 +556,7 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
556static int arcnet_rebuild_header(struct sk_buff *skb) 556static int arcnet_rebuild_header(struct sk_buff *skb)
557{ 557{
558 struct net_device *dev = skb->dev; 558 struct net_device *dev = skb->dev;
559 struct arcnet_local *lp = dev->priv; 559 struct arcnet_local *lp = netdev_priv(dev);
560 int status = 0; /* default is failure */ 560 int status = 0; /* default is failure */
561 unsigned short type; 561 unsigned short type;
562 uint8_t daddr=0; 562 uint8_t daddr=0;
@@ -603,7 +603,7 @@ static int arcnet_rebuild_header(struct sk_buff *skb)
603/* Called by the kernel in order to transmit a packet. */ 603/* Called by the kernel in order to transmit a packet. */
604static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev) 604static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
605{ 605{
606 struct arcnet_local *lp = dev->priv; 606 struct arcnet_local *lp = netdev_priv(dev);
607 struct archdr *pkt; 607 struct archdr *pkt;
608 struct arc_rfc1201 *soft; 608 struct arc_rfc1201 *soft;
609 struct ArcProto *proto; 609 struct ArcProto *proto;
@@ -693,7 +693,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
693 */ 693 */
694static int go_tx(struct net_device *dev) 694static int go_tx(struct net_device *dev)
695{ 695{
696 struct arcnet_local *lp = dev->priv; 696 struct arcnet_local *lp = netdev_priv(dev);
697 697
698 BUGMSG(D_DURING, "go_tx: status=%Xh, intmask=%Xh, next_tx=%d, cur_tx=%d\n", 698 BUGMSG(D_DURING, "go_tx: status=%Xh, intmask=%Xh, next_tx=%d, cur_tx=%d\n",
699 ASTATUS(), lp->intmask, lp->next_tx, lp->cur_tx); 699 ASTATUS(), lp->intmask, lp->next_tx, lp->cur_tx);
@@ -723,7 +723,7 @@ static int go_tx(struct net_device *dev)
723static void arcnet_timeout(struct net_device *dev) 723static void arcnet_timeout(struct net_device *dev)
724{ 724{
725 unsigned long flags; 725 unsigned long flags;
726 struct arcnet_local *lp = dev->priv; 726 struct arcnet_local *lp = netdev_priv(dev);
727 int status = ASTATUS(); 727 int status = ASTATUS();
728 char *msg; 728 char *msg;
729 729
@@ -771,8 +771,8 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
771 BUGMSG(D_DURING, "\n"); 771 BUGMSG(D_DURING, "\n");
772 772
773 BUGMSG(D_DURING, "in arcnet_interrupt\n"); 773 BUGMSG(D_DURING, "in arcnet_interrupt\n");
774 774
775 lp = dev->priv; 775 lp = netdev_priv(dev);
776 BUG_ON(!lp); 776 BUG_ON(!lp);
777 777
778 spin_lock(&lp->lock); 778 spin_lock(&lp->lock);
@@ -1010,7 +1010,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
1010 */ 1010 */
1011static void arcnet_rx(struct net_device *dev, int bufnum) 1011static void arcnet_rx(struct net_device *dev, int bufnum)
1012{ 1012{
1013 struct arcnet_local *lp = dev->priv; 1013 struct arcnet_local *lp = netdev_priv(dev);
1014 struct archdr pkt; 1014 struct archdr pkt;
1015 struct arc_rfc1201 *soft; 1015 struct arc_rfc1201 *soft;
1016 int length, ofs; 1016 int length, ofs;
@@ -1074,7 +1074,7 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
1074 */ 1074 */
1075static struct net_device_stats *arcnet_get_stats(struct net_device *dev) 1075static struct net_device_stats *arcnet_get_stats(struct net_device *dev)
1076{ 1076{
1077 struct arcnet_local *lp = dev->priv; 1077 struct arcnet_local *lp = netdev_priv(dev);
1078 return &lp->stats; 1078 return &lp->stats;
1079} 1079}
1080 1080
@@ -1091,7 +1091,7 @@ static void null_rx(struct net_device *dev, int bufnum,
1091static int null_build_header(struct sk_buff *skb, struct net_device *dev, 1091static int null_build_header(struct sk_buff *skb, struct net_device *dev,
1092 unsigned short type, uint8_t daddr) 1092 unsigned short type, uint8_t daddr)
1093{ 1093{
1094 struct arcnet_local *lp = dev->priv; 1094 struct arcnet_local *lp = netdev_priv(dev);
1095 1095
1096 BUGMSG(D_PROTO, 1096 BUGMSG(D_PROTO,
1097 "tx: can't build header for encap %02Xh; load a protocol driver.\n", 1097 "tx: can't build header for encap %02Xh; load a protocol driver.\n",
@@ -1106,7 +1106,7 @@ static int null_build_header(struct sk_buff *skb, struct net_device *dev,
1106static int null_prepare_tx(struct net_device *dev, struct archdr *pkt, 1106static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
1107 int length, int bufnum) 1107 int length, int bufnum)
1108{ 1108{
1109 struct arcnet_local *lp = dev->priv; 1109 struct arcnet_local *lp = netdev_priv(dev);
1110 struct arc_hardware newpkt; 1110 struct arc_hardware newpkt;
1111 1111
1112 BUGMSG(D_PROTO, "tx: no encap for this host; load a protocol driver.\n"); 1112 BUGMSG(D_PROTO, "tx: no encap for this host; load a protocol driver.\n");
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 02cb8f1c1148..e544953d8e9a 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -103,7 +103,7 @@ MODULE_LICENSE("GPL");
103static void rx(struct net_device *dev, int bufnum, 103static void rx(struct net_device *dev, int bufnum,
104 struct archdr *pkthdr, int length) 104 struct archdr *pkthdr, int length)
105{ 105{
106 struct arcnet_local *lp = (struct arcnet_local *) dev->priv; 106 struct arcnet_local *lp = netdev_priv(dev);
107 struct sk_buff *skb; 107 struct sk_buff *skb;
108 struct archdr *pkt = pkthdr; 108 struct archdr *pkt = pkthdr;
109 char *pktbuf, *pkthdrbuf; 109 char *pktbuf, *pkthdrbuf;
@@ -151,7 +151,6 @@ static void rx(struct net_device *dev, int bufnum,
151 skb->protocol = __constant_htons(ETH_P_ARCNET); 151 skb->protocol = __constant_htons(ETH_P_ARCNET);
152; 152;
153 netif_rx(skb); 153 netif_rx(skb);
154 dev->last_rx = jiffies;
155} 154}
156 155
157 156
@@ -198,7 +197,7 @@ static int build_header(struct sk_buff *skb,
198static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length, 197static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
199 int bufnum) 198 int bufnum)
200{ 199{
201 struct arcnet_local *lp = (struct arcnet_local *) dev->priv; 200 struct arcnet_local *lp = netdev_priv(dev);
202 struct arc_hardware *hard = &pkt->hard; 201 struct arc_hardware *hard = &pkt->hard;
203 int ofs; 202 int ofs;
204 203
@@ -250,7 +249,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
250 249
251static int ack_tx(struct net_device *dev, int acked) 250static int ack_tx(struct net_device *dev, int acked)
252{ 251{
253 struct arcnet_local *lp = (struct arcnet_local *) dev->priv; 252 struct arcnet_local *lp = netdev_priv(dev);
254 struct sk_buff *ackskb; 253 struct sk_buff *ackskb;
255 struct archdr *ackpkt; 254 struct archdr *ackpkt;
256 int length=sizeof(struct arc_cap); 255 int length=sizeof(struct arc_cap);
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index 9289e6103de5..ea53a940272f 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -52,7 +52,7 @@ static int __init com20020isa_probe(struct net_device *dev)
52{ 52{
53 int ioaddr; 53 int ioaddr;
54 unsigned long airqmask; 54 unsigned long airqmask;
55 struct arcnet_local *lp = dev->priv; 55 struct arcnet_local *lp = netdev_priv(dev);
56 int err; 56 int err;
57 57
58 BUGLVL(D_NORMAL) printk(VERSION); 58 BUGLVL(D_NORMAL) printk(VERSION);
@@ -151,7 +151,7 @@ static int __init com20020_init(void)
151 if (node && node != 0xff) 151 if (node && node != 0xff)
152 dev->dev_addr[0] = node; 152 dev->dev_addr[0] = node;
153 153
154 lp = dev->priv; 154 lp = netdev_priv(dev);
155 lp->backplane = backplane; 155 lp->backplane = backplane;
156 lp->clockp = clockp & 7; 156 lp->clockp = clockp & 7;
157 lp->clockm = clockm & 3; 157 lp->clockm = clockm & 3;
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index b8c0fa6d401d..8b51f632581d 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -72,7 +72,7 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de
72 dev = alloc_arcdev(device); 72 dev = alloc_arcdev(device);
73 if (!dev) 73 if (!dev)
74 return -ENOMEM; 74 return -ENOMEM;
75 lp = dev->priv; 75 lp = netdev_priv(dev);
76 76
77 pci_set_drvdata(pdev, dev); 77 pci_set_drvdata(pdev, dev);
78 78
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 70124a944e7d..103688358fb8 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -89,7 +89,7 @@ static void com20020_copy_to_card(struct net_device *dev, int bufnum,
89int com20020_check(struct net_device *dev) 89int com20020_check(struct net_device *dev)
90{ 90{
91 int ioaddr = dev->base_addr, status; 91 int ioaddr = dev->base_addr, status;
92 struct arcnet_local *lp = dev->priv; 92 struct arcnet_local *lp = netdev_priv(dev);
93 93
94 ARCRESET0; 94 ARCRESET0;
95 mdelay(RESETtime); 95 mdelay(RESETtime);
@@ -159,7 +159,7 @@ int com20020_found(struct net_device *dev, int shared)
159 159
160 /* Initialize the rest of the device structure. */ 160 /* Initialize the rest of the device structure. */
161 161
162 lp = dev->priv; 162 lp = netdev_priv(dev);
163 163
164 lp->hw.owner = THIS_MODULE; 164 lp->hw.owner = THIS_MODULE;
165 lp->hw.command = com20020_command; 165 lp->hw.command = com20020_command;
@@ -233,7 +233,7 @@ int com20020_found(struct net_device *dev, int shared)
233 */ 233 */
234static int com20020_reset(struct net_device *dev, int really_reset) 234static int com20020_reset(struct net_device *dev, int really_reset)
235{ 235{
236 struct arcnet_local *lp = dev->priv; 236 struct arcnet_local *lp = netdev_priv(dev);
237 u_int ioaddr = dev->base_addr; 237 u_int ioaddr = dev->base_addr;
238 u_char inbyte; 238 u_char inbyte;
239 239
@@ -300,7 +300,7 @@ static int com20020_status(struct net_device *dev)
300 300
301static void com20020_close(struct net_device *dev) 301static void com20020_close(struct net_device *dev)
302{ 302{
303 struct arcnet_local *lp = dev->priv; 303 struct arcnet_local *lp = netdev_priv(dev);
304 int ioaddr = dev->base_addr; 304 int ioaddr = dev->base_addr;
305 305
306 /* disable transmitter */ 306 /* disable transmitter */
@@ -317,7 +317,7 @@ static void com20020_close(struct net_device *dev)
317 */ 317 */
318static void com20020_set_mc_list(struct net_device *dev) 318static void com20020_set_mc_list(struct net_device *dev)
319{ 319{
320 struct arcnet_local *lp = dev->priv; 320 struct arcnet_local *lp = netdev_priv(dev);
321 int ioaddr = dev->base_addr; 321 int ioaddr = dev->base_addr;
322 322
323 if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP)) { /* Enable promiscuous mode */ 323 if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP)) { /* Enable promiscuous mode */
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 6599f1046c7b..89de29b3b1dc 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -248,7 +248,7 @@ static int __init com90io_found(struct net_device *dev)
248 return -EBUSY; 248 return -EBUSY;
249 } 249 }
250 250
251 lp = dev->priv; 251 lp = netdev_priv(dev);
252 lp->card_name = "COM90xx I/O"; 252 lp->card_name = "COM90xx I/O";
253 lp->hw.command = com90io_command; 253 lp->hw.command = com90io_command;
254 lp->hw.status = com90io_status; 254 lp->hw.status = com90io_status;
@@ -290,7 +290,7 @@ static int __init com90io_found(struct net_device *dev)
290 */ 290 */
291static int com90io_reset(struct net_device *dev, int really_reset) 291static int com90io_reset(struct net_device *dev, int really_reset)
292{ 292{
293 struct arcnet_local *lp = dev->priv; 293 struct arcnet_local *lp = netdev_priv(dev);
294 short ioaddr = dev->base_addr; 294 short ioaddr = dev->base_addr;
295 295
296 BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS()); 296 BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS());
diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index 0d45553ff75c..f4113d26587a 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -468,7 +468,7 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem
468 release_mem_region(shmem, MIRROR_SIZE); 468 release_mem_region(shmem, MIRROR_SIZE);
469 return -ENOMEM; 469 return -ENOMEM;
470 } 470 }
471 lp = dev->priv; 471 lp = netdev_priv(dev);
472 /* find the real shared memory start/end points, including mirrors */ 472 /* find the real shared memory start/end points, including mirrors */
473 473
474 /* guess the actual size of one "memory mirror" - the number of 474 /* guess the actual size of one "memory mirror" - the number of
@@ -585,7 +585,7 @@ static void com90xx_setmask(struct net_device *dev, int mask)
585 */ 585 */
586int com90xx_reset(struct net_device *dev, int really_reset) 586int com90xx_reset(struct net_device *dev, int really_reset)
587{ 587{
588 struct arcnet_local *lp = dev->priv; 588 struct arcnet_local *lp = netdev_priv(dev);
589 short ioaddr = dev->base_addr; 589 short ioaddr = dev->base_addr;
590 590
591 BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS()); 591 BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS());
@@ -621,7 +621,7 @@ int com90xx_reset(struct net_device *dev, int really_reset)
621static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset, 621static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
622 void *buf, int count) 622 void *buf, int count)
623{ 623{
624 struct arcnet_local *lp = dev->priv; 624 struct arcnet_local *lp = netdev_priv(dev);
625 void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset; 625 void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
626 TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count)); 626 TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
627} 627}
@@ -630,7 +630,7 @@ static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
630static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset, 630static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
631 void *buf, int count) 631 void *buf, int count)
632{ 632{
633 struct arcnet_local *lp = dev->priv; 633 struct arcnet_local *lp = netdev_priv(dev);
634 void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset; 634 void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
635 TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count)); 635 TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
636} 636}
@@ -656,7 +656,7 @@ static void __exit com90xx_exit(void)
656 656
657 for (count = 0; count < numcards; count++) { 657 for (count = 0; count < numcards; count++) {
658 dev = cards[count]; 658 dev = cards[count];
659 lp = dev->priv; 659 lp = netdev_priv(dev);
660 660
661 unregister_netdev(dev); 661 unregister_netdev(dev);
662 free_irq(dev->irq, dev); 662 free_irq(dev->irq, dev);
diff --git a/drivers/net/arcnet/rfc1051.c b/drivers/net/arcnet/rfc1051.c
index dab185bc51f1..49d39a9cb696 100644
--- a/drivers/net/arcnet/rfc1051.c
+++ b/drivers/net/arcnet/rfc1051.c
@@ -88,7 +88,7 @@ MODULE_LICENSE("GPL");
88 */ 88 */
89static __be16 type_trans(struct sk_buff *skb, struct net_device *dev) 89static __be16 type_trans(struct sk_buff *skb, struct net_device *dev)
90{ 90{
91 struct arcnet_local *lp = dev->priv; 91 struct arcnet_local *lp = netdev_priv(dev);
92 struct archdr *pkt = (struct archdr *) skb->data; 92 struct archdr *pkt = (struct archdr *) skb->data;
93 struct arc_rfc1051 *soft = &pkt->soft.rfc1051; 93 struct arc_rfc1051 *soft = &pkt->soft.rfc1051;
94 int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE; 94 int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE;
@@ -125,7 +125,7 @@ static __be16 type_trans(struct sk_buff *skb, struct net_device *dev)
125static void rx(struct net_device *dev, int bufnum, 125static void rx(struct net_device *dev, int bufnum,
126 struct archdr *pkthdr, int length) 126 struct archdr *pkthdr, int length)
127{ 127{
128 struct arcnet_local *lp = dev->priv; 128 struct arcnet_local *lp = netdev_priv(dev);
129 struct sk_buff *skb; 129 struct sk_buff *skb;
130 struct archdr *pkt = pkthdr; 130 struct archdr *pkt = pkthdr;
131 int ofs; 131 int ofs;
@@ -159,7 +159,6 @@ static void rx(struct net_device *dev, int bufnum,
159 159
160 skb->protocol = type_trans(skb, dev); 160 skb->protocol = type_trans(skb, dev);
161 netif_rx(skb); 161 netif_rx(skb);
162 dev->last_rx = jiffies;
163} 162}
164 163
165 164
@@ -169,7 +168,7 @@ static void rx(struct net_device *dev, int bufnum,
169static int build_header(struct sk_buff *skb, struct net_device *dev, 168static int build_header(struct sk_buff *skb, struct net_device *dev,
170 unsigned short type, uint8_t daddr) 169 unsigned short type, uint8_t daddr)
171{ 170{
172 struct arcnet_local *lp = dev->priv; 171 struct arcnet_local *lp = netdev_priv(dev);
173 int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE; 172 int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE;
174 struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size); 173 struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size);
175 struct arc_rfc1051 *soft = &pkt->soft.rfc1051; 174 struct arc_rfc1051 *soft = &pkt->soft.rfc1051;
@@ -220,7 +219,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
220static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length, 219static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
221 int bufnum) 220 int bufnum)
222{ 221{
223 struct arcnet_local *lp = dev->priv; 222 struct arcnet_local *lp = netdev_priv(dev);
224 struct arc_hardware *hard = &pkt->hard; 223 struct arc_hardware *hard = &pkt->hard;
225 int ofs; 224 int ofs;
226 225
diff --git a/drivers/net/arcnet/rfc1201.c b/drivers/net/arcnet/rfc1201.c
index 6d6d95cc4404..2303d3a1f4b6 100644
--- a/drivers/net/arcnet/rfc1201.c
+++ b/drivers/net/arcnet/rfc1201.c
@@ -92,7 +92,7 @@ static __be16 type_trans(struct sk_buff *skb, struct net_device *dev)
92{ 92{
93 struct archdr *pkt = (struct archdr *) skb->data; 93 struct archdr *pkt = (struct archdr *) skb->data;
94 struct arc_rfc1201 *soft = &pkt->soft.rfc1201; 94 struct arc_rfc1201 *soft = &pkt->soft.rfc1201;
95 struct arcnet_local *lp = dev->priv; 95 struct arcnet_local *lp = netdev_priv(dev);
96 int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE; 96 int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE;
97 97
98 /* Pull off the arcnet header. */ 98 /* Pull off the arcnet header. */
@@ -134,7 +134,7 @@ static __be16 type_trans(struct sk_buff *skb, struct net_device *dev)
134static void rx(struct net_device *dev, int bufnum, 134static void rx(struct net_device *dev, int bufnum,
135 struct archdr *pkthdr, int length) 135 struct archdr *pkthdr, int length)
136{ 136{
137 struct arcnet_local *lp = dev->priv; 137 struct arcnet_local *lp = netdev_priv(dev);
138 struct sk_buff *skb; 138 struct sk_buff *skb;
139 struct archdr *pkt = pkthdr; 139 struct archdr *pkt = pkthdr;
140 struct arc_rfc1201 *soft = &pkthdr->soft.rfc1201; 140 struct arc_rfc1201 *soft = &pkthdr->soft.rfc1201;
@@ -230,7 +230,6 @@ static void rx(struct net_device *dev, int bufnum,
230 230
231 skb->protocol = type_trans(skb, dev); 231 skb->protocol = type_trans(skb, dev);
232 netif_rx(skb); 232 netif_rx(skb);
233 dev->last_rx = jiffies;
234 } else { /* split packet */ 233 } else { /* split packet */
235 /* 234 /*
236 * NOTE: MSDOS ARP packet correction should only need to apply to 235 * NOTE: MSDOS ARP packet correction should only need to apply to
@@ -366,7 +365,6 @@ static void rx(struct net_device *dev, int bufnum,
366 365
367 skb->protocol = type_trans(skb, dev); 366 skb->protocol = type_trans(skb, dev);
368 netif_rx(skb); 367 netif_rx(skb);
369 dev->last_rx = jiffies;
370 } 368 }
371 } 369 }
372} 370}
@@ -376,7 +374,7 @@ static void rx(struct net_device *dev, int bufnum,
376static int build_header(struct sk_buff *skb, struct net_device *dev, 374static int build_header(struct sk_buff *skb, struct net_device *dev,
377 unsigned short type, uint8_t daddr) 375 unsigned short type, uint8_t daddr)
378{ 376{
379 struct arcnet_local *lp = dev->priv; 377 struct arcnet_local *lp = netdev_priv(dev);
380 int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE; 378 int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE;
381 struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size); 379 struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size);
382 struct arc_rfc1201 *soft = &pkt->soft.rfc1201; 380 struct arc_rfc1201 *soft = &pkt->soft.rfc1201;
@@ -443,7 +441,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
443static void load_pkt(struct net_device *dev, struct arc_hardware *hard, 441static void load_pkt(struct net_device *dev, struct arc_hardware *hard,
444 struct arc_rfc1201 *soft, int softlen, int bufnum) 442 struct arc_rfc1201 *soft, int softlen, int bufnum)
445{ 443{
446 struct arcnet_local *lp = dev->priv; 444 struct arcnet_local *lp = netdev_priv(dev);
447 int ofs; 445 int ofs;
448 446
449 /* assume length <= XMTU: someone should have handled that by now. */ 447 /* assume length <= XMTU: someone should have handled that by now. */
@@ -476,7 +474,7 @@ static void load_pkt(struct net_device *dev, struct arc_hardware *hard,
476static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length, 474static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
477 int bufnum) 475 int bufnum)
478{ 476{
479 struct arcnet_local *lp = dev->priv; 477 struct arcnet_local *lp = netdev_priv(dev);
480 const int maxsegsize = XMTU - RFC1201_HDR_SIZE; 478 const int maxsegsize = XMTU - RFC1201_HDR_SIZE;
481 struct Outgoing *out; 479 struct Outgoing *out;
482 480
@@ -511,7 +509,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
511 509
512static int continue_tx(struct net_device *dev, int bufnum) 510static int continue_tx(struct net_device *dev, int bufnum)
513{ 511{
514 struct arcnet_local *lp = dev->priv; 512 struct arcnet_local *lp = netdev_priv(dev);
515 struct Outgoing *out = &lp->outgoing; 513 struct Outgoing *out = &lp->outgoing;
516 struct arc_hardware *hard = &out->pkt->hard; 514 struct arc_hardware *hard = &out->pkt->hard;
517 struct arc_rfc1201 *soft = &out->pkt->soft.rfc1201, *newsoft; 515 struct arc_rfc1201 *soft = &out->pkt->soft.rfc1201, *newsoft;
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c
index 29e53eb71c74..e1d72e06f3e1 100644
--- a/drivers/net/ariadne.c
+++ b/drivers/net/ariadne.c
@@ -165,7 +165,6 @@ static int __devinit ariadne_init_one(struct zorro_dev *z,
165 struct net_device *dev; 165 struct net_device *dev;
166 struct ariadne_private *priv; 166 struct ariadne_private *priv;
167 int err; 167 int err;
168 DECLARE_MAC_BUF(mac);
169 168
170 r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960"); 169 r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960");
171 if (!r1) 170 if (!r1)
@@ -215,9 +214,8 @@ static int __devinit ariadne_init_one(struct zorro_dev *z,
215 } 214 }
216 zorro_set_drvdata(z, dev); 215 zorro_set_drvdata(z, dev);
217 216
218 printk(KERN_INFO "%s: Ariadne at 0x%08lx, Ethernet Address " 217 printk(KERN_INFO "%s: Ariadne at 0x%08lx, Ethernet Address %pM\n",
219 "%s\n", dev->name, board, 218 dev->name, board, dev->dev_addr);
220 print_mac(mac, dev->dev_addr));
221 219
222 return 0; 220 return 0;
223} 221}
@@ -613,14 +611,10 @@ static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev)
613 611
614#if 0 612#if 0
615{ 613{
616 DECLARE_MAC_BUF(mac); 614 printk(KERN_DEBUG "TX pkt type 0x%04x from %pM to %pM "
617 DECLARE_MAC_BUF(mac2);
618
619 printk(KERN_DEBUG "TX pkt type 0x%04x from %s to %s "
620 " data 0x%08x len %d\n", 615 " data 0x%08x len %d\n",
621 ((u_short *)skb->data)[6], 616 ((u_short *)skb->data)[6],
622 print_mac(mac, ((const u8 *)skb->data)+6), 617 skb->data + 6, skb->data,
623 print_mac(mac, (const u8 *)skb->data),
624 (int)skb->data, (int)skb->len); 618 (int)skb->data, (int)skb->len);
625} 619}
626#endif 620#endif
@@ -743,25 +737,22 @@ static int ariadne_rx(struct net_device *dev)
743 skb->protocol=eth_type_trans(skb,dev); 737 skb->protocol=eth_type_trans(skb,dev);
744#if 0 738#if 0
745{ 739{
746 DECLARE_MAC_BUF(mac);
747
748 printk(KERN_DEBUG "RX pkt type 0x%04x from ", 740 printk(KERN_DEBUG "RX pkt type 0x%04x from ",
749 ((u_short *)skb->data)[6]); 741 ((u_short *)skb->data)[6]);
750 { 742 {
751 u_char *ptr = &((u_char *)skb->data)[6]; 743 u_char *ptr = &((u_char *)skb->data)[6];
752 printk("%s", print_mac(mac, ptr)); 744 printk("%pM", ptr);
753 } 745 }
754 printk(" to "); 746 printk(" to ");
755 { 747 {
756 u_char *ptr = (u_char *)skb->data; 748 u_char *ptr = (u_char *)skb->data;
757 printk("%s", print_mac(mac, ptr)); 749 printk("%pM", ptr);
758 } 750 }
759 printk(" data 0x%08x len %d\n", (int)skb->data, (int)skb->len); 751 printk(" data 0x%08x len %d\n", (int)skb->data, (int)skb->len);
760} 752}
761#endif 753#endif
762 754
763 netif_rx(skb); 755 netif_rx(skb);
764 dev->last_rx = jiffies;
765 dev->stats.rx_packets++; 756 dev->stats.rx_packets++;
766 dev->stats.rx_bytes += pkt_len; 757 dev->stats.rx_bytes += pkt_len;
767 } 758 }
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index aa4a5246be53..0c628a9e5339 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -532,7 +532,6 @@ am79c961_rx(struct net_device *dev, struct dev_priv *priv)
532 am_writeword(dev, hdraddr + 2, RMD_OWN); 532 am_writeword(dev, hdraddr + 2, RMD_OWN);
533 skb->protocol = eth_type_trans(skb, dev); 533 skb->protocol = eth_type_trans(skb, dev);
534 netif_rx(skb); 534 netif_rx(skb);
535 dev->last_rx = jiffies;
536 priv->stats.rx_bytes += len; 535 priv->stats.rx_bytes += len;
537 priv->stats.rx_packets ++; 536 priv->stats.rx_packets ++;
538 } else { 537 } else {
@@ -745,10 +744,8 @@ static int __init am79c961_probe(struct platform_device *pdev)
745 744
746 ret = register_netdev(dev); 745 ret = register_netdev(dev);
747 if (ret == 0) { 746 if (ret == 0) {
748 DECLARE_MAC_BUF(mac); 747 printk(KERN_INFO "%s: ether address %pM\n",
749 748 dev->name, dev->dev_addr);
750 printk(KERN_INFO "%s: ether address %s\n",
751 dev->name, print_mac(mac, dev->dev_addr));
752 return 0; 749 return 0;
753 } 750 }
754 751
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 6f431a887e7e..442938d50380 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -485,7 +485,6 @@ static void update_mac_address(struct net_device *dev)
485static int set_mac_address(struct net_device *dev, void* addr) 485static int set_mac_address(struct net_device *dev, void* addr)
486{ 486{
487 struct sockaddr *address = addr; 487 struct sockaddr *address = addr;
488 DECLARE_MAC_BUF(mac);
489 488
490 if (!is_valid_ether_addr(address->sa_data)) 489 if (!is_valid_ether_addr(address->sa_data))
491 return -EADDRNOTAVAIL; 490 return -EADDRNOTAVAIL;
@@ -493,8 +492,8 @@ static int set_mac_address(struct net_device *dev, void* addr)
493 memcpy(dev->dev_addr, address->sa_data, dev->addr_len); 492 memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
494 update_mac_address(dev); 493 update_mac_address(dev);
495 494
496 printk("%s: Setting MAC address to %s\n", dev->name, 495 printk("%s: Setting MAC address to %pM\n", dev->name,
497 print_mac(mac, dev->dev_addr)); 496 dev->dev_addr);
498 497
499 return 0; 498 return 0;
500} 499}
@@ -894,7 +893,6 @@ static void at91ether_rx(struct net_device *dev)
894 memcpy(skb_put(skb, pktlen), p_recv, pktlen); 893 memcpy(skb_put(skb, pktlen), p_recv, pktlen);
895 894
896 skb->protocol = eth_type_trans(skb, dev); 895 skb->protocol = eth_type_trans(skb, dev);
897 dev->last_rx = jiffies;
898 dev->stats.rx_bytes += pktlen; 896 dev->stats.rx_bytes += pktlen;
899 netif_rx(skb); 897 netif_rx(skb);
900 } 898 }
@@ -978,7 +976,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
978 struct at91_private *lp; 976 struct at91_private *lp;
979 unsigned int val; 977 unsigned int val;
980 int res; 978 int res;
981 DECLARE_MAC_BUF(mac);
982 979
983 dev = alloc_etherdev(sizeof(struct at91_private)); 980 dev = alloc_etherdev(sizeof(struct at91_private));
984 if (!dev) 981 if (!dev)
@@ -1084,11 +1081,11 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1084 gpio_request(lp->board_data.phy_irq_pin, "ethernet_phy"); 1081 gpio_request(lp->board_data.phy_irq_pin, "ethernet_phy");
1085 1082
1086 /* Display ethernet banner */ 1083 /* Display ethernet banner */
1087 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%s)\n", 1084 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%pM)\n",
1088 dev->name, (uint) dev->base_addr, dev->irq, 1085 dev->name, (uint) dev->base_addr, dev->irq,
1089 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-", 1086 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-",
1090 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex", 1087 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex",
1091 print_mac(mac, dev->dev_addr)); 1088 dev->dev_addr);
1092 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) 1089 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
1093 printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); 1090 printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
1094 else if (phy_type == MII_LXT971A_ID) 1091 else if (phy_type == MII_LXT971A_ID)
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 1267444d79da..588c9739d13d 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -259,8 +259,6 @@ static int ep93xx_rx(struct net_device *dev, int processed, int budget)
259 skb_put(skb, length); 259 skb_put(skb, length);
260 skb->protocol = eth_type_trans(skb, dev); 260 skb->protocol = eth_type_trans(skb, dev);
261 261
262 dev->last_rx = jiffies;
263
264 netif_receive_skb(skb); 262 netif_receive_skb(skb);
265 263
266 ep->stats.rx_packets++; 264 ep->stats.rx_packets++;
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c
index 3bb9e293e2ef..e380de454463 100644
--- a/drivers/net/arm/ether1.c
+++ b/drivers/net/arm/ether1.c
@@ -996,7 +996,6 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
996{ 996{
997 struct net_device *dev; 997 struct net_device *dev;
998 int i, ret = 0; 998 int i, ret = 0;
999 DECLARE_MAC_BUF(mac);
1000 999
1001 ether1_banner(); 1000 ether1_banner();
1002 1001
@@ -1044,8 +1043,8 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
1044 if (ret) 1043 if (ret)
1045 goto free; 1044 goto free;
1046 1045
1047 printk(KERN_INFO "%s: ether1 in slot %d, %s\n", 1046 printk(KERN_INFO "%s: ether1 in slot %d, %pM\n",
1048 dev->name, ec->slot_no, print_mac(mac, dev->dev_addr)); 1047 dev->name, ec->slot_no, dev->dev_addr);
1049 1048
1050 ecard_set_drvdata(ec, dev); 1049 ecard_set_drvdata(ec, dev);
1051 return 0; 1050 return 0;
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c
index 67e96ae85035..21a7bef12d3b 100644
--- a/drivers/net/arm/ether3.c
+++ b/drivers/net/arm/ether3.c
@@ -776,7 +776,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
776 const struct ether3_data *data = id->data; 776 const struct ether3_data *data = id->data;
777 struct net_device *dev; 777 struct net_device *dev;
778 int bus_type, ret; 778 int bus_type, ret;
779 DECLARE_MAC_BUF(mac);
780 779
781 ether3_banner(); 780 ether3_banner();
782 781
@@ -859,8 +858,8 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
859 if (ret) 858 if (ret)
860 goto free; 859 goto free;
861 860
862 printk("%s: %s in slot %d, %s\n", 861 printk("%s: %s in slot %d, %pM\n",
863 dev->name, data->name, ec->slot_no, print_mac(mac, dev->dev_addr)); 862 dev->name, data->name, ec->slot_no, dev->dev_addr);
864 863
865 ecard_set_drvdata(ec, dev); 864 ecard_set_drvdata(ec, dev);
866 return 0; 865 return 0;
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 5c5f1e470d3c..9eb9d1bedc85 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -648,7 +648,6 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
648 struct net_device *dev; 648 struct net_device *dev;
649 struct etherh_priv *eh; 649 struct etherh_priv *eh;
650 int ret; 650 int ret;
651 DECLARE_MAC_BUF(mac);
652 651
653 etherh_banner(); 652 etherh_banner();
654 653
@@ -746,8 +745,8 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
746 if (ret) 745 if (ret)
747 goto free; 746 goto free;
748 747
749 printk(KERN_INFO "%s: %s in slot %d, %s\n", 748 printk(KERN_INFO "%s: %s in slot %d, %pM\n",
750 dev->name, data->name, ec->slot_no, print_mac(mac, dev->dev_addr)); 749 dev->name, data->name, ec->slot_no, dev->dev_addr);
751 750
752 ecard_set_drvdata(ec, dev); 751 ecard_set_drvdata(ec, dev);
753 752
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index e2d702b8b2e4..14ffa2a61890 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -588,7 +588,6 @@ static int eth_poll(struct napi_struct *napi, int budget)
588 debug_pkt(dev, "eth_poll", skb->data, skb->len); 588 debug_pkt(dev, "eth_poll", skb->data, skb->len);
589 589
590 skb->protocol = eth_type_trans(skb, dev); 590 skb->protocol = eth_type_trans(skb, dev);
591 dev->last_rx = jiffies;
592 port->stat.rx_packets++; 591 port->stat.rx_packets++;
593 port->stat.rx_bytes += skb->len; 592 port->stat.rx_bytes += skb->len;
594 netif_receive_skb(skb); 593 netif_receive_skb(skb);
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c
index 7e874d485d24..2d4b5c31652e 100644
--- a/drivers/net/at1700.c
+++ b/drivers/net/at1700.c
@@ -265,7 +265,6 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
265 unsigned int i, irq, is_fmv18x = 0, is_at1700 = 0; 265 unsigned int i, irq, is_fmv18x = 0, is_at1700 = 0;
266 int slot, ret = -ENODEV; 266 int slot, ret = -ENODEV;
267 struct net_local *lp = netdev_priv(dev); 267 struct net_local *lp = netdev_priv(dev);
268 DECLARE_MAC_BUF(mac);
269 268
270 if (!request_region(ioaddr, AT1700_IO_EXTENT, DRV_NAME)) 269 if (!request_region(ioaddr, AT1700_IO_EXTENT, DRV_NAME))
271 return -EBUSY; 270 return -EBUSY;
@@ -397,7 +396,7 @@ found:
397 dev->dev_addr[i] = val; 396 dev->dev_addr[i] = val;
398 } 397 }
399 } 398 }
400 printk("%s", print_mac(mac, dev->dev_addr)); 399 printk("%pM", dev->dev_addr);
401 400
402 /* The EEPROM word 12 bit 0x0400 means use regular 100 ohm 10baseT signals, 401 /* The EEPROM word 12 bit 0x0400 means use regular 100 ohm 10baseT signals,
403 rather than 150 ohm shielded twisted pair compensation. 402 rather than 150 ohm shielded twisted pair compensation.
@@ -768,7 +767,6 @@ net_rx(struct net_device *dev)
768 insw(ioaddr + DATAPORT, skb_put(skb,pkt_len), (pkt_len + 1) >> 1); 767 insw(ioaddr + DATAPORT, skb_put(skb,pkt_len), (pkt_len + 1) >> 1);
769 skb->protocol=eth_type_trans(skb, dev); 768 skb->protocol=eth_type_trans(skb, dev);
770 netif_rx(skb); 769 netif_rx(skb);
771 dev->last_rx = jiffies;
772 dev->stats.rx_packets++; 770 dev->stats.rx_packets++;
773 dev->stats.rx_bytes += pkt_len; 771 dev->stats.rx_bytes += pkt_len;
774 } 772 }
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c
index 0860cc280b01..2d81f6afcb58 100644
--- a/drivers/net/atarilance.c
+++ b/drivers/net/atarilance.c
@@ -466,7 +466,6 @@ static unsigned long __init lance_probe1( struct net_device *dev,
466 int i; 466 int i;
467 static int did_version; 467 static int did_version;
468 unsigned short save1, save2; 468 unsigned short save1, save2;
469 DECLARE_MAC_BUF(mac);
470 469
471 PROBE_PRINT(( "Probing for Lance card at mem %#lx io %#lx\n", 470 PROBE_PRINT(( "Probing for Lance card at mem %#lx io %#lx\n",
472 (long)memaddr, (long)ioaddr )); 471 (long)memaddr, (long)ioaddr ));
@@ -521,7 +520,7 @@ static unsigned long __init lance_probe1( struct net_device *dev,
521 return( 0 ); 520 return( 0 );
522 521
523 probe_ok: 522 probe_ok:
524 lp = (struct lance_private *)dev->priv; 523 lp = netdev_priv(dev);
525 MEM = (struct lance_memory *)memaddr; 524 MEM = (struct lance_memory *)memaddr;
526 IO = lp->iobase = (struct lance_ioreg *)ioaddr; 525 IO = lp->iobase = (struct lance_ioreg *)ioaddr;
527 dev->base_addr = (unsigned long)ioaddr; /* informational only */ 526 dev->base_addr = (unsigned long)ioaddr; /* informational only */
@@ -595,7 +594,7 @@ static unsigned long __init lance_probe1( struct net_device *dev,
595 i = IO->mem; 594 i = IO->mem;
596 break; 595 break;
597 } 596 }
598 printk("%s\n", print_mac(mac, dev->dev_addr)); 597 printk("%pM\n", dev->dev_addr);
599 if (lp->cardtype == OLD_RIEBL) { 598 if (lp->cardtype == OLD_RIEBL) {
600 printk( "%s: Warning: This is a default ethernet address!\n", 599 printk( "%s: Warning: This is a default ethernet address!\n",
601 dev->name ); 600 dev->name );
@@ -640,8 +639,8 @@ static unsigned long __init lance_probe1( struct net_device *dev,
640 639
641 640
642static int lance_open( struct net_device *dev ) 641static int lance_open( struct net_device *dev )
643 642{
644{ struct lance_private *lp = (struct lance_private *)dev->priv; 643 struct lance_private *lp = netdev_priv(dev);
645 struct lance_ioreg *IO = lp->iobase; 644 struct lance_ioreg *IO = lp->iobase;
646 int i; 645 int i;
647 646
@@ -681,8 +680,8 @@ static int lance_open( struct net_device *dev )
681/* Initialize the LANCE Rx and Tx rings. */ 680/* Initialize the LANCE Rx and Tx rings. */
682 681
683static void lance_init_ring( struct net_device *dev ) 682static void lance_init_ring( struct net_device *dev )
684 683{
685{ struct lance_private *lp = (struct lance_private *)dev->priv; 684 struct lance_private *lp = netdev_priv(dev);
686 int i; 685 int i;
687 unsigned offset; 686 unsigned offset;
688 687
@@ -730,7 +729,7 @@ static void lance_init_ring( struct net_device *dev )
730 729
731static void lance_tx_timeout (struct net_device *dev) 730static void lance_tx_timeout (struct net_device *dev)
732{ 731{
733 struct lance_private *lp = (struct lance_private *) dev->priv; 732 struct lance_private *lp = netdev_priv(dev);
734 struct lance_ioreg *IO = lp->iobase; 733 struct lance_ioreg *IO = lp->iobase;
735 734
736 AREG = CSR0; 735 AREG = CSR0;
@@ -772,14 +771,12 @@ static void lance_tx_timeout (struct net_device *dev)
772/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ 771/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
773 772
774static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ) 773static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
775 774{
776{ struct lance_private *lp = (struct lance_private *)dev->priv; 775 struct lance_private *lp = netdev_priv(dev);
777 struct lance_ioreg *IO = lp->iobase; 776 struct lance_ioreg *IO = lp->iobase;
778 int entry, len; 777 int entry, len;
779 struct lance_tx_head *head; 778 struct lance_tx_head *head;
780 unsigned long flags; 779 unsigned long flags;
781 DECLARE_MAC_BUF(mac);
782 DECLARE_MAC_BUF(mac2);
783 780
784 DPRINTK( 2, ( "%s: lance_start_xmit() called, csr0 %4.4x.\n", 781 DPRINTK( 2, ( "%s: lance_start_xmit() called, csr0 %4.4x.\n",
785 dev->name, DREG )); 782 dev->name, DREG ));
@@ -802,12 +799,10 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
802 799
803 /* Fill in a Tx ring entry */ 800 /* Fill in a Tx ring entry */
804 if (lance_debug >= 3) { 801 if (lance_debug >= 3) {
805 printk( "%s: TX pkt type 0x%04x from " 802 printk( "%s: TX pkt type 0x%04x from %pM to %pM"
806 "%s to %s"
807 " data at 0x%08x len %d\n", 803 " data at 0x%08x len %d\n",
808 dev->name, ((u_short *)skb->data)[6], 804 dev->name, ((u_short *)skb->data)[6],
809 print_mac(mac, &skb->data[6]), 805 &skb->data[6], skb->data,
810 print_mac(mac2, skb->data),
811 (int)skb->data, (int)skb->len ); 806 (int)skb->data, (int)skb->len );
812 } 807 }
813 808
@@ -865,7 +860,7 @@ static irqreturn_t lance_interrupt( int irq, void *dev_id )
865 return IRQ_NONE; 860 return IRQ_NONE;
866 } 861 }
867 862
868 lp = (struct lance_private *)dev->priv; 863 lp = netdev_priv(dev);
869 IO = lp->iobase; 864 IO = lp->iobase;
870 spin_lock (&lp->devlock); 865 spin_lock (&lp->devlock);
871 866
@@ -965,8 +960,8 @@ static irqreturn_t lance_interrupt( int irq, void *dev_id )
965 960
966 961
967static int lance_rx( struct net_device *dev ) 962static int lance_rx( struct net_device *dev )
968 963{
969{ struct lance_private *lp = (struct lance_private *)dev->priv; 964 struct lance_private *lp = netdev_priv(dev);
970 int entry = lp->cur_rx & RX_RING_MOD_MASK; 965 int entry = lp->cur_rx & RX_RING_MOD_MASK;
971 int i; 966 int i;
972 967
@@ -1019,14 +1014,12 @@ static int lance_rx( struct net_device *dev )
1019 1014
1020 if (lance_debug >= 3) { 1015 if (lance_debug >= 3) {
1021 u_char *data = PKTBUF_ADDR(head); 1016 u_char *data = PKTBUF_ADDR(head);
1022 DECLARE_MAC_BUF(mac);
1023 DECLARE_MAC_BUF(mac2);
1024 1017
1025 printk(KERN_DEBUG "%s: RX pkt type 0x%04x from %s to %s " 1018 printk(KERN_DEBUG "%s: RX pkt type 0x%04x from %pM to %pM "
1026 "data %02x %02x %02x %02x %02x %02x %02x %02x " 1019 "data %02x %02x %02x %02x %02x %02x %02x %02x "
1027 "len %d\n", 1020 "len %d\n",
1028 dev->name, ((u_short *)data)[6], 1021 dev->name, ((u_short *)data)[6],
1029 print_mac(mac, &data[6]), print_mac(mac2, data), 1022 &data[6], data,
1030 data[15], data[16], data[17], data[18], 1023 data[15], data[16], data[17], data[18],
1031 data[19], data[20], data[21], data[22], 1024 data[19], data[20], data[21], data[22],
1032 pkt_len); 1025 pkt_len);
@@ -1037,7 +1030,6 @@ static int lance_rx( struct net_device *dev )
1037 lp->memcpy_f( skb->data, PKTBUF_ADDR(head), pkt_len ); 1030 lp->memcpy_f( skb->data, PKTBUF_ADDR(head), pkt_len );
1038 skb->protocol = eth_type_trans( skb, dev ); 1031 skb->protocol = eth_type_trans( skb, dev );
1039 netif_rx( skb ); 1032 netif_rx( skb );
1040 dev->last_rx = jiffies;
1041 dev->stats.rx_packets++; 1033 dev->stats.rx_packets++;
1042 dev->stats.rx_bytes += pkt_len; 1034 dev->stats.rx_bytes += pkt_len;
1043 } 1035 }
@@ -1057,8 +1049,8 @@ static int lance_rx( struct net_device *dev )
1057 1049
1058 1050
1059static int lance_close( struct net_device *dev ) 1051static int lance_close( struct net_device *dev )
1060 1052{
1061{ struct lance_private *lp = (struct lance_private *)dev->priv; 1053 struct lance_private *lp = netdev_priv(dev);
1062 struct lance_ioreg *IO = lp->iobase; 1054 struct lance_ioreg *IO = lp->iobase;
1063 1055
1064 netif_stop_queue (dev); 1056 netif_stop_queue (dev);
@@ -1084,8 +1076,8 @@ static int lance_close( struct net_device *dev )
1084 */ 1076 */
1085 1077
1086static void set_multicast_list( struct net_device *dev ) 1078static void set_multicast_list( struct net_device *dev )
1087 1079{
1088{ struct lance_private *lp = (struct lance_private *)dev->priv; 1080 struct lance_private *lp = netdev_priv(dev);
1089 struct lance_ioreg *IO = lp->iobase; 1081 struct lance_ioreg *IO = lp->iobase;
1090 1082
1091 if (netif_running(dev)) 1083 if (netif_running(dev))
@@ -1126,8 +1118,8 @@ static void set_multicast_list( struct net_device *dev )
1126/* This is needed for old RieblCards and possible for new RieblCards */ 1118/* This is needed for old RieblCards and possible for new RieblCards */
1127 1119
1128static int lance_set_mac_address( struct net_device *dev, void *addr ) 1120static int lance_set_mac_address( struct net_device *dev, void *addr )
1129 1121{
1130{ struct lance_private *lp = (struct lance_private *)dev->priv; 1122 struct lance_private *lp = netdev_priv(dev);
1131 struct sockaddr *saddr = addr; 1123 struct sockaddr *saddr = addr;
1132 int i; 1124 int i;
1133 1125
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index 9b603528143d..c8b7cea4b14e 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -1460,7 +1460,6 @@ static void atl1e_clean_rx_irq(struct atl1e_adapter *adapter, u8 que,
1460 netif_receive_skb(skb); 1460 netif_receive_skb(skb);
1461 } 1461 }
1462 1462
1463 netdev->last_rx = jiffies;
1464skip_pkt: 1463skip_pkt:
1465 /* skip current packet whether it's ok or not. */ 1464 /* skip current packet whether it's ok or not. */
1466 rx_page->read_offset += 1465 rx_page->read_offset +=
@@ -2488,7 +2487,7 @@ static pci_ers_result_t
2488atl1e_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) 2487atl1e_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
2489{ 2488{
2490 struct net_device *netdev = pci_get_drvdata(pdev); 2489 struct net_device *netdev = pci_get_drvdata(pdev);
2491 struct atl1e_adapter *adapter = netdev->priv; 2490 struct atl1e_adapter *adapter = netdev_priv(netdev);
2492 2491
2493 netif_device_detach(netdev); 2492 netif_device_detach(netdev);
2494 2493
@@ -2511,7 +2510,7 @@ atl1e_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
2511static pci_ers_result_t atl1e_io_slot_reset(struct pci_dev *pdev) 2510static pci_ers_result_t atl1e_io_slot_reset(struct pci_dev *pdev)
2512{ 2511{
2513 struct net_device *netdev = pci_get_drvdata(pdev); 2512 struct net_device *netdev = pci_get_drvdata(pdev);
2514 struct atl1e_adapter *adapter = netdev->priv; 2513 struct atl1e_adapter *adapter = netdev_priv(netdev);
2515 2514
2516 if (pci_enable_device(pdev)) { 2515 if (pci_enable_device(pdev)) {
2517 dev_err(&pdev->dev, 2516 dev_err(&pdev->dev,
@@ -2539,7 +2538,7 @@ static pci_ers_result_t atl1e_io_slot_reset(struct pci_dev *pdev)
2539static void atl1e_io_resume(struct pci_dev *pdev) 2538static void atl1e_io_resume(struct pci_dev *pdev)
2540{ 2539{
2541 struct net_device *netdev = pci_get_drvdata(pdev); 2540 struct net_device *netdev = pci_get_drvdata(pdev);
2542 struct atl1e_adapter *adapter = netdev->priv; 2541 struct atl1e_adapter *adapter = netdev_priv(netdev);
2543 2542
2544 if (netif_running(netdev)) { 2543 if (netif_running(netdev)) {
2545 if (atl1e_up(adapter)) { 2544 if (atl1e_up(adapter)) {
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index aef403d299ee..611a86ebe164 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -1390,7 +1390,8 @@ static u32 atl1_check_link(struct atl1_adapter *adapter)
1390 /* auto-neg, insert timer to re-config phy */ 1390 /* auto-neg, insert timer to re-config phy */
1391 if (!adapter->phy_timer_pending) { 1391 if (!adapter->phy_timer_pending) {
1392 adapter->phy_timer_pending = true; 1392 adapter->phy_timer_pending = true;
1393 mod_timer(&adapter->phy_config_timer, jiffies + 3 * HZ); 1393 mod_timer(&adapter->phy_config_timer,
1394 round_jiffies(jiffies + 3 * HZ));
1394 } 1395 }
1395 1396
1396 return 0; 1397 return 0;
@@ -1662,6 +1663,7 @@ static void atl1_via_workaround(struct atl1_adapter *adapter)
1662 1663
1663static void atl1_inc_smb(struct atl1_adapter *adapter) 1664static void atl1_inc_smb(struct atl1_adapter *adapter)
1664{ 1665{
1666 struct net_device *netdev = adapter->netdev;
1665 struct stats_msg_block *smb = adapter->smb.smb; 1667 struct stats_msg_block *smb = adapter->smb.smb;
1666 1668
1667 /* Fill out the OS statistics structure */ 1669 /* Fill out the OS statistics structure */
@@ -1704,30 +1706,30 @@ static void atl1_inc_smb(struct atl1_adapter *adapter)
1704 adapter->soft_stats.tx_trunc += smb->tx_trunc; 1706 adapter->soft_stats.tx_trunc += smb->tx_trunc;
1705 adapter->soft_stats.tx_pause += smb->tx_pause; 1707 adapter->soft_stats.tx_pause += smb->tx_pause;
1706 1708
1707 adapter->net_stats.rx_packets = adapter->soft_stats.rx_packets; 1709 netdev->stats.rx_packets = adapter->soft_stats.rx_packets;
1708 adapter->net_stats.tx_packets = adapter->soft_stats.tx_packets; 1710 netdev->stats.tx_packets = adapter->soft_stats.tx_packets;
1709 adapter->net_stats.rx_bytes = adapter->soft_stats.rx_bytes; 1711 netdev->stats.rx_bytes = adapter->soft_stats.rx_bytes;
1710 adapter->net_stats.tx_bytes = adapter->soft_stats.tx_bytes; 1712 netdev->stats.tx_bytes = adapter->soft_stats.tx_bytes;
1711 adapter->net_stats.multicast = adapter->soft_stats.multicast; 1713 netdev->stats.multicast = adapter->soft_stats.multicast;
1712 adapter->net_stats.collisions = adapter->soft_stats.collisions; 1714 netdev->stats.collisions = adapter->soft_stats.collisions;
1713 adapter->net_stats.rx_errors = adapter->soft_stats.rx_errors; 1715 netdev->stats.rx_errors = adapter->soft_stats.rx_errors;
1714 adapter->net_stats.rx_over_errors = 1716 netdev->stats.rx_over_errors =
1715 adapter->soft_stats.rx_missed_errors; 1717 adapter->soft_stats.rx_missed_errors;
1716 adapter->net_stats.rx_length_errors = 1718 netdev->stats.rx_length_errors =
1717 adapter->soft_stats.rx_length_errors; 1719 adapter->soft_stats.rx_length_errors;
1718 adapter->net_stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; 1720 netdev->stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors;
1719 adapter->net_stats.rx_frame_errors = 1721 netdev->stats.rx_frame_errors =
1720 adapter->soft_stats.rx_frame_errors; 1722 adapter->soft_stats.rx_frame_errors;
1721 adapter->net_stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; 1723 netdev->stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors;
1722 adapter->net_stats.rx_missed_errors = 1724 netdev->stats.rx_missed_errors =
1723 adapter->soft_stats.rx_missed_errors; 1725 adapter->soft_stats.rx_missed_errors;
1724 adapter->net_stats.tx_errors = adapter->soft_stats.tx_errors; 1726 netdev->stats.tx_errors = adapter->soft_stats.tx_errors;
1725 adapter->net_stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; 1727 netdev->stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors;
1726 adapter->net_stats.tx_aborted_errors = 1728 netdev->stats.tx_aborted_errors =
1727 adapter->soft_stats.tx_aborted_errors; 1729 adapter->soft_stats.tx_aborted_errors;
1728 adapter->net_stats.tx_window_errors = 1730 netdev->stats.tx_window_errors =
1729 adapter->soft_stats.tx_window_errors; 1731 adapter->soft_stats.tx_window_errors;
1730 adapter->net_stats.tx_carrier_errors = 1732 netdev->stats.tx_carrier_errors =
1731 adapter->soft_stats.tx_carrier_errors; 1733 adapter->soft_stats.tx_carrier_errors;
1732} 1734}
1733 1735
@@ -1860,7 +1862,7 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter)
1860 adapter->rx_buffer_len + NET_IP_ALIGN); 1862 adapter->rx_buffer_len + NET_IP_ALIGN);
1861 if (unlikely(!skb)) { 1863 if (unlikely(!skb)) {
1862 /* Better luck next round */ 1864 /* Better luck next round */
1863 adapter->net_stats.rx_dropped++; 1865 adapter->netdev->stats.rx_dropped++;
1864 break; 1866 break;
1865 } 1867 }
1866 1868
@@ -2026,8 +2028,6 @@ rrd_ok:
2026 buffer_info->skb = NULL; 2028 buffer_info->skb = NULL;
2027 buffer_info->alloced = 0; 2029 buffer_info->alloced = 0;
2028 rrd->xsz.valid = 0; 2030 rrd->xsz.valid = 0;
2029
2030 adapter->netdev->last_rx = jiffies;
2031 } 2031 }
2032 2032
2033 atomic_set(&rrd_ring->next_to_clean, rrd_next_to_clean); 2033 atomic_set(&rrd_ring->next_to_clean, rrd_next_to_clean);
@@ -2524,17 +2524,6 @@ static irqreturn_t atl1_intr(int irq, void *data)
2524 return IRQ_HANDLED; 2524 return IRQ_HANDLED;
2525} 2525}
2526 2526
2527/*
2528 * atl1_watchdog - Timer Call-back
2529 * @data: pointer to netdev cast into an unsigned long
2530 */
2531static void atl1_watchdog(unsigned long data)
2532{
2533 struct atl1_adapter *adapter = (struct atl1_adapter *)data;
2534
2535 /* Reset the timer */
2536 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
2537}
2538 2527
2539/* 2528/*
2540 * atl1_phy_config - Timer Call-back 2529 * atl1_phy_config - Timer Call-back
@@ -2607,7 +2596,6 @@ static s32 atl1_up(struct atl1_adapter *adapter)
2607 if (unlikely(err)) 2596 if (unlikely(err))
2608 goto err_up; 2597 goto err_up;
2609 2598
2610 mod_timer(&adapter->watchdog_timer, jiffies);
2611 atlx_irq_enable(adapter); 2599 atlx_irq_enable(adapter);
2612 atl1_check_link(adapter); 2600 atl1_check_link(adapter);
2613 netif_start_queue(netdev); 2601 netif_start_queue(netdev);
@@ -2625,7 +2613,6 @@ static void atl1_down(struct atl1_adapter *adapter)
2625 struct net_device *netdev = adapter->netdev; 2613 struct net_device *netdev = adapter->netdev;
2626 2614
2627 netif_stop_queue(netdev); 2615 netif_stop_queue(netdev);
2628 del_timer_sync(&adapter->watchdog_timer);
2629 del_timer_sync(&adapter->phy_config_timer); 2616 del_timer_sync(&adapter->phy_config_timer);
2630 adapter->phy_timer_pending = false; 2617 adapter->phy_timer_pending = false;
2631 2618
@@ -2983,7 +2970,7 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
2983 netdev->open = &atl1_open; 2970 netdev->open = &atl1_open;
2984 netdev->stop = &atl1_close; 2971 netdev->stop = &atl1_close;
2985 netdev->hard_start_xmit = &atl1_xmit_frame; 2972 netdev->hard_start_xmit = &atl1_xmit_frame;
2986 netdev->get_stats = &atlx_get_stats; 2973
2987 netdev->set_multicast_list = &atlx_set_multi; 2974 netdev->set_multicast_list = &atlx_set_multi;
2988 netdev->set_mac_address = &atl1_set_mac; 2975 netdev->set_mac_address = &atl1_set_mac;
2989 netdev->change_mtu = &atl1_change_mtu; 2976 netdev->change_mtu = &atl1_change_mtu;
@@ -3049,13 +3036,8 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
3049 netif_carrier_off(netdev); 3036 netif_carrier_off(netdev);
3050 netif_stop_queue(netdev); 3037 netif_stop_queue(netdev);
3051 3038
3052 init_timer(&adapter->watchdog_timer); 3039 setup_timer(&adapter->phy_config_timer, &atl1_phy_config,
3053 adapter->watchdog_timer.function = &atl1_watchdog; 3040 (unsigned long)adapter);
3054 adapter->watchdog_timer.data = (unsigned long)adapter;
3055
3056 init_timer(&adapter->phy_config_timer);
3057 adapter->phy_config_timer.function = &atl1_phy_config;
3058 adapter->phy_config_timer.data = (unsigned long)adapter;
3059 adapter->phy_timer_pending = false; 3041 adapter->phy_timer_pending = false;
3060 3042
3061 INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task); 3043 INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task);
@@ -3173,8 +3155,6 @@ static struct atl1_stats atl1_gstrings_stats[] = {
3173 {"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)}, 3155 {"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)},
3174 {"rx_errors", ATL1_STAT(soft_stats.rx_errors)}, 3156 {"rx_errors", ATL1_STAT(soft_stats.rx_errors)},
3175 {"tx_errors", ATL1_STAT(soft_stats.tx_errors)}, 3157 {"tx_errors", ATL1_STAT(soft_stats.tx_errors)},
3176 {"rx_dropped", ATL1_STAT(net_stats.rx_dropped)},
3177 {"tx_dropped", ATL1_STAT(net_stats.tx_dropped)},
3178 {"multicast", ATL1_STAT(soft_stats.multicast)}, 3158 {"multicast", ATL1_STAT(soft_stats.multicast)},
3179 {"collisions", ATL1_STAT(soft_stats.collisions)}, 3159 {"collisions", ATL1_STAT(soft_stats.collisions)},
3180 {"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)}, 3160 {"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)},
diff --git a/drivers/net/atlx/atl1.h b/drivers/net/atlx/atl1.h
index ffa73fc8d95e..146372fd6683 100644
--- a/drivers/net/atlx/atl1.h
+++ b/drivers/net/atlx/atl1.h
@@ -754,7 +754,7 @@ struct atl1_hw {
754struct atl1_adapter { 754struct atl1_adapter {
755 struct net_device *netdev; 755 struct net_device *netdev;
756 struct pci_dev *pdev; 756 struct pci_dev *pdev;
757 struct net_device_stats net_stats; 757
758 struct atl1_sft_stats soft_stats; 758 struct atl1_sft_stats soft_stats;
759 struct vlan_group *vlgrp; 759 struct vlan_group *vlgrp;
760 u32 rx_buffer_len; 760 u32 rx_buffer_len;
@@ -765,7 +765,7 @@ struct atl1_adapter {
765 struct work_struct tx_timeout_task; 765 struct work_struct tx_timeout_task;
766 struct work_struct link_chg_task; 766 struct work_struct link_chg_task;
767 struct work_struct pcie_dma_to_rst_task; 767 struct work_struct pcie_dma_to_rst_task;
768 struct timer_list watchdog_timer; 768
769 struct timer_list phy_config_timer; 769 struct timer_list phy_config_timer;
770 bool phy_timer_pending; 770 bool phy_timer_pending;
771 771
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index f5bdc92c1a65..60c9e5375eed 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -418,7 +418,7 @@ static void atl2_intr_rx(struct atl2_adapter *adapter)
418 * Check that some rx space is free. If not, 418 * Check that some rx space is free. If not,
419 * free one and mark stats->rx_dropped++. 419 * free one and mark stats->rx_dropped++.
420 */ 420 */
421 adapter->net_stats.rx_dropped++; 421 netdev->stats.rx_dropped++;
422 break; 422 break;
423 } 423 }
424 skb_reserve(skb, NET_IP_ALIGN); 424 skb_reserve(skb, NET_IP_ALIGN);
@@ -435,20 +435,19 @@ static void atl2_intr_rx(struct atl2_adapter *adapter)
435 } else 435 } else
436#endif 436#endif
437 netif_rx(skb); 437 netif_rx(skb);
438 adapter->net_stats.rx_bytes += rx_size; 438 netdev->stats.rx_bytes += rx_size;
439 adapter->net_stats.rx_packets++; 439 netdev->stats.rx_packets++;
440 netdev->last_rx = jiffies;
441 } else { 440 } else {
442 adapter->net_stats.rx_errors++; 441 netdev->stats.rx_errors++;
443 442
444 if (rxd->status.ok && rxd->status.pkt_size <= 60) 443 if (rxd->status.ok && rxd->status.pkt_size <= 60)
445 adapter->net_stats.rx_length_errors++; 444 netdev->stats.rx_length_errors++;
446 if (rxd->status.mcast) 445 if (rxd->status.mcast)
447 adapter->net_stats.multicast++; 446 netdev->stats.multicast++;
448 if (rxd->status.crc) 447 if (rxd->status.crc)
449 adapter->net_stats.rx_crc_errors++; 448 netdev->stats.rx_crc_errors++;
450 if (rxd->status.align) 449 if (rxd->status.align)
451 adapter->net_stats.rx_frame_errors++; 450 netdev->stats.rx_frame_errors++;
452 } 451 }
453 452
454 /* advance write ptr */ 453 /* advance write ptr */
@@ -463,6 +462,7 @@ static void atl2_intr_rx(struct atl2_adapter *adapter)
463 462
464static void atl2_intr_tx(struct atl2_adapter *adapter) 463static void atl2_intr_tx(struct atl2_adapter *adapter)
465{ 464{
465 struct net_device *netdev = adapter->netdev;
466 u32 txd_read_ptr; 466 u32 txd_read_ptr;
467 u32 txs_write_ptr; 467 u32 txs_write_ptr;
468 struct tx_pkt_status *txs; 468 struct tx_pkt_status *txs;
@@ -522,20 +522,20 @@ static void atl2_intr_tx(struct atl2_adapter *adapter)
522 522
523 /* tx statistics: */ 523 /* tx statistics: */
524 if (txs->ok) { 524 if (txs->ok) {
525 adapter->net_stats.tx_bytes += txs->pkt_size; 525 netdev->stats.tx_bytes += txs->pkt_size;
526 adapter->net_stats.tx_packets++; 526 netdev->stats.tx_packets++;
527 } 527 }
528 else 528 else
529 adapter->net_stats.tx_errors++; 529 netdev->stats.tx_errors++;
530 530
531 if (txs->defer) 531 if (txs->defer)
532 adapter->net_stats.collisions++; 532 netdev->stats.collisions++;
533 if (txs->abort_col) 533 if (txs->abort_col)
534 adapter->net_stats.tx_aborted_errors++; 534 netdev->stats.tx_aborted_errors++;
535 if (txs->late_col) 535 if (txs->late_col)
536 adapter->net_stats.tx_window_errors++; 536 netdev->stats.tx_window_errors++;
537 if (txs->underun) 537 if (txs->underun)
538 adapter->net_stats.tx_fifo_errors++; 538 netdev->stats.tx_fifo_errors++;
539 } while (1); 539 } while (1);
540 540
541 if (free_hole) { 541 if (free_hole) {
@@ -621,7 +621,7 @@ static irqreturn_t atl2_intr(int irq, void *data)
621 621
622 /* link event */ 622 /* link event */
623 if (status & (ISR_PHY | ISR_MANUAL)) { 623 if (status & (ISR_PHY | ISR_MANUAL)) {
624 adapter->net_stats.tx_carrier_errors++; 624 adapter->netdev->stats.tx_carrier_errors++;
625 atl2_check_for_link(adapter); 625 atl2_check_for_link(adapter);
626 } 626 }
627 627
@@ -723,7 +723,7 @@ static int atl2_open(struct net_device *netdev)
723 723
724 clear_bit(__ATL2_DOWN, &adapter->flags); 724 clear_bit(__ATL2_DOWN, &adapter->flags);
725 725
726 mod_timer(&adapter->watchdog_timer, jiffies + 4*HZ); 726 mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 4*HZ));
727 727
728 val = ATL2_READ_REG(&adapter->hw, REG_MASTER_CTRL); 728 val = ATL2_READ_REG(&adapter->hw, REG_MASTER_CTRL);
729 ATL2_WRITE_REG(&adapter->hw, REG_MASTER_CTRL, 729 ATL2_WRITE_REG(&adapter->hw, REG_MASTER_CTRL,
@@ -900,19 +900,6 @@ static int atl2_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
900} 900}
901 901
902/* 902/*
903 * atl2_get_stats - Get System Network Statistics
904 * @netdev: network interface device structure
905 *
906 * Returns the address of the device statistics structure.
907 * The statistics are actually updated from the timer callback.
908 */
909static struct net_device_stats *atl2_get_stats(struct net_device *netdev)
910{
911 struct atl2_adapter *adapter = netdev_priv(netdev);
912 return &adapter->net_stats;
913}
914
915/*
916 * atl2_change_mtu - Change the Maximum Transfer Unit 903 * atl2_change_mtu - Change the Maximum Transfer Unit
917 * @netdev: network interface device structure 904 * @netdev: network interface device structure
918 * @new_mtu: new value for maximum frame size 905 * @new_mtu: new value for maximum frame size
@@ -1050,18 +1037,21 @@ static void atl2_tx_timeout(struct net_device *netdev)
1050static void atl2_watchdog(unsigned long data) 1037static void atl2_watchdog(unsigned long data)
1051{ 1038{
1052 struct atl2_adapter *adapter = (struct atl2_adapter *) data; 1039 struct atl2_adapter *adapter = (struct atl2_adapter *) data;
1053 u32 drop_rxd, drop_rxs;
1054 unsigned long flags;
1055 1040
1056 if (!test_bit(__ATL2_DOWN, &adapter->flags)) { 1041 if (!test_bit(__ATL2_DOWN, &adapter->flags)) {
1042 u32 drop_rxd, drop_rxs;
1043 unsigned long flags;
1044
1057 spin_lock_irqsave(&adapter->stats_lock, flags); 1045 spin_lock_irqsave(&adapter->stats_lock, flags);
1058 drop_rxd = ATL2_READ_REG(&adapter->hw, REG_STS_RXD_OV); 1046 drop_rxd = ATL2_READ_REG(&adapter->hw, REG_STS_RXD_OV);
1059 drop_rxs = ATL2_READ_REG(&adapter->hw, REG_STS_RXS_OV); 1047 drop_rxs = ATL2_READ_REG(&adapter->hw, REG_STS_RXS_OV);
1060 adapter->net_stats.rx_over_errors += (drop_rxd+drop_rxs);
1061 spin_unlock_irqrestore(&adapter->stats_lock, flags); 1048 spin_unlock_irqrestore(&adapter->stats_lock, flags);
1062 1049
1050 adapter->netdev->stats.rx_over_errors += drop_rxd + drop_rxs;
1051
1063 /* Reset the timer */ 1052 /* Reset the timer */
1064 mod_timer(&adapter->watchdog_timer, jiffies + 4 * HZ); 1053 mod_timer(&adapter->watchdog_timer,
1054 round_jiffies(jiffies + 4 * HZ));
1065 } 1055 }
1066} 1056}
1067 1057
@@ -1265,7 +1255,8 @@ static int atl2_check_link(struct atl2_adapter *adapter)
1265 * (if interval smaller than 5 seconds, something strange) */ 1255 * (if interval smaller than 5 seconds, something strange) */
1266 if (!test_bit(__ATL2_DOWN, &adapter->flags)) { 1256 if (!test_bit(__ATL2_DOWN, &adapter->flags)) {
1267 if (!test_and_set_bit(0, &adapter->cfg_phy)) 1257 if (!test_and_set_bit(0, &adapter->cfg_phy))
1268 mod_timer(&adapter->phy_config_timer, jiffies + 5 * HZ); 1258 mod_timer(&adapter->phy_config_timer,
1259 round_jiffies(jiffies + 5 * HZ));
1269 } 1260 }
1270 1261
1271 return 0; 1262 return 0;
@@ -1396,7 +1387,6 @@ static int __devinit atl2_probe(struct pci_dev *pdev,
1396 netdev->open = &atl2_open; 1387 netdev->open = &atl2_open;
1397 netdev->stop = &atl2_close; 1388 netdev->stop = &atl2_close;
1398 netdev->hard_start_xmit = &atl2_xmit_frame; 1389 netdev->hard_start_xmit = &atl2_xmit_frame;
1399 netdev->get_stats = &atl2_get_stats;
1400 netdev->set_multicast_list = &atl2_set_multi; 1390 netdev->set_multicast_list = &atl2_set_multi;
1401 netdev->set_mac_address = &atl2_set_mac; 1391 netdev->set_mac_address = &atl2_set_mac;
1402 netdev->change_mtu = &atl2_change_mtu; 1392 netdev->change_mtu = &atl2_change_mtu;
diff --git a/drivers/net/atlx/atl2.h b/drivers/net/atlx/atl2.h
index 09974df76b18..d918bbe621ea 100644
--- a/drivers/net/atlx/atl2.h
+++ b/drivers/net/atlx/atl2.h
@@ -453,7 +453,6 @@ struct atl2_adapter {
453 /* OS defined structs */ 453 /* OS defined structs */
454 struct net_device *netdev; 454 struct net_device *netdev;
455 struct pci_dev *pdev; 455 struct pci_dev *pdev;
456 struct net_device_stats net_stats;
457#ifdef NETIF_F_HW_VLAN_TX 456#ifdef NETIF_F_HW_VLAN_TX
458 struct vlan_group *vlgrp; 457 struct vlan_group *vlgrp;
459#endif 458#endif
diff --git a/drivers/net/atlx/atlx.c b/drivers/net/atlx/atlx.c
index 3cc9d1089ca1..3dc014215679 100644
--- a/drivers/net/atlx/atlx.c
+++ b/drivers/net/atlx/atlx.c
@@ -182,19 +182,6 @@ static void atlx_clear_phy_int(struct atlx_adapter *adapter)
182} 182}
183 183
184/* 184/*
185 * atlx_get_stats - Get System Network Statistics
186 * @netdev: network interface device structure
187 *
188 * Returns the address of the device statistics structure.
189 * The statistics are actually updated from the timer callback.
190 */
191static struct net_device_stats *atlx_get_stats(struct net_device *netdev)
192{
193 struct atlx_adapter *adapter = netdev_priv(netdev);
194 return &adapter->net_stats;
195}
196
197/*
198 * atlx_tx_timeout - Respond to a Tx Hang 185 * atlx_tx_timeout - Respond to a Tx Hang
199 * @netdev: network interface device structure 186 * @netdev: network interface device structure
200 */ 187 */
diff --git a/drivers/net/atp.c b/drivers/net/atp.c
index c10cd8058e23..7028b276dfd3 100644
--- a/drivers/net/atp.c
+++ b/drivers/net/atp.c
@@ -248,7 +248,6 @@ static int __init atp_probe1(long ioaddr)
248 struct net_local *lp; 248 struct net_local *lp;
249 int saved_ctrl_reg, status, i; 249 int saved_ctrl_reg, status, i;
250 int res; 250 int res;
251 DECLARE_MAC_BUF(mac);
252 251
253 outb(0xff, ioaddr + PAR_DATA); 252 outb(0xff, ioaddr + PAR_DATA);
254 /* Save the original value of the Control register, in case we guessed 253 /* Save the original value of the Control register, in case we guessed
@@ -324,8 +323,8 @@ static int __init atp_probe1(long ioaddr)
324#endif 323#endif
325 324
326 printk(KERN_NOTICE "%s: Pocket adapter found at %#3lx, IRQ %d, " 325 printk(KERN_NOTICE "%s: Pocket adapter found at %#3lx, IRQ %d, "
327 "SAPROM %s.\n", 326 "SAPROM %pM.\n",
328 dev->name, dev->base_addr, dev->irq, print_mac(mac, dev->dev_addr)); 327 dev->name, dev->base_addr, dev->irq, dev->dev_addr);
329 328
330 /* Reset the ethernet hardware and activate the printer pass-through. */ 329 /* Reset the ethernet hardware and activate the printer pass-through. */
331 write_reg_high(ioaddr, CMR1, CMR1h_RESET | CMR1h_MUX); 330 write_reg_high(ioaddr, CMR1, CMR1h_RESET | CMR1h_MUX);
@@ -913,7 +912,8 @@ static void __exit atp_cleanup_module(void) {
913 struct net_device *next_dev; 912 struct net_device *next_dev;
914 913
915 while (root_atp_dev) { 914 while (root_atp_dev) {
916 next_dev = ((struct net_local *)root_atp_dev->priv)->next_module; 915 struct net_local *atp_local = netdev_priv(root_atp_dev);
916 next_dev = atp_local->next_module;
917 unregister_netdev(root_atp_dev); 917 unregister_netdev(root_atp_dev);
918 /* No need to release_region(), since we never snarf it. */ 918 /* No need to release_region(), since we never snarf it. */
919 free_netdev(root_atp_dev); 919 free_netdev(root_atp_dev);
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 019b13c08ae6..ecc2573b3dce 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -193,7 +193,7 @@ struct au1000_private *au_macs[NUM_ETH_INTERFACES];
193 */ 193 */
194static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg) 194static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
195{ 195{
196 struct au1000_private *aup = (struct au1000_private *) dev->priv; 196 struct au1000_private *aup = netdev_priv(dev);
197 volatile u32 *const mii_control_reg = &aup->mac->mii_control; 197 volatile u32 *const mii_control_reg = &aup->mac->mii_control;
198 volatile u32 *const mii_data_reg = &aup->mac->mii_data; 198 volatile u32 *const mii_data_reg = &aup->mac->mii_data;
199 u32 timedout = 20; 199 u32 timedout = 20;
@@ -228,7 +228,7 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
228static void au1000_mdio_write(struct net_device *dev, int phy_addr, 228static void au1000_mdio_write(struct net_device *dev, int phy_addr,
229 int reg, u16 value) 229 int reg, u16 value)
230{ 230{
231 struct au1000_private *aup = (struct au1000_private *) dev->priv; 231 struct au1000_private *aup = netdev_priv(dev);
232 volatile u32 *const mii_control_reg = &aup->mac->mii_control; 232 volatile u32 *const mii_control_reg = &aup->mac->mii_control;
233 volatile u32 *const mii_data_reg = &aup->mac->mii_data; 233 volatile u32 *const mii_data_reg = &aup->mac->mii_data;
234 u32 timedout = 20; 234 u32 timedout = 20;
@@ -283,7 +283,7 @@ static int au1000_mdiobus_reset(struct mii_bus *bus)
283 283
284static int mii_probe (struct net_device *dev) 284static int mii_probe (struct net_device *dev)
285{ 285{
286 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 286 struct au1000_private *const aup = netdev_priv(dev);
287 struct phy_device *phydev = NULL; 287 struct phy_device *phydev = NULL;
288 288
289#if defined(AU1XXX_PHY_STATIC_CONFIG) 289#if defined(AU1XXX_PHY_STATIC_CONFIG)
@@ -415,7 +415,7 @@ void ReleaseDB(struct au1000_private *aup, db_dest_t *pDB)
415 415
416static void enable_rx_tx(struct net_device *dev) 416static void enable_rx_tx(struct net_device *dev)
417{ 417{
418 struct au1000_private *aup = (struct au1000_private *) dev->priv; 418 struct au1000_private *aup = netdev_priv(dev);
419 419
420 if (au1000_debug > 4) 420 if (au1000_debug > 4)
421 printk(KERN_INFO "%s: enable_rx_tx\n", dev->name); 421 printk(KERN_INFO "%s: enable_rx_tx\n", dev->name);
@@ -426,7 +426,7 @@ static void enable_rx_tx(struct net_device *dev)
426 426
427static void hard_stop(struct net_device *dev) 427static void hard_stop(struct net_device *dev)
428{ 428{
429 struct au1000_private *aup = (struct au1000_private *) dev->priv; 429 struct au1000_private *aup = netdev_priv(dev);
430 430
431 if (au1000_debug > 4) 431 if (au1000_debug > 4)
432 printk(KERN_INFO "%s: hard stop\n", dev->name); 432 printk(KERN_INFO "%s: hard stop\n", dev->name);
@@ -438,7 +438,7 @@ static void hard_stop(struct net_device *dev)
438static void enable_mac(struct net_device *dev, int force_reset) 438static void enable_mac(struct net_device *dev, int force_reset)
439{ 439{
440 unsigned long flags; 440 unsigned long flags;
441 struct au1000_private *aup = (struct au1000_private *) dev->priv; 441 struct au1000_private *aup = netdev_priv(dev);
442 442
443 spin_lock_irqsave(&aup->lock, flags); 443 spin_lock_irqsave(&aup->lock, flags);
444 444
@@ -457,7 +457,7 @@ static void enable_mac(struct net_device *dev, int force_reset)
457 457
458static void reset_mac_unlocked(struct net_device *dev) 458static void reset_mac_unlocked(struct net_device *dev)
459{ 459{
460 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 460 struct au1000_private *const aup = netdev_priv(dev);
461 int i; 461 int i;
462 462
463 hard_stop(dev); 463 hard_stop(dev);
@@ -483,7 +483,7 @@ static void reset_mac_unlocked(struct net_device *dev)
483 483
484static void reset_mac(struct net_device *dev) 484static void reset_mac(struct net_device *dev)
485{ 485{
486 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 486 struct au1000_private *const aup = netdev_priv(dev);
487 unsigned long flags; 487 unsigned long flags;
488 488
489 if (au1000_debug > 4) 489 if (au1000_debug > 4)
@@ -572,7 +572,7 @@ static int __init au1000_init_module(void)
572 572
573static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 573static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
574{ 574{
575 struct au1000_private *aup = (struct au1000_private *)dev->priv; 575 struct au1000_private *aup = netdev_priv(dev);
576 576
577 if (aup->phy_dev) 577 if (aup->phy_dev)
578 return phy_ethtool_gset(aup->phy_dev, cmd); 578 return phy_ethtool_gset(aup->phy_dev, cmd);
@@ -582,7 +582,7 @@ static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
582 582
583static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 583static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
584{ 584{
585 struct au1000_private *aup = (struct au1000_private *)dev->priv; 585 struct au1000_private *aup = netdev_priv(dev);
586 586
587 if (!capable(CAP_NET_ADMIN)) 587 if (!capable(CAP_NET_ADMIN))
588 return -EPERM; 588 return -EPERM;
@@ -596,7 +596,7 @@ static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
596static void 596static void
597au1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 597au1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
598{ 598{
599 struct au1000_private *aup = (struct au1000_private *)dev->priv; 599 struct au1000_private *aup = netdev_priv(dev);
600 600
601 strcpy(info->driver, DRV_NAME); 601 strcpy(info->driver, DRV_NAME);
602 strcpy(info->version, DRV_VERSION); 602 strcpy(info->version, DRV_VERSION);
@@ -652,7 +652,7 @@ static struct net_device * au1000_probe(int port_num)
652 printk("%s: Au1xx0 Ethernet found at 0x%x, irq %d\n", 652 printk("%s: Au1xx0 Ethernet found at 0x%x, irq %d\n",
653 dev->name, base, irq); 653 dev->name, base, irq);
654 654
655 aup = dev->priv; 655 aup = netdev_priv(dev);
656 656
657 spin_lock_init(&aup->lock); 657 spin_lock_init(&aup->lock);
658 658
@@ -817,7 +817,7 @@ err_out:
817 */ 817 */
818static int au1000_init(struct net_device *dev) 818static int au1000_init(struct net_device *dev)
819{ 819{
820 struct au1000_private *aup = (struct au1000_private *) dev->priv; 820 struct au1000_private *aup = netdev_priv(dev);
821 unsigned long flags; 821 unsigned long flags;
822 int i; 822 int i;
823 u32 control; 823 u32 control;
@@ -868,7 +868,7 @@ static int au1000_init(struct net_device *dev)
868static void 868static void
869au1000_adjust_link(struct net_device *dev) 869au1000_adjust_link(struct net_device *dev)
870{ 870{
871 struct au1000_private *aup = (struct au1000_private *) dev->priv; 871 struct au1000_private *aup = netdev_priv(dev);
872 struct phy_device *phydev = aup->phy_dev; 872 struct phy_device *phydev = aup->phy_dev;
873 unsigned long flags; 873 unsigned long flags;
874 874
@@ -947,7 +947,7 @@ au1000_adjust_link(struct net_device *dev)
947static int au1000_open(struct net_device *dev) 947static int au1000_open(struct net_device *dev)
948{ 948{
949 int retval; 949 int retval;
950 struct au1000_private *aup = (struct au1000_private *) dev->priv; 950 struct au1000_private *aup = netdev_priv(dev);
951 951
952 if (au1000_debug > 4) 952 if (au1000_debug > 4)
953 printk("%s: open: dev=%p\n", dev->name, dev); 953 printk("%s: open: dev=%p\n", dev->name, dev);
@@ -982,7 +982,7 @@ static int au1000_open(struct net_device *dev)
982static int au1000_close(struct net_device *dev) 982static int au1000_close(struct net_device *dev)
983{ 983{
984 unsigned long flags; 984 unsigned long flags;
985 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 985 struct au1000_private *const aup = netdev_priv(dev);
986 986
987 if (au1000_debug > 4) 987 if (au1000_debug > 4)
988 printk("%s: close: dev=%p\n", dev->name, dev); 988 printk("%s: close: dev=%p\n", dev->name, dev);
@@ -1013,7 +1013,7 @@ static void __exit au1000_cleanup_module(void)
1013 for (i = 0; i < num_ifs; i++) { 1013 for (i = 0; i < num_ifs; i++) {
1014 dev = iflist[i].dev; 1014 dev = iflist[i].dev;
1015 if (dev) { 1015 if (dev) {
1016 aup = (struct au1000_private *) dev->priv; 1016 aup = netdev_priv(dev);
1017 unregister_netdev(dev); 1017 unregister_netdev(dev);
1018 mdiobus_unregister(aup->mii_bus); 1018 mdiobus_unregister(aup->mii_bus);
1019 mdiobus_free(aup->mii_bus); 1019 mdiobus_free(aup->mii_bus);
@@ -1035,7 +1035,7 @@ static void __exit au1000_cleanup_module(void)
1035 1035
1036static void update_tx_stats(struct net_device *dev, u32 status) 1036static void update_tx_stats(struct net_device *dev, u32 status)
1037{ 1037{
1038 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1038 struct au1000_private *aup = netdev_priv(dev);
1039 struct net_device_stats *ps = &dev->stats; 1039 struct net_device_stats *ps = &dev->stats;
1040 1040
1041 if (status & TX_FRAME_ABORTED) { 1041 if (status & TX_FRAME_ABORTED) {
@@ -1064,7 +1064,7 @@ static void update_tx_stats(struct net_device *dev, u32 status)
1064 */ 1064 */
1065static void au1000_tx_ack(struct net_device *dev) 1065static void au1000_tx_ack(struct net_device *dev)
1066{ 1066{
1067 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1067 struct au1000_private *aup = netdev_priv(dev);
1068 volatile tx_dma_t *ptxd; 1068 volatile tx_dma_t *ptxd;
1069 1069
1070 ptxd = aup->tx_dma_ring[aup->tx_tail]; 1070 ptxd = aup->tx_dma_ring[aup->tx_tail];
@@ -1091,7 +1091,7 @@ static void au1000_tx_ack(struct net_device *dev)
1091 */ 1091 */
1092static int au1000_tx(struct sk_buff *skb, struct net_device *dev) 1092static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1093{ 1093{
1094 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1094 struct au1000_private *aup = netdev_priv(dev);
1095 struct net_device_stats *ps = &dev->stats; 1095 struct net_device_stats *ps = &dev->stats;
1096 volatile tx_dma_t *ptxd; 1096 volatile tx_dma_t *ptxd;
1097 u32 buff_stat; 1097 u32 buff_stat;
@@ -1145,7 +1145,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1145 1145
1146static inline void update_rx_stats(struct net_device *dev, u32 status) 1146static inline void update_rx_stats(struct net_device *dev, u32 status)
1147{ 1147{
1148 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1148 struct au1000_private *aup = netdev_priv(dev);
1149 struct net_device_stats *ps = &dev->stats; 1149 struct net_device_stats *ps = &dev->stats;
1150 1150
1151 ps->rx_packets++; 1151 ps->rx_packets++;
@@ -1173,7 +1173,7 @@ static inline void update_rx_stats(struct net_device *dev, u32 status)
1173 */ 1173 */
1174static int au1000_rx(struct net_device *dev) 1174static int au1000_rx(struct net_device *dev)
1175{ 1175{
1176 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1176 struct au1000_private *aup = netdev_priv(dev);
1177 struct sk_buff *skb; 1177 struct sk_buff *skb;
1178 volatile rx_dma_t *prxd; 1178 volatile rx_dma_t *prxd;
1179 u32 buff_stat, status; 1179 u32 buff_stat, status;
@@ -1240,7 +1240,6 @@ static int au1000_rx(struct net_device *dev)
1240 /* next descriptor */ 1240 /* next descriptor */
1241 prxd = aup->rx_dma_ring[aup->rx_head]; 1241 prxd = aup->rx_dma_ring[aup->rx_head];
1242 buff_stat = prxd->buff_stat; 1242 buff_stat = prxd->buff_stat;
1243 dev->last_rx = jiffies;
1244 } 1243 }
1245 return 0; 1244 return 0;
1246} 1245}
@@ -1276,7 +1275,7 @@ static void au1000_tx_timeout(struct net_device *dev)
1276 1275
1277static void set_rx_mode(struct net_device *dev) 1276static void set_rx_mode(struct net_device *dev)
1278{ 1277{
1279 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1278 struct au1000_private *aup = netdev_priv(dev);
1280 1279
1281 if (au1000_debug > 4) 1280 if (au1000_debug > 4)
1282 printk("%s: set_rx_mode: flags=%x\n", dev->name, dev->flags); 1281 printk("%s: set_rx_mode: flags=%x\n", dev->name, dev->flags);
@@ -1308,7 +1307,7 @@ static void set_rx_mode(struct net_device *dev)
1308 1307
1309static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1308static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1310{ 1309{
1311 struct au1000_private *aup = (struct au1000_private *)dev->priv; 1310 struct au1000_private *aup = netdev_priv(dev);
1312 1311
1313 if (!netif_running(dev)) return -EINVAL; 1312 if (!netif_running(dev)) return -EINVAL;
1314 1313
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 9a314d88e7b6..337488ec707c 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -758,13 +758,10 @@ static int ax_init_dev(struct net_device *dev, int first_init)
758#endif 758#endif
759 ax_NS8390_init(dev, 0); 759 ax_NS8390_init(dev, 0);
760 760
761 if (first_init) { 761 if (first_init)
762 DECLARE_MAC_BUF(mac); 762 dev_info(&ax->dev->dev, "%dbit, irq %d, %lx, MAC: %pM\n",
763
764 dev_info(&ax->dev->dev, "%dbit, irq %d, %lx, MAC: %s\n",
765 ei_status.word16 ? 16:8, dev->irq, dev->base_addr, 763 ei_status.word16 ? 16:8, dev->irq, dev->base_addr,
766 print_mac(mac, dev->dev_addr)); 764 dev->dev_addr);
767 }
768 765
769 ret = register_netdev(dev); 766 ret = register_netdev(dev);
770 if (ret) 767 if (ret)
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index c3bda5ce67c4..2c7a32eb92a5 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -829,7 +829,6 @@ static int b44_rx(struct b44 *bp, int budget)
829 skb->ip_summed = CHECKSUM_NONE; 829 skb->ip_summed = CHECKSUM_NONE;
830 skb->protocol = eth_type_trans(skb, bp->dev); 830 skb->protocol = eth_type_trans(skb, bp->dev);
831 netif_receive_skb(skb); 831 netif_receive_skb(skb);
832 bp->dev->last_rx = jiffies;
833 received++; 832 received++;
834 budget--; 833 budget--;
835 next_pkt: 834 next_pkt:
@@ -2117,7 +2116,6 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2117 struct net_device *dev; 2116 struct net_device *dev;
2118 struct b44 *bp; 2117 struct b44 *bp;
2119 int err; 2118 int err;
2120 DECLARE_MAC_BUF(mac);
2121 2119
2122 instance++; 2120 instance++;
2123 2121
@@ -2213,8 +2211,8 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2213 */ 2211 */
2214 b44_chip_reset(bp, B44_CHIP_RESET_FULL); 2212 b44_chip_reset(bp, B44_CHIP_RESET_FULL);
2215 2213
2216 printk(KERN_INFO "%s: Broadcom 44xx/47xx 10/100BaseT Ethernet %s\n", 2214 printk(KERN_INFO "%s: Broadcom 44xx/47xx 10/100BaseT Ethernet %pM\n",
2217 dev->name, print_mac(mac, dev->dev_addr)); 2215 dev->name, dev->dev_addr);
2218 2216
2219 return 0; 2217 return 0;
2220 2218
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index b458d607a9c6..78e31aa861e0 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -741,7 +741,6 @@ static void bfin_mac_rx(struct net_device *dev)
741 blackfin_dcache_invalidate_range((unsigned long)skb->head, 741 blackfin_dcache_invalidate_range((unsigned long)skb->head,
742 (unsigned long)skb->tail); 742 (unsigned long)skb->tail);
743 743
744 dev->last_rx = jiffies;
745 skb->protocol = eth_type_trans(skb, dev); 744 skb->protocol = eth_type_trans(skb, dev);
746#if defined(BFIN_MAC_CSUM_OFFLOAD) 745#if defined(BFIN_MAC_CSUM_OFFLOAD)
747 skb->csum = current_rx_ptr->status.ip_payload_csum; 746 skb->csum = current_rx_ptr->status.ip_payload_csum;
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index a42bd19646d3..8a546a33d581 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -716,13 +716,11 @@ static irqreturn_t bmac_rxdma_intr(int irq, void *dev_id)
716 skb_put(skb, nb); 716 skb_put(skb, nb);
717 skb->protocol = eth_type_trans(skb, dev); 717 skb->protocol = eth_type_trans(skb, dev);
718 netif_rx(skb); 718 netif_rx(skb);
719 dev->last_rx = jiffies;
720 ++dev->stats.rx_packets; 719 ++dev->stats.rx_packets;
721 dev->stats.rx_bytes += nb; 720 dev->stats.rx_bytes += nb;
722 } else { 721 } else {
723 ++dev->stats.rx_dropped; 722 ++dev->stats.rx_dropped;
724 } 723 }
725 dev->last_rx = jiffies;
726 if ((skb = bp->rx_bufs[i]) == NULL) { 724 if ((skb = bp->rx_bufs[i]) == NULL) {
727 bp->rx_bufs[i] = skb = dev_alloc_skb(RX_BUFLEN+2); 725 bp->rx_bufs[i] = skb = dev_alloc_skb(RX_BUFLEN+2);
728 if (skb != NULL) 726 if (skb != NULL)
@@ -1258,7 +1256,6 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1258 unsigned char addr[6]; 1256 unsigned char addr[6];
1259 struct net_device *dev; 1257 struct net_device *dev;
1260 int is_bmac_plus = ((int)match->data) != 0; 1258 int is_bmac_plus = ((int)match->data) != 0;
1261 DECLARE_MAC_BUF(mac);
1262 1259
1263 if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) { 1260 if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) {
1264 printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n"); 1261 printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n");
@@ -1368,8 +1365,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1368 goto err_out_irq2; 1365 goto err_out_irq2;
1369 } 1366 }
1370 1367
1371 printk(KERN_INFO "%s: BMAC%s at %s", 1368 printk(KERN_INFO "%s: BMAC%s at %pM",
1372 dev->name, (is_bmac_plus ? "+" : ""), print_mac(mac, dev->dev_addr)); 1369 dev->name, (is_bmac_plus ? "+" : ""), dev->dev_addr);
1373 XXDEBUG((", base_addr=%#0lx", dev->base_addr)); 1370 XXDEBUG((", base_addr=%#0lx", dev->base_addr));
1374 printk("\n"); 1371 printk("\n");
1375 1372
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index d07e3f148951..fe802215214f 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -57,8 +57,8 @@
57 57
58#define DRV_MODULE_NAME "bnx2" 58#define DRV_MODULE_NAME "bnx2"
59#define PFX DRV_MODULE_NAME ": " 59#define PFX DRV_MODULE_NAME ": "
60#define DRV_MODULE_VERSION "1.8.1" 60#define DRV_MODULE_VERSION "1.8.2"
61#define DRV_MODULE_RELDATE "Oct 7, 2008" 61#define DRV_MODULE_RELDATE "Nov 10, 2008"
62 62
63#define RUN_AT(x) (jiffies + (x)) 63#define RUN_AT(x) (jiffies + (x))
64 64
@@ -89,6 +89,7 @@ typedef enum {
89 BCM5709, 89 BCM5709,
90 BCM5709S, 90 BCM5709S,
91 BCM5716, 91 BCM5716,
92 BCM5716S,
92} board_t; 93} board_t;
93 94
94/* indexed by board_t, above */ 95/* indexed by board_t, above */
@@ -105,6 +106,7 @@ static struct {
105 { "Broadcom NetXtreme II BCM5709 1000Base-T" }, 106 { "Broadcom NetXtreme II BCM5709 1000Base-T" },
106 { "Broadcom NetXtreme II BCM5709 1000Base-SX" }, 107 { "Broadcom NetXtreme II BCM5709 1000Base-SX" },
107 { "Broadcom NetXtreme II BCM5716 1000Base-T" }, 108 { "Broadcom NetXtreme II BCM5716 1000Base-T" },
109 { "Broadcom NetXtreme II BCM5716 1000Base-SX" },
108 }; 110 };
109 111
110static DEFINE_PCI_DEVICE_TABLE(bnx2_pci_tbl) = { 112static DEFINE_PCI_DEVICE_TABLE(bnx2_pci_tbl) = {
@@ -128,6 +130,8 @@ static DEFINE_PCI_DEVICE_TABLE(bnx2_pci_tbl) = {
128 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709S }, 130 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709S },
129 { PCI_VENDOR_ID_BROADCOM, 0x163b, 131 { PCI_VENDOR_ID_BROADCOM, 0x163b,
130 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716 }, 132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716 },
133 { PCI_VENDOR_ID_BROADCOM, 0x163c,
134 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716 },
131 { 0, } 135 { 0, }
132}; 136};
133 137
@@ -1652,7 +1656,7 @@ bnx2_setup_serdes_phy(struct bnx2 *bp, u8 port)
1652 * exchanging base pages plus 3 next pages and 1656 * exchanging base pages plus 3 next pages and
1653 * normally completes in about 120 msec. 1657 * normally completes in about 120 msec.
1654 */ 1658 */
1655 bp->current_interval = SERDES_AN_TIMEOUT; 1659 bp->current_interval = BNX2_SERDES_AN_TIMEOUT;
1656 bp->serdes_an_pending = 1; 1660 bp->serdes_an_pending = 1;
1657 mod_timer(&bp->timer, jiffies + bp->current_interval); 1661 mod_timer(&bp->timer, jiffies + bp->current_interval);
1658 } else { 1662 } else {
@@ -2274,7 +2278,7 @@ bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int ack, int silent)
2274 return 0; 2278 return 0;
2275 2279
2276 /* wait for an acknowledgement. */ 2280 /* wait for an acknowledgement. */
2277 for (i = 0; i < (FW_ACK_TIME_OUT_MS / 10); i++) { 2281 for (i = 0; i < (BNX2_FW_ACK_TIME_OUT_MS / 10); i++) {
2278 msleep(10); 2282 msleep(10);
2279 2283
2280 val = bnx2_shmem_rd(bp, BNX2_FW_MB); 2284 val = bnx2_shmem_rd(bp, BNX2_FW_MB);
@@ -3000,7 +3004,6 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
3000#endif 3004#endif
3001 netif_receive_skb(skb); 3005 netif_receive_skb(skb);
3002 3006
3003 bp->dev->last_rx = jiffies;
3004 rx_pkt++; 3007 rx_pkt++;
3005 3008
3006next_rx: 3009next_rx:
@@ -4470,7 +4473,7 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
4470static int 4473static int
4471bnx2_init_chip(struct bnx2 *bp) 4474bnx2_init_chip(struct bnx2 *bp)
4472{ 4475{
4473 u32 val; 4476 u32 val, mtu;
4474 int rc, i; 4477 int rc, i;
4475 4478
4476 /* Make sure the interrupt is not active. */ 4479 /* Make sure the interrupt is not active. */
@@ -4562,11 +4565,19 @@ bnx2_init_chip(struct bnx2 *bp)
4562 REG_WR(bp, BNX2_EMAC_BACKOFF_SEED, val); 4565 REG_WR(bp, BNX2_EMAC_BACKOFF_SEED, val);
4563 4566
4564 /* Program the MTU. Also include 4 bytes for CRC32. */ 4567 /* Program the MTU. Also include 4 bytes for CRC32. */
4565 val = bp->dev->mtu + ETH_HLEN + 4; 4568 mtu = bp->dev->mtu;
4569 val = mtu + ETH_HLEN + ETH_FCS_LEN;
4566 if (val > (MAX_ETHERNET_PACKET_SIZE + 4)) 4570 if (val > (MAX_ETHERNET_PACKET_SIZE + 4))
4567 val |= BNX2_EMAC_RX_MTU_SIZE_JUMBO_ENA; 4571 val |= BNX2_EMAC_RX_MTU_SIZE_JUMBO_ENA;
4568 REG_WR(bp, BNX2_EMAC_RX_MTU_SIZE, val); 4572 REG_WR(bp, BNX2_EMAC_RX_MTU_SIZE, val);
4569 4573
4574 if (mtu < 1500)
4575 mtu = 1500;
4576
4577 bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG, BNX2_RBUF_CONFIG_VAL(mtu));
4578 bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG2, BNX2_RBUF_CONFIG2_VAL(mtu));
4579 bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG3, BNX2_RBUF_CONFIG3_VAL(mtu));
4580
4570 for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) 4581 for (i = 0; i < BNX2_MAX_MSIX_VEC; i++)
4571 bp->bnx2_napi[i].last_status_idx = 0; 4582 bp->bnx2_napi[i].last_status_idx = 0;
4572 4583
@@ -5694,7 +5705,7 @@ bnx2_5708_serdes_timer(struct bnx2 *bp)
5694 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr); 5705 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
5695 if (bmcr & BMCR_ANENABLE) { 5706 if (bmcr & BMCR_ANENABLE) {
5696 bnx2_enable_forced_2g5(bp); 5707 bnx2_enable_forced_2g5(bp);
5697 bp->current_interval = SERDES_FORCED_TIMEOUT; 5708 bp->current_interval = BNX2_SERDES_FORCED_TIMEOUT;
5698 } else { 5709 } else {
5699 bnx2_disable_forced_2g5(bp); 5710 bnx2_disable_forced_2g5(bp);
5700 bp->serdes_an_pending = 2; 5711 bp->serdes_an_pending = 2;
@@ -6511,7 +6522,7 @@ bnx2_nway_reset(struct net_device *dev)
6511 6522
6512 spin_lock_bh(&bp->phy_lock); 6523 spin_lock_bh(&bp->phy_lock);
6513 6524
6514 bp->current_interval = SERDES_AN_TIMEOUT; 6525 bp->current_interval = BNX2_SERDES_AN_TIMEOUT;
6515 bp->serdes_an_pending = 1; 6526 bp->serdes_an_pending = 1;
6516 mod_timer(&bp->timer, jiffies + bp->current_interval); 6527 mod_timer(&bp->timer, jiffies + bp->current_interval);
6517 } 6528 }
@@ -7586,7 +7597,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
7586 7597
7587 if ((CHIP_ID(bp) == CHIP_ID_5708_A0) || 7598 if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
7588 (CHIP_ID(bp) == CHIP_ID_5708_B0) || 7599 (CHIP_ID(bp) == CHIP_ID_5708_B0) ||
7589 (CHIP_ID(bp) == CHIP_ID_5708_B1)) { 7600 (CHIP_ID(bp) == CHIP_ID_5708_B1) ||
7601 !(REG_RD(bp, BNX2_PCI_CONFIG_3) & BNX2_PCI_CONFIG_3_VAUX_PRESET)) {
7590 bp->flags |= BNX2_FLAG_NO_WOL; 7602 bp->flags |= BNX2_FLAG_NO_WOL;
7591 bp->wol = 0; 7603 bp->wol = 0;
7592 } 7604 }
@@ -7703,7 +7715,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7703 struct bnx2 *bp; 7715 struct bnx2 *bp;
7704 int rc; 7716 int rc;
7705 char str[40]; 7717 char str[40];
7706 DECLARE_MAC_BUF(mac);
7707 7718
7708 if (version_printed++ == 0) 7719 if (version_printed++ == 0)
7709 printk(KERN_INFO "%s", version); 7720 printk(KERN_INFO "%s", version);
@@ -7770,14 +7781,14 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7770 } 7781 }
7771 7782
7772 printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, " 7783 printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, "
7773 "IRQ %d, node addr %s\n", 7784 "IRQ %d, node addr %pM\n",
7774 dev->name, 7785 dev->name,
7775 board_info[ent->driver_data].name, 7786 board_info[ent->driver_data].name,
7776 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A', 7787 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
7777 ((CHIP_ID(bp) & 0x0ff0) >> 4), 7788 ((CHIP_ID(bp) & 0x0ff0) >> 4),
7778 bnx2_bus_string(bp, str), 7789 bnx2_bus_string(bp, str),
7779 dev->base_addr, 7790 dev->base_addr,
7780 bp->pdev->irq, print_mac(mac, dev->dev_addr)); 7791 bp->pdev->irq, dev->dev_addr);
7781 7792
7782 return 0; 7793 return 0;
7783} 7794}
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 617d95340160..34ca47812af4 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -4199,7 +4199,14 @@ struct l2_fhdr {
4199 4199
4200#define BNX2_RBUF_CONFIG 0x0020000c 4200#define BNX2_RBUF_CONFIG 0x0020000c
4201#define BNX2_RBUF_CONFIG_XOFF_TRIP (0x3ffL<<0) 4201#define BNX2_RBUF_CONFIG_XOFF_TRIP (0x3ffL<<0)
4202#define BNX2_RBUF_CONFIG_XOFF_TRIP_VAL(mtu) \
4203 ((((mtu) - 1500) * 31 / 1000) + 54)
4202#define BNX2_RBUF_CONFIG_XON_TRIP (0x3ffL<<16) 4204#define BNX2_RBUF_CONFIG_XON_TRIP (0x3ffL<<16)
4205#define BNX2_RBUF_CONFIG_XON_TRIP_VAL(mtu) \
4206 ((((mtu) - 1500) * 39 / 1000) + 66)
4207#define BNX2_RBUF_CONFIG_VAL(mtu) \
4208 (BNX2_RBUF_CONFIG_XOFF_TRIP_VAL(mtu) | \
4209 (BNX2_RBUF_CONFIG_XON_TRIP_VAL(mtu) << 16))
4203 4210
4204#define BNX2_RBUF_FW_BUF_ALLOC 0x00200010 4211#define BNX2_RBUF_FW_BUF_ALLOC 0x00200010
4205#define BNX2_RBUF_FW_BUF_ALLOC_VALUE (0x1ffL<<7) 4212#define BNX2_RBUF_FW_BUF_ALLOC_VALUE (0x1ffL<<7)
@@ -4221,11 +4228,25 @@ struct l2_fhdr {
4221 4228
4222#define BNX2_RBUF_CONFIG2 0x0020001c 4229#define BNX2_RBUF_CONFIG2 0x0020001c
4223#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP (0x3ffL<<0) 4230#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP (0x3ffL<<0)
4231#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP_VAL(mtu) \
4232 ((((mtu) - 1500) * 4 / 1000) + 5)
4224#define BNX2_RBUF_CONFIG2_MAC_KEEP_TRIP (0x3ffL<<16) 4233#define BNX2_RBUF_CONFIG2_MAC_KEEP_TRIP (0x3ffL<<16)
4234#define BNX2_RBUF_CONFIG2_MAC_KEEP_TRIP_VAL(mtu) \
4235 ((((mtu) - 1500) * 2 / 100) + 30)
4236#define BNX2_RBUF_CONFIG2_VAL(mtu) \
4237 (BNX2_RBUF_CONFIG2_MAC_DROP_TRIP_VAL(mtu) | \
4238 (BNX2_RBUF_CONFIG2_MAC_KEEP_TRIP_VAL(mtu) << 16))
4225 4239
4226#define BNX2_RBUF_CONFIG3 0x00200020 4240#define BNX2_RBUF_CONFIG3 0x00200020
4227#define BNX2_RBUF_CONFIG3_CU_DROP_TRIP (0x3ffL<<0) 4241#define BNX2_RBUF_CONFIG3_CU_DROP_TRIP (0x3ffL<<0)
4242#define BNX2_RBUF_CONFIG3_CU_DROP_TRIP_VAL(mtu) \
4243 ((((mtu) - 1500) * 12 / 1000) + 18)
4228#define BNX2_RBUF_CONFIG3_CU_KEEP_TRIP (0x3ffL<<16) 4244#define BNX2_RBUF_CONFIG3_CU_KEEP_TRIP (0x3ffL<<16)
4245#define BNX2_RBUF_CONFIG3_CU_KEEP_TRIP_VAL(mtu) \
4246 ((((mtu) - 1500) * 2 / 100) + 30)
4247#define BNX2_RBUF_CONFIG3_VAL(mtu) \
4248 (BNX2_RBUF_CONFIG3_CU_DROP_TRIP_VAL(mtu) | \
4249 (BNX2_RBUF_CONFIG3_CU_KEEP_TRIP_VAL(mtu) << 16))
4229 4250
4230#define BNX2_RBUF_PKT_DATA 0x00208000 4251#define BNX2_RBUF_PKT_DATA 0x00208000
4231#define BNX2_RBUF_CLIST_DATA 0x00210000 4252#define BNX2_RBUF_CLIST_DATA 0x00210000
@@ -6658,8 +6679,6 @@ struct bnx2_napi {
6658 struct bnx2_tx_ring_info tx_ring; 6679 struct bnx2_tx_ring_info tx_ring;
6659}; 6680};
6660 6681
6661#define BNX2_TIMER_INTERVAL HZ
6662
6663struct bnx2 { 6682struct bnx2 {
6664 /* Fields used in the tx and intr/napi performance paths are grouped */ 6683 /* Fields used in the tx and intr/napi performance paths are grouped */
6665 /* together in the beginning of the structure. */ 6684 /* together in the beginning of the structure. */
@@ -6707,7 +6726,11 @@ struct bnx2 {
6707 6726
6708 /* End of fields used in the performance code paths. */ 6727 /* End of fields used in the performance code paths. */
6709 6728
6710 int current_interval; 6729 unsigned int current_interval;
6730#define BNX2_TIMER_INTERVAL HZ
6731#define BNX2_SERDES_AN_TIMEOUT (HZ / 3)
6732#define BNX2_SERDES_FORCED_TIMEOUT (HZ / 10)
6733
6711 struct timer_list timer; 6734 struct timer_list timer;
6712 struct work_struct reset_task; 6735 struct work_struct reset_task;
6713 6736
@@ -6839,8 +6862,6 @@ struct bnx2 {
6839#define PHY_LOOPBACK 2 6862#define PHY_LOOPBACK 2
6840 6863
6841 u8 serdes_an_pending; 6864 u8 serdes_an_pending;
6842#define SERDES_AN_TIMEOUT (HZ / 3)
6843#define SERDES_FORCED_TIMEOUT (HZ / 10)
6844 6865
6845 u8 mac_addr[8]; 6866 u8 mac_addr[8];
6846 6867
@@ -6938,14 +6959,14 @@ struct fw_info {
6938/* This value (in milliseconds) determines the frequency of the driver 6959/* This value (in milliseconds) determines the frequency of the driver
6939 * issuing the PULSE message code. The firmware monitors this periodic 6960 * issuing the PULSE message code. The firmware monitors this periodic
6940 * pulse to determine when to switch to an OS-absent mode. */ 6961 * pulse to determine when to switch to an OS-absent mode. */
6941#define DRV_PULSE_PERIOD_MS 250 6962#define BNX2_DRV_PULSE_PERIOD_MS 250
6942 6963
6943/* This value (in milliseconds) determines how long the driver should 6964/* This value (in milliseconds) determines how long the driver should
6944 * wait for an acknowledgement from the firmware before timing out. Once 6965 * wait for an acknowledgement from the firmware before timing out. Once
6945 * the firmware has timed out, the driver will assume there is no firmware 6966 * the firmware has timed out, the driver will assume there is no firmware
6946 * running and there won't be any firmware-driver synchronization during a 6967 * running and there won't be any firmware-driver synchronization during a
6947 * driver reset. */ 6968 * driver reset. */
6948#define FW_ACK_TIME_OUT_MS 1000 6969#define BNX2_FW_ACK_TIME_OUT_MS 1000
6949 6970
6950 6971
6951#define BNX2_DRV_RESET_SIGNATURE 0x00000000 6972#define BNX2_DRV_RESET_SIGNATURE 0x00000000
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 600210d7eff9..49f8e7891626 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -1328,7 +1328,6 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1328 dev_kfree_skb(skb); 1328 dev_kfree_skb(skb);
1329 } 1329 }
1330 1330
1331 bp->dev->last_rx = jiffies;
1332 1331
1333 /* put new skb in bin */ 1332 /* put new skb in bin */
1334 fp->tpa_pool[queue].skb = new_skb; 1333 fp->tpa_pool[queue].skb = new_skb;
@@ -1557,7 +1556,6 @@ reuse_rx:
1557#endif 1556#endif
1558 netif_receive_skb(skb); 1557 netif_receive_skb(skb);
1559 1558
1560 bp->dev->last_rx = jiffies;
1561 1559
1562next_rx: 1560next_rx:
1563 rx_buf->skb = NULL; 1561 rx_buf->skb = NULL;
@@ -8769,7 +8767,6 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode, u8 link_up)
8769 rc = 0; 8767 rc = 0;
8770 8768
8771test_loopback_rx_exit: 8769test_loopback_rx_exit:
8772 bp->dev->last_rx = jiffies;
8773 8770
8774 fp->rx_bd_cons = NEXT_RX_IDX(fp->rx_bd_cons); 8771 fp->rx_bd_cons = NEXT_RX_IDX(fp->rx_bd_cons);
8775 fp->rx_bd_prod = NEXT_RX_IDX(fp->rx_bd_prod); 8772 fp->rx_bd_prod = NEXT_RX_IDX(fp->rx_bd_prod);
@@ -9853,11 +9850,8 @@ static void bnx2x_set_rx_mode(struct net_device *dev)
9853 mclist && (i < dev->mc_count); 9850 mclist && (i < dev->mc_count);
9854 i++, mclist = mclist->next) { 9851 i++, mclist = mclist->next) {
9855 9852
9856 DP(NETIF_MSG_IFUP, "Adding mcast MAC: " 9853 DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
9857 "%02x:%02x:%02x:%02x:%02x:%02x\n", 9854 mclist->dmi_addr);
9858 mclist->dmi_addr[0], mclist->dmi_addr[1],
9859 mclist->dmi_addr[2], mclist->dmi_addr[3],
9860 mclist->dmi_addr[4], mclist->dmi_addr[5]);
9861 9855
9862 crc = crc32c_le(0, mclist->dmi_addr, ETH_ALEN); 9856 crc = crc32c_le(0, mclist->dmi_addr, ETH_ALEN);
9863 bit = (crc >> 24) & 0xff; 9857 bit = (crc >> 24) & 0xff;
@@ -10092,8 +10086,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10092 10086
10093 dev->irq = pdev->irq; 10087 dev->irq = pdev->irq;
10094 10088
10095 bp->regview = ioremap_nocache(dev->base_addr, 10089 bp->regview = pci_ioremap_bar(pdev, 0);
10096 pci_resource_len(pdev, 0));
10097 if (!bp->regview) { 10090 if (!bp->regview) {
10098 printk(KERN_ERR PFX "Cannot map register space, aborting\n"); 10091 printk(KERN_ERR PFX "Cannot map register space, aborting\n");
10099 rc = -ENOMEM; 10092 rc = -ENOMEM;
@@ -10194,7 +10187,6 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
10194 struct net_device *dev = NULL; 10187 struct net_device *dev = NULL;
10195 struct bnx2x *bp; 10188 struct bnx2x *bp;
10196 int rc; 10189 int rc;
10197 DECLARE_MAC_BUF(mac);
10198 10190
10199 if (version_printed++ == 0) 10191 if (version_printed++ == 0)
10200 printk(KERN_INFO "%s", version); 10192 printk(KERN_INFO "%s", version);
@@ -10238,7 +10230,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
10238 bnx2x_get_pcie_width(bp), 10230 bnx2x_get_pcie_width(bp),
10239 (bnx2x_get_pcie_speed(bp) == 2) ? "5GHz (Gen2)" : "2.5GHz", 10231 (bnx2x_get_pcie_speed(bp) == 2) ? "5GHz (Gen2)" : "2.5GHz",
10240 dev->base_addr, bp->pdev->irq); 10232 dev->base_addr, bp->pdev->irq);
10241 printk(KERN_CONT "node addr %s\n", print_mac(mac, dev->dev_addr)); 10233 printk(KERN_CONT "node addr %pM\n", dev->dev_addr);
10242 return 0; 10234 return 0;
10243 10235
10244init_one_exit: 10236init_one_exit:
diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile
index 5cdae2bc055a..6f9c6faef24c 100644
--- a/drivers/net/bonding/Makefile
+++ b/drivers/net/bonding/Makefile
@@ -6,3 +6,6 @@ obj-$(CONFIG_BONDING) += bonding.o
6 6
7bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o 7bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o
8 8
9ipv6-$(subst m,y,$(CONFIG_IPV6)) += bond_ipv6.o
10bonding-objs += $(ipv6-y)
11
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 6106660a4a44..78f645d6471a 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -27,6 +27,7 @@
27#include <linux/netdevice.h> 27#include <linux/netdevice.h>
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <linux/ethtool.h> 29#include <linux/ethtool.h>
30#include <linux/etherdevice.h>
30#include <linux/if_bonding.h> 31#include <linux/if_bonding.h>
31#include <linux/pkt_sched.h> 32#include <linux/pkt_sched.h>
32#include <net/net_namespace.h> 33#include <net/net_namespace.h>
@@ -236,6 +237,17 @@ static inline struct aggregator *__get_next_agg(struct aggregator *aggregator)
236 return &(SLAVE_AD_INFO(slave->next).aggregator); 237 return &(SLAVE_AD_INFO(slave->next).aggregator);
237} 238}
238 239
240/*
241 * __agg_has_partner
242 *
243 * Return nonzero if aggregator has a partner (denoted by a non-zero ether
244 * address for the partner). Return 0 if not.
245 */
246static inline int __agg_has_partner(struct aggregator *agg)
247{
248 return !is_zero_ether_addr(agg->partner_system.mac_addr_value);
249}
250
239/** 251/**
240 * __disable_port - disable the port's slave 252 * __disable_port - disable the port's slave
241 * @port: the port we're looking at 253 * @port: the port we're looking at
@@ -274,14 +286,14 @@ static inline int __port_is_enabled(struct port *port)
274 * __get_agg_selection_mode - get the aggregator selection mode 286 * __get_agg_selection_mode - get the aggregator selection mode
275 * @port: the port we're looking at 287 * @port: the port we're looking at
276 * 288 *
277 * Get the aggregator selection mode. Can be %BANDWIDTH or %COUNT. 289 * Get the aggregator selection mode. Can be %STABLE, %BANDWIDTH or %COUNT.
278 */ 290 */
279static inline u32 __get_agg_selection_mode(struct port *port) 291static inline u32 __get_agg_selection_mode(struct port *port)
280{ 292{
281 struct bonding *bond = __get_bond_by_port(port); 293 struct bonding *bond = __get_bond_by_port(port);
282 294
283 if (bond == NULL) { 295 if (bond == NULL) {
284 return AD_BANDWIDTH; 296 return BOND_AD_STABLE;
285 } 297 }
286 298
287 return BOND_AD_INFO(bond).agg_select_mode; 299 return BOND_AD_INFO(bond).agg_select_mode;
@@ -1414,9 +1426,82 @@ static void ad_port_selection_logic(struct port *port)
1414 // else set ready=FALSE in all aggregator's ports 1426 // else set ready=FALSE in all aggregator's ports
1415 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); 1427 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
1416 1428
1417 if (!__check_agg_selection_timer(port) && (aggregator = __get_first_agg(port))) { 1429 aggregator = __get_first_agg(port);
1418 ad_agg_selection_logic(aggregator); 1430 ad_agg_selection_logic(aggregator);
1431}
1432
1433/*
1434 * Decide if "agg" is a better choice for the new active aggregator that
1435 * the current best, according to the ad_select policy.
1436 */
1437static struct aggregator *ad_agg_selection_test(struct aggregator *best,
1438 struct aggregator *curr)
1439{
1440 /*
1441 * 0. If no best, select current.
1442 *
1443 * 1. If the current agg is not individual, and the best is
1444 * individual, select current.
1445 *
1446 * 2. If current agg is individual and the best is not, keep best.
1447 *
1448 * 3. Therefore, current and best are both individual or both not
1449 * individual, so:
1450 *
1451 * 3a. If current agg partner replied, and best agg partner did not,
1452 * select current.
1453 *
1454 * 3b. If current agg partner did not reply and best agg partner
1455 * did reply, keep best.
1456 *
1457 * 4. Therefore, current and best both have partner replies or
1458 * both do not, so perform selection policy:
1459 *
1460 * BOND_AD_COUNT: Select by count of ports. If count is equal,
1461 * select by bandwidth.
1462 *
1463 * BOND_AD_STABLE, BOND_AD_BANDWIDTH: Select by bandwidth.
1464 */
1465 if (!best)
1466 return curr;
1467
1468 if (!curr->is_individual && best->is_individual)
1469 return curr;
1470
1471 if (curr->is_individual && !best->is_individual)
1472 return best;
1473
1474 if (__agg_has_partner(curr) && !__agg_has_partner(best))
1475 return curr;
1476
1477 if (!__agg_has_partner(curr) && __agg_has_partner(best))
1478 return best;
1479
1480 switch (__get_agg_selection_mode(curr->lag_ports)) {
1481 case BOND_AD_COUNT:
1482 if (curr->num_of_ports > best->num_of_ports)
1483 return curr;
1484
1485 if (curr->num_of_ports < best->num_of_ports)
1486 return best;
1487
1488 /*FALLTHROUGH*/
1489 case BOND_AD_STABLE:
1490 case BOND_AD_BANDWIDTH:
1491 if (__get_agg_bandwidth(curr) > __get_agg_bandwidth(best))
1492 return curr;
1493
1494 break;
1495
1496 default:
1497 printk(KERN_WARNING DRV_NAME
1498 ": %s: Impossible agg select mode %d\n",
1499 curr->slave->dev->master->name,
1500 __get_agg_selection_mode(curr->lag_ports));
1501 break;
1419 } 1502 }
1503
1504 return best;
1420} 1505}
1421 1506
1422/** 1507/**
@@ -1424,156 +1509,138 @@ static void ad_port_selection_logic(struct port *port)
1424 * @aggregator: the aggregator we're looking at 1509 * @aggregator: the aggregator we're looking at
1425 * 1510 *
1426 * It is assumed that only one aggregator may be selected for a team. 1511 * It is assumed that only one aggregator may be selected for a team.
1427 * The logic of this function is to select (at first time) the aggregator with 1512 *
1428 * the most ports attached to it, and to reselect the active aggregator only if 1513 * The logic of this function is to select the aggregator according to
1429 * the previous aggregator has no more ports related to it. 1514 * the ad_select policy:
1515 *
1516 * BOND_AD_STABLE: select the aggregator with the most ports attached to
1517 * it, and to reselect the active aggregator only if the previous
1518 * aggregator has no more ports related to it.
1519 *
1520 * BOND_AD_BANDWIDTH: select the aggregator with the highest total
1521 * bandwidth, and reselect whenever a link state change takes place or the
1522 * set of slaves in the bond changes.
1523 *
1524 * BOND_AD_COUNT: select the aggregator with largest number of ports
1525 * (slaves), and reselect whenever a link state change takes place or the
1526 * set of slaves in the bond changes.
1430 * 1527 *
1431 * FIXME: this function MUST be called with the first agg in the bond, or 1528 * FIXME: this function MUST be called with the first agg in the bond, or
1432 * __get_active_agg() won't work correctly. This function should be better 1529 * __get_active_agg() won't work correctly. This function should be better
1433 * called with the bond itself, and retrieve the first agg from it. 1530 * called with the bond itself, and retrieve the first agg from it.
1434 */ 1531 */
1435static void ad_agg_selection_logic(struct aggregator *aggregator) 1532static void ad_agg_selection_logic(struct aggregator *agg)
1436{ 1533{
1437 struct aggregator *best_aggregator = NULL, *active_aggregator = NULL; 1534 struct aggregator *best, *active, *origin;
1438 struct aggregator *last_active_aggregator = NULL, *origin_aggregator;
1439 struct port *port; 1535 struct port *port;
1440 u16 num_of_aggs=0;
1441 1536
1442 origin_aggregator = aggregator; 1537 origin = agg;
1443 1538
1444 //get current active aggregator 1539 active = __get_active_agg(agg);
1445 last_active_aggregator = __get_active_agg(aggregator); 1540 best = active;
1446 1541
1447 // search for the aggregator with the most ports attached to it.
1448 do { 1542 do {
1449 // count how many candidate lag's we have 1543 agg->is_active = 0;
1450 if (aggregator->lag_ports) { 1544
1451 num_of_aggs++; 1545 if (agg->num_of_ports)
1452 } 1546 best = ad_agg_selection_test(best, agg);
1453 if (aggregator->is_active && !aggregator->is_individual && // if current aggregator is the active aggregator 1547
1454 MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(null_mac_addr))) { // and partner answers to 802.3ad PDUs 1548 } while ((agg = __get_next_agg(agg)));
1455 if (aggregator->num_of_ports) { // if any ports attached to the current aggregator 1549
1456 best_aggregator=NULL; // disregard the best aggregator that was chosen by now 1550 if (best &&
1457 break; // stop the selection of other aggregator if there are any ports attached to this active aggregator 1551 __get_agg_selection_mode(best->lag_ports) == BOND_AD_STABLE) {
1458 } else { // no ports attached to this active aggregator 1552 /*
1459 aggregator->is_active = 0; // mark this aggregator as not active anymore 1553 * For the STABLE policy, don't replace the old active
1554 * aggregator if it's still active (it has an answering
1555 * partner) or if both the best and active don't have an
1556 * answering partner.
1557 */
1558 if (active && active->lag_ports &&
1559 active->lag_ports->is_enabled &&
1560 (__agg_has_partner(active) ||
1561 (!__agg_has_partner(active) && !__agg_has_partner(best)))) {
1562 if (!(!active->actor_oper_aggregator_key &&
1563 best->actor_oper_aggregator_key)) {
1564 best = NULL;
1565 active->is_active = 1;
1460 } 1566 }
1461 } 1567 }
1462 if (aggregator->num_of_ports) { // if any ports attached 1568 }
1463 if (best_aggregator) { // if there is a candidte aggregator
1464 //The reasons for choosing new best aggregator:
1465 // 1. if current agg is NOT individual and the best agg chosen so far is individual OR
1466 // current and best aggs are both individual or both not individual, AND
1467 // 2a. current agg partner reply but best agg partner do not reply OR
1468 // 2b. current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply AND
1469 // current has more ports/bandwidth, or same amount of ports but current has faster ports, THEN
1470 // current agg become best agg so far
1471
1472 //if current agg is NOT individual and the best agg chosen so far is individual change best_aggregator
1473 if (!aggregator->is_individual && best_aggregator->is_individual) {
1474 best_aggregator=aggregator;
1475 }
1476 // current and best aggs are both individual or both not individual
1477 else if ((aggregator->is_individual && best_aggregator->is_individual) ||
1478 (!aggregator->is_individual && !best_aggregator->is_individual)) {
1479 // current and best aggs are both individual or both not individual AND
1480 // current agg partner reply but best agg partner do not reply
1481 if ((MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(null_mac_addr)) &&
1482 !MAC_ADDRESS_COMPARE(&(best_aggregator->partner_system), &(null_mac_addr)))) {
1483 best_aggregator=aggregator;
1484 }
1485 // current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply
1486 else if (! (!MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(null_mac_addr)) &&
1487 MAC_ADDRESS_COMPARE(&(best_aggregator->partner_system), &(null_mac_addr)))) {
1488 if ((__get_agg_selection_mode(aggregator->lag_ports) == AD_BANDWIDTH)&&
1489 (__get_agg_bandwidth(aggregator) > __get_agg_bandwidth(best_aggregator))) {
1490 best_aggregator=aggregator;
1491 } else if (__get_agg_selection_mode(aggregator->lag_ports) == AD_COUNT) {
1492 if (((aggregator->num_of_ports > best_aggregator->num_of_ports) &&
1493 (aggregator->actor_oper_aggregator_key & AD_SPEED_KEY_BITS))||
1494 ((aggregator->num_of_ports == best_aggregator->num_of_ports) &&
1495 ((u16)(aggregator->actor_oper_aggregator_key & AD_SPEED_KEY_BITS) >
1496 (u16)(best_aggregator->actor_oper_aggregator_key & AD_SPEED_KEY_BITS)))) {
1497 best_aggregator=aggregator;
1498 }
1499 }
1500 }
1501 }
1502 } else {
1503 best_aggregator=aggregator;
1504 }
1505 }
1506 aggregator->is_active = 0; // mark all aggregators as not active anymore
1507 } while ((aggregator = __get_next_agg(aggregator)));
1508
1509 // if we have new aggregator selected, don't replace the old aggregator if it has an answering partner,
1510 // or if both old aggregator and new aggregator don't have answering partner
1511 if (best_aggregator) {
1512 if (last_active_aggregator && last_active_aggregator->lag_ports && last_active_aggregator->lag_ports->is_enabled &&
1513 (MAC_ADDRESS_COMPARE(&(last_active_aggregator->partner_system), &(null_mac_addr)) || // partner answers OR
1514 (!MAC_ADDRESS_COMPARE(&(last_active_aggregator->partner_system), &(null_mac_addr)) && // both old and new
1515 !MAC_ADDRESS_COMPARE(&(best_aggregator->partner_system), &(null_mac_addr)))) // partner do not answer
1516 ) {
1517 // if new aggregator has link, and old aggregator does not, replace old aggregator.(do nothing)
1518 // -> don't replace otherwise.
1519 if (!(!last_active_aggregator->actor_oper_aggregator_key && best_aggregator->actor_oper_aggregator_key)) {
1520 best_aggregator=NULL;
1521 last_active_aggregator->is_active = 1; // don't replace good old aggregator
1522 1569
1523 } 1570 if (best && (best == active)) {
1524 } 1571 best = NULL;
1572 active->is_active = 1;
1525 } 1573 }
1526 1574
1527 // if there is new best aggregator, activate it 1575 // if there is new best aggregator, activate it
1528 if (best_aggregator) { 1576 if (best) {
1529 for (aggregator = __get_first_agg(best_aggregator->lag_ports); 1577 dprintk("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1530 aggregator; 1578 best->aggregator_identifier, best->num_of_ports,
1531 aggregator = __get_next_agg(aggregator)) { 1579 best->actor_oper_aggregator_key,
1532 1580 best->partner_oper_aggregator_key,
1533 dprintk("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d\n", 1581 best->is_individual, best->is_active);
1534 aggregator->aggregator_identifier, aggregator->num_of_ports, 1582 dprintk("best ports %p slave %p %s\n",
1535 aggregator->actor_oper_aggregator_key, aggregator->partner_oper_aggregator_key, 1583 best->lag_ports, best->slave,
1536 aggregator->is_individual, aggregator->is_active); 1584 best->slave ? best->slave->dev->name : "NULL");
1585
1586 for (agg = __get_first_agg(best->lag_ports); agg;
1587 agg = __get_next_agg(agg)) {
1588
1589 dprintk("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1590 agg->aggregator_identifier, agg->num_of_ports,
1591 agg->actor_oper_aggregator_key,
1592 agg->partner_oper_aggregator_key,
1593 agg->is_individual, agg->is_active);
1537 } 1594 }
1538 1595
1539 // check if any partner replys 1596 // check if any partner replys
1540 if (best_aggregator->is_individual) { 1597 if (best->is_individual) {
1541 printk(KERN_WARNING DRV_NAME ": %s: Warning: No 802.3ad response from " 1598 printk(KERN_WARNING DRV_NAME ": %s: Warning: No 802.3ad"
1542 "the link partner for any adapters in the bond\n", 1599 " response from the link partner for any"
1543 best_aggregator->slave->dev->master->name); 1600 " adapters in the bond\n",
1544 } 1601 best->slave->dev->master->name);
1545
1546 // check if there are more than one aggregator
1547 if (num_of_aggs > 1) {
1548 dprintk("Warning: More than one Link Aggregation Group was "
1549 "found in the bond. Only one group will function in the bond\n");
1550 } 1602 }
1551 1603
1552 best_aggregator->is_active = 1; 1604 best->is_active = 1;
1553 dprintk("LAG %d choosed as the active LAG\n", best_aggregator->aggregator_identifier); 1605 dprintk("LAG %d chosen as the active LAG\n",
1554 dprintk("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d\n", 1606 best->aggregator_identifier);
1555 best_aggregator->aggregator_identifier, best_aggregator->num_of_ports, 1607 dprintk("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1556 best_aggregator->actor_oper_aggregator_key, best_aggregator->partner_oper_aggregator_key, 1608 best->aggregator_identifier, best->num_of_ports,
1557 best_aggregator->is_individual, best_aggregator->is_active); 1609 best->actor_oper_aggregator_key,
1610 best->partner_oper_aggregator_key,
1611 best->is_individual, best->is_active);
1558 1612
1559 // disable the ports that were related to the former active_aggregator 1613 // disable the ports that were related to the former active_aggregator
1560 if (last_active_aggregator) { 1614 if (active) {
1561 for (port=last_active_aggregator->lag_ports; port; port=port->next_port_in_aggregator) { 1615 for (port = active->lag_ports; port;
1616 port = port->next_port_in_aggregator) {
1562 __disable_port(port); 1617 __disable_port(port);
1563 } 1618 }
1564 } 1619 }
1565 } 1620 }
1566 1621
1567 // if the selected aggregator is of join individuals(partner_system is NULL), enable their ports 1622 /*
1568 active_aggregator = __get_active_agg(origin_aggregator); 1623 * if the selected aggregator is of join individuals
1624 * (partner_system is NULL), enable their ports
1625 */
1626 active = __get_active_agg(origin);
1569 1627
1570 if (active_aggregator) { 1628 if (active) {
1571 if (!MAC_ADDRESS_COMPARE(&(active_aggregator->partner_system), &(null_mac_addr))) { 1629 if (!__agg_has_partner(active)) {
1572 for (port=active_aggregator->lag_ports; port; port=port->next_port_in_aggregator) { 1630 for (port = active->lag_ports; port;
1631 port = port->next_port_in_aggregator) {
1573 __enable_port(port); 1632 __enable_port(port);
1574 } 1633 }
1575 } 1634 }
1576 } 1635 }
1636
1637 if (origin->slave) {
1638 struct bonding *bond;
1639
1640 bond = bond_get_bond_by_slave(origin->slave);
1641 if (bond)
1642 bond_3ad_set_carrier(bond);
1643 }
1577} 1644}
1578 1645
1579/** 1646/**
@@ -1830,6 +1897,19 @@ static void ad_initialize_lacpdu(struct lacpdu *lacpdu)
1830// Check aggregators status in team every T seconds 1897// Check aggregators status in team every T seconds
1831#define AD_AGGREGATOR_SELECTION_TIMER 8 1898#define AD_AGGREGATOR_SELECTION_TIMER 8
1832 1899
1900/*
1901 * bond_3ad_initiate_agg_selection(struct bonding *bond)
1902 *
1903 * Set the aggregation selection timer, to initiate an agg selection in
1904 * the very near future. Called during first initialization, and during
1905 * any down to up transitions of the bond.
1906 */
1907void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout)
1908{
1909 BOND_AD_INFO(bond).agg_select_timer = timeout;
1910 BOND_AD_INFO(bond).agg_select_mode = bond->params.ad_select;
1911}
1912
1833static u16 aggregator_identifier; 1913static u16 aggregator_identifier;
1834 1914
1835/** 1915/**
@@ -1854,9 +1934,9 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fas
1854 // initialize how many times this module is called in one second(should be about every 100ms) 1934 // initialize how many times this module is called in one second(should be about every 100ms)
1855 ad_ticks_per_sec = tick_resolution; 1935 ad_ticks_per_sec = tick_resolution;
1856 1936
1857 // initialize the aggregator selection timer(to activate an aggregation selection after initialize) 1937 bond_3ad_initiate_agg_selection(bond,
1858 BOND_AD_INFO(bond).agg_select_timer = (AD_AGGREGATOR_SELECTION_TIMER * ad_ticks_per_sec); 1938 AD_AGGREGATOR_SELECTION_TIMER *
1859 BOND_AD_INFO(bond).agg_select_mode = AD_BANDWIDTH; 1939 ad_ticks_per_sec);
1860 } 1940 }
1861} 1941}
1862 1942
@@ -2346,7 +2426,7 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
2346int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) 2426int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2347{ 2427{
2348 struct slave *slave, *start_at; 2428 struct slave *slave, *start_at;
2349 struct bonding *bond = dev->priv; 2429 struct bonding *bond = netdev_priv(dev);
2350 int slave_agg_no; 2430 int slave_agg_no;
2351 int slaves_in_agg; 2431 int slaves_in_agg;
2352 int agg_id; 2432 int agg_id;
@@ -2426,7 +2506,7 @@ out:
2426 2506
2427int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev) 2507int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev)
2428{ 2508{
2429 struct bonding *bond = dev->priv; 2509 struct bonding *bond = netdev_priv(dev);
2430 struct slave *slave = NULL; 2510 struct slave *slave = NULL;
2431 int ret = NET_RX_DROP; 2511 int ret = NET_RX_DROP;
2432 2512
@@ -2437,7 +2517,8 @@ int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct pac
2437 goto out; 2517 goto out;
2438 2518
2439 read_lock(&bond->lock); 2519 read_lock(&bond->lock);
2440 slave = bond_get_slave_by_dev((struct bonding *)dev->priv, orig_dev); 2520 slave = bond_get_slave_by_dev((struct bonding *)netdev_priv(dev),
2521 orig_dev);
2441 if (!slave) 2522 if (!slave)
2442 goto out_unlock; 2523 goto out_unlock;
2443 2524
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index b5ee45f6d55a..a803fe05f63e 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -42,10 +42,11 @@ typedef struct mac_addr {
42 u8 mac_addr_value[ETH_ALEN]; 42 u8 mac_addr_value[ETH_ALEN];
43} mac_addr_t; 43} mac_addr_t;
44 44
45typedef enum { 45enum {
46 AD_BANDWIDTH = 0, 46 BOND_AD_STABLE = 0,
47 AD_COUNT 47 BOND_AD_BANDWIDTH = 1,
48} agg_selection_t; 48 BOND_AD_COUNT = 2,
49};
49 50
50// rx machine states(43.4.11 in the 802.3ad standard) 51// rx machine states(43.4.11 in the 802.3ad standard)
51typedef enum { 52typedef enum {
@@ -277,6 +278,7 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fas
277int bond_3ad_bind_slave(struct slave *slave); 278int bond_3ad_bind_slave(struct slave *slave);
278void bond_3ad_unbind_slave(struct slave *slave); 279void bond_3ad_unbind_slave(struct slave *slave);
279void bond_3ad_state_machine_handler(struct work_struct *); 280void bond_3ad_state_machine_handler(struct work_struct *);
281void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout);
280void bond_3ad_adapter_speed_changed(struct slave *slave); 282void bond_3ad_adapter_speed_changed(struct slave *slave);
281void bond_3ad_adapter_duplex_changed(struct slave *slave); 283void bond_3ad_adapter_duplex_changed(struct slave *slave);
282void bond_3ad_handle_link_change(struct slave *slave, char link); 284void bond_3ad_handle_link_change(struct slave *slave, char link);
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 87437c788476..073d25f357bb 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -346,14 +346,18 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
346 346
347static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev) 347static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev)
348{ 348{
349 struct bonding *bond = bond_dev->priv; 349 struct bonding *bond;
350 struct arp_pkt *arp = (struct arp_pkt *)skb->data; 350 struct arp_pkt *arp = (struct arp_pkt *)skb->data;
351 int res = NET_RX_DROP; 351 int res = NET_RX_DROP;
352 352
353 if (dev_net(bond_dev) != &init_net) 353 if (dev_net(bond_dev) != &init_net)
354 goto out; 354 goto out;
355 355
356 if (!(bond_dev->flags & IFF_MASTER)) 356 while (bond_dev->priv_flags & IFF_802_1Q_VLAN)
357 bond_dev = vlan_dev_real_dev(bond_dev);
358
359 if (!(bond_dev->priv_flags & IFF_BONDING) ||
360 !(bond_dev->flags & IFF_MASTER))
357 goto out; 361 goto out;
358 362
359 if (!arp) { 363 if (!arp) {
@@ -368,6 +372,9 @@ static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct
368 372
369 if (arp->op_code == htons(ARPOP_REPLY)) { 373 if (arp->op_code == htons(ARPOP_REPLY)) {
370 /* update rx hash table for this ARP */ 374 /* update rx hash table for this ARP */
375 printk("rar: update orig %s bond_dev %s\n", orig_dev->name,
376 bond_dev->name);
377 bond = netdev_priv(bond_dev);
371 rlb_update_entry_from_arp(bond, arp); 378 rlb_update_entry_from_arp(bond, arp);
372 dprintk("Server received an ARP Reply from client\n"); 379 dprintk("Server received an ARP Reply from client\n");
373 } 380 }
@@ -818,7 +825,7 @@ static int rlb_initialize(struct bonding *bond)
818 825
819 /*initialize packet type*/ 826 /*initialize packet type*/
820 pk_type->type = __constant_htons(ETH_P_ARP); 827 pk_type->type = __constant_htons(ETH_P_ARP);
821 pk_type->dev = bond->dev; 828 pk_type->dev = NULL;
822 pk_type->func = rlb_arp_recv; 829 pk_type->func = rlb_arp_recv;
823 830
824 /* register to receive ARPs */ 831 /* register to receive ARPs */
@@ -1285,7 +1292,7 @@ void bond_alb_deinitialize(struct bonding *bond)
1285 1292
1286int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) 1293int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1287{ 1294{
1288 struct bonding *bond = bond_dev->priv; 1295 struct bonding *bond = netdev_priv(bond_dev);
1289 struct ethhdr *eth_data; 1296 struct ethhdr *eth_data;
1290 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 1297 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1291 struct slave *tx_slave = NULL; 1298 struct slave *tx_slave = NULL;
@@ -1706,7 +1713,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
1706 */ 1713 */
1707int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) 1714int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1708{ 1715{
1709 struct bonding *bond = bond_dev->priv; 1716 struct bonding *bond = netdev_priv(bond_dev);
1710 struct sockaddr *sa = addr; 1717 struct sockaddr *sa = addr;
1711 struct slave *slave, *swap_slave; 1718 struct slave *slave, *swap_slave;
1712 int res; 1719 int res;
diff --git a/drivers/net/bonding/bond_ipv6.c b/drivers/net/bonding/bond_ipv6.c
new file mode 100644
index 000000000000..7c78b7bf671c
--- /dev/null
+++ b/drivers/net/bonding/bond_ipv6.c
@@ -0,0 +1,218 @@
1/*
2 * Copyright(c) 2008 Hewlett-Packard Development Company, L.P.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 */
22
23//#define BONDING_DEBUG 1
24
25#include <linux/types.h>
26#include <linux/if_vlan.h>
27#include <net/ipv6.h>
28#include <net/ndisc.h>
29#include <net/addrconf.h>
30#include "bonding.h"
31
32/*
33 * Assign bond->master_ipv6 to the next IPv6 address in the list, or
34 * zero it out if there are none.
35 */
36static void bond_glean_dev_ipv6(struct net_device *dev, struct in6_addr *addr)
37{
38 struct inet6_dev *idev;
39 struct inet6_ifaddr *ifa;
40
41 if (!dev)
42 return;
43
44 idev = in6_dev_get(dev);
45 if (!idev)
46 return;
47
48 read_lock_bh(&idev->lock);
49 ifa = idev->addr_list;
50 if (ifa)
51 ipv6_addr_copy(addr, &ifa->addr);
52 else
53 ipv6_addr_set(addr, 0, 0, 0, 0);
54
55 read_unlock_bh(&idev->lock);
56
57 in6_dev_put(idev);
58}
59
60static void bond_na_send(struct net_device *slave_dev,
61 struct in6_addr *daddr,
62 int router,
63 unsigned short vlan_id)
64{
65 struct in6_addr mcaddr;
66 struct icmp6hdr icmp6h = {
67 .icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT,
68 };
69 struct sk_buff *skb;
70
71 icmp6h.icmp6_router = router;
72 icmp6h.icmp6_solicited = 0;
73 icmp6h.icmp6_override = 1;
74
75 addrconf_addr_solict_mult(daddr, &mcaddr);
76
77 dprintk("ipv6 na on slave %s: dest %pI6, src %pI6\n",
78 slave->name, &mcaddr, daddr);
79
80 skb = ndisc_build_skb(slave_dev, &mcaddr, daddr, &icmp6h, daddr,
81 ND_OPT_TARGET_LL_ADDR);
82
83 if (!skb) {
84 printk(KERN_ERR DRV_NAME ": NA packet allocation failed\n");
85 return;
86 }
87
88 if (vlan_id) {
89 skb = vlan_put_tag(skb, vlan_id);
90 if (!skb) {
91 printk(KERN_ERR DRV_NAME ": failed to insert VLAN tag\n");
92 return;
93 }
94 }
95
96 ndisc_send_skb(skb, slave_dev, NULL, &mcaddr, daddr, &icmp6h);
97}
98
99/*
100 * Kick out an unsolicited Neighbor Advertisement for an IPv6 address on
101 * the bonding master. This will help the switch learn our address
102 * if in active-backup mode.
103 *
104 * Caller must hold curr_slave_lock for read or better
105 */
106void bond_send_unsolicited_na(struct bonding *bond)
107{
108 struct slave *slave = bond->curr_active_slave;
109 struct vlan_entry *vlan;
110 struct inet6_dev *idev;
111 int is_router;
112
113 dprintk("bond_send_unsol_na: bond %s slave %s\n", bond->dev->name,
114 slave ? slave->dev->name : "NULL");
115
116 if (!slave || !bond->send_unsol_na ||
117 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))
118 return;
119
120 bond->send_unsol_na--;
121
122 idev = in6_dev_get(bond->dev);
123 if (!idev)
124 return;
125
126 is_router = !!idev->cnf.forwarding;
127
128 in6_dev_put(idev);
129
130 if (!ipv6_addr_any(&bond->master_ipv6))
131 bond_na_send(slave->dev, &bond->master_ipv6, is_router, 0);
132
133 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
134 if (!ipv6_addr_any(&vlan->vlan_ipv6)) {
135 bond_na_send(slave->dev, &vlan->vlan_ipv6, is_router,
136 vlan->vlan_id);
137 }
138 }
139}
140
141/*
142 * bond_inet6addr_event: handle inet6addr notifier chain events.
143 *
144 * We keep track of device IPv6 addresses primarily to use as source
145 * addresses in NS probes.
146 *
147 * We track one IPv6 for the main device (if it has one).
148 */
149static int bond_inet6addr_event(struct notifier_block *this,
150 unsigned long event,
151 void *ptr)
152{
153 struct inet6_ifaddr *ifa = ptr;
154 struct net_device *vlan_dev, *event_dev = ifa->idev->dev;
155 struct bonding *bond;
156 struct vlan_entry *vlan;
157
158 if (dev_net(event_dev) != &init_net)
159 return NOTIFY_DONE;
160
161 list_for_each_entry(bond, &bond_dev_list, bond_list) {
162 if (bond->dev == event_dev) {
163 switch (event) {
164 case NETDEV_UP:
165 if (ipv6_addr_any(&bond->master_ipv6))
166 ipv6_addr_copy(&bond->master_ipv6,
167 &ifa->addr);
168 return NOTIFY_OK;
169 case NETDEV_DOWN:
170 if (ipv6_addr_equal(&bond->master_ipv6,
171 &ifa->addr))
172 bond_glean_dev_ipv6(bond->dev,
173 &bond->master_ipv6);
174 return NOTIFY_OK;
175 default:
176 return NOTIFY_DONE;
177 }
178 }
179
180 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
181 vlan_dev = vlan_group_get_device(bond->vlgrp,
182 vlan->vlan_id);
183 if (vlan_dev == event_dev) {
184 switch (event) {
185 case NETDEV_UP:
186 if (ipv6_addr_any(&vlan->vlan_ipv6))
187 ipv6_addr_copy(&vlan->vlan_ipv6,
188 &ifa->addr);
189 return NOTIFY_OK;
190 case NETDEV_DOWN:
191 if (ipv6_addr_equal(&vlan->vlan_ipv6,
192 &ifa->addr))
193 bond_glean_dev_ipv6(vlan_dev,
194 &vlan->vlan_ipv6);
195 return NOTIFY_OK;
196 default:
197 return NOTIFY_DONE;
198 }
199 }
200 }
201 }
202 return NOTIFY_DONE;
203}
204
205static struct notifier_block bond_inet6addr_notifier = {
206 .notifier_call = bond_inet6addr_event,
207};
208
209void bond_register_ipv6_notifier(void)
210{
211 register_inet6addr_notifier(&bond_inet6addr_notifier);
212}
213
214void bond_unregister_ipv6_notifier(void)
215{
216 unregister_inet6addr_notifier(&bond_inet6addr_notifier);
217}
218
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a3efba59eee9..a08ea4808056 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -89,6 +89,7 @@
89 89
90static int max_bonds = BOND_DEFAULT_MAX_BONDS; 90static int max_bonds = BOND_DEFAULT_MAX_BONDS;
91static int num_grat_arp = 1; 91static int num_grat_arp = 1;
92static int num_unsol_na = 1;
92static int miimon = BOND_LINK_MON_INTERV; 93static int miimon = BOND_LINK_MON_INTERV;
93static int updelay = 0; 94static int updelay = 0;
94static int downdelay = 0; 95static int downdelay = 0;
@@ -96,6 +97,7 @@ static int use_carrier = 1;
96static char *mode = NULL; 97static char *mode = NULL;
97static char *primary = NULL; 98static char *primary = NULL;
98static char *lacp_rate = NULL; 99static char *lacp_rate = NULL;
100static char *ad_select = NULL;
99static char *xmit_hash_policy = NULL; 101static char *xmit_hash_policy = NULL;
100static int arp_interval = BOND_LINK_ARP_INTERV; 102static int arp_interval = BOND_LINK_ARP_INTERV;
101static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; 103static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, };
@@ -107,6 +109,8 @@ module_param(max_bonds, int, 0);
107MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); 109MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
108module_param(num_grat_arp, int, 0644); 110module_param(num_grat_arp, int, 0644);
109MODULE_PARM_DESC(num_grat_arp, "Number of gratuitous ARP packets to send on failover event"); 111MODULE_PARM_DESC(num_grat_arp, "Number of gratuitous ARP packets to send on failover event");
112module_param(num_unsol_na, int, 0644);
113MODULE_PARM_DESC(num_unsol_na, "Number of unsolicited IPv6 Neighbor Advertisements packets to send on failover event");
110module_param(miimon, int, 0); 114module_param(miimon, int, 0);
111MODULE_PARM_DESC(miimon, "Link check interval in milliseconds"); 115MODULE_PARM_DESC(miimon, "Link check interval in milliseconds");
112module_param(updelay, int, 0); 116module_param(updelay, int, 0);
@@ -127,6 +131,8 @@ MODULE_PARM_DESC(primary, "Primary network device to use");
127module_param(lacp_rate, charp, 0); 131module_param(lacp_rate, charp, 0);
128MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner " 132MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner "
129 "(slow/fast)"); 133 "(slow/fast)");
134module_param(ad_select, charp, 0);
135MODULE_PARM_DESC(ad_select, "803.ad aggregation selection logic: stable (0, default), bandwidth (1), count (2)");
130module_param(xmit_hash_policy, charp, 0); 136module_param(xmit_hash_policy, charp, 0);
131MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method: 0 for layer 2 (default)" 137MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method: 0 for layer 2 (default)"
132 ", 1 for layer 3+4"); 138 ", 1 for layer 3+4");
@@ -197,6 +203,13 @@ struct bond_parm_tbl fail_over_mac_tbl[] = {
197{ NULL, -1}, 203{ NULL, -1},
198}; 204};
199 205
206struct bond_parm_tbl ad_select_tbl[] = {
207{ "stable", BOND_AD_STABLE},
208{ "bandwidth", BOND_AD_BANDWIDTH},
209{ "count", BOND_AD_COUNT},
210{ NULL, -1},
211};
212
200/*-------------------------- Forward declarations ---------------------------*/ 213/*-------------------------- Forward declarations ---------------------------*/
201 214
202static void bond_send_gratuitous_arp(struct bonding *bond); 215static void bond_send_gratuitous_arp(struct bonding *bond);
@@ -242,14 +255,13 @@ static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
242 dprintk("bond: %s, vlan id %d\n", 255 dprintk("bond: %s, vlan id %d\n",
243 (bond ? bond->dev->name: "None"), vlan_id); 256 (bond ? bond->dev->name: "None"), vlan_id);
244 257
245 vlan = kmalloc(sizeof(struct vlan_entry), GFP_KERNEL); 258 vlan = kzalloc(sizeof(struct vlan_entry), GFP_KERNEL);
246 if (!vlan) { 259 if (!vlan) {
247 return -ENOMEM; 260 return -ENOMEM;
248 } 261 }
249 262
250 INIT_LIST_HEAD(&vlan->vlan_list); 263 INIT_LIST_HEAD(&vlan->vlan_list);
251 vlan->vlan_id = vlan_id; 264 vlan->vlan_id = vlan_id;
252 vlan->vlan_ip = 0;
253 265
254 write_lock_bh(&bond->lock); 266 write_lock_bh(&bond->lock);
255 267
@@ -442,7 +454,7 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_de
442 */ 454 */
443static void bond_vlan_rx_register(struct net_device *bond_dev, struct vlan_group *grp) 455static void bond_vlan_rx_register(struct net_device *bond_dev, struct vlan_group *grp)
444{ 456{
445 struct bonding *bond = bond_dev->priv; 457 struct bonding *bond = netdev_priv(bond_dev);
446 struct slave *slave; 458 struct slave *slave;
447 int i; 459 int i;
448 460
@@ -465,7 +477,7 @@ static void bond_vlan_rx_register(struct net_device *bond_dev, struct vlan_group
465 */ 477 */
466static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid) 478static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
467{ 479{
468 struct bonding *bond = bond_dev->priv; 480 struct bonding *bond = netdev_priv(bond_dev);
469 struct slave *slave; 481 struct slave *slave;
470 int i, res; 482 int i, res;
471 483
@@ -493,7 +505,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
493 */ 505 */
494static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid) 506static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
495{ 507{
496 struct bonding *bond = bond_dev->priv; 508 struct bonding *bond = netdev_priv(bond_dev);
497 struct slave *slave; 509 struct slave *slave;
498 struct net_device *vlan_dev; 510 struct net_device *vlan_dev;
499 int i, res; 511 int i, res;
@@ -927,7 +939,7 @@ static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond,
927 */ 939 */
928static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device *slave_dev) 940static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device *slave_dev)
929{ 941{
930 struct bonding *bond = bond_dev->priv; 942 struct bonding *bond = netdev_priv(bond_dev);
931 struct dev_mc_list *dmi; 943 struct dev_mc_list *dmi;
932 944
933 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) { 945 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) {
@@ -1208,6 +1220,9 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1208 bond->send_grat_arp = bond->params.num_grat_arp; 1220 bond->send_grat_arp = bond->params.num_grat_arp;
1209 bond_send_gratuitous_arp(bond); 1221 bond_send_gratuitous_arp(bond);
1210 1222
1223 bond->send_unsol_na = bond->params.num_unsol_na;
1224 bond_send_unsolicited_na(bond);
1225
1211 write_unlock_bh(&bond->curr_slave_lock); 1226 write_unlock_bh(&bond->curr_slave_lock);
1212 read_unlock(&bond->lock); 1227 read_unlock(&bond->lock);
1213 1228
@@ -1368,7 +1383,7 @@ done:
1368static void bond_setup_by_slave(struct net_device *bond_dev, 1383static void bond_setup_by_slave(struct net_device *bond_dev,
1369 struct net_device *slave_dev) 1384 struct net_device *slave_dev)
1370{ 1385{
1371 struct bonding *bond = bond_dev->priv; 1386 struct bonding *bond = netdev_priv(bond_dev);
1372 1387
1373 bond_dev->neigh_setup = slave_dev->neigh_setup; 1388 bond_dev->neigh_setup = slave_dev->neigh_setup;
1374 bond_dev->header_ops = slave_dev->header_ops; 1389 bond_dev->header_ops = slave_dev->header_ops;
@@ -1385,7 +1400,7 @@ static void bond_setup_by_slave(struct net_device *bond_dev,
1385/* enslave device <slave> to bond device <master> */ 1400/* enslave device <slave> to bond device <master> */
1386int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) 1401int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1387{ 1402{
1388 struct bonding *bond = bond_dev->priv; 1403 struct bonding *bond = netdev_priv(bond_dev);
1389 struct slave *new_slave = NULL; 1404 struct slave *new_slave = NULL;
1390 struct dev_mc_list *dmi; 1405 struct dev_mc_list *dmi;
1391 struct sockaddr addr; 1406 struct sockaddr addr;
@@ -1787,11 +1802,10 @@ err_undo_flags:
1787 */ 1802 */
1788int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) 1803int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1789{ 1804{
1790 struct bonding *bond = bond_dev->priv; 1805 struct bonding *bond = netdev_priv(bond_dev);
1791 struct slave *slave, *oldcurrent; 1806 struct slave *slave, *oldcurrent;
1792 struct sockaddr addr; 1807 struct sockaddr addr;
1793 int mac_addr_differ; 1808 int mac_addr_differ;
1794 DECLARE_MAC_BUF(mac);
1795 1809
1796 /* slave is not a slave or master is not master of this slave */ 1810 /* slave is not a slave or master is not master of this slave */
1797 if (!(slave_dev->flags & IFF_SLAVE) || 1811 if (!(slave_dev->flags & IFF_SLAVE) ||
@@ -1820,11 +1834,11 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1820 if (!mac_addr_differ && (bond->slave_cnt > 1)) 1834 if (!mac_addr_differ && (bond->slave_cnt > 1))
1821 printk(KERN_WARNING DRV_NAME 1835 printk(KERN_WARNING DRV_NAME
1822 ": %s: Warning: the permanent HWaddr of %s - " 1836 ": %s: Warning: the permanent HWaddr of %s - "
1823 "%s - is still in use by %s. " 1837 "%pM - is still in use by %s. "
1824 "Set the HWaddr of %s to a different address " 1838 "Set the HWaddr of %s to a different address "
1825 "to avoid conflicts.\n", 1839 "to avoid conflicts.\n",
1826 bond_dev->name, slave_dev->name, 1840 bond_dev->name, slave_dev->name,
1827 print_mac(mac, slave->perm_hwaddr), 1841 slave->perm_hwaddr,
1828 bond_dev->name, slave_dev->name); 1842 bond_dev->name, slave_dev->name);
1829 } 1843 }
1830 1844
@@ -1999,7 +2013,7 @@ static void bond_destructor(struct net_device *bond_dev)
1999*/ 2013*/
2000int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev) 2014int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev)
2001{ 2015{
2002 struct bonding *bond = bond_dev->priv; 2016 struct bonding *bond = netdev_priv(bond_dev);
2003 int ret; 2017 int ret;
2004 2018
2005 ret = bond_release(bond_dev, slave_dev); 2019 ret = bond_release(bond_dev, slave_dev);
@@ -2016,7 +2030,7 @@ int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *sl
2016 */ 2030 */
2017static int bond_release_all(struct net_device *bond_dev) 2031static int bond_release_all(struct net_device *bond_dev)
2018{ 2032{
2019 struct bonding *bond = bond_dev->priv; 2033 struct bonding *bond = netdev_priv(bond_dev);
2020 struct slave *slave; 2034 struct slave *slave;
2021 struct net_device *slave_dev; 2035 struct net_device *slave_dev;
2022 struct sockaddr addr; 2036 struct sockaddr addr;
@@ -2147,7 +2161,7 @@ out:
2147 */ 2161 */
2148static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_device *slave_dev) 2162static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_device *slave_dev)
2149{ 2163{
2150 struct bonding *bond = bond_dev->priv; 2164 struct bonding *bond = netdev_priv(bond_dev);
2151 struct slave *old_active = NULL; 2165 struct slave *old_active = NULL;
2152 struct slave *new_active = NULL; 2166 struct slave *new_active = NULL;
2153 int res = 0; 2167 int res = 0;
@@ -2196,7 +2210,7 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
2196 2210
2197static int bond_info_query(struct net_device *bond_dev, struct ifbond *info) 2211static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
2198{ 2212{
2199 struct bonding *bond = bond_dev->priv; 2213 struct bonding *bond = netdev_priv(bond_dev);
2200 2214
2201 info->bond_mode = bond->params.mode; 2215 info->bond_mode = bond->params.mode;
2202 info->miimon = bond->params.miimon; 2216 info->miimon = bond->params.miimon;
@@ -2210,7 +2224,7 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
2210 2224
2211static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *info) 2225static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *info)
2212{ 2226{
2213 struct bonding *bond = bond_dev->priv; 2227 struct bonding *bond = netdev_priv(bond_dev);
2214 struct slave *slave; 2228 struct slave *slave;
2215 int i, found = 0; 2229 int i, found = 0;
2216 2230
@@ -2464,6 +2478,12 @@ void bond_mii_monitor(struct work_struct *work)
2464 read_unlock(&bond->curr_slave_lock); 2478 read_unlock(&bond->curr_slave_lock);
2465 } 2479 }
2466 2480
2481 if (bond->send_unsol_na) {
2482 read_lock(&bond->curr_slave_lock);
2483 bond_send_unsolicited_na(bond);
2484 read_unlock(&bond->curr_slave_lock);
2485 }
2486
2467 if (bond_miimon_inspect(bond)) { 2487 if (bond_miimon_inspect(bond)) {
2468 read_unlock(&bond->lock); 2488 read_unlock(&bond->lock);
2469 rtnl_lock(); 2489 rtnl_lock();
@@ -2586,8 +2606,8 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2586 if (rv) { 2606 if (rv) {
2587 if (net_ratelimit()) { 2607 if (net_ratelimit()) {
2588 printk(KERN_WARNING DRV_NAME 2608 printk(KERN_WARNING DRV_NAME
2589 ": %s: no route to arp_ip_target %u.%u.%u.%u\n", 2609 ": %s: no route to arp_ip_target %pI4\n",
2590 bond->dev->name, NIPQUAD(fl.fl4_dst)); 2610 bond->dev->name, &fl.fl4_dst);
2591 } 2611 }
2592 continue; 2612 continue;
2593 } 2613 }
@@ -2623,8 +2643,8 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2623 2643
2624 if (net_ratelimit()) { 2644 if (net_ratelimit()) {
2625 printk(KERN_WARNING DRV_NAME 2645 printk(KERN_WARNING DRV_NAME
2626 ": %s: no path to arp_ip_target %u.%u.%u.%u via rt.dev %s\n", 2646 ": %s: no path to arp_ip_target %pI4 via rt.dev %s\n",
2627 bond->dev->name, NIPQUAD(fl.fl4_dst), 2647 bond->dev->name, &fl.fl4_dst,
2628 rt->u.dst.dev ? rt->u.dst.dev->name : "NULL"); 2648 rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
2629 } 2649 }
2630 ip_rt_put(rt); 2650 ip_rt_put(rt);
@@ -2673,10 +2693,8 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32
2673 2693
2674 targets = bond->params.arp_targets; 2694 targets = bond->params.arp_targets;
2675 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) { 2695 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
2676 dprintk("bva: sip %u.%u.%u.%u tip %u.%u.%u.%u t[%d] " 2696 dprintk("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n",
2677 "%u.%u.%u.%u bhti(tip) %d\n", 2697 &sip, &tip, i, &targets[i], bond_has_this_ip(bond, tip));
2678 NIPQUAD(sip), NIPQUAD(tip), i, NIPQUAD(targets[i]),
2679 bond_has_this_ip(bond, tip));
2680 if (sip == targets[i]) { 2698 if (sip == targets[i]) {
2681 if (bond_has_this_ip(bond, tip)) 2699 if (bond_has_this_ip(bond, tip))
2682 slave->last_arp_rx = jiffies; 2700 slave->last_arp_rx = jiffies;
@@ -2699,7 +2717,7 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
2699 if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER)) 2717 if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER))
2700 goto out; 2718 goto out;
2701 2719
2702 bond = dev->priv; 2720 bond = netdev_priv(dev);
2703 read_lock(&bond->lock); 2721 read_lock(&bond->lock);
2704 2722
2705 dprintk("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n", 2723 dprintk("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n",
@@ -2728,10 +2746,10 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
2728 arp_ptr += 4 + dev->addr_len; 2746 arp_ptr += 4 + dev->addr_len;
2729 memcpy(&tip, arp_ptr, 4); 2747 memcpy(&tip, arp_ptr, 4);
2730 2748
2731 dprintk("bond_arp_rcv: %s %s/%d av %d sv %d sip %u.%u.%u.%u" 2749 dprintk("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n",
2732 " tip %u.%u.%u.%u\n", bond->dev->name, slave->dev->name, 2750 bond->dev->name, slave->dev->name, slave->state,
2733 slave->state, bond->params.arp_validate, 2751 bond->params.arp_validate, slave_do_arp_validate(bond, slave),
2734 slave_do_arp_validate(bond, slave), NIPQUAD(sip), NIPQUAD(tip)); 2752 &sip, &tip);
2735 2753
2736 /* 2754 /*
2737 * Backup slaves won't see the ARP reply, but do come through 2755 * Backup slaves won't see the ARP reply, but do come through
@@ -3161,6 +3179,12 @@ void bond_activebackup_arp_mon(struct work_struct *work)
3161 read_unlock(&bond->curr_slave_lock); 3179 read_unlock(&bond->curr_slave_lock);
3162 } 3180 }
3163 3181
3182 if (bond->send_unsol_na) {
3183 read_lock(&bond->curr_slave_lock);
3184 bond_send_unsolicited_na(bond);
3185 read_unlock(&bond->curr_slave_lock);
3186 }
3187
3164 if (bond_ab_arp_inspect(bond, delta_in_ticks)) { 3188 if (bond_ab_arp_inspect(bond, delta_in_ticks)) {
3165 read_unlock(&bond->lock); 3189 read_unlock(&bond->lock);
3166 rtnl_lock(); 3190 rtnl_lock();
@@ -3239,7 +3263,6 @@ static void bond_info_show_master(struct seq_file *seq)
3239 struct bonding *bond = seq->private; 3263 struct bonding *bond = seq->private;
3240 struct slave *curr; 3264 struct slave *curr;
3241 int i; 3265 int i;
3242 u32 target;
3243 3266
3244 read_lock(&bond->curr_slave_lock); 3267 read_lock(&bond->curr_slave_lock);
3245 curr = bond->curr_active_slave; 3268 curr = bond->curr_active_slave;
@@ -3293,8 +3316,7 @@ static void bond_info_show_master(struct seq_file *seq)
3293 continue; 3316 continue;
3294 if (printed) 3317 if (printed)
3295 seq_printf(seq, ","); 3318 seq_printf(seq, ",");
3296 target = ntohl(bond->params.arp_targets[i]); 3319 seq_printf(seq, " %pI4", &bond->params.arp_targets[i]);
3297 seq_printf(seq, " %d.%d.%d.%d", HIPQUAD(target));
3298 printed = 1; 3320 printed = 1;
3299 } 3321 }
3300 seq_printf(seq, "\n"); 3322 seq_printf(seq, "\n");
@@ -3302,11 +3324,12 @@ static void bond_info_show_master(struct seq_file *seq)
3302 3324
3303 if (bond->params.mode == BOND_MODE_8023AD) { 3325 if (bond->params.mode == BOND_MODE_8023AD) {
3304 struct ad_info ad_info; 3326 struct ad_info ad_info;
3305 DECLARE_MAC_BUF(mac);
3306 3327
3307 seq_puts(seq, "\n802.3ad info\n"); 3328 seq_puts(seq, "\n802.3ad info\n");
3308 seq_printf(seq, "LACP rate: %s\n", 3329 seq_printf(seq, "LACP rate: %s\n",
3309 (bond->params.lacp_fast) ? "fast" : "slow"); 3330 (bond->params.lacp_fast) ? "fast" : "slow");
3331 seq_printf(seq, "Aggregator selection policy (ad_select): %s\n",
3332 ad_select_tbl[bond->params.ad_select].modename);
3310 3333
3311 if (bond_3ad_get_active_agg_info(bond, &ad_info)) { 3334 if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
3312 seq_printf(seq, "bond %s has no active aggregator\n", 3335 seq_printf(seq, "bond %s has no active aggregator\n",
@@ -3322,8 +3345,8 @@ static void bond_info_show_master(struct seq_file *seq)
3322 ad_info.actor_key); 3345 ad_info.actor_key);
3323 seq_printf(seq, "\tPartner Key: %d\n", 3346 seq_printf(seq, "\tPartner Key: %d\n",
3324 ad_info.partner_key); 3347 ad_info.partner_key);
3325 seq_printf(seq, "\tPartner Mac Address: %s\n", 3348 seq_printf(seq, "\tPartner Mac Address: %pM\n",
3326 print_mac(mac, ad_info.partner_system)); 3349 ad_info.partner_system);
3327 } 3350 }
3328 } 3351 }
3329} 3352}
@@ -3331,7 +3354,6 @@ static void bond_info_show_master(struct seq_file *seq)
3331static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave) 3354static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave)
3332{ 3355{
3333 struct bonding *bond = seq->private; 3356 struct bonding *bond = seq->private;
3334 DECLARE_MAC_BUF(mac);
3335 3357
3336 seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name); 3358 seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
3337 seq_printf(seq, "MII Status: %s\n", 3359 seq_printf(seq, "MII Status: %s\n",
@@ -3339,9 +3361,7 @@ static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave
3339 seq_printf(seq, "Link Failure Count: %u\n", 3361 seq_printf(seq, "Link Failure Count: %u\n",
3340 slave->link_failure_count); 3362 slave->link_failure_count);
3341 3363
3342 seq_printf(seq, 3364 seq_printf(seq, "Permanent HW addr: %pM\n", slave->perm_hwaddr);
3343 "Permanent HW addr: %s\n",
3344 print_mac(mac, slave->perm_hwaddr));
3345 3365
3346 if (bond->params.mode == BOND_MODE_8023AD) { 3366 if (bond->params.mode == BOND_MODE_8023AD) {
3347 const struct aggregator *agg 3367 const struct aggregator *agg
@@ -3506,7 +3526,7 @@ static int bond_event_changename(struct bonding *bond)
3506 3526
3507static int bond_master_netdev_event(unsigned long event, struct net_device *bond_dev) 3527static int bond_master_netdev_event(unsigned long event, struct net_device *bond_dev)
3508{ 3528{
3509 struct bonding *event_bond = bond_dev->priv; 3529 struct bonding *event_bond = netdev_priv(bond_dev);
3510 3530
3511 switch (event) { 3531 switch (event) {
3512 case NETDEV_CHANGENAME: 3532 case NETDEV_CHANGENAME:
@@ -3524,7 +3544,7 @@ static int bond_master_netdev_event(unsigned long event, struct net_device *bond
3524static int bond_slave_netdev_event(unsigned long event, struct net_device *slave_dev) 3544static int bond_slave_netdev_event(unsigned long event, struct net_device *slave_dev)
3525{ 3545{
3526 struct net_device *bond_dev = slave_dev->master; 3546 struct net_device *bond_dev = slave_dev->master;
3527 struct bonding *bond = bond_dev->priv; 3547 struct bonding *bond = netdev_priv(bond_dev);
3528 3548
3529 switch (event) { 3549 switch (event) {
3530 case NETDEV_UNREGISTER: 3550 case NETDEV_UNREGISTER:
@@ -3775,7 +3795,7 @@ static int bond_xmit_hash_policy_l2(struct sk_buff *skb,
3775 3795
3776static int bond_open(struct net_device *bond_dev) 3796static int bond_open(struct net_device *bond_dev)
3777{ 3797{
3778 struct bonding *bond = bond_dev->priv; 3798 struct bonding *bond = netdev_priv(bond_dev);
3779 3799
3780 bond->kill_timers = 0; 3800 bond->kill_timers = 0;
3781 3801
@@ -3816,6 +3836,7 @@ static int bond_open(struct net_device *bond_dev)
3816 queue_delayed_work(bond->wq, &bond->ad_work, 0); 3836 queue_delayed_work(bond->wq, &bond->ad_work, 0);
3817 /* register to receive LACPDUs */ 3837 /* register to receive LACPDUs */
3818 bond_register_lacpdu(bond); 3838 bond_register_lacpdu(bond);
3839 bond_3ad_initiate_agg_selection(bond, 1);
3819 } 3840 }
3820 3841
3821 return 0; 3842 return 0;
@@ -3823,7 +3844,7 @@ static int bond_open(struct net_device *bond_dev)
3823 3844
3824static int bond_close(struct net_device *bond_dev) 3845static int bond_close(struct net_device *bond_dev)
3825{ 3846{
3826 struct bonding *bond = bond_dev->priv; 3847 struct bonding *bond = netdev_priv(bond_dev);
3827 3848
3828 if (bond->params.mode == BOND_MODE_8023AD) { 3849 if (bond->params.mode == BOND_MODE_8023AD) {
3829 /* Unregister the receive of LACPDUs */ 3850 /* Unregister the receive of LACPDUs */
@@ -3836,6 +3857,7 @@ static int bond_close(struct net_device *bond_dev)
3836 write_lock_bh(&bond->lock); 3857 write_lock_bh(&bond->lock);
3837 3858
3838 bond->send_grat_arp = 0; 3859 bond->send_grat_arp = 0;
3860 bond->send_unsol_na = 0;
3839 3861
3840 /* signal timers not to re-arm */ 3862 /* signal timers not to re-arm */
3841 bond->kill_timers = 1; 3863 bond->kill_timers = 1;
@@ -3876,7 +3898,7 @@ static int bond_close(struct net_device *bond_dev)
3876 3898
3877static struct net_device_stats *bond_get_stats(struct net_device *bond_dev) 3899static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
3878{ 3900{
3879 struct bonding *bond = bond_dev->priv; 3901 struct bonding *bond = netdev_priv(bond_dev);
3880 struct net_device_stats *stats = &(bond->stats), *sstats; 3902 struct net_device_stats *stats = &(bond->stats), *sstats;
3881 struct net_device_stats local_stats; 3903 struct net_device_stats local_stats;
3882 struct slave *slave; 3904 struct slave *slave;
@@ -3954,7 +3976,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3954 } 3976 }
3955 3977
3956 if (mii->reg_num == 1) { 3978 if (mii->reg_num == 1) {
3957 struct bonding *bond = bond_dev->priv; 3979 struct bonding *bond = netdev_priv(bond_dev);
3958 mii->val_out = 0; 3980 mii->val_out = 0;
3959 read_lock(&bond->lock); 3981 read_lock(&bond->lock);
3960 read_lock(&bond->curr_slave_lock); 3982 read_lock(&bond->curr_slave_lock);
@@ -4046,7 +4068,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
4046 4068
4047static void bond_set_multicast_list(struct net_device *bond_dev) 4069static void bond_set_multicast_list(struct net_device *bond_dev)
4048{ 4070{
4049 struct bonding *bond = bond_dev->priv; 4071 struct bonding *bond = netdev_priv(bond_dev);
4050 struct dev_mc_list *dmi; 4072 struct dev_mc_list *dmi;
4051 4073
4052 /* 4074 /*
@@ -4107,7 +4129,7 @@ static void bond_set_multicast_list(struct net_device *bond_dev)
4107 */ 4129 */
4108static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) 4130static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
4109{ 4131{
4110 struct bonding *bond = bond_dev->priv; 4132 struct bonding *bond = netdev_priv(bond_dev);
4111 struct slave *slave, *stop_at; 4133 struct slave *slave, *stop_at;
4112 int res = 0; 4134 int res = 0;
4113 int i; 4135 int i;
@@ -4179,7 +4201,7 @@ unwind:
4179 */ 4201 */
4180static int bond_set_mac_address(struct net_device *bond_dev, void *addr) 4202static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
4181{ 4203{
4182 struct bonding *bond = bond_dev->priv; 4204 struct bonding *bond = netdev_priv(bond_dev);
4183 struct sockaddr *sa = addr, tmp_sa; 4205 struct sockaddr *sa = addr, tmp_sa;
4184 struct slave *slave, *stop_at; 4206 struct slave *slave, *stop_at;
4185 int res = 0; 4207 int res = 0;
@@ -4260,7 +4282,7 @@ unwind:
4260 4282
4261static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev) 4283static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev)
4262{ 4284{
4263 struct bonding *bond = bond_dev->priv; 4285 struct bonding *bond = netdev_priv(bond_dev);
4264 struct slave *slave, *start_at; 4286 struct slave *slave, *start_at;
4265 int i, slave_no, res = 1; 4287 int i, slave_no, res = 1;
4266 4288
@@ -4309,7 +4331,7 @@ out:
4309 */ 4331 */
4310static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) 4332static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev)
4311{ 4333{
4312 struct bonding *bond = bond_dev->priv; 4334 struct bonding *bond = netdev_priv(bond_dev);
4313 int res = 1; 4335 int res = 1;
4314 4336
4315 read_lock(&bond->lock); 4337 read_lock(&bond->lock);
@@ -4341,7 +4363,7 @@ out:
4341 */ 4363 */
4342static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) 4364static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
4343{ 4365{
4344 struct bonding *bond = bond_dev->priv; 4366 struct bonding *bond = netdev_priv(bond_dev);
4345 struct slave *slave, *start_at; 4367 struct slave *slave, *start_at;
4346 int slave_no; 4368 int slave_no;
4347 int i; 4369 int i;
@@ -4387,7 +4409,7 @@ out:
4387 */ 4409 */
4388static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) 4410static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
4389{ 4411{
4390 struct bonding *bond = bond_dev->priv; 4412 struct bonding *bond = netdev_priv(bond_dev);
4391 struct slave *slave, *start_at; 4413 struct slave *slave, *start_at;
4392 struct net_device *tx_dev = NULL; 4414 struct net_device *tx_dev = NULL;
4393 int i; 4415 int i;
@@ -4530,7 +4552,7 @@ static const struct ethtool_ops bond_ethtool_ops = {
4530 */ 4552 */
4531static int bond_init(struct net_device *bond_dev, struct bond_params *params) 4553static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4532{ 4554{
4533 struct bonding *bond = bond_dev->priv; 4555 struct bonding *bond = netdev_priv(bond_dev);
4534 4556
4535 dprintk("Begin bond_init for %s\n", bond_dev->name); 4557 dprintk("Begin bond_init for %s\n", bond_dev->name);
4536 4558
@@ -4551,6 +4573,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4551 bond->primary_slave = NULL; 4573 bond->primary_slave = NULL;
4552 bond->dev = bond_dev; 4574 bond->dev = bond_dev;
4553 bond->send_grat_arp = 0; 4575 bond->send_grat_arp = 0;
4576 bond->send_unsol_na = 0;
4554 bond->setup_by_slave = 0; 4577 bond->setup_by_slave = 0;
4555 INIT_LIST_HEAD(&bond->vlan_list); 4578 INIT_LIST_HEAD(&bond->vlan_list);
4556 4579
@@ -4573,6 +4596,8 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4573 bond_dev->tx_queue_len = 0; 4596 bond_dev->tx_queue_len = 0;
4574 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST; 4597 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
4575 bond_dev->priv_flags |= IFF_BONDING; 4598 bond_dev->priv_flags |= IFF_BONDING;
4599 if (bond->params.arp_interval)
4600 bond_dev->priv_flags |= IFF_MASTER_ARPMON;
4576 4601
4577 /* At first, we block adding VLANs. That's the only way to 4602 /* At first, we block adding VLANs. That's the only way to
4578 * prevent problems that occur when adding VLANs over an 4603 * prevent problems that occur when adding VLANs over an
@@ -4632,7 +4657,7 @@ static void bond_work_cancel_all(struct bonding *bond)
4632 */ 4657 */
4633static void bond_deinit(struct net_device *bond_dev) 4658static void bond_deinit(struct net_device *bond_dev)
4634{ 4659{
4635 struct bonding *bond = bond_dev->priv; 4660 struct bonding *bond = netdev_priv(bond_dev);
4636 4661
4637 list_del(&bond->bond_list); 4662 list_del(&bond->bond_list);
4638 4663
@@ -4751,6 +4776,23 @@ static int bond_check_params(struct bond_params *params)
4751 } 4776 }
4752 } 4777 }
4753 4778
4779 if (ad_select) {
4780 params->ad_select = bond_parse_parm(ad_select, ad_select_tbl);
4781 if (params->ad_select == -1) {
4782 printk(KERN_ERR DRV_NAME
4783 ": Error: Invalid ad_select \"%s\"\n",
4784 ad_select == NULL ? "NULL" : ad_select);
4785 return -EINVAL;
4786 }
4787
4788 if (bond_mode != BOND_MODE_8023AD) {
4789 printk(KERN_WARNING DRV_NAME
4790 ": ad_select param only affects 802.3ad mode\n");
4791 }
4792 } else {
4793 params->ad_select = BOND_AD_STABLE;
4794 }
4795
4754 if (max_bonds < 0 || max_bonds > INT_MAX) { 4796 if (max_bonds < 0 || max_bonds > INT_MAX) {
4755 printk(KERN_WARNING DRV_NAME 4797 printk(KERN_WARNING DRV_NAME
4756 ": Warning: max_bonds (%d) not in range %d-%d, so it " 4798 ": Warning: max_bonds (%d) not in range %d-%d, so it "
@@ -4798,6 +4840,13 @@ static int bond_check_params(struct bond_params *params)
4798 num_grat_arp = 1; 4840 num_grat_arp = 1;
4799 } 4841 }
4800 4842
4843 if (num_unsol_na < 0 || num_unsol_na > 255) {
4844 printk(KERN_WARNING DRV_NAME
4845 ": Warning: num_unsol_na (%d) not in range 0-255 so it "
4846 "was reset to 1 \n", num_unsol_na);
4847 num_unsol_na = 1;
4848 }
4849
4801 /* reset values for 802.3ad */ 4850 /* reset values for 802.3ad */
4802 if (bond_mode == BOND_MODE_8023AD) { 4851 if (bond_mode == BOND_MODE_8023AD) {
4803 if (!miimon) { 4852 if (!miimon) {
@@ -4999,6 +5048,7 @@ static int bond_check_params(struct bond_params *params)
4999 params->xmit_policy = xmit_hashtype; 5048 params->xmit_policy = xmit_hashtype;
5000 params->miimon = miimon; 5049 params->miimon = miimon;
5001 params->num_grat_arp = num_grat_arp; 5050 params->num_grat_arp = num_grat_arp;
5051 params->num_unsol_na = num_unsol_na;
5002 params->arp_interval = arp_interval; 5052 params->arp_interval = arp_interval;
5003 params->arp_validate = arp_validate_value; 5053 params->arp_validate = arp_validate_value;
5004 params->updelay = updelay; 5054 params->updelay = updelay;
@@ -5099,7 +5149,7 @@ int bond_create(char *name, struct bond_params *params)
5099 5149
5100 up_write(&bonding_rwsem); 5150 up_write(&bonding_rwsem);
5101 rtnl_unlock(); /* allows sysfs registration of net device */ 5151 rtnl_unlock(); /* allows sysfs registration of net device */
5102 res = bond_create_sysfs_entry(bond_dev->priv); 5152 res = bond_create_sysfs_entry(netdev_priv(bond_dev));
5103 if (res < 0) { 5153 if (res < 0) {
5104 rtnl_lock(); 5154 rtnl_lock();
5105 down_write(&bonding_rwsem); 5155 down_write(&bonding_rwsem);
@@ -5151,6 +5201,7 @@ static int __init bonding_init(void)
5151 5201
5152 register_netdevice_notifier(&bond_netdev_notifier); 5202 register_netdevice_notifier(&bond_netdev_notifier);
5153 register_inetaddr_notifier(&bond_inetaddr_notifier); 5203 register_inetaddr_notifier(&bond_inetaddr_notifier);
5204 bond_register_ipv6_notifier();
5154 5205
5155 goto out; 5206 goto out;
5156err: 5207err:
@@ -5173,6 +5224,7 @@ static void __exit bonding_exit(void)
5173{ 5224{
5174 unregister_netdevice_notifier(&bond_netdev_notifier); 5225 unregister_netdevice_notifier(&bond_netdev_notifier);
5175 unregister_inetaddr_notifier(&bond_inetaddr_notifier); 5226 unregister_inetaddr_notifier(&bond_inetaddr_notifier);
5227 bond_unregister_ipv6_notifier();
5176 5228
5177 bond_destroy_sysfs(); 5229 bond_destroy_sysfs();
5178 5230
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 3bdb47382521..fc490d89d4af 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -39,7 +39,7 @@
39/* #define BONDING_DEBUG 1 */ 39/* #define BONDING_DEBUG 1 */
40#include "bonding.h" 40#include "bonding.h"
41#define to_dev(obj) container_of(obj,struct device,kobj) 41#define to_dev(obj) container_of(obj,struct device,kobj)
42#define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) 42#define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd))))
43 43
44/*---------------------------- Declarations -------------------------------*/ 44/*---------------------------- Declarations -------------------------------*/
45 45
@@ -48,6 +48,7 @@ extern struct list_head bond_dev_list;
48extern struct bond_params bonding_defaults; 48extern struct bond_params bonding_defaults;
49extern struct bond_parm_tbl bond_mode_tbl[]; 49extern struct bond_parm_tbl bond_mode_tbl[];
50extern struct bond_parm_tbl bond_lacp_tbl[]; 50extern struct bond_parm_tbl bond_lacp_tbl[];
51extern struct bond_parm_tbl ad_select_tbl[];
51extern struct bond_parm_tbl xmit_hashtype_tbl[]; 52extern struct bond_parm_tbl xmit_hashtype_tbl[];
52extern struct bond_parm_tbl arp_validate_tbl[]; 53extern struct bond_parm_tbl arp_validate_tbl[];
53extern struct bond_parm_tbl fail_over_mac_tbl[]; 54extern struct bond_parm_tbl fail_over_mac_tbl[];
@@ -620,6 +621,8 @@ static ssize_t bonding_store_arp_interval(struct device *d,
620 ": %s: Setting ARP monitoring interval to %d.\n", 621 ": %s: Setting ARP monitoring interval to %d.\n",
621 bond->dev->name, new_value); 622 bond->dev->name, new_value);
622 bond->params.arp_interval = new_value; 623 bond->params.arp_interval = new_value;
624 if (bond->params.arp_interval)
625 bond->dev->priv_flags |= IFF_MASTER_ARPMON;
623 if (bond->params.miimon) { 626 if (bond->params.miimon) {
624 printk(KERN_INFO DRV_NAME 627 printk(KERN_INFO DRV_NAME
625 ": %s: ARP monitoring cannot be used with MII monitoring. " 628 ": %s: ARP monitoring cannot be used with MII monitoring. "
@@ -672,8 +675,8 @@ static ssize_t bonding_show_arp_targets(struct device *d,
672 675
673 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { 676 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
674 if (bond->params.arp_targets[i]) 677 if (bond->params.arp_targets[i])
675 res += sprintf(buf + res, "%u.%u.%u.%u ", 678 res += sprintf(buf + res, "%pI4 ",
676 NIPQUAD(bond->params.arp_targets[i])); 679 &bond->params.arp_targets[i]);
677 } 680 }
678 if (res) 681 if (res)
679 buf[res-1] = '\n'; /* eat the leftover space */ 682 buf[res-1] = '\n'; /* eat the leftover space */
@@ -695,8 +698,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
695 if (buf[0] == '+') { 698 if (buf[0] == '+') {
696 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 699 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
697 printk(KERN_ERR DRV_NAME 700 printk(KERN_ERR DRV_NAME
698 ": %s: invalid ARP target %u.%u.%u.%u specified for addition\n", 701 ": %s: invalid ARP target %pI4 specified for addition\n",
699 bond->dev->name, NIPQUAD(newtarget)); 702 bond->dev->name, &newtarget);
700 ret = -EINVAL; 703 ret = -EINVAL;
701 goto out; 704 goto out;
702 } 705 }
@@ -704,8 +707,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
704 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { 707 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
705 if (targets[i] == newtarget) { /* duplicate */ 708 if (targets[i] == newtarget) { /* duplicate */
706 printk(KERN_ERR DRV_NAME 709 printk(KERN_ERR DRV_NAME
707 ": %s: ARP target %u.%u.%u.%u is already present\n", 710 ": %s: ARP target %pI4 is already present\n",
708 bond->dev->name, NIPQUAD(newtarget)); 711 bond->dev->name, &newtarget);
709 if (done) 712 if (done)
710 targets[i] = 0; 713 targets[i] = 0;
711 ret = -EINVAL; 714 ret = -EINVAL;
@@ -713,8 +716,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
713 } 716 }
714 if (targets[i] == 0 && !done) { 717 if (targets[i] == 0 && !done) {
715 printk(KERN_INFO DRV_NAME 718 printk(KERN_INFO DRV_NAME
716 ": %s: adding ARP target %d.%d.%d.%d.\n", 719 ": %s: adding ARP target %pI4.\n",
717 bond->dev->name, NIPQUAD(newtarget)); 720 bond->dev->name, &newtarget);
718 done = 1; 721 done = 1;
719 targets[i] = newtarget; 722 targets[i] = newtarget;
720 } 723 }
@@ -731,8 +734,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
731 else if (buf[0] == '-') { 734 else if (buf[0] == '-') {
732 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 735 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
733 printk(KERN_ERR DRV_NAME 736 printk(KERN_ERR DRV_NAME
734 ": %s: invalid ARP target %d.%d.%d.%d specified for removal\n", 737 ": %s: invalid ARP target %pI4 specified for removal\n",
735 bond->dev->name, NIPQUAD(newtarget)); 738 bond->dev->name, &newtarget);
736 ret = -EINVAL; 739 ret = -EINVAL;
737 goto out; 740 goto out;
738 } 741 }
@@ -740,16 +743,16 @@ static ssize_t bonding_store_arp_targets(struct device *d,
740 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { 743 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
741 if (targets[i] == newtarget) { 744 if (targets[i] == newtarget) {
742 printk(KERN_INFO DRV_NAME 745 printk(KERN_INFO DRV_NAME
743 ": %s: removing ARP target %d.%d.%d.%d.\n", 746 ": %s: removing ARP target %pI4.\n",
744 bond->dev->name, NIPQUAD(newtarget)); 747 bond->dev->name, &newtarget);
745 targets[i] = 0; 748 targets[i] = 0;
746 done = 1; 749 done = 1;
747 } 750 }
748 } 751 }
749 if (!done) { 752 if (!done) {
750 printk(KERN_INFO DRV_NAME 753 printk(KERN_INFO DRV_NAME
751 ": %s: unable to remove nonexistent ARP target %d.%d.%d.%d.\n", 754 ": %s: unable to remove nonexistent ARP target %pI4.\n",
752 bond->dev->name, NIPQUAD(newtarget)); 755 bond->dev->name, &newtarget);
753 ret = -EINVAL; 756 ret = -EINVAL;
754 goto out; 757 goto out;
755 } 758 }
@@ -942,6 +945,53 @@ out:
942} 945}
943static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); 946static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp);
944 947
948static ssize_t bonding_show_ad_select(struct device *d,
949 struct device_attribute *attr,
950 char *buf)
951{
952 struct bonding *bond = to_bond(d);
953
954 return sprintf(buf, "%s %d\n",
955 ad_select_tbl[bond->params.ad_select].modename,
956 bond->params.ad_select);
957}
958
959
960static ssize_t bonding_store_ad_select(struct device *d,
961 struct device_attribute *attr,
962 const char *buf, size_t count)
963{
964 int new_value, ret = count;
965 struct bonding *bond = to_bond(d);
966
967 if (bond->dev->flags & IFF_UP) {
968 printk(KERN_ERR DRV_NAME
969 ": %s: Unable to update ad_select because interface "
970 "is up.\n", bond->dev->name);
971 ret = -EPERM;
972 goto out;
973 }
974
975 new_value = bond_parse_parm(buf, ad_select_tbl);
976
977 if (new_value != -1) {
978 bond->params.ad_select = new_value;
979 printk(KERN_INFO DRV_NAME
980 ": %s: Setting ad_select to %s (%d).\n",
981 bond->dev->name, ad_select_tbl[new_value].modename,
982 new_value);
983 } else {
984 printk(KERN_ERR DRV_NAME
985 ": %s: Ignoring invalid ad_select value %.*s.\n",
986 bond->dev->name, (int)strlen(buf) - 1, buf);
987 ret = -EINVAL;
988 }
989out:
990 return ret;
991}
992
993static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, bonding_show_ad_select, bonding_store_ad_select);
994
945/* 995/*
946 * Show and set the number of grat ARP to send after a failover event. 996 * Show and set the number of grat ARP to send after a failover event.
947 */ 997 */
@@ -981,6 +1031,47 @@ out:
981 return ret; 1031 return ret;
982} 1032}
983static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp); 1033static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp);
1034
1035/*
1036 * Show and set the number of unsolicted NA's to send after a failover event.
1037 */
1038static ssize_t bonding_show_n_unsol_na(struct device *d,
1039 struct device_attribute *attr,
1040 char *buf)
1041{
1042 struct bonding *bond = to_bond(d);
1043
1044 return sprintf(buf, "%d\n", bond->params.num_unsol_na);
1045}
1046
1047static ssize_t bonding_store_n_unsol_na(struct device *d,
1048 struct device_attribute *attr,
1049 const char *buf, size_t count)
1050{
1051 int new_value, ret = count;
1052 struct bonding *bond = to_bond(d);
1053
1054 if (sscanf(buf, "%d", &new_value) != 1) {
1055 printk(KERN_ERR DRV_NAME
1056 ": %s: no num_unsol_na value specified.\n",
1057 bond->dev->name);
1058 ret = -EINVAL;
1059 goto out;
1060 }
1061 if (new_value < 0 || new_value > 255) {
1062 printk(KERN_ERR DRV_NAME
1063 ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
1064 bond->dev->name, new_value);
1065 ret = -EINVAL;
1066 goto out;
1067 } else {
1068 bond->params.num_unsol_na = new_value;
1069 }
1070out:
1071 return ret;
1072}
1073static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, bonding_show_n_unsol_na, bonding_store_n_unsol_na);
1074
984/* 1075/*
985 * Show and set the MII monitor interval. There are two tricky bits 1076 * Show and set the MII monitor interval. There are two tricky bits
986 * here. First, if MII monitoring is activated, then we must disable 1077 * here. First, if MII monitoring is activated, then we must disable
@@ -1039,6 +1130,7 @@ static ssize_t bonding_store_miimon(struct device *d,
1039 "ARP monitoring. Disabling ARP monitoring...\n", 1130 "ARP monitoring. Disabling ARP monitoring...\n",
1040 bond->dev->name); 1131 bond->dev->name);
1041 bond->params.arp_interval = 0; 1132 bond->params.arp_interval = 0;
1133 bond->dev->priv_flags &= ~IFF_MASTER_ARPMON;
1042 if (bond->params.arp_validate) { 1134 if (bond->params.arp_validate) {
1043 bond_unregister_arp(bond); 1135 bond_unregister_arp(bond);
1044 bond->params.arp_validate = 1136 bond->params.arp_validate =
@@ -1391,13 +1483,11 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
1391{ 1483{
1392 int count = 0; 1484 int count = 0;
1393 struct bonding *bond = to_bond(d); 1485 struct bonding *bond = to_bond(d);
1394 DECLARE_MAC_BUF(mac);
1395 1486
1396 if (bond->params.mode == BOND_MODE_8023AD) { 1487 if (bond->params.mode == BOND_MODE_8023AD) {
1397 struct ad_info ad_info; 1488 struct ad_info ad_info;
1398 if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { 1489 if (!bond_3ad_get_active_agg_info(bond, &ad_info)) {
1399 count = sprintf(buf,"%s\n", 1490 count = sprintf(buf, "%pM\n", ad_info.partner_system);
1400 print_mac(mac, ad_info.partner_system));
1401 } 1491 }
1402 } 1492 }
1403 1493
@@ -1417,8 +1507,10 @@ static struct attribute *per_bond_attrs[] = {
1417 &dev_attr_downdelay.attr, 1507 &dev_attr_downdelay.attr,
1418 &dev_attr_updelay.attr, 1508 &dev_attr_updelay.attr,
1419 &dev_attr_lacp_rate.attr, 1509 &dev_attr_lacp_rate.attr,
1510 &dev_attr_ad_select.attr,
1420 &dev_attr_xmit_hash_policy.attr, 1511 &dev_attr_xmit_hash_policy.attr,
1421 &dev_attr_num_grat_arp.attr, 1512 &dev_attr_num_grat_arp.attr,
1513 &dev_attr_num_unsol_na.attr,
1422 &dev_attr_miimon.attr, 1514 &dev_attr_miimon.attr,
1423 &dev_attr_primary.attr, 1515 &dev_attr_primary.attr,
1424 &dev_attr_use_carrier.attr, 1516 &dev_attr_use_carrier.attr,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index ffb668dd6d3b..921abacc6074 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -19,16 +19,19 @@
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/if_bonding.h> 20#include <linux/if_bonding.h>
21#include <linux/kobject.h> 21#include <linux/kobject.h>
22#include <linux/in6.h>
22#include "bond_3ad.h" 23#include "bond_3ad.h"
23#include "bond_alb.h" 24#include "bond_alb.h"
24 25
25#define DRV_VERSION "3.3.0" 26#define DRV_VERSION "3.5.0"
26#define DRV_RELDATE "June 10, 2008" 27#define DRV_RELDATE "November 4, 2008"
27#define DRV_NAME "bonding" 28#define DRV_NAME "bonding"
28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" 29#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
29 30
30#define BOND_MAX_ARP_TARGETS 16 31#define BOND_MAX_ARP_TARGETS 16
31 32
33extern struct list_head bond_dev_list;
34
32#ifdef BONDING_DEBUG 35#ifdef BONDING_DEBUG
33#define dprintk(fmt, args...) \ 36#define dprintk(fmt, args...) \
34 printk(KERN_DEBUG \ 37 printk(KERN_DEBUG \
@@ -126,6 +129,7 @@ struct bond_params {
126 int xmit_policy; 129 int xmit_policy;
127 int miimon; 130 int miimon;
128 int num_grat_arp; 131 int num_grat_arp;
132 int num_unsol_na;
129 int arp_interval; 133 int arp_interval;
130 int arp_validate; 134 int arp_validate;
131 int use_carrier; 135 int use_carrier;
@@ -133,6 +137,7 @@ struct bond_params {
133 int updelay; 137 int updelay;
134 int downdelay; 138 int downdelay;
135 int lacp_fast; 139 int lacp_fast;
140 int ad_select;
136 char primary[IFNAMSIZ]; 141 char primary[IFNAMSIZ];
137 __be32 arp_targets[BOND_MAX_ARP_TARGETS]; 142 __be32 arp_targets[BOND_MAX_ARP_TARGETS];
138}; 143};
@@ -148,6 +153,9 @@ struct vlan_entry {
148 struct list_head vlan_list; 153 struct list_head vlan_list;
149 __be32 vlan_ip; 154 __be32 vlan_ip;
150 unsigned short vlan_id; 155 unsigned short vlan_id;
156#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
157 struct in6_addr vlan_ipv6;
158#endif
151}; 159};
152 160
153struct slave { 161struct slave {
@@ -195,6 +203,7 @@ struct bonding {
195 rwlock_t curr_slave_lock; 203 rwlock_t curr_slave_lock;
196 s8 kill_timers; 204 s8 kill_timers;
197 s8 send_grat_arp; 205 s8 send_grat_arp;
206 s8 send_unsol_na;
198 s8 setup_by_slave; 207 s8 setup_by_slave;
199 struct net_device_stats stats; 208 struct net_device_stats stats;
200#ifdef CONFIG_PROC_FS 209#ifdef CONFIG_PROC_FS
@@ -218,6 +227,9 @@ struct bonding {
218 struct delayed_work arp_work; 227 struct delayed_work arp_work;
219 struct delayed_work alb_work; 228 struct delayed_work alb_work;
220 struct delayed_work ad_work; 229 struct delayed_work ad_work;
230#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
231 struct in6_addr master_ipv6;
232#endif
221}; 233};
222 234
223/** 235/**
@@ -245,7 +257,7 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
245 return NULL; 257 return NULL;
246 } 258 }
247 259
248 return (struct bonding *)slave->dev->master->priv; 260 return (struct bonding *)netdev_priv(slave->dev->master);
249} 261}
250 262
251#define BOND_FOM_NONE 0 263#define BOND_FOM_NONE 0
@@ -275,7 +287,7 @@ static inline unsigned long slave_last_rx(struct bonding *bond,
275 287
276static inline void bond_set_slave_inactive_flags(struct slave *slave) 288static inline void bond_set_slave_inactive_flags(struct slave *slave)
277{ 289{
278 struct bonding *bond = slave->dev->master->priv; 290 struct bonding *bond = netdev_priv(slave->dev->master);
279 if (bond->params.mode != BOND_MODE_TLB && 291 if (bond->params.mode != BOND_MODE_TLB &&
280 bond->params.mode != BOND_MODE_ALB) 292 bond->params.mode != BOND_MODE_ALB)
281 slave->state = BOND_STATE_BACKUP; 293 slave->state = BOND_STATE_BACKUP;
@@ -341,5 +353,24 @@ extern struct bond_parm_tbl xmit_hashtype_tbl[];
341extern struct bond_parm_tbl arp_validate_tbl[]; 353extern struct bond_parm_tbl arp_validate_tbl[];
342extern struct bond_parm_tbl fail_over_mac_tbl[]; 354extern struct bond_parm_tbl fail_over_mac_tbl[];
343 355
356#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
357void bond_send_unsolicited_na(struct bonding *bond);
358void bond_register_ipv6_notifier(void);
359void bond_unregister_ipv6_notifier(void);
360#else
361static inline void bond_send_unsolicited_na(struct bonding *bond)
362{
363 return;
364}
365static inline void bond_register_ipv6_notifier(void)
366{
367 return;
368}
369static inline void bond_unregister_ipv6_notifier(void)
370{
371 return;
372}
373#endif
374
344#endif /* _LINUX_BONDING_H */ 375#endif /* _LINUX_BONDING_H */
345 376
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 86909cfb14de..bc84c4ca898e 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -2405,7 +2405,6 @@ static int cas_rx_ringN(struct cas *cp, int ring, int budget)
2405 cp->net_stats[ring].rx_packets++; 2405 cp->net_stats[ring].rx_packets++;
2406 cp->net_stats[ring].rx_bytes += len; 2406 cp->net_stats[ring].rx_bytes += len;
2407 spin_unlock(&cp->stat_lock[ring]); 2407 spin_unlock(&cp->stat_lock[ring]);
2408 cp->dev->last_rx = jiffies;
2409 2408
2410 next: 2409 next:
2411 npackets++; 2410 npackets++;
@@ -4988,7 +4987,6 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4988 int i, err, pci_using_dac; 4987 int i, err, pci_using_dac;
4989 u16 pci_cmd; 4988 u16 pci_cmd;
4990 u8 orig_cacheline_size = 0, cas_cacheline_size = 0; 4989 u8 orig_cacheline_size = 0, cas_cacheline_size = 0;
4991 DECLARE_MAC_BUF(mac);
4992 4990
4993 if (cas_version_printed++ == 0) 4991 if (cas_version_printed++ == 0)
4994 printk(KERN_INFO "%s", version); 4992 printk(KERN_INFO "%s", version);
@@ -5201,12 +5199,12 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5201 5199
5202 i = readl(cp->regs + REG_BIM_CFG); 5200 i = readl(cp->regs + REG_BIM_CFG);
5203 printk(KERN_INFO "%s: Sun Cassini%s (%sbit/%sMHz PCI/%s) " 5201 printk(KERN_INFO "%s: Sun Cassini%s (%sbit/%sMHz PCI/%s) "
5204 "Ethernet[%d] %s\n", dev->name, 5202 "Ethernet[%d] %pM\n", dev->name,
5205 (cp->cas_flags & CAS_FLAG_REG_PLUS) ? "+" : "", 5203 (cp->cas_flags & CAS_FLAG_REG_PLUS) ? "+" : "",
5206 (i & BIM_CFG_32BIT) ? "32" : "64", 5204 (i & BIM_CFG_32BIT) ? "32" : "64",
5207 (i & BIM_CFG_66MHZ) ? "66" : "33", 5205 (i & BIM_CFG_66MHZ) ? "66" : "33",
5208 (cp->phy_type == CAS_PHY_SERDES) ? "Fi" : "Cu", pdev->irq, 5206 (cp->phy_type == CAS_PHY_SERDES) ? "Fi" : "Cu", pdev->irq,
5209 print_mac(mac, dev->dev_addr)); 5207 dev->dev_addr);
5210 5208
5211 pci_set_drvdata(pdev, dev); 5209 pci_set_drvdata(pdev, dev);
5212 cp->hw_running = 1; 5210 cp->hw_running = 1;
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 638c9a27a7a6..5fb0038b8549 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -120,7 +120,7 @@ static const char pci_speed[][4] = {
120 */ 120 */
121static void t1_set_rxmode(struct net_device *dev) 121static void t1_set_rxmode(struct net_device *dev)
122{ 122{
123 struct adapter *adapter = dev->priv; 123 struct adapter *adapter = dev->ml_priv;
124 struct cmac *mac = adapter->port[dev->if_port].mac; 124 struct cmac *mac = adapter->port[dev->if_port].mac;
125 struct t1_rx_mode rm; 125 struct t1_rx_mode rm;
126 126
@@ -252,7 +252,7 @@ static void cxgb_down(struct adapter *adapter)
252static int cxgb_open(struct net_device *dev) 252static int cxgb_open(struct net_device *dev)
253{ 253{
254 int err; 254 int err;
255 struct adapter *adapter = dev->priv; 255 struct adapter *adapter = dev->ml_priv;
256 int other_ports = adapter->open_device_map & PORT_MASK; 256 int other_ports = adapter->open_device_map & PORT_MASK;
257 257
258 napi_enable(&adapter->napi); 258 napi_enable(&adapter->napi);
@@ -272,7 +272,7 @@ static int cxgb_open(struct net_device *dev)
272 272
273static int cxgb_close(struct net_device *dev) 273static int cxgb_close(struct net_device *dev)
274{ 274{
275 struct adapter *adapter = dev->priv; 275 struct adapter *adapter = dev->ml_priv;
276 struct port_info *p = &adapter->port[dev->if_port]; 276 struct port_info *p = &adapter->port[dev->if_port];
277 struct cmac *mac = p->mac; 277 struct cmac *mac = p->mac;
278 278
@@ -298,7 +298,7 @@ static int cxgb_close(struct net_device *dev)
298 298
299static struct net_device_stats *t1_get_stats(struct net_device *dev) 299static struct net_device_stats *t1_get_stats(struct net_device *dev)
300{ 300{
301 struct adapter *adapter = dev->priv; 301 struct adapter *adapter = dev->ml_priv;
302 struct port_info *p = &adapter->port[dev->if_port]; 302 struct port_info *p = &adapter->port[dev->if_port];
303 struct net_device_stats *ns = &p->netstats; 303 struct net_device_stats *ns = &p->netstats;
304 const struct cmac_statistics *pstats; 304 const struct cmac_statistics *pstats;
@@ -346,14 +346,14 @@ static struct net_device_stats *t1_get_stats(struct net_device *dev)
346 346
347static u32 get_msglevel(struct net_device *dev) 347static u32 get_msglevel(struct net_device *dev)
348{ 348{
349 struct adapter *adapter = dev->priv; 349 struct adapter *adapter = dev->ml_priv;
350 350
351 return adapter->msg_enable; 351 return adapter->msg_enable;
352} 352}
353 353
354static void set_msglevel(struct net_device *dev, u32 val) 354static void set_msglevel(struct net_device *dev, u32 val)
355{ 355{
356 struct adapter *adapter = dev->priv; 356 struct adapter *adapter = dev->ml_priv;
357 357
358 adapter->msg_enable = val; 358 adapter->msg_enable = val;
359} 359}
@@ -434,7 +434,7 @@ static int get_regs_len(struct net_device *dev)
434 434
435static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 435static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
436{ 436{
437 struct adapter *adapter = dev->priv; 437 struct adapter *adapter = dev->ml_priv;
438 438
439 strcpy(info->driver, DRV_NAME); 439 strcpy(info->driver, DRV_NAME);
440 strcpy(info->version, DRV_VERSION); 440 strcpy(info->version, DRV_VERSION);
@@ -461,7 +461,7 @@ static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
461static void get_stats(struct net_device *dev, struct ethtool_stats *stats, 461static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
462 u64 *data) 462 u64 *data)
463{ 463{
464 struct adapter *adapter = dev->priv; 464 struct adapter *adapter = dev->ml_priv;
465 struct cmac *mac = adapter->port[dev->if_port].mac; 465 struct cmac *mac = adapter->port[dev->if_port].mac;
466 const struct cmac_statistics *s; 466 const struct cmac_statistics *s;
467 const struct sge_intr_counts *t; 467 const struct sge_intr_counts *t;
@@ -552,7 +552,7 @@ static inline void reg_block_dump(struct adapter *ap, void *buf,
552static void get_regs(struct net_device *dev, struct ethtool_regs *regs, 552static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
553 void *buf) 553 void *buf)
554{ 554{
555 struct adapter *ap = dev->priv; 555 struct adapter *ap = dev->ml_priv;
556 556
557 /* 557 /*
558 * Version scheme: bits 0..9: chip version, bits 10..15: chip revision 558 * Version scheme: bits 0..9: chip version, bits 10..15: chip revision
@@ -574,7 +574,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
574 574
575static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 575static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
576{ 576{
577 struct adapter *adapter = dev->priv; 577 struct adapter *adapter = dev->ml_priv;
578 struct port_info *p = &adapter->port[dev->if_port]; 578 struct port_info *p = &adapter->port[dev->if_port];
579 579
580 cmd->supported = p->link_config.supported; 580 cmd->supported = p->link_config.supported;
@@ -634,7 +634,7 @@ static int speed_duplex_to_caps(int speed, int duplex)
634 634
635static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 635static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
636{ 636{
637 struct adapter *adapter = dev->priv; 637 struct adapter *adapter = dev->ml_priv;
638 struct port_info *p = &adapter->port[dev->if_port]; 638 struct port_info *p = &adapter->port[dev->if_port];
639 struct link_config *lc = &p->link_config; 639 struct link_config *lc = &p->link_config;
640 640
@@ -669,7 +669,7 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
669static void get_pauseparam(struct net_device *dev, 669static void get_pauseparam(struct net_device *dev,
670 struct ethtool_pauseparam *epause) 670 struct ethtool_pauseparam *epause)
671{ 671{
672 struct adapter *adapter = dev->priv; 672 struct adapter *adapter = dev->ml_priv;
673 struct port_info *p = &adapter->port[dev->if_port]; 673 struct port_info *p = &adapter->port[dev->if_port];
674 674
675 epause->autoneg = (p->link_config.requested_fc & PAUSE_AUTONEG) != 0; 675 epause->autoneg = (p->link_config.requested_fc & PAUSE_AUTONEG) != 0;
@@ -680,7 +680,7 @@ static void get_pauseparam(struct net_device *dev,
680static int set_pauseparam(struct net_device *dev, 680static int set_pauseparam(struct net_device *dev,
681 struct ethtool_pauseparam *epause) 681 struct ethtool_pauseparam *epause)
682{ 682{
683 struct adapter *adapter = dev->priv; 683 struct adapter *adapter = dev->ml_priv;
684 struct port_info *p = &adapter->port[dev->if_port]; 684 struct port_info *p = &adapter->port[dev->if_port];
685 struct link_config *lc = &p->link_config; 685 struct link_config *lc = &p->link_config;
686 686
@@ -709,14 +709,14 @@ static int set_pauseparam(struct net_device *dev,
709 709
710static u32 get_rx_csum(struct net_device *dev) 710static u32 get_rx_csum(struct net_device *dev)
711{ 711{
712 struct adapter *adapter = dev->priv; 712 struct adapter *adapter = dev->ml_priv;
713 713
714 return (adapter->flags & RX_CSUM_ENABLED) != 0; 714 return (adapter->flags & RX_CSUM_ENABLED) != 0;
715} 715}
716 716
717static int set_rx_csum(struct net_device *dev, u32 data) 717static int set_rx_csum(struct net_device *dev, u32 data)
718{ 718{
719 struct adapter *adapter = dev->priv; 719 struct adapter *adapter = dev->ml_priv;
720 720
721 if (data) 721 if (data)
722 adapter->flags |= RX_CSUM_ENABLED; 722 adapter->flags |= RX_CSUM_ENABLED;
@@ -727,7 +727,7 @@ static int set_rx_csum(struct net_device *dev, u32 data)
727 727
728static int set_tso(struct net_device *dev, u32 value) 728static int set_tso(struct net_device *dev, u32 value)
729{ 729{
730 struct adapter *adapter = dev->priv; 730 struct adapter *adapter = dev->ml_priv;
731 731
732 if (!(adapter->flags & TSO_CAPABLE)) 732 if (!(adapter->flags & TSO_CAPABLE))
733 return value ? -EOPNOTSUPP : 0; 733 return value ? -EOPNOTSUPP : 0;
@@ -736,7 +736,7 @@ static int set_tso(struct net_device *dev, u32 value)
736 736
737static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) 737static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
738{ 738{
739 struct adapter *adapter = dev->priv; 739 struct adapter *adapter = dev->ml_priv;
740 int jumbo_fl = t1_is_T1B(adapter) ? 1 : 0; 740 int jumbo_fl = t1_is_T1B(adapter) ? 1 : 0;
741 741
742 e->rx_max_pending = MAX_RX_BUFFERS; 742 e->rx_max_pending = MAX_RX_BUFFERS;
@@ -752,7 +752,7 @@ static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
752 752
753static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) 753static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
754{ 754{
755 struct adapter *adapter = dev->priv; 755 struct adapter *adapter = dev->ml_priv;
756 int jumbo_fl = t1_is_T1B(adapter) ? 1 : 0; 756 int jumbo_fl = t1_is_T1B(adapter) ? 1 : 0;
757 757
758 if (e->rx_pending > MAX_RX_BUFFERS || e->rx_mini_pending || 758 if (e->rx_pending > MAX_RX_BUFFERS || e->rx_mini_pending ||
@@ -776,7 +776,7 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
776 776
777static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) 777static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
778{ 778{
779 struct adapter *adapter = dev->priv; 779 struct adapter *adapter = dev->ml_priv;
780 780
781 adapter->params.sge.rx_coalesce_usecs = c->rx_coalesce_usecs; 781 adapter->params.sge.rx_coalesce_usecs = c->rx_coalesce_usecs;
782 adapter->params.sge.coalesce_enable = c->use_adaptive_rx_coalesce; 782 adapter->params.sge.coalesce_enable = c->use_adaptive_rx_coalesce;
@@ -787,7 +787,7 @@ static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
787 787
788static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) 788static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
789{ 789{
790 struct adapter *adapter = dev->priv; 790 struct adapter *adapter = dev->ml_priv;
791 791
792 c->rx_coalesce_usecs = adapter->params.sge.rx_coalesce_usecs; 792 c->rx_coalesce_usecs = adapter->params.sge.rx_coalesce_usecs;
793 c->rate_sample_interval = adapter->params.sge.sample_interval_usecs; 793 c->rate_sample_interval = adapter->params.sge.sample_interval_usecs;
@@ -797,7 +797,7 @@ static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
797 797
798static int get_eeprom_len(struct net_device *dev) 798static int get_eeprom_len(struct net_device *dev)
799{ 799{
800 struct adapter *adapter = dev->priv; 800 struct adapter *adapter = dev->ml_priv;
801 801
802 return t1_is_asic(adapter) ? EEPROM_SIZE : 0; 802 return t1_is_asic(adapter) ? EEPROM_SIZE : 0;
803} 803}
@@ -810,7 +810,7 @@ static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
810{ 810{
811 int i; 811 int i;
812 u8 buf[EEPROM_SIZE] __attribute__((aligned(4))); 812 u8 buf[EEPROM_SIZE] __attribute__((aligned(4)));
813 struct adapter *adapter = dev->priv; 813 struct adapter *adapter = dev->ml_priv;
814 814
815 e->magic = EEPROM_MAGIC(adapter); 815 e->magic = EEPROM_MAGIC(adapter);
816 for (i = e->offset & ~3; i < e->offset + e->len; i += sizeof(u32)) 816 for (i = e->offset & ~3; i < e->offset + e->len; i += sizeof(u32))
@@ -848,7 +848,7 @@ static const struct ethtool_ops t1_ethtool_ops = {
848 848
849static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 849static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
850{ 850{
851 struct adapter *adapter = dev->priv; 851 struct adapter *adapter = dev->ml_priv;
852 struct mii_ioctl_data *data = if_mii(req); 852 struct mii_ioctl_data *data = if_mii(req);
853 853
854 switch (cmd) { 854 switch (cmd) {
@@ -887,7 +887,7 @@ static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
887static int t1_change_mtu(struct net_device *dev, int new_mtu) 887static int t1_change_mtu(struct net_device *dev, int new_mtu)
888{ 888{
889 int ret; 889 int ret;
890 struct adapter *adapter = dev->priv; 890 struct adapter *adapter = dev->ml_priv;
891 struct cmac *mac = adapter->port[dev->if_port].mac; 891 struct cmac *mac = adapter->port[dev->if_port].mac;
892 892
893 if (!mac->ops->set_mtu) 893 if (!mac->ops->set_mtu)
@@ -902,7 +902,7 @@ static int t1_change_mtu(struct net_device *dev, int new_mtu)
902 902
903static int t1_set_mac_addr(struct net_device *dev, void *p) 903static int t1_set_mac_addr(struct net_device *dev, void *p)
904{ 904{
905 struct adapter *adapter = dev->priv; 905 struct adapter *adapter = dev->ml_priv;
906 struct cmac *mac = adapter->port[dev->if_port].mac; 906 struct cmac *mac = adapter->port[dev->if_port].mac;
907 struct sockaddr *addr = p; 907 struct sockaddr *addr = p;
908 908
@@ -918,7 +918,7 @@ static int t1_set_mac_addr(struct net_device *dev, void *p)
918static void vlan_rx_register(struct net_device *dev, 918static void vlan_rx_register(struct net_device *dev,
919 struct vlan_group *grp) 919 struct vlan_group *grp)
920{ 920{
921 struct adapter *adapter = dev->priv; 921 struct adapter *adapter = dev->ml_priv;
922 922
923 spin_lock_irq(&adapter->async_lock); 923 spin_lock_irq(&adapter->async_lock);
924 adapter->vlan_grp = grp; 924 adapter->vlan_grp = grp;
@@ -931,7 +931,7 @@ static void vlan_rx_register(struct net_device *dev,
931static void t1_netpoll(struct net_device *dev) 931static void t1_netpoll(struct net_device *dev)
932{ 932{
933 unsigned long flags; 933 unsigned long flags;
934 struct adapter *adapter = dev->priv; 934 struct adapter *adapter = dev->ml_priv;
935 935
936 local_irq_save(flags); 936 local_irq_save(flags);
937 t1_interrupt(adapter->pdev->irq, adapter); 937 t1_interrupt(adapter->pdev->irq, adapter);
@@ -1077,7 +1077,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1077 SET_NETDEV_DEV(netdev, &pdev->dev); 1077 SET_NETDEV_DEV(netdev, &pdev->dev);
1078 1078
1079 if (!adapter) { 1079 if (!adapter) {
1080 adapter = netdev->priv; 1080 adapter = netdev_priv(netdev);
1081 adapter->pdev = pdev; 1081 adapter->pdev = pdev;
1082 adapter->port[0].dev = netdev; /* so we don't leak it */ 1082 adapter->port[0].dev = netdev; /* so we don't leak it */
1083 1083
@@ -1118,7 +1118,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1118 netdev->if_port = i; 1118 netdev->if_port = i;
1119 netdev->mem_start = mmio_start; 1119 netdev->mem_start = mmio_start;
1120 netdev->mem_end = mmio_start + mmio_len - 1; 1120 netdev->mem_end = mmio_start + mmio_len - 1;
1121 netdev->priv = adapter; 1121 netdev->ml_priv = adapter;
1122 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; 1122 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
1123 netdev->features |= NETIF_F_LLTX; 1123 netdev->features |= NETIF_F_LLTX;
1124 1124
@@ -1382,7 +1382,7 @@ static inline void t1_sw_reset(struct pci_dev *pdev)
1382static void __devexit remove_one(struct pci_dev *pdev) 1382static void __devexit remove_one(struct pci_dev *pdev)
1383{ 1383{
1384 struct net_device *dev = pci_get_drvdata(pdev); 1384 struct net_device *dev = pci_get_drvdata(pdev);
1385 struct adapter *adapter = dev->priv; 1385 struct adapter *adapter = dev->ml_priv;
1386 int i; 1386 int i;
1387 1387
1388 for_each_port(adapter, i) { 1388 for_each_port(adapter, i) {
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index d6c7d2aa761b..ca80289fc04d 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -1385,7 +1385,6 @@ static void sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len)
1385 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id()); 1385 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id());
1386 1386
1387 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev); 1387 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev);
1388 skb->dev->last_rx = jiffies;
1389 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff && 1388 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff &&
1390 skb->protocol == htons(ETH_P_IP) && 1389 skb->protocol == htons(ETH_P_IP) &&
1391 (skb->data[9] == IPPROTO_TCP || skb->data[9] == IPPROTO_UDP)) { 1390 (skb->data[9] == IPPROTO_TCP || skb->data[9] == IPPROTO_UDP)) {
@@ -1786,7 +1785,7 @@ static inline int eth_hdr_len(const void *data)
1786 */ 1785 */
1787int t1_start_xmit(struct sk_buff *skb, struct net_device *dev) 1786int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1788{ 1787{
1789 struct adapter *adapter = dev->priv; 1788 struct adapter *adapter = dev->ml_priv;
1790 struct sge *sge = adapter->sge; 1789 struct sge *sge = adapter->sge;
1791 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port], 1790 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port],
1792 smp_processor_id()); 1791 smp_processor_id());
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 017a5361b980..d39a77cba1af 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1103,7 +1103,6 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1103 struct cpmac_priv *priv; 1103 struct cpmac_priv *priv;
1104 struct net_device *dev; 1104 struct net_device *dev;
1105 struct plat_cpmac_data *pdata; 1105 struct plat_cpmac_data *pdata;
1106 DECLARE_MAC_BUF(mac);
1107 1106
1108 pdata = pdev->dev.platform_data; 1107 pdata = pdev->dev.platform_data;
1109 1108
@@ -1180,8 +1179,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1180 if (netif_msg_probe(priv)) { 1179 if (netif_msg_probe(priv)) {
1181 printk(KERN_INFO 1180 printk(KERN_INFO
1182 "cpmac: device %s (regs: %p, irq: %d, phy: %s, " 1181 "cpmac: device %s (regs: %p, irq: %d, phy: %s, "
1183 "mac: %s)\n", dev->name, (void *)mem->start, dev->irq, 1182 "mac: %pM)\n", dev->name, (void *)mem->start, dev->irq,
1184 priv->phy_name, print_mac(mac, dev->dev_addr)); 1183 priv->phy_name, dev->dev_addr);
1185 } 1184 }
1186 return 0; 1185 return 0;
1187 1186
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 7e8a63106bdf..c9806c58b2fd 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -419,7 +419,6 @@ e100_set_mac_address(struct net_device *dev, void *p)
419{ 419{
420 struct net_local *np = netdev_priv(dev); 420 struct net_local *np = netdev_priv(dev);
421 struct sockaddr *addr = p; 421 struct sockaddr *addr = p;
422 DECLARE_MAC_BUF(mac);
423 422
424 spin_lock(&np->lock); /* preemption protection */ 423 spin_lock(&np->lock); /* preemption protection */
425 424
@@ -440,8 +439,7 @@ e100_set_mac_address(struct net_device *dev, void *p)
440 439
441 /* show it in the log as well */ 440 /* show it in the log as well */
442 441
443 printk(KERN_INFO "%s: changed MAC to %s\n", 442 printk(KERN_INFO "%s: changed MAC to %pM\n", dev->name, dev->dev_addr);
444 dev->name, print_mac(mac, dev->dev_addr));
445 443
446 spin_unlock(&np->lock); 444 spin_unlock(&np->lock);
447 445
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 7107620f615d..b063395c4a96 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -521,7 +521,6 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
521 unsigned rev_type = 0; 521 unsigned rev_type = 0;
522 int eeprom_buff[CHKSUM_LEN]; 522 int eeprom_buff[CHKSUM_LEN];
523 int retval; 523 int retval;
524 DECLARE_MAC_BUF(mac);
525 524
526 /* Initialize the device structure. */ 525 /* Initialize the device structure. */
527 if (!modular) { 526 if (!modular) {
@@ -846,7 +845,7 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
846 } 845 }
847 846
848 /* print the ethernet address. */ 847 /* print the ethernet address. */
849 printk(", MAC %s", print_mac(mac, dev->dev_addr)); 848 printk(", MAC %pM", dev->dev_addr);
850 849
851 dev->open = net_open; 850 dev->open = net_open;
852 dev->stop = net_close; 851 dev->stop = net_close;
@@ -1025,7 +1024,6 @@ skip_this_frame:
1025 } 1024 }
1026 skb->protocol=eth_type_trans(skb,dev); 1025 skb->protocol=eth_type_trans(skb,dev);
1027 netif_rx(skb); 1026 netif_rx(skb);
1028 dev->last_rx = jiffies;
1029 lp->stats.rx_packets++; 1027 lp->stats.rx_packets++;
1030 lp->stats.rx_bytes += length; 1028 lp->stats.rx_bytes += length;
1031} 1029}
@@ -1719,7 +1717,6 @@ net_rx(struct net_device *dev)
1719 1717
1720 skb->protocol=eth_type_trans(skb,dev); 1718 skb->protocol=eth_type_trans(skb,dev);
1721 netif_rx(skb); 1719 netif_rx(skb);
1722 dev->last_rx = jiffies;
1723 lp->stats.rx_packets++; 1720 lp->stats.rx_packets++;
1724 lp->stats.rx_bytes += length; 1721 lp->stats.rx_bytes += length;
1725} 1722}
@@ -1817,11 +1814,10 @@ static int set_mac_address(struct net_device *dev, void *p)
1817 1814
1818 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 1815 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
1819 1816
1820 if (net_debug) { 1817 if (net_debug)
1821 DECLARE_MAC_BUF(mac); 1818 printk("%s: Setting MAC address to %pM.\n",
1822 printk("%s: Setting MAC address to %s.\n", 1819 dev->name, dev->dev_addr);
1823 dev->name, print_mac(mac, dev->dev_addr)); 1820
1824 }
1825 /* set the Ethernet address */ 1821 /* set the Ethernet address */
1826 for (i=0; i < ETH_ALEN/2; i++) 1822 for (i=0; i < ETH_ALEN/2; i++)
1827 writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8)); 1823 writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8));
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 2c341f83d327..b6b2a46b7d0e 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -494,6 +494,36 @@ static void enable_all_napi(struct adapter *adap)
494} 494}
495 495
496/** 496/**
497 * set_qset_lro - Turn a queue set's LRO capability on and off
498 * @dev: the device the qset is attached to
499 * @qset_idx: the queue set index
500 * @val: the LRO switch
501 *
502 * Sets LRO on or off for a particular queue set.
503 * the device's features flag is updated to reflect the LRO
504 * capability when all queues belonging to the device are
505 * in the same state.
506 */
507static void set_qset_lro(struct net_device *dev, int qset_idx, int val)
508{
509 struct port_info *pi = netdev_priv(dev);
510 struct adapter *adapter = pi->adapter;
511 int i, lro_on = 1;
512
513 adapter->params.sge.qset[qset_idx].lro = !!val;
514 adapter->sge.qs[qset_idx].lro_enabled = !!val;
515
516 /* let ethtool report LRO on only if all queues are LRO enabled */
517 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; ++i)
518 lro_on &= adapter->params.sge.qset[i].lro;
519
520 if (lro_on)
521 dev->features |= NETIF_F_LRO;
522 else
523 dev->features &= ~NETIF_F_LRO;
524}
525
526/**
497 * setup_sge_qsets - configure SGE Tx/Rx/response queues 527 * setup_sge_qsets - configure SGE Tx/Rx/response queues
498 * @adap: the adapter 528 * @adap: the adapter
499 * 529 *
@@ -516,8 +546,7 @@ static int setup_sge_qsets(struct adapter *adap)
516 pi->qs = &adap->sge.qs[pi->first_qset]; 546 pi->qs = &adap->sge.qs[pi->first_qset];
517 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets; 547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets;
518 ++j, ++qset_idx) { 548 ++j, ++qset_idx) {
519 if (!pi->rx_csum_offload) 549 set_qset_lro(dev, qset_idx, pi->rx_csum_offload);
520 adap->params.sge.qset[qset_idx].lro = 0;
521 err = t3_sge_alloc_qset(adap, qset_idx, 1, 550 err = t3_sge_alloc_qset(adap, qset_idx, 1,
522 (adap->flags & USING_MSIX) ? qset_idx + 1 : 551 (adap->flags & USING_MSIX) ? qset_idx + 1 :
523 irq_idx, 552 irq_idx,
@@ -1634,13 +1663,10 @@ static int set_rx_csum(struct net_device *dev, u32 data)
1634 1663
1635 p->rx_csum_offload = data; 1664 p->rx_csum_offload = data;
1636 if (!data) { 1665 if (!data) {
1637 struct adapter *adap = p->adapter;
1638 int i; 1666 int i;
1639 1667
1640 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) { 1668 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++)
1641 adap->params.sge.qset[i].lro = 0; 1669 set_qset_lro(dev, i, 0);
1642 adap->sge.qs[i].lro_enabled = 0;
1643 }
1644 } 1670 }
1645 return 0; 1671 return 0;
1646} 1672}
@@ -1795,6 +1821,25 @@ static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1795 memset(&wol->sopass, 0, sizeof(wol->sopass)); 1821 memset(&wol->sopass, 0, sizeof(wol->sopass));
1796} 1822}
1797 1823
1824static int cxgb3_set_flags(struct net_device *dev, u32 data)
1825{
1826 struct port_info *pi = netdev_priv(dev);
1827 int i;
1828
1829 if (data & ETH_FLAG_LRO) {
1830 if (!pi->rx_csum_offload)
1831 return -EINVAL;
1832
1833 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1834 set_qset_lro(dev, i, 1);
1835
1836 } else
1837 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1838 set_qset_lro(dev, i, 0);
1839
1840 return 0;
1841}
1842
1798static const struct ethtool_ops cxgb_ethtool_ops = { 1843static const struct ethtool_ops cxgb_ethtool_ops = {
1799 .get_settings = get_settings, 1844 .get_settings = get_settings,
1800 .set_settings = set_settings, 1845 .set_settings = set_settings,
@@ -1824,6 +1869,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
1824 .get_regs = get_regs, 1869 .get_regs = get_regs,
1825 .get_wol = get_wol, 1870 .get_wol = get_wol,
1826 .set_tso = ethtool_op_set_tso, 1871 .set_tso = ethtool_op_set_tso,
1872 .get_flags = ethtool_op_get_flags,
1873 .set_flags = cxgb3_set_flags,
1827}; 1874};
1828 1875
1829static int in_range(int val, int lo, int hi) 1876static int in_range(int val, int lo, int hi)
@@ -1940,11 +1987,9 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1940 } 1987 }
1941 } 1988 }
1942 } 1989 }
1943 if (t.lro >= 0) { 1990 if (t.lro >= 0)
1944 struct sge_qset *qs = &adapter->sge.qs[t.qset_idx]; 1991 set_qset_lro(dev, t.qset_idx, t.lro);
1945 q->lro = t.lro; 1992
1946 qs->lro_enabled = t.lro;
1947 }
1948 break; 1993 break;
1949 } 1994 }
1950 case CHELSIO_GET_QSET_PARAMS:{ 1995 case CHELSIO_GET_QSET_PARAMS:{
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index c6480be0bc1f..268f15801ec6 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1876,7 +1876,6 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq,
1876 1876
1877 skb_pull(skb, sizeof(*p) + pad); 1877 skb_pull(skb, sizeof(*p) + pad);
1878 skb->protocol = eth_type_trans(skb, adap->port[p->iff]); 1878 skb->protocol = eth_type_trans(skb, adap->port[p->iff]);
1879 skb->dev->last_rx = jiffies;
1880 pi = netdev_priv(skb->dev); 1879 pi = netdev_priv(skb->dev);
1881 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) && 1880 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) &&
1882 !p->fragment) { 1881 !p->fragment) {
diff --git a/drivers/net/de600.c b/drivers/net/de600.c
index cb849b091f98..970f820ba814 100644
--- a/drivers/net/de600.c
+++ b/drivers/net/de600.c
@@ -369,7 +369,6 @@ static void de600_rx_intr(struct net_device *dev)
369 netif_rx(skb); 369 netif_rx(skb);
370 370
371 /* update stats */ 371 /* update stats */
372 dev->last_rx = jiffies;
373 dev->stats.rx_packets++; /* count all receives */ 372 dev->stats.rx_packets++; /* count all receives */
374 dev->stats.rx_bytes += size; /* count all received bytes */ 373 dev->stats.rx_bytes += size; /* count all received bytes */
375 374
@@ -384,7 +383,6 @@ static struct net_device * __init de600_probe(void)
384 int i; 383 int i;
385 struct net_device *dev; 384 struct net_device *dev;
386 int err; 385 int err;
387 DECLARE_MAC_BUF(mac);
388 386
389 dev = alloc_etherdev(0); 387 dev = alloc_etherdev(0);
390 if (!dev) 388 if (!dev)
@@ -439,7 +437,7 @@ static struct net_device * __init de600_probe(void)
439 goto out1; 437 goto out1;
440 } 438 }
441 439
442 printk(", Ethernet Address: %s\n", print_mac(mac, dev->dev_addr)); 440 printk(", Ethernet Address: %pM\n", dev->dev_addr);
443 441
444 dev->open = de600_open; 442 dev->open = de600_open;
445 dev->stop = de600_close; 443 dev->stop = de600_close;
diff --git a/drivers/net/de620.c b/drivers/net/de620.c
index d454e143483e..0d4b6acc11a6 100644
--- a/drivers/net/de620.c
+++ b/drivers/net/de620.c
@@ -686,7 +686,6 @@ static int de620_rx_intr(struct net_device *dev)
686 PRINTK(("Read %d bytes\n", size)); 686 PRINTK(("Read %d bytes\n", size));
687 skb->protocol=eth_type_trans(skb,dev); 687 skb->protocol=eth_type_trans(skb,dev);
688 netif_rx(skb); /* deliver it "upstairs" */ 688 netif_rx(skb); /* deliver it "upstairs" */
689 dev->last_rx = jiffies;
690 /* count all receives */ 689 /* count all receives */
691 dev->stats.rx_packets++; 690 dev->stats.rx_packets++;
692 dev->stats.rx_bytes += size; 691 dev->stats.rx_bytes += size;
@@ -800,7 +799,6 @@ struct net_device * __init de620_probe(int unit)
800 struct net_device *dev; 799 struct net_device *dev;
801 int err = -ENOMEM; 800 int err = -ENOMEM;
802 int i; 801 int i;
803 DECLARE_MAC_BUF(mac);
804 802
805 dev = alloc_etherdev(0); 803 dev = alloc_etherdev(0);
806 if (!dev) 804 if (!dev)
@@ -853,7 +851,7 @@ struct net_device * __init de620_probe(int unit)
853 dev->broadcast[i] = 0xff; 851 dev->broadcast[i] = 0xff;
854 } 852 }
855 853
856 printk(", Ethernet Address: %s", print_mac(mac, dev->dev_addr)); 854 printk(", Ethernet Address: %pM", dev->dev_addr);
857 855
858 printk(" (%dk RAM,", 856 printk(" (%dk RAM,",
859 (nic_data.RAM_Size) ? (nic_data.RAM_Size >> 2) : 64); 857 (nic_data.RAM_Size) ? (nic_data.RAM_Size >> 2) : 64);
@@ -876,10 +874,7 @@ struct net_device * __init de620_probe(int unit)
876 if (de620_debug) { 874 if (de620_debug) {
877 printk("\nEEPROM contents:\n"); 875 printk("\nEEPROM contents:\n");
878 printk("RAM_Size = 0x%02X\n", nic_data.RAM_Size); 876 printk("RAM_Size = 0x%02X\n", nic_data.RAM_Size);
879 printk("NodeID = %02X:%02X:%02X:%02X:%02X:%02X\n", 877 printk("NodeID = %pM\n", nic_data.NodeID);
880 nic_data.NodeID[0], nic_data.NodeID[1],
881 nic_data.NodeID[2], nic_data.NodeID[3],
882 nic_data.NodeID[4], nic_data.NodeID[5]);
883 printk("Model = %d\n", nic_data.Model); 878 printk("Model = %d\n", nic_data.Model);
884 printk("Media = %d\n", nic_data.Media); 879 printk("Media = %d\n", nic_data.Media);
885 printk("SCR = 0x%02x\n", nic_data.SCR); 880 printk("SCR = 0x%02x\n", nic_data.SCR);
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 3e3506411ac0..7ce3053530f9 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -622,7 +622,6 @@ static int lance_rx(struct net_device *dev)
622 622
623 skb->protocol = eth_type_trans(skb, dev); 623 skb->protocol = eth_type_trans(skb, dev);
624 netif_rx(skb); 624 netif_rx(skb);
625 dev->last_rx = jiffies;
626 dev->stats.rx_packets++; 625 dev->stats.rx_packets++;
627 } 626 }
628 627
@@ -1023,7 +1022,6 @@ static int __init dec_lance_probe(struct device *bdev, const int type)
1023 int i, ret; 1022 int i, ret;
1024 unsigned long esar_base; 1023 unsigned long esar_base;
1025 unsigned char *esar; 1024 unsigned char *esar;
1026 DECLARE_MAC_BUF(mac);
1027 1025
1028 if (dec_lance_debug && version_printed++ == 0) 1026 if (dec_lance_debug && version_printed++ == 0)
1029 printk(version); 1027 printk(version);
@@ -1035,7 +1033,7 @@ static int __init dec_lance_probe(struct device *bdev, const int type)
1035 dev = root_lance_dev; 1033 dev = root_lance_dev;
1036 while (dev) { 1034 while (dev) {
1037 i++; 1035 i++;
1038 lp = (struct lance_private *)dev->priv; 1036 lp = netdev_priv(dev);
1039 dev = lp->next; 1037 dev = lp->next;
1040 } 1038 }
1041 snprintf(name, sizeof(name), fmt, i); 1039 snprintf(name, sizeof(name), fmt, i);
@@ -1223,8 +1221,7 @@ static int __init dec_lance_probe(struct device *bdev, const int type)
1223 for (i = 0; i < 6; i++) 1221 for (i = 0; i < 6; i++)
1224 dev->dev_addr[i] = esar[i * 4]; 1222 dev->dev_addr[i] = esar[i * 4];
1225 1223
1226 printk(", addr = %s, irq = %d\n", 1224 printk(", addr = %pM, irq = %d\n", dev->dev_addr, dev->irq);
1227 print_mac(mac, dev->dev_addr), dev->irq);
1228 1225
1229 dev->open = &lance_open; 1226 dev->open = &lance_open;
1230 dev->stop = &lance_close; 1227 dev->stop = &lance_close;
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index c062aacf229c..6e6583b609f7 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -511,7 +511,7 @@ static int __devinit dfx_register(struct device *bdev)
511 int dfx_bus_pci = DFX_BUS_PCI(bdev); 511 int dfx_bus_pci = DFX_BUS_PCI(bdev);
512 int dfx_bus_tc = DFX_BUS_TC(bdev); 512 int dfx_bus_tc = DFX_BUS_TC(bdev);
513 int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; 513 int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
514 char *print_name = bdev->bus_id; 514 const char *print_name = dev_name(bdev);
515 struct net_device *dev; 515 struct net_device *dev;
516 DFX_board_t *bp; /* board pointer */ 516 DFX_board_t *bp; /* board pointer */
517 resource_size_t bar_start = 0; /* pointer to port */ 517 resource_size_t bar_start = 0; /* pointer to port */
@@ -3103,7 +3103,6 @@ static void dfx_rcv_queue_process(
3103 netif_rx(skb); 3103 netif_rx(skb);
3104 3104
3105 /* Update the rcv counters */ 3105 /* Update the rcv counters */
3106 bp->dev->last_rx = jiffies;
3107 bp->rcv_total_frames++; 3106 bp->rcv_total_frames++;
3108 if (*(p_buff + RCV_BUFF_K_DA) & 0x01) 3107 if (*(p_buff + RCV_BUFF_K_DA) & 0x01)
3109 bp->rcv_multicast_frames++; 3108 bp->rcv_multicast_frames++;
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index ace39ec0a367..ec34f03cb982 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -573,7 +573,6 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device)
573 s16 nicsr; 573 s16 nicsr;
574 u_long ioaddr; 574 u_long ioaddr;
575 u_long mem_start; 575 u_long mem_start;
576 DECLARE_MAC_BUF(mac);
577 576
578 /* 577 /*
579 * We are now supposed to enter this function with the 578 * We are now supposed to enter this function with the
@@ -601,7 +600,7 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device)
601 return -ENXIO; 600 return -ENXIO;
602 } 601 }
603 602
604 lp = (struct depca_private *) dev->priv; 603 lp = netdev_priv(dev);
605 mem_start = lp->mem_start; 604 mem_start = lp->mem_start;
606 605
607 if (!mem_start || lp->adapter < DEPCA || lp->adapter >=unknown) 606 if (!mem_start || lp->adapter < DEPCA || lp->adapter >=unknown)
@@ -633,7 +632,7 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device)
633 632
634 printk(", h/w address "); 633 printk(", h/w address ");
635 status = get_hw_addr(dev); 634 status = get_hw_addr(dev);
636 printk("%s", print_mac(mac, dev->dev_addr)); 635 printk("%pM", dev->dev_addr);
637 if (status != 0) { 636 if (status != 0) {
638 printk(" which has an Ethernet PROM CRC error.\n"); 637 printk(" which has an Ethernet PROM CRC error.\n");
639 return -ENXIO; 638 return -ENXIO;
@@ -821,7 +820,7 @@ out_priv:
821 820
822static int depca_open(struct net_device *dev) 821static int depca_open(struct net_device *dev)
823{ 822{
824 struct depca_private *lp = (struct depca_private *) dev->priv; 823 struct depca_private *lp = netdev_priv(dev);
825 u_long ioaddr = dev->base_addr; 824 u_long ioaddr = dev->base_addr;
826 s16 nicsr; 825 s16 nicsr;
827 int status = 0; 826 int status = 0;
@@ -866,7 +865,7 @@ static int depca_open(struct net_device *dev)
866/* Initialize the lance Rx and Tx descriptor rings. */ 865/* Initialize the lance Rx and Tx descriptor rings. */
867static void depca_init_ring(struct net_device *dev) 866static void depca_init_ring(struct net_device *dev)
868{ 867{
869 struct depca_private *lp = (struct depca_private *) dev->priv; 868 struct depca_private *lp = netdev_priv(dev);
870 u_int i; 869 u_int i;
871 u_long offset; 870 u_long offset;
872 871
@@ -924,7 +923,7 @@ static void depca_tx_timeout(struct net_device *dev)
924*/ 923*/
925static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev) 924static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev)
926{ 925{
927 struct depca_private *lp = (struct depca_private *) dev->priv; 926 struct depca_private *lp = netdev_priv(dev);
928 u_long ioaddr = dev->base_addr; 927 u_long ioaddr = dev->base_addr;
929 int status = 0; 928 int status = 0;
930 929
@@ -972,7 +971,7 @@ static irqreturn_t depca_interrupt(int irq, void *dev_id)
972 return IRQ_NONE; 971 return IRQ_NONE;
973 } 972 }
974 973
975 lp = (struct depca_private *) dev->priv; 974 lp = netdev_priv(dev);
976 ioaddr = dev->base_addr; 975 ioaddr = dev->base_addr;
977 976
978 spin_lock(&lp->lock); 977 spin_lock(&lp->lock);
@@ -1010,7 +1009,7 @@ static irqreturn_t depca_interrupt(int irq, void *dev_id)
1010/* Called with lp->lock held */ 1009/* Called with lp->lock held */
1011static int depca_rx(struct net_device *dev) 1010static int depca_rx(struct net_device *dev)
1012{ 1011{
1013 struct depca_private *lp = (struct depca_private *) dev->priv; 1012 struct depca_private *lp = netdev_priv(dev);
1014 int i, entry; 1013 int i, entry;
1015 s32 status; 1014 s32 status;
1016 1015
@@ -1057,7 +1056,6 @@ static int depca_rx(struct net_device *dev)
1057 /* 1056 /*
1058 ** Update stats 1057 ** Update stats
1059 */ 1058 */
1060 dev->last_rx = jiffies;
1061 dev->stats.rx_packets++; 1059 dev->stats.rx_packets++;
1062 dev->stats.rx_bytes += pkt_len; 1060 dev->stats.rx_bytes += pkt_len;
1063 for (i = 1; i < DEPCA_PKT_STAT_SZ - 1; i++) { 1061 for (i = 1; i < DEPCA_PKT_STAT_SZ - 1; i++) {
@@ -1108,7 +1106,7 @@ static int depca_rx(struct net_device *dev)
1108*/ 1106*/
1109static int depca_tx(struct net_device *dev) 1107static int depca_tx(struct net_device *dev)
1110{ 1108{
1111 struct depca_private *lp = (struct depca_private *) dev->priv; 1109 struct depca_private *lp = netdev_priv(dev);
1112 int entry; 1110 int entry;
1113 s32 status; 1111 s32 status;
1114 u_long ioaddr = dev->base_addr; 1112 u_long ioaddr = dev->base_addr;
@@ -1149,7 +1147,7 @@ static int depca_tx(struct net_device *dev)
1149 1147
1150static int depca_close(struct net_device *dev) 1148static int depca_close(struct net_device *dev)
1151{ 1149{
1152 struct depca_private *lp = (struct depca_private *) dev->priv; 1150 struct depca_private *lp = netdev_priv(dev);
1153 s16 nicsr; 1151 s16 nicsr;
1154 u_long ioaddr = dev->base_addr; 1152 u_long ioaddr = dev->base_addr;
1155 1153
@@ -1185,7 +1183,7 @@ static int depca_close(struct net_device *dev)
1185 1183
1186static void LoadCSRs(struct net_device *dev) 1184static void LoadCSRs(struct net_device *dev)
1187{ 1185{
1188 struct depca_private *lp = (struct depca_private *) dev->priv; 1186 struct depca_private *lp = netdev_priv(dev);
1189 u_long ioaddr = dev->base_addr; 1187 u_long ioaddr = dev->base_addr;
1190 1188
1191 outw(CSR1, DEPCA_ADDR); /* initialisation block address LSW */ 1189 outw(CSR1, DEPCA_ADDR); /* initialisation block address LSW */
@@ -1202,7 +1200,7 @@ static void LoadCSRs(struct net_device *dev)
1202 1200
1203static int InitRestartDepca(struct net_device *dev) 1201static int InitRestartDepca(struct net_device *dev)
1204{ 1202{
1205 struct depca_private *lp = (struct depca_private *) dev->priv; 1203 struct depca_private *lp = netdev_priv(dev);
1206 u_long ioaddr = dev->base_addr; 1204 u_long ioaddr = dev->base_addr;
1207 int i, status = 0; 1205 int i, status = 0;
1208 1206
@@ -1234,7 +1232,7 @@ static int InitRestartDepca(struct net_device *dev)
1234*/ 1232*/
1235static void set_multicast_list(struct net_device *dev) 1233static void set_multicast_list(struct net_device *dev)
1236{ 1234{
1237 struct depca_private *lp = (struct depca_private *) dev->priv; 1235 struct depca_private *lp = netdev_priv(dev);
1238 u_long ioaddr = dev->base_addr; 1236 u_long ioaddr = dev->base_addr;
1239 1237
1240 netif_stop_queue(dev); 1238 netif_stop_queue(dev);
@@ -1263,7 +1261,7 @@ static void set_multicast_list(struct net_device *dev)
1263*/ 1261*/
1264static void SetMulticastFilter(struct net_device *dev) 1262static void SetMulticastFilter(struct net_device *dev)
1265{ 1263{
1266 struct depca_private *lp = (struct depca_private *) dev->priv; 1264 struct depca_private *lp = netdev_priv(dev);
1267 struct dev_mc_list *dmi = dev->mc_list; 1265 struct dev_mc_list *dmi = dev->mc_list;
1268 char *addrs; 1266 char *addrs;
1269 int i, j, bit, byte; 1267 int i, j, bit, byte;
@@ -1431,7 +1429,7 @@ static int __init depca_mca_probe(struct device *device)
1431 1429
1432 dev->irq = irq; 1430 dev->irq = irq;
1433 dev->base_addr = iobase; 1431 dev->base_addr = iobase;
1434 lp = dev->priv; 1432 lp = netdev_priv(dev);
1435 lp->depca_bus = DEPCA_BUS_MCA; 1433 lp->depca_bus = DEPCA_BUS_MCA;
1436 lp->adapter = depca_mca_adapter_type[mdev->index]; 1434 lp->adapter = depca_mca_adapter_type[mdev->index];
1437 lp->mem_start = mem_start; 1435 lp->mem_start = mem_start;
@@ -1534,7 +1532,7 @@ static int __init depca_isa_probe (struct platform_device *device)
1534 dev->base_addr = ioaddr; 1532 dev->base_addr = ioaddr;
1535 dev->irq = irq; /* Use whatever value the user gave 1533 dev->irq = irq; /* Use whatever value the user gave
1536 * us, and 0 if he didn't. */ 1534 * us, and 0 if he didn't. */
1537 lp = dev->priv; 1535 lp = netdev_priv(dev);
1538 lp->depca_bus = DEPCA_BUS_ISA; 1536 lp->depca_bus = DEPCA_BUS_ISA;
1539 lp->adapter = adapter; 1537 lp->adapter = adapter;
1540 lp->mem_start = mem_start; 1538 lp->mem_start = mem_start;
@@ -1580,7 +1578,7 @@ static int __init depca_eisa_probe (struct device *device)
1580 1578
1581 dev->base_addr = ioaddr; 1579 dev->base_addr = ioaddr;
1582 dev->irq = irq; 1580 dev->irq = irq;
1583 lp = dev->priv; 1581 lp = netdev_priv(dev);
1584 lp->depca_bus = DEPCA_BUS_EISA; 1582 lp->depca_bus = DEPCA_BUS_EISA;
1585 lp->adapter = edev->id.driver_data; 1583 lp->adapter = edev->id.driver_data;
1586 lp->mem_start = mem_start; 1584 lp->mem_start = mem_start;
@@ -1605,7 +1603,7 @@ static int __devexit depca_device_remove (struct device *device)
1605 int bus; 1603 int bus;
1606 1604
1607 dev = device->driver_data; 1605 dev = device->driver_data;
1608 lp = dev->priv; 1606 lp = netdev_priv(dev);
1609 1607
1610 unregister_netdev (dev); 1608 unregister_netdev (dev);
1611 iounmap (lp->sh_mem); 1609 iounmap (lp->sh_mem);
@@ -1747,7 +1745,7 @@ static int __init DevicePresent(u_long ioaddr)
1747static int __init get_hw_addr(struct net_device *dev) 1745static int __init get_hw_addr(struct net_device *dev)
1748{ 1746{
1749 u_long ioaddr = dev->base_addr; 1747 u_long ioaddr = dev->base_addr;
1750 struct depca_private *lp = dev->priv; 1748 struct depca_private *lp = netdev_priv(dev);
1751 int i, k, tmp, status = 0; 1749 int i, k, tmp, status = 0;
1752 u_short j, x, chksum; 1750 u_short j, x, chksum;
1753 1751
@@ -1782,7 +1780,7 @@ static int __init get_hw_addr(struct net_device *dev)
1782*/ 1780*/
1783static int load_packet(struct net_device *dev, struct sk_buff *skb) 1781static int load_packet(struct net_device *dev, struct sk_buff *skb)
1784{ 1782{
1785 struct depca_private *lp = (struct depca_private *) dev->priv; 1783 struct depca_private *lp = netdev_priv(dev);
1786 int i, entry, end, len, status = 0; 1784 int i, entry, end, len, status = 0;
1787 1785
1788 entry = lp->tx_new; /* Ring around buffer number. */ 1786 entry = lp->tx_new; /* Ring around buffer number. */
@@ -1837,11 +1835,10 @@ static int load_packet(struct net_device *dev, struct sk_buff *skb)
1837 1835
1838static void depca_dbg_open(struct net_device *dev) 1836static void depca_dbg_open(struct net_device *dev)
1839{ 1837{
1840 struct depca_private *lp = (struct depca_private *) dev->priv; 1838 struct depca_private *lp = netdev_priv(dev);
1841 u_long ioaddr = dev->base_addr; 1839 u_long ioaddr = dev->base_addr;
1842 struct depca_init *p = &lp->init_block; 1840 struct depca_init *p = &lp->init_block;
1843 int i; 1841 int i;
1844 DECLARE_MAC_BUF(mac);
1845 1842
1846 if (depca_debug > 1) { 1843 if (depca_debug > 1) {
1847 /* Do not copy the shadow init block into shared memory */ 1844 /* Do not copy the shadow init block into shared memory */
@@ -1880,7 +1877,7 @@ static void depca_dbg_open(struct net_device *dev)
1880 printk("...0x%8.8x\n", readl(&lp->tx_ring[i].base)); 1877 printk("...0x%8.8x\n", readl(&lp->tx_ring[i].base));
1881 printk("Initialisation block at 0x%8.8lx(Phys)\n", lp->mem_start); 1878 printk("Initialisation block at 0x%8.8lx(Phys)\n", lp->mem_start);
1882 printk(" mode: 0x%4.4x\n", p->mode); 1879 printk(" mode: 0x%4.4x\n", p->mode);
1883 printk(" physical address: %s\n", print_mac(mac, p->phys_addr)); 1880 printk(" physical address: %pM\n", p->phys_addr);
1884 printk(" multicast hash table: "); 1881 printk(" multicast hash table: ");
1885 for (i = 0; i < (HASH_TABLE_LEN >> 3) - 1; i++) { 1882 for (i = 0; i < (HASH_TABLE_LEN >> 3) - 1; i++) {
1886 printk("%2.2x:", p->mcast_table[i]); 1883 printk("%2.2x:", p->mcast_table[i]);
@@ -1909,7 +1906,7 @@ static void depca_dbg_open(struct net_device *dev)
1909*/ 1906*/
1910static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1907static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1911{ 1908{
1912 struct depca_private *lp = (struct depca_private *) dev->priv; 1909 struct depca_private *lp = netdev_priv(dev);
1913 struct depca_ioctl *ioc = (struct depca_ioctl *) &rq->ifr_ifru; 1910 struct depca_ioctl *ioc = (struct depca_ioctl *) &rq->ifr_ifru;
1914 int i, status = 0; 1911 int i, status = 0;
1915 u_long ioaddr = dev->base_addr; 1912 u_long ioaddr = dev->base_addr;
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index f8037110a522..9ec9785a9fc3 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -97,7 +97,6 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
97 static int version_printed; 97 static int version_printed;
98 void *ring_space; 98 void *ring_space;
99 dma_addr_t ring_dma; 99 dma_addr_t ring_dma;
100 DECLARE_MAC_BUF(mac);
101 100
102 if (!version_printed++) 101 if (!version_printed++)
103 printk ("%s", version); 102 printk ("%s", version);
@@ -257,8 +256,8 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
257 256
258 card_idx++; 257 card_idx++;
259 258
260 printk (KERN_INFO "%s: %s, %s, IRQ %d\n", 259 printk (KERN_INFO "%s: %s, %pM, IRQ %d\n",
261 dev->name, np->name, print_mac(mac, dev->dev_addr), irq); 260 dev->name, np->name, dev->dev_addr, irq);
262 if (tx_coalesce > 1) 261 if (tx_coalesce > 1)
263 printk(KERN_INFO "tx_coalesce:\t%d packets\n", 262 printk(KERN_INFO "tx_coalesce:\t%d packets\n",
264 tx_coalesce); 263 tx_coalesce);
@@ -892,7 +891,6 @@ receive_packet (struct net_device *dev)
892 } 891 }
893#endif 892#endif
894 netif_rx (skb); 893 netif_rx (skb);
895 dev->last_rx = jiffies;
896 } 894 }
897 entry = (entry + 1) % RX_RING_SIZE; 895 entry = (entry + 1) % RX_RING_SIZE;
898 } 896 }
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 5a9083e3f443..bcf92917bbf3 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -137,7 +137,7 @@ typedef struct board_info {
137 137
138static inline board_info_t *to_dm9000_board(struct net_device *dev) 138static inline board_info_t *to_dm9000_board(struct net_device *dev)
139{ 139{
140 return dev->priv; 140 return netdev_priv(dev);
141} 141}
142 142
143/* DM9000 network board routine ---------------------------- */ 143/* DM9000 network board routine ---------------------------- */
@@ -626,7 +626,7 @@ static unsigned char dm9000_type_to_char(enum dm9000_type type)
626static void 626static void
627dm9000_hash_table(struct net_device *dev) 627dm9000_hash_table(struct net_device *dev)
628{ 628{
629 board_info_t *db = (board_info_t *) dev->priv; 629 board_info_t *db = netdev_priv(dev);
630 struct dev_mc_list *mcptr = dev->mc_list; 630 struct dev_mc_list *mcptr = dev->mc_list;
631 int mc_cnt = dev->mc_count; 631 int mc_cnt = dev->mc_count;
632 int i, oft; 632 int i, oft;
@@ -677,7 +677,7 @@ dm9000_hash_table(struct net_device *dev)
677static void 677static void
678dm9000_init_dm9000(struct net_device *dev) 678dm9000_init_dm9000(struct net_device *dev)
679{ 679{
680 board_info_t *db = dev->priv; 680 board_info_t *db = netdev_priv(dev);
681 unsigned int imr; 681 unsigned int imr;
682 682
683 dm9000_dbg(db, 1, "entering %s\n", __func__); 683 dm9000_dbg(db, 1, "entering %s\n", __func__);
@@ -723,7 +723,7 @@ dm9000_init_dm9000(struct net_device *dev)
723/* Our watchdog timed out. Called by the networking layer */ 723/* Our watchdog timed out. Called by the networking layer */
724static void dm9000_timeout(struct net_device *dev) 724static void dm9000_timeout(struct net_device *dev)
725{ 725{
726 board_info_t *db = (board_info_t *) dev->priv; 726 board_info_t *db = netdev_priv(dev);
727 u8 reg_save; 727 u8 reg_save;
728 unsigned long flags; 728 unsigned long flags;
729 729
@@ -751,7 +751,7 @@ static int
751dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) 751dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
752{ 752{
753 unsigned long flags; 753 unsigned long flags;
754 board_info_t *db = dev->priv; 754 board_info_t *db = netdev_priv(dev);
755 755
756 dm9000_dbg(db, 3, "%s:\n", __func__); 756 dm9000_dbg(db, 3, "%s:\n", __func__);
757 757
@@ -831,7 +831,7 @@ struct dm9000_rxhdr {
831static void 831static void
832dm9000_rx(struct net_device *dev) 832dm9000_rx(struct net_device *dev)
833{ 833{
834 board_info_t *db = (board_info_t *) dev->priv; 834 board_info_t *db = netdev_priv(dev);
835 struct dm9000_rxhdr rxhdr; 835 struct dm9000_rxhdr rxhdr;
836 struct sk_buff *skb; 836 struct sk_buff *skb;
837 u8 rxbyte, *rdptr; 837 u8 rxbyte, *rdptr;
@@ -928,7 +928,7 @@ dm9000_rx(struct net_device *dev)
928static irqreturn_t dm9000_interrupt(int irq, void *dev_id) 928static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
929{ 929{
930 struct net_device *dev = dev_id; 930 struct net_device *dev = dev_id;
931 board_info_t *db = dev->priv; 931 board_info_t *db = netdev_priv(dev);
932 int int_status; 932 int int_status;
933 u8 reg_save; 933 u8 reg_save;
934 934
@@ -996,7 +996,7 @@ static void dm9000_poll_controller(struct net_device *dev)
996static int 996static int
997dm9000_open(struct net_device *dev) 997dm9000_open(struct net_device *dev)
998{ 998{
999 board_info_t *db = dev->priv; 999 board_info_t *db = netdev_priv(dev);
1000 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK; 1000 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
1001 1001
1002 if (netif_msg_ifup(db)) 1002 if (netif_msg_ifup(db))
@@ -1046,7 +1046,7 @@ static void dm9000_msleep(board_info_t *db, unsigned int ms)
1046static int 1046static int
1047dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg) 1047dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1048{ 1048{
1049 board_info_t *db = (board_info_t *) dev->priv; 1049 board_info_t *db = netdev_priv(dev);
1050 unsigned long flags; 1050 unsigned long flags;
1051 unsigned int reg_save; 1051 unsigned int reg_save;
1052 int ret; 1052 int ret;
@@ -1093,7 +1093,7 @@ static void
1093dm9000_phy_write(struct net_device *dev, 1093dm9000_phy_write(struct net_device *dev,
1094 int phyaddr_unused, int reg, int value) 1094 int phyaddr_unused, int reg, int value)
1095{ 1095{
1096 board_info_t *db = (board_info_t *) dev->priv; 1096 board_info_t *db = netdev_priv(dev);
1097 unsigned long flags; 1097 unsigned long flags;
1098 unsigned long reg_save; 1098 unsigned long reg_save;
1099 1099
@@ -1134,7 +1134,7 @@ dm9000_phy_write(struct net_device *dev,
1134static void 1134static void
1135dm9000_shutdown(struct net_device *dev) 1135dm9000_shutdown(struct net_device *dev)
1136{ 1136{
1137 board_info_t *db = dev->priv; 1137 board_info_t *db = netdev_priv(dev);
1138 1138
1139 /* RESET device */ 1139 /* RESET device */
1140 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */ 1140 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
@@ -1150,7 +1150,7 @@ dm9000_shutdown(struct net_device *dev)
1150static int 1150static int
1151dm9000_stop(struct net_device *ndev) 1151dm9000_stop(struct net_device *ndev)
1152{ 1152{
1153 board_info_t *db = ndev->priv; 1153 board_info_t *db = netdev_priv(ndev);
1154 1154
1155 if (netif_msg_ifdown(db)) 1155 if (netif_msg_ifdown(db))
1156 dev_dbg(db->dev, "shutting down %s\n", ndev->name); 1156 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
@@ -1197,7 +1197,7 @@ dm9000_probe(struct platform_device *pdev)
1197 dev_dbg(&pdev->dev, "dm9000_probe()\n"); 1197 dev_dbg(&pdev->dev, "dm9000_probe()\n");
1198 1198
1199 /* setup board info structure */ 1199 /* setup board info structure */
1200 db = ndev->priv; 1200 db = netdev_priv(ndev);
1201 memset(db, 0, sizeof(*db)); 1201 memset(db, 0, sizeof(*db));
1202 1202
1203 db->dev = &pdev->dev; 1203 db->dev = &pdev->dev;
@@ -1385,13 +1385,11 @@ dm9000_probe(struct platform_device *pdev)
1385 platform_set_drvdata(pdev, ndev); 1385 platform_set_drvdata(pdev, ndev);
1386 ret = register_netdev(ndev); 1386 ret = register_netdev(ndev);
1387 1387
1388 if (ret == 0) { 1388 if (ret == 0)
1389 DECLARE_MAC_BUF(mac); 1389 printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %pM (%s)\n",
1390 printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %s (%s)\n",
1391 ndev->name, dm9000_type_to_char(db->type), 1390 ndev->name, dm9000_type_to_char(db->type),
1392 db->io_addr, db->io_data, ndev->irq, 1391 db->io_addr, db->io_data, ndev->irq,
1393 print_mac(mac, ndev->dev_addr), mac_src); 1392 ndev->dev_addr, mac_src);
1394 }
1395 return 0; 1393 return 0;
1396 1394
1397out: 1395out:
@@ -1410,7 +1408,7 @@ dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
1410 board_info_t *db; 1408 board_info_t *db;
1411 1409
1412 if (ndev) { 1410 if (ndev) {
1413 db = (board_info_t *) ndev->priv; 1411 db = netdev_priv(ndev);
1414 db->in_suspend = 1; 1412 db->in_suspend = 1;
1415 1413
1416 if (netif_running(ndev)) { 1414 if (netif_running(ndev)) {
@@ -1425,7 +1423,7 @@ static int
1425dm9000_drv_resume(struct platform_device *dev) 1423dm9000_drv_resume(struct platform_device *dev)
1426{ 1424{
1427 struct net_device *ndev = platform_get_drvdata(dev); 1425 struct net_device *ndev = platform_get_drvdata(dev);
1428 board_info_t *db = (board_info_t *) ndev->priv; 1426 board_info_t *db = netdev_priv(ndev);
1429 1427
1430 if (ndev) { 1428 if (ndev) {
1431 1429
@@ -1449,7 +1447,7 @@ dm9000_drv_remove(struct platform_device *pdev)
1449 platform_set_drvdata(pdev, NULL); 1447 platform_set_drvdata(pdev, NULL);
1450 1448
1451 unregister_netdev(ndev); 1449 unregister_netdev(ndev);
1452 dm9000_release_board(pdev, (board_info_t *) ndev->priv); 1450 dm9000_release_board(pdev, (board_info_t *) netdev_priv(ndev));
1453 free_netdev(ndev); /* free device structure */ 1451 free_netdev(ndev); /* free device structure */
1454 1452
1455 dev_dbg(&pdev->dev, "released and freed device\n"); 1453 dev_dbg(&pdev->dev, "released and freed device\n");
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index e8bfcce6b319..c9c707980865 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1880,7 +1880,6 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1880 } else { 1880 } else {
1881 dev->stats.rx_packets++; 1881 dev->stats.rx_packets++;
1882 dev->stats.rx_bytes += actual_size; 1882 dev->stats.rx_bytes += actual_size;
1883 nic->netdev->last_rx = jiffies;
1884 netif_receive_skb(skb); 1883 netif_receive_skb(skb);
1885 if(work_done) 1884 if(work_done)
1886 (*work_done)++; 1885 (*work_done)++;
@@ -2322,7 +2321,8 @@ static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
2322{ 2321{
2323 struct nic *nic = netdev_priv(netdev); 2322 struct nic *nic = netdev_priv(netdev);
2324 2323
2325 if(wol->wolopts != WAKE_MAGIC && wol->wolopts != 0) 2324 if ((wol->wolopts && wol->wolopts != WAKE_MAGIC) ||
2325 !device_can_wakeup(&nic->pdev->dev))
2326 return -EOPNOTSUPP; 2326 return -EOPNOTSUPP;
2327 2327
2328 if(wol->wolopts) 2328 if(wol->wolopts)
@@ -2330,6 +2330,8 @@ static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
2330 else 2330 else
2331 nic->flags &= ~wol_magic; 2331 nic->flags &= ~wol_magic;
2332 2332
2333 device_set_wakeup_enable(&nic->pdev->dev, wol->wolopts);
2334
2333 e100_exec_cb(nic, NULL, e100_configure); 2335 e100_exec_cb(nic, NULL, e100_configure);
2334 2336
2335 return 0; 2337 return 0;
@@ -2616,7 +2618,6 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2616 struct net_device *netdev; 2618 struct net_device *netdev;
2617 struct nic *nic; 2619 struct nic *nic;
2618 int err; 2620 int err;
2619 DECLARE_MAC_BUF(mac);
2620 2621
2621 if(!(netdev = alloc_etherdev(sizeof(struct nic)))) { 2622 if(!(netdev = alloc_etherdev(sizeof(struct nic)))) {
2622 if(((1 << debug) - 1) & NETIF_MSG_PROBE) 2623 if(((1 << debug) - 1) & NETIF_MSG_PROBE)
@@ -2734,8 +2735,10 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2734 2735
2735 /* Wol magic packet can be enabled from eeprom */ 2736 /* Wol magic packet can be enabled from eeprom */
2736 if((nic->mac >= mac_82558_D101_A4) && 2737 if((nic->mac >= mac_82558_D101_A4) &&
2737 (nic->eeprom[eeprom_id] & eeprom_id_wol)) 2738 (nic->eeprom[eeprom_id] & eeprom_id_wol)) {
2738 nic->flags |= wol_magic; 2739 nic->flags |= wol_magic;
2740 device_set_wakeup_enable(&pdev->dev, true);
2741 }
2739 2742
2740 /* ack any pending wake events, disable PME */ 2743 /* ack any pending wake events, disable PME */
2741 pci_pme_active(pdev, false); 2744 pci_pme_active(pdev, false);
@@ -2746,9 +2749,9 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2746 goto err_out_free; 2749 goto err_out_free;
2747 } 2750 }
2748 2751
2749 DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, MAC addr %s\n", 2752 DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, MAC addr %pM\n",
2750 (unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0), 2753 (unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
2751 pdev->irq, print_mac(mac, netdev->dev_addr)); 2754 pdev->irq, netdev->dev_addr);
2752 2755
2753 return 0; 2756 return 0;
2754 2757
@@ -2794,11 +2797,10 @@ static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
2794 pci_save_state(pdev); 2797 pci_save_state(pdev);
2795 2798
2796 if ((nic->flags & wol_magic) | e100_asf(nic)) { 2799 if ((nic->flags & wol_magic) | e100_asf(nic)) {
2797 pci_enable_wake(pdev, PCI_D3hot, 1); 2800 if (pci_enable_wake(pdev, PCI_D3cold, true))
2798 pci_enable_wake(pdev, PCI_D3cold, 1); 2801 pci_enable_wake(pdev, PCI_D3hot, true);
2799 } else { 2802 } else {
2800 pci_enable_wake(pdev, PCI_D3hot, 0); 2803 pci_enable_wake(pdev, PCI_D3hot, false);
2801 pci_enable_wake(pdev, PCI_D3cold, 0);
2802 } 2804 }
2803 2805
2804 pci_disable_device(pdev); 2806 pci_disable_device(pdev);
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 872799b746f5..dd8343244378 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -912,7 +912,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
912 u16 eeprom_data = 0; 912 u16 eeprom_data = 0;
913 u16 eeprom_apme_mask = E1000_EEPROM_APME; 913 u16 eeprom_apme_mask = E1000_EEPROM_APME;
914 int bars, need_ioport; 914 int bars, need_ioport;
915 DECLARE_MAC_BUF(mac);
916 915
917 /* do not allocate ioport bars when not needed */ 916 /* do not allocate ioport bars when not needed */
918 need_ioport = e1000_is_need_ioport(pdev); 917 need_ioport = e1000_is_need_ioport(pdev);
@@ -967,8 +966,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
967 hw->back = adapter; 966 hw->back = adapter;
968 967
969 err = -EIO; 968 err = -EIO;
970 hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0), 969 hw->hw_addr = pci_ioremap_bar(pdev, BAR_0);
971 pci_resource_len(pdev, BAR_0));
972 if (!hw->hw_addr) 970 if (!hw->hw_addr)
973 goto err_ioremap; 971 goto err_ioremap;
974 972
@@ -1016,9 +1014,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1016 * because it depends on mac_type */ 1014 * because it depends on mac_type */
1017 if ((hw->mac_type == e1000_ich8lan) && 1015 if ((hw->mac_type == e1000_ich8lan) &&
1018 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { 1016 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
1019 hw->flash_address = 1017 hw->flash_address = pci_ioremap_bar(pdev, 1);
1020 ioremap(pci_resource_start(pdev, 1),
1021 pci_resource_len(pdev, 1));
1022 if (!hw->flash_address) 1018 if (!hw->flash_address)
1023 goto err_flashmap; 1019 goto err_flashmap;
1024 } 1020 }
@@ -1195,7 +1191,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1195 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" : 1191 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
1196 "32-bit")); 1192 "32-bit"));
1197 1193
1198 printk("%s\n", print_mac(mac, netdev->dev_addr)); 1194 printk("%pM\n", netdev->dev_addr);
1199 1195
1200 if (hw->bus_type == e1000_bus_type_pci_express) { 1196 if (hw->bus_type == e1000_bus_type_pci_express) {
1201 DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no " 1197 DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
@@ -3791,8 +3787,7 @@ static int e1000_clean(struct napi_struct *napi, int budget)
3791 struct net_device *poll_dev = adapter->netdev; 3787 struct net_device *poll_dev = adapter->netdev;
3792 int tx_cleaned = 0, work_done = 0; 3788 int tx_cleaned = 0, work_done = 0;
3793 3789
3794 /* Must NOT use netdev_priv macro here. */ 3790 adapter = netdev_priv(poll_dev);
3795 adapter = poll_dev->priv;
3796 3791
3797 /* e1000_clean is called per-cpu. This lock protects 3792 /* e1000_clean is called per-cpu. This lock protects
3798 * tx_ring[0] from being cleaned by multiple cpus 3793 * tx_ring[0] from being cleaned by multiple cpus
@@ -4104,8 +4099,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
4104 netif_receive_skb(skb); 4099 netif_receive_skb(skb);
4105 } 4100 }
4106 4101
4107 netdev->last_rx = jiffies;
4108
4109next_desc: 4102next_desc:
4110 rx_desc->status = 0; 4103 rx_desc->status = 0;
4111 4104
@@ -4789,7 +4782,7 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
4789 pci_channel_state_t state) 4782 pci_channel_state_t state)
4790{ 4783{
4791 struct net_device *netdev = pci_get_drvdata(pdev); 4784 struct net_device *netdev = pci_get_drvdata(pdev);
4792 struct e1000_adapter *adapter = netdev->priv; 4785 struct e1000_adapter *adapter = netdev_priv(netdev);
4793 4786
4794 netif_device_detach(netdev); 4787 netif_device_detach(netdev);
4795 4788
@@ -4811,7 +4804,7 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
4811static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev) 4804static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4812{ 4805{
4813 struct net_device *netdev = pci_get_drvdata(pdev); 4806 struct net_device *netdev = pci_get_drvdata(pdev);
4814 struct e1000_adapter *adapter = netdev->priv; 4807 struct e1000_adapter *adapter = netdev_priv(netdev);
4815 struct e1000_hw *hw = &adapter->hw; 4808 struct e1000_hw *hw = &adapter->hw;
4816 int err; 4809 int err;
4817 4810
@@ -4845,7 +4838,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4845static void e1000_io_resume(struct pci_dev *pdev) 4838static void e1000_io_resume(struct pci_dev *pdev)
4846{ 4839{
4847 struct net_device *netdev = pci_get_drvdata(pdev); 4840 struct net_device *netdev = pci_get_drvdata(pdev);
4848 struct e1000_adapter *adapter = netdev->priv; 4841 struct e1000_adapter *adapter = netdev_priv(netdev);
4849 struct e1000_hw *hw = &adapter->hw; 4842 struct e1000_hw *hw = &adapter->hw;
4850 4843
4851 e1000_init_manageability(adapter); 4844 e1000_init_manageability(adapter);
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index b2c910c52df9..3027ad53fa65 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -973,6 +973,12 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
973 ew32(CTRL_EXT, reg); 973 ew32(CTRL_EXT, reg);
974 } 974 }
975 975
976 if (hw->mac.type == e1000_82571) {
977 reg = er32(PBA_ECC);
978 reg |= E1000_PBA_ECC_CORR_EN;
979 ew32(PBA_ECC, reg);
980 }
981
976 /* PCI-Ex Control Register */ 982 /* PCI-Ex Control Register */
977 if (hw->mac.type == e1000_82574) { 983 if (hw->mac.type == e1000_82574) {
978 reg = er32(GCR); 984 reg = er32(GCR);
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 48f79ecb82a0..34a68fcab5a9 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -372,6 +372,13 @@
372#define E1000_ICR_TXQ1 0x00800000 /* Tx Queue 1 Interrupt */ 372#define E1000_ICR_TXQ1 0x00800000 /* Tx Queue 1 Interrupt */
373#define E1000_ICR_OTHER 0x01000000 /* Other Interrupts */ 373#define E1000_ICR_OTHER 0x01000000 /* Other Interrupts */
374 374
375/* PBA ECC Register */
376#define E1000_PBA_ECC_COUNTER_MASK 0xFFF00000 /* ECC counter mask */
377#define E1000_PBA_ECC_COUNTER_SHIFT 20 /* ECC counter shift value */
378#define E1000_PBA_ECC_CORR_EN 0x00000001 /* ECC correction enable */
379#define E1000_PBA_ECC_STAT_CLR 0x00000002 /* Clear ECC error counter */
380#define E1000_PBA_ECC_INT_EN 0x00000004 /* Enable ICR bit 5 for ECC */
381
375/* 382/*
376 * This defines the bits that are set in the Interrupt Mask 383 * This defines the bits that are set in the Interrupt Mask
377 * Set/Read Register. Each bit is documented below: 384 * Set/Read Register. Each bit is documented below:
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index f66ed37a7f76..c4ffd4b70517 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -87,6 +87,7 @@ enum e1e_registers {
87 E1000_EEMNGCTL = 0x01010, /* MNG EEprom Control */ 87 E1000_EEMNGCTL = 0x01010, /* MNG EEprom Control */
88 E1000_EEWR = 0x0102C, /* EEPROM Write Register - RW */ 88 E1000_EEWR = 0x0102C, /* EEPROM Write Register - RW */
89 E1000_FLOP = 0x0103C, /* FLASH Opcode Register */ 89 E1000_FLOP = 0x0103C, /* FLASH Opcode Register */
90 E1000_PBA_ECC = 0x01100, /* PBA ECC Register */
90 E1000_ERT = 0x02008, /* Early Rx Threshold - RW */ 91 E1000_ERT = 0x02008, /* Early Rx Threshold - RW */
91 E1000_FCRTL = 0x02160, /* Flow Control Receive Threshold Low - RW */ 92 E1000_FCRTL = 0x02160, /* Flow Control Receive Threshold Low - RW */
92 E1000_FCRTH = 0x02168, /* Flow Control Receive Threshold High - RW */ 93 E1000_FCRTH = 0x02168, /* Flow Control Receive Threshold High - RW */
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 91795f78c3e4..4f06641cd6d4 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -103,8 +103,6 @@ static void e1000_receive_skb(struct e1000_adapter *adapter,
103 le16_to_cpu(vlan)); 103 le16_to_cpu(vlan));
104 else 104 else
105 netif_receive_skb(skb); 105 netif_receive_skb(skb);
106
107 netdev->last_rx = jiffies;
108} 106}
109 107
110/** 108/**
@@ -2004,8 +2002,7 @@ static int e1000_clean(struct napi_struct *napi, int budget)
2004 struct net_device *poll_dev = adapter->netdev; 2002 struct net_device *poll_dev = adapter->netdev;
2005 int tx_cleaned = 0, work_done = 0; 2003 int tx_cleaned = 0, work_done = 0;
2006 2004
2007 /* Must NOT use netdev_priv macro here. */ 2005 adapter = netdev_priv(poll_dev);
2008 adapter = poll_dev->priv;
2009 2006
2010 if (adapter->msix_entries && 2007 if (adapter->msix_entries &&
2011 !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val)) 2008 !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
@@ -4670,14 +4667,12 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
4670 u32 pba_num; 4667 u32 pba_num;
4671 4668
4672 /* print bus type/speed/width info */ 4669 /* print bus type/speed/width info */
4673 e_info("(PCI Express:2.5GB/s:%s) %02x:%02x:%02x:%02x:%02x:%02x\n", 4670 e_info("(PCI Express:2.5GB/s:%s) %pM\n",
4674 /* bus width */ 4671 /* bus width */
4675 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" : 4672 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
4676 "Width x1"), 4673 "Width x1"),
4677 /* MAC address */ 4674 /* MAC address */
4678 netdev->dev_addr[0], netdev->dev_addr[1], 4675 netdev->dev_addr);
4679 netdev->dev_addr[2], netdev->dev_addr[3],
4680 netdev->dev_addr[4], netdev->dev_addr[5]);
4681 e_info("Intel(R) PRO/%s Network Connection\n", 4676 e_info("Intel(R) PRO/%s Network Connection\n",
4682 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000"); 4677 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
4683 e1000e_read_pba_num(hw, &pba_num); 4678 e1000e_read_pba_num(hw, &pba_num);
@@ -4925,10 +4920,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4925 memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); 4920 memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
4926 4921
4927 if (!is_valid_ether_addr(netdev->perm_addr)) { 4922 if (!is_valid_ether_addr(netdev->perm_addr)) {
4928 e_err("Invalid MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n", 4923 e_err("Invalid MAC Address: %pM\n", netdev->perm_addr);
4929 netdev->perm_addr[0], netdev->perm_addr[1],
4930 netdev->perm_addr[2], netdev->perm_addr[3],
4931 netdev->perm_addr[4], netdev->perm_addr[5]);
4932 err = -EIO; 4924 err = -EIO;
4933 goto err_eeprom; 4925 goto err_eeprom;
4934 } 4926 }
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index 1f11350e16cf..0a984619411b 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -605,7 +605,7 @@ out:
605 605
606static void __init printEEPROMInfo(struct net_device *dev) 606static void __init printEEPROMInfo(struct net_device *dev)
607{ 607{
608 struct eepro_local *lp = (struct eepro_local *)dev->priv; 608 struct eepro_local *lp = netdev_priv(dev);
609 int ioaddr = dev->base_addr; 609 int ioaddr = dev->base_addr;
610 unsigned short Word; 610 unsigned short Word;
611 int i,j; 611 int i,j;
@@ -690,7 +690,6 @@ static void __init eepro_print_info (struct net_device *dev)
690 struct eepro_local * lp = netdev_priv(dev); 690 struct eepro_local * lp = netdev_priv(dev);
691 int i; 691 int i;
692 const char * ifmap[] = {"AUI", "10Base2", "10BaseT"}; 692 const char * ifmap[] = {"AUI", "10Base2", "10BaseT"};
693 DECLARE_MAC_BUF(mac);
694 693
695 i = inb(dev->base_addr + ID_REG); 694 i = inb(dev->base_addr + ID_REG);
696 printk(KERN_DEBUG " id: %#x ",i); 695 printk(KERN_DEBUG " id: %#x ",i);
@@ -715,7 +714,7 @@ static void __init eepro_print_info (struct net_device *dev)
715 break; 714 break;
716 } 715 }
717 716
718 printk(" %s", print_mac(mac, dev->dev_addr)); 717 printk(" %pM", dev->dev_addr);
719 718
720 if (net_debug > 3) 719 if (net_debug > 3)
721 printk(KERN_DEBUG ", %dK RCV buffer", 720 printk(KERN_DEBUG ", %dK RCV buffer",
@@ -1581,7 +1580,6 @@ eepro_rx(struct net_device *dev)
1581 1580
1582 skb->protocol = eth_type_trans(skb,dev); 1581 skb->protocol = eth_type_trans(skb,dev);
1583 netif_rx(skb); 1582 netif_rx(skb);
1584 dev->last_rx = jiffies;
1585 dev->stats.rx_packets++; 1583 dev->stats.rx_packets++;
1586 } 1584 }
1587 1585
@@ -1676,7 +1674,7 @@ eepro_transmit_interrupt(struct net_device *dev)
1676static int eepro_ethtool_get_settings(struct net_device *dev, 1674static int eepro_ethtool_get_settings(struct net_device *dev,
1677 struct ethtool_cmd *cmd) 1675 struct ethtool_cmd *cmd)
1678{ 1676{
1679 struct eepro_local *lp = (struct eepro_local *)dev->priv; 1677 struct eepro_local *lp = netdev_priv(dev);
1680 1678
1681 cmd->supported = SUPPORTED_10baseT_Half | 1679 cmd->supported = SUPPORTED_10baseT_Half |
1682 SUPPORTED_10baseT_Full | 1680 SUPPORTED_10baseT_Full |
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
deleted file mode 100644
index e3e26c595fa3..000000000000
--- a/drivers/net/eepro100.c
+++ /dev/null
@@ -1,2401 +0,0 @@
1/* drivers/net/eepro100.c: An Intel i82557-559 Ethernet driver for Linux. */
2/*
3 Written 1996-1999 by Donald Becker.
4
5 The driver also contains updates by different kernel developers
6 (see incomplete list below).
7 Current maintainer is Andrey V. Savochkin <saw@saw.sw.com.sg>.
8 Please use this email address and linux-kernel mailing list for bug reports.
9
10 This software may be used and distributed according to the terms
11 of the GNU General Public License, incorporated herein by reference.
12
13 This driver is for the Intel EtherExpress Pro100 (Speedo3) design.
14 It should work with all i82557/558/559 boards.
15
16 Version history:
17 1998 Apr - 2000 Feb Andrey V. Savochkin <saw@saw.sw.com.sg>
18 Serious fixes for multicast filter list setting, TX timeout routine;
19 RX ring refilling logic; other stuff
20 2000 Feb Jeff Garzik <jgarzik@pobox.com>
21 Convert to new PCI driver interface
22 2000 Mar 24 Dragan Stancevic <visitor@valinux.com>
23 Disabled FC and ER, to avoid lockups when when we get FCP interrupts.
24 2000 Jul 17 Goutham Rao <goutham.rao@intel.com>
25 PCI DMA API fixes, adding pci_dma_sync_single calls where neccesary
26 2000 Aug 31 David Mosberger <davidm@hpl.hp.com>
27 rx_align support: enables rx DMA without causing unaligned accesses.
28*/
29
30static const char * const version =
31"eepro100.c:v1.09j-t 9/29/99 Donald Becker\n"
32"eepro100.c: $Revision: 1.36 $ 2000/11/17 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n";
33
34/* A few user-configurable values that apply to all boards.
35 First set is undocumented and spelled per Intel recommendations. */
36
37static int congenb /* = 0 */; /* Enable congestion control in the DP83840. */
38static int txfifo = 8; /* Tx FIFO threshold in 4 byte units, 0-15 */
39static int rxfifo = 8; /* Rx FIFO threshold, default 32 bytes. */
40/* Tx/Rx DMA burst length, 0-127, 0 == no preemption, tx==128 -> disabled. */
41static int txdmacount = 128;
42static int rxdmacount /* = 0 */;
43
44#if defined(__ia64__) || defined(__alpha__) || defined(__sparc__) || defined(__mips__) || \
45 defined(__arm__)
46 /* align rx buffers to 2 bytes so that IP header is aligned */
47# define rx_align(skb) skb_reserve((skb), 2)
48# define RxFD_ALIGNMENT __attribute__ ((aligned (2), packed))
49#else
50# define rx_align(skb)
51# define RxFD_ALIGNMENT
52#endif
53
54/* Set the copy breakpoint for the copy-only-tiny-buffer Rx method.
55 Lower values use more memory, but are faster. */
56static int rx_copybreak = 200;
57
58/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
59static int max_interrupt_work = 20;
60
61/* Maximum number of multicast addresses to filter (vs. rx-all-multicast) */
62static int multicast_filter_limit = 64;
63
64/* 'options' is used to pass a transceiver override or full-duplex flag
65 e.g. "options=16" for FD, "options=32" for 100mbps-only. */
66static int full_duplex[] = {-1, -1, -1, -1, -1, -1, -1, -1};
67static int options[] = {-1, -1, -1, -1, -1, -1, -1, -1};
68
69/* A few values that may be tweaked. */
70/* The ring sizes should be a power of two for efficiency. */
71#define TX_RING_SIZE 64
72#define RX_RING_SIZE 64
73/* How much slots multicast filter setup may take.
74 Do not descrease without changing set_rx_mode() implementaion. */
75#define TX_MULTICAST_SIZE 2
76#define TX_MULTICAST_RESERV (TX_MULTICAST_SIZE*2)
77/* Actual number of TX packets queued, must be
78 <= TX_RING_SIZE-TX_MULTICAST_RESERV. */
79#define TX_QUEUE_LIMIT (TX_RING_SIZE-TX_MULTICAST_RESERV)
80/* Hysteresis marking queue as no longer full. */
81#define TX_QUEUE_UNFULL (TX_QUEUE_LIMIT-4)
82
83/* Operational parameters that usually are not changed. */
84
85/* Time in jiffies before concluding the transmitter is hung. */
86#define TX_TIMEOUT (2*HZ)
87/* Size of an pre-allocated Rx buffer: <Ethernet MTU> + slack.*/
88#define PKT_BUF_SZ 1536
89
90#include <linux/module.h>
91
92#include <linux/kernel.h>
93#include <linux/string.h>
94#include <linux/errno.h>
95#include <linux/ioport.h>
96#include <linux/slab.h>
97#include <linux/interrupt.h>
98#include <linux/timer.h>
99#include <linux/pci.h>
100#include <linux/spinlock.h>
101#include <linux/init.h>
102#include <linux/mii.h>
103#include <linux/delay.h>
104#include <linux/bitops.h>
105
106#include <asm/io.h>
107#include <asm/uaccess.h>
108#include <asm/irq.h>
109
110#include <linux/netdevice.h>
111#include <linux/etherdevice.h>
112#include <linux/rtnetlink.h>
113#include <linux/skbuff.h>
114#include <linux/ethtool.h>
115
116static int use_io;
117static int debug = -1;
118#define DEBUG_DEFAULT (NETIF_MSG_DRV | \
119 NETIF_MSG_HW | \
120 NETIF_MSG_RX_ERR | \
121 NETIF_MSG_TX_ERR)
122#define DEBUG ((debug >= 0) ? (1<<debug)-1 : DEBUG_DEFAULT)
123
124
125MODULE_AUTHOR("Maintainer: Andrey V. Savochkin <saw@saw.sw.com.sg>");
126MODULE_DESCRIPTION("Intel i82557/i82558/i82559 PCI EtherExpressPro driver");
127MODULE_LICENSE("GPL");
128module_param(use_io, int, 0);
129module_param(debug, int, 0);
130module_param_array(options, int, NULL, 0);
131module_param_array(full_duplex, int, NULL, 0);
132module_param(congenb, int, 0);
133module_param(txfifo, int, 0);
134module_param(rxfifo, int, 0);
135module_param(txdmacount, int, 0);
136module_param(rxdmacount, int, 0);
137module_param(rx_copybreak, int, 0);
138module_param(max_interrupt_work, int, 0);
139module_param(multicast_filter_limit, int, 0);
140MODULE_PARM_DESC(debug, "debug level (0-6)");
141MODULE_PARM_DESC(options, "Bits 0-3: transceiver type, bit 4: full duplex, bit 5: 100Mbps");
142MODULE_PARM_DESC(full_duplex, "full duplex setting(s) (1)");
143MODULE_PARM_DESC(congenb, "Enable congestion control (1)");
144MODULE_PARM_DESC(txfifo, "Tx FIFO threshold in 4 byte units, (0-15)");
145MODULE_PARM_DESC(rxfifo, "Rx FIFO threshold in 4 byte units, (0-15)");
146MODULE_PARM_DESC(txdmacount, "Tx DMA burst length; 128 - disable (0-128)");
147MODULE_PARM_DESC(rxdmacount, "Rx DMA burst length; 128 - disable (0-128)");
148MODULE_PARM_DESC(rx_copybreak, "copy breakpoint for copy-only-tiny-frames");
149MODULE_PARM_DESC(max_interrupt_work, "maximum events handled per interrupt");
150MODULE_PARM_DESC(multicast_filter_limit, "maximum number of filtered multicast addresses");
151
152#define RUN_AT(x) (jiffies + (x))
153
154#define netdevice_start(dev)
155#define netdevice_stop(dev)
156#define netif_set_tx_timeout(dev, tf, tm) \
157 do { \
158 (dev)->tx_timeout = (tf); \
159 (dev)->watchdog_timeo = (tm); \
160 } while(0)
161
162
163
164/*
165 Theory of Operation
166
167I. Board Compatibility
168
169This device driver is designed for the Intel i82557 "Speedo3" chip, Intel's
170single-chip fast Ethernet controller for PCI, as used on the Intel
171EtherExpress Pro 100 adapter.
172
173II. Board-specific settings
174
175PCI bus devices are configured by the system at boot time, so no jumpers
176need to be set on the board. The system BIOS should be set to assign the
177PCI INTA signal to an otherwise unused system IRQ line. While it's
178possible to share PCI interrupt lines, it negatively impacts performance and
179only recent kernels support it.
180
181III. Driver operation
182
183IIIA. General
184The Speedo3 is very similar to other Intel network chips, that is to say
185"apparently designed on a different planet". This chips retains the complex
186Rx and Tx descriptors and multiple buffers pointers as previous chips, but
187also has simplified Tx and Rx buffer modes. This driver uses the "flexible"
188Tx mode, but in a simplified lower-overhead manner: it associates only a
189single buffer descriptor with each frame descriptor.
190
191Despite the extra space overhead in each receive skbuff, the driver must use
192the simplified Rx buffer mode to assure that only a single data buffer is
193associated with each RxFD. The driver implements this by reserving space
194for the Rx descriptor at the head of each Rx skbuff.
195
196The Speedo-3 has receive and command unit base addresses that are added to
197almost all descriptor pointers. The driver sets these to zero, so that all
198pointer fields are absolute addresses.
199
200The System Control Block (SCB) of some previous Intel chips exists on the
201chip in both PCI I/O and memory space. This driver uses the I/O space
202registers, but might switch to memory mapped mode to better support non-x86
203processors.
204
205IIIB. Transmit structure
206
207The driver must use the complex Tx command+descriptor mode in order to
208have a indirect pointer to the skbuff data section. Each Tx command block
209(TxCB) is associated with two immediately appended Tx Buffer Descriptor
210(TxBD). A fixed ring of these TxCB+TxBD pairs are kept as part of the
211speedo_private data structure for each adapter instance.
212
213The newer i82558 explicitly supports this structure, and can read the two
214TxBDs in the same PCI burst as the TxCB.
215
216This ring structure is used for all normal transmit packets, but the
217transmit packet descriptors aren't long enough for most non-Tx commands such
218as CmdConfigure. This is complicated by the possibility that the chip has
219already loaded the link address in the previous descriptor. So for these
220commands we convert the next free descriptor on the ring to a NoOp, and point
221that descriptor's link to the complex command.
222
223An additional complexity of these non-transmit commands are that they may be
224added asynchronous to the normal transmit queue, so we disable interrupts
225whenever the Tx descriptor ring is manipulated.
226
227A notable aspect of these special configure commands is that they do
228work with the normal Tx ring entry scavenge method. The Tx ring scavenge
229is done at interrupt time using the 'dirty_tx' index, and checking for the
230command-complete bit. While the setup frames may have the NoOp command on the
231Tx ring marked as complete, but not have completed the setup command, this
232is not a problem. The tx_ring entry can be still safely reused, as the
233tx_skbuff[] entry is always empty for config_cmd and mc_setup frames.
234
235Commands may have bits set e.g. CmdSuspend in the command word to either
236suspend or stop the transmit/command unit. This driver always flags the last
237command with CmdSuspend, erases the CmdSuspend in the previous command, and
238then issues a CU_RESUME.
239Note: Watch out for the potential race condition here: imagine
240 erasing the previous suspend
241 the chip processes the previous command
242 the chip processes the final command, and suspends
243 doing the CU_RESUME
244 the chip processes the next-yet-valid post-final-command.
245So blindly sending a CU_RESUME is only safe if we do it immediately after
246after erasing the previous CmdSuspend, without the possibility of an
247intervening delay. Thus the resume command is always within the
248interrupts-disabled region. This is a timing dependence, but handling this
249condition in a timing-independent way would considerably complicate the code.
250
251Note: In previous generation Intel chips, restarting the command unit was a
252notoriously slow process. This is presumably no longer true.
253
254IIIC. Receive structure
255
256Because of the bus-master support on the Speedo3 this driver uses the new
257SKBUFF_RX_COPYBREAK scheme, rather than a fixed intermediate receive buffer.
258This scheme allocates full-sized skbuffs as receive buffers. The value
259SKBUFF_RX_COPYBREAK is used as the copying breakpoint: it is chosen to
260trade-off the memory wasted by passing the full-sized skbuff to the queue
261layer for all frames vs. the copying cost of copying a frame to a
262correctly-sized skbuff.
263
264For small frames the copying cost is negligible (esp. considering that we
265are pre-loading the cache with immediately useful header information), so we
266allocate a new, minimally-sized skbuff. For large frames the copying cost
267is non-trivial, and the larger copy might flush the cache of useful data, so
268we pass up the skbuff the packet was received into.
269
270IV. Notes
271
272Thanks to Steve Williams of Intel for arranging the non-disclosure agreement
273that stated that I could disclose the information. But I still resent
274having to sign an Intel NDA when I'm helping Intel sell their own product!
275
276*/
277
278static int speedo_found1(struct pci_dev *pdev, void __iomem *ioaddr, int fnd_cnt, int acpi_idle_state);
279
280/* Offsets to the various registers.
281 All accesses need not be longword aligned. */
282enum speedo_offsets {
283 SCBStatus = 0, SCBCmd = 2, /* Rx/Command Unit command and status. */
284 SCBIntmask = 3,
285 SCBPointer = 4, /* General purpose pointer. */
286 SCBPort = 8, /* Misc. commands and operands. */
287 SCBflash = 12, SCBeeprom = 14, /* EEPROM and flash memory control. */
288 SCBCtrlMDI = 16, /* MDI interface control. */
289 SCBEarlyRx = 20, /* Early receive byte count. */
290};
291/* Commands that can be put in a command list entry. */
292enum commands {
293 CmdNOp = 0, CmdIASetup = 0x10000, CmdConfigure = 0x20000,
294 CmdMulticastList = 0x30000, CmdTx = 0x40000, CmdTDR = 0x50000,
295 CmdDump = 0x60000, CmdDiagnose = 0x70000,
296 CmdSuspend = 0x40000000, /* Suspend after completion. */
297 CmdIntr = 0x20000000, /* Interrupt after completion. */
298 CmdTxFlex = 0x00080000, /* Use "Flexible mode" for CmdTx command. */
299};
300/* Clear CmdSuspend (1<<30) avoiding interference with the card access to the
301 status bits. Previous driver versions used separate 16 bit fields for
302 commands and statuses. --SAW
303 */
304#if defined(__alpha__)
305# define clear_suspend(cmd) clear_bit(30, &(cmd)->cmd_status);
306#else
307# define clear_suspend(cmd) ((__le16 *)&(cmd)->cmd_status)[1] &= ~cpu_to_le16(1<<14)
308#endif
309
310enum SCBCmdBits {
311 SCBMaskCmdDone=0x8000, SCBMaskRxDone=0x4000, SCBMaskCmdIdle=0x2000,
312 SCBMaskRxSuspend=0x1000, SCBMaskEarlyRx=0x0800, SCBMaskFlowCtl=0x0400,
313 SCBTriggerIntr=0x0200, SCBMaskAll=0x0100,
314 /* The rest are Rx and Tx commands. */
315 CUStart=0x0010, CUResume=0x0020, CUStatsAddr=0x0040, CUShowStats=0x0050,
316 CUCmdBase=0x0060, /* CU Base address (set to zero) . */
317 CUDumpStats=0x0070, /* Dump then reset stats counters. */
318 RxStart=0x0001, RxResume=0x0002, RxAbort=0x0004, RxAddrLoad=0x0006,
319 RxResumeNoResources=0x0007,
320};
321
322enum SCBPort_cmds {
323 PortReset=0, PortSelfTest=1, PortPartialReset=2, PortDump=3,
324};
325
326/* The Speedo3 Rx and Tx frame/buffer descriptors. */
327struct descriptor { /* A generic descriptor. */
328 volatile __le32 cmd_status; /* All command and status fields. */
329 __le32 link; /* struct descriptor * */
330 unsigned char params[0];
331};
332
333/* The Speedo3 Rx and Tx buffer descriptors. */
334struct RxFD { /* Receive frame descriptor. */
335 volatile __le32 status;
336 __le32 link; /* struct RxFD * */
337 __le32 rx_buf_addr; /* void * */
338 __le32 count;
339} RxFD_ALIGNMENT;
340
341/* Selected elements of the Tx/RxFD.status word. */
342enum RxFD_bits {
343 RxComplete=0x8000, RxOK=0x2000,
344 RxErrCRC=0x0800, RxErrAlign=0x0400, RxErrTooBig=0x0200, RxErrSymbol=0x0010,
345 RxEth2Type=0x0020, RxNoMatch=0x0004, RxNoIAMatch=0x0002,
346 TxUnderrun=0x1000, StatusComplete=0x8000,
347};
348
349#define CONFIG_DATA_SIZE 22
350struct TxFD { /* Transmit frame descriptor set. */
351 __le32 status;
352 __le32 link; /* void * */
353 __le32 tx_desc_addr; /* Always points to the tx_buf_addr element. */
354 __le32 count; /* # of TBD (=1), Tx start thresh., etc. */
355 /* This constitutes two "TBD" entries -- we only use one. */
356#define TX_DESCR_BUF_OFFSET 16
357 __le32 tx_buf_addr0; /* void *, frame to be transmitted. */
358 __le32 tx_buf_size0; /* Length of Tx frame. */
359 __le32 tx_buf_addr1; /* void *, frame to be transmitted. */
360 __le32 tx_buf_size1; /* Length of Tx frame. */
361 /* the structure must have space for at least CONFIG_DATA_SIZE starting
362 * from tx_desc_addr field */
363};
364
365/* Multicast filter setting block. --SAW */
366struct speedo_mc_block {
367 struct speedo_mc_block *next;
368 unsigned int tx;
369 dma_addr_t frame_dma;
370 unsigned int len;
371 struct descriptor frame __attribute__ ((__aligned__(16)));
372};
373
374/* Elements of the dump_statistics block. This block must be lword aligned. */
375struct speedo_stats {
376 __le32 tx_good_frames;
377 __le32 tx_coll16_errs;
378 __le32 tx_late_colls;
379 __le32 tx_underruns;
380 __le32 tx_lost_carrier;
381 __le32 tx_deferred;
382 __le32 tx_one_colls;
383 __le32 tx_multi_colls;
384 __le32 tx_total_colls;
385 __le32 rx_good_frames;
386 __le32 rx_crc_errs;
387 __le32 rx_align_errs;
388 __le32 rx_resource_errs;
389 __le32 rx_overrun_errs;
390 __le32 rx_colls_errs;
391 __le32 rx_runt_errs;
392 __le32 done_marker;
393};
394
395enum Rx_ring_state_bits {
396 RrNoMem=1, RrPostponed=2, RrNoResources=4, RrOOMReported=8,
397};
398
399/* Do not change the position (alignment) of the first few elements!
400 The later elements are grouped for cache locality.
401
402 Unfortunately, all the positions have been shifted since there.
403 A new re-alignment is required. 2000/03/06 SAW */
404struct speedo_private {
405 void __iomem *regs;
406 struct TxFD *tx_ring; /* Commands (usually CmdTxPacket). */
407 struct RxFD *rx_ringp[RX_RING_SIZE]; /* Rx descriptor, used as ring. */
408 /* The addresses of a Tx/Rx-in-place packets/buffers. */
409 struct sk_buff *tx_skbuff[TX_RING_SIZE];
410 struct sk_buff *rx_skbuff[RX_RING_SIZE];
411 /* Mapped addresses of the rings. */
412 dma_addr_t tx_ring_dma;
413#define TX_RING_ELEM_DMA(sp, n) ((sp)->tx_ring_dma + (n)*sizeof(struct TxFD))
414 dma_addr_t rx_ring_dma[RX_RING_SIZE];
415 struct descriptor *last_cmd; /* Last command sent. */
416 unsigned int cur_tx, dirty_tx; /* The ring entries to be free()ed. */
417 spinlock_t lock; /* Group with Tx control cache line. */
418 u32 tx_threshold; /* The value for txdesc.count. */
419 struct RxFD *last_rxf; /* Last filled RX buffer. */
420 dma_addr_t last_rxf_dma;
421 unsigned int cur_rx, dirty_rx; /* The next free ring entry */
422 long last_rx_time; /* Last Rx, in jiffies, to handle Rx hang. */
423 struct net_device_stats stats;
424 struct speedo_stats *lstats;
425 dma_addr_t lstats_dma;
426 int chip_id;
427 struct pci_dev *pdev;
428 struct timer_list timer; /* Media selection timer. */
429 struct speedo_mc_block *mc_setup_head; /* Multicast setup frame list head. */
430 struct speedo_mc_block *mc_setup_tail; /* Multicast setup frame list tail. */
431 long in_interrupt; /* Word-aligned dev->interrupt */
432 unsigned char acpi_pwr;
433 signed char rx_mode; /* Current PROMISC/ALLMULTI setting. */
434 unsigned int tx_full:1; /* The Tx queue is full. */
435 unsigned int flow_ctrl:1; /* Use 802.3x flow control. */
436 unsigned int rx_bug:1; /* Work around receiver hang errata. */
437 unsigned char default_port:8; /* Last dev->if_port value. */
438 unsigned char rx_ring_state; /* RX ring status flags. */
439 unsigned short phy[2]; /* PHY media interfaces available. */
440 unsigned short partner; /* Link partner caps. */
441 struct mii_if_info mii_if; /* MII API hooks, info */
442 u32 msg_enable; /* debug message level */
443};
444
445/* The parameters for a CmdConfigure operation.
446 There are so many options that it would be difficult to document each bit.
447 We mostly use the default or recommended settings. */
448static const char i82557_config_cmd[CONFIG_DATA_SIZE] = {
449 22, 0x08, 0, 0, 0, 0, 0x32, 0x03, 1, /* 1=Use MII 0=Use AUI */
450 0, 0x2E, 0, 0x60, 0,
451 0xf2, 0x48, 0, 0x40, 0xf2, 0x80, /* 0x40=Force full-duplex */
452 0x3f, 0x05, };
453static const char i82558_config_cmd[CONFIG_DATA_SIZE] = {
454 22, 0x08, 0, 1, 0, 0, 0x22, 0x03, 1, /* 1=Use MII 0=Use AUI */
455 0, 0x2E, 0, 0x60, 0x08, 0x88,
456 0x68, 0, 0x40, 0xf2, 0x84, /* Disable FC */
457 0x31, 0x05, };
458
459/* PHY media interface chips. */
460static const char * const phys[] = {
461 "None", "i82553-A/B", "i82553-C", "i82503",
462 "DP83840", "80c240", "80c24", "i82555",
463 "unknown-8", "unknown-9", "DP83840A", "unknown-11",
464 "unknown-12", "unknown-13", "unknown-14", "unknown-15", };
465enum phy_chips { NonSuchPhy=0, I82553AB, I82553C, I82503, DP83840, S80C240,
466 S80C24, I82555, DP83840A=10, };
467static const char is_mii[] = { 0, 1, 1, 0, 1, 1, 0, 1 };
468#define EE_READ_CMD (6)
469
470static int eepro100_init_one(struct pci_dev *pdev,
471 const struct pci_device_id *ent);
472
473static int do_eeprom_cmd(void __iomem *ioaddr, int cmd, int cmd_len);
474static int mdio_read(struct net_device *dev, int phy_id, int location);
475static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
476static int speedo_open(struct net_device *dev);
477static void speedo_resume(struct net_device *dev);
478static void speedo_timer(unsigned long data);
479static void speedo_init_rx_ring(struct net_device *dev);
480static void speedo_tx_timeout(struct net_device *dev);
481static int speedo_start_xmit(struct sk_buff *skb, struct net_device *dev);
482static void speedo_refill_rx_buffers(struct net_device *dev, int force);
483static int speedo_rx(struct net_device *dev);
484static void speedo_tx_buffer_gc(struct net_device *dev);
485static irqreturn_t speedo_interrupt(int irq, void *dev_instance);
486static int speedo_close(struct net_device *dev);
487static struct net_device_stats *speedo_get_stats(struct net_device *dev);
488static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
489static void set_rx_mode(struct net_device *dev);
490static void speedo_show_state(struct net_device *dev);
491static const struct ethtool_ops ethtool_ops;
492
493
494
495#ifdef honor_default_port
496/* Optional driver feature to allow forcing the transceiver setting.
497 Not recommended. */
498static int mii_ctrl[8] = { 0x3300, 0x3100, 0x0000, 0x0100,
499 0x2000, 0x2100, 0x0400, 0x3100};
500#endif
501
502/* How to wait for the command unit to accept a command.
503 Typically this takes 0 ticks. */
504static inline unsigned char wait_for_cmd_done(struct net_device *dev,
505 struct speedo_private *sp)
506{
507 int wait = 1000;
508 void __iomem *cmd_ioaddr = sp->regs + SCBCmd;
509 unsigned char r;
510
511 do {
512 udelay(1);
513 r = ioread8(cmd_ioaddr);
514 } while(r && --wait >= 0);
515
516 if (wait < 0)
517 printk(KERN_ALERT "%s: wait_for_cmd_done timeout!\n", dev->name);
518 return r;
519}
520
521static int __devinit eepro100_init_one (struct pci_dev *pdev,
522 const struct pci_device_id *ent)
523{
524 void __iomem *ioaddr;
525 int irq, pci_bar;
526 int acpi_idle_state = 0, pm;
527 static int cards_found /* = 0 */;
528 unsigned long pci_base;
529
530#ifndef MODULE
531 /* when built-in, we only print version if device is found */
532 static int did_version;
533 if (did_version++ == 0)
534 printk(version);
535#endif
536
537 /* save power state before pci_enable_device overwrites it */
538 pm = pci_find_capability(pdev, PCI_CAP_ID_PM);
539 if (pm) {
540 u16 pwr_command;
541 pci_read_config_word(pdev, pm + PCI_PM_CTRL, &pwr_command);
542 acpi_idle_state = pwr_command & PCI_PM_CTRL_STATE_MASK;
543 }
544
545 if (pci_enable_device(pdev))
546 goto err_out_free_mmio_region;
547
548 pci_set_master(pdev);
549
550 if (!request_region(pci_resource_start(pdev, 1),
551 pci_resource_len(pdev, 1), "eepro100")) {
552 dev_err(&pdev->dev, "eepro100: cannot reserve I/O ports\n");
553 goto err_out_none;
554 }
555 if (!request_mem_region(pci_resource_start(pdev, 0),
556 pci_resource_len(pdev, 0), "eepro100")) {
557 dev_err(&pdev->dev, "eepro100: cannot reserve MMIO region\n");
558 goto err_out_free_pio_region;
559 }
560
561 irq = pdev->irq;
562 pci_bar = use_io ? 1 : 0;
563 pci_base = pci_resource_start(pdev, pci_bar);
564 if (DEBUG & NETIF_MSG_PROBE)
565 printk("Found Intel i82557 PCI Speedo at %#lx, IRQ %d.\n",
566 pci_base, irq);
567
568 ioaddr = pci_iomap(pdev, pci_bar, 0);
569 if (!ioaddr) {
570 dev_err(&pdev->dev, "eepro100: cannot remap IO\n");
571 goto err_out_free_mmio_region;
572 }
573
574 if (speedo_found1(pdev, ioaddr, cards_found, acpi_idle_state) == 0)
575 cards_found++;
576 else
577 goto err_out_iounmap;
578
579 return 0;
580
581err_out_iounmap: ;
582 pci_iounmap(pdev, ioaddr);
583err_out_free_mmio_region:
584 release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
585err_out_free_pio_region:
586 release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1));
587err_out_none:
588 return -ENODEV;
589}
590
591#ifdef CONFIG_NET_POLL_CONTROLLER
592/*
593 * Polling 'interrupt' - used by things like netconsole to send skbs
594 * without having to re-enable interrupts. It's not called while
595 * the interrupt routine is executing.
596 */
597
598static void poll_speedo (struct net_device *dev)
599{
600 /* disable_irq is not very nice, but with the funny lockless design
601 we have no other choice. */
602 disable_irq(dev->irq);
603 speedo_interrupt (dev->irq, dev);
604 enable_irq(dev->irq);
605}
606#endif
607
608static int __devinit speedo_found1(struct pci_dev *pdev,
609 void __iomem *ioaddr, int card_idx, int acpi_idle_state)
610{
611 struct net_device *dev;
612 struct speedo_private *sp;
613 const char *product;
614 int i, option;
615 u16 eeprom[0x100];
616 int size;
617 void *tx_ring_space;
618 dma_addr_t tx_ring_dma;
619 DECLARE_MAC_BUF(mac);
620
621 size = TX_RING_SIZE * sizeof(struct TxFD) + sizeof(struct speedo_stats);
622 tx_ring_space = pci_alloc_consistent(pdev, size, &tx_ring_dma);
623 if (tx_ring_space == NULL)
624 return -1;
625
626 dev = alloc_etherdev(sizeof(struct speedo_private));
627 if (dev == NULL) {
628 printk(KERN_ERR "eepro100: Could not allocate ethernet device.\n");
629 pci_free_consistent(pdev, size, tx_ring_space, tx_ring_dma);
630 return -1;
631 }
632
633 SET_NETDEV_DEV(dev, &pdev->dev);
634
635 if (dev->mem_start > 0)
636 option = dev->mem_start;
637 else if (card_idx >= 0 && options[card_idx] >= 0)
638 option = options[card_idx];
639 else
640 option = 0;
641
642 rtnl_lock();
643 if (dev_alloc_name(dev, dev->name) < 0)
644 goto err_free_unlock;
645
646 /* Read the station address EEPROM before doing the reset.
647 Nominally his should even be done before accepting the device, but
648 then we wouldn't have a device name with which to report the error.
649 The size test is for 6 bit vs. 8 bit address serial EEPROMs.
650 */
651 {
652 void __iomem *iobase;
653 int read_cmd, ee_size;
654 u16 sum;
655 int j;
656
657 /* Use IO only to avoid postponed writes and satisfy EEPROM timing
658 requirements. */
659 iobase = pci_iomap(pdev, 1, pci_resource_len(pdev, 1));
660 if (!iobase)
661 goto err_free_unlock;
662 if ((do_eeprom_cmd(iobase, EE_READ_CMD << 24, 27) & 0xffe0000)
663 == 0xffe0000) {
664 ee_size = 0x100;
665 read_cmd = EE_READ_CMD << 24;
666 } else {
667 ee_size = 0x40;
668 read_cmd = EE_READ_CMD << 22;
669 }
670
671 for (j = 0, i = 0, sum = 0; i < ee_size; i++) {
672 u16 value = do_eeprom_cmd(iobase, read_cmd | (i << 16), 27);
673 eeprom[i] = value;
674 sum += value;
675 if (i < 3) {
676 dev->dev_addr[j++] = value;
677 dev->dev_addr[j++] = value >> 8;
678 }
679 }
680 if (sum != 0xBABA)
681 printk(KERN_WARNING "%s: Invalid EEPROM checksum %#4.4x, "
682 "check settings before activating this device!\n",
683 dev->name, sum);
684 /* Don't unregister_netdev(dev); as the EEPro may actually be
685 usable, especially if the MAC address is set later.
686 On the other hand, it may be unusable if MDI data is corrupted. */
687
688 pci_iounmap(pdev, iobase);
689 }
690
691 /* Reset the chip: stop Tx and Rx processes and clear counters.
692 This takes less than 10usec and will easily finish before the next
693 action. */
694 iowrite32(PortReset, ioaddr + SCBPort);
695 ioread32(ioaddr + SCBPort);
696 udelay(10);
697
698 if (eeprom[3] & 0x0100)
699 product = "OEM i82557/i82558 10/100 Ethernet";
700 else
701 product = pci_name(pdev);
702
703 printk(KERN_INFO "%s: %s, %s, IRQ %d.\n", dev->name, product,
704 print_mac(mac, dev->dev_addr), pdev->irq);
705
706 sp = netdev_priv(dev);
707
708 /* we must initialize this early, for mdio_{read,write} */
709 sp->regs = ioaddr;
710
711#if 1 || defined(kernel_bloat)
712 /* OK, this is pure kernel bloat. I don't like it when other drivers
713 waste non-pageable kernel space to emit similar messages, but I need
714 them for bug reports. */
715 {
716 const char *connectors[] = {" RJ45", " BNC", " AUI", " MII"};
717 /* The self-test results must be paragraph aligned. */
718 volatile s32 *self_test_results;
719 int boguscnt = 16000; /* Timeout for set-test. */
720 if ((eeprom[3] & 0x03) != 0x03)
721 printk(KERN_INFO " Receiver lock-up bug exists -- enabling"
722 " work-around.\n");
723 printk(KERN_INFO " Board assembly %4.4x%2.2x-%3.3d, Physical"
724 " connectors present:",
725 eeprom[8], eeprom[9]>>8, eeprom[9] & 0xff);
726 for (i = 0; i < 4; i++)
727 if (eeprom[5] & (1<<i))
728 printk(connectors[i]);
729 printk("\n"KERN_INFO" Primary interface chip %s PHY #%d.\n",
730 phys[(eeprom[6]>>8)&15], eeprom[6] & 0x1f);
731 if (eeprom[7] & 0x0700)
732 printk(KERN_INFO " Secondary interface chip %s.\n",
733 phys[(eeprom[7]>>8)&7]);
734 if (((eeprom[6]>>8) & 0x3f) == DP83840
735 || ((eeprom[6]>>8) & 0x3f) == DP83840A) {
736 int mdi_reg23 = mdio_read(dev, eeprom[6] & 0x1f, 23) | 0x0422;
737 if (congenb)
738 mdi_reg23 |= 0x0100;
739 printk(KERN_INFO" DP83840 specific setup, setting register 23 to %4.4x.\n",
740 mdi_reg23);
741 mdio_write(dev, eeprom[6] & 0x1f, 23, mdi_reg23);
742 }
743 if ((option >= 0) && (option & 0x70)) {
744 printk(KERN_INFO " Forcing %dMbs %s-duplex operation.\n",
745 (option & 0x20 ? 100 : 10),
746 (option & 0x10 ? "full" : "half"));
747 mdio_write(dev, eeprom[6] & 0x1f, MII_BMCR,
748 ((option & 0x20) ? 0x2000 : 0) | /* 100mbps? */
749 ((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */
750 }
751
752 /* Perform a system self-test. */
753 self_test_results = (s32*) ((((long) tx_ring_space) + 15) & ~0xf);
754 self_test_results[0] = 0;
755 self_test_results[1] = -1;
756 iowrite32(tx_ring_dma | PortSelfTest, ioaddr + SCBPort);
757 do {
758 udelay(10);
759 } while (self_test_results[1] == -1 && --boguscnt >= 0);
760
761 if (boguscnt < 0) { /* Test optimized out. */
762 printk(KERN_ERR "Self test failed, status %8.8x:\n"
763 KERN_ERR " Failure to initialize the i82557.\n"
764 KERN_ERR " Verify that the card is a bus-master"
765 " capable slot.\n",
766 self_test_results[1]);
767 } else
768 printk(KERN_INFO " General self-test: %s.\n"
769 KERN_INFO " Serial sub-system self-test: %s.\n"
770 KERN_INFO " Internal registers self-test: %s.\n"
771 KERN_INFO " ROM checksum self-test: %s (%#8.8x).\n",
772 self_test_results[1] & 0x1000 ? "failed" : "passed",
773 self_test_results[1] & 0x0020 ? "failed" : "passed",
774 self_test_results[1] & 0x0008 ? "failed" : "passed",
775 self_test_results[1] & 0x0004 ? "failed" : "passed",
776 self_test_results[0]);
777 }
778#endif /* kernel_bloat */
779
780 iowrite32(PortReset, ioaddr + SCBPort);
781 ioread32(ioaddr + SCBPort);
782 udelay(10);
783
784 /* Return the chip to its original power state. */
785 pci_set_power_state(pdev, acpi_idle_state);
786
787 pci_set_drvdata (pdev, dev);
788 SET_NETDEV_DEV(dev, &pdev->dev);
789
790 dev->irq = pdev->irq;
791
792 sp->pdev = pdev;
793 sp->msg_enable = DEBUG;
794 sp->acpi_pwr = acpi_idle_state;
795 sp->tx_ring = tx_ring_space;
796 sp->tx_ring_dma = tx_ring_dma;
797 sp->lstats = (struct speedo_stats *)(sp->tx_ring + TX_RING_SIZE);
798 sp->lstats_dma = TX_RING_ELEM_DMA(sp, TX_RING_SIZE);
799 init_timer(&sp->timer); /* used in ioctl() */
800 spin_lock_init(&sp->lock);
801
802 sp->mii_if.full_duplex = option >= 0 && (option & 0x10) ? 1 : 0;
803 if (card_idx >= 0) {
804 if (full_duplex[card_idx] >= 0)
805 sp->mii_if.full_duplex = full_duplex[card_idx];
806 }
807 sp->default_port = option >= 0 ? (option & 0x0f) : 0;
808
809 sp->phy[0] = eeprom[6];
810 sp->phy[1] = eeprom[7];
811
812 sp->mii_if.phy_id = eeprom[6] & 0x1f;
813 sp->mii_if.phy_id_mask = 0x1f;
814 sp->mii_if.reg_num_mask = 0x1f;
815 sp->mii_if.dev = dev;
816 sp->mii_if.mdio_read = mdio_read;
817 sp->mii_if.mdio_write = mdio_write;
818
819 sp->rx_bug = (eeprom[3] & 0x03) == 3 ? 0 : 1;
820 if (((pdev->device > 0x1030 && (pdev->device < 0x103F)))
821 || (pdev->device == 0x2449) || (pdev->device == 0x2459)
822 || (pdev->device == 0x245D)) {
823 sp->chip_id = 1;
824 }
825
826 if (sp->rx_bug)
827 printk(KERN_INFO " Receiver lock-up workaround activated.\n");
828
829 /* The Speedo-specific entries in the device structure. */
830 dev->open = &speedo_open;
831 dev->hard_start_xmit = &speedo_start_xmit;
832 netif_set_tx_timeout(dev, &speedo_tx_timeout, TX_TIMEOUT);
833 dev->stop = &speedo_close;
834 dev->get_stats = &speedo_get_stats;
835 dev->set_multicast_list = &set_rx_mode;
836 dev->do_ioctl = &speedo_ioctl;
837 SET_ETHTOOL_OPS(dev, &ethtool_ops);
838#ifdef CONFIG_NET_POLL_CONTROLLER
839 dev->poll_controller = &poll_speedo;
840#endif
841
842 if (register_netdevice(dev))
843 goto err_free_unlock;
844 rtnl_unlock();
845
846 return 0;
847
848 err_free_unlock:
849 rtnl_unlock();
850 free_netdev(dev);
851 return -1;
852}
853
854static void do_slow_command(struct net_device *dev, struct speedo_private *sp, int cmd)
855{
856 void __iomem *cmd_ioaddr = sp->regs + SCBCmd;
857 int wait = 0;
858 do
859 if (ioread8(cmd_ioaddr) == 0) break;
860 while(++wait <= 200);
861 if (wait > 100)
862 printk(KERN_ERR "Command %4.4x never accepted (%d polls)!\n",
863 ioread8(cmd_ioaddr), wait);
864
865 iowrite8(cmd, cmd_ioaddr);
866
867 for (wait = 0; wait <= 100; wait++)
868 if (ioread8(cmd_ioaddr) == 0) return;
869 for (; wait <= 20000; wait++)
870 if (ioread8(cmd_ioaddr) == 0) return;
871 else udelay(1);
872 printk(KERN_ERR "Command %4.4x was not accepted after %d polls!"
873 " Current status %8.8x.\n",
874 cmd, wait, ioread32(sp->regs + SCBStatus));
875}
876
877/* Serial EEPROM section.
878 A "bit" grungy, but we work our way through bit-by-bit :->. */
879/* EEPROM_Ctrl bits. */
880#define EE_SHIFT_CLK 0x01 /* EEPROM shift clock. */
881#define EE_CS 0x02 /* EEPROM chip select. */
882#define EE_DATA_WRITE 0x04 /* EEPROM chip data in. */
883#define EE_DATA_READ 0x08 /* EEPROM chip data out. */
884#define EE_ENB (0x4800 | EE_CS)
885#define EE_WRITE_0 0x4802
886#define EE_WRITE_1 0x4806
887#define EE_OFFSET SCBeeprom
888
889/* The fixes for the code were kindly provided by Dragan Stancevic
890 <visitor@valinux.com> to strictly follow Intel specifications of EEPROM
891 access timing.
892 The publicly available sheet 64486302 (sec. 3.1) specifies 1us access
893 interval for serial EEPROM. However, it looks like that there is an
894 additional requirement dictating larger udelay's in the code below.
895 2000/05/24 SAW */
896static int __devinit do_eeprom_cmd(void __iomem *ioaddr, int cmd, int cmd_len)
897{
898 unsigned retval = 0;
899 void __iomem *ee_addr = ioaddr + SCBeeprom;
900
901 iowrite16(EE_ENB, ee_addr); udelay(2);
902 iowrite16(EE_ENB | EE_SHIFT_CLK, ee_addr); udelay(2);
903
904 /* Shift the command bits out. */
905 do {
906 short dataval = (cmd & (1 << cmd_len)) ? EE_WRITE_1 : EE_WRITE_0;
907 iowrite16(dataval, ee_addr); udelay(2);
908 iowrite16(dataval | EE_SHIFT_CLK, ee_addr); udelay(2);
909 retval = (retval << 1) | ((ioread16(ee_addr) & EE_DATA_READ) ? 1 : 0);
910 } while (--cmd_len >= 0);
911 iowrite16(EE_ENB, ee_addr); udelay(2);
912
913 /* Terminate the EEPROM access. */
914 iowrite16(EE_ENB & ~EE_CS, ee_addr);
915 return retval;
916}
917
918static int mdio_read(struct net_device *dev, int phy_id, int location)
919{
920 struct speedo_private *sp = netdev_priv(dev);
921 void __iomem *ioaddr = sp->regs;
922 int val, boguscnt = 64*10; /* <64 usec. to complete, typ 27 ticks */
923 iowrite32(0x08000000 | (location<<16) | (phy_id<<21), ioaddr + SCBCtrlMDI);
924 do {
925 val = ioread32(ioaddr + SCBCtrlMDI);
926 if (--boguscnt < 0) {
927 printk(KERN_ERR " mdio_read() timed out with val = %8.8x.\n", val);
928 break;
929 }
930 } while (! (val & 0x10000000));
931 return val & 0xffff;
932}
933
934static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
935{
936 struct speedo_private *sp = netdev_priv(dev);
937 void __iomem *ioaddr = sp->regs;
938 int val, boguscnt = 64*10; /* <64 usec. to complete, typ 27 ticks */
939 iowrite32(0x04000000 | (location<<16) | (phy_id<<21) | value,
940 ioaddr + SCBCtrlMDI);
941 do {
942 val = ioread32(ioaddr + SCBCtrlMDI);
943 if (--boguscnt < 0) {
944 printk(KERN_ERR" mdio_write() timed out with val = %8.8x.\n", val);
945 break;
946 }
947 } while (! (val & 0x10000000));
948}
949
950static int
951speedo_open(struct net_device *dev)
952{
953 struct speedo_private *sp = netdev_priv(dev);
954 void __iomem *ioaddr = sp->regs;
955 int retval;
956
957 if (netif_msg_ifup(sp))
958 printk(KERN_DEBUG "%s: speedo_open() irq %d.\n", dev->name, dev->irq);
959
960 pci_set_power_state(sp->pdev, PCI_D0);
961
962 /* Set up the Tx queue early.. */
963 sp->cur_tx = 0;
964 sp->dirty_tx = 0;
965 sp->last_cmd = NULL;
966 sp->tx_full = 0;
967 sp->in_interrupt = 0;
968
969 /* .. we can safely take handler calls during init. */
970 retval = request_irq(dev->irq, &speedo_interrupt, IRQF_SHARED, dev->name, dev);
971 if (retval) {
972 return retval;
973 }
974
975 dev->if_port = sp->default_port;
976
977#ifdef oh_no_you_dont_unless_you_honour_the_options_passed_in_to_us
978 /* Retrigger negotiation to reset previous errors. */
979 if ((sp->phy[0] & 0x8000) == 0) {
980 int phy_addr = sp->phy[0] & 0x1f ;
981 /* Use 0x3300 for restarting NWay, other values to force xcvr:
982 0x0000 10-HD
983 0x0100 10-FD
984 0x2000 100-HD
985 0x2100 100-FD
986 */
987#ifdef honor_default_port
988 mdio_write(dev, phy_addr, MII_BMCR, mii_ctrl[dev->default_port & 7]);
989#else
990 mdio_write(dev, phy_addr, MII_BMCR, 0x3300);
991#endif
992 }
993#endif
994
995 speedo_init_rx_ring(dev);
996
997 /* Fire up the hardware. */
998 iowrite16(SCBMaskAll, ioaddr + SCBCmd);
999 speedo_resume(dev);
1000
1001 netdevice_start(dev);
1002 netif_start_queue(dev);
1003
1004 /* Setup the chip and configure the multicast list. */
1005 sp->mc_setup_head = NULL;
1006 sp->mc_setup_tail = NULL;
1007 sp->flow_ctrl = sp->partner = 0;
1008 sp->rx_mode = -1; /* Invalid -> always reset the mode. */
1009 set_rx_mode(dev);
1010 if ((sp->phy[0] & 0x8000) == 0)
1011 sp->mii_if.advertising = mdio_read(dev, sp->phy[0] & 0x1f, MII_ADVERTISE);
1012
1013 mii_check_link(&sp->mii_if);
1014
1015 if (netif_msg_ifup(sp)) {
1016 printk(KERN_DEBUG "%s: Done speedo_open(), status %8.8x.\n",
1017 dev->name, ioread16(ioaddr + SCBStatus));
1018 }
1019
1020 /* Set the timer. The timer serves a dual purpose:
1021 1) to monitor the media interface (e.g. link beat) and perhaps switch
1022 to an alternate media type
1023 2) to monitor Rx activity, and restart the Rx process if the receiver
1024 hangs. */
1025 sp->timer.expires = RUN_AT((24*HZ)/10); /* 2.4 sec. */
1026 sp->timer.data = (unsigned long)dev;
1027 sp->timer.function = &speedo_timer; /* timer handler */
1028 add_timer(&sp->timer);
1029
1030 /* No need to wait for the command unit to accept here. */
1031 if ((sp->phy[0] & 0x8000) == 0)
1032 mdio_read(dev, sp->phy[0] & 0x1f, MII_BMCR);
1033
1034 return 0;
1035}
1036
1037/* Start the chip hardware after a full reset. */
1038static void speedo_resume(struct net_device *dev)
1039{
1040 struct speedo_private *sp = netdev_priv(dev);
1041 void __iomem *ioaddr = sp->regs;
1042
1043 /* Start with a Tx threshold of 256 (0x..20.... 8 byte units). */
1044 sp->tx_threshold = 0x01208000;
1045
1046 /* Set the segment registers to '0'. */
1047 if (wait_for_cmd_done(dev, sp) != 0) {
1048 iowrite32(PortPartialReset, ioaddr + SCBPort);
1049 udelay(10);
1050 }
1051
1052 iowrite32(0, ioaddr + SCBPointer);
1053 ioread32(ioaddr + SCBPointer); /* Flush to PCI. */
1054 udelay(10); /* Bogus, but it avoids the bug. */
1055
1056 /* Note: these next two operations can take a while. */
1057 do_slow_command(dev, sp, RxAddrLoad);
1058 do_slow_command(dev, sp, CUCmdBase);
1059
1060 /* Load the statistics block and rx ring addresses. */
1061 iowrite32(sp->lstats_dma, ioaddr + SCBPointer);
1062 ioread32(ioaddr + SCBPointer); /* Flush to PCI */
1063
1064 iowrite8(CUStatsAddr, ioaddr + SCBCmd);
1065 sp->lstats->done_marker = 0;
1066 wait_for_cmd_done(dev, sp);
1067
1068 if (sp->rx_ringp[sp->cur_rx % RX_RING_SIZE] == NULL) {
1069 if (netif_msg_rx_err(sp))
1070 printk(KERN_DEBUG "%s: NULL cur_rx in speedo_resume().\n",
1071 dev->name);
1072 } else {
1073 iowrite32(sp->rx_ring_dma[sp->cur_rx % RX_RING_SIZE],
1074 ioaddr + SCBPointer);
1075 ioread32(ioaddr + SCBPointer); /* Flush to PCI */
1076 }
1077
1078 /* Note: RxStart should complete instantly. */
1079 do_slow_command(dev, sp, RxStart);
1080 do_slow_command(dev, sp, CUDumpStats);
1081
1082 /* Fill the first command with our physical address. */
1083 {
1084 struct descriptor *ias_cmd;
1085
1086 ias_cmd =
1087 (struct descriptor *)&sp->tx_ring[sp->cur_tx++ % TX_RING_SIZE];
1088 /* Avoid a bug(?!) here by marking the command already completed. */
1089 ias_cmd->cmd_status = cpu_to_le32((CmdSuspend | CmdIASetup) | 0xa000);
1090 ias_cmd->link =
1091 cpu_to_le32(TX_RING_ELEM_DMA(sp, sp->cur_tx % TX_RING_SIZE));
1092 memcpy(ias_cmd->params, dev->dev_addr, 6);
1093 if (sp->last_cmd)
1094 clear_suspend(sp->last_cmd);
1095 sp->last_cmd = ias_cmd;
1096 }
1097
1098 /* Start the chip's Tx process and unmask interrupts. */
1099 iowrite32(TX_RING_ELEM_DMA(sp, sp->dirty_tx % TX_RING_SIZE),
1100 ioaddr + SCBPointer);
1101 /* We are not ACK-ing FCP and ER in the interrupt handler yet so they should
1102 remain masked --Dragan */
1103 iowrite16(CUStart | SCBMaskEarlyRx | SCBMaskFlowCtl, ioaddr + SCBCmd);
1104}
1105
1106/*
1107 * Sometimes the receiver stops making progress. This routine knows how to
1108 * get it going again, without losing packets or being otherwise nasty like
1109 * a chip reset would be. Previously the driver had a whole sequence
1110 * of if RxSuspended, if it's no buffers do one thing, if it's no resources,
1111 * do another, etc. But those things don't really matter. Separate logic
1112 * in the ISR provides for allocating buffers--the other half of operation
1113 * is just making sure the receiver is active. speedo_rx_soft_reset does that.
1114 * This problem with the old, more involved algorithm is shown up under
1115 * ping floods on the order of 60K packets/second on a 100Mbps fdx network.
1116 */
1117static void
1118speedo_rx_soft_reset(struct net_device *dev)
1119{
1120 struct speedo_private *sp = netdev_priv(dev);
1121 struct RxFD *rfd;
1122 void __iomem *ioaddr;
1123
1124 ioaddr = sp->regs;
1125 if (wait_for_cmd_done(dev, sp) != 0) {
1126 printk("%s: previous command stalled\n", dev->name);
1127 return;
1128 }
1129 /*
1130 * Put the hardware into a known state.
1131 */
1132 iowrite8(RxAbort, ioaddr + SCBCmd);
1133
1134 rfd = sp->rx_ringp[sp->cur_rx % RX_RING_SIZE];
1135
1136 rfd->rx_buf_addr = cpu_to_le32(0xffffffff);
1137
1138 if (wait_for_cmd_done(dev, sp) != 0) {
1139 printk("%s: RxAbort command stalled\n", dev->name);
1140 return;
1141 }
1142 iowrite32(sp->rx_ring_dma[sp->cur_rx % RX_RING_SIZE],
1143 ioaddr + SCBPointer);
1144 iowrite8(RxStart, ioaddr + SCBCmd);
1145}
1146
1147
1148/* Media monitoring and control. */
1149static void speedo_timer(unsigned long data)
1150{
1151 struct net_device *dev = (struct net_device *)data;
1152 struct speedo_private *sp = netdev_priv(dev);
1153 void __iomem *ioaddr = sp->regs;
1154 int phy_num = sp->phy[0] & 0x1f;
1155
1156 /* We have MII and lost link beat. */
1157 if ((sp->phy[0] & 0x8000) == 0) {
1158 int partner = mdio_read(dev, phy_num, MII_LPA);
1159 if (partner != sp->partner) {
1160 int flow_ctrl = sp->mii_if.advertising & partner & 0x0400 ? 1 : 0;
1161 if (netif_msg_link(sp)) {
1162 printk(KERN_DEBUG "%s: Link status change.\n", dev->name);
1163 printk(KERN_DEBUG "%s: Old partner %x, new %x, adv %x.\n",
1164 dev->name, sp->partner, partner, sp->mii_if.advertising);
1165 }
1166 sp->partner = partner;
1167 if (flow_ctrl != sp->flow_ctrl) {
1168 sp->flow_ctrl = flow_ctrl;
1169 sp->rx_mode = -1; /* Trigger a reload. */
1170 }
1171 }
1172 }
1173 mii_check_link(&sp->mii_if);
1174 if (netif_msg_timer(sp)) {
1175 printk(KERN_DEBUG "%s: Media control tick, status %4.4x.\n",
1176 dev->name, ioread16(ioaddr + SCBStatus));
1177 }
1178 if (sp->rx_mode < 0 ||
1179 (sp->rx_bug && jiffies - sp->last_rx_time > 2*HZ)) {
1180 /* We haven't received a packet in a Long Time. We might have been
1181 bitten by the receiver hang bug. This can be cleared by sending
1182 a set multicast list command. */
1183 if (netif_msg_timer(sp))
1184 printk(KERN_DEBUG "%s: Sending a multicast list set command"
1185 " from a timer routine,"
1186 " m=%d, j=%ld, l=%ld.\n",
1187 dev->name, sp->rx_mode, jiffies, sp->last_rx_time);
1188 set_rx_mode(dev);
1189 }
1190 /* We must continue to monitor the media. */
1191 sp->timer.expires = RUN_AT(2*HZ); /* 2.0 sec. */
1192 add_timer(&sp->timer);
1193}
1194
1195static void speedo_show_state(struct net_device *dev)
1196{
1197 struct speedo_private *sp = netdev_priv(dev);
1198 int i;
1199
1200 if (netif_msg_pktdata(sp)) {
1201 printk(KERN_DEBUG "%s: Tx ring dump, Tx queue %u / %u:\n",
1202 dev->name, sp->cur_tx, sp->dirty_tx);
1203 for (i = 0; i < TX_RING_SIZE; i++)
1204 printk(KERN_DEBUG "%s: %c%c%2d %8.8x.\n", dev->name,
1205 i == sp->dirty_tx % TX_RING_SIZE ? '*' : ' ',
1206 i == sp->cur_tx % TX_RING_SIZE ? '=' : ' ',
1207 i, sp->tx_ring[i].status);
1208
1209 printk(KERN_DEBUG "%s: Printing Rx ring"
1210 " (next to receive into %u, dirty index %u).\n",
1211 dev->name, sp->cur_rx, sp->dirty_rx);
1212 for (i = 0; i < RX_RING_SIZE; i++)
1213 printk(KERN_DEBUG "%s: %c%c%c%2d %8.8x.\n", dev->name,
1214 sp->rx_ringp[i] == sp->last_rxf ? 'l' : ' ',
1215 i == sp->dirty_rx % RX_RING_SIZE ? '*' : ' ',
1216 i == sp->cur_rx % RX_RING_SIZE ? '=' : ' ',
1217 i, (sp->rx_ringp[i] != NULL) ?
1218 (unsigned)sp->rx_ringp[i]->status : 0);
1219 }
1220
1221#if 0
1222 {
1223 void __iomem *ioaddr = sp->regs;
1224 int phy_num = sp->phy[0] & 0x1f;
1225 for (i = 0; i < 16; i++) {
1226 /* FIXME: what does it mean? --SAW */
1227 if (i == 6) i = 21;
1228 printk(KERN_DEBUG "%s: PHY index %d register %d is %4.4x.\n",
1229 dev->name, phy_num, i, mdio_read(dev, phy_num, i));
1230 }
1231 }
1232#endif
1233
1234}
1235
1236/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
1237static void
1238speedo_init_rx_ring(struct net_device *dev)
1239{
1240 struct speedo_private *sp = netdev_priv(dev);
1241 struct RxFD *rxf, *last_rxf = NULL;
1242 dma_addr_t last_rxf_dma = 0 /* to shut up the compiler */;
1243 int i;
1244
1245 sp->cur_rx = 0;
1246
1247 for (i = 0; i < RX_RING_SIZE; i++) {
1248 struct sk_buff *skb;
1249 skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD));
1250 if (skb)
1251 rx_align(skb); /* Align IP on 16 byte boundary */
1252 sp->rx_skbuff[i] = skb;
1253 if (skb == NULL)
1254 break; /* OK. Just initially short of Rx bufs. */
1255 skb->dev = dev; /* Mark as being used by this device. */
1256 rxf = (struct RxFD *)skb->data;
1257 sp->rx_ringp[i] = rxf;
1258 sp->rx_ring_dma[i] =
1259 pci_map_single(sp->pdev, rxf,
1260 PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_BIDIRECTIONAL);
1261 skb_reserve(skb, sizeof(struct RxFD));
1262 if (last_rxf) {
1263 last_rxf->link = cpu_to_le32(sp->rx_ring_dma[i]);
1264 pci_dma_sync_single_for_device(sp->pdev, last_rxf_dma,
1265 sizeof(struct RxFD), PCI_DMA_TODEVICE);
1266 }
1267 last_rxf = rxf;
1268 last_rxf_dma = sp->rx_ring_dma[i];
1269 rxf->status = cpu_to_le32(0x00000001); /* '1' is flag value only. */
1270 rxf->link = 0; /* None yet. */
1271 /* This field unused by i82557. */
1272 rxf->rx_buf_addr = cpu_to_le32(0xffffffff);
1273 rxf->count = cpu_to_le32(PKT_BUF_SZ << 16);
1274 pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[i],
1275 sizeof(struct RxFD), PCI_DMA_TODEVICE);
1276 }
1277 sp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
1278 /* Mark the last entry as end-of-list. */
1279 last_rxf->status = cpu_to_le32(0xC0000002); /* '2' is flag value only. */
1280 pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[RX_RING_SIZE-1],
1281 sizeof(struct RxFD), PCI_DMA_TODEVICE);
1282 sp->last_rxf = last_rxf;
1283 sp->last_rxf_dma = last_rxf_dma;
1284}
1285
1286static void speedo_purge_tx(struct net_device *dev)
1287{
1288 struct speedo_private *sp = netdev_priv(dev);
1289 int entry;
1290
1291 while ((int)(sp->cur_tx - sp->dirty_tx) > 0) {
1292 entry = sp->dirty_tx % TX_RING_SIZE;
1293 if (sp->tx_skbuff[entry]) {
1294 sp->stats.tx_errors++;
1295 pci_unmap_single(sp->pdev,
1296 le32_to_cpu(sp->tx_ring[entry].tx_buf_addr0),
1297 sp->tx_skbuff[entry]->len, PCI_DMA_TODEVICE);
1298 dev_kfree_skb_irq(sp->tx_skbuff[entry]);
1299 sp->tx_skbuff[entry] = NULL;
1300 }
1301 sp->dirty_tx++;
1302 }
1303 while (sp->mc_setup_head != NULL) {
1304 struct speedo_mc_block *t;
1305 if (netif_msg_tx_err(sp))
1306 printk(KERN_DEBUG "%s: freeing mc frame.\n", dev->name);
1307 pci_unmap_single(sp->pdev, sp->mc_setup_head->frame_dma,
1308 sp->mc_setup_head->len, PCI_DMA_TODEVICE);
1309 t = sp->mc_setup_head->next;
1310 kfree(sp->mc_setup_head);
1311 sp->mc_setup_head = t;
1312 }
1313 sp->mc_setup_tail = NULL;
1314 sp->tx_full = 0;
1315 netif_wake_queue(dev);
1316}
1317
1318static void reset_mii(struct net_device *dev)
1319{
1320 struct speedo_private *sp = netdev_priv(dev);
1321
1322 /* Reset the MII transceiver, suggested by Fred Young @ scalable.com. */
1323 if ((sp->phy[0] & 0x8000) == 0) {
1324 int phy_addr = sp->phy[0] & 0x1f;
1325 int advertising = mdio_read(dev, phy_addr, MII_ADVERTISE);
1326 int mii_bmcr = mdio_read(dev, phy_addr, MII_BMCR);
1327 mdio_write(dev, phy_addr, MII_BMCR, 0x0400);
1328 mdio_write(dev, phy_addr, MII_BMSR, 0x0000);
1329 mdio_write(dev, phy_addr, MII_ADVERTISE, 0x0000);
1330 mdio_write(dev, phy_addr, MII_BMCR, 0x8000);
1331#ifdef honor_default_port
1332 mdio_write(dev, phy_addr, MII_BMCR, mii_ctrl[dev->default_port & 7]);
1333#else
1334 mdio_read(dev, phy_addr, MII_BMCR);
1335 mdio_write(dev, phy_addr, MII_BMCR, mii_bmcr);
1336 mdio_write(dev, phy_addr, MII_ADVERTISE, advertising);
1337#endif
1338 }
1339}
1340
1341static void speedo_tx_timeout(struct net_device *dev)
1342{
1343 struct speedo_private *sp = netdev_priv(dev);
1344 void __iomem *ioaddr = sp->regs;
1345 int status = ioread16(ioaddr + SCBStatus);
1346 unsigned long flags;
1347
1348 if (netif_msg_tx_err(sp)) {
1349 printk(KERN_WARNING "%s: Transmit timed out: status %4.4x "
1350 " %4.4x at %d/%d command %8.8x.\n",
1351 dev->name, status, ioread16(ioaddr + SCBCmd),
1352 sp->dirty_tx, sp->cur_tx,
1353 sp->tx_ring[sp->dirty_tx % TX_RING_SIZE].status);
1354
1355 }
1356 speedo_show_state(dev);
1357#if 0
1358 if ((status & 0x00C0) != 0x0080
1359 && (status & 0x003C) == 0x0010) {
1360 /* Only the command unit has stopped. */
1361 printk(KERN_WARNING "%s: Trying to restart the transmitter...\n",
1362 dev->name);
1363 iowrite32(TX_RING_ELEM_DMA(sp, dirty_tx % TX_RING_SIZE]),
1364 ioaddr + SCBPointer);
1365 iowrite16(CUStart, ioaddr + SCBCmd);
1366 reset_mii(dev);
1367 } else {
1368#else
1369 {
1370#endif
1371 del_timer_sync(&sp->timer);
1372 /* Reset the Tx and Rx units. */
1373 iowrite32(PortReset, ioaddr + SCBPort);
1374 /* We may get spurious interrupts here. But I don't think that they
1375 may do much harm. 1999/12/09 SAW */
1376 udelay(10);
1377 /* Disable interrupts. */
1378 iowrite16(SCBMaskAll, ioaddr + SCBCmd);
1379 synchronize_irq(dev->irq);
1380 speedo_tx_buffer_gc(dev);
1381 /* Free as much as possible.
1382 It helps to recover from a hang because of out-of-memory.
1383 It also simplifies speedo_resume() in case TX ring is full or
1384 close-to-be full. */
1385 speedo_purge_tx(dev);
1386 speedo_refill_rx_buffers(dev, 1);
1387 spin_lock_irqsave(&sp->lock, flags);
1388 speedo_resume(dev);
1389 sp->rx_mode = -1;
1390 dev->trans_start = jiffies;
1391 spin_unlock_irqrestore(&sp->lock, flags);
1392 set_rx_mode(dev); /* it takes the spinlock itself --SAW */
1393 /* Reset MII transceiver. Do it before starting the timer to serialize
1394 mdio_xxx operations. Yes, it's a paranoya :-) 2000/05/09 SAW */
1395 reset_mii(dev);
1396 sp->timer.expires = RUN_AT(2*HZ);
1397 add_timer(&sp->timer);
1398 }
1399 return;
1400}
1401
1402static int
1403speedo_start_xmit(struct sk_buff *skb, struct net_device *dev)
1404{
1405 struct speedo_private *sp = netdev_priv(dev);
1406 void __iomem *ioaddr = sp->regs;
1407 int entry;
1408
1409 /* Prevent interrupts from changing the Tx ring from underneath us. */
1410 unsigned long flags;
1411
1412 spin_lock_irqsave(&sp->lock, flags);
1413
1414 /* Check if there are enough space. */
1415 if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
1416 printk(KERN_ERR "%s: incorrect tbusy state, fixed.\n", dev->name);
1417 netif_stop_queue(dev);
1418 sp->tx_full = 1;
1419 spin_unlock_irqrestore(&sp->lock, flags);
1420 return 1;
1421 }
1422
1423 /* Calculate the Tx descriptor entry. */
1424 entry = sp->cur_tx++ % TX_RING_SIZE;
1425
1426 sp->tx_skbuff[entry] = skb;
1427 sp->tx_ring[entry].status =
1428 cpu_to_le32(CmdSuspend | CmdTx | CmdTxFlex);
1429 if (!(entry & ((TX_RING_SIZE>>2)-1)))
1430 sp->tx_ring[entry].status |= cpu_to_le32(CmdIntr);
1431 sp->tx_ring[entry].link =
1432 cpu_to_le32(TX_RING_ELEM_DMA(sp, sp->cur_tx % TX_RING_SIZE));
1433 sp->tx_ring[entry].tx_desc_addr =
1434 cpu_to_le32(TX_RING_ELEM_DMA(sp, entry) + TX_DESCR_BUF_OFFSET);
1435 /* The data region is always in one buffer descriptor. */
1436 sp->tx_ring[entry].count = cpu_to_le32(sp->tx_threshold);
1437 sp->tx_ring[entry].tx_buf_addr0 =
1438 cpu_to_le32(pci_map_single(sp->pdev, skb->data,
1439 skb->len, PCI_DMA_TODEVICE));
1440 sp->tx_ring[entry].tx_buf_size0 = cpu_to_le32(skb->len);
1441
1442 /* workaround for hardware bug on 10 mbit half duplex */
1443
1444 if ((sp->partner == 0) && (sp->chip_id == 1)) {
1445 wait_for_cmd_done(dev, sp);
1446 iowrite8(0 , ioaddr + SCBCmd);
1447 udelay(1);
1448 }
1449
1450 /* Trigger the command unit resume. */
1451 wait_for_cmd_done(dev, sp);
1452 clear_suspend(sp->last_cmd);
1453 /* We want the time window between clearing suspend flag on the previous
1454 command and resuming CU to be as small as possible.
1455 Interrupts in between are very undesired. --SAW */
1456 iowrite8(CUResume, ioaddr + SCBCmd);
1457 sp->last_cmd = (struct descriptor *)&sp->tx_ring[entry];
1458
1459 /* Leave room for set_rx_mode(). If there is no more space than reserved
1460 for multicast filter mark the ring as full. */
1461 if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
1462 netif_stop_queue(dev);
1463 sp->tx_full = 1;
1464 }
1465
1466 spin_unlock_irqrestore(&sp->lock, flags);
1467
1468 dev->trans_start = jiffies;
1469
1470 return 0;
1471}
1472
1473static void speedo_tx_buffer_gc(struct net_device *dev)
1474{
1475 unsigned int dirty_tx;
1476 struct speedo_private *sp = netdev_priv(dev);
1477
1478 dirty_tx = sp->dirty_tx;
1479 while ((int)(sp->cur_tx - dirty_tx) > 0) {
1480 int entry = dirty_tx % TX_RING_SIZE;
1481 int status = le32_to_cpu(sp->tx_ring[entry].status);
1482
1483 if (netif_msg_tx_done(sp))
1484 printk(KERN_DEBUG " scavenge candidate %d status %4.4x.\n",
1485 entry, status);
1486 if ((status & StatusComplete) == 0)
1487 break; /* It still hasn't been processed. */
1488 if (status & TxUnderrun)
1489 if (sp->tx_threshold < 0x01e08000) {
1490 if (netif_msg_tx_err(sp))
1491 printk(KERN_DEBUG "%s: TX underrun, threshold adjusted.\n",
1492 dev->name);
1493 sp->tx_threshold += 0x00040000;
1494 }
1495 /* Free the original skb. */
1496 if (sp->tx_skbuff[entry]) {
1497 sp->stats.tx_packets++; /* Count only user packets. */
1498 sp->stats.tx_bytes += sp->tx_skbuff[entry]->len;
1499 pci_unmap_single(sp->pdev,
1500 le32_to_cpu(sp->tx_ring[entry].tx_buf_addr0),
1501 sp->tx_skbuff[entry]->len, PCI_DMA_TODEVICE);
1502 dev_kfree_skb_irq(sp->tx_skbuff[entry]);
1503 sp->tx_skbuff[entry] = NULL;
1504 }
1505 dirty_tx++;
1506 }
1507
1508 if (netif_msg_tx_err(sp) && (int)(sp->cur_tx - dirty_tx) > TX_RING_SIZE) {
1509 printk(KERN_ERR "out-of-sync dirty pointer, %d vs. %d,"
1510 " full=%d.\n",
1511 dirty_tx, sp->cur_tx, sp->tx_full);
1512 dirty_tx += TX_RING_SIZE;
1513 }
1514
1515 while (sp->mc_setup_head != NULL
1516 && (int)(dirty_tx - sp->mc_setup_head->tx - 1) > 0) {
1517 struct speedo_mc_block *t;
1518 if (netif_msg_tx_err(sp))
1519 printk(KERN_DEBUG "%s: freeing mc frame.\n", dev->name);
1520 pci_unmap_single(sp->pdev, sp->mc_setup_head->frame_dma,
1521 sp->mc_setup_head->len, PCI_DMA_TODEVICE);
1522 t = sp->mc_setup_head->next;
1523 kfree(sp->mc_setup_head);
1524 sp->mc_setup_head = t;
1525 }
1526 if (sp->mc_setup_head == NULL)
1527 sp->mc_setup_tail = NULL;
1528
1529 sp->dirty_tx = dirty_tx;
1530}
1531
1532/* The interrupt handler does all of the Rx thread work and cleans up
1533 after the Tx thread. */
1534static irqreturn_t speedo_interrupt(int irq, void *dev_instance)
1535{
1536 struct net_device *dev = (struct net_device *)dev_instance;
1537 struct speedo_private *sp;
1538 void __iomem *ioaddr;
1539 long boguscnt = max_interrupt_work;
1540 unsigned short status;
1541 unsigned int handled = 0;
1542
1543 sp = netdev_priv(dev);
1544 ioaddr = sp->regs;
1545
1546#ifndef final_version
1547 /* A lock to prevent simultaneous entry on SMP machines. */
1548 if (test_and_set_bit(0, (void*)&sp->in_interrupt)) {
1549 printk(KERN_ERR"%s: SMP simultaneous entry of an interrupt handler.\n",
1550 dev->name);
1551 sp->in_interrupt = 0; /* Avoid halting machine. */
1552 return IRQ_NONE;
1553 }
1554#endif
1555
1556 do {
1557 status = ioread16(ioaddr + SCBStatus);
1558 /* Acknowledge all of the current interrupt sources ASAP. */
1559 /* Will change from 0xfc00 to 0xff00 when we start handling
1560 FCP and ER interrupts --Dragan */
1561 iowrite16(status & 0xfc00, ioaddr + SCBStatus);
1562
1563 if (netif_msg_intr(sp))
1564 printk(KERN_DEBUG "%s: interrupt status=%#4.4x.\n",
1565 dev->name, status);
1566
1567 if ((status & 0xfc00) == 0)
1568 break;
1569 handled = 1;
1570
1571
1572 if ((status & 0x5000) || /* Packet received, or Rx error. */
1573 (sp->rx_ring_state&(RrNoMem|RrPostponed)) == RrPostponed)
1574 /* Need to gather the postponed packet. */
1575 speedo_rx(dev);
1576
1577 /* Always check if all rx buffers are allocated. --SAW */
1578 speedo_refill_rx_buffers(dev, 0);
1579
1580 spin_lock(&sp->lock);
1581 /*
1582 * The chip may have suspended reception for various reasons.
1583 * Check for that, and re-prime it should this be the case.
1584 */
1585 switch ((status >> 2) & 0xf) {
1586 case 0: /* Idle */
1587 break;
1588 case 1: /* Suspended */
1589 case 2: /* No resources (RxFDs) */
1590 case 9: /* Suspended with no more RBDs */
1591 case 10: /* No resources due to no RBDs */
1592 case 12: /* Ready with no RBDs */
1593 speedo_rx_soft_reset(dev);
1594 break;
1595 case 3: case 5: case 6: case 7: case 8:
1596 case 11: case 13: case 14: case 15:
1597 /* these are all reserved values */
1598 break;
1599 }
1600
1601
1602 /* User interrupt, Command/Tx unit interrupt or CU not active. */
1603 if (status & 0xA400) {
1604 speedo_tx_buffer_gc(dev);
1605 if (sp->tx_full
1606 && (int)(sp->cur_tx - sp->dirty_tx) < TX_QUEUE_UNFULL) {
1607 /* The ring is no longer full. */
1608 sp->tx_full = 0;
1609 netif_wake_queue(dev); /* Attention: under a spinlock. --SAW */
1610 }
1611 }
1612
1613 spin_unlock(&sp->lock);
1614
1615 if (--boguscnt < 0) {
1616 printk(KERN_ERR "%s: Too much work at interrupt, status=0x%4.4x.\n",
1617 dev->name, status);
1618 /* Clear all interrupt sources. */
1619 /* Will change from 0xfc00 to 0xff00 when we start handling
1620 FCP and ER interrupts --Dragan */
1621 iowrite16(0xfc00, ioaddr + SCBStatus);
1622 break;
1623 }
1624 } while (1);
1625
1626 if (netif_msg_intr(sp))
1627 printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
1628 dev->name, ioread16(ioaddr + SCBStatus));
1629
1630 clear_bit(0, (void*)&sp->in_interrupt);
1631 return IRQ_RETVAL(handled);
1632}
1633
1634static inline struct RxFD *speedo_rx_alloc(struct net_device *dev, int entry)
1635{
1636 struct speedo_private *sp = netdev_priv(dev);
1637 struct RxFD *rxf;
1638 struct sk_buff *skb;
1639 /* Get a fresh skbuff to replace the consumed one. */
1640 skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD));
1641 if (skb)
1642 rx_align(skb); /* Align IP on 16 byte boundary */
1643 sp->rx_skbuff[entry] = skb;
1644 if (skb == NULL) {
1645 sp->rx_ringp[entry] = NULL;
1646 return NULL;
1647 }
1648 rxf = sp->rx_ringp[entry] = (struct RxFD *)skb->data;
1649 sp->rx_ring_dma[entry] =
1650 pci_map_single(sp->pdev, rxf,
1651 PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
1652 skb->dev = dev;
1653 skb_reserve(skb, sizeof(struct RxFD));
1654 rxf->rx_buf_addr = cpu_to_le32(0xffffffff);
1655 pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[entry],
1656 sizeof(struct RxFD), PCI_DMA_TODEVICE);
1657 return rxf;
1658}
1659
1660static inline void speedo_rx_link(struct net_device *dev, int entry,
1661 struct RxFD *rxf, dma_addr_t rxf_dma)
1662{
1663 struct speedo_private *sp = netdev_priv(dev);
1664 rxf->status = cpu_to_le32(0xC0000001); /* '1' for driver use only. */
1665 rxf->link = 0; /* None yet. */
1666 rxf->count = cpu_to_le32(PKT_BUF_SZ << 16);
1667 sp->last_rxf->link = cpu_to_le32(rxf_dma);
1668 sp->last_rxf->status &= cpu_to_le32(~0xC0000000);
1669 pci_dma_sync_single_for_device(sp->pdev, sp->last_rxf_dma,
1670 sizeof(struct RxFD), PCI_DMA_TODEVICE);
1671 sp->last_rxf = rxf;
1672 sp->last_rxf_dma = rxf_dma;
1673}
1674
1675static int speedo_refill_rx_buf(struct net_device *dev, int force)
1676{
1677 struct speedo_private *sp = netdev_priv(dev);
1678 int entry;
1679 struct RxFD *rxf;
1680
1681 entry = sp->dirty_rx % RX_RING_SIZE;
1682 if (sp->rx_skbuff[entry] == NULL) {
1683 rxf = speedo_rx_alloc(dev, entry);
1684 if (rxf == NULL) {
1685 unsigned int forw;
1686 int forw_entry;
1687 if (netif_msg_rx_err(sp) || !(sp->rx_ring_state & RrOOMReported)) {
1688 printk(KERN_WARNING "%s: can't fill rx buffer (force %d)!\n",
1689 dev->name, force);
1690 sp->rx_ring_state |= RrOOMReported;
1691 }
1692 speedo_show_state(dev);
1693 if (!force)
1694 return -1; /* Better luck next time! */
1695 /* Borrow an skb from one of next entries. */
1696 for (forw = sp->dirty_rx + 1; forw != sp->cur_rx; forw++)
1697 if (sp->rx_skbuff[forw % RX_RING_SIZE] != NULL)
1698 break;
1699 if (forw == sp->cur_rx)
1700 return -1;
1701 forw_entry = forw % RX_RING_SIZE;
1702 sp->rx_skbuff[entry] = sp->rx_skbuff[forw_entry];
1703 sp->rx_skbuff[forw_entry] = NULL;
1704 rxf = sp->rx_ringp[forw_entry];
1705 sp->rx_ringp[forw_entry] = NULL;
1706 sp->rx_ringp[entry] = rxf;
1707 }
1708 } else {
1709 rxf = sp->rx_ringp[entry];
1710 }
1711 speedo_rx_link(dev, entry, rxf, sp->rx_ring_dma[entry]);
1712 sp->dirty_rx++;
1713 sp->rx_ring_state &= ~(RrNoMem|RrOOMReported); /* Mark the progress. */
1714 return 0;
1715}
1716
1717static void speedo_refill_rx_buffers(struct net_device *dev, int force)
1718{
1719 struct speedo_private *sp = netdev_priv(dev);
1720
1721 /* Refill the RX ring. */
1722 while ((int)(sp->cur_rx - sp->dirty_rx) > 0 &&
1723 speedo_refill_rx_buf(dev, force) != -1);
1724}
1725
1726static int
1727speedo_rx(struct net_device *dev)
1728{
1729 struct speedo_private *sp = netdev_priv(dev);
1730 int entry = sp->cur_rx % RX_RING_SIZE;
1731 int rx_work_limit = sp->dirty_rx + RX_RING_SIZE - sp->cur_rx;
1732 int alloc_ok = 1;
1733 int npkts = 0;
1734
1735 if (netif_msg_intr(sp))
1736 printk(KERN_DEBUG " In speedo_rx().\n");
1737 /* If we own the next entry, it's a new packet. Send it up. */
1738 while (sp->rx_ringp[entry] != NULL) {
1739 int status;
1740 int pkt_len;
1741
1742 pci_dma_sync_single_for_cpu(sp->pdev, sp->rx_ring_dma[entry],
1743 sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
1744 status = le32_to_cpu(sp->rx_ringp[entry]->status);
1745 pkt_len = le32_to_cpu(sp->rx_ringp[entry]->count) & 0x3fff;
1746
1747 if (!(status & RxComplete))
1748 break;
1749
1750 if (--rx_work_limit < 0)
1751 break;
1752
1753 /* Check for a rare out-of-memory case: the current buffer is
1754 the last buffer allocated in the RX ring. --SAW */
1755 if (sp->last_rxf == sp->rx_ringp[entry]) {
1756 /* Postpone the packet. It'll be reaped at an interrupt when this
1757 packet is no longer the last packet in the ring. */
1758 if (netif_msg_rx_err(sp))
1759 printk(KERN_DEBUG "%s: RX packet postponed!\n",
1760 dev->name);
1761 sp->rx_ring_state |= RrPostponed;
1762 break;
1763 }
1764
1765 if (netif_msg_rx_status(sp))
1766 printk(KERN_DEBUG " speedo_rx() status %8.8x len %d.\n", status,
1767 pkt_len);
1768 if ((status & (RxErrTooBig|RxOK|0x0f90)) != RxOK) {
1769 if (status & RxErrTooBig)
1770 printk(KERN_ERR "%s: Ethernet frame overran the Rx buffer, "
1771 "status %8.8x!\n", dev->name, status);
1772 else if (! (status & RxOK)) {
1773 /* There was a fatal error. This *should* be impossible. */
1774 sp->stats.rx_errors++;
1775 printk(KERN_ERR "%s: Anomalous event in speedo_rx(), "
1776 "status %8.8x.\n",
1777 dev->name, status);
1778 }
1779 } else {
1780 struct sk_buff *skb;
1781
1782 /* Check if the packet is long enough to just accept without
1783 copying to a properly sized skbuff. */
1784 if (pkt_len < rx_copybreak
1785 && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
1786 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1787 /* 'skb_put()' points to the start of sk_buff data area. */
1788 pci_dma_sync_single_for_cpu(sp->pdev, sp->rx_ring_dma[entry],
1789 sizeof(struct RxFD) + pkt_len,
1790 PCI_DMA_FROMDEVICE);
1791
1792#if 1 || USE_IP_CSUM
1793 /* Packet is in one chunk -- we can copy + cksum. */
1794 skb_copy_to_linear_data(skb, sp->rx_skbuff[entry]->data, pkt_len);
1795 skb_put(skb, pkt_len);
1796#else
1797 skb_copy_from_linear_data(sp->rx_skbuff[entry],
1798 skb_put(skb, pkt_len),
1799 pkt_len);
1800#endif
1801 pci_dma_sync_single_for_device(sp->pdev, sp->rx_ring_dma[entry],
1802 sizeof(struct RxFD) + pkt_len,
1803 PCI_DMA_FROMDEVICE);
1804 npkts++;
1805 } else {
1806 /* Pass up the already-filled skbuff. */
1807 skb = sp->rx_skbuff[entry];
1808 if (skb == NULL) {
1809 printk(KERN_ERR "%s: Inconsistent Rx descriptor chain.\n",
1810 dev->name);
1811 break;
1812 }
1813 sp->rx_skbuff[entry] = NULL;
1814 skb_put(skb, pkt_len);
1815 npkts++;
1816 sp->rx_ringp[entry] = NULL;
1817 pci_unmap_single(sp->pdev, sp->rx_ring_dma[entry],
1818 PKT_BUF_SZ + sizeof(struct RxFD),
1819 PCI_DMA_FROMDEVICE);
1820 }
1821 skb->protocol = eth_type_trans(skb, dev);
1822 netif_rx(skb);
1823 dev->last_rx = jiffies;
1824 sp->stats.rx_packets++;
1825 sp->stats.rx_bytes += pkt_len;
1826 }
1827 entry = (++sp->cur_rx) % RX_RING_SIZE;
1828 sp->rx_ring_state &= ~RrPostponed;
1829 /* Refill the recently taken buffers.
1830 Do it one-by-one to handle traffic bursts better. */
1831 if (alloc_ok && speedo_refill_rx_buf(dev, 0) == -1)
1832 alloc_ok = 0;
1833 }
1834
1835 /* Try hard to refill the recently taken buffers. */
1836 speedo_refill_rx_buffers(dev, 1);
1837
1838 if (npkts)
1839 sp->last_rx_time = jiffies;
1840
1841 return 0;
1842}
1843
1844static int
1845speedo_close(struct net_device *dev)
1846{
1847 struct speedo_private *sp = netdev_priv(dev);
1848 void __iomem *ioaddr = sp->regs;
1849 int i;
1850
1851 netdevice_stop(dev);
1852 netif_stop_queue(dev);
1853
1854 if (netif_msg_ifdown(sp))
1855 printk(KERN_DEBUG "%s: Shutting down ethercard, status was %4.4x.\n",
1856 dev->name, ioread16(ioaddr + SCBStatus));
1857
1858 /* Shut off the media monitoring timer. */
1859 del_timer_sync(&sp->timer);
1860
1861 iowrite16(SCBMaskAll, ioaddr + SCBCmd);
1862
1863 /* Shutting down the chip nicely fails to disable flow control. So.. */
1864 iowrite32(PortPartialReset, ioaddr + SCBPort);
1865 ioread32(ioaddr + SCBPort); /* flush posted write */
1866 /*
1867 * The chip requires a 10 microsecond quiet period. Wait here!
1868 */
1869 udelay(10);
1870
1871 free_irq(dev->irq, dev);
1872 speedo_show_state(dev);
1873
1874 /* Free all the skbuffs in the Rx and Tx queues. */
1875 for (i = 0; i < RX_RING_SIZE; i++) {
1876 struct sk_buff *skb = sp->rx_skbuff[i];
1877 sp->rx_skbuff[i] = NULL;
1878 /* Clear the Rx descriptors. */
1879 if (skb) {
1880 pci_unmap_single(sp->pdev,
1881 sp->rx_ring_dma[i],
1882 PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
1883 dev_kfree_skb(skb);
1884 }
1885 }
1886
1887 for (i = 0; i < TX_RING_SIZE; i++) {
1888 struct sk_buff *skb = sp->tx_skbuff[i];
1889 sp->tx_skbuff[i] = NULL;
1890 /* Clear the Tx descriptors. */
1891 if (skb) {
1892 pci_unmap_single(sp->pdev,
1893 le32_to_cpu(sp->tx_ring[i].tx_buf_addr0),
1894 skb->len, PCI_DMA_TODEVICE);
1895 dev_kfree_skb(skb);
1896 }
1897 }
1898
1899 /* Free multicast setting blocks. */
1900 for (i = 0; sp->mc_setup_head != NULL; i++) {
1901 struct speedo_mc_block *t;
1902 t = sp->mc_setup_head->next;
1903 kfree(sp->mc_setup_head);
1904 sp->mc_setup_head = t;
1905 }
1906 sp->mc_setup_tail = NULL;
1907 if (netif_msg_ifdown(sp))
1908 printk(KERN_DEBUG "%s: %d multicast blocks dropped.\n", dev->name, i);
1909
1910 pci_set_power_state(sp->pdev, PCI_D2);
1911
1912 return 0;
1913}
1914
1915/* The Speedo-3 has an especially awkward and unusable method of getting
1916 statistics out of the chip. It takes an unpredictable length of time
1917 for the dump-stats command to complete. To avoid a busy-wait loop we
1918 update the stats with the previous dump results, and then trigger a
1919 new dump.
1920
1921 Oh, and incoming frames are dropped while executing dump-stats!
1922 */
1923static struct net_device_stats *
1924speedo_get_stats(struct net_device *dev)
1925{
1926 struct speedo_private *sp = netdev_priv(dev);
1927 void __iomem *ioaddr = sp->regs;
1928
1929 /* Update only if the previous dump finished. */
1930 if (sp->lstats->done_marker == cpu_to_le32(0xA007)) {
1931 sp->stats.tx_aborted_errors += le32_to_cpu(sp->lstats->tx_coll16_errs);
1932 sp->stats.tx_window_errors += le32_to_cpu(sp->lstats->tx_late_colls);
1933 sp->stats.tx_fifo_errors += le32_to_cpu(sp->lstats->tx_underruns);
1934 sp->stats.tx_fifo_errors += le32_to_cpu(sp->lstats->tx_lost_carrier);
1935 /*sp->stats.tx_deferred += le32_to_cpu(sp->lstats->tx_deferred);*/
1936 sp->stats.collisions += le32_to_cpu(sp->lstats->tx_total_colls);
1937 sp->stats.rx_crc_errors += le32_to_cpu(sp->lstats->rx_crc_errs);
1938 sp->stats.rx_frame_errors += le32_to_cpu(sp->lstats->rx_align_errs);
1939 sp->stats.rx_over_errors += le32_to_cpu(sp->lstats->rx_resource_errs);
1940 sp->stats.rx_fifo_errors += le32_to_cpu(sp->lstats->rx_overrun_errs);
1941 sp->stats.rx_length_errors += le32_to_cpu(sp->lstats->rx_runt_errs);
1942 sp->lstats->done_marker = 0x0000;
1943 if (netif_running(dev)) {
1944 unsigned long flags;
1945 /* Take a spinlock to make wait_for_cmd_done and sending the
1946 command atomic. --SAW */
1947 spin_lock_irqsave(&sp->lock, flags);
1948 wait_for_cmd_done(dev, sp);
1949 iowrite8(CUDumpStats, ioaddr + SCBCmd);
1950 spin_unlock_irqrestore(&sp->lock, flags);
1951 }
1952 }
1953 return &sp->stats;
1954}
1955
1956static void speedo_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1957{
1958 struct speedo_private *sp = netdev_priv(dev);
1959 strncpy(info->driver, "eepro100", sizeof(info->driver)-1);
1960 strncpy(info->version, version, sizeof(info->version)-1);
1961 if (sp->pdev)
1962 strcpy(info->bus_info, pci_name(sp->pdev));
1963}
1964
1965static int speedo_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1966{
1967 struct speedo_private *sp = netdev_priv(dev);
1968 spin_lock_irq(&sp->lock);
1969 mii_ethtool_gset(&sp->mii_if, ecmd);
1970 spin_unlock_irq(&sp->lock);
1971 return 0;
1972}
1973
1974static int speedo_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1975{
1976 struct speedo_private *sp = netdev_priv(dev);
1977 int res;
1978 spin_lock_irq(&sp->lock);
1979 res = mii_ethtool_sset(&sp->mii_if, ecmd);
1980 spin_unlock_irq(&sp->lock);
1981 return res;
1982}
1983
1984static int speedo_nway_reset(struct net_device *dev)
1985{
1986 struct speedo_private *sp = netdev_priv(dev);
1987 return mii_nway_restart(&sp->mii_if);
1988}
1989
1990static u32 speedo_get_link(struct net_device *dev)
1991{
1992 struct speedo_private *sp = netdev_priv(dev);
1993 return mii_link_ok(&sp->mii_if);
1994}
1995
1996static u32 speedo_get_msglevel(struct net_device *dev)
1997{
1998 struct speedo_private *sp = netdev_priv(dev);
1999 return sp->msg_enable;
2000}
2001
2002static void speedo_set_msglevel(struct net_device *dev, u32 v)
2003{
2004 struct speedo_private *sp = netdev_priv(dev);
2005 sp->msg_enable = v;
2006}
2007
2008static const struct ethtool_ops ethtool_ops = {
2009 .get_drvinfo = speedo_get_drvinfo,
2010 .get_settings = speedo_get_settings,
2011 .set_settings = speedo_set_settings,
2012 .nway_reset = speedo_nway_reset,
2013 .get_link = speedo_get_link,
2014 .get_msglevel = speedo_get_msglevel,
2015 .set_msglevel = speedo_set_msglevel,
2016};
2017
2018static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2019{
2020 struct speedo_private *sp = netdev_priv(dev);
2021 struct mii_ioctl_data *data = if_mii(rq);
2022 int phy = sp->phy[0] & 0x1f;
2023 int saved_acpi;
2024 int t;
2025
2026 switch(cmd) {
2027 case SIOCGMIIPHY: /* Get address of MII PHY in use. */
2028 data->phy_id = phy;
2029
2030 case SIOCGMIIREG: /* Read MII PHY register. */
2031 /* FIXME: these operations need to be serialized with MDIO
2032 access from the timeout handler.
2033 They are currently serialized only with MDIO access from the
2034 timer routine. 2000/05/09 SAW */
2035 saved_acpi = pci_set_power_state(sp->pdev, PCI_D0);
2036 t = del_timer_sync(&sp->timer);
2037 data->val_out = mdio_read(dev, data->phy_id & 0x1f, data->reg_num & 0x1f);
2038 if (t)
2039 add_timer(&sp->timer); /* may be set to the past --SAW */
2040 pci_set_power_state(sp->pdev, saved_acpi);
2041 return 0;
2042
2043 case SIOCSMIIREG: /* Write MII PHY register. */
2044 if (!capable(CAP_NET_ADMIN))
2045 return -EPERM;
2046 saved_acpi = pci_set_power_state(sp->pdev, PCI_D0);
2047 t = del_timer_sync(&sp->timer);
2048 mdio_write(dev, data->phy_id, data->reg_num, data->val_in);
2049 if (t)
2050 add_timer(&sp->timer); /* may be set to the past --SAW */
2051 pci_set_power_state(sp->pdev, saved_acpi);
2052 return 0;
2053 default:
2054 return -EOPNOTSUPP;
2055 }
2056}
2057
2058/* Set or clear the multicast filter for this adaptor.
2059 This is very ugly with Intel chips -- we usually have to execute an
2060 entire configuration command, plus process a multicast command.
2061 This is complicated. We must put a large configuration command and
2062 an arbitrarily-sized multicast command in the transmit list.
2063 To minimize the disruption -- the previous command might have already
2064 loaded the link -- we convert the current command block, normally a Tx
2065 command, into a no-op and link it to the new command.
2066*/
2067static void set_rx_mode(struct net_device *dev)
2068{
2069 struct speedo_private *sp = netdev_priv(dev);
2070 void __iomem *ioaddr = sp->regs;
2071 struct descriptor *last_cmd;
2072 char new_rx_mode;
2073 unsigned long flags;
2074 int entry, i;
2075
2076 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
2077 new_rx_mode = 3;
2078 } else if ((dev->flags & IFF_ALLMULTI) ||
2079 dev->mc_count > multicast_filter_limit) {
2080 new_rx_mode = 1;
2081 } else
2082 new_rx_mode = 0;
2083
2084 if (netif_msg_rx_status(sp))
2085 printk(KERN_DEBUG "%s: set_rx_mode %d -> %d\n", dev->name,
2086 sp->rx_mode, new_rx_mode);
2087
2088 if ((int)(sp->cur_tx - sp->dirty_tx) > TX_RING_SIZE - TX_MULTICAST_SIZE) {
2089 /* The Tx ring is full -- don't add anything! Hope the mode will be
2090 * set again later. */
2091 sp->rx_mode = -1;
2092 return;
2093 }
2094
2095 if (new_rx_mode != sp->rx_mode) {
2096 u8 *config_cmd_data;
2097
2098 spin_lock_irqsave(&sp->lock, flags);
2099 entry = sp->cur_tx++ % TX_RING_SIZE;
2100 last_cmd = sp->last_cmd;
2101 sp->last_cmd = (struct descriptor *)&sp->tx_ring[entry];
2102
2103 sp->tx_skbuff[entry] = NULL; /* Redundant. */
2104 sp->tx_ring[entry].status = cpu_to_le32(CmdSuspend | CmdConfigure);
2105 sp->tx_ring[entry].link =
2106 cpu_to_le32(TX_RING_ELEM_DMA(sp, (entry + 1) % TX_RING_SIZE));
2107 config_cmd_data = (void *)&sp->tx_ring[entry].tx_desc_addr;
2108 /* Construct a full CmdConfig frame. */
2109 memcpy(config_cmd_data, i82558_config_cmd, CONFIG_DATA_SIZE);
2110 config_cmd_data[1] = (txfifo << 4) | rxfifo;
2111 config_cmd_data[4] = rxdmacount;
2112 config_cmd_data[5] = txdmacount + 0x80;
2113 config_cmd_data[15] |= (new_rx_mode & 2) ? 1 : 0;
2114 /* 0x80 doesn't disable FC 0x84 does.
2115 Disable Flow control since we are not ACK-ing any FC interrupts
2116 for now. --Dragan */
2117 config_cmd_data[19] = 0x84;
2118 config_cmd_data[19] |= sp->mii_if.full_duplex ? 0x40 : 0;
2119 config_cmd_data[21] = (new_rx_mode & 1) ? 0x0D : 0x05;
2120 if (sp->phy[0] & 0x8000) { /* Use the AUI port instead. */
2121 config_cmd_data[15] |= 0x80;
2122 config_cmd_data[8] = 0;
2123 }
2124 /* Trigger the command unit resume. */
2125 wait_for_cmd_done(dev, sp);
2126 clear_suspend(last_cmd);
2127 iowrite8(CUResume, ioaddr + SCBCmd);
2128 if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
2129 netif_stop_queue(dev);
2130 sp->tx_full = 1;
2131 }
2132 spin_unlock_irqrestore(&sp->lock, flags);
2133 }
2134
2135 if (new_rx_mode == 0 && dev->mc_count < 4) {
2136 /* The simple case of 0-3 multicast list entries occurs often, and
2137 fits within one tx_ring[] entry. */
2138 struct dev_mc_list *mclist;
2139 __le16 *setup_params, *eaddrs;
2140
2141 spin_lock_irqsave(&sp->lock, flags);
2142 entry = sp->cur_tx++ % TX_RING_SIZE;
2143 last_cmd = sp->last_cmd;
2144 sp->last_cmd = (struct descriptor *)&sp->tx_ring[entry];
2145
2146 sp->tx_skbuff[entry] = NULL;
2147 sp->tx_ring[entry].status = cpu_to_le32(CmdSuspend | CmdMulticastList);
2148 sp->tx_ring[entry].link =
2149 cpu_to_le32(TX_RING_ELEM_DMA(sp, (entry + 1) % TX_RING_SIZE));
2150 sp->tx_ring[entry].tx_desc_addr = 0; /* Really MC list count. */
2151 setup_params = (__le16 *)&sp->tx_ring[entry].tx_desc_addr;
2152 *setup_params++ = cpu_to_le16(dev->mc_count*6);
2153 /* Fill in the multicast addresses. */
2154 for (i = 0, mclist = dev->mc_list; i < dev->mc_count;
2155 i++, mclist = mclist->next) {
2156 eaddrs = (__le16 *)mclist->dmi_addr;
2157 *setup_params++ = *eaddrs++;
2158 *setup_params++ = *eaddrs++;
2159 *setup_params++ = *eaddrs++;
2160 }
2161
2162 wait_for_cmd_done(dev, sp);
2163 clear_suspend(last_cmd);
2164 /* Immediately trigger the command unit resume. */
2165 iowrite8(CUResume, ioaddr + SCBCmd);
2166
2167 if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
2168 netif_stop_queue(dev);
2169 sp->tx_full = 1;
2170 }
2171 spin_unlock_irqrestore(&sp->lock, flags);
2172 } else if (new_rx_mode == 0) {
2173 struct dev_mc_list *mclist;
2174 __le16 *setup_params, *eaddrs;
2175 struct speedo_mc_block *mc_blk;
2176 struct descriptor *mc_setup_frm;
2177 int i;
2178
2179 mc_blk = kmalloc(sizeof(*mc_blk) + 2 + multicast_filter_limit*6,
2180 GFP_ATOMIC);
2181 if (mc_blk == NULL) {
2182 printk(KERN_ERR "%s: Failed to allocate a setup frame.\n",
2183 dev->name);
2184 sp->rx_mode = -1; /* We failed, try again. */
2185 return;
2186 }
2187 mc_blk->next = NULL;
2188 mc_blk->len = 2 + multicast_filter_limit*6;
2189 mc_blk->frame_dma =
2190 pci_map_single(sp->pdev, &mc_blk->frame, mc_blk->len,
2191 PCI_DMA_TODEVICE);
2192 mc_setup_frm = &mc_blk->frame;
2193
2194 /* Fill the setup frame. */
2195 if (netif_msg_ifup(sp))
2196 printk(KERN_DEBUG "%s: Constructing a setup frame at %p.\n",
2197 dev->name, mc_setup_frm);
2198 mc_setup_frm->cmd_status =
2199 cpu_to_le32(CmdSuspend | CmdIntr | CmdMulticastList);
2200 /* Link set below. */
2201 setup_params = (__le16 *)&mc_setup_frm->params;
2202 *setup_params++ = cpu_to_le16(dev->mc_count*6);
2203 /* Fill in the multicast addresses. */
2204 for (i = 0, mclist = dev->mc_list; i < dev->mc_count;
2205 i++, mclist = mclist->next) {
2206 eaddrs = (__le16 *)mclist->dmi_addr;
2207 *setup_params++ = *eaddrs++;
2208 *setup_params++ = *eaddrs++;
2209 *setup_params++ = *eaddrs++;
2210 }
2211
2212 /* Disable interrupts while playing with the Tx Cmd list. */
2213 spin_lock_irqsave(&sp->lock, flags);
2214
2215 if (sp->mc_setup_tail)
2216 sp->mc_setup_tail->next = mc_blk;
2217 else
2218 sp->mc_setup_head = mc_blk;
2219 sp->mc_setup_tail = mc_blk;
2220 mc_blk->tx = sp->cur_tx;
2221
2222 entry = sp->cur_tx++ % TX_RING_SIZE;
2223 last_cmd = sp->last_cmd;
2224 sp->last_cmd = mc_setup_frm;
2225
2226 /* Change the command to a NoOp, pointing to the CmdMulti command. */
2227 sp->tx_skbuff[entry] = NULL;
2228 sp->tx_ring[entry].status = cpu_to_le32(CmdNOp);
2229 sp->tx_ring[entry].link = cpu_to_le32(mc_blk->frame_dma);
2230
2231 /* Set the link in the setup frame. */
2232 mc_setup_frm->link =
2233 cpu_to_le32(TX_RING_ELEM_DMA(sp, (entry + 1) % TX_RING_SIZE));
2234
2235 pci_dma_sync_single_for_device(sp->pdev, mc_blk->frame_dma,
2236 mc_blk->len, PCI_DMA_TODEVICE);
2237
2238 wait_for_cmd_done(dev, sp);
2239 clear_suspend(last_cmd);
2240 /* Immediately trigger the command unit resume. */
2241 iowrite8(CUResume, ioaddr + SCBCmd);
2242
2243 if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
2244 netif_stop_queue(dev);
2245 sp->tx_full = 1;
2246 }
2247 spin_unlock_irqrestore(&sp->lock, flags);
2248
2249 if (netif_msg_rx_status(sp))
2250 printk(" CmdMCSetup frame length %d in entry %d.\n",
2251 dev->mc_count, entry);
2252 }
2253
2254 sp->rx_mode = new_rx_mode;
2255}
2256
2257#ifdef CONFIG_PM
2258static int eepro100_suspend(struct pci_dev *pdev, pm_message_t state)
2259{
2260 struct net_device *dev = pci_get_drvdata (pdev);
2261 struct speedo_private *sp = netdev_priv(dev);
2262 void __iomem *ioaddr = sp->regs;
2263
2264 pci_save_state(pdev);
2265
2266 if (!netif_running(dev))
2267 return 0;
2268
2269 del_timer_sync(&sp->timer);
2270
2271 netif_device_detach(dev);
2272 iowrite32(PortPartialReset, ioaddr + SCBPort);
2273
2274 /* XXX call pci_set_power_state ()? */
2275 pci_disable_device(pdev);
2276 pci_set_power_state (pdev, PCI_D3hot);
2277 return 0;
2278}
2279
2280static int eepro100_resume(struct pci_dev *pdev)
2281{
2282 struct net_device *dev = pci_get_drvdata (pdev);
2283 struct speedo_private *sp = netdev_priv(dev);
2284 void __iomem *ioaddr = sp->regs;
2285 int rc;
2286
2287 pci_set_power_state(pdev, PCI_D0);
2288 pci_restore_state(pdev);
2289
2290 rc = pci_enable_device(pdev);
2291 if (rc)
2292 return rc;
2293
2294 pci_set_master(pdev);
2295
2296 if (!netif_running(dev))
2297 return 0;
2298
2299 /* I'm absolutely uncertain if this part of code may work.
2300 The problems are:
2301 - correct hardware reinitialization;
2302 - correct driver behavior between different steps of the
2303 reinitialization;
2304 - serialization with other driver calls.
2305 2000/03/08 SAW */
2306 iowrite16(SCBMaskAll, ioaddr + SCBCmd);
2307 speedo_resume(dev);
2308 netif_device_attach(dev);
2309 sp->rx_mode = -1;
2310 sp->flow_ctrl = sp->partner = 0;
2311 set_rx_mode(dev);
2312 sp->timer.expires = RUN_AT(2*HZ);
2313 add_timer(&sp->timer);
2314 return 0;
2315}
2316#endif /* CONFIG_PM */
2317
2318static void __devexit eepro100_remove_one (struct pci_dev *pdev)
2319{
2320 struct net_device *dev = pci_get_drvdata (pdev);
2321 struct speedo_private *sp = netdev_priv(dev);
2322
2323 unregister_netdev(dev);
2324
2325 release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1));
2326 release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
2327
2328 pci_iounmap(pdev, sp->regs);
2329 pci_free_consistent(pdev, TX_RING_SIZE * sizeof(struct TxFD)
2330 + sizeof(struct speedo_stats),
2331 sp->tx_ring, sp->tx_ring_dma);
2332 pci_disable_device(pdev);
2333 free_netdev(dev);
2334}
2335
2336static struct pci_device_id eepro100_pci_tbl[] = {
2337 { PCI_VENDOR_ID_INTEL, 0x1229, PCI_ANY_ID, PCI_ANY_ID, },
2338 { PCI_VENDOR_ID_INTEL, 0x1209, PCI_ANY_ID, PCI_ANY_ID, },
2339 { PCI_VENDOR_ID_INTEL, 0x1029, PCI_ANY_ID, PCI_ANY_ID, },
2340 { PCI_VENDOR_ID_INTEL, 0x1030, PCI_ANY_ID, PCI_ANY_ID, },
2341 { PCI_VENDOR_ID_INTEL, 0x1031, PCI_ANY_ID, PCI_ANY_ID, },
2342 { PCI_VENDOR_ID_INTEL, 0x1032, PCI_ANY_ID, PCI_ANY_ID, },
2343 { PCI_VENDOR_ID_INTEL, 0x1033, PCI_ANY_ID, PCI_ANY_ID, },
2344 { PCI_VENDOR_ID_INTEL, 0x1034, PCI_ANY_ID, PCI_ANY_ID, },
2345 { PCI_VENDOR_ID_INTEL, 0x1035, PCI_ANY_ID, PCI_ANY_ID, },
2346 { PCI_VENDOR_ID_INTEL, 0x1036, PCI_ANY_ID, PCI_ANY_ID, },
2347 { PCI_VENDOR_ID_INTEL, 0x1037, PCI_ANY_ID, PCI_ANY_ID, },
2348 { PCI_VENDOR_ID_INTEL, 0x1038, PCI_ANY_ID, PCI_ANY_ID, },
2349 { PCI_VENDOR_ID_INTEL, 0x1039, PCI_ANY_ID, PCI_ANY_ID, },
2350 { PCI_VENDOR_ID_INTEL, 0x103A, PCI_ANY_ID, PCI_ANY_ID, },
2351 { PCI_VENDOR_ID_INTEL, 0x103B, PCI_ANY_ID, PCI_ANY_ID, },
2352 { PCI_VENDOR_ID_INTEL, 0x103C, PCI_ANY_ID, PCI_ANY_ID, },
2353 { PCI_VENDOR_ID_INTEL, 0x103D, PCI_ANY_ID, PCI_ANY_ID, },
2354 { PCI_VENDOR_ID_INTEL, 0x103E, PCI_ANY_ID, PCI_ANY_ID, },
2355 { PCI_VENDOR_ID_INTEL, 0x1050, PCI_ANY_ID, PCI_ANY_ID, },
2356 { PCI_VENDOR_ID_INTEL, 0x1059, PCI_ANY_ID, PCI_ANY_ID, },
2357 { PCI_VENDOR_ID_INTEL, 0x1227, PCI_ANY_ID, PCI_ANY_ID, },
2358 { PCI_VENDOR_ID_INTEL, 0x2449, PCI_ANY_ID, PCI_ANY_ID, },
2359 { PCI_VENDOR_ID_INTEL, 0x2459, PCI_ANY_ID, PCI_ANY_ID, },
2360 { PCI_VENDOR_ID_INTEL, 0x245D, PCI_ANY_ID, PCI_ANY_ID, },
2361 { PCI_VENDOR_ID_INTEL, 0x5200, PCI_ANY_ID, PCI_ANY_ID, },
2362 { PCI_VENDOR_ID_INTEL, 0x5201, PCI_ANY_ID, PCI_ANY_ID, },
2363 { 0,}
2364};
2365MODULE_DEVICE_TABLE(pci, eepro100_pci_tbl);
2366
2367static struct pci_driver eepro100_driver = {
2368 .name = "eepro100",
2369 .id_table = eepro100_pci_tbl,
2370 .probe = eepro100_init_one,
2371 .remove = __devexit_p(eepro100_remove_one),
2372#ifdef CONFIG_PM
2373 .suspend = eepro100_suspend,
2374 .resume = eepro100_resume,
2375#endif /* CONFIG_PM */
2376};
2377
2378static int __init eepro100_init_module(void)
2379{
2380#ifdef MODULE
2381 printk(version);
2382#endif
2383 return pci_register_driver(&eepro100_driver);
2384}
2385
2386static void __exit eepro100_cleanup_module(void)
2387{
2388 pci_unregister_driver(&eepro100_driver);
2389}
2390
2391module_init(eepro100_init_module);
2392module_exit(eepro100_cleanup_module);
2393
2394/*
2395 * Local variables:
2396 * compile-command: "gcc -DMODULE -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -c eepro100.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`"
2397 * c-indent-level: 4
2398 * c-basic-offset: 4
2399 * tab-width: 4
2400 * End:
2401 */
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index b751c1b96cfa..a125e41240f5 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -967,7 +967,6 @@ static void eexp_hw_rx_pio(struct net_device *dev)
967 insw(ioaddr+DATAPORT, skb_put(skb,pkt_len),(pkt_len+1)>>1); 967 insw(ioaddr+DATAPORT, skb_put(skb,pkt_len),(pkt_len+1)>>1);
968 skb->protocol = eth_type_trans(skb,dev); 968 skb->protocol = eth_type_trans(skb,dev);
969 netif_rx(skb); 969 netif_rx(skb);
970 dev->last_rx = jiffies;
971 dev->stats.rx_packets++; 970 dev->stats.rx_packets++;
972 dev->stats.rx_bytes += pkt_len; 971 dev->stats.rx_bytes += pkt_len;
973 } 972 }
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 002d918fb4c7..9930d5f8b9e1 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0095" 43#define DRV_VERSION "EHEA_0096"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 422fcb93e2c3..44c9ae18383f 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -728,7 +728,6 @@ static int ehea_proc_rwqes(struct net_device *dev,
728 } 728 }
729 729
730 ehea_proc_skb(pr, cqe, skb); 730 ehea_proc_skb(pr, cqe, skb);
731 dev->last_rx = jiffies;
732 } else { 731 } else {
733 pr->p_stats.poll_receive_errors++; 732 pr->p_stats.poll_receive_errors++;
734 port_reset = ehea_treat_poll_error(pr, rq, cqe, 733 port_reset = ehea_treat_poll_error(pr, rq, cqe,
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index 9d006878f045..3c0ec82f36fb 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -653,7 +653,7 @@ static int ehea_update_busmap(unsigned long pfn, unsigned long nr_pages, int add
653 int top = ehea_calc_index(i, EHEA_TOP_INDEX_SHIFT); 653 int top = ehea_calc_index(i, EHEA_TOP_INDEX_SHIFT);
654 int dir = ehea_calc_index(i, EHEA_DIR_INDEX_SHIFT); 654 int dir = ehea_calc_index(i, EHEA_DIR_INDEX_SHIFT);
655 int idx = i & EHEA_INDEX_MASK; 655 int idx = i & EHEA_INDEX_MASK;
656 656
657 if (add) { 657 if (add) {
658 int ret = ehea_init_bmap(ehea_bmap, top, dir); 658 int ret = ehea_init_bmap(ehea_bmap, top, dir);
659 if (ret) 659 if (ret)
@@ -780,7 +780,7 @@ void ehea_destroy_busmap(void)
780 780
781 kfree(ehea_bmap); 781 kfree(ehea_bmap);
782 ehea_bmap = NULL; 782 ehea_bmap = NULL;
783out_destroy: 783out_destroy:
784 mutex_unlock(&ehea_busmap_mutex); 784 mutex_unlock(&ehea_busmap_mutex);
785} 785}
786 786
@@ -858,10 +858,10 @@ static u64 ehea_reg_mr_sections(int top, int dir, u64 *pt,
858 for (idx = 0; idx < EHEA_MAP_ENTRIES; idx++) { 858 for (idx = 0; idx < EHEA_MAP_ENTRIES; idx++) {
859 if (!ehea_bmap->top[top]->dir[dir]->ent[idx]) 859 if (!ehea_bmap->top[top]->dir[dir]->ent[idx])
860 continue; 860 continue;
861 861
862 hret = ehea_reg_mr_section(top, dir, idx, pt, adapter, mr); 862 hret = ehea_reg_mr_section(top, dir, idx, pt, adapter, mr);
863 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED)) 863 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED))
864 return hret; 864 return hret;
865 } 865 }
866 return hret; 866 return hret;
867} 867}
@@ -879,7 +879,7 @@ static u64 ehea_reg_mr_dir_sections(int top, u64 *pt,
879 879
880 hret = ehea_reg_mr_sections(top, dir, pt, adapter, mr); 880 hret = ehea_reg_mr_sections(top, dir, pt, adapter, mr);
881 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED)) 881 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED))
882 return hret; 882 return hret;
883 } 883 }
884 return hret; 884 return hret;
885} 885}
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index e1b441effbbe..32c19790d013 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -477,12 +477,10 @@ static int enc28j60_set_hw_macaddr(struct net_device *ndev)
477 477
478 mutex_lock(&priv->lock); 478 mutex_lock(&priv->lock);
479 if (!priv->hw_enable) { 479 if (!priv->hw_enable) {
480 if (netif_msg_drv(priv)) { 480 if (netif_msg_drv(priv))
481 DECLARE_MAC_BUF(mac);
482 printk(KERN_INFO DRV_NAME 481 printk(KERN_INFO DRV_NAME
483 ": %s: Setting MAC address to %s\n", 482 ": %s: Setting MAC address to %pM\n",
484 ndev->name, print_mac(mac, ndev->dev_addr)); 483 ndev->name, ndev->dev_addr);
485 }
486 /* NOTE: MAC address in ENC28J60 is byte-backward */ 484 /* NOTE: MAC address in ENC28J60 is byte-backward */
487 nolock_regb_write(priv, MAADR5, ndev->dev_addr[0]); 485 nolock_regb_write(priv, MAADR5, ndev->dev_addr[0]);
488 nolock_regb_write(priv, MAADR4, ndev->dev_addr[1]); 486 nolock_regb_write(priv, MAADR4, ndev->dev_addr[1]);
@@ -946,7 +944,6 @@ static void enc28j60_hw_rx(struct net_device *ndev)
946 /* update statistics */ 944 /* update statistics */
947 ndev->stats.rx_packets++; 945 ndev->stats.rx_packets++;
948 ndev->stats.rx_bytes += len; 946 ndev->stats.rx_bytes += len;
949 ndev->last_rx = jiffies;
950 netif_rx(skb); 947 netif_rx(skb);
951 } 948 }
952 } 949 }
@@ -1328,11 +1325,9 @@ static int enc28j60_net_open(struct net_device *dev)
1328 printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); 1325 printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__);
1329 1326
1330 if (!is_valid_ether_addr(dev->dev_addr)) { 1327 if (!is_valid_ether_addr(dev->dev_addr)) {
1331 if (netif_msg_ifup(priv)) { 1328 if (netif_msg_ifup(priv))
1332 DECLARE_MAC_BUF(mac); 1329 dev_err(&dev->dev, "invalid MAC address %pM\n",
1333 dev_err(&dev->dev, "invalid MAC address %s\n", 1330 dev->dev_addr);
1334 print_mac(mac, dev->dev_addr));
1335 }
1336 return -EADDRNOTAVAIL; 1331 return -EADDRNOTAVAIL;
1337 } 1332 }
1338 /* Reset the hardware here (and take it out of low power mode) */ 1333 /* Reset the hardware here (and take it out of low power mode) */
@@ -1453,7 +1448,7 @@ enc28j60_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1453 strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); 1448 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
1454 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 1449 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
1455 strlcpy(info->bus_info, 1450 strlcpy(info->bus_info,
1456 dev->dev.parent->bus_id, sizeof(info->bus_info)); 1451 dev_name(dev->dev.parent), sizeof(info->bus_info));
1457} 1452}
1458 1453
1459static int 1454static int
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index 180e968dc54d..8594d7f8fe66 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -951,7 +951,6 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
951 } 951 }
952 952
953 skb->dev = enic->netdev; 953 skb->dev = enic->netdev;
954 enic->netdev->last_rx = jiffies;
955 954
956 if (enic->vlan_group && vlan_stripped) { 955 if (enic->vlan_group && vlan_stripped) {
957 956
diff --git a/drivers/net/enic/enic_res.c b/drivers/net/enic/enic_res.c
index 95184b9108ef..e5fc9384f8f5 100644
--- a/drivers/net/enic/enic_res.c
+++ b/drivers/net/enic/enic_res.c
@@ -90,11 +90,8 @@ int enic_get_vnic_config(struct enic *enic)
90 90
91 c->intr_timer = min_t(u16, VNIC_INTR_TIMER_MAX, c->intr_timer); 91 c->intr_timer = min_t(u16, VNIC_INTR_TIMER_MAX, c->intr_timer);
92 92
93 printk(KERN_INFO PFX "vNIC MAC addr %02x:%02x:%02x:%02x:%02x:%02x " 93 printk(KERN_INFO PFX "vNIC MAC addr %pM wq/rq %d/%d\n",
94 "wq/rq %d/%d\n", 94 enic->mac_addr, c->wq_desc_count, c->rq_desc_count);
95 enic->mac_addr[0], enic->mac_addr[1], enic->mac_addr[2],
96 enic->mac_addr[3], enic->mac_addr[4], enic->mac_addr[5],
97 c->wq_desc_count, c->rq_desc_count);
98 printk(KERN_INFO PFX "vNIC mtu %d csum tx/rx %d/%d tso/lro %d/%d " 95 printk(KERN_INFO PFX "vNIC mtu %d csum tx/rx %d/%d tso/lro %d/%d "
99 "intr timer %d\n", 96 "intr timer %d\n",
100 c->mtu, ENIC_SETTING(enic, TXCSUM), 97 c->mtu, ENIC_SETTING(enic, TXCSUM),
diff --git a/drivers/net/enic/vnic_dev.c b/drivers/net/enic/vnic_dev.c
index 4d104f5c30f9..9afd33c7188d 100644
--- a/drivers/net/enic/vnic_dev.c
+++ b/drivers/net/enic/vnic_dev.c
@@ -489,10 +489,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
489 489
490 err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait); 490 err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait);
491 if (err) 491 if (err)
492 printk(KERN_ERR 492 printk(KERN_ERR "Can't add addr [%pM], %d\n", addr, err);
493 "Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
494 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
495 err);
496} 493}
497 494
498void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr) 495void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
@@ -507,10 +504,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
507 504
508 err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a0, &a1, wait); 505 err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a0, &a1, wait);
509 if (err) 506 if (err)
510 printk(KERN_ERR 507 printk(KERN_ERR "Can't del addr [%pM], %d\n", addr, err);
511 "Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
512 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
513 err);
514} 508}
515 509
516int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr) 510int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 76118ddd1042..4a951b8cb4d7 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -322,7 +322,6 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
322 int i, ret, option = 0, duplex = 0; 322 int i, ret, option = 0, duplex = 0;
323 void *ring_space; 323 void *ring_space;
324 dma_addr_t ring_dma; 324 dma_addr_t ring_dma;
325 DECLARE_MAC_BUF(mac);
326 325
327/* when built into the kernel, we only print version if device is found */ 326/* when built into the kernel, we only print version if device is found */
328#ifndef MODULE 327#ifndef MODULE
@@ -364,7 +363,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
364 ioaddr = pci_resource_start (pdev, 0); 363 ioaddr = pci_resource_start (pdev, 0);
365#else 364#else
366 ioaddr = pci_resource_start (pdev, 1); 365 ioaddr = pci_resource_start (pdev, 1);
367 ioaddr = (long) ioremap (ioaddr, pci_resource_len (pdev, 1)); 366 ioaddr = (long) pci_ioremap_bar(pdev, 1);
368 if (!ioaddr) { 367 if (!ioaddr) {
369 dev_err(&pdev->dev, "ioremap failed\n"); 368 dev_err(&pdev->dev, "ioremap failed\n");
370 goto err_out_free_netdev; 369 goto err_out_free_netdev;
@@ -372,7 +371,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
372#endif 371#endif
373 372
374 pci_set_drvdata(pdev, dev); 373 pci_set_drvdata(pdev, dev);
375 ep = dev->priv; 374 ep = netdev_priv(dev);
376 ep->mii.dev = dev; 375 ep->mii.dev = dev;
377 ep->mii.mdio_read = mdio_read; 376 ep->mii.mdio_read = mdio_read;
378 ep->mii.mdio_write = mdio_write; 377 ep->mii.mdio_write = mdio_write;
@@ -499,9 +498,9 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
499 if (ret < 0) 498 if (ret < 0)
500 goto err_out_unmap_rx; 499 goto err_out_unmap_rx;
501 500
502 printk(KERN_INFO "%s: %s at %#lx, IRQ %d, %s\n", 501 printk(KERN_INFO "%s: %s at %#lx, IRQ %d, %pM\n",
503 dev->name, pci_id_tbl[chip_idx].name, ioaddr, dev->irq, 502 dev->name, pci_id_tbl[chip_idx].name, ioaddr, dev->irq,
504 print_mac(mac, dev->dev_addr)); 503 dev->dev_addr);
505 504
506out: 505out:
507 return ret; 506 return ret;
@@ -655,7 +654,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int value)
655 654
656static int epic_open(struct net_device *dev) 655static int epic_open(struct net_device *dev)
657{ 656{
658 struct epic_private *ep = dev->priv; 657 struct epic_private *ep = netdev_priv(dev);
659 long ioaddr = dev->base_addr; 658 long ioaddr = dev->base_addr;
660 int i; 659 int i;
661 int retval; 660 int retval;
@@ -767,7 +766,7 @@ static int epic_open(struct net_device *dev)
767static void epic_pause(struct net_device *dev) 766static void epic_pause(struct net_device *dev)
768{ 767{
769 long ioaddr = dev->base_addr; 768 long ioaddr = dev->base_addr;
770 struct epic_private *ep = dev->priv; 769 struct epic_private *ep = netdev_priv(dev);
771 770
772 netif_stop_queue (dev); 771 netif_stop_queue (dev);
773 772
@@ -790,7 +789,7 @@ static void epic_pause(struct net_device *dev)
790static void epic_restart(struct net_device *dev) 789static void epic_restart(struct net_device *dev)
791{ 790{
792 long ioaddr = dev->base_addr; 791 long ioaddr = dev->base_addr;
793 struct epic_private *ep = dev->priv; 792 struct epic_private *ep = netdev_priv(dev);
794 int i; 793 int i;
795 794
796 /* Soft reset the chip. */ 795 /* Soft reset the chip. */
@@ -842,7 +841,7 @@ static void epic_restart(struct net_device *dev)
842 841
843static void check_media(struct net_device *dev) 842static void check_media(struct net_device *dev)
844{ 843{
845 struct epic_private *ep = dev->priv; 844 struct epic_private *ep = netdev_priv(dev);
846 long ioaddr = dev->base_addr; 845 long ioaddr = dev->base_addr;
847 int mii_lpa = ep->mii_phy_cnt ? mdio_read(dev, ep->phys[0], MII_LPA) : 0; 846 int mii_lpa = ep->mii_phy_cnt ? mdio_read(dev, ep->phys[0], MII_LPA) : 0;
848 int negotiated = mii_lpa & ep->mii.advertising; 847 int negotiated = mii_lpa & ep->mii.advertising;
@@ -864,7 +863,7 @@ static void check_media(struct net_device *dev)
864static void epic_timer(unsigned long data) 863static void epic_timer(unsigned long data)
865{ 864{
866 struct net_device *dev = (struct net_device *)data; 865 struct net_device *dev = (struct net_device *)data;
867 struct epic_private *ep = dev->priv; 866 struct epic_private *ep = netdev_priv(dev);
868 long ioaddr = dev->base_addr; 867 long ioaddr = dev->base_addr;
869 int next_tick = 5*HZ; 868 int next_tick = 5*HZ;
870 869
@@ -885,7 +884,7 @@ static void epic_timer(unsigned long data)
885 884
886static void epic_tx_timeout(struct net_device *dev) 885static void epic_tx_timeout(struct net_device *dev)
887{ 886{
888 struct epic_private *ep = dev->priv; 887 struct epic_private *ep = netdev_priv(dev);
889 long ioaddr = dev->base_addr; 888 long ioaddr = dev->base_addr;
890 889
891 if (debug > 0) { 890 if (debug > 0) {
@@ -914,7 +913,7 @@ static void epic_tx_timeout(struct net_device *dev)
914/* Initialize the Rx and Tx rings, along with various 'dev' bits. */ 913/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
915static void epic_init_ring(struct net_device *dev) 914static void epic_init_ring(struct net_device *dev)
916{ 915{
917 struct epic_private *ep = dev->priv; 916 struct epic_private *ep = netdev_priv(dev);
918 int i; 917 int i;
919 918
920 ep->tx_full = 0; 919 ep->tx_full = 0;
@@ -960,7 +959,7 @@ static void epic_init_ring(struct net_device *dev)
960 959
961static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev) 960static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev)
962{ 961{
963 struct epic_private *ep = dev->priv; 962 struct epic_private *ep = netdev_priv(dev);
964 int entry, free_count; 963 int entry, free_count;
965 u32 ctrl_word; 964 u32 ctrl_word;
966 unsigned long flags; 965 unsigned long flags;
@@ -1088,7 +1087,7 @@ static void epic_tx(struct net_device *dev, struct epic_private *ep)
1088static irqreturn_t epic_interrupt(int irq, void *dev_instance) 1087static irqreturn_t epic_interrupt(int irq, void *dev_instance)
1089{ 1088{
1090 struct net_device *dev = dev_instance; 1089 struct net_device *dev = dev_instance;
1091 struct epic_private *ep = dev->priv; 1090 struct epic_private *ep = netdev_priv(dev);
1092 long ioaddr = dev->base_addr; 1091 long ioaddr = dev->base_addr;
1093 unsigned int handled = 0; 1092 unsigned int handled = 0;
1094 int status; 1093 int status;
@@ -1156,7 +1155,7 @@ out:
1156 1155
1157static int epic_rx(struct net_device *dev, int budget) 1156static int epic_rx(struct net_device *dev, int budget)
1158{ 1157{
1159 struct epic_private *ep = dev->priv; 1158 struct epic_private *ep = netdev_priv(dev);
1160 int entry = ep->cur_rx % RX_RING_SIZE; 1159 int entry = ep->cur_rx % RX_RING_SIZE;
1161 int rx_work_limit = ep->dirty_rx + RX_RING_SIZE - ep->cur_rx; 1160 int rx_work_limit = ep->dirty_rx + RX_RING_SIZE - ep->cur_rx;
1162 int work_done = 0; 1161 int work_done = 0;
@@ -1223,7 +1222,6 @@ static int epic_rx(struct net_device *dev, int budget)
1223 } 1222 }
1224 skb->protocol = eth_type_trans(skb, dev); 1223 skb->protocol = eth_type_trans(skb, dev);
1225 netif_receive_skb(skb); 1224 netif_receive_skb(skb);
1226 dev->last_rx = jiffies;
1227 ep->stats.rx_packets++; 1225 ep->stats.rx_packets++;
1228 ep->stats.rx_bytes += pkt_len; 1226 ep->stats.rx_bytes += pkt_len;
1229 } 1227 }
@@ -1308,7 +1306,7 @@ rx_action:
1308static int epic_close(struct net_device *dev) 1306static int epic_close(struct net_device *dev)
1309{ 1307{
1310 long ioaddr = dev->base_addr; 1308 long ioaddr = dev->base_addr;
1311 struct epic_private *ep = dev->priv; 1309 struct epic_private *ep = netdev_priv(dev);
1312 struct sk_buff *skb; 1310 struct sk_buff *skb;
1313 int i; 1311 int i;
1314 1312
@@ -1358,7 +1356,7 @@ static int epic_close(struct net_device *dev)
1358 1356
1359static struct net_device_stats *epic_get_stats(struct net_device *dev) 1357static struct net_device_stats *epic_get_stats(struct net_device *dev)
1360{ 1358{
1361 struct epic_private *ep = dev->priv; 1359 struct epic_private *ep = netdev_priv(dev);
1362 long ioaddr = dev->base_addr; 1360 long ioaddr = dev->base_addr;
1363 1361
1364 if (netif_running(dev)) { 1362 if (netif_running(dev)) {
@@ -1379,7 +1377,7 @@ static struct net_device_stats *epic_get_stats(struct net_device *dev)
1379static void set_rx_mode(struct net_device *dev) 1377static void set_rx_mode(struct net_device *dev)
1380{ 1378{
1381 long ioaddr = dev->base_addr; 1379 long ioaddr = dev->base_addr;
1382 struct epic_private *ep = dev->priv; 1380 struct epic_private *ep = netdev_priv(dev);
1383 unsigned char mc_filter[8]; /* Multicast hash filter */ 1381 unsigned char mc_filter[8]; /* Multicast hash filter */
1384 int i; 1382 int i;
1385 1383
@@ -1418,7 +1416,7 @@ static void set_rx_mode(struct net_device *dev)
1418 1416
1419static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info) 1417static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
1420{ 1418{
1421 struct epic_private *np = dev->priv; 1419 struct epic_private *np = netdev_priv(dev);
1422 1420
1423 strcpy (info->driver, DRV_NAME); 1421 strcpy (info->driver, DRV_NAME);
1424 strcpy (info->version, DRV_VERSION); 1422 strcpy (info->version, DRV_VERSION);
@@ -1427,7 +1425,7 @@ static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *
1427 1425
1428static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1426static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1429{ 1427{
1430 struct epic_private *np = dev->priv; 1428 struct epic_private *np = netdev_priv(dev);
1431 int rc; 1429 int rc;
1432 1430
1433 spin_lock_irq(&np->lock); 1431 spin_lock_irq(&np->lock);
@@ -1439,7 +1437,7 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1439 1437
1440static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1438static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1441{ 1439{
1442 struct epic_private *np = dev->priv; 1440 struct epic_private *np = netdev_priv(dev);
1443 int rc; 1441 int rc;
1444 1442
1445 spin_lock_irq(&np->lock); 1443 spin_lock_irq(&np->lock);
@@ -1451,13 +1449,13 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1451 1449
1452static int netdev_nway_reset(struct net_device *dev) 1450static int netdev_nway_reset(struct net_device *dev)
1453{ 1451{
1454 struct epic_private *np = dev->priv; 1452 struct epic_private *np = netdev_priv(dev);
1455 return mii_nway_restart(&np->mii); 1453 return mii_nway_restart(&np->mii);
1456} 1454}
1457 1455
1458static u32 netdev_get_link(struct net_device *dev) 1456static u32 netdev_get_link(struct net_device *dev)
1459{ 1457{
1460 struct epic_private *np = dev->priv; 1458 struct epic_private *np = netdev_priv(dev);
1461 return mii_link_ok(&np->mii); 1459 return mii_link_ok(&np->mii);
1462} 1460}
1463 1461
@@ -1506,7 +1504,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
1506 1504
1507static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1505static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1508{ 1506{
1509 struct epic_private *np = dev->priv; 1507 struct epic_private *np = netdev_priv(dev);
1510 long ioaddr = dev->base_addr; 1508 long ioaddr = dev->base_addr;
1511 struct mii_ioctl_data *data = if_mii(rq); 1509 struct mii_ioctl_data *data = if_mii(rq);
1512 int rc; 1510 int rc;
@@ -1534,7 +1532,7 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1534static void __devexit epic_remove_one (struct pci_dev *pdev) 1532static void __devexit epic_remove_one (struct pci_dev *pdev)
1535{ 1533{
1536 struct net_device *dev = pci_get_drvdata(pdev); 1534 struct net_device *dev = pci_get_drvdata(pdev);
1537 struct epic_private *ep = dev->priv; 1535 struct epic_private *ep = netdev_priv(dev);
1538 1536
1539 pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma); 1537 pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma);
1540 pci_free_consistent(pdev, RX_TOTAL_SIZE, ep->rx_ring, ep->rx_ring_dma); 1538 pci_free_consistent(pdev, RX_TOTAL_SIZE, ep->rx_ring, ep->rx_ring_dma);
diff --git a/drivers/net/es3210.c b/drivers/net/es3210.c
index deefa51b8c31..e7df9f4a183d 100644
--- a/drivers/net/es3210.c
+++ b/drivers/net/es3210.c
@@ -179,7 +179,6 @@ static int __init es_probe1(struct net_device *dev, int ioaddr)
179{ 179{
180 int i, retval; 180 int i, retval;
181 unsigned long eisa_id; 181 unsigned long eisa_id;
182 DECLARE_MAC_BUF(mac);
183 182
184 if (!request_region(ioaddr + ES_SA_PROM, ES_IO_EXTENT, "es3210")) 183 if (!request_region(ioaddr + ES_SA_PROM, ES_IO_EXTENT, "es3210"))
185 return -ENODEV; 184 return -ENODEV;
@@ -205,14 +204,14 @@ static int __init es_probe1(struct net_device *dev, int ioaddr)
205 if (dev->dev_addr[0] != ES_ADDR0 || 204 if (dev->dev_addr[0] != ES_ADDR0 ||
206 dev->dev_addr[1] != ES_ADDR1 || 205 dev->dev_addr[1] != ES_ADDR1 ||
207 dev->dev_addr[2] != ES_ADDR2) { 206 dev->dev_addr[2] != ES_ADDR2) {
208 printk("es3210.c: card not found %s (invalid_prefix).\n", 207 printk("es3210.c: card not found %pM (invalid_prefix).\n",
209 print_mac(mac, dev->dev_addr)); 208 dev->dev_addr);
210 retval = -ENODEV; 209 retval = -ENODEV;
211 goto out; 210 goto out;
212 } 211 }
213 212
214 printk("es3210.c: ES3210 rev. %ld at %#x, node %s", 213 printk("es3210.c: ES3210 rev. %ld at %#x, node %pM",
215 eisa_id>>24, ioaddr, print_mac(mac, dev->dev_addr)); 214 eisa_id>>24, ioaddr, dev->dev_addr);
216 215
217 /* Snarf the interrupt now. */ 216 /* Snarf the interrupt now. */
218 if (dev->irq == 0) { 217 if (dev->irq == 0) {
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index bee8b3fbc565..8d9fe4dd346f 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -1205,7 +1205,6 @@ static void eth16i_rx(struct net_device *dev)
1205 printk(KERN_DEBUG ".\n"); 1205 printk(KERN_DEBUG ".\n");
1206 } 1206 }
1207 netif_rx(skb); 1207 netif_rx(skb);
1208 dev->last_rx = jiffies;
1209 dev->stats.rx_packets++; 1208 dev->stats.rx_packets++;
1210 dev->stats.rx_bytes += pkt_len; 1209 dev->stats.rx_bytes += pkt_len;
1211 1210
@@ -1466,7 +1465,7 @@ void __exit cleanup_module(void)
1466 for(this_dev = 0; this_dev < MAX_ETH16I_CARDS; this_dev++) { 1465 for(this_dev = 0; this_dev < MAX_ETH16I_CARDS; this_dev++) {
1467 struct net_device *dev = dev_eth16i[this_dev]; 1466 struct net_device *dev = dev_eth16i[this_dev];
1468 1467
1469 if(dev->priv) { 1468 if (netdev_priv(dev)) {
1470 unregister_netdev(dev); 1469 unregister_netdev(dev);
1471 free_irq(dev->irq, dev); 1470 free_irq(dev->irq, dev);
1472 release_region(dev->base_addr, ETH16I_IO_EXTENT); 1471 release_region(dev->base_addr, ETH16I_IO_EXTENT);
diff --git a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c
index 593a120e31b2..f3b664aafb82 100644
--- a/drivers/net/ewrk3.c
+++ b/drivers/net/ewrk3.c
@@ -396,7 +396,6 @@ ewrk3_hw_init(struct net_device *dev, u_long iobase)
396 u_long mem_start, shmem_length; 396 u_long mem_start, shmem_length;
397 u_char cr, cmr, icr, nicsr, lemac, hard_strapped = 0; 397 u_char cr, cmr, icr, nicsr, lemac, hard_strapped = 0;
398 u_char eeprom_image[EEPROM_MAX], chksum, eisa_cr = 0; 398 u_char eeprom_image[EEPROM_MAX], chksum, eisa_cr = 0;
399 DECLARE_MAC_BUF(mac);
400 399
401 /* 400 /*
402 ** Stop the EWRK3. Enable the DBR ROM. Disable interrupts and remote boot. 401 ** Stop the EWRK3. Enable the DBR ROM. Disable interrupts and remote boot.
@@ -461,7 +460,7 @@ ewrk3_hw_init(struct net_device *dev, u_long iobase)
461 if (lemac != LeMAC2) 460 if (lemac != LeMAC2)
462 DevicePresent(iobase); /* need after EWRK3_INIT */ 461 DevicePresent(iobase); /* need after EWRK3_INIT */
463 status = get_hw_addr(dev, eeprom_image, lemac); 462 status = get_hw_addr(dev, eeprom_image, lemac);
464 printk("%s\n", print_mac(mac, dev->dev_addr)); 463 printk("%pM\n", dev->dev_addr);
465 464
466 if (status) { 465 if (status) {
467 printk(" which has an EEPROM CRC error.\n"); 466 printk(" which has an EEPROM CRC error.\n");
@@ -646,10 +645,8 @@ static int ewrk3_open(struct net_device *dev)
646 ewrk3_init(dev); 645 ewrk3_init(dev);
647 646
648 if (ewrk3_debug > 1) { 647 if (ewrk3_debug > 1) {
649 DECLARE_MAC_BUF(mac);
650 printk("%s: ewrk3 open with irq %d\n", dev->name, dev->irq); 648 printk("%s: ewrk3 open with irq %d\n", dev->name, dev->irq);
651 printk(" physical address: %s\n", 649 printk(" physical address: %pM\n", dev->dev_addr);
652 print_mac(mac, dev->dev_addr));
653 if (lp->shmem_length == 0) { 650 if (lp->shmem_length == 0) {
654 printk(" no shared memory, I/O only mode\n"); 651 printk(" no shared memory, I/O only mode\n");
655 } else { 652 } else {
@@ -1029,7 +1026,6 @@ static int ewrk3_rx(struct net_device *dev)
1029 /* 1026 /*
1030 ** Update stats 1027 ** Update stats
1031 */ 1028 */
1032 dev->last_rx = jiffies;
1033 dev->stats.rx_packets++; 1029 dev->stats.rx_packets++;
1034 dev->stats.rx_bytes += pkt_len; 1030 dev->stats.rx_bytes += pkt_len;
1035 } else { 1031 } else {
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index b455ae931f7a..31ab1ff623fc 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -486,7 +486,6 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
486#else 486#else
487 int bar = 1; 487 int bar = 1;
488#endif 488#endif
489 DECLARE_MAC_BUF(mac);
490 489
491/* when built into the kernel, we only print version if device is found */ 490/* when built into the kernel, we only print version if device is found */
492#ifndef MODULE 491#ifndef MODULE
@@ -665,9 +664,9 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
665 if (err) 664 if (err)
666 goto err_out_free_tx; 665 goto err_out_free_tx;
667 666
668 printk(KERN_INFO "%s: %s at %p, %s, IRQ %d.\n", 667 printk(KERN_INFO "%s: %s at %p, %pM, IRQ %d.\n",
669 dev->name, skel_netdrv_tbl[chip_id].chip_name, ioaddr, 668 dev->name, skel_netdrv_tbl[chip_id].chip_name, ioaddr,
670 print_mac(mac, dev->dev_addr), irq); 669 dev->dev_addr, irq);
671 670
672 return 0; 671 return 0;
673 672
@@ -1727,7 +1726,6 @@ static int netdev_rx(struct net_device *dev)
1727 } 1726 }
1728 skb->protocol = eth_type_trans(skb, dev); 1727 skb->protocol = eth_type_trans(skb, dev);
1729 netif_rx(skb); 1728 netif_rx(skb);
1730 dev->last_rx = jiffies;
1731 np->stats.rx_packets++; 1729 np->stats.rx_packets++;
1732 np->stats.rx_bytes += pkt_len; 1730 np->stats.rx_bytes += pkt_len;
1733 } 1731 }
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index ecd5c71a7a8a..7e33c129d51c 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1155,7 +1155,7 @@ static phy_info_t const phy_info_ks8721bl = {
1155 1155
1156static void mii_parse_dp8384x_sr2(uint mii_reg, struct net_device *dev) 1156static void mii_parse_dp8384x_sr2(uint mii_reg, struct net_device *dev)
1157{ 1157{
1158 struct fec_enet_private *fep = dev->priv; 1158 struct fec_enet_private *fep = netdev_priv(dev);
1159 volatile uint *s = &(fep->phy_status); 1159 volatile uint *s = &(fep->phy_status);
1160 1160
1161 *s &= ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); 1161 *s &= ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC);
@@ -2562,7 +2562,6 @@ static int __init fec_enet_module_init(void)
2562{ 2562{
2563 struct net_device *dev; 2563 struct net_device *dev;
2564 int i, err; 2564 int i, err;
2565 DECLARE_MAC_BUF(mac);
2566 2565
2567 printk("FEC ENET Version 0.2\n"); 2566 printk("FEC ENET Version 0.2\n");
2568 2567
@@ -2581,8 +2580,7 @@ static int __init fec_enet_module_init(void)
2581 return -EIO; 2580 return -EIO;
2582 } 2581 }
2583 2582
2584 printk("%s: ethernet %s\n", 2583 printk("%s: ethernet %pM\n", dev->name, dev->dev_addr);
2585 dev->name, print_mac(mac, dev->dev_addr));
2586 } 2584 }
2587 return 0; 2585 return 0;
2588} 2586}
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index aec3b97e794d..cd8e98b45ec5 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -216,7 +216,7 @@ static int mpc52xx_fec_init_phy(struct net_device *dev)
216 struct phy_device *phydev; 216 struct phy_device *phydev;
217 char phy_id[BUS_ID_SIZE]; 217 char phy_id[BUS_ID_SIZE];
218 218
219 snprintf(phy_id, BUS_ID_SIZE, "%x:%02x", 219 snprintf(phy_id, sizeof(phy_id), "%x:%02x",
220 (unsigned int)dev->base_addr, priv->phy_addr); 220 (unsigned int)dev->base_addr, priv->phy_addr);
221 221
222 priv->link = PHY_DOWN; 222 priv->link = PHY_DOWN;
@@ -487,7 +487,6 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
487 rskb->protocol = eth_type_trans(rskb, dev); 487 rskb->protocol = eth_type_trans(rskb, dev);
488 488
489 netif_rx(rskb); 489 netif_rx(rskb);
490 dev->last_rx = jiffies;
491 } else { 490 } else {
492 /* Can't get a new one : reuse the same & drop pkt */ 491 /* Can't get a new one : reuse the same & drop pkt */
493 dev_notice(&dev->dev, "Memory squeeze, dropping packet.\n"); 492 dev_notice(&dev->dev, "Memory squeeze, dropping packet.\n");
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index cc7328b15521..765210ea097d 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -818,7 +818,7 @@ struct fe_priv {
818 * Maximum number of loops until we assume that a bit in the irq mask 818 * Maximum number of loops until we assume that a bit in the irq mask
819 * is stuck. Overridable with module param. 819 * is stuck. Overridable with module param.
820 */ 820 */
821static int max_interrupt_work = 5; 821static int max_interrupt_work = 15;
822 822
823/* 823/*
824 * Optimization can be either throuput mode or cpu mode 824 * Optimization can be either throuput mode or cpu mode
@@ -2735,7 +2735,6 @@ static int nv_rx_process(struct net_device *dev, int limit)
2735#else 2735#else
2736 netif_rx(skb); 2736 netif_rx(skb);
2737#endif 2737#endif
2738 dev->last_rx = jiffies;
2739 dev->stats.rx_packets++; 2738 dev->stats.rx_packets++;
2740 dev->stats.rx_bytes += len; 2739 dev->stats.rx_bytes += len;
2741next_pkt: 2740next_pkt:
@@ -2848,7 +2847,6 @@ static int nv_rx_process_optimized(struct net_device *dev, int limit)
2848 } 2847 }
2849 } 2848 }
2850 2849
2851 dev->last_rx = jiffies;
2852 dev->stats.rx_packets++; 2850 dev->stats.rx_packets++;
2853 dev->stats.rx_bytes += len; 2851 dev->stats.rx_bytes += len;
2854 } else { 2852 } else {
@@ -5420,7 +5418,6 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5420 u32 powerstate, txreg; 5418 u32 powerstate, txreg;
5421 u32 phystate_orig = 0, phystate; 5419 u32 phystate_orig = 0, phystate;
5422 int phyinitialized = 0; 5420 int phyinitialized = 0;
5423 DECLARE_MAC_BUF(mac);
5424 static int printed_version; 5421 static int printed_version;
5425 5422
5426 if (!printed_version++) 5423 if (!printed_version++)
@@ -5653,8 +5650,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5653 * to 01:23:45:67:89:ab 5650 * to 01:23:45:67:89:ab
5654 */ 5651 */
5655 dev_printk(KERN_ERR, &pci_dev->dev, 5652 dev_printk(KERN_ERR, &pci_dev->dev,
5656 "Invalid Mac address detected: %s\n", 5653 "Invalid Mac address detected: %pM\n",
5657 print_mac(mac, dev->dev_addr)); 5654 dev->dev_addr);
5658 dev_printk(KERN_ERR, &pci_dev->dev, 5655 dev_printk(KERN_ERR, &pci_dev->dev,
5659 "Please complain to your hardware vendor. Switching to a random MAC.\n"); 5656 "Please complain to your hardware vendor. Switching to a random MAC.\n");
5660 dev->dev_addr[0] = 0x00; 5657 dev->dev_addr[0] = 0x00;
@@ -5663,8 +5660,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5663 get_random_bytes(&dev->dev_addr[3], 3); 5660 get_random_bytes(&dev->dev_addr[3], 3);
5664 } 5661 }
5665 5662
5666 dprintk(KERN_DEBUG "%s: MAC Address %s\n", 5663 dprintk(KERN_DEBUG "%s: MAC Address %pM\n",
5667 pci_name(pci_dev), print_mac(mac, dev->dev_addr)); 5664 pci_name(pci_dev), dev->dev_addr);
5668 5665
5669 /* set mac address */ 5666 /* set mac address */
5670 nv_copy_mac_to_hw(dev); 5667 nv_copy_mac_to_hw(dev);
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index a6f49d025787..df66d620b115 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -1117,10 +1117,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1117 if (ret) 1117 if (ret)
1118 goto out_free_bd; 1118 goto out_free_bd;
1119 1119
1120 printk(KERN_INFO "%s: fs_enet: %02x:%02x:%02x:%02x:%02x:%02x\n", 1120 printk(KERN_INFO "%s: fs_enet: %pM\n", ndev->name, ndev->dev_addr);
1121 ndev->name,
1122 ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2],
1123 ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]);
1124 1121
1125 return 0; 1122 return 0;
1126 1123
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index c4af949bf860..2635f5bed77f 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -162,7 +162,6 @@ static int gfar_probe(struct platform_device *pdev)
162 struct gianfar_platform_data *einfo; 162 struct gianfar_platform_data *einfo;
163 struct resource *r; 163 struct resource *r;
164 int err = 0, irq; 164 int err = 0, irq;
165 DECLARE_MAC_BUF(mac);
166 165
167 einfo = (struct gianfar_platform_data *) pdev->dev.platform_data; 166 einfo = (struct gianfar_platform_data *) pdev->dev.platform_data;
168 167
@@ -364,8 +363,7 @@ static int gfar_probe(struct platform_device *pdev)
364 gfar_init_sysfs(dev); 363 gfar_init_sysfs(dev);
365 364
366 /* Print out the device info */ 365 /* Print out the device info */
367 printk(KERN_INFO DEVICE_NAME "%s\n", 366 printk(KERN_INFO DEVICE_NAME "%pM\n", dev->name, dev->dev_addr);
368 dev->name, print_mac(mac, dev->dev_addr));
369 367
370 /* Even more device info helps when determining which kernel */ 368 /* Even more device info helps when determining which kernel */
371 /* provided which set of benchmarks. */ 369 /* provided which set of benchmarks. */
@@ -548,7 +546,7 @@ static int init_phy(struct net_device *dev)
548 priv->oldspeed = 0; 546 priv->oldspeed = 0;
549 priv->oldduplex = -1; 547 priv->oldduplex = -1;
550 548
551 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id); 549 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id);
552 550
553 interface = gfar_get_interface(dev); 551 interface = gfar_get_interface(dev);
554 552
@@ -1696,8 +1694,6 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
1696 dev->stats.rx_bytes += pkt_len; 1694 dev->stats.rx_bytes += pkt_len;
1697 } 1695 }
1698 1696
1699 dev->last_rx = jiffies;
1700
1701 priv->rx_skbuff[priv->skb_currx] = newskb; 1697 priv->rx_skbuff[priv->skb_currx] = newskb;
1702 1698
1703 /* Setup the new bdp */ 1699 /* Setup the new bdp */
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 3199526bcecb..77f2b2934e67 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -582,7 +582,6 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
582 void *ring_space; 582 void *ring_space;
583 dma_addr_t ring_dma; 583 dma_addr_t ring_dma;
584 int ret = -ENOMEM; 584 int ret = -ENOMEM;
585 DECLARE_MAC_BUF(mac);
586 585
587/* when built into the kernel, we only print version if device is found */ 586/* when built into the kernel, we only print version if device is found */
588#ifndef MODULE 587#ifndef MODULE
@@ -744,9 +743,9 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
744 goto err_out_unmap_rx; 743 goto err_out_unmap_rx;
745 } 744 }
746 745
747 printk(KERN_INFO "%s: %s type %x at %p, %s, IRQ %d.\n", 746 printk(KERN_INFO "%s: %s type %x at %p, %pM, IRQ %d.\n",
748 dev->name, chip_tbl[chip_id].name, readl(ioaddr + ChipRev), 747 dev->name, chip_tbl[chip_id].name, readl(ioaddr + ChipRev),
749 ioaddr, print_mac(mac, dev->dev_addr), irq); 748 ioaddr, dev->dev_addr, irq);
750 i = readb(ioaddr + PCIClkMeas); 749 i = readb(ioaddr + PCIClkMeas);
751 printk(KERN_INFO "%s: %d-bit %d Mhz PCI bus (%d), Virtual Jumpers " 750 printk(KERN_INFO "%s: %d-bit %d Mhz PCI bus (%d), Virtual Jumpers "
752 "%2.2x, LPA %4.4x.\n", 751 "%2.2x, LPA %4.4x.\n",
@@ -1646,7 +1645,6 @@ static int hamachi_rx(struct net_device *dev)
1646#endif /* RX_CHECKSUM */ 1645#endif /* RX_CHECKSUM */
1647 1646
1648 netif_rx(skb); 1647 netif_rx(skb);
1649 dev->last_rx = jiffies;
1650 hmp->stats.rx_packets++; 1648 hmp->stats.rx_packets++;
1651 } 1649 }
1652 entry = (++hmp->cur_rx) % RX_RING_SIZE; 1650 entry = (++hmp->cur_rx) % RX_RING_SIZE;
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 0f501d2ca935..50f1e172ee8f 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -373,7 +373,6 @@ static void sp_bump(struct sixpack *sp, char cmd)
373 memcpy(ptr, sp->cooked_buf + 1, count); 373 memcpy(ptr, sp->cooked_buf + 1, count);
374 skb->protocol = ax25_type_trans(skb, sp->dev); 374 skb->protocol = ax25_type_trans(skb, sp->dev);
375 netif_rx(skb); 375 netif_rx(skb);
376 sp->dev->last_rx = jiffies;
377 sp->dev->stats.rx_packets++; 376 sp->dev->stats.rx_packets++;
378 377
379 return; 378 return;
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 00bc7fbb6b37..81a65e3a1c05 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -555,7 +555,6 @@ static void do_rxpacket(struct net_device *dev)
555 memcpy(cp, bc->hdlcrx.buf, pktlen - 1); 555 memcpy(cp, bc->hdlcrx.buf, pktlen - 1);
556 skb->protocol = ax25_type_trans(skb, dev); 556 skb->protocol = ax25_type_trans(skb, dev);
557 netif_rx(skb); 557 netif_rx(skb);
558 dev->last_rx = jiffies;
559 bc->stats.rx_packets++; 558 bc->stats.rx_packets++;
560} 559}
561 560
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 58f4b1d7bf1f..46f8f3390e7d 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -230,7 +230,6 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
230 230
231 skb->protocol = ax25_type_trans(skb, dev); 231 skb->protocol = ax25_type_trans(skb, dev);
232 netif_rx(skb); 232 netif_rx(skb);
233 dev->last_rx = jiffies;
234unlock: 233unlock:
235 234
236 rcu_read_unlock(); 235 rcu_read_unlock();
@@ -441,16 +440,15 @@ static int bpq_seq_show(struct seq_file *seq, void *v)
441 "dev ether destination accept from\n"); 440 "dev ether destination accept from\n");
442 else { 441 else {
443 const struct bpqdev *bpqdev = v; 442 const struct bpqdev *bpqdev = v;
444 DECLARE_MAC_BUF(mac);
445 443
446 seq_printf(seq, "%-5s %-10s %s ", 444 seq_printf(seq, "%-5s %-10s %pM ",
447 bpqdev->axdev->name, bpqdev->ethdev->name, 445 bpqdev->axdev->name, bpqdev->ethdev->name,
448 print_mac(mac, bpqdev->dest_addr)); 446 bpqdev->dest_addr);
449 447
450 if (is_multicast_ether_addr(bpqdev->acpt_addr)) 448 if (is_multicast_ether_addr(bpqdev->acpt_addr))
451 seq_printf(seq, "*\n"); 449 seq_printf(seq, "*\n");
452 else 450 else
453 seq_printf(seq, "%s\n", print_mac(mac, bpqdev->acpt_addr)); 451 seq_printf(seq, "%pM\n", bpqdev->acpt_addr);
454 452
455 } 453 }
456 return 0; 454 return 0;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index e8cfadefa4b6..7e4611442237 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -1283,7 +1283,6 @@ static void rx_bh(struct work_struct *ugli_api)
1283 memcpy(&data[1], priv->rx_buf[i], cb); 1283 memcpy(&data[1], priv->rx_buf[i], cb);
1284 skb->protocol = ax25_type_trans(skb, priv->dev); 1284 skb->protocol = ax25_type_trans(skb, priv->dev);
1285 netif_rx(skb); 1285 netif_rx(skb);
1286 priv->dev->last_rx = jiffies;
1287 priv->stats.rx_packets++; 1286 priv->stats.rx_packets++;
1288 priv->stats.rx_bytes += cb; 1287 priv->stats.rx_bytes += cb;
1289 } 1288 }
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index c258a0586e61..8eba61a1d4ab 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -162,7 +162,6 @@ static void hdlc_rx_flag(struct net_device *dev, struct hdlcdrv_state *s)
162 memcpy(cp, s->hdlcrx.buffer, pkt_len - 1); 162 memcpy(cp, s->hdlcrx.buffer, pkt_len - 1);
163 skb->protocol = ax25_type_trans(skb, dev); 163 skb->protocol = ax25_type_trans(skb, dev);
164 netif_rx(skb); 164 netif_rx(skb);
165 dev->last_rx = jiffies;
166 s->stats.rx_packets++; 165 s->stats.rx_packets++;
167} 166}
168 167
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index b8e25c4624d2..7570c73f18c0 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -303,7 +303,6 @@ static void ax_bump(struct mkiss *ax)
303 memcpy(skb_put(skb,count), ax->rbuff, count); 303 memcpy(skb_put(skb,count), ax->rbuff, count);
304 skb->protocol = ax25_type_trans(skb, ax->dev); 304 skb->protocol = ax25_type_trans(skb, ax->dev);
305 netif_rx(skb); 305 netif_rx(skb);
306 ax->dev->last_rx = jiffies;
307 ax->stats.rx_packets++; 306 ax->stats.rx_packets++;
308 ax->stats.rx_bytes += count; 307 ax->stats.rx_bytes += count;
309 spin_unlock_bh(&ax->buflock); 308 spin_unlock_bh(&ax->buflock);
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index c17e39bc5460..802d1c7c4af1 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1627,7 +1627,6 @@ static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb)
1627 skb->protocol = ax25_type_trans(skb, scc->dev); 1627 skb->protocol = ax25_type_trans(skb, scc->dev);
1628 1628
1629 netif_rx(skb); 1629 netif_rx(skb);
1630 scc->dev->last_rx = jiffies;
1631 return; 1630 return;
1632} 1631}
1633 1632
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 1c942862a3f4..5407f7486c9c 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -515,7 +515,6 @@ static inline void yam_rx_flag(struct net_device *dev, struct yam_port *yp)
515 memcpy(cp, yp->rx_buf, pkt_len - 1); 515 memcpy(cp, yp->rx_buf, pkt_len - 1);
516 skb->protocol = ax25_type_trans(skb, dev); 516 skb->protocol = ax25_type_trans(skb, dev);
517 netif_rx(skb); 517 netif_rx(skb);
518 dev->last_rx = jiffies;
519 ++yp->stats.rx_packets; 518 ++yp->stats.rx_packets;
520 } 519 }
521 } 520 }
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index fbbd3e660c27..9026fd6ea0ff 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -166,7 +166,6 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
166 const char name[] = "HP-PC-LAN+"; 166 const char name[] = "HP-PC-LAN+";
167 int mem_start; 167 int mem_start;
168 static unsigned version_printed; 168 static unsigned version_printed;
169 DECLARE_MAC_BUF(mac);
170 169
171 if (!request_region(ioaddr, HP_IO_EXTENT, DRV_NAME)) 170 if (!request_region(ioaddr, HP_IO_EXTENT, DRV_NAME))
172 return -EBUSY; 171 return -EBUSY;
@@ -193,7 +192,7 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
193 } 192 }
194 checksum += inb(ioaddr + 14); 193 checksum += inb(ioaddr + 14);
195 194
196 printk("%s", print_mac(mac, dev->dev_addr)); 195 printk("%pM", dev->dev_addr);
197 196
198 if (checksum != 0xff) { 197 if (checksum != 0xff) {
199 printk(" bad checksum %2.2x.\n", checksum); 198 printk(" bad checksum %2.2x.\n", checksum);
diff --git a/drivers/net/hp.c b/drivers/net/hp.c
index 0a8c64930ad3..3669194f1063 100644
--- a/drivers/net/hp.c
+++ b/drivers/net/hp.c
@@ -127,7 +127,6 @@ static int __init hp_probe1(struct net_device *dev, int ioaddr)
127 int i, retval, board_id, wordmode; 127 int i, retval, board_id, wordmode;
128 const char *name; 128 const char *name;
129 static unsigned version_printed; 129 static unsigned version_printed;
130 DECLARE_MAC_BUF(mac);
131 130
132 if (!request_region(ioaddr, HP_IO_EXTENT, DRV_NAME)) 131 if (!request_region(ioaddr, HP_IO_EXTENT, DRV_NAME))
133 return -EBUSY; 132 return -EBUSY;
@@ -161,7 +160,7 @@ static int __init hp_probe1(struct net_device *dev, int ioaddr)
161 for(i = 0; i < ETHER_ADDR_LEN; i++) 160 for(i = 0; i < ETHER_ADDR_LEN; i++)
162 dev->dev_addr[i] = inb(ioaddr + i); 161 dev->dev_addr[i] = inb(ioaddr + i);
163 162
164 printk(" %s", print_mac(mac, dev->dev_addr)); 163 printk(" %pM", dev->dev_addr);
165 164
166 /* Snarf the interrupt now. Someday this could be moved to open(). */ 165 /* Snarf the interrupt now. Someday this could be moved to open(). */
167 if (dev->irq < 2) { 166 if (dev->irq < 2) {
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index 571dd80fb850..4dda9b043b13 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -1834,7 +1834,6 @@ static void hp100_rx(struct net_device *dev)
1834 ptr[9], ptr[10], ptr[11]); 1834 ptr[9], ptr[10], ptr[11]);
1835#endif 1835#endif
1836 netif_rx(skb); 1836 netif_rx(skb);
1837 dev->last_rx = jiffies;
1838 lp->stats.rx_packets++; 1837 lp->stats.rx_packets++;
1839 lp->stats.rx_bytes += pkt_len; 1838 lp->stats.rx_bytes += pkt_len;
1840 } 1839 }
@@ -1925,7 +1924,6 @@ static void hp100_rx_bm(struct net_device *dev)
1925 1924
1926 netif_rx(ptr->skb); /* Up and away... */ 1925 netif_rx(ptr->skb); /* Up and away... */
1927 1926
1928 dev->last_rx = jiffies;
1929 lp->stats.rx_packets++; 1927 lp->stats.rx_packets++;
1930 lp->stats.rx_bytes += pkt_len; 1928 lp->stats.rx_bytes += pkt_len;
1931 } 1929 }
@@ -2093,9 +2091,8 @@ static void hp100_set_multicast_list(struct net_device *dev)
2093 addrs = dmi->dmi_addr; 2091 addrs = dmi->dmi_addr;
2094 if ((*addrs & 0x01) == 0x01) { /* multicast address? */ 2092 if ((*addrs & 0x01) == 0x01) { /* multicast address? */
2095#ifdef HP100_DEBUG 2093#ifdef HP100_DEBUG
2096 DECLARE_MAC_BUF(mac); 2094 printk("hp100: %s: multicast = %pM, ",
2097 printk("hp100: %s: multicast = %s, ", 2095 dev->name, addrs);
2098 dev->name, print_mac(mac, addrs));
2099#endif 2096#endif
2100 for (j = idx = 0; j < 6; j++) { 2097 for (j = idx = 0; j < 6; j++) {
2101 idx ^= *addrs++ & 0x3f; 2098 idx ^= *addrs++ & 0x3f;
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index b96cf2dcb109..b0ae0766ea4e 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -103,7 +103,6 @@ static int __devinit hydra_init(struct zorro_dev *z)
103 int start_page, stop_page; 103 int start_page, stop_page;
104 int j; 104 int j;
105 int err; 105 int err;
106 DECLARE_MAC_BUF(mac);
107 106
108 static u32 hydra_offsets[16] = { 107 static u32 hydra_offsets[16] = {
109 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 108 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
@@ -163,8 +162,8 @@ static int __devinit hydra_init(struct zorro_dev *z)
163 zorro_set_drvdata(z, dev); 162 zorro_set_drvdata(z, dev);
164 163
165 printk(KERN_INFO "%s: Hydra at 0x%08lx, address " 164 printk(KERN_INFO "%s: Hydra at 0x%08lx, address "
166 "%s (hydra.c " HYDRA_VERSION ")\n", 165 "%pM (hydra.c " HYDRA_VERSION ")\n",
167 dev->name, z->resource.start, print_mac(mac, dev->dev_addr)); 166 dev->name, z->resource.start, dev->dev_addr);
168 167
169 return 0; 168 return 0;
170} 169}
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 901212aa37cb..87a706694fb3 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -396,9 +396,7 @@ static void emac_hash_mc(struct emac_instance *dev)
396 396
397 for (dmi = dev->ndev->mc_list; dmi; dmi = dmi->next) { 397 for (dmi = dev->ndev->mc_list; dmi; dmi = dmi->next) {
398 int slot, reg, mask; 398 int slot, reg, mask;
399 DBG2(dev, "mc %02x:%02x:%02x:%02x:%02x:%02x" NL, 399 DBG2(dev, "mc %pM" NL, dmi->dmi_addr);
400 dmi->dmi_addr[0], dmi->dmi_addr[1], dmi->dmi_addr[2],
401 dmi->dmi_addr[3], dmi->dmi_addr[4], dmi->dmi_addr[5]);
402 400
403 slot = EMAC_XAHT_CRC_TO_SLOT(dev, ether_crc(ETH_ALEN, dmi->dmi_addr)); 401 slot = EMAC_XAHT_CRC_TO_SLOT(dev, ether_crc(ETH_ALEN, dmi->dmi_addr));
404 reg = EMAC_XAHT_SLOT_TO_REG(dev, slot); 402 reg = EMAC_XAHT_SLOT_TO_REG(dev, slot);
@@ -2865,11 +2863,8 @@ static int __devinit emac_probe(struct of_device *ofdev,
2865 wake_up_all(&emac_probe_wait); 2863 wake_up_all(&emac_probe_wait);
2866 2864
2867 2865
2868 printk(KERN_INFO 2866 printk(KERN_INFO "%s: EMAC-%d %s, MAC %pM\n",
2869 "%s: EMAC-%d %s, MAC %02x:%02x:%02x:%02x:%02x:%02x\n", 2867 ndev->name, dev->cell_index, np->full_name, ndev->dev_addr);
2870 ndev->name, dev->cell_index, np->full_name,
2871 ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2],
2872 ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]);
2873 2868
2874 if (dev->phy_mode == PHY_MODE_SGMII) 2869 if (dev->phy_mode == PHY_MODE_SGMII)
2875 printk(KERN_NOTICE "%s: in SGMII mode\n", ndev->name); 2870 printk(KERN_NOTICE "%s: in SGMII mode\n", ndev->name);
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index f02764725a22..5b5bf9f9861a 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -605,7 +605,6 @@ static void irqrx_handler(struct net_device *dev)
605 skb->ip_summed = CHECKSUM_NONE; 605 skb->ip_summed = CHECKSUM_NONE;
606 606
607 /* bookkeeping */ 607 /* bookkeeping */
608 dev->last_rx = jiffies;
609 dev->stats.rx_packets++; 608 dev->stats.rx_packets++;
610 dev->stats.rx_bytes += rda.length; 609 dev->stats.rx_bytes += rda.length;
611 610
@@ -914,7 +913,6 @@ static int __devinit ibmlana_init_one(struct device *kdev)
914 int base = 0, irq = 0, iobase = 0, memlen = 0; 913 int base = 0, irq = 0, iobase = 0, memlen = 0;
915 ibmlana_priv *priv; 914 ibmlana_priv *priv;
916 ibmlana_medium medium; 915 ibmlana_medium medium;
917 DECLARE_MAC_BUF(mac);
918 916
919 dev = alloc_etherdev(sizeof(ibmlana_priv)); 917 dev = alloc_etherdev(sizeof(ibmlana_priv));
920 if (!dev) 918 if (!dev)
@@ -990,10 +988,10 @@ static int __devinit ibmlana_init_one(struct device *kdev)
990 /* print config */ 988 /* print config */
991 989
992 printk(KERN_INFO "%s: IRQ %d, I/O %#lx, memory %#lx-%#lx, " 990 printk(KERN_INFO "%s: IRQ %d, I/O %#lx, memory %#lx-%#lx, "
993 "MAC address %s.\n", 991 "MAC address %pM.\n",
994 dev->name, priv->realirq, dev->base_addr, 992 dev->name, priv->realirq, dev->base_addr,
995 dev->mem_start, dev->mem_end - 1, 993 dev->mem_start, dev->mem_end - 1,
996 print_mac(mac, dev->dev_addr)); 994 dev->dev_addr);
997 printk(KERN_INFO "%s: %s medium\n", dev->name, MediaNames[priv->medium]); 995 printk(KERN_INFO "%s: %s medium\n", dev->name, MediaNames[priv->medium]);
998 996
999 /* reset board */ 997 /* reset board */
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index c2d57f836088..02ecfdb4df6b 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -527,7 +527,7 @@ retry:
527 527
528static int ibmveth_open(struct net_device *netdev) 528static int ibmveth_open(struct net_device *netdev)
529{ 529{
530 struct ibmveth_adapter *adapter = netdev->priv; 530 struct ibmveth_adapter *adapter = netdev_priv(netdev);
531 u64 mac_address = 0; 531 u64 mac_address = 0;
532 int rxq_entries = 1; 532 int rxq_entries = 1;
533 unsigned long lpar_rc; 533 unsigned long lpar_rc;
@@ -666,7 +666,7 @@ static int ibmveth_open(struct net_device *netdev)
666 666
667static int ibmveth_close(struct net_device *netdev) 667static int ibmveth_close(struct net_device *netdev)
668{ 668{
669 struct ibmveth_adapter *adapter = netdev->priv; 669 struct ibmveth_adapter *adapter = netdev_priv(netdev);
670 long lpar_rc; 670 long lpar_rc;
671 671
672 ibmveth_debug_printk("close starting\n"); 672 ibmveth_debug_printk("close starting\n");
@@ -722,7 +722,7 @@ static u32 netdev_get_link(struct net_device *dev) {
722 722
723static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) 723static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data)
724{ 724{
725 struct ibmveth_adapter *adapter = dev->priv; 725 struct ibmveth_adapter *adapter = netdev_priv(dev);
726 726
727 if (data) 727 if (data)
728 adapter->rx_csum = 1; 728 adapter->rx_csum = 1;
@@ -741,7 +741,7 @@ static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data)
741 741
742static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) 742static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data)
743{ 743{
744 struct ibmveth_adapter *adapter = dev->priv; 744 struct ibmveth_adapter *adapter = netdev_priv(dev);
745 745
746 if (data) { 746 if (data) {
747 dev->features |= NETIF_F_IP_CSUM; 747 dev->features |= NETIF_F_IP_CSUM;
@@ -753,7 +753,7 @@ static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data)
753static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, 753static int ibmveth_set_csum_offload(struct net_device *dev, u32 data,
754 void (*done) (struct net_device *, u32)) 754 void (*done) (struct net_device *, u32))
755{ 755{
756 struct ibmveth_adapter *adapter = dev->priv; 756 struct ibmveth_adapter *adapter = netdev_priv(dev);
757 u64 set_attr, clr_attr, ret_attr; 757 u64 set_attr, clr_attr, ret_attr;
758 long ret; 758 long ret;
759 int rc1 = 0, rc2 = 0; 759 int rc1 = 0, rc2 = 0;
@@ -805,7 +805,7 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data,
805 805
806static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) 806static int ibmveth_set_rx_csum(struct net_device *dev, u32 data)
807{ 807{
808 struct ibmveth_adapter *adapter = dev->priv; 808 struct ibmveth_adapter *adapter = netdev_priv(dev);
809 809
810 if ((data && adapter->rx_csum) || (!data && !adapter->rx_csum)) 810 if ((data && adapter->rx_csum) || (!data && !adapter->rx_csum))
811 return 0; 811 return 0;
@@ -815,7 +815,7 @@ static int ibmveth_set_rx_csum(struct net_device *dev, u32 data)
815 815
816static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) 816static int ibmveth_set_tx_csum(struct net_device *dev, u32 data)
817{ 817{
818 struct ibmveth_adapter *adapter = dev->priv; 818 struct ibmveth_adapter *adapter = netdev_priv(dev);
819 int rc = 0; 819 int rc = 0;
820 820
821 if (data && (dev->features & NETIF_F_IP_CSUM)) 821 if (data && (dev->features & NETIF_F_IP_CSUM))
@@ -833,7 +833,7 @@ static int ibmveth_set_tx_csum(struct net_device *dev, u32 data)
833 833
834static u32 ibmveth_get_rx_csum(struct net_device *dev) 834static u32 ibmveth_get_rx_csum(struct net_device *dev)
835{ 835{
836 struct ibmveth_adapter *adapter = dev->priv; 836 struct ibmveth_adapter *adapter = netdev_priv(dev);
837 return adapter->rx_csum; 837 return adapter->rx_csum;
838} 838}
839 839
@@ -862,7 +862,7 @@ static void ibmveth_get_ethtool_stats(struct net_device *dev,
862 struct ethtool_stats *stats, u64 *data) 862 struct ethtool_stats *stats, u64 *data)
863{ 863{
864 int i; 864 int i;
865 struct ibmveth_adapter *adapter = dev->priv; 865 struct ibmveth_adapter *adapter = netdev_priv(dev);
866 866
867 for (i = 0; i < ARRAY_SIZE(ibmveth_stats); i++) 867 for (i = 0; i < ARRAY_SIZE(ibmveth_stats); i++)
868 data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset); 868 data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset);
@@ -889,7 +889,7 @@ static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
889 889
890static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) 890static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
891{ 891{
892 struct ibmveth_adapter *adapter = netdev->priv; 892 struct ibmveth_adapter *adapter = netdev_priv(netdev);
893 union ibmveth_buf_desc desc; 893 union ibmveth_buf_desc desc;
894 unsigned long lpar_rc; 894 unsigned long lpar_rc;
895 unsigned long correlator; 895 unsigned long correlator;
@@ -1014,7 +1014,6 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
1014 netdev->stats.rx_packets++; 1014 netdev->stats.rx_packets++;
1015 netdev->stats.rx_bytes += length; 1015 netdev->stats.rx_bytes += length;
1016 frames_processed++; 1016 frames_processed++;
1017 netdev->last_rx = jiffies;
1018 } 1017 }
1019 } while (frames_processed < budget); 1018 } while (frames_processed < budget);
1020 1019
@@ -1045,7 +1044,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
1045static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance) 1044static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance)
1046{ 1045{
1047 struct net_device *netdev = dev_instance; 1046 struct net_device *netdev = dev_instance;
1048 struct ibmveth_adapter *adapter = netdev->priv; 1047 struct ibmveth_adapter *adapter = netdev_priv(netdev);
1049 unsigned long lpar_rc; 1048 unsigned long lpar_rc;
1050 1049
1051 if (netif_rx_schedule_prep(netdev, &adapter->napi)) { 1050 if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
@@ -1059,7 +1058,7 @@ static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance)
1059 1058
1060static void ibmveth_set_multicast_list(struct net_device *netdev) 1059static void ibmveth_set_multicast_list(struct net_device *netdev)
1061{ 1060{
1062 struct ibmveth_adapter *adapter = netdev->priv; 1061 struct ibmveth_adapter *adapter = netdev_priv(netdev);
1063 unsigned long lpar_rc; 1062 unsigned long lpar_rc;
1064 1063
1065 if((netdev->flags & IFF_PROMISC) || (netdev->mc_count > adapter->mcastFilterSize)) { 1064 if((netdev->flags & IFF_PROMISC) || (netdev->mc_count > adapter->mcastFilterSize)) {
@@ -1107,7 +1106,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)
1107 1106
1108static int ibmveth_change_mtu(struct net_device *dev, int new_mtu) 1107static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
1109{ 1108{
1110 struct ibmveth_adapter *adapter = dev->priv; 1109 struct ibmveth_adapter *adapter = netdev_priv(dev);
1111 struct vio_dev *viodev = adapter->vdev; 1110 struct vio_dev *viodev = adapter->vdev;
1112 int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH; 1111 int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH;
1113 int i; 1112 int i;
@@ -1159,7 +1158,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
1159#ifdef CONFIG_NET_POLL_CONTROLLER 1158#ifdef CONFIG_NET_POLL_CONTROLLER
1160static void ibmveth_poll_controller(struct net_device *dev) 1159static void ibmveth_poll_controller(struct net_device *dev)
1161{ 1160{
1162 ibmveth_replenish_task(dev->priv); 1161 ibmveth_replenish_task(netdev_priv(dev));
1163 ibmveth_interrupt(dev->irq, dev); 1162 ibmveth_interrupt(dev->irq, dev);
1164} 1163}
1165#endif 1164#endif
@@ -1241,7 +1240,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
1241 if(!netdev) 1240 if(!netdev)
1242 return -ENOMEM; 1241 return -ENOMEM;
1243 1242
1244 adapter = netdev->priv; 1243 adapter = netdev_priv(netdev);
1245 dev->dev.driver_data = netdev; 1244 dev->dev.driver_data = netdev;
1246 1245
1247 adapter->vdev = dev; 1246 adapter->vdev = dev;
@@ -1337,7 +1336,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
1337static int __devexit ibmveth_remove(struct vio_dev *dev) 1336static int __devexit ibmveth_remove(struct vio_dev *dev)
1338{ 1337{
1339 struct net_device *netdev = dev->dev.driver_data; 1338 struct net_device *netdev = dev->dev.driver_data;
1340 struct ibmveth_adapter *adapter = netdev->priv; 1339 struct ibmveth_adapter *adapter = netdev_priv(netdev);
1341 int i; 1340 int i;
1342 1341
1343 for(i = 0; i<IbmVethNumBufferPools; i++) 1342 for(i = 0; i<IbmVethNumBufferPools; i++)
@@ -1371,13 +1370,12 @@ static int ibmveth_show(struct seq_file *seq, void *v)
1371 struct ibmveth_adapter *adapter = seq->private; 1370 struct ibmveth_adapter *adapter = seq->private;
1372 char *current_mac = ((char*) &adapter->netdev->dev_addr); 1371 char *current_mac = ((char*) &adapter->netdev->dev_addr);
1373 char *firmware_mac = ((char*) &adapter->mac_addr) ; 1372 char *firmware_mac = ((char*) &adapter->mac_addr) ;
1374 DECLARE_MAC_BUF(mac);
1375 1373
1376 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version); 1374 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version);
1377 1375
1378 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address); 1376 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address);
1379 seq_printf(seq, "Current MAC: %s\n", print_mac(mac, current_mac)); 1377 seq_printf(seq, "Current MAC: %pM\n", current_mac);
1380 seq_printf(seq, "Firmware MAC: %s\n", print_mac(mac, firmware_mac)); 1378 seq_printf(seq, "Firmware MAC: %pM\n", firmware_mac);
1381 1379
1382 seq_printf(seq, "\nAdapter Statistics:\n"); 1380 seq_printf(seq, "\nAdapter Statistics:\n");
1383 seq_printf(seq, " TX: vio_map_single failres: %ld\n", adapter->tx_map_failed); 1381 seq_printf(seq, " TX: vio_map_single failres: %ld\n", adapter->tx_map_failed);
@@ -1472,7 +1470,7 @@ const char * buf, size_t count)
1472 kobj); 1470 kobj);
1473 struct net_device *netdev = 1471 struct net_device *netdev =
1474 container_of(kobj->parent, struct device, kobj)->driver_data; 1472 container_of(kobj->parent, struct device, kobj)->driver_data;
1475 struct ibmveth_adapter *adapter = netdev->priv; 1473 struct ibmveth_adapter *adapter = netdev_priv(netdev);
1476 long value = simple_strtol(buf, NULL, 10); 1474 long value = simple_strtol(buf, NULL, 10);
1477 long rc; 1475 long rc;
1478 1476
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index 89964fa739a0..9b9066c5b0e1 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -101,8 +101,8 @@ static const struct igb_stats igb_gstrings_stats[] = {
101}; 101};
102 102
103#define IGB_QUEUE_STATS_LEN \ 103#define IGB_QUEUE_STATS_LEN \
104 ((((struct igb_adapter *)netdev->priv)->num_rx_queues + \ 104 ((((struct igb_adapter *)netdev_priv(netdev))->num_rx_queues + \
105 ((struct igb_adapter *)netdev->priv)->num_tx_queues) * \ 105 ((struct igb_adapter *)netdev_priv(netdev))->num_tx_queues) * \
106 (sizeof(struct igb_queue_stats) / sizeof(u64))) 106 (sizeof(struct igb_queue_stats) / sizeof(u64)))
107#define IGB_GLOBAL_STATS_LEN \ 107#define IGB_GLOBAL_STATS_LEN \
108 sizeof(igb_gstrings_stats) / sizeof(struct igb_stats) 108 sizeof(igb_gstrings_stats) / sizeof(struct igb_stats)
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 1cbae85b1426..5f954b01e21a 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1275,16 +1275,14 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1275 1275
1276 dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n"); 1276 dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n");
1277 /* print bus type/speed/width info */ 1277 /* print bus type/speed/width info */
1278 dev_info(&pdev->dev, 1278 dev_info(&pdev->dev, "%s: (PCIe:%s:%s) %pM\n",
1279 "%s: (PCIe:%s:%s) %02x:%02x:%02x:%02x:%02x:%02x\n",
1280 netdev->name, 1279 netdev->name,
1281 ((hw->bus.speed == e1000_bus_speed_2500) 1280 ((hw->bus.speed == e1000_bus_speed_2500)
1282 ? "2.5Gb/s" : "unknown"), 1281 ? "2.5Gb/s" : "unknown"),
1283 ((hw->bus.width == e1000_bus_width_pcie_x4) 1282 ((hw->bus.width == e1000_bus_width_pcie_x4)
1284 ? "Width x4" : (hw->bus.width == e1000_bus_width_pcie_x1) 1283 ? "Width x4" : (hw->bus.width == e1000_bus_width_pcie_x1)
1285 ? "Width x1" : "unknown"), 1284 ? "Width x1" : "unknown"),
1286 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2], 1285 netdev->dev_addr);
1287 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
1288 1286
1289 igb_read_part_num(hw, &part_num); 1287 igb_read_part_num(hw, &part_num);
1290 dev_info(&pdev->dev, "%s: PBA No: %06x-%03x\n", netdev->name, 1288 dev_info(&pdev->dev, "%s: PBA No: %06x-%03x\n", netdev->name,
@@ -3942,8 +3940,6 @@ send_up:
3942 3940
3943 igb_receive_skb(rx_ring, staterr, rx_desc, skb); 3941 igb_receive_skb(rx_ring, staterr, rx_desc, skb);
3944 3942
3945 netdev->last_rx = jiffies;
3946
3947next_desc: 3943next_desc:
3948 rx_desc->wb.upper.status_error = 0; 3944 rx_desc->wb.upper.status_error = 0;
3949 3945
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index 1f25263dc7eb..170b12d1d70e 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -390,11 +390,8 @@ static int nic_init(struct ioc3 *ioc3)
390 } 390 }
391 391
392 printk("Found %s NIC", type); 392 printk("Found %s NIC", type);
393 if (type != unknown) { 393 if (type != unknown)
394 printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x," 394 printk (" registration number %pM, CRC %02x", serial, crc);
395 " CRC %02x", serial[0], serial[1], serial[2],
396 serial[3], serial[4], serial[5], crc);
397 }
398 printk(".\n"); 395 printk(".\n");
399 396
400 return 0; 397 return 0;
@@ -443,12 +440,9 @@ static void ioc3_get_eaddr_nic(struct ioc3_private *ip)
443 */ 440 */
444static void ioc3_get_eaddr(struct ioc3_private *ip) 441static void ioc3_get_eaddr(struct ioc3_private *ip)
445{ 442{
446 DECLARE_MAC_BUF(mac);
447
448 ioc3_get_eaddr_nic(ip); 443 ioc3_get_eaddr_nic(ip);
449 444
450 printk("Ethernet address is %s.\n", 445 printk("Ethernet address is %pM.\n", priv_netdev(ip)->dev_addr);
451 print_mac(mac, priv_netdev(ip)->dev_addr));
452} 446}
453 447
454static void __ioc3_set_mac_address(struct net_device *dev) 448static void __ioc3_set_mac_address(struct net_device *dev)
@@ -627,7 +621,6 @@ static inline void ioc3_rx(struct ioc3_private *ip)
627 rxb = (struct ioc3_erxbuf *) new_skb->data; 621 rxb = (struct ioc3_erxbuf *) new_skb->data;
628 skb_reserve(new_skb, RX_OFFSET); 622 skb_reserve(new_skb, RX_OFFSET);
629 623
630 priv_netdev(ip)->last_rx = jiffies;
631 ip->stats.rx_packets++; /* Statistics */ 624 ip->stats.rx_packets++; /* Statistics */
632 ip->stats.rx_bytes += len; 625 ip->stats.rx_bytes += len;
633 } else { 626 } else {
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 7373dafbb3f7..24c777aff5c6 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -1222,7 +1222,6 @@ static void ipg_nic_rx_with_start_and_end(struct net_device *dev,
1222 skb->protocol = eth_type_trans(skb, dev); 1222 skb->protocol = eth_type_trans(skb, dev);
1223 skb->ip_summed = CHECKSUM_NONE; 1223 skb->ip_summed = CHECKSUM_NONE;
1224 netif_rx(skb); 1224 netif_rx(skb);
1225 dev->last_rx = jiffies;
1226 sp->rx_buff[entry] = NULL; 1225 sp->rx_buff[entry] = NULL;
1227} 1226}
1228 1227
@@ -1256,7 +1255,6 @@ static void ipg_nic_rx_with_start(struct net_device *dev,
1256 jumbo->skb = skb; 1255 jumbo->skb = skb;
1257 1256
1258 sp->rx_buff[entry] = NULL; 1257 sp->rx_buff[entry] = NULL;
1259 dev->last_rx = jiffies;
1260} 1258}
1261 1259
1262static void ipg_nic_rx_with_end(struct net_device *dev, 1260static void ipg_nic_rx_with_end(struct net_device *dev,
@@ -1292,7 +1290,6 @@ static void ipg_nic_rx_with_end(struct net_device *dev,
1292 } 1290 }
1293 } 1291 }
1294 1292
1295 dev->last_rx = jiffies;
1296 jumbo->found_start = 0; 1293 jumbo->found_start = 0;
1297 jumbo->current_size = 0; 1294 jumbo->current_size = 0;
1298 jumbo->skb = NULL; 1295 jumbo->skb = NULL;
@@ -1325,7 +1322,6 @@ static void ipg_nic_rx_no_start_no_end(struct net_device *dev,
1325 skb->data, sp->rxfrag_size); 1322 skb->data, sp->rxfrag_size);
1326 } 1323 }
1327 } 1324 }
1328 dev->last_rx = jiffies;
1329 ipg_nic_rx_free_skb(dev); 1325 ipg_nic_rx_free_skb(dev);
1330 } 1326 }
1331 } else { 1327 } else {
@@ -1494,11 +1490,6 @@ static int ipg_nic_rx(struct net_device *dev)
1494 * when processing completes. 1490 * when processing completes.
1495 */ 1491 */
1496 netif_rx(skb); 1492 netif_rx(skb);
1497
1498 /* Record frame receive time (jiffies = Linux
1499 * kernel current time stamp).
1500 */
1501 dev->last_rx = jiffies;
1502 } 1493 }
1503 1494
1504 /* Assure RX buffer is not reused by IPG. */ 1495 /* Assure RX buffer is not reused by IPG. */
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 2ff181861d2d..3c58e67ef1e4 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -292,7 +292,7 @@ static int ali_ircc_open(int i, chipio_t *info)
292 return -ENOMEM; 292 return -ENOMEM;
293 } 293 }
294 294
295 self = dev->priv; 295 self = netdev_priv(dev);
296 self->netdev = dev; 296 self->netdev = dev;
297 spin_lock_init(&self->lock); 297 spin_lock_init(&self->lock);
298 298
@@ -665,7 +665,7 @@ static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id)
665 665
666 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__); 666 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
667 667
668 self = dev->priv; 668 self = netdev_priv(dev);
669 669
670 spin_lock(&self->lock); 670 spin_lock(&self->lock);
671 671
@@ -1333,7 +1333,7 @@ static int ali_ircc_net_open(struct net_device *dev)
1333 1333
1334 IRDA_ASSERT(dev != NULL, return -1;); 1334 IRDA_ASSERT(dev != NULL, return -1;);
1335 1335
1336 self = (struct ali_ircc_cb *) dev->priv; 1336 self = netdev_priv(dev);
1337 1337
1338 IRDA_ASSERT(self != NULL, return 0;); 1338 IRDA_ASSERT(self != NULL, return 0;);
1339 1339
@@ -1396,7 +1396,7 @@ static int ali_ircc_net_close(struct net_device *dev)
1396 1396
1397 IRDA_ASSERT(dev != NULL, return -1;); 1397 IRDA_ASSERT(dev != NULL, return -1;);
1398 1398
1399 self = (struct ali_ircc_cb *) dev->priv; 1399 self = netdev_priv(dev);
1400 IRDA_ASSERT(self != NULL, return 0;); 1400 IRDA_ASSERT(self != NULL, return 0;);
1401 1401
1402 /* Stop device */ 1402 /* Stop device */
@@ -1436,7 +1436,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1436 1436
1437 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ ); 1437 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
1438 1438
1439 self = (struct ali_ircc_cb *) dev->priv; 1439 self = netdev_priv(dev);
1440 iobase = self->io.fir_base; 1440 iobase = self->io.fir_base;
1441 1441
1442 netif_stop_queue(dev); 1442 netif_stop_queue(dev);
@@ -1931,7 +1931,6 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1931 skb_reset_mac_header(skb); 1931 skb_reset_mac_header(skb);
1932 skb->protocol = htons(ETH_P_IRDA); 1932 skb->protocol = htons(ETH_P_IRDA);
1933 netif_rx(skb); 1933 netif_rx(skb);
1934 self->netdev->last_rx = jiffies;
1935 } 1934 }
1936 } 1935 }
1937 1936
@@ -1960,7 +1959,7 @@ static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1960 1959
1961 IRDA_ASSERT(dev != NULL, return 0;); 1960 IRDA_ASSERT(dev != NULL, return 0;);
1962 1961
1963 self = (struct ali_ircc_cb *) dev->priv; 1962 self = netdev_priv(dev);
1964 IRDA_ASSERT(self != NULL, return 0;); 1963 IRDA_ASSERT(self != NULL, return 0;);
1965 1964
1966 iobase = self->io.sir_base; 1965 iobase = self->io.sir_base;
@@ -2028,7 +2027,7 @@ static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2028 2027
2029 IRDA_ASSERT(dev != NULL, return -1;); 2028 IRDA_ASSERT(dev != NULL, return -1;);
2030 2029
2031 self = dev->priv; 2030 self = netdev_priv(dev);
2032 2031
2033 IRDA_ASSERT(self != NULL, return -1;); 2032 IRDA_ASSERT(self != NULL, return -1;);
2034 2033
@@ -2114,7 +2113,7 @@ static int ali_ircc_is_receiving(struct ali_ircc_cb *self)
2114 2113
2115static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev) 2114static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev)
2116{ 2115{
2117 struct ali_ircc_cb *self = (struct ali_ircc_cb *) dev->priv; 2116 struct ali_ircc_cb *self = netdev_priv(dev);
2118 2117
2119 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ ); 2118 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
2120 2119
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index a1e4508717c8..6c4b53ffbcac 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -620,7 +620,6 @@ static int au1k_irda_rx(struct net_device *dev)
620 /* next descriptor */ 620 /* next descriptor */
621 prxd = aup->rx_ring[aup->rx_head]; 621 prxd = aup->rx_ring[aup->rx_head];
622 flags = prxd->flags; 622 flags = prxd->flags;
623 dev->last_rx = jiffies;
624 623
625 } 624 }
626 return 0; 625 return 0;
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 69d16b30323b..687c2d53d4d2 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -979,7 +979,7 @@ toshoboe_hard_xmit (struct sk_buff *skb, struct net_device *dev)
979 unsigned long flags; 979 unsigned long flags;
980 struct irda_skb_cb *cb = (struct irda_skb_cb *) skb->cb; 980 struct irda_skb_cb *cb = (struct irda_skb_cb *) skb->cb;
981 981
982 self = (struct toshoboe_cb *) dev->priv; 982 self = netdev_priv(dev);
983 983
984 IRDA_ASSERT (self != NULL, return 0; ); 984 IRDA_ASSERT (self != NULL, return 0; );
985 985
@@ -1384,7 +1384,7 @@ toshoboe_net_close (struct net_device *dev)
1384 IRDA_DEBUG (4, "%s()\n", __func__); 1384 IRDA_DEBUG (4, "%s()\n", __func__);
1385 1385
1386 IRDA_ASSERT (dev != NULL, return -1; ); 1386 IRDA_ASSERT (dev != NULL, return -1; );
1387 self = (struct toshoboe_cb *) dev->priv; 1387 self = netdev_priv(dev);
1388 1388
1389 /* Stop device */ 1389 /* Stop device */
1390 netif_stop_queue(dev); 1390 netif_stop_queue(dev);
@@ -1422,7 +1422,7 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1422 1422
1423 IRDA_ASSERT (dev != NULL, return -1; ); 1423 IRDA_ASSERT (dev != NULL, return -1; );
1424 1424
1425 self = dev->priv; 1425 self = netdev_priv(dev);
1426 1426
1427 IRDA_ASSERT (self != NULL, return -1; ); 1427 IRDA_ASSERT (self != NULL, return -1; );
1428 1428
@@ -1546,7 +1546,7 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid)
1546 return -ENOMEM; 1546 return -ENOMEM;
1547 } 1547 }
1548 1548
1549 self = dev->priv; 1549 self = netdev_priv(dev);
1550 self->netdev = dev; 1550 self->netdev = dev;
1551 self->pdev = pci_dev; 1551 self->pdev = pci_dev;
1552 self->base = pci_resource_start(pci_dev,0); 1552 self->base = pci_resource_start(pci_dev,0);
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index b5d6b9ac162a..205e4e825a97 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -384,7 +384,7 @@ static void speed_bulk_callback(struct urb *urb)
384 */ 384 */
385static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev) 385static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
386{ 386{
387 struct irda_usb_cb *self = netdev->priv; 387 struct irda_usb_cb *self = netdev_priv(netdev);
388 struct urb *urb = self->tx_urb; 388 struct urb *urb = self->tx_urb;
389 unsigned long flags; 389 unsigned long flags;
390 s32 speed; 390 s32 speed;
@@ -628,7 +628,7 @@ static void write_bulk_callback(struct urb *urb)
628static void irda_usb_net_timeout(struct net_device *netdev) 628static void irda_usb_net_timeout(struct net_device *netdev)
629{ 629{
630 unsigned long flags; 630 unsigned long flags;
631 struct irda_usb_cb *self = netdev->priv; 631 struct irda_usb_cb *self = netdev_priv(netdev);
632 struct urb *urb; 632 struct urb *urb;
633 int done = 0; /* If we have made any progress */ 633 int done = 0; /* If we have made any progress */
634 634
@@ -929,7 +929,6 @@ static void irda_usb_receive(struct urb *urb)
929 /* Keep stats up to date */ 929 /* Keep stats up to date */
930 self->stats.rx_bytes += len; 930 self->stats.rx_bytes += len;
931 self->stats.rx_packets++; 931 self->stats.rx_packets++;
932 self->netdev->last_rx = jiffies;
933 932
934done: 933done:
935 /* Note : at this point, the URB we've just received (urb) 934 /* Note : at this point, the URB we've just received (urb)
@@ -1175,7 +1174,7 @@ static int irda_usb_net_open(struct net_device *netdev)
1175 IRDA_DEBUG(1, "%s()\n", __func__); 1174 IRDA_DEBUG(1, "%s()\n", __func__);
1176 1175
1177 IRDA_ASSERT(netdev != NULL, return -1;); 1176 IRDA_ASSERT(netdev != NULL, return -1;);
1178 self = (struct irda_usb_cb *) netdev->priv; 1177 self = netdev_priv(netdev);
1179 IRDA_ASSERT(self != NULL, return -1;); 1178 IRDA_ASSERT(self != NULL, return -1;);
1180 1179
1181 spin_lock_irqsave(&self->lock, flags); 1180 spin_lock_irqsave(&self->lock, flags);
@@ -1257,7 +1256,7 @@ static int irda_usb_net_close(struct net_device *netdev)
1257 IRDA_DEBUG(1, "%s()\n", __func__); 1256 IRDA_DEBUG(1, "%s()\n", __func__);
1258 1257
1259 IRDA_ASSERT(netdev != NULL, return -1;); 1258 IRDA_ASSERT(netdev != NULL, return -1;);
1260 self = (struct irda_usb_cb *) netdev->priv; 1259 self = netdev_priv(netdev);
1261 IRDA_ASSERT(self != NULL, return -1;); 1260 IRDA_ASSERT(self != NULL, return -1;);
1262 1261
1263 /* Clear this flag *before* unlinking the urbs and *before* 1262 /* Clear this flag *before* unlinking the urbs and *before*
@@ -1306,7 +1305,7 @@ static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1306 int ret = 0; 1305 int ret = 0;
1307 1306
1308 IRDA_ASSERT(dev != NULL, return -1;); 1307 IRDA_ASSERT(dev != NULL, return -1;);
1309 self = dev->priv; 1308 self = netdev_priv(dev);
1310 IRDA_ASSERT(self != NULL, return -1;); 1309 IRDA_ASSERT(self != NULL, return -1;);
1311 1310
1312 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name, cmd); 1311 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name, cmd);
@@ -1348,7 +1347,7 @@ static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1348 */ 1347 */
1349static struct net_device_stats *irda_usb_net_get_stats(struct net_device *dev) 1348static struct net_device_stats *irda_usb_net_get_stats(struct net_device *dev)
1350{ 1349{
1351 struct irda_usb_cb *self = dev->priv; 1350 struct irda_usb_cb *self = netdev_priv(dev);
1352 return &self->stats; 1351 return &self->stats;
1353} 1352}
1354 1353
@@ -1641,7 +1640,7 @@ static int irda_usb_probe(struct usb_interface *intf,
1641 goto err_out; 1640 goto err_out;
1642 1641
1643 SET_NETDEV_DEV(net, &intf->dev); 1642 SET_NETDEV_DEV(net, &intf->dev);
1644 self = net->priv; 1643 self = netdev_priv(net);
1645 self->netdev = net; 1644 self->netdev = net;
1646 spin_lock_init(&self->lock); 1645 spin_lock_init(&self->lock);
1647 init_timer(&self->rx_defer_timer); 1646 init_timer(&self->rx_defer_timer);
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c
index e1429fc6d050..c747c874d44d 100644
--- a/drivers/net/irda/kingsun-sir.c
+++ b/drivers/net/irda/kingsun-sir.c
@@ -235,7 +235,6 @@ static void kingsun_rcv_irq(struct urb *urb)
235 &kingsun->stats, 235 &kingsun->stats,
236 &kingsun->rx_buff, bytes[i]); 236 &kingsun->rx_buff, bytes[i]);
237 } 237 }
238 kingsun->netdev->last_rx = jiffies;
239 do_gettimeofday(&kingsun->rx_time); 238 do_gettimeofday(&kingsun->rx_time);
240 kingsun->receiving = 239 kingsun->receiving =
241 (kingsun->rx_buff.state != OUTSIDE_FRAME) 240 (kingsun->rx_buff.state != OUTSIDE_FRAME)
diff --git a/drivers/net/irda/ks959-sir.c b/drivers/net/irda/ks959-sir.c
index 2e67ae015d91..600d96f9cdb7 100644
--- a/drivers/net/irda/ks959-sir.c
+++ b/drivers/net/irda/ks959-sir.c
@@ -474,7 +474,6 @@ static void ks959_rcv_irq(struct urb *urb)
474 bytes[i]); 474 bytes[i]);
475 } 475 }
476 } 476 }
477 kingsun->netdev->last_rx = jiffies;
478 do_gettimeofday(&kingsun->rx_time); 477 do_gettimeofday(&kingsun->rx_time);
479 kingsun->receiving = 478 kingsun->receiving =
480 (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0; 479 (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0;
diff --git a/drivers/net/irda/ksdazzle-sir.c b/drivers/net/irda/ksdazzle-sir.c
index 3843b5faba8b..0e7f89337b25 100644
--- a/drivers/net/irda/ksdazzle-sir.c
+++ b/drivers/net/irda/ksdazzle-sir.c
@@ -371,7 +371,6 @@ static void ksdazzle_rcv_irq(struct urb *urb)
371 async_unwrap_char(kingsun->netdev, &kingsun->stats, 371 async_unwrap_char(kingsun->netdev, &kingsun->stats,
372 &kingsun->rx_unwrap_buff, bytes[i]); 372 &kingsun->rx_unwrap_buff, bytes[i]);
373 } 373 }
374 kingsun->netdev->last_rx = jiffies;
375 kingsun->receiving = 374 kingsun->receiving =
376 (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0; 375 (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0;
377 } 376 }
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index ad92d3ff1c40..904c9610c0dd 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -806,7 +806,6 @@ static void mcs_receive_irq(struct urb *urb)
806 mcs_unwrap_fir(mcs, urb->transfer_buffer, 806 mcs_unwrap_fir(mcs, urb->transfer_buffer,
807 urb->actual_length); 807 urb->actual_length);
808 } 808 }
809 mcs->netdev->last_rx = jiffies;
810 do_gettimeofday(&mcs->rx_time); 809 do_gettimeofday(&mcs->rx_time);
811 } 810 }
812 811
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index 8583d951a6ad..2c6bf2d11bb1 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -373,7 +373,7 @@ static int __init nsc_ircc_open(chipio_t *info)
373 return -ENOMEM; 373 return -ENOMEM;
374 } 374 }
375 375
376 self = dev->priv; 376 self = netdev_priv(dev);
377 self->netdev = dev; 377 self->netdev = dev;
378 spin_lock_init(&self->lock); 378 spin_lock_init(&self->lock);
379 379
@@ -1354,7 +1354,7 @@ static int nsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
1354 __s32 speed; 1354 __s32 speed;
1355 __u8 bank; 1355 __u8 bank;
1356 1356
1357 self = (struct nsc_ircc_cb *) dev->priv; 1357 self = netdev_priv(dev);
1358 1358
1359 IRDA_ASSERT(self != NULL, return 0;); 1359 IRDA_ASSERT(self != NULL, return 0;);
1360 1360
@@ -1427,7 +1427,7 @@ static int nsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev)
1427 __u8 bank; 1427 __u8 bank;
1428 int mtt, diff; 1428 int mtt, diff;
1429 1429
1430 self = (struct nsc_ircc_cb *) dev->priv; 1430 self = netdev_priv(dev);
1431 iobase = self->io.fir_base; 1431 iobase = self->io.fir_base;
1432 1432
1433 netif_stop_queue(dev); 1433 netif_stop_queue(dev);
@@ -1896,7 +1896,6 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
1896 skb_reset_mac_header(skb); 1896 skb_reset_mac_header(skb);
1897 skb->protocol = htons(ETH_P_IRDA); 1897 skb->protocol = htons(ETH_P_IRDA);
1898 netif_rx(skb); 1898 netif_rx(skb);
1899 self->netdev->last_rx = jiffies;
1900 } 1899 }
1901 } 1900 }
1902 /* Restore bank register */ 1901 /* Restore bank register */
@@ -2085,7 +2084,7 @@ static irqreturn_t nsc_ircc_interrupt(int irq, void *dev_id)
2085 __u8 bsr, eir; 2084 __u8 bsr, eir;
2086 int iobase; 2085 int iobase;
2087 2086
2088 self = dev->priv; 2087 self = netdev_priv(dev);
2089 2088
2090 spin_lock(&self->lock); 2089 spin_lock(&self->lock);
2091 2090
@@ -2166,7 +2165,7 @@ static int nsc_ircc_net_open(struct net_device *dev)
2166 IRDA_DEBUG(4, "%s()\n", __func__); 2165 IRDA_DEBUG(4, "%s()\n", __func__);
2167 2166
2168 IRDA_ASSERT(dev != NULL, return -1;); 2167 IRDA_ASSERT(dev != NULL, return -1;);
2169 self = (struct nsc_ircc_cb *) dev->priv; 2168 self = netdev_priv(dev);
2170 2169
2171 IRDA_ASSERT(self != NULL, return 0;); 2170 IRDA_ASSERT(self != NULL, return 0;);
2172 2171
@@ -2229,7 +2228,7 @@ static int nsc_ircc_net_close(struct net_device *dev)
2229 2228
2230 IRDA_ASSERT(dev != NULL, return -1;); 2229 IRDA_ASSERT(dev != NULL, return -1;);
2231 2230
2232 self = (struct nsc_ircc_cb *) dev->priv; 2231 self = netdev_priv(dev);
2233 IRDA_ASSERT(self != NULL, return 0;); 2232 IRDA_ASSERT(self != NULL, return 0;);
2234 2233
2235 /* Stop device */ 2234 /* Stop device */
@@ -2275,7 +2274,7 @@ static int nsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2275 2274
2276 IRDA_ASSERT(dev != NULL, return -1;); 2275 IRDA_ASSERT(dev != NULL, return -1;);
2277 2276
2278 self = dev->priv; 2277 self = netdev_priv(dev);
2279 2278
2280 IRDA_ASSERT(self != NULL, return -1;); 2279 IRDA_ASSERT(self != NULL, return -1;);
2281 2280
@@ -2310,7 +2309,7 @@ static int nsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2310 2309
2311static struct net_device_stats *nsc_ircc_net_get_stats(struct net_device *dev) 2310static struct net_device_stats *nsc_ircc_net_get_stats(struct net_device *dev)
2312{ 2311{
2313 struct nsc_ircc_cb *self = (struct nsc_ircc_cb *) dev->priv; 2312 struct nsc_ircc_cb *self = netdev_priv(dev);
2314 2313
2315 return &self->stats; 2314 return &self->stats;
2316} 2315}
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index c5b02b66f756..a0ee05318155 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -225,7 +225,6 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
225 } 225 }
226 lsr = STLSR; 226 lsr = STLSR;
227 } 227 }
228 dev->last_rx = jiffies;
229 si->last_oscr = OSCR; 228 si->last_oscr = OSCR;
230 break; 229 break;
231 230
@@ -237,7 +236,6 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
237 si->stats.rx_bytes++; 236 si->stats.rx_bytes++;
238 async_unwrap_char(dev, &si->stats, &si->rx_buff, STRBR); 237 async_unwrap_char(dev, &si->stats, &si->rx_buff, STRBR);
239 } while (STLSR & LSR_DR); 238 } while (STLSR & LSR_DR);
240 dev->last_rx = jiffies;
241 si->last_oscr = OSCR; 239 si->last_oscr = OSCR;
242 break; 240 break;
243 241
@@ -397,8 +395,6 @@ static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev, in
397 395
398 si->stats.rx_packets++; 396 si->stats.rx_packets++;
399 si->stats.rx_bytes += len; 397 si->stats.rx_bytes += len;
400
401 dev->last_rx = jiffies;
402 } 398 }
403} 399}
404 400
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index a95188948de7..ccde5829ba21 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -298,7 +298,7 @@ static int sa1100_irda_suspend(struct platform_device *pdev, pm_message_t state)
298 if (!dev) 298 if (!dev)
299 return 0; 299 return 0;
300 300
301 si = dev->priv; 301 si = netdev_priv(dev);
302 if (si->open) { 302 if (si->open) {
303 /* 303 /*
304 * Stop the transmit queue 304 * Stop the transmit queue
@@ -323,7 +323,7 @@ static int sa1100_irda_resume(struct platform_device *pdev)
323 if (!dev) 323 if (!dev)
324 return 0; 324 return 0;
325 325
326 si = dev->priv; 326 si = netdev_priv(dev);
327 if (si->open) { 327 if (si->open) {
328 /* 328 /*
329 * If we missed a speed change, initialise at the new speed 329 * If we missed a speed change, initialise at the new speed
@@ -359,7 +359,7 @@ static int sa1100_irda_resume(struct platform_device *pdev)
359 */ 359 */
360static void sa1100_irda_hpsir_irq(struct net_device *dev) 360static void sa1100_irda_hpsir_irq(struct net_device *dev)
361{ 361{
362 struct sa1100_irda *si = dev->priv; 362 struct sa1100_irda *si = netdev_priv(dev);
363 int status; 363 int status;
364 364
365 status = Ser2UTSR0; 365 status = Ser2UTSR0;
@@ -410,7 +410,6 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
410 Ser2UTDR); 410 Ser2UTDR);
411 } while (Ser2UTSR1 & UTSR1_RNE); 411 } while (Ser2UTSR1 & UTSR1_RNE);
412 412
413 dev->last_rx = jiffies;
414 } 413 }
415 414
416 if (status & UTSR0_TFS && si->tx_buff.len) { 415 if (status & UTSR0_TFS && si->tx_buff.len) {
@@ -515,7 +514,6 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
515 sa1100_irda_rx_alloc(si); 514 sa1100_irda_rx_alloc(si);
516 515
517 netif_rx(skb); 516 netif_rx(skb);
518 dev->last_rx = jiffies;
519 } else { 517 } else {
520 /* 518 /*
521 * Remap the buffer. 519 * Remap the buffer.
@@ -534,7 +532,7 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
534 */ 532 */
535static void sa1100_irda_fir_irq(struct net_device *dev) 533static void sa1100_irda_fir_irq(struct net_device *dev)
536{ 534{
537 struct sa1100_irda *si = dev->priv; 535 struct sa1100_irda *si = netdev_priv(dev);
538 536
539 /* 537 /*
540 * Stop RX DMA 538 * Stop RX DMA
@@ -582,7 +580,7 @@ static void sa1100_irda_fir_irq(struct net_device *dev)
582static irqreturn_t sa1100_irda_irq(int irq, void *dev_id) 580static irqreturn_t sa1100_irda_irq(int irq, void *dev_id)
583{ 581{
584 struct net_device *dev = dev_id; 582 struct net_device *dev = dev_id;
585 if (IS_FIR(((struct sa1100_irda *)dev->priv))) 583 if (IS_FIR(((struct sa1100_irda *)netdev_priv(dev))))
586 sa1100_irda_fir_irq(dev); 584 sa1100_irda_fir_irq(dev);
587 else 585 else
588 sa1100_irda_hpsir_irq(dev); 586 sa1100_irda_hpsir_irq(dev);
@@ -595,7 +593,7 @@ static irqreturn_t sa1100_irda_irq(int irq, void *dev_id)
595static void sa1100_irda_txdma_irq(void *id) 593static void sa1100_irda_txdma_irq(void *id)
596{ 594{
597 struct net_device *dev = id; 595 struct net_device *dev = id;
598 struct sa1100_irda *si = dev->priv; 596 struct sa1100_irda *si = netdev_priv(dev);
599 struct sk_buff *skb = si->txskb; 597 struct sk_buff *skb = si->txskb;
600 598
601 si->txskb = NULL; 599 si->txskb = NULL;
@@ -649,7 +647,7 @@ static void sa1100_irda_txdma_irq(void *id)
649 647
650static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) 648static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
651{ 649{
652 struct sa1100_irda *si = dev->priv; 650 struct sa1100_irda *si = netdev_priv(dev);
653 int speed = irda_get_next_speed(skb); 651 int speed = irda_get_next_speed(skb);
654 652
655 /* 653 /*
@@ -724,7 +722,7 @@ static int
724sa1100_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd) 722sa1100_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
725{ 723{
726 struct if_irda_req *rq = (struct if_irda_req *)ifreq; 724 struct if_irda_req *rq = (struct if_irda_req *)ifreq;
727 struct sa1100_irda *si = dev->priv; 725 struct sa1100_irda *si = netdev_priv(dev);
728 int ret = -EOPNOTSUPP; 726 int ret = -EOPNOTSUPP;
729 727
730 switch (cmd) { 728 switch (cmd) {
@@ -766,13 +764,13 @@ sa1100_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
766 764
767static struct net_device_stats *sa1100_irda_stats(struct net_device *dev) 765static struct net_device_stats *sa1100_irda_stats(struct net_device *dev)
768{ 766{
769 struct sa1100_irda *si = dev->priv; 767 struct sa1100_irda *si = netdev_priv(dev);
770 return &si->stats; 768 return &si->stats;
771} 769}
772 770
773static int sa1100_irda_start(struct net_device *dev) 771static int sa1100_irda_start(struct net_device *dev)
774{ 772{
775 struct sa1100_irda *si = dev->priv; 773 struct sa1100_irda *si = netdev_priv(dev);
776 int err; 774 int err;
777 775
778 si->speed = 9600; 776 si->speed = 9600;
@@ -835,7 +833,7 @@ err_irq:
835 833
836static int sa1100_irda_stop(struct net_device *dev) 834static int sa1100_irda_stop(struct net_device *dev)
837{ 835{
838 struct sa1100_irda *si = dev->priv; 836 struct sa1100_irda *si = netdev_priv(dev);
839 837
840 disable_irq(dev->irq); 838 disable_irq(dev->irq);
841 sa1100_irda_shutdown(si); 839 sa1100_irda_shutdown(si);
@@ -908,7 +906,7 @@ static int sa1100_irda_probe(struct platform_device *pdev)
908 if (!dev) 906 if (!dev)
909 goto err_mem_4; 907 goto err_mem_4;
910 908
911 si = dev->priv; 909 si = netdev_priv(dev);
912 si->dev = &pdev->dev; 910 si->dev = &pdev->dev;
913 si->pdata = pdev->dev.platform_data; 911 si->pdata = pdev->dev.platform_data;
914 912
@@ -987,7 +985,7 @@ static int sa1100_irda_remove(struct platform_device *pdev)
987 struct net_device *dev = platform_get_drvdata(pdev); 985 struct net_device *dev = platform_get_drvdata(pdev);
988 986
989 if (dev) { 987 if (dev) {
990 struct sa1100_irda *si = dev->priv; 988 struct sa1100_irda *si = netdev_priv(dev);
991 unregister_netdev(dev); 989 unregister_netdev(dev);
992 kfree(si->tx_buff.head); 990 kfree(si->tx_buff.head);
993 kfree(si->rx_buff.head); 991 kfree(si->rx_buff.head);
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 3f32909c24c8..ceef040aa76d 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -584,14 +584,14 @@ EXPORT_SYMBOL(sirdev_receive);
584 584
585static struct net_device_stats *sirdev_get_stats(struct net_device *ndev) 585static struct net_device_stats *sirdev_get_stats(struct net_device *ndev)
586{ 586{
587 struct sir_dev *dev = ndev->priv; 587 struct sir_dev *dev = netdev_priv(ndev);
588 588
589 return (dev) ? &dev->stats : NULL; 589 return (dev) ? &dev->stats : NULL;
590} 590}
591 591
592static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev) 592static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
593{ 593{
594 struct sir_dev *dev = ndev->priv; 594 struct sir_dev *dev = netdev_priv(ndev);
595 unsigned long flags; 595 unsigned long flags;
596 int actual = 0; 596 int actual = 0;
597 int err; 597 int err;
@@ -683,7 +683,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
683static int sirdev_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) 683static int sirdev_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
684{ 684{
685 struct if_irda_req *irq = (struct if_irda_req *) rq; 685 struct if_irda_req *irq = (struct if_irda_req *) rq;
686 struct sir_dev *dev = ndev->priv; 686 struct sir_dev *dev = netdev_priv(ndev);
687 int ret = 0; 687 int ret = 0;
688 688
689 IRDA_ASSERT(dev != NULL, return -1;); 689 IRDA_ASSERT(dev != NULL, return -1;);
@@ -795,7 +795,7 @@ static void sirdev_free_buffers(struct sir_dev *dev)
795 795
796static int sirdev_open(struct net_device *ndev) 796static int sirdev_open(struct net_device *ndev)
797{ 797{
798 struct sir_dev *dev = ndev->priv; 798 struct sir_dev *dev = netdev_priv(ndev);
799 const struct sir_driver *drv = dev->drv; 799 const struct sir_driver *drv = dev->drv;
800 800
801 if (!drv) 801 if (!drv)
@@ -840,7 +840,7 @@ errout_dec:
840 840
841static int sirdev_close(struct net_device *ndev) 841static int sirdev_close(struct net_device *ndev)
842{ 842{
843 struct sir_dev *dev = ndev->priv; 843 struct sir_dev *dev = netdev_priv(ndev);
844 const struct sir_driver *drv; 844 const struct sir_driver *drv;
845 845
846// IRDA_DEBUG(0, "%s\n", __func__); 846// IRDA_DEBUG(0, "%s\n", __func__);
@@ -896,7 +896,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
896 IRDA_ERROR("%s - Can't allocate memory for IrDA control block!\n", __func__); 896 IRDA_ERROR("%s - Can't allocate memory for IrDA control block!\n", __func__);
897 goto out; 897 goto out;
898 } 898 }
899 dev = ndev->priv; 899 dev = netdev_priv(ndev);
900 900
901 irda_init_max_qos_capabilies(&dev->qos); 901 irda_init_max_qos_capabilies(&dev->qos);
902 dev->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|IR_115200; 902 dev->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 3575804fd7c6..ca4cd9266e55 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -824,7 +824,6 @@ static void stir_rcv_irq(struct urb *urb)
824 unwrap_chars(stir, urb->transfer_buffer, 824 unwrap_chars(stir, urb->transfer_buffer,
825 urb->actual_length); 825 urb->actual_length);
826 826
827 stir->netdev->last_rx = jiffies;
828 do_gettimeofday(&stir->rx_time); 827 do_gettimeofday(&stir->rx_time);
829 } 828 }
830 829
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 84e609ea5fbb..74c78cf7a333 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -334,7 +334,7 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
334 if (dev == NULL) 334 if (dev == NULL)
335 return -ENOMEM; 335 return -ENOMEM;
336 336
337 self = dev->priv; 337 self = netdev_priv(dev);
338 self->netdev = dev; 338 self->netdev = dev;
339 spin_lock_init(&self->lock); 339 spin_lock_init(&self->lock);
340 340
@@ -824,7 +824,7 @@ static int via_ircc_hard_xmit_sir(struct sk_buff *skb,
824 u16 iobase; 824 u16 iobase;
825 __u32 speed; 825 __u32 speed;
826 826
827 self = (struct via_ircc_cb *) dev->priv; 827 self = netdev_priv(dev);
828 IRDA_ASSERT(self != NULL, return 0;); 828 IRDA_ASSERT(self != NULL, return 0;);
829 iobase = self->io.fir_base; 829 iobase = self->io.fir_base;
830 830
@@ -896,7 +896,7 @@ static int via_ircc_hard_xmit_fir(struct sk_buff *skb,
896 __u32 speed; 896 __u32 speed;
897 unsigned long flags; 897 unsigned long flags;
898 898
899 self = (struct via_ircc_cb *) dev->priv; 899 self = netdev_priv(dev);
900 iobase = self->io.fir_base; 900 iobase = self->io.fir_base;
901 901
902 if (self->st_fifo.len) 902 if (self->st_fifo.len)
@@ -1349,7 +1349,7 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
1349static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id) 1349static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id)
1350{ 1350{
1351 struct net_device *dev = dev_id; 1351 struct net_device *dev = dev_id;
1352 struct via_ircc_cb *self = dev->priv; 1352 struct via_ircc_cb *self = netdev_priv(dev);
1353 int iobase; 1353 int iobase;
1354 u8 iHostIntType, iRxIntType, iTxIntType; 1354 u8 iHostIntType, iRxIntType, iTxIntType;
1355 1355
@@ -1522,7 +1522,7 @@ static int via_ircc_net_open(struct net_device *dev)
1522 IRDA_DEBUG(3, "%s()\n", __func__); 1522 IRDA_DEBUG(3, "%s()\n", __func__);
1523 1523
1524 IRDA_ASSERT(dev != NULL, return -1;); 1524 IRDA_ASSERT(dev != NULL, return -1;);
1525 self = (struct via_ircc_cb *) dev->priv; 1525 self = netdev_priv(dev);
1526 self->stats.rx_packets = 0; 1526 self->stats.rx_packets = 0;
1527 IRDA_ASSERT(self != NULL, return 0;); 1527 IRDA_ASSERT(self != NULL, return 0;);
1528 iobase = self->io.fir_base; 1528 iobase = self->io.fir_base;
@@ -1589,7 +1589,7 @@ static int via_ircc_net_close(struct net_device *dev)
1589 IRDA_DEBUG(3, "%s()\n", __func__); 1589 IRDA_DEBUG(3, "%s()\n", __func__);
1590 1590
1591 IRDA_ASSERT(dev != NULL, return -1;); 1591 IRDA_ASSERT(dev != NULL, return -1;);
1592 self = (struct via_ircc_cb *) dev->priv; 1592 self = netdev_priv(dev);
1593 IRDA_ASSERT(self != NULL, return 0;); 1593 IRDA_ASSERT(self != NULL, return 0;);
1594 1594
1595 /* Stop device */ 1595 /* Stop device */
@@ -1628,7 +1628,7 @@ static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
1628 int ret = 0; 1628 int ret = 0;
1629 1629
1630 IRDA_ASSERT(dev != NULL, return -1;); 1630 IRDA_ASSERT(dev != NULL, return -1;);
1631 self = dev->priv; 1631 self = netdev_priv(dev);
1632 IRDA_ASSERT(self != NULL, return -1;); 1632 IRDA_ASSERT(self != NULL, return -1;);
1633 IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name, 1633 IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name,
1634 cmd); 1634 cmd);
@@ -1663,7 +1663,7 @@ static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
1663static struct net_device_stats *via_ircc_net_get_stats(struct net_device 1663static struct net_device_stats *via_ircc_net_get_stats(struct net_device
1664 *dev) 1664 *dev)
1665{ 1665{
1666 struct via_ircc_cb *self = (struct via_ircc_cb *) dev->priv; 1666 struct via_ircc_cb *self = netdev_priv(dev);
1667 1667
1668 return &self->stats; 1668 return &self->stats;
1669} 1669}
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 9c926d205de9..0d30f8d659a1 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -178,7 +178,7 @@ static void vlsi_proc_pdev(struct seq_file *seq, struct pci_dev *pdev)
178 178
179static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev) 179static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev)
180{ 180{
181 vlsi_irda_dev_t *idev = ndev->priv; 181 vlsi_irda_dev_t *idev = netdev_priv(ndev);
182 u8 byte; 182 u8 byte;
183 u16 word; 183 u16 word;
184 unsigned delta1, delta2; 184 unsigned delta1, delta2;
@@ -346,7 +346,7 @@ static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r)
346static int vlsi_seq_show(struct seq_file *seq, void *v) 346static int vlsi_seq_show(struct seq_file *seq, void *v)
347{ 347{
348 struct net_device *ndev = seq->private; 348 struct net_device *ndev = seq->private;
349 vlsi_irda_dev_t *idev = ndev->priv; 349 vlsi_irda_dev_t *idev = netdev_priv(ndev);
350 unsigned long flags; 350 unsigned long flags;
351 351
352 seq_printf(seq, "\n%s %s\n\n", DRIVER_NAME, DRIVER_VERSION); 352 seq_printf(seq, "\n%s %s\n\n", DRIVER_NAME, DRIVER_VERSION);
@@ -543,7 +543,7 @@ static int vlsi_process_rx(struct vlsi_ring *r, struct ring_descr *rd)
543 struct sk_buff *skb; 543 struct sk_buff *skb;
544 int ret = 0; 544 int ret = 0;
545 struct net_device *ndev = (struct net_device *)pci_get_drvdata(r->pdev); 545 struct net_device *ndev = (struct net_device *)pci_get_drvdata(r->pdev);
546 vlsi_irda_dev_t *idev = ndev->priv; 546 vlsi_irda_dev_t *idev = netdev_priv(ndev);
547 547
548 pci_dma_sync_single_for_cpu(r->pdev, rd_get_addr(rd), r->len, r->dir); 548 pci_dma_sync_single_for_cpu(r->pdev, rd_get_addr(rd), r->len, r->dir);
549 /* dma buffer now owned by the CPU */ 549 /* dma buffer now owned by the CPU */
@@ -600,7 +600,6 @@ static int vlsi_process_rx(struct vlsi_ring *r, struct ring_descr *rd)
600 netif_rx(skb); 600 netif_rx(skb);
601 else 601 else
602 netif_rx_ni(skb); 602 netif_rx_ni(skb);
603 ndev->last_rx = jiffies;
604 603
605done: 604done:
606 rd_set_status(rd, 0); 605 rd_set_status(rd, 0);
@@ -638,7 +637,7 @@ static void vlsi_fill_rx(struct vlsi_ring *r)
638 637
639static void vlsi_rx_interrupt(struct net_device *ndev) 638static void vlsi_rx_interrupt(struct net_device *ndev)
640{ 639{
641 vlsi_irda_dev_t *idev = ndev->priv; 640 vlsi_irda_dev_t *idev = netdev_priv(ndev);
642 struct vlsi_ring *r = idev->rx_ring; 641 struct vlsi_ring *r = idev->rx_ring;
643 struct ring_descr *rd; 642 struct ring_descr *rd;
644 int ret; 643 int ret;
@@ -856,7 +855,7 @@ static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
856 855
857static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) 856static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
858{ 857{
859 vlsi_irda_dev_t *idev = ndev->priv; 858 vlsi_irda_dev_t *idev = netdev_priv(ndev);
860 struct vlsi_ring *r = idev->tx_ring; 859 struct vlsi_ring *r = idev->tx_ring;
861 struct ring_descr *rd; 860 struct ring_descr *rd;
862 unsigned long flags; 861 unsigned long flags;
@@ -1063,7 +1062,7 @@ drop:
1063 1062
1064static void vlsi_tx_interrupt(struct net_device *ndev) 1063static void vlsi_tx_interrupt(struct net_device *ndev)
1065{ 1064{
1066 vlsi_irda_dev_t *idev = ndev->priv; 1065 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1067 struct vlsi_ring *r = idev->tx_ring; 1066 struct vlsi_ring *r = idev->tx_ring;
1068 struct ring_descr *rd; 1067 struct ring_descr *rd;
1069 unsigned iobase; 1068 unsigned iobase;
@@ -1262,7 +1261,7 @@ static inline void vlsi_clear_regs(unsigned iobase)
1262static int vlsi_init_chip(struct pci_dev *pdev) 1261static int vlsi_init_chip(struct pci_dev *pdev)
1263{ 1262{
1264 struct net_device *ndev = pci_get_drvdata(pdev); 1263 struct net_device *ndev = pci_get_drvdata(pdev);
1265 vlsi_irda_dev_t *idev = ndev->priv; 1264 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1266 unsigned iobase; 1265 unsigned iobase;
1267 u16 ptr; 1266 u16 ptr;
1268 1267
@@ -1376,14 +1375,14 @@ static int vlsi_stop_hw(vlsi_irda_dev_t *idev)
1376 1375
1377static struct net_device_stats * vlsi_get_stats(struct net_device *ndev) 1376static struct net_device_stats * vlsi_get_stats(struct net_device *ndev)
1378{ 1377{
1379 vlsi_irda_dev_t *idev = ndev->priv; 1378 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1380 1379
1381 return &idev->stats; 1380 return &idev->stats;
1382} 1381}
1383 1382
1384static void vlsi_tx_timeout(struct net_device *ndev) 1383static void vlsi_tx_timeout(struct net_device *ndev)
1385{ 1384{
1386 vlsi_irda_dev_t *idev = ndev->priv; 1385 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1387 1386
1388 1387
1389 vlsi_reg_debug(ndev->base_addr, __func__); 1388 vlsi_reg_debug(ndev->base_addr, __func__);
@@ -1408,7 +1407,7 @@ static void vlsi_tx_timeout(struct net_device *ndev)
1408 1407
1409static int vlsi_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) 1408static int vlsi_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
1410{ 1409{
1411 vlsi_irda_dev_t *idev = ndev->priv; 1410 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1412 struct if_irda_req *irq = (struct if_irda_req *) rq; 1411 struct if_irda_req *irq = (struct if_irda_req *) rq;
1413 unsigned long flags; 1412 unsigned long flags;
1414 u16 fifocnt; 1413 u16 fifocnt;
@@ -1458,7 +1457,7 @@ static int vlsi_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
1458static irqreturn_t vlsi_interrupt(int irq, void *dev_instance) 1457static irqreturn_t vlsi_interrupt(int irq, void *dev_instance)
1459{ 1458{
1460 struct net_device *ndev = dev_instance; 1459 struct net_device *ndev = dev_instance;
1461 vlsi_irda_dev_t *idev = ndev->priv; 1460 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1462 unsigned iobase; 1461 unsigned iobase;
1463 u8 irintr; 1462 u8 irintr;
1464 int boguscount = 5; 1463 int boguscount = 5;
@@ -1499,7 +1498,7 @@ static irqreturn_t vlsi_interrupt(int irq, void *dev_instance)
1499 1498
1500static int vlsi_open(struct net_device *ndev) 1499static int vlsi_open(struct net_device *ndev)
1501{ 1500{
1502 vlsi_irda_dev_t *idev = ndev->priv; 1501 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1503 int err = -EAGAIN; 1502 int err = -EAGAIN;
1504 char hwname[32]; 1503 char hwname[32];
1505 1504
@@ -1558,7 +1557,7 @@ errout:
1558 1557
1559static int vlsi_close(struct net_device *ndev) 1558static int vlsi_close(struct net_device *ndev)
1560{ 1559{
1561 vlsi_irda_dev_t *idev = ndev->priv; 1560 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1562 1561
1563 netif_stop_queue(ndev); 1562 netif_stop_queue(ndev);
1564 1563
@@ -1581,7 +1580,7 @@ static int vlsi_close(struct net_device *ndev)
1581 1580
1582static int vlsi_irda_init(struct net_device *ndev) 1581static int vlsi_irda_init(struct net_device *ndev)
1583{ 1582{
1584 vlsi_irda_dev_t *idev = ndev->priv; 1583 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1585 struct pci_dev *pdev = idev->pdev; 1584 struct pci_dev *pdev = idev->pdev;
1586 1585
1587 ndev->irq = pdev->irq; 1586 ndev->irq = pdev->irq;
@@ -1656,7 +1655,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1656 goto out_disable; 1655 goto out_disable;
1657 } 1656 }
1658 1657
1659 idev = ndev->priv; 1658 idev = netdev_priv(ndev);
1660 1659
1661 spin_lock_init(&idev->lock); 1660 spin_lock_init(&idev->lock);
1662 mutex_init(&idev->mtx); 1661 mutex_init(&idev->mtx);
@@ -1713,7 +1712,7 @@ static void __devexit vlsi_irda_remove(struct pci_dev *pdev)
1713 1712
1714 unregister_netdev(ndev); 1713 unregister_netdev(ndev);
1715 1714
1716 idev = ndev->priv; 1715 idev = netdev_priv(ndev);
1717 mutex_lock(&idev->mtx); 1716 mutex_lock(&idev->mtx);
1718 if (idev->proc_entry) { 1717 if (idev->proc_entry) {
1719 remove_proc_entry(ndev->name, vlsi_proc_root); 1718 remove_proc_entry(ndev->name, vlsi_proc_root);
@@ -1748,7 +1747,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
1748 __func__, pci_name(pdev)); 1747 __func__, pci_name(pdev));
1749 return 0; 1748 return 0;
1750 } 1749 }
1751 idev = ndev->priv; 1750 idev = netdev_priv(ndev);
1752 mutex_lock(&idev->mtx); 1751 mutex_lock(&idev->mtx);
1753 if (pdev->current_state != 0) { /* already suspended */ 1752 if (pdev->current_state != 0) { /* already suspended */
1754 if (state.event > pdev->current_state) { /* simply go deeper */ 1753 if (state.event > pdev->current_state) { /* simply go deeper */
@@ -1787,7 +1786,7 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
1787 __func__, pci_name(pdev)); 1786 __func__, pci_name(pdev));
1788 return 0; 1787 return 0;
1789 } 1788 }
1790 idev = ndev->priv; 1789 idev = netdev_priv(ndev);
1791 mutex_lock(&idev->mtx); 1790 mutex_lock(&idev->mtx);
1792 if (pdev->current_state == 0) { 1791 if (pdev->current_state == 0) {
1793 mutex_unlock(&idev->mtx); 1792 mutex_unlock(&idev->mtx);
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index 002a6d769f21..161d591aeb97 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -178,7 +178,7 @@ int w83977af_open(int i, unsigned int iobase, unsigned int irq,
178 goto err_out; 178 goto err_out;
179 } 179 }
180 180
181 self = dev->priv; 181 self = netdev_priv(dev);
182 spin_lock_init(&self->lock); 182 spin_lock_init(&self->lock);
183 183
184 184
@@ -497,7 +497,7 @@ int w83977af_hard_xmit(struct sk_buff *skb, struct net_device *dev)
497 __u8 set; 497 __u8 set;
498 int mtt; 498 int mtt;
499 499
500 self = (struct w83977af_ir *) dev->priv; 500 self = netdev_priv(dev);
501 501
502 iobase = self->io.fir_base; 502 iobase = self->io.fir_base;
503 503
@@ -923,7 +923,6 @@ int w83977af_dma_receive_complete(struct w83977af_ir *self)
923 skb_reset_mac_header(skb); 923 skb_reset_mac_header(skb);
924 skb->protocol = htons(ETH_P_IRDA); 924 skb->protocol = htons(ETH_P_IRDA);
925 netif_rx(skb); 925 netif_rx(skb);
926 self->netdev->last_rx = jiffies;
927 } 926 }
928 } 927 }
929 /* Restore set register */ 928 /* Restore set register */
@@ -1119,7 +1118,7 @@ static irqreturn_t w83977af_interrupt(int irq, void *dev_id)
1119 __u8 set, icr, isr; 1118 __u8 set, icr, isr;
1120 int iobase; 1119 int iobase;
1121 1120
1122 self = dev->priv; 1121 self = netdev_priv(dev);
1123 1122
1124 iobase = self->io.fir_base; 1123 iobase = self->io.fir_base;
1125 1124
@@ -1192,7 +1191,7 @@ static int w83977af_net_open(struct net_device *dev)
1192 IRDA_DEBUG(0, "%s()\n", __func__ ); 1191 IRDA_DEBUG(0, "%s()\n", __func__ );
1193 1192
1194 IRDA_ASSERT(dev != NULL, return -1;); 1193 IRDA_ASSERT(dev != NULL, return -1;);
1195 self = (struct w83977af_ir *) dev->priv; 1194 self = netdev_priv(dev);
1196 1195
1197 IRDA_ASSERT(self != NULL, return 0;); 1196 IRDA_ASSERT(self != NULL, return 0;);
1198 1197
@@ -1256,7 +1255,7 @@ static int w83977af_net_close(struct net_device *dev)
1256 1255
1257 IRDA_ASSERT(dev != NULL, return -1;); 1256 IRDA_ASSERT(dev != NULL, return -1;);
1258 1257
1259 self = (struct w83977af_ir *) dev->priv; 1258 self = netdev_priv(dev);
1260 1259
1261 IRDA_ASSERT(self != NULL, return 0;); 1260 IRDA_ASSERT(self != NULL, return 0;);
1262 1261
@@ -1303,7 +1302,7 @@ static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1303 1302
1304 IRDA_ASSERT(dev != NULL, return -1;); 1303 IRDA_ASSERT(dev != NULL, return -1;);
1305 1304
1306 self = dev->priv; 1305 self = netdev_priv(dev);
1307 1306
1308 IRDA_ASSERT(self != NULL, return -1;); 1307 IRDA_ASSERT(self != NULL, return -1;);
1309 1308
@@ -1339,7 +1338,7 @@ out:
1339 1338
1340static struct net_device_stats *w83977af_net_get_stats(struct net_device *dev) 1339static struct net_device_stats *w83977af_net_get_stats(struct net_device *dev)
1341{ 1340{
1342 struct w83977af_ir *self = (struct w83977af_ir *) dev->priv; 1341 struct w83977af_ir *self = netdev_priv(dev);
1343 1342
1344 return &self->stats; 1343 return &self->stats;
1345} 1344}
diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c
index d6ff26af37b3..15ebae9b98d4 100644
--- a/drivers/net/isa-skeleton.c
+++ b/drivers/net/isa-skeleton.c
@@ -192,7 +192,6 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr)
192 static unsigned version_printed; 192 static unsigned version_printed;
193 int i; 193 int i;
194 int err = -ENODEV; 194 int err = -ENODEV;
195 DECLARE_MAC_BUF(mac);
196 195
197 /* Grab the region so that no one else tries to probe our ioports. */ 196 /* Grab the region so that no one else tries to probe our ioports. */
198 if (!request_region(ioaddr, NETCARD_IO_EXTENT, cardname)) 197 if (!request_region(ioaddr, NETCARD_IO_EXTENT, cardname))
@@ -220,7 +219,7 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr)
220 for (i = 0; i < 6; i++) 219 for (i = 0; i < 6; i++)
221 dev->dev_addr[i] = inb(ioaddr + i); 220 dev->dev_addr[i] = inb(ioaddr + i);
222 221
223 printk("%s", print_mac(mac, dev->dev_addr)); 222 printk("%pM", dev->dev_addr);
224 223
225 err = -EAGAIN; 224 err = -EAGAIN;
226#ifdef jumpered_interrupts 225#ifdef jumpered_interrupts
@@ -584,7 +583,6 @@ net_rx(struct net_device *dev)
584 insw(ioaddr, skb->data, (pkt_len + 1) >> 1); 583 insw(ioaddr, skb->data, (pkt_len + 1) >> 1);
585 584
586 netif_rx(skb); 585 netif_rx(skb);
587 dev->last_rx = jiffies;
588 lp->stats.rx_packets++; 586 lp->stats.rx_packets++;
589 lp->stats.rx_bytes += pkt_len; 587 lp->stats.rx_bytes += pkt_len;
590 } 588 }
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index c46864d626b2..c7457f97259d 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -952,7 +952,7 @@ static int veth_change_mtu(struct net_device *dev, int new_mtu)
952 952
953static void veth_set_multicast_list(struct net_device *dev) 953static void veth_set_multicast_list(struct net_device *dev)
954{ 954{
955 struct veth_port *port = (struct veth_port *) dev->priv; 955 struct veth_port *port = netdev_priv(dev);
956 unsigned long flags; 956 unsigned long flags;
957 957
958 write_lock_irqsave(&port->mcast_gate, flags); 958 write_lock_irqsave(&port->mcast_gate, flags);
@@ -1044,7 +1044,7 @@ static struct net_device *veth_probe_one(int vlan,
1044 return NULL; 1044 return NULL;
1045 } 1045 }
1046 1046
1047 port = (struct veth_port *) dev->priv; 1047 port = netdev_priv(dev);
1048 1048
1049 spin_lock_init(&port->queue_lock); 1049 spin_lock_init(&port->queue_lock);
1050 rwlock_init(&port->mcast_gate); 1050 rwlock_init(&port->mcast_gate);
@@ -1102,7 +1102,7 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp,
1102 struct net_device *dev) 1102 struct net_device *dev)
1103{ 1103{
1104 struct veth_lpar_connection *cnx = veth_cnx[rlp]; 1104 struct veth_lpar_connection *cnx = veth_cnx[rlp];
1105 struct veth_port *port = (struct veth_port *) dev->priv; 1105 struct veth_port *port = netdev_priv(dev);
1106 HvLpEvent_Rc rc; 1106 HvLpEvent_Rc rc;
1107 struct veth_msg *msg = NULL; 1107 struct veth_msg *msg = NULL;
1108 unsigned long flags; 1108 unsigned long flags;
@@ -1191,7 +1191,7 @@ static void veth_transmit_to_many(struct sk_buff *skb,
1191static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev) 1191static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev)
1192{ 1192{
1193 unsigned char *frame = skb->data; 1193 unsigned char *frame = skb->data;
1194 struct veth_port *port = (struct veth_port *) dev->priv; 1194 struct veth_port *port = netdev_priv(dev);
1195 HvLpIndexMap lpmask; 1195 HvLpIndexMap lpmask;
1196 1196
1197 if (! (frame[0] & 0x01)) { 1197 if (! (frame[0] & 0x01)) {
@@ -1255,7 +1255,7 @@ static void veth_wake_queues(struct veth_lpar_connection *cnx)
1255 if (! dev) 1255 if (! dev)
1256 continue; 1256 continue;
1257 1257
1258 port = (struct veth_port *)dev->priv; 1258 port = netdev_priv(dev);
1259 1259
1260 if (! (port->lpar_map & (1<<cnx->remote_lp))) 1260 if (! (port->lpar_map & (1<<cnx->remote_lp)))
1261 continue; 1261 continue;
@@ -1284,7 +1284,7 @@ static void veth_stop_queues(struct veth_lpar_connection *cnx)
1284 if (! dev) 1284 if (! dev)
1285 continue; 1285 continue;
1286 1286
1287 port = (struct veth_port *)dev->priv; 1287 port = netdev_priv(dev);
1288 1288
1289 /* If this cnx is not on the vlan for this port, continue */ 1289 /* If this cnx is not on the vlan for this port, continue */
1290 if (! (port->lpar_map & (1 << cnx->remote_lp))) 1290 if (! (port->lpar_map & (1 << cnx->remote_lp)))
@@ -1506,7 +1506,7 @@ static void veth_receive(struct veth_lpar_connection *cnx,
1506 continue; 1506 continue;
1507 } 1507 }
1508 1508
1509 port = (struct veth_port *)dev->priv; 1509 port = netdev_priv(dev);
1510 dest = *((u64 *) skb->data) & 0xFFFFFFFFFFFF0000; 1510 dest = *((u64 *) skb->data) & 0xFFFFFFFFFFFF0000;
1511 1511
1512 if ((vlan > HVMAXARCHITECTEDVIRTUALLANS) || !port) { 1512 if ((vlan > HVMAXARCHITECTEDVIRTUALLANS) || !port) {
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index be3c7dc96f63..cb7d1a6d3434 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -381,8 +381,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
381 adapter->hw.back = adapter; 381 adapter->hw.back = adapter;
382 adapter->msg_enable = netif_msg_init(debug, DEFAULT_DEBUG_LEVEL_SHIFT); 382 adapter->msg_enable = netif_msg_init(debug, DEFAULT_DEBUG_LEVEL_SHIFT);
383 383
384 adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, BAR_0), 384 adapter->hw.hw_addr = pci_ioremap_bar(pdev, BAR_0);
385 pci_resource_len(pdev, BAR_0));
386 if (!adapter->hw.hw_addr) { 385 if (!adapter->hw.hw_addr) {
387 err = -EIO; 386 err = -EIO;
388 goto err_ioremap; 387 goto err_ioremap;
@@ -1981,7 +1980,6 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
1981 } else { 1980 } else {
1982 netif_receive_skb(skb); 1981 netif_receive_skb(skb);
1983 } 1982 }
1984 netdev->last_rx = jiffies;
1985 1983
1986rxdesc_done: 1984rxdesc_done:
1987 /* clean up descriptor, might be written over by hw */ 1985 /* clean up descriptor, might be written over by hw */
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index e116d340dcc6..132854f646ba 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -267,6 +267,7 @@ struct ixgbe_adapter {
267#define IXGBE_FLAG_RSS_CAPABLE (u32)(1 << 17) 267#define IXGBE_FLAG_RSS_CAPABLE (u32)(1 << 17)
268#define IXGBE_FLAG_VMDQ_CAPABLE (u32)(1 << 18) 268#define IXGBE_FLAG_VMDQ_CAPABLE (u32)(1 << 18)
269#define IXGBE_FLAG_VMDQ_ENABLED (u32)(1 << 19) 269#define IXGBE_FLAG_VMDQ_ENABLED (u32)(1 << 19)
270#define IXGBE_FLAG_FAN_FAIL_CAPABLE (u32)(1 << 20)
270#define IXGBE_FLAG_NEED_LINK_UPDATE (u32)(1 << 22) 271#define IXGBE_FLAG_NEED_LINK_UPDATE (u32)(1 << 22)
271#define IXGBE_FLAG_IN_WATCHDOG_TASK (u32)(1 << 23) 272#define IXGBE_FLAG_IN_WATCHDOG_TASK (u32)(1 << 23)
272 273
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 7cddcfba809e..c2cdb042c481 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -59,6 +59,11 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
59 59
60 /* PHY Init */ 60 /* PHY Init */
61 switch (phy->type) { 61 switch (phy->type) {
62 case ixgbe_phy_tn:
63 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
64 phy->ops.get_firmware_version =
65 &ixgbe_get_phy_firmware_version_tnx;
66 break;
62 default: 67 default:
63 break; 68 break;
64 } 69 }
@@ -189,6 +194,9 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
189 case IXGBE_DEV_ID_82598EB_XF_LR: 194 case IXGBE_DEV_ID_82598EB_XF_LR:
190 media_type = ixgbe_media_type_fiber; 195 media_type = ixgbe_media_type_fiber;
191 break; 196 break;
197 case IXGBE_DEV_ID_82598AT:
198 media_type = ixgbe_media_type_copper;
199 break;
192 default: 200 default:
193 media_type = ixgbe_media_type_unknown; 201 media_type = ixgbe_media_type_unknown;
194 break; 202 break;
@@ -872,6 +880,10 @@ s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
872 case IXGBE_DEV_ID_82598EB_XF_LR: 880 case IXGBE_DEV_ID_82598EB_XF_LR:
873 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR; 881 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
874 break; 882 break;
883 case IXGBE_DEV_ID_82598AT:
884 physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_T |
885 IXGBE_PHYSICAL_LAYER_1000BASE_T);
886 break;
875 887
876 default: 888 default:
877 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; 889 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 81a9c4b86726..a610016a0172 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -94,9 +94,9 @@ static struct ixgbe_stats ixgbe_gstrings_stats[] = {
94}; 94};
95 95
96#define IXGBE_QUEUE_STATS_LEN \ 96#define IXGBE_QUEUE_STATS_LEN \
97 ((((struct ixgbe_adapter *)netdev->priv)->num_tx_queues + \ 97 ((((struct ixgbe_adapter *)netdev_priv(netdev))->num_tx_queues + \
98 ((struct ixgbe_adapter *)netdev->priv)->num_rx_queues) * \ 98 ((struct ixgbe_adapter *)netdev_priv(netdev))->num_rx_queues) * \
99 (sizeof(struct ixgbe_queue_stats) / sizeof(u64))) 99 (sizeof(struct ixgbe_queue_stats) / sizeof(u64)))
100#define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + IXGBE_QUEUE_STATS_LEN) 100#define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + IXGBE_QUEUE_STATS_LEN)
101#define IXGBE_GLOBAL_STATS_LEN ARRAY_SIZE(ixgbe_gstrings_stats) 101#define IXGBE_GLOBAL_STATS_LEN ARRAY_SIZE(ixgbe_gstrings_stats)
102#define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + IXGBE_QUEUE_STATS_LEN) 102#define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + IXGBE_QUEUE_STATS_LEN)
@@ -149,6 +149,8 @@ static int ixgbe_set_settings(struct net_device *netdev,
149{ 149{
150 struct ixgbe_adapter *adapter = netdev_priv(netdev); 150 struct ixgbe_adapter *adapter = netdev_priv(netdev);
151 struct ixgbe_hw *hw = &adapter->hw; 151 struct ixgbe_hw *hw = &adapter->hw;
152 u32 advertised, old;
153 s32 err;
152 154
153 switch (hw->phy.media_type) { 155 switch (hw->phy.media_type) {
154 case ixgbe_media_type_fiber: 156 case ixgbe_media_type_fiber:
@@ -157,6 +159,31 @@ static int ixgbe_set_settings(struct net_device *netdev,
157 return -EINVAL; 159 return -EINVAL;
158 /* in this case we currently only support 10Gb/FULL */ 160 /* in this case we currently only support 10Gb/FULL */
159 break; 161 break;
162 case ixgbe_media_type_copper:
163 /* 10000/copper and 1000/copper must autoneg
164 * this function does not support any duplex forcing, but can
165 * limit the advertising of the adapter to only 10000 or 1000 */
166 if (ecmd->autoneg == AUTONEG_DISABLE)
167 return -EINVAL;
168
169 old = hw->phy.autoneg_advertised;
170 advertised = 0;
171 if (ecmd->advertising & ADVERTISED_10000baseT_Full)
172 advertised |= IXGBE_LINK_SPEED_10GB_FULL;
173
174 if (ecmd->advertising & ADVERTISED_1000baseT_Full)
175 advertised |= IXGBE_LINK_SPEED_1GB_FULL;
176
177 if (old == advertised)
178 break;
179 /* this sets the link speed and restarts auto-neg */
180 err = hw->mac.ops.setup_link_speed(hw, advertised, true, true);
181 if (err) {
182 DPRINTK(PROBE, INFO,
183 "setup link failed with code %d\n", err);
184 hw->mac.ops.setup_link_speed(hw, old, true, true);
185 }
186 break;
160 default: 187 default:
161 break; 188 break;
162 } 189 }
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 7548fb7360d9..d1f80dd88bc9 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -68,6 +68,8 @@ static struct pci_device_id ixgbe_pci_tbl[] = {
68 board_82598 }, 68 board_82598 },
69 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_SINGLE_PORT), 69 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_SINGLE_PORT),
70 board_82598 }, 70 board_82598 },
71 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AT),
72 board_82598 },
71 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598EB_CX4), 73 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598EB_CX4),
72 board_82598 }, 74 board_82598 },
73 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598_CX4_DUAL_PORT), 75 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598_CX4_DUAL_PORT),
@@ -666,7 +668,6 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter *adapter,
666 668
667 skb->protocol = eth_type_trans(skb, adapter->netdev); 669 skb->protocol = eth_type_trans(skb, adapter->netdev);
668 ixgbe_receive_skb(adapter, skb, staterr, rx_ring, rx_desc); 670 ixgbe_receive_skb(adapter, skb, staterr, rx_ring, rx_desc);
669 adapter->netdev->last_rx = jiffies;
670 671
671next_desc: 672next_desc:
672 rx_desc->wb.upper.status_error = 0; 673 rx_desc->wb.upper.status_error = 0;
@@ -904,6 +905,17 @@ static void ixgbe_set_itr_msix(struct ixgbe_q_vector *q_vector)
904 return; 905 return;
905} 906}
906 907
908static void ixgbe_check_fan_failure(struct ixgbe_adapter *adapter, u32 eicr)
909{
910 struct ixgbe_hw *hw = &adapter->hw;
911
912 if ((adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) &&
913 (eicr & IXGBE_EICR_GPI_SDP1)) {
914 DPRINTK(PROBE, CRIT, "Fan has stopped, replace the adapter\n");
915 /* write to clear the interrupt */
916 IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1);
917 }
918}
907 919
908static void ixgbe_check_lsc(struct ixgbe_adapter *adapter) 920static void ixgbe_check_lsc(struct ixgbe_adapter *adapter)
909{ 921{
@@ -928,6 +940,8 @@ static irqreturn_t ixgbe_msix_lsc(int irq, void *data)
928 if (eicr & IXGBE_EICR_LSC) 940 if (eicr & IXGBE_EICR_LSC)
929 ixgbe_check_lsc(adapter); 941 ixgbe_check_lsc(adapter);
930 942
943 ixgbe_check_fan_failure(adapter, eicr);
944
931 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 945 if (!test_bit(__IXGBE_DOWN, &adapter->state))
932 IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); 946 IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
933 947
@@ -1316,6 +1330,8 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
1316 if (eicr & IXGBE_EICR_LSC) 1330 if (eicr & IXGBE_EICR_LSC)
1317 ixgbe_check_lsc(adapter); 1331 ixgbe_check_lsc(adapter);
1318 1332
1333 ixgbe_check_fan_failure(adapter, eicr);
1334
1319 if (netif_rx_schedule_prep(netdev, &adapter->q_vector[0].napi)) { 1335 if (netif_rx_schedule_prep(netdev, &adapter->q_vector[0].napi)) {
1320 adapter->tx_ring[0].total_packets = 0; 1336 adapter->tx_ring[0].total_packets = 0;
1321 adapter->tx_ring[0].total_bytes = 0; 1337 adapter->tx_ring[0].total_bytes = 0;
@@ -1418,6 +1434,8 @@ static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
1418{ 1434{
1419 u32 mask; 1435 u32 mask;
1420 mask = IXGBE_EIMS_ENABLE_MASK; 1436 mask = IXGBE_EIMS_ENABLE_MASK;
1437 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE)
1438 mask |= IXGBE_EIMS_GPI_SDP1;
1421 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask); 1439 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
1422 IXGBE_WRITE_FLUSH(&adapter->hw); 1440 IXGBE_WRITE_FLUSH(&adapter->hw);
1423} 1441}
@@ -1927,6 +1945,13 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
1927 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE); 1945 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
1928 } 1946 }
1929 1947
1948 /* Enable fan failure interrupt if media type is copper */
1949 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) {
1950 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
1951 gpie |= IXGBE_SDP1_GPIEN;
1952 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
1953 }
1954
1930 mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD); 1955 mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD);
1931 if (max_frame != (mhadd >> IXGBE_MHADD_MFS_SHIFT)) { 1956 if (max_frame != (mhadd >> IXGBE_MHADD_MFS_SHIFT)) {
1932 mhadd &= ~IXGBE_MHADD_MFS_MASK; 1957 mhadd &= ~IXGBE_MHADD_MFS_MASK;
@@ -1972,6 +1997,9 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
1972 1997
1973 ixgbe_irq_enable(adapter); 1998 ixgbe_irq_enable(adapter);
1974 1999
2000 /* enable transmits */
2001 netif_tx_start_all_queues(netdev);
2002
1975 /* bring the link up in the watchdog, this could race with our first 2003 /* bring the link up in the watchdog, this could race with our first
1976 * link up interrupt but shouldn't be a problem */ 2004 * link up interrupt but shouldn't be a problem */
1977 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; 2005 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
@@ -2564,6 +2592,9 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
2564 rss = min(IXGBE_MAX_RSS_INDICES, (int)num_online_cpus()); 2592 rss = min(IXGBE_MAX_RSS_INDICES, (int)num_online_cpus());
2565 adapter->ring_feature[RING_F_RSS].indices = rss; 2593 adapter->ring_feature[RING_F_RSS].indices = rss;
2566 adapter->flags |= IXGBE_FLAG_RSS_ENABLED; 2594 adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
2595 if (hw->mac.ops.get_media_type &&
2596 (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper))
2597 adapter->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE;
2567 2598
2568 /* default flow control settings */ 2599 /* default flow control settings */
2569 hw->fc.original_type = ixgbe_fc_none; 2600 hw->fc.original_type = ixgbe_fc_none;
@@ -3219,7 +3250,6 @@ static void ixgbe_watchdog_task(struct work_struct *work)
3219 (FLOW_TX ? "TX" : "None")))); 3250 (FLOW_TX ? "TX" : "None"))));
3220 3251
3221 netif_carrier_on(netdev); 3252 netif_carrier_on(netdev);
3222 netif_tx_wake_all_queues(netdev);
3223 } else { 3253 } else {
3224 /* Force detection of hung controller */ 3254 /* Force detection of hung controller */
3225 adapter->detect_tx_hung = true; 3255 adapter->detect_tx_hung = true;
@@ -3230,7 +3260,6 @@ static void ixgbe_watchdog_task(struct work_struct *work)
3230 if (netif_carrier_ok(netdev)) { 3260 if (netif_carrier_ok(netdev)) {
3231 DPRINTK(LINK, INFO, "NIC Link is Down\n"); 3261 DPRINTK(LINK, INFO, "NIC Link is Down\n");
3232 netif_carrier_off(netdev); 3262 netif_carrier_off(netdev);
3233 netif_tx_stop_all_queues(netdev);
3234 } 3263 }
3235 } 3264 }
3236 3265
@@ -3691,6 +3720,10 @@ static int ixgbe_link_config(struct ixgbe_hw *hw)
3691 /* must always autoneg for both 1G and 10G link */ 3720 /* must always autoneg for both 1G and 10G link */
3692 hw->mac.autoneg = true; 3721 hw->mac.autoneg = true;
3693 3722
3723 if ((hw->mac.type == ixgbe_mac_82598EB) &&
3724 (hw->phy.media_type == ixgbe_media_type_copper))
3725 autoneg = IXGBE_LINK_SPEED_82598_AUTONEG;
3726
3694 return hw->mac.ops.setup_link_speed(hw, autoneg, true, true); 3727 return hw->mac.ops.setup_link_speed(hw, autoneg, true, true);
3695} 3728}
3696 3729
@@ -3877,8 +3910,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3877 pci_read_config_word(pdev, IXGBE_PCI_LINK_STATUS, &link_status); 3910 pci_read_config_word(pdev, IXGBE_PCI_LINK_STATUS, &link_status);
3878 link_speed = link_status & IXGBE_PCI_LINK_SPEED; 3911 link_speed = link_status & IXGBE_PCI_LINK_SPEED;
3879 link_width = link_status & IXGBE_PCI_LINK_WIDTH; 3912 link_width = link_status & IXGBE_PCI_LINK_WIDTH;
3880 dev_info(&pdev->dev, "(PCI Express:%s:%s) " 3913 dev_info(&pdev->dev, "(PCI Express:%s:%s) %pM\n",
3881 "%02x:%02x:%02x:%02x:%02x:%02x\n",
3882 ((link_speed == IXGBE_PCI_LINK_SPEED_5000) ? "5.0Gb/s" : 3914 ((link_speed == IXGBE_PCI_LINK_SPEED_5000) ? "5.0Gb/s" :
3883 (link_speed == IXGBE_PCI_LINK_SPEED_2500) ? "2.5Gb/s" : 3915 (link_speed == IXGBE_PCI_LINK_SPEED_2500) ? "2.5Gb/s" :
3884 "Unknown"), 3916 "Unknown"),
@@ -3887,8 +3919,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3887 (link_width == IXGBE_PCI_LINK_WIDTH_2) ? "Width x2" : 3919 (link_width == IXGBE_PCI_LINK_WIDTH_2) ? "Width x2" :
3888 (link_width == IXGBE_PCI_LINK_WIDTH_1) ? "Width x1" : 3920 (link_width == IXGBE_PCI_LINK_WIDTH_1) ? "Width x1" :
3889 "Unknown"), 3921 "Unknown"),
3890 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2], 3922 netdev->dev_addr);
3891 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
3892 ixgbe_read_pba_num_generic(hw, &part_num); 3923 ixgbe_read_pba_num_generic(hw, &part_num);
3893 dev_info(&pdev->dev, "MAC: %d, PHY: %d, PBA No: %06x-%03x\n", 3924 dev_info(&pdev->dev, "MAC: %d, PHY: %d, PBA No: %06x-%03x\n",
3894 hw->mac.type, hw->phy.type, 3925 hw->mac.type, hw->phy.type,
@@ -3913,7 +3944,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3913 } 3944 }
3914 3945
3915 netif_carrier_off(netdev); 3946 netif_carrier_off(netdev);
3916 netif_tx_stop_all_queues(netdev);
3917 3947
3918 ixgbe_napi_add_all(adapter); 3948 ixgbe_napi_add_all(adapter);
3919 3949
@@ -4011,7 +4041,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
4011 pci_channel_state_t state) 4041 pci_channel_state_t state)
4012{ 4042{
4013 struct net_device *netdev = pci_get_drvdata(pdev); 4043 struct net_device *netdev = pci_get_drvdata(pdev);
4014 struct ixgbe_adapter *adapter = netdev->priv; 4044 struct ixgbe_adapter *adapter = netdev_priv(netdev);
4015 4045
4016 netif_device_detach(netdev); 4046 netif_device_detach(netdev);
4017 4047
@@ -4032,7 +4062,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
4032static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev) 4062static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev)
4033{ 4063{
4034 struct net_device *netdev = pci_get_drvdata(pdev); 4064 struct net_device *netdev = pci_get_drvdata(pdev);
4035 struct ixgbe_adapter *adapter = netdev->priv; 4065 struct ixgbe_adapter *adapter = netdev_priv(netdev);
4036 4066
4037 if (pci_enable_device(pdev)) { 4067 if (pci_enable_device(pdev)) {
4038 DPRINTK(PROBE, ERR, 4068 DPRINTK(PROBE, ERR,
@@ -4060,7 +4090,7 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev)
4060static void ixgbe_io_resume(struct pci_dev *pdev) 4090static void ixgbe_io_resume(struct pci_dev *pdev)
4061{ 4091{
4062 struct net_device *netdev = pci_get_drvdata(pdev); 4092 struct net_device *netdev = pci_get_drvdata(pdev);
4063 struct ixgbe_adapter *adapter = netdev->priv; 4093 struct ixgbe_adapter *adapter = netdev_priv(netdev);
4064 4094
4065 if (netif_running(netdev)) { 4095 if (netif_running(netdev)) {
4066 if (ixgbe_up(adapter)) { 4096 if (ixgbe_up(adapter)) {
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 764035a8c9a1..981e6d849592 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -121,6 +121,9 @@ static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
121 enum ixgbe_phy_type phy_type; 121 enum ixgbe_phy_type phy_type;
122 122
123 switch (phy_id) { 123 switch (phy_id) {
124 case TN1010_PHY_ID:
125 phy_type = ixgbe_phy_tn;
126 break;
124 case QT2022_PHY_ID: 127 case QT2022_PHY_ID:
125 phy_type = ixgbe_phy_qt; 128 phy_type = ixgbe_phy_qt;
126 break; 129 break;
@@ -426,3 +429,68 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
426 return 0; 429 return 0;
427} 430}
428 431
432/**
433 * ixgbe_check_phy_link_tnx - Determine link and speed status
434 * @hw: pointer to hardware structure
435 *
436 * Reads the VS1 register to determine if link is up and the current speed for
437 * the PHY.
438 **/
439s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
440 bool *link_up)
441{
442 s32 status = 0;
443 u32 time_out;
444 u32 max_time_out = 10;
445 u16 phy_link = 0;
446 u16 phy_speed = 0;
447 u16 phy_data = 0;
448
449 /* Initialize speed and link to default case */
450 *link_up = false;
451 *speed = IXGBE_LINK_SPEED_10GB_FULL;
452
453 /*
454 * Check current speed and link status of the PHY register.
455 * This is a vendor specific register and may have to
456 * be changed for other copper PHYs.
457 */
458 for (time_out = 0; time_out < max_time_out; time_out++) {
459 udelay(10);
460 status = hw->phy.ops.read_reg(hw,
461 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
462 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
463 &phy_data);
464 phy_link = phy_data &
465 IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
466 phy_speed = phy_data &
467 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
468 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
469 *link_up = true;
470 if (phy_speed ==
471 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
472 *speed = IXGBE_LINK_SPEED_1GB_FULL;
473 break;
474 }
475 }
476
477 return status;
478}
479
480/**
481 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
482 * @hw: pointer to hardware structure
483 * @firmware_version: pointer to the PHY Firmware Version
484 **/
485s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
486 u16 *firmware_version)
487{
488 s32 status = 0;
489
490 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
491 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
492 firmware_version);
493
494 return status;
495}
496
diff --git a/drivers/net/ixgbe/ixgbe_phy.h b/drivers/net/ixgbe/ixgbe_phy.h
index 9bfe3f2b1d8f..5cc063d02770 100644
--- a/drivers/net/ixgbe/ixgbe_phy.h
+++ b/drivers/net/ixgbe/ixgbe_phy.h
@@ -77,4 +77,11 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
77 bool autoneg, 77 bool autoneg,
78 bool autoneg_wait_to_complete); 78 bool autoneg_wait_to_complete);
79 79
80/* PHY specific */
81s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw,
82 ixgbe_link_speed *speed,
83 bool *link_up);
84s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
85 u16 *firmware_version);
86
80#endif /* _IXGBE_PHY_H_ */ 87#endif /* _IXGBE_PHY_H_ */
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index c6f8fa1c4e59..51df39dae816 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -36,6 +36,7 @@
36/* Device IDs */ 36/* Device IDs */
37#define IXGBE_DEV_ID_82598AF_DUAL_PORT 0x10C6 37#define IXGBE_DEV_ID_82598AF_DUAL_PORT 0x10C6
38#define IXGBE_DEV_ID_82598AF_SINGLE_PORT 0x10C7 38#define IXGBE_DEV_ID_82598AF_SINGLE_PORT 0x10C7
39#define IXGBE_DEV_ID_82598AT 0x10C8
39#define IXGBE_DEV_ID_82598EB_CX4 0x10DD 40#define IXGBE_DEV_ID_82598EB_CX4 0x10DD
40#define IXGBE_DEV_ID_82598_CX4_DUAL_PORT 0x10EC 41#define IXGBE_DEV_ID_82598_CX4_DUAL_PORT 0x10EC
41#define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4 42#define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4
@@ -488,6 +489,8 @@
488#define IXGBE_MAX_PHY_ADDR 32 489#define IXGBE_MAX_PHY_ADDR 32
489 490
490/* PHY IDs*/ 491/* PHY IDs*/
492#define TN1010_PHY_ID 0x00A19410
493#define TNX_FW_REV 0xB
491#define QT2022_PHY_ID 0x0043A400 494#define QT2022_PHY_ID 0x0043A400
492 495
493/* PHY Types */ 496/* PHY Types */
@@ -1202,6 +1205,7 @@ enum ixgbe_mac_type {
1202 1205
1203enum ixgbe_phy_type { 1206enum ixgbe_phy_type {
1204 ixgbe_phy_unknown = 0, 1207 ixgbe_phy_unknown = 0,
1208 ixgbe_phy_tn,
1205 ixgbe_phy_qt, 1209 ixgbe_phy_qt,
1206 ixgbe_phy_xaui, 1210 ixgbe_phy_xaui,
1207 ixgbe_phy_tw_tyco, 1211 ixgbe_phy_tw_tyco,
@@ -1396,6 +1400,8 @@ struct ixgbe_phy_operations {
1396 s32 (*setup_link)(struct ixgbe_hw *); 1400 s32 (*setup_link)(struct ixgbe_hw *);
1397 s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool, 1401 s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool,
1398 bool); 1402 bool);
1403 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *);
1404 s32 (*get_firmware_version)(struct ixgbe_hw *, u16 *);
1399 s32 (*read_i2c_byte)(struct ixgbe_hw *, u8, u8, u8 *); 1405 s32 (*read_i2c_byte)(struct ixgbe_hw *, u8, u8, u8 *);
1400 s32 (*write_i2c_byte)(struct ixgbe_hw *, u8, u8, u8); 1406 s32 (*write_i2c_byte)(struct ixgbe_hw *, u8, u8, u8);
1401 s32 (*read_i2c_eeprom)(struct ixgbe_hw *, u8 , u8 *); 1407 s32 (*read_i2c_eeprom)(struct ixgbe_hw *, u8 , u8 *);
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index 7b70c66504a0..bd96dbc8e021 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -114,8 +114,6 @@ static int ixpdev_rx(struct net_device *dev, int processed, int budget)
114 skb_put(skb, desc->pkt_length); 114 skb_put(skb, desc->pkt_length);
115 skb->protocol = eth_type_trans(skb, nds[desc->channel]); 115 skb->protocol = eth_type_trans(skb, nds[desc->channel]);
116 116
117 dev->last_rx = jiffies;
118
119 netif_receive_skb(skb); 117 netif_receive_skb(skb);
120 } 118 }
121 119
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index 07944820f745..334ff9e12cdd 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -208,7 +208,6 @@ static int __init jazz_sonic_probe(struct platform_device *pdev)
208 struct sonic_local *lp; 208 struct sonic_local *lp;
209 struct resource *res; 209 struct resource *res;
210 int err = 0; 210 int err = 0;
211 DECLARE_MAC_BUF(mac);
212 211
213 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 212 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
214 if (!res) 213 if (!res)
@@ -233,8 +232,7 @@ static int __init jazz_sonic_probe(struct platform_device *pdev)
233 if (err) 232 if (err)
234 goto out1; 233 goto out1;
235 234
236 printk("%s: MAC %s IRQ %d\n", 235 printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
237 dev->name, print_mac(mac, dev->dev_addr), dev->irq);
238 236
239 return 0; 237 return 0;
240 238
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 81c6cdc3851f..0796d0b0e338 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -931,7 +931,6 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
931 RXWBFLAG_DEST_MUL) 931 RXWBFLAG_DEST_MUL)
932 ++(NET_STAT(jme).multicast); 932 ++(NET_STAT(jme).multicast);
933 933
934 jme->dev->last_rx = jiffies;
935 NET_STAT(jme).rx_bytes += framesize; 934 NET_STAT(jme).rx_bytes += framesize;
936 ++(NET_STAT(jme).rx_packets); 935 ++(NET_STAT(jme).rx_packets);
937 } 936 }
@@ -2862,18 +2861,10 @@ jme_init_one(struct pci_dev *pdev,
2862 goto err_out_free_shadow; 2861 goto err_out_free_shadow;
2863 } 2862 }
2864 2863
2865 msg_probe(jme, 2864 msg_probe(jme, "JMC250 gigabit%s ver:%x rev:%x macaddr:%pM\n",
2866 "JMC250 gigabit%s ver:%x rev:%x "
2867 "macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
2868 (jme->fpgaver != 0) ? " (FPGA)" : "", 2865 (jme->fpgaver != 0) ? " (FPGA)" : "",
2869 (jme->fpgaver != 0) ? jme->fpgaver : jme->chiprev, 2866 (jme->fpgaver != 0) ? jme->fpgaver : jme->chiprev,
2870 jme->rev, 2867 jme->rev, netdev->dev_addr);
2871 netdev->dev_addr[0],
2872 netdev->dev_addr[1],
2873 netdev->dev_addr[2],
2874 netdev->dev_addr[3],
2875 netdev->dev_addr[4],
2876 netdev->dev_addr[5]);
2877 2868
2878 return 0; 2869 return 0;
2879 2870
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index e18576316bda..63626953f07e 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -409,7 +409,6 @@ static int korina_rx(struct net_device *dev, int limit)
409 409
410 /* Pass the packet to upper layers */ 410 /* Pass the packet to upper layers */
411 netif_receive_skb(skb); 411 netif_receive_skb(skb);
412 dev->last_rx = jiffies;
413 dev->stats.rx_packets++; 412 dev->stats.rx_packets++;
414 dev->stats.rx_bytes += pkt_len; 413 dev->stats.rx_bytes += pkt_len;
415 414
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index 977ed3401bb3..f63789affb1a 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -466,7 +466,6 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
466 unsigned long flags; 466 unsigned long flags;
467 int err = -ENOMEM; 467 int err = -ENOMEM;
468 void __iomem *bios; 468 void __iomem *bios;
469 DECLARE_MAC_BUF(mac);
470 469
471 /* First we look for special cases. 470 /* First we look for special cases.
472 Check for HP's on-board ethernet by looking for 'HP' in the BIOS. 471 Check for HP's on-board ethernet by looking for 'HP' in the BIOS.
@@ -529,7 +528,7 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
529 The first six bytes are the station address. */ 528 The first six bytes are the station address. */
530 for (i = 0; i < 6; i++) 529 for (i = 0; i < 6; i++)
531 dev->dev_addr[i] = inb(ioaddr + i); 530 dev->dev_addr[i] = inb(ioaddr + i);
532 printk("%s", print_mac(mac, dev->dev_addr)); 531 printk("%pM", dev->dev_addr);
533 532
534 dev->base_addr = ioaddr; 533 dev->base_addr = ioaddr;
535 /* Make certain the data structures used by the LANCE are aligned and DMAble. */ 534 /* Make certain the data structures used by the LANCE are aligned and DMAble. */
@@ -1191,7 +1190,6 @@ lance_rx(struct net_device *dev)
1191 pkt_len); 1190 pkt_len);
1192 skb->protocol=eth_type_trans(skb,dev); 1191 skb->protocol=eth_type_trans(skb,dev);
1193 netif_rx(skb); 1192 netif_rx(skb);
1194 dev->last_rx = jiffies;
1195 lp->stats.rx_packets++; 1193 lp->stats.rx_packets++;
1196 lp->stats.rx_bytes+=pkt_len; 1194 lp->stats.rx_bytes+=pkt_len;
1197 } 1195 }
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
index b59f442bbf36..7415f517491d 100644
--- a/drivers/net/lib82596.c
+++ b/drivers/net/lib82596.c
@@ -739,7 +739,6 @@ memory_squeeze:
739 skb->len = pkt_len; 739 skb->len = pkt_len;
740 skb->protocol = eth_type_trans(skb, dev); 740 skb->protocol = eth_type_trans(skb, dev);
741 netif_rx(skb); 741 netif_rx(skb);
742 dev->last_rx = jiffies;
743 dev->stats.rx_packets++; 742 dev->stats.rx_packets++;
744 dev->stats.rx_bytes += pkt_len; 743 dev->stats.rx_bytes += pkt_len;
745 } 744 }
@@ -1034,12 +1033,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
1034 1033
1035static void print_eth(unsigned char *add, char *str) 1034static void print_eth(unsigned char *add, char *str)
1036{ 1035{
1037 DECLARE_MAC_BUF(mac); 1036 printk(KERN_DEBUG "i596 0x%p, %pM --> %pM %02X%02X, %s\n",
1038 DECLARE_MAC_BUF(mac2); 1037 add, add + 6, add, add[12], add[13], str);
1039
1040 printk(KERN_DEBUG "i596 0x%p, %s --> %s %02X%02X, %s\n",
1041 add, print_mac(mac, add + 6), print_mac(mac2, add),
1042 add[12], add[13], str);
1043} 1038}
1044 1039
1045static int __devinit i82596_probe(struct net_device *dev) 1040static int __devinit i82596_probe(struct net_device *dev)
@@ -1343,7 +1338,6 @@ static void set_multicast_list(struct net_device *dev)
1343 struct i596_private *lp = netdev_priv(dev); 1338 struct i596_private *lp = netdev_priv(dev);
1344 struct i596_dma *dma = lp->dma; 1339 struct i596_dma *dma = lp->dma;
1345 int config = 0, cnt; 1340 int config = 0, cnt;
1346 DECLARE_MAC_BUF(mac);
1347 1341
1348 DEB(DEB_MULTI, 1342 DEB(DEB_MULTI,
1349 printk(KERN_DEBUG 1343 printk(KERN_DEBUG
@@ -1407,8 +1401,8 @@ static void set_multicast_list(struct net_device *dev)
1407 if (i596_debug > 1) 1401 if (i596_debug > 1)
1408 DEB(DEB_MULTI, 1402 DEB(DEB_MULTI,
1409 printk(KERN_DEBUG 1403 printk(KERN_DEBUG
1410 "%s: Adding address %s\n", 1404 "%s: Adding address %pM\n",
1411 dev->name, print_mac(mac, cp))); 1405 dev->name, cp));
1412 } 1406 }
1413 DMA_WBACK_INV(dev, &dma->mc_cmd, sizeof(struct mc_cmd)); 1407 DMA_WBACK_INV(dev, &dma->mc_cmd, sizeof(struct mc_cmd));
1414 i596_add_cmd(dev, &cmd->cmd); 1408 i596_add_cmd(dev, &cmd->cmd);
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
index f80dcc11fe26..9430167a3b13 100644
--- a/drivers/net/lib8390.c
+++ b/drivers/net/lib8390.c
@@ -764,7 +764,6 @@ static void ei_receive(struct net_device *dev)
764 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame)); 764 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
765 skb->protocol=eth_type_trans(skb,dev); 765 skb->protocol=eth_type_trans(skb,dev);
766 netif_rx(skb); 766 netif_rx(skb);
767 dev->last_rx = jiffies;
768 dev->stats.rx_packets++; 767 dev->stats.rx_packets++;
769 dev->stats.rx_bytes += pkt_len; 768 dev->stats.rx_bytes += pkt_len;
770 if (pkt_stat & ENRSR_PHY) 769 if (pkt_stat & ENRSR_PHY)
diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c
index b36989097883..bc70d5e79ab1 100644
--- a/drivers/net/lne390.c
+++ b/drivers/net/lne390.c
@@ -169,7 +169,6 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr)
169{ 169{
170 int i, revision, ret; 170 int i, revision, ret;
171 unsigned long eisa_id; 171 unsigned long eisa_id;
172 DECLARE_MAC_BUF(mac);
173 172
174 if (inb_p(ioaddr + LNE390_ID_PORT) == 0xff) return -ENODEV; 173 if (inb_p(ioaddr + LNE390_ID_PORT) == 0xff) return -ENODEV;
175 174
@@ -203,8 +202,8 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr)
203 202
204 for(i = 0; i < ETHER_ADDR_LEN; i++) 203 for(i = 0; i < ETHER_ADDR_LEN; i++)
205 dev->dev_addr[i] = inb(ioaddr + LNE390_SA_PROM + i); 204 dev->dev_addr[i] = inb(ioaddr + LNE390_SA_PROM + i);
206 printk("lne390.c: LNE390%X in EISA slot %d, address %s.\n", 205 printk("lne390.c: LNE390%X in EISA slot %d, address %pM.\n",
207 0xa+revision, ioaddr/0x1000, print_mac(mac, dev->dev_addr)); 206 0xa+revision, ioaddr/0x1000, dev->dev_addr);
208 207
209 printk("lne390.c: "); 208 printk("lne390.c: ");
210 209
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index b1ac63ab8c16..c4516b580ba5 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -76,8 +76,6 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
76 76
77 skb->protocol = eth_type_trans(skb,dev); 77 skb->protocol = eth_type_trans(skb,dev);
78 78
79 dev->last_rx = jiffies;
80
81 /* it's OK to use per_cpu_ptr() because BHs are off */ 79 /* it's OK to use per_cpu_ptr() because BHs are off */
82 pcpu_lstats = dev->ml_priv; 80 pcpu_lstats = dev->ml_priv;
83 lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id()); 81 lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
@@ -206,17 +204,8 @@ static __net_exit void loopback_net_exit(struct net *net)
206 unregister_netdev(dev); 204 unregister_netdev(dev);
207} 205}
208 206
209static struct pernet_operations __net_initdata loopback_net_ops = { 207/* Registered in net/core/dev.c */
208struct pernet_operations __net_initdata loopback_net_ops = {
210 .init = loopback_net_init, 209 .init = loopback_net_init,
211 .exit = loopback_net_exit, 210 .exit = loopback_net_exit,
212}; 211};
213
214static int __init loopback_init(void)
215{
216 return register_pernet_device(&loopback_net_ops);
217}
218
219/* Loopback is special. It should be initialized before any other network
220 * device and network subsystem.
221 */
222fs_initcall(loopback_init);
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c
index 83fa9d82a004..4d1a059921c6 100644
--- a/drivers/net/lp486e.c
+++ b/drivers/net/lp486e.c
@@ -390,7 +390,7 @@ i596_timeout(struct net_device *dev, char *msg, int ct) {
390 struct i596_private *lp; 390 struct i596_private *lp;
391 int boguscnt = ct; 391 int boguscnt = ct;
392 392
393 lp = (struct i596_private *) dev->priv; 393 lp = netdev_priv(dev);
394 while (lp->scb.command) { 394 while (lp->scb.command) {
395 if (--boguscnt == 0) { 395 if (--boguscnt == 0) {
396 printk("%s: %s timed out - stat %4.4x, cmd %4.4x\n", 396 printk("%s: %s timed out - stat %4.4x, cmd %4.4x\n",
@@ -411,7 +411,7 @@ init_rx_bufs(struct net_device *dev, int num) {
411 int i; 411 int i;
412 // struct i596_rbd *rbd; 412 // struct i596_rbd *rbd;
413 413
414 lp = (struct i596_private *) dev->priv; 414 lp = netdev_priv(dev);
415 lp->scb.pa_rfd = I596_NULL; 415 lp->scb.pa_rfd = I596_NULL;
416 416
417 for (i = 0; i < num; i++) { 417 for (i = 0; i < num; i++) {
@@ -468,7 +468,7 @@ remove_rx_bufs(struct net_device *dev) {
468 struct i596_private *lp; 468 struct i596_private *lp;
469 struct i596_rfd *rfd; 469 struct i596_rfd *rfd;
470 470
471 lp = (struct i596_private *) dev->priv; 471 lp = netdev_priv(dev);
472 lp->rx_tail->pa_next = I596_NULL; 472 lp->rx_tail->pa_next = I596_NULL;
473 473
474 do { 474 do {
@@ -517,7 +517,7 @@ CLEAR_INT(void) {
517/* selftest or dump */ 517/* selftest or dump */
518static void 518static void
519i596_port_do(struct net_device *dev, int portcmd, char *cmdname) { 519i596_port_do(struct net_device *dev, int portcmd, char *cmdname) {
520 struct i596_private *lp = dev->priv; 520 struct i596_private *lp = netdev_priv(dev);
521 u16 *outp; 521 u16 *outp;
522 int i, m; 522 int i, m;
523 523
@@ -541,7 +541,7 @@ i596_port_do(struct net_device *dev, int portcmd, char *cmdname) {
541 541
542static int 542static int
543i596_scp_setup(struct net_device *dev) { 543i596_scp_setup(struct net_device *dev) {
544 struct i596_private *lp = dev->priv; 544 struct i596_private *lp = netdev_priv(dev);
545 int boguscnt; 545 int boguscnt;
546 546
547 /* Setup SCP, ISCP, SCB */ 547 /* Setup SCP, ISCP, SCB */
@@ -622,7 +622,7 @@ init_i596(struct net_device *dev) {
622 if (i596_scp_setup(dev)) 622 if (i596_scp_setup(dev))
623 return 1; 623 return 1;
624 624
625 lp = (struct i596_private *) dev->priv; 625 lp = netdev_priv(dev);
626 lp->scb.command = 0; 626 lp->scb.command = 0;
627 627
628 memcpy ((void *)lp->i596_config, init_setup, 14); 628 memcpy ((void *)lp->i596_config, init_setup, 14);
@@ -676,7 +676,6 @@ i596_rx_one(struct net_device *dev, struct i596_private *lp,
676 676
677 skb->protocol = eth_type_trans(skb,dev); 677 skb->protocol = eth_type_trans(skb,dev);
678 netif_rx(skb); 678 netif_rx(skb);
679 dev->last_rx = jiffies;
680 dev->stats.rx_packets++; 679 dev->stats.rx_packets++;
681 } else { 680 } else {
682#if 0 681#if 0
@@ -705,7 +704,7 @@ i596_rx_one(struct net_device *dev, struct i596_private *lp,
705 704
706static int 705static int
707i596_rx(struct net_device *dev) { 706i596_rx(struct net_device *dev) {
708 struct i596_private *lp = (struct i596_private *) dev->priv; 707 struct i596_private *lp = netdev_priv(dev);
709 struct i596_rfd *rfd; 708 struct i596_rfd *rfd;
710 int frames = 0; 709 int frames = 0;
711 710
@@ -738,7 +737,7 @@ i596_cleanup_cmd(struct net_device *dev) {
738 struct i596_private *lp; 737 struct i596_private *lp;
739 struct i596_cmd *cmd; 738 struct i596_cmd *cmd;
740 739
741 lp = (struct i596_private *) dev->priv; 740 lp = netdev_priv(dev);
742 while (lp->cmd_head) { 741 while (lp->cmd_head) {
743 cmd = (struct i596_cmd *)lp->cmd_head; 742 cmd = (struct i596_cmd *)lp->cmd_head;
744 743
@@ -806,7 +805,7 @@ static void i596_reset(struct net_device *dev, struct i596_private *lp, int ioad
806} 805}
807 806
808static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd) { 807static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd) {
809 struct i596_private *lp = dev->priv; 808 struct i596_private *lp = netdev_priv(dev);
810 int ioaddr = dev->base_addr; 809 int ioaddr = dev->base_addr;
811 unsigned long flags; 810 unsigned long flags;
812 811
@@ -912,7 +911,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) {
912 911
913static void 912static void
914i596_tx_timeout (struct net_device *dev) { 913i596_tx_timeout (struct net_device *dev) {
915 struct i596_private *lp = dev->priv; 914 struct i596_private *lp = netdev_priv(dev);
916 int ioaddr = dev->base_addr; 915 int ioaddr = dev->base_addr;
917 916
918 /* Transmitter timeout, serious problems. */ 917 /* Transmitter timeout, serious problems. */
@@ -970,7 +969,7 @@ static int __init lp486e_probe(struct net_device *dev) {
970 return -EBUSY; 969 return -EBUSY;
971 } 970 }
972 971
973 lp = (struct i596_private *) dev->priv; 972 lp = netdev_priv(dev);
974 spin_lock_init(&lp->cmd_lock); 973 spin_lock_init(&lp->cmd_lock);
975 974
976 /* 975 /*
@@ -1147,7 +1146,7 @@ static irqreturn_t
1147i596_interrupt(int irq, void *dev_instance) 1146i596_interrupt(int irq, void *dev_instance)
1148{ 1147{
1149 struct net_device *dev = dev_instance; 1148 struct net_device *dev = dev_instance;
1150 struct i596_private *lp = dev->priv; 1149 struct i596_private *lp = netdev_priv(dev);
1151 unsigned short status, ack_cmd = 0; 1150 unsigned short status, ack_cmd = 0;
1152 int frames_in = 0; 1151 int frames_in = 0;
1153 1152
@@ -1215,7 +1214,7 @@ i596_interrupt(int irq, void *dev_instance)
1215} 1214}
1216 1215
1217static int i596_close(struct net_device *dev) { 1216static int i596_close(struct net_device *dev) {
1218 struct i596_private *lp = dev->priv; 1217 struct i596_private *lp = netdev_priv(dev);
1219 1218
1220 netif_stop_queue(dev); 1219 netif_stop_queue(dev);
1221 1220
@@ -1242,7 +1241,7 @@ static int i596_close(struct net_device *dev) {
1242*/ 1241*/
1243 1242
1244static void set_multicast_list(struct net_device *dev) { 1243static void set_multicast_list(struct net_device *dev) {
1245 struct i596_private *lp = dev->priv; 1244 struct i596_private *lp = netdev_priv(dev);
1246 struct i596_cmd *cmd; 1245 struct i596_cmd *cmd;
1247 1246
1248 if (i596_debug > 1) 1247 if (i596_debug > 1)
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
index 4ce8afd481c3..2ee477c84b06 100644
--- a/drivers/net/mac89x0.c
+++ b/drivers/net/mac89x0.c
@@ -181,7 +181,6 @@ struct net_device * __init mac89x0_probe(int unit)
181 unsigned long ioaddr; 181 unsigned long ioaddr;
182 unsigned short sig; 182 unsigned short sig;
183 int err = -ENODEV; 183 int err = -ENODEV;
184 DECLARE_MAC_BUF(mac);
185 184
186 if (!MACH_IS_MAC) 185 if (!MACH_IS_MAC)
187 return ERR_PTR(-ENODEV); 186 return ERR_PTR(-ENODEV);
@@ -279,8 +278,7 @@ struct net_device * __init mac89x0_probe(int unit)
279 278
280 /* print the IRQ and ethernet address. */ 279 /* print the IRQ and ethernet address. */
281 280
282 printk(" IRQ %d ADDR %s\n", 281 printk(" IRQ %d ADDR %pM\n", dev->irq, dev->dev_addr);
283 dev->irq, print_mac(mac, dev->dev_addr));
284 282
285 dev->open = net_open; 283 dev->open = net_open;
286 dev->stop = net_close; 284 dev->stop = net_close;
@@ -518,7 +516,6 @@ net_rx(struct net_device *dev)
518 516
519 skb->protocol=eth_type_trans(skb,dev); 517 skb->protocol=eth_type_trans(skb,dev);
520 netif_rx(skb); 518 netif_rx(skb);
521 dev->last_rx = jiffies;
522 lp->stats.rx_packets++; 519 lp->stats.rx_packets++;
523 lp->stats.rx_bytes += length; 520 lp->stats.rx_bytes += length;
524} 521}
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 01f7a31bac76..261b9507124b 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -435,7 +435,6 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
435 435
436 bp->stats.rx_packets++; 436 bp->stats.rx_packets++;
437 bp->stats.rx_bytes += len; 437 bp->stats.rx_bytes += len;
438 bp->dev->last_rx = jiffies;
439 dev_dbg(&bp->pdev->dev, "received skb of length %u, csum: %08x\n", 438 dev_dbg(&bp->pdev->dev, "received skb of length %u, csum: %08x\n",
440 skb->len, skb->csum); 439 skb->len, skb->csum);
441 netif_receive_skb(skb); 440 netif_receive_skb(skb);
@@ -1104,7 +1103,6 @@ static int __init macb_probe(struct platform_device *pdev)
1104 unsigned long pclk_hz; 1103 unsigned long pclk_hz;
1105 u32 config; 1104 u32 config;
1106 int err = -ENXIO; 1105 int err = -ENXIO;
1107 DECLARE_MAC_BUF(mac);
1108 1106
1109 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1107 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1110 if (!regs) { 1108 if (!regs) {
@@ -1223,10 +1221,8 @@ static int __init macb_probe(struct platform_device *pdev)
1223 1221
1224 platform_set_drvdata(pdev, dev); 1222 platform_set_drvdata(pdev, dev);
1225 1223
1226 printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d " 1224 printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d (%pM)\n",
1227 "(%s)\n", 1225 dev->name, dev->base_addr, dev->irq, dev->dev_addr);
1228 dev->name, dev->base_addr, dev->irq,
1229 print_mac(mac, dev->dev_addr));
1230 1226
1231 phydev = bp->phy_dev; 1227 phydev = bp->phy_dev;
1232 printk(KERN_INFO "%s: attached PHY driver [%s] " 1228 printk(KERN_INFO "%s: attached PHY driver [%s] "
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index 451acdca2a21..feebbd92aff2 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -101,7 +101,6 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
101 struct mace_data *mp; 101 struct mace_data *mp;
102 const unsigned char *addr; 102 const unsigned char *addr;
103 int j, rev, rc = -EBUSY; 103 int j, rev, rc = -EBUSY;
104 DECLARE_MAC_BUF(mac);
105 104
106 if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) { 105 if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) {
107 printk(KERN_ERR "can't use MACE %s: need 3 addrs and 3 irqs\n", 106 printk(KERN_ERR "can't use MACE %s: need 3 addrs and 3 irqs\n",
@@ -144,7 +143,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
144 } 143 }
145 SET_NETDEV_DEV(dev, &mdev->ofdev.dev); 144 SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
146 145
147 mp = dev->priv; 146 mp = netdev_priv(dev);
148 mp->mdev = mdev; 147 mp->mdev = mdev;
149 macio_set_drvdata(mdev, dev); 148 macio_set_drvdata(mdev, dev);
150 149
@@ -165,7 +164,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
165 in_8(&mp->mace->chipid_lo); 164 in_8(&mp->mace->chipid_lo);
166 165
167 166
168 mp = (struct mace_data *) dev->priv; 167 mp = netdev_priv(dev);
169 mp->maccc = ENXMT | ENRCV; 168 mp->maccc = ENXMT | ENRCV;
170 169
171 mp->tx_dma = ioremap(macio_resource_start(mdev, 1), 0x1000); 170 mp->tx_dma = ioremap(macio_resource_start(mdev, 1), 0x1000);
@@ -241,8 +240,8 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
241 goto err_free_rx_irq; 240 goto err_free_rx_irq;
242 } 241 }
243 242
244 printk(KERN_INFO "%s: MACE at %s, chip revision %d.%d\n", 243 printk(KERN_INFO "%s: MACE at %pM, chip revision %d.%d\n",
245 dev->name, print_mac(mac, dev->dev_addr), 244 dev->name, dev->dev_addr,
246 mp->chipid >> 8, mp->chipid & 0xff); 245 mp->chipid >> 8, mp->chipid & 0xff);
247 246
248 return 0; 247 return 0;
@@ -276,7 +275,7 @@ static int __devexit mace_remove(struct macio_dev *mdev)
276 275
277 macio_set_drvdata(mdev, NULL); 276 macio_set_drvdata(mdev, NULL);
278 277
279 mp = dev->priv; 278 mp = netdev_priv(dev);
280 279
281 unregister_netdev(dev); 280 unregister_netdev(dev);
282 281
@@ -312,7 +311,7 @@ static void dbdma_reset(volatile struct dbdma_regs __iomem *dma)
312 311
313static void mace_reset(struct net_device *dev) 312static void mace_reset(struct net_device *dev)
314{ 313{
315 struct mace_data *mp = (struct mace_data *) dev->priv; 314 struct mace_data *mp = netdev_priv(dev);
316 volatile struct mace __iomem *mb = mp->mace; 315 volatile struct mace __iomem *mb = mp->mace;
317 int i; 316 int i;
318 317
@@ -367,7 +366,7 @@ static void mace_reset(struct net_device *dev)
367 366
368static void __mace_set_address(struct net_device *dev, void *addr) 367static void __mace_set_address(struct net_device *dev, void *addr)
369{ 368{
370 struct mace_data *mp = (struct mace_data *) dev->priv; 369 struct mace_data *mp = netdev_priv(dev);
371 volatile struct mace __iomem *mb = mp->mace; 370 volatile struct mace __iomem *mb = mp->mace;
372 unsigned char *p = addr; 371 unsigned char *p = addr;
373 int i; 372 int i;
@@ -388,7 +387,7 @@ static void __mace_set_address(struct net_device *dev, void *addr)
388 387
389static int mace_set_address(struct net_device *dev, void *addr) 388static int mace_set_address(struct net_device *dev, void *addr)
390{ 389{
391 struct mace_data *mp = (struct mace_data *) dev->priv; 390 struct mace_data *mp = netdev_priv(dev);
392 volatile struct mace __iomem *mb = mp->mace; 391 volatile struct mace __iomem *mb = mp->mace;
393 unsigned long flags; 392 unsigned long flags;
394 393
@@ -423,7 +422,7 @@ static inline void mace_clean_rings(struct mace_data *mp)
423 422
424static int mace_open(struct net_device *dev) 423static int mace_open(struct net_device *dev)
425{ 424{
426 struct mace_data *mp = (struct mace_data *) dev->priv; 425 struct mace_data *mp = netdev_priv(dev);
427 volatile struct mace __iomem *mb = mp->mace; 426 volatile struct mace __iomem *mb = mp->mace;
428 volatile struct dbdma_regs __iomem *rd = mp->rx_dma; 427 volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
429 volatile struct dbdma_regs __iomem *td = mp->tx_dma; 428 volatile struct dbdma_regs __iomem *td = mp->tx_dma;
@@ -493,7 +492,7 @@ static int mace_open(struct net_device *dev)
493 492
494static int mace_close(struct net_device *dev) 493static int mace_close(struct net_device *dev)
495{ 494{
496 struct mace_data *mp = (struct mace_data *) dev->priv; 495 struct mace_data *mp = netdev_priv(dev);
497 volatile struct mace __iomem *mb = mp->mace; 496 volatile struct mace __iomem *mb = mp->mace;
498 volatile struct dbdma_regs __iomem *rd = mp->rx_dma; 497 volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
499 volatile struct dbdma_regs __iomem *td = mp->tx_dma; 498 volatile struct dbdma_regs __iomem *td = mp->tx_dma;
@@ -513,7 +512,7 @@ static int mace_close(struct net_device *dev)
513 512
514static inline void mace_set_timeout(struct net_device *dev) 513static inline void mace_set_timeout(struct net_device *dev)
515{ 514{
516 struct mace_data *mp = (struct mace_data *) dev->priv; 515 struct mace_data *mp = netdev_priv(dev);
517 516
518 if (mp->timeout_active) 517 if (mp->timeout_active)
519 del_timer(&mp->tx_timeout); 518 del_timer(&mp->tx_timeout);
@@ -526,7 +525,7 @@ static inline void mace_set_timeout(struct net_device *dev)
526 525
527static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev) 526static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
528{ 527{
529 struct mace_data *mp = (struct mace_data *) dev->priv; 528 struct mace_data *mp = netdev_priv(dev);
530 volatile struct dbdma_regs __iomem *td = mp->tx_dma; 529 volatile struct dbdma_regs __iomem *td = mp->tx_dma;
531 volatile struct dbdma_cmd *cp, *np; 530 volatile struct dbdma_cmd *cp, *np;
532 unsigned long flags; 531 unsigned long flags;
@@ -581,7 +580,7 @@ static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
581 580
582static void mace_set_multicast(struct net_device *dev) 581static void mace_set_multicast(struct net_device *dev)
583{ 582{
584 struct mace_data *mp = (struct mace_data *) dev->priv; 583 struct mace_data *mp = netdev_priv(dev);
585 volatile struct mace __iomem *mb = mp->mace; 584 volatile struct mace __iomem *mb = mp->mace;
586 int i, j; 585 int i, j;
587 u32 crc; 586 u32 crc;
@@ -656,7 +655,7 @@ static void mace_handle_misc_intrs(struct mace_data *mp, int intr, struct net_de
656static irqreturn_t mace_interrupt(int irq, void *dev_id) 655static irqreturn_t mace_interrupt(int irq, void *dev_id)
657{ 656{
658 struct net_device *dev = (struct net_device *) dev_id; 657 struct net_device *dev = (struct net_device *) dev_id;
659 struct mace_data *mp = (struct mace_data *) dev->priv; 658 struct mace_data *mp = netdev_priv(dev);
660 volatile struct mace __iomem *mb = mp->mace; 659 volatile struct mace __iomem *mb = mp->mace;
661 volatile struct dbdma_regs __iomem *td = mp->tx_dma; 660 volatile struct dbdma_regs __iomem *td = mp->tx_dma;
662 volatile struct dbdma_cmd *cp; 661 volatile struct dbdma_cmd *cp;
@@ -802,7 +801,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
802static void mace_tx_timeout(unsigned long data) 801static void mace_tx_timeout(unsigned long data)
803{ 802{
804 struct net_device *dev = (struct net_device *) data; 803 struct net_device *dev = (struct net_device *) data;
805 struct mace_data *mp = (struct mace_data *) dev->priv; 804 struct mace_data *mp = netdev_priv(dev);
806 volatile struct mace __iomem *mb = mp->mace; 805 volatile struct mace __iomem *mb = mp->mace;
807 volatile struct dbdma_regs __iomem *td = mp->tx_dma; 806 volatile struct dbdma_regs __iomem *td = mp->tx_dma;
808 volatile struct dbdma_regs __iomem *rd = mp->rx_dma; 807 volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
@@ -873,7 +872,7 @@ static irqreturn_t mace_txdma_intr(int irq, void *dev_id)
873static irqreturn_t mace_rxdma_intr(int irq, void *dev_id) 872static irqreturn_t mace_rxdma_intr(int irq, void *dev_id)
874{ 873{
875 struct net_device *dev = (struct net_device *) dev_id; 874 struct net_device *dev = (struct net_device *) dev_id;
876 struct mace_data *mp = (struct mace_data *) dev->priv; 875 struct mace_data *mp = netdev_priv(dev);
877 volatile struct dbdma_regs __iomem *rd = mp->rx_dma; 876 volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
878 volatile struct dbdma_cmd *cp, *np; 877 volatile struct dbdma_cmd *cp, *np;
879 int i, nb, stat, next; 878 int i, nb, stat, next;
@@ -929,7 +928,6 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id)
929 skb->protocol = eth_type_trans(skb, dev); 928 skb->protocol = eth_type_trans(skb, dev);
930 dev->stats.rx_bytes += skb->len; 929 dev->stats.rx_bytes += skb->len;
931 netif_rx(skb); 930 netif_rx(skb);
932 dev->last_rx = jiffies;
933 mp->rx_bufs[i] = NULL; 931 mp->rx_bufs[i] = NULL;
934 ++dev->stats.rx_packets; 932 ++dev->stats.rx_packets;
935 } 933 }
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 85587a6667b9..274e99bb63ac 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -194,7 +194,6 @@ static int __devinit mace_probe(struct platform_device *pdev)
194 unsigned char checksum = 0; 194 unsigned char checksum = 0;
195 static int found = 0; 195 static int found = 0;
196 int err; 196 int err;
197 DECLARE_MAC_BUF(mac);
198 197
199 if (found || macintosh_config->ether_type != MAC_ETHER_MACE) 198 if (found || macintosh_config->ether_type != MAC_ETHER_MACE)
200 return -ENODEV; 199 return -ENODEV;
@@ -249,8 +248,8 @@ static int __devinit mace_probe(struct platform_device *pdev)
249 dev->set_multicast_list = mace_set_multicast; 248 dev->set_multicast_list = mace_set_multicast;
250 dev->set_mac_address = mace_set_address; 249 dev->set_mac_address = mace_set_address;
251 250
252 printk(KERN_INFO "%s: 68K MACE, hardware address %s\n", 251 printk(KERN_INFO "%s: 68K MACE, hardware address %pM\n",
253 dev->name, print_mac(mac, dev->dev_addr)); 252 dev->name, dev->dev_addr);
254 253
255 err = register_netdev(dev); 254 err = register_netdev(dev);
256 if (!err) 255 if (!err)
@@ -674,7 +673,6 @@ static void mace_dma_rx_frame(struct net_device *dev, struct mace_frame *mf)
674 673
675 skb->protocol = eth_type_trans(skb, dev); 674 skb->protocol = eth_type_trans(skb, dev);
676 netif_rx(skb); 675 netif_rx(skb);
677 dev->last_rx = jiffies;
678 dev->stats.rx_packets++; 676 dev->stats.rx_packets++;
679 dev->stats.rx_bytes += frame_length; 677 dev->stats.rx_bytes += frame_length;
680 } 678 }
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index e64c2086d33c..205bb05c25d6 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -220,7 +220,6 @@ static int __init mac_onboard_sonic_ethernet_addr(struct net_device *dev)
220 struct sonic_local *lp = netdev_priv(dev); 220 struct sonic_local *lp = netdev_priv(dev);
221 const int prom_addr = ONBOARD_SONIC_PROM_BASE; 221 const int prom_addr = ONBOARD_SONIC_PROM_BASE;
222 int i; 222 int i;
223 DECLARE_MAC_BUF(mac);
224 223
225 /* On NuBus boards we can sometimes look in the ROM resources. 224 /* On NuBus boards we can sometimes look in the ROM resources.
226 No such luck for comm-slot/onboard. */ 225 No such luck for comm-slot/onboard. */
@@ -264,8 +263,8 @@ static int __init mac_onboard_sonic_ethernet_addr(struct net_device *dev)
264 dev->dev_addr[1] = val >> 8; 263 dev->dev_addr[1] = val >> 8;
265 dev->dev_addr[0] = val & 0xff; 264 dev->dev_addr[0] = val & 0xff;
266 265
267 printk(KERN_INFO "HW Address from CAM 15: %s\n", 266 printk(KERN_INFO "HW Address from CAM 15: %pM\n",
268 print_mac(mac, dev->dev_addr)); 267 dev->dev_addr);
269 } else return 0; 268 } else return 0;
270 269
271 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) && 270 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
@@ -560,7 +559,6 @@ static int __init mac_sonic_probe(struct platform_device *pdev)
560 struct net_device *dev; 559 struct net_device *dev;
561 struct sonic_local *lp; 560 struct sonic_local *lp;
562 int err; 561 int err;
563 DECLARE_MAC_BUF(mac);
564 562
565 dev = alloc_etherdev(sizeof(struct sonic_local)); 563 dev = alloc_etherdev(sizeof(struct sonic_local));
566 if (!dev) 564 if (!dev)
@@ -584,8 +582,7 @@ found:
584 if (err) 582 if (err)
585 goto out; 583 goto out;
586 584
587 printk("%s: MAC %s IRQ %d\n", 585 printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
588 dev->name, print_mac(mac, dev->dev_addr), dev->irq);
589 586
590 return 0; 587 return 0;
591 588
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 42394505bb50..cabde9ab0e4a 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -84,7 +84,6 @@ static void macvlan_broadcast(struct sk_buff *skb,
84 dev->stats.rx_bytes += skb->len + ETH_HLEN; 84 dev->stats.rx_bytes += skb->len + ETH_HLEN;
85 dev->stats.rx_packets++; 85 dev->stats.rx_packets++;
86 dev->stats.multicast++; 86 dev->stats.multicast++;
87 dev->last_rx = jiffies;
88 87
89 nskb->dev = dev; 88 nskb->dev = dev;
90 if (!compare_ether_addr(eth->h_dest, dev->broadcast)) 89 if (!compare_ether_addr(eth->h_dest, dev->broadcast))
@@ -133,7 +132,6 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb)
133 132
134 dev->stats.rx_bytes += skb->len + ETH_HLEN; 133 dev->stats.rx_bytes += skb->len + ETH_HLEN;
135 dev->stats.rx_packets++; 134 dev->stats.rx_packets++;
136 dev->last_rx = jiffies;
137 135
138 skb->dev = dev; 136 skb->dev = dev;
139 skb->pkt_type = PACKET_HOST; 137 skb->pkt_type = PACKET_HOST;
@@ -333,10 +331,34 @@ static u32 macvlan_ethtool_get_rx_csum(struct net_device *dev)
333 return lowerdev->ethtool_ops->get_rx_csum(lowerdev); 331 return lowerdev->ethtool_ops->get_rx_csum(lowerdev);
334} 332}
335 333
334static int macvlan_ethtool_get_settings(struct net_device *dev,
335 struct ethtool_cmd *cmd)
336{
337 const struct macvlan_dev *vlan = netdev_priv(dev);
338 struct net_device *lowerdev = vlan->lowerdev;
339
340 if (!lowerdev->ethtool_ops->get_settings)
341 return -EOPNOTSUPP;
342
343 return lowerdev->ethtool_ops->get_settings(lowerdev, cmd);
344}
345
346static u32 macvlan_ethtool_get_flags(struct net_device *dev)
347{
348 const struct macvlan_dev *vlan = netdev_priv(dev);
349 struct net_device *lowerdev = vlan->lowerdev;
350
351 if (!lowerdev->ethtool_ops->get_flags)
352 return 0;
353 return lowerdev->ethtool_ops->get_flags(lowerdev);
354}
355
336static const struct ethtool_ops macvlan_ethtool_ops = { 356static const struct ethtool_ops macvlan_ethtool_ops = {
337 .get_link = ethtool_op_get_link, 357 .get_link = ethtool_op_get_link,
358 .get_settings = macvlan_ethtool_get_settings,
338 .get_rx_csum = macvlan_ethtool_get_rx_csum, 359 .get_rx_csum = macvlan_ethtool_get_rx_csum,
339 .get_drvinfo = macvlan_ethtool_get_drvinfo, 360 .get_drvinfo = macvlan_ethtool_get_drvinfo,
361 .get_flags = macvlan_ethtool_get_flags,
340}; 362};
341 363
342static void macvlan_setup(struct net_device *dev) 364static void macvlan_setup(struct net_device *dev)
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index a1e22ed1f6ee..c336a1f42510 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -94,10 +94,9 @@ char o2meth_eaddr[8]={0,0,0,0,0,0,0,0};
94static inline void load_eaddr(struct net_device *dev) 94static inline void load_eaddr(struct net_device *dev)
95{ 95{
96 int i; 96 int i;
97 DECLARE_MAC_BUF(mac);
98 u64 macaddr; 97 u64 macaddr;
99 98
100 DPRINTK("Loading MAC Address: %s\n", print_mac(mac, dev->dev_addr)); 99 DPRINTK("Loading MAC Address: %pM\n", dev->dev_addr);
101 macaddr = 0; 100 macaddr = 0;
102 for (i = 0; i < 6; i++) 101 for (i = 0; i < 6; i++)
103 macaddr |= (u64)dev->dev_addr[i] << ((5 - i) * 8); 102 macaddr |= (u64)dev->dev_addr[i] << ((5 - i) * 8);
@@ -421,7 +420,6 @@ static void meth_rx(struct net_device* dev, unsigned long int_status)
421 skb_put(skb_c, len); 420 skb_put(skb_c, len);
422 priv->rx_skbs[priv->rx_write] = skb; 421 priv->rx_skbs[priv->rx_write] = skb;
423 skb_c->protocol = eth_type_trans(skb_c, dev); 422 skb_c->protocol = eth_type_trans(skb_c, dev);
424 dev->last_rx = jiffies;
425 dev->stats.rx_packets++; 423 dev->stats.rx_packets++;
426 dev->stats.rx_bytes += len; 424 dev->stats.rx_bytes += len;
427 netif_rx(skb_c); 425 netif_rx(skb_c);
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 6232227f56c3..944ad47c9519 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -776,8 +776,6 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
776 } else 776 } else
777 netif_receive_skb(skb); 777 netif_receive_skb(skb);
778 778
779 dev->last_rx = jiffies;
780
781next: 779next:
782 ++cq->mcq.cons_index; 780 ++cq->mcq.cons_index;
783 index = (cq->mcq.cons_index) & ring->size_mask; 781 index = (cq->mcq.cons_index) & ring->size_mask;
diff --git a/drivers/net/mlx4/mcg.c b/drivers/net/mlx4/mcg.c
index 592c01ae2c5d..b1622062b12d 100644
--- a/drivers/net/mlx4/mcg.c
+++ b/drivers/net/mlx4/mcg.c
@@ -118,17 +118,7 @@ static int find_mgm(struct mlx4_dev *dev,
118 return err; 118 return err;
119 119
120 if (0) 120 if (0)
121 mlx4_dbg(dev, "Hash for %04x:%04x:%04x:%04x:" 121 mlx4_dbg(dev, "Hash for %pI6 is %04x\n", gid, *hash);
122 "%04x:%04x:%04x:%04x is %04x\n",
123 be16_to_cpu(((__be16 *) gid)[0]),
124 be16_to_cpu(((__be16 *) gid)[1]),
125 be16_to_cpu(((__be16 *) gid)[2]),
126 be16_to_cpu(((__be16 *) gid)[3]),
127 be16_to_cpu(((__be16 *) gid)[4]),
128 be16_to_cpu(((__be16 *) gid)[5]),
129 be16_to_cpu(((__be16 *) gid)[6]),
130 be16_to_cpu(((__be16 *) gid)[7]),
131 *hash);
132 122
133 *index = *hash; 123 *index = *hash;
134 *prev = -1; 124 *prev = -1;
@@ -277,16 +267,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
277 goto out; 267 goto out;
278 268
279 if (index == -1) { 269 if (index == -1) {
280 mlx4_err(dev, "MGID %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x " 270 mlx4_err(dev, "MGID %pI6 not found\n", gid);
281 "not found\n",
282 be16_to_cpu(((__be16 *) gid)[0]),
283 be16_to_cpu(((__be16 *) gid)[1]),
284 be16_to_cpu(((__be16 *) gid)[2]),
285 be16_to_cpu(((__be16 *) gid)[3]),
286 be16_to_cpu(((__be16 *) gid)[4]),
287 be16_to_cpu(((__be16 *) gid)[5]),
288 be16_to_cpu(((__be16 *) gid)[6]),
289 be16_to_cpu(((__be16 *) gid)[7]));
290 err = -EINVAL; 271 err = -EINVAL;
291 goto out; 272 goto out;
292 } 273 }
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index 98ddc0811f93..24f6d2585a6e 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -58,17 +58,17 @@
58#define mlx4_dbg(mlevel, priv, format, arg...) \ 58#define mlx4_dbg(mlevel, priv, format, arg...) \
59 if (NETIF_MSG_##mlevel & priv->msg_enable) \ 59 if (NETIF_MSG_##mlevel & priv->msg_enable) \
60 printk(KERN_DEBUG "%s %s: " format , DRV_NAME ,\ 60 printk(KERN_DEBUG "%s %s: " format , DRV_NAME ,\
61 (&priv->mdev->pdev->dev)->bus_id , ## arg) 61 (dev_name(&priv->mdev->pdev->dev)) , ## arg)
62 62
63#define mlx4_err(mdev, format, arg...) \ 63#define mlx4_err(mdev, format, arg...) \
64 printk(KERN_ERR "%s %s: " format , DRV_NAME ,\ 64 printk(KERN_ERR "%s %s: " format , DRV_NAME ,\
65 (&mdev->pdev->dev)->bus_id , ## arg) 65 (dev_name(&mdev->pdev->dev)) , ## arg)
66#define mlx4_info(mdev, format, arg...) \ 66#define mlx4_info(mdev, format, arg...) \
67 printk(KERN_INFO "%s %s: " format , DRV_NAME ,\ 67 printk(KERN_INFO "%s %s: " format , DRV_NAME ,\
68 (&mdev->pdev->dev)->bus_id , ## arg) 68 (dev_name(&mdev->pdev->dev)) , ## arg)
69#define mlx4_warn(mdev, format, arg...) \ 69#define mlx4_warn(mdev, format, arg...) \
70 printk(KERN_WARNING "%s %s: " format , DRV_NAME ,\ 70 printk(KERN_WARNING "%s %s: " format , DRV_NAME ,\
71 (&mdev->pdev->dev)->bus_id , ## arg) 71 (dev_name(&mdev->pdev->dev)) , ## arg)
72 72
73/* 73/*
74 * Device constants 74 * Device constants
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b9dcdbd369f8..b13fbc4ebd87 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -557,8 +557,6 @@ static int rxq_process(struct rx_queue *rxq, int budget)
557 skb->protocol = eth_type_trans(skb, mp->dev); 557 skb->protocol = eth_type_trans(skb, mp->dev);
558 netif_receive_skb(skb); 558 netif_receive_skb(skb);
559 } 559 }
560
561 mp->dev->last_rx = jiffies;
562 } 560 }
563 561
564 if (rx < budget) 562 if (rx < budget)
@@ -2592,7 +2590,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
2592 struct mv643xx_eth_private *mp; 2590 struct mv643xx_eth_private *mp;
2593 struct net_device *dev; 2591 struct net_device *dev;
2594 struct resource *res; 2592 struct resource *res;
2595 DECLARE_MAC_BUF(mac);
2596 int err; 2593 int err;
2597 2594
2598 pd = pdev->dev.platform_data; 2595 pd = pdev->dev.platform_data;
@@ -2686,8 +2683,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
2686 if (err) 2683 if (err)
2687 goto out; 2684 goto out;
2688 2685
2689 dev_printk(KERN_NOTICE, &dev->dev, "port %d with MAC address %s\n", 2686 dev_printk(KERN_NOTICE, &dev->dev, "port %d with MAC address %pM\n",
2690 mp->port_num, print_mac(mac, dev->dev_addr)); 2687 mp->port_num, dev->dev_addr);
2691 2688
2692 if (mp->tx_desc_sram_size > 0) 2689 if (mp->tx_desc_sram_size > 0)
2693 dev_printk(KERN_NOTICE, &dev->dev, "configured with sram\n"); 2690 dev_printk(KERN_NOTICE, &dev->dev, "configured with sram\n");
diff --git a/drivers/net/mvme147.c b/drivers/net/mvme147.c
index 06ca4252155f..435e5a847c43 100644
--- a/drivers/net/mvme147.c
+++ b/drivers/net/mvme147.c
@@ -67,7 +67,6 @@ struct net_device * __init mvme147lance_probe(int unit)
67 u_long *addr; 67 u_long *addr;
68 u_long address; 68 u_long address;
69 int err; 69 int err;
70 DECLARE_MAC_BUF(mac);
71 70
72 if (!MACH_IS_MVME147 || called) 71 if (!MACH_IS_MVME147 || called)
73 return ERR_PTR(-ENODEV); 72 return ERR_PTR(-ENODEV);
@@ -102,11 +101,11 @@ struct net_device * __init mvme147lance_probe(int unit)
102 dev->dev_addr[3]=address&0xff; 101 dev->dev_addr[3]=address&0xff;
103 102
104 printk("%s: MVME147 at 0x%08lx, irq %d, " 103 printk("%s: MVME147 at 0x%08lx, irq %d, "
105 "Hardware Address %s\n", 104 "Hardware Address %pM\n",
106 dev->name, dev->base_addr, MVME147_LANCE_IRQ, 105 dev->name, dev->base_addr, MVME147_LANCE_IRQ,
107 print_mac(mac, dev->dev_addr)); 106 dev->dev_addr);
108 107
109 lp = (struct m147lance_private *)dev->priv; 108 lp = netdev_priv(dev);
110 lp->ram = __get_dma_pages(GFP_ATOMIC, 3); /* 16K */ 109 lp->ram = __get_dma_pages(GFP_ATOMIC, 3); /* 16K */
111 if (!lp->ram) 110 if (!lp->ram)
112 { 111 {
@@ -190,7 +189,7 @@ int __init init_module(void)
190 189
191void __exit cleanup_module(void) 190void __exit cleanup_module(void)
192{ 191{
193 struct m147lance_private *lp = dev_mvme147_lance->priv; 192 struct m147lance_private *lp = netdev_priv(dev_mvme147_lance);
194 unregister_netdev(dev_mvme147_lance); 193 unregister_netdev(dev_mvme147_lance);
195 free_pages(lp->ram, 3); 194 free_pages(lp->ram, 3);
196 free_netdev(dev_mvme147_lance); 195 free_netdev(dev_mvme147_lance);
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index b37867097308..56c6f876042c 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -1334,7 +1334,6 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, struct myri10ge_rx_buf *rx,
1334 myri10ge_vlan_ip_csum(skb, csum); 1334 myri10ge_vlan_ip_csum(skb, csum);
1335 } 1335 }
1336 netif_receive_skb(skb); 1336 netif_receive_skb(skb);
1337 dev->last_rx = jiffies;
1338 return 1; 1337 return 1;
1339} 1338}
1340 1339
@@ -2985,7 +2984,6 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
2985 struct dev_mc_list *mc_list; 2984 struct dev_mc_list *mc_list;
2986 __be32 data[2] = { 0, 0 }; 2985 __be32 data[2] = { 0, 0 };
2987 int err; 2986 int err;
2988 DECLARE_MAC_BUF(mac);
2989 2987
2990 /* can be called from atomic contexts, 2988 /* can be called from atomic contexts,
2991 * pass 1 to force atomicity in myri10ge_send_cmd() */ 2989 * pass 1 to force atomicity in myri10ge_send_cmd() */
@@ -3032,8 +3030,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
3032 printk(KERN_ERR "myri10ge: %s: Failed " 3030 printk(KERN_ERR "myri10ge: %s: Failed "
3033 "MXGEFW_JOIN_MULTICAST_GROUP, error status:" 3031 "MXGEFW_JOIN_MULTICAST_GROUP, error status:"
3034 "%d\t", dev->name, err); 3032 "%d\t", dev->name, err);
3035 printk(KERN_ERR "MAC %s\n", 3033 printk(KERN_ERR "MAC %pM\n", mc_list->dmi_addr);
3036 print_mac(mac, mc_list->dmi_addr));
3037 goto abort; 3034 goto abort;
3038 } 3035 }
3039 } 3036 }
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 3ad7589d6a1c..6833f65f8aec 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -318,13 +318,10 @@ static void myri_is_not_so_happy(struct myri_eth *mp)
318#ifdef DEBUG_HEADER 318#ifdef DEBUG_HEADER
319static void dump_ehdr(struct ethhdr *ehdr) 319static void dump_ehdr(struct ethhdr *ehdr)
320{ 320{
321 DECLARE_MAC_BUF(mac); 321 printk("ehdr[h_dst(%pM)"
322 DECLARE_MAC_BUF(mac2); 322 "h_source(%pM)"
323 printk("ehdr[h_dst(%s)"
324 "h_source(%s)"
325 "h_proto(%04x)]\n", 323 "h_proto(%04x)]\n",
326 print_mac(mac, ehdr->h_dest), print_mac(mac2, ehdr->h_source), 324 ehdr->h_dest, ehdr->h_source, ehdr->h_proto);
327 ehdr->h_proto);
328} 325}
329 326
330static void dump_ehdr_and_myripad(unsigned char *stuff) 327static void dump_ehdr_and_myripad(unsigned char *stuff)
@@ -528,7 +525,6 @@ static void myri_rx(struct myri_eth *mp, struct net_device *dev)
528 DRX(("prot[%04x] netif_rx ", skb->protocol)); 525 DRX(("prot[%04x] netif_rx ", skb->protocol));
529 netif_rx(skb); 526 netif_rx(skb);
530 527
531 dev->last_rx = jiffies;
532 dev->stats.rx_packets++; 528 dev->stats.rx_packets++;
533 dev->stats.rx_bytes += len; 529 dev->stats.rx_bytes += len;
534 next: 530 next:
@@ -540,7 +536,7 @@ static void myri_rx(struct myri_eth *mp, struct net_device *dev)
540static irqreturn_t myri_interrupt(int irq, void *dev_id) 536static irqreturn_t myri_interrupt(int irq, void *dev_id)
541{ 537{
542 struct net_device *dev = (struct net_device *) dev_id; 538 struct net_device *dev = (struct net_device *) dev_id;
543 struct myri_eth *mp = (struct myri_eth *) dev->priv; 539 struct myri_eth *mp = netdev_priv(dev);
544 void __iomem *lregs = mp->lregs; 540 void __iomem *lregs = mp->lregs;
545 struct myri_channel __iomem *chan = &mp->shmem->channel; 541 struct myri_channel __iomem *chan = &mp->shmem->channel;
546 unsigned long flags; 542 unsigned long flags;
@@ -579,14 +575,14 @@ static irqreturn_t myri_interrupt(int irq, void *dev_id)
579 575
580static int myri_open(struct net_device *dev) 576static int myri_open(struct net_device *dev)
581{ 577{
582 struct myri_eth *mp = (struct myri_eth *) dev->priv; 578 struct myri_eth *mp = netdev_priv(dev);
583 579
584 return myri_init(mp, in_interrupt()); 580 return myri_init(mp, in_interrupt());
585} 581}
586 582
587static int myri_close(struct net_device *dev) 583static int myri_close(struct net_device *dev)
588{ 584{
589 struct myri_eth *mp = (struct myri_eth *) dev->priv; 585 struct myri_eth *mp = netdev_priv(dev);
590 586
591 myri_clean_rings(mp); 587 myri_clean_rings(mp);
592 return 0; 588 return 0;
@@ -594,7 +590,7 @@ static int myri_close(struct net_device *dev)
594 590
595static void myri_tx_timeout(struct net_device *dev) 591static void myri_tx_timeout(struct net_device *dev)
596{ 592{
597 struct myri_eth *mp = (struct myri_eth *) dev->priv; 593 struct myri_eth *mp = netdev_priv(dev);
598 594
599 printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name); 595 printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
600 596
@@ -605,7 +601,7 @@ static void myri_tx_timeout(struct net_device *dev)
605 601
606static int myri_start_xmit(struct sk_buff *skb, struct net_device *dev) 602static int myri_start_xmit(struct sk_buff *skb, struct net_device *dev)
607{ 603{
608 struct myri_eth *mp = (struct myri_eth *) dev->priv; 604 struct myri_eth *mp = netdev_priv(dev);
609 struct sendq __iomem *sq = mp->sq; 605 struct sendq __iomem *sq = mp->sq;
610 struct myri_txd __iomem *txd; 606 struct myri_txd __iomem *txd;
611 unsigned long flags; 607 unsigned long flags;
@@ -905,7 +901,6 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic
905 struct device_node *dp = op->node; 901 struct device_node *dp = op->node;
906 static unsigned version_printed; 902 static unsigned version_printed;
907 struct net_device *dev; 903 struct net_device *dev;
908 DECLARE_MAC_BUF(mac);
909 struct myri_eth *mp; 904 struct myri_eth *mp;
910 const void *prop; 905 const void *prop;
911 static int num; 906 static int num;
@@ -1088,8 +1083,8 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic
1088 1083
1089 num++; 1084 num++;
1090 1085
1091 printk("%s: MyriCOM MyriNET Ethernet %s\n", 1086 printk("%s: MyriCOM MyriNET Ethernet %pM\n",
1092 dev->name, print_mac(mac, dev->dev_addr)); 1087 dev->name, dev->dev_addr);
1093 1088
1094 return 0; 1089 return 0;
1095 1090
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index f7fa3944659b..9f81fcb96882 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -792,7 +792,6 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
792 const int pcibar = 1; /* PCI base address register */ 792 const int pcibar = 1; /* PCI base address register */
793 int prev_eedata; 793 int prev_eedata;
794 u32 tmp; 794 u32 tmp;
795 DECLARE_MAC_BUF(mac);
796 795
797/* when built into the kernel, we only print version if device is found */ 796/* when built into the kernel, we only print version if device is found */
798#ifndef MODULE 797#ifndef MODULE
@@ -948,10 +947,10 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
948 947
949 if (netif_msg_drv(np)) { 948 if (netif_msg_drv(np)) {
950 printk(KERN_INFO "natsemi %s: %s at %#08llx " 949 printk(KERN_INFO "natsemi %s: %s at %#08llx "
951 "(%s), %s, IRQ %d", 950 "(%s), %pM, IRQ %d",
952 dev->name, natsemi_pci_info[chip_idx].name, 951 dev->name, natsemi_pci_info[chip_idx].name,
953 (unsigned long long)iostart, pci_name(np->pci_dev), 952 (unsigned long long)iostart, pci_name(np->pci_dev),
954 print_mac(mac, dev->dev_addr), irq); 953 dev->dev_addr, irq);
955 if (dev->if_port == PORT_TP) 954 if (dev->if_port == PORT_TP)
956 printk(", port TP.\n"); 955 printk(", port TP.\n");
957 else if (np->ignore_phy) 956 else if (np->ignore_phy)
@@ -2362,7 +2361,6 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do)
2362 } 2361 }
2363 skb->protocol = eth_type_trans(skb, dev); 2362 skb->protocol = eth_type_trans(skb, dev);
2364 netif_receive_skb(skb); 2363 netif_receive_skb(skb);
2365 dev->last_rx = jiffies;
2366 np->stats.rx_packets++; 2364 np->stats.rx_packets++;
2367 np->stats.rx_bytes += pkt_len; 2365 np->stats.rx_bytes += pkt_len;
2368 } 2366 }
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index fbc7531d3c7d..aa99f5e09d37 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -204,7 +204,6 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
204 static unsigned version_printed; 204 static unsigned version_printed;
205 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 205 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
206 unsigned char bus_width; 206 unsigned char bus_width;
207 DECLARE_MAC_BUF(mac);
208 207
209 if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME)) 208 if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME))
210 return -EBUSY; 209 return -EBUSY;
@@ -299,7 +298,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
299 298
300 for(i = 0; i < ETHER_ADDR_LEN; i++) 299 for(i = 0; i < ETHER_ADDR_LEN; i++)
301 dev->dev_addr[i] = SA_prom[i]; 300 dev->dev_addr[i] = SA_prom[i];
302 printk(" %s\n", print_mac(mac, dev->dev_addr)); 301 printk(" %pM\n", dev->dev_addr);
303 302
304 printk("%s: %s found at %#x, using IRQ %d.\n", 303 printk("%s: %s found at %#x, using IRQ %d.\n",
305 dev->name, name, ioaddr, dev->irq); 304 dev->name, name, ioaddr, dev->irq);
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index eb681c0d51ba..f708712a374a 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -297,7 +297,6 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
297 int neX000, ctron, copam, bad_card; 297 int neX000, ctron, copam, bad_card;
298 int reg0, ret; 298 int reg0, ret;
299 static unsigned version_printed; 299 static unsigned version_printed;
300 DECLARE_MAC_BUF(mac);
301 300
302 if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME)) 301 if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME))
303 return -EBUSY; 302 return -EBUSY;
@@ -517,7 +516,7 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
517 } 516 }
518#endif 517#endif
519 518
520 printk("%s\n", print_mac(mac, dev->dev_addr)); 519 printk("%pM\n", dev->dev_addr);
521 520
522 ei_status.name = name; 521 ei_status.name = name;
523 ei_status.tx_start_page = start_page; 522 ei_status.tx_start_page = start_page;
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index 332df75a9ab6..6f8f32603466 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -302,7 +302,6 @@ out:
302static int ne2_procinfo(char *buf, int slot, struct net_device *dev) 302static int ne2_procinfo(char *buf, int slot, struct net_device *dev)
303{ 303{
304 int len=0; 304 int len=0;
305 DECLARE_MAC_BUF(mac);
306 305
307 len += sprintf(buf+len, "The NE/2 Ethernet Adapter\n" ); 306 len += sprintf(buf+len, "The NE/2 Ethernet Adapter\n" );
308 len += sprintf(buf+len, "Driver written by Wim Dumon "); 307 len += sprintf(buf+len, "Driver written by Wim Dumon ");
@@ -313,7 +312,7 @@ static int ne2_procinfo(char *buf, int slot, struct net_device *dev)
313 len += sprintf(buf+len, "Based on the original NE2000 drivers\n" ); 312 len += sprintf(buf+len, "Based on the original NE2000 drivers\n" );
314 len += sprintf(buf+len, "Base IO: %#x\n", (unsigned int)dev->base_addr); 313 len += sprintf(buf+len, "Base IO: %#x\n", (unsigned int)dev->base_addr);
315 len += sprintf(buf+len, "IRQ : %d\n", dev->irq); 314 len += sprintf(buf+len, "IRQ : %d\n", dev->irq);
316 len += sprintf(buf+len, "HW addr : %s\n", print_mac(mac, dev->dev_addr)); 315 len += sprintf(buf+len, "HW addr : %pM\n", dev->dev_addr);
317 316
318 return len; 317 return len;
319} 318}
@@ -326,7 +325,6 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
326 const char *name = "NE/2"; 325 const char *name = "NE/2";
327 int start_page, stop_page; 326 int start_page, stop_page;
328 static unsigned version_printed; 327 static unsigned version_printed;
329 DECLARE_MAC_BUF(mac);
330 328
331 if (ei_debug && version_printed++ == 0) 329 if (ei_debug && version_printed++ == 0)
332 printk(version); 330 printk(version);
@@ -469,7 +467,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
469 for(i = 0; i < ETHER_ADDR_LEN; i++) 467 for(i = 0; i < ETHER_ADDR_LEN; i++)
470 dev->dev_addr[i] = SA_prom[i]; 468 dev->dev_addr[i] = SA_prom[i];
471 469
472 printk(" %s\n", print_mac(mac, dev->dev_addr)); 470 printk(" %pM\n", dev->dev_addr);
473 471
474 printk("%s: %s found at %#x, using IRQ %d.\n", 472 printk("%s: %s found at %#x, using IRQ %d.\n",
475 dev->name, name, base_addr, dev->irq); 473 dev->name, name, base_addr, dev->irq);
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index de0de744a8fa..ea22ae268a5d 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -212,7 +212,6 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
212 static unsigned int fnd_cnt; 212 static unsigned int fnd_cnt;
213 long ioaddr; 213 long ioaddr;
214 int flags = pci_clone_list[chip_idx].flags; 214 int flags = pci_clone_list[chip_idx].flags;
215 DECLARE_MAC_BUF(mac);
216 215
217/* when built into the kernel, we only print version if device is found */ 216/* when built into the kernel, we only print version if device is found */
218#ifndef MODULE 217#ifndef MODULE
@@ -368,9 +367,9 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
368 367
369 for(i = 0; i < 6; i++) 368 for(i = 0; i < 6; i++)
370 dev->dev_addr[i] = SA_prom[i]; 369 dev->dev_addr[i] = SA_prom[i];
371 printk("%s: %s found at %#lx, IRQ %d, %s.\n", 370 printk("%s: %s found at %#lx, IRQ %d, %pM.\n",
372 dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq, 371 dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq,
373 print_mac(mac, dev->dev_addr)); 372 dev->dev_addr);
374 373
375 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 374 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
376 375
@@ -626,7 +625,7 @@ static void ne2k_pci_block_output(struct net_device *dev, int count,
626static void ne2k_pci_get_drvinfo(struct net_device *dev, 625static void ne2k_pci_get_drvinfo(struct net_device *dev,
627 struct ethtool_drvinfo *info) 626 struct ethtool_drvinfo *info)
628{ 627{
629 struct ei_device *ei = dev->priv; 628 struct ei_device *ei = netdev_priv(dev);
630 struct pci_dev *pci_dev = (struct pci_dev *) ei->priv; 629 struct pci_dev *pci_dev = (struct pci_dev *) ei->priv;
631 630
632 strcpy(info->driver, DRV_NAME); 631 strcpy(info->driver, DRV_NAME);
diff --git a/drivers/net/ne3210.c b/drivers/net/ne3210.c
index 425043a88db9..6681ca748c74 100644
--- a/drivers/net/ne3210.c
+++ b/drivers/net/ne3210.c
@@ -99,7 +99,6 @@ static int __init ne3210_eisa_probe (struct device *device)
99 int i, retval, port_index; 99 int i, retval, port_index;
100 struct eisa_device *edev = to_eisa_device (device); 100 struct eisa_device *edev = to_eisa_device (device);
101 struct net_device *dev; 101 struct net_device *dev;
102 DECLARE_MAC_BUF(mac);
103 102
104 /* Allocate dev->priv and fill in 8390 specific dev fields. */ 103 /* Allocate dev->priv and fill in 8390 specific dev fields. */
105 if (!(dev = alloc_ei_netdev ())) { 104 if (!(dev = alloc_ei_netdev ())) {
@@ -131,8 +130,8 @@ static int __init ne3210_eisa_probe (struct device *device)
131 port_index = inb(ioaddr + NE3210_CFG2) >> 6; 130 port_index = inb(ioaddr + NE3210_CFG2) >> 6;
132 for(i = 0; i < ETHER_ADDR_LEN; i++) 131 for(i = 0; i < ETHER_ADDR_LEN; i++)
133 dev->dev_addr[i] = inb(ioaddr + NE3210_SA_PROM + i); 132 dev->dev_addr[i] = inb(ioaddr + NE3210_SA_PROM + i);
134 printk("ne3210.c: NE3210 in EISA slot %d, media: %s, addr: %s.\n", 133 printk("ne3210.c: NE3210 in EISA slot %d, media: %s, addr: %pM.\n",
135 edev->slot, ifmap[port_index], print_mac(mac, dev->dev_addr)); 134 edev->slot, ifmap[port_index], dev->dev_addr);
136 135
137 /* Snarf the interrupt now. CFG file has them all listed as `edge' with share=NO */ 136 /* Snarf the interrupt now. CFG file has them all listed as `edge' with share=NO */
138 dev->irq = irq_map[(inb(ioaddr + NE3210_CFG2) >> 3) & 0x07]; 137 dev->irq = irq_map[(inb(ioaddr + NE3210_CFG2) >> 3) & 0x07];
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 9681618c3232..d304d38cd5d1 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -307,17 +307,14 @@ static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
307static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) 307static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
308{ 308{
309 struct net_device *dev = nt->np.dev; 309 struct net_device *dev = nt->np.dev;
310 static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
310 311
311 DECLARE_MAC_BUF(mac); 312 return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast);
312 return snprintf(buf, PAGE_SIZE, "%s\n", dev ?
313 print_mac(mac, dev->dev_addr) : "ff:ff:ff:ff:ff:ff");
314} 313}
315 314
316static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf) 315static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
317{ 316{
318 DECLARE_MAC_BUF(mac); 317 return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac);
319 return snprintf(buf, PAGE_SIZE, "%s\n",
320 print_mac(mac, nt->np.remote_mac));
321} 318}
322 319
323/* 320/*
diff --git a/drivers/net/netx-eth.c b/drivers/net/netx-eth.c
index b9bed82e1d21..b418771f6811 100644
--- a/drivers/net/netx-eth.c
+++ b/drivers/net/netx-eth.c
@@ -165,7 +165,6 @@ static void netx_eth_receive(struct net_device *ndev)
165 pfifo_push(EMPTY_PTR_FIFO(priv->id), 165 pfifo_push(EMPTY_PTR_FIFO(priv->id),
166 FIFO_PTR_SEGMENT(seg) | FIFO_PTR_FRAMENO(frameno)); 166 FIFO_PTR_SEGMENT(seg) | FIFO_PTR_FRAMENO(frameno));
167 167
168 ndev->last_rx = jiffies;
169 skb->protocol = eth_type_trans(skb, ndev); 168 skb->protocol = eth_type_trans(skb, ndev);
170 netif_rx(skb); 169 netif_rx(skb);
171 ndev->stats.rx_packets++; 170 ndev->stats.rx_packets++;
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 84978f80f396..86379fdd8b0e 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -537,7 +537,7 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
537static int nx_p3_sre_macaddr_change(struct net_device *dev, 537static int nx_p3_sre_macaddr_change(struct net_device *dev,
538 u8 *addr, unsigned op) 538 u8 *addr, unsigned op)
539{ 539{
540 struct netxen_adapter *adapter = (struct netxen_adapter *)dev->priv; 540 struct netxen_adapter *adapter = netdev_priv(dev);
541 nx_nic_req_t req; 541 nx_nic_req_t req;
542 nx_mac_req_t mac_req; 542 nx_mac_req_t mac_req;
543 int rv; 543 int rv;
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 5bba675d0504..d924468e506e 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -1285,9 +1285,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1285 } 1285 }
1286 adapter->stats.rxdropped++; 1286 adapter->stats.rxdropped++;
1287 } else { 1287 } else {
1288
1289 netif_receive_skb(skb); 1288 netif_receive_skb(skb);
1290 netdev->last_rx = jiffies;
1291 1289
1292 adapter->stats.no_rcv++; 1290 adapter->stats.no_rcv++;
1293 adapter->stats.rxbytes += length; 1291 adapter->stats.rxbytes += length;
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 6ef3f0d84bcf..25bfb3acf5e4 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -439,7 +439,6 @@ netxen_read_mac_addr(struct netxen_adapter *adapter)
439 int i; 439 int i;
440 unsigned char *p; 440 unsigned char *p;
441 __le64 mac_addr; 441 __le64 mac_addr;
442 DECLARE_MAC_BUF(mac);
443 struct net_device *netdev = adapter->netdev; 442 struct net_device *netdev = adapter->netdev;
444 struct pci_dev *pdev = adapter->pdev; 443 struct pci_dev *pdev = adapter->pdev;
445 444
@@ -462,10 +461,9 @@ netxen_read_mac_addr(struct netxen_adapter *adapter)
462 461
463 /* set station address */ 462 /* set station address */
464 463
465 if (!is_valid_ether_addr(netdev->perm_addr)) { 464 if (!is_valid_ether_addr(netdev->perm_addr))
466 dev_warn(&pdev->dev, "Bad MAC address %s.\n", 465 dev_warn(&pdev->dev, "Bad MAC address %pM.\n", netdev->dev_addr);
467 print_mac(mac, netdev->dev_addr)); 466 else
468 } else
469 adapter->macaddr_set(adapter, netdev->dev_addr); 467 adapter->macaddr_set(adapter, netdev->dev_addr);
470 468
471 return 0; 469 return 0;
@@ -543,7 +541,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
543 541
544 SET_NETDEV_DEV(netdev, &pdev->dev); 542 SET_NETDEV_DEV(netdev, &pdev->dev);
545 543
546 adapter = netdev->priv; 544 adapter = netdev_priv(netdev);
547 adapter->netdev = netdev; 545 adapter->netdev = netdev;
548 adapter->pdev = pdev; 546 adapter->pdev = pdev;
549 adapter->ahw.pci_func = pci_func_id; 547 adapter->ahw.pci_func = pci_func_id;
@@ -988,7 +986,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
988 */ 986 */
989static int netxen_nic_open(struct net_device *netdev) 987static int netxen_nic_open(struct net_device *netdev)
990{ 988{
991 struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv; 989 struct netxen_adapter *adapter = netdev_priv(netdev);
992 int err = 0; 990 int err = 0;
993 int ctx, ring; 991 int ctx, ring;
994 irq_handler_t handler; 992 irq_handler_t handler;
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
index 27f07f6a45b1..c3b9c83b32fe 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -608,7 +608,6 @@ int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
608 int phy = adapter->physical_port; 608 int phy = adapter->physical_port;
609 unsigned char mac_addr[6]; 609 unsigned char mac_addr[6];
610 int i; 610 int i;
611 DECLARE_MAC_BUF(mac);
612 611
613 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 612 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
614 return 0; 613 return 0;
@@ -636,10 +635,8 @@ int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
636 if (i == 10) { 635 if (i == 10) {
637 printk(KERN_ERR "%s: cannot set Mac addr for %s\n", 636 printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
638 netxen_nic_driver_name, adapter->netdev->name); 637 netxen_nic_driver_name, adapter->netdev->name);
639 printk(KERN_ERR "MAC address set: %s.\n", 638 printk(KERN_ERR "MAC address set: %pM.\n", addr);
640 print_mac(mac, addr)); 639 printk(KERN_ERR "MAC address get: %pM.\n", mac_addr);
641 printk(KERN_ERR "MAC address get: %s.\n",
642 print_mac(mac, mac_addr));
643 } 640 }
644 return 0; 641 return 0;
645} 642}
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c
index 8e0ca9f4e404..0cf6addbe40f 100644
--- a/drivers/net/ni5010.c
+++ b/drivers/net/ni5010.c
@@ -203,7 +203,6 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
203 unsigned int data = 0; 203 unsigned int data = 0;
204 int boguscount = 40; 204 int boguscount = 40;
205 int err = -ENODEV; 205 int err = -ENODEV;
206 DECLARE_MAC_BUF(mac);
207 206
208 dev->base_addr = ioaddr; 207 dev->base_addr = ioaddr;
209 dev->irq = irq; 208 dev->irq = irq;
@@ -271,7 +270,7 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
271 outw(i, IE_GP); 270 outw(i, IE_GP);
272 dev->dev_addr[i] = inb(IE_SAPROM); 271 dev->dev_addr[i] = inb(IE_SAPROM);
273 } 272 }
274 printk("%s ", print_mac(mac, dev->dev_addr)); 273 printk("%pM ", dev->dev_addr);
275 274
276 PRINTK2((KERN_DEBUG "%s: I/O #4 passed!\n", dev->name)); 275 PRINTK2((KERN_DEBUG "%s: I/O #4 passed!\n", dev->name));
277 276
@@ -329,7 +328,7 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
329 outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */ 328 outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */
330 } 329 }
331 printk("-> bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE); 330 printk("-> bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE);
332 memset(dev->priv, 0, sizeof(struct ni5010_local)); 331 memset(netdev_priv(dev), 0, sizeof(struct ni5010_local));
333 332
334 dev->open = ni5010_open; 333 dev->open = ni5010_open;
335 dev->stop = ni5010_close; 334 dev->stop = ni5010_close;
@@ -570,7 +569,6 @@ static void ni5010_rx(struct net_device *dev)
570 569
571 skb->protocol = eth_type_trans(skb,dev); 570 skb->protocol = eth_type_trans(skb,dev);
572 netif_rx(skb); 571 netif_rx(skb);
573 dev->last_rx = jiffies;
574 dev->stats.rx_packets++; 572 dev->stats.rx_packets++;
575 dev->stats.rx_bytes += i_pkt_size; 573 dev->stats.rx_bytes += i_pkt_size;
576 574
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index b9a882d362da..10cfd0f91fc0 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -214,7 +214,7 @@ struct priv {
214/* wait for command with timeout: */ 214/* wait for command with timeout: */
215static void wait_for_scb_cmd(struct net_device *dev) 215static void wait_for_scb_cmd(struct net_device *dev)
216{ 216{
217 struct priv *p = dev->priv; 217 struct priv *p = netdev_priv(dev);
218 int i; 218 int i;
219 for (i = 0; i < 16384; i++) { 219 for (i = 0; i < 16384; i++) {
220 if (readb(&p->scb->cmd_cuc) == 0) 220 if (readb(&p->scb->cmd_cuc) == 0)
@@ -233,7 +233,7 @@ static void wait_for_scb_cmd(struct net_device *dev)
233 233
234static void wait_for_scb_cmd_ruc(struct net_device *dev) 234static void wait_for_scb_cmd_ruc(struct net_device *dev)
235{ 235{
236 struct priv *p = dev->priv; 236 struct priv *p = netdev_priv(dev);
237 int i; 237 int i;
238 for (i = 0; i < 16384; i++) { 238 for (i = 0; i < 16384; i++) {
239 if (readb(&p->scb->cmd_ruc) == 0) 239 if (readb(&p->scb->cmd_ruc) == 0)
@@ -298,7 +298,7 @@ static int ni52_open(struct net_device *dev)
298static int check_iscp(struct net_device *dev, void __iomem *addr) 298static int check_iscp(struct net_device *dev, void __iomem *addr)
299{ 299{
300 struct iscp_struct __iomem *iscp = addr; 300 struct iscp_struct __iomem *iscp = addr;
301 struct priv *p = dev->priv; 301 struct priv *p = netdev_priv(dev);
302 memset_io(iscp, 0, sizeof(struct iscp_struct)); 302 memset_io(iscp, 0, sizeof(struct iscp_struct));
303 303
304 writel(make24(iscp), &p->scp->iscp); 304 writel(make24(iscp), &p->scp->iscp);
@@ -318,7 +318,7 @@ static int check_iscp(struct net_device *dev, void __iomem *addr)
318 */ 318 */
319static int check586(struct net_device *dev, unsigned size) 319static int check586(struct net_device *dev, unsigned size)
320{ 320{
321 struct priv *p = dev->priv; 321 struct priv *p = netdev_priv(dev);
322 int i; 322 int i;
323 323
324 p->mapped = ioremap(dev->mem_start, size); 324 p->mapped = ioremap(dev->mem_start, size);
@@ -354,7 +354,7 @@ Enodev:
354 */ 354 */
355static void alloc586(struct net_device *dev) 355static void alloc586(struct net_device *dev)
356{ 356{
357 struct priv *p = (struct priv *) dev->priv; 357 struct priv *p = netdev_priv(dev);
358 358
359 ni_reset586(); 359 ni_reset586();
360 mdelay(32); 360 mdelay(32);
@@ -400,7 +400,7 @@ struct net_device * __init ni52_probe(int unit)
400 if (!dev) 400 if (!dev)
401 return ERR_PTR(-ENOMEM); 401 return ERR_PTR(-ENOMEM);
402 402
403 p = dev->priv; 403 p = netdev_priv(dev);
404 404
405 if (unit >= 0) { 405 if (unit >= 0) {
406 sprintf(dev->name, "eth%d", unit); 406 sprintf(dev->name, "eth%d", unit);
@@ -446,7 +446,7 @@ out:
446static int __init ni52_probe1(struct net_device *dev, int ioaddr) 446static int __init ni52_probe1(struct net_device *dev, int ioaddr)
447{ 447{
448 int i, size, retval; 448 int i, size, retval;
449 struct priv *priv = dev->priv; 449 struct priv *priv = netdev_priv(dev);
450 450
451 dev->base_addr = ioaddr; 451 dev->base_addr = ioaddr;
452 dev->irq = irq; 452 dev->irq = irq;
@@ -588,7 +588,7 @@ static int init586(struct net_device *dev)
588{ 588{
589 void __iomem *ptr; 589 void __iomem *ptr;
590 int i, result = 0; 590 int i, result = 0;
591 struct priv *p = (struct priv *)dev->priv; 591 struct priv *p = netdev_priv(dev);
592 struct configure_cmd_struct __iomem *cfg_cmd; 592 struct configure_cmd_struct __iomem *cfg_cmd;
593 struct iasetup_cmd_struct __iomem *ias_cmd; 593 struct iasetup_cmd_struct __iomem *ias_cmd;
594 struct tdr_cmd_struct __iomem *tdr_cmd; 594 struct tdr_cmd_struct __iomem *tdr_cmd;
@@ -829,7 +829,7 @@ static void __iomem *alloc_rfa(struct net_device *dev, void __iomem *ptr)
829 struct rfd_struct __iomem *rfd = ptr; 829 struct rfd_struct __iomem *rfd = ptr;
830 struct rbd_struct __iomem *rbd; 830 struct rbd_struct __iomem *rbd;
831 int i; 831 int i;
832 struct priv *p = (struct priv *) dev->priv; 832 struct priv *p = netdev_priv(dev);
833 833
834 memset_io(rfd, 0, 834 memset_io(rfd, 0,
835 sizeof(struct rfd_struct) * (p->num_recv_buffs + rfdadd)); 835 sizeof(struct rfd_struct) * (p->num_recv_buffs + rfdadd));
@@ -878,7 +878,7 @@ static irqreturn_t ni52_interrupt(int irq, void *dev_id)
878 int cnt = 0; 878 int cnt = 0;
879 struct priv *p; 879 struct priv *p;
880 880
881 p = (struct priv *) dev->priv; 881 p = netdev_priv(dev);
882 882
883 if (debuglevel > 1) 883 if (debuglevel > 1)
884 printk("I"); 884 printk("I");
@@ -950,7 +950,7 @@ static void ni52_rcv_int(struct net_device *dev)
950 unsigned short totlen; 950 unsigned short totlen;
951 struct sk_buff *skb; 951 struct sk_buff *skb;
952 struct rbd_struct __iomem *rbd; 952 struct rbd_struct __iomem *rbd;
953 struct priv *p = (struct priv *)dev->priv; 953 struct priv *p = netdev_priv(dev);
954 954
955 if (debuglevel > 0) 955 if (debuglevel > 0)
956 printk("R"); 956 printk("R");
@@ -970,7 +970,6 @@ static void ni52_rcv_int(struct net_device *dev)
970 memcpy_fromio(skb->data, p->base + readl(&rbd->buffer), totlen); 970 memcpy_fromio(skb->data, p->base + readl(&rbd->buffer), totlen);
971 skb->protocol = eth_type_trans(skb, dev); 971 skb->protocol = eth_type_trans(skb, dev);
972 netif_rx(skb); 972 netif_rx(skb);
973 dev->last_rx = jiffies;
974 p->stats.rx_packets++; 973 p->stats.rx_packets++;
975 p->stats.rx_bytes += totlen; 974 p->stats.rx_bytes += totlen;
976 } else 975 } else
@@ -1040,7 +1039,7 @@ static void ni52_rcv_int(struct net_device *dev)
1040 1039
1041static void ni52_rnr_int(struct net_device *dev) 1040static void ni52_rnr_int(struct net_device *dev)
1042{ 1041{
1043 struct priv *p = (struct priv *) dev->priv; 1042 struct priv *p = netdev_priv(dev);
1044 1043
1045 p->stats.rx_errors++; 1044 p->stats.rx_errors++;
1046 1045
@@ -1065,7 +1064,7 @@ static void ni52_rnr_int(struct net_device *dev)
1065static void ni52_xmt_int(struct net_device *dev) 1064static void ni52_xmt_int(struct net_device *dev)
1066{ 1065{
1067 int status; 1066 int status;
1068 struct priv *p = (struct priv *) dev->priv; 1067 struct priv *p = netdev_priv(dev);
1069 1068
1070 if (debuglevel > 0) 1069 if (debuglevel > 0)
1071 printk("X"); 1070 printk("X");
@@ -1113,7 +1112,7 @@ static void ni52_xmt_int(struct net_device *dev)
1113 1112
1114static void startrecv586(struct net_device *dev) 1113static void startrecv586(struct net_device *dev)
1115{ 1114{
1116 struct priv *p = (struct priv *) dev->priv; 1115 struct priv *p = netdev_priv(dev);
1117 1116
1118 wait_for_scb_cmd(dev); 1117 wait_for_scb_cmd(dev);
1119 wait_for_scb_cmd_ruc(dev); 1118 wait_for_scb_cmd_ruc(dev);
@@ -1126,7 +1125,7 @@ static void startrecv586(struct net_device *dev)
1126 1125
1127static void ni52_timeout(struct net_device *dev) 1126static void ni52_timeout(struct net_device *dev)
1128{ 1127{
1129 struct priv *p = (struct priv *) dev->priv; 1128 struct priv *p = netdev_priv(dev);
1130#ifndef NO_NOPCOMMANDS 1129#ifndef NO_NOPCOMMANDS
1131 if (readb(&p->scb->cus) & CU_ACTIVE) { /* COMMAND-UNIT active? */ 1130 if (readb(&p->scb->cus) & CU_ACTIVE) { /* COMMAND-UNIT active? */
1132 netif_wake_queue(dev); 1131 netif_wake_queue(dev);
@@ -1177,7 +1176,7 @@ static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev)
1177#ifndef NO_NOPCOMMANDS 1176#ifndef NO_NOPCOMMANDS
1178 int next_nop; 1177 int next_nop;
1179#endif 1178#endif
1180 struct priv *p = (struct priv *) dev->priv; 1179 struct priv *p = netdev_priv(dev);
1181 1180
1182 if (skb->len > XMIT_BUFF_SIZE) { 1181 if (skb->len > XMIT_BUFF_SIZE) {
1183 printk(KERN_ERR "%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n", dev->name, XMIT_BUFF_SIZE, skb->len); 1182 printk(KERN_ERR "%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n", dev->name, XMIT_BUFF_SIZE, skb->len);
@@ -1274,7 +1273,7 @@ static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev)
1274 1273
1275static struct net_device_stats *ni52_get_stats(struct net_device *dev) 1274static struct net_device_stats *ni52_get_stats(struct net_device *dev)
1276{ 1275{
1277 struct priv *p = (struct priv *) dev->priv; 1276 struct priv *p = netdev_priv(dev);
1278 unsigned short crc, aln, rsc, ovrn; 1277 unsigned short crc, aln, rsc, ovrn;
1279 1278
1280 /* Get error-statistics from the ni82586 */ 1279 /* Get error-statistics from the ni82586 */
@@ -1337,7 +1336,7 @@ int __init init_module(void)
1337 1336
1338void __exit cleanup_module(void) 1337void __exit cleanup_module(void)
1339{ 1338{
1340 struct priv *p = dev_ni52->priv; 1339 struct priv *p = netdev_priv(dev_ni52);
1341 unregister_netdev(dev_ni52); 1340 unregister_netdev(dev_ni52);
1342 iounmap(p->mapped); 1341 iounmap(p->mapped);
1343 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE); 1342 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE);
diff --git a/drivers/net/ni65.c b/drivers/net/ni65.c
index 3edc971d0eca..24e393b3e0b7 100644
--- a/drivers/net/ni65.c
+++ b/drivers/net/ni65.c
@@ -1113,7 +1113,6 @@ static void ni65_recv_intr(struct net_device *dev,int csr0)
1113 p->stats.rx_bytes += len; 1113 p->stats.rx_bytes += len;
1114 skb->protocol=eth_type_trans(skb,dev); 1114 skb->protocol=eth_type_trans(skb,dev);
1115 netif_rx(skb); 1115 netif_rx(skb);
1116 dev->last_rx = jiffies;
1117 } 1116 }
1118 else 1117 else
1119 { 1118 {
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 1b6f548c4411..5ddca4e3d27b 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -3392,8 +3392,6 @@ static int niu_process_rx_pkt(struct niu *np, struct rx_ring_info *rp)
3392 skb->protocol = eth_type_trans(skb, np->dev); 3392 skb->protocol = eth_type_trans(skb, np->dev);
3393 netif_receive_skb(skb); 3393 netif_receive_skb(skb);
3394 3394
3395 np->dev->last_rx = jiffies;
3396
3397 return num_rcr; 3395 return num_rcr;
3398} 3396}
3399 3397
@@ -8909,10 +8907,8 @@ static void __devinit niu_assign_netdev_ops(struct net_device *dev)
8909static void __devinit niu_device_announce(struct niu *np) 8907static void __devinit niu_device_announce(struct niu *np)
8910{ 8908{
8911 struct net_device *dev = np->dev; 8909 struct net_device *dev = np->dev;
8912 DECLARE_MAC_BUF(mac);
8913 8910
8914 pr_info("%s: NIU Ethernet %s\n", 8911 pr_info("%s: NIU Ethernet %pM\n", dev->name, dev->dev_addr);
8915 dev->name, print_mac(mac, dev->dev_addr));
8916 8912
8917 if (np->parent->plat_type == PLAT_TYPE_ATCA_CP3220) { 8913 if (np->parent->plat_type == PLAT_TYPE_ATCA_CP3220) {
8918 pr_info("%s: Port type[%s] mode[%s:%s] XCVR[%s] phy[%s]\n", 8914 pr_info("%s: Port type[%s] mode[%s:%s] XCVR[%s] phy[%s]\n",
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index ff449619f047..4bb64415437f 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -1955,7 +1955,6 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1955 long addr; 1955 long addr;
1956 int err; 1956 int err;
1957 int using_dac = 0; 1957 int using_dac = 0;
1958 DECLARE_MAC_BUF(mac);
1959 1958
1960 /* See if we can set the dma mask early on; failure is fatal. */ 1959 /* See if we can set the dma mask early on; failure is fatal. */
1961 if (sizeof(dma_addr_t) == 8 && 1960 if (sizeof(dma_addr_t) == 8 &&
@@ -2220,12 +2219,11 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
2220 ndev->features |= NETIF_F_HIGHDMA; 2219 ndev->features |= NETIF_F_HIGHDMA;
2221 } 2220 }
2222 2221
2223 printk(KERN_INFO "%s: ns83820 v" VERSION ": DP83820 v%u.%u: %s io=0x%08lx irq=%d f=%s\n", 2222 printk(KERN_INFO "%s: ns83820 v" VERSION ": DP83820 v%u.%u: %pM io=0x%08lx irq=%d f=%s\n",
2224 ndev->name, 2223 ndev->name,
2225 (unsigned)readl(dev->base + SRR) >> 8, 2224 (unsigned)readl(dev->base + SRR) >> 8,
2226 (unsigned)readl(dev->base + SRR) & 0xff, 2225 (unsigned)readl(dev->base + SRR) & 0xff,
2227 print_mac(mac, ndev->dev_addr), 2226 ndev->dev_addr, addr, pci_dev->irq,
2228 addr, pci_dev->irq,
2229 (ndev->features & NETIF_F_HIGHDMA) ? "h,sg" : "sg" 2227 (ndev->features & NETIF_F_HIGHDMA) ? "h,sg" : "sg"
2230 ); 2228 );
2231 2229
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index edc0fd588985..fcbf6ccd0a85 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -1105,7 +1105,8 @@ static int pasemi_mac_phy_init(struct net_device *dev)
1105 goto err; 1105 goto err;
1106 1106
1107 phy_id = *prop; 1107 phy_id = *prop;
1108 snprintf(mac->phy_id, BUS_ID_SIZE, "%x:%02x", (int)r.start, phy_id); 1108 snprintf(mac->phy_id, sizeof(mac->phy_id), "%x:%02x",
1109 (int)r.start, phy_id);
1109 1110
1110 of_node_put(phy_dn); 1111 of_node_put(phy_dn);
1111 1112
@@ -1742,7 +1743,6 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1742 struct net_device *dev; 1743 struct net_device *dev;
1743 struct pasemi_mac *mac; 1744 struct pasemi_mac *mac;
1744 int err; 1745 int err;
1745 DECLARE_MAC_BUF(mac_buf);
1746 1746
1747 err = pci_enable_device(pdev); 1747 err = pci_enable_device(pdev);
1748 if (err) 1748 if (err)
@@ -1849,9 +1849,9 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1849 err); 1849 err);
1850 goto out; 1850 goto out;
1851 } else if netif_msg_probe(mac) 1851 } else if netif_msg_probe(mac)
1852 printk(KERN_INFO "%s: PA Semi %s: intf %d, hw addr %s\n", 1852 printk(KERN_INFO "%s: PA Semi %s: intf %d, hw addr %pM\n",
1853 dev->name, mac->type == MAC_TYPE_GMAC ? "GMAC" : "XAUI", 1853 dev->name, mac->type == MAC_TYPE_GMAC ? "GMAC" : "XAUI",
1854 mac->dma_if, print_mac(mac_buf, dev->dev_addr)); 1854 mac->dma_if, dev->dev_addr);
1855 1855
1856 return err; 1856 return err;
1857 1857
diff --git a/drivers/net/pasemi_mac_ethtool.c b/drivers/net/pasemi_mac_ethtool.c
index 5e8df3afea64..064a4fe1dd90 100644
--- a/drivers/net/pasemi_mac_ethtool.c
+++ b/drivers/net/pasemi_mac_ethtool.c
@@ -109,7 +109,7 @@ static void
109pasemi_mac_ethtool_get_ringparam(struct net_device *netdev, 109pasemi_mac_ethtool_get_ringparam(struct net_device *netdev,
110 struct ethtool_ringparam *ering) 110 struct ethtool_ringparam *ering)
111{ 111{
112 struct pasemi_mac *mac = netdev->priv; 112 struct pasemi_mac *mac = netdev_priv(netdev);
113 113
114 ering->tx_max_pending = TX_RING_SIZE/2; 114 ering->tx_max_pending = TX_RING_SIZE/2;
115 ering->tx_pending = RING_USED(mac->tx)/2; 115 ering->tx_pending = RING_USED(mac->tx)/2;
@@ -130,7 +130,7 @@ static int pasemi_mac_get_sset_count(struct net_device *netdev, int sset)
130static void pasemi_mac_get_ethtool_stats(struct net_device *netdev, 130static void pasemi_mac_get_ethtool_stats(struct net_device *netdev,
131 struct ethtool_stats *stats, u64 *data) 131 struct ethtool_stats *stats, u64 *data)
132{ 132{
133 struct pasemi_mac *mac = netdev->priv; 133 struct pasemi_mac *mac = netdev_priv(netdev);
134 int i; 134 int i;
135 135
136 data[0] = pasemi_read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if)) 136 data[0] = pasemi_read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if))
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index 0a575fef29e6..b23b5c397b1d 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -737,7 +737,6 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
737 int i, addr_len, option; 737 int i, addr_len, option;
738 void *ioaddr = NULL; 738 void *ioaddr = NULL;
739 static int board_idx = -1; 739 static int board_idx = -1;
740 DECLARE_MAC_BUF(mac);
741 740
742/* when built into the kernel, we only print version if device is found */ 741/* when built into the kernel, we only print version if device is found */
743#ifndef MODULE 742#ifndef MODULE
@@ -797,11 +796,11 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
797 796
798 tp->phys[0] = 32; 797 tp->phys[0] = 32;
799 798
800 printk (KERN_INFO "%s: %s at 0x%lx, %sIRQ %d\n", 799 printk (KERN_INFO "%s: %s at 0x%lx, %pM IRQ %d\n",
801 dev->name, 800 dev->name,
802 board_info[ent->driver_data].name, 801 board_info[ent->driver_data].name,
803 dev->base_addr, 802 dev->base_addr,
804 print_mac(mac, dev->dev_addr), 803 dev->dev_addr,
805 dev->irq); 804 dev->irq);
806 805
807 printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n", 806 printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n",
@@ -1566,7 +1565,6 @@ static void netdrv_rx_interrupt (struct net_device *dev,
1566 1565
1567 skb->protocol = eth_type_trans (skb, dev); 1566 skb->protocol = eth_type_trans (skb, dev);
1568 netif_rx (skb); 1567 netif_rx (skb);
1569 dev->last_rx = jiffies;
1570 dev->stats.rx_bytes += pkt_size; 1568 dev->stats.rx_bytes += pkt_size;
1571 dev->stats.rx_packets++; 1569 dev->stats.rx_packets++;
1572 } else { 1570 } else {
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 08c4dd896077..e5cb6b1f0ebd 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -345,7 +345,6 @@ static int tc574_config(struct pcmcia_device *link)
345 __be16 *phys_addr; 345 __be16 *phys_addr;
346 char *cardname; 346 char *cardname;
347 __u32 config; 347 __u32 config;
348 DECLARE_MAC_BUF(mac);
349 348
350 phys_addr = (__be16 *)dev->dev_addr; 349 phys_addr = (__be16 *)dev->dev_addr;
351 350
@@ -463,9 +462,9 @@ static int tc574_config(struct pcmcia_device *link)
463 strcpy(lp->node.dev_name, dev->name); 462 strcpy(lp->node.dev_name, dev->name);
464 463
465 printk(KERN_INFO "%s: %s at io %#3lx, irq %d, " 464 printk(KERN_INFO "%s: %s at io %#3lx, irq %d, "
466 "hw_addr %s.\n", 465 "hw_addr %pM.\n",
467 dev->name, cardname, dev->base_addr, dev->irq, 466 dev->name, cardname, dev->base_addr, dev->irq,
468 print_mac(mac, dev->dev_addr)); 467 dev->dev_addr);
469 printk(" %dK FIFO split %s Rx:Tx, %sMII interface.\n", 468 printk(" %dK FIFO split %s Rx:Tx, %sMII interface.\n",
470 8 << config & Ram_size, 469 8 << config & Ram_size,
471 ram_split[(config & Ram_split) >> Ram_split_shift], 470 ram_split[(config & Ram_split) >> Ram_split_shift],
@@ -1062,7 +1061,6 @@ static int el3_rx(struct net_device *dev, int worklimit)
1062 ((pkt_len+3)>>2)); 1061 ((pkt_len+3)>>2));
1063 skb->protocol = eth_type_trans(skb, dev); 1062 skb->protocol = eth_type_trans(skb, dev);
1064 netif_rx(skb); 1063 netif_rx(skb);
1065 dev->last_rx = jiffies;
1066 dev->stats.rx_packets++; 1064 dev->stats.rx_packets++;
1067 dev->stats.rx_bytes += pkt_len; 1065 dev->stats.rx_bytes += pkt_len;
1068 } else { 1066 } else {
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index c235cdba69c6..73ecc657999d 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -255,7 +255,6 @@ static int tc589_config(struct pcmcia_device *link)
255 int last_fn, last_ret, i, j, multi = 0, fifo; 255 int last_fn, last_ret, i, j, multi = 0, fifo;
256 unsigned int ioaddr; 256 unsigned int ioaddr;
257 char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 257 char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
258 DECLARE_MAC_BUF(mac);
259 258
260 DEBUG(0, "3c589_config(0x%p)\n", link); 259 DEBUG(0, "3c589_config(0x%p)\n", link);
261 260
@@ -333,9 +332,9 @@ static int tc589_config(struct pcmcia_device *link)
333 strcpy(lp->node.dev_name, dev->name); 332 strcpy(lp->node.dev_name, dev->name);
334 333
335 printk(KERN_INFO "%s: 3Com 3c%s, io %#3lx, irq %d, " 334 printk(KERN_INFO "%s: 3Com 3c%s, io %#3lx, irq %d, "
336 "hw_addr %s\n", 335 "hw_addr %pM\n",
337 dev->name, (multi ? "562" : "589"), dev->base_addr, dev->irq, 336 dev->name, (multi ? "562" : "589"), dev->base_addr, dev->irq,
338 print_mac(mac, dev->dev_addr)); 337 dev->dev_addr);
339 printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n", 338 printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n",
340 (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], 339 (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3],
341 if_names[dev->if_port]); 340 if_names[dev->if_port]);
@@ -884,7 +883,6 @@ static int el3_rx(struct net_device *dev)
884 (pkt_len+3)>>2); 883 (pkt_len+3)>>2);
885 skb->protocol = eth_type_trans(skb, dev); 884 skb->protocol = eth_type_trans(skb, dev);
886 netif_rx(skb); 885 netif_rx(skb);
887 dev->last_rx = jiffies;
888 dev->stats.rx_packets++; 886 dev->stats.rx_packets++;
889 dev->stats.rx_bytes += pkt_len; 887 dev->stats.rx_bytes += pkt_len;
890 } else { 888 } else {
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index b37a498939ae..2aca8df34970 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -321,7 +321,6 @@ static int axnet_config(struct pcmcia_device *link)
321 struct net_device *dev = link->priv; 321 struct net_device *dev = link->priv;
322 axnet_dev_t *info = PRIV(dev); 322 axnet_dev_t *info = PRIV(dev);
323 int i, j, last_ret, last_fn; 323 int i, j, last_ret, last_fn;
324 DECLARE_MAC_BUF(mac);
325 324
326 DEBUG(0, "axnet_config(0x%p)\n", link); 325 DEBUG(0, "axnet_config(0x%p)\n", link);
327 326
@@ -397,10 +396,10 @@ static int axnet_config(struct pcmcia_device *link)
397 strcpy(info->node.dev_name, dev->name); 396 strcpy(info->node.dev_name, dev->name);
398 397
399 printk(KERN_INFO "%s: Asix AX88%d90: io %#3lx, irq %d, " 398 printk(KERN_INFO "%s: Asix AX88%d90: io %#3lx, irq %d, "
400 "hw_addr %s\n", 399 "hw_addr %pM\n",
401 dev->name, ((info->flags & IS_AX88790) ? 7 : 1), 400 dev->name, ((info->flags & IS_AX88790) ? 7 : 1),
402 dev->base_addr, dev->irq, 401 dev->base_addr, dev->irq,
403 print_mac(mac, dev->dev_addr)); 402 dev->dev_addr);
404 if (info->phy_id != -1) { 403 if (info->phy_id != -1) {
405 DEBUG(0, " MII transceiver at index %d, status %x.\n", info->phy_id, j); 404 DEBUG(0, " MII transceiver at index %d, status %x.\n", info->phy_id, j);
406 } else { 405 } else {
@@ -1493,7 +1492,6 @@ static void ei_receive(struct net_device *dev)
1493 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame)); 1492 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
1494 skb->protocol=eth_type_trans(skb,dev); 1493 skb->protocol=eth_type_trans(skb,dev);
1495 netif_rx(skb); 1494 netif_rx(skb);
1496 dev->last_rx = jiffies;
1497 dev->stats.rx_packets++; 1495 dev->stats.rx_packets++;
1498 dev->stats.rx_bytes += pkt_len; 1496 dev->stats.rx_bytes += pkt_len;
1499 if (pkt_stat & ENRSR_PHY) 1497 if (pkt_stat & ENRSR_PHY)
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 831090c75622..7b5c77b7bd27 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -155,7 +155,7 @@ static int com20020_probe(struct pcmcia_device *p_dev)
155 if (!dev) 155 if (!dev)
156 goto fail_alloc_dev; 156 goto fail_alloc_dev;
157 157
158 lp = dev->priv; 158 lp = netdev_priv(dev);
159 lp->timeout = timeout; 159 lp->timeout = timeout;
160 lp->backplane = backplane; 160 lp->backplane = backplane;
161 lp->clockp = clockp; 161 lp->clockp = clockp;
@@ -303,7 +303,7 @@ static int com20020_config(struct pcmcia_device *link)
303 goto failed; 303 goto failed;
304 } 304 }
305 305
306 lp = dev->priv; 306 lp = netdev_priv(dev);
307 lp->card_name = "PCMCIA COM20020"; 307 lp->card_name = "PCMCIA COM20020";
308 lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */ 308 lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
309 309
@@ -364,7 +364,7 @@ static int com20020_resume(struct pcmcia_device *link)
364 364
365 if (link->open) { 365 if (link->open) {
366 int ioaddr = dev->base_addr; 366 int ioaddr = dev->base_addr;
367 struct arcnet_local *lp = dev->priv; 367 struct arcnet_local *lp = netdev_priv(dev);
368 ARCRESET; 368 ARCRESET;
369 } 369 }
370 370
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 69d916daa7bb..69dcfbbabe82 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -125,6 +125,7 @@ typedef struct local_info_t {
125 u_short tx_queue_len; 125 u_short tx_queue_len;
126 cardtype_t cardtype; 126 cardtype_t cardtype;
127 u_short sent; 127 u_short sent;
128 u_char __iomem *base;
128} local_info_t; 129} local_info_t;
129 130
130#define MC_FILTERBREAK 64 131#define MC_FILTERBREAK 64
@@ -242,6 +243,7 @@ static int fmvj18x_probe(struct pcmcia_device *link)
242 lp = netdev_priv(dev); 243 lp = netdev_priv(dev);
243 link->priv = dev; 244 link->priv = dev;
244 lp->p_dev = link; 245 lp->p_dev = link;
246 lp->base = NULL;
245 247
246 /* The io structure describes IO port mapping */ 248 /* The io structure describes IO port mapping */
247 link->io.NumPorts1 = 32; 249 link->io.NumPorts1 = 32;
@@ -348,7 +350,6 @@ static int fmvj18x_config(struct pcmcia_device *link)
348 cardtype_t cardtype; 350 cardtype_t cardtype;
349 char *card_name = "unknown"; 351 char *card_name = "unknown";
350 u_char *node_id; 352 u_char *node_id;
351 DECLARE_MAC_BUF(mac);
352 353
353 DEBUG(0, "fmvj18x_config(0x%p)\n", link); 354 DEBUG(0, "fmvj18x_config(0x%p)\n", link);
354 355
@@ -443,8 +444,10 @@ static int fmvj18x_config(struct pcmcia_device *link)
443 dev->irq = link->irq.AssignedIRQ; 444 dev->irq = link->irq.AssignedIRQ;
444 dev->base_addr = link->io.BasePort1; 445 dev->base_addr = link->io.BasePort1;
445 446
446 if (link->io.BasePort2 != 0) 447 if (link->io.BasePort2 != 0) {
447 fmvj18x_setup_mfc(link); 448 ret = fmvj18x_setup_mfc(link);
449 if (ret != 0) goto failed;
450 }
448 451
449 ioaddr = dev->base_addr; 452 ioaddr = dev->base_addr;
450 453
@@ -539,9 +542,9 @@ static int fmvj18x_config(struct pcmcia_device *link)
539 542
540 /* print current configuration */ 543 /* print current configuration */
541 printk(KERN_INFO "%s: %s, sram %s, port %#3lx, irq %d, " 544 printk(KERN_INFO "%s: %s, sram %s, port %#3lx, irq %d, "
542 "hw_addr %s\n", 545 "hw_addr %pM\n",
543 dev->name, card_name, sram_config == 0 ? "4K TX*2" : "8K TX*2", 546 dev->name, card_name, sram_config == 0 ? "4K TX*2" : "8K TX*2",
544 dev->base_addr, dev->irq, print_mac(mac, dev->dev_addr)); 547 dev->base_addr, dev->irq, dev->dev_addr);
545 548
546 return 0; 549 return 0;
547 550
@@ -611,10 +614,10 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link)
611{ 614{
612 win_req_t req; 615 win_req_t req;
613 memreq_t mem; 616 memreq_t mem;
614 u_char __iomem *base; 617 int i;
615 int i, j;
616 struct net_device *dev = link->priv; 618 struct net_device *dev = link->priv;
617 unsigned int ioaddr; 619 unsigned int ioaddr;
620 local_info_t *lp = netdev_priv(dev);
618 621
619 /* Allocate a small memory window */ 622 /* Allocate a small memory window */
620 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 623 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
@@ -626,25 +629,32 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link)
626 return -1; 629 return -1;
627 } 630 }
628 631
629 base = ioremap(req.Base, req.Size); 632 lp->base = ioremap(req.Base, req.Size);
633 if (lp->base == NULL) {
634 printk(KERN_NOTICE "fmvj18x_cs: ioremap failed\n");
635 return -1;
636 }
637
630 mem.Page = 0; 638 mem.Page = 0;
631 mem.CardOffset = 0; 639 mem.CardOffset = 0;
632 pcmcia_map_mem_page(link->win, &mem); 640 i = pcmcia_map_mem_page(link->win, &mem);
633 641 if (i != 0) {
642 iounmap(lp->base);
643 lp->base = NULL;
644 cs_error(link, MapMemPage, i);
645 return -1;
646 }
647
634 ioaddr = dev->base_addr; 648 ioaddr = dev->base_addr;
635 writeb(0x47, base+0x800); /* Config Option Register of LAN */ 649 writeb(0x47, lp->base+0x800); /* Config Option Register of LAN */
636 writeb(0x0, base+0x802); /* Config and Status Register */ 650 writeb(0x0, lp->base+0x802); /* Config and Status Register */
637 651
638 writeb(ioaddr & 0xff, base+0x80a); /* I/O Base(Low) of LAN */ 652 writeb(ioaddr & 0xff, lp->base+0x80a); /* I/O Base(Low) of LAN */
639 writeb((ioaddr >> 8) & 0xff, base+0x80c); /* I/O Base(High) of LAN */ 653 writeb((ioaddr >> 8) & 0xff, lp->base+0x80c); /* I/O Base(High) of LAN */
640 654
641 writeb(0x45, base+0x820); /* Config Option Register of Modem */ 655 writeb(0x45, lp->base+0x820); /* Config Option Register of Modem */
642 writeb(0x8, base+0x822); /* Config and Status Register */ 656 writeb(0x8, lp->base+0x822); /* Config and Status Register */
643 657
644 iounmap(base);
645 j = pcmcia_release_window(link->win);
646 if (j != 0)
647 cs_error(link, ReleaseWindow, j);
648 return 0; 658 return 0;
649 659
650} 660}
@@ -652,8 +662,25 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link)
652 662
653static void fmvj18x_release(struct pcmcia_device *link) 663static void fmvj18x_release(struct pcmcia_device *link)
654{ 664{
655 DEBUG(0, "fmvj18x_release(0x%p)\n", link); 665
656 pcmcia_disable_device(link); 666 struct net_device *dev = link->priv;
667 local_info_t *lp = netdev_priv(dev);
668 u_char __iomem *tmp;
669 int j;
670
671 DEBUG(0, "fmvj18x_release(0x%p)\n", link);
672
673 if (lp->base != NULL) {
674 tmp = lp->base;
675 lp->base = NULL; /* set NULL before iounmap */
676 iounmap(tmp);
677 j = pcmcia_release_window(link->win);
678 if (j != 0)
679 cs_error(link, ReleaseWindow, j);
680 }
681
682 pcmcia_disable_device(link);
683
657} 684}
658 685
659static int fmvj18x_suspend(struct pcmcia_device *link) 686static int fmvj18x_suspend(struct pcmcia_device *link)
@@ -784,6 +811,13 @@ static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
784 811
785 outb(D_TX_INTR, ioaddr + TX_INTR); 812 outb(D_TX_INTR, ioaddr + TX_INTR);
786 outb(D_RX_INTR, ioaddr + RX_INTR); 813 outb(D_RX_INTR, ioaddr + RX_INTR);
814
815 if (lp->base != NULL) {
816 /* Ack interrupt for multifunction card */
817 writeb(0x01, lp->base+0x802);
818 writeb(0x09, lp->base+0x822);
819 }
820
787 return IRQ_HANDLED; 821 return IRQ_HANDLED;
788 822
789} /* fjn_interrupt */ 823} /* fjn_interrupt */
@@ -1036,7 +1070,6 @@ static void fjn_rx(struct net_device *dev)
1036#endif 1070#endif
1037 1071
1038 netif_rx(skb); 1072 netif_rx(skb);
1039 dev->last_rx = jiffies;
1040 lp->stats.rx_packets++; 1073 lp->stats.rx_packets++;
1041 lp->stats.rx_bytes += pkt_len; 1074 lp->stats.rx_bytes += pkt_len;
1042 } 1075 }
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 448cd40aeba5..ec7c588c9ae5 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -659,7 +659,6 @@ static int nmclan_config(struct pcmcia_device *link)
659 u_char buf[64]; 659 u_char buf[64];
660 int i, last_ret, last_fn; 660 int i, last_ret, last_fn;
661 unsigned int ioaddr; 661 unsigned int ioaddr;
662 DECLARE_MAC_BUF(mac);
663 662
664 DEBUG(0, "nmclan_config(0x%p)\n", link); 663 DEBUG(0, "nmclan_config(0x%p)\n", link);
665 664
@@ -719,9 +718,9 @@ static int nmclan_config(struct pcmcia_device *link)
719 strcpy(lp->node.dev_name, dev->name); 718 strcpy(lp->node.dev_name, dev->name);
720 719
721 printk(KERN_INFO "%s: nmclan: port %#3lx, irq %d, %s port," 720 printk(KERN_INFO "%s: nmclan: port %#3lx, irq %d, %s port,"
722 " hw_addr %s\n", 721 " hw_addr %pM\n",
723 dev->name, dev->base_addr, dev->irq, if_names[dev->if_port], 722 dev->name, dev->base_addr, dev->irq, if_names[dev->if_port],
724 print_mac(mac, dev->dev_addr)); 723 dev->dev_addr);
725 return 0; 724 return 0;
726 725
727cs_failed: 726cs_failed:
@@ -1193,7 +1192,6 @@ static int mace_rx(struct net_device *dev, unsigned char RxCnt)
1193 1192
1194 netif_rx(skb); /* Send the packet to the upper (protocol) layers. */ 1193 netif_rx(skb); /* Send the packet to the upper (protocol) layers. */
1195 1194
1196 dev->last_rx = jiffies;
1197 lp->linux_stats.rx_packets++; 1195 lp->linux_stats.rx_packets++;
1198 lp->linux_stats.rx_bytes += pkt_len; 1196 lp->linux_stats.rx_bytes += pkt_len;
1199 outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */ 1197 outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index e40d6301aa7a..69625373a8ed 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -554,7 +554,6 @@ static int pcnet_config(struct pcmcia_device *link)
554 int last_ret, last_fn, start_pg, stop_pg, cm_offset; 554 int last_ret, last_fn, start_pg, stop_pg, cm_offset;
555 int has_shmem = 0; 555 int has_shmem = 0;
556 hw_info_t *local_hw_info; 556 hw_info_t *local_hw_info;
557 DECLARE_MAC_BUF(mac);
558 557
559 DEBUG(0, "pcnet_config(0x%p)\n", link); 558 DEBUG(0, "pcnet_config(0x%p)\n", link);
560 559
@@ -675,7 +674,7 @@ static int pcnet_config(struct pcmcia_device *link)
675 printk (" mem %#5lx,", dev->mem_start); 674 printk (" mem %#5lx,", dev->mem_start);
676 if (info->flags & HAS_MISC_REG) 675 if (info->flags & HAS_MISC_REG)
677 printk(" %s xcvr,", if_names[dev->if_port]); 676 printk(" %s xcvr,", if_names[dev->if_port]);
678 printk(" hw_addr %s\n", print_mac(mac, dev->dev_addr)); 677 printk(" hw_addr %pM\n", dev->dev_addr);
679 return 0; 678 return 0;
680 679
681cs_failed: 680cs_failed:
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index c74d6656d266..fccd53ef3c64 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -949,7 +949,6 @@ static int smc91c92_config(struct pcmcia_device *link)
949 int i, j, rev; 949 int i, j, rev;
950 unsigned int ioaddr; 950 unsigned int ioaddr;
951 u_long mir; 951 u_long mir;
952 DECLARE_MAC_BUF(mac);
953 952
954 DEBUG(0, "smc91c92_config(0x%p)\n", link); 953 DEBUG(0, "smc91c92_config(0x%p)\n", link);
955 954
@@ -1062,9 +1061,9 @@ static int smc91c92_config(struct pcmcia_device *link)
1062 strcpy(smc->node.dev_name, dev->name); 1061 strcpy(smc->node.dev_name, dev->name);
1063 1062
1064 printk(KERN_INFO "%s: smc91c%s rev %d: io %#3lx, irq %d, " 1063 printk(KERN_INFO "%s: smc91c%s rev %d: io %#3lx, irq %d, "
1065 "hw_addr %s\n", 1064 "hw_addr %pM\n",
1066 dev->name, name, (rev & 0x0f), dev->base_addr, dev->irq, 1065 dev->name, name, (rev & 0x0f), dev->base_addr, dev->irq,
1067 print_mac(mac, dev->dev_addr)); 1066 dev->dev_addr);
1068 1067
1069 if (rev > 0) { 1068 if (rev > 0) {
1070 if (mir & 0x3ff) 1069 if (mir & 0x3ff)
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index e1fd585e7131..fef7e1861d6a 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -772,7 +772,6 @@ xirc2ps_config(struct pcmcia_device * link)
772 int err, i; 772 int err, i;
773 u_char buf[64]; 773 u_char buf[64];
774 cistpl_lan_node_id_t *node_id = (cistpl_lan_node_id_t*)parse.funce.data; 774 cistpl_lan_node_id_t *node_id = (cistpl_lan_node_id_t*)parse.funce.data;
775 DECLARE_MAC_BUF(mac);
776 775
777 local->dingo_ccr = NULL; 776 local->dingo_ccr = NULL;
778 777
@@ -1051,9 +1050,9 @@ xirc2ps_config(struct pcmcia_device * link)
1051 strcpy(local->node.dev_name, dev->name); 1050 strcpy(local->node.dev_name, dev->name);
1052 1051
1053 /* give some infos about the hardware */ 1052 /* give some infos about the hardware */
1054 printk(KERN_INFO "%s: %s: port %#3lx, irq %d, hwaddr %s\n", 1053 printk(KERN_INFO "%s: %s: port %#3lx, irq %d, hwaddr %pM\n",
1055 dev->name, local->manf_str,(u_long)dev->base_addr, (int)dev->irq, 1054 dev->name, local->manf_str,(u_long)dev->base_addr, (int)dev->irq,
1056 print_mac(mac, dev->dev_addr)); 1055 dev->dev_addr);
1057 1056
1058 return 0; 1057 return 0;
1059 1058
@@ -1243,7 +1242,6 @@ xirc2ps_interrupt(int irq, void *dev_id)
1243 } 1242 }
1244 skb->protocol = eth_type_trans(skb, dev); 1243 skb->protocol = eth_type_trans(skb, dev);
1245 netif_rx(skb); 1244 netif_rx(skb);
1246 dev->last_rx = jiffies;
1247 lp->stats.rx_packets++; 1245 lp->stats.rx_packets++;
1248 lp->stats.rx_bytes += pktlen; 1246 lp->stats.rx_bytes += pktlen;
1249 if (!(rsr & PhyPkt)) 1247 if (!(rsr & PhyPkt))
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index ca8c0e037400..f2b192c80e17 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1246,7 +1246,6 @@ static void pcnet32_rx_entry(struct net_device *dev,
1246 dev->stats.rx_bytes += skb->len; 1246 dev->stats.rx_bytes += skb->len;
1247 skb->protocol = eth_type_trans(skb, dev); 1247 skb->protocol = eth_type_trans(skb, dev);
1248 netif_receive_skb(skb); 1248 netif_receive_skb(skb);
1249 dev->last_rx = jiffies;
1250 dev->stats.rx_packets++; 1249 dev->stats.rx_packets++;
1251 return; 1250 return;
1252} 1251}
@@ -1747,8 +1746,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1747 memset(dev->dev_addr, 0, sizeof(dev->dev_addr)); 1746 memset(dev->dev_addr, 0, sizeof(dev->dev_addr));
1748 1747
1749 if (pcnet32_debug & NETIF_MSG_PROBE) { 1748 if (pcnet32_debug & NETIF_MSG_PROBE) {
1750 DECLARE_MAC_BUF(mac); 1749 printk(" %pM", dev->dev_addr);
1751 printk(" %s", print_mac(mac, dev->dev_addr));
1752 1750
1753 /* Version 0x2623 and 0x2624 */ 1751 /* Version 0x2623 and 0x2624 */
1754 if (((chip_version + 1) & 0xfffe) == 0x2624) { 1752 if (((chip_version + 1) & 0xfffe) == 0x2624) {
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d55932acd887..c4c5a2f8ec74 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -84,10 +84,13 @@ config MDIO_BITBANG
84 84
85 If in doubt, say N. 85 If in doubt, say N.
86 86
87config MDIO_OF_GPIO 87config MDIO_GPIO
88 tristate "Support for GPIO lib-based bitbanged MDIO buses" 88 tristate "Support for GPIO lib-based bitbanged MDIO buses"
89 depends on MDIO_BITBANG && OF_GPIO 89 depends on MDIO_BITBANG && GENERIC_GPIO
90 ---help--- 90 ---help---
91 Supports GPIO lib-based MDIO busses. 91 Supports GPIO lib-based MDIO busses.
92 92
93 To compile this driver as a module, choose M here: the module
94 will be called mdio-gpio.
95
93endif # PHYLIB 96endif # PHYLIB
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index eee329fa6f53..9ae5d30b5f4e 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -15,4 +15,4 @@ obj-$(CONFIG_ICPLUS_PHY) += icplus.o
15obj-$(CONFIG_REALTEK_PHY) += realtek.o 15obj-$(CONFIG_REALTEK_PHY) += realtek.o
16obj-$(CONFIG_FIXED_PHY) += fixed.o 16obj-$(CONFIG_FIXED_PHY) += fixed.o
17obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o 17obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
18obj-$(CONFIG_MDIO_OF_GPIO) += mdio-ofgpio.o 18obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 4b4dc98ad165..fd4fc66b6d6e 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -17,6 +17,8 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/phy.h> 18#include <linux/phy.h>
19 19
20#define PHY_ID_BCM50610 0x0143bd60
21
20#define MII_BCM54XX_ECR 0x10 /* BCM54xx extended control register */ 22#define MII_BCM54XX_ECR 0x10 /* BCM54xx extended control register */
21#define MII_BCM54XX_ECR_IM 0x1000 /* Interrupt mask */ 23#define MII_BCM54XX_ECR_IM 0x1000 /* Interrupt mask */
22#define MII_BCM54XX_ECR_IF 0x0800 /* Interrupt force */ 24#define MII_BCM54XX_ECR_IF 0x0800 /* Interrupt force */
@@ -54,6 +56,21 @@
54#define MII_BCM54XX_SHD_DATA(x) ((x & 0x3ff) << 0) 56#define MII_BCM54XX_SHD_DATA(x) ((x & 0x3ff) << 0)
55 57
56/* 58/*
59 * AUXILIARY CONTROL SHADOW ACCESS REGISTERS. (PHY REG 0x18)
60 */
61#define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL 0x0000
62#define MII_BCM54XX_AUXCTL_ACTL_TX_6DB 0x0400
63#define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA 0x0800
64
65#define MII_BCM54XX_AUXCTL_MISC_WREN 0x8000
66#define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX 0x0200
67#define MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC 0x7000
68#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC 0x0007
69
70#define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL 0x0000
71
72
73/*
57 * Broadcom LED source encodings. These are used in BCM5461, BCM5481, 74 * Broadcom LED source encodings. These are used in BCM5461, BCM5481,
58 * BCM5482, and possibly some others. 75 * BCM5482, and possibly some others.
59 */ 76 */
@@ -88,6 +105,24 @@
88#define BCM5482_SHD_MODE_1000BX 0x0001 /* Enable 1000BASE-X registers */ 105#define BCM5482_SHD_MODE_1000BX 0x0001 /* Enable 1000BASE-X registers */
89 106
90/* 107/*
108 * EXPANSION SHADOW ACCESS REGISTERS. (PHY REG 0x15, 0x16, and 0x17)
109 */
110#define MII_BCM54XX_EXP_AADJ1CH0 0x001f
111#define MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN 0x0200
112#define MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF 0x0100
113#define MII_BCM54XX_EXP_AADJ1CH3 0x601f
114#define MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ 0x0002
115#define MII_BCM54XX_EXP_EXP08 0x0F08
116#define MII_BCM54XX_EXP_EXP08_RJCT_2MHZ 0x0001
117#define MII_BCM54XX_EXP_EXP08_EARLY_DAC_WAKE 0x0200
118#define MII_BCM54XX_EXP_EXP75 0x0f75
119#define MII_BCM54XX_EXP_EXP75_VDACCTRL 0x003c
120#define MII_BCM54XX_EXP_EXP96 0x0f96
121#define MII_BCM54XX_EXP_EXP96_MYST 0x0010
122#define MII_BCM54XX_EXP_EXP97 0x0f97
123#define MII_BCM54XX_EXP_EXP97_MYST 0x0c0c
124
125/*
91 * BCM5482: Secondary SerDes registers 126 * BCM5482: Secondary SerDes registers
92 */ 127 */
93#define BCM5482_SSD_1000BX_CTL 0x00 /* 1000BASE-X Control */ 128#define BCM5482_SSD_1000BX_CTL 0x00 /* 1000BASE-X Control */
@@ -128,40 +163,93 @@ static int bcm54xx_shadow_write(struct phy_device *phydev, u16 shadow, u16 val)
128 MII_BCM54XX_SHD_DATA(val)); 163 MII_BCM54XX_SHD_DATA(val));
129} 164}
130 165
131/* 166/* Indirect register access functions for the Expansion Registers */
132 * Indirect register access functions for the Expansion Registers 167static int bcm54xx_exp_read(struct phy_device *phydev, u8 regnum)
133 * and Secondary SerDes registers (when sec_serdes=1).
134 */
135static int bcm54xx_exp_read(struct phy_device *phydev,
136 int sec_serdes, u8 regnum)
137{ 168{
138 int val; 169 int val;
139 170
140 phy_write(phydev, MII_BCM54XX_EXP_SEL, 171 val = phy_write(phydev, MII_BCM54XX_EXP_SEL, regnum);
141 (sec_serdes ? MII_BCM54XX_EXP_SEL_SSD : 172 if (val < 0)
142 MII_BCM54XX_EXP_SEL_ER) | 173 return val;
143 regnum); 174
144 val = phy_read(phydev, MII_BCM54XX_EXP_DATA); 175 val = phy_read(phydev, MII_BCM54XX_EXP_DATA);
145 phy_write(phydev, MII_BCM54XX_EXP_SEL, regnum); 176
177 /* Restore default value. It's O.K. if this write fails. */
178 phy_write(phydev, MII_BCM54XX_EXP_SEL, 0);
146 179
147 return val; 180 return val;
148} 181}
149 182
150static int bcm54xx_exp_write(struct phy_device *phydev, 183static int bcm54xx_exp_write(struct phy_device *phydev, u16 regnum, u16 val)
151 int sec_serdes, u8 regnum, u16 val)
152{ 184{
153 int ret; 185 int ret;
154 186
155 phy_write(phydev, MII_BCM54XX_EXP_SEL, 187 ret = phy_write(phydev, MII_BCM54XX_EXP_SEL, regnum);
156 (sec_serdes ? MII_BCM54XX_EXP_SEL_SSD : 188 if (ret < 0)
157 MII_BCM54XX_EXP_SEL_ER) | 189 return ret;
158 regnum); 190
159 ret = phy_write(phydev, MII_BCM54XX_EXP_DATA, val); 191 ret = phy_write(phydev, MII_BCM54XX_EXP_DATA, val);
160 phy_write(phydev, MII_BCM54XX_EXP_SEL, regnum); 192
193 /* Restore default value. It's O.K. if this write fails. */
194 phy_write(phydev, MII_BCM54XX_EXP_SEL, 0);
161 195
162 return ret; 196 return ret;
163} 197}
164 198
199static int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val)
200{
201 return phy_write(phydev, MII_BCM54XX_AUX_CTL, regnum | val);
202}
203
204static int bcm50610_a0_workaround(struct phy_device *phydev)
205{
206 int err;
207
208 err = bcm54xx_auxctl_write(phydev,
209 MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
210 MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA |
211 MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
212 if (err < 0)
213 return err;
214
215 err = bcm54xx_exp_write(phydev, MII_BCM54XX_EXP_EXP08,
216 MII_BCM54XX_EXP_EXP08_RJCT_2MHZ |
217 MII_BCM54XX_EXP_EXP08_EARLY_DAC_WAKE);
218 if (err < 0)
219 goto error;
220
221 err = bcm54xx_exp_write(phydev, MII_BCM54XX_EXP_AADJ1CH0,
222 MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN |
223 MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF);
224 if (err < 0)
225 goto error;
226
227 err = bcm54xx_exp_write(phydev, MII_BCM54XX_EXP_AADJ1CH3,
228 MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ);
229 if (err < 0)
230 goto error;
231
232 err = bcm54xx_exp_write(phydev, MII_BCM54XX_EXP_EXP75,
233 MII_BCM54XX_EXP_EXP75_VDACCTRL);
234 if (err < 0)
235 goto error;
236
237 err = bcm54xx_exp_write(phydev, MII_BCM54XX_EXP_EXP96,
238 MII_BCM54XX_EXP_EXP96_MYST);
239 if (err < 0)
240 goto error;
241
242 err = bcm54xx_exp_write(phydev, MII_BCM54XX_EXP_EXP97,
243 MII_BCM54XX_EXP_EXP97_MYST);
244
245error:
246 bcm54xx_auxctl_write(phydev,
247 MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
248 MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
249
250 return err;
251}
252
165static int bcm54xx_config_init(struct phy_device *phydev) 253static int bcm54xx_config_init(struct phy_device *phydev)
166{ 254{
167 int reg, err; 255 int reg, err;
@@ -183,6 +271,13 @@ static int bcm54xx_config_init(struct phy_device *phydev)
183 err = phy_write(phydev, MII_BCM54XX_IMR, reg); 271 err = phy_write(phydev, MII_BCM54XX_IMR, reg);
184 if (err < 0) 272 if (err < 0)
185 return err; 273 return err;
274
275 if (phydev->drv->phy_id == PHY_ID_BCM50610) {
276 err = bcm50610_a0_workaround(phydev);
277 if (err < 0)
278 return err;
279 }
280
186 return 0; 281 return 0;
187} 282}
188 283
@@ -205,18 +300,27 @@ static int bcm5482_config_init(struct phy_device *phydev)
205 /* 300 /*
206 * Enable SGMII slave mode and auto-detection 301 * Enable SGMII slave mode and auto-detection
207 */ 302 */
208 reg = bcm54xx_exp_read(phydev, 1, BCM5482_SSD_SGMII_SLAVE); 303 reg = BCM5482_SSD_SGMII_SLAVE | MII_BCM54XX_EXP_SEL_SSD;
209 bcm54xx_exp_write(phydev, 1, BCM5482_SSD_SGMII_SLAVE, 304 err = bcm54xx_exp_read(phydev, reg);
210 reg | 305 if (err < 0)
211 BCM5482_SSD_SGMII_SLAVE_EN | 306 return err;
212 BCM5482_SSD_SGMII_SLAVE_AD); 307 err = bcm54xx_exp_write(phydev, reg, err |
308 BCM5482_SSD_SGMII_SLAVE_EN |
309 BCM5482_SSD_SGMII_SLAVE_AD);
310 if (err < 0)
311 return err;
213 312
214 /* 313 /*
215 * Disable secondary SerDes powerdown 314 * Disable secondary SerDes powerdown
216 */ 315 */
217 reg = bcm54xx_exp_read(phydev, 1, BCM5482_SSD_1000BX_CTL); 316 reg = BCM5482_SSD_1000BX_CTL | MII_BCM54XX_EXP_SEL_SSD;
218 bcm54xx_exp_write(phydev, 1, BCM5482_SSD_1000BX_CTL, 317 err = bcm54xx_exp_read(phydev, reg);
219 reg & ~BCM5482_SSD_1000BX_CTL_PWRDOWN); 318 if (err < 0)
319 return err;
320 err = bcm54xx_exp_write(phydev, reg,
321 err & ~BCM5482_SSD_1000BX_CTL_PWRDOWN);
322 if (err < 0)
323 return err;
220 324
221 /* 325 /*
222 * Select 1000BASE-X register set (primary SerDes) 326 * Select 1000BASE-X register set (primary SerDes)
@@ -335,7 +439,8 @@ static struct phy_driver bcm5411_driver = {
335 .phy_id = 0x00206070, 439 .phy_id = 0x00206070,
336 .phy_id_mask = 0xfffffff0, 440 .phy_id_mask = 0xfffffff0,
337 .name = "Broadcom BCM5411", 441 .name = "Broadcom BCM5411",
338 .features = PHY_GBIT_FEATURES, 442 .features = PHY_GBIT_FEATURES |
443 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
339 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 444 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
340 .config_init = bcm54xx_config_init, 445 .config_init = bcm54xx_config_init,
341 .config_aneg = genphy_config_aneg, 446 .config_aneg = genphy_config_aneg,
@@ -349,7 +454,8 @@ static struct phy_driver bcm5421_driver = {
349 .phy_id = 0x002060e0, 454 .phy_id = 0x002060e0,
350 .phy_id_mask = 0xfffffff0, 455 .phy_id_mask = 0xfffffff0,
351 .name = "Broadcom BCM5421", 456 .name = "Broadcom BCM5421",
352 .features = PHY_GBIT_FEATURES, 457 .features = PHY_GBIT_FEATURES |
458 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
353 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 459 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
354 .config_init = bcm54xx_config_init, 460 .config_init = bcm54xx_config_init,
355 .config_aneg = genphy_config_aneg, 461 .config_aneg = genphy_config_aneg,
@@ -363,7 +469,8 @@ static struct phy_driver bcm5461_driver = {
363 .phy_id = 0x002060c0, 469 .phy_id = 0x002060c0,
364 .phy_id_mask = 0xfffffff0, 470 .phy_id_mask = 0xfffffff0,
365 .name = "Broadcom BCM5461", 471 .name = "Broadcom BCM5461",
366 .features = PHY_GBIT_FEATURES, 472 .features = PHY_GBIT_FEATURES |
473 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
367 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 474 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
368 .config_init = bcm54xx_config_init, 475 .config_init = bcm54xx_config_init,
369 .config_aneg = genphy_config_aneg, 476 .config_aneg = genphy_config_aneg,
@@ -377,7 +484,8 @@ static struct phy_driver bcm5464_driver = {
377 .phy_id = 0x002060b0, 484 .phy_id = 0x002060b0,
378 .phy_id_mask = 0xfffffff0, 485 .phy_id_mask = 0xfffffff0,
379 .name = "Broadcom BCM5464", 486 .name = "Broadcom BCM5464",
380 .features = PHY_GBIT_FEATURES, 487 .features = PHY_GBIT_FEATURES |
488 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
381 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 489 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
382 .config_init = bcm54xx_config_init, 490 .config_init = bcm54xx_config_init,
383 .config_aneg = genphy_config_aneg, 491 .config_aneg = genphy_config_aneg,
@@ -391,7 +499,8 @@ static struct phy_driver bcm5481_driver = {
391 .phy_id = 0x0143bca0, 499 .phy_id = 0x0143bca0,
392 .phy_id_mask = 0xfffffff0, 500 .phy_id_mask = 0xfffffff0,
393 .name = "Broadcom BCM5481", 501 .name = "Broadcom BCM5481",
394 .features = PHY_GBIT_FEATURES, 502 .features = PHY_GBIT_FEATURES |
503 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
395 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 504 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
396 .config_init = bcm54xx_config_init, 505 .config_init = bcm54xx_config_init,
397 .config_aneg = bcm5481_config_aneg, 506 .config_aneg = bcm5481_config_aneg,
@@ -405,7 +514,8 @@ static struct phy_driver bcm5482_driver = {
405 .phy_id = 0x0143bcb0, 514 .phy_id = 0x0143bcb0,
406 .phy_id_mask = 0xfffffff0, 515 .phy_id_mask = 0xfffffff0,
407 .name = "Broadcom BCM5482", 516 .name = "Broadcom BCM5482",
408 .features = PHY_GBIT_FEATURES, 517 .features = PHY_GBIT_FEATURES |
518 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
409 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 519 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
410 .config_init = bcm5482_config_init, 520 .config_init = bcm5482_config_init,
411 .config_aneg = genphy_config_aneg, 521 .config_aneg = genphy_config_aneg,
@@ -415,6 +525,21 @@ static struct phy_driver bcm5482_driver = {
415 .driver = { .owner = THIS_MODULE }, 525 .driver = { .owner = THIS_MODULE },
416}; 526};
417 527
528static struct phy_driver bcm50610_driver = {
529 .phy_id = PHY_ID_BCM50610,
530 .phy_id_mask = 0xfffffff0,
531 .name = "Broadcom BCM50610",
532 .features = PHY_GBIT_FEATURES |
533 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
534 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
535 .config_init = bcm54xx_config_init,
536 .config_aneg = genphy_config_aneg,
537 .read_status = genphy_read_status,
538 .ack_interrupt = bcm54xx_ack_interrupt,
539 .config_intr = bcm54xx_config_intr,
540 .driver = { .owner = THIS_MODULE },
541};
542
418static int __init broadcom_init(void) 543static int __init broadcom_init(void)
419{ 544{
420 int ret; 545 int ret;
@@ -437,8 +562,13 @@ static int __init broadcom_init(void)
437 ret = phy_driver_register(&bcm5482_driver); 562 ret = phy_driver_register(&bcm5482_driver);
438 if (ret) 563 if (ret)
439 goto out_5482; 564 goto out_5482;
565 ret = phy_driver_register(&bcm50610_driver);
566 if (ret)
567 goto out_50610;
440 return ret; 568 return ret;
441 569
570out_50610:
571 phy_driver_unregister(&bcm5482_driver);
442out_5482: 572out_5482:
443 phy_driver_unregister(&bcm5481_driver); 573 phy_driver_unregister(&bcm5481_driver);
444out_5481: 574out_5481:
@@ -455,6 +585,7 @@ out_5411:
455 585
456static void __exit broadcom_exit(void) 586static void __exit broadcom_exit(void)
457{ 587{
588 phy_driver_unregister(&bcm50610_driver);
458 phy_driver_unregister(&bcm5482_driver); 589 phy_driver_unregister(&bcm5482_driver);
459 phy_driver_unregister(&bcm5481_driver); 590 phy_driver_unregister(&bcm5481_driver);
460 phy_driver_unregister(&bcm5464_driver); 591 phy_driver_unregister(&bcm5464_driver);
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
new file mode 100644
index 000000000000..a439ebeb4319
--- /dev/null
+++ b/drivers/net/phy/mdio-gpio.c
@@ -0,0 +1,296 @@
1/*
2 * GPIO based MDIO bitbang driver.
3 * Supports OpenFirmware.
4 *
5 * Copyright (c) 2008 CSE Semaphore Belgium.
6 * by Laurent Pinchart <laurentp@cse-semaphore.com>
7 *
8 * Copyright (C) 2008, Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
9 *
10 * Based on earlier work by
11 *
12 * Copyright (c) 2003 Intracom S.A.
13 * by Pantelis Antoniou <panto@intracom.gr>
14 *
15 * 2005 (c) MontaVista Software, Inc.
16 * Vitaly Bordug <vbordug@ru.mvista.com>
17 *
18 * This file is licensed under the terms of the GNU General Public License
19 * version 2. This program is licensed "as is" without any warranty of any
20 * kind, whether express or implied.
21 */
22
23#include <linux/module.h>
24#include <linux/slab.h>
25#include <linux/init.h>
26#include <linux/interrupt.h>
27#include <linux/platform_device.h>
28#include <linux/gpio.h>
29#include <linux/mdio-gpio.h>
30
31#ifdef CONFIG_OF_GPIO
32#include <linux/of_gpio.h>
33#include <linux/of_platform.h>
34#endif
35
36struct mdio_gpio_info {
37 struct mdiobb_ctrl ctrl;
38 int mdc, mdio;
39};
40
41static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
42{
43 struct mdio_gpio_info *bitbang =
44 container_of(ctrl, struct mdio_gpio_info, ctrl);
45
46 if (dir)
47 gpio_direction_output(bitbang->mdio, 1);
48 else
49 gpio_direction_input(bitbang->mdio);
50}
51
52static int mdio_get(struct mdiobb_ctrl *ctrl)
53{
54 struct mdio_gpio_info *bitbang =
55 container_of(ctrl, struct mdio_gpio_info, ctrl);
56
57 return gpio_get_value(bitbang->mdio);
58}
59
60static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
61{
62 struct mdio_gpio_info *bitbang =
63 container_of(ctrl, struct mdio_gpio_info, ctrl);
64
65 gpio_set_value(bitbang->mdio, what);
66}
67
68static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
69{
70 struct mdio_gpio_info *bitbang =
71 container_of(ctrl, struct mdio_gpio_info, ctrl);
72
73 gpio_set_value(bitbang->mdc, what);
74}
75
76static struct mdiobb_ops mdio_gpio_ops = {
77 .owner = THIS_MODULE,
78 .set_mdc = mdc_set,
79 .set_mdio_dir = mdio_dir,
80 .set_mdio_data = mdio_set,
81 .get_mdio_data = mdio_get,
82};
83
84static int __devinit mdio_gpio_bus_init(struct device *dev,
85 struct mdio_gpio_platform_data *pdata,
86 int bus_id)
87{
88 struct mii_bus *new_bus;
89 struct mdio_gpio_info *bitbang;
90 int ret = -ENOMEM;
91 int i;
92
93 bitbang = kzalloc(sizeof(*bitbang), GFP_KERNEL);
94 if (!bitbang)
95 goto out;
96
97 bitbang->ctrl.ops = &mdio_gpio_ops;
98 bitbang->mdc = pdata->mdc;
99 bitbang->mdio = pdata->mdio;
100
101 new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
102 if (!new_bus)
103 goto out_free_bitbang;
104
105 new_bus->name = "GPIO Bitbanged MDIO",
106
107 ret = -ENODEV;
108
109 new_bus->phy_mask = pdata->phy_mask;
110 new_bus->irq = pdata->irqs;
111 new_bus->parent = dev;
112
113 if (new_bus->phy_mask == ~0)
114 goto out_free_bus;
115
116 for (i = 0; i < PHY_MAX_ADDR; i++)
117 if (!new_bus->irq[i])
118 new_bus->irq[i] = PHY_POLL;
119
120 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", bus_id);
121
122 if (gpio_request(bitbang->mdc, "mdc"))
123 goto out_free_bus;
124
125 if (gpio_request(bitbang->mdio, "mdio"))
126 goto out_free_mdc;
127
128 dev_set_drvdata(dev, new_bus);
129
130 ret = mdiobus_register(new_bus);
131 if (ret)
132 goto out_free_all;
133
134 return 0;
135
136out_free_all:
137 dev_set_drvdata(dev, NULL);
138 gpio_free(bitbang->mdio);
139out_free_mdc:
140 gpio_free(bitbang->mdc);
141out_free_bus:
142 free_mdio_bitbang(new_bus);
143out_free_bitbang:
144 kfree(bitbang);
145out:
146 return ret;
147}
148
149static void __devexit mdio_gpio_bus_destroy(struct device *dev)
150{
151 struct mii_bus *bus = dev_get_drvdata(dev);
152 struct mdio_gpio_info *bitbang = bus->priv;
153
154 mdiobus_unregister(bus);
155 free_mdio_bitbang(bus);
156 dev_set_drvdata(dev, NULL);
157 gpio_free(bitbang->mdc);
158 gpio_free(bitbang->mdio);
159 kfree(bitbang);
160}
161
162static int __devinit mdio_gpio_probe(struct platform_device *pdev)
163{
164 struct mdio_gpio_platform_data *pdata = pdev->dev.platform_data;
165
166 if (!pdata)
167 return -ENODEV;
168
169 return mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id);
170}
171
172static int __devexit mdio_gpio_remove(struct platform_device *pdev)
173{
174 mdio_gpio_bus_destroy(&pdev->dev);
175
176 return 0;
177}
178
179#ifdef CONFIG_OF_GPIO
180static void __devinit add_phy(struct mdio_gpio_platform_data *pdata,
181 struct device_node *np)
182{
183 const u32 *data;
184 int len, id, irq;
185
186 data = of_get_property(np, "reg", &len);
187 if (!data || len != 4)
188 return;
189
190 id = *data;
191 pdata->phy_mask &= ~(1 << id);
192
193 irq = of_irq_to_resource(np, 0, NULL);
194 if (irq)
195 pdata->irqs[id] = irq;
196}
197
198static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,
199 const struct of_device_id *match)
200{
201 struct device_node *np = NULL;
202 struct mdio_gpio_platform_data *pdata;
203
204 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
205 if (!pdata)
206 return -ENOMEM;
207
208 pdata->mdc = of_get_gpio(ofdev->node, 0);
209 pdata->mdio = of_get_gpio(ofdev->node, 1);
210
211 if (pdata->mdc < 0 || pdata->mdio < 0)
212 goto out_free;
213
214 while ((np = of_get_next_child(ofdev->node, np)))
215 if (!strcmp(np->type, "ethernet-phy"))
216 add_phy(pdata, np);
217
218 return mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->mdc);
219
220out_free:
221 kfree(pdata);
222 return -ENODEV;
223}
224
225static int __devexit mdio_ofgpio_remove(struct of_device *ofdev)
226{
227 mdio_gpio_bus_destroy(&ofdev->dev);
228 kfree(ofdev->dev.platform_data);
229
230 return 0;
231}
232
233static struct of_device_id mdio_ofgpio_match[] = {
234 {
235 .compatible = "virtual,mdio-gpio",
236 },
237 {},
238};
239
240static struct of_platform_driver mdio_ofgpio_driver = {
241 .name = "mdio-gpio",
242 .match_table = mdio_ofgpio_match,
243 .probe = mdio_ofgpio_probe,
244 .remove = __devexit_p(mdio_ofgpio_remove),
245};
246
247static inline int __init mdio_ofgpio_init(void)
248{
249 return of_register_platform_driver(&mdio_ofgpio_driver);
250}
251
252static inline void __exit mdio_ofgpio_exit(void)
253{
254 of_unregister_platform_driver(&mdio_ofgpio_driver);
255}
256#else
257static inline int __init mdio_ofgpio_init(void) { return 0; }
258static inline void __exit mdio_ofgpio_exit(void) { }
259#endif /* CONFIG_OF_GPIO */
260
261static struct platform_driver mdio_gpio_driver = {
262 .probe = mdio_gpio_probe,
263 .remove = __devexit_p(mdio_gpio_remove),
264 .driver = {
265 .name = "mdio-gpio",
266 .owner = THIS_MODULE,
267 },
268};
269
270static int __init mdio_gpio_init(void)
271{
272 int ret;
273
274 ret = mdio_ofgpio_init();
275 if (ret)
276 return ret;
277
278 ret = platform_driver_register(&mdio_gpio_driver);
279 if (ret)
280 mdio_ofgpio_exit();
281
282 return ret;
283}
284module_init(mdio_gpio_init);
285
286static void __exit mdio_gpio_exit(void)
287{
288 platform_driver_unregister(&mdio_gpio_driver);
289 mdio_ofgpio_exit();
290}
291module_exit(mdio_gpio_exit);
292
293MODULE_ALIAS("platform:mdio-gpio");
294MODULE_AUTHOR("Laurent Pinchart, Paulius Zaleckas");
295MODULE_LICENSE("GPL");
296MODULE_DESCRIPTION("Generic driver for MDIO bus emulation using GPIO");
diff --git a/drivers/net/phy/mdio-ofgpio.c b/drivers/net/phy/mdio-ofgpio.c
deleted file mode 100644
index 2ff97754e574..000000000000
--- a/drivers/net/phy/mdio-ofgpio.c
+++ /dev/null
@@ -1,204 +0,0 @@
1/*
2 * OpenFirmware GPIO based MDIO bitbang driver.
3 *
4 * Copyright (c) 2008 CSE Semaphore Belgium.
5 * by Laurent Pinchart <laurentp@cse-semaphore.com>
6 *
7 * Based on earlier work by
8 *
9 * Copyright (c) 2003 Intracom S.A.
10 * by Pantelis Antoniou <panto@intracom.gr>
11 *
12 * 2005 (c) MontaVista Software, Inc.
13 * Vitaly Bordug <vbordug@ru.mvista.com>
14 *
15 * This file is licensed under the terms of the GNU General Public License
16 * version 2. This program is licensed "as is" without any warranty of any
17 * kind, whether express or implied.
18 */
19
20#include <linux/module.h>
21#include <linux/slab.h>
22#include <linux/init.h>
23#include <linux/interrupt.h>
24#include <linux/mdio-bitbang.h>
25#include <linux/of_gpio.h>
26#include <linux/of_platform.h>
27
28struct mdio_gpio_info {
29 struct mdiobb_ctrl ctrl;
30 int mdc, mdio;
31};
32
33static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
34{
35 struct mdio_gpio_info *bitbang =
36 container_of(ctrl, struct mdio_gpio_info, ctrl);
37
38 if (dir)
39 gpio_direction_output(bitbang->mdio, 1);
40 else
41 gpio_direction_input(bitbang->mdio);
42}
43
44static int mdio_read(struct mdiobb_ctrl *ctrl)
45{
46 struct mdio_gpio_info *bitbang =
47 container_of(ctrl, struct mdio_gpio_info, ctrl);
48
49 return gpio_get_value(bitbang->mdio);
50}
51
52static void mdio(struct mdiobb_ctrl *ctrl, int what)
53{
54 struct mdio_gpio_info *bitbang =
55 container_of(ctrl, struct mdio_gpio_info, ctrl);
56
57 gpio_set_value(bitbang->mdio, what);
58}
59
60static void mdc(struct mdiobb_ctrl *ctrl, int what)
61{
62 struct mdio_gpio_info *bitbang =
63 container_of(ctrl, struct mdio_gpio_info, ctrl);
64
65 gpio_set_value(bitbang->mdc, what);
66}
67
68static struct mdiobb_ops mdio_gpio_ops = {
69 .owner = THIS_MODULE,
70 .set_mdc = mdc,
71 .set_mdio_dir = mdio_dir,
72 .set_mdio_data = mdio,
73 .get_mdio_data = mdio_read,
74};
75
76static int __devinit mdio_ofgpio_bitbang_init(struct mii_bus *bus,
77 struct device_node *np)
78{
79 struct mdio_gpio_info *bitbang = bus->priv;
80
81 bitbang->mdc = of_get_gpio(np, 0);
82 bitbang->mdio = of_get_gpio(np, 1);
83
84 if (bitbang->mdc < 0 || bitbang->mdio < 0)
85 return -ENODEV;
86
87 snprintf(bus->id, MII_BUS_ID_SIZE, "%x", bitbang->mdc);
88 return 0;
89}
90
91static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
92{
93 const u32 *data;
94 int len, id, irq;
95
96 data = of_get_property(np, "reg", &len);
97 if (!data || len != 4)
98 return;
99
100 id = *data;
101 bus->phy_mask &= ~(1 << id);
102
103 irq = of_irq_to_resource(np, 0, NULL);
104 if (irq != NO_IRQ)
105 bus->irq[id] = irq;
106}
107
108static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,
109 const struct of_device_id *match)
110{
111 struct device_node *np = NULL;
112 struct mii_bus *new_bus;
113 struct mdio_gpio_info *bitbang;
114 int ret = -ENOMEM;
115 int i;
116
117 bitbang = kzalloc(sizeof(struct mdio_gpio_info), GFP_KERNEL);
118 if (!bitbang)
119 goto out;
120
121 bitbang->ctrl.ops = &mdio_gpio_ops;
122
123 new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
124 if (!new_bus)
125 goto out_free_bitbang;
126
127 new_bus->name = "GPIO Bitbanged MII",
128
129 ret = mdio_ofgpio_bitbang_init(new_bus, ofdev->node);
130 if (ret)
131 goto out_free_bus;
132
133 new_bus->phy_mask = ~0;
134 new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
135 if (!new_bus->irq)
136 goto out_free_bus;
137
138 for (i = 0; i < PHY_MAX_ADDR; i++)
139 new_bus->irq[i] = -1;
140
141 while ((np = of_get_next_child(ofdev->node, np)))
142 if (!strcmp(np->type, "ethernet-phy"))
143 add_phy(new_bus, np);
144
145 new_bus->parent = &ofdev->dev;
146 dev_set_drvdata(&ofdev->dev, new_bus);
147
148 ret = mdiobus_register(new_bus);
149 if (ret)
150 goto out_free_irqs;
151
152 return 0;
153
154out_free_irqs:
155 dev_set_drvdata(&ofdev->dev, NULL);
156 kfree(new_bus->irq);
157out_free_bus:
158 free_mdio_bitbang(new_bus);
159out_free_bitbang:
160 kfree(bitbang);
161out:
162 return ret;
163}
164
165static int mdio_ofgpio_remove(struct of_device *ofdev)
166{
167 struct mii_bus *bus = dev_get_drvdata(&ofdev->dev);
168 struct mdio_gpio_info *bitbang = bus->priv;
169
170 mdiobus_unregister(bus);
171 kfree(bus->irq);
172 free_mdio_bitbang(bus);
173 dev_set_drvdata(&ofdev->dev, NULL);
174 kfree(bitbang);
175
176 return 0;
177}
178
179static struct of_device_id mdio_ofgpio_match[] = {
180 {
181 .compatible = "virtual,mdio-gpio",
182 },
183 {},
184};
185
186static struct of_platform_driver mdio_ofgpio_driver = {
187 .name = "mdio-gpio",
188 .match_table = mdio_ofgpio_match,
189 .probe = mdio_ofgpio_probe,
190 .remove = mdio_ofgpio_remove,
191};
192
193static int mdio_ofgpio_init(void)
194{
195 return of_register_platform_driver(&mdio_ofgpio_driver);
196}
197
198static void mdio_ofgpio_exit(void)
199{
200 of_unregister_platform_driver(&mdio_ofgpio_driver);
201}
202
203module_init(mdio_ofgpio_init);
204module_exit(mdio_ofgpio_exit);
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 536bda1f428b..868812ff6de8 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -97,7 +97,7 @@ int mdiobus_register(struct mii_bus *bus)
97 bus->dev.parent = bus->parent; 97 bus->dev.parent = bus->parent;
98 bus->dev.class = &mdio_bus_class; 98 bus->dev.class = &mdio_bus_class;
99 bus->dev.groups = NULL; 99 bus->dev.groups = NULL;
100 memcpy(bus->dev.bus_id, bus->id, MII_BUS_ID_SIZE); 100 dev_set_name(&bus->dev, bus->id);
101 101
102 err = device_register(&bus->dev); 102 err = device_register(&bus->dev);
103 if (err) { 103 if (err) {
@@ -191,7 +191,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
191 191
192 phydev->dev.parent = bus->parent; 192 phydev->dev.parent = bus->parent;
193 phydev->dev.bus = &mdio_bus_type; 193 phydev->dev.bus = &mdio_bus_type;
194 snprintf(phydev->dev.bus_id, BUS_ID_SIZE, PHY_ID_FMT, bus->id, addr); 194 dev_set_name(&phydev->dev, PHY_ID_FMT, bus->id, addr);
195 195
196 phydev->bus = bus; 196 phydev->bus = bus;
197 197
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index df4e6257d4a7..e4ede6080c9d 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -45,7 +45,7 @@
45 */ 45 */
46void phy_print_status(struct phy_device *phydev) 46void phy_print_status(struct phy_device *phydev)
47{ 47{
48 pr_info("PHY: %s - Link is %s", phydev->dev.bus_id, 48 pr_info("PHY: %s - Link is %s", dev_name(&phydev->dev),
49 phydev->link ? "Up" : "Down"); 49 phydev->link ? "Up" : "Down");
50 if (phydev->link) 50 if (phydev->link)
51 printk(" - %d/%s", phydev->speed, 51 printk(" - %d/%s", phydev->speed,
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8fb1faca883a..bce918bd3cdd 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -74,7 +74,7 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
74 if (!fixup) 74 if (!fixup)
75 return -ENOMEM; 75 return -ENOMEM;
76 76
77 strncpy(fixup->bus_id, bus_id, BUS_ID_SIZE); 77 strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id));
78 fixup->phy_uid = phy_uid; 78 fixup->phy_uid = phy_uid;
79 fixup->phy_uid_mask = phy_uid_mask; 79 fixup->phy_uid_mask = phy_uid_mask;
80 fixup->run = run; 80 fixup->run = run;
@@ -109,7 +109,7 @@ EXPORT_SYMBOL(phy_register_fixup_for_id);
109 */ 109 */
110static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) 110static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup)
111{ 111{
112 if (strcmp(fixup->bus_id, phydev->dev.bus_id) != 0) 112 if (strcmp(fixup->bus_id, dev_name(&phydev->dev)) != 0)
113 if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0) 113 if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0)
114 return 0; 114 return 0;
115 115
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 73baa7a3bb0e..c05d38d46350 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -126,6 +126,27 @@ static struct phy_driver lan8700_driver = {
126 .driver = { .owner = THIS_MODULE, } 126 .driver = { .owner = THIS_MODULE, }
127}; 127};
128 128
129static struct phy_driver lan911x_int_driver = {
130 .phy_id = 0x0007c0d0, /* OUI=0x00800f, Model#=0x0d */
131 .phy_id_mask = 0xfffffff0,
132 .name = "SMSC LAN911x Internal PHY",
133
134 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
135 | SUPPORTED_Asym_Pause),
136 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
137
138 /* basic functions */
139 .config_aneg = genphy_config_aneg,
140 .read_status = genphy_read_status,
141 .config_init = smsc_phy_config_init,
142
143 /* IRQ related */
144 .ack_interrupt = smsc_phy_ack_interrupt,
145 .config_intr = smsc_phy_config_intr,
146
147 .driver = { .owner = THIS_MODULE, }
148};
149
129static int __init smsc_init(void) 150static int __init smsc_init(void)
130{ 151{
131 int ret; 152 int ret;
@@ -142,8 +163,14 @@ static int __init smsc_init(void)
142 if (ret) 163 if (ret)
143 goto err3; 164 goto err3;
144 165
166 ret = phy_driver_register (&lan911x_int_driver);
167 if (ret)
168 goto err4;
169
145 return 0; 170 return 0;
146 171
172err4:
173 phy_driver_unregister (&lan8700_driver);
147err3: 174err3:
148 phy_driver_unregister (&lan8187_driver); 175 phy_driver_unregister (&lan8187_driver);
149err2: 176err2:
@@ -154,6 +181,7 @@ err1:
154 181
155static void __exit smsc_exit(void) 182static void __exit smsc_exit(void)
156{ 183{
184 phy_driver_unregister (&lan911x_int_driver);
157 phy_driver_unregister (&lan8700_driver); 185 phy_driver_unregister (&lan8700_driver);
158 phy_driver_unregister (&lan8187_driver); 186 phy_driver_unregister (&lan8187_driver);
159 phy_driver_unregister (&lan83c185_driver); 187 phy_driver_unregister (&lan83c185_driver);
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 1e965427b0e9..d544d4a086dc 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -229,7 +229,7 @@ static inline void enable_parport_interrupts (struct net_device *dev)
229 if (dev->irq != -1) 229 if (dev->irq != -1)
230 { 230 {
231 struct parport *port = 231 struct parport *port =
232 ((struct net_local *)dev->priv)->pardev->port; 232 ((struct net_local *)netdev_priv(dev))->pardev->port;
233 port->ops->enable_irq (port); 233 port->ops->enable_irq (port);
234 } 234 }
235} 235}
@@ -239,7 +239,7 @@ static inline void disable_parport_interrupts (struct net_device *dev)
239 if (dev->irq != -1) 239 if (dev->irq != -1)
240 { 240 {
241 struct parport *port = 241 struct parport *port =
242 ((struct net_local *)dev->priv)->pardev->port; 242 ((struct net_local *)netdev_priv(dev))->pardev->port;
243 port->ops->disable_irq (port); 243 port->ops->disable_irq (port);
244 } 244 }
245} 245}
@@ -247,7 +247,7 @@ static inline void disable_parport_interrupts (struct net_device *dev)
247static inline void write_data (struct net_device *dev, unsigned char data) 247static inline void write_data (struct net_device *dev, unsigned char data)
248{ 248{
249 struct parport *port = 249 struct parport *port =
250 ((struct net_local *)dev->priv)->pardev->port; 250 ((struct net_local *)netdev_priv(dev))->pardev->port;
251 251
252 port->ops->write_data (port, data); 252 port->ops->write_data (port, data);
253} 253}
@@ -255,7 +255,7 @@ static inline void write_data (struct net_device *dev, unsigned char data)
255static inline unsigned char read_status (struct net_device *dev) 255static inline unsigned char read_status (struct net_device *dev)
256{ 256{
257 struct parport *port = 257 struct parport *port =
258 ((struct net_local *)dev->priv)->pardev->port; 258 ((struct net_local *)netdev_priv(dev))->pardev->port;
259 259
260 return port->ops->read_status (port); 260 return port->ops->read_status (port);
261} 261}
@@ -664,7 +664,6 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
664 /* Inform the upper layer for the arrival of a packet. */ 664 /* Inform the upper layer for the arrival of a packet. */
665 rcv->skb->protocol=plip_type_trans(rcv->skb, dev); 665 rcv->skb->protocol=plip_type_trans(rcv->skb, dev);
666 netif_rx_ni(rcv->skb); 666 netif_rx_ni(rcv->skb);
667 dev->last_rx = jiffies;
668 dev->stats.rx_bytes += rcv->length.h; 667 dev->stats.rx_bytes += rcv->length.h;
669 dev->stats.rx_packets++; 668 dev->stats.rx_packets++;
670 rcv->skb = NULL; 669 rcv->skb = NULL;
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 7e857e938adb..274d495a1c50 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1684,7 +1684,6 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1684 skb->protocol = htons(npindex_to_ethertype[npi]); 1684 skb->protocol = htons(npindex_to_ethertype[npi]);
1685 skb_reset_mac_header(skb); 1685 skb_reset_mac_header(skb);
1686 netif_rx(skb); 1686 netif_rx(skb);
1687 ppp->dev->last_rx = jiffies;
1688 } 1687 }
1689 } 1688 }
1690 return; 1689 return;
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index b646e92134dc..c22b30533a14 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -958,7 +958,6 @@ static int pppoe_seq_show(struct seq_file *seq, void *v)
958{ 958{
959 struct pppox_sock *po; 959 struct pppox_sock *po;
960 char *dev_name; 960 char *dev_name;
961 DECLARE_MAC_BUF(mac);
962 961
963 if (v == SEQ_START_TOKEN) { 962 if (v == SEQ_START_TOKEN) {
964 seq_puts(seq, "Id Address Device\n"); 963 seq_puts(seq, "Id Address Device\n");
@@ -968,8 +967,8 @@ static int pppoe_seq_show(struct seq_file *seq, void *v)
968 po = v; 967 po = v;
969 dev_name = po->pppoe_pa.dev; 968 dev_name = po->pppoe_pa.dev;
970 969
971 seq_printf(seq, "%08X %s %8s\n", 970 seq_printf(seq, "%08X %pM %8s\n",
972 po->pppoe_pa.sid, print_mac(mac, po->pppoe_pa.remote), dev_name); 971 po->pppoe_pa.sid, po->pppoe_pa.remote, dev_name);
973out: 972out:
974 return 0; 973 return 0;
975} 974}
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index 2eb54fd7bed5..4b564eda5bd9 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -1443,7 +1443,6 @@ int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card)
1443{ 1443{
1444 int status; 1444 int status;
1445 u64 v1, v2; 1445 u64 v1, v2;
1446 DECLARE_MAC_BUF(mac);
1447 1446
1448 netdev->features = NETIF_F_IP_CSUM; 1447 netdev->features = NETIF_F_IP_CSUM;
1449 1448
@@ -1474,9 +1473,8 @@ int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card)
1474 __func__, netdev->name, status); 1473 __func__, netdev->name, status);
1475 return status; 1474 return status;
1476 } 1475 }
1477 dev_info(ctodev(card), "%s: MAC addr %s\n", 1476 dev_info(ctodev(card), "%s: MAC addr %pM\n",
1478 netdev->name, 1477 netdev->name, netdev->dev_addr);
1479 print_mac(mac, netdev->dev_addr));
1480 1478
1481 return 0; 1479 return 0;
1482} 1480}
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index a834b52a6a2c..ec2314246682 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -30,10 +30,11 @@
30#include <linux/ip.h> 30#include <linux/ip.h>
31#include <linux/tcp.h> 31#include <linux/tcp.h>
32#include <linux/wireless.h> 32#include <linux/wireless.h>
33#include <linux/ieee80211.h>
34#include <linux/if_arp.h>
33#include <linux/ctype.h> 35#include <linux/ctype.h>
34#include <linux/string.h> 36#include <linux/string.h>
35#include <net/iw_handler.h> 37#include <net/iw_handler.h>
36#include <net/ieee80211.h>
37 38
38#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
39#include <net/checksum.h> 40#include <net/checksum.h>
@@ -449,9 +450,9 @@ static size_t gelic_wl_synthesize_ie(u8 *buf,
449 450
450 /* element id */ 451 /* element id */
451 if (rsn) 452 if (rsn)
452 *buf++ = MFIE_TYPE_RSN; 453 *buf++ = WLAN_EID_RSN;
453 else 454 else
454 *buf++ = MFIE_TYPE_GENERIC; 455 *buf++ = WLAN_EID_GENERIC;
455 456
456 /* length filed; set later */ 457 /* length filed; set later */
457 buf++; 458 buf++;
@@ -539,7 +540,7 @@ static void gelic_wl_parse_ie(u8 *data, size_t len,
539 break; 540 break;
540 541
541 switch (item_id) { 542 switch (item_id) {
542 case MFIE_TYPE_GENERIC: 543 case WLAN_EID_GENERIC:
543 if ((OUI_LEN + 1 <= item_len) && 544 if ((OUI_LEN + 1 <= item_len) &&
544 !memcmp(pos, wpa_oui, OUI_LEN) && 545 !memcmp(pos, wpa_oui, OUI_LEN) &&
545 pos[OUI_LEN] == 0x01) { 546 pos[OUI_LEN] == 0x01) {
@@ -547,7 +548,7 @@ static void gelic_wl_parse_ie(u8 *data, size_t len,
547 ie_info->wpa.len = item_len + 2; 548 ie_info->wpa.len = item_len + 2;
548 } 549 }
549 break; 550 break;
550 case MFIE_TYPE_RSN: 551 case WLAN_EID_RSN:
551 ie_info->rsn.data = pos - 2; 552 ie_info->rsn.data = pos - 2;
552 /* length includes the header */ 553 /* length includes the header */
553 ie_info->rsn.len = item_len + 2; 554 ie_info->rsn.len = item_len + 2;
@@ -581,7 +582,7 @@ static char *gelic_wl_translate_scan(struct net_device *netdev,
581 char *tmp; 582 char *tmp;
582 u8 rate; 583 u8 rate;
583 unsigned int i, j, len; 584 unsigned int i, j, len;
584 u8 buf[MAX_WPA_IE_LEN]; 585 u8 buf[64]; /* arbitrary size large enough */
585 586
586 pr_debug("%s: <-\n", __func__); 587 pr_debug("%s: <-\n", __func__);
587 588
@@ -763,7 +764,6 @@ static void scan_list_dump(struct gelic_wl_info *wl)
763{ 764{
764 struct gelic_wl_scan_info *scan_info; 765 struct gelic_wl_scan_info *scan_info;
765 int i; 766 int i;
766 DECLARE_MAC_BUF(mac);
767 767
768 i = 0; 768 i = 0;
769 list_for_each_entry(scan_info, &wl->network_list, list) { 769 list_for_each_entry(scan_info, &wl->network_list, list) {
@@ -775,8 +775,7 @@ static void scan_list_dump(struct gelic_wl_info *wl)
775 scan_info->rate_len, scan_info->rate_ext_len, 775 scan_info->rate_len, scan_info->rate_ext_len,
776 scan_info->essid_len); 776 scan_info->essid_len);
777 /* -- */ 777 /* -- */
778 pr_debug("bssid=%s\n", 778 pr_debug("bssid=%pM\n", &scan_info->hwinfo->bssid[2]);
779 print_mac(mac, &scan_info->hwinfo->bssid[2]));
780 pr_debug("essid=%s\n", scan_info->hwinfo->essid); 779 pr_debug("essid=%s\n", scan_info->hwinfo->essid);
781 } 780 }
782} 781}
@@ -1167,11 +1166,7 @@ static int gelic_wl_set_ap(struct net_device *netdev,
1167 ETH_ALEN); 1166 ETH_ALEN);
1168 set_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat); 1167 set_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat);
1169 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat); 1168 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
1170 pr_debug("%s: bss=%02x:%02x:%02x:%02x:%02x:%02x\n", 1169 pr_debug("%s: bss=%pM\n", __func__, wl->bssid);
1171 __func__,
1172 wl->bssid[0], wl->bssid[1],
1173 wl->bssid[2], wl->bssid[3],
1174 wl->bssid[4], wl->bssid[5]);
1175 } else { 1170 } else {
1176 pr_debug("%s: clear bssid\n", __func__); 1171 pr_debug("%s: clear bssid\n", __func__);
1177 clear_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat); 1172 clear_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat);
@@ -1632,7 +1627,6 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1632 unsigned long this_time = jiffies; 1627 unsigned long this_time = jiffies;
1633 unsigned int data_len, i, found, r; 1628 unsigned int data_len, i, found, r;
1634 void *buf; 1629 void *buf;
1635 DECLARE_MAC_BUF(mac);
1636 1630
1637 pr_debug("%s:start\n", __func__); 1631 pr_debug("%s:start\n", __func__);
1638 mutex_lock(&wl->scan_lock); 1632 mutex_lock(&wl->scan_lock);
@@ -1684,9 +1678,9 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1684 scan_info_size < data_len; 1678 scan_info_size < data_len;
1685 i++, scan_info_size += be16_to_cpu(scan_info->size), 1679 i++, scan_info_size += be16_to_cpu(scan_info->size),
1686 scan_info = (void *)scan_info + be16_to_cpu(scan_info->size)) { 1680 scan_info = (void *)scan_info + be16_to_cpu(scan_info->size)) {
1687 pr_debug("%s:size=%d bssid=%s scan_info=%p\n", __func__, 1681 pr_debug("%s:size=%d bssid=%pM scan_info=%p\n", __func__,
1688 be16_to_cpu(scan_info->size), 1682 be16_to_cpu(scan_info->size),
1689 print_mac(mac, &scan_info->bssid[2]), scan_info); 1683 &scan_info->bssid[2], scan_info);
1690 1684
1691 /* 1685 /*
1692 * The wireless firmware may return invalid channel 0 and/or 1686 * The wireless firmware may return invalid channel 0 and/or
@@ -1741,14 +1735,14 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1741 target->essid_len = strnlen(scan_info->essid, 1735 target->essid_len = strnlen(scan_info->essid,
1742 sizeof(scan_info->essid)); 1736 sizeof(scan_info->essid));
1743 target->rate_len = 0; 1737 target->rate_len = 0;
1744 for (r = 0; r < MAX_RATES_LENGTH; r++) 1738 for (r = 0; r < 12; r++)
1745 if (scan_info->rate[r]) 1739 if (scan_info->rate[r])
1746 target->rate_len++; 1740 target->rate_len++;
1747 if (8 < target->rate_len) 1741 if (8 < target->rate_len)
1748 pr_info("%s: AP returns %d rates\n", __func__, 1742 pr_info("%s: AP returns %d rates\n", __func__,
1749 target->rate_len); 1743 target->rate_len);
1750 target->rate_ext_len = 0; 1744 target->rate_ext_len = 0;
1751 for (r = 0; r < MAX_RATES_EX_LENGTH; r++) 1745 for (r = 0; r < 16; r++)
1752 if (scan_info->ext_rate[r]) 1746 if (scan_info->ext_rate[r])
1753 target->rate_ext_len++; 1747 target->rate_ext_len++;
1754 list_move_tail(&target->list, &wl->network_list); 1748 list_move_tail(&target->list, &wl->network_list);
@@ -1787,7 +1781,6 @@ struct gelic_wl_scan_info *gelic_wl_find_best_bss(struct gelic_wl_info *wl)
1787 struct gelic_wl_scan_info *best_bss; 1781 struct gelic_wl_scan_info *best_bss;
1788 int weight, best_weight; 1782 int weight, best_weight;
1789 u16 security; 1783 u16 security;
1790 DECLARE_MAC_BUF(mac);
1791 1784
1792 pr_debug("%s: <-\n", __func__); 1785 pr_debug("%s: <-\n", __func__);
1793 1786
@@ -1857,8 +1850,8 @@ struct gelic_wl_scan_info *gelic_wl_find_best_bss(struct gelic_wl_info *wl)
1857#ifdef DEBUG 1850#ifdef DEBUG
1858 pr_debug("%s: -> bss=%p\n", __func__, best_bss); 1851 pr_debug("%s: -> bss=%p\n", __func__, best_bss);
1859 if (best_bss) { 1852 if (best_bss) {
1860 pr_debug("%s:addr=%s\n", __func__, 1853 pr_debug("%s:addr=%pM\n", __func__,
1861 print_mac(mac, &best_bss->hwinfo->bssid[2])); 1854 &best_bss->hwinfo->bssid[2]);
1862 } 1855 }
1863#endif 1856#endif
1864 return best_bss; 1857 return best_bss;
diff --git a/drivers/net/ps3_gelic_wireless.h b/drivers/net/ps3_gelic_wireless.h
index 5339e0078d18..5b631c6c9775 100644
--- a/drivers/net/ps3_gelic_wireless.h
+++ b/drivers/net/ps3_gelic_wireless.h
@@ -164,8 +164,8 @@ struct gelic_eurus_scan_info {
164 __be16 security; 164 __be16 security;
165 u8 bssid[8]; /* last ETH_ALEN are valid. bssid[0],[1] are unused */ 165 u8 bssid[8]; /* last ETH_ALEN are valid. bssid[0],[1] are unused */
166 u8 essid[32]; /* IW_ESSID_MAX_SIZE */ 166 u8 essid[32]; /* IW_ESSID_MAX_SIZE */
167 u8 rate[16]; /* first MAX_RATES_LENGTH(12) are valid */ 167 u8 rate[16]; /* first 12 are valid */
168 u8 ext_rate[16]; /* first MAX_RATES_EX_LENGTH(16) are valid */ 168 u8 ext_rate[16]; /* first 16 are valid */
169 __be32 reserved1; 169 __be32 reserved1;
170 __be32 reserved2; 170 __be32 reserved2;
171 __be32 reserved3; 171 __be32 reserved3;
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index 508452c02151..f188736028d7 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -2127,7 +2127,6 @@ static void ql_process_mac_rx_intr(struct ql3_adapter *qdev,
2127 skb->protocol = eth_type_trans(skb, qdev->ndev); 2127 skb->protocol = eth_type_trans(skb, qdev->ndev);
2128 2128
2129 netif_receive_skb(skb); 2129 netif_receive_skb(skb);
2130 qdev->ndev->last_rx = jiffies;
2131 lrg_buf_cb2->skb = NULL; 2130 lrg_buf_cb2->skb = NULL;
2132 2131
2133 if (qdev->device_id == QL3022_DEVICE_ID) 2132 if (qdev->device_id == QL3022_DEVICE_ID)
@@ -2201,7 +2200,6 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
2201 netif_receive_skb(skb2); 2200 netif_receive_skb(skb2);
2202 ndev->stats.rx_packets++; 2201 ndev->stats.rx_packets++;
2203 ndev->stats.rx_bytes += length; 2202 ndev->stats.rx_bytes += length;
2204 ndev->last_rx = jiffies;
2205 lrg_buf_cb2->skb = NULL; 2203 lrg_buf_cb2->skb = NULL;
2206 2204
2207 if (qdev->device_id == QL3022_DEVICE_ID) 2205 if (qdev->device_id == QL3022_DEVICE_ID)
@@ -3520,7 +3518,6 @@ static void ql_display_dev_info(struct net_device *ndev)
3520{ 3518{
3521 struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev); 3519 struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev);
3522 struct pci_dev *pdev = qdev->pdev; 3520 struct pci_dev *pdev = qdev->pdev;
3523 DECLARE_MAC_BUF(mac);
3524 3521
3525 printk(KERN_INFO PFX 3522 printk(KERN_INFO PFX
3526 "\n%s Adapter %d RevisionID %d found %s on PCI slot %d.\n", 3523 "\n%s Adapter %d RevisionID %d found %s on PCI slot %d.\n",
@@ -3546,8 +3543,8 @@ static void ql_display_dev_info(struct net_device *ndev)
3546 3543
3547 if (netif_msg_probe(qdev)) 3544 if (netif_msg_probe(qdev))
3548 printk(KERN_INFO PFX 3545 printk(KERN_INFO PFX
3549 "%s: MAC address %s\n", 3546 "%s: MAC address %pM\n",
3550 ndev->name, print_mac(mac, ndev->dev_addr)); 3547 ndev->name, ndev->dev_addr);
3551} 3548}
3552 3549
3553static int ql_adapter_down(struct ql3_adapter *qdev, int do_reset) 3550static int ql_adapter_down(struct ql3_adapter *qdev, int do_reset)
@@ -3969,9 +3966,7 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
3969 if (qdev->device_id == QL3032_DEVICE_ID) 3966 if (qdev->device_id == QL3032_DEVICE_ID)
3970 ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3967 ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
3971 3968
3972 qdev->mem_map_registers = 3969 qdev->mem_map_registers = pci_ioremap_bar(pdev, 1);
3973 ioremap_nocache(pci_resource_start(pdev, 1),
3974 pci_resource_len(qdev->pdev, 1));
3975 if (!qdev->mem_map_registers) { 3970 if (!qdev->mem_map_registers) {
3976 printk(KERN_ERR PFX "%s: cannot map device registers\n", 3971 printk(KERN_ERR PFX "%s: cannot map device registers\n",
3977 pci_name(pdev)); 3972 pci_name(pdev));
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index b83a9c9b6a97..3a6d3ac25f12 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -336,12 +336,11 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
336 (addr[5]); 336 (addr[5]);
337 337
338 QPRINTK(qdev, IFUP, INFO, 338 QPRINTK(qdev, IFUP, INFO,
339 "Adding %s address %02x:%02x:%02x:%02x:%02x:%02x" 339 "Adding %s address %pM"
340 " at index %d in the CAM.\n", 340 " at index %d in the CAM.\n",
341 ((type == 341 ((type ==
342 MAC_ADDR_TYPE_MULTI_MAC) ? "MULTICAST" : 342 MAC_ADDR_TYPE_MULTI_MAC) ? "MULTICAST" :
343 "UNICAST"), addr[0], addr[1], addr[2], addr[3], 343 "UNICAST"), addr, index);
344 addr[4], addr[5], index);
345 344
346 status = 345 status =
347 ql_wait_reg_rdy(qdev, 346 ql_wait_reg_rdy(qdev,
@@ -1452,7 +1451,6 @@ static void ql_process_mac_rx_intr(struct ql_adapter *qdev,
1452 "Passing a normal packet upstream.\n"); 1451 "Passing a normal packet upstream.\n");
1453 netif_rx(skb); 1452 netif_rx(skb);
1454 } 1453 }
1455 ndev->last_rx = jiffies;
1456} 1454}
1457 1455
1458/* Process an outbound completion from an rx ring. */ 1456/* Process an outbound completion from an rx ring. */
@@ -3127,11 +3125,7 @@ static void ql_display_dev_info(struct net_device *ndev)
3127 qdev->chip_rev_id >> 4 & 0x0000000f, 3125 qdev->chip_rev_id >> 4 & 0x0000000f,
3128 qdev->chip_rev_id >> 8 & 0x0000000f, 3126 qdev->chip_rev_id >> 8 & 0x0000000f,
3129 qdev->chip_rev_id >> 12 & 0x0000000f); 3127 qdev->chip_rev_id >> 12 & 0x0000000f);
3130 QPRINTK(qdev, PROBE, INFO, 3128 QPRINTK(qdev, PROBE, INFO, "MAC address %pM\n", ndev->dev_addr);
3131 "MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
3132 ndev->dev_addr[0], ndev->dev_addr[1],
3133 ndev->dev_addr[2], ndev->dev_addr[3], ndev->dev_addr[4],
3134 ndev->dev_addr[5]);
3135} 3129}
3136 3130
3137static int ql_adapter_down(struct ql_adapter *qdev) 3131static int ql_adapter_down(struct ql_adapter *qdev)
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 34fe7ef8e5ed..d9a6e920fd62 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -598,7 +598,6 @@ static int r6040_rx(struct net_device *dev, int limit)
598 598
599 /* Send to upper layer */ 599 /* Send to upper layer */
600 netif_receive_skb(skb_ptr); 600 netif_receive_skb(skb_ptr);
601 dev->last_rx = jiffies;
602 dev->stats.rx_packets++; 601 dev->stats.rx_packets++;
603 dev->stats.rx_bytes += descptr->len - 4; 602 dev->stats.rx_bytes += descptr->len - 4;
604 603
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 4b7cb389dc49..cb5042ef6dc7 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -3484,7 +3484,6 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
3484 if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0) 3484 if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0)
3485 netif_receive_skb(skb); 3485 netif_receive_skb(skb);
3486 3486
3487 dev->last_rx = jiffies;
3488 dev->stats.rx_bytes += pkt_size; 3487 dev->stats.rx_bytes += pkt_size;
3489 dev->stats.rx_packets++; 3488 dev->stats.rx_packets++;
3490 } 3489 }
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index 2b8fd68bc516..a6fd27a2cc3d 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -94,7 +94,7 @@ static int rionet_rx_clean(struct net_device *ndev)
94{ 94{
95 int i; 95 int i;
96 int error = 0; 96 int error = 0;
97 struct rionet_private *rnet = ndev->priv; 97 struct rionet_private *rnet = netdev_priv(ndev);
98 void *data; 98 void *data;
99 99
100 i = rnet->rx_slot; 100 i = rnet->rx_slot;
@@ -132,7 +132,7 @@ static int rionet_rx_clean(struct net_device *ndev)
132static void rionet_rx_fill(struct net_device *ndev, int end) 132static void rionet_rx_fill(struct net_device *ndev, int end)
133{ 133{
134 int i; 134 int i;
135 struct rionet_private *rnet = ndev->priv; 135 struct rionet_private *rnet = netdev_priv(ndev);
136 136
137 i = rnet->rx_slot; 137 i = rnet->rx_slot;
138 do { 138 do {
@@ -151,7 +151,7 @@ static void rionet_rx_fill(struct net_device *ndev, int end)
151static int rionet_queue_tx_msg(struct sk_buff *skb, struct net_device *ndev, 151static int rionet_queue_tx_msg(struct sk_buff *skb, struct net_device *ndev,
152 struct rio_dev *rdev) 152 struct rio_dev *rdev)
153{ 153{
154 struct rionet_private *rnet = ndev->priv; 154 struct rionet_private *rnet = netdev_priv(ndev);
155 155
156 rio_add_outb_message(rnet->mport, rdev, 0, skb->data, skb->len); 156 rio_add_outb_message(rnet->mport, rdev, 0, skb->data, skb->len);
157 rnet->tx_skb[rnet->tx_slot] = skb; 157 rnet->tx_skb[rnet->tx_slot] = skb;
@@ -175,7 +175,7 @@ static int rionet_queue_tx_msg(struct sk_buff *skb, struct net_device *ndev,
175static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev) 175static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
176{ 176{
177 int i; 177 int i;
178 struct rionet_private *rnet = ndev->priv; 178 struct rionet_private *rnet = netdev_priv(ndev);
179 struct ethhdr *eth = (struct ethhdr *)skb->data; 179 struct ethhdr *eth = (struct ethhdr *)skb->data;
180 u16 destid; 180 u16 destid;
181 unsigned long flags; 181 unsigned long flags;
@@ -215,7 +215,7 @@ static void rionet_dbell_event(struct rio_mport *mport, void *dev_id, u16 sid, u
215 u16 info) 215 u16 info)
216{ 216{
217 struct net_device *ndev = dev_id; 217 struct net_device *ndev = dev_id;
218 struct rionet_private *rnet = ndev->priv; 218 struct rionet_private *rnet = netdev_priv(ndev);
219 struct rionet_peer *peer; 219 struct rionet_peer *peer;
220 220
221 if (netif_msg_intr(rnet)) 221 if (netif_msg_intr(rnet))
@@ -243,7 +243,7 @@ static void rionet_inb_msg_event(struct rio_mport *mport, void *dev_id, int mbox
243{ 243{
244 int n; 244 int n;
245 struct net_device *ndev = dev_id; 245 struct net_device *ndev = dev_id;
246 struct rionet_private *rnet = (struct rionet_private *)ndev->priv; 246 struct rionet_private *rnet = netdev_priv(ndev);
247 247
248 if (netif_msg_intr(rnet)) 248 if (netif_msg_intr(rnet))
249 printk(KERN_INFO "%s: inbound message event, mbox %d slot %d\n", 249 printk(KERN_INFO "%s: inbound message event, mbox %d slot %d\n",
@@ -258,7 +258,7 @@ static void rionet_inb_msg_event(struct rio_mport *mport, void *dev_id, int mbox
258static void rionet_outb_msg_event(struct rio_mport *mport, void *dev_id, int mbox, int slot) 258static void rionet_outb_msg_event(struct rio_mport *mport, void *dev_id, int mbox, int slot)
259{ 259{
260 struct net_device *ndev = dev_id; 260 struct net_device *ndev = dev_id;
261 struct rionet_private *rnet = ndev->priv; 261 struct rionet_private *rnet = netdev_priv(ndev);
262 262
263 spin_lock(&rnet->lock); 263 spin_lock(&rnet->lock);
264 264
@@ -287,7 +287,7 @@ static int rionet_open(struct net_device *ndev)
287 int i, rc = 0; 287 int i, rc = 0;
288 struct rionet_peer *peer, *tmp; 288 struct rionet_peer *peer, *tmp;
289 u32 pwdcsr; 289 u32 pwdcsr;
290 struct rionet_private *rnet = ndev->priv; 290 struct rionet_private *rnet = netdev_priv(ndev);
291 291
292 if (netif_msg_ifup(rnet)) 292 if (netif_msg_ifup(rnet))
293 printk(KERN_INFO "%s: open\n", DRV_NAME); 293 printk(KERN_INFO "%s: open\n", DRV_NAME);
@@ -351,7 +351,7 @@ static int rionet_open(struct net_device *ndev)
351 351
352static int rionet_close(struct net_device *ndev) 352static int rionet_close(struct net_device *ndev)
353{ 353{
354 struct rionet_private *rnet = (struct rionet_private *)ndev->priv; 354 struct rionet_private *rnet = netdev_priv(ndev);
355 struct rionet_peer *peer, *tmp; 355 struct rionet_peer *peer, *tmp;
356 int i; 356 int i;
357 357
@@ -400,7 +400,7 @@ static void rionet_remove(struct rio_dev *rdev)
400static void rionet_get_drvinfo(struct net_device *ndev, 400static void rionet_get_drvinfo(struct net_device *ndev,
401 struct ethtool_drvinfo *info) 401 struct ethtool_drvinfo *info)
402{ 402{
403 struct rionet_private *rnet = ndev->priv; 403 struct rionet_private *rnet = netdev_priv(ndev);
404 404
405 strcpy(info->driver, DRV_NAME); 405 strcpy(info->driver, DRV_NAME);
406 strcpy(info->version, DRV_VERSION); 406 strcpy(info->version, DRV_VERSION);
@@ -410,14 +410,14 @@ static void rionet_get_drvinfo(struct net_device *ndev,
410 410
411static u32 rionet_get_msglevel(struct net_device *ndev) 411static u32 rionet_get_msglevel(struct net_device *ndev)
412{ 412{
413 struct rionet_private *rnet = ndev->priv; 413 struct rionet_private *rnet = netdev_priv(ndev);
414 414
415 return rnet->msg_enable; 415 return rnet->msg_enable;
416} 416}
417 417
418static void rionet_set_msglevel(struct net_device *ndev, u32 value) 418static void rionet_set_msglevel(struct net_device *ndev, u32 value)
419{ 419{
420 struct rionet_private *rnet = ndev->priv; 420 struct rionet_private *rnet = netdev_priv(ndev);
421 421
422 rnet->msg_enable = value; 422 rnet->msg_enable = value;
423} 423}
@@ -435,7 +435,6 @@ static int rionet_setup_netdev(struct rio_mport *mport)
435 struct net_device *ndev = NULL; 435 struct net_device *ndev = NULL;
436 struct rionet_private *rnet; 436 struct rionet_private *rnet;
437 u16 device_id; 437 u16 device_id;
438 DECLARE_MAC_BUF(mac);
439 438
440 /* Allocate our net_device structure */ 439 /* Allocate our net_device structure */
441 ndev = alloc_etherdev(sizeof(struct rionet_private)); 440 ndev = alloc_etherdev(sizeof(struct rionet_private));
@@ -456,7 +455,7 @@ static int rionet_setup_netdev(struct rio_mport *mport)
456 RIO_MAX_ROUTE_ENTRIES(mport->sys_size)); 455 RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
457 456
458 /* Set up private area */ 457 /* Set up private area */
459 rnet = (struct rionet_private *)ndev->priv; 458 rnet = netdev_priv(ndev);
460 rnet->mport = mport; 459 rnet->mport = mport;
461 460
462 /* Set the default MAC address */ 461 /* Set the default MAC address */
@@ -485,12 +484,12 @@ static int rionet_setup_netdev(struct rio_mport *mport)
485 if (rc != 0) 484 if (rc != 0)
486 goto out; 485 goto out;
487 486
488 printk("%s: %s %s Version %s, MAC %s\n", 487 printk("%s: %s %s Version %s, MAC %pM\n",
489 ndev->name, 488 ndev->name,
490 DRV_NAME, 489 DRV_NAME,
491 DRV_DESC, 490 DRV_DESC,
492 DRV_VERSION, 491 DRV_VERSION,
493 print_mac(mac, ndev->dev_addr)); 492 ndev->dev_addr);
494 493
495 out: 494 out:
496 return rc; 495 return rc;
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c
index 3dd8f1342f70..6e4131f9a933 100644
--- a/drivers/net/rrunner.c
+++ b/drivers/net/rrunner.c
@@ -511,7 +511,6 @@ static int __devinit rr_init(struct net_device *dev)
511 struct rr_private *rrpriv; 511 struct rr_private *rrpriv;
512 struct rr_regs __iomem *regs; 512 struct rr_regs __iomem *regs;
513 u32 sram_size, rev; 513 u32 sram_size, rev;
514 DECLARE_MAC_BUF(mac);
515 514
516 rrpriv = netdev_priv(dev); 515 rrpriv = netdev_priv(dev);
517 regs = rrpriv->regs; 516 regs = rrpriv->regs;
@@ -549,7 +548,7 @@ static int __devinit rr_init(struct net_device *dev)
549 *(__be32 *)(dev->dev_addr+2) = 548 *(__be32 *)(dev->dev_addr+2) =
550 htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4]))); 549 htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4])));
551 550
552 printk(" MAC: %s\n", print_mac(mac, dev->dev_addr)); 551 printk(" MAC: %pM\n", dev->dev_addr);
553 552
554 sram_size = rr_read_eeprom_word(rrpriv, 8); 553 sram_size = rr_read_eeprom_word(rrpriv, 8);
555 printk(" SRAM size 0x%06x\n", sram_size); 554 printk(" SRAM size 0x%06x\n", sram_size);
@@ -1006,7 +1005,6 @@ static void rx_int(struct net_device *dev, u32 rxlimit, u32 index)
1006 1005
1007 netif_rx(skb); /* send it up */ 1006 netif_rx(skb); /* send it up */
1008 1007
1009 dev->last_rx = jiffies;
1010 dev->stats.rx_packets++; 1008 dev->stats.rx_packets++;
1011 dev->stats.rx_bytes += pkt_len; 1009 dev->stats.rx_bytes += pkt_len;
1012 } 1010 }
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 6a1375f9cbb8..62369341cb2c 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -357,7 +357,7 @@ static void s2io_vlan_rx_register(struct net_device *dev,
357 struct vlan_group *grp) 357 struct vlan_group *grp)
358{ 358{
359 int i; 359 int i;
360 struct s2io_nic *nic = dev->priv; 360 struct s2io_nic *nic = netdev_priv(dev);
361 unsigned long flags[MAX_TX_FIFOS]; 361 unsigned long flags[MAX_TX_FIFOS];
362 struct mac_info *mac_control = &nic->mac_control; 362 struct mac_info *mac_control = &nic->mac_control;
363 struct config_param *config = &nic->config; 363 struct config_param *config = &nic->config;
@@ -375,7 +375,7 @@ static void s2io_vlan_rx_register(struct net_device *dev,
375static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid) 375static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid)
376{ 376{
377 int i; 377 int i;
378 struct s2io_nic *nic = dev->priv; 378 struct s2io_nic *nic = netdev_priv(dev);
379 unsigned long flags[MAX_TX_FIFOS]; 379 unsigned long flags[MAX_TX_FIFOS];
380 struct mac_info *mac_control = &nic->mac_control; 380 struct mac_info *mac_control = &nic->mac_control;
381 struct config_param *config = &nic->config; 381 struct config_param *config = &nic->config;
@@ -2837,7 +2837,7 @@ static int s2io_poll_msix(struct napi_struct *napi, int budget)
2837 int pkts_processed = 0; 2837 int pkts_processed = 0;
2838 u8 __iomem *addr = NULL; 2838 u8 __iomem *addr = NULL;
2839 u8 val8 = 0; 2839 u8 val8 = 0;
2840 struct s2io_nic *nic = dev->priv; 2840 struct s2io_nic *nic = netdev_priv(dev);
2841 struct XENA_dev_config __iomem *bar0 = nic->bar0; 2841 struct XENA_dev_config __iomem *bar0 = nic->bar0;
2842 int budget_org = budget; 2842 int budget_org = budget;
2843 2843
@@ -2909,7 +2909,7 @@ static int s2io_poll_inta(struct napi_struct *napi, int budget)
2909 */ 2909 */
2910static void s2io_netpoll(struct net_device *dev) 2910static void s2io_netpoll(struct net_device *dev)
2911{ 2911{
2912 struct s2io_nic *nic = dev->priv; 2912 struct s2io_nic *nic = netdev_priv(dev);
2913 struct mac_info *mac_control; 2913 struct mac_info *mac_control;
2914 struct config_param *config; 2914 struct config_param *config;
2915 struct XENA_dev_config __iomem *bar0 = nic->bar0; 2915 struct XENA_dev_config __iomem *bar0 = nic->bar0;
@@ -3171,7 +3171,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
3171static void s2io_mdio_write(u32 mmd_type, u64 addr, u16 value, struct net_device *dev) 3171static void s2io_mdio_write(u32 mmd_type, u64 addr, u16 value, struct net_device *dev)
3172{ 3172{
3173 u64 val64 = 0x0; 3173 u64 val64 = 0x0;
3174 struct s2io_nic *sp = dev->priv; 3174 struct s2io_nic *sp = netdev_priv(dev);
3175 struct XENA_dev_config __iomem *bar0 = sp->bar0; 3175 struct XENA_dev_config __iomem *bar0 = sp->bar0;
3176 3176
3177 //address transaction 3177 //address transaction
@@ -3220,7 +3220,7 @@ static u64 s2io_mdio_read(u32 mmd_type, u64 addr, struct net_device *dev)
3220{ 3220{
3221 u64 val64 = 0x0; 3221 u64 val64 = 0x0;
3222 u64 rval64 = 0x0; 3222 u64 rval64 = 0x0;
3223 struct s2io_nic *sp = dev->priv; 3223 struct s2io_nic *sp = netdev_priv(dev);
3224 struct XENA_dev_config __iomem *bar0 = sp->bar0; 3224 struct XENA_dev_config __iomem *bar0 = sp->bar0;
3225 3225
3226 /* address transaction */ 3226 /* address transaction */
@@ -3324,7 +3324,7 @@ static void s2io_updt_xpak_counter(struct net_device *dev)
3324 u64 val64 = 0x0; 3324 u64 val64 = 0x0;
3325 u64 addr = 0x0; 3325 u64 addr = 0x0;
3326 3326
3327 struct s2io_nic *sp = dev->priv; 3327 struct s2io_nic *sp = netdev_priv(dev);
3328 struct stat_block *stat_info = sp->mac_control.stats_info; 3328 struct stat_block *stat_info = sp->mac_control.stats_info;
3329 3329
3330 /* Check the communication with the MDIO slave */ 3330 /* Check the communication with the MDIO slave */
@@ -3990,7 +3990,7 @@ static void remove_inta_isr(struct s2io_nic *sp)
3990 3990
3991static int s2io_open(struct net_device *dev) 3991static int s2io_open(struct net_device *dev)
3992{ 3992{
3993 struct s2io_nic *sp = dev->priv; 3993 struct s2io_nic *sp = netdev_priv(dev);
3994 int err = 0; 3994 int err = 0;
3995 3995
3996 /* 3996 /*
@@ -4048,7 +4048,7 @@ hw_init_failed:
4048 4048
4049static int s2io_close(struct net_device *dev) 4049static int s2io_close(struct net_device *dev)
4050{ 4050{
4051 struct s2io_nic *sp = dev->priv; 4051 struct s2io_nic *sp = netdev_priv(dev);
4052 struct config_param *config = &sp->config; 4052 struct config_param *config = &sp->config;
4053 u64 tmp64; 4053 u64 tmp64;
4054 int offset; 4054 int offset;
@@ -4087,7 +4087,7 @@ static int s2io_close(struct net_device *dev)
4087 4087
4088static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) 4088static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4089{ 4089{
4090 struct s2io_nic *sp = dev->priv; 4090 struct s2io_nic *sp = netdev_priv(dev);
4091 u16 frg_cnt, frg_len, i, queue, queue_len, put_off, get_off; 4091 u16 frg_cnt, frg_len, i, queue, queue_len, put_off, get_off;
4092 register u64 val64; 4092 register u64 val64;
4093 struct TxD *txdp; 4093 struct TxD *txdp;
@@ -4485,7 +4485,7 @@ static int do_s2io_chk_alarm_bit(u64 value, void __iomem * addr,
4485static void s2io_handle_errors(void * dev_id) 4485static void s2io_handle_errors(void * dev_id)
4486{ 4486{
4487 struct net_device *dev = (struct net_device *) dev_id; 4487 struct net_device *dev = (struct net_device *) dev_id;
4488 struct s2io_nic *sp = dev->priv; 4488 struct s2io_nic *sp = netdev_priv(dev);
4489 struct XENA_dev_config __iomem *bar0 = sp->bar0; 4489 struct XENA_dev_config __iomem *bar0 = sp->bar0;
4490 u64 temp64 = 0,val64=0; 4490 u64 temp64 = 0,val64=0;
4491 int i = 0; 4491 int i = 0;
@@ -4752,7 +4752,7 @@ reset:
4752static irqreturn_t s2io_isr(int irq, void *dev_id) 4752static irqreturn_t s2io_isr(int irq, void *dev_id)
4753{ 4753{
4754 struct net_device *dev = (struct net_device *) dev_id; 4754 struct net_device *dev = (struct net_device *) dev_id;
4755 struct s2io_nic *sp = dev->priv; 4755 struct s2io_nic *sp = netdev_priv(dev);
4756 struct XENA_dev_config __iomem *bar0 = sp->bar0; 4756 struct XENA_dev_config __iomem *bar0 = sp->bar0;
4757 int i; 4757 int i;
4758 u64 reason = 0; 4758 u64 reason = 0;
@@ -4881,7 +4881,7 @@ static void s2io_updt_stats(struct s2io_nic *sp)
4881 4881
4882static struct net_device_stats *s2io_get_stats(struct net_device *dev) 4882static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4883{ 4883{
4884 struct s2io_nic *sp = dev->priv; 4884 struct s2io_nic *sp = netdev_priv(dev);
4885 struct mac_info *mac_control; 4885 struct mac_info *mac_control;
4886 struct config_param *config; 4886 struct config_param *config;
4887 int i; 4887 int i;
@@ -4948,7 +4948,7 @@ static void s2io_set_multicast(struct net_device *dev)
4948{ 4948{
4949 int i, j, prev_cnt; 4949 int i, j, prev_cnt;
4950 struct dev_mc_list *mclist; 4950 struct dev_mc_list *mclist;
4951 struct s2io_nic *sp = dev->priv; 4951 struct s2io_nic *sp = netdev_priv(dev);
4952 struct XENA_dev_config __iomem *bar0 = sp->bar0; 4952 struct XENA_dev_config __iomem *bar0 = sp->bar0;
4953 u64 val64 = 0, multi_mac = 0x010203040506ULL, mask = 4953 u64 val64 = 0, multi_mac = 0x010203040506ULL, mask =
4954 0xfeffffffffffULL; 4954 0xfeffffffffffULL;
@@ -5277,7 +5277,7 @@ static int s2io_set_mac_addr(struct net_device *dev, void *p)
5277 5277
5278static int do_s2io_prog_unicast(struct net_device *dev, u8 *addr) 5278static int do_s2io_prog_unicast(struct net_device *dev, u8 *addr)
5279{ 5279{
5280 struct s2io_nic *sp = dev->priv; 5280 struct s2io_nic *sp = netdev_priv(dev);
5281 register u64 mac_addr = 0, perm_addr = 0; 5281 register u64 mac_addr = 0, perm_addr = 0;
5282 int i; 5282 int i;
5283 u64 tmp64; 5283 u64 tmp64;
@@ -5336,7 +5336,7 @@ static int do_s2io_prog_unicast(struct net_device *dev, u8 *addr)
5336static int s2io_ethtool_sset(struct net_device *dev, 5336static int s2io_ethtool_sset(struct net_device *dev,
5337 struct ethtool_cmd *info) 5337 struct ethtool_cmd *info)
5338{ 5338{
5339 struct s2io_nic *sp = dev->priv; 5339 struct s2io_nic *sp = netdev_priv(dev);
5340 if ((info->autoneg == AUTONEG_ENABLE) || 5340 if ((info->autoneg == AUTONEG_ENABLE) ||
5341 (info->speed != SPEED_10000) || (info->duplex != DUPLEX_FULL)) 5341 (info->speed != SPEED_10000) || (info->duplex != DUPLEX_FULL))
5342 return -EINVAL; 5342 return -EINVAL;
@@ -5362,7 +5362,7 @@ static int s2io_ethtool_sset(struct net_device *dev,
5362 5362
5363static int s2io_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info) 5363static int s2io_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info)
5364{ 5364{
5365 struct s2io_nic *sp = dev->priv; 5365 struct s2io_nic *sp = netdev_priv(dev);
5366 info->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); 5366 info->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
5367 info->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); 5367 info->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
5368 info->port = PORT_FIBRE; 5368 info->port = PORT_FIBRE;
@@ -5397,7 +5397,7 @@ static int s2io_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info)
5397static void s2io_ethtool_gdrvinfo(struct net_device *dev, 5397static void s2io_ethtool_gdrvinfo(struct net_device *dev,
5398 struct ethtool_drvinfo *info) 5398 struct ethtool_drvinfo *info)
5399{ 5399{
5400 struct s2io_nic *sp = dev->priv; 5400 struct s2io_nic *sp = netdev_priv(dev);
5401 5401
5402 strncpy(info->driver, s2io_driver_name, sizeof(info->driver)); 5402 strncpy(info->driver, s2io_driver_name, sizeof(info->driver));
5403 strncpy(info->version, s2io_driver_version, sizeof(info->version)); 5403 strncpy(info->version, s2io_driver_version, sizeof(info->version));
@@ -5427,7 +5427,7 @@ static void s2io_ethtool_gregs(struct net_device *dev,
5427 int i; 5427 int i;
5428 u64 reg; 5428 u64 reg;
5429 u8 *reg_space = (u8 *) space; 5429 u8 *reg_space = (u8 *) space;
5430 struct s2io_nic *sp = dev->priv; 5430 struct s2io_nic *sp = netdev_priv(dev);
5431 5431
5432 regs->len = XENA_REG_SPACE; 5432 regs->len = XENA_REG_SPACE;
5433 regs->version = sp->pdev->subsystem_device; 5433 regs->version = sp->pdev->subsystem_device;
@@ -5487,7 +5487,7 @@ static void s2io_phy_id(unsigned long data)
5487static int s2io_ethtool_idnic(struct net_device *dev, u32 data) 5487static int s2io_ethtool_idnic(struct net_device *dev, u32 data)
5488{ 5488{
5489 u64 val64 = 0, last_gpio_ctrl_val; 5489 u64 val64 = 0, last_gpio_ctrl_val;
5490 struct s2io_nic *sp = dev->priv; 5490 struct s2io_nic *sp = netdev_priv(dev);
5491 struct XENA_dev_config __iomem *bar0 = sp->bar0; 5491 struct XENA_dev_config __iomem *bar0 = sp->bar0;
5492 u16 subid; 5492 u16 subid;
5493 5493
@@ -5525,7 +5525,7 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data)
5525static void s2io_ethtool_gringparam(struct net_device *dev, 5525static void s2io_ethtool_gringparam(struct net_device *dev,
5526 struct ethtool_ringparam *ering) 5526 struct ethtool_ringparam *ering)
5527{ 5527{
5528 struct s2io_nic *sp = dev->priv; 5528 struct s2io_nic *sp = netdev_priv(dev);
5529 int i,tx_desc_count=0,rx_desc_count=0; 5529 int i,tx_desc_count=0,rx_desc_count=0;
5530 5530
5531 if (sp->rxd_mode == RXD_MODE_1) 5531 if (sp->rxd_mode == RXD_MODE_1)
@@ -5568,7 +5568,7 @@ static void s2io_ethtool_getpause_data(struct net_device *dev,
5568 struct ethtool_pauseparam *ep) 5568 struct ethtool_pauseparam *ep)
5569{ 5569{
5570 u64 val64; 5570 u64 val64;
5571 struct s2io_nic *sp = dev->priv; 5571 struct s2io_nic *sp = netdev_priv(dev);
5572 struct XENA_dev_config __iomem *bar0 = sp->bar0; 5572 struct XENA_dev_config __iomem *bar0 = sp->bar0;
5573 5573
5574 val64 = readq(&bar0->rmac_pause_cfg); 5574 val64 = readq(&bar0->rmac_pause_cfg);
@@ -5595,7 +5595,7 @@ static int s2io_ethtool_setpause_data(struct net_device *dev,
5595 struct ethtool_pauseparam *ep) 5595 struct ethtool_pauseparam *ep)
5596{ 5596{
5597 u64 val64; 5597 u64 val64;
5598 struct s2io_nic *sp = dev->priv; 5598 struct s2io_nic *sp = netdev_priv(dev);
5599 struct XENA_dev_config __iomem *bar0 = sp->bar0; 5599 struct XENA_dev_config __iomem *bar0 = sp->bar0;
5600 5600
5601 val64 = readq(&bar0->rmac_pause_cfg); 5601 val64 = readq(&bar0->rmac_pause_cfg);
@@ -5825,7 +5825,7 @@ static int s2io_ethtool_geeprom(struct net_device *dev,
5825{ 5825{
5826 u32 i, valid; 5826 u32 i, valid;
5827 u64 data; 5827 u64 data;
5828 struct s2io_nic *sp = dev->priv; 5828 struct s2io_nic *sp = netdev_priv(dev);
5829 5829
5830 eeprom->magic = sp->pdev->vendor | (sp->pdev->device << 16); 5830 eeprom->magic = sp->pdev->vendor | (sp->pdev->device << 16);
5831 5831
@@ -5863,7 +5863,7 @@ static int s2io_ethtool_seeprom(struct net_device *dev,
5863{ 5863{
5864 int len = eeprom->len, cnt = 0; 5864 int len = eeprom->len, cnt = 0;
5865 u64 valid = 0, data; 5865 u64 valid = 0, data;
5866 struct s2io_nic *sp = dev->priv; 5866 struct s2io_nic *sp = netdev_priv(dev);
5867 5867
5868 if (eeprom->magic != (sp->pdev->vendor | (sp->pdev->device << 16))) { 5868 if (eeprom->magic != (sp->pdev->vendor | (sp->pdev->device << 16))) {
5869 DBG_PRINT(ERR_DBG, 5869 DBG_PRINT(ERR_DBG,
@@ -6243,7 +6243,7 @@ static void s2io_ethtool_test(struct net_device *dev,
6243 struct ethtool_test *ethtest, 6243 struct ethtool_test *ethtest,
6244 uint64_t * data) 6244 uint64_t * data)
6245{ 6245{
6246 struct s2io_nic *sp = dev->priv; 6246 struct s2io_nic *sp = netdev_priv(dev);
6247 int orig_state = netif_running(sp->dev); 6247 int orig_state = netif_running(sp->dev);
6248 6248
6249 if (ethtest->flags == ETH_TEST_FL_OFFLINE) { 6249 if (ethtest->flags == ETH_TEST_FL_OFFLINE) {
@@ -6299,7 +6299,7 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
6299 u64 * tmp_stats) 6299 u64 * tmp_stats)
6300{ 6300{
6301 int i = 0, k; 6301 int i = 0, k;
6302 struct s2io_nic *sp = dev->priv; 6302 struct s2io_nic *sp = netdev_priv(dev);
6303 struct stat_block *stat_info = sp->mac_control.stats_info; 6303 struct stat_block *stat_info = sp->mac_control.stats_info;
6304 6304
6305 s2io_updt_stats(sp); 6305 s2io_updt_stats(sp);
@@ -6578,14 +6578,14 @@ static int s2io_ethtool_get_regs_len(struct net_device *dev)
6578 6578
6579static u32 s2io_ethtool_get_rx_csum(struct net_device * dev) 6579static u32 s2io_ethtool_get_rx_csum(struct net_device * dev)
6580{ 6580{
6581 struct s2io_nic *sp = dev->priv; 6581 struct s2io_nic *sp = netdev_priv(dev);
6582 6582
6583 return (sp->rx_csum); 6583 return (sp->rx_csum);
6584} 6584}
6585 6585
6586static int s2io_ethtool_set_rx_csum(struct net_device *dev, u32 data) 6586static int s2io_ethtool_set_rx_csum(struct net_device *dev, u32 data)
6587{ 6587{
6588 struct s2io_nic *sp = dev->priv; 6588 struct s2io_nic *sp = netdev_priv(dev);
6589 6589
6590 if (data) 6590 if (data)
6591 sp->rx_csum = 1; 6591 sp->rx_csum = 1;
@@ -6602,7 +6602,7 @@ static int s2io_get_eeprom_len(struct net_device *dev)
6602 6602
6603static int s2io_get_sset_count(struct net_device *dev, int sset) 6603static int s2io_get_sset_count(struct net_device *dev, int sset)
6604{ 6604{
6605 struct s2io_nic *sp = dev->priv; 6605 struct s2io_nic *sp = netdev_priv(dev);
6606 6606
6607 switch (sset) { 6607 switch (sset) {
6608 case ETH_SS_TEST: 6608 case ETH_SS_TEST:
@@ -6625,7 +6625,7 @@ static void s2io_ethtool_get_strings(struct net_device *dev,
6625 u32 stringset, u8 * data) 6625 u32 stringset, u8 * data)
6626{ 6626{
6627 int stat_size = 0; 6627 int stat_size = 0;
6628 struct s2io_nic *sp = dev->priv; 6628 struct s2io_nic *sp = netdev_priv(dev);
6629 6629
6630 switch (stringset) { 6630 switch (stringset) {
6631 case ETH_SS_TEST: 6631 case ETH_SS_TEST:
@@ -6727,7 +6727,7 @@ static int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
6727 6727
6728static int s2io_change_mtu(struct net_device *dev, int new_mtu) 6728static int s2io_change_mtu(struct net_device *dev, int new_mtu)
6729{ 6729{
6730 struct s2io_nic *sp = dev->priv; 6730 struct s2io_nic *sp = netdev_priv(dev);
6731 int ret = 0; 6731 int ret = 0;
6732 6732
6733 if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) { 6733 if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) {
@@ -7331,7 +7331,7 @@ out_unlock:
7331 7331
7332static void s2io_tx_watchdog(struct net_device *dev) 7332static void s2io_tx_watchdog(struct net_device *dev)
7333{ 7333{
7334 struct s2io_nic *sp = dev->priv; 7334 struct s2io_nic *sp = netdev_priv(dev);
7335 7335
7336 if (netif_carrier_ok(dev)) { 7336 if (netif_carrier_ok(dev)) {
7337 sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt++; 7337 sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt++;
@@ -7544,7 +7544,6 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7544 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; 7544 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
7545send_up: 7545send_up:
7546 queue_rx_frame(skb, RXD_GET_VLAN_TAG(rxdp->Control_2)); 7546 queue_rx_frame(skb, RXD_GET_VLAN_TAG(rxdp->Control_2));
7547 dev->last_rx = jiffies;
7548aggregate: 7547aggregate:
7549 sp->mac_control.rings[ring_no].rx_bufs_left -= 1; 7548 sp->mac_control.rings[ring_no].rx_bufs_left -= 1;
7550 return SUCCESS; 7549 return SUCCESS;
@@ -7748,7 +7747,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7748 int mode; 7747 int mode;
7749 u8 dev_intr_type = intr_type; 7748 u8 dev_intr_type = intr_type;
7750 u8 dev_multiq = 0; 7749 u8 dev_multiq = 0;
7751 DECLARE_MAC_BUF(mac);
7752 7750
7753 ret = s2io_verify_parm(pdev, &dev_intr_type, &dev_multiq); 7751 ret = s2io_verify_parm(pdev, &dev_intr_type, &dev_multiq);
7754 if (ret) 7752 if (ret)
@@ -7798,7 +7796,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7798 SET_NETDEV_DEV(dev, &pdev->dev); 7796 SET_NETDEV_DEV(dev, &pdev->dev);
7799 7797
7800 /* Private member variable initialized to s2io NIC structure */ 7798 /* Private member variable initialized to s2io NIC structure */
7801 sp = dev->priv; 7799 sp = netdev_priv(dev);
7802 memset(sp, 0, sizeof(struct s2io_nic)); 7800 memset(sp, 0, sizeof(struct s2io_nic));
7803 sp->dev = dev; 7801 sp->dev = dev;
7804 sp->pdev = pdev; 7802 sp->pdev = pdev;
@@ -7918,8 +7916,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7918 goto mem_alloc_failed; 7916 goto mem_alloc_failed;
7919 } 7917 }
7920 7918
7921 sp->bar0 = ioremap(pci_resource_start(pdev, 0), 7919 sp->bar0 = pci_ioremap_bar(pdev, 0);
7922 pci_resource_len(pdev, 0));
7923 if (!sp->bar0) { 7920 if (!sp->bar0) {
7924 DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem1\n", 7921 DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem1\n",
7925 dev->name); 7922 dev->name);
@@ -7927,8 +7924,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7927 goto bar0_remap_failed; 7924 goto bar0_remap_failed;
7928 } 7925 }
7929 7926
7930 sp->bar1 = ioremap(pci_resource_start(pdev, 2), 7927 sp->bar1 = pci_ioremap_bar(pdev, 2);
7931 pci_resource_len(pdev, 2));
7932 if (!sp->bar1) { 7928 if (!sp->bar1) {
7933 DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem2\n", 7929 DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem2\n",
7934 dev->name); 7930 dev->name);
@@ -8125,8 +8121,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
8125 sp->product_name, pdev->revision); 8121 sp->product_name, pdev->revision);
8126 DBG_PRINT(ERR_DBG, "%s: Driver version %s\n", dev->name, 8122 DBG_PRINT(ERR_DBG, "%s: Driver version %s\n", dev->name,
8127 s2io_driver_version); 8123 s2io_driver_version);
8128 DBG_PRINT(ERR_DBG, "%s: MAC ADDR: %s\n", 8124 DBG_PRINT(ERR_DBG, "%s: MAC ADDR: %pM\n", dev->name, dev->dev_addr);
8129 dev->name, print_mac(mac, dev->dev_addr));
8130 DBG_PRINT(ERR_DBG, "SERIAL NUMBER: %s\n", sp->serial_num); 8125 DBG_PRINT(ERR_DBG, "SERIAL NUMBER: %s\n", sp->serial_num);
8131 if (sp->device_type & XFRAME_II_DEVICE) { 8126 if (sp->device_type & XFRAME_II_DEVICE) {
8132 mode = s2io_print_pci_mode(sp); 8127 mode = s2io_print_pci_mode(sp);
@@ -8255,7 +8250,7 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev)
8255 8250
8256 flush_scheduled_work(); 8251 flush_scheduled_work();
8257 8252
8258 sp = dev->priv; 8253 sp = netdev_priv(dev);
8259 unregister_netdev(dev); 8254 unregister_netdev(dev);
8260 8255
8261 free_shared_mem(sp); 8256 free_shared_mem(sp);
@@ -8590,7 +8585,7 @@ static void clear_lro_session(struct lro *lro)
8590static void queue_rx_frame(struct sk_buff *skb, u16 vlan_tag) 8585static void queue_rx_frame(struct sk_buff *skb, u16 vlan_tag)
8591{ 8586{
8592 struct net_device *dev = skb->dev; 8587 struct net_device *dev = skb->dev;
8593 struct s2io_nic *sp = dev->priv; 8588 struct s2io_nic *sp = netdev_priv(dev);
8594 8589
8595 skb->protocol = eth_type_trans(skb, dev); 8590 skb->protocol = eth_type_trans(skb, dev);
8596 if (sp->vlgrp && vlan_tag 8591 if (sp->vlgrp && vlan_tag
@@ -8639,7 +8634,7 @@ static pci_ers_result_t s2io_io_error_detected(struct pci_dev *pdev,
8639 pci_channel_state_t state) 8634 pci_channel_state_t state)
8640{ 8635{
8641 struct net_device *netdev = pci_get_drvdata(pdev); 8636 struct net_device *netdev = pci_get_drvdata(pdev);
8642 struct s2io_nic *sp = netdev->priv; 8637 struct s2io_nic *sp = netdev_priv(netdev);
8643 8638
8644 netif_device_detach(netdev); 8639 netif_device_detach(netdev);
8645 8640
@@ -8664,7 +8659,7 @@ static pci_ers_result_t s2io_io_error_detected(struct pci_dev *pdev,
8664static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev) 8659static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev)
8665{ 8660{
8666 struct net_device *netdev = pci_get_drvdata(pdev); 8661 struct net_device *netdev = pci_get_drvdata(pdev);
8667 struct s2io_nic *sp = netdev->priv; 8662 struct s2io_nic *sp = netdev_priv(netdev);
8668 8663
8669 if (pci_enable_device(pdev)) { 8664 if (pci_enable_device(pdev)) {
8670 printk(KERN_ERR "s2io: " 8665 printk(KERN_ERR "s2io: "
@@ -8688,7 +8683,7 @@ static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev)
8688static void s2io_io_resume(struct pci_dev *pdev) 8683static void s2io_io_resume(struct pci_dev *pdev)
8689{ 8684{
8690 struct net_device *netdev = pci_get_drvdata(pdev); 8685 struct net_device *netdev = pci_get_drvdata(pdev);
8691 struct s2io_nic *sp = netdev->priv; 8686 struct s2io_nic *sp = netdev_priv(netdev);
8692 8687
8693 if (netif_running(netdev)) { 8688 if (netif_running(netdev)) {
8694 if (s2io_card_up(sp)) { 8689 if (s2io_card_up(sp)) {
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index 5986cec17f19..be3025310e90 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -869,7 +869,6 @@ printk("cm0: IP identification: %02x%02x fragment offset: %02x%02x\n", buffer[3
869 /* datagram completed: send to upper level */ 869 /* datagram completed: send to upper level */
870 skb_trim(skb, dlen); 870 skb_trim(skb, dlen);
871 netif_rx(skb); 871 netif_rx(skb);
872 dev->last_rx = jiffies;
873 stats->rx_bytes+=dlen; 872 stats->rx_bytes+=dlen;
874 stats->rx_packets++; 873 stats->rx_packets++;
875 lp->rx_skb[ns] = NULL; 874 lp->rx_skb[ns] = NULL;
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 2615d46e6e50..480caec1e024 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2292,7 +2292,6 @@ static int sbmac_init(struct platform_device *pldev, long long base)
2292 uint64_t ea_reg; 2292 uint64_t ea_reg;
2293 int i; 2293 int i;
2294 int err; 2294 int err;
2295 DECLARE_MAC_BUF(mac);
2296 2295
2297 sc->sbm_dev = dev; 2296 sc->sbm_dev = dev;
2298 sc->sbe_idx = idx; 2297 sc->sbe_idx = idx;
@@ -2373,8 +2372,8 @@ static int sbmac_init(struct platform_device *pldev, long long base)
2373 * process so we need to finish off the config message that 2372 * process so we need to finish off the config message that
2374 * was being displayed) 2373 * was being displayed)
2375 */ 2374 */
2376 pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %s\n", 2375 pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n",
2377 dev->name, base, print_mac(mac, eaddr)); 2376 dev->name, base, eaddr);
2378 2377
2379 sc->mii_bus->name = sbmac_mdio_string; 2378 sc->mii_bus->name = sbmac_mdio_string;
2380 snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx); 2379 snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx);
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index 61955f8d8011..590f2175e9e0 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -816,7 +816,6 @@ static void _sc92031_rx_tasklet(struct net_device *dev)
816 } 816 }
817 817
818 skb->protocol = eth_type_trans(skb, dev); 818 skb->protocol = eth_type_trans(skb, dev);
819 dev->last_rx = jiffies;
820 netif_rx(skb); 819 netif_rx(skb);
821 820
822 dev->stats.rx_bytes += pkt_size; 821 dev->stats.rx_bytes += pkt_size;
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
index 48c64fb20eec..2fbc8f1e8b48 100644
--- a/drivers/net/seeq8005.c
+++ b/drivers/net/seeq8005.c
@@ -158,7 +158,6 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr)
158 int old_dmaar; 158 int old_dmaar;
159 int old_rear; 159 int old_rear;
160 int retval; 160 int retval;
161 DECLARE_MAC_BUF(mac);
162 161
163 if (!request_region(ioaddr, SEEQ8005_IO_EXTENT, "seeq8005")) 162 if (!request_region(ioaddr, SEEQ8005_IO_EXTENT, "seeq8005"))
164 return -ENODEV; 163 return -ENODEV;
@@ -303,7 +302,7 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr)
303 /* Retrieve and print the ethernet address. */ 302 /* Retrieve and print the ethernet address. */
304 for (i = 0; i < 6; i++) 303 for (i = 0; i < 6; i++)
305 dev->dev_addr[i] = SA_prom[i+6]; 304 dev->dev_addr[i] = SA_prom[i+6];
306 printk("%s", print_mac(mac, dev->dev_addr)); 305 printk("%pM", dev->dev_addr);
307 306
308 if (dev->irq == 0xff) 307 if (dev->irq == 0xff)
309 ; /* Do nothing: a user-level program will set it. */ 308 ; /* Do nothing: a user-level program will set it. */
@@ -564,7 +563,6 @@ static void seeq8005_rx(struct net_device *dev)
564 563
565 skb->protocol=eth_type_trans(skb,dev); 564 skb->protocol=eth_type_trans(skb,dev);
566 netif_rx(skb); 565 netif_rx(skb);
567 dev->last_rx = jiffies;
568 dev->stats.rx_packets++; 566 dev->stats.rx_packets++;
569 dev->stats.rx_bytes += pkt_len; 567 dev->stats.rx_bytes += pkt_len;
570 } 568 }
diff --git a/drivers/net/sfc/Kconfig b/drivers/net/sfc/Kconfig
index 3be13b592b4d..3e25fb38f739 100644
--- a/drivers/net/sfc/Kconfig
+++ b/drivers/net/sfc/Kconfig
@@ -12,3 +12,11 @@ config SFC
12 12
13 To compile this driver as a module, choose M here. The module 13 To compile this driver as a module, choose M here. The module
14 will be called sfc. 14 will be called sfc.
15config SFC_MTD
16 bool "Solarflare Solarstorm SFC4000 flash MTD support"
17 depends on SFC && MTD
18 default y
19 help
20 This exposes the on-board flash memory as an MTD device (e.g.
21 /dev/mtd1). This makes it possible to upload new boot code
22 to the NIC.
diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index c8f5704c8fb1..e507daa4f0e8 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/Makefile
@@ -1,5 +1,6 @@
1sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \ 1sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \
2 selftest.o ethtool.o xfp_phy.o \ 2 selftest.o ethtool.o xfp_phy.o \
3 mdio_10g.o tenxpress.o boards.o sfe4001.o 3 mdio_10g.o tenxpress.o boards.o sfe4001.o
4sfc-$(CONFIG_SFC_MTD) += mtd.o
4 5
5obj-$(CONFIG_SFC) += sfc.o 6obj-$(CONFIG_SFC) += sfc.o
diff --git a/drivers/net/sfc/boards.c b/drivers/net/sfc/boards.c
index 99e602373269..edf026280bec 100644
--- a/drivers/net/sfc/boards.c
+++ b/drivers/net/sfc/boards.c
@@ -11,6 +11,7 @@
11#include "phy.h" 11#include "phy.h"
12#include "boards.h" 12#include "boards.h"
13#include "efx.h" 13#include "efx.h"
14#include "workarounds.h"
14 15
15/* Macros for unpacking the board revision */ 16/* Macros for unpacking the board revision */
16/* The revision info is in host byte order. */ 17/* The revision info is in host byte order. */
@@ -52,9 +53,128 @@ static void board_blink(struct efx_nic *efx, bool blink)
52} 53}
53 54
54/***************************************************************************** 55/*****************************************************************************
56 * Support for LM87 sensor chip used on several boards
57 */
58#define LM87_REG_ALARMS1 0x41
59#define LM87_REG_ALARMS2 0x42
60#define LM87_IN_LIMITS(nr, _min, _max) \
61 0x2B + (nr) * 2, _max, 0x2C + (nr) * 2, _min
62#define LM87_AIN_LIMITS(nr, _min, _max) \
63 0x3B + (nr), _max, 0x1A + (nr), _min
64#define LM87_TEMP_INT_LIMITS(_min, _max) \
65 0x39, _max, 0x3A, _min
66#define LM87_TEMP_EXT1_LIMITS(_min, _max) \
67 0x37, _max, 0x38, _min
68
69#define LM87_ALARM_TEMP_INT 0x10
70#define LM87_ALARM_TEMP_EXT1 0x20
71
72#if defined(CONFIG_SENSORS_LM87) || defined(CONFIG_SENSORS_LM87_MODULE)
73
74static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
75 const u8 *reg_values)
76{
77 struct i2c_client *client = i2c_new_device(&efx->i2c_adap, info);
78 int rc;
79
80 if (!client)
81 return -EIO;
82
83 while (*reg_values) {
84 u8 reg = *reg_values++;
85 u8 value = *reg_values++;
86 rc = i2c_smbus_write_byte_data(client, reg, value);
87 if (rc)
88 goto err;
89 }
90
91 efx->board_info.hwmon_client = client;
92 return 0;
93
94err:
95 i2c_unregister_device(client);
96 return rc;
97}
98
99static void efx_fini_lm87(struct efx_nic *efx)
100{
101 i2c_unregister_device(efx->board_info.hwmon_client);
102}
103
104static int efx_check_lm87(struct efx_nic *efx, unsigned mask)
105{
106 struct i2c_client *client = efx->board_info.hwmon_client;
107 s32 alarms1, alarms2;
108
109 /* If link is up then do not monitor temperature */
110 if (EFX_WORKAROUND_7884(efx) && efx->link_up)
111 return 0;
112
113 alarms1 = i2c_smbus_read_byte_data(client, LM87_REG_ALARMS1);
114 alarms2 = i2c_smbus_read_byte_data(client, LM87_REG_ALARMS2);
115 if (alarms1 < 0)
116 return alarms1;
117 if (alarms2 < 0)
118 return alarms2;
119 alarms1 &= mask;
120 alarms2 &= mask >> 8;
121 if (alarms1 || alarms2) {
122 EFX_ERR(efx,
123 "LM87 detected a hardware failure (status %02x:%02x)"
124 "%s%s\n",
125 alarms1, alarms2,
126 (alarms1 & LM87_ALARM_TEMP_INT) ? " INTERNAL" : "",
127 (alarms1 & LM87_ALARM_TEMP_EXT1) ? " EXTERNAL" : "");
128 return -ERANGE;
129 }
130
131 return 0;
132}
133
134#else /* !CONFIG_SENSORS_LM87 */
135
136static inline int
137efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
138 const u8 *reg_values)
139{
140 return 0;
141}
142static inline void efx_fini_lm87(struct efx_nic *efx)
143{
144}
145static inline int efx_check_lm87(struct efx_nic *efx, unsigned mask)
146{
147 return 0;
148}
149
150#endif /* CONFIG_SENSORS_LM87 */
151
152/*****************************************************************************
55 * Support for the SFE4002 153 * Support for the SFE4002
56 * 154 *
57 */ 155 */
156static u8 sfe4002_lm87_channel = 0x03; /* use AIN not FAN inputs */
157
158static const u8 sfe4002_lm87_regs[] = {
159 LM87_IN_LIMITS(0, 0x83, 0x91), /* 2.5V: 1.8V +/- 5% */
160 LM87_IN_LIMITS(1, 0x51, 0x5a), /* Vccp1: 1.2V +/- 5% */
161 LM87_IN_LIMITS(2, 0xb6, 0xca), /* 3.3V: 3.3V +/- 5% */
162 LM87_IN_LIMITS(3, 0xb0, 0xc9), /* 5V: 4.6-5.2V */
163 LM87_IN_LIMITS(4, 0xb0, 0xe0), /* 12V: 11-14V */
164 LM87_IN_LIMITS(5, 0x44, 0x4b), /* Vccp2: 1.0V +/- 5% */
165 LM87_AIN_LIMITS(0, 0xa0, 0xb2), /* AIN1: 1.66V +/- 5% */
166 LM87_AIN_LIMITS(1, 0x91, 0xa1), /* AIN2: 1.5V +/- 5% */
167 LM87_TEMP_INT_LIMITS(10, 60), /* board */
168 LM87_TEMP_EXT1_LIMITS(10, 70), /* Falcon */
169 0
170};
171
172static struct i2c_board_info sfe4002_hwmon_info = {
173 I2C_BOARD_INFO("lm87", 0x2e),
174 .platform_data = &sfe4002_lm87_channel,
175 .irq = -1,
176};
177
58/****************************************************************************/ 178/****************************************************************************/
59/* LED allocations. Note that on rev A0 boards the schematic and the reality 179/* LED allocations. Note that on rev A0 boards the schematic and the reality
60 * differ: red and green are swapped. Below is the fixed (A1) layout (there 180 * differ: red and green are swapped. Below is the fixed (A1) layout (there
@@ -84,11 +204,27 @@ static void sfe4002_fault_led(struct efx_nic *efx, bool state)
84 QUAKE_LED_OFF); 204 QUAKE_LED_OFF);
85} 205}
86 206
207static int sfe4002_check_hw(struct efx_nic *efx)
208{
209 /* A0 board rev. 4002s report a temperature fault the whole time
210 * (bad sensor) so we mask it out. */
211 unsigned alarm_mask =
212 (efx->board_info.major == 0 && efx->board_info.minor == 0) ?
213 ~LM87_ALARM_TEMP_EXT1 : ~0;
214
215 return efx_check_lm87(efx, alarm_mask);
216}
217
87static int sfe4002_init(struct efx_nic *efx) 218static int sfe4002_init(struct efx_nic *efx)
88{ 219{
220 int rc = efx_init_lm87(efx, &sfe4002_hwmon_info, sfe4002_lm87_regs);
221 if (rc)
222 return rc;
223 efx->board_info.monitor = sfe4002_check_hw;
89 efx->board_info.init_leds = sfe4002_init_leds; 224 efx->board_info.init_leds = sfe4002_init_leds;
90 efx->board_info.set_fault_led = sfe4002_fault_led; 225 efx->board_info.set_fault_led = sfe4002_fault_led;
91 efx->board_info.blink = board_blink; 226 efx->board_info.blink = board_blink;
227 efx->board_info.fini = efx_fini_lm87;
92 return 0; 228 return 0;
93} 229}
94 230
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 06ea71c7e34e..ac7bdbf3fd4a 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -77,11 +77,6 @@ static int napi_weight = 64;
77 */ 77 */
78unsigned int efx_monitor_interval = 1 * HZ; 78unsigned int efx_monitor_interval = 1 * HZ;
79 79
80/* This controls whether or not the hardware monitor will trigger a
81 * reset when it detects an error condition.
82 */
83static unsigned int monitor_reset = true;
84
85/* This controls whether or not the driver will initialise devices 80/* This controls whether or not the driver will initialise devices
86 * with invalid MAC addresses stored in the EEPROM or flash. If true, 81 * with invalid MAC addresses stored in the EEPROM or flash. If true,
87 * such devices will be initialised with a random locally-generated 82 * such devices will be initialised with a random locally-generated
@@ -612,17 +607,15 @@ static int efx_probe_port(struct efx_nic *efx)
612 if (is_valid_ether_addr(efx->mac_address)) { 607 if (is_valid_ether_addr(efx->mac_address)) {
613 memcpy(efx->net_dev->dev_addr, efx->mac_address, ETH_ALEN); 608 memcpy(efx->net_dev->dev_addr, efx->mac_address, ETH_ALEN);
614 } else { 609 } else {
615 DECLARE_MAC_BUF(mac); 610 EFX_ERR(efx, "invalid MAC address %pM\n",
616 611 efx->mac_address);
617 EFX_ERR(efx, "invalid MAC address %s\n",
618 print_mac(mac, efx->mac_address));
619 if (!allow_bad_hwaddr) { 612 if (!allow_bad_hwaddr) {
620 rc = -EINVAL; 613 rc = -EINVAL;
621 goto err; 614 goto err;
622 } 615 }
623 random_ether_addr(efx->net_dev->dev_addr); 616 random_ether_addr(efx->net_dev->dev_addr);
624 EFX_INFO(efx, "using locally-generated MAC %s\n", 617 EFX_INFO(efx, "using locally-generated MAC %pM\n",
625 print_mac(mac, efx->net_dev->dev_addr)); 618 efx->net_dev->dev_addr);
626 } 619 }
627 620
628 return 0; 621 return 0;
@@ -1178,17 +1171,6 @@ static void efx_monitor(struct work_struct *data)
1178 rc = falcon_check_xmac(efx); 1171 rc = falcon_check_xmac(efx);
1179 mutex_unlock(&efx->mac_lock); 1172 mutex_unlock(&efx->mac_lock);
1180 1173
1181 if (rc) {
1182 if (monitor_reset) {
1183 EFX_ERR(efx, "hardware monitor detected a fault: "
1184 "triggering reset\n");
1185 efx_schedule_reset(efx, RESET_TYPE_MONITOR);
1186 } else {
1187 EFX_ERR(efx, "hardware monitor detected a fault, "
1188 "skipping reset\n");
1189 }
1190 }
1191
1192 queue_delayed_work(efx->workqueue, &efx->monitor_work, 1174 queue_delayed_work(efx->workqueue, &efx->monitor_work,
1193 efx_monitor_interval); 1175 efx_monitor_interval);
1194} 1176}
@@ -1360,12 +1342,11 @@ static void efx_watchdog(struct net_device *net_dev)
1360{ 1342{
1361 struct efx_nic *efx = netdev_priv(net_dev); 1343 struct efx_nic *efx = netdev_priv(net_dev);
1362 1344
1363 EFX_ERR(efx, "TX stuck with stop_count=%d port_enabled=%d: %s\n", 1345 EFX_ERR(efx, "TX stuck with stop_count=%d port_enabled=%d:"
1364 atomic_read(&efx->netif_stop_count), efx->port_enabled, 1346 " resetting channels\n",
1365 monitor_reset ? "resetting channels" : "skipping reset"); 1347 atomic_read(&efx->netif_stop_count), efx->port_enabled);
1366 1348
1367 if (monitor_reset) 1349 efx_schedule_reset(efx, RESET_TYPE_TX_WATCHDOG);
1368 efx_schedule_reset(efx, RESET_TYPE_MONITOR);
1369} 1350}
1370 1351
1371 1352
@@ -1401,9 +1382,8 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
1401 EFX_ASSERT_RESET_SERIALISED(efx); 1382 EFX_ASSERT_RESET_SERIALISED(efx);
1402 1383
1403 if (!is_valid_ether_addr(new_addr)) { 1384 if (!is_valid_ether_addr(new_addr)) {
1404 DECLARE_MAC_BUF(mac); 1385 EFX_ERR(efx, "invalid ethernet MAC address requested: %pM\n",
1405 EFX_ERR(efx, "invalid ethernet MAC address requested: %s\n", 1386 new_addr);
1406 print_mac(mac, new_addr));
1407 return -EINVAL; 1387 return -EINVAL;
1408 } 1388 }
1409 1389
@@ -1462,6 +1442,7 @@ static int efx_netdev_event(struct notifier_block *this,
1462 struct efx_nic *efx = netdev_priv(net_dev); 1442 struct efx_nic *efx = netdev_priv(net_dev);
1463 1443
1464 strcpy(efx->name, net_dev->name); 1444 strcpy(efx->name, net_dev->name);
1445 efx_mtd_rename(efx);
1465 } 1446 }
1466 1447
1467 return NOTIFY_DONE; 1448 return NOTIFY_DONE;
@@ -1553,6 +1534,7 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd)
1553 1534
1554 efx_stop_all(efx); 1535 efx_stop_all(efx);
1555 mutex_lock(&efx->mac_lock); 1536 mutex_lock(&efx->mac_lock);
1537 mutex_lock(&efx->spi_lock);
1556 1538
1557 rc = falcon_xmac_get_settings(efx, ecmd); 1539 rc = falcon_xmac_get_settings(efx, ecmd);
1558 if (rc) 1540 if (rc)
@@ -1585,6 +1567,7 @@ int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok)
1585 EFX_ERR(efx, "could not restore PHY settings\n"); 1567 EFX_ERR(efx, "could not restore PHY settings\n");
1586 } 1568 }
1587 1569
1570 mutex_unlock(&efx->spi_lock);
1588 mutex_unlock(&efx->mac_lock); 1571 mutex_unlock(&efx->mac_lock);
1589 1572
1590 if (ok) { 1573 if (ok) {
@@ -1780,6 +1763,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
1780 memset(efx, 0, sizeof(*efx)); 1763 memset(efx, 0, sizeof(*efx));
1781 spin_lock_init(&efx->biu_lock); 1764 spin_lock_init(&efx->biu_lock);
1782 spin_lock_init(&efx->phy_lock); 1765 spin_lock_init(&efx->phy_lock);
1766 mutex_init(&efx->spi_lock);
1783 INIT_WORK(&efx->reset_work, efx_reset_work); 1767 INIT_WORK(&efx->reset_work, efx_reset_work);
1784 INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor); 1768 INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor);
1785 efx->pci_dev = pci_dev; 1769 efx->pci_dev = pci_dev;
@@ -1914,6 +1898,8 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
1914 if (!efx) 1898 if (!efx)
1915 return; 1899 return;
1916 1900
1901 efx_mtd_remove(efx);
1902
1917 /* Mark the NIC as fini, then stop the interface */ 1903 /* Mark the NIC as fini, then stop the interface */
1918 rtnl_lock(); 1904 rtnl_lock();
1919 efx->state = STATE_FINI; 1905 efx->state = STATE_FINI;
@@ -2080,6 +2066,7 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
2080 2066
2081 EFX_LOG(efx, "initialisation successful\n"); 2067 EFX_LOG(efx, "initialisation successful\n");
2082 2068
2069 efx_mtd_probe(efx); /* allowed to fail */
2083 return 0; 2070 return 0;
2084 2071
2085 fail5: 2072 fail5:
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h
index d02937b70eee..dd0d45b9e71f 100644
--- a/drivers/net/sfc/efx.h
+++ b/drivers/net/sfc/efx.h
@@ -58,6 +58,16 @@ extern int efx_port_dummy_op_int(struct efx_nic *efx);
58extern void efx_port_dummy_op_void(struct efx_nic *efx); 58extern void efx_port_dummy_op_void(struct efx_nic *efx);
59extern void efx_port_dummy_op_blink(struct efx_nic *efx, bool blink); 59extern void efx_port_dummy_op_blink(struct efx_nic *efx, bool blink);
60 60
61/* MTD */
62#ifdef CONFIG_SFC_MTD
63extern int efx_mtd_probe(struct efx_nic *efx);
64extern void efx_mtd_rename(struct efx_nic *efx);
65extern void efx_mtd_remove(struct efx_nic *efx);
66#else
67static inline int efx_mtd_probe(struct efx_nic *efx) { return 0; }
68static inline void efx_mtd_rename(struct efx_nic *efx) {}
69static inline void efx_mtd_remove(struct efx_nic *efx) {}
70#endif
61 71
62extern unsigned int efx_monitor_interval; 72extern unsigned int efx_monitor_interval;
63 73
diff --git a/drivers/net/sfc/enum.h b/drivers/net/sfc/enum.h
index cec15dbb88e4..41e758e8fdb1 100644
--- a/drivers/net/sfc/enum.h
+++ b/drivers/net/sfc/enum.h
@@ -72,7 +72,7 @@ extern const char *efx_loopback_mode_names[];
72 * @RESET_TYPE_ALL: reset everything but PCI core blocks 72 * @RESET_TYPE_ALL: reset everything but PCI core blocks
73 * @RESET_TYPE_WORLD: reset everything, save & restore PCI config 73 * @RESET_TYPE_WORLD: reset everything, save & restore PCI config
74 * @RESET_TYPE_DISABLE: disable NIC 74 * @RESET_TYPE_DISABLE: disable NIC
75 * @RESET_TYPE_MONITOR: reset due to hardware monitor 75 * @RESET_TYPE_TX_WATCHDOG: reset due to TX watchdog
76 * @RESET_TYPE_INT_ERROR: reset due to internal error 76 * @RESET_TYPE_INT_ERROR: reset due to internal error
77 * @RESET_TYPE_RX_RECOVERY: reset to recover from RX datapath errors 77 * @RESET_TYPE_RX_RECOVERY: reset to recover from RX datapath errors
78 * @RESET_TYPE_RX_DESC_FETCH: pcie error during rx descriptor fetch 78 * @RESET_TYPE_RX_DESC_FETCH: pcie error during rx descriptor fetch
@@ -86,7 +86,7 @@ enum reset_type {
86 RESET_TYPE_WORLD = 2, 86 RESET_TYPE_WORLD = 2,
87 RESET_TYPE_DISABLE = 3, 87 RESET_TYPE_DISABLE = 3,
88 RESET_TYPE_MAX_METHOD, 88 RESET_TYPE_MAX_METHOD,
89 RESET_TYPE_MONITOR, 89 RESET_TYPE_TX_WATCHDOG,
90 RESET_TYPE_INT_ERROR, 90 RESET_TYPE_INT_ERROR,
91 RESET_TYPE_RX_RECOVERY, 91 RESET_TYPE_RX_RECOVERY,
92 RESET_TYPE_RX_DESC_FETCH, 92 RESET_TYPE_RX_DESC_FETCH,
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index cd0d0873d978..abd8fcd6e62d 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -172,10 +172,7 @@ static struct efx_ethtool_stat efx_ethtool_stats[] = {
172/* Number of ethtool statistics */ 172/* Number of ethtool statistics */
173#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats) 173#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
174 174
175/* EEPROM range with gPXE configuration */
176#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB 175#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
177#define EFX_ETHTOOL_EEPROM_MIN 0x800U
178#define EFX_ETHTOOL_EEPROM_MAX 0x1800U
179 176
180/************************************************************************** 177/**************************************************************************
181 * 178 *
@@ -545,8 +542,8 @@ static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
545 542
546 if (!spi) 543 if (!spi)
547 return 0; 544 return 0;
548 return min(spi->size, EFX_ETHTOOL_EEPROM_MAX) - 545 return min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
549 min(spi->size, EFX_ETHTOOL_EEPROM_MIN); 546 min(spi->size, EFX_EEPROM_BOOTCONFIG_START);
550} 547}
551 548
552static int efx_ethtool_get_eeprom(struct net_device *net_dev, 549static int efx_ethtool_get_eeprom(struct net_device *net_dev,
@@ -557,8 +554,10 @@ static int efx_ethtool_get_eeprom(struct net_device *net_dev,
557 size_t len; 554 size_t len;
558 int rc; 555 int rc;
559 556
560 rc = falcon_spi_read(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN, 557 mutex_lock(&efx->spi_lock);
558 rc = falcon_spi_read(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
561 eeprom->len, &len, buf); 559 eeprom->len, &len, buf);
560 mutex_unlock(&efx->spi_lock);
562 eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC; 561 eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
563 eeprom->len = len; 562 eeprom->len = len;
564 return rc; 563 return rc;
@@ -575,8 +574,10 @@ static int efx_ethtool_set_eeprom(struct net_device *net_dev,
575 if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC) 574 if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
576 return -EINVAL; 575 return -EINVAL;
577 576
578 rc = falcon_spi_write(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN, 577 mutex_lock(&efx->spi_lock);
578 rc = falcon_spi_write(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
579 eeprom->len, &len, buf); 579 eeprom->len, &len, buf);
580 mutex_unlock(&efx->spi_lock);
580 eeprom->len = len; 581 eeprom->len = len;
581 return rc; 582 return rc;
582} 583}
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 31ed1f49de00..71e0bed60616 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1628,9 +1628,9 @@ static int falcon_spi_wait(struct efx_nic *efx)
1628 } 1628 }
1629} 1629}
1630 1630
1631static int falcon_spi_cmd(const struct efx_spi_device *spi, 1631int falcon_spi_cmd(const struct efx_spi_device *spi,
1632 unsigned int command, int address, 1632 unsigned int command, int address,
1633 const void *in, void *out, unsigned int len) 1633 const void *in, void *out, unsigned int len)
1634{ 1634{
1635 struct efx_nic *efx = spi->efx; 1635 struct efx_nic *efx = spi->efx;
1636 bool addressed = (address >= 0); 1636 bool addressed = (address >= 0);
@@ -1641,6 +1641,7 @@ static int falcon_spi_cmd(const struct efx_spi_device *spi,
1641 /* Input validation */ 1641 /* Input validation */
1642 if (len > FALCON_SPI_MAX_LEN) 1642 if (len > FALCON_SPI_MAX_LEN)
1643 return -EINVAL; 1643 return -EINVAL;
1644 BUG_ON(!mutex_is_locked(&efx->spi_lock));
1644 1645
1645 /* Check SPI not currently being accessed */ 1646 /* Check SPI not currently being accessed */
1646 rc = falcon_spi_wait(efx); 1647 rc = falcon_spi_wait(efx);
@@ -1699,8 +1700,7 @@ efx_spi_munge_command(const struct efx_spi_device *spi,
1699 return command | (((address >> 8) & spi->munge_address) << 3); 1700 return command | (((address >> 8) & spi->munge_address) << 3);
1700} 1701}
1701 1702
1702 1703int falcon_spi_fast_wait(const struct efx_spi_device *spi)
1703static int falcon_spi_fast_wait(const struct efx_spi_device *spi)
1704{ 1704{
1705 u8 status; 1705 u8 status;
1706 int i, rc; 1706 int i, rc;
@@ -2253,13 +2253,15 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
2253 __le16 *word, *limit; 2253 __le16 *word, *limit;
2254 u32 csum; 2254 u32 csum;
2255 2255
2256 region = kmalloc(NVCONFIG_END, GFP_KERNEL); 2256 region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL);
2257 if (!region) 2257 if (!region)
2258 return -ENOMEM; 2258 return -ENOMEM;
2259 nvconfig = region + NVCONFIG_OFFSET; 2259 nvconfig = region + NVCONFIG_OFFSET;
2260 2260
2261 spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom; 2261 spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom;
2262 rc = falcon_spi_read(spi, 0, NVCONFIG_END, NULL, region); 2262 mutex_lock(&efx->spi_lock);
2263 rc = falcon_spi_read(spi, 0, FALCON_NVCONFIG_END, NULL, region);
2264 mutex_unlock(&efx->spi_lock);
2263 if (rc) { 2265 if (rc) {
2264 EFX_ERR(efx, "Failed to read %s\n", 2266 EFX_ERR(efx, "Failed to read %s\n",
2265 efx->spi_flash ? "flash" : "EEPROM"); 2267 efx->spi_flash ? "flash" : "EEPROM");
@@ -2283,7 +2285,7 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
2283 limit = (__le16 *) (nvconfig + 1); 2285 limit = (__le16 *) (nvconfig + 1);
2284 } else { 2286 } else {
2285 word = region; 2287 word = region;
2286 limit = region + NVCONFIG_END; 2288 limit = region + FALCON_NVCONFIG_END;
2287 } 2289 }
2288 for (csum = 0; word < limit; ++word) 2290 for (csum = 0; word < limit; ++word)
2289 csum += le16_to_cpu(*word); 2291 csum += le16_to_cpu(*word);
@@ -2555,6 +2557,11 @@ static int falcon_spi_device_init(struct efx_nic *efx,
2555 SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ADDR_LEN); 2557 SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ADDR_LEN);
2556 spi_device->munge_address = (spi_device->size == 1 << 9 && 2558 spi_device->munge_address = (spi_device->size == 1 << 9 &&
2557 spi_device->addr_len == 1); 2559 spi_device->addr_len == 1);
2560 spi_device->erase_command =
2561 SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ERASE_CMD);
2562 spi_device->erase_size =
2563 1 << SPI_DEV_TYPE_FIELD(device_type,
2564 SPI_DEV_TYPE_ERASE_SIZE);
2558 spi_device->block_size = 2565 spi_device->block_size =
2559 1 << SPI_DEV_TYPE_FIELD(device_type, 2566 1 << SPI_DEV_TYPE_FIELD(device_type,
2560 SPI_DEV_TYPE_BLOCK_SIZE); 2567 SPI_DEV_TYPE_BLOCK_SIZE);
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h
index 5d584b0dbb51..040e70ed4ec7 100644
--- a/drivers/net/sfc/falcon_hwdefs.h
+++ b/drivers/net/sfc/falcon_hwdefs.h
@@ -1150,7 +1150,6 @@ struct falcon_nvconfig_board_v3 {
1150 (((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field))) 1150 (((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field)))
1151 1151
1152#define NVCONFIG_OFFSET 0x300 1152#define NVCONFIG_OFFSET 0x300
1153#define NVCONFIG_END 0x400
1154 1153
1155#define NVCONFIG_BOARD_MAGIC_NUM 0xFA1C 1154#define NVCONFIG_BOARD_MAGIC_NUM 0xFA1C
1156struct falcon_nvconfig { 1155struct falcon_nvconfig {
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c
index 003e48dcb2f3..19e25210b687 100644
--- a/drivers/net/sfc/mdio_10g.c
+++ b/drivers/net/sfc/mdio_10g.c
@@ -260,6 +260,41 @@ void mdio_clause45_phy_reconfigure(struct efx_nic *efx)
260 MDIO_MMDREG_CTRL1, ctrl2); 260 MDIO_MMDREG_CTRL1, ctrl2);
261} 261}
262 262
263static void mdio_clause45_set_mmd_lpower(struct efx_nic *efx,
264 int lpower, int mmd)
265{
266 int phy = efx->mii.phy_id;
267 int stat = mdio_clause45_read(efx, phy, mmd, MDIO_MMDREG_STAT1);
268 int ctrl1, ctrl2;
269
270 EFX_TRACE(efx, "Setting low power mode for MMD %d to %d\n",
271 mmd, lpower);
272
273 if (stat & (1 << MDIO_MMDREG_STAT1_LPABLE_LBN)) {
274 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy,
275 mmd, MDIO_MMDREG_CTRL1);
276 if (lpower)
277 ctrl2 |= (1 << MDIO_MMDREG_CTRL1_LPOWER_LBN);
278 else
279 ctrl2 &= ~(1 << MDIO_MMDREG_CTRL1_LPOWER_LBN);
280 if (ctrl1 != ctrl2)
281 mdio_clause45_write(efx, phy, mmd,
282 MDIO_MMDREG_CTRL1, ctrl2);
283 }
284}
285
286void mdio_clause45_set_mmds_lpower(struct efx_nic *efx,
287 int low_power, unsigned int mmd_mask)
288{
289 int mmd = 0;
290 while (mmd_mask) {
291 if (mmd_mask & 1)
292 mdio_clause45_set_mmd_lpower(efx, low_power, mmd);
293 mmd_mask = (mmd_mask >> 1);
294 mmd++;
295 }
296}
297
263/** 298/**
264 * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO. 299 * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO.
265 * @efx: Efx NIC 300 * @efx: Efx NIC
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h
index 19c42eaf7fb4..db9f358349c6 100644
--- a/drivers/net/sfc/mdio_10g.h
+++ b/drivers/net/sfc/mdio_10g.h
@@ -54,6 +54,9 @@
54/* Loopback bit for WIS, PCS, PHYSX and DTEXS */ 54/* Loopback bit for WIS, PCS, PHYSX and DTEXS */
55#define MDIO_MMDREG_CTRL1_LBACK_LBN (14) 55#define MDIO_MMDREG_CTRL1_LBACK_LBN (14)
56#define MDIO_MMDREG_CTRL1_LBACK_WIDTH (1) 56#define MDIO_MMDREG_CTRL1_LBACK_WIDTH (1)
57/* Low power */
58#define MDIO_MMDREG_CTRL1_LPOWER_LBN (11)
59#define MDIO_MMDREG_CTRL1_LPOWER_WIDTH (1)
57 60
58/* Bits in MMDREG_STAT1 */ 61/* Bits in MMDREG_STAT1 */
59#define MDIO_MMDREG_STAT1_FAULT_LBN (7) 62#define MDIO_MMDREG_STAT1_FAULT_LBN (7)
@@ -240,6 +243,10 @@ extern void mdio_clause45_transmit_disable(struct efx_nic *efx);
240/* Generic part of reconfigure: set/clear loopback bits */ 243/* Generic part of reconfigure: set/clear loopback bits */
241extern void mdio_clause45_phy_reconfigure(struct efx_nic *efx); 244extern void mdio_clause45_phy_reconfigure(struct efx_nic *efx);
242 245
246/* Set the power state of the specified MMDs */
247extern void mdio_clause45_set_mmds_lpower(struct efx_nic *efx,
248 int low_power, unsigned int mmd_mask);
249
243/* Read (some of) the PHY settings over MDIO */ 250/* Read (some of) the PHY settings over MDIO */
244extern void mdio_clause45_get_settings(struct efx_nic *efx, 251extern void mdio_clause45_get_settings(struct efx_nic *efx,
245 struct ethtool_cmd *ecmd); 252 struct ethtool_cmd *ecmd);
diff --git a/drivers/net/sfc/mtd.c b/drivers/net/sfc/mtd.c
new file mode 100644
index 000000000000..a1e6c2875fc0
--- /dev/null
+++ b/drivers/net/sfc/mtd.c
@@ -0,0 +1,268 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/module.h>
12#include <linux/mtd/mtd.h>
13#include <linux/delay.h>
14
15#define EFX_DRIVER_NAME "sfc_mtd"
16#include "net_driver.h"
17#include "spi.h"
18
19#define EFX_SPI_VERIFY_BUF_LEN 16
20
21struct efx_mtd {
22 const struct efx_spi_device *spi;
23 struct mtd_info mtd;
24 char name[IFNAMSIZ + 20];
25};
26
27/* SPI utilities */
28
29static int efx_spi_slow_wait(struct efx_mtd *efx_mtd, bool uninterruptible)
30{
31 const struct efx_spi_device *spi = efx_mtd->spi;
32 struct efx_nic *efx = spi->efx;
33 u8 status;
34 int rc, i;
35
36 /* Wait up to 4s for flash/EEPROM to finish a slow operation. */
37 for (i = 0; i < 40; i++) {
38 __set_current_state(uninterruptible ?
39 TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);
40 schedule_timeout(HZ / 10);
41 rc = falcon_spi_cmd(spi, SPI_RDSR, -1, NULL,
42 &status, sizeof(status));
43 if (rc)
44 return rc;
45 if (!(status & SPI_STATUS_NRDY))
46 return 0;
47 if (signal_pending(current))
48 return -EINTR;
49 }
50 EFX_ERR(efx, "timed out waiting for %s\n", efx_mtd->name);
51 return -ETIMEDOUT;
52}
53
54static int efx_spi_unlock(const struct efx_spi_device *spi)
55{
56 const u8 unlock_mask = (SPI_STATUS_BP2 | SPI_STATUS_BP1 |
57 SPI_STATUS_BP0);
58 u8 status;
59 int rc;
60
61 rc = falcon_spi_cmd(spi, SPI_RDSR, -1, NULL, &status, sizeof(status));
62 if (rc)
63 return rc;
64
65 if (!(status & unlock_mask))
66 return 0; /* already unlocked */
67
68 rc = falcon_spi_cmd(spi, SPI_WREN, -1, NULL, NULL, 0);
69 if (rc)
70 return rc;
71 rc = falcon_spi_cmd(spi, SPI_SST_EWSR, -1, NULL, NULL, 0);
72 if (rc)
73 return rc;
74
75 status &= ~unlock_mask;
76 rc = falcon_spi_cmd(spi, SPI_WRSR, -1, &status, NULL, sizeof(status));
77 if (rc)
78 return rc;
79 rc = falcon_spi_fast_wait(spi);
80 if (rc)
81 return rc;
82
83 return 0;
84}
85
86static int efx_spi_erase(struct efx_mtd *efx_mtd, loff_t start, size_t len)
87{
88 const struct efx_spi_device *spi = efx_mtd->spi;
89 unsigned pos, block_len;
90 u8 empty[EFX_SPI_VERIFY_BUF_LEN];
91 u8 buffer[EFX_SPI_VERIFY_BUF_LEN];
92 int rc;
93
94 if (len != spi->erase_size)
95 return -EINVAL;
96
97 if (spi->erase_command == 0)
98 return -EOPNOTSUPP;
99
100 rc = efx_spi_unlock(spi);
101 if (rc)
102 return rc;
103 rc = falcon_spi_cmd(spi, SPI_WREN, -1, NULL, NULL, 0);
104 if (rc)
105 return rc;
106 rc = falcon_spi_cmd(spi, spi->erase_command, start, NULL, NULL, 0);
107 if (rc)
108 return rc;
109 rc = efx_spi_slow_wait(efx_mtd, false);
110
111 /* Verify the entire region has been wiped */
112 memset(empty, 0xff, sizeof(empty));
113 for (pos = 0; pos < len; pos += block_len) {
114 block_len = min(len - pos, sizeof(buffer));
115 rc = falcon_spi_read(spi, start + pos, block_len, NULL, buffer);
116 if (rc)
117 return rc;
118 if (memcmp(empty, buffer, block_len))
119 return -EIO;
120
121 /* Avoid locking up the system */
122 cond_resched();
123 if (signal_pending(current))
124 return -EINTR;
125 }
126
127 return rc;
128}
129
130/* MTD interface */
131
132static int efx_mtd_read(struct mtd_info *mtd, loff_t start, size_t len,
133 size_t *retlen, u8 *buffer)
134{
135 struct efx_mtd *efx_mtd = mtd->priv;
136 const struct efx_spi_device *spi = efx_mtd->spi;
137 struct efx_nic *efx = spi->efx;
138 int rc;
139
140 rc = mutex_lock_interruptible(&efx->spi_lock);
141 if (rc)
142 return rc;
143 rc = falcon_spi_read(spi, FALCON_FLASH_BOOTCODE_START + start,
144 len, retlen, buffer);
145 mutex_unlock(&efx->spi_lock);
146 return rc;
147}
148
149static int efx_mtd_erase(struct mtd_info *mtd, struct erase_info *erase)
150{
151 struct efx_mtd *efx_mtd = mtd->priv;
152 struct efx_nic *efx = efx_mtd->spi->efx;
153 int rc;
154
155 rc = mutex_lock_interruptible(&efx->spi_lock);
156 if (rc)
157 return rc;
158 rc = efx_spi_erase(efx_mtd, FALCON_FLASH_BOOTCODE_START + erase->addr,
159 erase->len);
160 mutex_unlock(&efx->spi_lock);
161
162 if (rc == 0) {
163 erase->state = MTD_ERASE_DONE;
164 } else {
165 erase->state = MTD_ERASE_FAILED;
166 erase->fail_addr = 0xffffffff;
167 }
168 mtd_erase_callback(erase);
169 return rc;
170}
171
172static int efx_mtd_write(struct mtd_info *mtd, loff_t start,
173 size_t len, size_t *retlen, const u8 *buffer)
174{
175 struct efx_mtd *efx_mtd = mtd->priv;
176 const struct efx_spi_device *spi = efx_mtd->spi;
177 struct efx_nic *efx = spi->efx;
178 int rc;
179
180 rc = mutex_lock_interruptible(&efx->spi_lock);
181 if (rc)
182 return rc;
183 rc = falcon_spi_write(spi, FALCON_FLASH_BOOTCODE_START + start,
184 len, retlen, buffer);
185 mutex_unlock(&efx->spi_lock);
186 return rc;
187}
188
189static void efx_mtd_sync(struct mtd_info *mtd)
190{
191 struct efx_mtd *efx_mtd = mtd->priv;
192 struct efx_nic *efx = efx_mtd->spi->efx;
193 int rc;
194
195 mutex_lock(&efx->spi_lock);
196 rc = efx_spi_slow_wait(efx_mtd, true);
197 mutex_unlock(&efx->spi_lock);
198
199 if (rc)
200 EFX_ERR(efx, "%s sync failed (%d)\n", efx_mtd->name, rc);
201 return;
202}
203
204void efx_mtd_remove(struct efx_nic *efx)
205{
206 if (efx->spi_flash && efx->spi_flash->mtd) {
207 struct efx_mtd *efx_mtd = efx->spi_flash->mtd;
208 int rc;
209
210 for (;;) {
211 rc = del_mtd_device(&efx_mtd->mtd);
212 if (rc != -EBUSY)
213 break;
214 ssleep(1);
215 }
216 WARN_ON(rc);
217 kfree(efx_mtd);
218 }
219}
220
221void efx_mtd_rename(struct efx_nic *efx)
222{
223 if (efx->spi_flash && efx->spi_flash->mtd) {
224 struct efx_mtd *efx_mtd = efx->spi_flash->mtd;
225 snprintf(efx_mtd->name, sizeof(efx_mtd->name),
226 "%s sfc_flash_bootrom", efx->name);
227 }
228}
229
230int efx_mtd_probe(struct efx_nic *efx)
231{
232 struct efx_spi_device *spi = efx->spi_flash;
233 struct efx_mtd *efx_mtd;
234
235 if (!spi || spi->size <= FALCON_FLASH_BOOTCODE_START)
236 return -ENODEV;
237
238 efx_mtd = kzalloc(sizeof(*efx_mtd), GFP_KERNEL);
239 if (!efx_mtd)
240 return -ENOMEM;
241
242 efx_mtd->spi = spi;
243 spi->mtd = efx_mtd;
244
245 efx_mtd->mtd.type = MTD_NORFLASH;
246 efx_mtd->mtd.flags = MTD_CAP_NORFLASH;
247 efx_mtd->mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
248 efx_mtd->mtd.erasesize = spi->erase_size;
249 efx_mtd->mtd.writesize = 1;
250 efx_mtd_rename(efx);
251
252 efx_mtd->mtd.owner = THIS_MODULE;
253 efx_mtd->mtd.priv = efx_mtd;
254 efx_mtd->mtd.name = efx_mtd->name;
255 efx_mtd->mtd.erase = efx_mtd_erase;
256 efx_mtd->mtd.read = efx_mtd_read;
257 efx_mtd->mtd.write = efx_mtd_write;
258 efx_mtd->mtd.sync = efx_mtd_sync;
259
260 if (add_mtd_device(&efx_mtd->mtd)) {
261 kfree(efx_mtd);
262 spi->mtd = NULL;
263 /* add_mtd_device() returns 1 if the MTD table is full */
264 return -ENOMEM;
265 }
266
267 return 0;
268}
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index cdb11fad6050..e596c9a6a4c4 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -414,6 +414,7 @@ struct efx_blinker {
414 * @init_leds: Sets up board LEDs 414 * @init_leds: Sets up board LEDs
415 * @set_fault_led: Turns the fault LED on or off 415 * @set_fault_led: Turns the fault LED on or off
416 * @blink: Starts/stops blinking 416 * @blink: Starts/stops blinking
417 * @monitor: Board-specific health check function
417 * @fini: Cleanup function 418 * @fini: Cleanup function
418 * @blinker: used to blink LEDs in software 419 * @blinker: used to blink LEDs in software
419 * @hwmon_client: I2C client for hardware monitor 420 * @hwmon_client: I2C client for hardware monitor
@@ -428,6 +429,7 @@ struct efx_board {
428 * have a separate init callback that happens later than 429 * have a separate init callback that happens later than
429 * board init. */ 430 * board init. */
430 int (*init_leds)(struct efx_nic *efx); 431 int (*init_leds)(struct efx_nic *efx);
432 int (*monitor) (struct efx_nic *nic);
431 void (*set_fault_led) (struct efx_nic *efx, bool state); 433 void (*set_fault_led) (struct efx_nic *efx, bool state);
432 void (*blink) (struct efx_nic *efx, bool start); 434 void (*blink) (struct efx_nic *efx, bool start);
433 void (*fini) (struct efx_nic *nic); 435 void (*fini) (struct efx_nic *nic);
@@ -525,11 +527,15 @@ struct efx_phy_operations {
525 * @enum efx_phy_mode - PHY operating mode flags 527 * @enum efx_phy_mode - PHY operating mode flags
526 * @PHY_MODE_NORMAL: on and should pass traffic 528 * @PHY_MODE_NORMAL: on and should pass traffic
527 * @PHY_MODE_TX_DISABLED: on with TX disabled 529 * @PHY_MODE_TX_DISABLED: on with TX disabled
530 * @PHY_MODE_LOW_POWER: set to low power through MDIO
531 * @PHY_MODE_OFF: switched off through external control
528 * @PHY_MODE_SPECIAL: on but will not pass traffic 532 * @PHY_MODE_SPECIAL: on but will not pass traffic
529 */ 533 */
530enum efx_phy_mode { 534enum efx_phy_mode {
531 PHY_MODE_NORMAL = 0, 535 PHY_MODE_NORMAL = 0,
532 PHY_MODE_TX_DISABLED = 1, 536 PHY_MODE_TX_DISABLED = 1,
537 PHY_MODE_LOW_POWER = 2,
538 PHY_MODE_OFF = 4,
533 PHY_MODE_SPECIAL = 8, 539 PHY_MODE_SPECIAL = 8,
534}; 540};
535 541
@@ -655,6 +661,7 @@ union efx_multicast_hash {
655 * This field will be %NULL if no flash device is present. 661 * This field will be %NULL if no flash device is present.
656 * @spi_eeprom: SPI EEPROM device 662 * @spi_eeprom: SPI EEPROM device
657 * This field will be %NULL if no EEPROM device is present. 663 * This field will be %NULL if no EEPROM device is present.
664 * @spi_lock: SPI bus lock
658 * @n_rx_nodesc_drop_cnt: RX no descriptor drop count 665 * @n_rx_nodesc_drop_cnt: RX no descriptor drop count
659 * @nic_data: Hardware dependant state 666 * @nic_data: Hardware dependant state
660 * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode, 667 * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode,
@@ -731,6 +738,7 @@ struct efx_nic {
731 738
732 struct efx_spi_device *spi_flash; 739 struct efx_spi_device *spi_flash;
733 struct efx_spi_device *spi_eeprom; 740 struct efx_spi_device *spi_eeprom;
741 struct mutex spi_lock;
734 742
735 unsigned n_rx_nodesc_drop_cnt; 743 unsigned n_rx_nodesc_drop_cnt;
736 744
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 0f805da4ce55..b8ba4bbad889 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -752,7 +752,7 @@ void __efx_rx_packet(struct efx_channel *channel,
752 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; 752 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
753 753
754done: 754done:
755 efx->net_dev->last_rx = jiffies; 755 ;
756} 756}
757 757
758void efx_rx_strategy(struct efx_channel *channel) 758void efx_rx_strategy(struct efx_channel *channel)
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index fe4e3fd22330..aa576c559ec8 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -21,6 +21,7 @@
21#include "falcon_hwdefs.h" 21#include "falcon_hwdefs.h"
22#include "falcon_io.h" 22#include "falcon_io.h"
23#include "mac.h" 23#include "mac.h"
24#include "workarounds.h"
24 25
25/************************************************************************** 26/**************************************************************************
26 * 27 *
@@ -65,48 +66,9 @@
65#define P1_SPARE_LBN 4 66#define P1_SPARE_LBN 4
66#define P1_SPARE_WIDTH 4 67#define P1_SPARE_WIDTH 4
67 68
68 69/* Temperature Sensor */
69/************************************************************************** 70#define MAX664X_REG_RSL 0x02
70 * 71#define MAX664X_REG_WLHO 0x0B
71 * Temperature Sensor
72 *
73 **************************************************************************/
74#define MAX6647 0x4e
75
76#define RLTS 0x00
77#define RLTE 0x01
78#define RSL 0x02
79#define RCL 0x03
80#define RCRA 0x04
81#define RLHN 0x05
82#define RLLI 0x06
83#define RRHI 0x07
84#define RRLS 0x08
85#define WCRW 0x0a
86#define WLHO 0x0b
87#define WRHA 0x0c
88#define WRLN 0x0e
89#define OSHT 0x0f
90#define REET 0x10
91#define RIET 0x11
92#define RWOE 0x19
93#define RWOI 0x20
94#define HYS 0x21
95#define QUEUE 0x22
96#define MFID 0xfe
97#define REVID 0xff
98
99/* Status bits */
100#define MAX6647_BUSY (1 << 7) /* ADC is converting */
101#define MAX6647_LHIGH (1 << 6) /* Local high temp. alarm */
102#define MAX6647_LLOW (1 << 5) /* Local low temp. alarm */
103#define MAX6647_RHIGH (1 << 4) /* Remote high temp. alarm */
104#define MAX6647_RLOW (1 << 3) /* Remote low temp. alarm */
105#define MAX6647_FAULT (1 << 2) /* DXN/DXP short/open circuit */
106#define MAX6647_EOT (1 << 1) /* Remote junction overtemp. */
107#define MAX6647_IOT (1 << 0) /* Local junction overtemp. */
108
109static const u8 xgphy_max_temperature = 90;
110 72
111static void sfe4001_poweroff(struct efx_nic *efx) 73static void sfe4001_poweroff(struct efx_nic *efx)
112{ 74{
@@ -119,7 +81,7 @@ static void sfe4001_poweroff(struct efx_nic *efx)
119 i2c_smbus_write_byte_data(ioexp_client, P0_CONFIG, 0xff); 81 i2c_smbus_write_byte_data(ioexp_client, P0_CONFIG, 0xff);
120 82
121 /* Clear any over-temperature alert */ 83 /* Clear any over-temperature alert */
122 i2c_smbus_read_byte_data(hwmon_client, RSL); 84 i2c_smbus_read_byte_data(hwmon_client, MAX664X_REG_RSL);
123} 85}
124 86
125static int sfe4001_poweron(struct efx_nic *efx) 87static int sfe4001_poweron(struct efx_nic *efx)
@@ -131,7 +93,7 @@ static int sfe4001_poweron(struct efx_nic *efx)
131 u8 out; 93 u8 out;
132 94
133 /* Clear any previous over-temperature alert */ 95 /* Clear any previous over-temperature alert */
134 rc = i2c_smbus_read_byte_data(hwmon_client, RSL); 96 rc = i2c_smbus_read_byte_data(hwmon_client, MAX664X_REG_RSL);
135 if (rc < 0) 97 if (rc < 0)
136 return rc; 98 return rc;
137 99
@@ -209,6 +171,34 @@ fail_on:
209 return rc; 171 return rc;
210} 172}
211 173
174static int sfe4001_check_hw(struct efx_nic *efx)
175{
176 s32 status;
177
178 /* If XAUI link is up then do not monitor */
179 if (EFX_WORKAROUND_7884(efx) && falcon_xaui_link_ok(efx))
180 return 0;
181
182 /* Check the powered status of the PHY. Lack of power implies that
183 * the MAX6647 has shut down power to it, probably due to a temp.
184 * alarm. Reading the power status rather than the MAX6647 status
185 * directly because the later is read-to-clear and would thus
186 * start to power up the PHY again when polled, causing us to blip
187 * the power undesirably.
188 * We know we can read from the IO expander because we did
189 * it during power-on. Assume failure now is bad news. */
190 status = i2c_smbus_read_byte_data(efx->board_info.ioexp_client, P1_IN);
191 if (status >= 0 &&
192 (status & ((1 << P1_AFE_PWD_LBN) | (1 << P1_DSP_PWD25_LBN))) != 0)
193 return 0;
194
195 /* Use board power control, not PHY power control */
196 sfe4001_poweroff(efx);
197 efx->phy_mode = PHY_MODE_OFF;
198
199 return (status < 0) ? -EIO : -ERANGE;
200}
201
212/* On SFE4001 rev A2 and later, we can control the FLASH_CFG_1 pin 202/* On SFE4001 rev A2 and later, we can control the FLASH_CFG_1 pin
213 * using the 3V3X output of the IO-expander. Allow the user to set 203 * using the 3V3X output of the IO-expander. Allow the user to set
214 * this when the device is stopped, and keep it stopped then. 204 * this when the device is stopped, and keep it stopped then.
@@ -261,35 +251,34 @@ static void sfe4001_fini(struct efx_nic *efx)
261 i2c_unregister_device(efx->board_info.hwmon_client); 251 i2c_unregister_device(efx->board_info.hwmon_client);
262} 252}
263 253
254static struct i2c_board_info sfe4001_hwmon_info = {
255 I2C_BOARD_INFO("max6647", 0x4e),
256 .irq = -1,
257};
258
264/* This board uses an I2C expander to provider power to the PHY, which needs to 259/* This board uses an I2C expander to provider power to the PHY, which needs to
265 * be turned on before the PHY can be used. 260 * be turned on before the PHY can be used.
266 * Context: Process context, rtnl lock held 261 * Context: Process context, rtnl lock held
267 */ 262 */
268int sfe4001_init(struct efx_nic *efx) 263int sfe4001_init(struct efx_nic *efx)
269{ 264{
270 struct i2c_client *hwmon_client;
271 int rc; 265 int rc;
272 266
273 hwmon_client = i2c_new_dummy(&efx->i2c_adap, MAX6647); 267#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
274 if (!hwmon_client) 268 efx->board_info.hwmon_client =
269 i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info);
270#else
271 efx->board_info.hwmon_client =
272 i2c_new_dummy(&efx->i2c_adap, sfe4001_hwmon_info.addr);
273#endif
274 if (!efx->board_info.hwmon_client)
275 return -EIO; 275 return -EIO;
276 efx->board_info.hwmon_client = hwmon_client;
277 276
278 /* Set DSP over-temperature alert threshold */ 277 /* Raise board/PHY high limit from 85 to 90 degrees Celsius */
279 EFX_INFO(efx, "DSP cut-out at %dC\n", xgphy_max_temperature); 278 rc = i2c_smbus_write_byte_data(efx->board_info.hwmon_client,
280 rc = i2c_smbus_write_byte_data(hwmon_client, WLHO, 279 MAX664X_REG_WLHO, 90);
281 xgphy_max_temperature);
282 if (rc) 280 if (rc)
283 goto fail_ioexp; 281 goto fail_hwmon;
284
285 /* Read it back and verify */
286 rc = i2c_smbus_read_byte_data(hwmon_client, RLHN);
287 if (rc < 0)
288 goto fail_ioexp;
289 if (rc != xgphy_max_temperature) {
290 rc = -EFAULT;
291 goto fail_ioexp;
292 }
293 282
294 efx->board_info.ioexp_client = i2c_new_dummy(&efx->i2c_adap, PCA9539); 283 efx->board_info.ioexp_client = i2c_new_dummy(&efx->i2c_adap, PCA9539);
295 if (!efx->board_info.ioexp_client) { 284 if (!efx->board_info.ioexp_client) {
@@ -301,6 +290,7 @@ int sfe4001_init(struct efx_nic *efx)
301 * blink code. */ 290 * blink code. */
302 efx->board_info.blink = tenxpress_phy_blink; 291 efx->board_info.blink = tenxpress_phy_blink;
303 292
293 efx->board_info.monitor = sfe4001_check_hw;
304 efx->board_info.fini = sfe4001_fini; 294 efx->board_info.fini = sfe4001_fini;
305 295
306 rc = sfe4001_poweron(efx); 296 rc = sfe4001_poweron(efx);
@@ -319,6 +309,6 @@ fail_on:
319fail_ioexp: 309fail_ioexp:
320 i2c_unregister_device(efx->board_info.ioexp_client); 310 i2c_unregister_device(efx->board_info.ioexp_client);
321fail_hwmon: 311fail_hwmon:
322 i2c_unregister_device(hwmon_client); 312 i2c_unregister_device(efx->board_info.hwmon_client);
323 return rc; 313 return rc;
324} 314}
diff --git a/drivers/net/sfc/spi.h b/drivers/net/sfc/spi.h
index feef61942377..c4aca132348a 100644
--- a/drivers/net/sfc/spi.h
+++ b/drivers/net/sfc/spi.h
@@ -25,6 +25,7 @@
25#define SPI_WRDI 0x04 /* Reset write enable latch */ 25#define SPI_WRDI 0x04 /* Reset write enable latch */
26#define SPI_RDSR 0x05 /* Read status register */ 26#define SPI_RDSR 0x05 /* Read status register */
27#define SPI_WREN 0x06 /* Set write enable latch */ 27#define SPI_WREN 0x06 /* Set write enable latch */
28#define SPI_SST_EWSR 0x50 /* SST: Enable write to status register */
28 29
29#define SPI_STATUS_WPEN 0x80 /* Write-protect pin enabled */ 30#define SPI_STATUS_WPEN 0x80 /* Write-protect pin enabled */
30#define SPI_STATUS_BP2 0x10 /* Block protection bit 2 */ 31#define SPI_STATUS_BP2 0x10 /* Block protection bit 2 */
@@ -36,6 +37,7 @@
36/** 37/**
37 * struct efx_spi_device - an Efx SPI (Serial Peripheral Interface) device 38 * struct efx_spi_device - an Efx SPI (Serial Peripheral Interface) device
38 * @efx: The Efx controller that owns this device 39 * @efx: The Efx controller that owns this device
40 * @mtd: MTD state
39 * @device_id: Controller's id for the device 41 * @device_id: Controller's id for the device
40 * @size: Size (in bytes) 42 * @size: Size (in bytes)
41 * @addr_len: Number of address bytes in read/write commands 43 * @addr_len: Number of address bytes in read/write commands
@@ -44,23 +46,51 @@
44 * use bit 3 of the command byte as address bit A8, rather 46 * use bit 3 of the command byte as address bit A8, rather
45 * than having a two-byte address. If this flag is set, then 47 * than having a two-byte address. If this flag is set, then
46 * commands should be munged in this way. 48 * commands should be munged in this way.
49 * @erase_command: Erase command (or 0 if sector erase not needed).
50 * @erase_size: Erase sector size (in bytes)
51 * Erase commands affect sectors with this size and alignment.
52 * This must be a power of two.
47 * @block_size: Write block size (in bytes). 53 * @block_size: Write block size (in bytes).
48 * Write commands are limited to blocks with this size and alignment. 54 * Write commands are limited to blocks with this size and alignment.
49 * @read: Read function for the device
50 * @write: Write function for the device
51 */ 55 */
52struct efx_spi_device { 56struct efx_spi_device {
53 struct efx_nic *efx; 57 struct efx_nic *efx;
58#ifdef CONFIG_SFC_MTD
59 void *mtd;
60#endif
54 int device_id; 61 int device_id;
55 unsigned int size; 62 unsigned int size;
56 unsigned int addr_len; 63 unsigned int addr_len;
57 unsigned int munge_address:1; 64 unsigned int munge_address:1;
65 u8 erase_command;
66 unsigned int erase_size;
58 unsigned int block_size; 67 unsigned int block_size;
59}; 68};
60 69
70int falcon_spi_cmd(const struct efx_spi_device *spi, unsigned int command,
71 int address, const void* in, void *out, unsigned int len);
72int falcon_spi_fast_wait(const struct efx_spi_device *spi);
61int falcon_spi_read(const struct efx_spi_device *spi, loff_t start, 73int falcon_spi_read(const struct efx_spi_device *spi, loff_t start,
62 size_t len, size_t *retlen, u8 *buffer); 74 size_t len, size_t *retlen, u8 *buffer);
63int falcon_spi_write(const struct efx_spi_device *spi, loff_t start, 75int falcon_spi_write(const struct efx_spi_device *spi, loff_t start,
64 size_t len, size_t *retlen, const u8 *buffer); 76 size_t len, size_t *retlen, const u8 *buffer);
65 77
78/*
79 * SFC4000 flash is partitioned into:
80 * 0-0x400 chip and board config (see falcon_hwdefs.h)
81 * 0x400-0x8000 unused (or may contain VPD if EEPROM not present)
82 * 0x8000-end boot code (mapped to PCI expansion ROM)
83 * SFC4000 small EEPROM (size < 0x400) is used for VPD only.
84 * SFC4000 large EEPROM (size >= 0x400) is partitioned into:
85 * 0-0x400 chip and board config
86 * configurable VPD
87 * 0x800-0x1800 boot config
88 * Aside from the chip and board config, all of these are optional and may
89 * be absent or truncated depending on the devices used.
90 */
91#define FALCON_NVCONFIG_END 0x400U
92#define FALCON_FLASH_BOOTCODE_START 0x8000U
93#define EFX_EEPROM_BOOTCONFIG_START 0x800U
94#define EFX_EEPROM_BOOTCONFIG_END 0x1800U
95
66#endif /* EFX_SPI_H */ 96#endif /* EFX_SPI_H */
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index d507c93d666e..8d41c29b9d7b 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -376,6 +376,7 @@ static int tenxpress_phy_check_hw(struct efx_nic *efx)
376{ 376{
377 struct tenxpress_phy_data *phy_data = efx->phy_data; 377 struct tenxpress_phy_data *phy_data = efx->phy_data;
378 bool link_ok; 378 bool link_ok;
379 int rc = 0;
379 380
380 link_ok = tenxpress_link_ok(efx, true); 381 link_ok = tenxpress_link_ok(efx, true);
381 382
@@ -391,7 +392,22 @@ static int tenxpress_phy_check_hw(struct efx_nic *efx)
391 atomic_set(&phy_data->bad_crc_count, 0); 392 atomic_set(&phy_data->bad_crc_count, 0);
392 } 393 }
393 394
394 return 0; 395 rc = efx->board_info.monitor(efx);
396 if (rc) {
397 EFX_ERR(efx, "Board sensor %s; shutting down PHY\n",
398 (rc == -ERANGE) ? "reported fault" : "failed");
399 if (efx->phy_mode & PHY_MODE_OFF) {
400 /* Assume that board has shut PHY off */
401 phy_data->phy_mode = PHY_MODE_OFF;
402 } else {
403 efx->phy_mode |= PHY_MODE_LOW_POWER;
404 mdio_clause45_set_mmds_lpower(efx, true,
405 efx->phy_op->mmds);
406 phy_data->phy_mode |= PHY_MODE_LOW_POWER;
407 }
408 }
409
410 return rc;
395} 411}
396 412
397static void tenxpress_phy_fini(struct efx_nic *efx) 413static void tenxpress_phy_fini(struct efx_nic *efx)
diff --git a/drivers/net/sfc/workarounds.h b/drivers/net/sfc/workarounds.h
index fa7b49d69288..ec50b90f4285 100644
--- a/drivers/net/sfc/workarounds.h
+++ b/drivers/net/sfc/workarounds.h
@@ -22,6 +22,8 @@
22#define EFX_WORKAROUND_5147 EFX_WORKAROUND_ALWAYS 22#define EFX_WORKAROUND_5147 EFX_WORKAROUND_ALWAYS
23/* RX PCIe double split performance issue */ 23/* RX PCIe double split performance issue */
24#define EFX_WORKAROUND_7575 EFX_WORKAROUND_ALWAYS 24#define EFX_WORKAROUND_7575 EFX_WORKAROUND_ALWAYS
25/* Bit-bashed I2C reads cause performance drop */
26#define EFX_WORKAROUND_7884 EFX_WORKAROUND_ALWAYS
25/* TX pkt parser problem with <= 16 byte TXes */ 27/* TX pkt parser problem with <= 16 byte TXes */
26#define EFX_WORKAROUND_9141 EFX_WORKAROUND_ALWAYS 28#define EFX_WORKAROUND_9141 EFX_WORKAROUND_ALWAYS
27/* Low rate CRC errors require XAUI reset */ 29/* Low rate CRC errors require XAUI reset */
diff --git a/drivers/net/sfc/xfp_phy.c b/drivers/net/sfc/xfp_phy.c
index 276151df3a70..91f024662101 100644
--- a/drivers/net/sfc/xfp_phy.c
+++ b/drivers/net/sfc/xfp_phy.c
@@ -128,6 +128,15 @@ static int xfp_phy_check_hw(struct efx_nic *efx)
128 if (link_up != efx->link_up) 128 if (link_up != efx->link_up)
129 falcon_xmac_sim_phy_event(efx); 129 falcon_xmac_sim_phy_event(efx);
130 130
131 rc = efx->board_info.monitor(efx);
132 if (rc) {
133 struct xfp_phy_data *phy_data = efx->phy_data;
134 EFX_ERR(efx, "XFP sensor alert; putting PHY into low power\n");
135 efx->phy_mode |= PHY_MODE_LOW_POWER;
136 mdio_clause45_set_mmds_lpower(efx, 1, XFP_REQUIRED_DEVS);
137 phy_data->phy_mode |= PHY_MODE_LOW_POWER;
138 }
139
131 return rc; 140 return rc;
132} 141}
133 142
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 6261201403cd..97d68560067d 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -377,7 +377,6 @@ memory_squeeze:
377 skb_put(skb, len); 377 skb_put(skb, len);
378 skb->protocol = eth_type_trans(skb, dev); 378 skb->protocol = eth_type_trans(skb, dev);
379 netif_rx(skb); 379 netif_rx(skb);
380 dev->last_rx = jiffies;
381 dev->stats.rx_packets++; 380 dev->stats.rx_packets++;
382 dev->stats.rx_bytes += len; 381 dev->stats.rx_bytes += len;
383 } else { 382 } else {
@@ -657,7 +656,7 @@ static void timeout(struct net_device *dev)
657 656
658static void sgiseeq_set_multicast(struct net_device *dev) 657static void sgiseeq_set_multicast(struct net_device *dev)
659{ 658{
660 struct sgiseeq_private *sp = (struct sgiseeq_private *) dev->priv; 659 struct sgiseeq_private *sp = netdev_priv(dev);
661 unsigned char oldmode = sp->mode; 660 unsigned char oldmode = sp->mode;
662 661
663 if(dev->flags & IFF_PROMISC) 662 if(dev->flags & IFF_PROMISC)
@@ -719,7 +718,6 @@ static int __init sgiseeq_probe(struct platform_device *pdev)
719 struct sgiseeq_private *sp; 718 struct sgiseeq_private *sp;
720 struct net_device *dev; 719 struct net_device *dev;
721 int err; 720 int err;
722 DECLARE_MAC_BUF(mac);
723 721
724 dev = alloc_etherdev(sizeof (struct sgiseeq_private)); 722 dev = alloc_etherdev(sizeof (struct sgiseeq_private));
725 if (!dev) { 723 if (!dev) {
@@ -793,8 +791,7 @@ static int __init sgiseeq_probe(struct platform_device *pdev)
793 goto err_out_free_page; 791 goto err_out_free_page;
794 } 792 }
795 793
796 printk(KERN_INFO "%s: %s %s\n", 794 printk(KERN_INFO "%s: %s %pM\n", dev->name, sgiseeqstr, dev->dev_addr);
797 dev->name, sgiseeqstr, print_mac(mac, dev->dev_addr));
798 795
799 return 0; 796 return 0;
800 797
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index a24bb68887ab..077d796ccb70 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -540,7 +540,6 @@ static int sh_eth_rx(struct net_device *ndev)
540 skb_put(skb, pkt_len); 540 skb_put(skb, pkt_len);
541 skb->protocol = eth_type_trans(skb, ndev); 541 skb->protocol = eth_type_trans(skb, ndev);
542 netif_rx(skb); 542 netif_rx(skb);
543 ndev->last_rx = jiffies;
544 mdp->stats.rx_packets++; 543 mdp->stats.rx_packets++;
545 mdp->stats.rx_bytes += pkt_len; 544 mdp->stats.rx_bytes += pkt_len;
546 } 545 }
@@ -800,7 +799,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
800 char phy_id[BUS_ID_SIZE]; 799 char phy_id[BUS_ID_SIZE];
801 struct phy_device *phydev = NULL; 800 struct phy_device *phydev = NULL;
802 801
803 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, 802 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
804 mdp->mii_bus->id , mdp->phy_id); 803 mdp->mii_bus->id , mdp->phy_id);
805 804
806 mdp->link = PHY_DOWN; 805 mdp->link = PHY_DOWN;
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index e6e3bf58a569..83cc3c5f7946 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -627,7 +627,6 @@ static int sis190_rx_interrupt(struct net_device *dev,
627 627
628 sis190_rx_skb(skb); 628 sis190_rx_skb(skb);
629 629
630 dev->last_rx = jiffies;
631 stats->rx_packets++; 630 stats->rx_packets++;
632 stats->rx_bytes += pkt_size; 631 stats->rx_bytes += pkt_size;
633 if ((status & BCAST) == MCAST) 632 if ((status & BCAST) == MCAST)
@@ -1791,7 +1790,6 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1791 struct net_device *dev; 1790 struct net_device *dev;
1792 void __iomem *ioaddr; 1791 void __iomem *ioaddr;
1793 int rc; 1792 int rc;
1794 DECLARE_MAC_BUF(mac);
1795 1793
1796 if (!printed_version) { 1794 if (!printed_version) {
1797 net_drv(&debug, KERN_INFO SIS190_DRIVER_NAME " loaded.\n"); 1795 net_drv(&debug, KERN_INFO SIS190_DRIVER_NAME " loaded.\n");
@@ -1841,10 +1839,9 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1841 if (rc < 0) 1839 if (rc < 0)
1842 goto err_remove_mii; 1840 goto err_remove_mii;
1843 1841
1844 net_probe(tp, KERN_INFO "%s: %s at %p (IRQ: %d), " 1842 net_probe(tp, KERN_INFO "%s: %s at %p (IRQ: %d), %pM\n",
1845 "%s\n",
1846 pci_name(pdev), sis_chip_info[ent->driver_data].name, 1843 pci_name(pdev), sis_chip_info[ent->driver_data].name,
1847 ioaddr, dev->irq, print_mac(mac, dev->dev_addr)); 1844 ioaddr, dev->irq, dev->dev_addr);
1848 1845
1849 net_probe(tp, KERN_INFO "%s: %s mode.\n", dev->name, 1846 net_probe(tp, KERN_INFO "%s: %s mode.\n", dev->name,
1850 (tp->features & F_HAS_RGMII) ? "RGMII" : "GMII"); 1847 (tp->features & F_HAS_RGMII) ? "RGMII" : "GMII");
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index fa3a460f8e2f..9a363dc0db41 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -404,7 +404,6 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
404 int i, ret; 404 int i, ret;
405 const char *card_name = card_names[pci_id->driver_data]; 405 const char *card_name = card_names[pci_id->driver_data];
406 const char *dev_name = pci_name(pci_dev); 406 const char *dev_name = pci_name(pci_dev);
407 DECLARE_MAC_BUF(mac);
408 407
409/* when built into the kernel, we only print version if device is found */ 408/* when built into the kernel, we only print version if device is found */
410#ifndef MODULE 409#ifndef MODULE
@@ -437,7 +436,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
437 if (ret) 436 if (ret)
438 goto err_out; 437 goto err_out;
439 438
440 sis_priv = net_dev->priv; 439 sis_priv = netdev_priv(net_dev);
441 net_dev->base_addr = ioaddr; 440 net_dev->base_addr = ioaddr;
442 net_dev->irq = pci_dev->irq; 441 net_dev->irq = pci_dev->irq;
443 sis_priv->pci_dev = pci_dev; 442 sis_priv->pci_dev = pci_dev;
@@ -534,9 +533,9 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
534 goto err_unmap_rx; 533 goto err_unmap_rx;
535 534
536 /* print some information about our NIC */ 535 /* print some information about our NIC */
537 printk(KERN_INFO "%s: %s at %#lx, IRQ %d, %s\n", 536 printk(KERN_INFO "%s: %s at %#lx, IRQ %d, %pM\n",
538 net_dev->name, card_name, ioaddr, net_dev->irq, 537 net_dev->name, card_name, ioaddr, net_dev->irq,
539 print_mac(mac, net_dev->dev_addr)); 538 net_dev->dev_addr);
540 539
541 /* Detect Wake on Lan support */ 540 /* Detect Wake on Lan support */
542 ret = (inl(net_dev->base_addr + CFGPMC) & PMESP) >> 27; 541 ret = (inl(net_dev->base_addr + CFGPMC) & PMESP) >> 27;
@@ -570,7 +569,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
570 569
571static int __devinit sis900_mii_probe(struct net_device * net_dev) 570static int __devinit sis900_mii_probe(struct net_device * net_dev)
572{ 571{
573 struct sis900_private * sis_priv = net_dev->priv; 572 struct sis900_private *sis_priv = netdev_priv(net_dev);
574 const char *dev_name = pci_name(sis_priv->pci_dev); 573 const char *dev_name = pci_name(sis_priv->pci_dev);
575 u16 poll_bit = MII_STAT_LINK, status = 0; 574 u16 poll_bit = MII_STAT_LINK, status = 0;
576 unsigned long timeout = jiffies + 5 * HZ; 575 unsigned long timeout = jiffies + 5 * HZ;
@@ -698,7 +697,7 @@ static int __devinit sis900_mii_probe(struct net_device * net_dev)
698 697
699static u16 sis900_default_phy(struct net_device * net_dev) 698static u16 sis900_default_phy(struct net_device * net_dev)
700{ 699{
701 struct sis900_private * sis_priv = net_dev->priv; 700 struct sis900_private *sis_priv = netdev_priv(net_dev);
702 struct mii_phy *phy = NULL, *phy_home = NULL, 701 struct mii_phy *phy = NULL, *phy_home = NULL,
703 *default_phy = NULL, *phy_lan = NULL; 702 *default_phy = NULL, *phy_lan = NULL;
704 u16 status; 703 u16 status;
@@ -999,7 +998,7 @@ static void sis900_poll(struct net_device *dev)
999static int 998static int
1000sis900_open(struct net_device *net_dev) 999sis900_open(struct net_device *net_dev)
1001{ 1000{
1002 struct sis900_private *sis_priv = net_dev->priv; 1001 struct sis900_private *sis_priv = netdev_priv(net_dev);
1003 long ioaddr = net_dev->base_addr; 1002 long ioaddr = net_dev->base_addr;
1004 int ret; 1003 int ret;
1005 1004
@@ -1055,7 +1054,7 @@ sis900_open(struct net_device *net_dev)
1055static void 1054static void
1056sis900_init_rxfilter (struct net_device * net_dev) 1055sis900_init_rxfilter (struct net_device * net_dev)
1057{ 1056{
1058 struct sis900_private *sis_priv = net_dev->priv; 1057 struct sis900_private *sis_priv = netdev_priv(net_dev);
1059 long ioaddr = net_dev->base_addr; 1058 long ioaddr = net_dev->base_addr;
1060 u32 rfcrSave; 1059 u32 rfcrSave;
1061 u32 i; 1060 u32 i;
@@ -1093,7 +1092,7 @@ sis900_init_rxfilter (struct net_device * net_dev)
1093static void 1092static void
1094sis900_init_tx_ring(struct net_device *net_dev) 1093sis900_init_tx_ring(struct net_device *net_dev)
1095{ 1094{
1096 struct sis900_private *sis_priv = net_dev->priv; 1095 struct sis900_private *sis_priv = netdev_priv(net_dev);
1097 long ioaddr = net_dev->base_addr; 1096 long ioaddr = net_dev->base_addr;
1098 int i; 1097 int i;
1099 1098
@@ -1127,7 +1126,7 @@ sis900_init_tx_ring(struct net_device *net_dev)
1127static void 1126static void
1128sis900_init_rx_ring(struct net_device *net_dev) 1127sis900_init_rx_ring(struct net_device *net_dev)
1129{ 1128{
1130 struct sis900_private *sis_priv = net_dev->priv; 1129 struct sis900_private *sis_priv = netdev_priv(net_dev);
1131 long ioaddr = net_dev->base_addr; 1130 long ioaddr = net_dev->base_addr;
1132 int i; 1131 int i;
1133 1132
@@ -1198,7 +1197,7 @@ sis900_init_rx_ring(struct net_device *net_dev)
1198 1197
1199static void sis630_set_eq(struct net_device *net_dev, u8 revision) 1198static void sis630_set_eq(struct net_device *net_dev, u8 revision)
1200{ 1199{
1201 struct sis900_private *sis_priv = net_dev->priv; 1200 struct sis900_private *sis_priv = netdev_priv(net_dev);
1202 u16 reg14h, eq_value=0, max_value=0, min_value=0; 1201 u16 reg14h, eq_value=0, max_value=0, min_value=0;
1203 int i, maxcount=10; 1202 int i, maxcount=10;
1204 1203
@@ -1271,7 +1270,7 @@ static void sis630_set_eq(struct net_device *net_dev, u8 revision)
1271static void sis900_timer(unsigned long data) 1270static void sis900_timer(unsigned long data)
1272{ 1271{
1273 struct net_device *net_dev = (struct net_device *)data; 1272 struct net_device *net_dev = (struct net_device *)data;
1274 struct sis900_private *sis_priv = net_dev->priv; 1273 struct sis900_private *sis_priv = netdev_priv(net_dev);
1275 struct mii_phy *mii_phy = sis_priv->mii; 1274 struct mii_phy *mii_phy = sis_priv->mii;
1276 static const int next_tick = 5*HZ; 1275 static const int next_tick = 5*HZ;
1277 u16 status; 1276 u16 status;
@@ -1341,7 +1340,7 @@ static void sis900_timer(unsigned long data)
1341 1340
1342static void sis900_check_mode(struct net_device *net_dev, struct mii_phy *mii_phy) 1341static void sis900_check_mode(struct net_device *net_dev, struct mii_phy *mii_phy)
1343{ 1342{
1344 struct sis900_private *sis_priv = net_dev->priv; 1343 struct sis900_private *sis_priv = netdev_priv(net_dev);
1345 long ioaddr = net_dev->base_addr; 1344 long ioaddr = net_dev->base_addr;
1346 int speed, duplex; 1345 int speed, duplex;
1347 1346
@@ -1420,7 +1419,7 @@ static void sis900_set_mode (long ioaddr, int speed, int duplex)
1420 1419
1421static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr) 1420static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr)
1422{ 1421{
1423 struct sis900_private *sis_priv = net_dev->priv; 1422 struct sis900_private *sis_priv = netdev_priv(net_dev);
1424 int i = 0; 1423 int i = 0;
1425 u32 status; 1424 u32 status;
1426 1425
@@ -1455,7 +1454,7 @@ static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr)
1455 1454
1456static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex) 1455static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex)
1457{ 1456{
1458 struct sis900_private *sis_priv = net_dev->priv; 1457 struct sis900_private *sis_priv = netdev_priv(net_dev);
1459 struct mii_phy *phy = sis_priv->mii; 1458 struct mii_phy *phy = sis_priv->mii;
1460 int phy_addr = sis_priv->cur_phy; 1459 int phy_addr = sis_priv->cur_phy;
1461 u32 status; 1460 u32 status;
@@ -1510,7 +1509,7 @@ static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex
1510 1509
1511static void sis900_tx_timeout(struct net_device *net_dev) 1510static void sis900_tx_timeout(struct net_device *net_dev)
1512{ 1511{
1513 struct sis900_private *sis_priv = net_dev->priv; 1512 struct sis900_private *sis_priv = netdev_priv(net_dev);
1514 long ioaddr = net_dev->base_addr; 1513 long ioaddr = net_dev->base_addr;
1515 unsigned long flags; 1514 unsigned long flags;
1516 int i; 1515 int i;
@@ -1569,7 +1568,7 @@ static void sis900_tx_timeout(struct net_device *net_dev)
1569static int 1568static int
1570sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev) 1569sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
1571{ 1570{
1572 struct sis900_private *sis_priv = net_dev->priv; 1571 struct sis900_private *sis_priv = netdev_priv(net_dev);
1573 long ioaddr = net_dev->base_addr; 1572 long ioaddr = net_dev->base_addr;
1574 unsigned int entry; 1573 unsigned int entry;
1575 unsigned long flags; 1574 unsigned long flags;
@@ -1639,7 +1638,7 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
1639static irqreturn_t sis900_interrupt(int irq, void *dev_instance) 1638static irqreturn_t sis900_interrupt(int irq, void *dev_instance)
1640{ 1639{
1641 struct net_device *net_dev = dev_instance; 1640 struct net_device *net_dev = dev_instance;
1642 struct sis900_private *sis_priv = net_dev->priv; 1641 struct sis900_private *sis_priv = netdev_priv(net_dev);
1643 int boguscnt = max_interrupt_work; 1642 int boguscnt = max_interrupt_work;
1644 long ioaddr = net_dev->base_addr; 1643 long ioaddr = net_dev->base_addr;
1645 u32 status; 1644 u32 status;
@@ -1701,7 +1700,7 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance)
1701 1700
1702static int sis900_rx(struct net_device *net_dev) 1701static int sis900_rx(struct net_device *net_dev)
1703{ 1702{
1704 struct sis900_private *sis_priv = net_dev->priv; 1703 struct sis900_private *sis_priv = netdev_priv(net_dev);
1705 long ioaddr = net_dev->base_addr; 1704 long ioaddr = net_dev->base_addr;
1706 unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC; 1705 unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC;
1707 u32 rx_status = sis_priv->rx_ring[entry].cmdsts; 1706 u32 rx_status = sis_priv->rx_ring[entry].cmdsts;
@@ -1790,7 +1789,6 @@ static int sis900_rx(struct net_device *net_dev)
1790 /* some network statistics */ 1789 /* some network statistics */
1791 if ((rx_status & BCAST) == MCAST) 1790 if ((rx_status & BCAST) == MCAST)
1792 net_dev->stats.multicast++; 1791 net_dev->stats.multicast++;
1793 net_dev->last_rx = jiffies;
1794 net_dev->stats.rx_bytes += rx_size; 1792 net_dev->stats.rx_bytes += rx_size;
1795 net_dev->stats.rx_packets++; 1793 net_dev->stats.rx_packets++;
1796 sis_priv->dirty_rx++; 1794 sis_priv->dirty_rx++;
@@ -1851,7 +1849,7 @@ refill_rx_ring:
1851 1849
1852static void sis900_finish_xmit (struct net_device *net_dev) 1850static void sis900_finish_xmit (struct net_device *net_dev)
1853{ 1851{
1854 struct sis900_private *sis_priv = net_dev->priv; 1852 struct sis900_private *sis_priv = netdev_priv(net_dev);
1855 1853
1856 for (; sis_priv->dirty_tx != sis_priv->cur_tx; sis_priv->dirty_tx++) { 1854 for (; sis_priv->dirty_tx != sis_priv->cur_tx; sis_priv->dirty_tx++) {
1857 struct sk_buff *skb; 1855 struct sk_buff *skb;
@@ -1920,7 +1918,7 @@ static void sis900_finish_xmit (struct net_device *net_dev)
1920static int sis900_close(struct net_device *net_dev) 1918static int sis900_close(struct net_device *net_dev)
1921{ 1919{
1922 long ioaddr = net_dev->base_addr; 1920 long ioaddr = net_dev->base_addr;
1923 struct sis900_private *sis_priv = net_dev->priv; 1921 struct sis900_private *sis_priv = netdev_priv(net_dev);
1924 struct sk_buff *skb; 1922 struct sk_buff *skb;
1925 int i; 1923 int i;
1926 1924
@@ -1975,7 +1973,7 @@ static int sis900_close(struct net_device *net_dev)
1975static void sis900_get_drvinfo(struct net_device *net_dev, 1973static void sis900_get_drvinfo(struct net_device *net_dev,
1976 struct ethtool_drvinfo *info) 1974 struct ethtool_drvinfo *info)
1977{ 1975{
1978 struct sis900_private *sis_priv = net_dev->priv; 1976 struct sis900_private *sis_priv = netdev_priv(net_dev);
1979 1977
1980 strcpy (info->driver, SIS900_MODULE_NAME); 1978 strcpy (info->driver, SIS900_MODULE_NAME);
1981 strcpy (info->version, SIS900_DRV_VERSION); 1979 strcpy (info->version, SIS900_DRV_VERSION);
@@ -1984,26 +1982,26 @@ static void sis900_get_drvinfo(struct net_device *net_dev,
1984 1982
1985static u32 sis900_get_msglevel(struct net_device *net_dev) 1983static u32 sis900_get_msglevel(struct net_device *net_dev)
1986{ 1984{
1987 struct sis900_private *sis_priv = net_dev->priv; 1985 struct sis900_private *sis_priv = netdev_priv(net_dev);
1988 return sis_priv->msg_enable; 1986 return sis_priv->msg_enable;
1989} 1987}
1990 1988
1991static void sis900_set_msglevel(struct net_device *net_dev, u32 value) 1989static void sis900_set_msglevel(struct net_device *net_dev, u32 value)
1992{ 1990{
1993 struct sis900_private *sis_priv = net_dev->priv; 1991 struct sis900_private *sis_priv = netdev_priv(net_dev);
1994 sis_priv->msg_enable = value; 1992 sis_priv->msg_enable = value;
1995} 1993}
1996 1994
1997static u32 sis900_get_link(struct net_device *net_dev) 1995static u32 sis900_get_link(struct net_device *net_dev)
1998{ 1996{
1999 struct sis900_private *sis_priv = net_dev->priv; 1997 struct sis900_private *sis_priv = netdev_priv(net_dev);
2000 return mii_link_ok(&sis_priv->mii_info); 1998 return mii_link_ok(&sis_priv->mii_info);
2001} 1999}
2002 2000
2003static int sis900_get_settings(struct net_device *net_dev, 2001static int sis900_get_settings(struct net_device *net_dev,
2004 struct ethtool_cmd *cmd) 2002 struct ethtool_cmd *cmd)
2005{ 2003{
2006 struct sis900_private *sis_priv = net_dev->priv; 2004 struct sis900_private *sis_priv = netdev_priv(net_dev);
2007 spin_lock_irq(&sis_priv->lock); 2005 spin_lock_irq(&sis_priv->lock);
2008 mii_ethtool_gset(&sis_priv->mii_info, cmd); 2006 mii_ethtool_gset(&sis_priv->mii_info, cmd);
2009 spin_unlock_irq(&sis_priv->lock); 2007 spin_unlock_irq(&sis_priv->lock);
@@ -2013,7 +2011,7 @@ static int sis900_get_settings(struct net_device *net_dev,
2013static int sis900_set_settings(struct net_device *net_dev, 2011static int sis900_set_settings(struct net_device *net_dev,
2014 struct ethtool_cmd *cmd) 2012 struct ethtool_cmd *cmd)
2015{ 2013{
2016 struct sis900_private *sis_priv = net_dev->priv; 2014 struct sis900_private *sis_priv = netdev_priv(net_dev);
2017 int rt; 2015 int rt;
2018 spin_lock_irq(&sis_priv->lock); 2016 spin_lock_irq(&sis_priv->lock);
2019 rt = mii_ethtool_sset(&sis_priv->mii_info, cmd); 2017 rt = mii_ethtool_sset(&sis_priv->mii_info, cmd);
@@ -2023,7 +2021,7 @@ static int sis900_set_settings(struct net_device *net_dev,
2023 2021
2024static int sis900_nway_reset(struct net_device *net_dev) 2022static int sis900_nway_reset(struct net_device *net_dev)
2025{ 2023{
2026 struct sis900_private *sis_priv = net_dev->priv; 2024 struct sis900_private *sis_priv = netdev_priv(net_dev);
2027 return mii_nway_restart(&sis_priv->mii_info); 2025 return mii_nway_restart(&sis_priv->mii_info);
2028} 2026}
2029 2027
@@ -2040,7 +2038,7 @@ static int sis900_nway_reset(struct net_device *net_dev)
2040 2038
2041static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol) 2039static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
2042{ 2040{
2043 struct sis900_private *sis_priv = net_dev->priv; 2041 struct sis900_private *sis_priv = netdev_priv(net_dev);
2044 long pmctrl_addr = net_dev->base_addr + pmctrl; 2042 long pmctrl_addr = net_dev->base_addr + pmctrl;
2045 u32 cfgpmcsr = 0, pmctrl_bits = 0; 2043 u32 cfgpmcsr = 0, pmctrl_bits = 0;
2046 2044
@@ -2111,7 +2109,7 @@ static const struct ethtool_ops sis900_ethtool_ops = {
2111 2109
2112static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd) 2110static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)
2113{ 2111{
2114 struct sis900_private *sis_priv = net_dev->priv; 2112 struct sis900_private *sis_priv = netdev_priv(net_dev);
2115 struct mii_ioctl_data *data = if_mii(rq); 2113 struct mii_ioctl_data *data = if_mii(rq);
2116 2114
2117 switch(cmd) { 2115 switch(cmd) {
@@ -2145,7 +2143,7 @@ static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)
2145 2143
2146static int sis900_set_config(struct net_device *dev, struct ifmap *map) 2144static int sis900_set_config(struct net_device *dev, struct ifmap *map)
2147{ 2145{
2148 struct sis900_private *sis_priv = dev->priv; 2146 struct sis900_private *sis_priv = netdev_priv(dev);
2149 struct mii_phy *mii_phy = sis_priv->mii; 2147 struct mii_phy *mii_phy = sis_priv->mii;
2150 2148
2151 u16 status; 2149 u16 status;
@@ -2268,7 +2266,7 @@ static inline u16 sis900_mcast_bitnr(u8 *addr, u8 revision)
2268static void set_rx_mode(struct net_device *net_dev) 2266static void set_rx_mode(struct net_device *net_dev)
2269{ 2267{
2270 long ioaddr = net_dev->base_addr; 2268 long ioaddr = net_dev->base_addr;
2271 struct sis900_private * sis_priv = net_dev->priv; 2269 struct sis900_private *sis_priv = netdev_priv(net_dev);
2272 u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */ 2270 u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */
2273 int i, table_entries; 2271 int i, table_entries;
2274 u32 rx_mode; 2272 u32 rx_mode;
@@ -2343,7 +2341,7 @@ static void set_rx_mode(struct net_device *net_dev)
2343 2341
2344static void sis900_reset(struct net_device *net_dev) 2342static void sis900_reset(struct net_device *net_dev)
2345{ 2343{
2346 struct sis900_private * sis_priv = net_dev->priv; 2344 struct sis900_private *sis_priv = netdev_priv(net_dev);
2347 long ioaddr = net_dev->base_addr; 2345 long ioaddr = net_dev->base_addr;
2348 int i = 0; 2346 int i = 0;
2349 u32 status = TxRCMP | RxRCMP; 2347 u32 status = TxRCMP | RxRCMP;
@@ -2376,7 +2374,7 @@ static void sis900_reset(struct net_device *net_dev)
2376static void __devexit sis900_remove(struct pci_dev *pci_dev) 2374static void __devexit sis900_remove(struct pci_dev *pci_dev)
2377{ 2375{
2378 struct net_device *net_dev = pci_get_drvdata(pci_dev); 2376 struct net_device *net_dev = pci_get_drvdata(pci_dev);
2379 struct sis900_private * sis_priv = net_dev->priv; 2377 struct sis900_private *sis_priv = netdev_priv(net_dev);
2380 struct mii_phy *phy = NULL; 2378 struct mii_phy *phy = NULL;
2381 2379
2382 while (sis_priv->first_mii) { 2380 while (sis_priv->first_mii) {
@@ -2420,7 +2418,7 @@ static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state)
2420static int sis900_resume(struct pci_dev *pci_dev) 2418static int sis900_resume(struct pci_dev *pci_dev)
2421{ 2419{
2422 struct net_device *net_dev = pci_get_drvdata(pci_dev); 2420 struct net_device *net_dev = pci_get_drvdata(pci_dev);
2423 struct sis900_private *sis_priv = net_dev->priv; 2421 struct sis900_private *sis_priv = netdev_priv(net_dev);
2424 long ioaddr = net_dev->base_addr; 2422 long ioaddr = net_dev->base_addr;
2425 2423
2426 if(!netif_running(net_dev)) 2424 if(!netif_running(net_dev))
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index a2b092bb3626..282bb47deccc 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -1680,7 +1680,6 @@ void mac_drv_rx_complete(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
1680 skb->protocol = fddi_type_trans(skb, bp->dev); 1680 skb->protocol = fddi_type_trans(skb, bp->dev);
1681 1681
1682 netif_rx(skb); 1682 netif_rx(skb);
1683 bp->dev->last_rx = jiffies;
1684 1683
1685 HWM_RX_CHECK(smc, RX_LOW_WATERMARK); 1684 HWM_RX_CHECK(smc, RX_LOW_WATERMARK);
1686 return; 1685 return;
@@ -1939,7 +1938,6 @@ int mac_drv_rx_init(struct s_smc *smc, int len, int fc,
1939 1938
1940 // deliver frame to system 1939 // deliver frame to system
1941 skb->protocol = fddi_type_trans(skb, smc->os.dev); 1940 skb->protocol = fddi_type_trans(skb, smc->os.dev);
1942 skb->dev->last_rx = jiffies;
1943 netif_rx(skb); 1941 netif_rx(skb);
1944 1942
1945 return (0); 1943 return (0);
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 43f4c730be42..05f9d50d956a 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -149,24 +149,6 @@ static u32 wol_supported(const struct skge_hw *hw)
149 return WAKE_MAGIC | WAKE_PHY; 149 return WAKE_MAGIC | WAKE_PHY;
150} 150}
151 151
152static u32 pci_wake_enabled(struct pci_dev *dev)
153{
154 int pm = pci_find_capability(dev, PCI_CAP_ID_PM);
155 u16 value;
156
157 /* If device doesn't support PM Capabilities, but request is to disable
158 * wake events, it's a nop; otherwise fail */
159 if (!pm)
160 return 0;
161
162 pci_read_config_word(dev, pm + PCI_PM_PMC, &value);
163
164 value &= PCI_PM_CAP_PME_MASK;
165 value >>= ffs(PCI_PM_CAP_PME_MASK) - 1; /* First bit of mask */
166
167 return value != 0;
168}
169
170static void skge_wol_init(struct skge_port *skge) 152static void skge_wol_init(struct skge_port *skge)
171{ 153{
172 struct skge_hw *hw = skge->hw; 154 struct skge_hw *hw = skge->hw;
@@ -254,10 +236,14 @@ static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
254 struct skge_port *skge = netdev_priv(dev); 236 struct skge_port *skge = netdev_priv(dev);
255 struct skge_hw *hw = skge->hw; 237 struct skge_hw *hw = skge->hw;
256 238
257 if (wol->wolopts & ~wol_supported(hw)) 239 if ((wol->wolopts & ~wol_supported(hw))
240 || !device_can_wakeup(&hw->pdev->dev))
258 return -EOPNOTSUPP; 241 return -EOPNOTSUPP;
259 242
260 skge->wol = wol->wolopts; 243 skge->wol = wol->wolopts;
244
245 device_set_wakeup_enable(&hw->pdev->dev, skge->wol);
246
261 return 0; 247 return 0;
262} 248}
263 249
@@ -3200,7 +3186,6 @@ static int skge_poll(struct napi_struct *napi, int to_do)
3200 3186
3201 skb = skge_rx_get(dev, e, control, rd->status, rd->csum2); 3187 skb = skge_rx_get(dev, e, control, rd->status, rd->csum2);
3202 if (likely(skb)) { 3188 if (likely(skb)) {
3203 dev->last_rx = jiffies;
3204 netif_receive_skb(skb); 3189 netif_receive_skb(skb);
3205 3190
3206 ++work_done; 3191 ++work_done;
@@ -3856,7 +3841,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3856 skge->speed = -1; 3841 skge->speed = -1;
3857 skge->advertising = skge_supported_modes(hw); 3842 skge->advertising = skge_supported_modes(hw);
3858 3843
3859 if (pci_wake_enabled(hw->pdev)) 3844 if (device_may_wakeup(&hw->pdev->dev))
3860 skge->wol = wol_supported(hw) & WAKE_MAGIC; 3845 skge->wol = wol_supported(hw) & WAKE_MAGIC;
3861 3846
3862 hw->dev[port] = dev; 3847 hw->dev[port] = dev;
@@ -3885,11 +3870,10 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3885static void __devinit skge_show_addr(struct net_device *dev) 3870static void __devinit skge_show_addr(struct net_device *dev)
3886{ 3871{
3887 const struct skge_port *skge = netdev_priv(dev); 3872 const struct skge_port *skge = netdev_priv(dev);
3888 DECLARE_MAC_BUF(mac);
3889 3873
3890 if (netif_msg_probe(skge)) 3874 if (netif_msg_probe(skge))
3891 printk(KERN_INFO PFX "%s: addr %s\n", 3875 printk(KERN_INFO PFX "%s: addr %pM\n",
3892 dev->name, print_mac(mac, dev->dev_addr)); 3876 dev->name, dev->dev_addr);
3893} 3877}
3894 3878
3895static int __devinit skge_probe(struct pci_dev *pdev, 3879static int __devinit skge_probe(struct pci_dev *pdev,
@@ -4082,8 +4066,8 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
4082 } 4066 }
4083 4067
4084 skge_write32(hw, B0_IMSK, 0); 4068 skge_write32(hw, B0_IMSK, 0);
4085 pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); 4069
4086 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 4070 pci_prepare_to_sleep(pdev);
4087 4071
4088 return 0; 4072 return 0;
4089} 4073}
@@ -4096,7 +4080,7 @@ static int skge_resume(struct pci_dev *pdev)
4096 if (!hw) 4080 if (!hw)
4097 return 0; 4081 return 0;
4098 4082
4099 err = pci_set_power_state(pdev, PCI_D0); 4083 err = pci_back_from_sleep(pdev);
4100 if (err) 4084 if (err)
4101 goto out; 4085 goto out;
4102 4086
@@ -4104,8 +4088,6 @@ static int skge_resume(struct pci_dev *pdev)
4104 if (err) 4088 if (err)
4105 goto out; 4089 goto out;
4106 4090
4107 pci_enable_wake(pdev, PCI_D0, 0);
4108
4109 err = skge_reset(hw); 4091 err = skge_reset(hw);
4110 if (err) 4092 if (err)
4111 goto out; 4093 goto out;
@@ -4146,8 +4128,8 @@ static void skge_shutdown(struct pci_dev *pdev)
4146 wol |= skge->wol; 4128 wol |= skge->wol;
4147 } 4129 }
4148 4130
4149 pci_enable_wake(pdev, PCI_D3hot, wol); 4131 if (pci_enable_wake(pdev, PCI_D3cold, wol))
4150 pci_enable_wake(pdev, PCI_D3cold, wol); 4132 pci_enable_wake(pdev, PCI_D3hot, wol);
4151 4133
4152 pci_disable_device(pdev); 4134 pci_disable_device(pdev);
4153 pci_set_power_state(pdev, PCI_D3hot); 4135 pci_set_power_state(pdev, PCI_D3hot);
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 3813d15e2df7..4dcd1a62fb49 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -4118,11 +4118,10 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
4118static void __devinit sky2_show_addr(struct net_device *dev) 4118static void __devinit sky2_show_addr(struct net_device *dev)
4119{ 4119{
4120 const struct sky2_port *sky2 = netdev_priv(dev); 4120 const struct sky2_port *sky2 = netdev_priv(dev);
4121 DECLARE_MAC_BUF(mac);
4122 4121
4123 if (netif_msg_probe(sky2)) 4122 if (netif_msg_probe(sky2))
4124 printk(KERN_INFO PFX "%s: addr %s\n", 4123 printk(KERN_INFO PFX "%s: addr %pM\n",
4125 dev->name, print_mac(mac, dev->dev_addr)); 4124 dev->name, dev->dev_addr);
4126} 4125}
4127 4126
4128/* Handle software interrupt used during MSI test */ 4127/* Handle software interrupt used during MSI test */
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 1d58991d395b..25cec06d6dcc 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -365,7 +365,6 @@ static void sl_bump(struct slip *sl)
365 skb_reset_mac_header(skb); 365 skb_reset_mac_header(skb);
366 skb->protocol = htons(ETH_P_IP); 366 skb->protocol = htons(ETH_P_IP);
367 netif_rx(skb); 367 netif_rx(skb);
368 sl->dev->last_rx = jiffies;
369 sl->rx_packets++; 368 sl->rx_packets++;
370} 369}
371 370
diff --git a/drivers/net/smc-mca.c b/drivers/net/smc-mca.c
index d6abb68e6e2f..58a0e0a4a325 100644
--- a/drivers/net/smc-mca.c
+++ b/drivers/net/smc-mca.c
@@ -196,7 +196,6 @@ static int __init ultramca_probe(struct device *gen_dev)
196 int tirq = 0; 196 int tirq = 0;
197 int base_addr = ultra_io[ultra_found]; 197 int base_addr = ultra_io[ultra_found];
198 int irq = ultra_irq[ultra_found]; 198 int irq = ultra_irq[ultra_found];
199 DECLARE_MAC_BUF(mac);
200 199
201 if (base_addr || irq) { 200 if (base_addr || irq) {
202 printk(KERN_INFO "Probing for SMC MCA adapter"); 201 printk(KERN_INFO "Probing for SMC MCA adapter");
@@ -334,8 +333,8 @@ static int __init ultramca_probe(struct device *gen_dev)
334 for (i = 0; i < 6; i++) 333 for (i = 0; i < 6; i++)
335 dev->dev_addr[i] = inb(ioaddr + 8 + i); 334 dev->dev_addr[i] = inb(ioaddr + 8 + i);
336 335
337 printk(KERN_INFO "smc_mca[%d]: Parameters: %#3x, %s", 336 printk(KERN_INFO "smc_mca[%d]: Parameters: %#3x, %pM",
338 slot + 1, ioaddr, print_mac(mac, dev->dev_addr)); 337 slot + 1, ioaddr, dev->dev_addr);
339 338
340 /* Switch from the station address to the alternate register set 339 /* Switch from the station address to the alternate register set
341 * and read the useful registers there. 340 * and read the useful registers there.
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index 00d6cf1af484..0fe0251767bb 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -198,7 +198,6 @@ static int __init ultra_probe1(struct net_device *dev, int ioaddr)
198 unsigned char num_pages, irqreg, addr, piomode; 198 unsigned char num_pages, irqreg, addr, piomode;
199 unsigned char idreg = inb(ioaddr + 7); 199 unsigned char idreg = inb(ioaddr + 7);
200 unsigned char reg4 = inb(ioaddr + 4) & 0x7f; 200 unsigned char reg4 = inb(ioaddr + 4) & 0x7f;
201 DECLARE_MAC_BUF(mac);
202 201
203 if (!request_region(ioaddr, ULTRA_IO_EXTENT, DRV_NAME)) 202 if (!request_region(ioaddr, ULTRA_IO_EXTENT, DRV_NAME))
204 return -EBUSY; 203 return -EBUSY;
@@ -228,8 +227,8 @@ static int __init ultra_probe1(struct net_device *dev, int ioaddr)
228 for (i = 0; i < 6; i++) 227 for (i = 0; i < 6; i++)
229 dev->dev_addr[i] = inb(ioaddr + 8 + i); 228 dev->dev_addr[i] = inb(ioaddr + 8 + i);
230 229
231 printk("%s: %s at %#3x, %s", dev->name, model_name, 230 printk("%s: %s at %#3x, %pM", dev->name, model_name,
232 ioaddr, print_mac(mac, dev->dev_addr)); 231 ioaddr, dev->dev_addr);
233 232
234 /* Switch from the station address to the alternate register set and 233 /* Switch from the station address to the alternate register set and
235 read the useful registers there. */ 234 read the useful registers there. */
diff --git a/drivers/net/smc-ultra32.c b/drivers/net/smc-ultra32.c
index a5a91ace28cc..cb6c097a2e0a 100644
--- a/drivers/net/smc-ultra32.c
+++ b/drivers/net/smc-ultra32.c
@@ -163,7 +163,6 @@ static int __init ultra32_probe1(struct net_device *dev, int ioaddr)
163 unsigned char idreg; 163 unsigned char idreg;
164 unsigned char reg4; 164 unsigned char reg4;
165 const char *ifmap[] = {"UTP No Link", "", "UTP/AUI", "UTP/BNC"}; 165 const char *ifmap[] = {"UTP No Link", "", "UTP/AUI", "UTP/BNC"};
166 DECLARE_MAC_BUF(mac);
167 166
168 if (!request_region(ioaddr, ULTRA32_IO_EXTENT, DRV_NAME)) 167 if (!request_region(ioaddr, ULTRA32_IO_EXTENT, DRV_NAME))
169 return -EBUSY; 168 return -EBUSY;
@@ -207,8 +206,8 @@ static int __init ultra32_probe1(struct net_device *dev, int ioaddr)
207 for (i = 0; i < 6; i++) 206 for (i = 0; i < 6; i++)
208 dev->dev_addr[i] = inb(ioaddr + 8 + i); 207 dev->dev_addr[i] = inb(ioaddr + 8 + i);
209 208
210 printk("%s: %s at 0x%X, %s", 209 printk("%s: %s at 0x%X, %pM",
211 dev->name, model_name, ioaddr, print_mac(mac, dev->dev_addr)); 210 dev->name, model_name, ioaddr, dev->dev_addr);
212 211
213 /* Switch from the station address to the alternate register set and 212 /* Switch from the station address to the alternate register set and
214 read the useful registers there. */ 213 read the useful registers there. */
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 1f26ab0e7986..a91b7351150d 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -439,7 +439,6 @@ static inline void smc911x_rcv(struct net_device *dev)
439 439
440 DBG(SMC_DEBUG_PKTS, "%s: Received packet\n", dev->name); 440 DBG(SMC_DEBUG_PKTS, "%s: Received packet\n", dev->name);
441 PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64); 441 PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64);
442 dev->last_rx = jiffies;
443 skb->protocol = eth_type_trans(skb, dev); 442 skb->protocol = eth_type_trans(skb, dev);
444 netif_rx(skb); 443 netif_rx(skb);
445 dev->stats.rx_packets++; 444 dev->stats.rx_packets++;
@@ -1231,7 +1230,6 @@ smc911x_rx_dma_irq(int dma, void *data)
1231 BUG_ON(skb == NULL); 1230 BUG_ON(skb == NULL);
1232 lp->current_rx_skb = NULL; 1231 lp->current_rx_skb = NULL;
1233 PRINT_PKT(skb->data, skb->len); 1232 PRINT_PKT(skb->data, skb->len);
1234 dev->last_rx = jiffies;
1235 skb->protocol = eth_type_trans(skb, dev); 1233 skb->protocol = eth_type_trans(skb, dev);
1236 dev->stats.rx_packets++; 1234 dev->stats.rx_packets++;
1237 dev->stats.rx_bytes += skb->len; 1235 dev->stats.rx_bytes += skb->len;
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index de67744c4a2a..e7cc80f32560 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -876,8 +876,6 @@ static int __init smc_probe(struct net_device *dev, int ioaddr)
876 word memory_info_register; 876 word memory_info_register;
877 word memory_cfg_register; 877 word memory_cfg_register;
878 878
879 DECLARE_MAC_BUF(mac);
880
881 /* Grab the region so that no one else tries to probe our ioports. */ 879 /* Grab the region so that no one else tries to probe our ioports. */
882 if (!request_region(ioaddr, SMC_IO_EXTENT, DRV_NAME)) 880 if (!request_region(ioaddr, SMC_IO_EXTENT, DRV_NAME))
883 return -EBUSY; 881 return -EBUSY;
@@ -1033,10 +1031,10 @@ static int __init smc_probe(struct net_device *dev, int ioaddr)
1033 /* 1031 /*
1034 . Print the Ethernet address 1032 . Print the Ethernet address
1035 */ 1033 */
1036 printk("ADDR: %s\n", print_mac(mac, dev->dev_addr)); 1034 printk("ADDR: %pM\n", dev->dev_addr);
1037 1035
1038 /* set the private data to zero by default */ 1036 /* set the private data to zero by default */
1039 memset(dev->priv, 0, sizeof(struct smc_local)); 1037 memset(netdev_priv(dev), 0, sizeof(struct smc_local));
1040 1038
1041 /* Grab the IRQ */ 1039 /* Grab the IRQ */
1042 retval = request_irq(dev->irq, &smc_interrupt, 0, DRV_NAME, dev); 1040 retval = request_irq(dev->irq, &smc_interrupt, 0, DRV_NAME, dev);
@@ -1110,7 +1108,7 @@ static int smc_open(struct net_device *dev)
1110 int i; /* used to set hw ethernet address */ 1108 int i; /* used to set hw ethernet address */
1111 1109
1112 /* clear out all the junk that was put here before... */ 1110 /* clear out all the junk that was put here before... */
1113 memset(dev->priv, 0, sizeof(struct smc_local)); 1111 memset(netdev_priv(dev), 0, sizeof(struct smc_local));
1114 1112
1115 /* reset the hardware */ 1113 /* reset the hardware */
1116 1114
@@ -1166,7 +1164,7 @@ static void smc_timeout(struct net_device *dev)
1166 smc_enable( dev->base_addr ); 1164 smc_enable( dev->base_addr );
1167 dev->trans_start = jiffies; 1165 dev->trans_start = jiffies;
1168 /* clear anything saved */ 1166 /* clear anything saved */
1169 ((struct smc_local *)dev->priv)->saved_skb = NULL; 1167 ((struct smc_local *)netdev_priv(dev))->saved_skb = NULL;
1170 netif_wake_queue(dev); 1168 netif_wake_queue(dev);
1171} 1169}
1172 1170
@@ -1272,7 +1270,6 @@ static void smc_rcv(struct net_device *dev)
1272 1270
1273 skb->protocol = eth_type_trans(skb, dev ); 1271 skb->protocol = eth_type_trans(skb, dev );
1274 netif_rx(skb); 1272 netif_rx(skb);
1275 dev->last_rx = jiffies;
1276 dev->stats.rx_packets++; 1273 dev->stats.rx_packets++;
1277 dev->stats.rx_bytes += packet_length; 1274 dev->stats.rx_bytes += packet_length;
1278 } else { 1275 } else {
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index fc80f250da31..5879c719b538 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -518,7 +518,6 @@ static inline void smc_rcv(struct net_device *dev)
518 518
519 PRINT_PKT(data, packet_len - 4); 519 PRINT_PKT(data, packet_len - 4);
520 520
521 dev->last_rx = jiffies;
522 skb->protocol = eth_type_trans(skb, dev); 521 skb->protocol = eth_type_trans(skb, dev);
523 netif_rx(skb); 522 netif_rx(skb);
524 dev->stats.rx_packets++; 523 dev->stats.rx_packets++;
@@ -1778,7 +1777,6 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr,
1778 int retval; 1777 int retval;
1779 unsigned int val, revision_register; 1778 unsigned int val, revision_register;
1780 const char *version_string; 1779 const char *version_string;
1781 DECLARE_MAC_BUF(mac);
1782 1780
1783 DBG(2, "%s: %s\n", CARDNAME, __func__); 1781 DBG(2, "%s: %s\n", CARDNAME, __func__);
1784 1782
@@ -1972,8 +1970,8 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr,
1972 "set using ifconfig\n", dev->name); 1970 "set using ifconfig\n", dev->name);
1973 } else { 1971 } else {
1974 /* Print the Ethernet address */ 1972 /* Print the Ethernet address */
1975 printk("%s: Ethernet addr: %s\n", 1973 printk("%s: Ethernet addr: %pM\n",
1976 dev->name, print_mac(mac, dev->dev_addr)); 1974 dev->name, dev->dev_addr);
1977 } 1975 }
1978 1976
1979 if (lp->phy_type == 0) { 1977 if (lp->phy_type == 0) {
@@ -2126,7 +2124,7 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
2126 * 0 --> there is a device 2124 * 0 --> there is a device
2127 * anything else, error 2125 * anything else, error
2128 */ 2126 */
2129static int smc_drv_probe(struct platform_device *pdev) 2127static int __init smc_drv_probe(struct platform_device *pdev)
2130{ 2128{
2131 struct smc91x_platdata *pd = pdev->dev.platform_data; 2129 struct smc91x_platdata *pd = pdev->dev.platform_data;
2132 struct smc_local *lp; 2130 struct smc_local *lp;
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
new file mode 100644
index 000000000000..fe517880fc97
--- /dev/null
+++ b/drivers/net/smsc911x.c
@@ -0,0 +1,2091 @@
1/***************************************************************************
2 *
3 * Copyright (C) 2004-2008 SMSC
4 * Copyright (C) 2005-2008 ARM
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 ***************************************************************************
21 * Rewritten, heavily based on smsc911x simple driver by SMSC.
22 * Partly uses io macros from smc91x.c by Nicolas Pitre
23 *
24 * Supported devices:
25 * LAN9115, LAN9116, LAN9117, LAN9118
26 * LAN9215, LAN9216, LAN9217, LAN9218
27 * LAN9210, LAN9211
28 * LAN9220, LAN9221
29 *
30 */
31
32#include <linux/crc32.h>
33#include <linux/delay.h>
34#include <linux/errno.h>
35#include <linux/etherdevice.h>
36#include <linux/ethtool.h>
37#include <linux/init.h>
38#include <linux/ioport.h>
39#include <linux/kernel.h>
40#include <linux/module.h>
41#include <linux/netdevice.h>
42#include <linux/platform_device.h>
43#include <linux/sched.h>
44#include <linux/slab.h>
45#include <linux/timer.h>
46#include <linux/version.h>
47#include <linux/bug.h>
48#include <linux/bitops.h>
49#include <linux/irq.h>
50#include <linux/io.h>
51#include <linux/phy.h>
52#include <linux/smsc911x.h>
53#include "smsc911x.h"
54
55#define SMSC_CHIPNAME "smsc911x"
56#define SMSC_MDIONAME "smsc911x-mdio"
57#define SMSC_DRV_VERSION "2008-10-21"
58
59MODULE_LICENSE("GPL");
60MODULE_VERSION(SMSC_DRV_VERSION);
61
62#if USE_DEBUG > 0
63static int debug = 16;
64#else
65static int debug = 3;
66#endif
67
68module_param(debug, int, 0);
69MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
70
71struct smsc911x_data {
72 void __iomem *ioaddr;
73
74 unsigned int idrev;
75
76 /* used to decide which workarounds apply */
77 unsigned int generation;
78
79 /* device configuration (copied from platform_data during probe) */
80 unsigned int irq_polarity;
81 unsigned int irq_type;
82 phy_interface_t phy_interface;
83
84 /* This needs to be acquired before calling any of below:
85 * smsc911x_mac_read(), smsc911x_mac_write()
86 */
87 spinlock_t mac_lock;
88
89#if (!SMSC_CAN_USE_32BIT)
90 /* spinlock to ensure 16-bit accesses are serialised */
91 spinlock_t dev_lock;
92#endif
93
94 struct phy_device *phy_dev;
95 struct mii_bus *mii_bus;
96 int phy_irq[PHY_MAX_ADDR];
97 unsigned int using_extphy;
98 int last_duplex;
99 int last_carrier;
100
101 u32 msg_enable;
102 unsigned int gpio_setting;
103 unsigned int gpio_orig_setting;
104 struct net_device *dev;
105 struct napi_struct napi;
106
107 unsigned int software_irq_signal;
108
109#ifdef USE_PHY_WORK_AROUND
110#define MIN_PACKET_SIZE (64)
111 char loopback_tx_pkt[MIN_PACKET_SIZE];
112 char loopback_rx_pkt[MIN_PACKET_SIZE];
113 unsigned int resetcount;
114#endif
115
116 /* Members for Multicast filter workaround */
117 unsigned int multicast_update_pending;
118 unsigned int set_bits_mask;
119 unsigned int clear_bits_mask;
120 unsigned int hashhi;
121 unsigned int hashlo;
122};
123
124#if SMSC_CAN_USE_32BIT
125
126static inline u32 smsc911x_reg_read(struct smsc911x_data *pdata, u32 reg)
127{
128 return readl(pdata->ioaddr + reg);
129}
130
131static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg,
132 u32 val)
133{
134 writel(val, pdata->ioaddr + reg);
135}
136
137/* Writes a packet to the TX_DATA_FIFO */
138static inline void
139smsc911x_tx_writefifo(struct smsc911x_data *pdata, unsigned int *buf,
140 unsigned int wordcount)
141{
142 writesl(pdata->ioaddr + TX_DATA_FIFO, buf, wordcount);
143}
144
145/* Reads a packet out of the RX_DATA_FIFO */
146static inline void
147smsc911x_rx_readfifo(struct smsc911x_data *pdata, unsigned int *buf,
148 unsigned int wordcount)
149{
150 readsl(pdata->ioaddr + RX_DATA_FIFO, buf, wordcount);
151}
152
153#else /* SMSC_CAN_USE_32BIT */
154
155/* These 16-bit access functions are significantly slower, due to the locking
156 * necessary. If your bus hardware can be configured to do this for you
157 * (in response to a single 32-bit operation from software), you should use
158 * the 32-bit access functions instead. */
159
160static inline u32 smsc911x_reg_read(struct smsc911x_data *pdata, u32 reg)
161{
162 unsigned long flags;
163 u32 data;
164
165 /* these two 16-bit reads must be performed consecutively, so must
166 * not be interrupted by our own ISR (which would start another
167 * read operation) */
168 spin_lock_irqsave(&pdata->dev_lock, flags);
169 data = ((readw(pdata->ioaddr + reg) & 0xFFFF) |
170 ((readw(pdata->ioaddr + reg + 2) & 0xFFFF) << 16));
171 spin_unlock_irqrestore(&pdata->dev_lock, flags);
172
173 return data;
174}
175
176static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg,
177 u32 val)
178{
179 unsigned long flags;
180
181 /* these two 16-bit writes must be performed consecutively, so must
182 * not be interrupted by our own ISR (which would start another
183 * read operation) */
184 spin_lock_irqsave(&pdata->dev_lock, flags);
185 writew(val & 0xFFFF, pdata->ioaddr + reg);
186 writew((val >> 16) & 0xFFFF, pdata->ioaddr + reg + 2);
187 spin_unlock_irqrestore(&pdata->dev_lock, flags);
188}
189
190/* Writes a packet to the TX_DATA_FIFO */
191static inline void
192smsc911x_tx_writefifo(struct smsc911x_data *pdata, unsigned int *buf,
193 unsigned int wordcount)
194{
195 while (wordcount--)
196 smsc911x_reg_write(pdata, TX_DATA_FIFO, *buf++);
197}
198
199/* Reads a packet out of the RX_DATA_FIFO */
200static inline void
201smsc911x_rx_readfifo(struct smsc911x_data *pdata, unsigned int *buf,
202 unsigned int wordcount)
203{
204 while (wordcount--)
205 *buf++ = smsc911x_reg_read(pdata, RX_DATA_FIFO);
206}
207
208#endif /* SMSC_CAN_USE_32BIT */
209
210/* waits for MAC not busy, with timeout. Only called by smsc911x_mac_read
211 * and smsc911x_mac_write, so assumes mac_lock is held */
212static int smsc911x_mac_complete(struct smsc911x_data *pdata)
213{
214 int i;
215 u32 val;
216
217 SMSC_ASSERT_MAC_LOCK(pdata);
218
219 for (i = 0; i < 40; i++) {
220 val = smsc911x_reg_read(pdata, MAC_CSR_CMD);
221 if (!(val & MAC_CSR_CMD_CSR_BUSY_))
222 return 0;
223 }
224 SMSC_WARNING(HW, "Timed out waiting for MAC not BUSY. "
225 "MAC_CSR_CMD: 0x%08X", val);
226 return -EIO;
227}
228
229/* Fetches a MAC register value. Assumes mac_lock is acquired */
230static u32 smsc911x_mac_read(struct smsc911x_data *pdata, unsigned int offset)
231{
232 unsigned int temp;
233
234 SMSC_ASSERT_MAC_LOCK(pdata);
235
236 temp = smsc911x_reg_read(pdata, MAC_CSR_CMD);
237 if (unlikely(temp & MAC_CSR_CMD_CSR_BUSY_)) {
238 SMSC_WARNING(HW, "MAC busy at entry");
239 return 0xFFFFFFFF;
240 }
241
242 /* Send the MAC cmd */
243 smsc911x_reg_write(pdata, MAC_CSR_CMD, ((offset & 0xFF) |
244 MAC_CSR_CMD_CSR_BUSY_ | MAC_CSR_CMD_R_NOT_W_));
245
246 /* Workaround for hardware read-after-write restriction */
247 temp = smsc911x_reg_read(pdata, BYTE_TEST);
248
249 /* Wait for the read to complete */
250 if (likely(smsc911x_mac_complete(pdata) == 0))
251 return smsc911x_reg_read(pdata, MAC_CSR_DATA);
252
253 SMSC_WARNING(HW, "MAC busy after read");
254 return 0xFFFFFFFF;
255}
256
257/* Set a mac register, mac_lock must be acquired before calling */
258static void smsc911x_mac_write(struct smsc911x_data *pdata,
259 unsigned int offset, u32 val)
260{
261 unsigned int temp;
262
263 SMSC_ASSERT_MAC_LOCK(pdata);
264
265 temp = smsc911x_reg_read(pdata, MAC_CSR_CMD);
266 if (unlikely(temp & MAC_CSR_CMD_CSR_BUSY_)) {
267 SMSC_WARNING(HW,
268 "smsc911x_mac_write failed, MAC busy at entry");
269 return;
270 }
271
272 /* Send data to write */
273 smsc911x_reg_write(pdata, MAC_CSR_DATA, val);
274
275 /* Write the actual data */
276 smsc911x_reg_write(pdata, MAC_CSR_CMD, ((offset & 0xFF) |
277 MAC_CSR_CMD_CSR_BUSY_));
278
279 /* Workaround for hardware read-after-write restriction */
280 temp = smsc911x_reg_read(pdata, BYTE_TEST);
281
282 /* Wait for the write to complete */
283 if (likely(smsc911x_mac_complete(pdata) == 0))
284 return;
285
286 SMSC_WARNING(HW,
287 "smsc911x_mac_write failed, MAC busy after write");
288}
289
290/* Get a phy register */
291static int smsc911x_mii_read(struct mii_bus *bus, int phyaddr, int regidx)
292{
293 struct smsc911x_data *pdata = (struct smsc911x_data *)bus->priv;
294 unsigned long flags;
295 unsigned int addr;
296 int i, reg;
297
298 spin_lock_irqsave(&pdata->mac_lock, flags);
299
300 /* Confirm MII not busy */
301 if (unlikely(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
302 SMSC_WARNING(HW,
303 "MII is busy in smsc911x_mii_read???");
304 reg = -EIO;
305 goto out;
306 }
307
308 /* Set the address, index & direction (read from PHY) */
309 addr = ((phyaddr & 0x1F) << 11) | ((regidx & 0x1F) << 6);
310 smsc911x_mac_write(pdata, MII_ACC, addr);
311
312 /* Wait for read to complete w/ timeout */
313 for (i = 0; i < 100; i++)
314 if (!(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
315 reg = smsc911x_mac_read(pdata, MII_DATA);
316 goto out;
317 }
318
319 SMSC_WARNING(HW, "Timed out waiting for MII write to finish");
320 reg = -EIO;
321
322out:
323 spin_unlock_irqrestore(&pdata->mac_lock, flags);
324 return reg;
325}
326
327/* Set a phy register */
328static int smsc911x_mii_write(struct mii_bus *bus, int phyaddr, int regidx,
329 u16 val)
330{
331 struct smsc911x_data *pdata = (struct smsc911x_data *)bus->priv;
332 unsigned long flags;
333 unsigned int addr;
334 int i, reg;
335
336 spin_lock_irqsave(&pdata->mac_lock, flags);
337
338 /* Confirm MII not busy */
339 if (unlikely(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
340 SMSC_WARNING(HW,
341 "MII is busy in smsc911x_mii_write???");
342 reg = -EIO;
343 goto out;
344 }
345
346 /* Put the data to write in the MAC */
347 smsc911x_mac_write(pdata, MII_DATA, val);
348
349 /* Set the address, index & direction (write to PHY) */
350 addr = ((phyaddr & 0x1F) << 11) | ((regidx & 0x1F) << 6) |
351 MII_ACC_MII_WRITE_;
352 smsc911x_mac_write(pdata, MII_ACC, addr);
353
354 /* Wait for write to complete w/ timeout */
355 for (i = 0; i < 100; i++)
356 if (!(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
357 reg = 0;
358 goto out;
359 }
360
361 SMSC_WARNING(HW, "Timed out waiting for MII write to finish");
362 reg = -EIO;
363
364out:
365 spin_unlock_irqrestore(&pdata->mac_lock, flags);
366 return reg;
367}
368
369/* Autodetects and initialises external phy for SMSC9115 and SMSC9117 flavors.
370 * If something goes wrong, returns -ENODEV to revert back to internal phy.
371 * Performed at initialisation only, so interrupts are enabled */
372static int smsc911x_phy_initialise_external(struct smsc911x_data *pdata)
373{
374 unsigned int hwcfg = smsc911x_reg_read(pdata, HW_CFG);
375
376 /* External phy is requested, supported, and detected */
377 if (hwcfg & HW_CFG_EXT_PHY_DET_) {
378
379 /* Switch to external phy. Assuming tx and rx are stopped
380 * because smsc911x_phy_initialise is called before
381 * smsc911x_rx_initialise and tx_initialise. */
382
383 /* Disable phy clocks to the MAC */
384 hwcfg &= (~HW_CFG_PHY_CLK_SEL_);
385 hwcfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS_;
386 smsc911x_reg_write(pdata, HW_CFG, hwcfg);
387 udelay(10); /* Enough time for clocks to stop */
388
389 /* Switch to external phy */
390 hwcfg |= HW_CFG_EXT_PHY_EN_;
391 smsc911x_reg_write(pdata, HW_CFG, hwcfg);
392
393 /* Enable phy clocks to the MAC */
394 hwcfg &= (~HW_CFG_PHY_CLK_SEL_);
395 hwcfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY_;
396 smsc911x_reg_write(pdata, HW_CFG, hwcfg);
397 udelay(10); /* Enough time for clocks to restart */
398
399 hwcfg |= HW_CFG_SMI_SEL_;
400 smsc911x_reg_write(pdata, HW_CFG, hwcfg);
401
402 SMSC_TRACE(HW, "Successfully switched to external PHY");
403 pdata->using_extphy = 1;
404 } else {
405 SMSC_WARNING(HW, "No external PHY detected, "
406 "Using internal PHY instead.");
407 /* Use internal phy */
408 return -ENODEV;
409 }
410 return 0;
411}
412
413/* Fetches a tx status out of the status fifo */
414static unsigned int smsc911x_tx_get_txstatus(struct smsc911x_data *pdata)
415{
416 unsigned int result =
417 smsc911x_reg_read(pdata, TX_FIFO_INF) & TX_FIFO_INF_TSUSED_;
418
419 if (result != 0)
420 result = smsc911x_reg_read(pdata, TX_STATUS_FIFO);
421
422 return result;
423}
424
425/* Fetches the next rx status */
426static unsigned int smsc911x_rx_get_rxstatus(struct smsc911x_data *pdata)
427{
428 unsigned int result =
429 smsc911x_reg_read(pdata, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED_;
430
431 if (result != 0)
432 result = smsc911x_reg_read(pdata, RX_STATUS_FIFO);
433
434 return result;
435}
436
437#ifdef USE_PHY_WORK_AROUND
438static int smsc911x_phy_check_loopbackpkt(struct smsc911x_data *pdata)
439{
440 unsigned int tries;
441 u32 wrsz;
442 u32 rdsz;
443 ulong bufp;
444
445 for (tries = 0; tries < 10; tries++) {
446 unsigned int txcmd_a;
447 unsigned int txcmd_b;
448 unsigned int status;
449 unsigned int pktlength;
450 unsigned int i;
451
452 /* Zero-out rx packet memory */
453 memset(pdata->loopback_rx_pkt, 0, MIN_PACKET_SIZE);
454
455 /* Write tx packet to 118 */
456 txcmd_a = (u32)((ulong)pdata->loopback_tx_pkt & 0x03) << 16;
457 txcmd_a |= TX_CMD_A_FIRST_SEG_ | TX_CMD_A_LAST_SEG_;
458 txcmd_a |= MIN_PACKET_SIZE;
459
460 txcmd_b = MIN_PACKET_SIZE << 16 | MIN_PACKET_SIZE;
461
462 smsc911x_reg_write(pdata, TX_DATA_FIFO, txcmd_a);
463 smsc911x_reg_write(pdata, TX_DATA_FIFO, txcmd_b);
464
465 bufp = (ulong)pdata->loopback_tx_pkt & (~0x3);
466 wrsz = MIN_PACKET_SIZE + 3;
467 wrsz += (u32)((ulong)pdata->loopback_tx_pkt & 0x3);
468 wrsz >>= 2;
469
470 smsc911x_tx_writefifo(pdata, (unsigned int *)bufp, wrsz);
471
472 /* Wait till transmit is done */
473 i = 60;
474 do {
475 udelay(5);
476 status = smsc911x_tx_get_txstatus(pdata);
477 } while ((i--) && (!status));
478
479 if (!status) {
480 SMSC_WARNING(HW, "Failed to transmit "
481 "during loopback test");
482 continue;
483 }
484 if (status & TX_STS_ES_) {
485 SMSC_WARNING(HW, "Transmit encountered "
486 "errors during loopback test");
487 continue;
488 }
489
490 /* Wait till receive is done */
491 i = 60;
492 do {
493 udelay(5);
494 status = smsc911x_rx_get_rxstatus(pdata);
495 } while ((i--) && (!status));
496
497 if (!status) {
498 SMSC_WARNING(HW,
499 "Failed to receive during loopback test");
500 continue;
501 }
502 if (status & RX_STS_ES_) {
503 SMSC_WARNING(HW, "Receive encountered "
504 "errors during loopback test");
505 continue;
506 }
507
508 pktlength = ((status & 0x3FFF0000UL) >> 16);
509 bufp = (ulong)pdata->loopback_rx_pkt;
510 rdsz = pktlength + 3;
511 rdsz += (u32)((ulong)pdata->loopback_rx_pkt & 0x3);
512 rdsz >>= 2;
513
514 smsc911x_rx_readfifo(pdata, (unsigned int *)bufp, rdsz);
515
516 if (pktlength != (MIN_PACKET_SIZE + 4)) {
517 SMSC_WARNING(HW, "Unexpected packet size "
518 "during loop back test, size=%d, will retry",
519 pktlength);
520 } else {
521 unsigned int j;
522 int mismatch = 0;
523 for (j = 0; j < MIN_PACKET_SIZE; j++) {
524 if (pdata->loopback_tx_pkt[j]
525 != pdata->loopback_rx_pkt[j]) {
526 mismatch = 1;
527 break;
528 }
529 }
530 if (!mismatch) {
531 SMSC_TRACE(HW, "Successfully verified "
532 "loopback packet");
533 return 0;
534 } else {
535 SMSC_WARNING(HW, "Data mismatch "
536 "during loop back test, will retry");
537 }
538 }
539 }
540
541 return -EIO;
542}
543
544static int smsc911x_phy_reset(struct smsc911x_data *pdata)
545{
546 struct phy_device *phy_dev = pdata->phy_dev;
547 unsigned int temp;
548 unsigned int i = 100000;
549
550 BUG_ON(!phy_dev);
551 BUG_ON(!phy_dev->bus);
552
553 SMSC_TRACE(HW, "Performing PHY BCR Reset");
554 smsc911x_mii_write(phy_dev->bus, phy_dev->addr, MII_BMCR, BMCR_RESET);
555 do {
556 msleep(1);
557 temp = smsc911x_mii_read(phy_dev->bus, phy_dev->addr,
558 MII_BMCR);
559 } while ((i--) && (temp & BMCR_RESET));
560
561 if (temp & BMCR_RESET) {
562 SMSC_WARNING(HW, "PHY reset failed to complete.");
563 return -EIO;
564 }
565 /* Extra delay required because the phy may not be completed with
566 * its reset when BMCR_RESET is cleared. Specs say 256 uS is
567 * enough delay but using 1ms here to be safe */
568 msleep(1);
569
570 return 0;
571}
572
573static int smsc911x_phy_loopbacktest(struct net_device *dev)
574{
575 struct smsc911x_data *pdata = netdev_priv(dev);
576 struct phy_device *phy_dev = pdata->phy_dev;
577 int result = -EIO;
578 unsigned int i, val;
579 unsigned long flags;
580
581 /* Initialise tx packet using broadcast destination address */
582 memset(pdata->loopback_tx_pkt, 0xff, ETH_ALEN);
583
584 /* Use incrementing source address */
585 for (i = 6; i < 12; i++)
586 pdata->loopback_tx_pkt[i] = (char)i;
587
588 /* Set length type field */
589 pdata->loopback_tx_pkt[12] = 0x00;
590 pdata->loopback_tx_pkt[13] = 0x00;
591
592 for (i = 14; i < MIN_PACKET_SIZE; i++)
593 pdata->loopback_tx_pkt[i] = (char)i;
594
595 val = smsc911x_reg_read(pdata, HW_CFG);
596 val &= HW_CFG_TX_FIF_SZ_;
597 val |= HW_CFG_SF_;
598 smsc911x_reg_write(pdata, HW_CFG, val);
599
600 smsc911x_reg_write(pdata, TX_CFG, TX_CFG_TX_ON_);
601 smsc911x_reg_write(pdata, RX_CFG,
602 (u32)((ulong)pdata->loopback_rx_pkt & 0x03) << 8);
603
604 for (i = 0; i < 10; i++) {
605 /* Set PHY to 10/FD, no ANEG, and loopback mode */
606 smsc911x_mii_write(phy_dev->bus, phy_dev->addr, MII_BMCR,
607 BMCR_LOOPBACK | BMCR_FULLDPLX);
608
609 /* Enable MAC tx/rx, FD */
610 spin_lock_irqsave(&pdata->mac_lock, flags);
611 smsc911x_mac_write(pdata, MAC_CR, MAC_CR_FDPX_
612 | MAC_CR_TXEN_ | MAC_CR_RXEN_);
613 spin_unlock_irqrestore(&pdata->mac_lock, flags);
614
615 if (smsc911x_phy_check_loopbackpkt(pdata) == 0) {
616 result = 0;
617 break;
618 }
619 pdata->resetcount++;
620
621 /* Disable MAC rx */
622 spin_lock_irqsave(&pdata->mac_lock, flags);
623 smsc911x_mac_write(pdata, MAC_CR, 0);
624 spin_unlock_irqrestore(&pdata->mac_lock, flags);
625
626 smsc911x_phy_reset(pdata);
627 }
628
629 /* Disable MAC */
630 spin_lock_irqsave(&pdata->mac_lock, flags);
631 smsc911x_mac_write(pdata, MAC_CR, 0);
632 spin_unlock_irqrestore(&pdata->mac_lock, flags);
633
634 /* Cancel PHY loopback mode */
635 smsc911x_mii_write(phy_dev->bus, phy_dev->addr, MII_BMCR, 0);
636
637 smsc911x_reg_write(pdata, TX_CFG, 0);
638 smsc911x_reg_write(pdata, RX_CFG, 0);
639
640 return result;
641}
642#endif /* USE_PHY_WORK_AROUND */
643
644static u8 smsc95xx_resolve_flowctrl_fulldplx(u16 lcladv, u16 rmtadv)
645{
646 u8 cap = 0;
647
648 if (lcladv & ADVERTISE_PAUSE_CAP) {
649 if (lcladv & ADVERTISE_PAUSE_ASYM) {
650 if (rmtadv & LPA_PAUSE_CAP)
651 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
652 else if (rmtadv & LPA_PAUSE_ASYM)
653 cap = FLOW_CTRL_RX;
654 } else {
655 if (rmtadv & LPA_PAUSE_CAP)
656 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
657 }
658 } else if (lcladv & ADVERTISE_PAUSE_ASYM) {
659 if ((rmtadv & LPA_PAUSE_CAP) && (rmtadv & LPA_PAUSE_ASYM))
660 cap = FLOW_CTRL_TX;
661 }
662
663 return cap;
664}
665
666static void smsc911x_phy_update_flowcontrol(struct smsc911x_data *pdata)
667{
668 struct phy_device *phy_dev = pdata->phy_dev;
669 u32 afc = smsc911x_reg_read(pdata, AFC_CFG);
670 u32 flow;
671 unsigned long flags;
672
673 if (phy_dev->duplex == DUPLEX_FULL) {
674 u16 lcladv = phy_read(phy_dev, MII_ADVERTISE);
675 u16 rmtadv = phy_read(phy_dev, MII_LPA);
676 u8 cap = smsc95xx_resolve_flowctrl_fulldplx(lcladv, rmtadv);
677
678 if (cap & FLOW_CTRL_RX)
679 flow = 0xFFFF0002;
680 else
681 flow = 0;
682
683 if (cap & FLOW_CTRL_TX)
684 afc |= 0xF;
685 else
686 afc &= ~0xF;
687
688 SMSC_TRACE(HW, "rx pause %s, tx pause %s",
689 (cap & FLOW_CTRL_RX ? "enabled" : "disabled"),
690 (cap & FLOW_CTRL_TX ? "enabled" : "disabled"));
691 } else {
692 SMSC_TRACE(HW, "half duplex");
693 flow = 0;
694 afc |= 0xF;
695 }
696
697 spin_lock_irqsave(&pdata->mac_lock, flags);
698 smsc911x_mac_write(pdata, FLOW, flow);
699 spin_unlock_irqrestore(&pdata->mac_lock, flags);
700
701 smsc911x_reg_write(pdata, AFC_CFG, afc);
702}
703
704/* Update link mode if anything has changed. Called periodically when the
705 * PHY is in polling mode, even if nothing has changed. */
706static void smsc911x_phy_adjust_link(struct net_device *dev)
707{
708 struct smsc911x_data *pdata = netdev_priv(dev);
709 struct phy_device *phy_dev = pdata->phy_dev;
710 unsigned long flags;
711 int carrier;
712
713 if (phy_dev->duplex != pdata->last_duplex) {
714 unsigned int mac_cr;
715 SMSC_TRACE(HW, "duplex state has changed");
716
717 spin_lock_irqsave(&pdata->mac_lock, flags);
718 mac_cr = smsc911x_mac_read(pdata, MAC_CR);
719 if (phy_dev->duplex) {
720 SMSC_TRACE(HW,
721 "configuring for full duplex mode");
722 mac_cr |= MAC_CR_FDPX_;
723 } else {
724 SMSC_TRACE(HW,
725 "configuring for half duplex mode");
726 mac_cr &= ~MAC_CR_FDPX_;
727 }
728 smsc911x_mac_write(pdata, MAC_CR, mac_cr);
729 spin_unlock_irqrestore(&pdata->mac_lock, flags);
730
731 smsc911x_phy_update_flowcontrol(pdata);
732 pdata->last_duplex = phy_dev->duplex;
733 }
734
735 carrier = netif_carrier_ok(dev);
736 if (carrier != pdata->last_carrier) {
737 SMSC_TRACE(HW, "carrier state has changed");
738 if (carrier) {
739 SMSC_TRACE(HW, "configuring for carrier OK");
740 if ((pdata->gpio_orig_setting & GPIO_CFG_LED1_EN_) &&
741 (!pdata->using_extphy)) {
742 /* Restore orginal GPIO configuration */
743 pdata->gpio_setting = pdata->gpio_orig_setting;
744 smsc911x_reg_write(pdata, GPIO_CFG,
745 pdata->gpio_setting);
746 }
747 } else {
748 SMSC_TRACE(HW, "configuring for no carrier");
749 /* Check global setting that LED1
750 * usage is 10/100 indicator */
751 pdata->gpio_setting = smsc911x_reg_read(pdata,
752 GPIO_CFG);
753 if ((pdata->gpio_setting & GPIO_CFG_LED1_EN_)
754 && (!pdata->using_extphy)) {
755 /* Force 10/100 LED off, after saving
756 * orginal GPIO configuration */
757 pdata->gpio_orig_setting = pdata->gpio_setting;
758
759 pdata->gpio_setting &= ~GPIO_CFG_LED1_EN_;
760 pdata->gpio_setting |= (GPIO_CFG_GPIOBUF0_
761 | GPIO_CFG_GPIODIR0_
762 | GPIO_CFG_GPIOD0_);
763 smsc911x_reg_write(pdata, GPIO_CFG,
764 pdata->gpio_setting);
765 }
766 }
767 pdata->last_carrier = carrier;
768 }
769}
770
771static int smsc911x_mii_probe(struct net_device *dev)
772{
773 struct smsc911x_data *pdata = netdev_priv(dev);
774 struct phy_device *phydev = NULL;
775 int phy_addr;
776
777 /* find the first phy */
778 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
779 if (pdata->mii_bus->phy_map[phy_addr]) {
780 phydev = pdata->mii_bus->phy_map[phy_addr];
781 SMSC_TRACE(PROBE, "PHY %d: addr %d, phy_id 0x%08X",
782 phy_addr, phydev->addr, phydev->phy_id);
783 break;
784 }
785 }
786
787 if (!phydev) {
788 pr_err("%s: no PHY found\n", dev->name);
789 return -ENODEV;
790 }
791
792 phydev = phy_connect(dev, phydev->dev.bus_id,
793 &smsc911x_phy_adjust_link, 0, pdata->phy_interface);
794
795 if (IS_ERR(phydev)) {
796 pr_err("%s: Could not attach to PHY\n", dev->name);
797 return PTR_ERR(phydev);
798 }
799
800 pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
801 dev->name, phydev->drv->name, phydev->dev.bus_id, phydev->irq);
802
803 /* mask with MAC supported features */
804 phydev->supported &= (PHY_BASIC_FEATURES | SUPPORTED_Pause |
805 SUPPORTED_Asym_Pause);
806 phydev->advertising = phydev->supported;
807
808 pdata->phy_dev = phydev;
809 pdata->last_duplex = -1;
810 pdata->last_carrier = -1;
811
812#ifdef USE_PHY_WORK_AROUND
813 if (smsc911x_phy_loopbacktest(dev) < 0) {
814 SMSC_WARNING(HW, "Failed Loop Back Test");
815 return -ENODEV;
816 }
817 SMSC_TRACE(HW, "Passed Loop Back Test");
818#endif /* USE_PHY_WORK_AROUND */
819
820 SMSC_TRACE(HW, "phy initialised succesfully");
821 return 0;
822}
823
824static int __devinit smsc911x_mii_init(struct platform_device *pdev,
825 struct net_device *dev)
826{
827 struct smsc911x_data *pdata = netdev_priv(dev);
828 int err = -ENXIO, i;
829
830 pdata->mii_bus = mdiobus_alloc();
831 if (!pdata->mii_bus) {
832 err = -ENOMEM;
833 goto err_out_1;
834 }
835
836 pdata->mii_bus->name = SMSC_MDIONAME;
837 snprintf(pdata->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id);
838 pdata->mii_bus->priv = pdata;
839 pdata->mii_bus->read = smsc911x_mii_read;
840 pdata->mii_bus->write = smsc911x_mii_write;
841 pdata->mii_bus->irq = pdata->phy_irq;
842 for (i = 0; i < PHY_MAX_ADDR; ++i)
843 pdata->mii_bus->irq[i] = PHY_POLL;
844
845 pdata->mii_bus->parent = &pdev->dev;
846 dev_set_drvdata(&pdev->dev, &pdata->mii_bus);
847
848 pdata->using_extphy = 0;
849
850 switch (pdata->idrev & 0xFFFF0000) {
851 case 0x01170000:
852 case 0x01150000:
853 case 0x117A0000:
854 case 0x115A0000:
855 /* External PHY supported, try to autodetect */
856 if (smsc911x_phy_initialise_external(pdata) < 0) {
857 SMSC_TRACE(HW, "No external PHY detected, "
858 "using internal PHY");
859 }
860 break;
861 default:
862 SMSC_TRACE(HW, "External PHY is not supported, "
863 "using internal PHY");
864 break;
865 }
866
867 if (!pdata->using_extphy) {
868 /* Mask all PHYs except ID 1 (internal) */
869 pdata->mii_bus->phy_mask = ~(1 << 1);
870 }
871
872 if (mdiobus_register(pdata->mii_bus)) {
873 SMSC_WARNING(PROBE, "Error registering mii bus");
874 goto err_out_free_bus_2;
875 }
876
877 if (smsc911x_mii_probe(dev) < 0) {
878 SMSC_WARNING(PROBE, "Error registering mii bus");
879 goto err_out_unregister_bus_3;
880 }
881
882 return 0;
883
884err_out_unregister_bus_3:
885 mdiobus_unregister(pdata->mii_bus);
886err_out_free_bus_2:
887 mdiobus_free(pdata->mii_bus);
888err_out_1:
889 return err;
890}
891
892/* Gets the number of tx statuses in the fifo */
893static unsigned int smsc911x_tx_get_txstatcount(struct smsc911x_data *pdata)
894{
895 return (smsc911x_reg_read(pdata, TX_FIFO_INF)
896 & TX_FIFO_INF_TSUSED_) >> 16;
897}
898
899/* Reads tx statuses and increments counters where necessary */
900static void smsc911x_tx_update_txcounters(struct net_device *dev)
901{
902 struct smsc911x_data *pdata = netdev_priv(dev);
903 unsigned int tx_stat;
904
905 while ((tx_stat = smsc911x_tx_get_txstatus(pdata)) != 0) {
906 if (unlikely(tx_stat & 0x80000000)) {
907 /* In this driver the packet tag is used as the packet
908 * length. Since a packet length can never reach the
909 * size of 0x8000, this bit is reserved. It is worth
910 * noting that the "reserved bit" in the warning above
911 * does not reference a hardware defined reserved bit
912 * but rather a driver defined one.
913 */
914 SMSC_WARNING(HW,
915 "Packet tag reserved bit is high");
916 } else {
917 if (unlikely(tx_stat & 0x00008000)) {
918 dev->stats.tx_errors++;
919 } else {
920 dev->stats.tx_packets++;
921 dev->stats.tx_bytes += (tx_stat >> 16);
922 }
923 if (unlikely(tx_stat & 0x00000100)) {
924 dev->stats.collisions += 16;
925 dev->stats.tx_aborted_errors += 1;
926 } else {
927 dev->stats.collisions +=
928 ((tx_stat >> 3) & 0xF);
929 }
930 if (unlikely(tx_stat & 0x00000800))
931 dev->stats.tx_carrier_errors += 1;
932 if (unlikely(tx_stat & 0x00000200)) {
933 dev->stats.collisions++;
934 dev->stats.tx_aborted_errors++;
935 }
936 }
937 }
938}
939
940/* Increments the Rx error counters */
941static void
942smsc911x_rx_counterrors(struct net_device *dev, unsigned int rxstat)
943{
944 int crc_err = 0;
945
946 if (unlikely(rxstat & 0x00008000)) {
947 dev->stats.rx_errors++;
948 if (unlikely(rxstat & 0x00000002)) {
949 dev->stats.rx_crc_errors++;
950 crc_err = 1;
951 }
952 }
953 if (likely(!crc_err)) {
954 if (unlikely((rxstat & 0x00001020) == 0x00001020)) {
955 /* Frame type indicates length,
956 * and length error is set */
957 dev->stats.rx_length_errors++;
958 }
959 if (rxstat & RX_STS_MCAST_)
960 dev->stats.multicast++;
961 }
962}
963
964/* Quickly dumps bad packets */
965static void
966smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsigned int pktbytes)
967{
968 unsigned int pktwords = (pktbytes + NET_IP_ALIGN + 3) >> 2;
969
970 if (likely(pktwords >= 4)) {
971 unsigned int timeout = 500;
972 unsigned int val;
973 smsc911x_reg_write(pdata, RX_DP_CTRL, RX_DP_CTRL_RX_FFWD_);
974 do {
975 udelay(1);
976 val = smsc911x_reg_read(pdata, RX_DP_CTRL);
977 } while (timeout-- && (val & RX_DP_CTRL_RX_FFWD_));
978
979 if (unlikely(timeout == 0))
980 SMSC_WARNING(HW, "Timed out waiting for "
981 "RX FFWD to finish, RX_DP_CTRL: 0x%08X", val);
982 } else {
983 unsigned int temp;
984 while (pktwords--)
985 temp = smsc911x_reg_read(pdata, RX_DATA_FIFO);
986 }
987}
988
989/* NAPI poll function */
990static int smsc911x_poll(struct napi_struct *napi, int budget)
991{
992 struct smsc911x_data *pdata =
993 container_of(napi, struct smsc911x_data, napi);
994 struct net_device *dev = pdata->dev;
995 int npackets = 0;
996
997 while (likely(netif_running(dev)) && (npackets < budget)) {
998 unsigned int pktlength;
999 unsigned int pktwords;
1000 struct sk_buff *skb;
1001 unsigned int rxstat = smsc911x_rx_get_rxstatus(pdata);
1002
1003 if (!rxstat) {
1004 unsigned int temp;
1005 /* We processed all packets available. Tell NAPI it can
1006 * stop polling then re-enable rx interrupts */
1007 smsc911x_reg_write(pdata, INT_STS, INT_STS_RSFL_);
1008 netif_rx_complete(dev, napi);
1009 temp = smsc911x_reg_read(pdata, INT_EN);
1010 temp |= INT_EN_RSFL_EN_;
1011 smsc911x_reg_write(pdata, INT_EN, temp);
1012 break;
1013 }
1014
1015 /* Count packet for NAPI scheduling, even if it has an error.
1016 * Error packets still require cycles to discard */
1017 npackets++;
1018
1019 pktlength = ((rxstat & 0x3FFF0000) >> 16);
1020 pktwords = (pktlength + NET_IP_ALIGN + 3) >> 2;
1021 smsc911x_rx_counterrors(dev, rxstat);
1022
1023 if (unlikely(rxstat & RX_STS_ES_)) {
1024 SMSC_WARNING(RX_ERR,
1025 "Discarding packet with error bit set");
1026 /* Packet has an error, discard it and continue with
1027 * the next */
1028 smsc911x_rx_fastforward(pdata, pktwords);
1029 dev->stats.rx_dropped++;
1030 continue;
1031 }
1032
1033 skb = netdev_alloc_skb(dev, pktlength + NET_IP_ALIGN);
1034 if (unlikely(!skb)) {
1035 SMSC_WARNING(RX_ERR,
1036 "Unable to allocate skb for rx packet");
1037 /* Drop the packet and stop this polling iteration */
1038 smsc911x_rx_fastforward(pdata, pktwords);
1039 dev->stats.rx_dropped++;
1040 break;
1041 }
1042
1043 skb->data = skb->head;
1044 skb_reset_tail_pointer(skb);
1045
1046 /* Align IP on 16B boundary */
1047 skb_reserve(skb, NET_IP_ALIGN);
1048 skb_put(skb, pktlength - 4);
1049 smsc911x_rx_readfifo(pdata, (unsigned int *)skb->head,
1050 pktwords);
1051 skb->protocol = eth_type_trans(skb, dev);
1052 skb->ip_summed = CHECKSUM_NONE;
1053 netif_receive_skb(skb);
1054
1055 /* Update counters */
1056 dev->stats.rx_packets++;
1057 dev->stats.rx_bytes += (pktlength - 4);
1058 dev->last_rx = jiffies;
1059 }
1060
1061 /* Return total received packets */
1062 return npackets;
1063}
1064
1065/* Returns hash bit number for given MAC address
1066 * Example:
1067 * 01 00 5E 00 00 01 -> returns bit number 31 */
1068static unsigned int smsc911x_hash(char addr[ETH_ALEN])
1069{
1070 return (ether_crc(ETH_ALEN, addr) >> 26) & 0x3f;
1071}
1072
1073static void smsc911x_rx_multicast_update(struct smsc911x_data *pdata)
1074{
1075 /* Performs the multicast & mac_cr update. This is called when
1076 * safe on the current hardware, and with the mac_lock held */
1077 unsigned int mac_cr;
1078
1079 SMSC_ASSERT_MAC_LOCK(pdata);
1080
1081 mac_cr = smsc911x_mac_read(pdata, MAC_CR);
1082 mac_cr |= pdata->set_bits_mask;
1083 mac_cr &= ~(pdata->clear_bits_mask);
1084 smsc911x_mac_write(pdata, MAC_CR, mac_cr);
1085 smsc911x_mac_write(pdata, HASHH, pdata->hashhi);
1086 smsc911x_mac_write(pdata, HASHL, pdata->hashlo);
1087 SMSC_TRACE(HW, "maccr 0x%08X, HASHH 0x%08X, HASHL 0x%08X",
1088 mac_cr, pdata->hashhi, pdata->hashlo);
1089}
1090
1091static void smsc911x_rx_multicast_update_workaround(struct smsc911x_data *pdata)
1092{
1093 unsigned int mac_cr;
1094
1095 /* This function is only called for older LAN911x devices
1096 * (revA or revB), where MAC_CR, HASHH and HASHL should not
1097 * be modified during Rx - newer devices immediately update the
1098 * registers.
1099 *
1100 * This is called from interrupt context */
1101
1102 spin_lock(&pdata->mac_lock);
1103
1104 /* Check Rx has stopped */
1105 if (smsc911x_mac_read(pdata, MAC_CR) & MAC_CR_RXEN_)
1106 SMSC_WARNING(DRV, "Rx not stopped");
1107
1108 /* Perform the update - safe to do now Rx has stopped */
1109 smsc911x_rx_multicast_update(pdata);
1110
1111 /* Re-enable Rx */
1112 mac_cr = smsc911x_mac_read(pdata, MAC_CR);
1113 mac_cr |= MAC_CR_RXEN_;
1114 smsc911x_mac_write(pdata, MAC_CR, mac_cr);
1115
1116 pdata->multicast_update_pending = 0;
1117
1118 spin_unlock(&pdata->mac_lock);
1119}
1120
1121static int smsc911x_soft_reset(struct smsc911x_data *pdata)
1122{
1123 unsigned int timeout;
1124 unsigned int temp;
1125
1126 /* Reset the LAN911x */
1127 smsc911x_reg_write(pdata, HW_CFG, HW_CFG_SRST_);
1128 timeout = 10;
1129 do {
1130 udelay(10);
1131 temp = smsc911x_reg_read(pdata, HW_CFG);
1132 } while ((--timeout) && (temp & HW_CFG_SRST_));
1133
1134 if (unlikely(temp & HW_CFG_SRST_)) {
1135 SMSC_WARNING(DRV, "Failed to complete reset");
1136 return -EIO;
1137 }
1138 return 0;
1139}
1140
1141/* Sets the device MAC address to dev_addr, called with mac_lock held */
1142static void
1143smsc911x_set_mac_address(struct smsc911x_data *pdata, u8 dev_addr[6])
1144{
1145 u32 mac_high16 = (dev_addr[5] << 8) | dev_addr[4];
1146 u32 mac_low32 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
1147 (dev_addr[1] << 8) | dev_addr[0];
1148
1149 SMSC_ASSERT_MAC_LOCK(pdata);
1150
1151 smsc911x_mac_write(pdata, ADDRH, mac_high16);
1152 smsc911x_mac_write(pdata, ADDRL, mac_low32);
1153}
1154
1155static int smsc911x_open(struct net_device *dev)
1156{
1157 struct smsc911x_data *pdata = netdev_priv(dev);
1158 unsigned int timeout;
1159 unsigned int temp;
1160 unsigned int intcfg;
1161
1162 /* if the phy is not yet registered, retry later*/
1163 if (!pdata->phy_dev) {
1164 SMSC_WARNING(HW, "phy_dev is NULL");
1165 return -EAGAIN;
1166 }
1167
1168 if (!is_valid_ether_addr(dev->dev_addr)) {
1169 SMSC_WARNING(HW, "dev_addr is not a valid MAC address");
1170 return -EADDRNOTAVAIL;
1171 }
1172
1173 /* Reset the LAN911x */
1174 if (smsc911x_soft_reset(pdata)) {
1175 SMSC_WARNING(HW, "soft reset failed");
1176 return -EIO;
1177 }
1178
1179 smsc911x_reg_write(pdata, HW_CFG, 0x00050000);
1180 smsc911x_reg_write(pdata, AFC_CFG, 0x006E3740);
1181
1182 /* Make sure EEPROM has finished loading before setting GPIO_CFG */
1183 timeout = 50;
1184 while ((timeout--) &&
1185 (smsc911x_reg_read(pdata, E2P_CMD) & E2P_CMD_EPC_BUSY_)) {
1186 udelay(10);
1187 }
1188
1189 if (unlikely(timeout == 0))
1190 SMSC_WARNING(IFUP,
1191 "Timed out waiting for EEPROM busy bit to clear");
1192
1193 smsc911x_reg_write(pdata, GPIO_CFG, 0x70070000);
1194
1195 /* The soft reset above cleared the device's MAC address,
1196 * restore it from local copy (set in probe) */
1197 spin_lock_irq(&pdata->mac_lock);
1198 smsc911x_set_mac_address(pdata, dev->dev_addr);
1199 spin_unlock_irq(&pdata->mac_lock);
1200
1201 /* Initialise irqs, but leave all sources disabled */
1202 smsc911x_reg_write(pdata, INT_EN, 0);
1203 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF);
1204
1205 /* Set interrupt deassertion to 100uS */
1206 intcfg = ((10 << 24) | INT_CFG_IRQ_EN_);
1207
1208 if (pdata->irq_polarity) {
1209 SMSC_TRACE(IFUP, "irq polarity: active high");
1210 intcfg |= INT_CFG_IRQ_POL_;
1211 } else {
1212 SMSC_TRACE(IFUP, "irq polarity: active low");
1213 }
1214
1215 if (pdata->irq_type) {
1216 SMSC_TRACE(IFUP, "irq type: push-pull");
1217 intcfg |= INT_CFG_IRQ_TYPE_;
1218 } else {
1219 SMSC_TRACE(IFUP, "irq type: open drain");
1220 }
1221
1222 smsc911x_reg_write(pdata, INT_CFG, intcfg);
1223
1224 SMSC_TRACE(IFUP, "Testing irq handler using IRQ %d", dev->irq);
1225 pdata->software_irq_signal = 0;
1226 smp_wmb();
1227
1228 temp = smsc911x_reg_read(pdata, INT_EN);
1229 temp |= INT_EN_SW_INT_EN_;
1230 smsc911x_reg_write(pdata, INT_EN, temp);
1231
1232 timeout = 1000;
1233 while (timeout--) {
1234 if (pdata->software_irq_signal)
1235 break;
1236 msleep(1);
1237 }
1238
1239 if (!pdata->software_irq_signal) {
1240 dev_warn(&dev->dev, "ISR failed signaling test (IRQ %d)\n",
1241 dev->irq);
1242 return -ENODEV;
1243 }
1244 SMSC_TRACE(IFUP, "IRQ handler passed test using IRQ %d", dev->irq);
1245
1246 dev_info(&dev->dev, "SMSC911x/921x identified at %#08lx, IRQ: %d\n",
1247 (unsigned long)pdata->ioaddr, dev->irq);
1248
1249 /* Bring the PHY up */
1250 phy_start(pdata->phy_dev);
1251
1252 temp = smsc911x_reg_read(pdata, HW_CFG);
1253 /* Preserve TX FIFO size and external PHY configuration */
1254 temp &= (HW_CFG_TX_FIF_SZ_|0x00000FFF);
1255 temp |= HW_CFG_SF_;
1256 smsc911x_reg_write(pdata, HW_CFG, temp);
1257
1258 temp = smsc911x_reg_read(pdata, FIFO_INT);
1259 temp |= FIFO_INT_TX_AVAIL_LEVEL_;
1260 temp &= ~(FIFO_INT_RX_STS_LEVEL_);
1261 smsc911x_reg_write(pdata, FIFO_INT, temp);
1262
1263 /* set RX Data offset to 2 bytes for alignment */
1264 smsc911x_reg_write(pdata, RX_CFG, (2 << 8));
1265
1266 /* enable NAPI polling before enabling RX interrupts */
1267 napi_enable(&pdata->napi);
1268
1269 temp = smsc911x_reg_read(pdata, INT_EN);
1270 temp |= (INT_EN_TDFA_EN_ | INT_EN_RSFL_EN_);
1271 smsc911x_reg_write(pdata, INT_EN, temp);
1272
1273 spin_lock_irq(&pdata->mac_lock);
1274 temp = smsc911x_mac_read(pdata, MAC_CR);
1275 temp |= (MAC_CR_TXEN_ | MAC_CR_RXEN_ | MAC_CR_HBDIS_);
1276 smsc911x_mac_write(pdata, MAC_CR, temp);
1277 spin_unlock_irq(&pdata->mac_lock);
1278
1279 smsc911x_reg_write(pdata, TX_CFG, TX_CFG_TX_ON_);
1280
1281 netif_start_queue(dev);
1282 return 0;
1283}
1284
1285/* Entry point for stopping the interface */
1286static int smsc911x_stop(struct net_device *dev)
1287{
1288 struct smsc911x_data *pdata = netdev_priv(dev);
1289 unsigned int temp;
1290
1291 BUG_ON(!pdata->phy_dev);
1292
1293 /* Disable all device interrupts */
1294 temp = smsc911x_reg_read(pdata, INT_CFG);
1295 temp &= ~INT_CFG_IRQ_EN_;
1296 smsc911x_reg_write(pdata, INT_CFG, temp);
1297
1298 /* Stop Tx and Rx polling */
1299 netif_stop_queue(dev);
1300 napi_disable(&pdata->napi);
1301
1302 /* At this point all Rx and Tx activity is stopped */
1303 dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
1304 smsc911x_tx_update_txcounters(dev);
1305
1306 /* Bring the PHY down */
1307 phy_stop(pdata->phy_dev);
1308
1309 SMSC_TRACE(IFDOWN, "Interface stopped");
1310 return 0;
1311}
1312
1313/* Entry point for transmitting a packet */
1314static int smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1315{
1316 struct smsc911x_data *pdata = netdev_priv(dev);
1317 unsigned int freespace;
1318 unsigned int tx_cmd_a;
1319 unsigned int tx_cmd_b;
1320 unsigned int temp;
1321 u32 wrsz;
1322 ulong bufp;
1323
1324 freespace = smsc911x_reg_read(pdata, TX_FIFO_INF) & TX_FIFO_INF_TDFREE_;
1325
1326 if (unlikely(freespace < TX_FIFO_LOW_THRESHOLD))
1327 SMSC_WARNING(TX_ERR,
1328 "Tx data fifo low, space available: %d", freespace);
1329
1330 /* Word alignment adjustment */
1331 tx_cmd_a = (u32)((ulong)skb->data & 0x03) << 16;
1332 tx_cmd_a |= TX_CMD_A_FIRST_SEG_ | TX_CMD_A_LAST_SEG_;
1333 tx_cmd_a |= (unsigned int)skb->len;
1334
1335 tx_cmd_b = ((unsigned int)skb->len) << 16;
1336 tx_cmd_b |= (unsigned int)skb->len;
1337
1338 smsc911x_reg_write(pdata, TX_DATA_FIFO, tx_cmd_a);
1339 smsc911x_reg_write(pdata, TX_DATA_FIFO, tx_cmd_b);
1340
1341 bufp = (ulong)skb->data & (~0x3);
1342 wrsz = (u32)skb->len + 3;
1343 wrsz += (u32)((ulong)skb->data & 0x3);
1344 wrsz >>= 2;
1345
1346 smsc911x_tx_writefifo(pdata, (unsigned int *)bufp, wrsz);
1347 freespace -= (skb->len + 32);
1348 dev_kfree_skb(skb);
1349 dev->trans_start = jiffies;
1350
1351 if (unlikely(smsc911x_tx_get_txstatcount(pdata) >= 30))
1352 smsc911x_tx_update_txcounters(dev);
1353
1354 if (freespace < TX_FIFO_LOW_THRESHOLD) {
1355 netif_stop_queue(dev);
1356 temp = smsc911x_reg_read(pdata, FIFO_INT);
1357 temp &= 0x00FFFFFF;
1358 temp |= 0x32000000;
1359 smsc911x_reg_write(pdata, FIFO_INT, temp);
1360 }
1361
1362 return NETDEV_TX_OK;
1363}
1364
1365/* Entry point for getting status counters */
1366static struct net_device_stats *smsc911x_get_stats(struct net_device *dev)
1367{
1368 struct smsc911x_data *pdata = netdev_priv(dev);
1369 smsc911x_tx_update_txcounters(dev);
1370 dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
1371 return &dev->stats;
1372}
1373
1374/* Entry point for setting addressing modes */
1375static void smsc911x_set_multicast_list(struct net_device *dev)
1376{
1377 struct smsc911x_data *pdata = netdev_priv(dev);
1378 unsigned long flags;
1379
1380 if (dev->flags & IFF_PROMISC) {
1381 /* Enabling promiscuous mode */
1382 pdata->set_bits_mask = MAC_CR_PRMS_;
1383 pdata->clear_bits_mask = (MAC_CR_MCPAS_ | MAC_CR_HPFILT_);
1384 pdata->hashhi = 0;
1385 pdata->hashlo = 0;
1386 } else if (dev->flags & IFF_ALLMULTI) {
1387 /* Enabling all multicast mode */
1388 pdata->set_bits_mask = MAC_CR_MCPAS_;
1389 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_HPFILT_);
1390 pdata->hashhi = 0;
1391 pdata->hashlo = 0;
1392 } else if (dev->mc_count > 0) {
1393 /* Enabling specific multicast addresses */
1394 unsigned int hash_high = 0;
1395 unsigned int hash_low = 0;
1396 unsigned int count = 0;
1397 struct dev_mc_list *mc_list = dev->mc_list;
1398
1399 pdata->set_bits_mask = MAC_CR_HPFILT_;
1400 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_MCPAS_);
1401
1402 while (mc_list) {
1403 count++;
1404 if ((mc_list->dmi_addrlen) == ETH_ALEN) {
1405 unsigned int bitnum =
1406 smsc911x_hash(mc_list->dmi_addr);
1407 unsigned int mask = 0x01 << (bitnum & 0x1F);
1408 if (bitnum & 0x20)
1409 hash_high |= mask;
1410 else
1411 hash_low |= mask;
1412 } else {
1413 SMSC_WARNING(DRV, "dmi_addrlen != 6");
1414 }
1415 mc_list = mc_list->next;
1416 }
1417 if (count != (unsigned int)dev->mc_count)
1418 SMSC_WARNING(DRV, "mc_count != dev->mc_count");
1419
1420 pdata->hashhi = hash_high;
1421 pdata->hashlo = hash_low;
1422 } else {
1423 /* Enabling local MAC address only */
1424 pdata->set_bits_mask = 0;
1425 pdata->clear_bits_mask =
1426 (MAC_CR_PRMS_ | MAC_CR_MCPAS_ | MAC_CR_HPFILT_);
1427 pdata->hashhi = 0;
1428 pdata->hashlo = 0;
1429 }
1430
1431 spin_lock_irqsave(&pdata->mac_lock, flags);
1432
1433 if (pdata->generation <= 1) {
1434 /* Older hardware revision - cannot change these flags while
1435 * receiving data */
1436 if (!pdata->multicast_update_pending) {
1437 unsigned int temp;
1438 SMSC_TRACE(HW, "scheduling mcast update");
1439 pdata->multicast_update_pending = 1;
1440
1441 /* Request the hardware to stop, then perform the
1442 * update when we get an RX_STOP interrupt */
1443 smsc911x_reg_write(pdata, INT_STS, INT_STS_RXSTOP_INT_);
1444 temp = smsc911x_reg_read(pdata, INT_EN);
1445 temp |= INT_EN_RXSTOP_INT_EN_;
1446 smsc911x_reg_write(pdata, INT_EN, temp);
1447
1448 temp = smsc911x_mac_read(pdata, MAC_CR);
1449 temp &= ~(MAC_CR_RXEN_);
1450 smsc911x_mac_write(pdata, MAC_CR, temp);
1451 } else {
1452 /* There is another update pending, this should now
1453 * use the newer values */
1454 }
1455 } else {
1456 /* Newer hardware revision - can write immediately */
1457 smsc911x_rx_multicast_update(pdata);
1458 }
1459
1460 spin_unlock_irqrestore(&pdata->mac_lock, flags);
1461}
1462
1463static irqreturn_t smsc911x_irqhandler(int irq, void *dev_id)
1464{
1465 struct net_device *dev = dev_id;
1466 struct smsc911x_data *pdata = netdev_priv(dev);
1467 u32 intsts = smsc911x_reg_read(pdata, INT_STS);
1468 u32 inten = smsc911x_reg_read(pdata, INT_EN);
1469 int serviced = IRQ_NONE;
1470 u32 temp;
1471
1472 if (unlikely(intsts & inten & INT_STS_SW_INT_)) {
1473 temp = smsc911x_reg_read(pdata, INT_EN);
1474 temp &= (~INT_EN_SW_INT_EN_);
1475 smsc911x_reg_write(pdata, INT_EN, temp);
1476 smsc911x_reg_write(pdata, INT_STS, INT_STS_SW_INT_);
1477 pdata->software_irq_signal = 1;
1478 smp_wmb();
1479 serviced = IRQ_HANDLED;
1480 }
1481
1482 if (unlikely(intsts & inten & INT_STS_RXSTOP_INT_)) {
1483 /* Called when there is a multicast update scheduled and
1484 * it is now safe to complete the update */
1485 SMSC_TRACE(INTR, "RX Stop interrupt");
1486 temp = smsc911x_reg_read(pdata, INT_EN);
1487 temp &= (~INT_EN_RXSTOP_INT_EN_);
1488 smsc911x_reg_write(pdata, INT_EN, temp);
1489 smsc911x_reg_write(pdata, INT_STS, INT_STS_RXSTOP_INT_);
1490 smsc911x_rx_multicast_update_workaround(pdata);
1491 serviced = IRQ_HANDLED;
1492 }
1493
1494 if (intsts & inten & INT_STS_TDFA_) {
1495 temp = smsc911x_reg_read(pdata, FIFO_INT);
1496 temp |= FIFO_INT_TX_AVAIL_LEVEL_;
1497 smsc911x_reg_write(pdata, FIFO_INT, temp);
1498 smsc911x_reg_write(pdata, INT_STS, INT_STS_TDFA_);
1499 netif_wake_queue(dev);
1500 serviced = IRQ_HANDLED;
1501 }
1502
1503 if (unlikely(intsts & inten & INT_STS_RXE_)) {
1504 SMSC_TRACE(INTR, "RX Error interrupt");
1505 smsc911x_reg_write(pdata, INT_STS, INT_STS_RXE_);
1506 serviced = IRQ_HANDLED;
1507 }
1508
1509 if (likely(intsts & inten & INT_STS_RSFL_)) {
1510 if (likely(netif_rx_schedule_prep(dev, &pdata->napi))) {
1511 /* Disable Rx interrupts */
1512 temp = smsc911x_reg_read(pdata, INT_EN);
1513 temp &= (~INT_EN_RSFL_EN_);
1514 smsc911x_reg_write(pdata, INT_EN, temp);
1515 /* Schedule a NAPI poll */
1516 __netif_rx_schedule(dev, &pdata->napi);
1517 } else {
1518 SMSC_WARNING(RX_ERR,
1519 "netif_rx_schedule_prep failed");
1520 }
1521 serviced = IRQ_HANDLED;
1522 }
1523
1524 return serviced;
1525}
1526
1527#ifdef CONFIG_NET_POLL_CONTROLLER
1528void smsc911x_poll_controller(struct net_device *dev)
1529{
1530 disable_irq(dev->irq);
1531 smsc911x_irqhandler(0, dev);
1532 enable_irq(dev->irq);
1533}
1534#endif /* CONFIG_NET_POLL_CONTROLLER */
1535
1536/* Standard ioctls for mii-tool */
1537static int smsc911x_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1538{
1539 struct smsc911x_data *pdata = netdev_priv(dev);
1540
1541 if (!netif_running(dev) || !pdata->phy_dev)
1542 return -EINVAL;
1543
1544 return phy_mii_ioctl(pdata->phy_dev, if_mii(ifr), cmd);
1545}
1546
1547static int
1548smsc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
1549{
1550 struct smsc911x_data *pdata = netdev_priv(dev);
1551
1552 cmd->maxtxpkt = 1;
1553 cmd->maxrxpkt = 1;
1554 return phy_ethtool_gset(pdata->phy_dev, cmd);
1555}
1556
1557static int
1558smsc911x_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
1559{
1560 struct smsc911x_data *pdata = netdev_priv(dev);
1561
1562 return phy_ethtool_sset(pdata->phy_dev, cmd);
1563}
1564
1565static void smsc911x_ethtool_getdrvinfo(struct net_device *dev,
1566 struct ethtool_drvinfo *info)
1567{
1568 strlcpy(info->driver, SMSC_CHIPNAME, sizeof(info->driver));
1569 strlcpy(info->version, SMSC_DRV_VERSION, sizeof(info->version));
1570 strlcpy(info->bus_info, dev->dev.parent->bus_id,
1571 sizeof(info->bus_info));
1572}
1573
1574static int smsc911x_ethtool_nwayreset(struct net_device *dev)
1575{
1576 struct smsc911x_data *pdata = netdev_priv(dev);
1577
1578 return phy_start_aneg(pdata->phy_dev);
1579}
1580
1581static u32 smsc911x_ethtool_getmsglevel(struct net_device *dev)
1582{
1583 struct smsc911x_data *pdata = netdev_priv(dev);
1584 return pdata->msg_enable;
1585}
1586
1587static void smsc911x_ethtool_setmsglevel(struct net_device *dev, u32 level)
1588{
1589 struct smsc911x_data *pdata = netdev_priv(dev);
1590 pdata->msg_enable = level;
1591}
1592
1593static int smsc911x_ethtool_getregslen(struct net_device *dev)
1594{
1595 return (((E2P_DATA - ID_REV) / 4 + 1) + (WUCSR - MAC_CR) + 1 + 32) *
1596 sizeof(u32);
1597}
1598
1599static void
1600smsc911x_ethtool_getregs(struct net_device *dev, struct ethtool_regs *regs,
1601 void *buf)
1602{
1603 struct smsc911x_data *pdata = netdev_priv(dev);
1604 struct phy_device *phy_dev = pdata->phy_dev;
1605 unsigned long flags;
1606 unsigned int i;
1607 unsigned int j = 0;
1608 u32 *data = buf;
1609
1610 regs->version = pdata->idrev;
1611 for (i = ID_REV; i <= E2P_DATA; i += (sizeof(u32)))
1612 data[j++] = smsc911x_reg_read(pdata, i);
1613
1614 for (i = MAC_CR; i <= WUCSR; i++) {
1615 spin_lock_irqsave(&pdata->mac_lock, flags);
1616 data[j++] = smsc911x_mac_read(pdata, i);
1617 spin_unlock_irqrestore(&pdata->mac_lock, flags);
1618 }
1619
1620 for (i = 0; i <= 31; i++)
1621 data[j++] = smsc911x_mii_read(phy_dev->bus, phy_dev->addr, i);
1622}
1623
1624static void smsc911x_eeprom_enable_access(struct smsc911x_data *pdata)
1625{
1626 unsigned int temp = smsc911x_reg_read(pdata, GPIO_CFG);
1627 temp &= ~GPIO_CFG_EEPR_EN_;
1628 smsc911x_reg_write(pdata, GPIO_CFG, temp);
1629 msleep(1);
1630}
1631
1632static int smsc911x_eeprom_send_cmd(struct smsc911x_data *pdata, u32 op)
1633{
1634 int timeout = 100;
1635 u32 e2cmd;
1636
1637 SMSC_TRACE(DRV, "op 0x%08x", op);
1638 if (smsc911x_reg_read(pdata, E2P_CMD) & E2P_CMD_EPC_BUSY_) {
1639 SMSC_WARNING(DRV, "Busy at start");
1640 return -EBUSY;
1641 }
1642
1643 e2cmd = op | E2P_CMD_EPC_BUSY_;
1644 smsc911x_reg_write(pdata, E2P_CMD, e2cmd);
1645
1646 do {
1647 msleep(1);
1648 e2cmd = smsc911x_reg_read(pdata, E2P_CMD);
1649 } while ((e2cmd & E2P_CMD_EPC_BUSY_) && (timeout--));
1650
1651 if (!timeout) {
1652 SMSC_TRACE(DRV, "TIMED OUT");
1653 return -EAGAIN;
1654 }
1655
1656 if (e2cmd & E2P_CMD_EPC_TIMEOUT_) {
1657 SMSC_TRACE(DRV, "Error occured during eeprom operation");
1658 return -EINVAL;
1659 }
1660
1661 return 0;
1662}
1663
1664static int smsc911x_eeprom_read_location(struct smsc911x_data *pdata,
1665 u8 address, u8 *data)
1666{
1667 u32 op = E2P_CMD_EPC_CMD_READ_ | address;
1668 int ret;
1669
1670 SMSC_TRACE(DRV, "address 0x%x", address);
1671 ret = smsc911x_eeprom_send_cmd(pdata, op);
1672
1673 if (!ret)
1674 data[address] = smsc911x_reg_read(pdata, E2P_DATA);
1675
1676 return ret;
1677}
1678
1679static int smsc911x_eeprom_write_location(struct smsc911x_data *pdata,
1680 u8 address, u8 data)
1681{
1682 u32 op = E2P_CMD_EPC_CMD_ERASE_ | address;
1683 int ret;
1684
1685 SMSC_TRACE(DRV, "address 0x%x, data 0x%x", address, data);
1686 ret = smsc911x_eeprom_send_cmd(pdata, op);
1687
1688 if (!ret) {
1689 op = E2P_CMD_EPC_CMD_WRITE_ | address;
1690 smsc911x_reg_write(pdata, E2P_DATA, (u32)data);
1691 ret = smsc911x_eeprom_send_cmd(pdata, op);
1692 }
1693
1694 return ret;
1695}
1696
1697static int smsc911x_ethtool_get_eeprom_len(struct net_device *dev)
1698{
1699 return SMSC911X_EEPROM_SIZE;
1700}
1701
1702static int smsc911x_ethtool_get_eeprom(struct net_device *dev,
1703 struct ethtool_eeprom *eeprom, u8 *data)
1704{
1705 struct smsc911x_data *pdata = netdev_priv(dev);
1706 u8 eeprom_data[SMSC911X_EEPROM_SIZE];
1707 int len;
1708 int i;
1709
1710 smsc911x_eeprom_enable_access(pdata);
1711
1712 len = min(eeprom->len, SMSC911X_EEPROM_SIZE);
1713 for (i = 0; i < len; i++) {
1714 int ret = smsc911x_eeprom_read_location(pdata, i, eeprom_data);
1715 if (ret < 0) {
1716 eeprom->len = 0;
1717 return ret;
1718 }
1719 }
1720
1721 memcpy(data, &eeprom_data[eeprom->offset], len);
1722 eeprom->len = len;
1723 return 0;
1724}
1725
1726static int smsc911x_ethtool_set_eeprom(struct net_device *dev,
1727 struct ethtool_eeprom *eeprom, u8 *data)
1728{
1729 int ret;
1730 struct smsc911x_data *pdata = netdev_priv(dev);
1731
1732 smsc911x_eeprom_enable_access(pdata);
1733 smsc911x_eeprom_send_cmd(pdata, E2P_CMD_EPC_CMD_EWEN_);
1734 ret = smsc911x_eeprom_write_location(pdata, eeprom->offset, *data);
1735 smsc911x_eeprom_send_cmd(pdata, E2P_CMD_EPC_CMD_EWDS_);
1736
1737 /* Single byte write, according to man page */
1738 eeprom->len = 1;
1739
1740 return ret;
1741}
1742
1743static struct ethtool_ops smsc911x_ethtool_ops = {
1744 .get_settings = smsc911x_ethtool_getsettings,
1745 .set_settings = smsc911x_ethtool_setsettings,
1746 .get_link = ethtool_op_get_link,
1747 .get_drvinfo = smsc911x_ethtool_getdrvinfo,
1748 .nway_reset = smsc911x_ethtool_nwayreset,
1749 .get_msglevel = smsc911x_ethtool_getmsglevel,
1750 .set_msglevel = smsc911x_ethtool_setmsglevel,
1751 .get_regs_len = smsc911x_ethtool_getregslen,
1752 .get_regs = smsc911x_ethtool_getregs,
1753 .get_eeprom_len = smsc911x_ethtool_get_eeprom_len,
1754 .get_eeprom = smsc911x_ethtool_get_eeprom,
1755 .set_eeprom = smsc911x_ethtool_set_eeprom,
1756};
1757
1758/* Initializing private device structures, only called from probe */
1759static int __devinit smsc911x_init(struct net_device *dev)
1760{
1761 struct smsc911x_data *pdata = netdev_priv(dev);
1762 unsigned int byte_test;
1763
1764 SMSC_TRACE(PROBE, "Driver Parameters:");
1765 SMSC_TRACE(PROBE, "LAN base: 0x%08lX",
1766 (unsigned long)pdata->ioaddr);
1767 SMSC_TRACE(PROBE, "IRQ: %d", dev->irq);
1768 SMSC_TRACE(PROBE, "PHY will be autodetected.");
1769
1770#if (!SMSC_CAN_USE_32BIT)
1771 spin_lock_init(&pdata->dev_lock);
1772#endif
1773
1774 if (pdata->ioaddr == 0) {
1775 SMSC_WARNING(PROBE, "pdata->ioaddr: 0x00000000");
1776 return -ENODEV;
1777 }
1778
1779 /* Check byte ordering */
1780 byte_test = smsc911x_reg_read(pdata, BYTE_TEST);
1781 SMSC_TRACE(PROBE, "BYTE_TEST: 0x%08X", byte_test);
1782 if (byte_test == 0x43218765) {
1783 SMSC_TRACE(PROBE, "BYTE_TEST looks swapped, "
1784 "applying WORD_SWAP");
1785 smsc911x_reg_write(pdata, WORD_SWAP, 0xffffffff);
1786
1787 /* 1 dummy read of BYTE_TEST is needed after a write to
1788 * WORD_SWAP before its contents are valid */
1789 byte_test = smsc911x_reg_read(pdata, BYTE_TEST);
1790
1791 byte_test = smsc911x_reg_read(pdata, BYTE_TEST);
1792 }
1793
1794 if (byte_test != 0x87654321) {
1795 SMSC_WARNING(DRV, "BYTE_TEST: 0x%08X", byte_test);
1796 if (((byte_test >> 16) & 0xFFFF) == (byte_test & 0xFFFF)) {
1797 SMSC_WARNING(PROBE,
1798 "top 16 bits equal to bottom 16 bits");
1799 SMSC_TRACE(PROBE, "This may mean the chip is set "
1800 "for 32 bit while the bus is reading 16 bit");
1801 }
1802 return -ENODEV;
1803 }
1804
1805 /* Default generation to zero (all workarounds apply) */
1806 pdata->generation = 0;
1807
1808 pdata->idrev = smsc911x_reg_read(pdata, ID_REV);
1809 switch (pdata->idrev & 0xFFFF0000) {
1810 case 0x01180000:
1811 case 0x01170000:
1812 case 0x01160000:
1813 case 0x01150000:
1814 /* LAN911[5678] family */
1815 pdata->generation = pdata->idrev & 0x0000FFFF;
1816 break;
1817
1818 case 0x118A0000:
1819 case 0x117A0000:
1820 case 0x116A0000:
1821 case 0x115A0000:
1822 /* LAN921[5678] family */
1823 pdata->generation = 3;
1824 break;
1825
1826 case 0x92100000:
1827 case 0x92110000:
1828 case 0x92200000:
1829 case 0x92210000:
1830 /* LAN9210/LAN9211/LAN9220/LAN9221 */
1831 pdata->generation = 4;
1832 break;
1833
1834 default:
1835 SMSC_WARNING(PROBE, "LAN911x not identified, idrev: 0x%08X",
1836 pdata->idrev);
1837 return -ENODEV;
1838 }
1839
1840 SMSC_TRACE(PROBE, "LAN911x identified, idrev: 0x%08X, generation: %d",
1841 pdata->idrev, pdata->generation);
1842
1843 if (pdata->generation == 0)
1844 SMSC_WARNING(PROBE,
1845 "This driver is not intended for this chip revision");
1846
1847 /* Reset the LAN911x */
1848 if (smsc911x_soft_reset(pdata))
1849 return -ENODEV;
1850
1851 /* Disable all interrupt sources until we bring the device up */
1852 smsc911x_reg_write(pdata, INT_EN, 0);
1853
1854 ether_setup(dev);
1855 dev->open = smsc911x_open;
1856 dev->stop = smsc911x_stop;
1857 dev->hard_start_xmit = smsc911x_hard_start_xmit;
1858 dev->get_stats = smsc911x_get_stats;
1859 dev->set_multicast_list = smsc911x_set_multicast_list;
1860 dev->flags |= IFF_MULTICAST;
1861 dev->do_ioctl = smsc911x_do_ioctl;
1862 netif_napi_add(dev, &pdata->napi, smsc911x_poll, SMSC_NAPI_WEIGHT);
1863 dev->ethtool_ops = &smsc911x_ethtool_ops;
1864
1865#ifdef CONFIG_NET_POLL_CONTROLLER
1866 dev->poll_controller = smsc911x_poll_controller;
1867#endif /* CONFIG_NET_POLL_CONTROLLER */
1868
1869 return 0;
1870}
1871
1872static int __devexit smsc911x_drv_remove(struct platform_device *pdev)
1873{
1874 struct net_device *dev;
1875 struct smsc911x_data *pdata;
1876 struct resource *res;
1877
1878 dev = platform_get_drvdata(pdev);
1879 BUG_ON(!dev);
1880 pdata = netdev_priv(dev);
1881 BUG_ON(!pdata);
1882 BUG_ON(!pdata->ioaddr);
1883 BUG_ON(!pdata->phy_dev);
1884
1885 SMSC_TRACE(IFDOWN, "Stopping driver.");
1886
1887 phy_disconnect(pdata->phy_dev);
1888 pdata->phy_dev = NULL;
1889 mdiobus_unregister(pdata->mii_bus);
1890 mdiobus_free(pdata->mii_bus);
1891
1892 platform_set_drvdata(pdev, NULL);
1893 unregister_netdev(dev);
1894 free_irq(dev->irq, dev);
1895 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1896 "smsc911x-memory");
1897 if (!res)
1898 platform_get_resource(pdev, IORESOURCE_MEM, 0);
1899
1900 release_mem_region(res->start, res->end - res->start);
1901
1902 iounmap(pdata->ioaddr);
1903
1904 free_netdev(dev);
1905
1906 return 0;
1907}
1908
1909static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
1910{
1911 struct net_device *dev;
1912 struct smsc911x_data *pdata;
1913 struct resource *res;
1914 unsigned int intcfg = 0;
1915 int res_size;
1916 int retval;
1917 DECLARE_MAC_BUF(mac);
1918
1919 pr_info("%s: Driver version %s.\n", SMSC_CHIPNAME, SMSC_DRV_VERSION);
1920
1921 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1922 "smsc911x-memory");
1923 if (!res)
1924 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1925 if (!res) {
1926 pr_warning("%s: Could not allocate resource.\n",
1927 SMSC_CHIPNAME);
1928 retval = -ENODEV;
1929 goto out_0;
1930 }
1931 res_size = res->end - res->start;
1932
1933 if (!request_mem_region(res->start, res_size, SMSC_CHIPNAME)) {
1934 retval = -EBUSY;
1935 goto out_0;
1936 }
1937
1938 dev = alloc_etherdev(sizeof(struct smsc911x_data));
1939 if (!dev) {
1940 pr_warning("%s: Could not allocate device.\n", SMSC_CHIPNAME);
1941 retval = -ENOMEM;
1942 goto out_release_io_1;
1943 }
1944
1945 SET_NETDEV_DEV(dev, &pdev->dev);
1946
1947 pdata = netdev_priv(dev);
1948
1949 dev->irq = platform_get_irq(pdev, 0);
1950 pdata->ioaddr = ioremap_nocache(res->start, res_size);
1951
1952 /* copy config parameters across if present, otherwise pdata
1953 * defaults to zeros */
1954 if (pdev->dev.platform_data) {
1955 struct smsc911x_platform_config *config =
1956 pdev->dev.platform_data;
1957 pdata->irq_polarity = config->irq_polarity;
1958 pdata->irq_type = config->irq_type;
1959 pdata->phy_interface = config->phy_interface;
1960 }
1961
1962 pdata->dev = dev;
1963 pdata->msg_enable = ((1 << debug) - 1);
1964
1965 if (pdata->ioaddr == NULL) {
1966 SMSC_WARNING(PROBE,
1967 "Error smsc911x base address invalid");
1968 retval = -ENOMEM;
1969 goto out_free_netdev_2;
1970 }
1971
1972 retval = smsc911x_init(dev);
1973 if (retval < 0)
1974 goto out_unmap_io_3;
1975
1976 /* configure irq polarity and type before connecting isr */
1977 if (pdata->irq_polarity == SMSC911X_IRQ_POLARITY_ACTIVE_HIGH)
1978 intcfg |= INT_CFG_IRQ_POL_;
1979
1980 if (pdata->irq_type == SMSC911X_IRQ_TYPE_PUSH_PULL)
1981 intcfg |= INT_CFG_IRQ_TYPE_;
1982
1983 smsc911x_reg_write(pdata, INT_CFG, intcfg);
1984
1985 /* Ensure interrupts are globally disabled before connecting ISR */
1986 smsc911x_reg_write(pdata, INT_EN, 0);
1987 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF);
1988
1989 retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED,
1990 SMSC_CHIPNAME, dev);
1991 if (retval) {
1992 SMSC_WARNING(PROBE,
1993 "Unable to claim requested irq: %d", dev->irq);
1994 goto out_unmap_io_3;
1995 }
1996
1997 platform_set_drvdata(pdev, dev);
1998
1999 retval = register_netdev(dev);
2000 if (retval) {
2001 SMSC_WARNING(PROBE,
2002 "Error %i registering device", retval);
2003 goto out_unset_drvdata_4;
2004 } else {
2005 SMSC_TRACE(PROBE, "Network interface: \"%s\"", dev->name);
2006 }
2007
2008 spin_lock_init(&pdata->mac_lock);
2009
2010 retval = smsc911x_mii_init(pdev, dev);
2011 if (retval) {
2012 SMSC_WARNING(PROBE,
2013 "Error %i initialising mii", retval);
2014 goto out_unregister_netdev_5;
2015 }
2016
2017 spin_lock_irq(&pdata->mac_lock);
2018
2019 /* Check if mac address has been specified when bringing interface up */
2020 if (is_valid_ether_addr(dev->dev_addr)) {
2021 smsc911x_set_mac_address(pdata, dev->dev_addr);
2022 SMSC_TRACE(PROBE, "MAC Address is specified by configuration");
2023 } else {
2024 /* Try reading mac address from device. if EEPROM is present
2025 * it will already have been set */
2026 u32 mac_high16 = smsc911x_mac_read(pdata, ADDRH);
2027 u32 mac_low32 = smsc911x_mac_read(pdata, ADDRL);
2028 dev->dev_addr[0] = (u8)(mac_low32);
2029 dev->dev_addr[1] = (u8)(mac_low32 >> 8);
2030 dev->dev_addr[2] = (u8)(mac_low32 >> 16);
2031 dev->dev_addr[3] = (u8)(mac_low32 >> 24);
2032 dev->dev_addr[4] = (u8)(mac_high16);
2033 dev->dev_addr[5] = (u8)(mac_high16 >> 8);
2034
2035 if (is_valid_ether_addr(dev->dev_addr)) {
2036 /* eeprom values are valid so use them */
2037 SMSC_TRACE(PROBE,
2038 "Mac Address is read from LAN911x EEPROM");
2039 } else {
2040 /* eeprom values are invalid, generate random MAC */
2041 random_ether_addr(dev->dev_addr);
2042 smsc911x_set_mac_address(pdata, dev->dev_addr);
2043 SMSC_TRACE(PROBE,
2044 "MAC Address is set to random_ether_addr");
2045 }
2046 }
2047
2048 spin_unlock_irq(&pdata->mac_lock);
2049
2050 dev_info(&dev->dev, "MAC Address: %s\n",
2051 print_mac(mac, dev->dev_addr));
2052
2053 return 0;
2054
2055out_unregister_netdev_5:
2056 unregister_netdev(dev);
2057out_unset_drvdata_4:
2058 platform_set_drvdata(pdev, NULL);
2059 free_irq(dev->irq, dev);
2060out_unmap_io_3:
2061 iounmap(pdata->ioaddr);
2062out_free_netdev_2:
2063 free_netdev(dev);
2064out_release_io_1:
2065 release_mem_region(res->start, res->end - res->start);
2066out_0:
2067 return retval;
2068}
2069
2070static struct platform_driver smsc911x_driver = {
2071 .probe = smsc911x_drv_probe,
2072 .remove = smsc911x_drv_remove,
2073 .driver = {
2074 .name = SMSC_CHIPNAME,
2075 },
2076};
2077
2078/* Entry point for loading the module */
2079static int __init smsc911x_init_module(void)
2080{
2081 return platform_driver_register(&smsc911x_driver);
2082}
2083
2084/* entry point for unloading the module */
2085static void __exit smsc911x_cleanup_module(void)
2086{
2087 platform_driver_unregister(&smsc911x_driver);
2088}
2089
2090module_init(smsc911x_init_module);
2091module_exit(smsc911x_cleanup_module);
diff --git a/drivers/net/smsc911x.h b/drivers/net/smsc911x.h
new file mode 100644
index 000000000000..feb36de274ca
--- /dev/null
+++ b/drivers/net/smsc911x.h
@@ -0,0 +1,394 @@
1/***************************************************************************
2 *
3 * Copyright (C) 2004-2008 SMSC
4 * Copyright (C) 2005-2008 ARM
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 ***************************************************************************/
21#ifndef __SMSC911X_H__
22#define __SMSC911X_H__
23
24#define SMSC_CAN_USE_32BIT 1
25#define TX_FIFO_LOW_THRESHOLD ((u32)1600)
26#define SMSC911X_EEPROM_SIZE ((u32)7)
27#define USE_DEBUG 0
28
29/* This is the maximum number of packets to be received every
30 * NAPI poll */
31#define SMSC_NAPI_WEIGHT 16
32
33/* implements a PHY loopback test at initialisation time, to ensure a packet
34 * can be succesfully looped back */
35#define USE_PHY_WORK_AROUND
36
37#define DPRINTK(nlevel, klevel, fmt, args...) \
38 ((void)((NETIF_MSG_##nlevel & pdata->msg_enable) && \
39 printk(KERN_##klevel "%s: %s: " fmt "\n", \
40 pdata->dev->name, __func__, ## args)))
41
42#if USE_DEBUG >= 1
43#define SMSC_WARNING(nlevel, fmt, args...) \
44 DPRINTK(nlevel, WARNING, fmt, ## args)
45#else
46#define SMSC_WARNING(nlevel, fmt, args...) \
47 ({ do {} while (0); 0; })
48#endif
49
50#if USE_DEBUG >= 2
51#define SMSC_TRACE(nlevel, fmt, args...) \
52 DPRINTK(nlevel, INFO, fmt, ## args)
53#else
54#define SMSC_TRACE(nlevel, fmt, args...) \
55 ({ do {} while (0); 0; })
56#endif
57
58#ifdef CONFIG_DEBUG_SPINLOCK
59#define SMSC_ASSERT_MAC_LOCK(pdata) \
60 WARN_ON(!spin_is_locked(&pdata->mac_lock))
61#else
62#define SMSC_ASSERT_MAC_LOCK(pdata) do {} while (0)
63#endif /* CONFIG_DEBUG_SPINLOCK */
64
65#define FLOW_CTRL_TX (1)
66#define FLOW_CTRL_RX (2)
67
68/* SMSC911x registers and bitfields */
69#define RX_DATA_FIFO 0x00
70
71#define TX_DATA_FIFO 0x20
72#define TX_CMD_A_ON_COMP_ 0x80000000
73#define TX_CMD_A_BUF_END_ALGN_ 0x03000000
74#define TX_CMD_A_4_BYTE_ALGN_ 0x00000000
75#define TX_CMD_A_16_BYTE_ALGN_ 0x01000000
76#define TX_CMD_A_32_BYTE_ALGN_ 0x02000000
77#define TX_CMD_A_DATA_OFFSET_ 0x001F0000
78#define TX_CMD_A_FIRST_SEG_ 0x00002000
79#define TX_CMD_A_LAST_SEG_ 0x00001000
80#define TX_CMD_A_BUF_SIZE_ 0x000007FF
81#define TX_CMD_B_PKT_TAG_ 0xFFFF0000
82#define TX_CMD_B_ADD_CRC_DISABLE_ 0x00002000
83#define TX_CMD_B_DISABLE_PADDING_ 0x00001000
84#define TX_CMD_B_PKT_BYTE_LENGTH_ 0x000007FF
85
86#define RX_STATUS_FIFO 0x40
87#define RX_STS_ES_ 0x00008000
88#define RX_STS_MCAST_ 0x00000400
89
90#define RX_STATUS_FIFO_PEEK 0x44
91
92#define TX_STATUS_FIFO 0x48
93#define TX_STS_ES_ 0x00008000
94
95#define TX_STATUS_FIFO_PEEK 0x4C
96
97#define ID_REV 0x50
98#define ID_REV_CHIP_ID_ 0xFFFF0000
99#define ID_REV_REV_ID_ 0x0000FFFF
100
101#define INT_CFG 0x54
102#define INT_CFG_INT_DEAS_ 0xFF000000
103#define INT_CFG_INT_DEAS_CLR_ 0x00004000
104#define INT_CFG_INT_DEAS_STS_ 0x00002000
105#define INT_CFG_IRQ_INT_ 0x00001000
106#define INT_CFG_IRQ_EN_ 0x00000100
107#define INT_CFG_IRQ_POL_ 0x00000010
108#define INT_CFG_IRQ_TYPE_ 0x00000001
109
110#define INT_STS 0x58
111#define INT_STS_SW_INT_ 0x80000000
112#define INT_STS_TXSTOP_INT_ 0x02000000
113#define INT_STS_RXSTOP_INT_ 0x01000000
114#define INT_STS_RXDFH_INT_ 0x00800000
115#define INT_STS_RXDF_INT_ 0x00400000
116#define INT_STS_TX_IOC_ 0x00200000
117#define INT_STS_RXD_INT_ 0x00100000
118#define INT_STS_GPT_INT_ 0x00080000
119#define INT_STS_PHY_INT_ 0x00040000
120#define INT_STS_PME_INT_ 0x00020000
121#define INT_STS_TXSO_ 0x00010000
122#define INT_STS_RWT_ 0x00008000
123#define INT_STS_RXE_ 0x00004000
124#define INT_STS_TXE_ 0x00002000
125#define INT_STS_TDFU_ 0x00000800
126#define INT_STS_TDFO_ 0x00000400
127#define INT_STS_TDFA_ 0x00000200
128#define INT_STS_TSFF_ 0x00000100
129#define INT_STS_TSFL_ 0x00000080
130#define INT_STS_RXDF_ 0x00000040
131#define INT_STS_RDFL_ 0x00000020
132#define INT_STS_RSFF_ 0x00000010
133#define INT_STS_RSFL_ 0x00000008
134#define INT_STS_GPIO2_INT_ 0x00000004
135#define INT_STS_GPIO1_INT_ 0x00000002
136#define INT_STS_GPIO0_INT_ 0x00000001
137
138#define INT_EN 0x5C
139#define INT_EN_SW_INT_EN_ 0x80000000
140#define INT_EN_TXSTOP_INT_EN_ 0x02000000
141#define INT_EN_RXSTOP_INT_EN_ 0x01000000
142#define INT_EN_RXDFH_INT_EN_ 0x00800000
143#define INT_EN_TIOC_INT_EN_ 0x00200000
144#define INT_EN_RXD_INT_EN_ 0x00100000
145#define INT_EN_GPT_INT_EN_ 0x00080000
146#define INT_EN_PHY_INT_EN_ 0x00040000
147#define INT_EN_PME_INT_EN_ 0x00020000
148#define INT_EN_TXSO_EN_ 0x00010000
149#define INT_EN_RWT_EN_ 0x00008000
150#define INT_EN_RXE_EN_ 0x00004000
151#define INT_EN_TXE_EN_ 0x00002000
152#define INT_EN_TDFU_EN_ 0x00000800
153#define INT_EN_TDFO_EN_ 0x00000400
154#define INT_EN_TDFA_EN_ 0x00000200
155#define INT_EN_TSFF_EN_ 0x00000100
156#define INT_EN_TSFL_EN_ 0x00000080
157#define INT_EN_RXDF_EN_ 0x00000040
158#define INT_EN_RDFL_EN_ 0x00000020
159#define INT_EN_RSFF_EN_ 0x00000010
160#define INT_EN_RSFL_EN_ 0x00000008
161#define INT_EN_GPIO2_INT_ 0x00000004
162#define INT_EN_GPIO1_INT_ 0x00000002
163#define INT_EN_GPIO0_INT_ 0x00000001
164
165#define BYTE_TEST 0x64
166
167#define FIFO_INT 0x68
168#define FIFO_INT_TX_AVAIL_LEVEL_ 0xFF000000
169#define FIFO_INT_TX_STS_LEVEL_ 0x00FF0000
170#define FIFO_INT_RX_AVAIL_LEVEL_ 0x0000FF00
171#define FIFO_INT_RX_STS_LEVEL_ 0x000000FF
172
173#define RX_CFG 0x6C
174#define RX_CFG_RX_END_ALGN_ 0xC0000000
175#define RX_CFG_RX_END_ALGN4_ 0x00000000
176#define RX_CFG_RX_END_ALGN16_ 0x40000000
177#define RX_CFG_RX_END_ALGN32_ 0x80000000
178#define RX_CFG_RX_DMA_CNT_ 0x0FFF0000
179#define RX_CFG_RX_DUMP_ 0x00008000
180#define RX_CFG_RXDOFF_ 0x00001F00
181
182#define TX_CFG 0x70
183#define TX_CFG_TXS_DUMP_ 0x00008000
184#define TX_CFG_TXD_DUMP_ 0x00004000
185#define TX_CFG_TXSAO_ 0x00000004
186#define TX_CFG_TX_ON_ 0x00000002
187#define TX_CFG_STOP_TX_ 0x00000001
188
189#define HW_CFG 0x74
190#define HW_CFG_TTM_ 0x00200000
191#define HW_CFG_SF_ 0x00100000
192#define HW_CFG_TX_FIF_SZ_ 0x000F0000
193#define HW_CFG_TR_ 0x00003000
194#define HW_CFG_SRST_ 0x00000001
195
196/* only available on 115/117 */
197#define HW_CFG_PHY_CLK_SEL_ 0x00000060
198#define HW_CFG_PHY_CLK_SEL_INT_PHY_ 0x00000000
199#define HW_CFG_PHY_CLK_SEL_EXT_PHY_ 0x00000020
200#define HW_CFG_PHY_CLK_SEL_CLK_DIS_ 0x00000040
201#define HW_CFG_SMI_SEL_ 0x00000010
202#define HW_CFG_EXT_PHY_DET_ 0x00000008
203#define HW_CFG_EXT_PHY_EN_ 0x00000004
204#define HW_CFG_SRST_TO_ 0x00000002
205
206/* only available on 116/118 */
207#define HW_CFG_32_16_BIT_MODE_ 0x00000004
208
209#define RX_DP_CTRL 0x78
210#define RX_DP_CTRL_RX_FFWD_ 0x80000000
211
212#define RX_FIFO_INF 0x7C
213#define RX_FIFO_INF_RXSUSED_ 0x00FF0000
214#define RX_FIFO_INF_RXDUSED_ 0x0000FFFF
215
216#define TX_FIFO_INF 0x80
217#define TX_FIFO_INF_TSUSED_ 0x00FF0000
218#define TX_FIFO_INF_TDFREE_ 0x0000FFFF
219
220#define PMT_CTRL 0x84
221#define PMT_CTRL_PM_MODE_ 0x00003000
222#define PMT_CTRL_PM_MODE_D0_ 0x00000000
223#define PMT_CTRL_PM_MODE_D1_ 0x00001000
224#define PMT_CTRL_PM_MODE_D2_ 0x00002000
225#define PMT_CTRL_PM_MODE_D3_ 0x00003000
226#define PMT_CTRL_PHY_RST_ 0x00000400
227#define PMT_CTRL_WOL_EN_ 0x00000200
228#define PMT_CTRL_ED_EN_ 0x00000100
229#define PMT_CTRL_PME_TYPE_ 0x00000040
230#define PMT_CTRL_WUPS_ 0x00000030
231#define PMT_CTRL_WUPS_NOWAKE_ 0x00000000
232#define PMT_CTRL_WUPS_ED_ 0x00000010
233#define PMT_CTRL_WUPS_WOL_ 0x00000020
234#define PMT_CTRL_WUPS_MULTI_ 0x00000030
235#define PMT_CTRL_PME_IND_ 0x00000008
236#define PMT_CTRL_PME_POL_ 0x00000004
237#define PMT_CTRL_PME_EN_ 0x00000002
238#define PMT_CTRL_READY_ 0x00000001
239
240#define GPIO_CFG 0x88
241#define GPIO_CFG_LED3_EN_ 0x40000000
242#define GPIO_CFG_LED2_EN_ 0x20000000
243#define GPIO_CFG_LED1_EN_ 0x10000000
244#define GPIO_CFG_GPIO2_INT_POL_ 0x04000000
245#define GPIO_CFG_GPIO1_INT_POL_ 0x02000000
246#define GPIO_CFG_GPIO0_INT_POL_ 0x01000000
247#define GPIO_CFG_EEPR_EN_ 0x00700000
248#define GPIO_CFG_GPIOBUF2_ 0x00040000
249#define GPIO_CFG_GPIOBUF1_ 0x00020000
250#define GPIO_CFG_GPIOBUF0_ 0x00010000
251#define GPIO_CFG_GPIODIR2_ 0x00000400
252#define GPIO_CFG_GPIODIR1_ 0x00000200
253#define GPIO_CFG_GPIODIR0_ 0x00000100
254#define GPIO_CFG_GPIOD4_ 0x00000020
255#define GPIO_CFG_GPIOD3_ 0x00000010
256#define GPIO_CFG_GPIOD2_ 0x00000004
257#define GPIO_CFG_GPIOD1_ 0x00000002
258#define GPIO_CFG_GPIOD0_ 0x00000001
259
260#define GPT_CFG 0x8C
261#define GPT_CFG_TIMER_EN_ 0x20000000
262#define GPT_CFG_GPT_LOAD_ 0x0000FFFF
263
264#define GPT_CNT 0x90
265#define GPT_CNT_GPT_CNT_ 0x0000FFFF
266
267#define WORD_SWAP 0x98
268
269#define FREE_RUN 0x9C
270
271#define RX_DROP 0xA0
272
273#define MAC_CSR_CMD 0xA4
274#define MAC_CSR_CMD_CSR_BUSY_ 0x80000000
275#define MAC_CSR_CMD_R_NOT_W_ 0x40000000
276#define MAC_CSR_CMD_CSR_ADDR_ 0x000000FF
277
278#define MAC_CSR_DATA 0xA8
279
280#define AFC_CFG 0xAC
281#define AFC_CFG_AFC_HI_ 0x00FF0000
282#define AFC_CFG_AFC_LO_ 0x0000FF00
283#define AFC_CFG_BACK_DUR_ 0x000000F0
284#define AFC_CFG_FCMULT_ 0x00000008
285#define AFC_CFG_FCBRD_ 0x00000004
286#define AFC_CFG_FCADD_ 0x00000002
287#define AFC_CFG_FCANY_ 0x00000001
288
289#define E2P_CMD 0xB0
290#define E2P_CMD_EPC_BUSY_ 0x80000000
291#define E2P_CMD_EPC_CMD_ 0x70000000
292#define E2P_CMD_EPC_CMD_READ_ 0x00000000
293#define E2P_CMD_EPC_CMD_EWDS_ 0x10000000
294#define E2P_CMD_EPC_CMD_EWEN_ 0x20000000
295#define E2P_CMD_EPC_CMD_WRITE_ 0x30000000
296#define E2P_CMD_EPC_CMD_WRAL_ 0x40000000
297#define E2P_CMD_EPC_CMD_ERASE_ 0x50000000
298#define E2P_CMD_EPC_CMD_ERAL_ 0x60000000
299#define E2P_CMD_EPC_CMD_RELOAD_ 0x70000000
300#define E2P_CMD_EPC_TIMEOUT_ 0x00000200
301#define E2P_CMD_MAC_ADDR_LOADED_ 0x00000100
302#define E2P_CMD_EPC_ADDR_ 0x000000FF
303
304#define E2P_DATA 0xB4
305#define E2P_DATA_EEPROM_DATA_ 0x000000FF
306#define LAN_REGISTER_EXTENT 0x00000100
307
308/*
309 * MAC Control and Status Register (Indirect Address)
310 * Offset (through the MAC_CSR CMD and DATA port)
311 */
312#define MAC_CR 0x01
313#define MAC_CR_RXALL_ 0x80000000
314#define MAC_CR_HBDIS_ 0x10000000
315#define MAC_CR_RCVOWN_ 0x00800000
316#define MAC_CR_LOOPBK_ 0x00200000
317#define MAC_CR_FDPX_ 0x00100000
318#define MAC_CR_MCPAS_ 0x00080000
319#define MAC_CR_PRMS_ 0x00040000
320#define MAC_CR_INVFILT_ 0x00020000
321#define MAC_CR_PASSBAD_ 0x00010000
322#define MAC_CR_HFILT_ 0x00008000
323#define MAC_CR_HPFILT_ 0x00002000
324#define MAC_CR_LCOLL_ 0x00001000
325#define MAC_CR_BCAST_ 0x00000800
326#define MAC_CR_DISRTY_ 0x00000400
327#define MAC_CR_PADSTR_ 0x00000100
328#define MAC_CR_BOLMT_MASK_ 0x000000C0
329#define MAC_CR_DFCHK_ 0x00000020
330#define MAC_CR_TXEN_ 0x00000008
331#define MAC_CR_RXEN_ 0x00000004
332
333#define ADDRH 0x02
334
335#define ADDRL 0x03
336
337#define HASHH 0x04
338
339#define HASHL 0x05
340
341#define MII_ACC 0x06
342#define MII_ACC_PHY_ADDR_ 0x0000F800
343#define MII_ACC_MIIRINDA_ 0x000007C0
344#define MII_ACC_MII_WRITE_ 0x00000002
345#define MII_ACC_MII_BUSY_ 0x00000001
346
347#define MII_DATA 0x07
348
349#define FLOW 0x08
350#define FLOW_FCPT_ 0xFFFF0000
351#define FLOW_FCPASS_ 0x00000004
352#define FLOW_FCEN_ 0x00000002
353#define FLOW_FCBSY_ 0x00000001
354
355#define VLAN1 0x09
356
357#define VLAN2 0x0A
358
359#define WUFF 0x0B
360
361#define WUCSR 0x0C
362#define WUCSR_GUE_ 0x00000200
363#define WUCSR_WUFR_ 0x00000040
364#define WUCSR_MPR_ 0x00000020
365#define WUCSR_WAKE_EN_ 0x00000004
366#define WUCSR_MPEN_ 0x00000002
367
368/*
369 * Phy definitions (vendor-specific)
370 */
371#define LAN9118_PHY_ID 0x00C0001C
372
373#define MII_INTSTS 0x1D
374
375#define MII_INTMSK 0x1E
376#define PHY_INTMSK_AN_RCV_ (1 << 1)
377#define PHY_INTMSK_PDFAULT_ (1 << 2)
378#define PHY_INTMSK_AN_ACK_ (1 << 3)
379#define PHY_INTMSK_LNKDOWN_ (1 << 4)
380#define PHY_INTMSK_RFAULT_ (1 << 5)
381#define PHY_INTMSK_AN_COMP_ (1 << 6)
382#define PHY_INTMSK_ENERGYON_ (1 << 7)
383#define PHY_INTMSK_DEFAULT_ (PHY_INTMSK_ENERGYON_ | \
384 PHY_INTMSK_AN_COMP_ | \
385 PHY_INTMSK_RFAULT_ | \
386 PHY_INTMSK_LNKDOWN_)
387
388#define ADVERTISE_PAUSE_ALL (ADVERTISE_PAUSE_CAP | \
389 ADVERTISE_PAUSE_ASYM)
390
391#define LPA_PAUSE_ALL (LPA_PAUSE_CAP | \
392 LPA_PAUSE_ASYM)
393
394#endif /* __SMSC911X_H__ */
diff --git a/drivers/net/sonic.c b/drivers/net/sonic.c
index 8069f3e32d83..211e805c1223 100644
--- a/drivers/net/sonic.c
+++ b/drivers/net/sonic.c
@@ -450,7 +450,6 @@ static void sonic_rx(struct net_device *dev)
450 skb_trim(used_skb, pkt_len); 450 skb_trim(used_skb, pkt_len);
451 used_skb->protocol = eth_type_trans(used_skb, dev); 451 used_skb->protocol = eth_type_trans(used_skb, dev);
452 netif_rx(used_skb); 452 netif_rx(used_skb);
453 dev->last_rx = jiffies;
454 lp->stats.rx_packets++; 453 lp->stats.rx_packets++;
455 lp->stats.rx_bytes += pkt_len; 454 lp->stats.rx_bytes += pkt_len;
456 455
diff --git a/drivers/net/sonic.h b/drivers/net/sonic.h
index 7db13e4a7ea5..07091dd27e5d 100644
--- a/drivers/net/sonic.h
+++ b/drivers/net/sonic.h
@@ -371,7 +371,7 @@ static inline __u16 sonic_buf_get(void* base, int bitmode,
371static inline void sonic_cda_put(struct net_device* dev, int entry, 371static inline void sonic_cda_put(struct net_device* dev, int entry,
372 int offset, __u16 val) 372 int offset, __u16 val)
373{ 373{
374 struct sonic_local* lp = (struct sonic_local *) dev->priv; 374 struct sonic_local *lp = netdev_priv(dev);
375 sonic_buf_put(lp->cda, lp->dma_bitmode, 375 sonic_buf_put(lp->cda, lp->dma_bitmode,
376 (entry * SIZEOF_SONIC_CD) + offset, val); 376 (entry * SIZEOF_SONIC_CD) + offset, val);
377} 377}
@@ -379,27 +379,27 @@ static inline void sonic_cda_put(struct net_device* dev, int entry,
379static inline __u16 sonic_cda_get(struct net_device* dev, int entry, 379static inline __u16 sonic_cda_get(struct net_device* dev, int entry,
380 int offset) 380 int offset)
381{ 381{
382 struct sonic_local* lp = (struct sonic_local *) dev->priv; 382 struct sonic_local *lp = netdev_priv(dev);
383 return sonic_buf_get(lp->cda, lp->dma_bitmode, 383 return sonic_buf_get(lp->cda, lp->dma_bitmode,
384 (entry * SIZEOF_SONIC_CD) + offset); 384 (entry * SIZEOF_SONIC_CD) + offset);
385} 385}
386 386
387static inline void sonic_set_cam_enable(struct net_device* dev, __u16 val) 387static inline void sonic_set_cam_enable(struct net_device* dev, __u16 val)
388{ 388{
389 struct sonic_local* lp = (struct sonic_local *) dev->priv; 389 struct sonic_local *lp = netdev_priv(dev);
390 sonic_buf_put(lp->cda, lp->dma_bitmode, SONIC_CDA_CAM_ENABLE, val); 390 sonic_buf_put(lp->cda, lp->dma_bitmode, SONIC_CDA_CAM_ENABLE, val);
391} 391}
392 392
393static inline __u16 sonic_get_cam_enable(struct net_device* dev) 393static inline __u16 sonic_get_cam_enable(struct net_device* dev)
394{ 394{
395 struct sonic_local* lp = (struct sonic_local *) dev->priv; 395 struct sonic_local *lp = netdev_priv(dev);
396 return sonic_buf_get(lp->cda, lp->dma_bitmode, SONIC_CDA_CAM_ENABLE); 396 return sonic_buf_get(lp->cda, lp->dma_bitmode, SONIC_CDA_CAM_ENABLE);
397} 397}
398 398
399static inline void sonic_tda_put(struct net_device* dev, int entry, 399static inline void sonic_tda_put(struct net_device* dev, int entry,
400 int offset, __u16 val) 400 int offset, __u16 val)
401{ 401{
402 struct sonic_local* lp = (struct sonic_local *) dev->priv; 402 struct sonic_local *lp = netdev_priv(dev);
403 sonic_buf_put(lp->tda, lp->dma_bitmode, 403 sonic_buf_put(lp->tda, lp->dma_bitmode,
404 (entry * SIZEOF_SONIC_TD) + offset, val); 404 (entry * SIZEOF_SONIC_TD) + offset, val);
405} 405}
@@ -407,7 +407,7 @@ static inline void sonic_tda_put(struct net_device* dev, int entry,
407static inline __u16 sonic_tda_get(struct net_device* dev, int entry, 407static inline __u16 sonic_tda_get(struct net_device* dev, int entry,
408 int offset) 408 int offset)
409{ 409{
410 struct sonic_local* lp = (struct sonic_local *) dev->priv; 410 struct sonic_local *lp = netdev_priv(dev);
411 return sonic_buf_get(lp->tda, lp->dma_bitmode, 411 return sonic_buf_get(lp->tda, lp->dma_bitmode,
412 (entry * SIZEOF_SONIC_TD) + offset); 412 (entry * SIZEOF_SONIC_TD) + offset);
413} 413}
@@ -415,7 +415,7 @@ static inline __u16 sonic_tda_get(struct net_device* dev, int entry,
415static inline void sonic_rda_put(struct net_device* dev, int entry, 415static inline void sonic_rda_put(struct net_device* dev, int entry,
416 int offset, __u16 val) 416 int offset, __u16 val)
417{ 417{
418 struct sonic_local* lp = (struct sonic_local *) dev->priv; 418 struct sonic_local *lp = netdev_priv(dev);
419 sonic_buf_put(lp->rda, lp->dma_bitmode, 419 sonic_buf_put(lp->rda, lp->dma_bitmode,
420 (entry * SIZEOF_SONIC_RD) + offset, val); 420 (entry * SIZEOF_SONIC_RD) + offset, val);
421} 421}
@@ -423,7 +423,7 @@ static inline void sonic_rda_put(struct net_device* dev, int entry,
423static inline __u16 sonic_rda_get(struct net_device* dev, int entry, 423static inline __u16 sonic_rda_get(struct net_device* dev, int entry,
424 int offset) 424 int offset)
425{ 425{
426 struct sonic_local* lp = (struct sonic_local *) dev->priv; 426 struct sonic_local *lp = netdev_priv(dev);
427 return sonic_buf_get(lp->rda, lp->dma_bitmode, 427 return sonic_buf_get(lp->rda, lp->dma_bitmode,
428 (entry * SIZEOF_SONIC_RD) + offset); 428 (entry * SIZEOF_SONIC_RD) + offset);
429} 429}
@@ -431,7 +431,7 @@ static inline __u16 sonic_rda_get(struct net_device* dev, int entry,
431static inline void sonic_rra_put(struct net_device* dev, int entry, 431static inline void sonic_rra_put(struct net_device* dev, int entry,
432 int offset, __u16 val) 432 int offset, __u16 val)
433{ 433{
434 struct sonic_local* lp = (struct sonic_local *) dev->priv; 434 struct sonic_local *lp = netdev_priv(dev);
435 sonic_buf_put(lp->rra, lp->dma_bitmode, 435 sonic_buf_put(lp->rra, lp->dma_bitmode,
436 (entry * SIZEOF_SONIC_RR) + offset, val); 436 (entry * SIZEOF_SONIC_RR) + offset, val);
437} 437}
@@ -439,7 +439,7 @@ static inline void sonic_rra_put(struct net_device* dev, int entry,
439static inline __u16 sonic_rra_get(struct net_device* dev, int entry, 439static inline __u16 sonic_rra_get(struct net_device* dev, int entry,
440 int offset) 440 int offset)
441{ 441{
442 struct sonic_local* lp = (struct sonic_local *) dev->priv; 442 struct sonic_local *lp = netdev_priv(dev);
443 return sonic_buf_get(lp->rra, lp->dma_bitmode, 443 return sonic_buf_get(lp->rra, lp->dma_bitmode,
444 (entry * SIZEOF_SONIC_RR) + offset); 444 (entry * SIZEOF_SONIC_RR) + offset);
445} 445}
diff --git a/drivers/net/spider_net_ethtool.c b/drivers/net/spider_net_ethtool.c
index 85691d2a0be2..5bae728c3820 100644
--- a/drivers/net/spider_net_ethtool.c
+++ b/drivers/net/spider_net_ethtool.c
@@ -118,7 +118,7 @@ spider_net_ethtool_nway_reset(struct net_device *netdev)
118static u32 118static u32
119spider_net_ethtool_get_rx_csum(struct net_device *netdev) 119spider_net_ethtool_get_rx_csum(struct net_device *netdev)
120{ 120{
121 struct spider_net_card *card = netdev->priv; 121 struct spider_net_card *card = netdev_priv(netdev);
122 122
123 return card->options.rx_csum; 123 return card->options.rx_csum;
124} 124}
@@ -126,7 +126,7 @@ spider_net_ethtool_get_rx_csum(struct net_device *netdev)
126static int 126static int
127spider_net_ethtool_set_rx_csum(struct net_device *netdev, u32 n) 127spider_net_ethtool_set_rx_csum(struct net_device *netdev, u32 n)
128{ 128{
129 struct spider_net_card *card = netdev->priv; 129 struct spider_net_card *card = netdev_priv(netdev);
130 130
131 card->options.rx_csum = n; 131 card->options.rx_csum = n;
132 return 0; 132 return 0;
@@ -137,7 +137,7 @@ static void
137spider_net_ethtool_get_ringparam(struct net_device *netdev, 137spider_net_ethtool_get_ringparam(struct net_device *netdev,
138 struct ethtool_ringparam *ering) 138 struct ethtool_ringparam *ering)
139{ 139{
140 struct spider_net_card *card = netdev->priv; 140 struct spider_net_card *card = netdev_priv(netdev);
141 141
142 ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX; 142 ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX;
143 ering->tx_pending = card->tx_chain.num_desc; 143 ering->tx_pending = card->tx_chain.num_desc;
@@ -158,7 +158,7 @@ static int spider_net_get_sset_count(struct net_device *netdev, int sset)
158static void spider_net_get_ethtool_stats(struct net_device *netdev, 158static void spider_net_get_ethtool_stats(struct net_device *netdev,
159 struct ethtool_stats *stats, u64 *data) 159 struct ethtool_stats *stats, u64 *data)
160{ 160{
161 struct spider_net_card *card = netdev->priv; 161 struct spider_net_card *card = netdev_priv(netdev);
162 162
163 data[0] = netdev->stats.tx_packets; 163 data[0] = netdev->stats.tx_packets;
164 data[1] = netdev->stats.tx_bytes; 164 data[1] = netdev->stats.tx_bytes;
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 1d2ef8f47780..0358809f409c 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -653,7 +653,6 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
653 void __iomem *base; 653 void __iomem *base;
654 int drv_flags, io_size; 654 int drv_flags, io_size;
655 int boguscnt; 655 int boguscnt;
656 DECLARE_MAC_BUF(mac);
657 656
658/* when built into the kernel, we only print version if device is found */ 657/* when built into the kernel, we only print version if device is found */
659#ifndef MODULE 658#ifndef MODULE
@@ -823,9 +822,9 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
823 if (register_netdev(dev)) 822 if (register_netdev(dev))
824 goto err_out_cleardev; 823 goto err_out_cleardev;
825 824
826 printk(KERN_INFO "%s: %s at %p, %s, IRQ %d.\n", 825 printk(KERN_INFO "%s: %s at %p, %pM, IRQ %d.\n",
827 dev->name, netdrv_tbl[chip_idx].name, base, 826 dev->name, netdrv_tbl[chip_idx].name, base,
828 print_mac(mac, dev->dev_addr), irq); 827 dev->dev_addr, irq);
829 828
830 if (drv_flags & CanHaveMII) { 829 if (drv_flags & CanHaveMII) {
831 int phy, phy_idx = 0; 830 int phy, phy_idx = 0;
@@ -1452,12 +1451,8 @@ static int __netdev_rx(struct net_device *dev, int *quota)
1452#ifndef final_version /* Remove after testing. */ 1451#ifndef final_version /* Remove after testing. */
1453 /* You will want this info for the initial debug. */ 1452 /* You will want this info for the initial debug. */
1454 if (debug > 5) { 1453 if (debug > 5) {
1455 printk(KERN_DEBUG " Rx data " MAC_FMT " " MAC_FMT 1454 printk(KERN_DEBUG " Rx data %pM %pM %2.2x%2.2x.\n",
1456 " %2.2x%2.2x.\n", 1455 skb->data, skb->data + 6,
1457 skb->data[0], skb->data[1], skb->data[2],
1458 skb->data[3], skb->data[4], skb->data[5],
1459 skb->data[6], skb->data[7], skb->data[8],
1460 skb->data[9], skb->data[10], skb->data[11],
1461 skb->data[12], skb->data[13]); 1456 skb->data[12], skb->data[13]);
1462 } 1457 }
1463#endif 1458#endif
@@ -1501,7 +1496,6 @@ static int __netdev_rx(struct net_device *dev, int *quota)
1501 } else 1496 } else
1502#endif /* VLAN_SUPPORT */ 1497#endif /* VLAN_SUPPORT */
1503 netif_receive_skb(skb); 1498 netif_receive_skb(skb);
1504 dev->last_rx = jiffies;
1505 np->stats.rx_packets++; 1499 np->stats.rx_packets++;
1506 1500
1507 next_rx: 1501 next_rx:
diff --git a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
index e531302d95f5..e8f97d5c9c23 100644
--- a/drivers/net/sun3_82586.c
+++ b/drivers/net/sun3_82586.c
@@ -247,7 +247,7 @@ static int check586(struct net_device *dev,char *where,unsigned size)
247 */ 247 */
248static void alloc586(struct net_device *dev) 248static void alloc586(struct net_device *dev)
249{ 249{
250 struct priv *p = (struct priv *) dev->priv; 250 struct priv *p = netdev_priv(dev);
251 251
252 sun3_reset586(); 252 sun3_reset586();
253 DELAY(1); 253 DELAY(1);
@@ -363,17 +363,21 @@ static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
363 goto out; 363 goto out;
364 } 364 }
365 365
366 ((struct priv *) (dev->priv))->memtop = (char *)dvma_btov(dev->mem_start); 366 ((struct priv *)netdev_priv(dev))->memtop =
367 ((struct priv *) (dev->priv))->base = (unsigned long) dvma_btov(0); 367 (char *)dvma_btov(dev->mem_start);
368 ((struct priv *)netdev_priv(dev))->base = (unsigned long) dvma_btov(0);
368 alloc586(dev); 369 alloc586(dev);
369 370
370 /* set number of receive-buffs according to memsize */ 371 /* set number of receive-buffs according to memsize */
371 if(size == 0x2000) 372 if(size == 0x2000)
372 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8; 373 ((struct priv *)netdev_priv(dev))->num_recv_buffs =
374 NUM_RECV_BUFFS_8;
373 else if(size == 0x4000) 375 else if(size == 0x4000)
374 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16; 376 ((struct priv *)netdev_priv(dev))->num_recv_buffs =
377 NUM_RECV_BUFFS_16;
375 else 378 else
376 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_32; 379 ((struct priv *)netdev_priv(dev))->num_recv_buffs =
380 NUM_RECV_BUFFS_32;
377 381
378 printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq); 382 printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq);
379 383
@@ -397,7 +401,7 @@ static int init586(struct net_device *dev)
397{ 401{
398 void *ptr; 402 void *ptr;
399 int i,result=0; 403 int i,result=0;
400 struct priv *p = (struct priv *) dev->priv; 404 struct priv *p = netdev_priv(dev);
401 volatile struct configure_cmd_struct *cfg_cmd; 405 volatile struct configure_cmd_struct *cfg_cmd;
402 volatile struct iasetup_cmd_struct *ias_cmd; 406 volatile struct iasetup_cmd_struct *ias_cmd;
403 volatile struct tdr_cmd_struct *tdr_cmd; 407 volatile struct tdr_cmd_struct *tdr_cmd;
@@ -631,7 +635,7 @@ static void *alloc_rfa(struct net_device *dev,void *ptr)
631 volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr; 635 volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
632 volatile struct rbd_struct *rbd; 636 volatile struct rbd_struct *rbd;
633 int i; 637 int i;
634 struct priv *p = (struct priv *) dev->priv; 638 struct priv *p = netdev_priv(dev);
635 639
636 memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd)); 640 memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
637 p->rfd_first = rfd; 641 p->rfd_first = rfd;
@@ -683,7 +687,7 @@ static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id)
683 printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq); 687 printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
684 return IRQ_NONE; 688 return IRQ_NONE;
685 } 689 }
686 p = (struct priv *) dev->priv; 690 p = netdev_priv(dev);
687 691
688 if(debuglevel > 1) 692 if(debuglevel > 1)
689 printk("I"); 693 printk("I");
@@ -753,7 +757,7 @@ static void sun3_82586_rcv_int(struct net_device *dev)
753 unsigned short totlen; 757 unsigned short totlen;
754 struct sk_buff *skb; 758 struct sk_buff *skb;
755 struct rbd_struct *rbd; 759 struct rbd_struct *rbd;
756 struct priv *p = (struct priv *) dev->priv; 760 struct priv *p = netdev_priv(dev);
757 761
758 if(debuglevel > 0) 762 if(debuglevel > 0)
759 printk("R"); 763 printk("R");
@@ -871,7 +875,7 @@ static void sun3_82586_rcv_int(struct net_device *dev)
871 875
872static void sun3_82586_rnr_int(struct net_device *dev) 876static void sun3_82586_rnr_int(struct net_device *dev)
873{ 877{
874 struct priv *p = (struct priv *) dev->priv; 878 struct priv *p = netdev_priv(dev);
875 879
876 p->stats.rx_errors++; 880 p->stats.rx_errors++;
877 881
@@ -895,7 +899,7 @@ static void sun3_82586_rnr_int(struct net_device *dev)
895static void sun3_82586_xmt_int(struct net_device *dev) 899static void sun3_82586_xmt_int(struct net_device *dev)
896{ 900{
897 int status; 901 int status;
898 struct priv *p = (struct priv *) dev->priv; 902 struct priv *p = netdev_priv(dev);
899 903
900 if(debuglevel > 0) 904 if(debuglevel > 0)
901 printk("X"); 905 printk("X");
@@ -945,7 +949,7 @@ static void sun3_82586_xmt_int(struct net_device *dev)
945 949
946static void startrecv586(struct net_device *dev) 950static void startrecv586(struct net_device *dev)
947{ 951{
948 struct priv *p = (struct priv *) dev->priv; 952 struct priv *p = netdev_priv(dev);
949 953
950 WAIT_4_SCB_CMD(); 954 WAIT_4_SCB_CMD();
951 WAIT_4_SCB_CMD_RUC(); 955 WAIT_4_SCB_CMD_RUC();
@@ -957,7 +961,7 @@ static void startrecv586(struct net_device *dev)
957 961
958static void sun3_82586_timeout(struct net_device *dev) 962static void sun3_82586_timeout(struct net_device *dev)
959{ 963{
960 struct priv *p = (struct priv *) dev->priv; 964 struct priv *p = netdev_priv(dev);
961#ifndef NO_NOPCOMMANDS 965#ifndef NO_NOPCOMMANDS
962 if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */ 966 if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
963 { 967 {
@@ -999,7 +1003,7 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
999#ifndef NO_NOPCOMMANDS 1003#ifndef NO_NOPCOMMANDS
1000 int next_nop; 1004 int next_nop;
1001#endif 1005#endif
1002 struct priv *p = (struct priv *) dev->priv; 1006 struct priv *p = netdev_priv(dev);
1003 1007
1004 if(skb->len > XMIT_BUFF_SIZE) 1008 if(skb->len > XMIT_BUFF_SIZE)
1005 { 1009 {
@@ -1108,7 +1112,7 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
1108 1112
1109static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev) 1113static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev)
1110{ 1114{
1111 struct priv *p = (struct priv *) dev->priv; 1115 struct priv *p = netdev_priv(dev);
1112 unsigned short crc,aln,rsc,ovrn; 1116 unsigned short crc,aln,rsc,ovrn;
1113 1117
1114 crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */ 1118 crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */
@@ -1171,7 +1175,7 @@ void cleanup_module(void)
1171 */ 1175 */
1172void sun3_82586_dump(struct net_device *dev,void *ptr) 1176void sun3_82586_dump(struct net_device *dev,void *ptr)
1173{ 1177{
1174 struct priv *p = (struct priv *) dev->priv; 1178 struct priv *p = netdev_priv(dev);
1175 struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr; 1179 struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
1176 int i; 1180 int i;
1177 1181
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index 359452a06c67..4bb8f72c65cc 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -303,7 +303,6 @@ static int __init lance_probe( struct net_device *dev)
303 static int did_version; 303 static int did_version;
304 volatile unsigned short *ioaddr_probe; 304 volatile unsigned short *ioaddr_probe;
305 unsigned short tmp1, tmp2; 305 unsigned short tmp1, tmp2;
306 DECLARE_MAC_BUF(mac);
307 306
308#ifdef CONFIG_SUN3 307#ifdef CONFIG_SUN3
309 ioaddr = (unsigned long)ioremap(LANCE_OBIO, PAGE_SIZE); 308 ioaddr = (unsigned long)ioremap(LANCE_OBIO, PAGE_SIZE);
@@ -379,7 +378,7 @@ static int __init lance_probe( struct net_device *dev)
379 MEM->init.hwaddr[4] = dev->dev_addr[5]; 378 MEM->init.hwaddr[4] = dev->dev_addr[5];
380 MEM->init.hwaddr[5] = dev->dev_addr[4]; 379 MEM->init.hwaddr[5] = dev->dev_addr[4];
381 380
382 printk("%s\n", print_mac(mac, dev->dev_addr)); 381 printk("%pM\n", dev->dev_addr);
383 382
384 MEM->init.mode = 0x0000; 383 MEM->init.mode = 0x0000;
385 MEM->init.filter[0] = 0x00000000; 384 MEM->init.filter[0] = 0x00000000;
@@ -824,12 +823,10 @@ static int lance_rx( struct net_device *dev )
824#if 0 823#if 0
825 if (lance_debug >= 3) { 824 if (lance_debug >= 3) {
826 u_char *data = PKTBUF_ADDR(head); 825 u_char *data = PKTBUF_ADDR(head);
827 DECLARE_MAC_BUF(mac);
828 DECLARE_MAC_BUF(mac2)
829 printk("%s: RX pkt %d type 0x%04x" 826 printk("%s: RX pkt %d type 0x%04x"
830 " from %s to %s", 827 " from %pM to %pM",
831 dev->name, lp->new_tx, ((u_short *)data)[6], 828 dev->name, lp->new_tx, ((u_short *)data)[6],
832 print_mac(mac, &data[6]), print_mac(mac2, data)); 829 &data[6], data);
833 830
834 printk(" data %02x %02x %02x %02x %02x %02x %02x %02x " 831 printk(" data %02x %02x %02x %02x %02x %02x %02x %02x "
835 "len %d at %08x\n", 832 "len %d at %08x\n",
@@ -852,7 +849,6 @@ static int lance_rx( struct net_device *dev )
852 849
853 skb->protocol = eth_type_trans( skb, dev ); 850 skb->protocol = eth_type_trans( skb, dev );
854 netif_rx( skb ); 851 netif_rx( skb );
855 dev->last_rx = jiffies;
856 dev->stats.rx_packets++; 852 dev->stats.rx_packets++;
857 dev->stats.rx_bytes += pkt_len; 853 dev->stats.rx_bytes += pkt_len;
858 } 854 }
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 018d0fca9422..977b3e08bbfc 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -878,7 +878,6 @@ static void bigmac_rx(struct bigmac *bp)
878 /* No checksums done by the BigMAC ;-( */ 878 /* No checksums done by the BigMAC ;-( */
879 skb->protocol = eth_type_trans(skb, bp->dev); 879 skb->protocol = eth_type_trans(skb, bp->dev);
880 netif_rx(skb); 880 netif_rx(skb);
881 bp->dev->last_rx = jiffies;
882 bp->enet_stats.rx_packets++; 881 bp->enet_stats.rx_packets++;
883 bp->enet_stats.rx_bytes += len; 882 bp->enet_stats.rx_bytes += len;
884 next: 883 next:
@@ -917,7 +916,7 @@ static irqreturn_t bigmac_interrupt(int irq, void *dev_id)
917 916
918static int bigmac_open(struct net_device *dev) 917static int bigmac_open(struct net_device *dev)
919{ 918{
920 struct bigmac *bp = (struct bigmac *) dev->priv; 919 struct bigmac *bp = netdev_priv(dev);
921 int ret; 920 int ret;
922 921
923 ret = request_irq(dev->irq, &bigmac_interrupt, IRQF_SHARED, dev->name, bp); 922 ret = request_irq(dev->irq, &bigmac_interrupt, IRQF_SHARED, dev->name, bp);
@@ -934,7 +933,7 @@ static int bigmac_open(struct net_device *dev)
934 933
935static int bigmac_close(struct net_device *dev) 934static int bigmac_close(struct net_device *dev)
936{ 935{
937 struct bigmac *bp = (struct bigmac *) dev->priv; 936 struct bigmac *bp = netdev_priv(dev);
938 937
939 del_timer(&bp->bigmac_timer); 938 del_timer(&bp->bigmac_timer);
940 bp->timer_state = asleep; 939 bp->timer_state = asleep;
@@ -948,7 +947,7 @@ static int bigmac_close(struct net_device *dev)
948 947
949static void bigmac_tx_timeout(struct net_device *dev) 948static void bigmac_tx_timeout(struct net_device *dev)
950{ 949{
951 struct bigmac *bp = (struct bigmac *) dev->priv; 950 struct bigmac *bp = netdev_priv(dev);
952 951
953 bigmac_init_hw(bp, 0); 952 bigmac_init_hw(bp, 0);
954 netif_wake_queue(dev); 953 netif_wake_queue(dev);
@@ -957,7 +956,7 @@ static void bigmac_tx_timeout(struct net_device *dev)
957/* Put a packet on the wire. */ 956/* Put a packet on the wire. */
958static int bigmac_start_xmit(struct sk_buff *skb, struct net_device *dev) 957static int bigmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
959{ 958{
960 struct bigmac *bp = (struct bigmac *) dev->priv; 959 struct bigmac *bp = netdev_priv(dev);
961 int len, entry; 960 int len, entry;
962 u32 mapping; 961 u32 mapping;
963 962
@@ -990,7 +989,7 @@ static int bigmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
990 989
991static struct net_device_stats *bigmac_get_stats(struct net_device *dev) 990static struct net_device_stats *bigmac_get_stats(struct net_device *dev)
992{ 991{
993 struct bigmac *bp = (struct bigmac *) dev->priv; 992 struct bigmac *bp = netdev_priv(dev);
994 993
995 bigmac_get_counters(bp, bp->bregs); 994 bigmac_get_counters(bp, bp->bregs);
996 return &bp->enet_stats; 995 return &bp->enet_stats;
@@ -998,7 +997,7 @@ static struct net_device_stats *bigmac_get_stats(struct net_device *dev)
998 997
999static void bigmac_set_multicast(struct net_device *dev) 998static void bigmac_set_multicast(struct net_device *dev)
1000{ 999{
1001 struct bigmac *bp = (struct bigmac *) dev->priv; 1000 struct bigmac *bp = netdev_priv(dev);
1002 void __iomem *bregs = bp->bregs; 1001 void __iomem *bregs = bp->bregs;
1003 struct dev_mc_list *dmi = dev->mc_list; 1002 struct dev_mc_list *dmi = dev->mc_list;
1004 char *addrs; 1003 char *addrs;
@@ -1061,7 +1060,7 @@ static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
1061 1060
1062static u32 bigmac_get_link(struct net_device *dev) 1061static u32 bigmac_get_link(struct net_device *dev)
1063{ 1062{
1064 struct bigmac *bp = dev->priv; 1063 struct bigmac *bp = netdev_priv(dev);
1065 1064
1066 spin_lock_irq(&bp->lock); 1065 spin_lock_irq(&bp->lock);
1067 bp->sw_bmsr = bigmac_tcvr_read(bp, bp->tregs, BIGMAC_BMSR); 1066 bp->sw_bmsr = bigmac_tcvr_read(bp, bp->tregs, BIGMAC_BMSR);
@@ -1081,7 +1080,6 @@ static int __devinit bigmac_ether_init(struct of_device *op,
1081 static int version_printed; 1080 static int version_printed;
1082 struct net_device *dev; 1081 struct net_device *dev;
1083 u8 bsizes, bsizes_more; 1082 u8 bsizes, bsizes_more;
1084 DECLARE_MAC_BUF(mac);
1085 struct bigmac *bp; 1083 struct bigmac *bp;
1086 int i; 1084 int i;
1087 1085
@@ -1212,8 +1210,8 @@ static int __devinit bigmac_ether_init(struct of_device *op,
1212 1210
1213 dev_set_drvdata(&bp->bigmac_op->dev, bp); 1211 dev_set_drvdata(&bp->bigmac_op->dev, bp);
1214 1212
1215 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet %s\n", 1213 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet %pM\n",
1216 dev->name, print_mac(mac, dev->dev_addr)); 1214 dev->name, dev->dev_addr);
1217 1215
1218 return 0; 1216 return 0;
1219 1217
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index f860ea150395..698893b92003 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -468,7 +468,6 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
468 int bar = 1; 468 int bar = 1;
469#endif 469#endif
470 int phy, phy_end, phy_idx = 0; 470 int phy, phy_end, phy_idx = 0;
471 DECLARE_MAC_BUF(mac);
472 471
473/* when built into the kernel, we only print version if device is found */ 472/* when built into the kernel, we only print version if device is found */
474#ifndef MODULE 473#ifndef MODULE
@@ -547,9 +546,9 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
547 if (i) 546 if (i)
548 goto err_out_unmap_rx; 547 goto err_out_unmap_rx;
549 548
550 printk(KERN_INFO "%s: %s at %p, %s, IRQ %d.\n", 549 printk(KERN_INFO "%s: %s at %p, %pM, IRQ %d.\n",
551 dev->name, pci_id_tbl[chip_idx].name, ioaddr, 550 dev->name, pci_id_tbl[chip_idx].name, ioaddr,
552 print_mac(mac, dev->dev_addr), irq); 551 dev->dev_addr, irq);
553 552
554 np->phys[0] = 1; /* Default setting */ 553 np->phys[0] = 1; /* Default setting */
555 np->mii_preamble_required++; 554 np->mii_preamble_required++;
@@ -1351,7 +1350,6 @@ static void rx_poll(unsigned long data)
1351 skb->protocol = eth_type_trans(skb, dev); 1350 skb->protocol = eth_type_trans(skb, dev);
1352 /* Note: checksum -> skb->ip_summed = CHECKSUM_UNNECESSARY; */ 1351 /* Note: checksum -> skb->ip_summed = CHECKSUM_UNNECESSARY; */
1353 netif_rx(skb); 1352 netif_rx(skb);
1354 dev->last_rx = jiffies;
1355 } 1353 }
1356 entry = (entry + 1) % RX_RING_SIZE; 1354 entry = (entry + 1) % RX_RING_SIZE;
1357 received++; 1355 received++;
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 4291458955ef..44be8dfbcf17 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -164,7 +164,7 @@ static u16 __phy_read(struct gem *gp, int phy_addr, int reg)
164 164
165static inline int _phy_read(struct net_device *dev, int mii_id, int reg) 165static inline int _phy_read(struct net_device *dev, int mii_id, int reg)
166{ 166{
167 struct gem *gp = dev->priv; 167 struct gem *gp = netdev_priv(dev);
168 return __phy_read(gp, mii_id, reg); 168 return __phy_read(gp, mii_id, reg);
169} 169}
170 170
@@ -197,7 +197,7 @@ static void __phy_write(struct gem *gp, int phy_addr, int reg, u16 val)
197 197
198static inline void _phy_write(struct net_device *dev, int mii_id, int reg, int val) 198static inline void _phy_write(struct net_device *dev, int mii_id, int reg, int val)
199{ 199{
200 struct gem *gp = dev->priv; 200 struct gem *gp = netdev_priv(dev);
201 __phy_write(gp, mii_id, reg, val & 0xffff); 201 __phy_write(gp, mii_id, reg, val & 0xffff);
202} 202}
203 203
@@ -863,7 +863,6 @@ static int gem_rx(struct gem *gp, int work_to_do)
863 863
864 gp->net_stats.rx_packets++; 864 gp->net_stats.rx_packets++;
865 gp->net_stats.rx_bytes += len; 865 gp->net_stats.rx_bytes += len;
866 gp->dev->last_rx = jiffies;
867 866
868 next: 867 next:
869 entry = NEXT_RX(entry); 868 entry = NEXT_RX(entry);
@@ -933,7 +932,7 @@ static int gem_poll(struct napi_struct *napi, int budget)
933static irqreturn_t gem_interrupt(int irq, void *dev_id) 932static irqreturn_t gem_interrupt(int irq, void *dev_id)
934{ 933{
935 struct net_device *dev = dev_id; 934 struct net_device *dev = dev_id;
936 struct gem *gp = dev->priv; 935 struct gem *gp = netdev_priv(dev);
937 unsigned long flags; 936 unsigned long flags;
938 937
939 /* Swallow interrupts when shutting the chip down, though 938 /* Swallow interrupts when shutting the chip down, though
@@ -979,7 +978,7 @@ static void gem_poll_controller(struct net_device *dev)
979 978
980static void gem_tx_timeout(struct net_device *dev) 979static void gem_tx_timeout(struct net_device *dev)
981{ 980{
982 struct gem *gp = dev->priv; 981 struct gem *gp = netdev_priv(dev);
983 982
984 printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name); 983 printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
985 if (!gp->running) { 984 if (!gp->running) {
@@ -1018,7 +1017,7 @@ static __inline__ int gem_intme(int entry)
1018 1017
1019static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev) 1018static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev)
1020{ 1019{
1021 struct gem *gp = dev->priv; 1020 struct gem *gp = netdev_priv(dev);
1022 int entry; 1021 int entry;
1023 u64 ctrl; 1022 u64 ctrl;
1024 unsigned long flags; 1023 unsigned long flags;
@@ -2191,7 +2190,7 @@ static void gem_stop_phy(struct gem *gp, int wol)
2191 2190
2192static int gem_do_start(struct net_device *dev) 2191static int gem_do_start(struct net_device *dev)
2193{ 2192{
2194 struct gem *gp = dev->priv; 2193 struct gem *gp = netdev_priv(dev);
2195 unsigned long flags; 2194 unsigned long flags;
2196 2195
2197 spin_lock_irqsave(&gp->lock, flags); 2196 spin_lock_irqsave(&gp->lock, flags);
@@ -2238,7 +2237,7 @@ static int gem_do_start(struct net_device *dev)
2238 2237
2239static void gem_do_stop(struct net_device *dev, int wol) 2238static void gem_do_stop(struct net_device *dev, int wol)
2240{ 2239{
2241 struct gem *gp = dev->priv; 2240 struct gem *gp = netdev_priv(dev);
2242 unsigned long flags; 2241 unsigned long flags;
2243 2242
2244 spin_lock_irqsave(&gp->lock, flags); 2243 spin_lock_irqsave(&gp->lock, flags);
@@ -2313,7 +2312,7 @@ static void gem_reset_task(struct work_struct *work)
2313 2312
2314static int gem_open(struct net_device *dev) 2313static int gem_open(struct net_device *dev)
2315{ 2314{
2316 struct gem *gp = dev->priv; 2315 struct gem *gp = netdev_priv(dev);
2317 int rc = 0; 2316 int rc = 0;
2318 2317
2319 mutex_lock(&gp->pm_mutex); 2318 mutex_lock(&gp->pm_mutex);
@@ -2332,7 +2331,7 @@ static int gem_open(struct net_device *dev)
2332 2331
2333static int gem_close(struct net_device *dev) 2332static int gem_close(struct net_device *dev)
2334{ 2333{
2335 struct gem *gp = dev->priv; 2334 struct gem *gp = netdev_priv(dev);
2336 2335
2337 mutex_lock(&gp->pm_mutex); 2336 mutex_lock(&gp->pm_mutex);
2338 2337
@@ -2351,7 +2350,7 @@ static int gem_close(struct net_device *dev)
2351static int gem_suspend(struct pci_dev *pdev, pm_message_t state) 2350static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
2352{ 2351{
2353 struct net_device *dev = pci_get_drvdata(pdev); 2352 struct net_device *dev = pci_get_drvdata(pdev);
2354 struct gem *gp = dev->priv; 2353 struct gem *gp = netdev_priv(dev);
2355 unsigned long flags; 2354 unsigned long flags;
2356 2355
2357 mutex_lock(&gp->pm_mutex); 2356 mutex_lock(&gp->pm_mutex);
@@ -2415,7 +2414,7 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
2415static int gem_resume(struct pci_dev *pdev) 2414static int gem_resume(struct pci_dev *pdev)
2416{ 2415{
2417 struct net_device *dev = pci_get_drvdata(pdev); 2416 struct net_device *dev = pci_get_drvdata(pdev);
2418 struct gem *gp = dev->priv; 2417 struct gem *gp = netdev_priv(dev);
2419 unsigned long flags; 2418 unsigned long flags;
2420 2419
2421 printk(KERN_INFO "%s: resuming\n", dev->name); 2420 printk(KERN_INFO "%s: resuming\n", dev->name);
@@ -2489,7 +2488,7 @@ static int gem_resume(struct pci_dev *pdev)
2489 2488
2490static struct net_device_stats *gem_get_stats(struct net_device *dev) 2489static struct net_device_stats *gem_get_stats(struct net_device *dev)
2491{ 2490{
2492 struct gem *gp = dev->priv; 2491 struct gem *gp = netdev_priv(dev);
2493 struct net_device_stats *stats = &gp->net_stats; 2492 struct net_device_stats *stats = &gp->net_stats;
2494 2493
2495 spin_lock_irq(&gp->lock); 2494 spin_lock_irq(&gp->lock);
@@ -2525,7 +2524,7 @@ static struct net_device_stats *gem_get_stats(struct net_device *dev)
2525static int gem_set_mac_address(struct net_device *dev, void *addr) 2524static int gem_set_mac_address(struct net_device *dev, void *addr)
2526{ 2525{
2527 struct sockaddr *macaddr = (struct sockaddr *) addr; 2526 struct sockaddr *macaddr = (struct sockaddr *) addr;
2528 struct gem *gp = dev->priv; 2527 struct gem *gp = netdev_priv(dev);
2529 unsigned char *e = &dev->dev_addr[0]; 2528 unsigned char *e = &dev->dev_addr[0];
2530 2529
2531 if (!is_valid_ether_addr(macaddr->sa_data)) 2530 if (!is_valid_ether_addr(macaddr->sa_data))
@@ -2553,7 +2552,7 @@ static int gem_set_mac_address(struct net_device *dev, void *addr)
2553 2552
2554static void gem_set_multicast(struct net_device *dev) 2553static void gem_set_multicast(struct net_device *dev)
2555{ 2554{
2556 struct gem *gp = dev->priv; 2555 struct gem *gp = netdev_priv(dev);
2557 u32 rxcfg, rxcfg_new; 2556 u32 rxcfg, rxcfg_new;
2558 int limit = 10000; 2557 int limit = 10000;
2559 2558
@@ -2602,7 +2601,7 @@ static void gem_set_multicast(struct net_device *dev)
2602 2601
2603static int gem_change_mtu(struct net_device *dev, int new_mtu) 2602static int gem_change_mtu(struct net_device *dev, int new_mtu)
2604{ 2603{
2605 struct gem *gp = dev->priv; 2604 struct gem *gp = netdev_priv(dev);
2606 2605
2607 if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU) 2606 if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU)
2608 return -EINVAL; 2607 return -EINVAL;
@@ -2633,7 +2632,7 @@ static int gem_change_mtu(struct net_device *dev, int new_mtu)
2633 2632
2634static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 2633static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2635{ 2634{
2636 struct gem *gp = dev->priv; 2635 struct gem *gp = netdev_priv(dev);
2637 2636
2638 strcpy(info->driver, DRV_NAME); 2637 strcpy(info->driver, DRV_NAME);
2639 strcpy(info->version, DRV_VERSION); 2638 strcpy(info->version, DRV_VERSION);
@@ -2642,7 +2641,7 @@ static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
2642 2641
2643static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2642static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2644{ 2643{
2645 struct gem *gp = dev->priv; 2644 struct gem *gp = netdev_priv(dev);
2646 2645
2647 if (gp->phy_type == phy_mii_mdio0 || 2646 if (gp->phy_type == phy_mii_mdio0 ||
2648 gp->phy_type == phy_mii_mdio1) { 2647 gp->phy_type == phy_mii_mdio1) {
@@ -2688,7 +2687,7 @@ static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2688 2687
2689static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2688static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2690{ 2689{
2691 struct gem *gp = dev->priv; 2690 struct gem *gp = netdev_priv(dev);
2692 2691
2693 /* Verify the settings we care about. */ 2692 /* Verify the settings we care about. */
2694 if (cmd->autoneg != AUTONEG_ENABLE && 2693 if (cmd->autoneg != AUTONEG_ENABLE &&
@@ -2719,7 +2718,7 @@ static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2719 2718
2720static int gem_nway_reset(struct net_device *dev) 2719static int gem_nway_reset(struct net_device *dev)
2721{ 2720{
2722 struct gem *gp = dev->priv; 2721 struct gem *gp = netdev_priv(dev);
2723 2722
2724 if (!gp->want_autoneg) 2723 if (!gp->want_autoneg)
2725 return -EINVAL; 2724 return -EINVAL;
@@ -2736,13 +2735,13 @@ static int gem_nway_reset(struct net_device *dev)
2736 2735
2737static u32 gem_get_msglevel(struct net_device *dev) 2736static u32 gem_get_msglevel(struct net_device *dev)
2738{ 2737{
2739 struct gem *gp = dev->priv; 2738 struct gem *gp = netdev_priv(dev);
2740 return gp->msg_enable; 2739 return gp->msg_enable;
2741} 2740}
2742 2741
2743static void gem_set_msglevel(struct net_device *dev, u32 value) 2742static void gem_set_msglevel(struct net_device *dev, u32 value)
2744{ 2743{
2745 struct gem *gp = dev->priv; 2744 struct gem *gp = netdev_priv(dev);
2746 gp->msg_enable = value; 2745 gp->msg_enable = value;
2747} 2746}
2748 2747
@@ -2754,7 +2753,7 @@ static void gem_set_msglevel(struct net_device *dev, u32 value)
2754 2753
2755static void gem_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2754static void gem_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2756{ 2755{
2757 struct gem *gp = dev->priv; 2756 struct gem *gp = netdev_priv(dev);
2758 2757
2759 /* Add more when I understand how to program the chip */ 2758 /* Add more when I understand how to program the chip */
2760 if (gp->has_wol) { 2759 if (gp->has_wol) {
@@ -2768,7 +2767,7 @@ static void gem_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2768 2767
2769static int gem_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2768static int gem_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2770{ 2769{
2771 struct gem *gp = dev->priv; 2770 struct gem *gp = netdev_priv(dev);
2772 2771
2773 if (!gp->has_wol) 2772 if (!gp->has_wol)
2774 return -EOPNOTSUPP; 2773 return -EOPNOTSUPP;
@@ -2790,7 +2789,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
2790 2789
2791static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2790static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2792{ 2791{
2793 struct gem *gp = dev->priv; 2792 struct gem *gp = netdev_priv(dev);
2794 struct mii_ioctl_data *data = if_mii(ifr); 2793 struct mii_ioctl_data *data = if_mii(ifr);
2795 int rc = -EOPNOTSUPP; 2794 int rc = -EOPNOTSUPP;
2796 unsigned long flags; 2795 unsigned long flags;
@@ -2922,7 +2921,7 @@ static void gem_remove_one(struct pci_dev *pdev)
2922 struct net_device *dev = pci_get_drvdata(pdev); 2921 struct net_device *dev = pci_get_drvdata(pdev);
2923 2922
2924 if (dev) { 2923 if (dev) {
2925 struct gem *gp = dev->priv; 2924 struct gem *gp = netdev_priv(dev);
2926 2925
2927 unregister_netdev(dev); 2926 unregister_netdev(dev);
2928 2927
@@ -2966,7 +2965,6 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
2966 struct net_device *dev; 2965 struct net_device *dev;
2967 struct gem *gp; 2966 struct gem *gp;
2968 int err, pci_using_dac; 2967 int err, pci_using_dac;
2969 DECLARE_MAC_BUF(mac);
2970 2968
2971 if (gem_version_printed++ == 0) 2969 if (gem_version_printed++ == 0)
2972 printk(KERN_INFO "%s", version); 2970 printk(KERN_INFO "%s", version);
@@ -3026,7 +3024,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3026 } 3024 }
3027 SET_NETDEV_DEV(dev, &pdev->dev); 3025 SET_NETDEV_DEV(dev, &pdev->dev);
3028 3026
3029 gp = dev->priv; 3027 gp = netdev_priv(dev);
3030 3028
3031 err = pci_request_regions(pdev, DRV_NAME); 3029 err = pci_request_regions(pdev, DRV_NAME);
3032 if (err) { 3030 if (err) {
@@ -3150,9 +3148,8 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3150 goto err_out_free_consistent; 3148 goto err_out_free_consistent;
3151 } 3149 }
3152 3150
3153 printk(KERN_INFO "%s: Sun GEM (PCI) 10/100/1000BaseT Ethernet " 3151 printk(KERN_INFO "%s: Sun GEM (PCI) 10/100/1000BaseT Ethernet %pM\n",
3154 "%s\n", 3152 dev->name, dev->dev_addr);
3155 dev->name, print_mac(mac, dev->dev_addr));
3156 3153
3157 if (gp->phy_type == phy_mii_mdio0 || 3154 if (gp->phy_type == phy_mii_mdio0 ||
3158 gp->phy_type == phy_mii_mdio1) 3155 gp->phy_type == phy_mii_mdio1)
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index f1ebeb5f65b2..b22d3355fb45 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2072,7 +2072,6 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
2072 skb->protocol = eth_type_trans(skb, dev); 2072 skb->protocol = eth_type_trans(skb, dev);
2073 netif_rx(skb); 2073 netif_rx(skb);
2074 2074
2075 dev->last_rx = jiffies;
2076 hp->net_stats.rx_packets++; 2075 hp->net_stats.rx_packets++;
2077 hp->net_stats.rx_bytes += len; 2076 hp->net_stats.rx_bytes += len;
2078 next: 2077 next:
@@ -2131,7 +2130,7 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie)
2131 2130
2132 for (i = 0; i < 4; i++) { 2131 for (i = 0; i < 4; i++) {
2133 struct net_device *dev = qp->happy_meals[i]; 2132 struct net_device *dev = qp->happy_meals[i];
2134 struct happy_meal *hp = dev->priv; 2133 struct happy_meal *hp = netdev_priv(dev);
2135 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); 2134 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT);
2136 2135
2137 HMD(("quattro_interrupt: status=%08x ", happy_status)); 2136 HMD(("quattro_interrupt: status=%08x ", happy_status));
@@ -2176,7 +2175,7 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie)
2176 2175
2177static int happy_meal_open(struct net_device *dev) 2176static int happy_meal_open(struct net_device *dev)
2178{ 2177{
2179 struct happy_meal *hp = dev->priv; 2178 struct happy_meal *hp = netdev_priv(dev);
2180 int res; 2179 int res;
2181 2180
2182 HMD(("happy_meal_open: ")); 2181 HMD(("happy_meal_open: "));
@@ -2208,7 +2207,7 @@ static int happy_meal_open(struct net_device *dev)
2208 2207
2209static int happy_meal_close(struct net_device *dev) 2208static int happy_meal_close(struct net_device *dev)
2210{ 2209{
2211 struct happy_meal *hp = dev->priv; 2210 struct happy_meal *hp = netdev_priv(dev);
2212 2211
2213 spin_lock_irq(&hp->happy_lock); 2212 spin_lock_irq(&hp->happy_lock);
2214 happy_meal_stop(hp, hp->gregs); 2213 happy_meal_stop(hp, hp->gregs);
@@ -2237,7 +2236,7 @@ static int happy_meal_close(struct net_device *dev)
2237 2236
2238static void happy_meal_tx_timeout(struct net_device *dev) 2237static void happy_meal_tx_timeout(struct net_device *dev)
2239{ 2238{
2240 struct happy_meal *hp = dev->priv; 2239 struct happy_meal *hp = netdev_priv(dev);
2241 2240
2242 printk (KERN_ERR "%s: transmit timed out, resetting\n", dev->name); 2241 printk (KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
2243 tx_dump_log(); 2242 tx_dump_log();
@@ -2255,7 +2254,7 @@ static void happy_meal_tx_timeout(struct net_device *dev)
2255 2254
2256static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) 2255static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
2257{ 2256{
2258 struct happy_meal *hp = dev->priv; 2257 struct happy_meal *hp = netdev_priv(dev);
2259 int entry; 2258 int entry;
2260 u32 tx_flags; 2259 u32 tx_flags;
2261 2260
@@ -2344,7 +2343,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
2344 2343
2345static struct net_device_stats *happy_meal_get_stats(struct net_device *dev) 2344static struct net_device_stats *happy_meal_get_stats(struct net_device *dev)
2346{ 2345{
2347 struct happy_meal *hp = dev->priv; 2346 struct happy_meal *hp = netdev_priv(dev);
2348 2347
2349 spin_lock_irq(&hp->happy_lock); 2348 spin_lock_irq(&hp->happy_lock);
2350 happy_meal_get_counters(hp, hp->bigmacregs); 2349 happy_meal_get_counters(hp, hp->bigmacregs);
@@ -2355,7 +2354,7 @@ static struct net_device_stats *happy_meal_get_stats(struct net_device *dev)
2355 2354
2356static void happy_meal_set_multicast(struct net_device *dev) 2355static void happy_meal_set_multicast(struct net_device *dev)
2357{ 2356{
2358 struct happy_meal *hp = dev->priv; 2357 struct happy_meal *hp = netdev_priv(dev);
2359 void __iomem *bregs = hp->bigmacregs; 2358 void __iomem *bregs = hp->bigmacregs;
2360 struct dev_mc_list *dmi = dev->mc_list; 2359 struct dev_mc_list *dmi = dev->mc_list;
2361 char *addrs; 2360 char *addrs;
@@ -2401,7 +2400,7 @@ static void happy_meal_set_multicast(struct net_device *dev)
2401/* Ethtool support... */ 2400/* Ethtool support... */
2402static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2401static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2403{ 2402{
2404 struct happy_meal *hp = dev->priv; 2403 struct happy_meal *hp = netdev_priv(dev);
2405 2404
2406 cmd->supported = 2405 cmd->supported =
2407 (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | 2406 (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
@@ -2446,7 +2445,7 @@ static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2446 2445
2447static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2446static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2448{ 2447{
2449 struct happy_meal *hp = dev->priv; 2448 struct happy_meal *hp = netdev_priv(dev);
2450 2449
2451 /* Verify the settings we care about. */ 2450 /* Verify the settings we care about. */
2452 if (cmd->autoneg != AUTONEG_ENABLE && 2451 if (cmd->autoneg != AUTONEG_ENABLE &&
@@ -2470,7 +2469,7 @@ static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2470 2469
2471static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 2470static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2472{ 2471{
2473 struct happy_meal *hp = dev->priv; 2472 struct happy_meal *hp = netdev_priv(dev);
2474 2473
2475 strcpy(info->driver, "sunhme"); 2474 strcpy(info->driver, "sunhme");
2476 strcpy(info->version, "2.02"); 2475 strcpy(info->version, "2.02");
@@ -2492,7 +2491,7 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
2492 2491
2493static u32 hme_get_link(struct net_device *dev) 2492static u32 hme_get_link(struct net_device *dev)
2494{ 2493{
2495 struct happy_meal *hp = dev->priv; 2494 struct happy_meal *hp = netdev_priv(dev);
2496 2495
2497 spin_lock_irq(&hp->happy_lock); 2496 spin_lock_irq(&hp->happy_lock);
2498 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); 2497 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
@@ -2617,7 +2616,6 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2617 struct net_device *dev; 2616 struct net_device *dev;
2618 int i, qfe_slot = -1; 2617 int i, qfe_slot = -1;
2619 int err = -ENODEV; 2618 int err = -ENODEV;
2620 DECLARE_MAC_BUF(mac);
2621 2619
2622 if (is_qfe) { 2620 if (is_qfe) {
2623 qp = quattro_sbus_find(op); 2621 qp = quattro_sbus_find(op);
@@ -2797,7 +2795,7 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2797 printk(KERN_INFO "%s: HAPPY MEAL (SBUS) 10/100baseT Ethernet ", 2795 printk(KERN_INFO "%s: HAPPY MEAL (SBUS) 10/100baseT Ethernet ",
2798 dev->name); 2796 dev->name);
2799 2797
2800 printk("%s\n", print_mac(mac, dev->dev_addr)); 2798 printk("%pM\n", dev->dev_addr);
2801 2799
2802 return 0; 2800 return 0;
2803 2801
@@ -2932,7 +2930,6 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
2932 int i, qfe_slot = -1; 2930 int i, qfe_slot = -1;
2933 char prom_name[64]; 2931 char prom_name[64];
2934 int err; 2932 int err;
2935 DECLARE_MAC_BUF(mac);
2936 2933
2937 /* Now make sure pci_dev cookie is there. */ 2934 /* Now make sure pci_dev cookie is there. */
2938#ifdef CONFIG_SPARC 2935#ifdef CONFIG_SPARC
@@ -2973,7 +2970,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
2973 2970
2974 dev->base_addr = (long) pdev; 2971 dev->base_addr = (long) pdev;
2975 2972
2976 hp = (struct happy_meal *)dev->priv; 2973 hp = netdev_priv(dev);
2977 memset(hp, 0, sizeof(*hp)); 2974 memset(hp, 0, sizeof(*hp));
2978 2975
2979 hp->happy_dev = pdev; 2976 hp->happy_dev = pdev;
@@ -3141,7 +3138,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
3141 printk(KERN_INFO "%s: HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ", 3138 printk(KERN_INFO "%s: HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ",
3142 dev->name); 3139 dev->name);
3143 3140
3144 printk("%s\n", print_mac(mac, dev->dev_addr)); 3141 printk("%pM\n", dev->dev_addr);
3145 3142
3146 return 0; 3143 return 0;
3147 3144
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 704301a5a7ff..281373281756 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -555,7 +555,6 @@ static void lance_rx_dvma(struct net_device *dev)
555 len); 555 len);
556 skb->protocol = eth_type_trans(skb, dev); 556 skb->protocol = eth_type_trans(skb, dev);
557 netif_rx(skb); 557 netif_rx(skb);
558 dev->last_rx = jiffies;
559 dev->stats.rx_packets++; 558 dev->stats.rx_packets++;
560 } 559 }
561 560
@@ -726,7 +725,6 @@ static void lance_rx_pio(struct net_device *dev)
726 lance_piocopy_to_skb(skb, &(ib->rx_buf[entry][0]), len); 725 lance_piocopy_to_skb(skb, &(ib->rx_buf[entry][0]), len);
727 skb->protocol = eth_type_trans(skb, dev); 726 skb->protocol = eth_type_trans(skb, dev);
728 netif_rx(skb); 727 netif_rx(skb);
729 dev->last_rx = jiffies;
730 dev->stats.rx_packets++; 728 dev->stats.rx_packets++;
731 } 729 }
732 730
@@ -1321,7 +1319,6 @@ static int __devinit sparc_lance_probe_one(struct of_device *op,
1321 static unsigned version_printed; 1319 static unsigned version_printed;
1322 struct lance_private *lp; 1320 struct lance_private *lp;
1323 struct net_device *dev; 1321 struct net_device *dev;
1324 DECLARE_MAC_BUF(mac);
1325 int i; 1322 int i;
1326 1323
1327 dev = alloc_etherdev(sizeof(struct lance_private) + 8); 1324 dev = alloc_etherdev(sizeof(struct lance_private) + 8);
@@ -1491,8 +1488,8 @@ no_link_test:
1491 1488
1492 dev_set_drvdata(&op->dev, lp); 1489 dev_set_drvdata(&op->dev, lp);
1493 1490
1494 printk(KERN_INFO "%s: LANCE %s\n", 1491 printk(KERN_INFO "%s: LANCE %pM\n",
1495 dev->name, print_mac(mac, dev->dev_addr)); 1492 dev->name, dev->dev_addr);
1496 1493
1497 return 0; 1494 return 0;
1498 1495
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index f63644744ff9..6e8f377355fe 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -446,7 +446,6 @@ static void qe_rx(struct sunqe *qep)
446 len); 446 len);
447 skb->protocol = eth_type_trans(skb, qep->dev); 447 skb->protocol = eth_type_trans(skb, qep->dev);
448 netif_rx(skb); 448 netif_rx(skb);
449 qep->dev->last_rx = jiffies;
450 dev->stats.rx_packets++; 449 dev->stats.rx_packets++;
451 dev->stats.rx_bytes += len; 450 dev->stats.rx_bytes += len;
452 } 451 }
@@ -513,7 +512,7 @@ static irqreturn_t qec_interrupt(int irq, void *dev_id)
513 512
514static int qe_open(struct net_device *dev) 513static int qe_open(struct net_device *dev)
515{ 514{
516 struct sunqe *qep = (struct sunqe *) dev->priv; 515 struct sunqe *qep = netdev_priv(dev);
517 516
518 qep->mconfig = (MREGS_MCONFIG_TXENAB | 517 qep->mconfig = (MREGS_MCONFIG_TXENAB |
519 MREGS_MCONFIG_RXENAB | 518 MREGS_MCONFIG_RXENAB |
@@ -523,7 +522,7 @@ static int qe_open(struct net_device *dev)
523 522
524static int qe_close(struct net_device *dev) 523static int qe_close(struct net_device *dev)
525{ 524{
526 struct sunqe *qep = (struct sunqe *) dev->priv; 525 struct sunqe *qep = netdev_priv(dev);
527 526
528 qe_stop(qep); 527 qe_stop(qep);
529 return 0; 528 return 0;
@@ -549,7 +548,7 @@ static void qe_tx_reclaim(struct sunqe *qep)
549 548
550static void qe_tx_timeout(struct net_device *dev) 549static void qe_tx_timeout(struct net_device *dev)
551{ 550{
552 struct sunqe *qep = (struct sunqe *) dev->priv; 551 struct sunqe *qep = netdev_priv(dev);
553 int tx_full; 552 int tx_full;
554 553
555 spin_lock_irq(&qep->lock); 554 spin_lock_irq(&qep->lock);
@@ -575,7 +574,7 @@ out:
575/* Get a packet queued to go onto the wire. */ 574/* Get a packet queued to go onto the wire. */
576static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev) 575static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev)
577{ 576{
578 struct sunqe *qep = (struct sunqe *) dev->priv; 577 struct sunqe *qep = netdev_priv(dev);
579 struct sunqe_buffers *qbufs = qep->buffers; 578 struct sunqe_buffers *qbufs = qep->buffers;
580 __u32 txbuf_dvma, qbufs_dvma = qep->buffers_dvma; 579 __u32 txbuf_dvma, qbufs_dvma = qep->buffers_dvma;
581 unsigned char *txbuf; 580 unsigned char *txbuf;
@@ -627,7 +626,7 @@ static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev)
627 626
628static void qe_set_multicast(struct net_device *dev) 627static void qe_set_multicast(struct net_device *dev)
629{ 628{
630 struct sunqe *qep = (struct sunqe *) dev->priv; 629 struct sunqe *qep = netdev_priv(dev);
631 struct dev_mc_list *dmi = dev->mc_list; 630 struct dev_mc_list *dmi = dev->mc_list;
632 u8 new_mconfig = qep->mconfig; 631 u8 new_mconfig = qep->mconfig;
633 char *addrs; 632 char *addrs;
@@ -693,7 +692,7 @@ static void qe_set_multicast(struct net_device *dev)
693static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 692static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
694{ 693{
695 const struct linux_prom_registers *regs; 694 const struct linux_prom_registers *regs;
696 struct sunqe *qep = dev->priv; 695 struct sunqe *qep = netdev_priv(dev);
697 struct of_device *op; 696 struct of_device *op;
698 697
699 strcpy(info->driver, "sunqe"); 698 strcpy(info->driver, "sunqe");
@@ -708,7 +707,7 @@ static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
708 707
709static u32 qe_get_link(struct net_device *dev) 708static u32 qe_get_link(struct net_device *dev)
710{ 709{
711 struct sunqe *qep = dev->priv; 710 struct sunqe *qep = netdev_priv(dev);
712 void __iomem *mregs = qep->mregs; 711 void __iomem *mregs = qep->mregs;
713 u8 phyconfig; 712 u8 phyconfig;
714 713
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c
index a720065553df..233f1cda36e5 100644
--- a/drivers/net/sunvnet.c
+++ b/drivers/net/sunvnet.c
@@ -1149,7 +1149,6 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev,
1149 struct vnet *vp; 1149 struct vnet *vp;
1150 const u64 *rmac; 1150 const u64 *rmac;
1151 int len, i, err, switch_port; 1151 int len, i, err, switch_port;
1152 DECLARE_MAC_BUF(mac);
1153 1152
1154 print_version(); 1153 print_version();
1155 1154
@@ -1214,8 +1213,8 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev,
1214 1213
1215 dev_set_drvdata(&vdev->dev, port); 1214 dev_set_drvdata(&vdev->dev, port);
1216 1215
1217 printk(KERN_INFO "%s: PORT ( remote-mac %s%s )\n", 1216 printk(KERN_INFO "%s: PORT ( remote-mac %pM%s )\n",
1218 vp->dev->name, print_mac(mac, port->raddr), 1217 vp->dev->name, port->raddr,
1219 switch_port ? " switch-port" : ""); 1218 switch_port ? " switch-port" : "");
1220 1219
1221 vio_port_up(&port->vio); 1220 vio_port_up(&port->vio);
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index df20cafff7dd..44126c463fac 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -236,7 +236,7 @@ struct tc35815_regs {
236#define Rx_Halted 0x00008000 /* Rx Halted */ 236#define Rx_Halted 0x00008000 /* Rx Halted */
237#define Rx_Good 0x00004000 /* Rx Good */ 237#define Rx_Good 0x00004000 /* Rx Good */
238#define Rx_RxPar 0x00002000 /* Rx Parity Error */ 238#define Rx_RxPar 0x00002000 /* Rx Parity Error */
239 /* 0x00001000 not use */ 239#define Rx_TypePkt 0x00001000 /* Rx Type Packet */
240#define Rx_LongErr 0x00000800 /* Rx Long Error */ 240#define Rx_LongErr 0x00000800 /* Rx Long Error */
241#define Rx_Over 0x00000400 /* Rx Overflow */ 241#define Rx_Over 0x00000400 /* Rx Overflow */
242#define Rx_CRCErr 0x00000200 /* Rx CRC Error */ 242#define Rx_CRCErr 0x00000200 /* Rx CRC Error */
@@ -244,8 +244,9 @@ struct tc35815_regs {
244#define Rx_10Stat 0x00000080 /* Rx 10Mbps Status */ 244#define Rx_10Stat 0x00000080 /* Rx 10Mbps Status */
245#define Rx_IntRx 0x00000040 /* Rx Interrupt */ 245#define Rx_IntRx 0x00000040 /* Rx Interrupt */
246#define Rx_CtlRecd 0x00000020 /* Rx Control Receive */ 246#define Rx_CtlRecd 0x00000020 /* Rx Control Receive */
247#define Rx_InLenErr 0x00000010 /* Rx In Range Frame Length Error */
247 248
248#define Rx_Stat_Mask 0x0000EFC0 /* Rx All Status Mask */ 249#define Rx_Stat_Mask 0x0000FFF0 /* Rx All Status Mask */
249 250
250/* Int_En bit asign -------------------------------------------------------- */ 251/* Int_En bit asign -------------------------------------------------------- */
251#define Int_NRAbtEn 0x00000800 /* 1:Non-recoverable Abort Enable */ 252#define Int_NRAbtEn 0x00000800 /* 1:Non-recoverable Abort Enable */
@@ -865,7 +866,6 @@ static int __devinit tc35815_init_one(struct pci_dev *pdev,
865 struct net_device *dev; 866 struct net_device *dev;
866 struct tc35815_local *lp; 867 struct tc35815_local *lp;
867 int rc; 868 int rc;
868 DECLARE_MAC_BUF(mac);
869 869
870 static int printed_version; 870 static int printed_version;
871 if (!printed_version++) { 871 if (!printed_version++) {
@@ -942,11 +942,11 @@ static int __devinit tc35815_init_one(struct pci_dev *pdev,
942 goto err_out; 942 goto err_out;
943 943
944 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 944 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
945 printk(KERN_INFO "%s: %s at 0x%lx, %s, IRQ %d\n", 945 printk(KERN_INFO "%s: %s at 0x%lx, %pM, IRQ %d\n",
946 dev->name, 946 dev->name,
947 chip_info[ent->driver_data].name, 947 chip_info[ent->driver_data].name,
948 dev->base_addr, 948 dev->base_addr,
949 print_mac(mac, dev->dev_addr), 949 dev->dev_addr,
950 dev->irq); 950 dev->irq);
951 951
952 rc = tc_mii_init(dev); 952 rc = tc_mii_init(dev);
@@ -1288,12 +1288,9 @@ panic_queues(struct net_device *dev)
1288 1288
1289static void print_eth(const u8 *add) 1289static void print_eth(const u8 *add)
1290{ 1290{
1291 DECLARE_MAC_BUF(mac);
1292
1293 printk(KERN_DEBUG "print_eth(%p)\n", add); 1291 printk(KERN_DEBUG "print_eth(%p)\n", add);
1294 printk(KERN_DEBUG " %s =>", print_mac(mac, add + 6)); 1292 printk(KERN_DEBUG " %pM => %pM : %02x%02x\n",
1295 printk(KERN_CONT " %s : %02x%02x\n", 1293 add + 6, add, add[12], add[13]);
1296 print_mac(mac, add), add[12], add[13]);
1297} 1294}
1298 1295
1299static int tc35815_tx_full(struct net_device *dev) 1296static int tc35815_tx_full(struct net_device *dev)
@@ -1760,7 +1757,6 @@ tc35815_rx(struct net_device *dev)
1760#else 1757#else
1761 netif_rx(skb); 1758 netif_rx(skb);
1762#endif 1759#endif
1763 dev->last_rx = jiffies;
1764 dev->stats.rx_packets++; 1760 dev->stats.rx_packets++;
1765 dev->stats.rx_bytes += pkt_len; 1761 dev->stats.rx_bytes += pkt_len;
1766 } else { 1762 } else {
@@ -2153,13 +2149,12 @@ static void tc35815_set_cam_entry(struct net_device *dev, int index, unsigned ch
2153 int cam_index = index * 6; 2149 int cam_index = index * 6;
2154 u32 cam_data; 2150 u32 cam_data;
2155 u32 saved_addr; 2151 u32 saved_addr;
2156 DECLARE_MAC_BUF(mac);
2157 2152
2158 saved_addr = tc_readl(&tr->CAM_Adr); 2153 saved_addr = tc_readl(&tr->CAM_Adr);
2159 2154
2160 if (netif_msg_hw(lp)) 2155 if (netif_msg_hw(lp))
2161 printk(KERN_DEBUG "%s: CAM %d: %s\n", 2156 printk(KERN_DEBUG "%s: CAM %d: %pM\n",
2162 dev->name, index, print_mac(mac, addr)); 2157 dev->name, index, addr);
2163 if (index & 1) { 2158 if (index & 1) {
2164 /* read modify write */ 2159 /* read modify write */
2165 tc_writel(cam_index - 2, &tr->CAM_Adr); 2160 tc_writel(cam_index - 2, &tr->CAM_Adr);
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c
index 91f9054a1d95..7e36a10423f9 100644
--- a/drivers/net/tehuti.c
+++ b/drivers/net/tehuti.c
@@ -251,7 +251,7 @@ static void bdx_isr_extra(struct bdx_priv *priv, u32 isr)
251static irqreturn_t bdx_isr_napi(int irq, void *dev) 251static irqreturn_t bdx_isr_napi(int irq, void *dev)
252{ 252{
253 struct net_device *ndev = dev; 253 struct net_device *ndev = dev;
254 struct bdx_priv *priv = ndev->priv; 254 struct bdx_priv *priv = netdev_priv(ndev);
255 u32 isr; 255 u32 isr;
256 256
257 ENTER; 257 ENTER;
@@ -559,7 +559,7 @@ static int bdx_close(struct net_device *ndev)
559 struct bdx_priv *priv = NULL; 559 struct bdx_priv *priv = NULL;
560 560
561 ENTER; 561 ENTER;
562 priv = ndev->priv; 562 priv = netdev_priv(ndev);
563 563
564 napi_disable(&priv->napi); 564 napi_disable(&priv->napi);
565 565
@@ -588,7 +588,7 @@ static int bdx_open(struct net_device *ndev)
588 int rc; 588 int rc;
589 589
590 ENTER; 590 ENTER;
591 priv = ndev->priv; 591 priv = netdev_priv(ndev);
592 bdx_reset(priv); 592 bdx_reset(priv);
593 if (netif_running(ndev)) 593 if (netif_running(ndev))
594 netif_stop_queue(priv->ndev); 594 netif_stop_queue(priv->ndev);
@@ -633,7 +633,7 @@ static int bdx_range_check(struct bdx_priv *priv, u32 offset)
633 633
634static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) 634static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
635{ 635{
636 struct bdx_priv *priv = ndev->priv; 636 struct bdx_priv *priv = netdev_priv(ndev);
637 u32 data[3]; 637 u32 data[3];
638 int error; 638 int error;
639 639
@@ -698,7 +698,7 @@ static int bdx_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
698 */ 698 */
699static void __bdx_vlan_rx_vid(struct net_device *ndev, uint16_t vid, int enable) 699static void __bdx_vlan_rx_vid(struct net_device *ndev, uint16_t vid, int enable)
700{ 700{
701 struct bdx_priv *priv = ndev->priv; 701 struct bdx_priv *priv = netdev_priv(ndev);
702 u32 reg, bit, val; 702 u32 reg, bit, val;
703 703
704 ENTER; 704 ENTER;
@@ -748,7 +748,7 @@ static void bdx_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid)
748static void 748static void
749bdx_vlan_rx_register(struct net_device *ndev, struct vlan_group *grp) 749bdx_vlan_rx_register(struct net_device *ndev, struct vlan_group *grp)
750{ 750{
751 struct bdx_priv *priv = ndev->priv; 751 struct bdx_priv *priv = netdev_priv(ndev);
752 752
753 ENTER; 753 ENTER;
754 DBG("device='%s', group='%p'\n", ndev->name, grp); 754 DBG("device='%s', group='%p'\n", ndev->name, grp);
@@ -787,7 +787,7 @@ static int bdx_change_mtu(struct net_device *ndev, int new_mtu)
787 787
788static void bdx_setmulti(struct net_device *ndev) 788static void bdx_setmulti(struct net_device *ndev)
789{ 789{
790 struct bdx_priv *priv = ndev->priv; 790 struct bdx_priv *priv = netdev_priv(ndev);
791 791
792 u32 rxf_val = 792 u32 rxf_val =
793 GMAC_RX_FILTER_AM | GMAC_RX_FILTER_AB | GMAC_RX_FILTER_OSEN; 793 GMAC_RX_FILTER_AM | GMAC_RX_FILTER_AB | GMAC_RX_FILTER_OSEN;
@@ -847,7 +847,7 @@ static void bdx_setmulti(struct net_device *ndev)
847 847
848static int bdx_set_mac(struct net_device *ndev, void *p) 848static int bdx_set_mac(struct net_device *ndev, void *p)
849{ 849{
850 struct bdx_priv *priv = ndev->priv; 850 struct bdx_priv *priv = netdev_priv(ndev);
851 struct sockaddr *addr = p; 851 struct sockaddr *addr = p;
852 852
853 ENTER; 853 ENTER;
@@ -929,7 +929,7 @@ static void bdx_update_stats(struct bdx_priv *priv)
929 929
930static struct net_device_stats *bdx_get_stats(struct net_device *ndev) 930static struct net_device_stats *bdx_get_stats(struct net_device *ndev)
931{ 931{
932 struct bdx_priv *priv = ndev->priv; 932 struct bdx_priv *priv = netdev_priv(ndev);
933 struct net_device_stats *net_stat = &priv->net_stats; 933 struct net_device_stats *net_stat = &priv->net_stats;
934 return net_stat; 934 return net_stat;
935} 935}
@@ -1237,7 +1237,6 @@ static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget)
1237 ENTER; 1237 ENTER;
1238 max_done = budget; 1238 max_done = budget;
1239 1239
1240 priv->ndev->last_rx = jiffies;
1241 f->m.wptr = READ_REG(priv, f->m.reg_WPTR) & TXF_WPTR_WR_PTR; 1240 f->m.wptr = READ_REG(priv, f->m.reg_WPTR) & TXF_WPTR_WR_PTR;
1242 1241
1243 size = f->m.wptr - f->m.rptr; 1242 size = f->m.wptr - f->m.rptr;
@@ -1624,7 +1623,7 @@ static inline int bdx_tx_space(struct bdx_priv *priv)
1624 */ 1623 */
1625static int bdx_tx_transmit(struct sk_buff *skb, struct net_device *ndev) 1624static int bdx_tx_transmit(struct sk_buff *skb, struct net_device *ndev)
1626{ 1625{
1627 struct bdx_priv *priv = ndev->priv; 1626 struct bdx_priv *priv = netdev_priv(ndev);
1628 struct txd_fifo *f = &priv->txd_fifo0; 1627 struct txd_fifo *f = &priv->txd_fifo0;
1629 int txd_checksum = 7; /* full checksum */ 1628 int txd_checksum = 7; /* full checksum */
1630 int txd_lgsnd = 0; 1629 int txd_lgsnd = 0;
@@ -2027,7 +2026,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2027 ndev->features |= NETIF_F_HIGHDMA; 2026 ndev->features |= NETIF_F_HIGHDMA;
2028 2027
2029 /************** priv ****************/ 2028 /************** priv ****************/
2030 priv = nic->priv[port] = ndev->priv; 2029 priv = nic->priv[port] = netdev_priv(ndev);
2031 2030
2032 memset(priv, 0, sizeof(struct bdx_priv)); 2031 memset(priv, 0, sizeof(struct bdx_priv));
2033 priv->pBdxRegs = nic->regs + port * 0x8000; 2032 priv->pBdxRegs = nic->regs + port * 0x8000;
@@ -2150,7 +2149,7 @@ static int bdx_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
2150{ 2149{
2151 u32 rdintcm; 2150 u32 rdintcm;
2152 u32 tdintcm; 2151 u32 tdintcm;
2153 struct bdx_priv *priv = netdev->priv; 2152 struct bdx_priv *priv = netdev_priv(netdev);
2154 2153
2155 rdintcm = priv->rdintcm; 2154 rdintcm = priv->rdintcm;
2156 tdintcm = priv->tdintcm; 2155 tdintcm = priv->tdintcm;
@@ -2181,7 +2180,7 @@ static int bdx_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
2181static void 2180static void
2182bdx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) 2181bdx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
2183{ 2182{
2184 struct bdx_priv *priv = netdev->priv; 2183 struct bdx_priv *priv = netdev_priv(netdev);
2185 2184
2186 strlcat(drvinfo->driver, BDX_DRV_NAME, sizeof(drvinfo->driver)); 2185 strlcat(drvinfo->driver, BDX_DRV_NAME, sizeof(drvinfo->driver));
2187 strlcat(drvinfo->version, BDX_DRV_VERSION, sizeof(drvinfo->version)); 2186 strlcat(drvinfo->version, BDX_DRV_VERSION, sizeof(drvinfo->version));
@@ -2223,7 +2222,7 @@ bdx_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *ecoal)
2223{ 2222{
2224 u32 rdintcm; 2223 u32 rdintcm;
2225 u32 tdintcm; 2224 u32 tdintcm;
2226 struct bdx_priv *priv = netdev->priv; 2225 struct bdx_priv *priv = netdev_priv(netdev);
2227 2226
2228 rdintcm = priv->rdintcm; 2227 rdintcm = priv->rdintcm;
2229 tdintcm = priv->tdintcm; 2228 tdintcm = priv->tdintcm;
@@ -2252,7 +2251,7 @@ bdx_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ecoal)
2252{ 2251{
2253 u32 rdintcm; 2252 u32 rdintcm;
2254 u32 tdintcm; 2253 u32 tdintcm;
2255 struct bdx_priv *priv = netdev->priv; 2254 struct bdx_priv *priv = netdev_priv(netdev);
2256 int rx_coal; 2255 int rx_coal;
2257 int tx_coal; 2256 int tx_coal;
2258 int rx_max_coal; 2257 int rx_max_coal;
@@ -2310,7 +2309,7 @@ static inline int bdx_tx_fifo_size_to_packets(int tx_size)
2310static void 2309static void
2311bdx_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) 2310bdx_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
2312{ 2311{
2313 struct bdx_priv *priv = netdev->priv; 2312 struct bdx_priv *priv = netdev_priv(netdev);
2314 2313
2315 /*max_pending - the maximum-sized FIFO we allow */ 2314 /*max_pending - the maximum-sized FIFO we allow */
2316 ring->rx_max_pending = bdx_rx_fifo_size_to_packets(3); 2315 ring->rx_max_pending = bdx_rx_fifo_size_to_packets(3);
@@ -2327,7 +2326,7 @@ bdx_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
2327static int 2326static int
2328bdx_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) 2327bdx_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
2329{ 2328{
2330 struct bdx_priv *priv = netdev->priv; 2329 struct bdx_priv *priv = netdev_priv(netdev);
2331 int rx_size = 0; 2330 int rx_size = 0;
2332 int tx_size = 0; 2331 int tx_size = 0;
2333 2332
@@ -2388,7 +2387,7 @@ static void bdx_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
2388 */ 2387 */
2389static int bdx_get_stats_count(struct net_device *netdev) 2388static int bdx_get_stats_count(struct net_device *netdev)
2390{ 2389{
2391 struct bdx_priv *priv = netdev->priv; 2390 struct bdx_priv *priv = netdev_priv(netdev);
2392 BDX_ASSERT(ARRAY_SIZE(bdx_stat_names) 2391 BDX_ASSERT(ARRAY_SIZE(bdx_stat_names)
2393 != sizeof(struct bdx_stats) / sizeof(u64)); 2392 != sizeof(struct bdx_stats) / sizeof(u64));
2394 return ((priv->stats_flag) ? ARRAY_SIZE(bdx_stat_names) : 0); 2393 return ((priv->stats_flag) ? ARRAY_SIZE(bdx_stat_names) : 0);
@@ -2403,7 +2402,7 @@ static int bdx_get_stats_count(struct net_device *netdev)
2403static void bdx_get_ethtool_stats(struct net_device *netdev, 2402static void bdx_get_ethtool_stats(struct net_device *netdev,
2404 struct ethtool_stats *stats, u64 *data) 2403 struct ethtool_stats *stats, u64 *data)
2405{ 2404{
2406 struct bdx_priv *priv = netdev->priv; 2405 struct bdx_priv *priv = netdev_priv(netdev);
2407 2406
2408 if (priv->stats_flag) { 2407 if (priv->stats_flag) {
2409 2408
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index eb9f8f3638e1..e05849ee9000 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -54,6 +54,9 @@
54#include <asm/prom.h> 54#include <asm/prom.h>
55#endif 55#endif
56 56
57#define BAR_0 0
58#define BAR_2 2
59
57#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 60#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
58#define TG3_VLAN_TAG_USED 1 61#define TG3_VLAN_TAG_USED 1
59#else 62#else
@@ -66,8 +69,8 @@
66 69
67#define DRV_MODULE_NAME "tg3" 70#define DRV_MODULE_NAME "tg3"
68#define PFX DRV_MODULE_NAME ": " 71#define PFX DRV_MODULE_NAME ": "
69#define DRV_MODULE_VERSION "3.94" 72#define DRV_MODULE_VERSION "3.95"
70#define DRV_MODULE_RELDATE "August 14, 2008" 73#define DRV_MODULE_RELDATE "November 3, 2008"
71 74
72#define TG3_DEF_MAC_MODE 0 75#define TG3_DEF_MAC_MODE 0
73#define TG3_DEF_RX_MODE 0 76#define TG3_DEF_RX_MODE 0
@@ -205,6 +208,8 @@ static struct pci_device_id tg3_pci_tbl[] = {
205 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5723)}, 208 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5723)},
206 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5761)}, 209 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5761)},
207 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5761E)}, 210 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5761E)},
211 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, TG3PCI_DEVICE_TIGON3_5761S)},
212 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, TG3PCI_DEVICE_TIGON3_5761SE)},
208 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5785)}, 213 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5785)},
209 {PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX)}, 214 {PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX)},
210 {PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9MXX)}, 215 {PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9MXX)},
@@ -872,13 +877,48 @@ static int tg3_mdio_reset(struct mii_bus *bp)
872 return 0; 877 return 0;
873} 878}
874 879
875static void tg3_mdio_config(struct tg3 *tp) 880static void tg3_mdio_config_5785(struct tg3 *tp)
876{ 881{
877 u32 val; 882 u32 val;
883 struct phy_device *phydev;
884
885 phydev = tp->mdio_bus->phy_map[PHY_ADDR];
886 switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) {
887 case TG3_PHY_ID_BCM50610:
888 val = MAC_PHYCFG2_50610_LED_MODES;
889 break;
890 case TG3_PHY_ID_BCMAC131:
891 val = MAC_PHYCFG2_AC131_LED_MODES;
892 break;
893 case TG3_PHY_ID_RTL8211C:
894 val = MAC_PHYCFG2_RTL8211C_LED_MODES;
895 break;
896 case TG3_PHY_ID_RTL8201E:
897 val = MAC_PHYCFG2_RTL8201E_LED_MODES;
898 break;
899 default:
900 return;
901 }
902
903 if (phydev->interface != PHY_INTERFACE_MODE_RGMII) {
904 tw32(MAC_PHYCFG2, val);
905
906 val = tr32(MAC_PHYCFG1);
907 val &= ~MAC_PHYCFG1_RGMII_INT;
908 tw32(MAC_PHYCFG1, val);
878 909
879 if (tp->mdio_bus->phy_map[PHY_ADDR]->interface !=
880 PHY_INTERFACE_MODE_RGMII)
881 return; 910 return;
911 }
912
913 if (!(tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE))
914 val |= MAC_PHYCFG2_EMODE_MASK_MASK |
915 MAC_PHYCFG2_FMODE_MASK_MASK |
916 MAC_PHYCFG2_GMODE_MASK_MASK |
917 MAC_PHYCFG2_ACT_MASK_MASK |
918 MAC_PHYCFG2_QUAL_MASK_MASK |
919 MAC_PHYCFG2_INBAND_ENABLE;
920
921 tw32(MAC_PHYCFG2, val);
882 922
883 val = tr32(MAC_PHYCFG1) & ~(MAC_PHYCFG1_RGMII_EXT_RX_DEC | 923 val = tr32(MAC_PHYCFG1) & ~(MAC_PHYCFG1_RGMII_EXT_RX_DEC |
884 MAC_PHYCFG1_RGMII_SND_STAT_EN); 924 MAC_PHYCFG1_RGMII_SND_STAT_EN);
@@ -890,11 +930,6 @@ static void tg3_mdio_config(struct tg3 *tp)
890 } 930 }
891 tw32(MAC_PHYCFG1, val | MAC_PHYCFG1_RGMII_INT | MAC_PHYCFG1_TXC_DRV); 931 tw32(MAC_PHYCFG1, val | MAC_PHYCFG1_RGMII_INT | MAC_PHYCFG1_TXC_DRV);
892 932
893 val = tr32(MAC_PHYCFG2) & ~(MAC_PHYCFG2_INBAND_ENABLE);
894 if (!(tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE))
895 val |= MAC_PHYCFG2_INBAND_ENABLE;
896 tw32(MAC_PHYCFG2, val);
897
898 val = tr32(MAC_EXT_RGMII_MODE); 933 val = tr32(MAC_EXT_RGMII_MODE);
899 val &= ~(MAC_RGMII_MODE_RX_INT_B | 934 val &= ~(MAC_RGMII_MODE_RX_INT_B |
900 MAC_RGMII_MODE_RX_QUALITY | 935 MAC_RGMII_MODE_RX_QUALITY |
@@ -903,7 +938,7 @@ static void tg3_mdio_config(struct tg3 *tp)
903 MAC_RGMII_MODE_TX_ENABLE | 938 MAC_RGMII_MODE_TX_ENABLE |
904 MAC_RGMII_MODE_TX_LOWPWR | 939 MAC_RGMII_MODE_TX_LOWPWR |
905 MAC_RGMII_MODE_TX_RESET); 940 MAC_RGMII_MODE_TX_RESET);
906 if (tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE) { 941 if (!(tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE)) {
907 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_RX_EN) 942 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_RX_EN)
908 val |= MAC_RGMII_MODE_RX_INT_B | 943 val |= MAC_RGMII_MODE_RX_INT_B |
909 MAC_RGMII_MODE_RX_QUALITY | 944 MAC_RGMII_MODE_RX_QUALITY |
@@ -929,8 +964,9 @@ static void tg3_mdio_start(struct tg3 *tp)
929 tw32_f(MAC_MI_MODE, tp->mi_mode); 964 tw32_f(MAC_MI_MODE, tp->mi_mode);
930 udelay(80); 965 udelay(80);
931 966
932 if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_INITED) 967 if ((tp->tg3_flags3 & TG3_FLG3_MDIOBUS_INITED) &&
933 tg3_mdio_config(tp); 968 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785)
969 tg3_mdio_config_5785(tp);
934} 970}
935 971
936static void tg3_mdio_stop(struct tg3 *tp) 972static void tg3_mdio_stop(struct tg3 *tp)
@@ -984,29 +1020,41 @@ static int tg3_mdio_init(struct tg3 *tp)
984 if (i) { 1020 if (i) {
985 printk(KERN_WARNING "%s: mdiobus_reg failed (0x%x)\n", 1021 printk(KERN_WARNING "%s: mdiobus_reg failed (0x%x)\n",
986 tp->dev->name, i); 1022 tp->dev->name, i);
1023 mdiobus_free(tp->mdio_bus);
987 return i; 1024 return i;
988 } 1025 }
989 1026
990 tp->tg3_flags3 |= TG3_FLG3_MDIOBUS_INITED;
991
992 phydev = tp->mdio_bus->phy_map[PHY_ADDR]; 1027 phydev = tp->mdio_bus->phy_map[PHY_ADDR];
993 1028
994 switch (phydev->phy_id) { 1029 if (!phydev || !phydev->drv) {
1030 printk(KERN_WARNING "%s: No PHY devices\n", tp->dev->name);
1031 mdiobus_unregister(tp->mdio_bus);
1032 mdiobus_free(tp->mdio_bus);
1033 return -ENODEV;
1034 }
1035
1036 switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) {
995 case TG3_PHY_ID_BCM50610: 1037 case TG3_PHY_ID_BCM50610:
996 phydev->interface = PHY_INTERFACE_MODE_RGMII;
997 if (tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE) 1038 if (tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE)
998 phydev->dev_flags |= PHY_BRCM_STD_IBND_DISABLE; 1039 phydev->dev_flags |= PHY_BRCM_STD_IBND_DISABLE;
999 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_RX_EN) 1040 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_RX_EN)
1000 phydev->dev_flags |= PHY_BRCM_EXT_IBND_RX_ENABLE; 1041 phydev->dev_flags |= PHY_BRCM_EXT_IBND_RX_ENABLE;
1001 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_TX_EN) 1042 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_TX_EN)
1002 phydev->dev_flags |= PHY_BRCM_EXT_IBND_TX_ENABLE; 1043 phydev->dev_flags |= PHY_BRCM_EXT_IBND_TX_ENABLE;
1044 /* fallthru */
1045 case TG3_PHY_ID_RTL8211C:
1046 phydev->interface = PHY_INTERFACE_MODE_RGMII;
1003 break; 1047 break;
1048 case TG3_PHY_ID_RTL8201E:
1004 case TG3_PHY_ID_BCMAC131: 1049 case TG3_PHY_ID_BCMAC131:
1005 phydev->interface = PHY_INTERFACE_MODE_MII; 1050 phydev->interface = PHY_INTERFACE_MODE_MII;
1006 break; 1051 break;
1007 } 1052 }
1008 1053
1009 tg3_mdio_config(tp); 1054 tp->tg3_flags3 |= TG3_FLG3_MDIOBUS_INITED;
1055
1056 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785)
1057 tg3_mdio_config_5785(tp);
1010 1058
1011 return 0; 1059 return 0;
1012} 1060}
@@ -1299,6 +1347,15 @@ static void tg3_adjust_link(struct net_device *dev)
1299 udelay(40); 1347 udelay(40);
1300 } 1348 }
1301 1349
1350 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) {
1351 if (phydev->speed == SPEED_10)
1352 tw32(MAC_MI_STAT,
1353 MAC_MI_STAT_10MBPS_MODE |
1354 MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
1355 else
1356 tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
1357 }
1358
1302 if (phydev->speed == SPEED_1000 && phydev->duplex == DUPLEX_HALF) 1359 if (phydev->speed == SPEED_1000 && phydev->duplex == DUPLEX_HALF)
1303 tw32(MAC_TX_LENGTHS, 1360 tw32(MAC_TX_LENGTHS,
1304 ((2 << TX_LENGTHS_IPG_CRS_SHIFT) | 1361 ((2 << TX_LENGTHS_IPG_CRS_SHIFT) |
@@ -1339,25 +1396,34 @@ static int tg3_phy_init(struct tg3 *tp)
1339 phydev = tp->mdio_bus->phy_map[PHY_ADDR]; 1396 phydev = tp->mdio_bus->phy_map[PHY_ADDR];
1340 1397
1341 /* Attach the MAC to the PHY. */ 1398 /* Attach the MAC to the PHY. */
1342 phydev = phy_connect(tp->dev, phydev->dev.bus_id, tg3_adjust_link, 1399 phydev = phy_connect(tp->dev, dev_name(&phydev->dev), tg3_adjust_link,
1343 phydev->dev_flags, phydev->interface); 1400 phydev->dev_flags, phydev->interface);
1344 if (IS_ERR(phydev)) { 1401 if (IS_ERR(phydev)) {
1345 printk(KERN_ERR "%s: Could not attach to PHY\n", tp->dev->name); 1402 printk(KERN_ERR "%s: Could not attach to PHY\n", tp->dev->name);
1346 return PTR_ERR(phydev); 1403 return PTR_ERR(phydev);
1347 } 1404 }
1348 1405
1349 tp->tg3_flags3 |= TG3_FLG3_PHY_CONNECTED;
1350
1351 /* Mask with MAC supported features. */ 1406 /* Mask with MAC supported features. */
1352 phydev->supported &= (PHY_GBIT_FEATURES | 1407 switch (phydev->interface) {
1353 SUPPORTED_Pause | 1408 case PHY_INTERFACE_MODE_GMII:
1354 SUPPORTED_Asym_Pause); 1409 case PHY_INTERFACE_MODE_RGMII:
1410 phydev->supported &= (PHY_GBIT_FEATURES |
1411 SUPPORTED_Pause |
1412 SUPPORTED_Asym_Pause);
1413 break;
1414 case PHY_INTERFACE_MODE_MII:
1415 phydev->supported &= (PHY_BASIC_FEATURES |
1416 SUPPORTED_Pause |
1417 SUPPORTED_Asym_Pause);
1418 break;
1419 default:
1420 phy_disconnect(tp->mdio_bus->phy_map[PHY_ADDR]);
1421 return -EINVAL;
1422 }
1355 1423
1356 phydev->advertising = phydev->supported; 1424 tp->tg3_flags3 |= TG3_FLG3_PHY_CONNECTED;
1357 1425
1358 printk(KERN_INFO 1426 phydev->advertising = phydev->supported;
1359 "%s: attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
1360 tp->dev->name, phydev->drv->name, phydev->dev.bus_id);
1361 1427
1362 return 0; 1428 return 0;
1363} 1429}
@@ -1737,7 +1803,8 @@ static int tg3_phy_reset(struct tg3 *tp)
1737 tw32(TG3_CPMU_CTRL, cpmuctrl); 1803 tw32(TG3_CPMU_CTRL, cpmuctrl);
1738 } 1804 }
1739 1805
1740 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { 1806 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX ||
1807 GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX) {
1741 u32 val; 1808 u32 val;
1742 1809
1743 val = tr32(TG3_CPMU_LSPD_1000MB_CLK); 1810 val = tr32(TG3_CPMU_LSPD_1000MB_CLK);
@@ -1961,7 +2028,7 @@ static int tg3_halt_cpu(struct tg3 *, u32);
1961static int tg3_nvram_lock(struct tg3 *); 2028static int tg3_nvram_lock(struct tg3 *);
1962static void tg3_nvram_unlock(struct tg3 *); 2029static void tg3_nvram_unlock(struct tg3 *);
1963 2030
1964static void tg3_power_down_phy(struct tg3 *tp) 2031static void tg3_power_down_phy(struct tg3 *tp, bool do_low_power)
1965{ 2032{
1966 u32 val; 2033 u32 val;
1967 2034
@@ -1984,10 +2051,15 @@ static void tg3_power_down_phy(struct tg3 *tp)
1984 tw32_f(GRC_MISC_CFG, val | GRC_MISC_CFG_EPHY_IDDQ); 2051 tw32_f(GRC_MISC_CFG, val | GRC_MISC_CFG_EPHY_IDDQ);
1985 udelay(40); 2052 udelay(40);
1986 return; 2053 return;
1987 } else if (!(tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB)) { 2054 } else if (do_low_power) {
1988 tg3_writephy(tp, MII_TG3_EXT_CTRL, 2055 tg3_writephy(tp, MII_TG3_EXT_CTRL,
1989 MII_TG3_EXT_CTRL_FORCE_LED_OFF); 2056 MII_TG3_EXT_CTRL_FORCE_LED_OFF);
1990 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2); 2057
2058 tg3_writephy(tp, MII_TG3_AUX_CTRL,
2059 MII_TG3_AUXCTL_SHDWSEL_PWRCTL |
2060 MII_TG3_AUXCTL_PCTL_100TX_LPWR |
2061 MII_TG3_AUXCTL_PCTL_SPR_ISOLATE |
2062 MII_TG3_AUXCTL_PCTL_VREG_11V);
1991 } 2063 }
1992 2064
1993 /* The PHY should not be powered down on some chips because 2065 /* The PHY should not be powered down on some chips because
@@ -1999,7 +2071,8 @@ static void tg3_power_down_phy(struct tg3 *tp)
1999 (tp->tg3_flags2 & TG3_FLG2_MII_SERDES))) 2071 (tp->tg3_flags2 & TG3_FLG2_MII_SERDES)))
2000 return; 2072 return;
2001 2073
2002 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { 2074 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX ||
2075 GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX) {
2003 val = tr32(TG3_CPMU_LSPD_1000MB_CLK); 2076 val = tr32(TG3_CPMU_LSPD_1000MB_CLK);
2004 val &= ~CPMU_LSPD_1000MB_MACCLK_MASK; 2077 val &= ~CPMU_LSPD_1000MB_MACCLK_MASK;
2005 val |= CPMU_LSPD_1000MB_MACCLK_12_5; 2078 val |= CPMU_LSPD_1000MB_MACCLK_12_5;
@@ -2009,9 +2082,47 @@ static void tg3_power_down_phy(struct tg3 *tp)
2009 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN); 2082 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN);
2010} 2083}
2011 2084
2085/* tp->lock is held. */
2086static void __tg3_set_mac_addr(struct tg3 *tp, int skip_mac_1)
2087{
2088 u32 addr_high, addr_low;
2089 int i;
2090
2091 addr_high = ((tp->dev->dev_addr[0] << 8) |
2092 tp->dev->dev_addr[1]);
2093 addr_low = ((tp->dev->dev_addr[2] << 24) |
2094 (tp->dev->dev_addr[3] << 16) |
2095 (tp->dev->dev_addr[4] << 8) |
2096 (tp->dev->dev_addr[5] << 0));
2097 for (i = 0; i < 4; i++) {
2098 if (i == 1 && skip_mac_1)
2099 continue;
2100 tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high);
2101 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
2102 }
2103
2104 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
2105 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
2106 for (i = 0; i < 12; i++) {
2107 tw32(MAC_EXTADDR_0_HIGH + (i * 8), addr_high);
2108 tw32(MAC_EXTADDR_0_LOW + (i * 8), addr_low);
2109 }
2110 }
2111
2112 addr_high = (tp->dev->dev_addr[0] +
2113 tp->dev->dev_addr[1] +
2114 tp->dev->dev_addr[2] +
2115 tp->dev->dev_addr[3] +
2116 tp->dev->dev_addr[4] +
2117 tp->dev->dev_addr[5]) &
2118 TX_BACKOFF_SEED_MASK;
2119 tw32(MAC_TX_BACKOFF_SEED, addr_high);
2120}
2121
2012static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) 2122static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2013{ 2123{
2014 u32 misc_host_ctrl; 2124 u32 misc_host_ctrl;
2125 bool device_should_wake, do_low_power;
2015 2126
2016 /* Make sure register accesses (indirect or otherwise) 2127 /* Make sure register accesses (indirect or otherwise)
2017 * will function correctly. 2128 * will function correctly.
@@ -2045,11 +2156,16 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2045 tw32(TG3PCI_MISC_HOST_CTRL, 2156 tw32(TG3PCI_MISC_HOST_CTRL,
2046 misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT); 2157 misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT);
2047 2158
2159 device_should_wake = pci_pme_capable(tp->pdev, state) &&
2160 device_may_wakeup(&tp->pdev->dev) &&
2161 (tp->tg3_flags & TG3_FLAG_WOL_ENABLE);
2162
2048 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) { 2163 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) {
2164 do_low_power = false;
2049 if ((tp->tg3_flags3 & TG3_FLG3_PHY_CONNECTED) && 2165 if ((tp->tg3_flags3 & TG3_FLG3_PHY_CONNECTED) &&
2050 !tp->link_config.phy_is_low_power) { 2166 !tp->link_config.phy_is_low_power) {
2051 struct phy_device *phydev; 2167 struct phy_device *phydev;
2052 u32 advertising; 2168 u32 phyid, advertising;
2053 2169
2054 phydev = tp->mdio_bus->phy_map[PHY_ADDR]; 2170 phydev = tp->mdio_bus->phy_map[PHY_ADDR];
2055 2171
@@ -2066,7 +2182,7 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2066 ADVERTISED_10baseT_Half; 2182 ADVERTISED_10baseT_Half;
2067 2183
2068 if ((tp->tg3_flags & TG3_FLAG_ENABLE_ASF) || 2184 if ((tp->tg3_flags & TG3_FLAG_ENABLE_ASF) ||
2069 (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)) { 2185 device_should_wake) {
2070 if (tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB) 2186 if (tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB)
2071 advertising |= 2187 advertising |=
2072 ADVERTISED_100baseT_Half | 2188 ADVERTISED_100baseT_Half |
@@ -2079,8 +2195,19 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2079 phydev->advertising = advertising; 2195 phydev->advertising = advertising;
2080 2196
2081 phy_start_aneg(phydev); 2197 phy_start_aneg(phydev);
2198
2199 phyid = phydev->drv->phy_id & phydev->drv->phy_id_mask;
2200 if (phyid != TG3_PHY_ID_BCMAC131) {
2201 phyid &= TG3_PHY_OUI_MASK;
2202 if (phyid == TG3_PHY_OUI_1 &&
2203 phyid == TG3_PHY_OUI_2 &&
2204 phyid == TG3_PHY_OUI_3)
2205 do_low_power = true;
2206 }
2082 } 2207 }
2083 } else { 2208 } else {
2209 do_low_power = false;
2210
2084 if (tp->link_config.phy_is_low_power == 0) { 2211 if (tp->link_config.phy_is_low_power == 0) {
2085 tp->link_config.phy_is_low_power = 1; 2212 tp->link_config.phy_is_low_power = 1;
2086 tp->link_config.orig_speed = tp->link_config.speed; 2213 tp->link_config.orig_speed = tp->link_config.speed;
@@ -2096,6 +2223,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2096 } 2223 }
2097 } 2224 }
2098 2225
2226 __tg3_set_mac_addr(tp, 0);
2227
2099 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 2228 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
2100 u32 val; 2229 u32 val;
2101 2230
@@ -2118,11 +2247,11 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2118 WOL_DRV_WOL | 2247 WOL_DRV_WOL |
2119 WOL_SET_MAGIC_PKT); 2248 WOL_SET_MAGIC_PKT);
2120 2249
2121 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) { 2250 if (device_should_wake) {
2122 u32 mac_mode; 2251 u32 mac_mode;
2123 2252
2124 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) { 2253 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) {
2125 if (!(tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB)) { 2254 if (do_low_power) {
2126 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x5a); 2255 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x5a);
2127 udelay(40); 2256 udelay(40);
2128 } 2257 }
@@ -2150,9 +2279,12 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2150 if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) 2279 if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
2151 tw32(MAC_LED_CTRL, tp->led_ctrl); 2280 tw32(MAC_LED_CTRL, tp->led_ctrl);
2152 2281
2153 if (pci_pme_capable(tp->pdev, state) && 2282 mac_mode |= MAC_MODE_MAGIC_PKT_ENABLE;
2154 (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)) 2283 if (((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) &&
2155 mac_mode |= MAC_MODE_MAGIC_PKT_ENABLE; 2284 !(tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) &&
2285 ((tp->tg3_flags & TG3_FLAG_ENABLE_ASF) ||
2286 (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE)))
2287 mac_mode |= MAC_MODE_KEEP_FRAME_IN_WOL;
2156 2288
2157 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { 2289 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
2158 mac_mode |= tp->mac_mode & 2290 mac_mode |= tp->mac_mode &
@@ -2224,10 +2356,10 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2224 } 2356 }
2225 } 2357 }
2226 2358
2227 if (!(tp->tg3_flags & TG3_FLAG_WOL_ENABLE) && 2359 if (!(device_should_wake) &&
2228 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF) && 2360 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF) &&
2229 !(tp->tg3_flags3 & TG3_FLG3_ENABLE_APE)) 2361 !(tp->tg3_flags3 & TG3_FLG3_ENABLE_APE))
2230 tg3_power_down_phy(tp); 2362 tg3_power_down_phy(tp, do_low_power);
2231 2363
2232 tg3_frob_aux_power(tp); 2364 tg3_frob_aux_power(tp);
2233 2365
@@ -2250,7 +2382,7 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2250 2382
2251 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); 2383 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);
2252 2384
2253 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) 2385 if (device_should_wake)
2254 pci_enable_wake(tp->pdev, state, true); 2386 pci_enable_wake(tp->pdev, state, true);
2255 2387
2256 /* Finally, set the new power state. */ 2388 /* Finally, set the new power state. */
@@ -3765,8 +3897,7 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset)
3765 err = tg3_setup_copper_phy(tp, force_reset); 3897 err = tg3_setup_copper_phy(tp, force_reset);
3766 } 3898 }
3767 3899
3768 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || 3900 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX) {
3769 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) {
3770 u32 val, scale; 3901 u32 val, scale;
3771 3902
3772 val = tr32(TG3_CPMU_CLCK_STAT) & CPMU_CLCK_STAT_MAC_CLCK_MASK; 3903 val = tr32(TG3_CPMU_CLCK_STAT) & CPMU_CLCK_STAT_MAC_CLCK_MASK;
@@ -4157,7 +4288,6 @@ static int tg3_rx(struct tg3 *tp, int budget)
4157#endif 4288#endif
4158 netif_receive_skb(skb); 4289 netif_receive_skb(skb);
4159 4290
4160 tp->dev->last_rx = jiffies;
4161 received++; 4291 received++;
4162 budget--; 4292 budget--;
4163 4293
@@ -5557,6 +5687,13 @@ static void tg3_ape_driver_state_change(struct tg3 *tp, int kind)
5557 event = APE_EVENT_STATUS_STATE_START; 5687 event = APE_EVENT_STATUS_STATE_START;
5558 break; 5688 break;
5559 case RESET_KIND_SHUTDOWN: 5689 case RESET_KIND_SHUTDOWN:
5690 /* With the interface we are currently using,
5691 * APE does not track driver state. Wiping
5692 * out the HOST SEGMENT SIGNATURE forces
5693 * the APE to assume OS absent status.
5694 */
5695 tg3_ape_write32(tp, TG3_APE_HOST_SEG_SIG, 0x0);
5696
5560 event = APE_EVENT_STATUS_STATE_UNLOAD; 5697 event = APE_EVENT_STATUS_STATE_UNLOAD;
5561 break; 5698 break;
5562 case RESET_KIND_SUSPEND: 5699 case RESET_KIND_SUSPEND:
@@ -5721,13 +5858,15 @@ static void tg3_restore_pci_state(struct tg3 *tp)
5721 5858
5722 pci_write_config_word(tp->pdev, PCI_COMMAND, tp->pci_cmd); 5859 pci_write_config_word(tp->pdev, PCI_COMMAND, tp->pci_cmd);
5723 5860
5724 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) 5861 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5785) {
5725 pcie_set_readrq(tp->pdev, 4096); 5862 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)
5726 else { 5863 pcie_set_readrq(tp->pdev, 4096);
5727 pci_write_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, 5864 else {
5728 tp->pci_cacheline_sz); 5865 pci_write_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE,
5729 pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER, 5866 tp->pci_cacheline_sz);
5730 tp->pci_lat_timer); 5867 pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER,
5868 tp->pci_lat_timer);
5869 }
5731 } 5870 }
5732 5871
5733 /* Make sure PCI-X relaxed ordering bit is clear. */ 5872 /* Make sure PCI-X relaxed ordering bit is clear. */
@@ -5884,8 +6023,9 @@ static int tg3_chip_reset(struct tg3 *tp)
5884 pci_write_config_dword(tp->pdev, 0xc4, 6023 pci_write_config_dword(tp->pdev, 0xc4,
5885 cfg_val | (1 << 15)); 6024 cfg_val | (1 << 15));
5886 } 6025 }
5887 /* Set PCIE max payload size and clear error status. */ 6026 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5785)
5888 pci_write_config_dword(tp->pdev, 0xd8, 0xf5000); 6027 /* Set PCIE max payload size and clear error status. */
6028 pci_write_config_dword(tp->pdev, 0xd8, 0xf5000);
5889 } 6029 }
5890 6030
5891 tg3_restore_pci_state(tp); 6031 tg3_restore_pci_state(tp);
@@ -6883,43 +7023,6 @@ static int tg3_load_tso_firmware(struct tg3 *tp)
6883} 7023}
6884 7024
6885 7025
6886/* tp->lock is held. */
6887static void __tg3_set_mac_addr(struct tg3 *tp, int skip_mac_1)
6888{
6889 u32 addr_high, addr_low;
6890 int i;
6891
6892 addr_high = ((tp->dev->dev_addr[0] << 8) |
6893 tp->dev->dev_addr[1]);
6894 addr_low = ((tp->dev->dev_addr[2] << 24) |
6895 (tp->dev->dev_addr[3] << 16) |
6896 (tp->dev->dev_addr[4] << 8) |
6897 (tp->dev->dev_addr[5] << 0));
6898 for (i = 0; i < 4; i++) {
6899 if (i == 1 && skip_mac_1)
6900 continue;
6901 tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high);
6902 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
6903 }
6904
6905 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
6906 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
6907 for (i = 0; i < 12; i++) {
6908 tw32(MAC_EXTADDR_0_HIGH + (i * 8), addr_high);
6909 tw32(MAC_EXTADDR_0_LOW + (i * 8), addr_low);
6910 }
6911 }
6912
6913 addr_high = (tp->dev->dev_addr[0] +
6914 tp->dev->dev_addr[1] +
6915 tp->dev->dev_addr[2] +
6916 tp->dev->dev_addr[3] +
6917 tp->dev->dev_addr[4] +
6918 tp->dev->dev_addr[5]) &
6919 TX_BACKOFF_SEED_MASK;
6920 tw32(MAC_TX_BACKOFF_SEED, addr_high);
6921}
6922
6923static int tg3_set_mac_addr(struct net_device *dev, void *p) 7026static int tg3_set_mac_addr(struct net_device *dev, void *p)
6924{ 7027{
6925 struct tg3 *tp = netdev_priv(dev); 7028 struct tg3 *tp = netdev_priv(dev);
@@ -7024,8 +7127,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7024 7127
7025 tg3_write_sig_legacy(tp, RESET_KIND_INIT); 7128 tg3_write_sig_legacy(tp, RESET_KIND_INIT);
7026 7129
7027 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || 7130 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX) {
7028 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) {
7029 val = tr32(TG3_CPMU_CTRL); 7131 val = tr32(TG3_CPMU_CTRL);
7030 val &= ~(CPMU_CTRL_LINK_AWARE_MODE | CPMU_CTRL_LINK_IDLE_MODE); 7132 val &= ~(CPMU_CTRL_LINK_AWARE_MODE | CPMU_CTRL_LINK_IDLE_MODE);
7031 tw32(TG3_CPMU_CTRL, val); 7133 tw32(TG3_CPMU_CTRL, val);
@@ -7091,8 +7193,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7091 return err; 7193 return err;
7092 7194
7093 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5784 && 7195 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5784 &&
7094 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5761 && 7196 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5761) {
7095 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5785) {
7096 /* This value is determined during the probe time DMA 7197 /* This value is determined during the probe time DMA
7097 * engine test, tg3_test_dma. 7198 * engine test, tg3_test_dma.
7098 */ 7199 */
@@ -9066,7 +9167,8 @@ static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
9066 else 9167 else
9067 wol->supported = 0; 9168 wol->supported = 0;
9068 wol->wolopts = 0; 9169 wol->wolopts = 0;
9069 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) 9170 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) &&
9171 device_can_wakeup(&tp->pdev->dev))
9070 wol->wolopts = WAKE_MAGIC; 9172 wol->wolopts = WAKE_MAGIC;
9071 memset(&wol->sopass, 0, sizeof(wol->sopass)); 9173 memset(&wol->sopass, 0, sizeof(wol->sopass));
9072} 9174}
@@ -11299,7 +11401,7 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11299 (val & VCPU_CFGSHDW_WOL_MAGPKT) && 11401 (val & VCPU_CFGSHDW_WOL_MAGPKT) &&
11300 device_may_wakeup(&tp->pdev->dev)) 11402 device_may_wakeup(&tp->pdev->dev))
11301 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 11403 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
11302 return; 11404 goto done;
11303 } 11405 }
11304 11406
11305 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val); 11407 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
@@ -11421,15 +11523,17 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11421 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) 11523 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
11422 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 11524 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
11423 } 11525 }
11424 if (nic_cfg & NIC_SRAM_DATA_CFG_APE_ENABLE) 11526
11527 if ((nic_cfg & NIC_SRAM_DATA_CFG_APE_ENABLE) &&
11528 (tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
11425 tp->tg3_flags3 |= TG3_FLG3_ENABLE_APE; 11529 tp->tg3_flags3 |= TG3_FLG3_ENABLE_APE;
11530
11426 if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES && 11531 if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES &&
11427 !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)) 11532 !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL))
11428 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; 11533 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP;
11429 11534
11430 if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && 11535 if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) &&
11431 (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE) && 11536 (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE))
11432 device_may_wakeup(&tp->pdev->dev))
11433 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 11537 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
11434 11538
11435 if (cfg2 & (1 << 17)) 11539 if (cfg2 & (1 << 17))
@@ -11455,6 +11559,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11455 if (cfg4 & NIC_SRAM_RGMII_EXT_IBND_TX_EN) 11559 if (cfg4 & NIC_SRAM_RGMII_EXT_IBND_TX_EN)
11456 tp->tg3_flags3 |= TG3_FLG3_RGMII_EXT_IBND_TX_EN; 11560 tp->tg3_flags3 |= TG3_FLG3_RGMII_EXT_IBND_TX_EN;
11457 } 11561 }
11562done:
11563 device_init_wakeup(&tp->pdev->dev, tp->tg3_flags & TG3_FLAG_WOL_CAP);
11564 device_set_wakeup_enable(&tp->pdev->dev,
11565 tp->tg3_flags & TG3_FLAG_WOL_ENABLE);
11458} 11566}
11459 11567
11460static int __devinit tg3_issue_otp_command(struct tg3 *tp, u32 cmd) 11568static int __devinit tg3_issue_otp_command(struct tg3 *tp, u32 cmd)
@@ -12091,7 +12199,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
12091 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) 12199 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN)
12092 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2; 12200 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2;
12093 } 12201 }
12094 } 12202 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785)
12203 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
12095 12204
12096 /* If we have an AMD 762 or VIA K8T800 chipset, write 12205 /* If we have an AMD 762 or VIA K8T800 chipset, write
12097 * reordering to the mailbox registers done by the host 12206 * reordering to the mailbox registers done by the host
@@ -12263,16 +12372,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
12263 12372
12264 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || 12373 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 ||
12265 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 || 12374 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 ||
12266 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) { 12375 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785)
12267 tp->tg3_flags |= TG3_FLAG_CPMU_PRESENT; 12376 tp->tg3_flags |= TG3_FLAG_CPMU_PRESENT;
12268 12377
12269 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 ||
12270 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1 ||
12271 tp->pci_chip_rev_id == CHIPREV_ID_5761_A0 ||
12272 tp->pci_chip_rev_id == CHIPREV_ID_5761_A1)
12273 tp->tg3_flags3 |= TG3_FLG3_5761_5784_AX_FIXES;
12274 }
12275
12276 /* Set up tp->grc_local_ctrl before calling tg3_set_power_state(). 12378 /* Set up tp->grc_local_ctrl before calling tg3_set_power_state().
12277 * GPIO1 driven high will bring 5700's external PHY out of reset. 12379 * GPIO1 driven high will bring 5700's external PHY out of reset.
12278 * It is also used as eeprom write protect on LOMs. 12380 * It is also used as eeprom write protect on LOMs.
@@ -13245,14 +13347,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13245 const struct pci_device_id *ent) 13347 const struct pci_device_id *ent)
13246{ 13348{
13247 static int tg3_version_printed = 0; 13349 static int tg3_version_printed = 0;
13248 resource_size_t tg3reg_base; 13350 resource_size_t tg3reg_len;
13249 unsigned long tg3reg_len;
13250 struct net_device *dev; 13351 struct net_device *dev;
13251 struct tg3 *tp; 13352 struct tg3 *tp;
13252 int err, pm_cap; 13353 int err, pm_cap;
13253 char str[40]; 13354 char str[40];
13254 u64 dma_mask, persist_dma_mask; 13355 u64 dma_mask, persist_dma_mask;
13255 DECLARE_MAC_BUF(mac);
13256 13356
13257 if (tg3_version_printed++ == 0) 13357 if (tg3_version_printed++ == 0)
13258 printk(KERN_INFO "%s", version); 13358 printk(KERN_INFO "%s", version);
@@ -13264,7 +13364,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13264 return err; 13364 return err;
13265 } 13365 }
13266 13366
13267 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 13367 if (!(pci_resource_flags(pdev, BAR_0) & IORESOURCE_MEM)) {
13268 printk(KERN_ERR PFX "Cannot find proper PCI device " 13368 printk(KERN_ERR PFX "Cannot find proper PCI device "
13269 "base address, aborting.\n"); 13369 "base address, aborting.\n");
13270 err = -ENODEV; 13370 err = -ENODEV;
@@ -13289,9 +13389,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13289 goto err_out_free_res; 13389 goto err_out_free_res;
13290 } 13390 }
13291 13391
13292 tg3reg_base = pci_resource_start(pdev, 0);
13293 tg3reg_len = pci_resource_len(pdev, 0);
13294
13295 dev = alloc_etherdev(sizeof(*tp)); 13392 dev = alloc_etherdev(sizeof(*tp));
13296 if (!dev) { 13393 if (!dev) {
13297 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n"); 13394 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
@@ -13343,7 +13440,11 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13343 spin_lock_init(&tp->indirect_lock); 13440 spin_lock_init(&tp->indirect_lock);
13344 INIT_WORK(&tp->reset_task, tg3_reset_task); 13441 INIT_WORK(&tp->reset_task, tg3_reset_task);
13345 13442
13346 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len); 13443 dev->mem_start = pci_resource_start(pdev, BAR_0);
13444 tg3reg_len = pci_resource_len(pdev, BAR_0);
13445 dev->mem_end = dev->mem_start + tg3reg_len;
13446
13447 tp->regs = ioremap_nocache(dev->mem_start, tg3reg_len);
13347 if (!tp->regs) { 13448 if (!tp->regs) {
13348 printk(KERN_ERR PFX "Cannot map device registers, " 13449 printk(KERN_ERR PFX "Cannot map device registers, "
13349 "aborting.\n"); 13450 "aborting.\n");
@@ -13466,17 +13567,14 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13466 } 13567 }
13467 13568
13468 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { 13569 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
13469 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { 13570 if (!(pci_resource_flags(pdev, BAR_2) & IORESOURCE_MEM)) {
13470 printk(KERN_ERR PFX "Cannot find proper PCI device " 13571 printk(KERN_ERR PFX "Cannot find proper PCI device "
13471 "base address for APE, aborting.\n"); 13572 "base address for APE, aborting.\n");
13472 err = -ENODEV; 13573 err = -ENODEV;
13473 goto err_out_iounmap; 13574 goto err_out_iounmap;
13474 } 13575 }
13475 13576
13476 tg3reg_base = pci_resource_start(pdev, 2); 13577 tp->aperegs = pci_ioremap_bar(pdev, BAR_2);
13477 tg3reg_len = pci_resource_len(pdev, 2);
13478
13479 tp->aperegs = ioremap_nocache(tg3reg_base, tg3reg_len);
13480 if (!tp->aperegs) { 13578 if (!tp->aperegs) {
13481 printk(KERN_ERR PFX "Cannot map APE registers, " 13579 printk(KERN_ERR PFX "Cannot map APE registers, "
13482 "aborting.\n"); 13580 "aborting.\n");
@@ -13535,26 +13633,34 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13535 goto err_out_apeunmap; 13633 goto err_out_apeunmap;
13536 } 13634 }
13537 13635
13538 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] " 13636 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x] (%s) MAC address %pM\n",
13539 "(%s) %s Ethernet %s\n",
13540 dev->name, 13637 dev->name,
13541 tp->board_part_number, 13638 tp->board_part_number,
13542 tp->pci_chip_rev_id, 13639 tp->pci_chip_rev_id,
13543 tg3_phy_string(tp),
13544 tg3_bus_string(tp, str), 13640 tg3_bus_string(tp, str),
13545 ((tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100Base-TX" : 13641 dev->dev_addr);
13546 ((tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) ? "1000Base-SX" :
13547 "10/100/1000Base-T")),
13548 print_mac(mac, dev->dev_addr));
13549 13642
13550 printk(KERN_INFO "%s: RXcsums[%d] LinkChgREG[%d] " 13643 if (tp->tg3_flags3 & TG3_FLG3_PHY_CONNECTED)
13551 "MIirq[%d] ASF[%d] WireSpeed[%d] TSOcap[%d]\n", 13644 printk(KERN_INFO
13645 "%s: attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
13646 tp->dev->name,
13647 tp->mdio_bus->phy_map[PHY_ADDR]->drv->name,
13648 dev_name(&tp->mdio_bus->phy_map[PHY_ADDR]->dev));
13649 else
13650 printk(KERN_INFO
13651 "%s: attached PHY is %s (%s Ethernet) (WireSpeed[%d])\n",
13652 tp->dev->name, tg3_phy_string(tp),
13653 ((tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100Base-TX" :
13654 ((tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) ? "1000Base-SX" :
13655 "10/100/1000Base-T")),
13656 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0);
13657
13658 printk(KERN_INFO "%s: RXcsums[%d] LinkChgREG[%d] MIirq[%d] ASF[%d] TSOcap[%d]\n",
13552 dev->name, 13659 dev->name,
13553 (tp->tg3_flags & TG3_FLAG_RX_CHECKSUMS) != 0, 13660 (tp->tg3_flags & TG3_FLAG_RX_CHECKSUMS) != 0,
13554 (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) != 0, 13661 (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) != 0,
13555 (tp->tg3_flags & TG3_FLAG_USE_MI_INTERRUPT) != 0, 13662 (tp->tg3_flags & TG3_FLAG_USE_MI_INTERRUPT) != 0,
13556 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0, 13663 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0,
13557 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0,
13558 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0); 13664 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0);
13559 printk(KERN_INFO "%s: dma_rwctrl[%08x] dma_mask[%d-bit]\n", 13665 printk(KERN_INFO "%s: dma_rwctrl[%08x] dma_mask[%d-bit]\n",
13560 dev->name, tp->dma_rwctrl, 13666 dev->name, tp->dma_rwctrl,
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index be252abe8985..599e490cf62c 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -38,6 +38,8 @@
38#define TG3PCI_DEVICE_TIGON3_2 0x1645 /* BCM5701 */ 38#define TG3PCI_DEVICE_TIGON3_2 0x1645 /* BCM5701 */
39#define TG3PCI_DEVICE_TIGON3_3 0x1646 /* BCM5702 */ 39#define TG3PCI_DEVICE_TIGON3_3 0x1646 /* BCM5702 */
40#define TG3PCI_DEVICE_TIGON3_4 0x1647 /* BCM5703 */ 40#define TG3PCI_DEVICE_TIGON3_4 0x1647 /* BCM5703 */
41#define TG3PCI_DEVICE_TIGON3_5761S 0x1688
42#define TG3PCI_DEVICE_TIGON3_5761SE 0x1689
41#define TG3PCI_COMMAND 0x00000004 43#define TG3PCI_COMMAND 0x00000004
42#define TG3PCI_STATUS 0x00000006 44#define TG3PCI_STATUS 0x00000006
43#define TG3PCI_CCREVID 0x00000008 45#define TG3PCI_CCREVID 0x00000008
@@ -325,6 +327,7 @@
325#define MAC_MODE_TDE_ENABLE 0x00200000 327#define MAC_MODE_TDE_ENABLE 0x00200000
326#define MAC_MODE_RDE_ENABLE 0x00400000 328#define MAC_MODE_RDE_ENABLE 0x00400000
327#define MAC_MODE_FHDE_ENABLE 0x00800000 329#define MAC_MODE_FHDE_ENABLE 0x00800000
330#define MAC_MODE_KEEP_FRAME_IN_WOL 0x01000000
328#define MAC_MODE_APE_RX_EN 0x08000000 331#define MAC_MODE_APE_RX_EN 0x08000000
329#define MAC_MODE_APE_TX_EN 0x10000000 332#define MAC_MODE_APE_TX_EN 0x10000000
330#define MAC_STATUS 0x00000404 333#define MAC_STATUS 0x00000404
@@ -414,6 +417,7 @@
414#define MI_COM_DATA_MASK 0x0000ffff 417#define MI_COM_DATA_MASK 0x0000ffff
415#define MAC_MI_STAT 0x00000450 418#define MAC_MI_STAT 0x00000450
416#define MAC_MI_STAT_LNKSTAT_ATTN_ENAB 0x00000001 419#define MAC_MI_STAT_LNKSTAT_ATTN_ENAB 0x00000001
420#define MAC_MI_STAT_10MBPS_MODE 0x00000002
417#define MAC_MI_MODE 0x00000454 421#define MAC_MI_MODE 0x00000454
418#define MAC_MI_MODE_CLK_10MHZ 0x00000001 422#define MAC_MI_MODE_CLK_10MHZ 0x00000001
419#define MAC_MI_MODE_SHORT_PREAMBLE 0x00000002 423#define MAC_MI_MODE_SHORT_PREAMBLE 0x00000002
@@ -539,6 +543,100 @@
539#define MAC_PHYCFG1_TXC_DRV 0x20000000 543#define MAC_PHYCFG1_TXC_DRV 0x20000000
540#define MAC_PHYCFG2 0x000005a4 544#define MAC_PHYCFG2 0x000005a4
541#define MAC_PHYCFG2_INBAND_ENABLE 0x00000001 545#define MAC_PHYCFG2_INBAND_ENABLE 0x00000001
546#define MAC_PHYCFG2_EMODE_MASK_MASK 0x000001c0
547#define MAC_PHYCFG2_EMODE_MASK_AC131 0x000000c0
548#define MAC_PHYCFG2_EMODE_MASK_50610 0x00000100
549#define MAC_PHYCFG2_EMODE_MASK_RT8211 0x00000000
550#define MAC_PHYCFG2_EMODE_MASK_RT8201 0x000001c0
551#define MAC_PHYCFG2_EMODE_COMP_MASK 0x00000e00
552#define MAC_PHYCFG2_EMODE_COMP_AC131 0x00000600
553#define MAC_PHYCFG2_EMODE_COMP_50610 0x00000400
554#define MAC_PHYCFG2_EMODE_COMP_RT8211 0x00000800
555#define MAC_PHYCFG2_EMODE_COMP_RT8201 0x00000000
556#define MAC_PHYCFG2_FMODE_MASK_MASK 0x00007000
557#define MAC_PHYCFG2_FMODE_MASK_AC131 0x00006000
558#define MAC_PHYCFG2_FMODE_MASK_50610 0x00004000
559#define MAC_PHYCFG2_FMODE_MASK_RT8211 0x00000000
560#define MAC_PHYCFG2_FMODE_MASK_RT8201 0x00007000
561#define MAC_PHYCFG2_FMODE_COMP_MASK 0x00038000
562#define MAC_PHYCFG2_FMODE_COMP_AC131 0x00030000
563#define MAC_PHYCFG2_FMODE_COMP_50610 0x00008000
564#define MAC_PHYCFG2_FMODE_COMP_RT8211 0x00038000
565#define MAC_PHYCFG2_FMODE_COMP_RT8201 0x00000000
566#define MAC_PHYCFG2_GMODE_MASK_MASK 0x001c0000
567#define MAC_PHYCFG2_GMODE_MASK_AC131 0x001c0000
568#define MAC_PHYCFG2_GMODE_MASK_50610 0x00100000
569#define MAC_PHYCFG2_GMODE_MASK_RT8211 0x00000000
570#define MAC_PHYCFG2_GMODE_MASK_RT8201 0x001c0000
571#define MAC_PHYCFG2_GMODE_COMP_MASK 0x00e00000
572#define MAC_PHYCFG2_GMODE_COMP_AC131 0x00e00000
573#define MAC_PHYCFG2_GMODE_COMP_50610 0x00000000
574#define MAC_PHYCFG2_GMODE_COMP_RT8211 0x00200000
575#define MAC_PHYCFG2_GMODE_COMP_RT8201 0x00000000
576#define MAC_PHYCFG2_ACT_MASK_MASK 0x03000000
577#define MAC_PHYCFG2_ACT_MASK_AC131 0x03000000
578#define MAC_PHYCFG2_ACT_MASK_50610 0x01000000
579#define MAC_PHYCFG2_ACT_MASK_RT8211 0x03000000
580#define MAC_PHYCFG2_ACT_MASK_RT8201 0x01000000
581#define MAC_PHYCFG2_ACT_COMP_MASK 0x0c000000
582#define MAC_PHYCFG2_ACT_COMP_AC131 0x00000000
583#define MAC_PHYCFG2_ACT_COMP_50610 0x00000000
584#define MAC_PHYCFG2_ACT_COMP_RT8211 0x00000000
585#define MAC_PHYCFG2_ACT_COMP_RT8201 0x08000000
586#define MAC_PHYCFG2_QUAL_MASK_MASK 0x30000000
587#define MAC_PHYCFG2_QUAL_MASK_AC131 0x30000000
588#define MAC_PHYCFG2_QUAL_MASK_50610 0x30000000
589#define MAC_PHYCFG2_QUAL_MASK_RT8211 0x30000000
590#define MAC_PHYCFG2_QUAL_MASK_RT8201 0x30000000
591#define MAC_PHYCFG2_QUAL_COMP_MASK 0xc0000000
592#define MAC_PHYCFG2_QUAL_COMP_AC131 0x00000000
593#define MAC_PHYCFG2_QUAL_COMP_50610 0x00000000
594#define MAC_PHYCFG2_QUAL_COMP_RT8211 0x00000000
595#define MAC_PHYCFG2_QUAL_COMP_RT8201 0x00000000
596#define MAC_PHYCFG2_50610_LED_MODES \
597 (MAC_PHYCFG2_EMODE_MASK_50610 | \
598 MAC_PHYCFG2_EMODE_COMP_50610 | \
599 MAC_PHYCFG2_FMODE_MASK_50610 | \
600 MAC_PHYCFG2_FMODE_COMP_50610 | \
601 MAC_PHYCFG2_GMODE_MASK_50610 | \
602 MAC_PHYCFG2_GMODE_COMP_50610 | \
603 MAC_PHYCFG2_ACT_MASK_50610 | \
604 MAC_PHYCFG2_ACT_COMP_50610 | \
605 MAC_PHYCFG2_QUAL_MASK_50610 | \
606 MAC_PHYCFG2_QUAL_COMP_50610)
607#define MAC_PHYCFG2_AC131_LED_MODES \
608 (MAC_PHYCFG2_EMODE_MASK_AC131 | \
609 MAC_PHYCFG2_EMODE_COMP_AC131 | \
610 MAC_PHYCFG2_FMODE_MASK_AC131 | \
611 MAC_PHYCFG2_FMODE_COMP_AC131 | \
612 MAC_PHYCFG2_GMODE_MASK_AC131 | \
613 MAC_PHYCFG2_GMODE_COMP_AC131 | \
614 MAC_PHYCFG2_ACT_MASK_AC131 | \
615 MAC_PHYCFG2_ACT_COMP_AC131 | \
616 MAC_PHYCFG2_QUAL_MASK_AC131 | \
617 MAC_PHYCFG2_QUAL_COMP_AC131)
618#define MAC_PHYCFG2_RTL8211C_LED_MODES \
619 (MAC_PHYCFG2_EMODE_MASK_RT8211 | \
620 MAC_PHYCFG2_EMODE_COMP_RT8211 | \
621 MAC_PHYCFG2_FMODE_MASK_RT8211 | \
622 MAC_PHYCFG2_FMODE_COMP_RT8211 | \
623 MAC_PHYCFG2_GMODE_MASK_RT8211 | \
624 MAC_PHYCFG2_GMODE_COMP_RT8211 | \
625 MAC_PHYCFG2_ACT_MASK_RT8211 | \
626 MAC_PHYCFG2_ACT_COMP_RT8211 | \
627 MAC_PHYCFG2_QUAL_MASK_RT8211 | \
628 MAC_PHYCFG2_QUAL_COMP_RT8211)
629#define MAC_PHYCFG2_RTL8201E_LED_MODES \
630 (MAC_PHYCFG2_EMODE_MASK_RT8201 | \
631 MAC_PHYCFG2_EMODE_COMP_RT8201 | \
632 MAC_PHYCFG2_FMODE_MASK_RT8201 | \
633 MAC_PHYCFG2_FMODE_COMP_RT8201 | \
634 MAC_PHYCFG2_GMODE_MASK_RT8201 | \
635 MAC_PHYCFG2_GMODE_COMP_RT8201 | \
636 MAC_PHYCFG2_ACT_MASK_RT8201 | \
637 MAC_PHYCFG2_ACT_COMP_RT8201 | \
638 MAC_PHYCFG2_QUAL_MASK_RT8201 | \
639 MAC_PHYCFG2_QUAL_COMP_RT8201)
542#define MAC_EXT_RGMII_MODE 0x000005a8 640#define MAC_EXT_RGMII_MODE 0x000005a8
543#define MAC_RGMII_MODE_TX_ENABLE 0x00000001 641#define MAC_RGMII_MODE_TX_ENABLE 0x00000001
544#define MAC_RGMII_MODE_TX_LOWPWR 0x00000002 642#define MAC_RGMII_MODE_TX_LOWPWR 0x00000002
@@ -1792,6 +1890,11 @@
1792 1890
1793#define MII_TG3_AUX_CTRL 0x18 /* auxilliary control register */ 1891#define MII_TG3_AUX_CTRL 0x18 /* auxilliary control register */
1794 1892
1893#define MII_TG3_AUXCTL_PCTL_100TX_LPWR 0x0010
1894#define MII_TG3_AUXCTL_PCTL_SPR_ISOLATE 0x0020
1895#define MII_TG3_AUXCTL_PCTL_VREG_11V 0x0180
1896#define MII_TG3_AUXCTL_SHDWSEL_PWRCTL 0x0002
1897
1795#define MII_TG3_AUXCTL_MISC_WREN 0x8000 1898#define MII_TG3_AUXCTL_MISC_WREN 0x8000
1796#define MII_TG3_AUXCTL_MISC_FORCE_AMDIX 0x0200 1899#define MII_TG3_AUXCTL_MISC_FORCE_AMDIX 0x0200
1797#define MII_TG3_AUXCTL_MISC_RDSEL_MISC 0x7000 1900#define MII_TG3_AUXCTL_MISC_RDSEL_MISC 0x7000
@@ -2507,7 +2610,6 @@ struct tg3 {
2507 u32 tg3_flags3; 2610 u32 tg3_flags3;
2508#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001 2611#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001
2509#define TG3_FLG3_ENABLE_APE 0x00000002 2612#define TG3_FLG3_ENABLE_APE 0x00000002
2510#define TG3_FLG3_5761_5784_AX_FIXES 0x00000004
2511#define TG3_FLG3_5701_DMA_BUG 0x00000008 2613#define TG3_FLG3_5701_DMA_BUG 0x00000008
2512#define TG3_FLG3_USE_PHYLIB 0x00000010 2614#define TG3_FLG3_USE_PHYLIB 0x00000010
2513#define TG3_FLG3_MDIOBUS_INITED 0x00000020 2615#define TG3_FLG3_MDIOBUS_INITED 0x00000020
@@ -2588,7 +2690,12 @@ struct tg3 {
2588#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */ 2690#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */
2589#define TG3_PHY_ID_BCM50610 0x143bd60 2691#define TG3_PHY_ID_BCM50610 0x143bd60
2590#define TG3_PHY_ID_BCMAC131 0x143bc70 2692#define TG3_PHY_ID_BCMAC131 0x143bc70
2591 2693#define TG3_PHY_ID_RTL8211C 0x001cc910
2694#define TG3_PHY_ID_RTL8201E 0x00008200
2695#define TG3_PHY_OUI_MASK 0xfffffc00
2696#define TG3_PHY_OUI_1 0x00206000
2697#define TG3_PHY_OUI_2 0x0143bc00
2698#define TG3_PHY_OUI_3 0x03625c00
2592 2699
2593 u32 led_ctrl; 2700 u32 led_ctrl;
2594 u32 phy_otp; 2701 u32 phy_otp;
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index c41d68761364..055d3429851f 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -1649,8 +1649,6 @@ drop_and_reuse:
1649 } 1649 }
1650 } 1650 }
1651 1651
1652 dev->last_rx = jiffies;
1653
1654 return ack; 1652 return ack;
1655 1653
1656} /* TLan_HandleRxEOF */ 1654} /* TLan_HandleRxEOF */
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index bf621328b601..87509a65b3bf 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -974,7 +974,6 @@ static void xl_rx(struct net_device *dev)
974 974
975 netif_rx(skb2) ; 975 netif_rx(skb2) ;
976 } /* if multiple buffers */ 976 } /* if multiple buffers */
977 dev->last_rx = jiffies ;
978 } /* while packet to do */ 977 } /* while packet to do */
979 978
980 /* Clear the updComplete interrupt */ 979 /* Clear the updComplete interrupt */
@@ -1571,7 +1570,6 @@ static void xl_arb_cmd(struct net_device *dev)
1571 * anyway. 1570 * anyway.
1572 */ 1571 */
1573 1572
1574 dev->last_rx = jiffies ;
1575 /* Acknowledge interrupt, this tells nic we are done with the arb */ 1573 /* Acknowledge interrupt, this tells nic we are done with the arb */
1576 writel(ACK_INTERRUPT | ARBCACK | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; 1574 writel(ACK_INTERRUPT | ARBCACK | LATCH_ACK, xl_mmio + MMIO_COMMAND) ;
1577 1575
diff --git a/drivers/net/tokenring/abyss.c b/drivers/net/tokenring/abyss.c
index 7a7de0469eae..b566d6d79ecd 100644
--- a/drivers/net/tokenring/abyss.c
+++ b/drivers/net/tokenring/abyss.c
@@ -99,7 +99,6 @@ static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_
99 struct net_local *tp; 99 struct net_local *tp;
100 int ret, pci_irq_line; 100 int ret, pci_irq_line;
101 unsigned long pci_ioaddr; 101 unsigned long pci_ioaddr;
102 DECLARE_MAC_BUF(mac);
103 102
104 if (versionprinted++ == 0) 103 if (versionprinted++ == 0)
105 printk("%s", version); 104 printk("%s", version);
@@ -147,8 +146,7 @@ static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_
147 146
148 abyss_read_eeprom(dev); 147 abyss_read_eeprom(dev);
149 148
150 printk("%s: Ring Station Address: %s\n", 149 printk("%s: Ring Station Address: %pM\n", dev->name, dev->dev_addr);
151 dev->name, print_mac(mac, dev->dev_addr));
152 150
153 tp = netdev_priv(dev); 151 tp = netdev_priv(dev);
154 tp->setnselout = abyss_setnselout_pins; 152 tp->setnselout = abyss_setnselout_pins;
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index e494c63bfbd9..9fd09938d45b 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -389,7 +389,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
389 unsigned long timeout; 389 unsigned long timeout;
390 static int version_printed; 390 static int version_printed;
391#endif 391#endif
392 DECLARE_MAC_BUF(mac);
393 392
394 /* Query the adapter PIO base port which will return 393 /* Query the adapter PIO base port which will return
395 * indication of where MMIO was placed. We also have a 394 * indication of where MMIO was placed. We also have a
@@ -703,8 +702,7 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
703 channel_def[cardpresent - 1], adapter_def(ti->adapter_type)); 702 channel_def[cardpresent - 1], adapter_def(ti->adapter_type));
704 DPRINTK("using irq %d, PIOaddr %hx, %dK shared RAM.\n", 703 DPRINTK("using irq %d, PIOaddr %hx, %dK shared RAM.\n",
705 irq, PIOaddr, ti->mapped_ram_size / 2); 704 irq, PIOaddr, ti->mapped_ram_size / 2);
706 DPRINTK("Hardware address : %s\n", 705 DPRINTK("Hardware address : %pM\n", dev->dev_addr);
707 print_mac(mac, dev->dev_addr));
708 if (ti->page_mask) 706 if (ti->page_mask)
709 DPRINTK("Shared RAM paging enabled. " 707 DPRINTK("Shared RAM paging enabled. "
710 "Page size: %uK Shared Ram size %dK\n", 708 "Page size: %uK Shared Ram size %dK\n",
@@ -1741,8 +1739,6 @@ static void tr_rx(struct net_device *dev)
1741 void __iomem *trhhdr = rbuf + offsetof(struct rec_buf, data); 1739 void __iomem *trhhdr = rbuf + offsetof(struct rec_buf, data);
1742 u8 saddr[6]; 1740 u8 saddr[6];
1743 u8 daddr[6]; 1741 u8 daddr[6];
1744 DECLARE_MAC_BUF(mac);
1745 DECLARE_MAC_BUF(mac2);
1746 int i; 1742 int i;
1747 for (i = 0 ; i < 6 ; i++) 1743 for (i = 0 ; i < 6 ; i++)
1748 saddr[i] = readb(trhhdr + SADDR_OFST + i); 1744 saddr[i] = readb(trhhdr + SADDR_OFST + i);
@@ -1750,9 +1746,9 @@ static void tr_rx(struct net_device *dev)
1750 daddr[i] = readb(trhhdr + DADDR_OFST + i); 1746 daddr[i] = readb(trhhdr + DADDR_OFST + i);
1751 DPRINTK("Probably non-IP frame received.\n"); 1747 DPRINTK("Probably non-IP frame received.\n");
1752 DPRINTK("ssap: %02X dsap: %02X " 1748 DPRINTK("ssap: %02X dsap: %02X "
1753 "saddr: %s daddr: %$s\n", 1749 "saddr: %pM daddr: %pM\n",
1754 readb(llc + SSAP_OFST), readb(llc + DSAP_OFST), 1750 readb(llc + SSAP_OFST), readb(llc + DSAP_OFST),
1755 print_mac(mac, saddr), print_mac(mac2, daddr)); 1751 saddr, daddr);
1756 } 1752 }
1757#endif 1753#endif
1758 1754
@@ -1826,7 +1822,6 @@ static void tr_rx(struct net_device *dev)
1826 skb->ip_summed = CHECKSUM_COMPLETE; 1822 skb->ip_summed = CHECKSUM_COMPLETE;
1827 } 1823 }
1828 netif_rx(skb); 1824 netif_rx(skb);
1829 dev->last_rx = jiffies;
1830} /*tr_rx */ 1825} /*tr_rx */
1831 1826
1832/*****************************************************************************/ 1827/*****************************************************************************/
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 59d1673f9387..239c75217b12 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -446,9 +446,6 @@ static int streamer_reset(struct net_device *dev)
446 unsigned int uaa_addr; 446 unsigned int uaa_addr;
447 struct sk_buff *skb = NULL; 447 struct sk_buff *skb = NULL;
448 __u16 misr; 448 __u16 misr;
449#if STREAMER_DEBUG
450 DECLARE_MAC_BUF(mac);
451#endif
452 449
453 streamer_priv = netdev_priv(dev); 450 streamer_priv = netdev_priv(dev);
454 streamer_mmio = streamer_priv->streamer_mmio; 451 streamer_mmio = streamer_priv->streamer_mmio;
@@ -577,8 +574,7 @@ static int streamer_reset(struct net_device *dev)
577 dev->dev_addr[i+1]= addr & 0xff; 574 dev->dev_addr[i+1]= addr & 0xff;
578 } 575 }
579#if STREAMER_DEBUG 576#if STREAMER_DEBUG
580 printk("Adapter address: %s\n", 577 printk("Adapter address: %pM\n", dev->dev_addr);
581 print_mac(mac, dev->dev_addr));
582#endif 578#endif
583 } 579 }
584 return 0; 580 return 0;
@@ -1013,7 +1009,6 @@ static void streamer_rx(struct net_device *dev)
1013 /* send up to the protocol */ 1009 /* send up to the protocol */
1014 netif_rx(skb); 1010 netif_rx(skb);
1015 } 1011 }
1016 dev->last_rx = jiffies;
1017 streamer_priv->streamer_stats.rx_packets++; 1012 streamer_priv->streamer_stats.rx_packets++;
1018 streamer_priv->streamer_stats.rx_bytes += length; 1013 streamer_priv->streamer_stats.rx_bytes += length;
1019 } /* if skb == null */ 1014 } /* if skb == null */
@@ -1538,7 +1533,6 @@ static void streamer_arb_cmd(struct net_device *dev)
1538 1533
1539#if STREAMER_NETWORK_MONITOR 1534#if STREAMER_NETWORK_MONITOR
1540 struct trh_hdr *mac_hdr; 1535 struct trh_hdr *mac_hdr;
1541 DECLARE_MAC_BUF(mac);
1542#endif 1536#endif
1543 1537
1544 writew(streamer_priv->arb, streamer_mmio + LAPA); 1538 writew(streamer_priv->arb, streamer_mmio + LAPA);
@@ -1611,11 +1605,11 @@ static void streamer_arb_cmd(struct net_device *dev)
1611 dev->name); 1605 dev->name);
1612 mac_hdr = tr_hdr(mac_frame); 1606 mac_hdr = tr_hdr(mac_frame);
1613 printk(KERN_WARNING 1607 printk(KERN_WARNING
1614 "%s: MAC Frame Dest. Addr: %s\n", 1608 "%s: MAC Frame Dest. Addr: %pM\n",
1615 dev->name, print_mac(mac, mac_hdr->daddr)); 1609 dev->name, mac_hdr->daddr);
1616 printk(KERN_WARNING 1610 printk(KERN_WARNING
1617 "%s: MAC Frame Srce. Addr: %s\n", 1611 "%s: MAC Frame Srce. Addr: %pM\n",
1618 dev->name, DEV->ADDR6(mac_hdr->saddr)); 1612 dev->name, mac_hdr->saddr);
1619#endif 1613#endif
1620 netif_rx(mac_frame); 1614 netif_rx(mac_frame);
1621 1615
@@ -1850,8 +1844,6 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1850 struct streamer_parameters_table spt; 1844 struct streamer_parameters_table spt;
1851 int size = 0; 1845 int size = 0;
1852 int i; 1846 int i;
1853 DECLARE_MAC_BUF(mac);
1854 DECLARE_MAC_BUF(mac2);
1855 1847
1856 writew(streamer_priv->streamer_addr_table_addr, streamer_mmio + LAPA); 1848 writew(streamer_priv->streamer_addr_table_addr, streamer_mmio + LAPA);
1857 for (i = 0; i < 14; i += 2) { 1849 for (i = 0; i < 14; i += 2) {
@@ -1873,9 +1865,8 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1873 size = sprintf(buffer, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev->name); 1865 size = sprintf(buffer, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev->name);
1874 1866
1875 size += sprintf(buffer + size, 1867 size += sprintf(buffer + size,
1876 "%6s: %s : %s : %02x:%02x:%02x:%02x\n", 1868 "%6s: %pM : %pM : %02x:%02x:%02x:%02x\n",
1877 dev->name, print_mac(mac, dev->dev_addr), 1869 dev->name, dev->dev_addr, sat.node_addr,
1878 print_mac(mac2, sat.node_addr),
1879 sat.func_addr[0], sat.func_addr[1], 1870 sat.func_addr[0], sat.func_addr[1],
1880 sat.func_addr[2], sat.func_addr[3]); 1871 sat.func_addr[2], sat.func_addr[3]);
1881 1872
@@ -1884,19 +1875,18 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1884 size += sprintf(buffer + size, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", dev->name); 1875 size += sprintf(buffer + size, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", dev->name);
1885 1876
1886 size += sprintf(buffer + size, 1877 size += sprintf(buffer + size,
1887 "%6s: %02x:%02x:%02x:%02x : %s : %s : %04x : %04x : %04x :\n", 1878 "%6s: %02x:%02x:%02x:%02x : %pM : %pM : %04x : %04x : %04x :\n",
1888 dev->name, spt.phys_addr[0], spt.phys_addr[1], 1879 dev->name, spt.phys_addr[0], spt.phys_addr[1],
1889 spt.phys_addr[2], spt.phys_addr[3], 1880 spt.phys_addr[2], spt.phys_addr[3],
1890 print_mac(mac, spt.up_node_addr), 1881 spt.up_node_addr, spt.poll_addr,
1891 print_mac(mac2, spt.poll_addr),
1892 ntohs(spt.acc_priority), ntohs(spt.auth_source_class), 1882 ntohs(spt.acc_priority), ntohs(spt.auth_source_class),
1893 ntohs(spt.att_code)); 1883 ntohs(spt.att_code));
1894 1884
1895 size += sprintf(buffer + size, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", dev->name); 1885 size += sprintf(buffer + size, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", dev->name);
1896 1886
1897 size += sprintf(buffer + size, 1887 size += sprintf(buffer + size,
1898 "%6s: %s : %04x : %04x : %04x : %04x : %04x : %04x : \n", 1888 "%6s: %pM : %04x : %04x : %04x : %04x : %04x : %04x : \n",
1899 dev->name, print_mac(mac, spt.source_addr), 1889 dev->name, spt.source_addr,
1900 ntohs(spt.beacon_type), ntohs(spt.major_vector), 1890 ntohs(spt.beacon_type), ntohs(spt.major_vector),
1901 ntohs(spt.lan_status), ntohs(spt.local_ring), 1891 ntohs(spt.lan_status), ntohs(spt.local_ring),
1902 ntohs(spt.mon_error), ntohs(spt.frame_correl)); 1892 ntohs(spt.mon_error), ntohs(spt.frame_correl));
@@ -1905,10 +1895,10 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1905 dev->name); 1895 dev->name);
1906 1896
1907 size += sprintf(buffer + size, 1897 size += sprintf(buffer + size,
1908 "%6s: : %02x : %02x : %s : %02x:%02x:%02x:%02x : \n", 1898 "%6s: : %02x : %02x : %pM : %02x:%02x:%02x:%02x : \n",
1909 dev->name, ntohs(spt.beacon_transmit), 1899 dev->name, ntohs(spt.beacon_transmit),
1910 ntohs(spt.beacon_receive), 1900 ntohs(spt.beacon_receive),
1911 print_mac(mac, spt.beacon_naun), 1901 spt.beacon_naun,
1912 spt.beacon_phys[0], spt.beacon_phys[1], 1902 spt.beacon_phys[0], spt.beacon_phys[1],
1913 spt.beacon_phys[2], spt.beacon_phys[3]); 1903 spt.beacon_phys[2], spt.beacon_phys[3]);
1914 return size; 1904 return size;
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index c9c5a2b1ed9e..0ba6f0bc7c00 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -152,7 +152,6 @@ static int __devinit madgemc_probe(struct device *device)
152 struct card_info *card; 152 struct card_info *card;
153 struct mca_device *mdev = to_mca_device(device); 153 struct mca_device *mdev = to_mca_device(device);
154 int ret = 0; 154 int ret = 0;
155 DECLARE_MAC_BUF(mac);
156 155
157 if (versionprinted++ == 0) 156 if (versionprinted++ == 0)
158 printk("%s", version); 157 printk("%s", version);
@@ -323,8 +322,8 @@ static int __devinit madgemc_probe(struct device *device)
323 mca_device_set_name(mdev, (card->cardtype == 0x08)?MADGEMC16_CARDNAME:MADGEMC32_CARDNAME); 322 mca_device_set_name(mdev, (card->cardtype == 0x08)?MADGEMC16_CARDNAME:MADGEMC32_CARDNAME);
324 mca_set_adapter_procfn(mdev->slot, madgemc_mcaproc, dev); 323 mca_set_adapter_procfn(mdev->slot, madgemc_mcaproc, dev);
325 324
326 printk("%s: Ring Station Address: %s\n", 325 printk("%s: Ring Station Address: %pM\n",
327 dev->name, print_mac(mac, dev->dev_addr)); 326 dev->name, dev->dev_addr);
328 327
329 if (tmsdev_init(dev, device)) { 328 if (tmsdev_init(dev, device)) {
330 printk("%s: unable to get memory for dev->priv.\n", 329 printk("%s: unable to get memory for dev->priv.\n",
@@ -690,7 +689,6 @@ static int madgemc_mcaproc(char *buf, int slot, void *d)
690 struct net_local *tp = netdev_priv(dev); 689 struct net_local *tp = netdev_priv(dev);
691 struct card_info *curcard = tp->tmspriv; 690 struct card_info *curcard = tp->tmspriv;
692 int len = 0; 691 int len = 0;
693 DECLARE_MAC_BUF(mac);
694 692
695 len += sprintf(buf+len, "-------\n"); 693 len += sprintf(buf+len, "-------\n");
696 if (curcard) { 694 if (curcard) {
@@ -714,8 +712,8 @@ static int madgemc_mcaproc(char *buf, int slot, void *d)
714 } 712 }
715 len += sprintf(buf+len, " (%s)\n", (curcard->fairness)?"Unfair":"Fair"); 713 len += sprintf(buf+len, " (%s)\n", (curcard->fairness)?"Unfair":"Fair");
716 714
717 len += sprintf(buf+len, "Ring Station Address: %s\n", 715 len += sprintf(buf+len, "Ring Station Address: %pM\n",
718 print_mac(mac, dev->dev_addr)); 716 dev->dev_addr);
719 } else 717 } else
720 len += sprintf(buf+len, "Card not configured\n"); 718 len += sprintf(buf+len, "Card not configured\n");
721 719
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 0ab51a0f35fc..ecb5c7c96910 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -421,10 +421,7 @@ static int olympic_init(struct net_device *dev)
421 memcpy_fromio(&dev->dev_addr[0], adapter_addr,6); 421 memcpy_fromio(&dev->dev_addr[0], adapter_addr,6);
422 422
423#if OLYMPIC_DEBUG 423#if OLYMPIC_DEBUG
424 { 424 printk("adapter address: %pM\n", dev->dev_addr);
425 DECLARE_MAC_BUF(mac);
426 printk("adapter address: %s\n", print_mac(mac, dev->dev_addr));
427 }
428#endif 425#endif
429 426
430 olympic_priv->olympic_addr_table_addr = swab16(readw(init_srb + 12)); 427 olympic_priv->olympic_addr_table_addr = swab16(readw(init_srb + 12));
@@ -441,7 +438,6 @@ static int olympic_open(struct net_device *dev)
441 unsigned long flags, t; 438 unsigned long flags, t;
442 int i, open_finished = 1 ; 439 int i, open_finished = 1 ;
443 u8 resp, err; 440 u8 resp, err;
444 DECLARE_MAC_BUF(mac);
445 441
446 DECLARE_WAITQUEUE(wait,current) ; 442 DECLARE_WAITQUEUE(wait,current) ;
447 443
@@ -569,8 +565,8 @@ static int olympic_open(struct net_device *dev)
569 goto out; 565 goto out;
570 566
571 case 0x32: 567 case 0x32:
572 printk(KERN_WARNING "%s: Invalid LAA: %s\n", 568 printk(KERN_WARNING "%s: Invalid LAA: %pM\n",
573 dev->name, print_mac(mac, olympic_priv->olympic_laa)); 569 dev->name, olympic_priv->olympic_laa);
574 goto out; 570 goto out;
575 571
576 default: 572 default:
@@ -704,13 +700,12 @@ static int olympic_open(struct net_device *dev)
704 u8 __iomem *opt; 700 u8 __iomem *opt;
705 int i; 701 int i;
706 u8 addr[6]; 702 u8 addr[6];
707 DECLARE_MAC_BUF(mac);
708 oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr); 703 oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr);
709 opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr); 704 opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr);
710 705
711 for (i = 0; i < 6; i++) 706 for (i = 0; i < 6; i++)
712 addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+i); 707 addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+i);
713 printk("%s: Node Address: %s\n",dev->name, print_mac(mac, addr)); 708 printk("%s: Node Address: %pM\n", dev->name, addr);
714 printk("%s: Functional Address: %02x:%02x:%02x:%02x\n",dev->name, 709 printk("%s: Functional Address: %02x:%02x:%02x:%02x\n",dev->name,
715 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)), 710 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)),
716 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1), 711 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1),
@@ -719,7 +714,7 @@ static int olympic_open(struct net_device *dev)
719 714
720 for (i = 0; i < 6; i++) 715 for (i = 0; i < 6; i++)
721 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+i); 716 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+i);
722 printk("%s: NAUN Address: %s\n",dev->name, print_mac(mac, addr)); 717 printk("%s: NAUN Address: %pM\n", dev->name, addr);
723 } 718 }
724 719
725 netif_start_queue(dev); 720 netif_start_queue(dev);
@@ -867,7 +862,6 @@ static void olympic_rx(struct net_device *dev)
867 skb->protocol = tr_type_trans(skb,dev); 862 skb->protocol = tr_type_trans(skb,dev);
868 netif_rx(skb) ; 863 netif_rx(skb) ;
869 } 864 }
870 dev->last_rx = jiffies ;
871 olympic_priv->olympic_stats.rx_packets++ ; 865 olympic_priv->olympic_stats.rx_packets++ ;
872 olympic_priv->olympic_stats.rx_bytes += length ; 866 olympic_priv->olympic_stats.rx_bytes += length ;
873 } /* if skb == null */ 867 } /* if skb == null */
@@ -1440,19 +1434,12 @@ static void olympic_arb_cmd(struct net_device *dev)
1440 struct trh_hdr *mac_hdr; 1434 struct trh_hdr *mac_hdr;
1441 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name); 1435 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name);
1442 mac_hdr = tr_hdr(mac_frame); 1436 mac_hdr = tr_hdr(mac_frame);
1443 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: " 1437 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: %pM\n",
1444 MAC_FMT " \n", dev->name, 1438 dev->name, mac_hdr->daddr);
1445 mac_hdr->daddr[0], mac_hdr->daddr[1], 1439 printk(KERN_WARNING "%s: MAC Frame Srce. Addr: %pM\n",
1446 mac_hdr->daddr[2], mac_hdr->daddr[3], 1440 dev->name, mac_hdr->saddr);
1447 mac_hdr->daddr[4], mac_hdr->daddr[5]);
1448 printk(KERN_WARNING "%s: MAC Frame Srce. Addr: "
1449 MAC_FMT " \n", dev->name,
1450 mac_hdr->saddr[0], mac_hdr->saddr[1],
1451 mac_hdr->saddr[2], mac_hdr->saddr[3],
1452 mac_hdr->saddr[4], mac_hdr->saddr[5]);
1453 } 1441 }
1454 netif_rx(mac_frame); 1442 netif_rx(mac_frame);
1455 dev->last_rx = jiffies;
1456 1443
1457drop_frame: 1444drop_frame:
1458 /* Now tell the card we have dealt with the received frame */ 1445 /* Now tell the card we have dealt with the received frame */
@@ -1647,8 +1634,6 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1647 u8 addr[6]; 1634 u8 addr[6];
1648 u8 addr2[6]; 1635 u8 addr2[6];
1649 int i; 1636 int i;
1650 DECLARE_MAC_BUF(mac);
1651 DECLARE_MAC_BUF(mac2);
1652 1637
1653 size = sprintf(buffer, 1638 size = sprintf(buffer,
1654 "IBM Pit/Pit-Phy/Olympic Chipset Token Ring Adapter %s\n",dev->name); 1639 "IBM Pit/Pit-Phy/Olympic Chipset Token Ring Adapter %s\n",dev->name);
@@ -1658,10 +1643,9 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1658 for (i = 0 ; i < 6 ; i++) 1643 for (i = 0 ; i < 6 ; i++)
1659 addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr) + i); 1644 addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr) + i);
1660 1645
1661 size += sprintf(buffer+size, "%6s: %s : %s : %02x:%02x:%02x:%02x\n", 1646 size += sprintf(buffer+size, "%6s: %pM : %pM : %02x:%02x:%02x:%02x\n",
1662 dev->name, 1647 dev->name,
1663 print_mac(mac, dev->dev_addr), 1648 dev->dev_addr, addr,
1664 print_mac(mac2, addr),
1665 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)), 1649 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)),
1666 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1), 1650 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1),
1667 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2), 1651 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2),
@@ -1677,14 +1661,13 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1677 for (i = 0 ; i < 6 ; i++) 1661 for (i = 0 ; i < 6 ; i++)
1678 addr2[i] = readb(opt+offsetof(struct olympic_parameters_table, poll_addr) + i); 1662 addr2[i] = readb(opt+offsetof(struct olympic_parameters_table, poll_addr) + i);
1679 1663
1680 size += sprintf(buffer+size, "%6s: %02x:%02x:%02x:%02x : %s : %s : %04x : %04x : %04x :\n", 1664 size += sprintf(buffer+size, "%6s: %02x:%02x:%02x:%02x : %pM : %pM : %04x : %04x : %04x :\n",
1681 dev->name, 1665 dev->name,
1682 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)), 1666 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)),
1683 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+1), 1667 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+1),
1684 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+2), 1668 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+2),
1685 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+3), 1669 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+3),
1686 print_mac(mac, addr), 1670 addr, addr2,
1687 print_mac(mac2, addr2),
1688 swab16(readw(opt+offsetof(struct olympic_parameters_table, acc_priority))), 1671 swab16(readw(opt+offsetof(struct olympic_parameters_table, acc_priority))),
1689 swab16(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))), 1672 swab16(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))),
1690 swab16(readw(opt+offsetof(struct olympic_parameters_table, att_code)))); 1673 swab16(readw(opt+offsetof(struct olympic_parameters_table, att_code))));
@@ -1694,9 +1677,8 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1694 1677
1695 for (i = 0 ; i < 6 ; i++) 1678 for (i = 0 ; i < 6 ; i++)
1696 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, source_addr) + i); 1679 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, source_addr) + i);
1697 size += sprintf(buffer+size, "%6s: %s : %04x : %04x : %04x : %04x : %04x : %04x : \n", 1680 size += sprintf(buffer+size, "%6s: %pM : %04x : %04x : %04x : %04x : %04x : %04x : \n",
1698 dev->name, 1681 dev->name, addr,
1699 print_mac(mac, addr),
1700 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))), 1682 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))),
1701 swab16(readw(opt+offsetof(struct olympic_parameters_table, major_vector))), 1683 swab16(readw(opt+offsetof(struct olympic_parameters_table, major_vector))),
1702 swab16(readw(opt+offsetof(struct olympic_parameters_table, lan_status))), 1684 swab16(readw(opt+offsetof(struct olympic_parameters_table, lan_status))),
@@ -1709,11 +1691,11 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1709 1691
1710 for (i = 0 ; i < 6 ; i++) 1692 for (i = 0 ; i < 6 ; i++)
1711 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, beacon_naun) + i); 1693 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, beacon_naun) + i);
1712 size += sprintf(buffer+size, "%6s: : %02x : %02x : %s : %02x:%02x:%02x:%02x : \n", 1694 size += sprintf(buffer+size, "%6s: : %02x : %02x : %pM : %02x:%02x:%02x:%02x : \n",
1713 dev->name, 1695 dev->name,
1714 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))), 1696 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))),
1715 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))), 1697 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))),
1716 print_mac(mac, addr), 1698 addr,
1717 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)), 1699 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)),
1718 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+1), 1700 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+1),
1719 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+2), 1701 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+2),
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index 00ea94513460..cd2d62f76079 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -122,7 +122,6 @@ static int __init setup_card(struct net_device *dev, struct device *pdev)
122 static int versionprinted; 122 static int versionprinted;
123 const unsigned *port; 123 const unsigned *port;
124 int j,err = 0; 124 int j,err = 0;
125 DECLARE_MAC_BUF(mac);
126 125
127 if (!dev) 126 if (!dev)
128 return -ENOMEM; 127 return -ENOMEM;
@@ -153,8 +152,8 @@ static int __init setup_card(struct net_device *dev, struct device *pdev)
153 152
154 proteon_read_eeprom(dev); 153 proteon_read_eeprom(dev);
155 154
156 printk(KERN_DEBUG "proteon.c: Ring Station Address: %s\n", 155 printk(KERN_DEBUG "proteon.c: Ring Station Address: %pM\n",
157 print_mac(mac, dev->dev_addr)); 156 dev->dev_addr);
158 157
159 tp = netdev_priv(dev); 158 tp = netdev_priv(dev);
160 tp->setnselout = proteon_setnselout_pins; 159 tp->setnselout = proteon_setnselout_pins;
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index 41b6999a0f33..b578744311b0 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -139,7 +139,6 @@ static int __init setup_card(struct net_device *dev, struct device *pdev)
139 static int versionprinted; 139 static int versionprinted;
140 const unsigned *port; 140 const unsigned *port;
141 int j, err = 0; 141 int j, err = 0;
142 DECLARE_MAC_BUF(mac);
143 142
144 if (!dev) 143 if (!dev)
145 return -ENOMEM; 144 return -ENOMEM;
@@ -170,8 +169,8 @@ static int __init setup_card(struct net_device *dev, struct device *pdev)
170 169
171 sk_isa_read_eeprom(dev); 170 sk_isa_read_eeprom(dev);
172 171
173 printk(KERN_DEBUG "skisa.c: Ring Station Address: %s\n", 172 printk(KERN_DEBUG "skisa.c: Ring Station Address: %pM\n",
174 print_mac(mac, dev->dev_addr)); 173 dev->dev_addr);
175 174
176 tp = netdev_priv(dev); 175 tp = netdev_priv(dev);
177 tp->setnselout = sk_isa_setnselout_pins; 176 tp->setnselout = sk_isa_setnselout_pins;
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index ed50d288e494..a011666342ff 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -3910,7 +3910,6 @@ static int smctr_process_rx_packet(MAC_HEADER *rmf, __u16 size,
3910 /* Kick the packet on up. */ 3910 /* Kick the packet on up. */
3911 skb->protocol = tr_type_trans(skb, dev); 3911 skb->protocol = tr_type_trans(skb, dev);
3912 netif_rx(skb); 3912 netif_rx(skb);
3913 dev->last_rx = jiffies;
3914 err = 0; 3913 err = 0;
3915 } 3914 }
3916 3915
@@ -4496,7 +4495,6 @@ static int smctr_rx_frame(struct net_device *dev)
4496 /* Kick the packet on up. */ 4495 /* Kick the packet on up. */
4497 skb->protocol = tr_type_trans(skb, dev); 4496 skb->protocol = tr_type_trans(skb, dev);
4498 netif_rx(skb); 4497 netif_rx(skb);
4499 dev->last_rx = jiffies;
4500 } else { 4498 } else {
4501 } 4499 }
4502 } 4500 }
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index d07c4523c847..5be34c2fd483 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -180,10 +180,14 @@ void tms380tr_wait(unsigned long time);
180static void tms380tr_write_rpl_status(RPL *rpl, unsigned int Status); 180static void tms380tr_write_rpl_status(RPL *rpl, unsigned int Status);
181static void tms380tr_write_tpl_status(TPL *tpl, unsigned int Status); 181static void tms380tr_write_tpl_status(TPL *tpl, unsigned int Status);
182 182
183#define SIFREADB(reg) (((struct net_local *)dev->priv)->sifreadb(dev, reg)) 183#define SIFREADB(reg) \
184#define SIFWRITEB(val, reg) (((struct net_local *)dev->priv)->sifwriteb(dev, val, reg)) 184 (((struct net_local *)netdev_priv(dev))->sifreadb(dev, reg))
185#define SIFREADW(reg) (((struct net_local *)dev->priv)->sifreadw(dev, reg)) 185#define SIFWRITEB(val, reg) \
186#define SIFWRITEW(val, reg) (((struct net_local *)dev->priv)->sifwritew(dev, val, reg)) 186 (((struct net_local *)netdev_priv(dev))->sifwriteb(dev, val, reg))
187#define SIFREADW(reg) \
188 (((struct net_local *)netdev_priv(dev))->sifreadw(dev, reg))
189#define SIFWRITEW(val, reg) \
190 (((struct net_local *)netdev_priv(dev))->sifwritew(dev, val, reg))
187 191
188 192
189 193
@@ -2186,7 +2190,6 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
2186 skb_trim(skb,Length); 2190 skb_trim(skb,Length);
2187 skb->protocol = tr_type_trans(skb,dev); 2191 skb->protocol = tr_type_trans(skb,dev);
2188 netif_rx(skb); 2192 netif_rx(skb);
2189 dev->last_rx = jiffies;
2190 } 2193 }
2191 } 2194 }
2192 else /* Invalid frame */ 2195 else /* Invalid frame */
@@ -2331,7 +2334,7 @@ int tmsdev_init(struct net_device *dev, struct device *pdev)
2331{ 2334{
2332 struct net_local *tms_local; 2335 struct net_local *tms_local;
2333 2336
2334 memset(dev->priv, 0, sizeof(struct net_local)); 2337 memset(netdev_priv(dev), 0, sizeof(struct net_local));
2335 tms_local = netdev_priv(dev); 2338 tms_local = netdev_priv(dev);
2336 init_waitqueue_head(&tms_local->wait_for_tok_int); 2339 init_waitqueue_head(&tms_local->wait_for_tok_int);
2337 if (pdev->dma_mask) 2340 if (pdev->dma_mask)
diff --git a/drivers/net/tokenring/tmspci.c b/drivers/net/tokenring/tmspci.c
index 5f0ee880cfff..5f601773c260 100644
--- a/drivers/net/tokenring/tmspci.c
+++ b/drivers/net/tokenring/tmspci.c
@@ -100,7 +100,6 @@ 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 DECLARE_MAC_BUF(mac);
104 103
105 if (versionprinted++ == 0) 104 if (versionprinted++ == 0)
106 printk("%s", version); 105 printk("%s", version);
@@ -137,8 +136,8 @@ static int __devinit tms_pci_attach(struct pci_dev *pdev, const struct pci_devic
137 136
138 tms_pci_read_eeprom(dev); 137 tms_pci_read_eeprom(dev);
139 138
140 printk("%s: Ring Station Address: %s\n", 139 printk("%s: Ring Station Address: %pM\n",
141 dev->name, print_mac(mac, dev->dev_addr)); 140 dev->name, dev->dev_addr);
142 141
143 ret = tmsdev_init(dev, &pdev->dev); 142 ret = tmsdev_init(dev, &pdev->dev);
144 if (ret) { 143 if (ret) {
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index eb1da6f0b086..271bc230c8a9 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -788,7 +788,6 @@ static int tsi108_complete_rx(struct net_device *dev, int budget)
788 skb_put(skb, data->rxring[rx].len); 788 skb_put(skb, data->rxring[rx].len);
789 skb->protocol = eth_type_trans(skb, dev); 789 skb->protocol = eth_type_trans(skb, dev);
790 netif_receive_skb(skb); 790 netif_receive_skb(skb);
791 dev->last_rx = jiffies;
792 } 791 }
793 792
794 return done; 793 return done;
@@ -1569,7 +1568,6 @@ tsi108_init_one(struct platform_device *pdev)
1569 struct tsi108_prv_data *data = NULL; 1568 struct tsi108_prv_data *data = NULL;
1570 hw_info *einfo; 1569 hw_info *einfo;
1571 int err = 0; 1570 int err = 0;
1572 DECLARE_MAC_BUF(mac);
1573 1571
1574 einfo = pdev->dev.platform_data; 1572 einfo = pdev->dev.platform_data;
1575 1573
@@ -1659,8 +1657,8 @@ tsi108_init_one(struct platform_device *pdev)
1659 } 1657 }
1660 1658
1661 platform_set_drvdata(pdev, dev); 1659 platform_set_drvdata(pdev, dev);
1662 printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: %s\n", 1660 printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: %pM\n",
1663 dev->name, print_mac(mac, dev->dev_addr)); 1661 dev->name, dev->dev_addr);
1664#ifdef DEBUG 1662#ifdef DEBUG
1665 data->msg_enable = DEBUG; 1663 data->msg_enable = DEBUG;
1666 dump_eth_one(dev); 1664 dump_eth_one(dev);
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 124d5d690dde..3aa60fad68c7 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -459,7 +459,6 @@ static void de_rx (struct de_private *de)
459 459
460 de->net_stats.rx_packets++; 460 de->net_stats.rx_packets++;
461 de->net_stats.rx_bytes += skb->len; 461 de->net_stats.rx_bytes += skb->len;
462 de->dev->last_rx = jiffies;
463 rc = netif_rx (skb); 462 rc = netif_rx (skb);
464 if (rc == NET_RX_DROP) 463 if (rc == NET_RX_DROP)
465 drop = 1; 464 drop = 1;
@@ -484,7 +483,7 @@ rx_next:
484static irqreturn_t de_interrupt (int irq, void *dev_instance) 483static irqreturn_t de_interrupt (int irq, void *dev_instance)
485{ 484{
486 struct net_device *dev = dev_instance; 485 struct net_device *dev = dev_instance;
487 struct de_private *de = dev->priv; 486 struct de_private *de = netdev_priv(dev);
488 u32 status; 487 u32 status;
489 488
490 status = dr32(MacStatus); 489 status = dr32(MacStatus);
@@ -590,7 +589,7 @@ next:
590 589
591static int de_start_xmit (struct sk_buff *skb, struct net_device *dev) 590static int de_start_xmit (struct sk_buff *skb, struct net_device *dev)
592{ 591{
593 struct de_private *de = dev->priv; 592 struct de_private *de = netdev_priv(dev);
594 unsigned int entry, tx_free; 593 unsigned int entry, tx_free;
595 u32 mapping, len, flags = FirstFrag | LastFrag; 594 u32 mapping, len, flags = FirstFrag | LastFrag;
596 struct de_desc *txd; 595 struct de_desc *txd;
@@ -653,7 +652,7 @@ static int de_start_xmit (struct sk_buff *skb, struct net_device *dev)
653 652
654static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev) 653static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
655{ 654{
656 struct de_private *de = dev->priv; 655 struct de_private *de = netdev_priv(dev);
657 u16 hash_table[32]; 656 u16 hash_table[32];
658 struct dev_mc_list *mclist; 657 struct dev_mc_list *mclist;
659 int i; 658 int i;
@@ -684,7 +683,7 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
684 683
685static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev) 684static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
686{ 685{
687 struct de_private *de = dev->priv; 686 struct de_private *de = netdev_priv(dev);
688 struct dev_mc_list *mclist; 687 struct dev_mc_list *mclist;
689 int i; 688 int i;
690 u16 *eaddrs; 689 u16 *eaddrs;
@@ -712,7 +711,7 @@ static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
712 711
713static void __de_set_rx_mode (struct net_device *dev) 712static void __de_set_rx_mode (struct net_device *dev)
714{ 713{
715 struct de_private *de = dev->priv; 714 struct de_private *de = netdev_priv(dev);
716 u32 macmode; 715 u32 macmode;
717 unsigned int entry; 716 unsigned int entry;
718 u32 mapping; 717 u32 mapping;
@@ -797,7 +796,7 @@ out:
797static void de_set_rx_mode (struct net_device *dev) 796static void de_set_rx_mode (struct net_device *dev)
798{ 797{
799 unsigned long flags; 798 unsigned long flags;
800 struct de_private *de = dev->priv; 799 struct de_private *de = netdev_priv(dev);
801 800
802 spin_lock_irqsave (&de->lock, flags); 801 spin_lock_irqsave (&de->lock, flags);
803 __de_set_rx_mode(dev); 802 __de_set_rx_mode(dev);
@@ -821,7 +820,7 @@ static void __de_get_stats(struct de_private *de)
821 820
822static struct net_device_stats *de_get_stats(struct net_device *dev) 821static struct net_device_stats *de_get_stats(struct net_device *dev)
823{ 822{
824 struct de_private *de = dev->priv; 823 struct de_private *de = netdev_priv(dev);
825 824
826 /* The chip only need report frame silently dropped. */ 825 /* The chip only need report frame silently dropped. */
827 spin_lock_irq(&de->lock); 826 spin_lock_irq(&de->lock);
@@ -1355,7 +1354,7 @@ static void de_free_rings (struct de_private *de)
1355 1354
1356static int de_open (struct net_device *dev) 1355static int de_open (struct net_device *dev)
1357{ 1356{
1358 struct de_private *de = dev->priv; 1357 struct de_private *de = netdev_priv(dev);
1359 int rc; 1358 int rc;
1360 1359
1361 if (netif_msg_ifup(de)) 1360 if (netif_msg_ifup(de))
@@ -1400,7 +1399,7 @@ err_out_free:
1400 1399
1401static int de_close (struct net_device *dev) 1400static int de_close (struct net_device *dev)
1402{ 1401{
1403 struct de_private *de = dev->priv; 1402 struct de_private *de = netdev_priv(dev);
1404 unsigned long flags; 1403 unsigned long flags;
1405 1404
1406 if (netif_msg_ifdown(de)) 1405 if (netif_msg_ifdown(de))
@@ -1423,7 +1422,7 @@ static int de_close (struct net_device *dev)
1423 1422
1424static void de_tx_timeout (struct net_device *dev) 1423static void de_tx_timeout (struct net_device *dev)
1425{ 1424{
1426 struct de_private *de = dev->priv; 1425 struct de_private *de = netdev_priv(dev);
1427 1426
1428 printk(KERN_DEBUG "%s: NIC status %08x mode %08x sia %08x desc %u/%u/%u\n", 1427 printk(KERN_DEBUG "%s: NIC status %08x mode %08x sia %08x desc %u/%u/%u\n",
1429 dev->name, dr32(MacStatus), dr32(MacMode), dr32(SIAStatus), 1428 dev->name, dr32(MacStatus), dr32(MacMode), dr32(SIAStatus),
@@ -1574,7 +1573,7 @@ static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd)
1574 1573
1575static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) 1574static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info)
1576{ 1575{
1577 struct de_private *de = dev->priv; 1576 struct de_private *de = netdev_priv(dev);
1578 1577
1579 strcpy (info->driver, DRV_NAME); 1578 strcpy (info->driver, DRV_NAME);
1580 strcpy (info->version, DRV_VERSION); 1579 strcpy (info->version, DRV_VERSION);
@@ -1589,7 +1588,7 @@ static int de_get_regs_len(struct net_device *dev)
1589 1588
1590static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) 1589static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1591{ 1590{
1592 struct de_private *de = dev->priv; 1591 struct de_private *de = netdev_priv(dev);
1593 int rc; 1592 int rc;
1594 1593
1595 spin_lock_irq(&de->lock); 1594 spin_lock_irq(&de->lock);
@@ -1601,7 +1600,7 @@ static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1601 1600
1602static int de_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) 1601static int de_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1603{ 1602{
1604 struct de_private *de = dev->priv; 1603 struct de_private *de = netdev_priv(dev);
1605 int rc; 1604 int rc;
1606 1605
1607 spin_lock_irq(&de->lock); 1606 spin_lock_irq(&de->lock);
@@ -1613,14 +1612,14 @@ static int de_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1613 1612
1614static u32 de_get_msglevel(struct net_device *dev) 1613static u32 de_get_msglevel(struct net_device *dev)
1615{ 1614{
1616 struct de_private *de = dev->priv; 1615 struct de_private *de = netdev_priv(dev);
1617 1616
1618 return de->msg_enable; 1617 return de->msg_enable;
1619} 1618}
1620 1619
1621static void de_set_msglevel(struct net_device *dev, u32 msglvl) 1620static void de_set_msglevel(struct net_device *dev, u32 msglvl)
1622{ 1621{
1623 struct de_private *de = dev->priv; 1622 struct de_private *de = netdev_priv(dev);
1624 1623
1625 de->msg_enable = msglvl; 1624 de->msg_enable = msglvl;
1626} 1625}
@@ -1628,7 +1627,7 @@ static void de_set_msglevel(struct net_device *dev, u32 msglvl)
1628static int de_get_eeprom(struct net_device *dev, 1627static int de_get_eeprom(struct net_device *dev,
1629 struct ethtool_eeprom *eeprom, u8 *data) 1628 struct ethtool_eeprom *eeprom, u8 *data)
1630{ 1629{
1631 struct de_private *de = dev->priv; 1630 struct de_private *de = netdev_priv(dev);
1632 1631
1633 if (!de->ee_data) 1632 if (!de->ee_data)
1634 return -EOPNOTSUPP; 1633 return -EOPNOTSUPP;
@@ -1642,7 +1641,7 @@ static int de_get_eeprom(struct net_device *dev,
1642 1641
1643static int de_nway_reset(struct net_device *dev) 1642static int de_nway_reset(struct net_device *dev)
1644{ 1643{
1645 struct de_private *de = dev->priv; 1644 struct de_private *de = netdev_priv(dev);
1646 u32 status; 1645 u32 status;
1647 1646
1648 if (de->media_type != DE_MEDIA_TP_AUTO) 1647 if (de->media_type != DE_MEDIA_TP_AUTO)
@@ -1661,7 +1660,7 @@ static int de_nway_reset(struct net_device *dev)
1661static void de_get_regs(struct net_device *dev, struct ethtool_regs *regs, 1660static void de_get_regs(struct net_device *dev, struct ethtool_regs *regs,
1662 void *data) 1661 void *data)
1663{ 1662{
1664 struct de_private *de = dev->priv; 1663 struct de_private *de = netdev_priv(dev);
1665 1664
1666 regs->version = (DE_REGS_VER << 2) | de->de21040; 1665 regs->version = (DE_REGS_VER << 2) | de->de21040;
1667 1666
@@ -1932,7 +1931,6 @@ static int __devinit de_init_one (struct pci_dev *pdev,
1932 void __iomem *regs; 1931 void __iomem *regs;
1933 unsigned long pciaddr; 1932 unsigned long pciaddr;
1934 static int board_idx = -1; 1933 static int board_idx = -1;
1935 DECLARE_MAC_BUF(mac);
1936 1934
1937 board_idx++; 1935 board_idx++;
1938 1936
@@ -1956,7 +1954,7 @@ static int __devinit de_init_one (struct pci_dev *pdev,
1956 dev->tx_timeout = de_tx_timeout; 1954 dev->tx_timeout = de_tx_timeout;
1957 dev->watchdog_timeo = TX_TIMEOUT; 1955 dev->watchdog_timeo = TX_TIMEOUT;
1958 1956
1959 de = dev->priv; 1957 de = netdev_priv(dev);
1960 de->de21040 = ent->driver_data == 0 ? 1 : 0; 1958 de->de21040 = ent->driver_data == 0 ? 1 : 0;
1961 de->pdev = pdev; 1959 de->pdev = pdev;
1962 de->dev = dev; 1960 de->dev = dev;
@@ -2046,11 +2044,11 @@ static int __devinit de_init_one (struct pci_dev *pdev,
2046 goto err_out_iomap; 2044 goto err_out_iomap;
2047 2045
2048 /* print info about board and interface just registered */ 2046 /* print info about board and interface just registered */
2049 printk (KERN_INFO "%s: %s at 0x%lx, %s, IRQ %d\n", 2047 printk (KERN_INFO "%s: %s at 0x%lx, %pM, IRQ %d\n",
2050 dev->name, 2048 dev->name,
2051 de->de21040 ? "21040" : "21041", 2049 de->de21040 ? "21040" : "21041",
2052 dev->base_addr, 2050 dev->base_addr,
2053 print_mac(mac, dev->dev_addr), 2051 dev->dev_addr,
2054 dev->irq); 2052 dev->irq);
2055 2053
2056 pci_set_drvdata(pdev, dev); 2054 pci_set_drvdata(pdev, dev);
@@ -2078,7 +2076,7 @@ err_out_free:
2078static void __devexit de_remove_one (struct pci_dev *pdev) 2076static void __devexit de_remove_one (struct pci_dev *pdev)
2079{ 2077{
2080 struct net_device *dev = pci_get_drvdata(pdev); 2078 struct net_device *dev = pci_get_drvdata(pdev);
2081 struct de_private *de = dev->priv; 2079 struct de_private *de = netdev_priv(dev);
2082 2080
2083 BUG_ON(!dev); 2081 BUG_ON(!dev);
2084 unregister_netdev(dev); 2082 unregister_netdev(dev);
@@ -2095,7 +2093,7 @@ static void __devexit de_remove_one (struct pci_dev *pdev)
2095static int de_suspend (struct pci_dev *pdev, pm_message_t state) 2093static int de_suspend (struct pci_dev *pdev, pm_message_t state)
2096{ 2094{
2097 struct net_device *dev = pci_get_drvdata (pdev); 2095 struct net_device *dev = pci_get_drvdata (pdev);
2098 struct de_private *de = dev->priv; 2096 struct de_private *de = netdev_priv(dev);
2099 2097
2100 rtnl_lock(); 2098 rtnl_lock();
2101 if (netif_running (dev)) { 2099 if (netif_running (dev)) {
@@ -2130,7 +2128,7 @@ static int de_suspend (struct pci_dev *pdev, pm_message_t state)
2130static int de_resume (struct pci_dev *pdev) 2128static int de_resume (struct pci_dev *pdev)
2131{ 2129{
2132 struct net_device *dev = pci_get_drvdata (pdev); 2130 struct net_device *dev = pci_get_drvdata (pdev);
2133 struct de_private *de = dev->priv; 2131 struct de_private *de = netdev_priv(dev);
2134 int retval = 0; 2132 int retval = 0;
2135 2133
2136 rtnl_lock(); 2134 rtnl_lock();
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 6444cbec0bdc..67bfd6f43366 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -1085,7 +1085,6 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1085 struct de4x5_private *lp = netdev_priv(dev); 1085 struct de4x5_private *lp = netdev_priv(dev);
1086 struct pci_dev *pdev = NULL; 1086 struct pci_dev *pdev = NULL;
1087 int i, status=0; 1087 int i, status=0;
1088 DECLARE_MAC_BUF(mac);
1089 1088
1090 gendev->driver_data = dev; 1089 gendev->driver_data = dev;
1091 1090
@@ -1119,10 +1118,10 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1119 } 1118 }
1120 1119
1121 dev->base_addr = iobase; 1120 dev->base_addr = iobase;
1122 printk ("%s: %s at 0x%04lx", gendev->bus_id, name, iobase); 1121 printk ("%s: %s at 0x%04lx", dev_name(gendev), name, iobase);
1123 1122
1124 status = get_hw_addr(dev); 1123 status = get_hw_addr(dev);
1125 printk(", h/w address %s\n", print_mac(mac, dev->dev_addr)); 1124 printk(", h/w address %pM\n", dev->dev_addr);
1126 1125
1127 if (status != 0) { 1126 if (status != 0) {
1128 printk(" which has an Ethernet PROM CRC error.\n"); 1127 printk(" which has an Ethernet PROM CRC error.\n");
@@ -1154,7 +1153,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1154 } 1153 }
1155 } 1154 }
1156 lp->fdx = lp->params.fdx; 1155 lp->fdx = lp->params.fdx;
1157 sprintf(lp->adapter_name,"%s (%s)", name, gendev->bus_id); 1156 sprintf(lp->adapter_name,"%s (%s)", name, dev_name(gendev));
1158 1157
1159 lp->dma_size = (NUM_RX_DESC + NUM_TX_DESC) * sizeof(struct de4x5_desc); 1158 lp->dma_size = (NUM_RX_DESC + NUM_TX_DESC) * sizeof(struct de4x5_desc);
1160#if defined(__alpha__) || defined(__powerpc__) || defined(CONFIG_SPARC) || defined(DE4X5_DO_MEMCPY) 1159#if defined(__alpha__) || defined(__powerpc__) || defined(CONFIG_SPARC) || defined(DE4X5_DO_MEMCPY)
@@ -1647,7 +1646,6 @@ de4x5_rx(struct net_device *dev)
1647 netif_rx(skb); 1646 netif_rx(skb);
1648 1647
1649 /* Update stats */ 1648 /* Update stats */
1650 dev->last_rx = jiffies;
1651 lp->stats.rx_packets++; 1649 lp->stats.rx_packets++;
1652 lp->stats.rx_bytes += pkt_len; 1650 lp->stats.rx_bytes += pkt_len;
1653 } 1651 }
@@ -5401,7 +5399,6 @@ static void
5401de4x5_dbg_srom(struct de4x5_srom *p) 5399de4x5_dbg_srom(struct de4x5_srom *p)
5402{ 5400{
5403 int i; 5401 int i;
5404 DECLARE_MAC_BUF(mac);
5405 5402
5406 if (de4x5_debug & DEBUG_SROM) { 5403 if (de4x5_debug & DEBUG_SROM) {
5407 printk("Sub-system Vendor ID: %04x\n", *((u_short *)p->sub_vendor_id)); 5404 printk("Sub-system Vendor ID: %04x\n", *((u_short *)p->sub_vendor_id));
@@ -5410,7 +5407,7 @@ de4x5_dbg_srom(struct de4x5_srom *p)
5410 printk("SROM version: %02x\n", (u_char)(p->version)); 5407 printk("SROM version: %02x\n", (u_char)(p->version));
5411 printk("# controllers: %02x\n", (u_char)(p->num_controllers)); 5408 printk("# controllers: %02x\n", (u_char)(p->num_controllers));
5412 5409
5413 printk("Hardware Address: %s\n", print_mac(mac, p->ieee_addr)); 5410 printk("Hardware Address: %pM\n", p->ieee_addr);
5414 printk("CRC checksum: %04x\n", (u_short)(p->chksum)); 5411 printk("CRC checksum: %04x\n", (u_short)(p->chksum));
5415 for (i=0; i<64; i++) { 5412 for (i=0; i<64; i++) {
5416 printk("%3d %04x\n", i<<1, (u_short)*((u_short *)p+i)); 5413 printk("%3d %04x\n", i<<1, (u_short)*((u_short *)p+i));
@@ -5424,12 +5421,10 @@ static void
5424de4x5_dbg_rx(struct sk_buff *skb, int len) 5421de4x5_dbg_rx(struct sk_buff *skb, int len)
5425{ 5422{
5426 int i, j; 5423 int i, j;
5427 DECLARE_MAC_BUF(mac);
5428 DECLARE_MAC_BUF(mac2);
5429 5424
5430 if (de4x5_debug & DEBUG_RX) { 5425 if (de4x5_debug & DEBUG_RX) {
5431 printk("R: %s <- %s len/SAP:%02x%02x [%d]\n", 5426 printk("R: %pM <- %pM len/SAP:%02x%02x [%d]\n",
5432 print_mac(mac, skb->data), print_mac(mac2, &skb->data[6]), 5427 skb->data, &skb->data[6],
5433 (u_char)skb->data[12], 5428 (u_char)skb->data[12],
5434 (u_char)skb->data[13], 5429 (u_char)skb->data[13],
5435 len); 5430 len);
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index c91852f49a48..28a5c51b43a0 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -362,7 +362,6 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
362 struct net_device *dev; 362 struct net_device *dev;
363 u32 pci_pmr; 363 u32 pci_pmr;
364 int i, err; 364 int i, err;
365 DECLARE_MAC_BUF(mac);
366 365
367 DMFE_DBUG(0, "dmfe_init_one()", 0); 366 DMFE_DBUG(0, "dmfe_init_one()", 0);
368 367
@@ -475,12 +474,11 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
475 if (err) 474 if (err)
476 goto err_out_free_buf; 475 goto err_out_free_buf;
477 476
478 printk(KERN_INFO "%s: Davicom DM%04lx at pci%s, " 477 printk(KERN_INFO "%s: Davicom DM%04lx at pci%s, %pM, irq %d.\n",
479 "%s, irq %d.\n",
480 dev->name, 478 dev->name,
481 ent->driver_data >> 16, 479 ent->driver_data >> 16,
482 pci_name(pdev), 480 pci_name(pdev),
483 print_mac(mac, dev->dev_addr), 481 dev->dev_addr,
484 dev->irq); 482 dev->irq);
485 483
486 pci_set_master(pdev); 484 pci_set_master(pdev);
@@ -1010,7 +1008,6 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
1010 1008
1011 skb->protocol = eth_type_trans(skb, dev); 1009 skb->protocol = eth_type_trans(skb, dev);
1012 netif_rx(skb); 1010 netif_rx(skb);
1013 dev->last_rx = jiffies;
1014 db->stats.rx_packets++; 1011 db->stats.rx_packets++;
1015 db->stats.rx_bytes += rxlen; 1012 db->stats.rx_bytes += rxlen;
1016 } 1013 }
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index 0dcced1263b9..391acd32a6a5 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -337,7 +337,7 @@ int __devinit tulip_read_eeprom(struct net_device *dev, int location, int addr_l
337{ 337{
338 int i; 338 int i;
339 unsigned retval = 0; 339 unsigned retval = 0;
340 struct tulip_private *tp = dev->priv; 340 struct tulip_private *tp = netdev_priv(dev);
341 void __iomem *ee_addr = tp->base_addr + CSR9; 341 void __iomem *ee_addr = tp->base_addr + CSR9;
342 int read_cmd = location | (EE_READ_CMD << addr_len); 342 int read_cmd = location | (EE_READ_CMD << addr_len);
343 343
diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
index c6bad987d63e..739d610d18c5 100644
--- a/drivers/net/tulip/interrupt.c
+++ b/drivers/net/tulip/interrupt.c
@@ -231,7 +231,6 @@ int tulip_poll(struct napi_struct *napi, int budget)
231 231
232 netif_receive_skb(skb); 232 netif_receive_skb(skb);
233 233
234 dev->last_rx = jiffies;
235 tp->stats.rx_packets++; 234 tp->stats.rx_packets++;
236 tp->stats.rx_bytes += pkt_len; 235 tp->stats.rx_bytes += pkt_len;
237 } 236 }
@@ -444,7 +443,6 @@ static int tulip_rx(struct net_device *dev)
444 443
445 netif_rx(skb); 444 netif_rx(skb);
446 445
447 dev->last_rx = jiffies;
448 tp->stats.rx_packets++; 446 tp->stats.rx_packets++;
449 tp->stats.rx_bytes += pkt_len; 447 tp->stats.rx_bytes += pkt_len;
450 } 448 }
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index cafa89e60167..1c5ef230b770 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1050,13 +1050,11 @@ static void set_rx_mode(struct net_device *dev)
1050 filterbit = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 1050 filterbit = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
1051 filterbit &= 0x3f; 1051 filterbit &= 0x3f;
1052 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31); 1052 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31);
1053 if (tulip_debug > 2) { 1053 if (tulip_debug > 2)
1054 DECLARE_MAC_BUF(mac); 1054 printk(KERN_INFO "%s: Added filter for %pM"
1055 printk(KERN_INFO "%s: Added filter for %s"
1056 " %8.8x bit %d.\n", 1055 " %8.8x bit %d.\n",
1057 dev->name, print_mac(mac, mclist->dmi_addr), 1056 dev->name, mclist->dmi_addr,
1058 ether_crc(ETH_ALEN, mclist->dmi_addr), filterbit); 1057 ether_crc(ETH_ALEN, mclist->dmi_addr), filterbit);
1059 }
1060 } 1058 }
1061 if (mc_filter[0] == tp->mc_filter[0] && 1059 if (mc_filter[0] == tp->mc_filter[0] &&
1062 mc_filter[1] == tp->mc_filter[1]) 1060 mc_filter[1] == tp->mc_filter[1])
@@ -1250,7 +1248,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1250 const char *chip_name = tulip_tbl[chip_idx].chip_name; 1248 const char *chip_name = tulip_tbl[chip_idx].chip_name;
1251 unsigned int eeprom_missing = 0; 1249 unsigned int eeprom_missing = 0;
1252 unsigned int force_csr0 = 0; 1250 unsigned int force_csr0 = 0;
1253 DECLARE_MAC_BUF(mac);
1254 1251
1255#ifndef MODULE 1252#ifndef MODULE
1256 static int did_version; /* Already printed version info. */ 1253 static int did_version; /* Already printed version info. */
@@ -1635,7 +1632,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1635 1632
1636 if (eeprom_missing) 1633 if (eeprom_missing)
1637 printk(" EEPROM not present,"); 1634 printk(" EEPROM not present,");
1638 printk(" %s", print_mac(mac, dev->dev_addr)); 1635 printk(" %pM", dev->dev_addr);
1639 printk(", IRQ %d.\n", irq); 1636 printk(", IRQ %d.\n", irq);
1640 1637
1641 if (tp->chip_id == PNIC2) 1638 if (tp->chip_id == PNIC2)
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index e9e628621639..00cbc5251dcc 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -261,7 +261,6 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
261 struct uli526x_board_info *db; /* board information structure */ 261 struct uli526x_board_info *db; /* board information structure */
262 struct net_device *dev; 262 struct net_device *dev;
263 int i, err; 263 int i, err;
264 DECLARE_MAC_BUF(mac);
265 264
266 ULI526X_DBUG(0, "uli526x_init_one()", 0); 265 ULI526X_DBUG(0, "uli526x_init_one()", 0);
267 266
@@ -379,9 +378,9 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
379 if (err) 378 if (err)
380 goto err_out_res; 379 goto err_out_res;
381 380
382 printk(KERN_INFO "%s: ULi M%04lx at pci%s, %s, irq %d.\n", 381 printk(KERN_INFO "%s: ULi M%04lx at pci%s, %pM, irq %d.\n",
383 dev->name,ent->driver_data >> 16,pci_name(pdev), 382 dev->name,ent->driver_data >> 16,pci_name(pdev),
384 print_mac(mac, dev->dev_addr), dev->irq); 383 dev->dev_addr, dev->irq);
385 384
386 pci_set_master(pdev); 385 pci_set_master(pdev);
387 386
@@ -855,7 +854,6 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
855 854
856 skb->protocol = eth_type_trans(skb, dev); 855 skb->protocol = eth_type_trans(skb, dev);
857 netif_rx(skb); 856 netif_rx(skb);
858 dev->last_rx = jiffies;
859 db->stats.rx_packets++; 857 db->stats.rx_packets++;
860 db->stats.rx_bytes += rxlen; 858 db->stats.rx_bytes += rxlen;
861 859
@@ -892,7 +890,7 @@ static struct net_device_stats * uli526x_get_stats(struct net_device *dev)
892 890
893static void uli526x_set_filter_mode(struct net_device * dev) 891static void uli526x_set_filter_mode(struct net_device * dev)
894{ 892{
895 struct uli526x_board_info *db = dev->priv; 893 struct uli526x_board_info *db = netdev_priv(dev);
896 unsigned long flags; 894 unsigned long flags;
897 895
898 ULI526X_DBUG(0, "uli526x_set_filter_mode()", 0); 896 ULI526X_DBUG(0, "uli526x_set_filter_mode()", 0);
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 50068194c163..022d99af8646 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -355,7 +355,6 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
355 int irq; 355 int irq;
356 int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0; 356 int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
357 void __iomem *ioaddr; 357 void __iomem *ioaddr;
358 DECLARE_MAC_BUF(mac);
359 358
360 i = pci_enable_device(pdev); 359 i = pci_enable_device(pdev);
361 if (i) return i; 360 if (i) return i;
@@ -435,9 +434,9 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
435 if (i) 434 if (i)
436 goto err_out_cleardev; 435 goto err_out_cleardev;
437 436
438 printk(KERN_INFO "%s: %s at %p, %s, IRQ %d.\n", 437 printk(KERN_INFO "%s: %s at %p, %pM, IRQ %d.\n",
439 dev->name, pci_id_tbl[chip_idx].name, ioaddr, 438 dev->name, pci_id_tbl[chip_idx].name, ioaddr,
440 print_mac(mac, dev->dev_addr), irq); 439 dev->dev_addr, irq);
441 440
442 if (np->drv_flags & CanHaveMII) { 441 if (np->drv_flags & CanHaveMII) {
443 int phy, phy_idx = 0; 442 int phy, phy_idx = 0;
@@ -1245,20 +1244,15 @@ static int netdev_rx(struct net_device *dev)
1245 } 1244 }
1246#ifndef final_version /* Remove after testing. */ 1245#ifndef final_version /* Remove after testing. */
1247 /* You will want this info for the initial debug. */ 1246 /* You will want this info for the initial debug. */
1248 if (debug > 5) { 1247 if (debug > 5)
1249 DECLARE_MAC_BUF(mac); 1248 printk(KERN_DEBUG " Rx data %pM %pM"
1250 DECLARE_MAC_BUF(mac2);
1251
1252 printk(KERN_DEBUG " Rx data %s %s"
1253 " %2.2x%2.2x %d.%d.%d.%d.\n", 1249 " %2.2x%2.2x %d.%d.%d.%d.\n",
1254 print_mac(mac, &skb->data[0]), print_mac(mac2, &skb->data[6]), 1250 &skb->data[0], &skb->data[6],
1255 skb->data[12], skb->data[13], 1251 skb->data[12], skb->data[13],
1256 skb->data[14], skb->data[15], skb->data[16], skb->data[17]); 1252 skb->data[14], skb->data[15], skb->data[16], skb->data[17]);
1257 }
1258#endif 1253#endif
1259 skb->protocol = eth_type_trans(skb, dev); 1254 skb->protocol = eth_type_trans(skb, dev);
1260 netif_rx(skb); 1255 netif_rx(skb);
1261 dev->last_rx = jiffies;
1262 np->stats.rx_packets++; 1256 np->stats.rx_packets++;
1263 np->stats.rx_bytes += pkt_len; 1257 np->stats.rx_bytes += pkt_len;
1264 } 1258 }
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 6b93d0169116..13c8703ecb9f 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -1072,7 +1072,6 @@ static void read_mac_address(struct xircom_private *card)
1072 unsigned char j, tuple, link, data_id, data_count; 1072 unsigned char j, tuple, link, data_id, data_count;
1073 unsigned long flags; 1073 unsigned long flags;
1074 int i; 1074 int i;
1075 DECLARE_MAC_BUF(mac);
1076 1075
1077 enter("read_mac_address"); 1076 enter("read_mac_address");
1078 1077
@@ -1102,7 +1101,7 @@ static void read_mac_address(struct xircom_private *card)
1102 } 1101 }
1103 } 1102 }
1104 spin_unlock_irqrestore(&card->lock, flags); 1103 spin_unlock_irqrestore(&card->lock, flags);
1105 pr_debug(" %s\n", print_mac(mac, card->dev->dev_addr)); 1104 pr_debug(" %pM\n", card->dev->dev_addr);
1106 leave("read_mac_address"); 1105 leave("read_mac_address");
1107} 1106}
1108 1107
@@ -1202,7 +1201,6 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
1202 skb_put(skb, pkt_len); 1201 skb_put(skb, pkt_len);
1203 skb->protocol = eth_type_trans(skb, dev); 1202 skb->protocol = eth_type_trans(skb, dev);
1204 netif_rx(skb); 1203 netif_rx(skb);
1205 dev->last_rx = jiffies;
1206 card->stats.rx_packets++; 1204 card->stats.rx_packets++;
1207 card->stats.rx_bytes += pkt_len; 1205 card->stats.rx_bytes += pkt_len;
1208 1206
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 33b6d1b122fb..5a6203072ce7 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -529,7 +529,6 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv,
529 } 529 }
530 530
531 netif_rx_ni(skb); 531 netif_rx_ni(skb);
532 tun->dev->last_rx = jiffies;
533 532
534 tun->dev->stats.rx_packets++; 533 tun->dev->stats.rx_packets++;
535 tun->dev->stats.rx_bytes += len; 534 tun->dev->stats.rx_bytes += len;
@@ -883,7 +882,6 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
883 void __user* argp = (void __user*)arg; 882 void __user* argp = (void __user*)arg;
884 struct ifreq ifr; 883 struct ifreq ifr;
885 int ret; 884 int ret;
886 DECLARE_MAC_BUF(mac);
887 885
888 if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) 886 if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89)
889 if (copy_from_user(&ifr, argp, sizeof ifr)) 887 if (copy_from_user(&ifr, argp, sizeof ifr))
@@ -1011,8 +1009,8 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1011 1009
1012 case SIOCSIFHWADDR: 1010 case SIOCSIFHWADDR:
1013 /* Set hw address */ 1011 /* Set hw address */
1014 DBG(KERN_DEBUG "%s: set hw address: %s\n", 1012 DBG(KERN_DEBUG "%s: set hw address: %pM\n",
1015 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data)); 1013 tun->dev->name, ifr.ifr_hwaddr.sa_data);
1016 1014
1017 rtnl_lock(); 1015 rtnl_lock();
1018 ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr); 1016 ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr);
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 734ce0977f02..5386d9b73e6a 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -1729,7 +1729,6 @@ typhoon_rx(struct typhoon *tp, struct basic_ring *rxRing, volatile __le32 * read
1729 netif_receive_skb(new_skb); 1729 netif_receive_skb(new_skb);
1730 spin_unlock(&tp->state_lock); 1730 spin_unlock(&tp->state_lock);
1731 1731
1732 tp->dev->last_rx = jiffies;
1733 received++; 1732 received++;
1734 budget--; 1733 budget--;
1735 } 1734 }
@@ -1798,7 +1797,7 @@ static irqreturn_t
1798typhoon_interrupt(int irq, void *dev_instance) 1797typhoon_interrupt(int irq, void *dev_instance)
1799{ 1798{
1800 struct net_device *dev = dev_instance; 1799 struct net_device *dev = dev_instance;
1801 struct typhoon *tp = dev->priv; 1800 struct typhoon *tp = netdev_priv(dev);
1802 void __iomem *ioaddr = tp->ioaddr; 1801 void __iomem *ioaddr = tp->ioaddr;
1803 u32 intr_status; 1802 u32 intr_status;
1804 1803
@@ -2311,7 +2310,6 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2311 struct cmd_desc xp_cmd; 2310 struct cmd_desc xp_cmd;
2312 struct resp_desc xp_resp[3]; 2311 struct resp_desc xp_resp[3];
2313 int err = 0; 2312 int err = 0;
2314 DECLARE_MAC_BUF(mac);
2315 2313
2316 if(!did_version++) 2314 if(!did_version++)
2317 printk(KERN_INFO "%s", version); 2315 printk(KERN_INFO "%s", version);
@@ -2526,11 +2524,11 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2526 2524
2527 pci_set_drvdata(pdev, dev); 2525 pci_set_drvdata(pdev, dev);
2528 2526
2529 printk(KERN_INFO "%s: %s at %s 0x%llx, %s\n", 2527 printk(KERN_INFO "%s: %s at %s 0x%llx, %pM\n",
2530 dev->name, typhoon_card_info[card_id].name, 2528 dev->name, typhoon_card_info[card_id].name,
2531 use_mmio ? "MMIO" : "IO", 2529 use_mmio ? "MMIO" : "IO",
2532 (unsigned long long)pci_resource_start(pdev, use_mmio), 2530 (unsigned long long)pci_resource_start(pdev, use_mmio),
2533 print_mac(mac, dev->dev_addr)); 2531 dev->dev_addr);
2534 2532
2535 /* xp_resp still contains the response to the READ_VERSIONS command. 2533 /* xp_resp still contains the response to the READ_VERSIONS command.
2536 * For debugging, let the user know what version he has. 2534 * For debugging, let the user know what version he has.
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index c87747bb24c5..0a5b817fd7ac 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -1615,8 +1615,8 @@ static int init_phy(struct net_device *dev)
1615 priv->oldspeed = 0; 1615 priv->oldspeed = 0;
1616 priv->oldduplex = -1; 1616 priv->oldduplex = -1;
1617 1617
1618 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, priv->ug_info->mdio_bus, 1618 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, priv->ug_info->mdio_bus,
1619 priv->ug_info->phy_address); 1619 priv->ug_info->phy_address);
1620 1620
1621 phydev = phy_connect(dev, phy_id, &adjust_link, 0, priv->phy_interface); 1621 phydev = phy_connect(dev, phy_id, &adjust_link, 0, priv->phy_interface);
1622 1622
@@ -3502,8 +3502,6 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit
3502 netif_receive_skb(skb); 3502 netif_receive_skb(skb);
3503 } 3503 }
3504 3504
3505 ugeth->dev->last_rx = jiffies;
3506
3507 skb = get_new_skb(ugeth, bd); 3505 skb = get_new_skb(ugeth, bd);
3508 if (!skb) { 3506 if (!skb) {
3509 if (netif_msg_rx_err(ugeth)) 3507 if (netif_msg_rx_err(ugeth))
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index 466a89e24444..d7621239059a 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -271,8 +271,6 @@ static void catc_rx_done(struct urb *urb)
271 271
272 } while (pkt_start - (u8 *) urb->transfer_buffer < urb->actual_length); 272 } while (pkt_start - (u8 *) urb->transfer_buffer < urb->actual_length);
273 273
274 catc->netdev->last_rx = jiffies;
275
276 if (catc->is_f5u011) { 274 if (catc->is_f5u011) {
277 if (atomic_read(&catc->recq_sz)) { 275 if (atomic_read(&catc->recq_sz)) {
278 int status; 276 int status;
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index b5143509e8be..bbcc76ae3c9c 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -344,14 +344,14 @@ out:
344static int mcs7830_mdio_read(struct net_device *netdev, int phy_id, 344static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
345 int location) 345 int location)
346{ 346{
347 struct usbnet *dev = netdev->priv; 347 struct usbnet *dev = netdev_priv(netdev);
348 return mcs7830_read_phy(dev, location); 348 return mcs7830_read_phy(dev, location);
349} 349}
350 350
351static void mcs7830_mdio_write(struct net_device *netdev, int phy_id, 351static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
352 int location, int val) 352 int location, int val)
353{ 353{
354 struct usbnet *dev = netdev->priv; 354 struct usbnet *dev = netdev_priv(netdev);
355 mcs7830_write_phy(dev, location, val); 355 mcs7830_write_phy(dev, location, val);
356} 356}
357 357
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index 7914867110ed..075e8e94225e 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -1213,7 +1213,7 @@ static void pegasus_set_multicast(struct net_device *net)
1213 pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST; 1213 pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST;
1214 pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; 1214 pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
1215 if (netif_msg_link(pegasus)) 1215 if (netif_msg_link(pegasus))
1216 pr_info("%s: set allmulti\n", net->name); 1216 pr_debug("%s: set allmulti\n", net->name);
1217 } else { 1217 } else {
1218 pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST; 1218 pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST;
1219 pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; 1219 pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
@@ -1273,6 +1273,7 @@ static inline void setup_pegasus_II(pegasus_t * pegasus)
1273} 1273}
1274 1274
1275 1275
1276static int pegasus_count;
1276static struct workqueue_struct *pegasus_workqueue = NULL; 1277static struct workqueue_struct *pegasus_workqueue = NULL;
1277#define CARRIER_CHECK_DELAY (2 * HZ) 1278#define CARRIER_CHECK_DELAY (2 * HZ)
1278 1279
@@ -1301,6 +1302,18 @@ static int pegasus_blacklisted(struct usb_device *udev)
1301 return 0; 1302 return 0;
1302} 1303}
1303 1304
1305/* we rely on probe() and remove() being serialized so we
1306 * don't need extra locking on pegasus_count.
1307 */
1308static void pegasus_dec_workqueue(void)
1309{
1310 pegasus_count--;
1311 if (pegasus_count == 0) {
1312 destroy_workqueue(pegasus_workqueue);
1313 pegasus_workqueue = NULL;
1314 }
1315}
1316
1304static int pegasus_probe(struct usb_interface *intf, 1317static int pegasus_probe(struct usb_interface *intf,
1305 const struct usb_device_id *id) 1318 const struct usb_device_id *id)
1306{ 1319{
@@ -1309,14 +1322,18 @@ static int pegasus_probe(struct usb_interface *intf,
1309 pegasus_t *pegasus; 1322 pegasus_t *pegasus;
1310 int dev_index = id - pegasus_ids; 1323 int dev_index = id - pegasus_ids;
1311 int res = -ENOMEM; 1324 int res = -ENOMEM;
1312 DECLARE_MAC_BUF(mac);
1313 1325
1314 usb_get_dev(dev); 1326 if (pegasus_blacklisted(dev))
1327 return -ENODEV;
1315 1328
1316 if (pegasus_blacklisted(dev)) { 1329 if (pegasus_count == 0) {
1317 res = -ENODEV; 1330 pegasus_workqueue = create_singlethread_workqueue("pegasus");
1318 goto out; 1331 if (!pegasus_workqueue)
1332 return -ENOMEM;
1319 } 1333 }
1334 pegasus_count++;
1335
1336 usb_get_dev(dev);
1320 1337
1321 net = alloc_etherdev(sizeof(struct pegasus)); 1338 net = alloc_etherdev(sizeof(struct pegasus));
1322 if (!net) { 1339 if (!net) {
@@ -1386,10 +1403,10 @@ static int pegasus_probe(struct usb_interface *intf,
1386 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1403 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
1387 CARRIER_CHECK_DELAY); 1404 CARRIER_CHECK_DELAY);
1388 1405
1389 dev_info(&intf->dev, "%s, %s, %s\n", 1406 dev_info(&intf->dev, "%s, %s, %pM\n",
1390 net->name, 1407 net->name,
1391 usb_dev_id[dev_index].name, 1408 usb_dev_id[dev_index].name,
1392 print_mac(mac, net->dev_addr)); 1409 net->dev_addr);
1393 return 0; 1410 return 0;
1394 1411
1395out3: 1412out3:
@@ -1401,6 +1418,7 @@ out1:
1401 free_netdev(net); 1418 free_netdev(net);
1402out: 1419out:
1403 usb_put_dev(dev); 1420 usb_put_dev(dev);
1421 pegasus_dec_workqueue();
1404 return res; 1422 return res;
1405} 1423}
1406 1424
@@ -1426,6 +1444,7 @@ static void pegasus_disconnect(struct usb_interface *intf)
1426 pegasus->rx_skb = NULL; 1444 pegasus->rx_skb = NULL;
1427 } 1445 }
1428 free_netdev(pegasus->net); 1446 free_netdev(pegasus->net);
1447 pegasus_dec_workqueue();
1429} 1448}
1430 1449
1431static int pegasus_suspend (struct usb_interface *intf, pm_message_t message) 1450static int pegasus_suspend (struct usb_interface *intf, pm_message_t message)
@@ -1469,7 +1488,7 @@ static struct usb_driver pegasus_driver = {
1469 .resume = pegasus_resume, 1488 .resume = pegasus_resume,
1470}; 1489};
1471 1490
1472static void parse_id(char *id) 1491static void __init parse_id(char *id)
1473{ 1492{
1474 unsigned int vendor_id=0, device_id=0, flags=0, i=0; 1493 unsigned int vendor_id=0, device_id=0, flags=0, i=0;
1475 char *token, *name=NULL; 1494 char *token, *name=NULL;
@@ -1505,15 +1524,11 @@ static int __init pegasus_init(void)
1505 pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION); 1524 pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION);
1506 if (devid) 1525 if (devid)
1507 parse_id(devid); 1526 parse_id(devid);
1508 pegasus_workqueue = create_singlethread_workqueue("pegasus");
1509 if (!pegasus_workqueue)
1510 return -ENOMEM;
1511 return usb_register(&pegasus_driver); 1527 return usb_register(&pegasus_driver);
1512} 1528}
1513 1529
1514static void __exit pegasus_exit(void) 1530static void __exit pegasus_exit(void)
1515{ 1531{
1516 destroy_workqueue(pegasus_workqueue);
1517 usb_deregister(&pegasus_driver); 1532 usb_deregister(&pegasus_driver);
1518} 1533}
1519 1534
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 51e2f5d7d14e..e0d349f74642 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -759,7 +759,6 @@ static int smsc95xx_reset(struct usbnet *dev)
759 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); 759 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
760 u32 read_buf, write_buf, burst_cap; 760 u32 read_buf, write_buf, burst_cap;
761 int ret = 0, timeout; 761 int ret = 0, timeout;
762 DECLARE_MAC_BUF(mac);
763 762
764 if (netif_msg_ifup(dev)) 763 if (netif_msg_ifup(dev))
765 devdbg(dev, "entering smsc95xx_reset"); 764 devdbg(dev, "entering smsc95xx_reset");
@@ -818,8 +817,7 @@ static int smsc95xx_reset(struct usbnet *dev)
818 return ret; 817 return ret;
819 818
820 if (netif_msg_ifup(dev)) 819 if (netif_msg_ifup(dev))
821 devdbg(dev, "MAC Address: %s", 820 devdbg(dev, "MAC Address: %pM", dev->net->dev_addr);
822 print_mac(mac, dev->net->dev_addr));
823 821
824 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); 822 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
825 if (ret < 0) { 823 if (ret < 0) {
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 02d25c743994..aa3149078888 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1125,7 +1125,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1125 struct usb_device *xdev; 1125 struct usb_device *xdev;
1126 int status; 1126 int status;
1127 const char *name; 1127 const char *name;
1128 DECLARE_MAC_BUF(mac);
1129 1128
1130 name = udev->dev.driver->name; 1129 name = udev->dev.driver->name;
1131 info = (struct driver_info *) prod->driver_info; 1130 info = (struct driver_info *) prod->driver_info;
@@ -1236,11 +1235,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1236 if (status) 1235 if (status)
1237 goto out3; 1236 goto out3;
1238 if (netif_msg_probe (dev)) 1237 if (netif_msg_probe (dev))
1239 devinfo (dev, "register '%s' at usb-%s-%s, %s, %s", 1238 devinfo (dev, "register '%s' at usb-%s-%s, %s, %pM",
1240 udev->dev.driver->name, 1239 udev->dev.driver->name,
1241 xdev->bus->bus_name, xdev->devpath, 1240 xdev->bus->bus_name, xdev->devpath,
1242 dev->driver_info->description, 1241 dev->driver_info->description,
1243 print_mac(mac, net->dev_addr)); 1242 net->dev_addr);
1244 1243
1245 // ok, it's ready to go. 1244 // ok, it's ready to go.
1246 usb_set_intfdata (udev, dev); 1245 usb_set_intfdata (udev, dev);
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 31cd817f33f9..75b40fefc4ee 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -8,7 +8,6 @@
8 * 8 *
9 */ 9 */
10 10
11#include <linux/list.h>
12#include <linux/netdevice.h> 11#include <linux/netdevice.h>
13#include <linux/ethtool.h> 12#include <linux/ethtool.h>
14#include <linux/etherdevice.h> 13#include <linux/etherdevice.h>
@@ -30,14 +29,10 @@ struct veth_net_stats {
30 29
31struct veth_priv { 30struct veth_priv {
32 struct net_device *peer; 31 struct net_device *peer;
33 struct net_device *dev;
34 struct list_head list;
35 struct veth_net_stats *stats; 32 struct veth_net_stats *stats;
36 unsigned ip_summed; 33 unsigned ip_summed;
37}; 34};
38 35
39static LIST_HEAD(veth_list);
40
41/* 36/*
42 * ethtool interface 37 * ethtool interface
43 */ 38 */
@@ -420,14 +415,10 @@ static int veth_newlink(struct net_device *dev,
420 */ 415 */
421 416
422 priv = netdev_priv(dev); 417 priv = netdev_priv(dev);
423 priv->dev = dev;
424 priv->peer = peer; 418 priv->peer = peer;
425 list_add(&priv->list, &veth_list);
426 419
427 priv = netdev_priv(peer); 420 priv = netdev_priv(peer);
428 priv->dev = peer;
429 priv->peer = dev; 421 priv->peer = dev;
430 INIT_LIST_HEAD(&priv->list);
431 return 0; 422 return 0;
432 423
433err_register_dev: 424err_register_dev:
@@ -449,13 +440,6 @@ static void veth_dellink(struct net_device *dev)
449 priv = netdev_priv(dev); 440 priv = netdev_priv(dev);
450 peer = priv->peer; 441 peer = priv->peer;
451 442
452 if (!list_empty(&priv->list))
453 list_del(&priv->list);
454
455 priv = netdev_priv(peer);
456 if (!list_empty(&priv->list))
457 list_del(&priv->list);
458
459 unregister_netdevice(dev); 443 unregister_netdevice(dev);
460 unregister_netdevice(peer); 444 unregister_netdevice(peer);
461} 445}
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 5b7870080c56..9a650d0a6795 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -631,7 +631,6 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
631#else 631#else
632 int bar = 0; 632 int bar = 0;
633#endif 633#endif
634 DECLARE_MAC_BUF(mac);
635 634
636/* when built into the kernel, we only print version if device is found */ 635/* when built into the kernel, we only print version if device is found */
637#ifndef MODULE 636#ifndef MODULE
@@ -787,14 +786,14 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
787 if (rc) 786 if (rc)
788 goto err_out_unmap; 787 goto err_out_unmap;
789 788
790 printk(KERN_INFO "%s: VIA %s at 0x%lx, %s, IRQ %d.\n", 789 printk(KERN_INFO "%s: VIA %s at 0x%lx, %pM, IRQ %d.\n",
791 dev->name, name, 790 dev->name, name,
792#ifdef USE_MMIO 791#ifdef USE_MMIO
793 memaddr, 792 memaddr,
794#else 793#else
795 (long)ioaddr, 794 (long)ioaddr,
796#endif 795#endif
797 print_mac(mac, dev->dev_addr), pdev->irq); 796 dev->dev_addr, pdev->irq);
798 797
799 pci_set_drvdata(pdev, dev); 798 pci_set_drvdata(pdev, dev);
800 799
@@ -1505,7 +1504,6 @@ static int rhine_rx(struct net_device *dev, int limit)
1505 } 1504 }
1506 skb->protocol = eth_type_trans(skb, dev); 1505 skb->protocol = eth_type_trans(skb, dev);
1507 netif_receive_skb(skb); 1506 netif_receive_skb(skb);
1508 dev->last_rx = jiffies;
1509 rp->stats.rx_bytes += pkt_len; 1507 rp->stats.rx_bytes += pkt_len;
1510 rp->stats.rx_packets++; 1508 rp->stats.rx_packets++;
1511 } 1509 }
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 11cb3e504e1c..dcbc152306e2 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -1412,8 +1412,6 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)
1412 1412
1413 rd->size |= RX_INTEN; 1413 rd->size |= RX_INTEN;
1414 1414
1415 vptr->dev->last_rx = jiffies;
1416
1417 rd_curr++; 1415 rd_curr++;
1418 if (rd_curr >= vptr->options.numrx) 1416 if (rd_curr >= vptr->options.numrx)
1419 rd_curr = 0; 1417 rd_curr = 0;
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0196a0df9021..e6b5d6ef9ea8 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -34,6 +34,7 @@ module_param(gso, bool, 0444);
34 34
35/* FIXME: MTU in config. */ 35/* FIXME: MTU in config. */
36#define MAX_PACKET_LEN (ETH_HLEN+ETH_DATA_LEN) 36#define MAX_PACKET_LEN (ETH_HLEN+ETH_DATA_LEN)
37#define GOOD_COPY_LEN 128
37 38
38struct virtnet_info 39struct virtnet_info
39{ 40{
@@ -58,6 +59,9 @@ struct virtnet_info
58 /* I like... big packets and I cannot lie! */ 59 /* I like... big packets and I cannot lie! */
59 bool big_packets; 60 bool big_packets;
60 61
62 /* Host will merge rx buffers for big packets (shake it! shake it!) */
63 bool mergeable_rx_bufs;
64
61 /* Receive & send queues. */ 65 /* Receive & send queues. */
62 struct sk_buff_head recv; 66 struct sk_buff_head recv;
63 struct sk_buff_head send; 67 struct sk_buff_head send;
@@ -66,22 +70,27 @@ struct virtnet_info
66 struct page *pages; 70 struct page *pages;
67}; 71};
68 72
69static inline struct virtio_net_hdr *skb_vnet_hdr(struct sk_buff *skb) 73static inline void *skb_vnet_hdr(struct sk_buff *skb)
70{ 74{
71 return (struct virtio_net_hdr *)skb->cb; 75 return (struct virtio_net_hdr *)skb->cb;
72} 76}
73 77
74static inline void vnet_hdr_to_sg(struct scatterlist *sg, struct sk_buff *skb)
75{
76 sg_init_one(sg, skb_vnet_hdr(skb), sizeof(struct virtio_net_hdr));
77}
78
79static void give_a_page(struct virtnet_info *vi, struct page *page) 78static void give_a_page(struct virtnet_info *vi, struct page *page)
80{ 79{
81 page->private = (unsigned long)vi->pages; 80 page->private = (unsigned long)vi->pages;
82 vi->pages = page; 81 vi->pages = page;
83} 82}
84 83
84static void trim_pages(struct virtnet_info *vi, struct sk_buff *skb)
85{
86 unsigned int i;
87
88 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
89 give_a_page(vi, skb_shinfo(skb)->frags[i].page);
90 skb_shinfo(skb)->nr_frags = 0;
91 skb->data_len = 0;
92}
93
85static struct page *get_a_page(struct virtnet_info *vi, gfp_t gfp_mask) 94static struct page *get_a_page(struct virtnet_info *vi, gfp_t gfp_mask)
86{ 95{
87 struct page *p = vi->pages; 96 struct page *p = vi->pages;
@@ -111,31 +120,97 @@ static void skb_xmit_done(struct virtqueue *svq)
111static void receive_skb(struct net_device *dev, struct sk_buff *skb, 120static void receive_skb(struct net_device *dev, struct sk_buff *skb,
112 unsigned len) 121 unsigned len)
113{ 122{
123 struct virtnet_info *vi = netdev_priv(dev);
114 struct virtio_net_hdr *hdr = skb_vnet_hdr(skb); 124 struct virtio_net_hdr *hdr = skb_vnet_hdr(skb);
115 int err; 125 int err;
126 int i;
116 127
117 if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { 128 if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
118 pr_debug("%s: short packet %i\n", dev->name, len); 129 pr_debug("%s: short packet %i\n", dev->name, len);
119 dev->stats.rx_length_errors++; 130 dev->stats.rx_length_errors++;
120 goto drop; 131 goto drop;
121 } 132 }
122 len -= sizeof(struct virtio_net_hdr);
123 133
124 if (len <= MAX_PACKET_LEN) { 134 if (vi->mergeable_rx_bufs) {
125 unsigned int i; 135 struct virtio_net_hdr_mrg_rxbuf *mhdr = skb_vnet_hdr(skb);
136 unsigned int copy;
137 char *p = page_address(skb_shinfo(skb)->frags[0].page);
126 138
127 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) 139 if (len > PAGE_SIZE)
128 give_a_page(dev->priv, skb_shinfo(skb)->frags[i].page); 140 len = PAGE_SIZE;
129 skb->data_len = 0; 141 len -= sizeof(struct virtio_net_hdr_mrg_rxbuf);
130 skb_shinfo(skb)->nr_frags = 0;
131 }
132 142
133 err = pskb_trim(skb, len); 143 memcpy(hdr, p, sizeof(*mhdr));
134 if (err) { 144 p += sizeof(*mhdr);
135 pr_debug("%s: pskb_trim failed %i %d\n", dev->name, len, err); 145
136 dev->stats.rx_dropped++; 146 copy = len;
137 goto drop; 147 if (copy > skb_tailroom(skb))
148 copy = skb_tailroom(skb);
149
150 memcpy(skb_put(skb, copy), p, copy);
151
152 len -= copy;
153
154 if (!len) {
155 give_a_page(vi, skb_shinfo(skb)->frags[0].page);
156 skb_shinfo(skb)->nr_frags--;
157 } else {
158 skb_shinfo(skb)->frags[0].page_offset +=
159 sizeof(*mhdr) + copy;
160 skb_shinfo(skb)->frags[0].size = len;
161 skb->data_len += len;
162 skb->len += len;
163 }
164
165 while (--mhdr->num_buffers) {
166 struct sk_buff *nskb;
167
168 i = skb_shinfo(skb)->nr_frags;
169 if (i >= MAX_SKB_FRAGS) {
170 pr_debug("%s: packet too long %d\n", dev->name,
171 len);
172 dev->stats.rx_length_errors++;
173 goto drop;
174 }
175
176 nskb = vi->rvq->vq_ops->get_buf(vi->rvq, &len);
177 if (!nskb) {
178 pr_debug("%s: rx error: %d buffers missing\n",
179 dev->name, mhdr->num_buffers);
180 dev->stats.rx_length_errors++;
181 goto drop;
182 }
183
184 __skb_unlink(nskb, &vi->recv);
185 vi->num--;
186
187 skb_shinfo(skb)->frags[i] = skb_shinfo(nskb)->frags[0];
188 skb_shinfo(nskb)->nr_frags = 0;
189 kfree_skb(nskb);
190
191 if (len > PAGE_SIZE)
192 len = PAGE_SIZE;
193
194 skb_shinfo(skb)->frags[i].size = len;
195 skb_shinfo(skb)->nr_frags++;
196 skb->data_len += len;
197 skb->len += len;
198 }
199 } else {
200 len -= sizeof(struct virtio_net_hdr);
201
202 if (len <= MAX_PACKET_LEN)
203 trim_pages(vi, skb);
204
205 err = pskb_trim(skb, len);
206 if (err) {
207 pr_debug("%s: pskb_trim failed %i %d\n", dev->name,
208 len, err);
209 dev->stats.rx_dropped++;
210 goto drop;
211 }
138 } 212 }
213
139 skb->truesize += skb->data_len; 214 skb->truesize += skb->data_len;
140 dev->stats.rx_bytes += skb->len; 215 dev->stats.rx_bytes += skb->len;
141 dev->stats.rx_packets++; 216 dev->stats.rx_packets++;
@@ -194,7 +269,7 @@ drop:
194 dev_kfree_skb(skb); 269 dev_kfree_skb(skb);
195} 270}
196 271
197static void try_fill_recv(struct virtnet_info *vi) 272static void try_fill_recv_maxbufs(struct virtnet_info *vi)
198{ 273{
199 struct sk_buff *skb; 274 struct sk_buff *skb;
200 struct scatterlist sg[2+MAX_SKB_FRAGS]; 275 struct scatterlist sg[2+MAX_SKB_FRAGS];
@@ -202,12 +277,16 @@ static void try_fill_recv(struct virtnet_info *vi)
202 277
203 sg_init_table(sg, 2+MAX_SKB_FRAGS); 278 sg_init_table(sg, 2+MAX_SKB_FRAGS);
204 for (;;) { 279 for (;;) {
280 struct virtio_net_hdr *hdr;
281
205 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN); 282 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
206 if (unlikely(!skb)) 283 if (unlikely(!skb))
207 break; 284 break;
208 285
209 skb_put(skb, MAX_PACKET_LEN); 286 skb_put(skb, MAX_PACKET_LEN);
210 vnet_hdr_to_sg(sg, skb); 287
288 hdr = skb_vnet_hdr(skb);
289 sg_init_one(sg, hdr, sizeof(*hdr));
211 290
212 if (vi->big_packets) { 291 if (vi->big_packets) {
213 for (i = 0; i < MAX_SKB_FRAGS; i++) { 292 for (i = 0; i < MAX_SKB_FRAGS; i++) {
@@ -232,6 +311,55 @@ static void try_fill_recv(struct virtnet_info *vi)
232 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb); 311 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb);
233 if (err) { 312 if (err) {
234 skb_unlink(skb, &vi->recv); 313 skb_unlink(skb, &vi->recv);
314 trim_pages(vi, skb);
315 kfree_skb(skb);
316 break;
317 }
318 vi->num++;
319 }
320 if (unlikely(vi->num > vi->max))
321 vi->max = vi->num;
322 vi->rvq->vq_ops->kick(vi->rvq);
323}
324
325static void try_fill_recv(struct virtnet_info *vi)
326{
327 struct sk_buff *skb;
328 struct scatterlist sg[1];
329 int err;
330
331 if (!vi->mergeable_rx_bufs) {
332 try_fill_recv_maxbufs(vi);
333 return;
334 }
335
336 for (;;) {
337 skb_frag_t *f;
338
339 skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN);
340 if (unlikely(!skb))
341 break;
342
343 skb_reserve(skb, NET_IP_ALIGN);
344
345 f = &skb_shinfo(skb)->frags[0];
346 f->page = get_a_page(vi, GFP_ATOMIC);
347 if (!f->page) {
348 kfree_skb(skb);
349 break;
350 }
351
352 f->page_offset = 0;
353 f->size = PAGE_SIZE;
354
355 skb_shinfo(skb)->nr_frags++;
356
357 sg_init_one(sg, page_address(f->page), PAGE_SIZE);
358 skb_queue_head(&vi->recv, skb);
359
360 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, 1, skb);
361 if (err) {
362 skb_unlink(skb, &vi->recv);
235 kfree_skb(skb); 363 kfree_skb(skb);
236 break; 364 break;
237 } 365 }
@@ -320,17 +448,14 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
320{ 448{
321 int num, err; 449 int num, err;
322 struct scatterlist sg[2+MAX_SKB_FRAGS]; 450 struct scatterlist sg[2+MAX_SKB_FRAGS];
323 struct virtio_net_hdr *hdr; 451 struct virtio_net_hdr_mrg_rxbuf *mhdr = skb_vnet_hdr(skb);
452 struct virtio_net_hdr *hdr = skb_vnet_hdr(skb);
324 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; 453 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
325 454
326 sg_init_table(sg, 2+MAX_SKB_FRAGS); 455 sg_init_table(sg, 2+MAX_SKB_FRAGS);
327 456
328 pr_debug("%s: xmit %p " MAC_FMT "\n", vi->dev->name, skb, 457 pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest);
329 dest[0], dest[1], dest[2],
330 dest[3], dest[4], dest[5]);
331 458
332 /* Encode metadata header at front. */
333 hdr = skb_vnet_hdr(skb);
334 if (skb->ip_summed == CHECKSUM_PARTIAL) { 459 if (skb->ip_summed == CHECKSUM_PARTIAL) {
335 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; 460 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
336 hdr->csum_start = skb->csum_start - skb_headroom(skb); 461 hdr->csum_start = skb->csum_start - skb_headroom(skb);
@@ -358,7 +483,14 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
358 hdr->gso_size = hdr->hdr_len = 0; 483 hdr->gso_size = hdr->hdr_len = 0;
359 } 484 }
360 485
361 vnet_hdr_to_sg(sg, skb); 486 mhdr->num_buffers = 0;
487
488 /* Encode metadata header at front. */
489 if (vi->mergeable_rx_bufs)
490 sg_init_one(sg, mhdr, sizeof(*mhdr));
491 else
492 sg_init_one(sg, hdr, sizeof(*hdr));
493
362 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; 494 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
363 495
364 err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); 496 err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb);
@@ -478,6 +610,7 @@ static int virtnet_set_tx_csum(struct net_device *dev, u32 data)
478static struct ethtool_ops virtnet_ethtool_ops = { 610static struct ethtool_ops virtnet_ethtool_ops = {
479 .set_tx_csum = virtnet_set_tx_csum, 611 .set_tx_csum = virtnet_set_tx_csum,
480 .set_sg = ethtool_op_set_sg, 612 .set_sg = ethtool_op_set_sg,
613 .set_tso = ethtool_op_set_tso,
481}; 614};
482 615
483static int virtnet_probe(struct virtio_device *vdev) 616static int virtnet_probe(struct virtio_device *vdev)
@@ -547,6 +680,9 @@ static int virtnet_probe(struct virtio_device *vdev)
547 || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN)) 680 || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
548 vi->big_packets = true; 681 vi->big_packets = true;
549 682
683 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
684 vi->mergeable_rx_bufs = true;
685
550 /* We expect two virtqueues, receive then send. */ 686 /* We expect two virtqueues, receive then send. */
551 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done); 687 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);
552 if (IS_ERR(vi->rvq)) { 688 if (IS_ERR(vi->rvq)) {
@@ -639,6 +775,7 @@ static unsigned int features[] = {
639 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, 775 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
640 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, 776 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
641 VIRTIO_NET_F_GUEST_ECN, /* We don't yet handle UFO input. */ 777 VIRTIO_NET_F_GUEST_ECN, /* We don't yet handle UFO input. */
778 VIRTIO_NET_F_MRG_RXBUF,
642 VIRTIO_F_NOTIFY_ON_EMPTY, 779 VIRTIO_F_NOTIFY_ON_EMPTY,
643}; 780};
644 781
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 7f97f8d08c39..d80b72e22dea 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -754,7 +754,6 @@ static int cosa_net_rx_done(struct channel_data *chan)
754 chan->netdev->stats.rx_bytes += chan->cosa->rxsize; 754 chan->netdev->stats.rx_bytes += chan->cosa->rxsize;
755 netif_rx(chan->rx_skb); 755 netif_rx(chan->rx_skb);
756 chan->rx_skb = NULL; 756 chan->rx_skb = NULL;
757 chan->netdev->last_rx = jiffies;
758 return 0; 757 return 0;
759} 758}
760 759
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
index 5a7303dc0965..aeea321e4a9d 100644
--- a/drivers/net/wan/cycx_x25.c
+++ b/drivers/net/wan/cycx_x25.c
@@ -843,7 +843,6 @@ static void cycx_x25_irq_rx(struct cycx_device *card, struct cycx_x25_cmd *cmd)
843 843
844 skb_reset_mac_header(skb); 844 skb_reset_mac_header(skb);
845 netif_rx(skb); 845 netif_rx(skb);
846 dev->last_rx = jiffies; /* timestamp */
847} 846}
848 847
849/* Connect interrupt handler. */ 848/* Connect interrupt handler. */
@@ -1494,7 +1493,6 @@ static void cycx_x25_chan_send_event(struct net_device *dev, u8 event)
1494 1493
1495 skb->protocol = x25_type_trans(skb, dev); 1494 skb->protocol = x25_type_trans(skb, dev);
1496 netif_rx(skb); 1495 netif_rx(skb);
1497 dev->last_rx = jiffies; /* timestamp */
1498} 1496}
1499 1497
1500/* Convert line speed in bps to a number used by cyclom 2x code. */ 1498/* Convert line speed in bps to a number used by cyclom 2x code. */
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index b14242768fad..a297e3efa05d 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -74,7 +74,7 @@ static int dlci_header(struct sk_buff *skb, struct net_device *dev,
74 unsigned int hlen; 74 unsigned int hlen;
75 char *dest; 75 char *dest;
76 76
77 dlp = dev->priv; 77 dlp = netdev_priv(dev);
78 78
79 hdr.control = FRAD_I_UI; 79 hdr.control = FRAD_I_UI;
80 switch(type) 80 switch(type)
@@ -110,7 +110,7 @@ static void dlci_receive(struct sk_buff *skb, struct net_device *dev)
110 struct frhdr *hdr; 110 struct frhdr *hdr;
111 int process, header; 111 int process, header;
112 112
113 dlp = dev->priv; 113 dlp = netdev_priv(dev);
114 if (!pskb_may_pull(skb, sizeof(*hdr))) { 114 if (!pskb_may_pull(skb, sizeof(*hdr))) {
115 printk(KERN_NOTICE "%s: invalid data no header\n", 115 printk(KERN_NOTICE "%s: invalid data no header\n",
116 dev->name); 116 dev->name);
@@ -181,7 +181,6 @@ static void dlci_receive(struct sk_buff *skb, struct net_device *dev)
181 dlp->stats.rx_bytes += skb->len; 181 dlp->stats.rx_bytes += skb->len;
182 netif_rx(skb); 182 netif_rx(skb);
183 dlp->stats.rx_packets++; 183 dlp->stats.rx_packets++;
184 dev->last_rx = jiffies;
185 } 184 }
186 else 185 else
187 dev_kfree_skb(skb); 186 dev_kfree_skb(skb);
@@ -197,7 +196,7 @@ static int dlci_transmit(struct sk_buff *skb, struct net_device *dev)
197 if (!skb || !dev) 196 if (!skb || !dev)
198 return(0); 197 return(0);
199 198
200 dlp = dev->priv; 199 dlp = netdev_priv(dev);
201 200
202 netif_stop_queue(dev); 201 netif_stop_queue(dev);
203 202
@@ -235,9 +234,9 @@ static int dlci_config(struct net_device *dev, struct dlci_conf __user *conf, in
235 struct frad_local *flp; 234 struct frad_local *flp;
236 int err; 235 int err;
237 236
238 dlp = dev->priv; 237 dlp = netdev_priv(dev);
239 238
240 flp = dlp->slave->priv; 239 flp = netdev_priv(dlp->slave);
241 240
242 if (!get) 241 if (!get)
243 { 242 {
@@ -269,7 +268,7 @@ static int dlci_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
269 if (!capable(CAP_NET_ADMIN)) 268 if (!capable(CAP_NET_ADMIN))
270 return(-EPERM); 269 return(-EPERM);
271 270
272 dlp = dev->priv; 271 dlp = netdev_priv(dev);
273 272
274 switch(cmd) 273 switch(cmd)
275 { 274 {
@@ -298,7 +297,7 @@ static int dlci_change_mtu(struct net_device *dev, int new_mtu)
298{ 297{
299 struct dlci_local *dlp; 298 struct dlci_local *dlp;
300 299
301 dlp = dev->priv; 300 dlp = netdev_priv(dev);
302 301
303 return((*dlp->slave->change_mtu)(dlp->slave, new_mtu)); 302 return((*dlp->slave->change_mtu)(dlp->slave, new_mtu));
304} 303}
@@ -309,7 +308,7 @@ static int dlci_open(struct net_device *dev)
309 struct frad_local *flp; 308 struct frad_local *flp;
310 int err; 309 int err;
311 310
312 dlp = dev->priv; 311 dlp = netdev_priv(dev);
313 312
314 if (!*(short *)(dev->dev_addr)) 313 if (!*(short *)(dev->dev_addr))
315 return(-EINVAL); 314 return(-EINVAL);
@@ -317,7 +316,7 @@ static int dlci_open(struct net_device *dev)
317 if (!netif_running(dlp->slave)) 316 if (!netif_running(dlp->slave))
318 return(-ENOTCONN); 317 return(-ENOTCONN);
319 318
320 flp = dlp->slave->priv; 319 flp = netdev_priv(dlp->slave);
321 err = (*flp->activate)(dlp->slave, dev); 320 err = (*flp->activate)(dlp->slave, dev);
322 if (err) 321 if (err)
323 return(err); 322 return(err);
@@ -335,9 +334,9 @@ static int dlci_close(struct net_device *dev)
335 334
336 netif_stop_queue(dev); 335 netif_stop_queue(dev);
337 336
338 dlp = dev->priv; 337 dlp = netdev_priv(dev);
339 338
340 flp = dlp->slave->priv; 339 flp = netdev_priv(dlp->slave);
341 err = (*flp->deactivate)(dlp->slave, dev); 340 err = (*flp->deactivate)(dlp->slave, dev);
342 341
343 return 0; 342 return 0;
@@ -347,7 +346,7 @@ static struct net_device_stats *dlci_get_stats(struct net_device *dev)
347{ 346{
348 struct dlci_local *dlp; 347 struct dlci_local *dlp;
349 348
350 dlp = dev->priv; 349 dlp = netdev_priv(dev);
351 350
352 return(&dlp->stats); 351 return(&dlp->stats);
353} 352}
@@ -365,7 +364,7 @@ static int dlci_add(struct dlci_add *dlci)
365 if (!slave) 364 if (!slave)
366 return -ENODEV; 365 return -ENODEV;
367 366
368 if (slave->type != ARPHRD_FRAD || slave->priv == NULL) 367 if (slave->type != ARPHRD_FRAD || netdev_priv(slave) == NULL)
369 goto err1; 368 goto err1;
370 369
371 /* create device name */ 370 /* create device name */
@@ -391,11 +390,11 @@ static int dlci_add(struct dlci_add *dlci)
391 390
392 *(short *)(master->dev_addr) = dlci->dlci; 391 *(short *)(master->dev_addr) = dlci->dlci;
393 392
394 dlp = (struct dlci_local *) master->priv; 393 dlp = netdev_priv(master);
395 dlp->slave = slave; 394 dlp->slave = slave;
396 dlp->master = master; 395 dlp->master = master;
397 396
398 flp = slave->priv; 397 flp = netdev_priv(slave);
399 err = (*flp->assoc)(slave, master); 398 err = (*flp->assoc)(slave, master);
400 if (err < 0) 399 if (err < 0)
401 goto err2; 400 goto err2;
@@ -435,9 +434,9 @@ static int dlci_del(struct dlci_add *dlci)
435 return(-EBUSY); 434 return(-EBUSY);
436 } 435 }
437 436
438 dlp = master->priv; 437 dlp = netdev_priv(master);
439 slave = dlp->slave; 438 slave = dlp->slave;
440 flp = slave->priv; 439 flp = netdev_priv(slave);
441 440
442 rtnl_lock(); 441 rtnl_lock();
443 err = (*flp->deassoc)(slave, master); 442 err = (*flp->deassoc)(slave, master);
@@ -491,7 +490,7 @@ static const struct header_ops dlci_header_ops = {
491 490
492static void dlci_setup(struct net_device *dev) 491static void dlci_setup(struct net_device *dev)
493{ 492{
494 struct dlci_local *dlp = dev->priv; 493 struct dlci_local *dlp = netdev_priv(dev);
495 494
496 dev->flags = 0; 495 dev->flags = 0;
497 dev->open = dlci_open; 496 dev->open = dlci_open;
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 5f1ccb2b08b1..888025db2f02 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -659,7 +659,6 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
659 skb_put(skb, pkt_len); 659 skb_put(skb, pkt_len);
660 if (netif_running(dev)) 660 if (netif_running(dev))
661 skb->protocol = hdlc_type_trans(skb, dev); 661 skb->protocol = hdlc_type_trans(skb, dev);
662 skb->dev->last_rx = jiffies;
663 netif_rx(skb); 662 netif_rx(skb);
664 } else { 663 } else {
665 if (skb->data[pkt_len] & FrameRdo) 664 if (skb->data[pkt_len] & FrameRdo)
@@ -730,8 +729,7 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
730 goto err_free_mmio_region_1; 729 goto err_free_mmio_region_1;
731 } 730 }
732 731
733 ioaddr = ioremap(pci_resource_start(pdev, 0), 732 ioaddr = pci_ioremap_bar(pdev, 0);
734 pci_resource_len(pdev, 0));
735 if (!ioaddr) { 733 if (!ioaddr) {
736 printk(KERN_ERR "%s: cannot remap MMIO region %llx @ %llx\n", 734 printk(KERN_ERR "%s: cannot remap MMIO region %llx @ %llx\n",
737 DRV_NAME, (unsigned long long)pci_resource_len(pdev, 0), 735 DRV_NAME, (unsigned long long)pci_resource_len(pdev, 0),
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 9557ad078ab8..48a2c9d28950 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -896,7 +896,6 @@ fst_rx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,
896 fst_process_rx_status(rx_status, port_to_dev(port)->name); 896 fst_process_rx_status(rx_status, port_to_dev(port)->name);
897 if (rx_status == NET_RX_DROP) 897 if (rx_status == NET_RX_DROP)
898 dev->stats.rx_dropped++; 898 dev->stats.rx_dropped++;
899 dev->last_rx = jiffies;
900} 899}
901 900
902/* 901/*
@@ -1322,7 +1321,6 @@ fst_intr_rx(struct fst_card_info *card, struct fst_port_info *port)
1322 fst_process_rx_status(rx_status, port_to_dev(port)->name); 1321 fst_process_rx_status(rx_status, port_to_dev(port)->name);
1323 if (rx_status == NET_RX_DROP) 1322 if (rx_status == NET_RX_DROP)
1324 dev->stats.rx_dropped++; 1323 dev->stats.rx_dropped++;
1325 dev->last_rx = jiffies;
1326 } else { 1324 } else {
1327 card->dma_skb_rx = skb; 1325 card->dma_skb_rx = skb;
1328 card->dma_port_rx = port; 1326 card->dma_port_rx = port;
diff --git a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c
index 591fb45a7c68..434583a94b32 100644
--- a/drivers/net/wan/hd6457x.c
+++ b/drivers/net/wan/hd6457x.c
@@ -328,7 +328,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u1
328#endif 328#endif
329 dev->stats.rx_packets++; 329 dev->stats.rx_packets++;
330 dev->stats.rx_bytes += skb->len; 330 dev->stats.rx_bytes += skb->len;
331 dev->last_rx = jiffies;
332 skb->protocol = hdlc_type_trans(skb, dev); 331 skb->protocol = hdlc_type_trans(skb, dev);
333 netif_rx(skb); 332 netif_rx(skb);
334} 333}
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index e299313f828a..af54f0cf1b35 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -66,7 +66,6 @@ static void hostess_input(struct z8530_channel *c, struct sk_buff *skb)
66 * it right now. 66 * it right now.
67 */ 67 */
68 netif_rx(skb); 68 netif_rx(skb);
69 c->netdevice->last_rx = jiffies;
70} 69}
71 70
72/* 71/*
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 24fd613466b7..5b61b3eef45f 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -143,7 +143,6 @@ static int lapbeth_data_indication(struct net_device *dev, struct sk_buff *skb)
143 *ptr = 0x00; 143 *ptr = 0x00;
144 144
145 skb->protocol = x25_type_trans(skb, dev); 145 skb->protocol = x25_type_trans(skb, dev);
146 skb->dev->last_rx = jiffies;
147 return netif_rx(skb); 146 return netif_rx(skb);
148} 147}
149 148
@@ -235,7 +234,6 @@ static void lapbeth_connected(struct net_device *dev, int reason)
235 *ptr = 0x01; 234 *ptr = 0x01;
236 235
237 skb->protocol = x25_type_trans(skb, dev); 236 skb->protocol = x25_type_trans(skb, dev);
238 skb->dev->last_rx = jiffies;
239 netif_rx(skb); 237 netif_rx(skb);
240} 238}
241 239
@@ -253,7 +251,6 @@ static void lapbeth_disconnected(struct net_device *dev, int reason)
253 *ptr = 0x02; 251 *ptr = 0x02;
254 252
255 skb->protocol = x25_type_trans(skb, dev); 253 skb->protocol = x25_type_trans(skb, dev);
256 skb->dev->last_rx = jiffies;
257 netif_rx(skb); 254 netif_rx(skb);
258} 255}
259 256
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index d7bb63e616b5..feac3b99f8fe 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -1594,7 +1594,6 @@ static int lmc_rx(struct net_device *dev)
1594 goto skip_packet; 1594 goto skip_packet;
1595 } 1595 }
1596 1596
1597 dev->last_rx = jiffies;
1598 sc->lmc_device->stats.rx_packets++; 1597 sc->lmc_device->stats.rx_packets++;
1599 sc->lmc_device->stats.rx_bytes += len; 1598 sc->lmc_device->stats.rx_bytes += len;
1600 1599
diff --git a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c
index be9877ff551e..94b4c208b013 100644
--- a/drivers/net/wan/lmc/lmc_proto.c
+++ b/drivers/net/wan/lmc/lmc_proto.c
@@ -142,7 +142,6 @@ void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
142 case LMC_PPP: 142 case LMC_PPP:
143 case LMC_NET: 143 case LMC_NET:
144 default: 144 default:
145 skb->dev->last_rx = jiffies;
146 netif_rx(skb); 145 netif_rx(skb);
147 break; 146 break;
148 case LMC_RAW: 147 case LMC_RAW:
diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c
index bf1b01590429..222671165223 100644
--- a/drivers/net/wan/pc300too.c
+++ b/drivers/net/wan/pc300too.c
@@ -379,7 +379,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
379 card->scabase = ioremap(scaphys, PC300_SCA_SIZE); 379 card->scabase = ioremap(scaphys, PC300_SCA_SIZE);
380 380
381 ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK; 381 ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK;
382 card->rambase = ioremap(ramphys, pci_resource_len(pdev,3)); 382 card->rambase = pci_ioremap_bar(pdev, 3);
383 383
384 if (card->plxbase == NULL || 384 if (card->plxbase == NULL ||
385 card->scabase == NULL || 385 card->scabase == NULL ||
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index b595b64e7538..bba111cdeebe 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -343,7 +343,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
343 card->scabase = ioremap(scaphys, PCI200SYN_SCA_SIZE); 343 card->scabase = ioremap(scaphys, PCI200SYN_SCA_SIZE);
344 344
345 ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK; 345 ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK;
346 card->rambase = ioremap(ramphys, pci_resource_len(pdev,3)); 346 card->rambase = pci_ioremap_bar(pdev, 3);
347 347
348 if (card->plxbase == NULL || 348 if (card->plxbase == NULL ||
349 card->scabase == NULL || 349 card->scabase == NULL ||
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index ee51b6a5e605..6db063e2d5bb 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -1013,13 +1013,11 @@ indicate_pkt( struct net_device *dev )
1013#ifdef CONFIG_SBNI_MULTILINE 1013#ifdef CONFIG_SBNI_MULTILINE
1014 skb->protocol = eth_type_trans( skb, nl->master ); 1014 skb->protocol = eth_type_trans( skb, nl->master );
1015 netif_rx( skb ); 1015 netif_rx( skb );
1016 dev->last_rx = jiffies;
1017 ++((struct net_local *) nl->master->priv)->stats.rx_packets; 1016 ++((struct net_local *) nl->master->priv)->stats.rx_packets;
1018 ((struct net_local *) nl->master->priv)->stats.rx_bytes += nl->inppos; 1017 ((struct net_local *) nl->master->priv)->stats.rx_bytes += nl->inppos;
1019#else 1018#else
1020 skb->protocol = eth_type_trans( skb, dev ); 1019 skb->protocol = eth_type_trans( skb, dev );
1021 netif_rx( skb ); 1020 netif_rx( skb );
1022 dev->last_rx = jiffies;
1023 ++nl->stats.rx_packets; 1021 ++nl->stats.rx_packets;
1024 nl->stats.rx_bytes += nl->inppos; 1022 nl->stats.rx_bytes += nl->inppos;
1025#endif 1023#endif
diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
index 73e2f2780932..6a07ba9371db 100644
--- a/drivers/net/wan/sdla.c
+++ b/drivers/net/wan/sdla.c
@@ -185,7 +185,7 @@ static void sdla_stop(struct net_device *dev)
185{ 185{
186 struct frad_local *flp; 186 struct frad_local *flp;
187 187
188 flp = dev->priv; 188 flp = netdev_priv(dev);
189 switch(flp->type) 189 switch(flp->type)
190 { 190 {
191 case SDLA_S502A: 191 case SDLA_S502A:
@@ -212,7 +212,7 @@ static void sdla_start(struct net_device *dev)
212{ 212{
213 struct frad_local *flp; 213 struct frad_local *flp;
214 214
215 flp = dev->priv; 215 flp = netdev_priv(dev);
216 switch(flp->type) 216 switch(flp->type)
217 { 217 {
218 case SDLA_S502A: 218 case SDLA_S502A:
@@ -432,7 +432,7 @@ static int sdla_cmd(struct net_device *dev, int cmd, short dlci, short flags,
432 int ret, waiting, len; 432 int ret, waiting, len;
433 long window; 433 long window;
434 434
435 flp = dev->priv; 435 flp = netdev_priv(dev);
436 window = flp->type == SDLA_S508 ? SDLA_508_CMD_BUF : SDLA_502_CMD_BUF; 436 window = flp->type == SDLA_S508 ? SDLA_508_CMD_BUF : SDLA_502_CMD_BUF;
437 cmd_buf = (struct sdla_cmd *)(dev->mem_start + (window & SDLA_ADDR_MASK)); 437 cmd_buf = (struct sdla_cmd *)(dev->mem_start + (window & SDLA_ADDR_MASK));
438 ret = 0; 438 ret = 0;
@@ -509,7 +509,7 @@ static int sdla_activate(struct net_device *slave, struct net_device *master)
509 struct frad_local *flp; 509 struct frad_local *flp;
510 int i; 510 int i;
511 511
512 flp = slave->priv; 512 flp = netdev_priv(slave);
513 513
514 for(i=0;i<CONFIG_DLCI_MAX;i++) 514 for(i=0;i<CONFIG_DLCI_MAX;i++)
515 if (flp->master[i] == master) 515 if (flp->master[i] == master)
@@ -531,7 +531,7 @@ static int sdla_deactivate(struct net_device *slave, struct net_device *master)
531 struct frad_local *flp; 531 struct frad_local *flp;
532 int i; 532 int i;
533 533
534 flp = slave->priv; 534 flp = netdev_priv(slave);
535 535
536 for(i=0;i<CONFIG_DLCI_MAX;i++) 536 for(i=0;i<CONFIG_DLCI_MAX;i++)
537 if (flp->master[i] == master) 537 if (flp->master[i] == master)
@@ -556,7 +556,7 @@ static int sdla_assoc(struct net_device *slave, struct net_device *master)
556 if (master->type != ARPHRD_DLCI) 556 if (master->type != ARPHRD_DLCI)
557 return(-EINVAL); 557 return(-EINVAL);
558 558
559 flp = slave->priv; 559 flp = netdev_priv(slave);
560 560
561 for(i=0;i<CONFIG_DLCI_MAX;i++) 561 for(i=0;i<CONFIG_DLCI_MAX;i++)
562 { 562 {
@@ -589,7 +589,7 @@ static int sdla_deassoc(struct net_device *slave, struct net_device *master)
589 struct frad_local *flp; 589 struct frad_local *flp;
590 int i; 590 int i;
591 591
592 flp = slave->priv; 592 flp = netdev_priv(slave);
593 593
594 for(i=0;i<CONFIG_DLCI_MAX;i++) 594 for(i=0;i<CONFIG_DLCI_MAX;i++)
595 if (flp->master[i] == master) 595 if (flp->master[i] == master)
@@ -619,7 +619,7 @@ static int sdla_dlci_conf(struct net_device *slave, struct net_device *master, i
619 int i; 619 int i;
620 short len, ret; 620 short len, ret;
621 621
622 flp = slave->priv; 622 flp = netdev_priv(slave);
623 623
624 for(i=0;i<CONFIG_DLCI_MAX;i++) 624 for(i=0;i<CONFIG_DLCI_MAX;i++)
625 if (flp->master[i] == master) 625 if (flp->master[i] == master)
@@ -628,7 +628,7 @@ static int sdla_dlci_conf(struct net_device *slave, struct net_device *master, i
628 if (i == CONFIG_DLCI_MAX) 628 if (i == CONFIG_DLCI_MAX)
629 return(-ENODEV); 629 return(-ENODEV);
630 630
631 dlp = master->priv; 631 dlp = netdev_priv(master);
632 632
633 ret = SDLA_RET_OK; 633 ret = SDLA_RET_OK;
634 len = sizeof(struct dlci_conf); 634 len = sizeof(struct dlci_conf);
@@ -659,7 +659,7 @@ static int sdla_transmit(struct sk_buff *skb, struct net_device *dev)
659 unsigned long flags; 659 unsigned long flags;
660 struct buf_entry *pbuf; 660 struct buf_entry *pbuf;
661 661
662 flp = dev->priv; 662 flp = netdev_priv(dev);
663 ret = 0; 663 ret = 0;
664 accept = 1; 664 accept = 1;
665 665
@@ -755,7 +755,7 @@ static void sdla_receive(struct net_device *dev)
755 int i=0, received, success, addr, buf_base, buf_top; 755 int i=0, received, success, addr, buf_base, buf_top;
756 short dlci, len, len2, split; 756 short dlci, len, len2, split;
757 757
758 flp = dev->priv; 758 flp = netdev_priv(dev);
759 success = 1; 759 success = 1;
760 received = addr = buf_top = buf_base = 0; 760 received = addr = buf_top = buf_base = 0;
761 len = dlci = 0; 761 len = dlci = 0;
@@ -860,7 +860,7 @@ static void sdla_receive(struct net_device *dev)
860 if (success) 860 if (success)
861 { 861 {
862 flp->stats.rx_packets++; 862 flp->stats.rx_packets++;
863 dlp = master->priv; 863 dlp = netdev_priv(master);
864 (*dlp->receive)(skb, master); 864 (*dlp->receive)(skb, master);
865 } 865 }
866 866
@@ -925,7 +925,7 @@ static void sdla_poll(unsigned long device)
925 struct frad_local *flp; 925 struct frad_local *flp;
926 926
927 dev = (struct net_device *) device; 927 dev = (struct net_device *) device;
928 flp = dev->priv; 928 flp = netdev_priv(dev);
929 929
930 if (sdla_byte(dev, SDLA_502_RCV_BUF)) 930 if (sdla_byte(dev, SDLA_502_RCV_BUF))
931 sdla_receive(dev); 931 sdla_receive(dev);
@@ -941,7 +941,7 @@ static int sdla_close(struct net_device *dev)
941 int len, i; 941 int len, i;
942 short dlcis[CONFIG_DLCI_MAX]; 942 short dlcis[CONFIG_DLCI_MAX];
943 943
944 flp = dev->priv; 944 flp = netdev_priv(dev);
945 945
946 len = 0; 946 len = 0;
947 for(i=0;i<CONFIG_DLCI_MAX;i++) 947 for(i=0;i<CONFIG_DLCI_MAX;i++)
@@ -1002,7 +1002,7 @@ static int sdla_open(struct net_device *dev)
1002 int len, i; 1002 int len, i;
1003 char byte; 1003 char byte;
1004 1004
1005 flp = dev->priv; 1005 flp = netdev_priv(dev);
1006 1006
1007 if (!flp->initialized) 1007 if (!flp->initialized)
1008 return(-EPERM); 1008 return(-EPERM);
@@ -1079,7 +1079,7 @@ static int sdla_open(struct net_device *dev)
1079 for(i=0;i<CONFIG_DLCI_MAX;i++) 1079 for(i=0;i<CONFIG_DLCI_MAX;i++)
1080 if (flp->dlci[i]) 1080 if (flp->dlci[i])
1081 { 1081 {
1082 dlp = flp->master[i]->priv; 1082 dlp = netdev_priv(flp->master[i]);
1083 if (dlp->configured) 1083 if (dlp->configured)
1084 sdla_cmd(dev, SDLA_SET_DLCI_CONFIGURATION, abs(flp->dlci[i]), 0, &dlp->config, sizeof(struct dlci_conf), NULL, NULL); 1084 sdla_cmd(dev, SDLA_SET_DLCI_CONFIGURATION, abs(flp->dlci[i]), 0, &dlp->config, sizeof(struct dlci_conf), NULL, NULL);
1085 } 1085 }
@@ -1099,7 +1099,7 @@ static int sdla_config(struct net_device *dev, struct frad_conf __user *conf, in
1099 if (dev->type == 0xFFFF) 1099 if (dev->type == 0xFFFF)
1100 return(-EUNATCH); 1100 return(-EUNATCH);
1101 1101
1102 flp = dev->priv; 1102 flp = netdev_priv(dev);
1103 1103
1104 if (!get) 1104 if (!get)
1105 { 1105 {
@@ -1230,7 +1230,7 @@ static int sdla_reconfig(struct net_device *dev)
1230 struct conf_data data; 1230 struct conf_data data;
1231 int i, len; 1231 int i, len;
1232 1232
1233 flp = dev->priv; 1233 flp = netdev_priv(dev);
1234 1234
1235 len = 0; 1235 len = 0;
1236 for(i=0;i<CONFIG_DLCI_MAX;i++) 1236 for(i=0;i<CONFIG_DLCI_MAX;i++)
@@ -1255,7 +1255,7 @@ static int sdla_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1255 if(!capable(CAP_NET_ADMIN)) 1255 if(!capable(CAP_NET_ADMIN))
1256 return -EPERM; 1256 return -EPERM;
1257 1257
1258 flp = dev->priv; 1258 flp = netdev_priv(dev);
1259 1259
1260 if (!flp->initialized) 1260 if (!flp->initialized)
1261 return(-EINVAL); 1261 return(-EINVAL);
@@ -1321,7 +1321,7 @@ static int sdla_change_mtu(struct net_device *dev, int new_mtu)
1321{ 1321{
1322 struct frad_local *flp; 1322 struct frad_local *flp;
1323 1323
1324 flp = dev->priv; 1324 flp = netdev_priv(dev);
1325 1325
1326 if (netif_running(dev)) 1326 if (netif_running(dev))
1327 return(-EBUSY); 1327 return(-EBUSY);
@@ -1338,7 +1338,7 @@ static int sdla_set_config(struct net_device *dev, struct ifmap *map)
1338 unsigned base; 1338 unsigned base;
1339 int err = -EINVAL; 1339 int err = -EINVAL;
1340 1340
1341 flp = dev->priv; 1341 flp = netdev_priv(dev);
1342 1342
1343 if (flp->initialized) 1343 if (flp->initialized)
1344 return(-EINVAL); 1344 return(-EINVAL);
@@ -1593,14 +1593,14 @@ fail:
1593static struct net_device_stats *sdla_stats(struct net_device *dev) 1593static struct net_device_stats *sdla_stats(struct net_device *dev)
1594{ 1594{
1595 struct frad_local *flp; 1595 struct frad_local *flp;
1596 flp = dev->priv; 1596 flp = netdev_priv(dev);
1597 1597
1598 return(&flp->stats); 1598 return(&flp->stats);
1599} 1599}
1600 1600
1601static void setup_sdla(struct net_device *dev) 1601static void setup_sdla(struct net_device *dev)
1602{ 1602{
1603 struct frad_local *flp = dev->priv; 1603 struct frad_local *flp = netdev_priv(dev);
1604 1604
1605 netdev_boot_setup_check(dev); 1605 netdev_boot_setup_check(dev);
1606 1606
@@ -1651,7 +1651,7 @@ static int __init init_sdla(void)
1651 1651
1652static void __exit exit_sdla(void) 1652static void __exit exit_sdla(void)
1653{ 1653{
1654 struct frad_local *flp = sdla->priv; 1654 struct frad_local *flp = netdev_priv(sdla);
1655 1655
1656 unregister_netdev(sdla); 1656 unregister_netdev(sdla);
1657 if (flp->initialized) { 1657 if (flp->initialized) {
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c
index c0235844a4d5..0941a26f6e3f 100644
--- a/drivers/net/wan/sealevel.c
+++ b/drivers/net/wan/sealevel.c
@@ -68,7 +68,6 @@ static void sealevel_input(struct z8530_channel *c, struct sk_buff *skb)
68 skb_reset_mac_header(skb); 68 skb_reset_mac_header(skb);
69 skb->dev = c->netdevice; 69 skb->dev = c->netdevice;
70 netif_rx(skb); 70 netif_rx(skb);
71 c->netdevice->last_rx = jiffies;
72} 71}
73 72
74/* 73/*
diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c
index 6e92f7b44b1a..58ae8a2223af 100644
--- a/drivers/net/wan/syncppp.c
+++ b/drivers/net/wan/syncppp.c
@@ -284,7 +284,6 @@ static void sppp_input (struct net_device *dev, struct sk_buff *skb)
284 printk(KERN_DEBUG "Yow an IP frame.\n"); 284 printk(KERN_DEBUG "Yow an IP frame.\n");
285 skb->protocol=htons(ETH_P_IP); 285 skb->protocol=htons(ETH_P_IP);
286 netif_rx(skb); 286 netif_rx(skb);
287 dev->last_rx = jiffies;
288 goto done; 287 goto done;
289 } 288 }
290 break; 289 break;
@@ -294,7 +293,6 @@ static void sppp_input (struct net_device *dev, struct sk_buff *skb)
294 if (sp->lcp.state == LCP_STATE_OPENED) { 293 if (sp->lcp.state == LCP_STATE_OPENED) {
295 skb->protocol=htons(ETH_P_IPX); 294 skb->protocol=htons(ETH_P_IPX);
296 netif_rx(skb); 295 netif_rx(skb);
297 dev->last_rx = jiffies;
298 goto done; 296 goto done;
299 } 297 }
300 break; 298 break;
@@ -321,14 +319,12 @@ static void sppp_input (struct net_device *dev, struct sk_buff *skb)
321 case ETH_P_IP: 319 case ETH_P_IP:
322 skb->protocol=htons(ETH_P_IP); 320 skb->protocol=htons(ETH_P_IP);
323 netif_rx(skb); 321 netif_rx(skb);
324 dev->last_rx = jiffies;
325 goto done; 322 goto done;
326#endif 323#endif
327#ifdef CONFIG_IPX 324#ifdef CONFIG_IPX
328 case ETH_P_IPX: 325 case ETH_P_IPX:
329 skb->protocol=htons(ETH_P_IPX); 326 skb->protocol=htons(ETH_P_IPX);
330 netif_rx(skb); 327 netif_rx(skb);
331 dev->last_rx = jiffies;
332 goto done; 328 goto done;
333#endif 329#endif
334 } 330 }
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index a8a5ca0ee6c2..88459490ecd2 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -220,7 +220,6 @@ static inline void wanxl_rx_intr(card_t *card)
220#endif 220#endif
221 dev->stats.rx_packets++; 221 dev->stats.rx_packets++;
222 dev->stats.rx_bytes += skb->len; 222 dev->stats.rx_bytes += skb->len;
223 dev->last_rx = jiffies;
224 skb->protocol = hdlc_type_trans(skb, dev); 223 skb->protocol = hdlc_type_trans(skb, dev);
225 netif_rx(skb); 224 netif_rx(skb);
226 skb = NULL; 225 skb = NULL;
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 2a6c7a60756f..85d789147300 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -64,7 +64,7 @@ static struct x25_asy *x25_asy_alloc(void)
64 if (dev == NULL) 64 if (dev == NULL)
65 break; 65 break;
66 66
67 sl = dev->priv; 67 sl = netdev_priv(dev);
68 /* Not in use ? */ 68 /* Not in use ? */
69 if (!test_and_set_bit(SLF_INUSE, &sl->flags)) 69 if (!test_and_set_bit(SLF_INUSE, &sl->flags))
70 return sl; 70 return sl;
@@ -86,7 +86,7 @@ static struct x25_asy *x25_asy_alloc(void)
86 return NULL; 86 return NULL;
87 87
88 /* Initialize channel control data */ 88 /* Initialize channel control data */
89 sl = dev->priv; 89 sl = netdev_priv(dev);
90 dev->base_addr = i; 90 dev->base_addr = i;
91 91
92 /* register device so that it can be ifconfig'ed */ 92 /* register device so that it can be ifconfig'ed */
@@ -120,7 +120,7 @@ static void x25_asy_free(struct x25_asy *sl)
120 120
121static int x25_asy_change_mtu(struct net_device *dev, int newmtu) 121static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
122{ 122{
123 struct x25_asy *sl = dev->priv; 123 struct x25_asy *sl = netdev_priv(dev);
124 unsigned char *xbuff, *rbuff; 124 unsigned char *xbuff, *rbuff;
125 int len = 2 * newmtu; 125 int len = 2 * newmtu;
126 126
@@ -211,7 +211,6 @@ static void x25_asy_bump(struct x25_asy *sl)
211 printk(KERN_DEBUG "x25_asy: data received err - %d\n", err); 211 printk(KERN_DEBUG "x25_asy: data received err - %d\n", err);
212 } else { 212 } else {
213 netif_rx(skb); 213 netif_rx(skb);
214 sl->dev->last_rx = jiffies;
215 sl->stats.rx_packets++; 214 sl->stats.rx_packets++;
216 } 215 }
217} 216}
@@ -280,7 +279,7 @@ static void x25_asy_write_wakeup(struct tty_struct *tty)
280 279
281static void x25_asy_timeout(struct net_device *dev) 280static void x25_asy_timeout(struct net_device *dev)
282{ 281{
283 struct x25_asy *sl = dev->priv; 282 struct x25_asy *sl = netdev_priv(dev);
284 283
285 spin_lock(&sl->lock); 284 spin_lock(&sl->lock);
286 if (netif_queue_stopped(dev)) { 285 if (netif_queue_stopped(dev)) {
@@ -301,7 +300,7 @@ static void x25_asy_timeout(struct net_device *dev)
301 300
302static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) 301static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
303{ 302{
304 struct x25_asy *sl = dev->priv; 303 struct x25_asy *sl = netdev_priv(dev);
305 int err; 304 int err;
306 305
307 if (!netif_running(sl->dev)) { 306 if (!netif_running(sl->dev)) {
@@ -361,7 +360,6 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
361 360
362static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb) 361static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb)
363{ 362{
364 skb->dev->last_rx = jiffies;
365 return netif_rx(skb); 363 return netif_rx(skb);
366} 364}
367 365
@@ -373,7 +371,7 @@ static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb)
373 371
374static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb) 372static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb)
375{ 373{
376 struct x25_asy *sl = dev->priv; 374 struct x25_asy *sl = netdev_priv(dev);
377 375
378 spin_lock(&sl->lock); 376 spin_lock(&sl->lock);
379 if (netif_queue_stopped(sl->dev) || sl->tty == NULL) { 377 if (netif_queue_stopped(sl->dev) || sl->tty == NULL) {
@@ -398,7 +396,7 @@ static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb)
398 396
399static void x25_asy_connected(struct net_device *dev, int reason) 397static void x25_asy_connected(struct net_device *dev, int reason)
400{ 398{
401 struct x25_asy *sl = dev->priv; 399 struct x25_asy *sl = netdev_priv(dev);
402 struct sk_buff *skb; 400 struct sk_buff *skb;
403 unsigned char *ptr; 401 unsigned char *ptr;
404 402
@@ -413,12 +411,11 @@ static void x25_asy_connected(struct net_device *dev, int reason)
413 411
414 skb->protocol = x25_type_trans(skb, sl->dev); 412 skb->protocol = x25_type_trans(skb, sl->dev);
415 netif_rx(skb); 413 netif_rx(skb);
416 sl->dev->last_rx = jiffies;
417} 414}
418 415
419static void x25_asy_disconnected(struct net_device *dev, int reason) 416static void x25_asy_disconnected(struct net_device *dev, int reason)
420{ 417{
421 struct x25_asy *sl = dev->priv; 418 struct x25_asy *sl = netdev_priv(dev);
422 struct sk_buff *skb; 419 struct sk_buff *skb;
423 unsigned char *ptr; 420 unsigned char *ptr;
424 421
@@ -433,7 +430,6 @@ static void x25_asy_disconnected(struct net_device *dev, int reason)
433 430
434 skb->protocol = x25_type_trans(skb, sl->dev); 431 skb->protocol = x25_type_trans(skb, sl->dev);
435 netif_rx(skb); 432 netif_rx(skb);
436 sl->dev->last_rx = jiffies;
437} 433}
438 434
439static struct lapb_register_struct x25_asy_callbacks = { 435static struct lapb_register_struct x25_asy_callbacks = {
@@ -450,7 +446,7 @@ static struct lapb_register_struct x25_asy_callbacks = {
450/* Open the low-level part of the X.25 channel. Easy! */ 446/* Open the low-level part of the X.25 channel. Easy! */
451static int x25_asy_open(struct net_device *dev) 447static int x25_asy_open(struct net_device *dev)
452{ 448{
453 struct x25_asy *sl = dev->priv; 449 struct x25_asy *sl = netdev_priv(dev);
454 unsigned long len; 450 unsigned long len;
455 int err; 451 int err;
456 452
@@ -499,7 +495,7 @@ norbuff:
499/* Close the low-level part of the X.25 channel. Easy! */ 495/* Close the low-level part of the X.25 channel. Easy! */
500static int x25_asy_close(struct net_device *dev) 496static int x25_asy_close(struct net_device *dev)
501{ 497{
502 struct x25_asy *sl = dev->priv; 498 struct x25_asy *sl = netdev_priv(dev);
503 int err; 499 int err;
504 500
505 spin_lock(&sl->lock); 501 spin_lock(&sl->lock);
@@ -615,7 +611,7 @@ static void x25_asy_close_tty(struct tty_struct *tty)
615 611
616static struct net_device_stats *x25_asy_get_stats(struct net_device *dev) 612static struct net_device_stats *x25_asy_get_stats(struct net_device *dev)
617{ 613{
618 struct x25_asy *sl = dev->priv; 614 struct x25_asy *sl = netdev_priv(dev);
619 return &sl->stats; 615 return &sl->stats;
620} 616}
621 617
@@ -717,7 +713,7 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file,
717 713
718static int x25_asy_open_dev(struct net_device *dev) 714static int x25_asy_open_dev(struct net_device *dev)
719{ 715{
720 struct x25_asy *sl = dev->priv; 716 struct x25_asy *sl = netdev_priv(dev);
721 if (sl->tty == NULL) 717 if (sl->tty == NULL)
722 return -ENODEV; 718 return -ENODEV;
723 return 0; 719 return 0;
@@ -726,7 +722,7 @@ static int x25_asy_open_dev(struct net_device *dev)
726/* Initialise the X.25 driver. Called by the device init code */ 722/* Initialise the X.25 driver. Called by the device init code */
727static void x25_asy_setup(struct net_device *dev) 723static void x25_asy_setup(struct net_device *dev)
728{ 724{
729 struct x25_asy *sl = dev->priv; 725 struct x25_asy *sl = netdev_priv(dev);
730 726
731 sl->magic = X25_ASY_MAGIC; 727 sl->magic = X25_ASY_MAGIC;
732 sl->dev = dev; 728 sl->dev = dev;
@@ -793,7 +789,7 @@ static void __exit exit_x25_asy(void)
793 for (i = 0; i < x25_asy_maxdev; i++) { 789 for (i = 0; i < x25_asy_maxdev; i++) {
794 dev = x25_asy_devs[i]; 790 dev = x25_asy_devs[i];
795 if (dev) { 791 if (dev) {
796 struct x25_asy *sl = dev->priv; 792 struct x25_asy *sl = netdev_priv(dev);
797 793
798 spin_lock_bh(&sl->lock); 794 spin_lock_bh(&sl->lock);
799 if (sl->tty) 795 if (sl->tty)
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index fa14255282af..6d96ed472119 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -156,7 +156,6 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr)
156 int word16 = 0; /* 0 = 8 bit, 1 = 16 bit */ 156 int word16 = 0; /* 0 = 8 bit, 1 = 16 bit */
157 const char *model_name; 157 const char *model_name;
158 static unsigned version_printed; 158 static unsigned version_printed;
159 DECLARE_MAC_BUF(mac);
160 159
161 for (i = 0; i < 8; i++) 160 for (i = 0; i < 8; i++)
162 checksum += inb(ioaddr + 8 + i); 161 checksum += inb(ioaddr + 8 + i);
@@ -178,8 +177,8 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr)
178 for (i = 0; i < 6; i++) 177 for (i = 0; i < 6; i++)
179 dev->dev_addr[i] = inb(ioaddr + 8 + i); 178 dev->dev_addr[i] = inb(ioaddr + 8 + i);
180 179
181 printk("%s: WD80x3 at %#3x, %s", 180 printk("%s: WD80x3 at %#3x, %pM",
182 dev->name, ioaddr, print_mac(mac, dev->dev_addr)); 181 dev->name, ioaddr, dev->dev_addr);
183 182
184 /* The following PureData probe code was contributed by 183 /* The following PureData probe code was contributed by
185 Mike Jagdis <jaggy@purplet.demon.co.uk>. Puredata does software 184 Mike Jagdis <jaggy@purplet.demon.co.uk>. Puredata does software
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 45bdf0b339bb..42afaedbb219 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -271,6 +271,7 @@ config LIBERTAS
271 tristate "Marvell 8xxx Libertas WLAN driver support" 271 tristate "Marvell 8xxx Libertas WLAN driver support"
272 depends on WLAN_80211 272 depends on WLAN_80211
273 select WIRELESS_EXT 273 select WIRELESS_EXT
274 select LIB80211
274 select FW_LOADER 275 select FW_LOADER
275 ---help--- 276 ---help---
276 A library for Marvell Libertas 8xxx devices. 277 A library for Marvell Libertas 8xxx devices.
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 59d2d805f60b..78820840fe21 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -16,14 +16,7 @@ obj-$(CONFIG_WAVELAN) += wavelan.o
16obj-$(CONFIG_PCMCIA_NETWAVE) += netwave_cs.o 16obj-$(CONFIG_PCMCIA_NETWAVE) += netwave_cs.o
17obj-$(CONFIG_PCMCIA_WAVELAN) += wavelan_cs.o 17obj-$(CONFIG_PCMCIA_WAVELAN) += wavelan_cs.o
18 18
19obj-$(CONFIG_HERMES) += orinoco.o hermes.o hermes_dld.o 19obj-$(CONFIG_HERMES) += orinoco/
20obj-$(CONFIG_PCMCIA_HERMES) += orinoco_cs.o
21obj-$(CONFIG_APPLE_AIRPORT) += airport.o
22obj-$(CONFIG_PLX_HERMES) += orinoco_plx.o
23obj-$(CONFIG_PCI_HERMES) += orinoco_pci.o
24obj-$(CONFIG_TMD_HERMES) += orinoco_tmd.o
25obj-$(CONFIG_NORTEL_HERMES) += orinoco_nortel.o
26obj-$(CONFIG_PCMCIA_SPECTRUM) += spectrum_cs.o
27 20
28obj-$(CONFIG_AIRO) += airo.o 21obj-$(CONFIG_AIRO) += airo.o
29obj-$(CONFIG_AIRO_CS) += airo_cs.o airo.o 22obj-$(CONFIG_AIRO_CS) += airo_cs.o airo.o
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index b2c050b68890..fc0897fb2239 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -341,15 +341,14 @@ static void adm8211_interrupt_tci(struct ieee80211_hw *dev)
341 pci_unmap_single(priv->pdev, info->mapping, 341 pci_unmap_single(priv->pdev, info->mapping,
342 info->skb->len, PCI_DMA_TODEVICE); 342 info->skb->len, PCI_DMA_TODEVICE);
343 343
344 memset(&txi->status, 0, sizeof(txi->status)); 344 ieee80211_tx_info_clear_status(txi);
345
345 skb_pull(skb, sizeof(struct adm8211_tx_hdr)); 346 skb_pull(skb, sizeof(struct adm8211_tx_hdr));
346 memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen); 347 memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen);
347 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { 348 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) &&
348 if (status & TDES0_STATUS_ES) 349 !(status & TDES0_STATUS_ES))
349 txi->status.excessive_retries = 1; 350 txi->flags |= IEEE80211_TX_STAT_ACK;
350 else 351
351 txi->flags |= IEEE80211_TX_STAT_ACK;
352 }
353 ieee80211_tx_status_irqsafe(dev, skb); 352 ieee80211_tx_status_irqsafe(dev, skb);
354 353
355 info->skb = NULL; 354 info->skb = NULL;
@@ -1298,25 +1297,10 @@ static void adm8211_set_bssid(struct ieee80211_hw *dev, const u8 *bssid)
1298 ADM8211_CSR_WRITE(ABDA1, reg); 1297 ADM8211_CSR_WRITE(ABDA1, reg);
1299} 1298}
1300 1299
1301static int adm8211_set_ssid(struct ieee80211_hw *dev, u8 *ssid, size_t ssid_len) 1300static int adm8211_config(struct ieee80211_hw *dev, u32 changed)
1302{
1303 struct adm8211_priv *priv = dev->priv;
1304 u8 buf[36];
1305
1306 if (ssid_len > 32)
1307 return -EINVAL;
1308
1309 memset(buf, 0, sizeof(buf));
1310 buf[0] = ssid_len;
1311 memcpy(buf + 1, ssid, ssid_len);
1312 adm8211_write_sram_bytes(dev, ADM8211_SRAM_SSID, buf, 33);
1313 /* TODO: configure beacon for adhoc? */
1314 return 0;
1315}
1316
1317static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
1318{ 1301{
1319 struct adm8211_priv *priv = dev->priv; 1302 struct adm8211_priv *priv = dev->priv;
1303 struct ieee80211_conf *conf = &dev->conf;
1320 int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); 1304 int channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
1321 1305
1322 if (channel != priv->channel) { 1306 if (channel != priv->channel) {
@@ -1338,13 +1322,6 @@ static int adm8211_config_interface(struct ieee80211_hw *dev,
1338 memcpy(priv->bssid, conf->bssid, ETH_ALEN); 1322 memcpy(priv->bssid, conf->bssid, ETH_ALEN);
1339 } 1323 }
1340 1324
1341 if (conf->ssid_len != priv->ssid_len ||
1342 memcmp(conf->ssid, priv->ssid, conf->ssid_len)) {
1343 adm8211_set_ssid(dev, conf->ssid, conf->ssid_len);
1344 priv->ssid_len = conf->ssid_len;
1345 memcpy(priv->ssid, conf->ssid, conf->ssid_len);
1346 }
1347
1348 return 0; 1325 return 0;
1349} 1326}
1350 1327
@@ -1690,8 +1667,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1690 struct ieee80211_hdr *hdr; 1667 struct ieee80211_hdr *hdr;
1691 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1668 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1692 struct ieee80211_rate *txrate = ieee80211_get_tx_rate(dev, info); 1669 struct ieee80211_rate *txrate = ieee80211_get_tx_rate(dev, info);
1670 u8 rc_flags;
1693 1671
1694 short_preamble = !!(txrate->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE); 1672 rc_flags = info->control.rates[0].flags;
1673 short_preamble = !!(rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
1695 plcp_signal = txrate->bitrate; 1674 plcp_signal = txrate->bitrate;
1696 1675
1697 hdr = (struct ieee80211_hdr *)skb->data; 1676 hdr = (struct ieee80211_hdr *)skb->data;
@@ -1723,10 +1702,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1723 if (short_preamble) 1702 if (short_preamble)
1724 txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE); 1703 txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE);
1725 1704
1726 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) 1705 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
1727 txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS); 1706 txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS);
1728 1707
1729 txhdr->retry_limit = info->control.retry_limit; 1708 txhdr->retry_limit = info->control.rates[0].count;
1730 1709
1731 adm8211_tx_raw(dev, skb, plcp_signal, hdrlen); 1710 adm8211_tx_raw(dev, skb, plcp_signal, hdrlen);
1732 1711
@@ -1791,7 +1770,6 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
1791 int err; 1770 int err;
1792 u32 reg; 1771 u32 reg;
1793 u8 perm_addr[ETH_ALEN]; 1772 u8 perm_addr[ETH_ALEN];
1794 DECLARE_MAC_BUF(mac);
1795 1773
1796 err = pci_enable_device(pdev); 1774 err = pci_enable_device(pdev);
1797 if (err) { 1775 if (err) {
@@ -1925,8 +1903,8 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
1925 goto err_free_desc; 1903 goto err_free_desc;
1926 } 1904 }
1927 1905
1928 printk(KERN_INFO "%s: hwaddr %s, Rev 0x%02x\n", 1906 printk(KERN_INFO "%s: hwaddr %pM, Rev 0x%02x\n",
1929 wiphy_name(dev->wiphy), print_mac(mac, dev->wiphy->perm_addr), 1907 wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
1930 pdev->revision); 1908 pdev->revision);
1931 1909
1932 return 0; 1910 return 0;
diff --git a/drivers/net/wireless/adm8211.h b/drivers/net/wireless/adm8211.h
index 9b190ee26e90..4f6ab1322189 100644
--- a/drivers/net/wireless/adm8211.h
+++ b/drivers/net/wireless/adm8211.h
@@ -553,8 +553,6 @@ struct adm8211_priv {
553 553
554 int channel; 554 int channel;
555 u8 bssid[ETH_ALEN]; 555 u8 bssid[ETH_ALEN];
556 u8 ssid[32];
557 size_t ssid_len;
558 556
559 u8 soft_rx_crc; 557 u8 soft_rx_crc;
560 u8 retry_limit; 558 u8 retry_limit;
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 370133e492d2..67d504e32290 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -47,10 +47,11 @@
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/pci.h> 48#include <linux/pci.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <net/ieee80211.h>
51#include <linux/kthread.h> 50#include <linux/kthread.h>
52#include <linux/freezer.h> 51#include <linux/freezer.h>
53 52
53#include <linux/ieee80211.h>
54
54#include "airo.h" 55#include "airo.h"
55 56
56#define DRV_NAME "airo" 57#define DRV_NAME "airo"
@@ -1270,6 +1271,7 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev);
1270#define airo_print_err(name, fmt, args...) \ 1271#define airo_print_err(name, fmt, args...) \
1271 airo_print(KERN_ERR, name, fmt, ##args) 1272 airo_print(KERN_ERR, name, fmt, ##args)
1272 1273
1274#define AIRO_FLASH(dev) (((struct airo_info *)dev->ml_priv)->flash)
1273 1275
1274/*********************************************************************** 1276/***********************************************************************
1275 * MIC ROUTINES * 1277 * MIC ROUTINES *
@@ -1865,7 +1867,7 @@ static void try_auto_wep(struct airo_info *ai)
1865} 1867}
1866 1868
1867static int airo_open(struct net_device *dev) { 1869static int airo_open(struct net_device *dev) {
1868 struct airo_info *ai = dev->priv; 1870 struct airo_info *ai = dev->ml_priv;
1869 int rc = 0; 1871 int rc = 0;
1870 1872
1871 if (test_bit(FLAG_FLASHING, &ai->flags)) 1873 if (test_bit(FLAG_FLASHING, &ai->flags))
@@ -1912,7 +1914,7 @@ static int airo_open(struct net_device *dev) {
1912static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) { 1914static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) {
1913 int npacks, pending; 1915 int npacks, pending;
1914 unsigned long flags; 1916 unsigned long flags;
1915 struct airo_info *ai = dev->priv; 1917 struct airo_info *ai = dev->ml_priv;
1916 1918
1917 if (!skb) { 1919 if (!skb) {
1918 airo_print_err(dev->name, "%s: skb == NULL!",__func__); 1920 airo_print_err(dev->name, "%s: skb == NULL!",__func__);
@@ -1956,7 +1958,7 @@ static int mpi_send_packet (struct net_device *dev)
1956 unsigned char *buffer; 1958 unsigned char *buffer;
1957 s16 len; 1959 s16 len;
1958 __le16 *payloadLen; 1960 __le16 *payloadLen;
1959 struct airo_info *ai = dev->priv; 1961 struct airo_info *ai = dev->ml_priv;
1960 u8 *sendbuf; 1962 u8 *sendbuf;
1961 1963
1962 /* get a packet to send */ 1964 /* get a packet to send */
@@ -2085,7 +2087,7 @@ static void get_tx_error(struct airo_info *ai, s32 fid)
2085static void airo_end_xmit(struct net_device *dev) { 2087static void airo_end_xmit(struct net_device *dev) {
2086 u16 status; 2088 u16 status;
2087 int i; 2089 int i;
2088 struct airo_info *priv = dev->priv; 2090 struct airo_info *priv = dev->ml_priv;
2089 struct sk_buff *skb = priv->xmit.skb; 2091 struct sk_buff *skb = priv->xmit.skb;
2090 int fid = priv->xmit.fid; 2092 int fid = priv->xmit.fid;
2091 u32 *fids = priv->fids; 2093 u32 *fids = priv->fids;
@@ -2111,7 +2113,7 @@ static void airo_end_xmit(struct net_device *dev) {
2111static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) { 2113static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) {
2112 s16 len; 2114 s16 len;
2113 int i, j; 2115 int i, j;
2114 struct airo_info *priv = dev->priv; 2116 struct airo_info *priv = dev->ml_priv;
2115 u32 *fids = priv->fids; 2117 u32 *fids = priv->fids;
2116 2118
2117 if ( skb == NULL ) { 2119 if ( skb == NULL ) {
@@ -2150,7 +2152,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) {
2150static void airo_end_xmit11(struct net_device *dev) { 2152static void airo_end_xmit11(struct net_device *dev) {
2151 u16 status; 2153 u16 status;
2152 int i; 2154 int i;
2153 struct airo_info *priv = dev->priv; 2155 struct airo_info *priv = dev->ml_priv;
2154 struct sk_buff *skb = priv->xmit11.skb; 2156 struct sk_buff *skb = priv->xmit11.skb;
2155 int fid = priv->xmit11.fid; 2157 int fid = priv->xmit11.fid;
2156 u32 *fids = priv->fids; 2158 u32 *fids = priv->fids;
@@ -2176,7 +2178,7 @@ static void airo_end_xmit11(struct net_device *dev) {
2176static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) { 2178static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
2177 s16 len; 2179 s16 len;
2178 int i, j; 2180 int i, j;
2179 struct airo_info *priv = dev->priv; 2181 struct airo_info *priv = dev->ml_priv;
2180 u32 *fids = priv->fids; 2182 u32 *fids = priv->fids;
2181 2183
2182 if (test_bit(FLAG_MPI, &priv->flags)) { 2184 if (test_bit(FLAG_MPI, &priv->flags)) {
@@ -2220,7 +2222,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
2220 2222
2221static void airo_read_stats(struct net_device *dev) 2223static void airo_read_stats(struct net_device *dev)
2222{ 2224{
2223 struct airo_info *ai = dev->priv; 2225 struct airo_info *ai = dev->ml_priv;
2224 StatsRid stats_rid; 2226 StatsRid stats_rid;
2225 __le32 *vals = stats_rid.vals; 2227 __le32 *vals = stats_rid.vals;
2226 2228
@@ -2254,7 +2256,7 @@ static void airo_read_stats(struct net_device *dev)
2254 2256
2255static struct net_device_stats *airo_get_stats(struct net_device *dev) 2257static struct net_device_stats *airo_get_stats(struct net_device *dev)
2256{ 2258{
2257 struct airo_info *local = dev->priv; 2259 struct airo_info *local = dev->ml_priv;
2258 2260
2259 if (!test_bit(JOB_STATS, &local->jobs)) { 2261 if (!test_bit(JOB_STATS, &local->jobs)) {
2260 /* Get stats out of the card if available */ 2262 /* Get stats out of the card if available */
@@ -2281,7 +2283,7 @@ static void airo_set_promisc(struct airo_info *ai) {
2281} 2283}
2282 2284
2283static void airo_set_multicast_list(struct net_device *dev) { 2285static void airo_set_multicast_list(struct net_device *dev) {
2284 struct airo_info *ai = dev->priv; 2286 struct airo_info *ai = dev->ml_priv;
2285 2287
2286 if ((dev->flags ^ ai->flags) & IFF_PROMISC) { 2288 if ((dev->flags ^ ai->flags) & IFF_PROMISC) {
2287 change_bit(FLAG_PROMISC, &ai->flags); 2289 change_bit(FLAG_PROMISC, &ai->flags);
@@ -2299,7 +2301,7 @@ static void airo_set_multicast_list(struct net_device *dev) {
2299 2301
2300static int airo_set_mac_address(struct net_device *dev, void *p) 2302static int airo_set_mac_address(struct net_device *dev, void *p)
2301{ 2303{
2302 struct airo_info *ai = dev->priv; 2304 struct airo_info *ai = dev->ml_priv;
2303 struct sockaddr *addr = p; 2305 struct sockaddr *addr = p;
2304 2306
2305 readConfigRid(ai, 1); 2307 readConfigRid(ai, 1);
@@ -2339,7 +2341,7 @@ static void del_airo_dev(struct airo_info *ai)
2339} 2341}
2340 2342
2341static int airo_close(struct net_device *dev) { 2343static int airo_close(struct net_device *dev) {
2342 struct airo_info *ai = dev->priv; 2344 struct airo_info *ai = dev->ml_priv;
2343 2345
2344 netif_stop_queue(dev); 2346 netif_stop_queue(dev);
2345 2347
@@ -2365,7 +2367,7 @@ static int airo_close(struct net_device *dev) {
2365 2367
2366void stop_airo_card( struct net_device *dev, int freeres ) 2368void stop_airo_card( struct net_device *dev, int freeres )
2367{ 2369{
2368 struct airo_info *ai = dev->priv; 2370 struct airo_info *ai = dev->ml_priv;
2369 2371
2370 set_bit(FLAG_RADIO_DOWN, &ai->flags); 2372 set_bit(FLAG_RADIO_DOWN, &ai->flags);
2371 disable_MAC(ai, 1); 2373 disable_MAC(ai, 1);
@@ -2665,7 +2667,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
2665 struct net_device *dev = alloc_netdev(0, "wifi%d", wifi_setup); 2667 struct net_device *dev = alloc_netdev(0, "wifi%d", wifi_setup);
2666 if (!dev) 2668 if (!dev)
2667 return NULL; 2669 return NULL;
2668 dev->priv = ethdev->priv; 2670 dev->ml_priv = ethdev->ml_priv;
2669 dev->irq = ethdev->irq; 2671 dev->irq = ethdev->irq;
2670 dev->base_addr = ethdev->base_addr; 2672 dev->base_addr = ethdev->base_addr;
2671 dev->wireless_data = ethdev->wireless_data; 2673 dev->wireless_data = ethdev->wireless_data;
@@ -2680,7 +2682,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
2680} 2682}
2681 2683
2682static int reset_card( struct net_device *dev , int lock) { 2684static int reset_card( struct net_device *dev , int lock) {
2683 struct airo_info *ai = dev->priv; 2685 struct airo_info *ai = dev->ml_priv;
2684 2686
2685 if (lock && down_interruptible(&ai->sem)) 2687 if (lock && down_interruptible(&ai->sem))
2686 return -1; 2688 return -1;
@@ -2757,7 +2759,6 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2757 struct net_device *dev; 2759 struct net_device *dev;
2758 struct airo_info *ai; 2760 struct airo_info *ai;
2759 int i, rc; 2761 int i, rc;
2760 DECLARE_MAC_BUF(mac);
2761 2762
2762 /* Create the network device object. */ 2763 /* Create the network device object. */
2763 dev = alloc_netdev(sizeof(*ai), "", ether_setup); 2764 dev = alloc_netdev(sizeof(*ai), "", ether_setup);
@@ -2766,7 +2767,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2766 return NULL; 2767 return NULL;
2767 } 2768 }
2768 2769
2769 ai = dev->priv; 2770 ai = dev->ml_priv = netdev_priv(dev);
2770 ai->wifidev = NULL; 2771 ai->wifidev = NULL;
2771 ai->flags = 1 << FLAG_RADIO_DOWN; 2772 ai->flags = 1 << FLAG_RADIO_DOWN;
2772 ai->jobs = 0; 2773 ai->jobs = 0;
@@ -2860,15 +2861,14 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2860 goto err_out_reg; 2861 goto err_out_reg;
2861 2862
2862 set_bit(FLAG_REGISTERED,&ai->flags); 2863 set_bit(FLAG_REGISTERED,&ai->flags);
2863 airo_print_info(dev->name, "MAC enabled %s", 2864 airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr);
2864 print_mac(mac, dev->dev_addr));
2865 2865
2866 /* Allocate the transmit buffers */ 2866 /* Allocate the transmit buffers */
2867 if (probe && !test_bit(FLAG_MPI,&ai->flags)) 2867 if (probe && !test_bit(FLAG_MPI,&ai->flags))
2868 for( i = 0; i < MAX_FIDS; i++ ) 2868 for( i = 0; i < MAX_FIDS; i++ )
2869 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); 2869 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
2870 2870
2871 if (setup_proc_entry(dev, dev->priv) < 0) 2871 if (setup_proc_entry(dev, dev->ml_priv) < 0)
2872 goto err_out_wifi; 2872 goto err_out_wifi;
2873 2873
2874 return dev; 2874 return dev;
@@ -2917,8 +2917,7 @@ static int waitbusy (struct airo_info *ai) {
2917int reset_airo_card( struct net_device *dev ) 2917int reset_airo_card( struct net_device *dev )
2918{ 2918{
2919 int i; 2919 int i;
2920 struct airo_info *ai = dev->priv; 2920 struct airo_info *ai = dev->ml_priv;
2921 DECLARE_MAC_BUF(mac);
2922 2921
2923 if (reset_card (dev, 1)) 2922 if (reset_card (dev, 1))
2924 return -1; 2923 return -1;
@@ -2927,8 +2926,7 @@ int reset_airo_card( struct net_device *dev )
2927 airo_print_err(dev->name, "MAC could not be enabled"); 2926 airo_print_err(dev->name, "MAC could not be enabled");
2928 return -1; 2927 return -1;
2929 } 2928 }
2930 airo_print_info(dev->name, "MAC enabled %s", 2929 airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr);
2931 print_mac(mac, dev->dev_addr));
2932 /* Allocate the transmit buffers if needed */ 2930 /* Allocate the transmit buffers if needed */
2933 if (!test_bit(FLAG_MPI,&ai->flags)) 2931 if (!test_bit(FLAG_MPI,&ai->flags))
2934 for( i = 0; i < MAX_FIDS; i++ ) 2932 for( i = 0; i < MAX_FIDS; i++ )
@@ -2942,7 +2940,7 @@ int reset_airo_card( struct net_device *dev )
2942EXPORT_SYMBOL(reset_airo_card); 2940EXPORT_SYMBOL(reset_airo_card);
2943 2941
2944static void airo_send_event(struct net_device *dev) { 2942static void airo_send_event(struct net_device *dev) {
2945 struct airo_info *ai = dev->priv; 2943 struct airo_info *ai = dev->ml_priv;
2946 union iwreq_data wrqu; 2944 union iwreq_data wrqu;
2947 StatusRid status_rid; 2945 StatusRid status_rid;
2948 2946
@@ -3019,7 +3017,7 @@ out:
3019 3017
3020static int airo_thread(void *data) { 3018static int airo_thread(void *data) {
3021 struct net_device *dev = data; 3019 struct net_device *dev = data;
3022 struct airo_info *ai = dev->priv; 3020 struct airo_info *ai = dev->ml_priv;
3023 int locked; 3021 int locked;
3024 3022
3025 set_freezable(); 3023 set_freezable();
@@ -3134,7 +3132,7 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
3134 struct net_device *dev = dev_id; 3132 struct net_device *dev = dev_id;
3135 u16 status; 3133 u16 status;
3136 u16 fid; 3134 u16 fid;
3137 struct airo_info *apriv = dev->priv; 3135 struct airo_info *apriv = dev->ml_priv;
3138 u16 savedInterrupts = 0; 3136 u16 savedInterrupts = 0;
3139 int handled = 0; 3137 int handled = 0;
3140 3138
@@ -3369,7 +3367,6 @@ badrx:
3369 skb->protocol = htons(ETH_P_802_2); 3367 skb->protocol = htons(ETH_P_802_2);
3370 } else 3368 } else
3371 skb->protocol = eth_type_trans(skb,dev); 3369 skb->protocol = eth_type_trans(skb,dev);
3372 skb->dev->last_rx = jiffies;
3373 skb->ip_summed = CHECKSUM_NONE; 3370 skb->ip_summed = CHECKSUM_NONE;
3374 3371
3375 netif_rx( skb ); 3372 netif_rx( skb );
@@ -3599,7 +3596,6 @@ badmic:
3599 3596
3600 skb->ip_summed = CHECKSUM_NONE; 3597 skb->ip_summed = CHECKSUM_NONE;
3601 skb->protocol = eth_type_trans(skb, ai->dev); 3598 skb->protocol = eth_type_trans(skb, ai->dev);
3602 skb->dev->last_rx = jiffies;
3603 netif_rx(skb); 3599 netif_rx(skb);
3604 } 3600 }
3605badrx: 3601badrx:
@@ -3693,7 +3689,6 @@ void mpi_receive_802_11 (struct airo_info *ai)
3693 skb->pkt_type = PACKET_OTHERHOST; 3689 skb->pkt_type = PACKET_OTHERHOST;
3694 skb->dev = ai->wifidev; 3690 skb->dev = ai->wifidev;
3695 skb->protocol = htons(ETH_P_802_2); 3691 skb->protocol = htons(ETH_P_802_2);
3696 skb->dev->last_rx = jiffies;
3697 skb->ip_summed = CHECKSUM_NONE; 3692 skb->ip_summed = CHECKSUM_NONE;
3698 netif_rx( skb ); 3693 netif_rx( skb );
3699badrx: 3694badrx:
@@ -4604,7 +4599,7 @@ static int proc_status_open(struct inode *inode, struct file *file)
4604 struct proc_data *data; 4599 struct proc_data *data;
4605 struct proc_dir_entry *dp = PDE(inode); 4600 struct proc_dir_entry *dp = PDE(inode);
4606 struct net_device *dev = dp->data; 4601 struct net_device *dev = dp->data;
4607 struct airo_info *apriv = dev->priv; 4602 struct airo_info *apriv = dev->ml_priv;
4608 CapabilityRid cap_rid; 4603 CapabilityRid cap_rid;
4609 StatusRid status_rid; 4604 StatusRid status_rid;
4610 u16 mode; 4605 u16 mode;
@@ -4687,7 +4682,7 @@ static int proc_stats_rid_open( struct inode *inode,
4687 struct proc_data *data; 4682 struct proc_data *data;
4688 struct proc_dir_entry *dp = PDE(inode); 4683 struct proc_dir_entry *dp = PDE(inode);
4689 struct net_device *dev = dp->data; 4684 struct net_device *dev = dp->data;
4690 struct airo_info *apriv = dev->priv; 4685 struct airo_info *apriv = dev->ml_priv;
4691 StatsRid stats; 4686 StatsRid stats;
4692 int i, j; 4687 int i, j;
4693 __le32 *vals = stats.vals; 4688 __le32 *vals = stats.vals;
@@ -4750,7 +4745,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
4750 struct proc_data *data = file->private_data; 4745 struct proc_data *data = file->private_data;
4751 struct proc_dir_entry *dp = PDE(inode); 4746 struct proc_dir_entry *dp = PDE(inode);
4752 struct net_device *dev = dp->data; 4747 struct net_device *dev = dp->data;
4753 struct airo_info *ai = dev->priv; 4748 struct airo_info *ai = dev->ml_priv;
4754 char *line; 4749 char *line;
4755 4750
4756 if ( !data->writelen ) return; 4751 if ( !data->writelen ) return;
@@ -4962,7 +4957,7 @@ static int proc_config_open(struct inode *inode, struct file *file)
4962 struct proc_data *data; 4957 struct proc_data *data;
4963 struct proc_dir_entry *dp = PDE(inode); 4958 struct proc_dir_entry *dp = PDE(inode);
4964 struct net_device *dev = dp->data; 4959 struct net_device *dev = dp->data;
4965 struct airo_info *ai = dev->priv; 4960 struct airo_info *ai = dev->ml_priv;
4966 int i; 4961 int i;
4967 __le16 mode; 4962 __le16 mode;
4968 4963
@@ -5053,7 +5048,7 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file)
5053 struct proc_data *data = (struct proc_data *)file->private_data; 5048 struct proc_data *data = (struct proc_data *)file->private_data;
5054 struct proc_dir_entry *dp = PDE(inode); 5049 struct proc_dir_entry *dp = PDE(inode);
5055 struct net_device *dev = dp->data; 5050 struct net_device *dev = dp->data;
5056 struct airo_info *ai = dev->priv; 5051 struct airo_info *ai = dev->ml_priv;
5057 SsidRid SSID_rid; 5052 SsidRid SSID_rid;
5058 int i; 5053 int i;
5059 char *p = data->wbuffer; 5054 char *p = data->wbuffer;
@@ -5096,7 +5091,7 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) {
5096 struct proc_data *data = (struct proc_data *)file->private_data; 5091 struct proc_data *data = (struct proc_data *)file->private_data;
5097 struct proc_dir_entry *dp = PDE(inode); 5092 struct proc_dir_entry *dp = PDE(inode);
5098 struct net_device *dev = dp->data; 5093 struct net_device *dev = dp->data;
5099 struct airo_info *ai = dev->priv; 5094 struct airo_info *ai = dev->ml_priv;
5100 APListRid APList_rid; 5095 APListRid APList_rid;
5101 int i; 5096 int i;
5102 5097
@@ -5191,7 +5186,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
5191 struct proc_data *data; 5186 struct proc_data *data;
5192 struct proc_dir_entry *dp = PDE(inode); 5187 struct proc_dir_entry *dp = PDE(inode);
5193 struct net_device *dev = dp->data; 5188 struct net_device *dev = dp->data;
5194 struct airo_info *ai = dev->priv; 5189 struct airo_info *ai = dev->ml_priv;
5195 int i; 5190 int i;
5196 char key[16]; 5191 char key[16];
5197 u16 index = 0; 5192 u16 index = 0;
@@ -5233,7 +5228,7 @@ static int proc_wepkey_open( struct inode *inode, struct file *file )
5233 struct proc_data *data; 5228 struct proc_data *data;
5234 struct proc_dir_entry *dp = PDE(inode); 5229 struct proc_dir_entry *dp = PDE(inode);
5235 struct net_device *dev = dp->data; 5230 struct net_device *dev = dp->data;
5236 struct airo_info *ai = dev->priv; 5231 struct airo_info *ai = dev->ml_priv;
5237 char *ptr; 5232 char *ptr;
5238 WepKeyRid wkr; 5233 WepKeyRid wkr;
5239 __le16 lastindex; 5234 __le16 lastindex;
@@ -5282,7 +5277,7 @@ static int proc_SSID_open(struct inode *inode, struct file *file)
5282 struct proc_data *data; 5277 struct proc_data *data;
5283 struct proc_dir_entry *dp = PDE(inode); 5278 struct proc_dir_entry *dp = PDE(inode);
5284 struct net_device *dev = dp->data; 5279 struct net_device *dev = dp->data;
5285 struct airo_info *ai = dev->priv; 5280 struct airo_info *ai = dev->ml_priv;
5286 int i; 5281 int i;
5287 char *ptr; 5282 char *ptr;
5288 SsidRid SSID_rid; 5283 SsidRid SSID_rid;
@@ -5326,11 +5321,10 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
5326 struct proc_data *data; 5321 struct proc_data *data;
5327 struct proc_dir_entry *dp = PDE(inode); 5322 struct proc_dir_entry *dp = PDE(inode);
5328 struct net_device *dev = dp->data; 5323 struct net_device *dev = dp->data;
5329 struct airo_info *ai = dev->priv; 5324 struct airo_info *ai = dev->ml_priv;
5330 int i; 5325 int i;
5331 char *ptr; 5326 char *ptr;
5332 APListRid APList_rid; 5327 APListRid APList_rid;
5333 DECLARE_MAC_BUF(mac);
5334 5328
5335 if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) 5329 if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5336 return -ENOMEM; 5330 return -ENOMEM;
@@ -5354,8 +5348,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
5354// We end when we find a zero MAC 5348// We end when we find a zero MAC
5355 if ( !*(int*)APList_rid.ap[i] && 5349 if ( !*(int*)APList_rid.ap[i] &&
5356 !*(int*)&APList_rid.ap[i][2]) break; 5350 !*(int*)&APList_rid.ap[i][2]) break;
5357 ptr += sprintf(ptr, "%s\n", 5351 ptr += sprintf(ptr, "%pM\n", APList_rid.ap[i]);
5358 print_mac(mac, APList_rid.ap[i]));
5359 } 5352 }
5360 if (i==0) ptr += sprintf(ptr, "Not using specific APs\n"); 5353 if (i==0) ptr += sprintf(ptr, "Not using specific APs\n");
5361 5354
@@ -5368,13 +5361,12 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
5368 struct proc_data *data; 5361 struct proc_data *data;
5369 struct proc_dir_entry *dp = PDE(inode); 5362 struct proc_dir_entry *dp = PDE(inode);
5370 struct net_device *dev = dp->data; 5363 struct net_device *dev = dp->data;
5371 struct airo_info *ai = dev->priv; 5364 struct airo_info *ai = dev->ml_priv;
5372 char *ptr; 5365 char *ptr;
5373 BSSListRid BSSList_rid; 5366 BSSListRid BSSList_rid;
5374 int rc; 5367 int rc;
5375 /* If doLoseSync is not 1, we won't do a Lose Sync */ 5368 /* If doLoseSync is not 1, we won't do a Lose Sync */
5376 int doLoseSync = -1; 5369 int doLoseSync = -1;
5377 DECLARE_MAC_BUF(mac);
5378 5370
5379 if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) 5371 if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5380 return -ENOMEM; 5372 return -ENOMEM;
@@ -5411,8 +5403,8 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
5411 we have to add a spin lock... */ 5403 we have to add a spin lock... */
5412 rc = readBSSListRid(ai, doLoseSync, &BSSList_rid); 5404 rc = readBSSListRid(ai, doLoseSync, &BSSList_rid);
5413 while(rc == 0 && BSSList_rid.index != cpu_to_le16(0xffff)) { 5405 while(rc == 0 && BSSList_rid.index != cpu_to_le16(0xffff)) {
5414 ptr += sprintf(ptr, "%s %*s rssi = %d", 5406 ptr += sprintf(ptr, "%pM %*s rssi = %d",
5415 print_mac(mac, BSSList_rid.bssid), 5407 BSSList_rid.bssid,
5416 (int)BSSList_rid.ssidLen, 5408 (int)BSSList_rid.ssidLen,
5417 BSSList_rid.ssid, 5409 BSSList_rid.ssid,
5418 le16_to_cpu(BSSList_rid.dBm)); 5410 le16_to_cpu(BSSList_rid.dBm));
@@ -5447,7 +5439,7 @@ static int proc_close( struct inode *inode, struct file *file )
5447 associated we will check every minute to see if anything has 5439 associated we will check every minute to see if anything has
5448 changed. */ 5440 changed. */
5449static void timer_func( struct net_device *dev ) { 5441static void timer_func( struct net_device *dev ) {
5450 struct airo_info *apriv = dev->priv; 5442 struct airo_info *apriv = dev->ml_priv;
5451 5443
5452/* We don't have a link so try changing the authtype */ 5444/* We don't have a link so try changing the authtype */
5453 readConfigRid(apriv, 0); 5445 readConfigRid(apriv, 0);
@@ -5518,7 +5510,7 @@ static void __devexit airo_pci_remove(struct pci_dev *pdev)
5518static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) 5510static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
5519{ 5511{
5520 struct net_device *dev = pci_get_drvdata(pdev); 5512 struct net_device *dev = pci_get_drvdata(pdev);
5521 struct airo_info *ai = dev->priv; 5513 struct airo_info *ai = dev->ml_priv;
5522 Cmd cmd; 5514 Cmd cmd;
5523 Resp rsp; 5515 Resp rsp;
5524 5516
@@ -5550,7 +5542,7 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
5550static int airo_pci_resume(struct pci_dev *pdev) 5542static int airo_pci_resume(struct pci_dev *pdev)
5551{ 5543{
5552 struct net_device *dev = pci_get_drvdata(pdev); 5544 struct net_device *dev = pci_get_drvdata(pdev);
5553 struct airo_info *ai = dev->priv; 5545 struct airo_info *ai = dev->ml_priv;
5554 pci_power_t prev_state = pdev->current_state; 5546 pci_power_t prev_state = pdev->current_state;
5555 5547
5556 pci_set_power_state(pdev, PCI_D0); 5548 pci_set_power_state(pdev, PCI_D0);
@@ -5729,7 +5721,7 @@ static int airo_set_freq(struct net_device *dev,
5729 struct iw_freq *fwrq, 5721 struct iw_freq *fwrq,
5730 char *extra) 5722 char *extra)
5731{ 5723{
5732 struct airo_info *local = dev->priv; 5724 struct airo_info *local = dev->ml_priv;
5733 int rc = -EINPROGRESS; /* Call commit handler */ 5725 int rc = -EINPROGRESS; /* Call commit handler */
5734 5726
5735 /* If setting by frequency, convert to a channel */ 5727 /* If setting by frequency, convert to a channel */
@@ -5774,7 +5766,7 @@ static int airo_get_freq(struct net_device *dev,
5774 struct iw_freq *fwrq, 5766 struct iw_freq *fwrq,
5775 char *extra) 5767 char *extra)
5776{ 5768{
5777 struct airo_info *local = dev->priv; 5769 struct airo_info *local = dev->ml_priv;
5778 StatusRid status_rid; /* Card status info */ 5770 StatusRid status_rid; /* Card status info */
5779 int ch; 5771 int ch;
5780 5772
@@ -5805,7 +5797,7 @@ static int airo_set_essid(struct net_device *dev,
5805 struct iw_point *dwrq, 5797 struct iw_point *dwrq,
5806 char *extra) 5798 char *extra)
5807{ 5799{
5808 struct airo_info *local = dev->priv; 5800 struct airo_info *local = dev->ml_priv;
5809 SsidRid SSID_rid; /* SSIDs */ 5801 SsidRid SSID_rid; /* SSIDs */
5810 5802
5811 /* Reload the list of current SSID */ 5803 /* Reload the list of current SSID */
@@ -5851,7 +5843,7 @@ static int airo_get_essid(struct net_device *dev,
5851 struct iw_point *dwrq, 5843 struct iw_point *dwrq,
5852 char *extra) 5844 char *extra)
5853{ 5845{
5854 struct airo_info *local = dev->priv; 5846 struct airo_info *local = dev->ml_priv;
5855 StatusRid status_rid; /* Card status info */ 5847 StatusRid status_rid; /* Card status info */
5856 5848
5857 readStatusRid(local, &status_rid, 1); 5849 readStatusRid(local, &status_rid, 1);
@@ -5879,7 +5871,7 @@ static int airo_set_wap(struct net_device *dev,
5879 struct sockaddr *awrq, 5871 struct sockaddr *awrq,
5880 char *extra) 5872 char *extra)
5881{ 5873{
5882 struct airo_info *local = dev->priv; 5874 struct airo_info *local = dev->ml_priv;
5883 Cmd cmd; 5875 Cmd cmd;
5884 Resp rsp; 5876 Resp rsp;
5885 APListRid APList_rid; 5877 APListRid APList_rid;
@@ -5916,7 +5908,7 @@ static int airo_get_wap(struct net_device *dev,
5916 struct sockaddr *awrq, 5908 struct sockaddr *awrq,
5917 char *extra) 5909 char *extra)
5918{ 5910{
5919 struct airo_info *local = dev->priv; 5911 struct airo_info *local = dev->ml_priv;
5920 StatusRid status_rid; /* Card status info */ 5912 StatusRid status_rid; /* Card status info */
5921 5913
5922 readStatusRid(local, &status_rid, 1); 5914 readStatusRid(local, &status_rid, 1);
@@ -5937,7 +5929,7 @@ static int airo_set_nick(struct net_device *dev,
5937 struct iw_point *dwrq, 5929 struct iw_point *dwrq,
5938 char *extra) 5930 char *extra)
5939{ 5931{
5940 struct airo_info *local = dev->priv; 5932 struct airo_info *local = dev->ml_priv;
5941 5933
5942 /* Check the size of the string */ 5934 /* Check the size of the string */
5943 if(dwrq->length > 16) { 5935 if(dwrq->length > 16) {
@@ -5960,7 +5952,7 @@ static int airo_get_nick(struct net_device *dev,
5960 struct iw_point *dwrq, 5952 struct iw_point *dwrq,
5961 char *extra) 5953 char *extra)
5962{ 5954{
5963 struct airo_info *local = dev->priv; 5955 struct airo_info *local = dev->ml_priv;
5964 5956
5965 readConfigRid(local, 1); 5957 readConfigRid(local, 1);
5966 strncpy(extra, local->config.nodeName, 16); 5958 strncpy(extra, local->config.nodeName, 16);
@@ -5979,7 +5971,7 @@ static int airo_set_rate(struct net_device *dev,
5979 struct iw_param *vwrq, 5971 struct iw_param *vwrq,
5980 char *extra) 5972 char *extra)
5981{ 5973{
5982 struct airo_info *local = dev->priv; 5974 struct airo_info *local = dev->ml_priv;
5983 CapabilityRid cap_rid; /* Card capability info */ 5975 CapabilityRid cap_rid; /* Card capability info */
5984 u8 brate = 0; 5976 u8 brate = 0;
5985 int i; 5977 int i;
@@ -6049,7 +6041,7 @@ static int airo_get_rate(struct net_device *dev,
6049 struct iw_param *vwrq, 6041 struct iw_param *vwrq,
6050 char *extra) 6042 char *extra)
6051{ 6043{
6052 struct airo_info *local = dev->priv; 6044 struct airo_info *local = dev->ml_priv;
6053 StatusRid status_rid; /* Card status info */ 6045 StatusRid status_rid; /* Card status info */
6054 6046
6055 readStatusRid(local, &status_rid, 1); 6047 readStatusRid(local, &status_rid, 1);
@@ -6071,7 +6063,7 @@ static int airo_set_rts(struct net_device *dev,
6071 struct iw_param *vwrq, 6063 struct iw_param *vwrq,
6072 char *extra) 6064 char *extra)
6073{ 6065{
6074 struct airo_info *local = dev->priv; 6066 struct airo_info *local = dev->ml_priv;
6075 int rthr = vwrq->value; 6067 int rthr = vwrq->value;
6076 6068
6077 if(vwrq->disabled) 6069 if(vwrq->disabled)
@@ -6095,7 +6087,7 @@ static int airo_get_rts(struct net_device *dev,
6095 struct iw_param *vwrq, 6087 struct iw_param *vwrq,
6096 char *extra) 6088 char *extra)
6097{ 6089{
6098 struct airo_info *local = dev->priv; 6090 struct airo_info *local = dev->ml_priv;
6099 6091
6100 readConfigRid(local, 1); 6092 readConfigRid(local, 1);
6101 vwrq->value = le16_to_cpu(local->config.rtsThres); 6093 vwrq->value = le16_to_cpu(local->config.rtsThres);
@@ -6114,7 +6106,7 @@ static int airo_set_frag(struct net_device *dev,
6114 struct iw_param *vwrq, 6106 struct iw_param *vwrq,
6115 char *extra) 6107 char *extra)
6116{ 6108{
6117 struct airo_info *local = dev->priv; 6109 struct airo_info *local = dev->ml_priv;
6118 int fthr = vwrq->value; 6110 int fthr = vwrq->value;
6119 6111
6120 if(vwrq->disabled) 6112 if(vwrq->disabled)
@@ -6139,7 +6131,7 @@ static int airo_get_frag(struct net_device *dev,
6139 struct iw_param *vwrq, 6131 struct iw_param *vwrq,
6140 char *extra) 6132 char *extra)
6141{ 6133{
6142 struct airo_info *local = dev->priv; 6134 struct airo_info *local = dev->ml_priv;
6143 6135
6144 readConfigRid(local, 1); 6136 readConfigRid(local, 1);
6145 vwrq->value = le16_to_cpu(local->config.fragThresh); 6137 vwrq->value = le16_to_cpu(local->config.fragThresh);
@@ -6158,7 +6150,7 @@ static int airo_set_mode(struct net_device *dev,
6158 __u32 *uwrq, 6150 __u32 *uwrq,
6159 char *extra) 6151 char *extra)
6160{ 6152{
6161 struct airo_info *local = dev->priv; 6153 struct airo_info *local = dev->ml_priv;
6162 int reset = 0; 6154 int reset = 0;
6163 6155
6164 readConfigRid(local, 1); 6156 readConfigRid(local, 1);
@@ -6221,7 +6213,7 @@ static int airo_get_mode(struct net_device *dev,
6221 __u32 *uwrq, 6213 __u32 *uwrq,
6222 char *extra) 6214 char *extra)
6223{ 6215{
6224 struct airo_info *local = dev->priv; 6216 struct airo_info *local = dev->ml_priv;
6225 6217
6226 readConfigRid(local, 1); 6218 readConfigRid(local, 1);
6227 /* If not managed, assume it's ad-hoc */ 6219 /* If not managed, assume it's ad-hoc */
@@ -6258,7 +6250,7 @@ static int airo_set_encode(struct net_device *dev,
6258 struct iw_point *dwrq, 6250 struct iw_point *dwrq,
6259 char *extra) 6251 char *extra)
6260{ 6252{
6261 struct airo_info *local = dev->priv; 6253 struct airo_info *local = dev->ml_priv;
6262 CapabilityRid cap_rid; /* Card capability info */ 6254 CapabilityRid cap_rid; /* Card capability info */
6263 int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 ); 6255 int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 );
6264 __le16 currentAuthType = local->config.authType; 6256 __le16 currentAuthType = local->config.authType;
@@ -6345,7 +6337,7 @@ static int airo_get_encode(struct net_device *dev,
6345 struct iw_point *dwrq, 6337 struct iw_point *dwrq,
6346 char *extra) 6338 char *extra)
6347{ 6339{
6348 struct airo_info *local = dev->priv; 6340 struct airo_info *local = dev->ml_priv;
6349 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 6341 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
6350 CapabilityRid cap_rid; /* Card capability info */ 6342 CapabilityRid cap_rid; /* Card capability info */
6351 6343
@@ -6393,7 +6385,7 @@ static int airo_set_encodeext(struct net_device *dev,
6393 union iwreq_data *wrqu, 6385 union iwreq_data *wrqu,
6394 char *extra) 6386 char *extra)
6395{ 6387{
6396 struct airo_info *local = dev->priv; 6388 struct airo_info *local = dev->ml_priv;
6397 struct iw_point *encoding = &wrqu->encoding; 6389 struct iw_point *encoding = &wrqu->encoding;
6398 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 6390 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6399 CapabilityRid cap_rid; /* Card capability info */ 6391 CapabilityRid cap_rid; /* Card capability info */
@@ -6479,7 +6471,7 @@ static int airo_get_encodeext(struct net_device *dev,
6479 union iwreq_data *wrqu, 6471 union iwreq_data *wrqu,
6480 char *extra) 6472 char *extra)
6481{ 6473{
6482 struct airo_info *local = dev->priv; 6474 struct airo_info *local = dev->ml_priv;
6483 struct iw_point *encoding = &wrqu->encoding; 6475 struct iw_point *encoding = &wrqu->encoding;
6484 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 6476 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6485 CapabilityRid cap_rid; /* Card capability info */ 6477 CapabilityRid cap_rid; /* Card capability info */
@@ -6542,7 +6534,7 @@ static int airo_set_auth(struct net_device *dev,
6542 struct iw_request_info *info, 6534 struct iw_request_info *info,
6543 union iwreq_data *wrqu, char *extra) 6535 union iwreq_data *wrqu, char *extra)
6544{ 6536{
6545 struct airo_info *local = dev->priv; 6537 struct airo_info *local = dev->ml_priv;
6546 struct iw_param *param = &wrqu->param; 6538 struct iw_param *param = &wrqu->param;
6547 __le16 currentAuthType = local->config.authType; 6539 __le16 currentAuthType = local->config.authType;
6548 6540
@@ -6610,7 +6602,7 @@ static int airo_get_auth(struct net_device *dev,
6610 struct iw_request_info *info, 6602 struct iw_request_info *info,
6611 union iwreq_data *wrqu, char *extra) 6603 union iwreq_data *wrqu, char *extra)
6612{ 6604{
6613 struct airo_info *local = dev->priv; 6605 struct airo_info *local = dev->ml_priv;
6614 struct iw_param *param = &wrqu->param; 6606 struct iw_param *param = &wrqu->param;
6615 __le16 currentAuthType = local->config.authType; 6607 __le16 currentAuthType = local->config.authType;
6616 6608
@@ -6659,7 +6651,7 @@ static int airo_set_txpow(struct net_device *dev,
6659 struct iw_param *vwrq, 6651 struct iw_param *vwrq,
6660 char *extra) 6652 char *extra)
6661{ 6653{
6662 struct airo_info *local = dev->priv; 6654 struct airo_info *local = dev->ml_priv;
6663 CapabilityRid cap_rid; /* Card capability info */ 6655 CapabilityRid cap_rid; /* Card capability info */
6664 int i; 6656 int i;
6665 int rc = -EINVAL; 6657 int rc = -EINVAL;
@@ -6696,7 +6688,7 @@ static int airo_get_txpow(struct net_device *dev,
6696 struct iw_param *vwrq, 6688 struct iw_param *vwrq,
6697 char *extra) 6689 char *extra)
6698{ 6690{
6699 struct airo_info *local = dev->priv; 6691 struct airo_info *local = dev->ml_priv;
6700 6692
6701 readConfigRid(local, 1); 6693 readConfigRid(local, 1);
6702 vwrq->value = le16_to_cpu(local->config.txPower); 6694 vwrq->value = le16_to_cpu(local->config.txPower);
@@ -6716,7 +6708,7 @@ static int airo_set_retry(struct net_device *dev,
6716 struct iw_param *vwrq, 6708 struct iw_param *vwrq,
6717 char *extra) 6709 char *extra)
6718{ 6710{
6719 struct airo_info *local = dev->priv; 6711 struct airo_info *local = dev->ml_priv;
6720 int rc = -EINVAL; 6712 int rc = -EINVAL;
6721 6713
6722 if(vwrq->disabled) { 6714 if(vwrq->disabled) {
@@ -6754,7 +6746,7 @@ static int airo_get_retry(struct net_device *dev,
6754 struct iw_param *vwrq, 6746 struct iw_param *vwrq,
6755 char *extra) 6747 char *extra)
6756{ 6748{
6757 struct airo_info *local = dev->priv; 6749 struct airo_info *local = dev->ml_priv;
6758 6750
6759 vwrq->disabled = 0; /* Can't be disabled */ 6751 vwrq->disabled = 0; /* Can't be disabled */
6760 6752
@@ -6785,7 +6777,7 @@ static int airo_get_range(struct net_device *dev,
6785 struct iw_point *dwrq, 6777 struct iw_point *dwrq,
6786 char *extra) 6778 char *extra)
6787{ 6779{
6788 struct airo_info *local = dev->priv; 6780 struct airo_info *local = dev->ml_priv;
6789 struct iw_range *range = (struct iw_range *) extra; 6781 struct iw_range *range = (struct iw_range *) extra;
6790 CapabilityRid cap_rid; /* Card capability info */ 6782 CapabilityRid cap_rid; /* Card capability info */
6791 int i; 6783 int i;
@@ -6910,7 +6902,7 @@ static int airo_set_power(struct net_device *dev,
6910 struct iw_param *vwrq, 6902 struct iw_param *vwrq,
6911 char *extra) 6903 char *extra)
6912{ 6904{
6913 struct airo_info *local = dev->priv; 6905 struct airo_info *local = dev->ml_priv;
6914 6906
6915 readConfigRid(local, 1); 6907 readConfigRid(local, 1);
6916 if (vwrq->disabled) { 6908 if (vwrq->disabled) {
@@ -6967,7 +6959,7 @@ static int airo_get_power(struct net_device *dev,
6967 struct iw_param *vwrq, 6959 struct iw_param *vwrq,
6968 char *extra) 6960 char *extra)
6969{ 6961{
6970 struct airo_info *local = dev->priv; 6962 struct airo_info *local = dev->ml_priv;
6971 __le16 mode; 6963 __le16 mode;
6972 6964
6973 readConfigRid(local, 1); 6965 readConfigRid(local, 1);
@@ -6998,7 +6990,7 @@ static int airo_set_sens(struct net_device *dev,
6998 struct iw_param *vwrq, 6990 struct iw_param *vwrq,
6999 char *extra) 6991 char *extra)
7000{ 6992{
7001 struct airo_info *local = dev->priv; 6993 struct airo_info *local = dev->ml_priv;
7002 6994
7003 readConfigRid(local, 1); 6995 readConfigRid(local, 1);
7004 local->config.rssiThreshold = 6996 local->config.rssiThreshold =
@@ -7017,7 +7009,7 @@ static int airo_get_sens(struct net_device *dev,
7017 struct iw_param *vwrq, 7009 struct iw_param *vwrq,
7018 char *extra) 7010 char *extra)
7019{ 7011{
7020 struct airo_info *local = dev->priv; 7012 struct airo_info *local = dev->ml_priv;
7021 7013
7022 readConfigRid(local, 1); 7014 readConfigRid(local, 1);
7023 vwrq->value = le16_to_cpu(local->config.rssiThreshold); 7015 vwrq->value = le16_to_cpu(local->config.rssiThreshold);
@@ -7037,7 +7029,7 @@ static int airo_get_aplist(struct net_device *dev,
7037 struct iw_point *dwrq, 7029 struct iw_point *dwrq,
7038 char *extra) 7030 char *extra)
7039{ 7031{
7040 struct airo_info *local = dev->priv; 7032 struct airo_info *local = dev->ml_priv;
7041 struct sockaddr *address = (struct sockaddr *) extra; 7033 struct sockaddr *address = (struct sockaddr *) extra;
7042 struct iw_quality qual[IW_MAX_AP]; 7034 struct iw_quality qual[IW_MAX_AP];
7043 BSSListRid BSSList; 7035 BSSListRid BSSList;
@@ -7110,7 +7102,7 @@ static int airo_set_scan(struct net_device *dev,
7110 struct iw_point *dwrq, 7102 struct iw_point *dwrq,
7111 char *extra) 7103 char *extra)
7112{ 7104{
7113 struct airo_info *ai = dev->priv; 7105 struct airo_info *ai = dev->ml_priv;
7114 Cmd cmd; 7106 Cmd cmd;
7115 Resp rsp; 7107 Resp rsp;
7116 int wake = 0; 7108 int wake = 0;
@@ -7156,7 +7148,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
7156 char *end_buf, 7148 char *end_buf,
7157 BSSListRid *bss) 7149 BSSListRid *bss)
7158{ 7150{
7159 struct airo_info *ai = dev->priv; 7151 struct airo_info *ai = dev->ml_priv;
7160 struct iw_event iwe; /* Temporary buffer */ 7152 struct iw_event iwe; /* Temporary buffer */
7161 __le16 capabilities; 7153 __le16 capabilities;
7162 char * current_val; /* For rates */ 7154 char * current_val; /* For rates */
@@ -7274,56 +7266,53 @@ static inline char *airo_translate_scan(struct net_device *dev,
7274 if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) { 7266 if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) {
7275 unsigned int num_null_ies = 0; 7267 unsigned int num_null_ies = 0;
7276 u16 length = sizeof (bss->extra.iep); 7268 u16 length = sizeof (bss->extra.iep);
7277 struct ieee80211_info_element *info_element = 7269 u8 *ie = (void *)&bss->extra.iep;
7278 (struct ieee80211_info_element *) &bss->extra.iep;
7279 7270
7280 while ((length >= sizeof(*info_element)) && (num_null_ies < 2)) { 7271 while ((length >= 2) && (num_null_ies < 2)) {
7281 if (sizeof(*info_element) + info_element->len > length) { 7272 if (2 + ie[1] > length) {
7282 /* Invalid element, don't continue parsing IE */ 7273 /* Invalid element, don't continue parsing IE */
7283 break; 7274 break;
7284 } 7275 }
7285 7276
7286 switch (info_element->id) { 7277 switch (ie[0]) {
7287 case MFIE_TYPE_SSID: 7278 case WLAN_EID_SSID:
7288 /* Two zero-length SSID elements 7279 /* Two zero-length SSID elements
7289 * mean we're done parsing elements */ 7280 * mean we're done parsing elements */
7290 if (!info_element->len) 7281 if (!ie[1])
7291 num_null_ies++; 7282 num_null_ies++;
7292 break; 7283 break;
7293 7284
7294 case MFIE_TYPE_GENERIC: 7285 case WLAN_EID_GENERIC:
7295 if (info_element->len >= 4 && 7286 if (ie[1] >= 4 &&
7296 info_element->data[0] == 0x00 && 7287 ie[2] == 0x00 &&
7297 info_element->data[1] == 0x50 && 7288 ie[3] == 0x50 &&
7298 info_element->data[2] == 0xf2 && 7289 ie[4] == 0xf2 &&
7299 info_element->data[3] == 0x01) { 7290 ie[5] == 0x01) {
7300 iwe.cmd = IWEVGENIE; 7291 iwe.cmd = IWEVGENIE;
7301 iwe.u.data.length = min(info_element->len + 2, 7292 /* 64 is an arbitrary cut-off */
7302 MAX_WPA_IE_LEN); 7293 iwe.u.data.length = min(ie[1] + 2,
7294 64);
7303 current_ev = iwe_stream_add_point( 7295 current_ev = iwe_stream_add_point(
7304 info, current_ev, 7296 info, current_ev,
7305 end_buf, &iwe, 7297 end_buf, &iwe, ie);
7306 (char *) info_element);
7307 } 7298 }
7308 break; 7299 break;
7309 7300
7310 case MFIE_TYPE_RSN: 7301 case WLAN_EID_RSN:
7311 iwe.cmd = IWEVGENIE; 7302 iwe.cmd = IWEVGENIE;
7312 iwe.u.data.length = min(info_element->len + 2, 7303 /* 64 is an arbitrary cut-off */
7313 MAX_WPA_IE_LEN); 7304 iwe.u.data.length = min(ie[1] + 2, 64);
7314 current_ev = iwe_stream_add_point( 7305 current_ev = iwe_stream_add_point(
7315 info, current_ev, end_buf, 7306 info, current_ev, end_buf,
7316 &iwe, (char *) info_element); 7307 &iwe, ie);
7317 break; 7308 break;
7318 7309
7319 default: 7310 default:
7320 break; 7311 break;
7321 } 7312 }
7322 7313
7323 length -= sizeof(*info_element) + info_element->len; 7314 length -= 2 + ie[1];
7324 info_element = 7315 ie += 2 + ie[1];
7325 (struct ieee80211_info_element *)&info_element->
7326 data[info_element->len];
7327 } 7316 }
7328 } 7317 }
7329 return current_ev; 7318 return current_ev;
@@ -7338,7 +7327,7 @@ static int airo_get_scan(struct net_device *dev,
7338 struct iw_point *dwrq, 7327 struct iw_point *dwrq,
7339 char *extra) 7328 char *extra)
7340{ 7329{
7341 struct airo_info *ai = dev->priv; 7330 struct airo_info *ai = dev->ml_priv;
7342 BSSListElement *net; 7331 BSSListElement *net;
7343 int err = 0; 7332 int err = 0;
7344 char *current_ev = extra; 7333 char *current_ev = extra;
@@ -7382,7 +7371,7 @@ static int airo_config_commit(struct net_device *dev,
7382 void *zwrq, /* NULL */ 7371 void *zwrq, /* NULL */
7383 char *extra) /* NULL */ 7372 char *extra) /* NULL */
7384{ 7373{
7385 struct airo_info *local = dev->priv; 7374 struct airo_info *local = dev->ml_priv;
7386 7375
7387 if (!test_bit (FLAG_COMMIT, &local->flags)) 7376 if (!test_bit (FLAG_COMMIT, &local->flags))
7388 return 0; 7377 return 0;
@@ -7527,7 +7516,7 @@ static const struct iw_handler_def airo_handler_def =
7527static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 7516static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
7528{ 7517{
7529 int rc = 0; 7518 int rc = 0;
7530 struct airo_info *ai = (struct airo_info *)dev->priv; 7519 struct airo_info *ai = dev->ml_priv;
7531 7520
7532 if (ai->power.event) 7521 if (ai->power.event)
7533 return 0; 7522 return 0;
@@ -7655,7 +7644,7 @@ static void airo_read_wireless_stats(struct airo_info *local)
7655 7644
7656static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev) 7645static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
7657{ 7646{
7658 struct airo_info *local = dev->priv; 7647 struct airo_info *local = dev->ml_priv;
7659 7648
7660 if (!test_bit(JOB_WSTATS, &local->jobs)) { 7649 if (!test_bit(JOB_WSTATS, &local->jobs)) {
7661 /* Get stats out of the card if available */ 7650 /* Get stats out of the card if available */
@@ -7680,7 +7669,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
7680 unsigned short ridcode; 7669 unsigned short ridcode;
7681 unsigned char *iobuf; 7670 unsigned char *iobuf;
7682 int len; 7671 int len;
7683 struct airo_info *ai = dev->priv; 7672 struct airo_info *ai = dev->ml_priv;
7684 7673
7685 if (test_bit(FLAG_FLASHING, &ai->flags)) 7674 if (test_bit(FLAG_FLASHING, &ai->flags))
7686 return -EIO; 7675 return -EIO;
@@ -7746,7 +7735,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
7746 */ 7735 */
7747 7736
7748static int writerids(struct net_device *dev, aironet_ioctl *comp) { 7737static int writerids(struct net_device *dev, aironet_ioctl *comp) {
7749 struct airo_info *ai = dev->priv; 7738 struct airo_info *ai = dev->ml_priv;
7750 int ridcode; 7739 int ridcode;
7751 int enabled; 7740 int enabled;
7752 static int (* writer)(struct airo_info *, u16 rid, const void *, int, int); 7741 static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
@@ -7869,41 +7858,41 @@ static int flashcard(struct net_device *dev, aironet_ioctl *comp) {
7869 switch(comp->command) 7858 switch(comp->command)
7870 { 7859 {
7871 case AIROFLSHRST: 7860 case AIROFLSHRST:
7872 return cmdreset((struct airo_info *)dev->priv); 7861 return cmdreset((struct airo_info *)dev->ml_priv);
7873 7862
7874 case AIROFLSHSTFL: 7863 case AIROFLSHSTFL:
7875 if (!((struct airo_info *)dev->priv)->flash && 7864 if (!AIRO_FLASH(dev) &&
7876 (((struct airo_info *)dev->priv)->flash = kmalloc (FLASHSIZE, GFP_KERNEL)) == NULL) 7865 (AIRO_FLASH(dev) = kmalloc(FLASHSIZE, GFP_KERNEL)) == NULL)
7877 return -ENOMEM; 7866 return -ENOMEM;
7878 return setflashmode((struct airo_info *)dev->priv); 7867 return setflashmode((struct airo_info *)dev->ml_priv);
7879 7868
7880 case AIROFLSHGCHR: /* Get char from aux */ 7869 case AIROFLSHGCHR: /* Get char from aux */
7881 if(comp->len != sizeof(int)) 7870 if(comp->len != sizeof(int))
7882 return -EINVAL; 7871 return -EINVAL;
7883 if (copy_from_user(&z,comp->data,comp->len)) 7872 if (copy_from_user(&z,comp->data,comp->len))
7884 return -EFAULT; 7873 return -EFAULT;
7885 return flashgchar((struct airo_info *)dev->priv,z,8000); 7874 return flashgchar((struct airo_info *)dev->ml_priv, z, 8000);
7886 7875
7887 case AIROFLSHPCHR: /* Send char to card. */ 7876 case AIROFLSHPCHR: /* Send char to card. */
7888 if(comp->len != sizeof(int)) 7877 if(comp->len != sizeof(int))
7889 return -EINVAL; 7878 return -EINVAL;
7890 if (copy_from_user(&z,comp->data,comp->len)) 7879 if (copy_from_user(&z,comp->data,comp->len))
7891 return -EFAULT; 7880 return -EFAULT;
7892 return flashpchar((struct airo_info *)dev->priv,z,8000); 7881 return flashpchar((struct airo_info *)dev->ml_priv, z, 8000);
7893 7882
7894 case AIROFLPUTBUF: /* Send 32k to card */ 7883 case AIROFLPUTBUF: /* Send 32k to card */
7895 if (!((struct airo_info *)dev->priv)->flash) 7884 if (!AIRO_FLASH(dev))
7896 return -ENOMEM; 7885 return -ENOMEM;
7897 if(comp->len > FLASHSIZE) 7886 if(comp->len > FLASHSIZE)
7898 return -EINVAL; 7887 return -EINVAL;
7899 if(copy_from_user(((struct airo_info *)dev->priv)->flash,comp->data,comp->len)) 7888 if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len))
7900 return -EFAULT; 7889 return -EFAULT;
7901 7890
7902 flashputbuf((struct airo_info *)dev->priv); 7891 flashputbuf((struct airo_info *)dev->ml_priv);
7903 return 0; 7892 return 0;
7904 7893
7905 case AIRORESTART: 7894 case AIRORESTART:
7906 if(flashrestart((struct airo_info *)dev->priv,dev)) 7895 if (flashrestart((struct airo_info *)dev->ml_priv, dev))
7907 return -EIO; 7896 return -EIO;
7908 return 0; 7897 return 0;
7909 } 7898 }
diff --git a/drivers/net/wireless/arlan-main.c b/drivers/net/wireless/arlan-main.c
index dec5e874a54d..bfca15da6f0f 100644
--- a/drivers/net/wireless/arlan-main.c
+++ b/drivers/net/wireless/arlan-main.c
@@ -1467,19 +1467,17 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short
1467 else if (hw_dst_addr[1] == 0x40) 1467 else if (hw_dst_addr[1] == 0x40)
1468 printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name); 1468 printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name);
1469 while (dmi) 1469 while (dmi)
1470 { if (dmi->dmi_addrlen == 6) 1470 {
1471 { 1471 if (dmi->dmi_addrlen == 6) {
1472 DECLARE_MAC_BUF(mac);
1473 if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP) 1472 if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP)
1474 printk(KERN_ERR "%s mcl %s\n", 1473 printk(KERN_ERR "%s mcl %pM\n",
1475 dev->name, print_mac(mac, dmi->dmi_addr)); 1474 dev->name, dmi->dmi_addr);
1476 for (i = 0; i < 6; i++) 1475 for (i = 0; i < 6; i++)
1477 if (dmi->dmi_addr[i] != hw_dst_addr[i]) 1476 if (dmi->dmi_addr[i] != hw_dst_addr[i])
1478 break; 1477 break;
1479 if (i == 6) 1478 if (i == 6)
1480 break; 1479 break;
1481 } 1480 } else
1482 else
1483 printk(KERN_ERR "%s: invalid multicast address length given.\n", dev->name); 1481 printk(KERN_ERR "%s: invalid multicast address length given.\n", dev->name);
1484 dmi = dmi->next; 1482 dmi = dmi->next;
1485 } 1483 }
@@ -1512,18 +1510,14 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short
1512 { 1510 {
1513 char immedDestAddress[6]; 1511 char immedDestAddress[6];
1514 char immedSrcAddress[6]; 1512 char immedSrcAddress[6];
1515 DECLARE_MAC_BUF(mac);
1516 DECLARE_MAC_BUF(mac2);
1517 DECLARE_MAC_BUF(mac3);
1518 DECLARE_MAC_BUF(mac4);
1519 memcpy_fromio(immedDestAddress, arlan->immedDestAddress, 6); 1513 memcpy_fromio(immedDestAddress, arlan->immedDestAddress, 6);
1520 memcpy_fromio(immedSrcAddress, arlan->immedSrcAddress, 6); 1514 memcpy_fromio(immedSrcAddress, arlan->immedSrcAddress, 6);
1521 1515
1522 printk(KERN_WARNING "%s t %s f %s imd %s ims %s\n", 1516 printk(KERN_WARNING "%s t %pM f %pM imd %pM ims %pM\n",
1523 dev->name, print_mac(mac, skbtmp), 1517 dev->name, skbtmp,
1524 print_mac(mac2, &skbtmp[6]), 1518 &skbtmp[6],
1525 print_mac(mac3, immedDestAddress), 1519 immedDestAddress,
1526 print_mac(mac4, immedSrcAddress)); 1520 immedSrcAddress);
1527 } 1521 }
1528 skb->protocol = eth_type_trans(skb, dev); 1522 skb->protocol = eth_type_trans(skb, dev);
1529 IFDEBUG(ARLAN_DEBUG_HEADER_DUMP) 1523 IFDEBUG(ARLAN_DEBUG_HEADER_DUMP)
@@ -1535,7 +1529,6 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short
1535 printk(KERN_WARNING "arlan kernel pkt type trans %x \n", skb->protocol); 1529 printk(KERN_WARNING "arlan kernel pkt type trans %x \n", skb->protocol);
1536 } 1530 }
1537 netif_rx(skb); 1531 netif_rx(skb);
1538 dev->last_rx = jiffies;
1539 dev->stats.rx_packets++; 1532 dev->stats.rx_packets++;
1540 dev->stats.rx_bytes += pkt_len; 1533 dev->stats.rx_bytes += pkt_len;
1541 } 1534 }
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath5k/ath5k.h
index 53ea439aff48..a725bb94a52d 100644
--- a/drivers/net/wireless/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath5k/ath5k.h
@@ -507,11 +507,15 @@ enum ath5k_tx_queue_id {
507#define AR5K_TXQ_FLAG_TXEOLINT_ENABLE 0x0004 /* Enable TXEOL interrupt -not used- */ 507#define AR5K_TXQ_FLAG_TXEOLINT_ENABLE 0x0004 /* Enable TXEOL interrupt -not used- */
508#define AR5K_TXQ_FLAG_TXDESCINT_ENABLE 0x0008 /* Enable TXDESC interrupt -not used- */ 508#define AR5K_TXQ_FLAG_TXDESCINT_ENABLE 0x0008 /* Enable TXDESC interrupt -not used- */
509#define AR5K_TXQ_FLAG_TXURNINT_ENABLE 0x0010 /* Enable TXURN interrupt */ 509#define AR5K_TXQ_FLAG_TXURNINT_ENABLE 0x0010 /* Enable TXURN interrupt */
510#define AR5K_TXQ_FLAG_BACKOFF_DISABLE 0x0020 /* Disable random post-backoff */ 510#define AR5K_TXQ_FLAG_CBRORNINT_ENABLE 0x0020 /* Enable CBRORN interrupt */
511#define AR5K_TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE 0x0040 /* Enable ready time expiry policy (?)*/ 511#define AR5K_TXQ_FLAG_CBRURNINT_ENABLE 0x0040 /* Enable CBRURN interrupt */
512#define AR5K_TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE 0x0080 /* Enable backoff while bursting */ 512#define AR5K_TXQ_FLAG_QTRIGINT_ENABLE 0x0080 /* Enable QTRIG interrupt */
513#define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS 0x0100 /* Disable backoff while bursting */ 513#define AR5K_TXQ_FLAG_TXNOFRMINT_ENABLE 0x0100 /* Enable TXNOFRM interrupt */
514#define AR5K_TXQ_FLAG_COMPRESSION_ENABLE 0x0200 /* Enable hw compression -not implemented-*/ 514#define AR5K_TXQ_FLAG_BACKOFF_DISABLE 0x0200 /* Disable random post-backoff */
515#define AR5K_TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE 0x0300 /* Enable ready time expiry policy (?)*/
516#define AR5K_TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE 0x0800 /* Enable backoff while bursting */
517#define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS 0x1000 /* Disable backoff while bursting */
518#define AR5K_TXQ_FLAG_COMPRESSION_ENABLE 0x2000 /* Enable hw compression -not implemented-*/
515 519
516/* 520/*
517 * A struct to hold tx queue's parameters 521 * A struct to hold tx queue's parameters
@@ -853,7 +857,7 @@ enum ath5k_ant_setting {
853 * checked. We should do this with ath5k_hw_update_mib_counters() but 857 * checked. We should do this with ath5k_hw_update_mib_counters() but
854 * it seems we should also then do some noise immunity work. 858 * it seems we should also then do some noise immunity work.
855 * @AR5K_INT_RXPHY: RX PHY Error 859 * @AR5K_INT_RXPHY: RX PHY Error
856 * @AR5K_INT_RXKCM: ?? 860 * @AR5K_INT_RXKCM: RX Key cache miss
857 * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a 861 * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a
858 * beacon that must be handled in software. The alternative is if you 862 * beacon that must be handled in software. The alternative is if you
859 * have VEOL support, in that case you let the hardware deal with things. 863 * have VEOL support, in that case you let the hardware deal with things.
@@ -869,7 +873,7 @@ enum ath5k_ant_setting {
869 * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by DMA 873 * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by DMA
870 * errors. These types of errors we can enable seem to be of type 874 * errors. These types of errors we can enable seem to be of type
871 * AR5K_SIMR2_MCABT, AR5K_SIMR2_SSERR and AR5K_SIMR2_DPERR. 875 * AR5K_SIMR2_MCABT, AR5K_SIMR2_SSERR and AR5K_SIMR2_DPERR.
872 * @AR5K_INT_GLOBAL: Seems to be used to clear and set the IER 876 * @AR5K_INT_GLOBAL: Used to clear and set the IER
873 * @AR5K_INT_NOCARD: signals the card has been removed 877 * @AR5K_INT_NOCARD: signals the card has been removed
874 * @AR5K_INT_COMMON: common interrupts shared amogst MACs with the same 878 * @AR5K_INT_COMMON: common interrupts shared amogst MACs with the same
875 * bit value 879 * bit value
@@ -881,36 +885,61 @@ enum ath5k_ant_setting {
881 * MACs. 885 * MACs.
882 */ 886 */
883enum ath5k_int { 887enum ath5k_int {
884 AR5K_INT_RX = 0x00000001, /* Not common */ 888 AR5K_INT_RXOK = 0x00000001,
885 AR5K_INT_RXDESC = 0x00000002, 889 AR5K_INT_RXDESC = 0x00000002,
890 AR5K_INT_RXERR = 0x00000004,
886 AR5K_INT_RXNOFRM = 0x00000008, 891 AR5K_INT_RXNOFRM = 0x00000008,
887 AR5K_INT_RXEOL = 0x00000010, 892 AR5K_INT_RXEOL = 0x00000010,
888 AR5K_INT_RXORN = 0x00000020, 893 AR5K_INT_RXORN = 0x00000020,
889 AR5K_INT_TX = 0x00000040, /* Not common */ 894 AR5K_INT_TXOK = 0x00000040,
890 AR5K_INT_TXDESC = 0x00000080, 895 AR5K_INT_TXDESC = 0x00000080,
896 AR5K_INT_TXERR = 0x00000100,
897 AR5K_INT_TXNOFRM = 0x00000200,
898 AR5K_INT_TXEOL = 0x00000400,
891 AR5K_INT_TXURN = 0x00000800, 899 AR5K_INT_TXURN = 0x00000800,
892 AR5K_INT_MIB = 0x00001000, 900 AR5K_INT_MIB = 0x00001000,
901 AR5K_INT_SWI = 0x00002000,
893 AR5K_INT_RXPHY = 0x00004000, 902 AR5K_INT_RXPHY = 0x00004000,
894 AR5K_INT_RXKCM = 0x00008000, 903 AR5K_INT_RXKCM = 0x00008000,
895 AR5K_INT_SWBA = 0x00010000, 904 AR5K_INT_SWBA = 0x00010000,
905 AR5K_INT_BRSSI = 0x00020000,
896 AR5K_INT_BMISS = 0x00040000, 906 AR5K_INT_BMISS = 0x00040000,
897 AR5K_INT_BNR = 0x00100000, /* Not common */ 907 AR5K_INT_FATAL = 0x00080000, /* Non common */
898 AR5K_INT_GPIO = 0x01000000, 908 AR5K_INT_BNR = 0x00100000, /* Non common */
899 AR5K_INT_FATAL = 0x40000000, /* Not common */ 909 AR5K_INT_TIM = 0x00200000, /* Non common */
900 AR5K_INT_GLOBAL = 0x80000000, 910 AR5K_INT_DTIM = 0x00400000, /* Non common */
901 911 AR5K_INT_DTIM_SYNC = 0x00800000, /* Non common */
902 AR5K_INT_COMMON = AR5K_INT_RXNOFRM 912 AR5K_INT_GPIO = 0x01000000,
903 | AR5K_INT_RXDESC 913 AR5K_INT_BCN_TIMEOUT = 0x02000000, /* Non common */
904 | AR5K_INT_RXEOL 914 AR5K_INT_CAB_TIMEOUT = 0x04000000, /* Non common */
905 | AR5K_INT_RXORN 915 AR5K_INT_RX_DOPPLER = 0x08000000, /* Non common */
906 | AR5K_INT_TXURN 916 AR5K_INT_QCBRORN = 0x10000000, /* Non common */
907 | AR5K_INT_TXDESC 917 AR5K_INT_QCBRURN = 0x20000000, /* Non common */
908 | AR5K_INT_MIB 918 AR5K_INT_QTRIG = 0x40000000, /* Non common */
909 | AR5K_INT_RXPHY 919 AR5K_INT_GLOBAL = 0x80000000,
910 | AR5K_INT_RXKCM 920
911 | AR5K_INT_SWBA 921 AR5K_INT_COMMON = AR5K_INT_RXOK
912 | AR5K_INT_BMISS 922 | AR5K_INT_RXDESC
913 | AR5K_INT_GPIO, 923 | AR5K_INT_RXERR
924 | AR5K_INT_RXNOFRM
925 | AR5K_INT_RXEOL
926 | AR5K_INT_RXORN
927 | AR5K_INT_TXOK
928 | AR5K_INT_TXDESC
929 | AR5K_INT_TXERR
930 | AR5K_INT_TXNOFRM
931 | AR5K_INT_TXEOL
932 | AR5K_INT_TXURN
933 | AR5K_INT_MIB
934 | AR5K_INT_SWI
935 | AR5K_INT_RXPHY
936 | AR5K_INT_RXKCM
937 | AR5K_INT_SWBA
938 | AR5K_INT_BRSSI
939 | AR5K_INT_BMISS
940 | AR5K_INT_GPIO
941 | AR5K_INT_GLOBAL,
942
914 AR5K_INT_NOCARD = 0xffffffff 943 AR5K_INT_NOCARD = 0xffffffff
915}; 944};
916 945
@@ -1064,10 +1093,11 @@ struct ath5k_hw {
1064 1093
1065 u8 ah_sta_id[ETH_ALEN]; 1094 u8 ah_sta_id[ETH_ALEN];
1066 1095
1067 /* Current BSSID we are trying to assoc to / creating. 1096 /* Current BSSID we are trying to assoc to / create.
1068 * This is passed by mac80211 on config_interface() and cached here for 1097 * This is passed by mac80211 on config_interface() and cached here for
1069 * use in resets */ 1098 * use in resets */
1070 u8 ah_bssid[ETH_ALEN]; 1099 u8 ah_bssid[ETH_ALEN];
1100 u8 ah_bssid_mask[ETH_ALEN];
1071 1101
1072 u32 ah_gpio[AR5K_MAX_GPIO]; 1102 u32 ah_gpio[AR5K_MAX_GPIO];
1073 int ah_gpio_npins; 1103 int ah_gpio_npins;
@@ -1081,6 +1111,11 @@ struct ath5k_hw {
1081 u32 ah_txq_imr_txurn; 1111 u32 ah_txq_imr_txurn;
1082 u32 ah_txq_imr_txdesc; 1112 u32 ah_txq_imr_txdesc;
1083 u32 ah_txq_imr_txeol; 1113 u32 ah_txq_imr_txeol;
1114 u32 ah_txq_imr_cbrorn;
1115 u32 ah_txq_imr_cbrurn;
1116 u32 ah_txq_imr_qtrig;
1117 u32 ah_txq_imr_nofrm;
1118 u32 ah_txq_isr;
1084 u32 *ah_rf_banks; 1119 u32 *ah_rf_banks;
1085 size_t ah_rf_banks_size; 1120 size_t ah_rf_banks_size;
1086 struct ath5k_gain ah_gain; 1121 struct ath5k_gain ah_gain;
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index cfd4d052d666..c7ffcbb9062d 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -60,6 +60,9 @@
60#include "debug.h" 60#include "debug.h"
61 61
62static int ath5k_calinterval = 10; /* Calibrate PHY every 10 secs (TODO: Fixme) */ 62static int ath5k_calinterval = 10; /* Calibrate PHY every 10 secs (TODO: Fixme) */
63static int modparam_nohwcrypt;
64module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
65MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
63 66
64 67
65/******************\ 68/******************\
@@ -219,8 +222,7 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
219 struct ieee80211_if_init_conf *conf); 222 struct ieee80211_if_init_conf *conf);
220static void ath5k_remove_interface(struct ieee80211_hw *hw, 223static void ath5k_remove_interface(struct ieee80211_hw *hw,
221 struct ieee80211_if_init_conf *conf); 224 struct ieee80211_if_init_conf *conf);
222static int ath5k_config(struct ieee80211_hw *hw, 225static int ath5k_config(struct ieee80211_hw *hw, u32 changed);
223 struct ieee80211_conf *conf);
224static int ath5k_config_interface(struct ieee80211_hw *hw, 226static int ath5k_config_interface(struct ieee80211_hw *hw,
225 struct ieee80211_vif *vif, 227 struct ieee80211_vif *vif,
226 struct ieee80211_if_conf *conf); 228 struct ieee80211_if_conf *conf);
@@ -238,8 +240,7 @@ static int ath5k_get_tx_stats(struct ieee80211_hw *hw,
238 struct ieee80211_tx_queue_stats *stats); 240 struct ieee80211_tx_queue_stats *stats);
239static u64 ath5k_get_tsf(struct ieee80211_hw *hw); 241static u64 ath5k_get_tsf(struct ieee80211_hw *hw);
240static void ath5k_reset_tsf(struct ieee80211_hw *hw); 242static void ath5k_reset_tsf(struct ieee80211_hw *hw);
241static int ath5k_beacon_update(struct ieee80211_hw *hw, 243static int ath5k_beacon_update(struct ath5k_softc *sc, struct sk_buff *skb);
242 struct sk_buff *skb);
243 244
244static struct ieee80211_ops ath5k_hw_ops = { 245static struct ieee80211_ops ath5k_hw_ops = {
245 .tx = ath5k_tx, 246 .tx = ath5k_tx,
@@ -543,8 +544,8 @@ ath5k_pci_probe(struct pci_dev *pdev,
543 544
544 /* set up multi-rate retry capabilities */ 545 /* set up multi-rate retry capabilities */
545 if (sc->ah->ah_version == AR5K_AR5212) { 546 if (sc->ah->ah_version == AR5K_AR5212) {
546 hw->max_altrates = 3; 547 hw->max_rates = 4;
547 hw->max_altrate_tries = 11; 548 hw->max_rate_tries = 11;
548 } 549 }
549 550
550 /* Finish private driver data initialization */ 551 /* Finish private driver data initialization */
@@ -1183,7 +1184,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1183 ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL, 1184 ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL,
1184 (sc->power_level * 2), 1185 (sc->power_level * 2),
1185 ieee80211_get_tx_rate(sc->hw, info)->hw_value, 1186 ieee80211_get_tx_rate(sc->hw, info)->hw_value,
1186 info->control.retry_limit, keyidx, 0, flags, 0, 0); 1187 info->control.rates[0].count, keyidx, 0, flags, 0, 0);
1187 if (ret) 1188 if (ret)
1188 goto err_unmap; 1189 goto err_unmap;
1189 1190
@@ -1195,7 +1196,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1195 break; 1196 break;
1196 1197
1197 mrr_rate[i] = rate->hw_value; 1198 mrr_rate[i] = rate->hw_value;
1198 mrr_tries[i] = info->control.retries[i].limit; 1199 mrr_tries[i] = info->control.rates[i + 1].count;
1199 } 1200 }
1200 1201
1201 ah->ah_setup_mrr_tx_desc(ah, ds, 1202 ah->ah_setup_mrr_tx_desc(ah, ds,
@@ -1780,7 +1781,17 @@ accept:
1780 1781
1781 rxs.noise = sc->ah->ah_noise_floor; 1782 rxs.noise = sc->ah->ah_noise_floor;
1782 rxs.signal = rxs.noise + rs.rs_rssi; 1783 rxs.signal = rxs.noise + rs.rs_rssi;
1783 rxs.qual = rs.rs_rssi * 100 / 64; 1784
1785 /* An rssi of 35 indicates you should be able use
1786 * 54 Mbps reliably. A more elaborate scheme can be used
1787 * here but it requires a map of SNR/throughput for each
1788 * possible mode used */
1789 rxs.qual = rs.rs_rssi * 100 / 35;
1790
1791 /* rssi can be more than 35 though, anything above that
1792 * should be considered at 100% */
1793 if (rxs.qual > 100)
1794 rxs.qual = 100;
1784 1795
1785 rxs.antenna = rs.rs_antenna; 1796 rxs.antenna = rs.rs_antenna;
1786 rxs.rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate); 1797 rxs.rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate);
@@ -1841,30 +1852,26 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
1841 pci_unmap_single(sc->pdev, bf->skbaddr, skb->len, 1852 pci_unmap_single(sc->pdev, bf->skbaddr, skb->len,
1842 PCI_DMA_TODEVICE); 1853 PCI_DMA_TODEVICE);
1843 1854
1844 memset(&info->status, 0, sizeof(info->status)); 1855 ieee80211_tx_info_clear_status(info);
1845 info->tx_rate_idx = ath5k_hw_to_driver_rix(sc,
1846 ts.ts_rate[ts.ts_final_idx]);
1847 info->status.retry_count = ts.ts_longretry;
1848
1849 for (i = 0; i < 4; i++) { 1856 for (i = 0; i < 4; i++) {
1850 struct ieee80211_tx_altrate *r = 1857 struct ieee80211_tx_rate *r =
1851 &info->status.retries[i]; 1858 &info->status.rates[i];
1852 1859
1853 if (ts.ts_rate[i]) { 1860 if (ts.ts_rate[i]) {
1854 r->rate_idx = ath5k_hw_to_driver_rix(sc, ts.ts_rate[i]); 1861 r->idx = ath5k_hw_to_driver_rix(sc, ts.ts_rate[i]);
1855 r->limit = ts.ts_retry[i]; 1862 r->count = ts.ts_retry[i];
1856 } else { 1863 } else {
1857 r->rate_idx = -1; 1864 r->idx = -1;
1858 r->limit = 0; 1865 r->count = 0;
1859 } 1866 }
1860 } 1867 }
1861 1868
1862 info->status.excessive_retries = 0; 1869 /* count the successful attempt as well */
1870 info->status.rates[ts.ts_final_idx].count++;
1871
1863 if (unlikely(ts.ts_status)) { 1872 if (unlikely(ts.ts_status)) {
1864 sc->ll_stats.dot11ACKFailureCount++; 1873 sc->ll_stats.dot11ACKFailureCount++;
1865 if (ts.ts_status & AR5K_TXERR_XRETRY) 1874 if (ts.ts_status & AR5K_TXERR_FILT)
1866 info->status.excessive_retries = 1;
1867 else if (ts.ts_status & AR5K_TXERR_FILT)
1868 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 1875 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
1869 } else { 1876 } else {
1870 info->flags |= IEEE80211_TX_STAT_ACK; 1877 info->flags |= IEEE80211_TX_STAT_ACK;
@@ -2138,8 +2145,6 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
2138 * 2145 *
2139 * In IBSS mode we use a self-linked tx descriptor if possible. We enable SWBA 2146 * In IBSS mode we use a self-linked tx descriptor if possible. We enable SWBA
2140 * interrupts to detect TSF updates only. 2147 * interrupts to detect TSF updates only.
2141 *
2142 * AP mode is missing.
2143 */ 2148 */
2144static void 2149static void
2145ath5k_beacon_config(struct ath5k_softc *sc) 2150ath5k_beacon_config(struct ath5k_softc *sc)
@@ -2152,7 +2157,9 @@ ath5k_beacon_config(struct ath5k_softc *sc)
2152 2157
2153 if (sc->opmode == NL80211_IFTYPE_STATION) { 2158 if (sc->opmode == NL80211_IFTYPE_STATION) {
2154 sc->imask |= AR5K_INT_BMISS; 2159 sc->imask |= AR5K_INT_BMISS;
2155 } else if (sc->opmode == NL80211_IFTYPE_ADHOC) { 2160 } else if (sc->opmode == NL80211_IFTYPE_ADHOC ||
2161 sc->opmode == NL80211_IFTYPE_MESH_POINT ||
2162 sc->opmode == NL80211_IFTYPE_AP) {
2156 /* 2163 /*
2157 * In IBSS mode we use a self-linked tx descriptor and let the 2164 * In IBSS mode we use a self-linked tx descriptor and let the
2158 * hardware send the beacons automatically. We have to load it 2165 * hardware send the beacons automatically. We have to load it
@@ -2164,13 +2171,15 @@ ath5k_beacon_config(struct ath5k_softc *sc)
2164 2171
2165 sc->imask |= AR5K_INT_SWBA; 2172 sc->imask |= AR5K_INT_SWBA;
2166 2173
2167 if (ath5k_hw_hasveol(ah)) { 2174 if (sc->opmode == NL80211_IFTYPE_ADHOC) {
2168 spin_lock(&sc->block); 2175 if (ath5k_hw_hasveol(ah)) {
2169 ath5k_beacon_send(sc); 2176 spin_lock(&sc->block);
2170 spin_unlock(&sc->block); 2177 ath5k_beacon_send(sc);
2171 } 2178 spin_unlock(&sc->block);
2179 }
2180 } else
2181 ath5k_beacon_update_timers(sc, -1);
2172 } 2182 }
2173 /* TODO else AP */
2174 2183
2175 ath5k_hw_set_imr(ah, sc->imask); 2184 ath5k_hw_set_imr(ah, sc->imask);
2176} 2185}
@@ -2210,7 +2219,7 @@ ath5k_init(struct ath5k_softc *sc, bool is_resume)
2210 */ 2219 */
2211 sc->curchan = sc->hw->conf.channel; 2220 sc->curchan = sc->hw->conf.channel;
2212 sc->curband = &sc->sbands[sc->curchan->band]; 2221 sc->curband = &sc->sbands[sc->curchan->band];
2213 sc->imask = AR5K_INT_RX | AR5K_INT_TX | AR5K_INT_RXEOL | 2222 sc->imask = AR5K_INT_RXOK | AR5K_INT_TXOK | AR5K_INT_RXEOL |
2214 AR5K_INT_RXORN | AR5K_INT_FATAL | AR5K_INT_GLOBAL | 2223 AR5K_INT_RXORN | AR5K_INT_FATAL | AR5K_INT_GLOBAL |
2215 AR5K_INT_MIB; 2224 AR5K_INT_MIB;
2216 ret = ath5k_reset(sc, false, false); 2225 ret = ath5k_reset(sc, false, false);
@@ -2404,9 +2413,10 @@ ath5k_intr(int irq, void *dev_id)
2404 /* bump tx trigger level */ 2413 /* bump tx trigger level */
2405 ath5k_hw_update_tx_triglevel(ah, true); 2414 ath5k_hw_update_tx_triglevel(ah, true);
2406 } 2415 }
2407 if (status & AR5K_INT_RX) 2416 if (status & (AR5K_INT_RXOK | AR5K_INT_RXERR))
2408 tasklet_schedule(&sc->rxtq); 2417 tasklet_schedule(&sc->rxtq);
2409 if (status & AR5K_INT_TX) 2418 if (status & (AR5K_INT_TXOK | AR5K_INT_TXDESC
2419 | AR5K_INT_TXERR | AR5K_INT_TXEOL))
2410 tasklet_schedule(&sc->txtq); 2420 tasklet_schedule(&sc->txtq);
2411 if (status & AR5K_INT_BMISS) { 2421 if (status & AR5K_INT_BMISS) {
2412 } 2422 }
@@ -2522,8 +2532,7 @@ ath5k_register_led(struct ath5k_softc *sc, struct ath5k_led *led,
2522 led->led_dev.brightness_set = ath5k_led_brightness_set; 2532 led->led_dev.brightness_set = ath5k_led_brightness_set;
2523 2533
2524 err = led_classdev_register(&sc->pdev->dev, &led->led_dev); 2534 err = led_classdev_register(&sc->pdev->dev, &led->led_dev);
2525 if (err) 2535 if (err) {
2526 {
2527 ATH5K_WARN(sc, "could not register LED %s\n", name); 2536 ATH5K_WARN(sc, "could not register LED %s\n", name);
2528 led->sc = NULL; 2537 led->sc = NULL;
2529 } 2538 }
@@ -2741,8 +2750,10 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
2741 sc->vif = conf->vif; 2750 sc->vif = conf->vif;
2742 2751
2743 switch (conf->type) { 2752 switch (conf->type) {
2753 case NL80211_IFTYPE_AP:
2744 case NL80211_IFTYPE_STATION: 2754 case NL80211_IFTYPE_STATION:
2745 case NL80211_IFTYPE_ADHOC: 2755 case NL80211_IFTYPE_ADHOC:
2756 case NL80211_IFTYPE_MESH_POINT:
2746 case NL80211_IFTYPE_MONITOR: 2757 case NL80211_IFTYPE_MONITOR:
2747 sc->opmode = conf->type; 2758 sc->opmode = conf->type;
2748 break; 2759 break;
@@ -2780,10 +2791,10 @@ end:
2780 * TODO: Phy disable/diversity etc 2791 * TODO: Phy disable/diversity etc
2781 */ 2792 */
2782static int 2793static int
2783ath5k_config(struct ieee80211_hw *hw, 2794ath5k_config(struct ieee80211_hw *hw, u32 changed)
2784 struct ieee80211_conf *conf)
2785{ 2795{
2786 struct ath5k_softc *sc = hw->priv; 2796 struct ath5k_softc *sc = hw->priv;
2797 struct ieee80211_conf *conf = &hw->conf;
2787 2798
2788 sc->bintval = conf->beacon_int; 2799 sc->bintval = conf->beacon_int;
2789 sc->power_level = conf->power_level; 2800 sc->power_level = conf->power_level;
@@ -2804,7 +2815,7 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2804 ret = -EIO; 2815 ret = -EIO;
2805 goto unlock; 2816 goto unlock;
2806 } 2817 }
2807 if (conf->bssid) { 2818 if (conf->changed & IEEE80211_IFCC_BSSID && conf->bssid) {
2808 /* Cache for later use during resets */ 2819 /* Cache for later use during resets */
2809 memcpy(ah->ah_bssid, conf->bssid, ETH_ALEN); 2820 memcpy(ah->ah_bssid, conf->bssid, ETH_ALEN);
2810 /* XXX: assoc id is set to 0 for now, mac80211 doesn't have 2821 /* XXX: assoc id is set to 0 for now, mac80211 doesn't have
@@ -2812,18 +2823,17 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2812 ath5k_hw_set_associd(ah, ah->ah_bssid, 0); 2823 ath5k_hw_set_associd(ah, ah->ah_bssid, 0);
2813 mmiowb(); 2824 mmiowb();
2814 } 2825 }
2815
2816 if (conf->changed & IEEE80211_IFCC_BEACON && 2826 if (conf->changed & IEEE80211_IFCC_BEACON &&
2817 vif->type == NL80211_IFTYPE_ADHOC) { 2827 (vif->type == NL80211_IFTYPE_ADHOC ||
2828 vif->type == NL80211_IFTYPE_MESH_POINT ||
2829 vif->type == NL80211_IFTYPE_AP)) {
2818 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); 2830 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
2819 if (!beacon) { 2831 if (!beacon) {
2820 ret = -ENOMEM; 2832 ret = -ENOMEM;
2821 goto unlock; 2833 goto unlock;
2822 } 2834 }
2823 /* call old handler for now */ 2835 ath5k_beacon_update(sc, beacon);
2824 ath5k_beacon_update(hw, beacon);
2825 } 2836 }
2826
2827 mutex_unlock(&sc->lock); 2837 mutex_unlock(&sc->lock);
2828 2838
2829 return ath5k_reset_wake(sc); 2839 return ath5k_reset_wake(sc);
@@ -2883,9 +2893,9 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
2883 if (*new_flags & FIF_PROMISC_IN_BSS) { 2893 if (*new_flags & FIF_PROMISC_IN_BSS) {
2884 rfilt |= AR5K_RX_FILTER_PROM; 2894 rfilt |= AR5K_RX_FILTER_PROM;
2885 __set_bit(ATH_STAT_PROMISC, sc->status); 2895 __set_bit(ATH_STAT_PROMISC, sc->status);
2886 } 2896 } else {
2887 else
2888 __clear_bit(ATH_STAT_PROMISC, sc->status); 2897 __clear_bit(ATH_STAT_PROMISC, sc->status);
2898 }
2889 } 2899 }
2890 2900
2891 /* Note, AR5K_RX_FILTER_MCAST is already enabled */ 2901 /* Note, AR5K_RX_FILTER_MCAST is already enabled */
@@ -2946,9 +2956,12 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
2946 sc->opmode == NL80211_IFTYPE_ADHOC) { 2956 sc->opmode == NL80211_IFTYPE_ADHOC) {
2947 rfilt |= AR5K_RX_FILTER_BEACON; 2957 rfilt |= AR5K_RX_FILTER_BEACON;
2948 } 2958 }
2959 if (sc->opmode == NL80211_IFTYPE_MESH_POINT)
2960 rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON |
2961 AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM;
2949 2962
2950 /* Set filters */ 2963 /* Set filters */
2951 ath5k_hw_set_rx_filter(ah,rfilt); 2964 ath5k_hw_set_rx_filter(ah, rfilt);
2952 2965
2953 /* Set multicast bits */ 2966 /* Set multicast bits */
2954 ath5k_hw_set_mcast_filter(ah, mfilt[0], mfilt[1]); 2967 ath5k_hw_set_mcast_filter(ah, mfilt[0], mfilt[1]);
@@ -2965,12 +2978,13 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2965 struct ath5k_softc *sc = hw->priv; 2978 struct ath5k_softc *sc = hw->priv;
2966 int ret = 0; 2979 int ret = 0;
2967 2980
2968 switch(key->alg) { 2981 if (modparam_nohwcrypt)
2982 return -EOPNOTSUPP;
2983
2984 switch (key->alg) {
2969 case ALG_WEP: 2985 case ALG_WEP:
2970 /* XXX: fix hardware encryption, its not working. For now
2971 * allow software encryption */
2972 /* break; */
2973 case ALG_TKIP: 2986 case ALG_TKIP:
2987 break;
2974 case ALG_CCMP: 2988 case ALG_CCMP:
2975 return -EOPNOTSUPP; 2989 return -EOPNOTSUPP;
2976 default: 2990 default:
@@ -2989,6 +3003,8 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2989 } 3003 }
2990 __set_bit(key->keyidx, sc->keymap); 3004 __set_bit(key->keyidx, sc->keymap);
2991 key->hw_key_idx = key->keyidx; 3005 key->hw_key_idx = key->keyidx;
3006 key->flags |= (IEEE80211_KEY_FLAG_GENERATE_IV |
3007 IEEE80211_KEY_FLAG_GENERATE_MMIC);
2992 break; 3008 break;
2993 case DISABLE_KEY: 3009 case DISABLE_KEY:
2994 ath5k_hw_reset_key(sc->ah, key->keyidx); 3010 ath5k_hw_reset_key(sc->ah, key->keyidx);
@@ -3055,19 +3071,13 @@ ath5k_reset_tsf(struct ieee80211_hw *hw)
3055} 3071}
3056 3072
3057static int 3073static int
3058ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) 3074ath5k_beacon_update(struct ath5k_softc *sc, struct sk_buff *skb)
3059{ 3075{
3060 struct ath5k_softc *sc = hw->priv;
3061 unsigned long flags; 3076 unsigned long flags;
3062 int ret; 3077 int ret;
3063 3078
3064 ath5k_debug_dump_skb(sc, skb, "BC ", 1); 3079 ath5k_debug_dump_skb(sc, skb, "BC ", 1);
3065 3080
3066 if (sc->opmode != NL80211_IFTYPE_ADHOC) {
3067 ret = -EIO;
3068 goto end;
3069 }
3070
3071 spin_lock_irqsave(&sc->block, flags); 3081 spin_lock_irqsave(&sc->block, flags);
3072 ath5k_txbuf_free(sc, sc->bbuf); 3082 ath5k_txbuf_free(sc, sc->bbuf);
3073 sc->bbuf->skb = skb; 3083 sc->bbuf->skb = skb;
@@ -3080,7 +3090,6 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
3080 mmiowb(); 3090 mmiowb();
3081 } 3091 }
3082 3092
3083end:
3084 return ret; 3093 return ret;
3085} 3094}
3086 3095
diff --git a/drivers/net/wireless/ath5k/dma.c b/drivers/net/wireless/ath5k/dma.c
index 7adceb2c7fab..7e2b1a67e5da 100644
--- a/drivers/net/wireless/ath5k/dma.c
+++ b/drivers/net/wireless/ath5k/dma.c
@@ -472,9 +472,6 @@ bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah)
472 * 472 *
473 * NOTE: We use read-and-clear register, so after this function is called ISR 473 * NOTE: We use read-and-clear register, so after this function is called ISR
474 * is zeroed. 474 * is zeroed.
475 *
476 * XXX: Why filter interrupts in sw with interrupt_mask ? No benefit at all
477 * plus it can be misleading (one might thing that we save interrupts this way)
478 */ 475 */
479int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) 476int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask)
480{ 477{
@@ -494,11 +491,16 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask)
494 } 491 }
495 } else { 492 } else {
496 /* 493 /*
497 * Read interrupt status from the Read-And-Clear 494 * Read interrupt status from Interrupt
498 * shadow register. 495 * Status Register shadow copy (Read And Clear)
496 *
499 * Note: PISR/SISR Not available on 5210 497 * Note: PISR/SISR Not available on 5210
500 */ 498 */
501 data = ath5k_hw_reg_read(ah, AR5K_RAC_PISR); 499 data = ath5k_hw_reg_read(ah, AR5K_RAC_PISR);
500 if (unlikely(data == AR5K_INT_NOCARD)) {
501 *interrupt_mask = data;
502 return -ENODEV;
503 }
502 } 504 }
503 505
504 /* 506 /*
@@ -506,17 +508,9 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask)
506 */ 508 */
507 *interrupt_mask = (data & AR5K_INT_COMMON) & ah->ah_imr; 509 *interrupt_mask = (data & AR5K_INT_COMMON) & ah->ah_imr;
508 510
509 if (unlikely(data == AR5K_INT_NOCARD))
510 return -ENODEV;
511
512 if (data & (AR5K_ISR_RXOK | AR5K_ISR_RXERR))
513 *interrupt_mask |= AR5K_INT_RX;
514
515 if (data & (AR5K_ISR_TXOK | AR5K_ISR_TXERR
516 | AR5K_ISR_TXDESC | AR5K_ISR_TXEOL))
517 *interrupt_mask |= AR5K_INT_TX;
518
519 if (ah->ah_version != AR5K_AR5210) { 511 if (ah->ah_version != AR5K_AR5210) {
512 u32 sisr2 = ath5k_hw_reg_read(ah, AR5K_RAC_SISR2);
513
520 /*HIU = Host Interface Unit (PCI etc)*/ 514 /*HIU = Host Interface Unit (PCI etc)*/
521 if (unlikely(data & (AR5K_ISR_HIUERR))) 515 if (unlikely(data & (AR5K_ISR_HIUERR)))
522 *interrupt_mask |= AR5K_INT_FATAL; 516 *interrupt_mask |= AR5K_INT_FATAL;
@@ -524,24 +518,93 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask)
524 /*Beacon Not Ready*/ 518 /*Beacon Not Ready*/
525 if (unlikely(data & (AR5K_ISR_BNR))) 519 if (unlikely(data & (AR5K_ISR_BNR)))
526 *interrupt_mask |= AR5K_INT_BNR; 520 *interrupt_mask |= AR5K_INT_BNR;
527 }
528 521
529 /* 522 if (unlikely(sisr2 & (AR5K_SISR2_SSERR |
530 * XXX: BMISS interrupts may occur after association. 523 AR5K_SISR2_DPERR |
531 * I found this on 5210 code but it needs testing. If this is 524 AR5K_SISR2_MCABT)))
532 * true we should disable them before assoc and re-enable them 525 *interrupt_mask |= AR5K_INT_FATAL;
533 * after a successfull assoc + some jiffies. 526
534 */ 527 if (data & AR5K_ISR_TIM)
535#if 0 528 *interrupt_mask |= AR5K_INT_TIM;
536 interrupt_mask &= ~AR5K_INT_BMISS; 529
537#endif 530 if (data & AR5K_ISR_BCNMISC) {
531 if (sisr2 & AR5K_SISR2_TIM)
532 *interrupt_mask |= AR5K_INT_TIM;
533 if (sisr2 & AR5K_SISR2_DTIM)
534 *interrupt_mask |= AR5K_INT_DTIM;
535 if (sisr2 & AR5K_SISR2_DTIM_SYNC)
536 *interrupt_mask |= AR5K_INT_DTIM_SYNC;
537 if (sisr2 & AR5K_SISR2_BCN_TIMEOUT)
538 *interrupt_mask |= AR5K_INT_BCN_TIMEOUT;
539 if (sisr2 & AR5K_SISR2_CAB_TIMEOUT)
540 *interrupt_mask |= AR5K_INT_CAB_TIMEOUT;
541 }
542
543 if (data & AR5K_ISR_RXDOPPLER)
544 *interrupt_mask |= AR5K_INT_RX_DOPPLER;
545 if (data & AR5K_ISR_QCBRORN) {
546 *interrupt_mask |= AR5K_INT_QCBRORN;
547 ah->ah_txq_isr |= AR5K_REG_MS(
548 ath5k_hw_reg_read(ah, AR5K_RAC_SISR3),
549 AR5K_SISR3_QCBRORN);
550 }
551 if (data & AR5K_ISR_QCBRURN) {
552 *interrupt_mask |= AR5K_INT_QCBRURN;
553 ah->ah_txq_isr |= AR5K_REG_MS(
554 ath5k_hw_reg_read(ah, AR5K_RAC_SISR3),
555 AR5K_SISR3_QCBRURN);
556 }
557 if (data & AR5K_ISR_QTRIG) {
558 *interrupt_mask |= AR5K_INT_QTRIG;
559 ah->ah_txq_isr |= AR5K_REG_MS(
560 ath5k_hw_reg_read(ah, AR5K_RAC_SISR4),
561 AR5K_SISR4_QTRIG);
562 }
563
564 if (data & AR5K_ISR_TXOK)
565 ah->ah_txq_isr |= AR5K_REG_MS(
566 ath5k_hw_reg_read(ah, AR5K_RAC_SISR0),
567 AR5K_SISR0_QCU_TXOK);
568
569 if (data & AR5K_ISR_TXDESC)
570 ah->ah_txq_isr |= AR5K_REG_MS(
571 ath5k_hw_reg_read(ah, AR5K_RAC_SISR0),
572 AR5K_SISR0_QCU_TXDESC);
573
574 if (data & AR5K_ISR_TXERR)
575 ah->ah_txq_isr |= AR5K_REG_MS(
576 ath5k_hw_reg_read(ah, AR5K_RAC_SISR1),
577 AR5K_SISR1_QCU_TXERR);
578
579 if (data & AR5K_ISR_TXEOL)
580 ah->ah_txq_isr |= AR5K_REG_MS(
581 ath5k_hw_reg_read(ah, AR5K_RAC_SISR1),
582 AR5K_SISR1_QCU_TXEOL);
583
584 if (data & AR5K_ISR_TXURN)
585 ah->ah_txq_isr |= AR5K_REG_MS(
586 ath5k_hw_reg_read(ah, AR5K_RAC_SISR2),
587 AR5K_SISR2_QCU_TXURN);
588 } else {
589 if (unlikely(data & (AR5K_ISR_SSERR | AR5K_ISR_MCABT
590 | AR5K_ISR_HIUERR | AR5K_ISR_DPERR)))
591 *interrupt_mask |= AR5K_INT_FATAL;
592
593 /*
594 * XXX: BMISS interrupts may occur after association.
595 * I found this on 5210 code but it needs testing. If this is
596 * true we should disable them before assoc and re-enable them
597 * after a successfull assoc + some jiffies.
598 interrupt_mask &= ~AR5K_INT_BMISS;
599 */
600 }
538 601
539 /* 602 /*
540 * In case we didn't handle anything, 603 * In case we didn't handle anything,
541 * print the register value. 604 * print the register value.
542 */ 605 */
543 if (unlikely(*interrupt_mask == 0 && net_ratelimit())) 606 if (unlikely(*interrupt_mask == 0 && net_ratelimit()))
544 ATH5K_PRINTF("0x%08x\n", data); 607 ATH5K_PRINTF("ISR: 0x%08x IMR: 0x%08x\n", data, ah->ah_imr);
545 608
546 return 0; 609 return 0;
547} 610}
@@ -560,14 +623,17 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask)
560{ 623{
561 enum ath5k_int old_mask, int_mask; 624 enum ath5k_int old_mask, int_mask;
562 625
626 old_mask = ah->ah_imr;
627
563 /* 628 /*
564 * Disable card interrupts to prevent any race conditions 629 * Disable card interrupts to prevent any race conditions
565 * (they will be re-enabled afterwards). 630 * (they will be re-enabled afterwards if AR5K_INT GLOBAL
631 * is set again on the new mask).
566 */ 632 */
567 ath5k_hw_reg_write(ah, AR5K_IER_DISABLE, AR5K_IER); 633 if (old_mask & AR5K_INT_GLOBAL) {
568 ath5k_hw_reg_read(ah, AR5K_IER); 634 ath5k_hw_reg_write(ah, AR5K_IER_DISABLE, AR5K_IER);
569 635 ath5k_hw_reg_read(ah, AR5K_IER);
570 old_mask = ah->ah_imr; 636 }
571 637
572 /* 638 /*
573 * Add additional, chipset-dependent interrupt mask flags 639 * Add additional, chipset-dependent interrupt mask flags
@@ -575,30 +641,64 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask)
575 */ 641 */
576 int_mask = new_mask & AR5K_INT_COMMON; 642 int_mask = new_mask & AR5K_INT_COMMON;
577 643
578 if (new_mask & AR5K_INT_RX)
579 int_mask |= AR5K_IMR_RXOK | AR5K_IMR_RXERR | AR5K_IMR_RXORN |
580 AR5K_IMR_RXDESC;
581
582 if (new_mask & AR5K_INT_TX)
583 int_mask |= AR5K_IMR_TXOK | AR5K_IMR_TXERR | AR5K_IMR_TXDESC |
584 AR5K_IMR_TXURN;
585
586 if (ah->ah_version != AR5K_AR5210) { 644 if (ah->ah_version != AR5K_AR5210) {
645 /* Preserve per queue TXURN interrupt mask */
646 u32 simr2 = ath5k_hw_reg_read(ah, AR5K_SIMR2)
647 & AR5K_SIMR2_QCU_TXURN;
648
587 if (new_mask & AR5K_INT_FATAL) { 649 if (new_mask & AR5K_INT_FATAL) {
588 int_mask |= AR5K_IMR_HIUERR; 650 int_mask |= AR5K_IMR_HIUERR;
589 AR5K_REG_ENABLE_BITS(ah, AR5K_SIMR2, AR5K_SIMR2_MCABT | 651 simr2 |= (AR5K_SIMR2_MCABT | AR5K_SIMR2_SSERR
590 AR5K_SIMR2_SSERR | AR5K_SIMR2_DPERR); 652 | AR5K_SIMR2_DPERR);
591 } 653 }
654
655 /*Beacon Not Ready*/
656 if (new_mask & AR5K_INT_BNR)
657 int_mask |= AR5K_INT_BNR;
658
659 if (new_mask & AR5K_INT_TIM)
660 int_mask |= AR5K_IMR_TIM;
661
662 if (new_mask & AR5K_INT_TIM)
663 simr2 |= AR5K_SISR2_TIM;
664 if (new_mask & AR5K_INT_DTIM)
665 simr2 |= AR5K_SISR2_DTIM;
666 if (new_mask & AR5K_INT_DTIM_SYNC)
667 simr2 |= AR5K_SISR2_DTIM_SYNC;
668 if (new_mask & AR5K_INT_BCN_TIMEOUT)
669 simr2 |= AR5K_SISR2_BCN_TIMEOUT;
670 if (new_mask & AR5K_INT_CAB_TIMEOUT)
671 simr2 |= AR5K_SISR2_CAB_TIMEOUT;
672
673 if (new_mask & AR5K_INT_RX_DOPPLER)
674 int_mask |= AR5K_IMR_RXDOPPLER;
675
676 /* Note: Per queue interrupt masks
677 * are set via reset_tx_queue (qcu.c) */
678 ath5k_hw_reg_write(ah, int_mask, AR5K_PIMR);
679 ath5k_hw_reg_write(ah, simr2, AR5K_SIMR2);
680
681 } else {
682 if (new_mask & AR5K_INT_FATAL)
683 int_mask |= (AR5K_IMR_SSERR | AR5K_IMR_MCABT
684 | AR5K_IMR_HIUERR | AR5K_IMR_DPERR);
685
686 ath5k_hw_reg_write(ah, int_mask, AR5K_IMR);
592 } 687 }
593 688
594 ath5k_hw_reg_write(ah, int_mask, AR5K_PIMR); 689 /* If RXNOFRM interrupt is masked disable it
690 * by setting AR5K_RXNOFRM to zero */
691 if (!(new_mask & AR5K_INT_RXNOFRM))
692 ath5k_hw_reg_write(ah, 0, AR5K_RXNOFRM);
595 693
596 /* Store new interrupt mask */ 694 /* Store new interrupt mask */
597 ah->ah_imr = new_mask; 695 ah->ah_imr = new_mask;
598 696
599 /* ..re-enable interrupts */ 697 /* ..re-enable interrupts if AR5K_INT_GLOBAL is set */
600 ath5k_hw_reg_write(ah, AR5K_IER_ENABLE, AR5K_IER); 698 if (new_mask & AR5K_INT_GLOBAL) {
601 ath5k_hw_reg_read(ah, AR5K_IER); 699 ath5k_hw_reg_write(ah, AR5K_IER_ENABLE, AR5K_IER);
700 ath5k_hw_reg_read(ah, AR5K_IER);
701 }
602 702
603 return old_mask; 703 return old_mask;
604} 704}
diff --git a/drivers/net/wireless/ath5k/initvals.c b/drivers/net/wireless/ath5k/initvals.c
index ceaa6c475c06..450bd6e945ff 100644
--- a/drivers/net/wireless/ath5k/initvals.c
+++ b/drivers/net/wireless/ath5k/initvals.c
@@ -1681,7 +1681,7 @@ int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel)
1681 */ 1681 */
1682 1682
1683 /* For AR5212 and combatible */ 1683 /* For AR5212 and combatible */
1684 if (ah->ah_version == AR5K_AR5212){ 1684 if (ah->ah_version == AR5K_AR5212) {
1685 1685
1686 /* First set of mode-specific settings */ 1686 /* First set of mode-specific settings */
1687 ath5k_hw_ini_mode_registers(ah, 1687 ath5k_hw_ini_mode_registers(ah,
@@ -1695,7 +1695,7 @@ int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel)
1695 ar5212_ini, change_channel); 1695 ar5212_ini, change_channel);
1696 1696
1697 /* Second set of mode-specific settings */ 1697 /* Second set of mode-specific settings */
1698 if (ah->ah_radio == AR5K_RF5111){ 1698 if (ah->ah_radio == AR5K_RF5111) {
1699 1699
1700 ath5k_hw_ini_mode_registers(ah, 1700 ath5k_hw_ini_mode_registers(ah,
1701 ARRAY_SIZE(ar5212_rf5111_ini_mode_end), 1701 ARRAY_SIZE(ar5212_rf5111_ini_mode_end),
@@ -1706,7 +1706,7 @@ int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel)
1706 ARRAY_SIZE(rf5111_ini_bbgain), 1706 ARRAY_SIZE(rf5111_ini_bbgain),
1707 rf5111_ini_bbgain, change_channel); 1707 rf5111_ini_bbgain, change_channel);
1708 1708
1709 } else if (ah->ah_radio == AR5K_RF5112){ 1709 } else if (ah->ah_radio == AR5K_RF5112) {
1710 1710
1711 ath5k_hw_ini_mode_registers(ah, 1711 ath5k_hw_ini_mode_registers(ah,
1712 ARRAY_SIZE(ar5212_rf5112_ini_mode_end), 1712 ARRAY_SIZE(ar5212_rf5112_ini_mode_end),
@@ -1716,7 +1716,7 @@ int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel)
1716 ARRAY_SIZE(rf5112_ini_bbgain), 1716 ARRAY_SIZE(rf5112_ini_bbgain),
1717 rf5112_ini_bbgain, change_channel); 1717 rf5112_ini_bbgain, change_channel);
1718 1718
1719 } else if (ah->ah_radio == AR5K_RF5413){ 1719 } else if (ah->ah_radio == AR5K_RF5413) {
1720 1720
1721 ath5k_hw_ini_mode_registers(ah, 1721 ath5k_hw_ini_mode_registers(ah,
1722 ARRAY_SIZE(rf5413_ini_mode_end), 1722 ARRAY_SIZE(rf5413_ini_mode_end),
diff --git a/drivers/net/wireless/ath5k/pcu.c b/drivers/net/wireless/ath5k/pcu.c
index a47df9a24aa1..d7f0c1017bda 100644
--- a/drivers/net/wireless/ath5k/pcu.c
+++ b/drivers/net/wireless/ath5k/pcu.c
@@ -46,34 +46,45 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
46{ 46{
47 u32 pcu_reg, beacon_reg, low_id, high_id; 47 u32 pcu_reg, beacon_reg, low_id, high_id;
48 48
49 pcu_reg = 0; 49
50 /* Preserve rest settings */
51 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
52 pcu_reg &= ~(AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_AP
53 | AR5K_STA_ID1_KEYSRCH_MODE
54 | (ah->ah_version == AR5K_AR5210 ?
55 (AR5K_STA_ID1_PWR_SV | AR5K_STA_ID1_NO_PSPOLL) : 0));
56
50 beacon_reg = 0; 57 beacon_reg = 0;
51 58
52 ATH5K_TRACE(ah->ah_sc); 59 ATH5K_TRACE(ah->ah_sc);
53 60
54 switch (ah->ah_op_mode) { 61 switch (ah->ah_op_mode) {
55 case NL80211_IFTYPE_ADHOC: 62 case NL80211_IFTYPE_ADHOC:
56 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_DESC_ANTENNA | 63 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_KEYSRCH_MODE;
57 (ah->ah_version == AR5K_AR5210 ?
58 AR5K_STA_ID1_NO_PSPOLL : 0);
59 beacon_reg |= AR5K_BCR_ADHOC; 64 beacon_reg |= AR5K_BCR_ADHOC;
65 if (ah->ah_version == AR5K_AR5210)
66 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
67 else
68 AR5K_REG_DISABLE_BITS(ah, AR5K_CFG, AR5K_CFG_ADHOC);
60 break; 69 break;
61 70
62 case NL80211_IFTYPE_AP: 71 case NL80211_IFTYPE_AP:
63 case NL80211_IFTYPE_MESH_POINT: 72 case NL80211_IFTYPE_MESH_POINT:
64 pcu_reg |= AR5K_STA_ID1_AP | AR5K_STA_ID1_RTS_DEF_ANTENNA | 73 pcu_reg |= AR5K_STA_ID1_AP | AR5K_STA_ID1_KEYSRCH_MODE;
65 (ah->ah_version == AR5K_AR5210 ?
66 AR5K_STA_ID1_NO_PSPOLL : 0);
67 beacon_reg |= AR5K_BCR_AP; 74 beacon_reg |= AR5K_BCR_AP;
75 if (ah->ah_version == AR5K_AR5210)
76 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
77 else
78 AR5K_REG_ENABLE_BITS(ah, AR5K_CFG, AR5K_CFG_ADHOC);
68 break; 79 break;
69 80
70 case NL80211_IFTYPE_STATION: 81 case NL80211_IFTYPE_STATION:
71 pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA | 82 pcu_reg |= AR5K_STA_ID1_KEYSRCH_MODE
72 (ah->ah_version == AR5K_AR5210 ? 83 | (ah->ah_version == AR5K_AR5210 ?
73 AR5K_STA_ID1_PWR_SV : 0); 84 AR5K_STA_ID1_PWR_SV : 0);
74 case NL80211_IFTYPE_MONITOR: 85 case NL80211_IFTYPE_MONITOR:
75 pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA | 86 pcu_reg |= AR5K_STA_ID1_KEYSRCH_MODE
76 (ah->ah_version == AR5K_AR5210 ? 87 | (ah->ah_version == AR5K_AR5210 ?
77 AR5K_STA_ID1_NO_PSPOLL : 0); 88 AR5K_STA_ID1_NO_PSPOLL : 0);
78 break; 89 break;
79 90
@@ -130,6 +141,8 @@ void ath5k_hw_update_mib_counters(struct ath5k_hw *ah,
130 ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_RXCLR); 141 ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_RXCLR);
131 ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_CYCLE); 142 ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_CYCLE);
132 } 143 }
144
145 /* TODO: Handle ANI stats */
133} 146}
134 147
135/** 148/**
@@ -254,6 +267,10 @@ void ath5k_hw_get_lladdr(struct ath5k_hw *ah, u8 *mac)
254 * @mac: The card's mac address 267 * @mac: The card's mac address
255 * 268 *
256 * Set station id on hw using the provided mac address 269 * Set station id on hw using the provided mac address
270 *
271 * NOTE: This is only called during attach, don't call it
272 * on reset because it overwrites all AR5K_STA_ID1 settings.
273 * We have set_opmode (above) for reset.
257 */ 274 */
258int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac) 275int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac)
259{ 276{
@@ -290,8 +307,10 @@ void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc_id)
290 * Set simple BSSID mask on 5212 307 * Set simple BSSID mask on 5212
291 */ 308 */
292 if (ah->ah_version == AR5K_AR5212) { 309 if (ah->ah_version == AR5K_AR5212) {
293 ath5k_hw_reg_write(ah, 0xffffffff, AR5K_BSS_IDM0); 310 ath5k_hw_reg_write(ah, AR5K_LOW_ID(ah->ah_bssid_mask),
294 ath5k_hw_reg_write(ah, 0xffffffff, AR5K_BSS_IDM1); 311 AR5K_BSS_IDM0);
312 ath5k_hw_reg_write(ah, AR5K_HIGH_ID(ah->ah_bssid_mask),
313 AR5K_BSS_IDM1);
295 } 314 }
296 315
297 /* 316 /*
@@ -415,6 +434,9 @@ int ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask)
415 u32 low_id, high_id; 434 u32 low_id, high_id;
416 ATH5K_TRACE(ah->ah_sc); 435 ATH5K_TRACE(ah->ah_sc);
417 436
437 /* Cache bssid mask so that we can restore it
438 * on reset */
439 memcpy(ah->ah_bssid_mask, mask, ETH_ALEN);
418 if (ah->ah_version == AR5K_AR5212) { 440 if (ah->ah_version == AR5K_AR5212) {
419 low_id = AR5K_LOW_ID(mask); 441 low_id = AR5K_LOW_ID(mask);
420 high_id = AR5K_HIGH_ID(mask); 442 high_id = AR5K_HIGH_ID(mask);
@@ -576,7 +598,7 @@ void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter)
576 filter |= AR5K_RX_FILTER_PROM; 598 filter |= AR5K_RX_FILTER_PROM;
577 } 599 }
578 600
579 /*Zero length DMA*/ 601 /*Zero length DMA (phy error reporting) */
580 if (data) 602 if (data)
581 AR5K_REG_ENABLE_BITS(ah, AR5K_RXCFG, AR5K_RXCFG_ZLFDMA); 603 AR5K_REG_ENABLE_BITS(ah, AR5K_RXCFG, AR5K_RXCFG_ZLFDMA);
582 else 604 else
@@ -661,7 +683,12 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
661 * Set the additional timers by mode 683 * Set the additional timers by mode
662 */ 684 */
663 switch (ah->ah_op_mode) { 685 switch (ah->ah_op_mode) {
686 case NL80211_IFTYPE_MONITOR:
664 case NL80211_IFTYPE_STATION: 687 case NL80211_IFTYPE_STATION:
688 /* In STA mode timer1 is used as next wakeup
689 * timer and timer2 as next CFP duration start
690 * timer. Both in 1/8TUs. */
691 /* TODO: PCF handling */
665 if (ah->ah_version == AR5K_AR5210) { 692 if (ah->ah_version == AR5K_AR5210) {
666 timer1 = 0xffffffff; 693 timer1 = 0xffffffff;
667 timer2 = 0xffffffff; 694 timer2 = 0xffffffff;
@@ -669,27 +696,60 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
669 timer1 = 0x0000ffff; 696 timer1 = 0x0000ffff;
670 timer2 = 0x0007ffff; 697 timer2 = 0x0007ffff;
671 } 698 }
699 /* Mark associated AP as PCF incapable for now */
700 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PCF);
672 break; 701 break;
673 702 case NL80211_IFTYPE_ADHOC:
703 AR5K_REG_ENABLE_BITS(ah, AR5K_TXCFG, AR5K_TXCFG_ADHOC_BCN_ATIM);
674 default: 704 default:
705 /* On non-STA modes timer1 is used as next DMA
706 * beacon alert (DBA) timer and timer2 as next
707 * software beacon alert. Both in 1/8TUs. */
675 timer1 = (next_beacon - AR5K_TUNE_DMA_BEACON_RESP) << 3; 708 timer1 = (next_beacon - AR5K_TUNE_DMA_BEACON_RESP) << 3;
676 timer2 = (next_beacon - AR5K_TUNE_SW_BEACON_RESP) << 3; 709 timer2 = (next_beacon - AR5K_TUNE_SW_BEACON_RESP) << 3;
710 break;
677 } 711 }
678 712
713 /* Timer3 marks the end of our ATIM window
714 * a zero length window is not allowed because
715 * we 'll get no beacons */
679 timer3 = next_beacon + (ah->ah_atim_window ? ah->ah_atim_window : 1); 716 timer3 = next_beacon + (ah->ah_atim_window ? ah->ah_atim_window : 1);
680 717
681 /* 718 /*
682 * Set the beacon register and enable all timers. 719 * Set the beacon register and enable all timers.
683 * (next beacon, DMA beacon, software beacon, ATIM window time)
684 */ 720 */
685 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0); 721 /* When in AP mode zero timer0 to start TSF */
722 if (ah->ah_op_mode == NL80211_IFTYPE_AP)
723 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0);
724 else
725 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
686 ath5k_hw_reg_write(ah, timer1, AR5K_TIMER1); 726 ath5k_hw_reg_write(ah, timer1, AR5K_TIMER1);
687 ath5k_hw_reg_write(ah, timer2, AR5K_TIMER2); 727 ath5k_hw_reg_write(ah, timer2, AR5K_TIMER2);
688 ath5k_hw_reg_write(ah, timer3, AR5K_TIMER3); 728 ath5k_hw_reg_write(ah, timer3, AR5K_TIMER3);
689 729
730 /* Force a TSF reset if requested and enable beacons */
731 if (interval & AR5K_BEACON_RESET_TSF)
732 ath5k_hw_reset_tsf(ah);
733
690 ath5k_hw_reg_write(ah, interval & (AR5K_BEACON_PERIOD | 734 ath5k_hw_reg_write(ah, interval & (AR5K_BEACON_PERIOD |
691 AR5K_BEACON_RESET_TSF | AR5K_BEACON_ENABLE), 735 AR5K_BEACON_ENABLE),
692 AR5K_BEACON); 736 AR5K_BEACON);
737
738 /* Flush any pending BMISS interrupts on ISR by
739 * performing a clear-on-write operation on PISR
740 * register for the BMISS bit (writing a bit on
741 * ISR togles a reset for that bit and leaves
742 * the rest bits intact) */
743 if (ah->ah_version == AR5K_AR5210)
744 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_ISR);
745 else
746 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_PISR);
747
748 /* TODO: Set enchanced sleep registers on AR5212
749 * based on vif->bss_conf params, until then
750 * disable power save reporting.*/
751 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PWR_SV);
752
693} 753}
694 754
695#if 0 755#if 0
@@ -899,14 +959,26 @@ int ath5k_hw_beaconq_finish(struct ath5k_hw *ah, unsigned long phys_addr)
899 */ 959 */
900int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry) 960int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry)
901{ 961{
902 unsigned int i; 962 unsigned int i, type;
963 u16 micentry = entry + AR5K_KEYTABLE_MIC_OFFSET;
903 964
904 ATH5K_TRACE(ah->ah_sc); 965 ATH5K_TRACE(ah->ah_sc);
905 AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE); 966 AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE);
906 967
968 type = ath5k_hw_reg_read(ah, AR5K_KEYTABLE_TYPE(entry));
969
907 for (i = 0; i < AR5K_KEYCACHE_SIZE; i++) 970 for (i = 0; i < AR5K_KEYCACHE_SIZE; i++)
908 ath5k_hw_reg_write(ah, 0, AR5K_KEYTABLE_OFF(entry, i)); 971 ath5k_hw_reg_write(ah, 0, AR5K_KEYTABLE_OFF(entry, i));
909 972
973 /* Reset associated MIC entry if TKIP
974 * is enabled located at offset (entry + 64) */
975 if (type == AR5K_KEYTABLE_TYPE_TKIP) {
976 AR5K_ASSERT_ENTRY(micentry, AR5K_KEYTABLE_SIZE);
977 for (i = 0; i < AR5K_KEYCACHE_SIZE / 2 ; i++)
978 ath5k_hw_reg_write(ah, 0,
979 AR5K_KEYTABLE_OFF(micentry, i));
980 }
981
910 /* 982 /*
911 * Set NULL encryption on AR5212+ 983 * Set NULL encryption on AR5212+
912 * 984 *
@@ -916,10 +988,16 @@ int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry)
916 * Note2: Windows driver (ndiswrapper) sets this to 988 * Note2: Windows driver (ndiswrapper) sets this to
917 * 0x00000714 instead of 0x00000007 989 * 0x00000714 instead of 0x00000007
918 */ 990 */
919 if (ah->ah_version > AR5K_AR5211) 991 if (ah->ah_version > AR5K_AR5211) {
920 ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL, 992 ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL,
921 AR5K_KEYTABLE_TYPE(entry)); 993 AR5K_KEYTABLE_TYPE(entry));
922 994
995 if (type == AR5K_KEYTABLE_TYPE_TKIP) {
996 ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL,
997 AR5K_KEYTABLE_TYPE(micentry));
998 }
999 }
1000
923 return 0; 1001 return 0;
924} 1002}
925 1003
@@ -943,17 +1021,29 @@ int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry,
943 const struct ieee80211_key_conf *key, const u8 *mac) 1021 const struct ieee80211_key_conf *key, const u8 *mac)
944{ 1022{
945 unsigned int i; 1023 unsigned int i;
1024 int keylen;
946 __le32 key_v[5] = {}; 1025 __le32 key_v[5] = {};
1026 __le32 key0 = 0, key1 = 0;
1027 __le32 *rxmic, *txmic;
947 u32 keytype; 1028 u32 keytype;
1029 u16 micentry = entry + AR5K_KEYTABLE_MIC_OFFSET;
1030 bool is_tkip;
948 1031
949 ATH5K_TRACE(ah->ah_sc); 1032 ATH5K_TRACE(ah->ah_sc);
950 1033
951 /* key->keylen comes in from mac80211 in bytes */ 1034 is_tkip = (key->alg == ALG_TKIP);
1035
1036 /*
1037 * key->keylen comes in from mac80211 in bytes.
1038 * TKIP is 128 bit + 128 bit mic
1039 */
1040 keylen = (is_tkip) ? (128 / 8) : key->keylen;
952 1041
953 if (key->keylen > AR5K_KEYTABLE_SIZE / 8) 1042 if (entry > AR5K_KEYTABLE_SIZE ||
1043 (is_tkip && micentry > AR5K_KEYTABLE_SIZE))
954 return -EOPNOTSUPP; 1044 return -EOPNOTSUPP;
955 1045
956 switch (key->keylen) { 1046 switch (keylen) {
957 /* WEP 40-bit = 40-bit entered key + 24 bit IV = 64-bit */ 1047 /* WEP 40-bit = 40-bit entered key + 24 bit IV = 64-bit */
958 case 40 / 8: 1048 case 40 / 8:
959 memcpy(&key_v[0], key->key, 5); 1049 memcpy(&key_v[0], key->key, 5);
@@ -967,24 +1057,66 @@ int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry,
967 memcpy(&key_v[4], &key->key[12], 1); 1057 memcpy(&key_v[4], &key->key[12], 1);
968 keytype = AR5K_KEYTABLE_TYPE_104; 1058 keytype = AR5K_KEYTABLE_TYPE_104;
969 break; 1059 break;
970 /* WEP 128-bit = 128-bit entered key + 24 bit IV = 152-bit */ 1060 /* WEP/TKIP 128-bit = 128-bit entered key + 24 bit IV = 152-bit */
971 case 128 / 8: 1061 case 128 / 8:
972 memcpy(&key_v[0], &key->key[0], 6); 1062 memcpy(&key_v[0], &key->key[0], 6);
973 memcpy(&key_v[2], &key->key[6], 6); 1063 memcpy(&key_v[2], &key->key[6], 6);
974 memcpy(&key_v[4], &key->key[12], 4); 1064 memcpy(&key_v[4], &key->key[12], 4);
975 keytype = AR5K_KEYTABLE_TYPE_128; 1065 keytype = is_tkip ?
1066 AR5K_KEYTABLE_TYPE_TKIP :
1067 AR5K_KEYTABLE_TYPE_128;
976 break; 1068 break;
977 1069
978 default: 1070 default:
979 return -EINVAL; /* shouldn't happen */ 1071 return -EINVAL; /* shouldn't happen */
980 } 1072 }
981 1073
1074 /* intentionally corrupt key until mic is installed */
1075 if (is_tkip) {
1076 key0 = key_v[0] = ~key_v[0];
1077 key1 = key_v[1] = ~key_v[1];
1078 }
1079
982 for (i = 0; i < ARRAY_SIZE(key_v); i++) 1080 for (i = 0; i < ARRAY_SIZE(key_v); i++)
983 ath5k_hw_reg_write(ah, le32_to_cpu(key_v[i]), 1081 ath5k_hw_reg_write(ah, le32_to_cpu(key_v[i]),
984 AR5K_KEYTABLE_OFF(entry, i)); 1082 AR5K_KEYTABLE_OFF(entry, i));
985 1083
986 ath5k_hw_reg_write(ah, keytype, AR5K_KEYTABLE_TYPE(entry)); 1084 ath5k_hw_reg_write(ah, keytype, AR5K_KEYTABLE_TYPE(entry));
987 1085
1086 if (is_tkip) {
1087 /* Install rx/tx MIC */
1088 rxmic = (__le32 *) &key->key[16];
1089 txmic = (__le32 *) &key->key[24];
1090#if 0
1091 /* MISC_MODE register & 0x04 - for mac srev >= griffin */
1092 key_v[0] = rxmic[0];
1093 key_v[1] = (txmic[0] >> 16) & 0xffff;
1094 key_v[2] = rxmic[1];
1095 key_v[3] = txmic[0] & 0xffff;
1096 key_v[4] = txmic[1];
1097#else
1098 key_v[0] = rxmic[0];
1099 key_v[1] = 0;
1100 key_v[2] = rxmic[1];
1101 key_v[3] = 0;
1102 key_v[4] = 0;
1103#endif
1104 for (i = 0; i < ARRAY_SIZE(key_v); i++)
1105 ath5k_hw_reg_write(ah, le32_to_cpu(key_v[i]),
1106 AR5K_KEYTABLE_OFF(micentry, i));
1107
1108 ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL,
1109 AR5K_KEYTABLE_TYPE(micentry));
1110 ath5k_hw_reg_write(ah, 0, AR5K_KEYTABLE_MAC0(micentry));
1111 ath5k_hw_reg_write(ah, 0, AR5K_KEYTABLE_MAC1(micentry));
1112
1113 /* restore first 2 words of key */
1114 ath5k_hw_reg_write(ah, le32_to_cpu(~key0),
1115 AR5K_KEYTABLE_OFF(entry, 0));
1116 ath5k_hw_reg_write(ah, le32_to_cpu(~key1),
1117 AR5K_KEYTABLE_OFF(entry, 1));
1118 }
1119
988 return ath5k_hw_set_key_lladdr(ah, entry, mac); 1120 return ath5k_hw_set_key_lladdr(ah, entry, mac);
989} 1121}
990 1122
diff --git a/drivers/net/wireless/ath5k/phy.c b/drivers/net/wireless/ath5k/phy.c
index e43f6563e61a..69625bf4d11c 100644
--- a/drivers/net/wireless/ath5k/phy.c
+++ b/drivers/net/wireless/ath5k/phy.c
@@ -1412,7 +1412,8 @@ static int ath5k_hw_rf5112_rfregs(struct ath5k_hw *ah,
1412 rf_ini = rfregs_2112a; 1412 rf_ini = rfregs_2112a;
1413 rf_size = ARRAY_SIZE(rfregs_5112a); 1413 rf_size = ARRAY_SIZE(rfregs_5112a);
1414 if (mode < 2) { 1414 if (mode < 2) {
1415 ATH5K_ERR(ah->ah_sc,"invalid channel mode: %i\n",mode); 1415 ATH5K_ERR(ah->ah_sc, "invalid channel mode: %i\n",
1416 mode);
1416 return -EINVAL; 1417 return -EINVAL;
1417 } 1418 }
1418 mode = mode - 2; /*no a/turboa modes for 2112*/ 1419 mode = mode - 2; /*no a/turboa modes for 2112*/
@@ -1708,7 +1709,7 @@ enum ath5k_rfgain ath5k_hw_get_rf_gain(struct ath5k_hw *ah)
1708 if (ah->ah_radio >= AR5K_RF5112) { 1709 if (ah->ah_radio >= AR5K_RF5112) {
1709 ath5k_hw_rfregs_gainf_corr(ah); 1710 ath5k_hw_rfregs_gainf_corr(ah);
1710 ah->ah_gain.g_current = 1711 ah->ah_gain.g_current =
1711 ah->ah_gain.g_current>=ah->ah_gain.g_f_corr ? 1712 ah->ah_gain.g_current >= ah->ah_gain.g_f_corr ?
1712 (ah->ah_gain.g_current-ah->ah_gain.g_f_corr) : 1713 (ah->ah_gain.g_current-ah->ah_gain.g_f_corr) :
1713 0; 1714 0;
1714 } 1715 }
diff --git a/drivers/net/wireless/ath5k/qcu.c b/drivers/net/wireless/ath5k/qcu.c
index 01bf09176d23..1b7bc50ea8eb 100644
--- a/drivers/net/wireless/ath5k/qcu.c
+++ b/drivers/net/wireless/ath5k/qcu.c
@@ -432,13 +432,30 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue)
432 if (tq->tqi_flags & AR5K_TXQ_FLAG_TXEOLINT_ENABLE) 432 if (tq->tqi_flags & AR5K_TXQ_FLAG_TXEOLINT_ENABLE)
433 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txeol, queue); 433 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txeol, queue);
434 434
435 if (tq->tqi_flags & AR5K_TXQ_FLAG_CBRORNINT_ENABLE)
436 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_cbrorn, queue);
437
438 if (tq->tqi_flags & AR5K_TXQ_FLAG_CBRURNINT_ENABLE)
439 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_cbrurn, queue);
440
441 if (tq->tqi_flags & AR5K_TXQ_FLAG_QTRIGINT_ENABLE)
442 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_qtrig, queue);
443
444 if (tq->tqi_flags & AR5K_TXQ_FLAG_TXNOFRMINT_ENABLE)
445 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_nofrm, queue);
435 446
436 /* Update secondary interrupt mask registers */ 447 /* Update secondary interrupt mask registers */
448
449 /* Filter out inactive queues */
437 ah->ah_txq_imr_txok &= ah->ah_txq_status; 450 ah->ah_txq_imr_txok &= ah->ah_txq_status;
438 ah->ah_txq_imr_txerr &= ah->ah_txq_status; 451 ah->ah_txq_imr_txerr &= ah->ah_txq_status;
439 ah->ah_txq_imr_txurn &= ah->ah_txq_status; 452 ah->ah_txq_imr_txurn &= ah->ah_txq_status;
440 ah->ah_txq_imr_txdesc &= ah->ah_txq_status; 453 ah->ah_txq_imr_txdesc &= ah->ah_txq_status;
441 ah->ah_txq_imr_txeol &= ah->ah_txq_status; 454 ah->ah_txq_imr_txeol &= ah->ah_txq_status;
455 ah->ah_txq_imr_cbrorn &= ah->ah_txq_status;
456 ah->ah_txq_imr_cbrurn &= ah->ah_txq_status;
457 ah->ah_txq_imr_qtrig &= ah->ah_txq_status;
458 ah->ah_txq_imr_nofrm &= ah->ah_txq_status;
442 459
443 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_txok, 460 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_txok,
444 AR5K_SIMR0_QCU_TXOK) | 461 AR5K_SIMR0_QCU_TXOK) |
@@ -448,8 +465,24 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue)
448 AR5K_SIMR1_QCU_TXERR) | 465 AR5K_SIMR1_QCU_TXERR) |
449 AR5K_REG_SM(ah->ah_txq_imr_txeol, 466 AR5K_REG_SM(ah->ah_txq_imr_txeol,
450 AR5K_SIMR1_QCU_TXEOL), AR5K_SIMR1); 467 AR5K_SIMR1_QCU_TXEOL), AR5K_SIMR1);
451 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_txurn, 468 /* Update simr2 but don't overwrite rest simr2 settings */
452 AR5K_SIMR2_QCU_TXURN), AR5K_SIMR2); 469 AR5K_REG_DISABLE_BITS(ah, AR5K_SIMR2, AR5K_SIMR2_QCU_TXURN);
470 AR5K_REG_ENABLE_BITS(ah, AR5K_SIMR2,
471 AR5K_REG_SM(ah->ah_txq_imr_txurn,
472 AR5K_SIMR2_QCU_TXURN));
473 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_cbrorn,
474 AR5K_SIMR3_QCBRORN) |
475 AR5K_REG_SM(ah->ah_txq_imr_cbrurn,
476 AR5K_SIMR3_QCBRURN), AR5K_SIMR3);
477 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_qtrig,
478 AR5K_SIMR4_QTRIG), AR5K_SIMR4);
479 /* Set TXNOFRM_QCU for the queues with TXNOFRM enabled */
480 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_nofrm,
481 AR5K_TXNOFRM_QCU), AR5K_TXNOFRM);
482 /* No queue has TXNOFRM enabled, disable the interrupt
483 * by setting AR5K_TXNOFRM to zero */
484 if (ah->ah_txq_imr_nofrm == 0)
485 ath5k_hw_reg_write(ah, 0, AR5K_TXNOFRM);
453 } 486 }
454 487
455 return 0; 488 return 0;
diff --git a/drivers/net/wireless/ath5k/reg.h b/drivers/net/wireless/ath5k/reg.h
index e557fe178bbf..69755fc2f9be 100644
--- a/drivers/net/wireless/ath5k/reg.h
+++ b/drivers/net/wireless/ath5k/reg.h
@@ -234,6 +234,7 @@
234#define AR5K_TXNOFRM 0x004c 234#define AR5K_TXNOFRM 0x004c
235#define AR5K_TXNOFRM_M 0x000003ff 235#define AR5K_TXNOFRM_M 0x000003ff
236#define AR5K_TXNOFRM_QCU 0x000ffc00 236#define AR5K_TXNOFRM_QCU 0x000ffc00
237#define AR5K_TXNOFRM_QCU_S 10
237 238
238/* 239/*
239 * Receive frame gap timeout register 240 * Receive frame gap timeout register
@@ -350,7 +351,7 @@
350 351
351#define AR5K_SISR3 0x0090 /* Register Address [5211+] */ 352#define AR5K_SISR3 0x0090 /* Register Address [5211+] */
352#define AR5K_SISR3_QCBRORN 0x000003ff /* Mask for QCBRORN */ 353#define AR5K_SISR3_QCBRORN 0x000003ff /* Mask for QCBRORN */
353#define AR5K_SISR3_QCBORN_S 0 354#define AR5K_SISR3_QCBRORN_S 0
354#define AR5K_SISR3_QCBRURN 0x03ff0000 /* Mask for QCBRURN */ 355#define AR5K_SISR3_QCBRURN 0x03ff0000 /* Mask for QCBRURN */
355#define AR5K_SISR3_QCBRURN_S 16 356#define AR5K_SISR3_QCBRURN_S 16
356 357
@@ -1113,14 +1114,16 @@
1113#define AR5K_PCU_MAX 0x8fff 1114#define AR5K_PCU_MAX 0x8fff
1114 1115
1115/* 1116/*
1116 * First station id register (MAC address in lower 32 bits) 1117 * First station id register (Lower 32 bits of MAC address)
1117 */ 1118 */
1118#define AR5K_STA_ID0 0x8000 1119#define AR5K_STA_ID0 0x8000
1120#define AR5K_STA_ID0_ARRD_L32 0xffffffff
1119 1121
1120/* 1122/*
1121 * Second station id register (MAC address in upper 16 bits) 1123 * Second station id register (Upper 16 bits of MAC address + PCU settings)
1122 */ 1124 */
1123#define AR5K_STA_ID1 0x8004 /* Register Address */ 1125#define AR5K_STA_ID1 0x8004 /* Register Address */
1126#define AR5K_STA_ID1_ADDR_U16 0x0000ffff /* Upper 16 bits of MAC addres */
1124#define AR5K_STA_ID1_AP 0x00010000 /* Set AP mode */ 1127#define AR5K_STA_ID1_AP 0x00010000 /* Set AP mode */
1125#define AR5K_STA_ID1_ADHOC 0x00020000 /* Set Ad-Hoc mode */ 1128#define AR5K_STA_ID1_ADHOC 0x00020000 /* Set Ad-Hoc mode */
1126#define AR5K_STA_ID1_PWR_SV 0x00040000 /* Power save reporting */ 1129#define AR5K_STA_ID1_PWR_SV 0x00040000 /* Power save reporting */
@@ -1810,6 +1813,10 @@
1810#define AR5K_KEYTABLE_MAC1(_n) AR5K_KEYTABLE_OFF(_n, 7) 1813#define AR5K_KEYTABLE_MAC1(_n) AR5K_KEYTABLE_OFF(_n, 7)
1811#define AR5K_KEYTABLE_VALID 0x00008000 1814#define AR5K_KEYTABLE_VALID 0x00008000
1812 1815
1816/* If key type is TKIP and MIC is enabled
1817 * MIC key goes in offset entry + 64 */
1818#define AR5K_KEYTABLE_MIC_OFFSET 64
1819
1813/* WEP 40-bit = 40-bit entered key + 24 bit IV = 64-bit 1820/* WEP 40-bit = 40-bit entered key + 24 bit IV = 64-bit
1814 * WEP 104-bit = 104-bit entered key + 24-bit IV = 128-bit 1821 * WEP 104-bit = 104-bit entered key + 24-bit IV = 128-bit
1815 * WEP 128-bit = 128-bit entered key + 24 bit IV = 152-bit 1822 * WEP 128-bit = 128-bit entered key + 24 bit IV = 152-bit
diff --git a/drivers/net/wireless/ath5k/reset.c b/drivers/net/wireless/ath5k/reset.c
index 1b6d45b6772d..b51bc030da02 100644
--- a/drivers/net/wireless/ath5k/reset.c
+++ b/drivers/net/wireless/ath5k/reset.c
@@ -864,8 +864,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
864 864
865 /* Pre-enable interrupts on 5211/5212*/ 865 /* Pre-enable interrupts on 5211/5212*/
866 if (ah->ah_version != AR5K_AR5210) 866 if (ah->ah_version != AR5K_AR5210)
867 ath5k_hw_set_imr(ah, AR5K_INT_RX | AR5K_INT_TX | 867 ath5k_hw_set_imr(ah, ah->ah_imr);
868 AR5K_INT_FATAL);
869 868
870 /* 869 /*
871 * Set RF kill flags if supported by the device (read from the EEPROM) 870 * Set RF kill flags if supported by the device (read from the EEPROM)
diff --git a/drivers/net/wireless/ath9k/Makefile b/drivers/net/wireless/ath9k/Makefile
index a6411517e5f8..c58cfdeb49c9 100644
--- a/drivers/net/wireless/ath9k/Makefile
+++ b/drivers/net/wireless/ath9k/Makefile
@@ -1,4 +1,8 @@
1ath9k-y += hw.o \ 1ath9k-y += hw.o \
2 eeprom.o \
3 mac.o \
4 calib.o \
5 ani.o \
2 phy.o \ 6 phy.o \
3 regd.o \ 7 regd.o \
4 beacon.o \ 8 beacon.o \
diff --git a/drivers/net/wireless/ath9k/ani.c b/drivers/net/wireless/ath9k/ani.c
new file mode 100644
index 000000000000..ada12e9aa7f9
--- /dev/null
+++ b/drivers/net/wireless/ath9k/ani.c
@@ -0,0 +1,854 @@
1/*
2 * Copyright (c) 2008 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "core.h"
18#include "hw.h"
19#include "reg.h"
20#include "phy.h"
21
22static int ath9k_hw_get_ani_channel_idx(struct ath_hal *ah,
23 struct ath9k_channel *chan)
24{
25 struct ath_hal_5416 *ahp = AH5416(ah);
26 int i;
27
28 for (i = 0; i < ARRAY_SIZE(ahp->ah_ani); i++) {
29 if (ahp->ah_ani[i].c.channel == chan->channel)
30 return i;
31 if (ahp->ah_ani[i].c.channel == 0) {
32 ahp->ah_ani[i].c.channel = chan->channel;
33 ahp->ah_ani[i].c.channelFlags = chan->channelFlags;
34 return i;
35 }
36 }
37
38 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
39 "No more channel states left. Using channel 0\n");
40
41 return 0;
42}
43
44static bool ath9k_hw_ani_control(struct ath_hal *ah,
45 enum ath9k_ani_cmd cmd, int param)
46{
47 struct ath_hal_5416 *ahp = AH5416(ah);
48 struct ar5416AniState *aniState = ahp->ah_curani;
49
50 switch (cmd & ahp->ah_ani_function) {
51 case ATH9K_ANI_NOISE_IMMUNITY_LEVEL:{
52 u32 level = param;
53
54 if (level >= ARRAY_SIZE(ahp->ah_totalSizeDesired)) {
55 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
56 "%s: level out of range (%u > %u)\n",
57 __func__, level,
58 (unsigned)ARRAY_SIZE(ahp->ah_totalSizeDesired));
59 return false;
60 }
61
62 REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ,
63 AR_PHY_DESIRED_SZ_TOT_DES,
64 ahp->ah_totalSizeDesired[level]);
65 REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
66 AR_PHY_AGC_CTL1_COARSE_LOW,
67 ahp->ah_coarseLow[level]);
68 REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
69 AR_PHY_AGC_CTL1_COARSE_HIGH,
70 ahp->ah_coarseHigh[level]);
71 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
72 AR_PHY_FIND_SIG_FIRPWR,
73 ahp->ah_firpwr[level]);
74
75 if (level > aniState->noiseImmunityLevel)
76 ahp->ah_stats.ast_ani_niup++;
77 else if (level < aniState->noiseImmunityLevel)
78 ahp->ah_stats.ast_ani_nidown++;
79 aniState->noiseImmunityLevel = level;
80 break;
81 }
82 case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{
83 const int m1ThreshLow[] = { 127, 50 };
84 const int m2ThreshLow[] = { 127, 40 };
85 const int m1Thresh[] = { 127, 0x4d };
86 const int m2Thresh[] = { 127, 0x40 };
87 const int m2CountThr[] = { 31, 16 };
88 const int m2CountThrLow[] = { 63, 48 };
89 u32 on = param ? 1 : 0;
90
91 REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
92 AR_PHY_SFCORR_LOW_M1_THRESH_LOW,
93 m1ThreshLow[on]);
94 REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
95 AR_PHY_SFCORR_LOW_M2_THRESH_LOW,
96 m2ThreshLow[on]);
97 REG_RMW_FIELD(ah, AR_PHY_SFCORR,
98 AR_PHY_SFCORR_M1_THRESH,
99 m1Thresh[on]);
100 REG_RMW_FIELD(ah, AR_PHY_SFCORR,
101 AR_PHY_SFCORR_M2_THRESH,
102 m2Thresh[on]);
103 REG_RMW_FIELD(ah, AR_PHY_SFCORR,
104 AR_PHY_SFCORR_M2COUNT_THR,
105 m2CountThr[on]);
106 REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
107 AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW,
108 m2CountThrLow[on]);
109
110 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
111 AR_PHY_SFCORR_EXT_M1_THRESH_LOW,
112 m1ThreshLow[on]);
113 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
114 AR_PHY_SFCORR_EXT_M2_THRESH_LOW,
115 m2ThreshLow[on]);
116 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
117 AR_PHY_SFCORR_EXT_M1_THRESH,
118 m1Thresh[on]);
119 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
120 AR_PHY_SFCORR_EXT_M2_THRESH,
121 m2Thresh[on]);
122
123 if (on)
124 REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
125 AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
126 else
127 REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW,
128 AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
129
130 if (!on != aniState->ofdmWeakSigDetectOff) {
131 if (on)
132 ahp->ah_stats.ast_ani_ofdmon++;
133 else
134 ahp->ah_stats.ast_ani_ofdmoff++;
135 aniState->ofdmWeakSigDetectOff = !on;
136 }
137 break;
138 }
139 case ATH9K_ANI_CCK_WEAK_SIGNAL_THR:{
140 const int weakSigThrCck[] = { 8, 6 };
141 u32 high = param ? 1 : 0;
142
143 REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT,
144 AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK,
145 weakSigThrCck[high]);
146 if (high != aniState->cckWeakSigThreshold) {
147 if (high)
148 ahp->ah_stats.ast_ani_cckhigh++;
149 else
150 ahp->ah_stats.ast_ani_ccklow++;
151 aniState->cckWeakSigThreshold = high;
152 }
153 break;
154 }
155 case ATH9K_ANI_FIRSTEP_LEVEL:{
156 const int firstep[] = { 0, 4, 8 };
157 u32 level = param;
158
159 if (level >= ARRAY_SIZE(firstep)) {
160 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
161 "%s: level out of range (%u > %u)\n",
162 __func__, level,
163 (unsigned) ARRAY_SIZE(firstep));
164 return false;
165 }
166 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
167 AR_PHY_FIND_SIG_FIRSTEP,
168 firstep[level]);
169 if (level > aniState->firstepLevel)
170 ahp->ah_stats.ast_ani_stepup++;
171 else if (level < aniState->firstepLevel)
172 ahp->ah_stats.ast_ani_stepdown++;
173 aniState->firstepLevel = level;
174 break;
175 }
176 case ATH9K_ANI_SPUR_IMMUNITY_LEVEL:{
177 const int cycpwrThr1[] =
178 { 2, 4, 6, 8, 10, 12, 14, 16 };
179 u32 level = param;
180
181 if (level >= ARRAY_SIZE(cycpwrThr1)) {
182 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
183 "%s: level out of range (%u > %u)\n",
184 __func__, level,
185 (unsigned)
186 ARRAY_SIZE(cycpwrThr1));
187 return false;
188 }
189 REG_RMW_FIELD(ah, AR_PHY_TIMING5,
190 AR_PHY_TIMING5_CYCPWR_THR1,
191 cycpwrThr1[level]);
192 if (level > aniState->spurImmunityLevel)
193 ahp->ah_stats.ast_ani_spurup++;
194 else if (level < aniState->spurImmunityLevel)
195 ahp->ah_stats.ast_ani_spurdown++;
196 aniState->spurImmunityLevel = level;
197 break;
198 }
199 case ATH9K_ANI_PRESENT:
200 break;
201 default:
202 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
203 "%s: invalid cmd %u\n", __func__, cmd);
204 return false;
205 }
206
207 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "%s: ANI parameters:\n", __func__);
208 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
209 "noiseImmunityLevel=%d, spurImmunityLevel=%d, "
210 "ofdmWeakSigDetectOff=%d\n",
211 aniState->noiseImmunityLevel, aniState->spurImmunityLevel,
212 !aniState->ofdmWeakSigDetectOff);
213 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
214 "cckWeakSigThreshold=%d, "
215 "firstepLevel=%d, listenTime=%d\n",
216 aniState->cckWeakSigThreshold, aniState->firstepLevel,
217 aniState->listenTime);
218 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
219 "cycleCount=%d, ofdmPhyErrCount=%d, cckPhyErrCount=%d\n\n",
220 aniState->cycleCount, aniState->ofdmPhyErrCount,
221 aniState->cckPhyErrCount);
222
223 return true;
224}
225
226static void ath9k_hw_update_mibstats(struct ath_hal *ah,
227 struct ath9k_mib_stats *stats)
228{
229 stats->ackrcv_bad += REG_READ(ah, AR_ACK_FAIL);
230 stats->rts_bad += REG_READ(ah, AR_RTS_FAIL);
231 stats->fcs_bad += REG_READ(ah, AR_FCS_FAIL);
232 stats->rts_good += REG_READ(ah, AR_RTS_OK);
233 stats->beacons += REG_READ(ah, AR_BEACON_CNT);
234}
235
236static void ath9k_ani_restart(struct ath_hal *ah)
237{
238 struct ath_hal_5416 *ahp = AH5416(ah);
239 struct ar5416AniState *aniState;
240
241 if (!DO_ANI(ah))
242 return;
243
244 aniState = ahp->ah_curani;
245
246 aniState->listenTime = 0;
247 if (ahp->ah_hasHwPhyCounters) {
248 if (aniState->ofdmTrigHigh > AR_PHY_COUNTMAX) {
249 aniState->ofdmPhyErrBase = 0;
250 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
251 "OFDM Trigger is too high for hw counters\n");
252 } else {
253 aniState->ofdmPhyErrBase =
254 AR_PHY_COUNTMAX - aniState->ofdmTrigHigh;
255 }
256 if (aniState->cckTrigHigh > AR_PHY_COUNTMAX) {
257 aniState->cckPhyErrBase = 0;
258 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
259 "CCK Trigger is too high for hw counters\n");
260 } else {
261 aniState->cckPhyErrBase =
262 AR_PHY_COUNTMAX - aniState->cckTrigHigh;
263 }
264 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
265 "%s: Writing ofdmbase=%u cckbase=%u\n",
266 __func__, aniState->ofdmPhyErrBase,
267 aniState->cckPhyErrBase);
268 REG_WRITE(ah, AR_PHY_ERR_1, aniState->ofdmPhyErrBase);
269 REG_WRITE(ah, AR_PHY_ERR_2, aniState->cckPhyErrBase);
270 REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
271 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
272
273 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
274 }
275 aniState->ofdmPhyErrCount = 0;
276 aniState->cckPhyErrCount = 0;
277}
278
279static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hal *ah)
280{
281 struct ath_hal_5416 *ahp = AH5416(ah);
282 struct ath9k_channel *chan = ah->ah_curchan;
283 struct ar5416AniState *aniState;
284 enum wireless_mode mode;
285 int32_t rssi;
286
287 if (!DO_ANI(ah))
288 return;
289
290 aniState = ahp->ah_curani;
291
292 if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
293 if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
294 aniState->noiseImmunityLevel + 1)) {
295 return;
296 }
297 }
298
299 if (aniState->spurImmunityLevel < HAL_SPUR_IMMUNE_MAX) {
300 if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
301 aniState->spurImmunityLevel + 1)) {
302 return;
303 }
304 }
305
306 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
307 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
308 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
309 aniState->firstepLevel + 1);
310 }
311 return;
312 }
313 rssi = BEACON_RSSI(ahp);
314 if (rssi > aniState->rssiThrHigh) {
315 if (!aniState->ofdmWeakSigDetectOff) {
316 if (ath9k_hw_ani_control(ah,
317 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
318 false)) {
319 ath9k_hw_ani_control(ah,
320 ATH9K_ANI_SPUR_IMMUNITY_LEVEL, 0);
321 return;
322 }
323 }
324 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
325 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
326 aniState->firstepLevel + 1);
327 return;
328 }
329 } else if (rssi > aniState->rssiThrLow) {
330 if (aniState->ofdmWeakSigDetectOff)
331 ath9k_hw_ani_control(ah,
332 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
333 true);
334 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX)
335 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
336 aniState->firstepLevel + 1);
337 return;
338 } else {
339 mode = ath9k_hw_chan2wmode(ah, chan);
340 if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) {
341 if (!aniState->ofdmWeakSigDetectOff)
342 ath9k_hw_ani_control(ah,
343 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
344 false);
345 if (aniState->firstepLevel > 0)
346 ath9k_hw_ani_control(ah,
347 ATH9K_ANI_FIRSTEP_LEVEL, 0);
348 return;
349 }
350 }
351}
352
353static void ath9k_hw_ani_cck_err_trigger(struct ath_hal *ah)
354{
355 struct ath_hal_5416 *ahp = AH5416(ah);
356 struct ath9k_channel *chan = ah->ah_curchan;
357 struct ar5416AniState *aniState;
358 enum wireless_mode mode;
359 int32_t rssi;
360
361 if (!DO_ANI(ah))
362 return;
363
364 aniState = ahp->ah_curani;
365 if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
366 if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
367 aniState->noiseImmunityLevel + 1)) {
368 return;
369 }
370 }
371 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
372 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
373 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
374 aniState->firstepLevel + 1);
375 }
376 return;
377 }
378 rssi = BEACON_RSSI(ahp);
379 if (rssi > aniState->rssiThrLow) {
380 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX)
381 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
382 aniState->firstepLevel + 1);
383 } else {
384 mode = ath9k_hw_chan2wmode(ah, chan);
385 if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) {
386 if (aniState->firstepLevel > 0)
387 ath9k_hw_ani_control(ah,
388 ATH9K_ANI_FIRSTEP_LEVEL, 0);
389 }
390 }
391}
392
393static void ath9k_hw_ani_lower_immunity(struct ath_hal *ah)
394{
395 struct ath_hal_5416 *ahp = AH5416(ah);
396 struct ar5416AniState *aniState;
397 int32_t rssi;
398
399 aniState = ahp->ah_curani;
400
401 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
402 if (aniState->firstepLevel > 0) {
403 if (ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
404 aniState->firstepLevel - 1))
405 return;
406 }
407 } else {
408 rssi = BEACON_RSSI(ahp);
409 if (rssi > aniState->rssiThrHigh) {
410 /* XXX: Handle me */
411 } else if (rssi > aniState->rssiThrLow) {
412 if (aniState->ofdmWeakSigDetectOff) {
413 if (ath9k_hw_ani_control(ah,
414 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
415 true) == true)
416 return;
417 }
418 if (aniState->firstepLevel > 0) {
419 if (ath9k_hw_ani_control(ah,
420 ATH9K_ANI_FIRSTEP_LEVEL,
421 aniState->firstepLevel - 1) == true)
422 return;
423 }
424 } else {
425 if (aniState->firstepLevel > 0) {
426 if (ath9k_hw_ani_control(ah,
427 ATH9K_ANI_FIRSTEP_LEVEL,
428 aniState->firstepLevel - 1) == true)
429 return;
430 }
431 }
432 }
433
434 if (aniState->spurImmunityLevel > 0) {
435 if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
436 aniState->spurImmunityLevel - 1))
437 return;
438 }
439
440 if (aniState->noiseImmunityLevel > 0) {
441 ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
442 aniState->noiseImmunityLevel - 1);
443 return;
444 }
445}
446
447static int32_t ath9k_hw_ani_get_listen_time(struct ath_hal *ah)
448{
449 struct ath_hal_5416 *ahp = AH5416(ah);
450 struct ar5416AniState *aniState;
451 u32 txFrameCount, rxFrameCount, cycleCount;
452 int32_t listenTime;
453
454 txFrameCount = REG_READ(ah, AR_TFCNT);
455 rxFrameCount = REG_READ(ah, AR_RFCNT);
456 cycleCount = REG_READ(ah, AR_CCCNT);
457
458 aniState = ahp->ah_curani;
459 if (aniState->cycleCount == 0 || aniState->cycleCount > cycleCount) {
460
461 listenTime = 0;
462 ahp->ah_stats.ast_ani_lzero++;
463 } else {
464 int32_t ccdelta = cycleCount - aniState->cycleCount;
465 int32_t rfdelta = rxFrameCount - aniState->rxFrameCount;
466 int32_t tfdelta = txFrameCount - aniState->txFrameCount;
467 listenTime = (ccdelta - rfdelta - tfdelta) / 44000;
468 }
469 aniState->cycleCount = cycleCount;
470 aniState->txFrameCount = txFrameCount;
471 aniState->rxFrameCount = rxFrameCount;
472
473 return listenTime;
474}
475
476void ath9k_ani_reset(struct ath_hal *ah)
477{
478 struct ath_hal_5416 *ahp = AH5416(ah);
479 struct ar5416AniState *aniState;
480 struct ath9k_channel *chan = ah->ah_curchan;
481 int index;
482
483 if (!DO_ANI(ah))
484 return;
485
486 index = ath9k_hw_get_ani_channel_idx(ah, chan);
487 aniState = &ahp->ah_ani[index];
488 ahp->ah_curani = aniState;
489
490 if (DO_ANI(ah) && ah->ah_opmode != ATH9K_M_STA
491 && ah->ah_opmode != ATH9K_M_IBSS) {
492 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
493 "%s: Reset ANI state opmode %u\n", __func__,
494 ah->ah_opmode);
495 ahp->ah_stats.ast_ani_reset++;
496
497 ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL, 0);
498 ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL, 0);
499 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL, 0);
500 ath9k_hw_ani_control(ah, ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
501 !ATH9K_ANI_USE_OFDM_WEAK_SIG);
502 ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
503 ATH9K_ANI_CCK_WEAK_SIG_THR);
504
505 ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) |
506 ATH9K_RX_FILTER_PHYERR);
507
508 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
509 ahp->ah_curani->ofdmTrigHigh =
510 ah->ah_config.ofdm_trig_high;
511 ahp->ah_curani->ofdmTrigLow =
512 ah->ah_config.ofdm_trig_low;
513 ahp->ah_curani->cckTrigHigh =
514 ah->ah_config.cck_trig_high;
515 ahp->ah_curani->cckTrigLow =
516 ah->ah_config.cck_trig_low;
517 }
518 ath9k_ani_restart(ah);
519 return;
520 }
521
522 if (aniState->noiseImmunityLevel != 0)
523 ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
524 aniState->noiseImmunityLevel);
525 if (aniState->spurImmunityLevel != 0)
526 ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
527 aniState->spurImmunityLevel);
528 if (aniState->ofdmWeakSigDetectOff)
529 ath9k_hw_ani_control(ah, ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
530 !aniState->ofdmWeakSigDetectOff);
531 if (aniState->cckWeakSigThreshold)
532 ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
533 aniState->cckWeakSigThreshold);
534 if (aniState->firstepLevel != 0)
535 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
536 aniState->firstepLevel);
537 if (ahp->ah_hasHwPhyCounters) {
538 ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) &
539 ~ATH9K_RX_FILTER_PHYERR);
540 ath9k_ani_restart(ah);
541 REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
542 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
543
544 } else {
545 ath9k_ani_restart(ah);
546 ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) |
547 ATH9K_RX_FILTER_PHYERR);
548 }
549}
550
551void ath9k_hw_ani_monitor(struct ath_hal *ah,
552 const struct ath9k_node_stats *stats,
553 struct ath9k_channel *chan)
554{
555 struct ath_hal_5416 *ahp = AH5416(ah);
556 struct ar5416AniState *aniState;
557 int32_t listenTime;
558
559 aniState = ahp->ah_curani;
560 ahp->ah_stats.ast_nodestats = *stats;
561
562 listenTime = ath9k_hw_ani_get_listen_time(ah);
563 if (listenTime < 0) {
564 ahp->ah_stats.ast_ani_lneg++;
565 ath9k_ani_restart(ah);
566 return;
567 }
568
569 aniState->listenTime += listenTime;
570
571 if (ahp->ah_hasHwPhyCounters) {
572 u32 phyCnt1, phyCnt2;
573 u32 ofdmPhyErrCnt, cckPhyErrCnt;
574
575 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
576
577 phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
578 phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
579
580 if (phyCnt1 < aniState->ofdmPhyErrBase ||
581 phyCnt2 < aniState->cckPhyErrBase) {
582 if (phyCnt1 < aniState->ofdmPhyErrBase) {
583 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
584 "%s: phyCnt1 0x%x, resetting "
585 "counter value to 0x%x\n",
586 __func__, phyCnt1,
587 aniState->ofdmPhyErrBase);
588 REG_WRITE(ah, AR_PHY_ERR_1,
589 aniState->ofdmPhyErrBase);
590 REG_WRITE(ah, AR_PHY_ERR_MASK_1,
591 AR_PHY_ERR_OFDM_TIMING);
592 }
593 if (phyCnt2 < aniState->cckPhyErrBase) {
594 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
595 "%s: phyCnt2 0x%x, resetting "
596 "counter value to 0x%x\n",
597 __func__, phyCnt2,
598 aniState->cckPhyErrBase);
599 REG_WRITE(ah, AR_PHY_ERR_2,
600 aniState->cckPhyErrBase);
601 REG_WRITE(ah, AR_PHY_ERR_MASK_2,
602 AR_PHY_ERR_CCK_TIMING);
603 }
604 return;
605 }
606
607 ofdmPhyErrCnt = phyCnt1 - aniState->ofdmPhyErrBase;
608 ahp->ah_stats.ast_ani_ofdmerrs +=
609 ofdmPhyErrCnt - aniState->ofdmPhyErrCount;
610 aniState->ofdmPhyErrCount = ofdmPhyErrCnt;
611
612 cckPhyErrCnt = phyCnt2 - aniState->cckPhyErrBase;
613 ahp->ah_stats.ast_ani_cckerrs +=
614 cckPhyErrCnt - aniState->cckPhyErrCount;
615 aniState->cckPhyErrCount = cckPhyErrCnt;
616 }
617
618 if (!DO_ANI(ah))
619 return;
620
621 if (aniState->listenTime > 5 * ahp->ah_aniPeriod) {
622 if (aniState->ofdmPhyErrCount <= aniState->listenTime *
623 aniState->ofdmTrigLow / 1000 &&
624 aniState->cckPhyErrCount <= aniState->listenTime *
625 aniState->cckTrigLow / 1000)
626 ath9k_hw_ani_lower_immunity(ah);
627 ath9k_ani_restart(ah);
628 } else if (aniState->listenTime > ahp->ah_aniPeriod) {
629 if (aniState->ofdmPhyErrCount > aniState->listenTime *
630 aniState->ofdmTrigHigh / 1000) {
631 ath9k_hw_ani_ofdm_err_trigger(ah);
632 ath9k_ani_restart(ah);
633 } else if (aniState->cckPhyErrCount >
634 aniState->listenTime * aniState->cckTrigHigh /
635 1000) {
636 ath9k_hw_ani_cck_err_trigger(ah);
637 ath9k_ani_restart(ah);
638 }
639 }
640}
641
642bool ath9k_hw_phycounters(struct ath_hal *ah)
643{
644 struct ath_hal_5416 *ahp = AH5416(ah);
645
646 return ahp->ah_hasHwPhyCounters ? true : false;
647}
648
649void ath9k_enable_mib_counters(struct ath_hal *ah)
650{
651 struct ath_hal_5416 *ahp = AH5416(ah);
652
653 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Enable MIB counters\n");
654
655 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
656
657 REG_WRITE(ah, AR_FILT_OFDM, 0);
658 REG_WRITE(ah, AR_FILT_CCK, 0);
659 REG_WRITE(ah, AR_MIBC,
660 ~(AR_MIBC_COW | AR_MIBC_FMC | AR_MIBC_CMC | AR_MIBC_MCS)
661 & 0x0f);
662 REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
663 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
664}
665
666void ath9k_hw_disable_mib_counters(struct ath_hal *ah)
667{
668 struct ath_hal_5416 *ahp = AH5416(ah);
669
670 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Disable MIB counters\n");
671
672 REG_WRITE(ah, AR_MIBC, AR_MIBC_FMC | AR_MIBC_CMC);
673
674 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
675
676 REG_WRITE(ah, AR_FILT_OFDM, 0);
677 REG_WRITE(ah, AR_FILT_CCK, 0);
678}
679
680u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hal *ah,
681 u32 *rxc_pcnt,
682 u32 *rxf_pcnt,
683 u32 *txf_pcnt)
684{
685 static u32 cycles, rx_clear, rx_frame, tx_frame;
686 u32 good = 1;
687
688 u32 rc = REG_READ(ah, AR_RCCNT);
689 u32 rf = REG_READ(ah, AR_RFCNT);
690 u32 tf = REG_READ(ah, AR_TFCNT);
691 u32 cc = REG_READ(ah, AR_CCCNT);
692
693 if (cycles == 0 || cycles > cc) {
694 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
695 "%s: cycle counter wrap. ExtBusy = 0\n",
696 __func__);
697 good = 0;
698 } else {
699 u32 cc_d = cc - cycles;
700 u32 rc_d = rc - rx_clear;
701 u32 rf_d = rf - rx_frame;
702 u32 tf_d = tf - tx_frame;
703
704 if (cc_d != 0) {
705 *rxc_pcnt = rc_d * 100 / cc_d;
706 *rxf_pcnt = rf_d * 100 / cc_d;
707 *txf_pcnt = tf_d * 100 / cc_d;
708 } else {
709 good = 0;
710 }
711 }
712
713 cycles = cc;
714 rx_frame = rf;
715 rx_clear = rc;
716 tx_frame = tf;
717
718 return good;
719}
720
721/*
722 * Process a MIB interrupt. We may potentially be invoked because
723 * any of the MIB counters overflow/trigger so don't assume we're
724 * here because a PHY error counter triggered.
725 */
726void ath9k_hw_procmibevent(struct ath_hal *ah,
727 const struct ath9k_node_stats *stats)
728{
729 struct ath_hal_5416 *ahp = AH5416(ah);
730 u32 phyCnt1, phyCnt2;
731
732 /* Reset these counters regardless */
733 REG_WRITE(ah, AR_FILT_OFDM, 0);
734 REG_WRITE(ah, AR_FILT_CCK, 0);
735 if (!(REG_READ(ah, AR_SLP_MIB_CTRL) & AR_SLP_MIB_PENDING))
736 REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR);
737
738 /* Clear the mib counters and save them in the stats */
739 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
740 ahp->ah_stats.ast_nodestats = *stats;
741
742 if (!DO_ANI(ah))
743 return;
744
745 /* NB: these are not reset-on-read */
746 phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
747 phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
748 if (((phyCnt1 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK) ||
749 ((phyCnt2 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK)) {
750 struct ar5416AniState *aniState = ahp->ah_curani;
751 u32 ofdmPhyErrCnt, cckPhyErrCnt;
752
753 /* NB: only use ast_ani_*errs with AH_PRIVATE_DIAG */
754 ofdmPhyErrCnt = phyCnt1 - aniState->ofdmPhyErrBase;
755 ahp->ah_stats.ast_ani_ofdmerrs +=
756 ofdmPhyErrCnt - aniState->ofdmPhyErrCount;
757 aniState->ofdmPhyErrCount = ofdmPhyErrCnt;
758
759 cckPhyErrCnt = phyCnt2 - aniState->cckPhyErrBase;
760 ahp->ah_stats.ast_ani_cckerrs +=
761 cckPhyErrCnt - aniState->cckPhyErrCount;
762 aniState->cckPhyErrCount = cckPhyErrCnt;
763
764 /*
765 * NB: figure out which counter triggered. If both
766 * trigger we'll only deal with one as the processing
767 * clobbers the error counter so the trigger threshold
768 * check will never be true.
769 */
770 if (aniState->ofdmPhyErrCount > aniState->ofdmTrigHigh)
771 ath9k_hw_ani_ofdm_err_trigger(ah);
772 if (aniState->cckPhyErrCount > aniState->cckTrigHigh)
773 ath9k_hw_ani_cck_err_trigger(ah);
774 /* NB: always restart to insure the h/w counters are reset */
775 ath9k_ani_restart(ah);
776 }
777}
778
779void ath9k_hw_ani_setup(struct ath_hal *ah)
780{
781 struct ath_hal_5416 *ahp = AH5416(ah);
782 int i;
783
784 const int totalSizeDesired[] = { -55, -55, -55, -55, -62 };
785 const int coarseHigh[] = { -14, -14, -14, -14, -12 };
786 const int coarseLow[] = { -64, -64, -64, -64, -70 };
787 const int firpwr[] = { -78, -78, -78, -78, -80 };
788
789 for (i = 0; i < 5; i++) {
790 ahp->ah_totalSizeDesired[i] = totalSizeDesired[i];
791 ahp->ah_coarseHigh[i] = coarseHigh[i];
792 ahp->ah_coarseLow[i] = coarseLow[i];
793 ahp->ah_firpwr[i] = firpwr[i];
794 }
795}
796
797void ath9k_hw_ani_attach(struct ath_hal *ah)
798{
799 struct ath_hal_5416 *ahp = AH5416(ah);
800 int i;
801
802 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Attach ANI\n");
803
804 ahp->ah_hasHwPhyCounters = 1;
805
806 memset(ahp->ah_ani, 0, sizeof(ahp->ah_ani));
807 for (i = 0; i < ARRAY_SIZE(ahp->ah_ani); i++) {
808 ahp->ah_ani[i].ofdmTrigHigh = ATH9K_ANI_OFDM_TRIG_HIGH;
809 ahp->ah_ani[i].ofdmTrigLow = ATH9K_ANI_OFDM_TRIG_LOW;
810 ahp->ah_ani[i].cckTrigHigh = ATH9K_ANI_CCK_TRIG_HIGH;
811 ahp->ah_ani[i].cckTrigLow = ATH9K_ANI_CCK_TRIG_LOW;
812 ahp->ah_ani[i].rssiThrHigh = ATH9K_ANI_RSSI_THR_HIGH;
813 ahp->ah_ani[i].rssiThrLow = ATH9K_ANI_RSSI_THR_LOW;
814 ahp->ah_ani[i].ofdmWeakSigDetectOff =
815 !ATH9K_ANI_USE_OFDM_WEAK_SIG;
816 ahp->ah_ani[i].cckWeakSigThreshold =
817 ATH9K_ANI_CCK_WEAK_SIG_THR;
818 ahp->ah_ani[i].spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
819 ahp->ah_ani[i].firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
820 if (ahp->ah_hasHwPhyCounters) {
821 ahp->ah_ani[i].ofdmPhyErrBase =
822 AR_PHY_COUNTMAX - ATH9K_ANI_OFDM_TRIG_HIGH;
823 ahp->ah_ani[i].cckPhyErrBase =
824 AR_PHY_COUNTMAX - ATH9K_ANI_CCK_TRIG_HIGH;
825 }
826 }
827 if (ahp->ah_hasHwPhyCounters) {
828 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
829 "Setting OfdmErrBase = 0x%08x\n",
830 ahp->ah_ani[0].ofdmPhyErrBase);
831 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Setting cckErrBase = 0x%08x\n",
832 ahp->ah_ani[0].cckPhyErrBase);
833
834 REG_WRITE(ah, AR_PHY_ERR_1, ahp->ah_ani[0].ofdmPhyErrBase);
835 REG_WRITE(ah, AR_PHY_ERR_2, ahp->ah_ani[0].cckPhyErrBase);
836 ath9k_enable_mib_counters(ah);
837 }
838 ahp->ah_aniPeriod = ATH9K_ANI_PERIOD;
839 if (ah->ah_config.enable_ani)
840 ahp->ah_procPhyErr |= HAL_PROCESS_ANI;
841}
842
843void ath9k_hw_ani_detach(struct ath_hal *ah)
844{
845 struct ath_hal_5416 *ahp = AH5416(ah);
846
847 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Detach ANI\n");
848
849 if (ahp->ah_hasHwPhyCounters) {
850 ath9k_hw_disable_mib_counters(ah);
851 REG_WRITE(ah, AR_PHY_ERR_1, 0);
852 REG_WRITE(ah, AR_PHY_ERR_2, 0);
853 }
854}
diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath9k/ath9k.h
index accace5f7efb..3a180ce1770b 100644
--- a/drivers/net/wireless/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath9k/ath9k.h
@@ -138,6 +138,19 @@ struct ath_desc {
138#define ATH9K_TXDESC_NOACK 0x0002 138#define ATH9K_TXDESC_NOACK 0x0002
139#define ATH9K_TXDESC_RTSENA 0x0004 139#define ATH9K_TXDESC_RTSENA 0x0004
140#define ATH9K_TXDESC_CTSENA 0x0008 140#define ATH9K_TXDESC_CTSENA 0x0008
141/* ATH9K_TXDESC_INTREQ forces a tx interrupt to be generated for
142 * the descriptor its marked on. We take a tx interrupt to reap
143 * descriptors when the h/w hits an EOL condition or
144 * when the descriptor is specifically marked to generate
145 * an interrupt with this flag. Descriptors should be
146 * marked periodically to insure timely replenishing of the
147 * supply needed for sending frames. Defering interrupts
148 * reduces system load and potentially allows more concurrent
149 * work to be done but if done to aggressively can cause
150 * senders to backup. When the hardware queue is left too
151 * large rate control information may also be too out of
152 * date. An Alternative for this is TX interrupt mitigation
153 * but this needs more testing. */
141#define ATH9K_TXDESC_INTREQ 0x0010 154#define ATH9K_TXDESC_INTREQ 0x0010
142#define ATH9K_TXDESC_VEOL 0x0020 155#define ATH9K_TXDESC_VEOL 0x0020
143#define ATH9K_TXDESC_EXT_ONLY 0x0040 156#define ATH9K_TXDESC_EXT_ONLY 0x0040
@@ -815,195 +828,251 @@ struct chan_centers {
815 u16 ext_center; 828 u16 ext_center;
816}; 829};
817 830
818int ath_hal_getcapability(struct ath_hal *ah, 831/* Helpers */
819 enum ath9k_capability_type type, 832
820 u32 capability, 833enum wireless_mode ath9k_hw_chan2wmode(struct ath_hal *ah,
821 u32 *result); 834 const struct ath9k_channel *chan);
822const struct ath9k_rate_table *ath9k_hw_getratetable(struct ath_hal *ah, 835bool ath9k_hw_wait(struct ath_hal *ah, u32 reg, u32 mask, u32 val);
823 u32 mode); 836u32 ath9k_hw_reverse_bits(u32 val, u32 n);
824void ath9k_hw_detach(struct ath_hal *ah); 837bool ath9k_get_channel_edges(struct ath_hal *ah,
825struct ath_hal *ath9k_hw_attach(u16 devid, 838 u16 flags, u16 *low,
826 struct ath_softc *sc, 839 u16 *high);
827 void __iomem *mem, 840u16 ath9k_hw_computetxtime(struct ath_hal *ah,
828 int *error); 841 const struct ath9k_rate_table *rates,
829bool ath9k_regd_init_channels(struct ath_hal *ah, 842 u32 frameLen, u16 rateix,
830 u32 maxchans, u32 *nchans, 843 bool shortPreamble);
831 u8 *regclassids,
832 u32 maxregids, u32 *nregids,
833 u16 cc,
834 bool enableOutdoor,
835 bool enableExtendedChannels);
836u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags); 844u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags);
837enum ath9k_int ath9k_hw_set_interrupts(struct ath_hal *ah, 845void ath9k_hw_get_channel_centers(struct ath_hal *ah,
838 enum ath9k_int ints); 846 struct ath9k_channel *chan,
839bool ath9k_hw_reset(struct ath_hal *ah, 847 struct chan_centers *centers);
840 struct ath9k_channel *chan, 848
849/* Attach, Detach */
850
851const char *ath9k_hw_probe(u16 vendorid, u16 devid);
852void ath9k_hw_detach(struct ath_hal *ah);
853struct ath_hal *ath9k_hw_attach(u16 devid, struct ath_softc *sc,
854 void __iomem *mem, int *error);
855void ath9k_hw_rfdetach(struct ath_hal *ah);
856
857
858/* HW Reset */
859
860bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
841 enum ath9k_ht_macmode macmode, 861 enum ath9k_ht_macmode macmode,
842 u8 txchainmask, u8 rxchainmask, 862 u8 txchainmask, u8 rxchainmask,
843 enum ath9k_ht_extprotspacing extprotspacing, 863 enum ath9k_ht_extprotspacing extprotspacing,
844 bool bChannelChange, 864 bool bChannelChange, int *status);
845 int *status); 865
846bool ath9k_hw_phy_disable(struct ath_hal *ah); 866/* Key Cache Management */
847void ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan, 867
848 bool *isCalDone);
849void ath9k_hw_ani_monitor(struct ath_hal *ah,
850 const struct ath9k_node_stats *stats,
851 struct ath9k_channel *chan);
852bool ath9k_hw_calibrate(struct ath_hal *ah,
853 struct ath9k_channel *chan,
854 u8 rxchainmask,
855 bool longcal,
856 bool *isCalDone);
857s16 ath9k_hw_getchan_noise(struct ath_hal *ah,
858 struct ath9k_channel *chan);
859void ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid,
860 u16 assocId);
861void ath9k_hw_setrxfilter(struct ath_hal *ah, u32 bits);
862void ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid,
863 u16 assocId);
864bool ath9k_hw_stoptxdma(struct ath_hal *ah, u32 q);
865void ath9k_hw_reset_tsf(struct ath_hal *ah);
866bool ath9k_hw_keyisvalid(struct ath_hal *ah, u16 entry);
867bool ath9k_hw_keysetmac(struct ath_hal *ah, u16 entry,
868 const u8 *mac);
869bool ath9k_hw_set_keycache_entry(struct ath_hal *ah,
870 u16 entry,
871 const struct ath9k_keyval *k,
872 const u8 *mac,
873 int xorKey);
874bool ath9k_hw_set_tsfadjust(struct ath_hal *ah,
875 u32 setting);
876void ath9k_hw_configpcipowersave(struct ath_hal *ah, int restore);
877bool ath9k_hw_intrpend(struct ath_hal *ah);
878bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked);
879bool ath9k_hw_updatetxtriglevel(struct ath_hal *ah,
880 bool bIncTrigLevel);
881void ath9k_hw_procmibevent(struct ath_hal *ah,
882 const struct ath9k_node_stats *stats);
883bool ath9k_hw_setrxabort(struct ath_hal *ah, bool set);
884void ath9k_hw_set11nmac2040(struct ath_hal *ah, enum ath9k_ht_macmode mode);
885bool ath9k_hw_phycounters(struct ath_hal *ah);
886bool ath9k_hw_keyreset(struct ath_hal *ah, u16 entry); 868bool ath9k_hw_keyreset(struct ath_hal *ah, u16 entry);
887bool ath9k_hw_getcapability(struct ath_hal *ah, 869bool ath9k_hw_keysetmac(struct ath_hal *ah, u16 entry, const u8 *mac);
888 enum ath9k_capability_type type, 870bool ath9k_hw_set_keycache_entry(struct ath_hal *ah, u16 entry,
889 u32 capability, 871 const struct ath9k_keyval *k,
890 u32 *result); 872 const u8 *mac, int xorKey);
891bool ath9k_hw_setcapability(struct ath_hal *ah, 873bool ath9k_hw_keyisvalid(struct ath_hal *ah, u16 entry);
892 enum ath9k_capability_type type, 874
893 u32 capability, 875/* Power Management */
894 u32 setting, 876
895 int *status);
896u32 ath9k_hw_getdefantenna(struct ath_hal *ah);
897void ath9k_hw_getmac(struct ath_hal *ah, u8 *mac);
898void ath9k_hw_getbssidmask(struct ath_hal *ah, u8 *mask);
899bool ath9k_hw_setbssidmask(struct ath_hal *ah,
900 const u8 *mask);
901bool ath9k_hw_setpower(struct ath_hal *ah, 877bool ath9k_hw_setpower(struct ath_hal *ah,
902 enum ath9k_power_mode mode); 878 enum ath9k_power_mode mode);
903enum ath9k_int ath9k_hw_intrget(struct ath_hal *ah); 879void ath9k_hw_configpcipowersave(struct ath_hal *ah, int restore);
904u64 ath9k_hw_gettsf64(struct ath_hal *ah); 880
881/* Beacon timers */
882
883void ath9k_hw_beaconinit(struct ath_hal *ah, u32 next_beacon, u32 beacon_period);
884void ath9k_hw_set_sta_beacon_timers(struct ath_hal *ah,
885 const struct ath9k_beacon_state *bs);
886
887/* Rate table */
888
889const struct ath9k_rate_table *ath9k_hw_getratetable(struct ath_hal *ah,
890 u32 mode);
891
892/* HW Capabilities */
893
894bool ath9k_hw_fill_cap_info(struct ath_hal *ah);
895bool ath9k_hw_getcapability(struct ath_hal *ah, enum ath9k_capability_type type,
896 u32 capability, u32 *result);
897bool ath9k_hw_setcapability(struct ath_hal *ah, enum ath9k_capability_type type,
898 u32 capability, u32 setting, int *status);
899
900/* GPIO / RFKILL / Antennae */
901
902void ath9k_hw_cfg_gpio_input(struct ath_hal *ah, u32 gpio);
903u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio);
904void ath9k_hw_cfg_output(struct ath_hal *ah, u32 gpio,
905 u32 ah_signal_type);
906void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 val);
907#ifdef CONFIG_RFKILL
908void ath9k_enable_rfkill(struct ath_hal *ah);
909#endif
910int ath9k_hw_select_antconfig(struct ath_hal *ah, u32 cfg);
905u32 ath9k_hw_getdefantenna(struct ath_hal *ah); 911u32 ath9k_hw_getdefantenna(struct ath_hal *ah);
906bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us); 912void ath9k_hw_setantenna(struct ath_hal *ah, u32 antenna);
907bool ath9k_hw_setantennaswitch(struct ath_hal *ah, 913bool ath9k_hw_setantennaswitch(struct ath_hal *ah,
908 enum ath9k_ant_setting settings, 914 enum ath9k_ant_setting settings,
909 struct ath9k_channel *chan, 915 struct ath9k_channel *chan,
910 u8 *tx_chainmask, 916 u8 *tx_chainmask,
911 u8 *rx_chainmask, 917 u8 *rx_chainmask,
912 u8 *antenna_cfgd); 918 u8 *antenna_cfgd);
913void ath9k_hw_setantenna(struct ath_hal *ah, u32 antenna); 919
914int ath9k_hw_select_antconfig(struct ath_hal *ah, 920/* General Operation */
915 u32 cfg); 921
916bool ath9k_hw_puttxbuf(struct ath_hal *ah, u32 q, 922u32 ath9k_hw_getrxfilter(struct ath_hal *ah);
917 u32 txdp); 923void ath9k_hw_setrxfilter(struct ath_hal *ah, u32 bits);
924bool ath9k_hw_phy_disable(struct ath_hal *ah);
925bool ath9k_hw_disable(struct ath_hal *ah);
926bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit);
927void ath9k_hw_getmac(struct ath_hal *ah, u8 *mac);
928bool ath9k_hw_setmac(struct ath_hal *ah, const u8 *mac);
929void ath9k_hw_setopmode(struct ath_hal *ah);
930void ath9k_hw_setmcastfilter(struct ath_hal *ah, u32 filter0, u32 filter1);
931void ath9k_hw_getbssidmask(struct ath_hal *ah, u8 *mask);
932bool ath9k_hw_setbssidmask(struct ath_hal *ah, const u8 *mask);
933void ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid, u16 assocId);
934u64 ath9k_hw_gettsf64(struct ath_hal *ah);
935void ath9k_hw_reset_tsf(struct ath_hal *ah);
936bool ath9k_hw_set_tsfadjust(struct ath_hal *ah, u32 setting);
937bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us);
938void ath9k_hw_set11nmac2040(struct ath_hal *ah, enum ath9k_ht_macmode mode);
939
940/* Regulatory */
941
942bool ath9k_regd_is_public_safety_sku(struct ath_hal *ah);
943struct ath9k_channel* ath9k_regd_check_channel(struct ath_hal *ah,
944 const struct ath9k_channel *c);
945u32 ath9k_regd_get_ctl(struct ath_hal *ah, struct ath9k_channel *chan);
946u32 ath9k_regd_get_antenna_allowed(struct ath_hal *ah,
947 struct ath9k_channel *chan);
948bool ath9k_regd_init_channels(struct ath_hal *ah,
949 u32 maxchans, u32 *nchans, u8 *regclassids,
950 u32 maxregids, u32 *nregids, u16 cc,
951 bool enableOutdoor, bool enableExtendedChannels);
952
953/* ANI */
954
955void ath9k_ani_reset(struct ath_hal *ah);
956void ath9k_hw_ani_monitor(struct ath_hal *ah,
957 const struct ath9k_node_stats *stats,
958 struct ath9k_channel *chan);
959bool ath9k_hw_phycounters(struct ath_hal *ah);
960void ath9k_enable_mib_counters(struct ath_hal *ah);
961void ath9k_hw_disable_mib_counters(struct ath_hal *ah);
962u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hal *ah,
963 u32 *rxc_pcnt,
964 u32 *rxf_pcnt,
965 u32 *txf_pcnt);
966void ath9k_hw_procmibevent(struct ath_hal *ah,
967 const struct ath9k_node_stats *stats);
968void ath9k_hw_ani_setup(struct ath_hal *ah);
969void ath9k_hw_ani_attach(struct ath_hal *ah);
970void ath9k_hw_ani_detach(struct ath_hal *ah);
971
972/* Calibration */
973
974void ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan,
975 bool *isCalDone);
976void ath9k_hw_start_nfcal(struct ath_hal *ah);
977void ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan);
978int16_t ath9k_hw_getnf(struct ath_hal *ah,
979 struct ath9k_channel *chan);
980void ath9k_init_nfcal_hist_buffer(struct ath_hal *ah);
981s16 ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan);
982bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
983 u8 rxchainmask, bool longcal,
984 bool *isCalDone);
985bool ath9k_hw_init_cal(struct ath_hal *ah,
986 struct ath9k_channel *chan);
987
988
989/* EEPROM */
990
991int ath9k_hw_set_txpower(struct ath_hal *ah,
992 struct ath9k_channel *chan,
993 u16 cfgCtl,
994 u8 twiceAntennaReduction,
995 u8 twiceMaxRegulatoryPower,
996 u8 powerLimit);
997void ath9k_hw_set_addac(struct ath_hal *ah, struct ath9k_channel *chan);
998bool ath9k_hw_set_power_per_rate_table(struct ath_hal *ah,
999 struct ath9k_channel *chan,
1000 int16_t *ratesArray,
1001 u16 cfgCtl,
1002 u8 AntennaReduction,
1003 u8 twiceMaxRegulatoryPower,
1004 u8 powerLimit);
1005bool ath9k_hw_set_power_cal_table(struct ath_hal *ah,
1006 struct ath9k_channel *chan,
1007 int16_t *pTxPowerIndexOffset);
1008bool ath9k_hw_eeprom_set_board_values(struct ath_hal *ah,
1009 struct ath9k_channel *chan);
1010int ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah,
1011 struct ath9k_channel *chan,
1012 u8 index, u16 *config);
1013u8 ath9k_hw_get_num_ant_config(struct ath_hal *ah,
1014 enum ieee80211_band freq_band);
1015u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah, u16 i, bool is2GHz);
1016int ath9k_hw_eeprom_attach(struct ath_hal *ah);
1017
1018/* Interrupt Handling */
1019
1020bool ath9k_hw_intrpend(struct ath_hal *ah);
1021bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked);
1022enum ath9k_int ath9k_hw_intrget(struct ath_hal *ah);
1023enum ath9k_int ath9k_hw_set_interrupts(struct ath_hal *ah, enum ath9k_int ints);
1024
1025/* MAC (PCU/QCU) */
1026
1027void ath9k_hw_dmaRegDump(struct ath_hal *ah);
1028u32 ath9k_hw_gettxbuf(struct ath_hal *ah, u32 q);
1029bool ath9k_hw_puttxbuf(struct ath_hal *ah, u32 q, u32 txdp);
918bool ath9k_hw_txstart(struct ath_hal *ah, u32 q); 1030bool ath9k_hw_txstart(struct ath_hal *ah, u32 q);
919u16 ath9k_hw_computetxtime(struct ath_hal *ah, 1031u32 ath9k_hw_numtxpending(struct ath_hal *ah, u32 q);
920 const struct ath9k_rate_table *rates, 1032bool ath9k_hw_updatetxtriglevel(struct ath_hal *ah, bool bIncTrigLevel);
921 u32 frameLen, u16 rateix, 1033bool ath9k_hw_stoptxdma(struct ath_hal *ah, u32 q);
922 bool shortPreamble); 1034bool ath9k_hw_filltxdesc(struct ath_hal *ah, struct ath_desc *ds,
1035 u32 segLen, bool firstSeg,
1036 bool lastSeg, const struct ath_desc *ds0);
1037void ath9k_hw_cleartxdesc(struct ath_hal *ah, struct ath_desc *ds);
1038int ath9k_hw_txprocdesc(struct ath_hal *ah, struct ath_desc *ds);
1039void ath9k_hw_set11n_txdesc(struct ath_hal *ah, struct ath_desc *ds,
1040 u32 pktLen, enum ath9k_pkt_type type, u32 txPower,
1041 u32 keyIx, enum ath9k_key_type keyType, u32 flags);
923void ath9k_hw_set11n_ratescenario(struct ath_hal *ah, struct ath_desc *ds, 1042void ath9k_hw_set11n_ratescenario(struct ath_hal *ah, struct ath_desc *ds,
924 struct ath_desc *lastds, 1043 struct ath_desc *lastds,
925 u32 durUpdateEn, u32 rtsctsRate, 1044 u32 durUpdateEn, u32 rtsctsRate,
926 u32 rtsctsDuration, 1045 u32 rtsctsDuration,
927 struct ath9k_11n_rate_series series[], 1046 struct ath9k_11n_rate_series series[],
928 u32 nseries, u32 flags); 1047 u32 nseries, u32 flags);
929void ath9k_hw_set11n_burstduration(struct ath_hal *ah, 1048void ath9k_hw_set11n_aggr_first(struct ath_hal *ah, struct ath_desc *ds,
930 struct ath_desc *ds, 1049 u32 aggrLen);
1050void ath9k_hw_set11n_aggr_middle(struct ath_hal *ah, struct ath_desc *ds,
1051 u32 numDelims);
1052void ath9k_hw_set11n_aggr_last(struct ath_hal *ah, struct ath_desc *ds);
1053void ath9k_hw_clr11n_aggr(struct ath_hal *ah, struct ath_desc *ds);
1054void ath9k_hw_set11n_burstduration(struct ath_hal *ah, struct ath_desc *ds,
931 u32 burstDuration); 1055 u32 burstDuration);
932void ath9k_hw_cleartxdesc(struct ath_hal *ah, struct ath_desc *ds); 1056void ath9k_hw_set11n_virtualmorefrag(struct ath_hal *ah, struct ath_desc *ds,
933u32 ath9k_hw_reverse_bits(u32 val, u32 n); 1057 u32 vmf);
934bool ath9k_hw_resettxqueue(struct ath_hal *ah, u32 q); 1058void ath9k_hw_gettxintrtxqs(struct ath_hal *ah, u32 *txqs);
935u32 ath9k_regd_get_ctl(struct ath_hal *ah, struct ath9k_channel *chan);
936u32 ath9k_regd_get_antenna_allowed(struct ath_hal *ah,
937 struct ath9k_channel *chan);
938u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags);
939bool ath9k_hw_get_txq_props(struct ath_hal *ah, int q,
940 struct ath9k_tx_queue_info *qinfo);
941bool ath9k_hw_set_txq_props(struct ath_hal *ah, int q, 1059bool ath9k_hw_set_txq_props(struct ath_hal *ah, int q,
942 const struct ath9k_tx_queue_info *qinfo); 1060 const struct ath9k_tx_queue_info *qinfo);
943struct ath9k_channel *ath9k_regd_check_channel(struct ath_hal *ah, 1061bool ath9k_hw_get_txq_props(struct ath_hal *ah, int q,
944 const struct ath9k_channel *c); 1062 struct ath9k_tx_queue_info *qinfo);
945void ath9k_hw_set11n_txdesc(struct ath_hal *ah, struct ath_desc *ds, 1063int ath9k_hw_setuptxqueue(struct ath_hal *ah, enum ath9k_tx_queue type,
946 u32 pktLen, enum ath9k_pkt_type type, 1064 const struct ath9k_tx_queue_info *qinfo);
947 u32 txPower, u32 keyIx, 1065bool ath9k_hw_releasetxqueue(struct ath_hal *ah, u32 q);
948 enum ath9k_key_type keyType, u32 flags); 1066bool ath9k_hw_resettxqueue(struct ath_hal *ah, u32 q);
949bool ath9k_hw_filltxdesc(struct ath_hal *ah, struct ath_desc *ds, 1067int ath9k_hw_rxprocdesc(struct ath_hal *ah, struct ath_desc *ds,
950 u32 segLen, bool firstSeg, 1068 u32 pa, struct ath_desc *nds, u64 tsf);
951 bool lastSeg,
952 const struct ath_desc *ds0);
953u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hal *ah,
954 u32 *rxc_pcnt,
955 u32 *rxf_pcnt,
956 u32 *txf_pcnt);
957void ath9k_hw_dmaRegDump(struct ath_hal *ah);
958void ath9k_hw_beaconinit(struct ath_hal *ah,
959 u32 next_beacon, u32 beacon_period);
960void ath9k_hw_set_sta_beacon_timers(struct ath_hal *ah,
961 const struct ath9k_beacon_state *bs);
962bool ath9k_hw_setuprxdesc(struct ath_hal *ah, struct ath_desc *ds, 1069bool ath9k_hw_setuprxdesc(struct ath_hal *ah, struct ath_desc *ds,
963 u32 size, u32 flags); 1070 u32 size, u32 flags);
1071bool ath9k_hw_setrxabort(struct ath_hal *ah, bool set);
964void ath9k_hw_putrxbuf(struct ath_hal *ah, u32 rxdp); 1072void ath9k_hw_putrxbuf(struct ath_hal *ah, u32 rxdp);
965void ath9k_hw_rxena(struct ath_hal *ah); 1073void ath9k_hw_rxena(struct ath_hal *ah);
966void ath9k_hw_setopmode(struct ath_hal *ah);
967bool ath9k_hw_setmac(struct ath_hal *ah, const u8 *mac);
968void ath9k_hw_setmcastfilter(struct ath_hal *ah, u32 filter0,
969 u32 filter1);
970u32 ath9k_hw_getrxfilter(struct ath_hal *ah);
971void ath9k_hw_startpcureceive(struct ath_hal *ah); 1074void ath9k_hw_startpcureceive(struct ath_hal *ah);
972void ath9k_hw_stoppcurecv(struct ath_hal *ah); 1075void ath9k_hw_stoppcurecv(struct ath_hal *ah);
973bool ath9k_hw_stopdmarecv(struct ath_hal *ah); 1076bool ath9k_hw_stopdmarecv(struct ath_hal *ah);
974int ath9k_hw_rxprocdesc(struct ath_hal *ah, 1077
975 struct ath_desc *ds, u32 pa,
976 struct ath_desc *nds, u64 tsf);
977u32 ath9k_hw_gettxbuf(struct ath_hal *ah, u32 q);
978int ath9k_hw_txprocdesc(struct ath_hal *ah,
979 struct ath_desc *ds);
980void ath9k_hw_set11n_aggr_middle(struct ath_hal *ah, struct ath_desc *ds,
981 u32 numDelims);
982void ath9k_hw_set11n_aggr_first(struct ath_hal *ah, struct ath_desc *ds,
983 u32 aggrLen);
984void ath9k_hw_set11n_aggr_last(struct ath_hal *ah, struct ath_desc *ds);
985bool ath9k_hw_releasetxqueue(struct ath_hal *ah, u32 q);
986void ath9k_hw_gettxintrtxqs(struct ath_hal *ah, u32 *txqs);
987void ath9k_hw_clr11n_aggr(struct ath_hal *ah, struct ath_desc *ds);
988void ath9k_hw_set11n_virtualmorefrag(struct ath_hal *ah,
989 struct ath_desc *ds, u32 vmf);
990bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit);
991bool ath9k_regd_is_public_safety_sku(struct ath_hal *ah);
992int ath9k_hw_setuptxqueue(struct ath_hal *ah, enum ath9k_tx_queue type,
993 const struct ath9k_tx_queue_info *qinfo);
994u32 ath9k_hw_numtxpending(struct ath_hal *ah, u32 q);
995const char *ath9k_hw_probe(u16 vendorid, u16 devid);
996bool ath9k_hw_disable(struct ath_hal *ah);
997void ath9k_hw_rfdetach(struct ath_hal *ah);
998void ath9k_hw_get_channel_centers(struct ath_hal *ah,
999 struct ath9k_channel *chan,
1000 struct chan_centers *centers);
1001bool ath9k_get_channel_edges(struct ath_hal *ah,
1002 u16 flags, u16 *low,
1003 u16 *high);
1004void ath9k_hw_cfg_output(struct ath_hal *ah, u32 gpio,
1005 u32 ah_signal_type);
1006void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 value);
1007u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio);
1008void ath9k_hw_cfg_gpio_input(struct ath_hal *ah, u32 gpio);
1009#endif 1078#endif
diff --git a/drivers/net/wireless/ath9k/beacon.c b/drivers/net/wireless/ath9k/beacon.c
index 9e15c30bbc06..d186cd41c235 100644
--- a/drivers/net/wireless/ath9k/beacon.c
+++ b/drivers/net/wireless/ath9k/beacon.c
@@ -114,7 +114,7 @@ static void ath_beacon_setup(struct ath_softc *sc,
114 ath9k_hw_set11n_txdesc(ah, ds, 114 ath9k_hw_set11n_txdesc(ah, ds,
115 skb->len + FCS_LEN, /* frame length */ 115 skb->len + FCS_LEN, /* frame length */
116 ATH9K_PKT_TYPE_BEACON, /* Atheros packet type */ 116 ATH9K_PKT_TYPE_BEACON, /* Atheros packet type */
117 avp->av_btxctl.txpower, /* txpower XXX */ 117 MAX_RATE_POWER, /* FIXME */
118 ATH9K_TXKEYIX_INVALID, /* no encryption */ 118 ATH9K_TXKEYIX_INVALID, /* no encryption */
119 ATH9K_KEY_TYPE_CLEAR, /* no encryption */ 119 ATH9K_KEY_TYPE_CLEAR, /* no encryption */
120 flags /* no ack, 120 flags /* no ack,
@@ -152,12 +152,14 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
152 struct ath_vap *avp; 152 struct ath_vap *avp;
153 struct sk_buff *skb; 153 struct sk_buff *skb;
154 struct ath_txq *cabq; 154 struct ath_txq *cabq;
155 struct ieee80211_vif *vif;
155 struct ieee80211_tx_info *info; 156 struct ieee80211_tx_info *info;
156 int cabq_depth; 157 int cabq_depth;
157 158
158 avp = sc->sc_vaps[if_id]; 159 vif = sc->sc_vaps[if_id];
159 ASSERT(avp); 160 ASSERT(vif);
160 161
162 avp = (void *)vif->drv_priv;
161 cabq = sc->sc_cabq; 163 cabq = sc->sc_cabq;
162 164
163 if (avp->av_bcbuf == NULL) { 165 if (avp->av_bcbuf == NULL) {
@@ -174,7 +176,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
174 PCI_DMA_TODEVICE); 176 PCI_DMA_TODEVICE);
175 } 177 }
176 178
177 skb = ieee80211_beacon_get(sc->hw, avp->av_if_data); 179 skb = ieee80211_beacon_get(sc->hw, vif);
178 bf->bf_mpdu = skb; 180 bf->bf_mpdu = skb;
179 if (skb == NULL) 181 if (skb == NULL)
180 return NULL; 182 return NULL;
@@ -196,7 +198,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
196 skb_end_pointer(skb) - skb->head, 198 skb_end_pointer(skb) - skb->head,
197 PCI_DMA_TODEVICE); 199 PCI_DMA_TODEVICE);
198 200
199 skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data); 201 skb = ieee80211_get_buffered_bc(sc->hw, vif);
200 202
201 /* 203 /*
202 * if the CABQ traffic from previous DTIM is pending and the current 204 * if the CABQ traffic from previous DTIM is pending and the current
@@ -232,7 +234,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
232 */ 234 */
233 while (skb) { 235 while (skb) {
234 ath_tx_cabq(sc, skb); 236 ath_tx_cabq(sc, skb);
235 skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data); 237 skb = ieee80211_get_buffered_bc(sc->hw, vif);
236 } 238 }
237 239
238 return bf; 240 return bf;
@@ -244,13 +246,16 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
244*/ 246*/
245static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id) 247static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
246{ 248{
249 struct ieee80211_vif *vif;
247 struct ath_hal *ah = sc->sc_ah; 250 struct ath_hal *ah = sc->sc_ah;
248 struct ath_buf *bf; 251 struct ath_buf *bf;
249 struct ath_vap *avp; 252 struct ath_vap *avp;
250 struct sk_buff *skb; 253 struct sk_buff *skb;
251 254
252 avp = sc->sc_vaps[if_id]; 255 vif = sc->sc_vaps[if_id];
253 ASSERT(avp); 256 ASSERT(vif);
257
258 avp = (void *)vif->drv_priv;
254 259
255 if (avp->av_bcbuf == NULL) { 260 if (avp->av_bcbuf == NULL) {
256 DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n", 261 DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n",
@@ -300,14 +305,17 @@ int ath_beaconq_setup(struct ath_hal *ah)
300*/ 305*/
301int ath_beacon_alloc(struct ath_softc *sc, int if_id) 306int ath_beacon_alloc(struct ath_softc *sc, int if_id)
302{ 307{
308 struct ieee80211_vif *vif;
303 struct ath_vap *avp; 309 struct ath_vap *avp;
304 struct ieee80211_hdr *hdr; 310 struct ieee80211_hdr *hdr;
305 struct ath_buf *bf; 311 struct ath_buf *bf;
306 struct sk_buff *skb; 312 struct sk_buff *skb;
307 __le64 tstamp; 313 __le64 tstamp;
308 314
309 avp = sc->sc_vaps[if_id]; 315 vif = sc->sc_vaps[if_id];
310 ASSERT(avp); 316 ASSERT(vif);
317
318 avp = (void *)vif->drv_priv;
311 319
312 /* Allocate a beacon descriptor if we haven't done so. */ 320 /* Allocate a beacon descriptor if we haven't done so. */
313 if (!avp->av_bcbuf) { 321 if (!avp->av_bcbuf) {
@@ -363,7 +371,7 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
363 * FIXME: Fill avp->av_btxctl.txpower and 371 * FIXME: Fill avp->av_btxctl.txpower and
364 * avp->av_btxctl.shortPreamble 372 * avp->av_btxctl.shortPreamble
365 */ 373 */
366 skb = ieee80211_beacon_get(sc->hw, avp->av_if_data); 374 skb = ieee80211_beacon_get(sc->hw, vif);
367 if (skb == NULL) { 375 if (skb == NULL) {
368 DPRINTF(sc, ATH_DBG_BEACON, "%s: cannot get skb\n", 376 DPRINTF(sc, ATH_DBG_BEACON, "%s: cannot get skb\n",
369 __func__); 377 __func__);
@@ -652,15 +660,21 @@ void ath_bstuck_process(struct ath_softc *sc)
652 */ 660 */
653void ath_beacon_config(struct ath_softc *sc, int if_id) 661void ath_beacon_config(struct ath_softc *sc, int if_id)
654{ 662{
663 struct ieee80211_vif *vif;
655 struct ath_hal *ah = sc->sc_ah; 664 struct ath_hal *ah = sc->sc_ah;
656 struct ath_beacon_config conf; 665 struct ath_beacon_config conf;
666 struct ath_vap *avp;
657 enum ath9k_opmode av_opmode; 667 enum ath9k_opmode av_opmode;
658 u32 nexttbtt, intval; 668 u32 nexttbtt, intval;
659 669
660 if (if_id != ATH_IF_ID_ANY) 670 if (if_id != ATH_IF_ID_ANY) {
661 av_opmode = sc->sc_vaps[if_id]->av_opmode; 671 vif = sc->sc_vaps[if_id];
662 else 672 ASSERT(vif);
673 avp = (void *)vif->drv_priv;
674 av_opmode = avp->av_opmode;
675 } else {
663 av_opmode = sc->sc_ah->ah_opmode; 676 av_opmode = sc->sc_ah->ah_opmode;
677 }
664 678
665 memset(&conf, 0, sizeof(struct ath_beacon_config)); 679 memset(&conf, 0, sizeof(struct ath_beacon_config));
666 680
diff --git a/drivers/net/wireless/ath9k/calib.c b/drivers/net/wireless/ath9k/calib.c
new file mode 100644
index 000000000000..1690759fe7b8
--- /dev/null
+++ b/drivers/net/wireless/ath9k/calib.c
@@ -0,0 +1,930 @@
1/*
2 * Copyright (c) 2008 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "core.h"
18#include "hw.h"
19#include "reg.h"
20#include "phy.h"
21
22static const int16_t NOISE_FLOOR[] = { -96, -93, -98, -96, -93, -96 };
23
24/* We can tune this as we go by monitoring really low values */
25#define ATH9K_NF_TOO_LOW -60
26
27/* AR5416 may return very high value (like -31 dBm), in those cases the nf
28 * is incorrect and we should use the static NF value. Later we can try to
29 * find out why they are reporting these values */
30
31static bool ath9k_hw_nf_in_range(struct ath_hal *ah, s16 nf)
32{
33 if (nf > ATH9K_NF_TOO_LOW) {
34 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
35 "%s: noise floor value detected (%d) is "
36 "lower than what we think is a "
37 "reasonable value (%d)\n",
38 __func__, nf, ATH9K_NF_TOO_LOW);
39 return false;
40 }
41 return true;
42}
43
44static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
45{
46 int16_t nfval;
47 int16_t sort[ATH9K_NF_CAL_HIST_MAX];
48 int i, j;
49
50 for (i = 0; i < ATH9K_NF_CAL_HIST_MAX; i++)
51 sort[i] = nfCalBuffer[i];
52
53 for (i = 0; i < ATH9K_NF_CAL_HIST_MAX - 1; i++) {
54 for (j = 1; j < ATH9K_NF_CAL_HIST_MAX - i; j++) {
55 if (sort[j] > sort[j - 1]) {
56 nfval = sort[j];
57 sort[j] = sort[j - 1];
58 sort[j - 1] = nfval;
59 }
60 }
61 }
62 nfval = sort[(ATH9K_NF_CAL_HIST_MAX - 1) >> 1];
63
64 return nfval;
65}
66
67static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h,
68 int16_t *nfarray)
69{
70 int i;
71
72 for (i = 0; i < NUM_NF_READINGS; i++) {
73 h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
74
75 if (++h[i].currIndex >= ATH9K_NF_CAL_HIST_MAX)
76 h[i].currIndex = 0;
77
78 if (h[i].invalidNFcount > 0) {
79 if (nfarray[i] < AR_PHY_CCA_MIN_BAD_VALUE ||
80 nfarray[i] > AR_PHY_CCA_MAX_HIGH_VALUE) {
81 h[i].invalidNFcount = ATH9K_NF_CAL_HIST_MAX;
82 } else {
83 h[i].invalidNFcount--;
84 h[i].privNF = nfarray[i];
85 }
86 } else {
87 h[i].privNF =
88 ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer);
89 }
90 }
91 return;
92}
93
94static void ath9k_hw_do_getnf(struct ath_hal *ah,
95 int16_t nfarray[NUM_NF_READINGS])
96{
97 int16_t nf;
98
99 if (AR_SREV_9280_10_OR_LATER(ah))
100 nf = MS(REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR);
101 else
102 nf = MS(REG_READ(ah, AR_PHY_CCA), AR_PHY_MINCCA_PWR);
103
104 if (nf & 0x100)
105 nf = 0 - ((nf ^ 0x1ff) + 1);
106 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
107 "NF calibrated [ctl] [chain 0] is %d\n", nf);
108 nfarray[0] = nf;
109
110 if (AR_SREV_9280_10_OR_LATER(ah))
111 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
112 AR9280_PHY_CH1_MINCCA_PWR);
113 else
114 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
115 AR_PHY_CH1_MINCCA_PWR);
116
117 if (nf & 0x100)
118 nf = 0 - ((nf ^ 0x1ff) + 1);
119 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
120 "NF calibrated [ctl] [chain 1] is %d\n", nf);
121 nfarray[1] = nf;
122
123 if (!AR_SREV_9280(ah)) {
124 nf = MS(REG_READ(ah, AR_PHY_CH2_CCA),
125 AR_PHY_CH2_MINCCA_PWR);
126 if (nf & 0x100)
127 nf = 0 - ((nf ^ 0x1ff) + 1);
128 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
129 "NF calibrated [ctl] [chain 2] is %d\n", nf);
130 nfarray[2] = nf;
131 }
132
133 if (AR_SREV_9280_10_OR_LATER(ah))
134 nf = MS(REG_READ(ah, AR_PHY_EXT_CCA),
135 AR9280_PHY_EXT_MINCCA_PWR);
136 else
137 nf = MS(REG_READ(ah, AR_PHY_EXT_CCA),
138 AR_PHY_EXT_MINCCA_PWR);
139
140 if (nf & 0x100)
141 nf = 0 - ((nf ^ 0x1ff) + 1);
142 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
143 "NF calibrated [ext] [chain 0] is %d\n", nf);
144 nfarray[3] = nf;
145
146 if (AR_SREV_9280_10_OR_LATER(ah))
147 nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA),
148 AR9280_PHY_CH1_EXT_MINCCA_PWR);
149 else
150 nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA),
151 AR_PHY_CH1_EXT_MINCCA_PWR);
152
153 if (nf & 0x100)
154 nf = 0 - ((nf ^ 0x1ff) + 1);
155 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
156 "NF calibrated [ext] [chain 1] is %d\n", nf);
157 nfarray[4] = nf;
158
159 if (!AR_SREV_9280(ah)) {
160 nf = MS(REG_READ(ah, AR_PHY_CH2_EXT_CCA),
161 AR_PHY_CH2_EXT_MINCCA_PWR);
162 if (nf & 0x100)
163 nf = 0 - ((nf ^ 0x1ff) + 1);
164 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
165 "NF calibrated [ext] [chain 2] is %d\n", nf);
166 nfarray[5] = nf;
167 }
168}
169
170static bool getNoiseFloorThresh(struct ath_hal *ah,
171 const struct ath9k_channel *chan,
172 int16_t *nft)
173{
174 switch (chan->chanmode) {
175 case CHANNEL_A:
176 case CHANNEL_A_HT20:
177 case CHANNEL_A_HT40PLUS:
178 case CHANNEL_A_HT40MINUS:
179 *nft = (int16_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_5);
180 break;
181 case CHANNEL_B:
182 case CHANNEL_G:
183 case CHANNEL_G_HT20:
184 case CHANNEL_G_HT40PLUS:
185 case CHANNEL_G_HT40MINUS:
186 *nft = (int16_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_2);
187 break;
188 default:
189 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
190 "%s: invalid channel flags 0x%x\n", __func__,
191 chan->channelFlags);
192 return false;
193 }
194
195 return true;
196}
197
198static void ath9k_hw_setup_calibration(struct ath_hal *ah,
199 struct hal_cal_list *currCal)
200{
201 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(0),
202 AR_PHY_TIMING_CTRL4_IQCAL_LOG_COUNT_MAX,
203 currCal->calData->calCountMax);
204
205 switch (currCal->calData->calType) {
206 case IQ_MISMATCH_CAL:
207 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_IQ);
208 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
209 "%s: starting IQ Mismatch Calibration\n",
210 __func__);
211 break;
212 case ADC_GAIN_CAL:
213 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_GAIN);
214 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
215 "%s: starting ADC Gain Calibration\n", __func__);
216 break;
217 case ADC_DC_CAL:
218 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_DC_PER);
219 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
220 "%s: starting ADC DC Calibration\n", __func__);
221 break;
222 case ADC_DC_INIT_CAL:
223 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_DC_INIT);
224 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
225 "%s: starting Init ADC DC Calibration\n",
226 __func__);
227 break;
228 }
229
230 REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0),
231 AR_PHY_TIMING_CTRL4_DO_CAL);
232}
233
234static void ath9k_hw_reset_calibration(struct ath_hal *ah,
235 struct hal_cal_list *currCal)
236{
237 struct ath_hal_5416 *ahp = AH5416(ah);
238 int i;
239
240 ath9k_hw_setup_calibration(ah, currCal);
241
242 currCal->calState = CAL_RUNNING;
243
244 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
245 ahp->ah_Meas0.sign[i] = 0;
246 ahp->ah_Meas1.sign[i] = 0;
247 ahp->ah_Meas2.sign[i] = 0;
248 ahp->ah_Meas3.sign[i] = 0;
249 }
250
251 ahp->ah_CalSamples = 0;
252}
253
254static void ath9k_hw_per_calibration(struct ath_hal *ah,
255 struct ath9k_channel *ichan,
256 u8 rxchainmask,
257 struct hal_cal_list *currCal,
258 bool *isCalDone)
259{
260 struct ath_hal_5416 *ahp = AH5416(ah);
261
262 *isCalDone = false;
263
264 if (currCal->calState == CAL_RUNNING) {
265 if (!(REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
266 AR_PHY_TIMING_CTRL4_DO_CAL)) {
267
268 currCal->calData->calCollect(ah);
269 ahp->ah_CalSamples++;
270
271 if (ahp->ah_CalSamples >= currCal->calData->calNumSamples) {
272 int i, numChains = 0;
273 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
274 if (rxchainmask & (1 << i))
275 numChains++;
276 }
277
278 currCal->calData->calPostProc(ah, numChains);
279 ichan->CalValid |= currCal->calData->calType;
280 currCal->calState = CAL_DONE;
281 *isCalDone = true;
282 } else {
283 ath9k_hw_setup_calibration(ah, currCal);
284 }
285 }
286 } else if (!(ichan->CalValid & currCal->calData->calType)) {
287 ath9k_hw_reset_calibration(ah, currCal);
288 }
289}
290
291static bool ath9k_hw_iscal_supported(struct ath_hal *ah,
292 struct ath9k_channel *chan,
293 enum hal_cal_types calType)
294{
295 struct ath_hal_5416 *ahp = AH5416(ah);
296 bool retval = false;
297
298 switch (calType & ahp->ah_suppCals) {
299 case IQ_MISMATCH_CAL:
300 if (!IS_CHAN_B(chan))
301 retval = true;
302 break;
303 case ADC_GAIN_CAL:
304 case ADC_DC_CAL:
305 if (!IS_CHAN_B(chan)
306 && !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
307 retval = true;
308 break;
309 }
310
311 return retval;
312}
313
314static void ath9k_hw_iqcal_collect(struct ath_hal *ah)
315{
316 struct ath_hal_5416 *ahp = AH5416(ah);
317 int i;
318
319 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
320 ahp->ah_totalPowerMeasI[i] +=
321 REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
322 ahp->ah_totalPowerMeasQ[i] +=
323 REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
324 ahp->ah_totalIqCorrMeas[i] +=
325 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
326 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
327 "%d: Chn %d pmi=0x%08x;pmq=0x%08x;iqcm=0x%08x;\n",
328 ahp->ah_CalSamples, i, ahp->ah_totalPowerMeasI[i],
329 ahp->ah_totalPowerMeasQ[i],
330 ahp->ah_totalIqCorrMeas[i]);
331 }
332}
333
334static void ath9k_hw_adc_gaincal_collect(struct ath_hal *ah)
335{
336 struct ath_hal_5416 *ahp = AH5416(ah);
337 int i;
338
339 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
340 ahp->ah_totalAdcIOddPhase[i] +=
341 REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
342 ahp->ah_totalAdcIEvenPhase[i] +=
343 REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
344 ahp->ah_totalAdcQOddPhase[i] +=
345 REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
346 ahp->ah_totalAdcQEvenPhase[i] +=
347 REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
348
349 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
350 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
351 "oddq=0x%08x; evenq=0x%08x;\n",
352 ahp->ah_CalSamples, i,
353 ahp->ah_totalAdcIOddPhase[i],
354 ahp->ah_totalAdcIEvenPhase[i],
355 ahp->ah_totalAdcQOddPhase[i],
356 ahp->ah_totalAdcQEvenPhase[i]);
357 }
358}
359
360static void ath9k_hw_adc_dccal_collect(struct ath_hal *ah)
361{
362 struct ath_hal_5416 *ahp = AH5416(ah);
363 int i;
364
365 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
366 ahp->ah_totalAdcDcOffsetIOddPhase[i] +=
367 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
368 ahp->ah_totalAdcDcOffsetIEvenPhase[i] +=
369 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
370 ahp->ah_totalAdcDcOffsetQOddPhase[i] +=
371 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
372 ahp->ah_totalAdcDcOffsetQEvenPhase[i] +=
373 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
374
375 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
376 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
377 "oddq=0x%08x; evenq=0x%08x;\n",
378 ahp->ah_CalSamples, i,
379 ahp->ah_totalAdcDcOffsetIOddPhase[i],
380 ahp->ah_totalAdcDcOffsetIEvenPhase[i],
381 ahp->ah_totalAdcDcOffsetQOddPhase[i],
382 ahp->ah_totalAdcDcOffsetQEvenPhase[i]);
383 }
384}
385
386static void ath9k_hw_iqcalibrate(struct ath_hal *ah, u8 numChains)
387{
388 struct ath_hal_5416 *ahp = AH5416(ah);
389 u32 powerMeasQ, powerMeasI, iqCorrMeas;
390 u32 qCoffDenom, iCoffDenom;
391 int32_t qCoff, iCoff;
392 int iqCorrNeg, i;
393
394 for (i = 0; i < numChains; i++) {
395 powerMeasI = ahp->ah_totalPowerMeasI[i];
396 powerMeasQ = ahp->ah_totalPowerMeasQ[i];
397 iqCorrMeas = ahp->ah_totalIqCorrMeas[i];
398
399 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
400 "Starting IQ Cal and Correction for Chain %d\n",
401 i);
402
403 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
404 "Orignal: Chn %diq_corr_meas = 0x%08x\n",
405 i, ahp->ah_totalIqCorrMeas[i]);
406
407 iqCorrNeg = 0;
408
409 if (iqCorrMeas > 0x80000000) {
410 iqCorrMeas = (0xffffffff - iqCorrMeas) + 1;
411 iqCorrNeg = 1;
412 }
413
414 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
415 "Chn %d pwr_meas_i = 0x%08x\n", i, powerMeasI);
416 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
417 "Chn %d pwr_meas_q = 0x%08x\n", i, powerMeasQ);
418 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, "iqCorrNeg is 0x%08x\n",
419 iqCorrNeg);
420
421 iCoffDenom = (powerMeasI / 2 + powerMeasQ / 2) / 128;
422 qCoffDenom = powerMeasQ / 64;
423
424 if (powerMeasQ != 0) {
425 iCoff = iqCorrMeas / iCoffDenom;
426 qCoff = powerMeasI / qCoffDenom - 64;
427 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
428 "Chn %d iCoff = 0x%08x\n", i, iCoff);
429 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
430 "Chn %d qCoff = 0x%08x\n", i, qCoff);
431
432 iCoff = iCoff & 0x3f;
433 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
434 "New: Chn %d iCoff = 0x%08x\n", i, iCoff);
435 if (iqCorrNeg == 0x0)
436 iCoff = 0x40 - iCoff;
437
438 if (qCoff > 15)
439 qCoff = 15;
440 else if (qCoff <= -16)
441 qCoff = 16;
442
443 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
444 "Chn %d : iCoff = 0x%x qCoff = 0x%x\n",
445 i, iCoff, qCoff);
446
447 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(i),
448 AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF,
449 iCoff);
450 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(i),
451 AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF,
452 qCoff);
453 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
454 "IQ Cal and Correction done for Chain %d\n",
455 i);
456 }
457 }
458
459 REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0),
460 AR_PHY_TIMING_CTRL4_IQCORR_ENABLE);
461}
462
463static void ath9k_hw_adc_gaincal_calibrate(struct ath_hal *ah, u8 numChains)
464{
465 struct ath_hal_5416 *ahp = AH5416(ah);
466 u32 iOddMeasOffset, iEvenMeasOffset, qOddMeasOffset, qEvenMeasOffset;
467 u32 qGainMismatch, iGainMismatch, val, i;
468
469 for (i = 0; i < numChains; i++) {
470 iOddMeasOffset = ahp->ah_totalAdcIOddPhase[i];
471 iEvenMeasOffset = ahp->ah_totalAdcIEvenPhase[i];
472 qOddMeasOffset = ahp->ah_totalAdcQOddPhase[i];
473 qEvenMeasOffset = ahp->ah_totalAdcQEvenPhase[i];
474
475 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
476 "Starting ADC Gain Cal for Chain %d\n", i);
477
478 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
479 "Chn %d pwr_meas_odd_i = 0x%08x\n", i,
480 iOddMeasOffset);
481 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
482 "Chn %d pwr_meas_even_i = 0x%08x\n", i,
483 iEvenMeasOffset);
484 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
485 "Chn %d pwr_meas_odd_q = 0x%08x\n", i,
486 qOddMeasOffset);
487 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
488 "Chn %d pwr_meas_even_q = 0x%08x\n", i,
489 qEvenMeasOffset);
490
491 if (iOddMeasOffset != 0 && qEvenMeasOffset != 0) {
492 iGainMismatch =
493 ((iEvenMeasOffset * 32) /
494 iOddMeasOffset) & 0x3f;
495 qGainMismatch =
496 ((qOddMeasOffset * 32) /
497 qEvenMeasOffset) & 0x3f;
498
499 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
500 "Chn %d gain_mismatch_i = 0x%08x\n", i,
501 iGainMismatch);
502 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
503 "Chn %d gain_mismatch_q = 0x%08x\n", i,
504 qGainMismatch);
505
506 val = REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i));
507 val &= 0xfffff000;
508 val |= (qGainMismatch) | (iGainMismatch << 6);
509 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i), val);
510
511 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
512 "ADC Gain Cal done for Chain %d\n", i);
513 }
514 }
515
516 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0),
517 REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0)) |
518 AR_PHY_NEW_ADC_GAIN_CORR_ENABLE);
519}
520
521static void ath9k_hw_adc_dccal_calibrate(struct ath_hal *ah, u8 numChains)
522{
523 struct ath_hal_5416 *ahp = AH5416(ah);
524 u32 iOddMeasOffset, iEvenMeasOffset, val, i;
525 int32_t qOddMeasOffset, qEvenMeasOffset, qDcMismatch, iDcMismatch;
526 const struct hal_percal_data *calData =
527 ahp->ah_cal_list_curr->calData;
528 u32 numSamples =
529 (1 << (calData->calCountMax + 5)) * calData->calNumSamples;
530
531 for (i = 0; i < numChains; i++) {
532 iOddMeasOffset = ahp->ah_totalAdcDcOffsetIOddPhase[i];
533 iEvenMeasOffset = ahp->ah_totalAdcDcOffsetIEvenPhase[i];
534 qOddMeasOffset = ahp->ah_totalAdcDcOffsetQOddPhase[i];
535 qEvenMeasOffset = ahp->ah_totalAdcDcOffsetQEvenPhase[i];
536
537 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
538 "Starting ADC DC Offset Cal for Chain %d\n", i);
539
540 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
541 "Chn %d pwr_meas_odd_i = %d\n", i,
542 iOddMeasOffset);
543 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
544 "Chn %d pwr_meas_even_i = %d\n", i,
545 iEvenMeasOffset);
546 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
547 "Chn %d pwr_meas_odd_q = %d\n", i,
548 qOddMeasOffset);
549 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
550 "Chn %d pwr_meas_even_q = %d\n", i,
551 qEvenMeasOffset);
552
553 iDcMismatch = (((iEvenMeasOffset - iOddMeasOffset) * 2) /
554 numSamples) & 0x1ff;
555 qDcMismatch = (((qOddMeasOffset - qEvenMeasOffset) * 2) /
556 numSamples) & 0x1ff;
557
558 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
559 "Chn %d dc_offset_mismatch_i = 0x%08x\n", i,
560 iDcMismatch);
561 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
562 "Chn %d dc_offset_mismatch_q = 0x%08x\n", i,
563 qDcMismatch);
564
565 val = REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i));
566 val &= 0xc0000fff;
567 val |= (qDcMismatch << 12) | (iDcMismatch << 21);
568 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i), val);
569
570 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
571 "ADC DC Offset Cal done for Chain %d\n", i);
572 }
573
574 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0),
575 REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0)) |
576 AR_PHY_NEW_ADC_DC_OFFSET_CORR_ENABLE);
577}
578
579void ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan,
580 bool *isCalDone)
581{
582 struct ath_hal_5416 *ahp = AH5416(ah);
583 struct ath9k_channel *ichan =
584 ath9k_regd_check_channel(ah, chan);
585 struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
586
587 *isCalDone = true;
588
589 if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah))
590 return;
591
592 if (currCal == NULL)
593 return;
594
595 if (ichan == NULL) {
596 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
597 "%s: invalid channel %u/0x%x; no mapping\n",
598 __func__, chan->channel, chan->channelFlags);
599 return;
600 }
601
602
603 if (currCal->calState != CAL_DONE) {
604 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
605 "%s: Calibration state incorrect, %d\n",
606 __func__, currCal->calState);
607 return;
608 }
609
610
611 if (!ath9k_hw_iscal_supported(ah, chan, currCal->calData->calType))
612 return;
613
614 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
615 "%s: Resetting Cal %d state for channel %u/0x%x\n",
616 __func__, currCal->calData->calType, chan->channel,
617 chan->channelFlags);
618
619 ichan->CalValid &= ~currCal->calData->calType;
620 currCal->calState = CAL_WAITING;
621
622 *isCalDone = false;
623}
624
625void ath9k_hw_start_nfcal(struct ath_hal *ah)
626{
627 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
628 AR_PHY_AGC_CONTROL_ENABLE_NF);
629 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
630 AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
631 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
632}
633
634void ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan)
635{
636 struct ath9k_nfcal_hist *h;
637 int i, j;
638 int32_t val;
639 const u32 ar5416_cca_regs[6] = {
640 AR_PHY_CCA,
641 AR_PHY_CH1_CCA,
642 AR_PHY_CH2_CCA,
643 AR_PHY_EXT_CCA,
644 AR_PHY_CH1_EXT_CCA,
645 AR_PHY_CH2_EXT_CCA
646 };
647 u8 chainmask;
648
649 if (AR_SREV_9280(ah))
650 chainmask = 0x1B;
651 else
652 chainmask = 0x3F;
653
654#ifdef ATH_NF_PER_CHAN
655 h = chan->nfCalHist;
656#else
657 h = ah->nfCalHist;
658#endif
659
660 for (i = 0; i < NUM_NF_READINGS; i++) {
661 if (chainmask & (1 << i)) {
662 val = REG_READ(ah, ar5416_cca_regs[i]);
663 val &= 0xFFFFFE00;
664 val |= (((u32) (h[i].privNF) << 1) & 0x1ff);
665 REG_WRITE(ah, ar5416_cca_regs[i], val);
666 }
667 }
668
669 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
670 AR_PHY_AGC_CONTROL_ENABLE_NF);
671 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
672 AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
673 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
674
675 for (j = 0; j < 1000; j++) {
676 if ((REG_READ(ah, AR_PHY_AGC_CONTROL) &
677 AR_PHY_AGC_CONTROL_NF) == 0)
678 break;
679 udelay(10);
680 }
681
682 for (i = 0; i < NUM_NF_READINGS; i++) {
683 if (chainmask & (1 << i)) {
684 val = REG_READ(ah, ar5416_cca_regs[i]);
685 val &= 0xFFFFFE00;
686 val |= (((u32) (-50) << 1) & 0x1ff);
687 REG_WRITE(ah, ar5416_cca_regs[i], val);
688 }
689 }
690}
691
692int16_t ath9k_hw_getnf(struct ath_hal *ah,
693 struct ath9k_channel *chan)
694{
695 int16_t nf, nfThresh;
696 int16_t nfarray[NUM_NF_READINGS] = { 0 };
697 struct ath9k_nfcal_hist *h;
698 u8 chainmask;
699
700 if (AR_SREV_9280(ah))
701 chainmask = 0x1B;
702 else
703 chainmask = 0x3F;
704
705 chan->channelFlags &= (~CHANNEL_CW_INT);
706 if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) {
707 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
708 "%s: NF did not complete in calibration window\n",
709 __func__);
710 nf = 0;
711 chan->rawNoiseFloor = nf;
712 return chan->rawNoiseFloor;
713 } else {
714 ath9k_hw_do_getnf(ah, nfarray);
715 nf = nfarray[0];
716 if (getNoiseFloorThresh(ah, chan, &nfThresh)
717 && nf > nfThresh) {
718 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
719 "%s: noise floor failed detected; "
720 "detected %d, threshold %d\n", __func__,
721 nf, nfThresh);
722 chan->channelFlags |= CHANNEL_CW_INT;
723 }
724 }
725
726#ifdef ATH_NF_PER_CHAN
727 h = chan->nfCalHist;
728#else
729 h = ah->nfCalHist;
730#endif
731
732 ath9k_hw_update_nfcal_hist_buffer(h, nfarray);
733 chan->rawNoiseFloor = h[0].privNF;
734
735 return chan->rawNoiseFloor;
736}
737
738void ath9k_init_nfcal_hist_buffer(struct ath_hal *ah)
739{
740 int i, j;
741
742 for (i = 0; i < NUM_NF_READINGS; i++) {
743 ah->nfCalHist[i].currIndex = 0;
744 ah->nfCalHist[i].privNF = AR_PHY_CCA_MAX_GOOD_VALUE;
745 ah->nfCalHist[i].invalidNFcount =
746 AR_PHY_CCA_FILTERWINDOW_LENGTH;
747 for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) {
748 ah->nfCalHist[i].nfCalBuffer[j] =
749 AR_PHY_CCA_MAX_GOOD_VALUE;
750 }
751 }
752 return;
753}
754
755s16 ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan)
756{
757 struct ath9k_channel *ichan;
758 s16 nf;
759
760 ichan = ath9k_regd_check_channel(ah, chan);
761 if (ichan == NULL) {
762 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
763 "%s: invalid channel %u/0x%x; no mapping\n",
764 __func__, chan->channel, chan->channelFlags);
765 return ATH_DEFAULT_NOISE_FLOOR;
766 }
767 if (ichan->rawNoiseFloor == 0) {
768 enum wireless_mode mode = ath9k_hw_chan2wmode(ah, chan);
769 nf = NOISE_FLOOR[mode];
770 } else
771 nf = ichan->rawNoiseFloor;
772
773 if (!ath9k_hw_nf_in_range(ah, nf))
774 nf = ATH_DEFAULT_NOISE_FLOOR;
775
776 return nf;
777}
778
779bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
780 u8 rxchainmask, bool longcal,
781 bool *isCalDone)
782{
783 struct ath_hal_5416 *ahp = AH5416(ah);
784 struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
785 struct ath9k_channel *ichan = ath9k_regd_check_channel(ah, chan);
786
787 *isCalDone = true;
788
789 if (ichan == NULL) {
790 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
791 "%s: invalid channel %u/0x%x; no mapping\n",
792 __func__, chan->channel, chan->channelFlags);
793 return false;
794 }
795
796 if (currCal &&
797 (currCal->calState == CAL_RUNNING ||
798 currCal->calState == CAL_WAITING)) {
799 ath9k_hw_per_calibration(ah, ichan, rxchainmask, currCal,
800 isCalDone);
801 if (*isCalDone) {
802 ahp->ah_cal_list_curr = currCal = currCal->calNext;
803
804 if (currCal->calState == CAL_WAITING) {
805 *isCalDone = false;
806 ath9k_hw_reset_calibration(ah, currCal);
807 }
808 }
809 }
810
811 if (longcal) {
812 ath9k_hw_getnf(ah, ichan);
813 ath9k_hw_loadnf(ah, ah->ah_curchan);
814 ath9k_hw_start_nfcal(ah);
815
816 if ((ichan->channelFlags & CHANNEL_CW_INT) != 0) {
817 chan->channelFlags |= CHANNEL_CW_INT;
818 ichan->channelFlags &= ~CHANNEL_CW_INT;
819 }
820 }
821
822 return true;
823}
824
825bool ath9k_hw_init_cal(struct ath_hal *ah,
826 struct ath9k_channel *chan)
827{
828 struct ath_hal_5416 *ahp = AH5416(ah);
829 struct ath9k_channel *ichan = ath9k_regd_check_channel(ah, chan);
830
831 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
832 REG_READ(ah, AR_PHY_AGC_CONTROL) |
833 AR_PHY_AGC_CONTROL_CAL);
834
835 if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 0)) {
836 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
837 "%s: offset calibration failed to complete in 1ms; "
838 "noisy environment?\n", __func__);
839 return false;
840 }
841
842 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
843 REG_READ(ah, AR_PHY_AGC_CONTROL) |
844 AR_PHY_AGC_CONTROL_NF);
845
846 ahp->ah_cal_list = ahp->ah_cal_list_last = ahp->ah_cal_list_curr = NULL;
847
848 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
849 if (ath9k_hw_iscal_supported(ah, chan, ADC_GAIN_CAL)) {
850 INIT_CAL(&ahp->ah_adcGainCalData);
851 INSERT_CAL(ahp, &ahp->ah_adcGainCalData);
852 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
853 "%s: enabling ADC Gain Calibration.\n",
854 __func__);
855 }
856 if (ath9k_hw_iscal_supported(ah, chan, ADC_DC_CAL)) {
857 INIT_CAL(&ahp->ah_adcDcCalData);
858 INSERT_CAL(ahp, &ahp->ah_adcDcCalData);
859 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
860 "%s: enabling ADC DC Calibration.\n",
861 __func__);
862 }
863 if (ath9k_hw_iscal_supported(ah, chan, IQ_MISMATCH_CAL)) {
864 INIT_CAL(&ahp->ah_iqCalData);
865 INSERT_CAL(ahp, &ahp->ah_iqCalData);
866 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
867 "%s: enabling IQ Calibration.\n",
868 __func__);
869 }
870
871 ahp->ah_cal_list_curr = ahp->ah_cal_list;
872
873 if (ahp->ah_cal_list_curr)
874 ath9k_hw_reset_calibration(ah, ahp->ah_cal_list_curr);
875 }
876
877 ichan->CalValid = 0;
878
879 return true;
880}
881
882const struct hal_percal_data iq_cal_multi_sample = {
883 IQ_MISMATCH_CAL,
884 MAX_CAL_SAMPLES,
885 PER_MIN_LOG_COUNT,
886 ath9k_hw_iqcal_collect,
887 ath9k_hw_iqcalibrate
888};
889const struct hal_percal_data iq_cal_single_sample = {
890 IQ_MISMATCH_CAL,
891 MIN_CAL_SAMPLES,
892 PER_MAX_LOG_COUNT,
893 ath9k_hw_iqcal_collect,
894 ath9k_hw_iqcalibrate
895};
896const struct hal_percal_data adc_gain_cal_multi_sample = {
897 ADC_GAIN_CAL,
898 MAX_CAL_SAMPLES,
899 PER_MIN_LOG_COUNT,
900 ath9k_hw_adc_gaincal_collect,
901 ath9k_hw_adc_gaincal_calibrate
902};
903const struct hal_percal_data adc_gain_cal_single_sample = {
904 ADC_GAIN_CAL,
905 MIN_CAL_SAMPLES,
906 PER_MAX_LOG_COUNT,
907 ath9k_hw_adc_gaincal_collect,
908 ath9k_hw_adc_gaincal_calibrate
909};
910const struct hal_percal_data adc_dc_cal_multi_sample = {
911 ADC_DC_CAL,
912 MAX_CAL_SAMPLES,
913 PER_MIN_LOG_COUNT,
914 ath9k_hw_adc_dccal_collect,
915 ath9k_hw_adc_dccal_calibrate
916};
917const struct hal_percal_data adc_dc_cal_single_sample = {
918 ADC_DC_CAL,
919 MIN_CAL_SAMPLES,
920 PER_MAX_LOG_COUNT,
921 ath9k_hw_adc_dccal_collect,
922 ath9k_hw_adc_dccal_calibrate
923};
924const struct hal_percal_data adc_init_dc_cal = {
925 ADC_DC_INIT_CAL,
926 MIN_CAL_SAMPLES,
927 INIT_LOG_COUNT,
928 ath9k_hw_adc_dccal_collect,
929 ath9k_hw_adc_dccal_calibrate
930};
diff --git a/drivers/net/wireless/ath9k/core.c b/drivers/net/wireless/ath9k/core.c
index c5033f6f42ac..5f5184acb274 100644
--- a/drivers/net/wireless/ath9k/core.c
+++ b/drivers/net/wireless/ath9k/core.c
@@ -14,13 +14,9 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17 /* Implementation of the main "ATH" layer. */
18
19#include "core.h" 17#include "core.h"
20#include "regd.h" 18#include "regd.h"
21 19
22static int ath_outdoor; /* enable outdoor use */
23
24static u32 ath_chainmask_sel_up_rssi_thres = 20static u32 ath_chainmask_sel_up_rssi_thres =
25 ATH_CHAINMASK_SEL_UP_RSSI_THRES; 21 ATH_CHAINMASK_SEL_UP_RSSI_THRES;
26static u32 ath_chainmask_sel_down_rssi_thres = 22static u32 ath_chainmask_sel_down_rssi_thres =
@@ -47,6 +43,41 @@ static void bus_read_cachesize(struct ath_softc *sc, int *csz)
47 *csz = DEFAULT_CACHELINE >> 2; /* Use the default size */ 43 *csz = DEFAULT_CACHELINE >> 2; /* Use the default size */
48} 44}
49 45
46static u8 parse_mpdudensity(u8 mpdudensity)
47{
48 /*
49 * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
50 * 0 for no restriction
51 * 1 for 1/4 us
52 * 2 for 1/2 us
53 * 3 for 1 us
54 * 4 for 2 us
55 * 5 for 4 us
56 * 6 for 8 us
57 * 7 for 16 us
58 */
59 switch (mpdudensity) {
60 case 0:
61 return 0;
62 case 1:
63 case 2:
64 case 3:
65 /* Our lower layer calculations limit our precision to
66 1 microsecond */
67 return 1;
68 case 4:
69 return 2;
70 case 5:
71 return 4;
72 case 6:
73 return 8;
74 case 7:
75 return 16;
76 default:
77 return 0;
78 }
79}
80
50/* 81/*
51 * Set current operating mode 82 * Set current operating mode
52 * 83 *
@@ -155,17 +186,10 @@ static int ath_setup_channels(struct ath_softc *sc)
155 struct ath9k_channel *c; 186 struct ath9k_channel *c;
156 187
157 /* Fill in ah->ah_channels */ 188 /* Fill in ah->ah_channels */
158 if (!ath9k_regd_init_channels(ah, 189 if (!ath9k_regd_init_channels(ah, ATH_CHAN_MAX, (u32 *)&nchan,
159 ATH_CHAN_MAX, 190 regclassids, ATH_REGCLASSIDS_MAX,
160 (u32 *)&nchan, 191 &nregclass, CTRY_DEFAULT, false, 1)) {
161 regclassids,
162 ATH_REGCLASSIDS_MAX,
163 &nregclass,
164 CTRY_DEFAULT,
165 false,
166 1)) {
167 u32 rd = ah->ah_currentRD; 192 u32 rd = ah->ah_currentRD;
168
169 DPRINTF(sc, ATH_DBG_FATAL, 193 DPRINTF(sc, ATH_DBG_FATAL,
170 "%s: unable to collect channel list; " 194 "%s: unable to collect channel list; "
171 "regdomain likely %u country code %u\n", 195 "regdomain likely %u country code %u\n",
@@ -186,40 +210,32 @@ static int ath_setup_channels(struct ath_softc *sc)
186 chan_2ghz[a].max_power = c->maxTxPower; 210 chan_2ghz[a].max_power = c->maxTxPower;
187 211
188 if (c->privFlags & CHANNEL_DISALLOW_ADHOC) 212 if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
189 chan_2ghz[a].flags |= 213 chan_2ghz[a].flags |= IEEE80211_CHAN_NO_IBSS;
190 IEEE80211_CHAN_NO_IBSS;
191 if (c->channelFlags & CHANNEL_PASSIVE) 214 if (c->channelFlags & CHANNEL_PASSIVE)
192 chan_2ghz[a].flags |= 215 chan_2ghz[a].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
193 IEEE80211_CHAN_PASSIVE_SCAN;
194 216
195 band_2ghz->n_channels = ++a; 217 band_2ghz->n_channels = ++a;
196 218
197 DPRINTF(sc, ATH_DBG_CONFIG, 219 DPRINTF(sc, ATH_DBG_CONFIG,
198 "%s: 2MHz channel: %d, " 220 "%s: 2MHz channel: %d, "
199 "channelFlags: 0x%x\n", 221 "channelFlags: 0x%x\n",
200 __func__, 222 __func__, c->channel, c->channelFlags);
201 c->channel,
202 c->channelFlags);
203 } else if (IS_CHAN_5GHZ(c)) { 223 } else if (IS_CHAN_5GHZ(c)) {
204 chan_5ghz[b].band = IEEE80211_BAND_5GHZ; 224 chan_5ghz[b].band = IEEE80211_BAND_5GHZ;
205 chan_5ghz[b].center_freq = c->channel; 225 chan_5ghz[b].center_freq = c->channel;
206 chan_5ghz[b].max_power = c->maxTxPower; 226 chan_5ghz[b].max_power = c->maxTxPower;
207 227
208 if (c->privFlags & CHANNEL_DISALLOW_ADHOC) 228 if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
209 chan_5ghz[b].flags |= 229 chan_5ghz[b].flags |= IEEE80211_CHAN_NO_IBSS;
210 IEEE80211_CHAN_NO_IBSS;
211 if (c->channelFlags & CHANNEL_PASSIVE) 230 if (c->channelFlags & CHANNEL_PASSIVE)
212 chan_5ghz[b].flags |= 231 chan_5ghz[b].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
213 IEEE80211_CHAN_PASSIVE_SCAN;
214 232
215 band_5ghz->n_channels = ++b; 233 band_5ghz->n_channels = ++b;
216 234
217 DPRINTF(sc, ATH_DBG_CONFIG, 235 DPRINTF(sc, ATH_DBG_CONFIG,
218 "%s: 5MHz channel: %d, " 236 "%s: 5MHz channel: %d, "
219 "channelFlags: 0x%x\n", 237 "channelFlags: 0x%x\n",
220 __func__, 238 __func__, c->channel, c->channelFlags);
221 c->channel,
222 c->channelFlags);
223 } 239 }
224 } 240 }
225 241
@@ -261,44 +277,6 @@ static enum wireless_mode ath_chan2mode(struct ath9k_channel *chan)
261} 277}
262 278
263/* 279/*
264 * Stop the device, grabbing the top-level lock to protect
265 * against concurrent entry through ath_init (which can happen
266 * if another thread does a system call and the thread doing the
267 * stop is preempted).
268 */
269
270static int ath_stop(struct ath_softc *sc)
271{
272 struct ath_hal *ah = sc->sc_ah;
273
274 DPRINTF(sc, ATH_DBG_CONFIG, "%s: invalid %ld\n",
275 __func__, sc->sc_flags & SC_OP_INVALID);
276
277 /*
278 * Shutdown the hardware and driver:
279 * stop output from above
280 * turn off timers
281 * disable interrupts
282 * clear transmit machinery
283 * clear receive machinery
284 * turn off the radio
285 * reclaim beacon resources
286 *
287 * Note that some of this work is not possible if the
288 * hardware is gone (invalid).
289 */
290
291 ath_draintxq(sc, false);
292 if (!(sc->sc_flags & SC_OP_INVALID)) {
293 ath_stoprecv(sc);
294 ath9k_hw_phy_disable(ah);
295 } else
296 sc->sc_rxlink = NULL;
297
298 return 0;
299}
300
301/*
302 * Set the current channel 280 * Set the current channel
303 * 281 *
304 * Set/change channels. If the channel is really being changed, it's done 282 * Set/change channels. If the channel is really being changed, it's done
@@ -606,114 +584,6 @@ static void ath_ani_calibrate(unsigned long data)
606 mod_timer(&sc->sc_ani.timer, jiffies + msecs_to_jiffies(cal_interval)); 584 mod_timer(&sc->sc_ani.timer, jiffies + msecs_to_jiffies(cal_interval));
607} 585}
608 586
609/******************/
610/* VAP management */
611/******************/
612
613int ath_vap_attach(struct ath_softc *sc,
614 int if_id,
615 struct ieee80211_vif *if_data,
616 enum ath9k_opmode opmode)
617{
618 struct ath_vap *avp;
619
620 if (if_id >= ATH_BCBUF || sc->sc_vaps[if_id] != NULL) {
621 DPRINTF(sc, ATH_DBG_FATAL,
622 "%s: Invalid interface id = %u\n", __func__, if_id);
623 return -EINVAL;
624 }
625
626 switch (opmode) {
627 case ATH9K_M_STA:
628 case ATH9K_M_IBSS:
629 case ATH9K_M_MONITOR:
630 break;
631 case ATH9K_M_HOSTAP:
632 /* XXX not right, beacon buffer is allocated on RUN trans */
633 if (list_empty(&sc->sc_bbuf))
634 return -ENOMEM;
635 break;
636 default:
637 return -EINVAL;
638 }
639
640 /* create ath_vap */
641 avp = kmalloc(sizeof(struct ath_vap), GFP_KERNEL);
642 if (avp == NULL)
643 return -ENOMEM;
644
645 memset(avp, 0, sizeof(struct ath_vap));
646 avp->av_if_data = if_data;
647 /* Set the VAP opmode */
648 avp->av_opmode = opmode;
649 avp->av_bslot = -1;
650
651 if (opmode == ATH9K_M_HOSTAP)
652 ath9k_hw_set_tsfadjust(sc->sc_ah, 1);
653
654 sc->sc_vaps[if_id] = avp;
655 sc->sc_nvaps++;
656 /* Set the device opmode */
657 sc->sc_ah->ah_opmode = opmode;
658
659 /* default VAP configuration */
660 avp->av_config.av_fixed_rateset = IEEE80211_FIXED_RATE_NONE;
661 avp->av_config.av_fixed_retryset = 0x03030303;
662
663 return 0;
664}
665
666int ath_vap_detach(struct ath_softc *sc, int if_id)
667{
668 struct ath_hal *ah = sc->sc_ah;
669 struct ath_vap *avp;
670
671 avp = sc->sc_vaps[if_id];
672 if (avp == NULL) {
673 DPRINTF(sc, ATH_DBG_FATAL, "%s: invalid interface id %u\n",
674 __func__, if_id);
675 return -EINVAL;
676 }
677
678 /*
679 * Quiesce the hardware while we remove the vap. In
680 * particular we need to reclaim all references to the
681 * vap state by any frames pending on the tx queues.
682 *
683 * XXX can we do this w/o affecting other vap's?
684 */
685 ath9k_hw_set_interrupts(ah, 0); /* disable interrupts */
686 ath_draintxq(sc, false); /* stop xmit side */
687 ath_stoprecv(sc); /* stop recv side */
688 ath_flushrecv(sc); /* flush recv queue */
689
690 kfree(avp);
691 sc->sc_vaps[if_id] = NULL;
692 sc->sc_nvaps--;
693
694 return 0;
695}
696
697int ath_vap_config(struct ath_softc *sc,
698 int if_id, struct ath_vap_config *if_config)
699{
700 struct ath_vap *avp;
701
702 if (if_id >= ATH_BCBUF) {
703 DPRINTF(sc, ATH_DBG_FATAL,
704 "%s: Invalid interface id = %u\n", __func__, if_id);
705 return -EINVAL;
706 }
707
708 avp = sc->sc_vaps[if_id];
709 ASSERT(avp != NULL);
710
711 if (avp)
712 memcpy(&avp->av_config, if_config, sizeof(avp->av_config));
713
714 return 0;
715}
716
717/********/ 587/********/
718/* Core */ 588/* Core */
719/********/ 589/********/
@@ -727,16 +597,6 @@ int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan)
727 DPRINTF(sc, ATH_DBG_CONFIG, "%s: mode %d\n", 597 DPRINTF(sc, ATH_DBG_CONFIG, "%s: mode %d\n",
728 __func__, sc->sc_ah->ah_opmode); 598 __func__, sc->sc_ah->ah_opmode);
729 599
730 /*
731 * Stop anything previously setup. This is safe
732 * whether this is the first time through or not.
733 */
734 ath_stop(sc);
735
736 /* Initialize chanmask selection */
737 sc->sc_tx_chainmask = ah->ah_caps.tx_chainmask;
738 sc->sc_rx_chainmask = ah->ah_caps.rx_chainmask;
739
740 /* Reset SERDES registers */ 600 /* Reset SERDES registers */
741 ath9k_hw_configpcipowersave(ah, 0); 601 ath9k_hw_configpcipowersave(ah, 0);
742 602
@@ -762,6 +622,7 @@ int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan)
762 goto done; 622 goto done;
763 } 623 }
764 spin_unlock_bh(&sc->sc_resetlock); 624 spin_unlock_bh(&sc->sc_resetlock);
625
765 /* 626 /*
766 * This is needed only to setup initial state 627 * This is needed only to setup initial state
767 * but it's best done after a reset. 628 * but it's best done after a reset.
@@ -781,6 +642,7 @@ int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan)
781 error = -EIO; 642 error = -EIO;
782 goto done; 643 goto done;
783 } 644 }
645
784 /* Setup our intr mask. */ 646 /* Setup our intr mask. */
785 sc->sc_imask = ATH9K_INT_RX | ATH9K_INT_TX 647 sc->sc_imask = ATH9K_INT_RX | ATH9K_INT_TX
786 | ATH9K_INT_RXEOL | ATH9K_INT_RXORN 648 | ATH9K_INT_RXEOL | ATH9K_INT_RXORN
@@ -810,30 +672,60 @@ int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan)
810 (sc->sc_ah->ah_opmode == ATH9K_M_STA) && 672 (sc->sc_ah->ah_opmode == ATH9K_M_STA) &&
811 !sc->sc_config.swBeaconProcess) 673 !sc->sc_config.swBeaconProcess)
812 sc->sc_imask |= ATH9K_INT_TIM; 674 sc->sc_imask |= ATH9K_INT_TIM;
813 /* 675
814 * Don't enable interrupts here as we've not yet built our
815 * vap and node data structures, which will be needed as soon
816 * as we start receiving.
817 */
818 ath_setcurmode(sc, ath_chan2mode(initial_chan)); 676 ath_setcurmode(sc, ath_chan2mode(initial_chan));
819 677
820 /* XXX: we must make sure h/w is ready and clear invalid flag
821 * before turning on interrupt. */
822 sc->sc_flags &= ~SC_OP_INVALID; 678 sc->sc_flags &= ~SC_OP_INVALID;
679
680 /* Disable BMISS interrupt when we're not associated */
681 sc->sc_imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS);
682 ath9k_hw_set_interrupts(sc->sc_ah,sc->sc_imask);
683
684 ieee80211_wake_queues(sc->hw);
823done: 685done:
824 return error; 686 return error;
825} 687}
826 688
689void ath_stop(struct ath_softc *sc)
690{
691 struct ath_hal *ah = sc->sc_ah;
692
693 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Cleaning up\n", __func__);
694
695 ieee80211_stop_queues(sc->hw);
696
697 /* make sure h/w will not generate any interrupt
698 * before setting the invalid flag. */
699 ath9k_hw_set_interrupts(ah, 0);
700
701 if (!(sc->sc_flags & SC_OP_INVALID)) {
702 ath_draintxq(sc, false);
703 ath_stoprecv(sc);
704 ath9k_hw_phy_disable(ah);
705 } else
706 sc->sc_rxlink = NULL;
707
708#ifdef CONFIG_RFKILL
709 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
710 cancel_delayed_work_sync(&sc->rf_kill.rfkill_poll);
711#endif
712 /* disable HAL and put h/w to sleep */
713 ath9k_hw_disable(sc->sc_ah);
714 ath9k_hw_configpcipowersave(sc->sc_ah, 1);
715
716 sc->sc_flags |= SC_OP_INVALID;
717}
718
827int ath_reset(struct ath_softc *sc, bool retry_tx) 719int ath_reset(struct ath_softc *sc, bool retry_tx)
828{ 720{
829 struct ath_hal *ah = sc->sc_ah; 721 struct ath_hal *ah = sc->sc_ah;
830 int status; 722 int status;
831 int error = 0; 723 int error = 0;
832 724
833 ath9k_hw_set_interrupts(ah, 0); /* disable interrupts */ 725 ath9k_hw_set_interrupts(ah, 0);
834 ath_draintxq(sc, retry_tx); /* stop xmit */ 726 ath_draintxq(sc, retry_tx);
835 ath_stoprecv(sc); /* stop recv */ 727 ath_stoprecv(sc);
836 ath_flushrecv(sc); /* flush recv queue */ 728 ath_flushrecv(sc);
837 729
838 /* Reset chip */ 730 /* Reset chip */
839 spin_lock_bh(&sc->sc_resetlock); 731 spin_lock_bh(&sc->sc_resetlock);
@@ -848,7 +740,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
848 } 740 }
849 spin_unlock_bh(&sc->sc_resetlock); 741 spin_unlock_bh(&sc->sc_resetlock);
850 742
851 if (ath_startrecv(sc) != 0) /* restart recv */ 743 if (ath_startrecv(sc) != 0)
852 DPRINTF(sc, ATH_DBG_FATAL, 744 DPRINTF(sc, ATH_DBG_FATAL,
853 "%s: unable to start recv logic\n", __func__); 745 "%s: unable to start recv logic\n", __func__);
854 746
@@ -881,29 +773,6 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
881 return error; 773 return error;
882} 774}
883 775
884int ath_suspend(struct ath_softc *sc)
885{
886 struct ath_hal *ah = sc->sc_ah;
887
888 /* No I/O if device has been surprise removed */
889 if (sc->sc_flags & SC_OP_INVALID)
890 return -EIO;
891
892 /* Shut off the interrupt before setting sc->sc_invalid to '1' */
893 ath9k_hw_set_interrupts(ah, 0);
894
895 /* XXX: we must make sure h/w will not generate any interrupt
896 * before setting the invalid flag. */
897 sc->sc_flags |= SC_OP_INVALID;
898
899 /* disable HAL and put h/w to sleep */
900 ath9k_hw_disable(sc->sc_ah);
901
902 ath9k_hw_configpcipowersave(sc->sc_ah, 1);
903
904 return 0;
905}
906
907/* Interrupt handler. Most of the actual processing is deferred. 776/* Interrupt handler. Most of the actual processing is deferred.
908 * It's the caller's responsibility to ensure the chip is awake. */ 777 * It's the caller's responsibility to ensure the chip is awake. */
909 778
@@ -1071,11 +940,9 @@ int ath_init(u16 devid, struct ath_softc *sc)
1071 940
1072 /* XXX: hardware will not be ready until ath_open() being called */ 941 /* XXX: hardware will not be ready until ath_open() being called */
1073 sc->sc_flags |= SC_OP_INVALID; 942 sc->sc_flags |= SC_OP_INVALID;
1074
1075 sc->sc_debug = DBG_DEFAULT; 943 sc->sc_debug = DBG_DEFAULT;
1076 DPRINTF(sc, ATH_DBG_CONFIG, "%s: devid 0x%x\n", __func__, devid);
1077 944
1078 /* Initialize tasklet */ 945 spin_lock_init(&sc->sc_resetlock);
1079 tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); 946 tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
1080 tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet, 947 tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet,
1081 (unsigned long)sc); 948 (unsigned long)sc);
@@ -1088,8 +955,6 @@ int ath_init(u16 devid, struct ath_softc *sc)
1088 /* XXX assert csz is non-zero */ 955 /* XXX assert csz is non-zero */
1089 sc->sc_cachelsz = csz << 2; /* convert to bytes */ 956 sc->sc_cachelsz = csz << 2; /* convert to bytes */
1090 957
1091 spin_lock_init(&sc->sc_resetlock);
1092
1093 ah = ath9k_hw_attach(devid, sc, sc->mem, &status); 958 ah = ath9k_hw_attach(devid, sc, sc->mem, &status);
1094 if (ah == NULL) { 959 if (ah == NULL) {
1095 DPRINTF(sc, ATH_DBG_FATAL, 960 DPRINTF(sc, ATH_DBG_FATAL,
@@ -1100,10 +965,6 @@ int ath_init(u16 devid, struct ath_softc *sc)
1100 } 965 }
1101 sc->sc_ah = ah; 966 sc->sc_ah = ah;
1102 967
1103 /* Initializes the noise floor to a reasonable default value.
1104 * Later on this will be updated during ANI processing. */
1105 sc->sc_ani.sc_noise_floor = ATH_DEFAULT_NOISE_FLOOR;
1106
1107 /* Get the hardware key cache size. */ 968 /* Get the hardware key cache size. */
1108 sc->sc_keymax = ah->ah_caps.keycache_size; 969 sc->sc_keymax = ah->ah_caps.keycache_size;
1109 if (sc->sc_keymax > ATH_KEYMAX) { 970 if (sc->sc_keymax > ATH_KEYMAX) {
@@ -1131,17 +992,14 @@ int ath_init(u16 devid, struct ath_softc *sc)
1131 set_bit(i + 64, sc->sc_keymap); 992 set_bit(i + 64, sc->sc_keymap);
1132 set_bit(i + 32 + 64, sc->sc_keymap); 993 set_bit(i + 32 + 64, sc->sc_keymap);
1133 } 994 }
1134 /* 995
1135 * Collect the channel list using the default country 996 /* Collect the channel list using the default country code */
1136 * code and including outdoor channels. The 802.11 layer 997
1137 * is resposible for filtering this list based on settings
1138 * like the phy mode.
1139 */
1140 error = ath_setup_channels(sc); 998 error = ath_setup_channels(sc);
1141 if (error) 999 if (error)
1142 goto bad; 1000 goto bad;
1143 1001
1144 /* default to STA mode */ 1002 /* default to MONITOR mode */
1145 sc->sc_ah->ah_opmode = ATH9K_M_MONITOR; 1003 sc->sc_ah->ah_opmode = ATH9K_M_MONITOR;
1146 1004
1147 /* Setup rate tables */ 1005 /* Setup rate tables */
@@ -1211,6 +1069,10 @@ int ath_init(u16 devid, struct ath_softc *sc)
1211 goto bad2; 1069 goto bad2;
1212 } 1070 }
1213 1071
1072 /* Initializes the noise floor to a reasonable default value.
1073 * Later on this will be updated during ANI processing. */
1074
1075 sc->sc_ani.sc_noise_floor = ATH_DEFAULT_NOISE_FLOOR;
1214 setup_timer(&sc->sc_ani.timer, ath_ani_calibrate, (unsigned long)sc); 1076 setup_timer(&sc->sc_ani.timer, ath_ani_calibrate, (unsigned long)sc);
1215 1077
1216 sc->sc_rc = ath_rate_attach(ah); 1078 sc->sc_rc = ath_rate_attach(ah);
@@ -1271,6 +1133,7 @@ int ath_init(u16 devid, struct ath_softc *sc)
1271 ATH_SET_VAP_BSSID_MASK(sc->sc_bssidmask); 1133 ATH_SET_VAP_BSSID_MASK(sc->sc_bssidmask);
1272 ath9k_hw_setbssidmask(ah, sc->sc_bssidmask); 1134 ath9k_hw_setbssidmask(ah, sc->sc_bssidmask);
1273 } 1135 }
1136
1274 sc->sc_slottime = ATH9K_SLOT_TIME_9; /* default to short slot time */ 1137 sc->sc_slottime = ATH9K_SLOT_TIME_9; /* default to short slot time */
1275 1138
1276 /* initialize beacon slots */ 1139 /* initialize beacon slots */
@@ -1285,6 +1148,22 @@ int ath_init(u16 devid, struct ath_softc *sc)
1285 ath_slow_ant_div_init(&sc->sc_antdiv, sc, 0x127); 1148 ath_slow_ant_div_init(&sc->sc_antdiv, sc, 0x127);
1286#endif 1149#endif
1287 1150
1151 /* setup channels and rates */
1152
1153 sc->sbands[IEEE80211_BAND_2GHZ].channels =
1154 sc->channels[IEEE80211_BAND_2GHZ];
1155 sc->sbands[IEEE80211_BAND_2GHZ].bitrates =
1156 sc->rates[IEEE80211_BAND_2GHZ];
1157 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
1158
1159 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->ah_caps.wireless_modes)) {
1160 sc->sbands[IEEE80211_BAND_5GHZ].channels =
1161 sc->channels[IEEE80211_BAND_5GHZ];
1162 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
1163 sc->rates[IEEE80211_BAND_5GHZ];
1164 sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
1165 }
1166
1288 return 0; 1167 return 0;
1289bad2: 1168bad2:
1290 /* cleanup tx queues */ 1169 /* cleanup tx queues */
@@ -1294,128 +1173,39 @@ bad2:
1294bad: 1173bad:
1295 if (ah) 1174 if (ah)
1296 ath9k_hw_detach(ah); 1175 ath9k_hw_detach(ah);
1297 return error;
1298}
1299
1300void ath_deinit(struct ath_softc *sc)
1301{
1302 struct ath_hal *ah = sc->sc_ah;
1303 int i;
1304
1305 DPRINTF(sc, ATH_DBG_CONFIG, "%s\n", __func__);
1306 1176
1307 tasklet_kill(&sc->intr_tq); 1177 return error;
1308 tasklet_kill(&sc->bcon_tasklet);
1309 ath_stop(sc);
1310 if (!(sc->sc_flags & SC_OP_INVALID))
1311 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
1312 ath_rate_detach(sc->sc_rc);
1313 /* cleanup tx queues */
1314 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
1315 if (ATH_TXQ_SETUP(sc, i))
1316 ath_tx_cleanupq(sc, &sc->sc_txq[i]);
1317 ath9k_hw_detach(ah);
1318} 1178}
1319 1179
1320/*******************/ 1180/*******************/
1321/* Node Management */ 1181/* Node Management */
1322/*******************/ 1182/*******************/
1323 1183
1324struct ath_node *ath_node_attach(struct ath_softc *sc, u8 *addr, int if_id) 1184void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta)
1325{ 1185{
1326 struct ath_vap *avp;
1327 struct ath_node *an; 1186 struct ath_node *an;
1328 DECLARE_MAC_BUF(mac);
1329
1330 avp = sc->sc_vaps[if_id];
1331 ASSERT(avp != NULL);
1332 1187
1333 /* mac80211 sta_notify callback is from an IRQ context, so no sleep */ 1188 an = (struct ath_node *)sta->drv_priv;
1334 an = kmalloc(sizeof(struct ath_node), GFP_ATOMIC);
1335 if (an == NULL)
1336 return NULL;
1337 memset(an, 0, sizeof(*an));
1338 1189
1339 an->an_sc = sc; 1190 if (sc->sc_flags & SC_OP_TXAGGR)
1340 memcpy(an->an_addr, addr, ETH_ALEN); 1191 ath_tx_node_init(sc, an);
1341 atomic_set(&an->an_refcnt, 1);
1342 1192
1343 /* set up per-node tx/rx state */ 1193 an->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
1344 ath_tx_node_init(sc, an); 1194 sta->ht_cap.ampdu_factor);
1345 ath_rx_node_init(sc, an); 1195 an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density);
1346 1196
1347 ath_chainmask_sel_init(sc, an); 1197 ath_chainmask_sel_init(sc, an);
1348 ath_chainmask_sel_timerstart(&an->an_chainmask_sel); 1198 ath_chainmask_sel_timerstart(&an->an_chainmask_sel);
1349 list_add(&an->list, &sc->node_list);
1350
1351 return an;
1352} 1199}
1353 1200
1354void ath_node_detach(struct ath_softc *sc, struct ath_node *an, bool bh_flag) 1201void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
1355{ 1202{
1356 unsigned long flags; 1203 struct ath_node *an = (struct ath_node *)sta->drv_priv;
1357
1358 DECLARE_MAC_BUF(mac);
1359 1204
1360 ath_chainmask_sel_timerstop(&an->an_chainmask_sel); 1205 ath_chainmask_sel_timerstop(&an->an_chainmask_sel);
1361 an->an_flags |= ATH_NODE_CLEAN;
1362 ath_tx_node_cleanup(sc, an, bh_flag);
1363 ath_rx_node_cleanup(sc, an);
1364
1365 ath_tx_node_free(sc, an);
1366 ath_rx_node_free(sc, an);
1367
1368 spin_lock_irqsave(&sc->node_lock, flags);
1369
1370 list_del(&an->list);
1371
1372 spin_unlock_irqrestore(&sc->node_lock, flags);
1373 1206
1374 kfree(an); 1207 if (sc->sc_flags & SC_OP_TXAGGR)
1375} 1208 ath_tx_node_cleanup(sc, an);
1376
1377/* Finds a node and increases the refcnt if found */
1378
1379struct ath_node *ath_node_get(struct ath_softc *sc, u8 *addr)
1380{
1381 struct ath_node *an = NULL, *an_found = NULL;
1382
1383 if (list_empty(&sc->node_list)) /* FIXME */
1384 goto out;
1385 list_for_each_entry(an, &sc->node_list, list) {
1386 if (!compare_ether_addr(an->an_addr, addr)) {
1387 atomic_inc(&an->an_refcnt);
1388 an_found = an;
1389 break;
1390 }
1391 }
1392out:
1393 return an_found;
1394}
1395
1396/* Decrements the refcnt and if it drops to zero, detach the node */
1397
1398void ath_node_put(struct ath_softc *sc, struct ath_node *an, bool bh_flag)
1399{
1400 if (atomic_dec_and_test(&an->an_refcnt))
1401 ath_node_detach(sc, an, bh_flag);
1402}
1403
1404/* Finds a node, doesn't increment refcnt. Caller must hold sc->node_lock */
1405struct ath_node *ath_node_find(struct ath_softc *sc, u8 *addr)
1406{
1407 struct ath_node *an = NULL, *an_found = NULL;
1408
1409 if (list_empty(&sc->node_list))
1410 return NULL;
1411
1412 list_for_each_entry(an, &sc->node_list, list)
1413 if (!compare_ether_addr(an->an_addr, addr)) {
1414 an_found = an;
1415 break;
1416 }
1417
1418 return an_found;
1419} 1209}
1420 1210
1421/* 1211/*
@@ -1436,11 +1226,8 @@ void ath_newassoc(struct ath_softc *sc,
1436 for (tidno = 0; tidno < WME_NUM_TID; tidno++) { 1226 for (tidno = 0; tidno < WME_NUM_TID; tidno++) {
1437 if (sc->sc_flags & SC_OP_TXAGGR) 1227 if (sc->sc_flags & SC_OP_TXAGGR)
1438 ath_tx_aggr_teardown(sc, an, tidno); 1228 ath_tx_aggr_teardown(sc, an, tidno);
1439 if (sc->sc_flags & SC_OP_RXAGGR)
1440 ath_rx_aggr_teardown(sc, an, tidno);
1441 } 1229 }
1442 } 1230 }
1443 an->an_flags = 0;
1444} 1231}
1445 1232
1446/**************/ 1233/**************/
@@ -1491,27 +1278,6 @@ void ath_update_txpow(struct ath_softc *sc)
1491 } 1278 }
1492} 1279}
1493 1280
1494/* Return the current country and domain information */
1495void ath_get_currentCountry(struct ath_softc *sc,
1496 struct ath9k_country_entry *ctry)
1497{
1498 ath9k_regd_get_current_country(sc->sc_ah, ctry);
1499
1500 /* If HAL not specific yet, since it is band dependent,
1501 * use the one we passed in. */
1502 if (ctry->countryCode == CTRY_DEFAULT) {
1503 ctry->iso[0] = 0;
1504 ctry->iso[1] = 0;
1505 } else if (ctry->iso[0] && ctry->iso[1]) {
1506 if (!ctry->iso[2]) {
1507 if (ath_outdoor)
1508 ctry->iso[2] = 'O';
1509 else
1510 ctry->iso[2] = 'I';
1511 }
1512 }
1513}
1514
1515/**************************/ 1281/**************************/
1516/* Slow Antenna Diversity */ 1282/* Slow Antenna Diversity */
1517/**************************/ 1283/**************************/
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index cb3e61e57c4d..69e8d3e41131 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -84,9 +84,6 @@ struct ath_node;
84#define TSF_TO_TU(_h,_l) \ 84#define TSF_TO_TU(_h,_l) \
85 ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10)) 85 ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
86 86
87#define ATH9K_BH_STATUS_INTACT 0
88#define ATH9K_BH_STATUS_CHANGE 1
89
90#define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1<<i)) 87#define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1<<i))
91 88
92static inline unsigned long get_timestamp(void) 89static inline unsigned long get_timestamp(void)
@@ -209,6 +206,7 @@ struct ath_buf_state {
209 struct ath_rc_series bfs_rcs[4]; /* rate series */ 206 struct ath_rc_series bfs_rcs[4]; /* rate series */
210 u32 bf_type; /* BUF_* (enum buffer_type) */ 207 u32 bf_type; /* BUF_* (enum buffer_type) */
211 /* key type use to encrypt this frame */ 208 /* key type use to encrypt this frame */
209 u32 bfs_keyix;
212 enum ath9k_key_type bfs_keytype; 210 enum ath9k_key_type bfs_keytype;
213}; 211};
214 212
@@ -219,6 +217,7 @@ struct ath_buf_state {
219#define bf_seqno bf_state.bfs_seqno 217#define bf_seqno bf_state.bfs_seqno
220#define bf_tidno bf_state.bfs_tidno 218#define bf_tidno bf_state.bfs_tidno
221#define bf_rcs bf_state.bfs_rcs 219#define bf_rcs bf_state.bfs_rcs
220#define bf_keyix bf_state.bfs_keyix
222#define bf_keytype bf_state.bfs_keytype 221#define bf_keytype bf_state.bfs_keytype
223#define bf_isdata(bf) (bf->bf_state.bf_type & BUF_DATA) 222#define bf_isdata(bf) (bf->bf_state.bf_type & BUF_DATA)
224#define bf_isaggr(bf) (bf->bf_state.bf_type & BUF_AGGR) 223#define bf_isaggr(bf) (bf->bf_state.bf_type & BUF_AGGR)
@@ -244,7 +243,6 @@ struct ath_buf {
244 struct ath_buf *bf_next; /* next subframe in the aggregate */ 243 struct ath_buf *bf_next; /* next subframe in the aggregate */
245 struct ath_buf *bf_rifslast; /* last buf for RIFS burst */ 244 struct ath_buf *bf_rifslast; /* last buf for RIFS burst */
246 void *bf_mpdu; /* enclosing frame structure */ 245 void *bf_mpdu; /* enclosing frame structure */
247 void *bf_node; /* pointer to the node */
248 struct ath_desc *bf_desc; /* virtual addr of desc */ 246 struct ath_desc *bf_desc; /* virtual addr of desc */
249 dma_addr_t bf_daddr; /* physical addr of desc */ 247 dma_addr_t bf_daddr; /* physical addr of desc */
250 dma_addr_t bf_buf_addr; /* physical addr of data buffer */ 248 dma_addr_t bf_buf_addr; /* physical addr of data buffer */
@@ -306,15 +304,7 @@ void ath_descdma_cleanup(struct ath_softc *sc,
306 304
307#define ATH_MAX_ANTENNA 3 305#define ATH_MAX_ANTENNA 3
308#define ATH_RXBUF 512 306#define ATH_RXBUF 512
309#define ATH_RX_TIMEOUT 40 /* 40 milliseconds */
310#define WME_NUM_TID 16 307#define WME_NUM_TID 16
311#define IEEE80211_BAR_CTL_TID_M 0xF000 /* tid mask */
312#define IEEE80211_BAR_CTL_TID_S 12 /* tid shift */
313
314enum ATH_RX_TYPE {
315 ATH_RX_NON_CONSUMED = 0,
316 ATH_RX_CONSUMED
317};
318 308
319/* per frame rx status block */ 309/* per frame rx status block */
320struct ath_recv_status { 310struct ath_recv_status {
@@ -348,49 +338,18 @@ struct ath_rxbuf {
348 struct ath_recv_status rx_status; /* cached rx status */ 338 struct ath_recv_status rx_status; /* cached rx status */
349}; 339};
350 340
351/* Per-TID aggregate receiver state for a node */
352struct ath_arx_tid {
353 struct ath_node *an;
354 struct ath_rxbuf *rxbuf; /* re-ordering buffer */
355 struct timer_list timer;
356 spinlock_t tidlock;
357 int baw_head; /* seq_next at head */
358 int baw_tail; /* tail of block-ack window */
359 int seq_reset; /* need to reset start sequence */
360 int addba_exchangecomplete;
361 u16 seq_next; /* next expected sequence */
362 u16 baw_size; /* block-ack window size */
363};
364
365/* Per-node receiver aggregate state */
366struct ath_arx {
367 struct ath_arx_tid tid[WME_NUM_TID];
368};
369
370int ath_startrecv(struct ath_softc *sc); 341int ath_startrecv(struct ath_softc *sc);
371bool ath_stoprecv(struct ath_softc *sc); 342bool ath_stoprecv(struct ath_softc *sc);
372void ath_flushrecv(struct ath_softc *sc); 343void ath_flushrecv(struct ath_softc *sc);
373u32 ath_calcrxfilter(struct ath_softc *sc); 344u32 ath_calcrxfilter(struct ath_softc *sc);
374void ath_rx_node_init(struct ath_softc *sc, struct ath_node *an);
375void ath_rx_node_free(struct ath_softc *sc, struct ath_node *an);
376void ath_rx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
377void ath_handle_rx_intr(struct ath_softc *sc); 345void ath_handle_rx_intr(struct ath_softc *sc);
378int ath_rx_init(struct ath_softc *sc, int nbufs); 346int ath_rx_init(struct ath_softc *sc, int nbufs);
379void ath_rx_cleanup(struct ath_softc *sc); 347void ath_rx_cleanup(struct ath_softc *sc);
380int ath_rx_tasklet(struct ath_softc *sc, int flush); 348int ath_rx_tasklet(struct ath_softc *sc, int flush);
381int ath_rx_input(struct ath_softc *sc,
382 struct ath_node *node,
383 int is_ampdu,
384 struct sk_buff *skb,
385 struct ath_recv_status *rx_status,
386 enum ATH_RX_TYPE *status);
387int _ath_rx_indicate(struct ath_softc *sc, 349int _ath_rx_indicate(struct ath_softc *sc,
388 struct sk_buff *skb, 350 struct sk_buff *skb,
389 struct ath_recv_status *status, 351 struct ath_recv_status *status,
390 u16 keyix); 352 u16 keyix);
391int ath_rx_subframe(struct ath_node *an, struct sk_buff *skb,
392 struct ath_recv_status *status);
393
394/******/ 353/******/
395/* TX */ 354/* TX */
396/******/ 355/******/
@@ -419,12 +378,6 @@ int ath_rx_subframe(struct ath_node *an, struct sk_buff *skb,
419#define WME_AC_VO 3 /* voice */ 378#define WME_AC_VO 3 /* voice */
420#define WME_NUM_AC 4 379#define WME_NUM_AC 4
421 380
422enum ATH_SM_PWRSAV{
423 ATH_SM_ENABLE,
424 ATH_SM_PWRSAV_STATIC,
425 ATH_SM_PWRSAV_DYNAMIC,
426};
427
428/* 381/*
429 * Data transmit queue state. One of these exists for each 382 * Data transmit queue state. One of these exists for each
430 * hardware transmit queue. Packets sent to us from above 383 * hardware transmit queue. Packets sent to us from above
@@ -444,9 +397,6 @@ struct ath_txq {
444 u8 axq_aggr_depth; /* aggregates queued */ 397 u8 axq_aggr_depth; /* aggregates queued */
445 u32 axq_totalqueued; /* total ever queued */ 398 u32 axq_totalqueued; /* total ever queued */
446 399
447 /* count to determine if descriptor should generate int on this txq. */
448 u32 axq_intrcnt;
449
450 bool stopped; /* Is mac80211 queue stopped ? */ 400 bool stopped; /* Is mac80211 queue stopped ? */
451 struct ath_buf *axq_linkbuf; /* virtual addr of last buffer*/ 401 struct ath_buf *axq_linkbuf; /* virtual addr of last buffer*/
452 402
@@ -460,6 +410,10 @@ struct ath_txq {
460 struct list_head axq_acq; 410 struct list_head axq_acq;
461}; 411};
462 412
413#define AGGR_CLEANUP BIT(1)
414#define AGGR_ADDBA_COMPLETE BIT(2)
415#define AGGR_ADDBA_PROGRESS BIT(3)
416
463/* per TID aggregate tx state for a destination */ 417/* per TID aggregate tx state for a destination */
464struct ath_atx_tid { 418struct ath_atx_tid {
465 struct list_head list; /* round-robin tid entry */ 419 struct list_head list; /* round-robin tid entry */
@@ -475,9 +429,7 @@ struct ath_atx_tid {
475 int baw_tail; /* next unused tx buffer slot */ 429 int baw_tail; /* next unused tx buffer slot */
476 int sched; 430 int sched;
477 int paused; 431 int paused;
478 int cleanup_inprogress; 432 u8 state;
479 u32 addba_exchangecomplete:1;
480 int32_t addba_exchangeinprogress;
481 int addba_exchangeattempts; 433 int addba_exchangeattempts;
482}; 434};
483 435
@@ -498,24 +450,8 @@ struct ath_atx {
498 450
499/* per-frame tx control block */ 451/* per-frame tx control block */
500struct ath_tx_control { 452struct ath_tx_control {
501 struct ath_node *an; 453 struct ath_txq *txq;
502 int if_id; 454 int if_id;
503 int qnum;
504 u32 ht:1;
505 u32 ps:1;
506 u32 use_minrate:1;
507 enum ath9k_pkt_type atype;
508 enum ath9k_key_type keytype;
509 u32 flags;
510 u16 seqno;
511 u16 tidno;
512 u16 txpower;
513 u16 frmlen;
514 u32 keyix;
515 int min_rate;
516 int mcast_rate;
517 struct ath_softc *dev;
518 dma_addr_t dmacontext;
519}; 455};
520 456
521/* per frame tx status block */ 457/* per frame tx status block */
@@ -550,33 +486,29 @@ void ath_draintxq(struct ath_softc *sc, bool retry_tx);
550void ath_tx_draintxq(struct ath_softc *sc, 486void ath_tx_draintxq(struct ath_softc *sc,
551 struct ath_txq *txq, bool retry_tx); 487 struct ath_txq *txq, bool retry_tx);
552void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an); 488void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
553void ath_tx_node_cleanup(struct ath_softc *sc, 489void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
554 struct ath_node *an, bool bh_flag);
555void ath_tx_node_free(struct ath_softc *sc, struct ath_node *an); 490void ath_tx_node_free(struct ath_softc *sc, struct ath_node *an);
556void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq); 491void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
557int ath_tx_init(struct ath_softc *sc, int nbufs); 492int ath_tx_init(struct ath_softc *sc, int nbufs);
558int ath_tx_cleanup(struct ath_softc *sc); 493int ath_tx_cleanup(struct ath_softc *sc);
559int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype); 494int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype);
495struct ath_txq *ath_test_get_txq(struct ath_softc *sc, struct sk_buff *skb);
560int ath_txq_update(struct ath_softc *sc, int qnum, 496int ath_txq_update(struct ath_softc *sc, int qnum,
561 struct ath9k_tx_queue_info *q); 497 struct ath9k_tx_queue_info *q);
562int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb); 498int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb,
499 struct ath_tx_control *txctl);
563void ath_tx_tasklet(struct ath_softc *sc); 500void ath_tx_tasklet(struct ath_softc *sc);
564u32 ath_txq_depth(struct ath_softc *sc, int qnum); 501u32 ath_txq_depth(struct ath_softc *sc, int qnum);
565u32 ath_txq_aggr_depth(struct ath_softc *sc, int qnum); 502u32 ath_txq_aggr_depth(struct ath_softc *sc, int qnum);
566void ath_notify_txq_status(struct ath_softc *sc, u16 queue_depth); 503void ath_notify_txq_status(struct ath_softc *sc, u16 queue_depth);
567void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, 504void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
568 struct ath_xmit_status *tx_status, struct ath_node *an); 505 struct ath_xmit_status *tx_status);
569void ath_tx_cabq(struct ath_softc *sc, struct sk_buff *skb); 506void ath_tx_cabq(struct ath_softc *sc, struct sk_buff *skb);
570 507
571/**********************/ 508/**********************/
572/* Node / Aggregation */ 509/* Node / Aggregation */
573/**********************/ 510/**********************/
574 511
575/* indicates the node is clened up */
576#define ATH_NODE_CLEAN 0x1
577/* indicates the node is 80211 power save */
578#define ATH_NODE_PWRSAVE 0x2
579
580#define ADDBA_EXCHANGE_ATTEMPTS 10 512#define ADDBA_EXCHANGE_ATTEMPTS 10
581#define ATH_AGGR_DELIM_SZ 4 /* delimiter size */ 513#define ATH_AGGR_DELIM_SZ 4 /* delimiter size */
582#define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */ 514#define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */
@@ -588,6 +520,7 @@ void ath_tx_cabq(struct ath_softc *sc, struct sk_buff *skb);
588#define IEEE80211_SEQ_SEQ_SHIFT 4 520#define IEEE80211_SEQ_SEQ_SHIFT 4
589#define IEEE80211_SEQ_MAX 4096 521#define IEEE80211_SEQ_MAX 4096
590#define IEEE80211_MIN_AMPDU_BUF 0x8 522#define IEEE80211_MIN_AMPDU_BUF 0x8
523#define IEEE80211_HTCAP_MAXRXAMPDU_FACTOR 13
591 524
592/* return whether a bit at index _n in bitmap _bm is set 525/* return whether a bit at index _n in bitmap _bm is set
593 * _sz is the size of the bitmap */ 526 * _sz is the size of the bitmap */
@@ -618,14 +551,6 @@ enum ATH_AGGR_STATUS {
618 ATH_AGGR_8K_LIMITED, 551 ATH_AGGR_8K_LIMITED,
619}; 552};
620 553
621enum ATH_AGGR_CHECK {
622 AGGR_NOT_REQUIRED,
623 AGGR_REQUIRED,
624 AGGR_CLEANUP_PROGRESS,
625 AGGR_EXCHANGE_PROGRESS,
626 AGGR_EXCHANGE_DONE
627};
628
629struct aggr_rifs_param { 554struct aggr_rifs_param {
630 int param_max_frames; 555 int param_max_frames;
631 int param_max_len; 556 int param_max_len;
@@ -637,51 +562,30 @@ struct aggr_rifs_param {
637/* Per-node aggregation state */ 562/* Per-node aggregation state */
638struct ath_node_aggr { 563struct ath_node_aggr {
639 struct ath_atx tx; /* node transmit state */ 564 struct ath_atx tx; /* node transmit state */
640 struct ath_arx rx; /* node receive state */
641}; 565};
642 566
643/* driver-specific node state */ 567/* driver-specific node state */
644struct ath_node { 568struct ath_node {
645 struct list_head list;
646 struct ath_softc *an_sc; 569 struct ath_softc *an_sc;
647 atomic_t an_refcnt;
648 struct ath_chainmask_sel an_chainmask_sel; 570 struct ath_chainmask_sel an_chainmask_sel;
649 struct ath_node_aggr an_aggr; 571 struct ath_node_aggr an_aggr;
650 u8 an_smmode; /* SM Power save mode */ 572 u16 maxampdu;
651 u8 an_flags; 573 u8 mpdudensity;
652 u8 an_addr[ETH_ALEN];
653}; 574};
654 575
655void ath_tx_resume_tid(struct ath_softc *sc, 576void ath_tx_resume_tid(struct ath_softc *sc,
656 struct ath_atx_tid *tid); 577 struct ath_atx_tid *tid);
657enum ATH_AGGR_CHECK ath_tx_aggr_check(struct ath_softc *sc, 578bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an, u8 tidno);
658 struct ath_node *an, u8 tidno);
659void ath_tx_aggr_teardown(struct ath_softc *sc, 579void ath_tx_aggr_teardown(struct ath_softc *sc,
660 struct ath_node *an, u8 tidno); 580 struct ath_node *an, u8 tidno);
661void ath_rx_aggr_teardown(struct ath_softc *sc, 581int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
662 struct ath_node *an, u8 tidno); 582 u16 tid, u16 *ssn);
663int ath_rx_aggr_start(struct ath_softc *sc, 583int ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
664 const u8 *addr, 584void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
665 u16 tid,
666 u16 *ssn);
667int ath_rx_aggr_stop(struct ath_softc *sc,
668 const u8 *addr,
669 u16 tid);
670int ath_tx_aggr_start(struct ath_softc *sc,
671 const u8 *addr,
672 u16 tid,
673 u16 *ssn);
674int ath_tx_aggr_stop(struct ath_softc *sc,
675 const u8 *addr,
676 u16 tid);
677void ath_newassoc(struct ath_softc *sc, 585void ath_newassoc(struct ath_softc *sc,
678 struct ath_node *node, int isnew, int isuapsd); 586 struct ath_node *node, int isnew, int isuapsd);
679struct ath_node *ath_node_attach(struct ath_softc *sc, 587void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta);
680 u8 addr[ETH_ALEN], int if_id); 588void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta);
681void ath_node_detach(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
682struct ath_node *ath_node_get(struct ath_softc *sc, u8 addr[ETH_ALEN]);
683void ath_node_put(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
684struct ath_node *ath_node_find(struct ath_softc *sc, u8 *addr);
685 589
686/*******************/ 590/*******************/
687/* Beacon Handling */ 591/* Beacon Handling */
@@ -745,23 +649,14 @@ struct ath_vap_config {
745 649
746/* driver-specific vap state */ 650/* driver-specific vap state */
747struct ath_vap { 651struct ath_vap {
748 struct ieee80211_vif *av_if_data; 652 int av_bslot; /* beacon slot index */
749 enum ath9k_opmode av_opmode; /* VAP operational mode */ 653 enum ath9k_opmode av_opmode; /* VAP operational mode */
750 struct ath_buf *av_bcbuf; /* beacon buffer */ 654 struct ath_buf *av_bcbuf; /* beacon buffer */
751 struct ath_tx_control av_btxctl; /* txctl information for beacon */ 655 struct ath_tx_control av_btxctl; /* txctl information for beacon */
752 int av_bslot; /* beacon slot index */
753 struct ath_vap_config av_config;/* vap configuration parameters*/ 656 struct ath_vap_config av_config;/* vap configuration parameters*/
754 struct ath_rate_node *rc_node; 657 struct ath_rate_node *rc_node;
755}; 658};
756 659
757int ath_vap_attach(struct ath_softc *sc,
758 int if_id,
759 struct ieee80211_vif *if_data,
760 enum ath9k_opmode opmode);
761int ath_vap_detach(struct ath_softc *sc, int if_id);
762int ath_vap_config(struct ath_softc *sc,
763 int if_id, struct ath_vap_config *if_config);
764
765/*********************/ 660/*********************/
766/* Antenna diversity */ 661/* Antenna diversity */
767/*********************/ 662/*********************/
@@ -919,8 +814,6 @@ enum RATE_TYPE {
919 814
920struct ath_ht_info { 815struct ath_ht_info {
921 enum ath9k_ht_macmode tx_chan_width; 816 enum ath9k_ht_macmode tx_chan_width;
922 u16 maxampdu;
923 u8 mpdudensity;
924 u8 ext_chan_offset; 817 u8 ext_chan_offset;
925}; 818};
926 819
@@ -971,14 +864,13 @@ struct ath_softc {
971 864
972 u8 sc_nbcnvaps; /* # of vaps sending beacons */ 865 u8 sc_nbcnvaps; /* # of vaps sending beacons */
973 u16 sc_nvaps; /* # of active virtual ap's */ 866 u16 sc_nvaps; /* # of active virtual ap's */
974 struct ath_vap *sc_vaps[ATH_BCBUF]; 867 struct ieee80211_vif *sc_vaps[ATH_BCBUF];
975 868
976 u8 sc_mcastantenna; 869 u8 sc_mcastantenna;
977 u8 sc_defant; /* current default antenna */ 870 u8 sc_defant; /* current default antenna */
978 u8 sc_rxotherant; /* rx's on non-default antenna */ 871 u8 sc_rxotherant; /* rx's on non-default antenna */
979 872
980 struct ath9k_node_stats sc_halstats; /* station-mode rssi stats */ 873 struct ath9k_node_stats sc_halstats; /* station-mode rssi stats */
981 struct list_head node_list;
982 struct ath_ht_info sc_ht_info; 874 struct ath_ht_info sc_ht_info;
983 enum ath9k_ht_extprotspacing sc_ht_extprotspacing; 875 enum ath9k_ht_extprotspacing sc_ht_extprotspacing;
984 876
@@ -1007,7 +899,6 @@ struct ath_softc {
1007 struct ath_txq sc_txq[ATH9K_NUM_TX_QUEUES]; 899 struct ath_txq sc_txq[ATH9K_NUM_TX_QUEUES];
1008 struct ath_descdma sc_txdma; 900 struct ath_descdma sc_txdma;
1009 u32 sc_txqsetup; 901 u32 sc_txqsetup;
1010 u32 sc_txintrperiod; /* tx interrupt batching */
1011 int sc_haltype2q[ATH9K_WME_AC_VO+1]; /* HAL WME AC -> h/w qnum */ 902 int sc_haltype2q[ATH9K_WME_AC_VO+1]; /* HAL WME AC -> h/w qnum */
1012 u16 seq_no; /* TX sequence number */ 903 u16 seq_no; /* TX sequence number */
1013 904
@@ -1040,7 +931,6 @@ struct ath_softc {
1040 spinlock_t sc_rxbuflock; 931 spinlock_t sc_rxbuflock;
1041 spinlock_t sc_txbuflock; 932 spinlock_t sc_txbuflock;
1042 spinlock_t sc_resetlock; 933 spinlock_t sc_resetlock;
1043 spinlock_t node_lock;
1044 934
1045 /* LEDs */ 935 /* LEDs */
1046 struct ath_led radio_led; 936 struct ath_led radio_led;
@@ -1056,9 +946,8 @@ struct ath_softc {
1056}; 946};
1057 947
1058int ath_init(u16 devid, struct ath_softc *sc); 948int ath_init(u16 devid, struct ath_softc *sc);
1059void ath_deinit(struct ath_softc *sc);
1060int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan); 949int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan);
1061int ath_suspend(struct ath_softc *sc); 950void ath_stop(struct ath_softc *sc);
1062irqreturn_t ath_isr(int irq, void *dev); 951irqreturn_t ath_isr(int irq, void *dev);
1063int ath_reset(struct ath_softc *sc, bool retry_tx); 952int ath_reset(struct ath_softc *sc, bool retry_tx);
1064int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan); 953int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan);
@@ -1077,8 +966,6 @@ int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
1077void ath_setslottime(struct ath_softc *sc); 966void ath_setslottime(struct ath_softc *sc);
1078void ath_update_txpow(struct ath_softc *sc); 967void ath_update_txpow(struct ath_softc *sc);
1079int ath_cabq_update(struct ath_softc *); 968int ath_cabq_update(struct ath_softc *);
1080void ath_get_currentCountry(struct ath_softc *sc,
1081 struct ath9k_country_entry *ctry);
1082u64 ath_extend_tsf(struct ath_softc *sc, u32 rstamp); 969u64 ath_extend_tsf(struct ath_softc *sc, u32 rstamp);
1083 970
1084#endif /* CORE_H */ 971#endif /* CORE_H */
diff --git a/drivers/net/wireless/ath9k/eeprom.c b/drivers/net/wireless/ath9k/eeprom.c
new file mode 100644
index 000000000000..f5fd03c0edd7
--- /dev/null
+++ b/drivers/net/wireless/ath9k/eeprom.c
@@ -0,0 +1,1605 @@
1/*
2 * Copyright (c) 2008 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "core.h"
18#include "hw.h"
19#include "reg.h"
20#include "phy.h"
21
22static void ath9k_hw_analog_shift_rmw(struct ath_hal *ah,
23 u32 reg, u32 mask,
24 u32 shift, u32 val)
25{
26 u32 regVal;
27
28 regVal = REG_READ(ah, reg) & ~mask;
29 regVal |= (val << shift) & mask;
30
31 REG_WRITE(ah, reg, regVal);
32
33 if (ah->ah_config.analog_shiftreg)
34 udelay(100);
35
36 return;
37}
38
39static inline u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz)
40{
41
42 if (fbin == AR5416_BCHAN_UNUSED)
43 return fbin;
44
45 return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
46}
47
48static inline int16_t ath9k_hw_interpolate(u16 target,
49 u16 srcLeft, u16 srcRight,
50 int16_t targetLeft,
51 int16_t targetRight)
52{
53 int16_t rv;
54
55 if (srcRight == srcLeft) {
56 rv = targetLeft;
57 } else {
58 rv = (int16_t) (((target - srcLeft) * targetRight +
59 (srcRight - target) * targetLeft) /
60 (srcRight - srcLeft));
61 }
62 return rv;
63}
64
65static inline bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList,
66 u16 listSize, u16 *indexL,
67 u16 *indexR)
68{
69 u16 i;
70
71 if (target <= pList[0]) {
72 *indexL = *indexR = 0;
73 return true;
74 }
75 if (target >= pList[listSize - 1]) {
76 *indexL = *indexR = (u16) (listSize - 1);
77 return true;
78 }
79
80 for (i = 0; i < listSize - 1; i++) {
81 if (pList[i] == target) {
82 *indexL = *indexR = i;
83 return true;
84 }
85 if (target < pList[i + 1]) {
86 *indexL = i;
87 *indexR = (u16) (i + 1);
88 return false;
89 }
90 }
91 return false;
92}
93
94static bool ath9k_hw_eeprom_read(struct ath_hal *ah, u32 off, u16 *data)
95{
96 (void)REG_READ(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
97
98 if (!ath9k_hw_wait(ah,
99 AR_EEPROM_STATUS_DATA,
100 AR_EEPROM_STATUS_DATA_BUSY |
101 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0)) {
102 return false;
103 }
104
105 *data = MS(REG_READ(ah, AR_EEPROM_STATUS_DATA),
106 AR_EEPROM_STATUS_DATA_VAL);
107
108 return true;
109}
110
111static int ath9k_hw_flash_map(struct ath_hal *ah)
112{
113 struct ath_hal_5416 *ahp = AH5416(ah);
114
115 ahp->ah_cal_mem = ioremap(AR5416_EEPROM_START_ADDR, AR5416_EEPROM_MAX);
116
117 if (!ahp->ah_cal_mem) {
118 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
119 "%s: cannot remap eeprom region \n", __func__);
120 return -EIO;
121 }
122
123 return 0;
124}
125
126static bool ath9k_hw_flash_read(struct ath_hal *ah, u32 off, u16 *data)
127{
128 struct ath_hal_5416 *ahp = AH5416(ah);
129
130 *data = ioread16(ahp->ah_cal_mem + off);
131
132 return true;
133}
134
135static inline bool ath9k_hw_nvram_read(struct ath_hal *ah, u32 off, u16 *data)
136{
137 if (ath9k_hw_use_flash(ah))
138 return ath9k_hw_flash_read(ah, off, data);
139 else
140 return ath9k_hw_eeprom_read(ah, off, data);
141}
142
143static bool ath9k_hw_fill_eeprom(struct ath_hal *ah)
144{
145 struct ath_hal_5416 *ahp = AH5416(ah);
146 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
147 u16 *eep_data;
148 int addr, ar5416_eep_start_loc = 0;
149
150 if (!ath9k_hw_use_flash(ah)) {
151 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
152 "%s: Reading from EEPROM, not flash\n", __func__);
153 ar5416_eep_start_loc = 256;
154 }
155
156 if (AR_SREV_9100(ah))
157 ar5416_eep_start_loc = 256;
158
159 eep_data = (u16 *)eep;
160
161 for (addr = 0; addr < sizeof(struct ar5416_eeprom) / sizeof(u16); addr++) {
162 if (!ath9k_hw_nvram_read(ah, addr + ar5416_eep_start_loc,
163 eep_data)) {
164 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
165 "%s: Unable to read eeprom region \n",
166 __func__);
167 return false;
168 }
169 eep_data++;
170 }
171 return true;
172}
173
174static int ath9k_hw_check_eeprom(struct ath_hal *ah)
175{
176 struct ath_hal_5416 *ahp = AH5416(ah);
177 struct ar5416_eeprom *eep =
178 (struct ar5416_eeprom *) &ahp->ah_eeprom;
179 u16 *eepdata, temp, magic, magic2;
180 u32 sum = 0, el;
181 bool need_swap = false;
182 int i, addr, size;
183
184 if (!ath9k_hw_use_flash(ah)) {
185 if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET,
186 &magic)) {
187 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
188 "%s: Reading Magic # failed\n", __func__);
189 return false;
190 }
191
192 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, "%s: Read Magic = 0x%04X\n",
193 __func__, magic);
194
195 if (magic != AR5416_EEPROM_MAGIC) {
196 magic2 = swab16(magic);
197
198 if (magic2 == AR5416_EEPROM_MAGIC) {
199 size = sizeof(struct ar5416_eeprom);
200 need_swap = true;
201 eepdata = (u16 *) (&ahp->ah_eeprom);
202
203 for (addr = 0; addr < size / sizeof(u16); addr++) {
204 temp = swab16(*eepdata);
205 *eepdata = temp;
206 eepdata++;
207
208 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
209 "0x%04X ", *eepdata);
210
211 if (((addr + 1) % 6) == 0)
212 DPRINTF(ah->ah_sc,
213 ATH_DBG_EEPROM, "\n");
214 }
215 } else {
216 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
217 "Invalid EEPROM Magic. "
218 "endianness mismatch.\n");
219 return -EINVAL;
220 }
221 }
222 }
223
224 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, "need_swap = %s.\n",
225 need_swap ? "True" : "False");
226
227 if (need_swap)
228 el = swab16(ahp->ah_eeprom.baseEepHeader.length);
229 else
230 el = ahp->ah_eeprom.baseEepHeader.length;
231
232 if (el > sizeof(struct ar5416_eeprom))
233 el = sizeof(struct ar5416_eeprom) / sizeof(u16);
234 else
235 el = el / sizeof(u16);
236
237 eepdata = (u16 *)(&ahp->ah_eeprom);
238
239 for (i = 0; i < el; i++)
240 sum ^= *eepdata++;
241
242 if (need_swap) {
243 u32 integer, j;
244 u16 word;
245
246 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
247 "EEPROM Endianness is not native.. Changing \n");
248
249 word = swab16(eep->baseEepHeader.length);
250 eep->baseEepHeader.length = word;
251
252 word = swab16(eep->baseEepHeader.checksum);
253 eep->baseEepHeader.checksum = word;
254
255 word = swab16(eep->baseEepHeader.version);
256 eep->baseEepHeader.version = word;
257
258 word = swab16(eep->baseEepHeader.regDmn[0]);
259 eep->baseEepHeader.regDmn[0] = word;
260
261 word = swab16(eep->baseEepHeader.regDmn[1]);
262 eep->baseEepHeader.regDmn[1] = word;
263
264 word = swab16(eep->baseEepHeader.rfSilent);
265 eep->baseEepHeader.rfSilent = word;
266
267 word = swab16(eep->baseEepHeader.blueToothOptions);
268 eep->baseEepHeader.blueToothOptions = word;
269
270 word = swab16(eep->baseEepHeader.deviceCap);
271 eep->baseEepHeader.deviceCap = word;
272
273 for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) {
274 struct modal_eep_header *pModal =
275 &eep->modalHeader[j];
276 integer = swab32(pModal->antCtrlCommon);
277 pModal->antCtrlCommon = integer;
278
279 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
280 integer = swab32(pModal->antCtrlChain[i]);
281 pModal->antCtrlChain[i] = integer;
282 }
283
284 for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) {
285 word = swab16(pModal->spurChans[i].spurChan);
286 pModal->spurChans[i].spurChan = word;
287 }
288 }
289 }
290
291 if (sum != 0xffff || ar5416_get_eep_ver(ahp) != AR5416_EEP_VER ||
292 ar5416_get_eep_rev(ahp) < AR5416_EEP_NO_BACK_VER) {
293 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
294 "Bad EEPROM checksum 0x%x or revision 0x%04x\n",
295 sum, ar5416_get_eep_ver(ahp));
296 return -EINVAL;
297 }
298
299 return 0;
300}
301
302static inline bool ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
303 u8 *pVpdList, u16 numIntercepts,
304 u8 *pRetVpdList)
305{
306 u16 i, k;
307 u8 currPwr = pwrMin;
308 u16 idxL = 0, idxR = 0;
309
310 for (i = 0; i <= (pwrMax - pwrMin) / 2; i++) {
311 ath9k_hw_get_lower_upper_index(currPwr, pPwrList,
312 numIntercepts, &(idxL),
313 &(idxR));
314 if (idxR < 1)
315 idxR = 1;
316 if (idxL == numIntercepts - 1)
317 idxL = (u16) (numIntercepts - 2);
318 if (pPwrList[idxL] == pPwrList[idxR])
319 k = pVpdList[idxL];
320 else
321 k = (u16)(((currPwr - pPwrList[idxL]) * pVpdList[idxR] +
322 (pPwrList[idxR] - currPwr) * pVpdList[idxL]) /
323 (pPwrList[idxR] - pPwrList[idxL]));
324 pRetVpdList[i] = (u8) k;
325 currPwr += 2;
326 }
327
328 return true;
329}
330
331static void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hal *ah,
332 struct ath9k_channel *chan,
333 struct cal_data_per_freq *pRawDataSet,
334 u8 *bChans, u16 availPiers,
335 u16 tPdGainOverlap, int16_t *pMinCalPower,
336 u16 *pPdGainBoundaries, u8 *pPDADCValues,
337 u16 numXpdGains)
338{
339 int i, j, k;
340 int16_t ss;
341 u16 idxL = 0, idxR = 0, numPiers;
342 static u8 vpdTableL[AR5416_NUM_PD_GAINS]
343 [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
344 static u8 vpdTableR[AR5416_NUM_PD_GAINS]
345 [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
346 static u8 vpdTableI[AR5416_NUM_PD_GAINS]
347 [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
348
349 u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
350 u8 minPwrT4[AR5416_NUM_PD_GAINS];
351 u8 maxPwrT4[AR5416_NUM_PD_GAINS];
352 int16_t vpdStep;
353 int16_t tmpVal;
354 u16 sizeCurrVpdTable, maxIndex, tgtIndex;
355 bool match;
356 int16_t minDelta = 0;
357 struct chan_centers centers;
358
359 ath9k_hw_get_channel_centers(ah, chan, &centers);
360
361 for (numPiers = 0; numPiers < availPiers; numPiers++) {
362 if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
363 break;
364 }
365
366 match = ath9k_hw_get_lower_upper_index((u8)FREQ2FBIN(centers.synth_center,
367 IS_CHAN_2GHZ(chan)),
368 bChans, numPiers, &idxL, &idxR);
369
370 if (match) {
371 for (i = 0; i < numXpdGains; i++) {
372 minPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][0];
373 maxPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][4];
374 ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
375 pRawDataSet[idxL].pwrPdg[i],
376 pRawDataSet[idxL].vpdPdg[i],
377 AR5416_PD_GAIN_ICEPTS,
378 vpdTableI[i]);
379 }
380 } else {
381 for (i = 0; i < numXpdGains; i++) {
382 pVpdL = pRawDataSet[idxL].vpdPdg[i];
383 pPwrL = pRawDataSet[idxL].pwrPdg[i];
384 pVpdR = pRawDataSet[idxR].vpdPdg[i];
385 pPwrR = pRawDataSet[idxR].pwrPdg[i];
386
387 minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
388
389 maxPwrT4[i] =
390 min(pPwrL[AR5416_PD_GAIN_ICEPTS - 1],
391 pPwrR[AR5416_PD_GAIN_ICEPTS - 1]);
392
393
394 ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
395 pPwrL, pVpdL,
396 AR5416_PD_GAIN_ICEPTS,
397 vpdTableL[i]);
398 ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
399 pPwrR, pVpdR,
400 AR5416_PD_GAIN_ICEPTS,
401 vpdTableR[i]);
402
403 for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
404 vpdTableI[i][j] =
405 (u8)(ath9k_hw_interpolate((u16)
406 FREQ2FBIN(centers.
407 synth_center,
408 IS_CHAN_2GHZ
409 (chan)),
410 bChans[idxL], bChans[idxR],
411 vpdTableL[i][j], vpdTableR[i][j]));
412 }
413 }
414 }
415
416 *pMinCalPower = (int16_t)(minPwrT4[0] / 2);
417
418 k = 0;
419
420 for (i = 0; i < numXpdGains; i++) {
421 if (i == (numXpdGains - 1))
422 pPdGainBoundaries[i] =
423 (u16)(maxPwrT4[i] / 2);
424 else
425 pPdGainBoundaries[i] =
426 (u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
427
428 pPdGainBoundaries[i] =
429 min((u16)AR5416_MAX_RATE_POWER, pPdGainBoundaries[i]);
430
431 if ((i == 0) && !AR_SREV_5416_V20_OR_LATER(ah)) {
432 minDelta = pPdGainBoundaries[0] - 23;
433 pPdGainBoundaries[0] = 23;
434 } else {
435 minDelta = 0;
436 }
437
438 if (i == 0) {
439 if (AR_SREV_9280_10_OR_LATER(ah))
440 ss = (int16_t)(0 - (minPwrT4[i] / 2));
441 else
442 ss = 0;
443 } else {
444 ss = (int16_t)((pPdGainBoundaries[i - 1] -
445 (minPwrT4[i] / 2)) -
446 tPdGainOverlap + 1 + minDelta);
447 }
448 vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
449 vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
450
451 while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
452 tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
453 pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
454 ss++;
455 }
456
457 sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
458 tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap -
459 (minPwrT4[i] / 2));
460 maxIndex = (tgtIndex < sizeCurrVpdTable) ?
461 tgtIndex : sizeCurrVpdTable;
462
463 while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
464 pPDADCValues[k++] = vpdTableI[i][ss++];
465 }
466
467 vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
468 vpdTableI[i][sizeCurrVpdTable - 2]);
469 vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
470
471 if (tgtIndex > maxIndex) {
472 while ((ss <= tgtIndex) &&
473 (k < (AR5416_NUM_PDADC_VALUES - 1))) {
474 tmpVal = (int16_t)((vpdTableI[i][sizeCurrVpdTable - 1] +
475 (ss - maxIndex + 1) * vpdStep));
476 pPDADCValues[k++] = (u8)((tmpVal > 255) ?
477 255 : tmpVal);
478 ss++;
479 }
480 }
481 }
482
483 while (i < AR5416_PD_GAINS_IN_MASK) {
484 pPdGainBoundaries[i] = pPdGainBoundaries[i - 1];
485 i++;
486 }
487
488 while (k < AR5416_NUM_PDADC_VALUES) {
489 pPDADCValues[k] = pPDADCValues[k - 1];
490 k++;
491 }
492
493 return;
494}
495
496static void ath9k_hw_get_legacy_target_powers(struct ath_hal *ah,
497 struct ath9k_channel *chan,
498 struct cal_target_power_leg *powInfo,
499 u16 numChannels,
500 struct cal_target_power_leg *pNewPower,
501 u16 numRates, bool isExtTarget)
502{
503 struct chan_centers centers;
504 u16 clo, chi;
505 int i;
506 int matchIndex = -1, lowIndex = -1;
507 u16 freq;
508
509 ath9k_hw_get_channel_centers(ah, chan, &centers);
510 freq = (isExtTarget) ? centers.ext_center : centers.ctl_center;
511
512 if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel,
513 IS_CHAN_2GHZ(chan))) {
514 matchIndex = 0;
515 } else {
516 for (i = 0; (i < numChannels) &&
517 (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
518 if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
519 IS_CHAN_2GHZ(chan))) {
520 matchIndex = i;
521 break;
522 } else if ((freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
523 IS_CHAN_2GHZ(chan))) &&
524 (freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
525 IS_CHAN_2GHZ(chan)))) {
526 lowIndex = i - 1;
527 break;
528 }
529 }
530 if ((matchIndex == -1) && (lowIndex == -1))
531 matchIndex = i - 1;
532 }
533
534 if (matchIndex != -1) {
535 *pNewPower = powInfo[matchIndex];
536 } else {
537 clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
538 IS_CHAN_2GHZ(chan));
539 chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
540 IS_CHAN_2GHZ(chan));
541
542 for (i = 0; i < numRates; i++) {
543 pNewPower->tPow2x[i] =
544 (u8)ath9k_hw_interpolate(freq, clo, chi,
545 powInfo[lowIndex].tPow2x[i],
546 powInfo[lowIndex + 1].tPow2x[i]);
547 }
548 }
549}
550
551static void ath9k_hw_get_target_powers(struct ath_hal *ah,
552 struct ath9k_channel *chan,
553 struct cal_target_power_ht *powInfo,
554 u16 numChannels,
555 struct cal_target_power_ht *pNewPower,
556 u16 numRates, bool isHt40Target)
557{
558 struct chan_centers centers;
559 u16 clo, chi;
560 int i;
561 int matchIndex = -1, lowIndex = -1;
562 u16 freq;
563
564 ath9k_hw_get_channel_centers(ah, chan, &centers);
565 freq = isHt40Target ? centers.synth_center : centers.ctl_center;
566
567 if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel, IS_CHAN_2GHZ(chan))) {
568 matchIndex = 0;
569 } else {
570 for (i = 0; (i < numChannels) &&
571 (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
572 if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
573 IS_CHAN_2GHZ(chan))) {
574 matchIndex = i;
575 break;
576 } else
577 if ((freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
578 IS_CHAN_2GHZ(chan))) &&
579 (freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
580 IS_CHAN_2GHZ(chan)))) {
581 lowIndex = i - 1;
582 break;
583 }
584 }
585 if ((matchIndex == -1) && (lowIndex == -1))
586 matchIndex = i - 1;
587 }
588
589 if (matchIndex != -1) {
590 *pNewPower = powInfo[matchIndex];
591 } else {
592 clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
593 IS_CHAN_2GHZ(chan));
594 chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
595 IS_CHAN_2GHZ(chan));
596
597 for (i = 0; i < numRates; i++) {
598 pNewPower->tPow2x[i] = (u8)ath9k_hw_interpolate(freq,
599 clo, chi,
600 powInfo[lowIndex].tPow2x[i],
601 powInfo[lowIndex + 1].tPow2x[i]);
602 }
603 }
604}
605
606static u16 ath9k_hw_get_max_edge_power(u16 freq,
607 struct cal_ctl_edges *pRdEdgesPower,
608 bool is2GHz)
609{
610 u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
611 int i;
612
613 for (i = 0; (i < AR5416_NUM_BAND_EDGES) &&
614 (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
615 if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) {
616 twiceMaxEdgePower = pRdEdgesPower[i].tPower;
617 break;
618 } else if ((i > 0) &&
619 (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel,
620 is2GHz))) {
621 if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel,
622 is2GHz) < freq &&
623 pRdEdgesPower[i - 1].flag) {
624 twiceMaxEdgePower =
625 pRdEdgesPower[i - 1].tPower;
626 }
627 break;
628 }
629 }
630
631 return twiceMaxEdgePower;
632}
633
634int ath9k_hw_set_txpower(struct ath_hal *ah,
635 struct ath9k_channel *chan,
636 u16 cfgCtl,
637 u8 twiceAntennaReduction,
638 u8 twiceMaxRegulatoryPower,
639 u8 powerLimit)
640{
641 struct ath_hal_5416 *ahp = AH5416(ah);
642 struct ar5416_eeprom *pEepData = &ahp->ah_eeprom;
643 struct modal_eep_header *pModal =
644 &(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]);
645 int16_t ratesArray[Ar5416RateSize];
646 int16_t txPowerIndexOffset = 0;
647 u8 ht40PowerIncForPdadc = 2;
648 int i;
649
650 memset(ratesArray, 0, sizeof(ratesArray));
651
652 if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
653 AR5416_EEP_MINOR_VER_2) {
654 ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
655 }
656
657 if (!ath9k_hw_set_power_per_rate_table(ah, chan,
658 &ratesArray[0], cfgCtl,
659 twiceAntennaReduction,
660 twiceMaxRegulatoryPower,
661 powerLimit)) {
662 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
663 "ath9k_hw_set_txpower: unable to set "
664 "tx power per rate table\n");
665 return -EIO;
666 }
667
668 if (!ath9k_hw_set_power_cal_table(ah, chan, &txPowerIndexOffset)) {
669 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
670 "ath9k_hw_set_txpower: unable to set power table\n");
671 return -EIO;
672 }
673
674 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
675 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
676 if (ratesArray[i] > AR5416_MAX_RATE_POWER)
677 ratesArray[i] = AR5416_MAX_RATE_POWER;
678 }
679
680 if (AR_SREV_9280_10_OR_LATER(ah)) {
681 for (i = 0; i < Ar5416RateSize; i++)
682 ratesArray[i] -= AR5416_PWR_TABLE_OFFSET * 2;
683 }
684
685 REG_WRITE(ah, AR_PHY_POWER_TX_RATE1,
686 ATH9K_POW_SM(ratesArray[rate18mb], 24)
687 | ATH9K_POW_SM(ratesArray[rate12mb], 16)
688 | ATH9K_POW_SM(ratesArray[rate9mb], 8)
689 | ATH9K_POW_SM(ratesArray[rate6mb], 0));
690 REG_WRITE(ah, AR_PHY_POWER_TX_RATE2,
691 ATH9K_POW_SM(ratesArray[rate54mb], 24)
692 | ATH9K_POW_SM(ratesArray[rate48mb], 16)
693 | ATH9K_POW_SM(ratesArray[rate36mb], 8)
694 | ATH9K_POW_SM(ratesArray[rate24mb], 0));
695
696 if (IS_CHAN_2GHZ(chan)) {
697 REG_WRITE(ah, AR_PHY_POWER_TX_RATE3,
698 ATH9K_POW_SM(ratesArray[rate2s], 24)
699 | ATH9K_POW_SM(ratesArray[rate2l], 16)
700 | ATH9K_POW_SM(ratesArray[rateXr], 8)
701 | ATH9K_POW_SM(ratesArray[rate1l], 0));
702 REG_WRITE(ah, AR_PHY_POWER_TX_RATE4,
703 ATH9K_POW_SM(ratesArray[rate11s], 24)
704 | ATH9K_POW_SM(ratesArray[rate11l], 16)
705 | ATH9K_POW_SM(ratesArray[rate5_5s], 8)
706 | ATH9K_POW_SM(ratesArray[rate5_5l], 0));
707 }
708
709 REG_WRITE(ah, AR_PHY_POWER_TX_RATE5,
710 ATH9K_POW_SM(ratesArray[rateHt20_3], 24)
711 | ATH9K_POW_SM(ratesArray[rateHt20_2], 16)
712 | ATH9K_POW_SM(ratesArray[rateHt20_1], 8)
713 | ATH9K_POW_SM(ratesArray[rateHt20_0], 0));
714 REG_WRITE(ah, AR_PHY_POWER_TX_RATE6,
715 ATH9K_POW_SM(ratesArray[rateHt20_7], 24)
716 | ATH9K_POW_SM(ratesArray[rateHt20_6], 16)
717 | ATH9K_POW_SM(ratesArray[rateHt20_5], 8)
718 | ATH9K_POW_SM(ratesArray[rateHt20_4], 0));
719
720 if (IS_CHAN_HT40(chan)) {
721 REG_WRITE(ah, AR_PHY_POWER_TX_RATE7,
722 ATH9K_POW_SM(ratesArray[rateHt40_3] +
723 ht40PowerIncForPdadc, 24)
724 | ATH9K_POW_SM(ratesArray[rateHt40_2] +
725 ht40PowerIncForPdadc, 16)
726 | ATH9K_POW_SM(ratesArray[rateHt40_1] +
727 ht40PowerIncForPdadc, 8)
728 | ATH9K_POW_SM(ratesArray[rateHt40_0] +
729 ht40PowerIncForPdadc, 0));
730 REG_WRITE(ah, AR_PHY_POWER_TX_RATE8,
731 ATH9K_POW_SM(ratesArray[rateHt40_7] +
732 ht40PowerIncForPdadc, 24)
733 | ATH9K_POW_SM(ratesArray[rateHt40_6] +
734 ht40PowerIncForPdadc, 16)
735 | ATH9K_POW_SM(ratesArray[rateHt40_5] +
736 ht40PowerIncForPdadc, 8)
737 | ATH9K_POW_SM(ratesArray[rateHt40_4] +
738 ht40PowerIncForPdadc, 0));
739
740 REG_WRITE(ah, AR_PHY_POWER_TX_RATE9,
741 ATH9K_POW_SM(ratesArray[rateExtOfdm], 24)
742 | ATH9K_POW_SM(ratesArray[rateExtCck], 16)
743 | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
744 | ATH9K_POW_SM(ratesArray[rateDupCck], 0));
745 }
746
747 REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
748 ATH9K_POW_SM(pModal->pwrDecreaseFor3Chain, 6)
749 | ATH9K_POW_SM(pModal->pwrDecreaseFor2Chain, 0));
750
751 i = rate6mb;
752
753 if (IS_CHAN_HT40(chan))
754 i = rateHt40_0;
755 else if (IS_CHAN_HT20(chan))
756 i = rateHt20_0;
757
758 if (AR_SREV_9280_10_OR_LATER(ah))
759 ah->ah_maxPowerLevel =
760 ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
761 else
762 ah->ah_maxPowerLevel = ratesArray[i];
763
764 return 0;
765}
766
767void ath9k_hw_set_addac(struct ath_hal *ah, struct ath9k_channel *chan)
768{
769 struct modal_eep_header *pModal;
770 struct ath_hal_5416 *ahp = AH5416(ah);
771 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
772 u8 biaslevel;
773
774 if (ah->ah_macVersion != AR_SREV_VERSION_9160)
775 return;
776
777 if (ar5416_get_eep_rev(ahp) < AR5416_EEP_MINOR_VER_7)
778 return;
779
780 pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
781
782 if (pModal->xpaBiasLvl != 0xff) {
783 biaslevel = pModal->xpaBiasLvl;
784 } else {
785 u16 resetFreqBin, freqBin, freqCount = 0;
786 struct chan_centers centers;
787
788 ath9k_hw_get_channel_centers(ah, chan, &centers);
789
790 resetFreqBin = FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan));
791 freqBin = pModal->xpaBiasLvlFreq[0] & 0xff;
792 biaslevel = (u8) (pModal->xpaBiasLvlFreq[0] >> 14);
793
794 freqCount++;
795
796 while (freqCount < 3) {
797 if (pModal->xpaBiasLvlFreq[freqCount] == 0x0)
798 break;
799
800 freqBin = pModal->xpaBiasLvlFreq[freqCount] & 0xff;
801 if (resetFreqBin >= freqBin) {
802 biaslevel = (u8)(pModal->xpaBiasLvlFreq[freqCount] >> 14);
803 } else {
804 break;
805 }
806 freqCount++;
807 }
808 }
809
810 if (IS_CHAN_2GHZ(chan)) {
811 INI_RA(&ahp->ah_iniAddac, 7, 1) =
812 (INI_RA(&ahp->ah_iniAddac, 7, 1) & (~0x18)) | biaslevel << 3;
813 } else {
814 INI_RA(&ahp->ah_iniAddac, 6, 1) =
815 (INI_RA(&ahp->ah_iniAddac, 6, 1) & (~0xc0)) | biaslevel << 6;
816 }
817}
818
819bool ath9k_hw_set_power_per_rate_table(struct ath_hal *ah,
820 struct ath9k_channel *chan,
821 int16_t *ratesArray,
822 u16 cfgCtl,
823 u8 AntennaReduction,
824 u8 twiceMaxRegulatoryPower,
825 u8 powerLimit)
826{
827 struct ath_hal_5416 *ahp = AH5416(ah);
828 struct ar5416_eeprom *pEepData = &ahp->ah_eeprom;
829 u8 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
830 static const u16 tpScaleReductionTable[5] =
831 { 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
832
833 int i;
834 int8_t twiceLargestAntenna;
835 struct cal_ctl_data *rep;
836 struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
837 0, { 0, 0, 0, 0}
838 };
839 struct cal_target_power_leg targetPowerOfdmExt = {
840 0, { 0, 0, 0, 0} }, targetPowerCckExt = {
841 0, { 0, 0, 0, 0 }
842 };
843 struct cal_target_power_ht targetPowerHt20, targetPowerHt40 = {
844 0, {0, 0, 0, 0}
845 };
846 u8 scaledPower = 0, minCtlPower, maxRegAllowedPower;
847 u16 ctlModesFor11a[] =
848 { CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40 };
849 u16 ctlModesFor11g[] =
850 { CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT, CTL_11G_EXT,
851 CTL_2GHT40
852 };
853 u16 numCtlModes, *pCtlMode, ctlMode, freq;
854 struct chan_centers centers;
855 int tx_chainmask;
856 u8 twiceMinEdgePower;
857
858 tx_chainmask = ahp->ah_txchainmask;
859
860 ath9k_hw_get_channel_centers(ah, chan, &centers);
861
862 twiceLargestAntenna = max(
863 pEepData->modalHeader
864 [IS_CHAN_2GHZ(chan)].antennaGainCh[0],
865 pEepData->modalHeader
866 [IS_CHAN_2GHZ(chan)].antennaGainCh[1]);
867
868 twiceLargestAntenna = max((u8)twiceLargestAntenna,
869 pEepData->modalHeader
870 [IS_CHAN_2GHZ(chan)].antennaGainCh[2]);
871
872 twiceLargestAntenna = (int8_t)min(AntennaReduction - twiceLargestAntenna, 0);
873
874 maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
875
876 if (ah->ah_tpScale != ATH9K_TP_SCALE_MAX) {
877 maxRegAllowedPower -=
878 (tpScaleReductionTable[(ah->ah_tpScale)] * 2);
879 }
880
881 scaledPower = min(powerLimit, maxRegAllowedPower);
882
883 switch (ar5416_get_ntxchains(tx_chainmask)) {
884 case 1:
885 break;
886 case 2:
887 scaledPower -=
888 pEepData->modalHeader[IS_CHAN_2GHZ(chan)].pwrDecreaseFor2Chain;
889 break;
890 case 3:
891 scaledPower -=
892 pEepData->modalHeader[IS_CHAN_2GHZ(chan)].pwrDecreaseFor3Chain;
893 break;
894 }
895
896 scaledPower = max(0, (int32_t) scaledPower);
897
898 if (IS_CHAN_2GHZ(chan)) {
899 numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
900 SUB_NUM_CTL_MODES_AT_2G_40;
901 pCtlMode = ctlModesFor11g;
902
903 ath9k_hw_get_legacy_target_powers(ah, chan,
904 pEepData->calTargetPowerCck,
905 AR5416_NUM_2G_CCK_TARGET_POWERS,
906 &targetPowerCck, 4, false);
907 ath9k_hw_get_legacy_target_powers(ah, chan,
908 pEepData->calTargetPower2G,
909 AR5416_NUM_2G_20_TARGET_POWERS,
910 &targetPowerOfdm, 4, false);
911 ath9k_hw_get_target_powers(ah, chan,
912 pEepData->calTargetPower2GHT20,
913 AR5416_NUM_2G_20_TARGET_POWERS,
914 &targetPowerHt20, 8, false);
915
916 if (IS_CHAN_HT40(chan)) {
917 numCtlModes = ARRAY_SIZE(ctlModesFor11g);
918 ath9k_hw_get_target_powers(ah, chan,
919 pEepData->calTargetPower2GHT40,
920 AR5416_NUM_2G_40_TARGET_POWERS,
921 &targetPowerHt40, 8, true);
922 ath9k_hw_get_legacy_target_powers(ah, chan,
923 pEepData->calTargetPowerCck,
924 AR5416_NUM_2G_CCK_TARGET_POWERS,
925 &targetPowerCckExt, 4, true);
926 ath9k_hw_get_legacy_target_powers(ah, chan,
927 pEepData->calTargetPower2G,
928 AR5416_NUM_2G_20_TARGET_POWERS,
929 &targetPowerOfdmExt, 4, true);
930 }
931 } else {
932 numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
933 SUB_NUM_CTL_MODES_AT_5G_40;
934 pCtlMode = ctlModesFor11a;
935
936 ath9k_hw_get_legacy_target_powers(ah, chan,
937 pEepData->calTargetPower5G,
938 AR5416_NUM_5G_20_TARGET_POWERS,
939 &targetPowerOfdm, 4, false);
940 ath9k_hw_get_target_powers(ah, chan,
941 pEepData->calTargetPower5GHT20,
942 AR5416_NUM_5G_20_TARGET_POWERS,
943 &targetPowerHt20, 8, false);
944
945 if (IS_CHAN_HT40(chan)) {
946 numCtlModes = ARRAY_SIZE(ctlModesFor11a);
947 ath9k_hw_get_target_powers(ah, chan,
948 pEepData->calTargetPower5GHT40,
949 AR5416_NUM_5G_40_TARGET_POWERS,
950 &targetPowerHt40, 8, true);
951 ath9k_hw_get_legacy_target_powers(ah, chan,
952 pEepData->calTargetPower5G,
953 AR5416_NUM_5G_20_TARGET_POWERS,
954 &targetPowerOfdmExt, 4, true);
955 }
956 }
957
958 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
959 bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
960 (pCtlMode[ctlMode] == CTL_2GHT40);
961 if (isHt40CtlMode)
962 freq = centers.synth_center;
963 else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
964 freq = centers.ext_center;
965 else
966 freq = centers.ctl_center;
967
968 if (ar5416_get_eep_ver(ahp) == 14 && ar5416_get_eep_rev(ahp) <= 2)
969 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
970
971 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
972 "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, "
973 "EXT_ADDITIVE %d\n",
974 ctlMode, numCtlModes, isHt40CtlMode,
975 (pCtlMode[ctlMode] & EXT_ADDITIVE));
976
977 for (i = 0; (i < AR5416_NUM_CTLS) && pEepData->ctlIndex[i]; i++) {
978 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
979 " LOOP-Ctlidx %d: cfgCtl 0x%2.2x "
980 "pCtlMode 0x%2.2x ctlIndex 0x%2.2x "
981 "chan %d\n",
982 i, cfgCtl, pCtlMode[ctlMode],
983 pEepData->ctlIndex[i], chan->channel);
984
985 if ((((cfgCtl & ~CTL_MODE_M) |
986 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
987 pEepData->ctlIndex[i]) ||
988 (((cfgCtl & ~CTL_MODE_M) |
989 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
990 ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))) {
991 rep = &(pEepData->ctlData[i]);
992
993 twiceMinEdgePower = ath9k_hw_get_max_edge_power(freq,
994 rep->ctlEdges[ar5416_get_ntxchains(tx_chainmask) - 1],
995 IS_CHAN_2GHZ(chan));
996
997 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
998 " MATCH-EE_IDX %d: ch %d is2 %d "
999 "2xMinEdge %d chainmask %d chains %d\n",
1000 i, freq, IS_CHAN_2GHZ(chan),
1001 twiceMinEdgePower, tx_chainmask,
1002 ar5416_get_ntxchains
1003 (tx_chainmask));
1004 if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL) {
1005 twiceMaxEdgePower = min(twiceMaxEdgePower,
1006 twiceMinEdgePower);
1007 } else {
1008 twiceMaxEdgePower = twiceMinEdgePower;
1009 break;
1010 }
1011 }
1012 }
1013
1014 minCtlPower = min(twiceMaxEdgePower, scaledPower);
1015
1016 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
1017 " SEL-Min ctlMode %d pCtlMode %d "
1018 "2xMaxEdge %d sP %d minCtlPwr %d\n",
1019 ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
1020 scaledPower, minCtlPower);
1021
1022 switch (pCtlMode[ctlMode]) {
1023 case CTL_11B:
1024 for (i = 0; i < ARRAY_SIZE(targetPowerCck.tPow2x); i++) {
1025 targetPowerCck.tPow2x[i] =
1026 min(targetPowerCck.tPow2x[i],
1027 minCtlPower);
1028 }
1029 break;
1030 case CTL_11A:
1031 case CTL_11G:
1032 for (i = 0; i < ARRAY_SIZE(targetPowerOfdm.tPow2x); i++) {
1033 targetPowerOfdm.tPow2x[i] =
1034 min(targetPowerOfdm.tPow2x[i],
1035 minCtlPower);
1036 }
1037 break;
1038 case CTL_5GHT20:
1039 case CTL_2GHT20:
1040 for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x); i++) {
1041 targetPowerHt20.tPow2x[i] =
1042 min(targetPowerHt20.tPow2x[i],
1043 minCtlPower);
1044 }
1045 break;
1046 case CTL_11B_EXT:
1047 targetPowerCckExt.tPow2x[0] =
1048 min(targetPowerCckExt.tPow2x[0], minCtlPower);
1049 break;
1050 case CTL_11A_EXT:
1051 case CTL_11G_EXT:
1052 targetPowerOfdmExt.tPow2x[0] =
1053 min(targetPowerOfdmExt.tPow2x[0], minCtlPower);
1054 break;
1055 case CTL_5GHT40:
1056 case CTL_2GHT40:
1057 for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) {
1058 targetPowerHt40.tPow2x[i] =
1059 min(targetPowerHt40.tPow2x[i],
1060 minCtlPower);
1061 }
1062 break;
1063 default:
1064 break;
1065 }
1066 }
1067
1068 ratesArray[rate6mb] = ratesArray[rate9mb] = ratesArray[rate12mb] =
1069 ratesArray[rate18mb] = ratesArray[rate24mb] =
1070 targetPowerOfdm.tPow2x[0];
1071 ratesArray[rate36mb] = targetPowerOfdm.tPow2x[1];
1072 ratesArray[rate48mb] = targetPowerOfdm.tPow2x[2];
1073 ratesArray[rate54mb] = targetPowerOfdm.tPow2x[3];
1074 ratesArray[rateXr] = targetPowerOfdm.tPow2x[0];
1075
1076 for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x); i++)
1077 ratesArray[rateHt20_0 + i] = targetPowerHt20.tPow2x[i];
1078
1079 if (IS_CHAN_2GHZ(chan)) {
1080 ratesArray[rate1l] = targetPowerCck.tPow2x[0];
1081 ratesArray[rate2s] = ratesArray[rate2l] =
1082 targetPowerCck.tPow2x[1];
1083 ratesArray[rate5_5s] = ratesArray[rate5_5l] =
1084 targetPowerCck.tPow2x[2];
1085 ;
1086 ratesArray[rate11s] = ratesArray[rate11l] =
1087 targetPowerCck.tPow2x[3];
1088 ;
1089 }
1090 if (IS_CHAN_HT40(chan)) {
1091 for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) {
1092 ratesArray[rateHt40_0 + i] =
1093 targetPowerHt40.tPow2x[i];
1094 }
1095 ratesArray[rateDupOfdm] = targetPowerHt40.tPow2x[0];
1096 ratesArray[rateDupCck] = targetPowerHt40.tPow2x[0];
1097 ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0];
1098 if (IS_CHAN_2GHZ(chan)) {
1099 ratesArray[rateExtCck] =
1100 targetPowerCckExt.tPow2x[0];
1101 }
1102 }
1103 return true;
1104}
1105
1106bool ath9k_hw_set_power_cal_table(struct ath_hal *ah,
1107 struct ath9k_channel *chan,
1108 int16_t *pTxPowerIndexOffset)
1109{
1110 struct ath_hal_5416 *ahp = AH5416(ah);
1111 struct ar5416_eeprom *pEepData = &ahp->ah_eeprom;
1112 struct cal_data_per_freq *pRawDataset;
1113 u8 *pCalBChans = NULL;
1114 u16 pdGainOverlap_t2;
1115 static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
1116 u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
1117 u16 numPiers, i, j;
1118 int16_t tMinCalPower;
1119 u16 numXpdGain, xpdMask;
1120 u16 xpdGainValues[AR5416_NUM_PD_GAINS] = { 0, 0, 0, 0 };
1121 u32 reg32, regOffset, regChainOffset;
1122 int16_t modalIdx;
1123
1124 modalIdx = IS_CHAN_2GHZ(chan) ? 1 : 0;
1125 xpdMask = pEepData->modalHeader[modalIdx].xpdGain;
1126
1127 if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
1128 AR5416_EEP_MINOR_VER_2) {
1129 pdGainOverlap_t2 =
1130 pEepData->modalHeader[modalIdx].pdGainOverlap;
1131 } else {
1132 pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
1133 AR_PHY_TPCRG5_PD_GAIN_OVERLAP));
1134 }
1135
1136 if (IS_CHAN_2GHZ(chan)) {
1137 pCalBChans = pEepData->calFreqPier2G;
1138 numPiers = AR5416_NUM_2G_CAL_PIERS;
1139 } else {
1140 pCalBChans = pEepData->calFreqPier5G;
1141 numPiers = AR5416_NUM_5G_CAL_PIERS;
1142 }
1143
1144 numXpdGain = 0;
1145
1146 for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) {
1147 if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) {
1148 if (numXpdGain >= AR5416_NUM_PD_GAINS)
1149 break;
1150 xpdGainValues[numXpdGain] =
1151 (u16)(AR5416_PD_GAINS_IN_MASK - i);
1152 numXpdGain++;
1153 }
1154 }
1155
1156 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_NUM_PD_GAIN,
1157 (numXpdGain - 1) & 0x3);
1158 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_1,
1159 xpdGainValues[0]);
1160 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_2,
1161 xpdGainValues[1]);
1162 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_3,
1163 xpdGainValues[2]);
1164
1165 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
1166 if (AR_SREV_5416_V20_OR_LATER(ah) &&
1167 (ahp->ah_rxchainmask == 5 || ahp->ah_txchainmask == 5) &&
1168 (i != 0)) {
1169 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
1170 } else
1171 regChainOffset = i * 0x1000;
1172
1173 if (pEepData->baseEepHeader.txMask & (1 << i)) {
1174 if (IS_CHAN_2GHZ(chan))
1175 pRawDataset = pEepData->calPierData2G[i];
1176 else
1177 pRawDataset = pEepData->calPierData5G[i];
1178
1179 ath9k_hw_get_gain_boundaries_pdadcs(ah, chan,
1180 pRawDataset, pCalBChans,
1181 numPiers, pdGainOverlap_t2,
1182 &tMinCalPower, gainBoundaries,
1183 pdadcValues, numXpdGain);
1184
1185 if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) {
1186 REG_WRITE(ah,
1187 AR_PHY_TPCRG5 + regChainOffset,
1188 SM(pdGainOverlap_t2,
1189 AR_PHY_TPCRG5_PD_GAIN_OVERLAP)
1190 | SM(gainBoundaries[0],
1191 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_1)
1192 | SM(gainBoundaries[1],
1193 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_2)
1194 | SM(gainBoundaries[2],
1195 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_3)
1196 | SM(gainBoundaries[3],
1197 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4));
1198 }
1199
1200 regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset;
1201 for (j = 0; j < 32; j++) {
1202 reg32 = ((pdadcValues[4 * j + 0] & 0xFF) << 0) |
1203 ((pdadcValues[4 * j + 1] & 0xFF) << 8) |
1204 ((pdadcValues[4 * j + 2] & 0xFF) << 16) |
1205 ((pdadcValues[4 * j + 3] & 0xFF) << 24);
1206 REG_WRITE(ah, regOffset, reg32);
1207
1208 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
1209 "PDADC (%d,%4x): %4.4x %8.8x\n",
1210 i, regChainOffset, regOffset,
1211 reg32);
1212 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
1213 "PDADC: Chain %d | PDADC %3d Value %3d | "
1214 "PDADC %3d Value %3d | PDADC %3d Value %3d | "
1215 "PDADC %3d Value %3d |\n",
1216 i, 4 * j, pdadcValues[4 * j],
1217 4 * j + 1, pdadcValues[4 * j + 1],
1218 4 * j + 2, pdadcValues[4 * j + 2],
1219 4 * j + 3,
1220 pdadcValues[4 * j + 3]);
1221
1222 regOffset += 4;
1223 }
1224 }
1225 }
1226
1227 *pTxPowerIndexOffset = 0;
1228
1229 return true;
1230}
1231
1232/* XXX: Clean me up, make me more legible */
1233bool ath9k_hw_eeprom_set_board_values(struct ath_hal *ah,
1234 struct ath9k_channel *chan)
1235{
1236 struct modal_eep_header *pModal;
1237 struct ath_hal_5416 *ahp = AH5416(ah);
1238 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
1239 int i, regChainOffset;
1240 u8 txRxAttenLocal;
1241 u16 ant_config;
1242
1243 pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
1244
1245 txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44;
1246
1247 ath9k_hw_get_eeprom_antenna_cfg(ah, chan, 1, &ant_config);
1248 REG_WRITE(ah, AR_PHY_SWITCH_COM, ant_config);
1249
1250 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
1251 if (AR_SREV_9280(ah)) {
1252 if (i >= 2)
1253 break;
1254 }
1255
1256 if (AR_SREV_5416_V20_OR_LATER(ah) &&
1257 (ahp->ah_rxchainmask == 5 || ahp->ah_txchainmask == 5)
1258 && (i != 0))
1259 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
1260 else
1261 regChainOffset = i * 0x1000;
1262
1263 REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
1264 pModal->antCtrlChain[i]);
1265
1266 REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
1267 (REG_READ(ah,
1268 AR_PHY_TIMING_CTRL4(0) +
1269 regChainOffset) &
1270 ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
1271 AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
1272 SM(pModal->iqCalICh[i],
1273 AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
1274 SM(pModal->iqCalQCh[i],
1275 AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
1276
1277 if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) {
1278 if ((eep->baseEepHeader.version &
1279 AR5416_EEP_VER_MINOR_MASK) >=
1280 AR5416_EEP_MINOR_VER_3) {
1281 txRxAttenLocal = pModal->txRxAttenCh[i];
1282 if (AR_SREV_9280_10_OR_LATER(ah)) {
1283 REG_RMW_FIELD(ah,
1284 AR_PHY_GAIN_2GHZ +
1285 regChainOffset,
1286 AR_PHY_GAIN_2GHZ_XATTEN1_MARGIN,
1287 pModal->
1288 bswMargin[i]);
1289 REG_RMW_FIELD(ah,
1290 AR_PHY_GAIN_2GHZ +
1291 regChainOffset,
1292 AR_PHY_GAIN_2GHZ_XATTEN1_DB,
1293 pModal->
1294 bswAtten[i]);
1295 REG_RMW_FIELD(ah,
1296 AR_PHY_GAIN_2GHZ +
1297 regChainOffset,
1298 AR_PHY_GAIN_2GHZ_XATTEN2_MARGIN,
1299 pModal->
1300 xatten2Margin[i]);
1301 REG_RMW_FIELD(ah,
1302 AR_PHY_GAIN_2GHZ +
1303 regChainOffset,
1304 AR_PHY_GAIN_2GHZ_XATTEN2_DB,
1305 pModal->
1306 xatten2Db[i]);
1307 } else {
1308 REG_WRITE(ah,
1309 AR_PHY_GAIN_2GHZ +
1310 regChainOffset,
1311 (REG_READ(ah,
1312 AR_PHY_GAIN_2GHZ +
1313 regChainOffset) &
1314 ~AR_PHY_GAIN_2GHZ_BSW_MARGIN)
1315 | SM(pModal->
1316 bswMargin[i],
1317 AR_PHY_GAIN_2GHZ_BSW_MARGIN));
1318 REG_WRITE(ah,
1319 AR_PHY_GAIN_2GHZ +
1320 regChainOffset,
1321 (REG_READ(ah,
1322 AR_PHY_GAIN_2GHZ +
1323 regChainOffset) &
1324 ~AR_PHY_GAIN_2GHZ_BSW_ATTEN)
1325 | SM(pModal->bswAtten[i],
1326 AR_PHY_GAIN_2GHZ_BSW_ATTEN));
1327 }
1328 }
1329 if (AR_SREV_9280_10_OR_LATER(ah)) {
1330 REG_RMW_FIELD(ah,
1331 AR_PHY_RXGAIN +
1332 regChainOffset,
1333 AR9280_PHY_RXGAIN_TXRX_ATTEN,
1334 txRxAttenLocal);
1335 REG_RMW_FIELD(ah,
1336 AR_PHY_RXGAIN +
1337 regChainOffset,
1338 AR9280_PHY_RXGAIN_TXRX_MARGIN,
1339 pModal->rxTxMarginCh[i]);
1340 } else {
1341 REG_WRITE(ah,
1342 AR_PHY_RXGAIN + regChainOffset,
1343 (REG_READ(ah,
1344 AR_PHY_RXGAIN +
1345 regChainOffset) &
1346 ~AR_PHY_RXGAIN_TXRX_ATTEN) |
1347 SM(txRxAttenLocal,
1348 AR_PHY_RXGAIN_TXRX_ATTEN));
1349 REG_WRITE(ah,
1350 AR_PHY_GAIN_2GHZ +
1351 regChainOffset,
1352 (REG_READ(ah,
1353 AR_PHY_GAIN_2GHZ +
1354 regChainOffset) &
1355 ~AR_PHY_GAIN_2GHZ_RXTX_MARGIN) |
1356 SM(pModal->rxTxMarginCh[i],
1357 AR_PHY_GAIN_2GHZ_RXTX_MARGIN));
1358 }
1359 }
1360 }
1361
1362 if (AR_SREV_9280_10_OR_LATER(ah)) {
1363 if (IS_CHAN_2GHZ(chan)) {
1364 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH0,
1365 AR_AN_RF2G1_CH0_OB,
1366 AR_AN_RF2G1_CH0_OB_S,
1367 pModal->ob);
1368 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH0,
1369 AR_AN_RF2G1_CH0_DB,
1370 AR_AN_RF2G1_CH0_DB_S,
1371 pModal->db);
1372 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH1,
1373 AR_AN_RF2G1_CH1_OB,
1374 AR_AN_RF2G1_CH1_OB_S,
1375 pModal->ob_ch1);
1376 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH1,
1377 AR_AN_RF2G1_CH1_DB,
1378 AR_AN_RF2G1_CH1_DB_S,
1379 pModal->db_ch1);
1380 } else {
1381 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH0,
1382 AR_AN_RF5G1_CH0_OB5,
1383 AR_AN_RF5G1_CH0_OB5_S,
1384 pModal->ob);
1385 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH0,
1386 AR_AN_RF5G1_CH0_DB5,
1387 AR_AN_RF5G1_CH0_DB5_S,
1388 pModal->db);
1389 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH1,
1390 AR_AN_RF5G1_CH1_OB5,
1391 AR_AN_RF5G1_CH1_OB5_S,
1392 pModal->ob_ch1);
1393 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH1,
1394 AR_AN_RF5G1_CH1_DB5,
1395 AR_AN_RF5G1_CH1_DB5_S,
1396 pModal->db_ch1);
1397 }
1398 ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2,
1399 AR_AN_TOP2_XPABIAS_LVL,
1400 AR_AN_TOP2_XPABIAS_LVL_S,
1401 pModal->xpaBiasLvl);
1402 ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2,
1403 AR_AN_TOP2_LOCALBIAS,
1404 AR_AN_TOP2_LOCALBIAS_S,
1405 pModal->local_bias);
1406 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, "ForceXPAon: %d\n",
1407 pModal->force_xpaon);
1408 REG_RMW_FIELD(ah, AR_PHY_XPA_CFG, AR_PHY_FORCE_XPA_CFG,
1409 pModal->force_xpaon);
1410 }
1411
1412 REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH,
1413 pModal->switchSettling);
1414 REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ, AR_PHY_DESIRED_SZ_ADC,
1415 pModal->adcDesiredSize);
1416
1417 if (!AR_SREV_9280_10_OR_LATER(ah))
1418 REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ,
1419 AR_PHY_DESIRED_SZ_PGA,
1420 pModal->pgaDesiredSize);
1421
1422 REG_WRITE(ah, AR_PHY_RF_CTL4,
1423 SM(pModal->txEndToXpaOff, AR_PHY_RF_CTL4_TX_END_XPAA_OFF)
1424 | SM(pModal->txEndToXpaOff,
1425 AR_PHY_RF_CTL4_TX_END_XPAB_OFF)
1426 | SM(pModal->txFrameToXpaOn,
1427 AR_PHY_RF_CTL4_FRAME_XPAA_ON)
1428 | SM(pModal->txFrameToXpaOn,
1429 AR_PHY_RF_CTL4_FRAME_XPAB_ON));
1430
1431 REG_RMW_FIELD(ah, AR_PHY_RF_CTL3, AR_PHY_TX_END_TO_A2_RX_ON,
1432 pModal->txEndToRxOn);
1433 if (AR_SREV_9280_10_OR_LATER(ah)) {
1434 REG_RMW_FIELD(ah, AR_PHY_CCA, AR9280_PHY_CCA_THRESH62,
1435 pModal->thresh62);
1436 REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0,
1437 AR_PHY_EXT_CCA0_THRESH62,
1438 pModal->thresh62);
1439 } else {
1440 REG_RMW_FIELD(ah, AR_PHY_CCA, AR_PHY_CCA_THRESH62,
1441 pModal->thresh62);
1442 REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
1443 AR_PHY_EXT_CCA_THRESH62,
1444 pModal->thresh62);
1445 }
1446
1447 if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
1448 AR5416_EEP_MINOR_VER_2) {
1449 REG_RMW_FIELD(ah, AR_PHY_RF_CTL2,
1450 AR_PHY_TX_END_DATA_START,
1451 pModal->txFrameToDataStart);
1452 REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_PA_ON,
1453 pModal->txFrameToPaOn);
1454 }
1455
1456 if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
1457 AR5416_EEP_MINOR_VER_3) {
1458 if (IS_CHAN_HT40(chan))
1459 REG_RMW_FIELD(ah, AR_PHY_SETTLING,
1460 AR_PHY_SETTLING_SWITCH,
1461 pModal->swSettleHt40);
1462 }
1463
1464 return true;
1465}
1466
1467int ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah,
1468 struct ath9k_channel *chan,
1469 u8 index, u16 *config)
1470{
1471 struct ath_hal_5416 *ahp = AH5416(ah);
1472 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
1473 struct modal_eep_header *pModal =
1474 &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
1475 struct base_eep_header *pBase = &eep->baseEepHeader;
1476
1477 switch (index) {
1478 case 0:
1479 *config = pModal->antCtrlCommon & 0xFFFF;
1480 return 0;
1481 case 1:
1482 if (pBase->version >= 0x0E0D) {
1483 if (pModal->useAnt1) {
1484 *config =
1485 ((pModal->antCtrlCommon & 0xFFFF0000) >> 16);
1486 return 0;
1487 }
1488 }
1489 break;
1490 default:
1491 break;
1492 }
1493
1494 return -EINVAL;
1495}
1496
1497u8 ath9k_hw_get_num_ant_config(struct ath_hal *ah,
1498 enum ieee80211_band freq_band)
1499{
1500 struct ath_hal_5416 *ahp = AH5416(ah);
1501 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
1502 struct modal_eep_header *pModal =
1503 &(eep->modalHeader[IEEE80211_BAND_5GHZ == freq_band]);
1504 struct base_eep_header *pBase = &eep->baseEepHeader;
1505 u8 num_ant_config;
1506
1507 num_ant_config = 1;
1508
1509 if (pBase->version >= 0x0E0D)
1510 if (pModal->useAnt1)
1511 num_ant_config += 1;
1512
1513 return num_ant_config;
1514}
1515
1516u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah, u16 i, bool is2GHz)
1517{
1518 struct ath_hal_5416 *ahp = AH5416(ah);
1519 struct ar5416_eeprom *eep =
1520 (struct ar5416_eeprom *) &ahp->ah_eeprom;
1521 u16 spur_val = AR_NO_SPUR;
1522
1523 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
1524 "Getting spur idx %d is2Ghz. %d val %x\n",
1525 i, is2GHz, ah->ah_config.spurchans[i][is2GHz]);
1526
1527 switch (ah->ah_config.spurmode) {
1528 case SPUR_DISABLE:
1529 break;
1530 case SPUR_ENABLE_IOCTL:
1531 spur_val = ah->ah_config.spurchans[i][is2GHz];
1532 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
1533 "Getting spur val from new loc. %d\n", spur_val);
1534 break;
1535 case SPUR_ENABLE_EEPROM:
1536 spur_val = eep->modalHeader[is2GHz].spurChans[i].spurChan;
1537 break;
1538
1539 }
1540
1541 return spur_val;
1542}
1543
1544u32 ath9k_hw_get_eeprom(struct ath_hal *ah,
1545 enum eeprom_param param)
1546{
1547 struct ath_hal_5416 *ahp = AH5416(ah);
1548 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
1549 struct modal_eep_header *pModal = eep->modalHeader;
1550 struct base_eep_header *pBase = &eep->baseEepHeader;
1551
1552 switch (param) {
1553 case EEP_NFTHRESH_5:
1554 return -pModal[0].noiseFloorThreshCh[0];
1555 case EEP_NFTHRESH_2:
1556 return -pModal[1].noiseFloorThreshCh[0];
1557 case AR_EEPROM_MAC(0):
1558 return pBase->macAddr[0] << 8 | pBase->macAddr[1];
1559 case AR_EEPROM_MAC(1):
1560 return pBase->macAddr[2] << 8 | pBase->macAddr[3];
1561 case AR_EEPROM_MAC(2):
1562 return pBase->macAddr[4] << 8 | pBase->macAddr[5];
1563 case EEP_REG_0:
1564 return pBase->regDmn[0];
1565 case EEP_REG_1:
1566 return pBase->regDmn[1];
1567 case EEP_OP_CAP:
1568 return pBase->deviceCap;
1569 case EEP_OP_MODE:
1570 return pBase->opCapFlags;
1571 case EEP_RF_SILENT:
1572 return pBase->rfSilent;
1573 case EEP_OB_5:
1574 return pModal[0].ob;
1575 case EEP_DB_5:
1576 return pModal[0].db;
1577 case EEP_OB_2:
1578 return pModal[1].ob;
1579 case EEP_DB_2:
1580 return pModal[1].db;
1581 case EEP_MINOR_REV:
1582 return pBase->version & AR5416_EEP_VER_MINOR_MASK;
1583 case EEP_TX_MASK:
1584 return pBase->txMask;
1585 case EEP_RX_MASK:
1586 return pBase->rxMask;
1587 default:
1588 return 0;
1589 }
1590}
1591
1592int ath9k_hw_eeprom_attach(struct ath_hal *ah)
1593{
1594 int status;
1595
1596 if (ath9k_hw_use_flash(ah))
1597 ath9k_hw_flash_map(ah);
1598
1599 if (!ath9k_hw_fill_eeprom(ah))
1600 return -EIO;
1601
1602 status = ath9k_hw_check_eeprom(ah);
1603
1604 return status;
1605}
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index 98bc25c9b3cf..e05c9ef55e47 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -23,183 +23,68 @@
23#include "phy.h" 23#include "phy.h"
24#include "initvals.h" 24#include "initvals.h"
25 25
26static void ath9k_hw_iqcal_collect(struct ath_hal *ah);
27static void ath9k_hw_iqcalibrate(struct ath_hal *ah, u8 numChains);
28static void ath9k_hw_adc_gaincal_collect(struct ath_hal *ah);
29static void ath9k_hw_adc_gaincal_calibrate(struct ath_hal *ah,
30 u8 numChains);
31static void ath9k_hw_adc_dccal_collect(struct ath_hal *ah);
32static void ath9k_hw_adc_dccal_calibrate(struct ath_hal *ah,
33 u8 numChains);
34
35static const u8 CLOCK_RATE[] = { 40, 80, 22, 44, 88, 40 }; 26static const u8 CLOCK_RATE[] = { 40, 80, 22, 44, 88, 40 };
36static const int16_t NOISE_FLOOR[] = { -96, -93, -98, -96, -93, -96 };
37
38static const struct hal_percal_data iq_cal_multi_sample = {
39 IQ_MISMATCH_CAL,
40 MAX_CAL_SAMPLES,
41 PER_MIN_LOG_COUNT,
42 ath9k_hw_iqcal_collect,
43 ath9k_hw_iqcalibrate
44};
45static const struct hal_percal_data iq_cal_single_sample = {
46 IQ_MISMATCH_CAL,
47 MIN_CAL_SAMPLES,
48 PER_MAX_LOG_COUNT,
49 ath9k_hw_iqcal_collect,
50 ath9k_hw_iqcalibrate
51};
52static const struct hal_percal_data adc_gain_cal_multi_sample = {
53 ADC_GAIN_CAL,
54 MAX_CAL_SAMPLES,
55 PER_MIN_LOG_COUNT,
56 ath9k_hw_adc_gaincal_collect,
57 ath9k_hw_adc_gaincal_calibrate
58};
59static const struct hal_percal_data adc_gain_cal_single_sample = {
60 ADC_GAIN_CAL,
61 MIN_CAL_SAMPLES,
62 PER_MAX_LOG_COUNT,
63 ath9k_hw_adc_gaincal_collect,
64 ath9k_hw_adc_gaincal_calibrate
65};
66static const struct hal_percal_data adc_dc_cal_multi_sample = {
67 ADC_DC_CAL,
68 MAX_CAL_SAMPLES,
69 PER_MIN_LOG_COUNT,
70 ath9k_hw_adc_dccal_collect,
71 ath9k_hw_adc_dccal_calibrate
72};
73static const struct hal_percal_data adc_dc_cal_single_sample = {
74 ADC_DC_CAL,
75 MIN_CAL_SAMPLES,
76 PER_MAX_LOG_COUNT,
77 ath9k_hw_adc_dccal_collect,
78 ath9k_hw_adc_dccal_calibrate
79};
80static const struct hal_percal_data adc_init_dc_cal = {
81 ADC_DC_INIT_CAL,
82 MIN_CAL_SAMPLES,
83 INIT_LOG_COUNT,
84 ath9k_hw_adc_dccal_collect,
85 ath9k_hw_adc_dccal_calibrate
86};
87 27
88static struct ath9k_rate_table ar5416_11a_table = { 28extern struct hal_percal_data iq_cal_multi_sample;
89 8, 29extern struct hal_percal_data iq_cal_single_sample;
90 {0}, 30extern struct hal_percal_data adc_gain_cal_multi_sample;
91 { 31extern struct hal_percal_data adc_gain_cal_single_sample;
92 {true, PHY_OFDM, 6000, 0x0b, 0x00, (0x80 | 12), 0}, 32extern struct hal_percal_data adc_dc_cal_multi_sample;
93 {true, PHY_OFDM, 9000, 0x0f, 0x00, 18, 0}, 33extern struct hal_percal_data adc_dc_cal_single_sample;
94 {true, PHY_OFDM, 12000, 0x0a, 0x00, (0x80 | 24), 2}, 34extern struct hal_percal_data adc_init_dc_cal;
95 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 2},
96 {true, PHY_OFDM, 24000, 0x09, 0x00, (0x80 | 48), 4},
97 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 4},
98 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 4},
99 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 4}
100 },
101};
102 35
103static struct ath9k_rate_table ar5416_11b_table = { 36static bool ath9k_hw_set_reset_reg(struct ath_hal *ah, u32 type);
104 4, 37static void ath9k_hw_set_regs(struct ath_hal *ah, struct ath9k_channel *chan,
105 {0}, 38 enum ath9k_ht_macmode macmode);
106 { 39static u32 ath9k_hw_ini_fixup(struct ath_hal *ah,
107 {true, PHY_CCK, 1000, 0x1b, 0x00, (0x80 | 2), 0}, 40 struct ar5416_eeprom *pEepData,
108 {true, PHY_CCK, 2000, 0x1a, 0x04, (0x80 | 4), 1}, 41 u32 reg, u32 value);
109 {true, PHY_CCK, 5500, 0x19, 0x04, (0x80 | 11), 1}, 42static void ath9k_hw_9280_spur_mitigate(struct ath_hal *ah, struct ath9k_channel *chan);
110 {true, PHY_CCK, 11000, 0x18, 0x04, (0x80 | 22), 1} 43static void ath9k_hw_spur_mitigate(struct ath_hal *ah, struct ath9k_channel *chan);
111 },
112};
113 44
114static struct ath9k_rate_table ar5416_11g_table = { 45/********************/
115 12, 46/* Helper Functions */
116 {0}, 47/********************/
117 {
118 {true, PHY_CCK, 1000, 0x1b, 0x00, (0x80 | 2), 0},
119 {true, PHY_CCK, 2000, 0x1a, 0x04, (0x80 | 4), 1},
120 {true, PHY_CCK, 5500, 0x19, 0x04, (0x80 | 11), 2},
121 {true, PHY_CCK, 11000, 0x18, 0x04, (0x80 | 22), 3},
122 48
123 {false, PHY_OFDM, 6000, 0x0b, 0x00, 12, 4}, 49static u32 ath9k_hw_mac_usec(struct ath_hal *ah, u32 clks)
124 {false, PHY_OFDM, 9000, 0x0f, 0x00, 18, 4}, 50{
125 {true, PHY_OFDM, 12000, 0x0a, 0x00, 24, 6}, 51 if (ah->ah_curchan != NULL)
126 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 6}, 52 return clks / CLOCK_RATE[ath9k_hw_chan2wmode(ah, ah->ah_curchan)];
127 {true, PHY_OFDM, 24000, 0x09, 0x00, 48, 8}, 53 else
128 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 8}, 54 return clks / CLOCK_RATE[ATH9K_MODE_11B];
129 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 8}, 55}
130 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 8}
131 },
132};
133 56
134static struct ath9k_rate_table ar5416_11ng_table = { 57static u32 ath9k_hw_mac_to_usec(struct ath_hal *ah, u32 clks)
135 28, 58{
136 {0}, 59 struct ath9k_channel *chan = ah->ah_curchan;
137 {
138 {true, PHY_CCK, 1000, 0x1b, 0x00, (0x80 | 2), 0},
139 {true, PHY_CCK, 2000, 0x1a, 0x04, (0x80 | 4), 1},
140 {true, PHY_CCK, 5500, 0x19, 0x04, (0x80 | 11), 2},
141 {true, PHY_CCK, 11000, 0x18, 0x04, (0x80 | 22), 3},
142 60
143 {false, PHY_OFDM, 6000, 0x0b, 0x00, 12, 4}, 61 if (chan && IS_CHAN_HT40(chan))
144 {false, PHY_OFDM, 9000, 0x0f, 0x00, 18, 4}, 62 return ath9k_hw_mac_usec(ah, clks) / 2;
145 {true, PHY_OFDM, 12000, 0x0a, 0x00, 24, 6}, 63 else
146 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 6}, 64 return ath9k_hw_mac_usec(ah, clks);
147 {true, PHY_OFDM, 24000, 0x09, 0x00, 48, 8}, 65}
148 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 8},
149 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 8},
150 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 8},
151 {true, PHY_HT, 6500, 0x80, 0x00, 0, 4},
152 {true, PHY_HT, 13000, 0x81, 0x00, 1, 6},
153 {true, PHY_HT, 19500, 0x82, 0x00, 2, 6},
154 {true, PHY_HT, 26000, 0x83, 0x00, 3, 8},
155 {true, PHY_HT, 39000, 0x84, 0x00, 4, 8},
156 {true, PHY_HT, 52000, 0x85, 0x00, 5, 8},
157 {true, PHY_HT, 58500, 0x86, 0x00, 6, 8},
158 {true, PHY_HT, 65000, 0x87, 0x00, 7, 8},
159 {true, PHY_HT, 13000, 0x88, 0x00, 8, 4},
160 {true, PHY_HT, 26000, 0x89, 0x00, 9, 6},
161 {true, PHY_HT, 39000, 0x8a, 0x00, 10, 6},
162 {true, PHY_HT, 52000, 0x8b, 0x00, 11, 8},
163 {true, PHY_HT, 78000, 0x8c, 0x00, 12, 8},
164 {true, PHY_HT, 104000, 0x8d, 0x00, 13, 8},
165 {true, PHY_HT, 117000, 0x8e, 0x00, 14, 8},
166 {true, PHY_HT, 130000, 0x8f, 0x00, 15, 8},
167 },
168};
169 66
170static struct ath9k_rate_table ar5416_11na_table = { 67static u32 ath9k_hw_mac_clks(struct ath_hal *ah, u32 usecs)
171 24, 68{
172 {0}, 69 if (ah->ah_curchan != NULL)
173 { 70 return usecs * CLOCK_RATE[ath9k_hw_chan2wmode(ah,
174 {true, PHY_OFDM, 6000, 0x0b, 0x00, (0x80 | 12), 0}, 71 ah->ah_curchan)];
175 {true, PHY_OFDM, 9000, 0x0f, 0x00, 18, 0}, 72 else
176 {true, PHY_OFDM, 12000, 0x0a, 0x00, (0x80 | 24), 2}, 73 return usecs * CLOCK_RATE[ATH9K_MODE_11B];
177 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 2}, 74}
178 {true, PHY_OFDM, 24000, 0x09, 0x00, (0x80 | 48), 4}, 75
179 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 4}, 76static u32 ath9k_hw_mac_to_clks(struct ath_hal *ah, u32 usecs)
180 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 4}, 77{
181 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 4}, 78 struct ath9k_channel *chan = ah->ah_curchan;
182 {true, PHY_HT, 6500, 0x80, 0x00, 0, 0}, 79
183 {true, PHY_HT, 13000, 0x81, 0x00, 1, 2}, 80 if (chan && IS_CHAN_HT40(chan))
184 {true, PHY_HT, 19500, 0x82, 0x00, 2, 2}, 81 return ath9k_hw_mac_clks(ah, usecs) * 2;
185 {true, PHY_HT, 26000, 0x83, 0x00, 3, 4}, 82 else
186 {true, PHY_HT, 39000, 0x84, 0x00, 4, 4}, 83 return ath9k_hw_mac_clks(ah, usecs);
187 {true, PHY_HT, 52000, 0x85, 0x00, 5, 4}, 84}
188 {true, PHY_HT, 58500, 0x86, 0x00, 6, 4},
189 {true, PHY_HT, 65000, 0x87, 0x00, 7, 4},
190 {true, PHY_HT, 13000, 0x88, 0x00, 8, 0},
191 {true, PHY_HT, 26000, 0x89, 0x00, 9, 2},
192 {true, PHY_HT, 39000, 0x8a, 0x00, 10, 2},
193 {true, PHY_HT, 52000, 0x8b, 0x00, 11, 4},
194 {true, PHY_HT, 78000, 0x8c, 0x00, 12, 4},
195 {true, PHY_HT, 104000, 0x8d, 0x00, 13, 4},
196 {true, PHY_HT, 117000, 0x8e, 0x00, 14, 4},
197 {true, PHY_HT, 130000, 0x8f, 0x00, 15, 4},
198 },
199};
200 85
201static enum wireless_mode ath9k_hw_chan2wmode(struct ath_hal *ah, 86enum wireless_mode ath9k_hw_chan2wmode(struct ath_hal *ah,
202 const struct ath9k_channel *chan) 87 const struct ath9k_channel *chan)
203{ 88{
204 if (IS_CHAN_CCK(chan)) 89 if (IS_CHAN_CCK(chan))
205 return ATH9K_MODE_11A; 90 return ATH9K_MODE_11A;
@@ -208,10 +93,7 @@ static enum wireless_mode ath9k_hw_chan2wmode(struct ath_hal *ah,
208 return ATH9K_MODE_11A; 93 return ATH9K_MODE_11A;
209} 94}
210 95
211static bool ath9k_hw_wait(struct ath_hal *ah, 96bool ath9k_hw_wait(struct ath_hal *ah, u32 reg, u32 mask, u32 val)
212 u32 reg,
213 u32 mask,
214 u32 val)
215{ 97{
216 int i; 98 int i;
217 99
@@ -222,78 +104,10 @@ static bool ath9k_hw_wait(struct ath_hal *ah,
222 udelay(AH_TIME_QUANTUM); 104 udelay(AH_TIME_QUANTUM);
223 } 105 }
224 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO, 106 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
225 "%s: timeout on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n", 107 "%s: timeout on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n",
226 __func__, reg, REG_READ(ah, reg), mask, val); 108 __func__, reg, REG_READ(ah, reg), mask, val);
227 return false;
228}
229
230static bool ath9k_hw_eeprom_read(struct ath_hal *ah, u32 off,
231 u16 *data)
232{
233 (void) REG_READ(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
234
235 if (!ath9k_hw_wait(ah,
236 AR_EEPROM_STATUS_DATA,
237 AR_EEPROM_STATUS_DATA_BUSY |
238 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0)) {
239 return false;
240 }
241
242 *data = MS(REG_READ(ah, AR_EEPROM_STATUS_DATA),
243 AR_EEPROM_STATUS_DATA_VAL);
244
245 return true;
246}
247
248static int ath9k_hw_flash_map(struct ath_hal *ah)
249{
250 struct ath_hal_5416 *ahp = AH5416(ah);
251
252 ahp->ah_cal_mem = ioremap(AR5416_EEPROM_START_ADDR, AR5416_EEPROM_MAX);
253
254 if (!ahp->ah_cal_mem) {
255 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
256 "%s: cannot remap eeprom region \n", __func__);
257 return -EIO;
258 }
259
260 return 0;
261}
262
263static bool ath9k_hw_flash_read(struct ath_hal *ah, u32 off,
264 u16 *data)
265{
266 struct ath_hal_5416 *ahp = AH5416(ah);
267
268 *data = ioread16(ahp->ah_cal_mem + off);
269 return true;
270}
271
272static void ath9k_hw_read_revisions(struct ath_hal *ah)
273{
274 u32 val;
275
276 val = REG_READ(ah, AR_SREV) & AR_SREV_ID;
277
278 if (val == 0xFF) {
279 val = REG_READ(ah, AR_SREV);
280
281 ah->ah_macVersion =
282 (val & AR_SREV_VERSION2) >> AR_SREV_TYPE2_S;
283
284 ah->ah_macRev = MS(val, AR_SREV_REVISION2);
285 ah->ah_isPciExpress =
286 (val & AR_SREV_TYPE2_HOST_MODE) ? 0 : 1;
287
288 } else {
289 if (!AR_SREV_9100(ah))
290 ah->ah_macVersion = MS(val, AR_SREV_VERSION);
291
292 ah->ah_macRev = val & AR_SREV_REVISION;
293 109
294 if (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE) 110 return false;
295 ah->ah_isPciExpress = true;
296 }
297} 111}
298 112
299u32 ath9k_hw_reverse_bits(u32 val, u32 n) 113u32 ath9k_hw_reverse_bits(u32 val, u32 n)
@@ -308,596 +122,215 @@ u32 ath9k_hw_reverse_bits(u32 val, u32 n)
308 return retval; 122 return retval;
309} 123}
310 124
311static void ath9k_hw_set_defaults(struct ath_hal *ah) 125bool ath9k_get_channel_edges(struct ath_hal *ah,
126 u16 flags, u16 *low,
127 u16 *high)
312{ 128{
313 int i; 129 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
314
315 ah->ah_config.dma_beacon_response_time = 2;
316 ah->ah_config.sw_beacon_response_time = 10;
317 ah->ah_config.additional_swba_backoff = 0;
318 ah->ah_config.ack_6mb = 0x0;
319 ah->ah_config.cwm_ignore_extcca = 0;
320 ah->ah_config.pcie_powersave_enable = 0;
321 ah->ah_config.pcie_l1skp_enable = 0;
322 ah->ah_config.pcie_clock_req = 0;
323 ah->ah_config.pcie_power_reset = 0x100;
324 ah->ah_config.pcie_restore = 0;
325 ah->ah_config.pcie_waen = 0;
326 ah->ah_config.analog_shiftreg = 1;
327 ah->ah_config.ht_enable = 1;
328 ah->ah_config.ofdm_trig_low = 200;
329 ah->ah_config.ofdm_trig_high = 500;
330 ah->ah_config.cck_trig_high = 200;
331 ah->ah_config.cck_trig_low = 100;
332 ah->ah_config.enable_ani = 1;
333 ah->ah_config.noise_immunity_level = 4;
334 ah->ah_config.ofdm_weaksignal_det = 1;
335 ah->ah_config.cck_weaksignal_thr = 0;
336 ah->ah_config.spur_immunity_level = 2;
337 ah->ah_config.firstep_level = 0;
338 ah->ah_config.rssi_thr_high = 40;
339 ah->ah_config.rssi_thr_low = 7;
340 ah->ah_config.diversity_control = 0;
341 ah->ah_config.antenna_switch_swap = 0;
342 130
343 for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { 131 if (flags & CHANNEL_5GHZ) {
344 ah->ah_config.spurchans[i][0] = AR_NO_SPUR; 132 *low = pCap->low_5ghz_chan;
345 ah->ah_config.spurchans[i][1] = AR_NO_SPUR; 133 *high = pCap->high_5ghz_chan;
134 return true;
346 } 135 }
347 136 if ((flags & CHANNEL_2GHZ)) {
348 ah->ah_config.intr_mitigation = 0; 137 *low = pCap->low_2ghz_chan;
349} 138 *high = pCap->high_2ghz_chan;
350 139 return true;
351static void ath9k_hw_override_ini(struct ath_hal *ah,
352 struct ath9k_channel *chan)
353{
354 if (!AR_SREV_5416_V20_OR_LATER(ah)
355 || AR_SREV_9280_10_OR_LATER(ah))
356 return;
357
358 REG_WRITE(ah, 0x9800 + (651 << 2), 0x11);
359}
360
361static void ath9k_hw_init_bb(struct ath_hal *ah,
362 struct ath9k_channel *chan)
363{
364 u32 synthDelay;
365
366 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
367 if (IS_CHAN_CCK(chan))
368 synthDelay = (4 * synthDelay) / 22;
369 else
370 synthDelay /= 10;
371
372 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
373
374 udelay(synthDelay + BASE_ACTIVATE_DELAY);
375}
376
377static void ath9k_hw_init_interrupt_masks(struct ath_hal *ah,
378 enum ath9k_opmode opmode)
379{
380 struct ath_hal_5416 *ahp = AH5416(ah);
381
382 ahp->ah_maskReg = AR_IMR_TXERR |
383 AR_IMR_TXURN |
384 AR_IMR_RXERR |
385 AR_IMR_RXORN |
386 AR_IMR_BCNMISC;
387
388 if (ahp->ah_intrMitigation)
389 ahp->ah_maskReg |= AR_IMR_RXINTM | AR_IMR_RXMINTR;
390 else
391 ahp->ah_maskReg |= AR_IMR_RXOK;
392
393 ahp->ah_maskReg |= AR_IMR_TXOK;
394
395 if (opmode == ATH9K_M_HOSTAP)
396 ahp->ah_maskReg |= AR_IMR_MIB;
397
398 REG_WRITE(ah, AR_IMR, ahp->ah_maskReg);
399 REG_WRITE(ah, AR_IMR_S2, REG_READ(ah, AR_IMR_S2) | AR_IMR_S2_GTT);
400
401 if (!AR_SREV_9100(ah)) {
402 REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF);
403 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, AR_INTR_SYNC_DEFAULT);
404 REG_WRITE(ah, AR_INTR_SYNC_MASK, 0);
405 } 140 }
141 return false;
406} 142}
407 143
408static void ath9k_hw_init_qos(struct ath_hal *ah) 144u16 ath9k_hw_computetxtime(struct ath_hal *ah,
409{ 145 const struct ath9k_rate_table *rates,
410 REG_WRITE(ah, AR_MIC_QOS_CONTROL, 0x100aa); 146 u32 frameLen, u16 rateix,
411 REG_WRITE(ah, AR_MIC_QOS_SELECT, 0x3210); 147 bool shortPreamble)
412
413 REG_WRITE(ah, AR_QOS_NO_ACK,
414 SM(2, AR_QOS_NO_ACK_TWO_BIT) |
415 SM(5, AR_QOS_NO_ACK_BIT_OFF) |
416 SM(0, AR_QOS_NO_ACK_BYTE_OFF));
417
418 REG_WRITE(ah, AR_TXOP_X, AR_TXOP_X_VAL);
419 REG_WRITE(ah, AR_TXOP_0_3, 0xFFFFFFFF);
420 REG_WRITE(ah, AR_TXOP_4_7, 0xFFFFFFFF);
421 REG_WRITE(ah, AR_TXOP_8_11, 0xFFFFFFFF);
422 REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF);
423}
424
425static void ath9k_hw_analog_shift_rmw(struct ath_hal *ah,
426 u32 reg,
427 u32 mask,
428 u32 shift,
429 u32 val)
430{
431 u32 regVal;
432
433 regVal = REG_READ(ah, reg) & ~mask;
434 regVal |= (val << shift) & mask;
435
436 REG_WRITE(ah, reg, regVal);
437
438 if (ah->ah_config.analog_shiftreg)
439 udelay(100);
440
441 return;
442}
443
444static u8 ath9k_hw_get_num_ant_config(struct ath_hal_5416 *ahp,
445 enum ieee80211_band freq_band)
446{ 148{
447 struct ar5416_eeprom *eep = &ahp->ah_eeprom; 149 u32 bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
448 struct modal_eep_header *pModal = 150 u32 kbps;
449 &(eep->modalHeader[IEEE80211_BAND_5GHZ == freq_band]);
450 struct base_eep_header *pBase = &eep->baseEepHeader;
451 u8 num_ant_config;
452
453 num_ant_config = 1;
454
455 if (pBase->version >= 0x0E0D)
456 if (pModal->useAnt1)
457 num_ant_config += 1;
458
459 return num_ant_config;
460}
461 151
462static int 152 kbps = rates->info[rateix].rateKbps;
463ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal_5416 *ahp,
464 struct ath9k_channel *chan,
465 u8 index,
466 u16 *config)
467{
468 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
469 struct modal_eep_header *pModal =
470 &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
471 struct base_eep_header *pBase = &eep->baseEepHeader;
472 153
473 switch (index) { 154 if (kbps == 0)
474 case 0:
475 *config = pModal->antCtrlCommon & 0xFFFF;
476 return 0; 155 return 0;
477 case 1: 156
478 if (pBase->version >= 0x0E0D) { 157 switch (rates->info[rateix].phy) {
479 if (pModal->useAnt1) { 158 case PHY_CCK:
480 *config = 159 phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
481 ((pModal->antCtrlCommon & 0xFFFF0000) >> 16); 160 if (shortPreamble && rates->info[rateix].shortPreamble)
482 return 0; 161 phyTime >>= 1;
483 } 162 numBits = frameLen << 3;
163 txTime = CCK_SIFS_TIME + phyTime + ((numBits * 1000) / kbps);
164 break;
165 case PHY_OFDM:
166 if (ah->ah_curchan && IS_CHAN_QUARTER_RATE(ah->ah_curchan)) {
167 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME_QUARTER) / 1000;
168 numBits = OFDM_PLCP_BITS + (frameLen << 3);
169 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
170 txTime = OFDM_SIFS_TIME_QUARTER
171 + OFDM_PREAMBLE_TIME_QUARTER
172 + (numSymbols * OFDM_SYMBOL_TIME_QUARTER);
173 } else if (ah->ah_curchan &&
174 IS_CHAN_HALF_RATE(ah->ah_curchan)) {
175 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME_HALF) / 1000;
176 numBits = OFDM_PLCP_BITS + (frameLen << 3);
177 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
178 txTime = OFDM_SIFS_TIME_HALF +
179 OFDM_PREAMBLE_TIME_HALF
180 + (numSymbols * OFDM_SYMBOL_TIME_HALF);
181 } else {
182 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME) / 1000;
183 numBits = OFDM_PLCP_BITS + (frameLen << 3);
184 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
185 txTime = OFDM_SIFS_TIME + OFDM_PREAMBLE_TIME
186 + (numSymbols * OFDM_SYMBOL_TIME);
484 } 187 }
485 break; 188 break;
486 default: 189 default:
190 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
191 "%s: unknown phy %u (rate ix %u)\n", __func__,
192 rates->info[rateix].phy, rateix);
193 txTime = 0;
487 break; 194 break;
488 } 195 }
489 196
490 return -EINVAL; 197 return txTime;
491}
492
493static inline bool ath9k_hw_nvram_read(struct ath_hal *ah,
494 u32 off,
495 u16 *data)
496{
497 if (ath9k_hw_use_flash(ah))
498 return ath9k_hw_flash_read(ah, off, data);
499 else
500 return ath9k_hw_eeprom_read(ah, off, data);
501} 198}
502 199
503static bool ath9k_hw_fill_eeprom(struct ath_hal *ah) 200u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags)
504{ 201{
505 struct ath_hal_5416 *ahp = AH5416(ah); 202 if (flags & CHANNEL_2GHZ) {
506 struct ar5416_eeprom *eep = &ahp->ah_eeprom; 203 if (freq == 2484)
507 u16 *eep_data; 204 return 14;
508 int addr, ar5416_eep_start_loc = 0; 205 if (freq < 2484)
509 206 return (freq - 2407) / 5;
510 if (!ath9k_hw_use_flash(ah)) { 207 else
511 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 208 return 15 + ((freq - 2512) / 20);
512 "%s: Reading from EEPROM, not flash\n", __func__); 209 } else if (flags & CHANNEL_5GHZ) {
513 ar5416_eep_start_loc = 256; 210 if (ath9k_regd_is_public_safety_sku(ah) &&
514 } 211 IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) {
515 if (AR_SREV_9100(ah)) 212 return ((freq * 10) +
516 ar5416_eep_start_loc = 256; 213 (((freq % 5) == 2) ? 5 : 0) - 49400) / 5;
517 214 } else if ((flags & CHANNEL_A) && (freq <= 5000)) {
518 eep_data = (u16 *) eep; 215 return (freq - 4000) / 5;
519 for (addr = 0; 216 } else {
520 addr < sizeof(struct ar5416_eeprom) / sizeof(u16); 217 return (freq - 5000) / 5;
521 addr++) {
522 if (!ath9k_hw_nvram_read(ah, addr + ar5416_eep_start_loc,
523 eep_data)) {
524 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
525 "%s: Unable to read eeprom region \n",
526 __func__);
527 return false;
528 } 218 }
529 eep_data++; 219 } else {
220 if (freq == 2484)
221 return 14;
222 if (freq < 2484)
223 return (freq - 2407) / 5;
224 if (freq < 5000) {
225 if (ath9k_regd_is_public_safety_sku(ah)
226 && IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) {
227 return ((freq * 10) +
228 (((freq % 5) ==
229 2) ? 5 : 0) - 49400) / 5;
230 } else if (freq > 4900) {
231 return (freq - 4000) / 5;
232 } else {
233 return 15 + ((freq - 2512) / 20);
234 }
235 }
236 return (freq - 5000) / 5;
530 } 237 }
531 return true;
532} 238}
533 239
534/* XXX: Clean me up, make me more legible */ 240void ath9k_hw_get_channel_centers(struct ath_hal *ah,
535static bool 241 struct ath9k_channel *chan,
536ath9k_hw_eeprom_set_board_values(struct ath_hal *ah, 242 struct chan_centers *centers)
537 struct ath9k_channel *chan)
538{ 243{
539 struct modal_eep_header *pModal; 244 int8_t extoff;
540 int i, regChainOffset;
541 struct ath_hal_5416 *ahp = AH5416(ah); 245 struct ath_hal_5416 *ahp = AH5416(ah);
542 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
543 u8 txRxAttenLocal;
544 u16 ant_config;
545 246
546 pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); 247 if (!IS_CHAN_HT40(chan)) {
248 centers->ctl_center = centers->ext_center =
249 centers->synth_center = chan->channel;
250 return;
251 }
547 252
548 txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44; 253 if ((chan->chanmode == CHANNEL_A_HT40PLUS) ||
254 (chan->chanmode == CHANNEL_G_HT40PLUS)) {
255 centers->synth_center =
256 chan->channel + HT40_CHANNEL_CENTER_SHIFT;
257 extoff = 1;
258 } else {
259 centers->synth_center =
260 chan->channel - HT40_CHANNEL_CENTER_SHIFT;
261 extoff = -1;
262 }
549 263
550 ath9k_hw_get_eeprom_antenna_cfg(ahp, chan, 1, &ant_config); 264 centers->ctl_center =
551 REG_WRITE(ah, AR_PHY_SWITCH_COM, ant_config); 265 centers->synth_center - (extoff * HT40_CHANNEL_CENTER_SHIFT);
266 centers->ext_center =
267 centers->synth_center + (extoff *
268 ((ahp->ah_extprotspacing == ATH9K_HT_EXTPROTSPACING_20) ?
269 HT40_CHANNEL_CENTER_SHIFT : 15));
552 270
553 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 271}
554 if (AR_SREV_9280(ah)) {
555 if (i >= 2)
556 break;
557 }
558 272
559 if (AR_SREV_5416_V20_OR_LATER(ah) && 273/******************/
560 (ahp->ah_rxchainmask == 5 || ahp->ah_txchainmask == 5) 274/* Chip Revisions */
561 && (i != 0)) 275/******************/
562 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
563 else
564 regChainOffset = i * 0x1000;
565
566 REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
567 pModal->antCtrlChain[i]);
568
569 REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
570 (REG_READ(ah,
571 AR_PHY_TIMING_CTRL4(0) +
572 regChainOffset) &
573 ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
574 AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
575 SM(pModal->iqCalICh[i],
576 AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
577 SM(pModal->iqCalQCh[i],
578 AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
579
580 if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) {
581 if ((eep->baseEepHeader.version &
582 AR5416_EEP_VER_MINOR_MASK) >=
583 AR5416_EEP_MINOR_VER_3) {
584 txRxAttenLocal = pModal->txRxAttenCh[i];
585 if (AR_SREV_9280_10_OR_LATER(ah)) {
586 REG_RMW_FIELD(ah,
587 AR_PHY_GAIN_2GHZ +
588 regChainOffset,
589 AR_PHY_GAIN_2GHZ_XATTEN1_MARGIN,
590 pModal->
591 bswMargin[i]);
592 REG_RMW_FIELD(ah,
593 AR_PHY_GAIN_2GHZ +
594 regChainOffset,
595 AR_PHY_GAIN_2GHZ_XATTEN1_DB,
596 pModal->
597 bswAtten[i]);
598 REG_RMW_FIELD(ah,
599 AR_PHY_GAIN_2GHZ +
600 regChainOffset,
601 AR_PHY_GAIN_2GHZ_XATTEN2_MARGIN,
602 pModal->
603 xatten2Margin[i]);
604 REG_RMW_FIELD(ah,
605 AR_PHY_GAIN_2GHZ +
606 regChainOffset,
607 AR_PHY_GAIN_2GHZ_XATTEN2_DB,
608 pModal->
609 xatten2Db[i]);
610 } else {
611 REG_WRITE(ah,
612 AR_PHY_GAIN_2GHZ +
613 regChainOffset,
614 (REG_READ(ah,
615 AR_PHY_GAIN_2GHZ +
616 regChainOffset) &
617 ~AR_PHY_GAIN_2GHZ_BSW_MARGIN)
618 | SM(pModal->
619 bswMargin[i],
620 AR_PHY_GAIN_2GHZ_BSW_MARGIN));
621 REG_WRITE(ah,
622 AR_PHY_GAIN_2GHZ +
623 regChainOffset,
624 (REG_READ(ah,
625 AR_PHY_GAIN_2GHZ +
626 regChainOffset) &
627 ~AR_PHY_GAIN_2GHZ_BSW_ATTEN)
628 | SM(pModal->bswAtten[i],
629 AR_PHY_GAIN_2GHZ_BSW_ATTEN));
630 }
631 }
632 if (AR_SREV_9280_10_OR_LATER(ah)) {
633 REG_RMW_FIELD(ah,
634 AR_PHY_RXGAIN +
635 regChainOffset,
636 AR9280_PHY_RXGAIN_TXRX_ATTEN,
637 txRxAttenLocal);
638 REG_RMW_FIELD(ah,
639 AR_PHY_RXGAIN +
640 regChainOffset,
641 AR9280_PHY_RXGAIN_TXRX_MARGIN,
642 pModal->rxTxMarginCh[i]);
643 } else {
644 REG_WRITE(ah,
645 AR_PHY_RXGAIN + regChainOffset,
646 (REG_READ(ah,
647 AR_PHY_RXGAIN +
648 regChainOffset) &
649 ~AR_PHY_RXGAIN_TXRX_ATTEN) |
650 SM(txRxAttenLocal,
651 AR_PHY_RXGAIN_TXRX_ATTEN));
652 REG_WRITE(ah,
653 AR_PHY_GAIN_2GHZ +
654 regChainOffset,
655 (REG_READ(ah,
656 AR_PHY_GAIN_2GHZ +
657 regChainOffset) &
658 ~AR_PHY_GAIN_2GHZ_RXTX_MARGIN) |
659 SM(pModal->rxTxMarginCh[i],
660 AR_PHY_GAIN_2GHZ_RXTX_MARGIN));
661 }
662 }
663 }
664 276
665 if (AR_SREV_9280_10_OR_LATER(ah)) { 277static void ath9k_hw_read_revisions(struct ath_hal *ah)
666 if (IS_CHAN_2GHZ(chan)) { 278{
667 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH0, 279 u32 val;
668 AR_AN_RF2G1_CH0_OB,
669 AR_AN_RF2G1_CH0_OB_S,
670 pModal->ob);
671 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH0,
672 AR_AN_RF2G1_CH0_DB,
673 AR_AN_RF2G1_CH0_DB_S,
674 pModal->db);
675 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH1,
676 AR_AN_RF2G1_CH1_OB,
677 AR_AN_RF2G1_CH1_OB_S,
678 pModal->ob_ch1);
679 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH1,
680 AR_AN_RF2G1_CH1_DB,
681 AR_AN_RF2G1_CH1_DB_S,
682 pModal->db_ch1);
683 } else {
684 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH0,
685 AR_AN_RF5G1_CH0_OB5,
686 AR_AN_RF5G1_CH0_OB5_S,
687 pModal->ob);
688 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH0,
689 AR_AN_RF5G1_CH0_DB5,
690 AR_AN_RF5G1_CH0_DB5_S,
691 pModal->db);
692 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH1,
693 AR_AN_RF5G1_CH1_OB5,
694 AR_AN_RF5G1_CH1_OB5_S,
695 pModal->ob_ch1);
696 ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH1,
697 AR_AN_RF5G1_CH1_DB5,
698 AR_AN_RF5G1_CH1_DB5_S,
699 pModal->db_ch1);
700 }
701 ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2,
702 AR_AN_TOP2_XPABIAS_LVL,
703 AR_AN_TOP2_XPABIAS_LVL_S,
704 pModal->xpaBiasLvl);
705 ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2,
706 AR_AN_TOP2_LOCALBIAS,
707 AR_AN_TOP2_LOCALBIAS_S,
708 pModal->local_bias);
709 DPRINTF(ah->ah_sc, ATH_DBG_ANY, "ForceXPAon: %d\n",
710 pModal->force_xpaon);
711 REG_RMW_FIELD(ah, AR_PHY_XPA_CFG, AR_PHY_FORCE_XPA_CFG,
712 pModal->force_xpaon);
713 }
714 280
715 REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH, 281 val = REG_READ(ah, AR_SREV) & AR_SREV_ID;
716 pModal->switchSettling);
717 REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ, AR_PHY_DESIRED_SZ_ADC,
718 pModal->adcDesiredSize);
719 282
720 if (!AR_SREV_9280_10_OR_LATER(ah)) 283 if (val == 0xFF) {
721 REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ, 284 val = REG_READ(ah, AR_SREV);
722 AR_PHY_DESIRED_SZ_PGA, 285 ah->ah_macVersion = (val & AR_SREV_VERSION2) >> AR_SREV_TYPE2_S;
723 pModal->pgaDesiredSize); 286 ah->ah_macRev = MS(val, AR_SREV_REVISION2);
724 287 ah->ah_isPciExpress = (val & AR_SREV_TYPE2_HOST_MODE) ? 0 : 1;
725 REG_WRITE(ah, AR_PHY_RF_CTL4,
726 SM(pModal->txEndToXpaOff, AR_PHY_RF_CTL4_TX_END_XPAA_OFF)
727 | SM(pModal->txEndToXpaOff,
728 AR_PHY_RF_CTL4_TX_END_XPAB_OFF)
729 | SM(pModal->txFrameToXpaOn,
730 AR_PHY_RF_CTL4_FRAME_XPAA_ON)
731 | SM(pModal->txFrameToXpaOn,
732 AR_PHY_RF_CTL4_FRAME_XPAB_ON));
733
734 REG_RMW_FIELD(ah, AR_PHY_RF_CTL3, AR_PHY_TX_END_TO_A2_RX_ON,
735 pModal->txEndToRxOn);
736 if (AR_SREV_9280_10_OR_LATER(ah)) {
737 REG_RMW_FIELD(ah, AR_PHY_CCA, AR9280_PHY_CCA_THRESH62,
738 pModal->thresh62);
739 REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0,
740 AR_PHY_EXT_CCA0_THRESH62,
741 pModal->thresh62);
742 } else { 288 } else {
743 REG_RMW_FIELD(ah, AR_PHY_CCA, AR_PHY_CCA_THRESH62, 289 if (!AR_SREV_9100(ah))
744 pModal->thresh62); 290 ah->ah_macVersion = MS(val, AR_SREV_VERSION);
745 REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
746 AR_PHY_EXT_CCA_THRESH62,
747 pModal->thresh62);
748 }
749 291
750 if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= 292 ah->ah_macRev = val & AR_SREV_REVISION;
751 AR5416_EEP_MINOR_VER_2) {
752 REG_RMW_FIELD(ah, AR_PHY_RF_CTL2,
753 AR_PHY_TX_END_DATA_START,
754 pModal->txFrameToDataStart);
755 REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_PA_ON,
756 pModal->txFrameToPaOn);
757 }
758 293
759 if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= 294 if (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE)
760 AR5416_EEP_MINOR_VER_3) { 295 ah->ah_isPciExpress = true;
761 if (IS_CHAN_HT40(chan))
762 REG_RMW_FIELD(ah, AR_PHY_SETTLING,
763 AR_PHY_SETTLING_SWITCH,
764 pModal->swSettleHt40);
765 } 296 }
766
767 return true;
768} 297}
769 298
770static int ath9k_hw_check_eeprom(struct ath_hal *ah) 299static int ath9k_hw_get_radiorev(struct ath_hal *ah)
771{ 300{
772 u32 sum = 0, el; 301 u32 val;
773 u16 *eepdata;
774 int i; 302 int i;
775 struct ath_hal_5416 *ahp = AH5416(ah);
776 bool need_swap = false;
777 struct ar5416_eeprom *eep =
778 (struct ar5416_eeprom *) &ahp->ah_eeprom;
779
780 if (!ath9k_hw_use_flash(ah)) {
781 u16 magic, magic2;
782 int addr;
783
784 if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET,
785 &magic)) {
786 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
787 "%s: Reading Magic # failed\n", __func__);
788 return false;
789 }
790 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, "%s: Read Magic = 0x%04X\n",
791 __func__, magic);
792
793 if (magic != AR5416_EEPROM_MAGIC) {
794 magic2 = swab16(magic);
795
796 if (magic2 == AR5416_EEPROM_MAGIC) {
797 need_swap = true;
798 eepdata = (u16 *) (&ahp->ah_eeprom);
799
800 for (addr = 0;
801 addr <
802 sizeof(struct ar5416_eeprom) /
803 sizeof(u16); addr++) {
804 u16 temp;
805
806 temp = swab16(*eepdata);
807 *eepdata = temp;
808 eepdata++;
809
810 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
811 "0x%04X ", *eepdata);
812 if (((addr + 1) % 6) == 0)
813 DPRINTF(ah->ah_sc,
814 ATH_DBG_EEPROM,
815 "\n");
816 }
817 } else {
818 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
819 "Invalid EEPROM Magic. "
820 "endianness missmatch.\n");
821 return -EINVAL;
822 }
823 }
824 }
825 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, "need_swap = %s.\n",
826 need_swap ? "True" : "False");
827
828 if (need_swap)
829 el = swab16(ahp->ah_eeprom.baseEepHeader.length);
830 else
831 el = ahp->ah_eeprom.baseEepHeader.length;
832
833 if (el > sizeof(struct ar5416_eeprom))
834 el = sizeof(struct ar5416_eeprom) / sizeof(u16);
835 else
836 el = el / sizeof(u16);
837
838 eepdata = (u16 *) (&ahp->ah_eeprom);
839
840 for (i = 0; i < el; i++)
841 sum ^= *eepdata++;
842
843 if (need_swap) {
844 u32 integer, j;
845 u16 word;
846
847 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
848 "EEPROM Endianness is not native.. Changing \n");
849
850 word = swab16(eep->baseEepHeader.length);
851 eep->baseEepHeader.length = word;
852
853 word = swab16(eep->baseEepHeader.checksum);
854 eep->baseEepHeader.checksum = word;
855
856 word = swab16(eep->baseEepHeader.version);
857 eep->baseEepHeader.version = word;
858
859 word = swab16(eep->baseEepHeader.regDmn[0]);
860 eep->baseEepHeader.regDmn[0] = word;
861 303
862 word = swab16(eep->baseEepHeader.regDmn[1]); 304 REG_WRITE(ah, AR_PHY(0x36), 0x00007058);
863 eep->baseEepHeader.regDmn[1] = word;
864
865 word = swab16(eep->baseEepHeader.rfSilent);
866 eep->baseEepHeader.rfSilent = word;
867
868 word = swab16(eep->baseEepHeader.blueToothOptions);
869 eep->baseEepHeader.blueToothOptions = word;
870 305
871 word = swab16(eep->baseEepHeader.deviceCap); 306 for (i = 0; i < 8; i++)
872 eep->baseEepHeader.deviceCap = word; 307 REG_WRITE(ah, AR_PHY(0x20), 0x00010000);
308 val = (REG_READ(ah, AR_PHY(256)) >> 24) & 0xff;
309 val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4);
873 310
874 for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) { 311 return ath9k_hw_reverse_bits(val, 8);
875 struct modal_eep_header *pModal = 312}
876 &eep->modalHeader[j];
877 integer = swab32(pModal->antCtrlCommon);
878 pModal->antCtrlCommon = integer;
879 313
880 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 314/************************************/
881 integer = swab32(pModal->antCtrlChain[i]); 315/* HW Attach, Detach, Init Routines */
882 pModal->antCtrlChain[i] = integer; 316/************************************/
883 }
884 317
885 for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) { 318static void ath9k_hw_disablepcie(struct ath_hal *ah)
886 word = swab16(pModal->spurChans[i].spurChan); 319{
887 pModal->spurChans[i].spurChan = word; 320 if (!AR_SREV_9100(ah))
888 } 321 return;
889 }
890 }
891 322
892 if (sum != 0xffff || ar5416_get_eep_ver(ahp) != AR5416_EEP_VER || 323 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
893 ar5416_get_eep_rev(ahp) < AR5416_EEP_NO_BACK_VER) { 324 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
894 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 325 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029);
895 "Bad EEPROM checksum 0x%x or revision 0x%04x\n", 326 REG_WRITE(ah, AR_PCIE_SERDES, 0x57160824);
896 sum, ar5416_get_eep_ver(ahp)); 327 REG_WRITE(ah, AR_PCIE_SERDES, 0x25980579);
897 return -EINVAL; 328 REG_WRITE(ah, AR_PCIE_SERDES, 0x00000000);
898 } 329 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
330 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
331 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007);
899 332
900 return 0; 333 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
901} 334}
902 335
903static bool ath9k_hw_chip_test(struct ath_hal *ah) 336static bool ath9k_hw_chip_test(struct ath_hal *ah)
@@ -905,9 +338,9 @@ static bool ath9k_hw_chip_test(struct ath_hal *ah)
905 u32 regAddr[2] = { AR_STA_ID0, AR_PHY_BASE + (8 << 2) }; 338 u32 regAddr[2] = { AR_STA_ID0, AR_PHY_BASE + (8 << 2) };
906 u32 regHold[2]; 339 u32 regHold[2];
907 u32 patternData[4] = { 0x55555555, 340 u32 patternData[4] = { 0x55555555,
908 0xaaaaaaaa, 341 0xaaaaaaaa,
909 0x66666666, 342 0x66666666,
910 0x99999999 }; 343 0x99999999 };
911 int i, j; 344 int i, j;
912 345
913 for (i = 0; i < 2; i++) { 346 for (i = 0; i < 2; i++) {
@@ -921,9 +354,9 @@ static bool ath9k_hw_chip_test(struct ath_hal *ah)
921 rdData = REG_READ(ah, addr); 354 rdData = REG_READ(ah, addr);
922 if (rdData != wrData) { 355 if (rdData != wrData) {
923 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, 356 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
924 "%s: address test failed " 357 "%s: address test failed "
925 "addr: 0x%08x - wr:0x%08x != rd:0x%08x\n", 358 "addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
926 __func__, addr, wrData, rdData); 359 __func__, addr, wrData, rdData);
927 return false; 360 return false;
928 } 361 }
929 } 362 }
@@ -933,9 +366,9 @@ static bool ath9k_hw_chip_test(struct ath_hal *ah)
933 rdData = REG_READ(ah, addr); 366 rdData = REG_READ(ah, addr);
934 if (wrData != rdData) { 367 if (wrData != rdData) {
935 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, 368 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
936 "%s: address test failed " 369 "%s: address test failed "
937 "addr: 0x%08x - wr:0x%08x != rd:0x%08x\n", 370 "addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
938 __func__, addr, wrData, rdData); 371 __func__, addr, wrData, rdData);
939 return false; 372 return false;
940 } 373 }
941 } 374 }
@@ -945,213 +378,62 @@ static bool ath9k_hw_chip_test(struct ath_hal *ah)
945 return true; 378 return true;
946} 379}
947 380
948u32 ath9k_hw_getrxfilter(struct ath_hal *ah) 381static const char *ath9k_hw_devname(u16 devid)
949{
950 u32 bits = REG_READ(ah, AR_RX_FILTER);
951 u32 phybits = REG_READ(ah, AR_PHY_ERR);
952
953 if (phybits & AR_PHY_ERR_RADAR)
954 bits |= ATH9K_RX_FILTER_PHYRADAR;
955 if (phybits & (AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING))
956 bits |= ATH9K_RX_FILTER_PHYERR;
957 return bits;
958}
959
960void ath9k_hw_setrxfilter(struct ath_hal *ah, u32 bits)
961{
962 u32 phybits;
963
964 REG_WRITE(ah, AR_RX_FILTER, (bits & 0xffff) | AR_RX_COMPR_BAR);
965 phybits = 0;
966 if (bits & ATH9K_RX_FILTER_PHYRADAR)
967 phybits |= AR_PHY_ERR_RADAR;
968 if (bits & ATH9K_RX_FILTER_PHYERR)
969 phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
970 REG_WRITE(ah, AR_PHY_ERR, phybits);
971
972 if (phybits)
973 REG_WRITE(ah, AR_RXCFG,
974 REG_READ(ah, AR_RXCFG) | AR_RXCFG_ZLFDMA);
975 else
976 REG_WRITE(ah, AR_RXCFG,
977 REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_ZLFDMA);
978}
979
980bool ath9k_hw_setcapability(struct ath_hal *ah,
981 enum ath9k_capability_type type,
982 u32 capability,
983 u32 setting,
984 int *status)
985{
986 struct ath_hal_5416 *ahp = AH5416(ah);
987 u32 v;
988
989 switch (type) {
990 case ATH9K_CAP_TKIP_MIC:
991 if (setting)
992 ahp->ah_staId1Defaults |=
993 AR_STA_ID1_CRPT_MIC_ENABLE;
994 else
995 ahp->ah_staId1Defaults &=
996 ~AR_STA_ID1_CRPT_MIC_ENABLE;
997 return true;
998 case ATH9K_CAP_DIVERSITY:
999 v = REG_READ(ah, AR_PHY_CCK_DETECT);
1000 if (setting)
1001 v |= AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
1002 else
1003 v &= ~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
1004 REG_WRITE(ah, AR_PHY_CCK_DETECT, v);
1005 return true;
1006 case ATH9K_CAP_MCAST_KEYSRCH:
1007 if (setting)
1008 ahp->ah_staId1Defaults |= AR_STA_ID1_MCAST_KSRCH;
1009 else
1010 ahp->ah_staId1Defaults &= ~AR_STA_ID1_MCAST_KSRCH;
1011 return true;
1012 case ATH9K_CAP_TSF_ADJUST:
1013 if (setting)
1014 ahp->ah_miscMode |= AR_PCU_TX_ADD_TSF;
1015 else
1016 ahp->ah_miscMode &= ~AR_PCU_TX_ADD_TSF;
1017 return true;
1018 default:
1019 return false;
1020 }
1021}
1022
1023void ath9k_hw_dmaRegDump(struct ath_hal *ah)
1024{ 382{
1025 u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 383 switch (devid) {
1026 int qcuOffset = 0, dcuOffset = 0; 384 case AR5416_DEVID_PCI:
1027 u32 *qcuBase = &val[0], *dcuBase = &val[4]; 385 case AR5416_DEVID_PCIE:
1028 int i; 386 return "Atheros 5416";
1029 387 case AR9160_DEVID_PCI:
1030 REG_WRITE(ah, AR_MACMISC, 388 return "Atheros 9160";
1031 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 389 case AR9280_DEVID_PCI:
1032 (AR_MACMISC_MISC_OBS_BUS_1 << 390 case AR9280_DEVID_PCIE:
1033 AR_MACMISC_MISC_OBS_BUS_MSB_S))); 391 return "Atheros 9280";
1034
1035 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "Raw DMA Debug values:\n");
1036 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
1037 if (i % 4 == 0)
1038 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "\n");
1039
1040 val[i] = REG_READ(ah, AR_DMADBG_0 + (i * sizeof(u32)));
1041 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "%d: %08x ", i, val[i]);
1042 }
1043
1044 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "\n\n");
1045 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1046 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
1047
1048 for (i = 0; i < ATH9K_NUM_QUEUES;
1049 i++, qcuOffset += 4, dcuOffset += 5) {
1050 if (i == 8) {
1051 qcuOffset = 0;
1052 qcuBase++;
1053 }
1054
1055 if (i == 6) {
1056 dcuOffset = 0;
1057 dcuBase++;
1058 }
1059
1060 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1061 "%2d %2x %1x %2x %2x\n",
1062 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
1063 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset +
1064 3),
1065 val[2] & (0x7 << (i * 3)) >> (i * 3),
1066 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
1067 } 392 }
1068 393
1069 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "\n"); 394 return NULL;
1070 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1071 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
1072 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
1073 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1074 "qcu_complete state: %2x dcu_complete state: %2x\n",
1075 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
1076 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1077 "dcu_arb state: %2x dcu_fp state: %2x\n",
1078 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
1079 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1080 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
1081 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
1082 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1083 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
1084 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
1085 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1086 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
1087 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
1088
1089 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "pcu observe 0x%x \n",
1090 REG_READ(ah, AR_OBS_BUS_1));
1091 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
1092 "AR_CR 0x%x \n", REG_READ(ah, AR_CR));
1093} 395}
1094 396
1095u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hal *ah, 397static void ath9k_hw_set_defaults(struct ath_hal *ah)
1096 u32 *rxc_pcnt,
1097 u32 *rxf_pcnt,
1098 u32 *txf_pcnt)
1099{ 398{
1100 static u32 cycles, rx_clear, rx_frame, tx_frame; 399 int i;
1101 u32 good = 1;
1102 400
1103 u32 rc = REG_READ(ah, AR_RCCNT); 401 ah->ah_config.dma_beacon_response_time = 2;
1104 u32 rf = REG_READ(ah, AR_RFCNT); 402 ah->ah_config.sw_beacon_response_time = 10;
1105 u32 tf = REG_READ(ah, AR_TFCNT); 403 ah->ah_config.additional_swba_backoff = 0;
1106 u32 cc = REG_READ(ah, AR_CCCNT); 404 ah->ah_config.ack_6mb = 0x0;
405 ah->ah_config.cwm_ignore_extcca = 0;
406 ah->ah_config.pcie_powersave_enable = 0;
407 ah->ah_config.pcie_l1skp_enable = 0;
408 ah->ah_config.pcie_clock_req = 0;
409 ah->ah_config.pcie_power_reset = 0x100;
410 ah->ah_config.pcie_restore = 0;
411 ah->ah_config.pcie_waen = 0;
412 ah->ah_config.analog_shiftreg = 1;
413 ah->ah_config.ht_enable = 1;
414 ah->ah_config.ofdm_trig_low = 200;
415 ah->ah_config.ofdm_trig_high = 500;
416 ah->ah_config.cck_trig_high = 200;
417 ah->ah_config.cck_trig_low = 100;
418 ah->ah_config.enable_ani = 1;
419 ah->ah_config.noise_immunity_level = 4;
420 ah->ah_config.ofdm_weaksignal_det = 1;
421 ah->ah_config.cck_weaksignal_thr = 0;
422 ah->ah_config.spur_immunity_level = 2;
423 ah->ah_config.firstep_level = 0;
424 ah->ah_config.rssi_thr_high = 40;
425 ah->ah_config.rssi_thr_low = 7;
426 ah->ah_config.diversity_control = 0;
427 ah->ah_config.antenna_switch_swap = 0;
1107 428
1108 if (cycles == 0 || cycles > cc) { 429 for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
1109 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, 430 ah->ah_config.spurchans[i][0] = AR_NO_SPUR;
1110 "%s: cycle counter wrap. ExtBusy = 0\n", 431 ah->ah_config.spurchans[i][1] = AR_NO_SPUR;
1111 __func__);
1112 good = 0;
1113 } else {
1114 u32 cc_d = cc - cycles;
1115 u32 rc_d = rc - rx_clear;
1116 u32 rf_d = rf - rx_frame;
1117 u32 tf_d = tf - tx_frame;
1118
1119 if (cc_d != 0) {
1120 *rxc_pcnt = rc_d * 100 / cc_d;
1121 *rxf_pcnt = rf_d * 100 / cc_d;
1122 *txf_pcnt = tf_d * 100 / cc_d;
1123 } else {
1124 good = 0;
1125 }
1126 } 432 }
1127 433
1128 cycles = cc; 434 ah->ah_config.intr_mitigation = 1;
1129 rx_frame = rf;
1130 rx_clear = rc;
1131 tx_frame = tf;
1132
1133 return good;
1134}
1135
1136void ath9k_hw_set11nmac2040(struct ath_hal *ah, enum ath9k_ht_macmode mode)
1137{
1138 u32 macmode;
1139
1140 if (mode == ATH9K_HT_MACMODE_2040 &&
1141 !ah->ah_config.cwm_ignore_extcca)
1142 macmode = AR_2040_JOINED_RX_CLEAR;
1143 else
1144 macmode = 0;
1145
1146 REG_WRITE(ah, AR_2040_MODE, macmode);
1147}
1148
1149static void ath9k_hw_mark_phy_inactive(struct ath_hal *ah)
1150{
1151 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
1152} 435}
1153 436
1154
1155static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid, 437static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
1156 struct ath_softc *sc, 438 struct ath_softc *sc,
1157 void __iomem *mem, 439 void __iomem *mem,
@@ -1165,20 +447,17 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
1165 ahp = kzalloc(sizeof(struct ath_hal_5416), GFP_KERNEL); 447 ahp = kzalloc(sizeof(struct ath_hal_5416), GFP_KERNEL);
1166 if (ahp == NULL) { 448 if (ahp == NULL) {
1167 DPRINTF(sc, ATH_DBG_FATAL, 449 DPRINTF(sc, ATH_DBG_FATAL,
1168 "%s: cannot allocate memory for state block\n", 450 "%s: cannot allocate memory for state block\n",
1169 __func__); 451 __func__);
1170 *status = -ENOMEM; 452 *status = -ENOMEM;
1171 return NULL; 453 return NULL;
1172 } 454 }
1173 455
1174 ah = &ahp->ah; 456 ah = &ahp->ah;
1175
1176 ah->ah_sc = sc; 457 ah->ah_sc = sc;
1177 ah->ah_sh = mem; 458 ah->ah_sh = mem;
1178
1179 ah->ah_magic = AR5416_MAGIC; 459 ah->ah_magic = AR5416_MAGIC;
1180 ah->ah_countryCode = CTRY_DEFAULT; 460 ah->ah_countryCode = CTRY_DEFAULT;
1181
1182 ah->ah_devid = devid; 461 ah->ah_devid = devid;
1183 ah->ah_subvendorid = 0; 462 ah->ah_subvendorid = 0;
1184 463
@@ -1190,12 +469,10 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
1190 469
1191 ah->ah_powerLimit = MAX_RATE_POWER; 470 ah->ah_powerLimit = MAX_RATE_POWER;
1192 ah->ah_tpScale = ATH9K_TP_SCALE_MAX; 471 ah->ah_tpScale = ATH9K_TP_SCALE_MAX;
1193
1194 ahp->ah_atimWindow = 0; 472 ahp->ah_atimWindow = 0;
1195 ahp->ah_diversityControl = ah->ah_config.diversity_control; 473 ahp->ah_diversityControl = ah->ah_config.diversity_control;
1196 ahp->ah_antennaSwitchSwap = 474 ahp->ah_antennaSwitchSwap =
1197 ah->ah_config.antenna_switch_swap; 475 ah->ah_config.antenna_switch_swap;
1198
1199 ahp->ah_staId1Defaults = AR_STA_ID1_CRPT_MIC_ENABLE; 476 ahp->ah_staId1Defaults = AR_STA_ID1_CRPT_MIC_ENABLE;
1200 ahp->ah_beaconInterval = 100; 477 ahp->ah_beaconInterval = 100;
1201 ahp->ah_enable32kHzClock = DONT_USE_32KHZ; 478 ahp->ah_enable32kHzClock = DONT_USE_32KHZ;
@@ -1210,163 +487,6 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
1210 return ahp; 487 return ahp;
1211} 488}
1212 489
1213static int ath9k_hw_eeprom_attach(struct ath_hal *ah)
1214{
1215 int status;
1216
1217 if (ath9k_hw_use_flash(ah))
1218 ath9k_hw_flash_map(ah);
1219
1220 if (!ath9k_hw_fill_eeprom(ah))
1221 return -EIO;
1222
1223 status = ath9k_hw_check_eeprom(ah);
1224
1225 return status;
1226}
1227
1228u32 ath9k_hw_get_eeprom(struct ath_hal_5416 *ahp,
1229 enum eeprom_param param)
1230{
1231 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
1232 struct modal_eep_header *pModal = eep->modalHeader;
1233 struct base_eep_header *pBase = &eep->baseEepHeader;
1234
1235 switch (param) {
1236 case EEP_NFTHRESH_5:
1237 return -pModal[0].noiseFloorThreshCh[0];
1238 case EEP_NFTHRESH_2:
1239 return -pModal[1].noiseFloorThreshCh[0];
1240 case AR_EEPROM_MAC(0):
1241 return pBase->macAddr[0] << 8 | pBase->macAddr[1];
1242 case AR_EEPROM_MAC(1):
1243 return pBase->macAddr[2] << 8 | pBase->macAddr[3];
1244 case AR_EEPROM_MAC(2):
1245 return pBase->macAddr[4] << 8 | pBase->macAddr[5];
1246 case EEP_REG_0:
1247 return pBase->regDmn[0];
1248 case EEP_REG_1:
1249 return pBase->regDmn[1];
1250 case EEP_OP_CAP:
1251 return pBase->deviceCap;
1252 case EEP_OP_MODE:
1253 return pBase->opCapFlags;
1254 case EEP_RF_SILENT:
1255 return pBase->rfSilent;
1256 case EEP_OB_5:
1257 return pModal[0].ob;
1258 case EEP_DB_5:
1259 return pModal[0].db;
1260 case EEP_OB_2:
1261 return pModal[1].ob;
1262 case EEP_DB_2:
1263 return pModal[1].db;
1264 case EEP_MINOR_REV:
1265 return pBase->version & AR5416_EEP_VER_MINOR_MASK;
1266 case EEP_TX_MASK:
1267 return pBase->txMask;
1268 case EEP_RX_MASK:
1269 return pBase->rxMask;
1270 default:
1271 return 0;
1272 }
1273}
1274
1275static int ath9k_hw_get_radiorev(struct ath_hal *ah)
1276{
1277 u32 val;
1278 int i;
1279
1280 REG_WRITE(ah, AR_PHY(0x36), 0x00007058);
1281 for (i = 0; i < 8; i++)
1282 REG_WRITE(ah, AR_PHY(0x20), 0x00010000);
1283 val = (REG_READ(ah, AR_PHY(256)) >> 24) & 0xff;
1284 val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4);
1285 return ath9k_hw_reverse_bits(val, 8);
1286}
1287
1288static int ath9k_hw_init_macaddr(struct ath_hal *ah)
1289{
1290 u32 sum;
1291 int i;
1292 u16 eeval;
1293 struct ath_hal_5416 *ahp = AH5416(ah);
1294 DECLARE_MAC_BUF(mac);
1295
1296 sum = 0;
1297 for (i = 0; i < 3; i++) {
1298 eeval = ath9k_hw_get_eeprom(ahp, AR_EEPROM_MAC(i));
1299 sum += eeval;
1300 ahp->ah_macaddr[2 * i] = eeval >> 8;
1301 ahp->ah_macaddr[2 * i + 1] = eeval & 0xff;
1302 }
1303 if (sum == 0 || sum == 0xffff * 3) {
1304 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
1305 "%s: mac address read failed: %s\n", __func__,
1306 print_mac(mac, ahp->ah_macaddr));
1307 return -EADDRNOTAVAIL;
1308 }
1309
1310 return 0;
1311}
1312
1313static inline int16_t ath9k_hw_interpolate(u16 target,
1314 u16 srcLeft,
1315 u16 srcRight,
1316 int16_t targetLeft,
1317 int16_t targetRight)
1318{
1319 int16_t rv;
1320
1321 if (srcRight == srcLeft) {
1322 rv = targetLeft;
1323 } else {
1324 rv = (int16_t) (((target - srcLeft) * targetRight +
1325 (srcRight - target) * targetLeft) /
1326 (srcRight - srcLeft));
1327 }
1328 return rv;
1329}
1330
1331static inline u16 ath9k_hw_fbin2freq(u8 fbin,
1332 bool is2GHz)
1333{
1334
1335 if (fbin == AR5416_BCHAN_UNUSED)
1336 return fbin;
1337
1338 return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
1339}
1340
1341static u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah,
1342 u16 i,
1343 bool is2GHz)
1344{
1345 struct ath_hal_5416 *ahp = AH5416(ah);
1346 struct ar5416_eeprom *eep =
1347 (struct ar5416_eeprom *) &ahp->ah_eeprom;
1348 u16 spur_val = AR_NO_SPUR;
1349
1350 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
1351 "Getting spur idx %d is2Ghz. %d val %x\n",
1352 i, is2GHz, ah->ah_config.spurchans[i][is2GHz]);
1353
1354 switch (ah->ah_config.spurmode) {
1355 case SPUR_DISABLE:
1356 break;
1357 case SPUR_ENABLE_IOCTL:
1358 spur_val = ah->ah_config.spurchans[i][is2GHz];
1359 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
1360 "Getting spur val from new loc. %d\n", spur_val);
1361 break;
1362 case SPUR_ENABLE_EEPROM:
1363 spur_val = eep->modalHeader[is2GHz].spurChans[i].spurChan;
1364 break;
1365
1366 }
1367 return spur_val;
1368}
1369
1370static int ath9k_hw_rfattach(struct ath_hal *ah) 490static int ath9k_hw_rfattach(struct ath_hal *ah)
1371{ 491{
1372 bool rfStatus = false; 492 bool rfStatus = false;
@@ -1375,8 +495,8 @@ static int ath9k_hw_rfattach(struct ath_hal *ah)
1375 rfStatus = ath9k_hw_init_rf(ah, &ecode); 495 rfStatus = ath9k_hw_init_rf(ah, &ecode);
1376 if (!rfStatus) { 496 if (!rfStatus) {
1377 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 497 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
1378 "%s: RF setup failed, status %u\n", __func__, 498 "%s: RF setup failed, status %u\n", __func__,
1379 ecode); 499 ecode);
1380 return ecode; 500 return ecode;
1381 } 501 }
1382 502
@@ -1401,9 +521,9 @@ static int ath9k_hw_rf_claim(struct ath_hal *ah)
1401 break; 521 break;
1402 default: 522 default:
1403 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, 523 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1404 "%s: 5G Radio Chip Rev 0x%02X is not " 524 "%s: 5G Radio Chip Rev 0x%02X is not "
1405 "supported by this driver\n", 525 "supported by this driver\n",
1406 __func__, ah->ah_analog5GhzRev); 526 __func__, ah->ah_analog5GhzRev);
1407 return -EOPNOTSUPP; 527 return -EOPNOTSUPP;
1408 } 528 }
1409 529
@@ -1412,1482 +532,37 @@ static int ath9k_hw_rf_claim(struct ath_hal *ah)
1412 return 0; 532 return 0;
1413} 533}
1414 534
1415static void ath9k_hw_init_pll(struct ath_hal *ah, 535static int ath9k_hw_init_macaddr(struct ath_hal *ah)
1416 struct ath9k_channel *chan)
1417{
1418 u32 pll;
1419
1420 if (AR_SREV_9100(ah)) {
1421 if (chan && IS_CHAN_5GHZ(chan))
1422 pll = 0x1450;
1423 else
1424 pll = 0x1458;
1425 } else {
1426 if (AR_SREV_9280_10_OR_LATER(ah)) {
1427 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
1428
1429 if (chan && IS_CHAN_HALF_RATE(chan))
1430 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
1431 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1432 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
1433
1434 if (chan && IS_CHAN_5GHZ(chan)) {
1435 pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
1436
1437
1438 if (AR_SREV_9280_20(ah)) {
1439 if (((chan->channel % 20) == 0)
1440 || ((chan->channel % 10) == 0))
1441 pll = 0x2850;
1442 else
1443 pll = 0x142c;
1444 }
1445 } else {
1446 pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
1447 }
1448
1449 } else if (AR_SREV_9160_10_OR_LATER(ah)) {
1450
1451 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
1452
1453 if (chan && IS_CHAN_HALF_RATE(chan))
1454 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
1455 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1456 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
1457
1458 if (chan && IS_CHAN_5GHZ(chan))
1459 pll |= SM(0x50, AR_RTC_9160_PLL_DIV);
1460 else
1461 pll |= SM(0x58, AR_RTC_9160_PLL_DIV);
1462 } else {
1463 pll = AR_RTC_PLL_REFDIV_5 | AR_RTC_PLL_DIV2;
1464
1465 if (chan && IS_CHAN_HALF_RATE(chan))
1466 pll |= SM(0x1, AR_RTC_PLL_CLKSEL);
1467 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1468 pll |= SM(0x2, AR_RTC_PLL_CLKSEL);
1469
1470 if (chan && IS_CHAN_5GHZ(chan))
1471 pll |= SM(0xa, AR_RTC_PLL_DIV);
1472 else
1473 pll |= SM(0xb, AR_RTC_PLL_DIV);
1474 }
1475 }
1476 REG_WRITE(ah, (u16) (AR_RTC_PLL_CONTROL), pll);
1477
1478 udelay(RTC_PLL_SETTLE_DELAY);
1479
1480 REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK);
1481}
1482
1483static void ath9k_hw_set_regs(struct ath_hal *ah, struct ath9k_channel *chan,
1484 enum ath9k_ht_macmode macmode)
1485{
1486 u32 phymode;
1487 struct ath_hal_5416 *ahp = AH5416(ah);
1488
1489 phymode = AR_PHY_FC_HT_EN | AR_PHY_FC_SHORT_GI_40
1490 | AR_PHY_FC_SINGLE_HT_LTF1 | AR_PHY_FC_WALSH;
1491
1492 if (IS_CHAN_HT40(chan)) {
1493 phymode |= AR_PHY_FC_DYN2040_EN;
1494
1495 if ((chan->chanmode == CHANNEL_A_HT40PLUS) ||
1496 (chan->chanmode == CHANNEL_G_HT40PLUS))
1497 phymode |= AR_PHY_FC_DYN2040_PRI_CH;
1498
1499 if (ahp->ah_extprotspacing == ATH9K_HT_EXTPROTSPACING_25)
1500 phymode |= AR_PHY_FC_DYN2040_EXT_CH;
1501 }
1502 REG_WRITE(ah, AR_PHY_TURBO, phymode);
1503
1504 ath9k_hw_set11nmac2040(ah, macmode);
1505
1506 REG_WRITE(ah, AR_GTXTO, 25 << AR_GTXTO_TIMEOUT_LIMIT_S);
1507 REG_WRITE(ah, AR_CST, 0xF << AR_CST_TIMEOUT_LIMIT_S);
1508}
1509
1510static void ath9k_hw_set_operating_mode(struct ath_hal *ah, int opmode)
1511{
1512 u32 val;
1513
1514 val = REG_READ(ah, AR_STA_ID1);
1515 val &= ~(AR_STA_ID1_STA_AP | AR_STA_ID1_ADHOC);
1516 switch (opmode) {
1517 case ATH9K_M_HOSTAP:
1518 REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_STA_AP
1519 | AR_STA_ID1_KSRCH_MODE);
1520 REG_CLR_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
1521 break;
1522 case ATH9K_M_IBSS:
1523 REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_ADHOC
1524 | AR_STA_ID1_KSRCH_MODE);
1525 REG_SET_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
1526 break;
1527 case ATH9K_M_STA:
1528 case ATH9K_M_MONITOR:
1529 REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_KSRCH_MODE);
1530 break;
1531 }
1532}
1533
1534static void
1535ath9k_hw_set_rfmode(struct ath_hal *ah, struct ath9k_channel *chan)
1536{
1537 u32 rfMode = 0;
1538
1539 if (chan == NULL)
1540 return;
1541
1542 rfMode |= (IS_CHAN_B(chan) || IS_CHAN_G(chan))
1543 ? AR_PHY_MODE_DYNAMIC : AR_PHY_MODE_OFDM;
1544
1545 if (!AR_SREV_9280_10_OR_LATER(ah))
1546 rfMode |= (IS_CHAN_5GHZ(chan)) ? AR_PHY_MODE_RF5GHZ :
1547 AR_PHY_MODE_RF2GHZ;
1548
1549 if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan))
1550 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
1551
1552 REG_WRITE(ah, AR_PHY_MODE, rfMode);
1553}
1554
1555static bool ath9k_hw_set_reset(struct ath_hal *ah, int type)
1556{
1557 u32 rst_flags;
1558 u32 tmpReg;
1559
1560 REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN |
1561 AR_RTC_FORCE_WAKE_ON_INT);
1562
1563 if (AR_SREV_9100(ah)) {
1564 rst_flags = AR_RTC_RC_MAC_WARM | AR_RTC_RC_MAC_COLD |
1565 AR_RTC_RC_COLD_RESET | AR_RTC_RC_WARM_RESET;
1566 } else {
1567 tmpReg = REG_READ(ah, AR_INTR_SYNC_CAUSE);
1568 if (tmpReg &
1569 (AR_INTR_SYNC_LOCAL_TIMEOUT |
1570 AR_INTR_SYNC_RADM_CPL_TIMEOUT)) {
1571 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
1572 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
1573 } else {
1574 REG_WRITE(ah, AR_RC, AR_RC_AHB);
1575 }
1576
1577 rst_flags = AR_RTC_RC_MAC_WARM;
1578 if (type == ATH9K_RESET_COLD)
1579 rst_flags |= AR_RTC_RC_MAC_COLD;
1580 }
1581
1582 REG_WRITE(ah, (u16) (AR_RTC_RC), rst_flags);
1583 udelay(50);
1584
1585 REG_WRITE(ah, (u16) (AR_RTC_RC), 0);
1586 if (!ath9k_hw_wait(ah, (u16) (AR_RTC_RC), AR_RTC_RC_M, 0)) {
1587 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
1588 "%s: RTC stuck in MAC reset\n",
1589 __func__);
1590 return false;
1591 }
1592
1593 if (!AR_SREV_9100(ah))
1594 REG_WRITE(ah, AR_RC, 0);
1595
1596 ath9k_hw_init_pll(ah, NULL);
1597
1598 if (AR_SREV_9100(ah))
1599 udelay(50);
1600
1601 return true;
1602}
1603
1604static bool ath9k_hw_set_reset_power_on(struct ath_hal *ah)
1605{
1606 REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN |
1607 AR_RTC_FORCE_WAKE_ON_INT);
1608
1609 REG_WRITE(ah, (u16) (AR_RTC_RESET), 0);
1610 REG_WRITE(ah, (u16) (AR_RTC_RESET), 1);
1611
1612 if (!ath9k_hw_wait(ah,
1613 AR_RTC_STATUS,
1614 AR_RTC_STATUS_M,
1615 AR_RTC_STATUS_ON)) {
1616 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: RTC not waking up\n",
1617 __func__);
1618 return false;
1619 }
1620
1621 ath9k_hw_read_revisions(ah);
1622
1623 return ath9k_hw_set_reset(ah, ATH9K_RESET_WARM);
1624}
1625
1626static bool ath9k_hw_set_reset_reg(struct ath_hal *ah,
1627 u32 type)
1628{
1629 REG_WRITE(ah, AR_RTC_FORCE_WAKE,
1630 AR_RTC_FORCE_WAKE_EN | AR_RTC_FORCE_WAKE_ON_INT);
1631
1632 switch (type) {
1633 case ATH9K_RESET_POWER_ON:
1634 return ath9k_hw_set_reset_power_on(ah);
1635 break;
1636 case ATH9K_RESET_WARM:
1637 case ATH9K_RESET_COLD:
1638 return ath9k_hw_set_reset(ah, type);
1639 break;
1640 default:
1641 return false;
1642 }
1643}
1644
1645static
1646struct ath9k_channel *ath9k_hw_check_chan(struct ath_hal *ah,
1647 struct ath9k_channel *chan)
1648{
1649 if (!(IS_CHAN_2GHZ(chan) ^ IS_CHAN_5GHZ(chan))) {
1650 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1651 "%s: invalid channel %u/0x%x; not marked as "
1652 "2GHz or 5GHz\n", __func__, chan->channel,
1653 chan->channelFlags);
1654 return NULL;
1655 }
1656
1657 if (!IS_CHAN_OFDM(chan) &&
1658 !IS_CHAN_CCK(chan) &&
1659 !IS_CHAN_HT20(chan) &&
1660 !IS_CHAN_HT40(chan)) {
1661 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1662 "%s: invalid channel %u/0x%x; not marked as "
1663 "OFDM or CCK or HT20 or HT40PLUS or HT40MINUS\n",
1664 __func__, chan->channel, chan->channelFlags);
1665 return NULL;
1666 }
1667
1668 return ath9k_regd_check_channel(ah, chan);
1669}
1670
1671static inline bool
1672ath9k_hw_get_lower_upper_index(u8 target,
1673 u8 *pList,
1674 u16 listSize,
1675 u16 *indexL,
1676 u16 *indexR)
1677{
1678 u16 i;
1679
1680 if (target <= pList[0]) {
1681 *indexL = *indexR = 0;
1682 return true;
1683 }
1684 if (target >= pList[listSize - 1]) {
1685 *indexL = *indexR = (u16) (listSize - 1);
1686 return true;
1687 }
1688
1689 for (i = 0; i < listSize - 1; i++) {
1690 if (pList[i] == target) {
1691 *indexL = *indexR = i;
1692 return true;
1693 }
1694 if (target < pList[i + 1]) {
1695 *indexL = i;
1696 *indexR = (u16) (i + 1);
1697 return false;
1698 }
1699 }
1700 return false;
1701}
1702
1703static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
1704{
1705 int16_t nfval;
1706 int16_t sort[ATH9K_NF_CAL_HIST_MAX];
1707 int i, j;
1708
1709 for (i = 0; i < ATH9K_NF_CAL_HIST_MAX; i++)
1710 sort[i] = nfCalBuffer[i];
1711
1712 for (i = 0; i < ATH9K_NF_CAL_HIST_MAX - 1; i++) {
1713 for (j = 1; j < ATH9K_NF_CAL_HIST_MAX - i; j++) {
1714 if (sort[j] > sort[j - 1]) {
1715 nfval = sort[j];
1716 sort[j] = sort[j - 1];
1717 sort[j - 1] = nfval;
1718 }
1719 }
1720 }
1721 nfval = sort[(ATH9K_NF_CAL_HIST_MAX - 1) >> 1];
1722
1723 return nfval;
1724}
1725
1726static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h,
1727 int16_t *nfarray)
1728{ 536{
537 u32 sum;
1729 int i; 538 int i;
1730 539 u16 eeval;
1731 for (i = 0; i < NUM_NF_READINGS; i++) {
1732 h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
1733
1734 if (++h[i].currIndex >= ATH9K_NF_CAL_HIST_MAX)
1735 h[i].currIndex = 0;
1736
1737 if (h[i].invalidNFcount > 0) {
1738 if (nfarray[i] < AR_PHY_CCA_MIN_BAD_VALUE
1739 || nfarray[i] > AR_PHY_CCA_MAX_HIGH_VALUE) {
1740 h[i].invalidNFcount = ATH9K_NF_CAL_HIST_MAX;
1741 } else {
1742 h[i].invalidNFcount--;
1743 h[i].privNF = nfarray[i];
1744 }
1745 } else {
1746 h[i].privNF =
1747 ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer);
1748 }
1749 }
1750 return;
1751}
1752
1753static void ar5416GetNoiseFloor(struct ath_hal *ah,
1754 int16_t nfarray[NUM_NF_READINGS])
1755{
1756 int16_t nf;
1757
1758 if (AR_SREV_9280_10_OR_LATER(ah))
1759 nf = MS(REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR);
1760 else
1761 nf = MS(REG_READ(ah, AR_PHY_CCA), AR_PHY_MINCCA_PWR);
1762
1763 if (nf & 0x100)
1764 nf = 0 - ((nf ^ 0x1ff) + 1);
1765 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
1766 "NF calibrated [ctl] [chain 0] is %d\n", nf);
1767 nfarray[0] = nf;
1768
1769 if (AR_SREV_9280_10_OR_LATER(ah))
1770 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
1771 AR9280_PHY_CH1_MINCCA_PWR);
1772 else
1773 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
1774 AR_PHY_CH1_MINCCA_PWR);
1775
1776 if (nf & 0x100)
1777 nf = 0 - ((nf ^ 0x1ff) + 1);
1778 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
1779 "NF calibrated [ctl] [chain 1] is %d\n", nf);
1780 nfarray[1] = nf;
1781
1782 if (!AR_SREV_9280(ah)) {
1783 nf = MS(REG_READ(ah, AR_PHY_CH2_CCA),
1784 AR_PHY_CH2_MINCCA_PWR);
1785 if (nf & 0x100)
1786 nf = 0 - ((nf ^ 0x1ff) + 1);
1787 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
1788 "NF calibrated [ctl] [chain 2] is %d\n", nf);
1789 nfarray[2] = nf;
1790 }
1791
1792 if (AR_SREV_9280_10_OR_LATER(ah))
1793 nf = MS(REG_READ(ah, AR_PHY_EXT_CCA),
1794 AR9280_PHY_EXT_MINCCA_PWR);
1795 else
1796 nf = MS(REG_READ(ah, AR_PHY_EXT_CCA),
1797 AR_PHY_EXT_MINCCA_PWR);
1798
1799 if (nf & 0x100)
1800 nf = 0 - ((nf ^ 0x1ff) + 1);
1801 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
1802 "NF calibrated [ext] [chain 0] is %d\n", nf);
1803 nfarray[3] = nf;
1804
1805 if (AR_SREV_9280_10_OR_LATER(ah))
1806 nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA),
1807 AR9280_PHY_CH1_EXT_MINCCA_PWR);
1808 else
1809 nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA),
1810 AR_PHY_CH1_EXT_MINCCA_PWR);
1811
1812 if (nf & 0x100)
1813 nf = 0 - ((nf ^ 0x1ff) + 1);
1814 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
1815 "NF calibrated [ext] [chain 1] is %d\n", nf);
1816 nfarray[4] = nf;
1817
1818 if (!AR_SREV_9280(ah)) {
1819 nf = MS(REG_READ(ah, AR_PHY_CH2_EXT_CCA),
1820 AR_PHY_CH2_EXT_MINCCA_PWR);
1821 if (nf & 0x100)
1822 nf = 0 - ((nf ^ 0x1ff) + 1);
1823 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
1824 "NF calibrated [ext] [chain 2] is %d\n", nf);
1825 nfarray[5] = nf;
1826 }
1827}
1828
1829static bool
1830getNoiseFloorThresh(struct ath_hal *ah,
1831 const struct ath9k_channel *chan,
1832 int16_t *nft)
1833{
1834 struct ath_hal_5416 *ahp = AH5416(ah); 540 struct ath_hal_5416 *ahp = AH5416(ah);
1835 541
1836 switch (chan->chanmode) { 542 sum = 0;
1837 case CHANNEL_A: 543 for (i = 0; i < 3; i++) {
1838 case CHANNEL_A_HT20: 544 eeval = ath9k_hw_get_eeprom(ah, AR_EEPROM_MAC(i));
1839 case CHANNEL_A_HT40PLUS: 545 sum += eeval;
1840 case CHANNEL_A_HT40MINUS: 546 ahp->ah_macaddr[2 * i] = eeval >> 8;
1841 *nft = (int16_t) ath9k_hw_get_eeprom(ahp, EEP_NFTHRESH_5); 547 ahp->ah_macaddr[2 * i + 1] = eeval & 0xff;
1842 break;
1843 case CHANNEL_B:
1844 case CHANNEL_G:
1845 case CHANNEL_G_HT20:
1846 case CHANNEL_G_HT40PLUS:
1847 case CHANNEL_G_HT40MINUS:
1848 *nft = (int16_t) ath9k_hw_get_eeprom(ahp, EEP_NFTHRESH_2);
1849 break;
1850 default:
1851 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1852 "%s: invalid channel flags 0x%x\n", __func__,
1853 chan->channelFlags);
1854 return false;
1855 }
1856 return true;
1857}
1858
1859static void ath9k_hw_start_nfcal(struct ath_hal *ah)
1860{
1861 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
1862 AR_PHY_AGC_CONTROL_ENABLE_NF);
1863 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
1864 AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
1865 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
1866}
1867
1868static void
1869ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan)
1870{
1871 struct ath9k_nfcal_hist *h;
1872 int i, j;
1873 int32_t val;
1874 const u32 ar5416_cca_regs[6] = {
1875 AR_PHY_CCA,
1876 AR_PHY_CH1_CCA,
1877 AR_PHY_CH2_CCA,
1878 AR_PHY_EXT_CCA,
1879 AR_PHY_CH1_EXT_CCA,
1880 AR_PHY_CH2_EXT_CCA
1881 };
1882 u8 chainmask;
1883
1884 if (AR_SREV_9280(ah))
1885 chainmask = 0x1B;
1886 else
1887 chainmask = 0x3F;
1888
1889#ifdef ATH_NF_PER_CHAN
1890 h = chan->nfCalHist;
1891#else
1892 h = ah->nfCalHist;
1893#endif
1894
1895 for (i = 0; i < NUM_NF_READINGS; i++) {
1896 if (chainmask & (1 << i)) {
1897 val = REG_READ(ah, ar5416_cca_regs[i]);
1898 val &= 0xFFFFFE00;
1899 val |= (((u32) (h[i].privNF) << 1) & 0x1ff);
1900 REG_WRITE(ah, ar5416_cca_regs[i], val);
1901 }
1902 }
1903
1904 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
1905 AR_PHY_AGC_CONTROL_ENABLE_NF);
1906 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
1907 AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
1908 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
1909
1910 for (j = 0; j < 1000; j++) {
1911 if ((REG_READ(ah, AR_PHY_AGC_CONTROL) &
1912 AR_PHY_AGC_CONTROL_NF) == 0)
1913 break;
1914 udelay(10);
1915 }
1916
1917 for (i = 0; i < NUM_NF_READINGS; i++) {
1918 if (chainmask & (1 << i)) {
1919 val = REG_READ(ah, ar5416_cca_regs[i]);
1920 val &= 0xFFFFFE00;
1921 val |= (((u32) (-50) << 1) & 0x1ff);
1922 REG_WRITE(ah, ar5416_cca_regs[i], val);
1923 }
1924 }
1925}
1926
1927static int16_t ath9k_hw_getnf(struct ath_hal *ah,
1928 struct ath9k_channel *chan)
1929{
1930 int16_t nf, nfThresh;
1931 int16_t nfarray[NUM_NF_READINGS] = { 0 };
1932 struct ath9k_nfcal_hist *h;
1933 u8 chainmask;
1934
1935 if (AR_SREV_9280(ah))
1936 chainmask = 0x1B;
1937 else
1938 chainmask = 0x3F;
1939
1940 chan->channelFlags &= (~CHANNEL_CW_INT);
1941 if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) {
1942 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
1943 "%s: NF did not complete in calibration window\n",
1944 __func__);
1945 nf = 0;
1946 chan->rawNoiseFloor = nf;
1947 return chan->rawNoiseFloor;
1948 } else {
1949 ar5416GetNoiseFloor(ah, nfarray);
1950 nf = nfarray[0];
1951 if (getNoiseFloorThresh(ah, chan, &nfThresh)
1952 && nf > nfThresh) {
1953 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
1954 "%s: noise floor failed detected; "
1955 "detected %d, threshold %d\n", __func__,
1956 nf, nfThresh);
1957 chan->channelFlags |= CHANNEL_CW_INT;
1958 }
1959 } 548 }
1960 549 if (sum == 0 || sum == 0xffff * 3) {
1961#ifdef ATH_NF_PER_CHAN 550 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
1962 h = chan->nfCalHist; 551 "%s: mac address read failed: %pM\n", __func__,
1963#else 552 ahp->ah_macaddr);
1964 h = ah->nfCalHist; 553 return -EADDRNOTAVAIL;
1965#endif
1966
1967 ath9k_hw_update_nfcal_hist_buffer(h, nfarray);
1968 chan->rawNoiseFloor = h[0].privNF;
1969
1970 return chan->rawNoiseFloor;
1971}
1972
1973static void ath9k_hw_update_mibstats(struct ath_hal *ah,
1974 struct ath9k_mib_stats *stats)
1975{
1976 stats->ackrcv_bad += REG_READ(ah, AR_ACK_FAIL);
1977 stats->rts_bad += REG_READ(ah, AR_RTS_FAIL);
1978 stats->fcs_bad += REG_READ(ah, AR_FCS_FAIL);
1979 stats->rts_good += REG_READ(ah, AR_RTS_OK);
1980 stats->beacons += REG_READ(ah, AR_BEACON_CNT);
1981}
1982
1983static void ath9k_enable_mib_counters(struct ath_hal *ah)
1984{
1985 struct ath_hal_5416 *ahp = AH5416(ah);
1986
1987 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Enable mib counters\n");
1988
1989 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
1990
1991 REG_WRITE(ah, AR_FILT_OFDM, 0);
1992 REG_WRITE(ah, AR_FILT_CCK, 0);
1993 REG_WRITE(ah, AR_MIBC,
1994 ~(AR_MIBC_COW | AR_MIBC_FMC | AR_MIBC_CMC | AR_MIBC_MCS)
1995 & 0x0f);
1996 REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
1997 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
1998}
1999
2000static void ath9k_hw_disable_mib_counters(struct ath_hal *ah)
2001{
2002 struct ath_hal_5416 *ahp = AH5416(ah);
2003
2004 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Disabling MIB counters\n");
2005
2006 REG_WRITE(ah, AR_MIBC, AR_MIBC_FMC | AR_MIBC_CMC);
2007
2008 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
2009
2010 REG_WRITE(ah, AR_FILT_OFDM, 0);
2011 REG_WRITE(ah, AR_FILT_CCK, 0);
2012}
2013
2014static int ath9k_hw_get_ani_channel_idx(struct ath_hal *ah,
2015 struct ath9k_channel *chan)
2016{
2017 struct ath_hal_5416 *ahp = AH5416(ah);
2018 int i;
2019
2020 for (i = 0; i < ARRAY_SIZE(ahp->ah_ani); i++) {
2021 if (ahp->ah_ani[i].c.channel == chan->channel)
2022 return i;
2023 if (ahp->ah_ani[i].c.channel == 0) {
2024 ahp->ah_ani[i].c.channel = chan->channel;
2025 ahp->ah_ani[i].c.channelFlags = chan->channelFlags;
2026 return i;
2027 }
2028 } 554 }
2029 555
2030 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2031 "No more channel states left. Using channel 0\n");
2032 return 0; 556 return 0;
2033} 557}
2034 558
2035static void ath9k_hw_ani_attach(struct ath_hal *ah)
2036{
2037 struct ath_hal_5416 *ahp = AH5416(ah);
2038 int i;
2039
2040 ahp->ah_hasHwPhyCounters = 1;
2041
2042 memset(ahp->ah_ani, 0, sizeof(ahp->ah_ani));
2043 for (i = 0; i < ARRAY_SIZE(ahp->ah_ani); i++) {
2044 ahp->ah_ani[i].ofdmTrigHigh = ATH9K_ANI_OFDM_TRIG_HIGH;
2045 ahp->ah_ani[i].ofdmTrigLow = ATH9K_ANI_OFDM_TRIG_LOW;
2046 ahp->ah_ani[i].cckTrigHigh = ATH9K_ANI_CCK_TRIG_HIGH;
2047 ahp->ah_ani[i].cckTrigLow = ATH9K_ANI_CCK_TRIG_LOW;
2048 ahp->ah_ani[i].rssiThrHigh = ATH9K_ANI_RSSI_THR_HIGH;
2049 ahp->ah_ani[i].rssiThrLow = ATH9K_ANI_RSSI_THR_LOW;
2050 ahp->ah_ani[i].ofdmWeakSigDetectOff =
2051 !ATH9K_ANI_USE_OFDM_WEAK_SIG;
2052 ahp->ah_ani[i].cckWeakSigThreshold =
2053 ATH9K_ANI_CCK_WEAK_SIG_THR;
2054 ahp->ah_ani[i].spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
2055 ahp->ah_ani[i].firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
2056 if (ahp->ah_hasHwPhyCounters) {
2057 ahp->ah_ani[i].ofdmPhyErrBase =
2058 AR_PHY_COUNTMAX - ATH9K_ANI_OFDM_TRIG_HIGH;
2059 ahp->ah_ani[i].cckPhyErrBase =
2060 AR_PHY_COUNTMAX - ATH9K_ANI_CCK_TRIG_HIGH;
2061 }
2062 }
2063 if (ahp->ah_hasHwPhyCounters) {
2064 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2065 "Setting OfdmErrBase = 0x%08x\n",
2066 ahp->ah_ani[0].ofdmPhyErrBase);
2067 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Setting cckErrBase = 0x%08x\n",
2068 ahp->ah_ani[0].cckPhyErrBase);
2069
2070 REG_WRITE(ah, AR_PHY_ERR_1, ahp->ah_ani[0].ofdmPhyErrBase);
2071 REG_WRITE(ah, AR_PHY_ERR_2, ahp->ah_ani[0].cckPhyErrBase);
2072 ath9k_enable_mib_counters(ah);
2073 }
2074 ahp->ah_aniPeriod = ATH9K_ANI_PERIOD;
2075 if (ah->ah_config.enable_ani)
2076 ahp->ah_procPhyErr |= HAL_PROCESS_ANI;
2077}
2078
2079static void ath9k_hw_ani_setup(struct ath_hal *ah)
2080{
2081 struct ath_hal_5416 *ahp = AH5416(ah);
2082 int i;
2083
2084 const int totalSizeDesired[] = { -55, -55, -55, -55, -62 };
2085 const int coarseHigh[] = { -14, -14, -14, -14, -12 };
2086 const int coarseLow[] = { -64, -64, -64, -64, -70 };
2087 const int firpwr[] = { -78, -78, -78, -78, -80 };
2088
2089 for (i = 0; i < 5; i++) {
2090 ahp->ah_totalSizeDesired[i] = totalSizeDesired[i];
2091 ahp->ah_coarseHigh[i] = coarseHigh[i];
2092 ahp->ah_coarseLow[i] = coarseLow[i];
2093 ahp->ah_firpwr[i] = firpwr[i];
2094 }
2095}
2096
2097static void ath9k_hw_ani_detach(struct ath_hal *ah)
2098{
2099 struct ath_hal_5416 *ahp = AH5416(ah);
2100
2101 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Detaching Ani\n");
2102 if (ahp->ah_hasHwPhyCounters) {
2103 ath9k_hw_disable_mib_counters(ah);
2104 REG_WRITE(ah, AR_PHY_ERR_1, 0);
2105 REG_WRITE(ah, AR_PHY_ERR_2, 0);
2106 }
2107}
2108
2109
2110static bool ath9k_hw_ani_control(struct ath_hal *ah,
2111 enum ath9k_ani_cmd cmd, int param)
2112{
2113 struct ath_hal_5416 *ahp = AH5416(ah);
2114 struct ar5416AniState *aniState = ahp->ah_curani;
2115
2116 switch (cmd & ahp->ah_ani_function) {
2117 case ATH9K_ANI_NOISE_IMMUNITY_LEVEL:{
2118 u32 level = param;
2119
2120 if (level >= ARRAY_SIZE(ahp->ah_totalSizeDesired)) {
2121 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2122 "%s: level out of range (%u > %u)\n",
2123 __func__, level,
2124 (unsigned) ARRAY_SIZE(ahp->
2125 ah_totalSizeDesired));
2126 return false;
2127 }
2128
2129 REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ,
2130 AR_PHY_DESIRED_SZ_TOT_DES,
2131 ahp->ah_totalSizeDesired[level]);
2132 REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
2133 AR_PHY_AGC_CTL1_COARSE_LOW,
2134 ahp->ah_coarseLow[level]);
2135 REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
2136 AR_PHY_AGC_CTL1_COARSE_HIGH,
2137 ahp->ah_coarseHigh[level]);
2138 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
2139 AR_PHY_FIND_SIG_FIRPWR,
2140 ahp->ah_firpwr[level]);
2141
2142 if (level > aniState->noiseImmunityLevel)
2143 ahp->ah_stats.ast_ani_niup++;
2144 else if (level < aniState->noiseImmunityLevel)
2145 ahp->ah_stats.ast_ani_nidown++;
2146 aniState->noiseImmunityLevel = level;
2147 break;
2148 }
2149 case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{
2150 const int m1ThreshLow[] = { 127, 50 };
2151 const int m2ThreshLow[] = { 127, 40 };
2152 const int m1Thresh[] = { 127, 0x4d };
2153 const int m2Thresh[] = { 127, 0x40 };
2154 const int m2CountThr[] = { 31, 16 };
2155 const int m2CountThrLow[] = { 63, 48 };
2156 u32 on = param ? 1 : 0;
2157
2158 REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
2159 AR_PHY_SFCORR_LOW_M1_THRESH_LOW,
2160 m1ThreshLow[on]);
2161 REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
2162 AR_PHY_SFCORR_LOW_M2_THRESH_LOW,
2163 m2ThreshLow[on]);
2164 REG_RMW_FIELD(ah, AR_PHY_SFCORR,
2165 AR_PHY_SFCORR_M1_THRESH,
2166 m1Thresh[on]);
2167 REG_RMW_FIELD(ah, AR_PHY_SFCORR,
2168 AR_PHY_SFCORR_M2_THRESH,
2169 m2Thresh[on]);
2170 REG_RMW_FIELD(ah, AR_PHY_SFCORR,
2171 AR_PHY_SFCORR_M2COUNT_THR,
2172 m2CountThr[on]);
2173 REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
2174 AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW,
2175 m2CountThrLow[on]);
2176
2177 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
2178 AR_PHY_SFCORR_EXT_M1_THRESH_LOW,
2179 m1ThreshLow[on]);
2180 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
2181 AR_PHY_SFCORR_EXT_M2_THRESH_LOW,
2182 m2ThreshLow[on]);
2183 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
2184 AR_PHY_SFCORR_EXT_M1_THRESH,
2185 m1Thresh[on]);
2186 REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
2187 AR_PHY_SFCORR_EXT_M2_THRESH,
2188 m2Thresh[on]);
2189
2190 if (on)
2191 REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
2192 AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
2193 else
2194 REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW,
2195 AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
2196
2197 if (!on != aniState->ofdmWeakSigDetectOff) {
2198 if (on)
2199 ahp->ah_stats.ast_ani_ofdmon++;
2200 else
2201 ahp->ah_stats.ast_ani_ofdmoff++;
2202 aniState->ofdmWeakSigDetectOff = !on;
2203 }
2204 break;
2205 }
2206 case ATH9K_ANI_CCK_WEAK_SIGNAL_THR:{
2207 const int weakSigThrCck[] = { 8, 6 };
2208 u32 high = param ? 1 : 0;
2209
2210 REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT,
2211 AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK,
2212 weakSigThrCck[high]);
2213 if (high != aniState->cckWeakSigThreshold) {
2214 if (high)
2215 ahp->ah_stats.ast_ani_cckhigh++;
2216 else
2217 ahp->ah_stats.ast_ani_ccklow++;
2218 aniState->cckWeakSigThreshold = high;
2219 }
2220 break;
2221 }
2222 case ATH9K_ANI_FIRSTEP_LEVEL:{
2223 const int firstep[] = { 0, 4, 8 };
2224 u32 level = param;
2225
2226 if (level >= ARRAY_SIZE(firstep)) {
2227 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2228 "%s: level out of range (%u > %u)\n",
2229 __func__, level,
2230 (unsigned) ARRAY_SIZE(firstep));
2231 return false;
2232 }
2233 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
2234 AR_PHY_FIND_SIG_FIRSTEP,
2235 firstep[level]);
2236 if (level > aniState->firstepLevel)
2237 ahp->ah_stats.ast_ani_stepup++;
2238 else if (level < aniState->firstepLevel)
2239 ahp->ah_stats.ast_ani_stepdown++;
2240 aniState->firstepLevel = level;
2241 break;
2242 }
2243 case ATH9K_ANI_SPUR_IMMUNITY_LEVEL:{
2244 const int cycpwrThr1[] =
2245 { 2, 4, 6, 8, 10, 12, 14, 16 };
2246 u32 level = param;
2247
2248 if (level >= ARRAY_SIZE(cycpwrThr1)) {
2249 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2250 "%s: level out of range (%u > %u)\n",
2251 __func__, level,
2252 (unsigned)
2253 ARRAY_SIZE(cycpwrThr1));
2254 return false;
2255 }
2256 REG_RMW_FIELD(ah, AR_PHY_TIMING5,
2257 AR_PHY_TIMING5_CYCPWR_THR1,
2258 cycpwrThr1[level]);
2259 if (level > aniState->spurImmunityLevel)
2260 ahp->ah_stats.ast_ani_spurup++;
2261 else if (level < aniState->spurImmunityLevel)
2262 ahp->ah_stats.ast_ani_spurdown++;
2263 aniState->spurImmunityLevel = level;
2264 break;
2265 }
2266 case ATH9K_ANI_PRESENT:
2267 break;
2268 default:
2269 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2270 "%s: invalid cmd %u\n", __func__, cmd);
2271 return false;
2272 }
2273
2274 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "%s: ANI parameters:\n", __func__);
2275 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2276 "noiseImmunityLevel=%d, spurImmunityLevel=%d, "
2277 "ofdmWeakSigDetectOff=%d\n",
2278 aniState->noiseImmunityLevel, aniState->spurImmunityLevel,
2279 !aniState->ofdmWeakSigDetectOff);
2280 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2281 "cckWeakSigThreshold=%d, "
2282 "firstepLevel=%d, listenTime=%d\n",
2283 aniState->cckWeakSigThreshold, aniState->firstepLevel,
2284 aniState->listenTime);
2285 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2286 "cycleCount=%d, ofdmPhyErrCount=%d, cckPhyErrCount=%d\n\n",
2287 aniState->cycleCount, aniState->ofdmPhyErrCount,
2288 aniState->cckPhyErrCount);
2289 return true;
2290}
2291
2292static void ath9k_ani_restart(struct ath_hal *ah)
2293{
2294 struct ath_hal_5416 *ahp = AH5416(ah);
2295 struct ar5416AniState *aniState;
2296
2297 if (!DO_ANI(ah))
2298 return;
2299
2300 aniState = ahp->ah_curani;
2301
2302 aniState->listenTime = 0;
2303 if (ahp->ah_hasHwPhyCounters) {
2304 if (aniState->ofdmTrigHigh > AR_PHY_COUNTMAX) {
2305 aniState->ofdmPhyErrBase = 0;
2306 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2307 "OFDM Trigger is too high for hw counters\n");
2308 } else {
2309 aniState->ofdmPhyErrBase =
2310 AR_PHY_COUNTMAX - aniState->ofdmTrigHigh;
2311 }
2312 if (aniState->cckTrigHigh > AR_PHY_COUNTMAX) {
2313 aniState->cckPhyErrBase = 0;
2314 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2315 "CCK Trigger is too high for hw counters\n");
2316 } else {
2317 aniState->cckPhyErrBase =
2318 AR_PHY_COUNTMAX - aniState->cckTrigHigh;
2319 }
2320 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2321 "%s: Writing ofdmbase=%u cckbase=%u\n",
2322 __func__, aniState->ofdmPhyErrBase,
2323 aniState->cckPhyErrBase);
2324 REG_WRITE(ah, AR_PHY_ERR_1, aniState->ofdmPhyErrBase);
2325 REG_WRITE(ah, AR_PHY_ERR_2, aniState->cckPhyErrBase);
2326 REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
2327 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
2328
2329 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
2330 }
2331 aniState->ofdmPhyErrCount = 0;
2332 aniState->cckPhyErrCount = 0;
2333}
2334
2335static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hal *ah)
2336{
2337 struct ath_hal_5416 *ahp = AH5416(ah);
2338 struct ath9k_channel *chan = ah->ah_curchan;
2339 struct ar5416AniState *aniState;
2340 enum wireless_mode mode;
2341 int32_t rssi;
2342
2343 if (!DO_ANI(ah))
2344 return;
2345
2346 aniState = ahp->ah_curani;
2347
2348 if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
2349 if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
2350 aniState->noiseImmunityLevel + 1)) {
2351 return;
2352 }
2353 }
2354
2355 if (aniState->spurImmunityLevel < HAL_SPUR_IMMUNE_MAX) {
2356 if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
2357 aniState->spurImmunityLevel + 1)) {
2358 return;
2359 }
2360 }
2361
2362 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
2363 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
2364 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
2365 aniState->firstepLevel + 1);
2366 }
2367 return;
2368 }
2369 rssi = BEACON_RSSI(ahp);
2370 if (rssi > aniState->rssiThrHigh) {
2371 if (!aniState->ofdmWeakSigDetectOff) {
2372 if (ath9k_hw_ani_control(ah,
2373 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
2374 false)) {
2375 ath9k_hw_ani_control(ah,
2376 ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
2377 0);
2378 return;
2379 }
2380 }
2381 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
2382 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
2383 aniState->firstepLevel + 1);
2384 return;
2385 }
2386 } else if (rssi > aniState->rssiThrLow) {
2387 if (aniState->ofdmWeakSigDetectOff)
2388 ath9k_hw_ani_control(ah,
2389 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
2390 true);
2391 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX)
2392 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
2393 aniState->firstepLevel + 1);
2394 return;
2395 } else {
2396 mode = ath9k_hw_chan2wmode(ah, chan);
2397 if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) {
2398 if (!aniState->ofdmWeakSigDetectOff)
2399 ath9k_hw_ani_control(ah,
2400 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
2401 false);
2402 if (aniState->firstepLevel > 0)
2403 ath9k_hw_ani_control(ah,
2404 ATH9K_ANI_FIRSTEP_LEVEL,
2405 0);
2406 return;
2407 }
2408 }
2409}
2410
2411static void ath9k_hw_ani_cck_err_trigger(struct ath_hal *ah)
2412{
2413 struct ath_hal_5416 *ahp = AH5416(ah);
2414 struct ath9k_channel *chan = ah->ah_curchan;
2415 struct ar5416AniState *aniState;
2416 enum wireless_mode mode;
2417 int32_t rssi;
2418
2419 if (!DO_ANI(ah))
2420 return;
2421
2422 aniState = ahp->ah_curani;
2423 if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
2424 if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
2425 aniState->noiseImmunityLevel + 1)) {
2426 return;
2427 }
2428 }
2429 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
2430 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
2431 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
2432 aniState->firstepLevel + 1);
2433 }
2434 return;
2435 }
2436 rssi = BEACON_RSSI(ahp);
2437 if (rssi > aniState->rssiThrLow) {
2438 if (aniState->firstepLevel < HAL_FIRST_STEP_MAX)
2439 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
2440 aniState->firstepLevel + 1);
2441 } else {
2442 mode = ath9k_hw_chan2wmode(ah, chan);
2443 if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) {
2444 if (aniState->firstepLevel > 0)
2445 ath9k_hw_ani_control(ah,
2446 ATH9K_ANI_FIRSTEP_LEVEL,
2447 0);
2448 }
2449 }
2450}
2451
2452static void ath9k_ani_reset(struct ath_hal *ah)
2453{
2454 struct ath_hal_5416 *ahp = AH5416(ah);
2455 struct ar5416AniState *aniState;
2456 struct ath9k_channel *chan = ah->ah_curchan;
2457 int index;
2458
2459 if (!DO_ANI(ah))
2460 return;
2461
2462 index = ath9k_hw_get_ani_channel_idx(ah, chan);
2463 aniState = &ahp->ah_ani[index];
2464 ahp->ah_curani = aniState;
2465
2466 if (DO_ANI(ah) && ah->ah_opmode != ATH9K_M_STA
2467 && ah->ah_opmode != ATH9K_M_IBSS) {
2468 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2469 "%s: Reset ANI state opmode %u\n", __func__,
2470 ah->ah_opmode);
2471 ahp->ah_stats.ast_ani_reset++;
2472 ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL, 0);
2473 ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL, 0);
2474 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL, 0);
2475 ath9k_hw_ani_control(ah,
2476 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
2477 !ATH9K_ANI_USE_OFDM_WEAK_SIG);
2478 ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
2479 ATH9K_ANI_CCK_WEAK_SIG_THR);
2480 ath9k_hw_setrxfilter(ah,
2481 ath9k_hw_getrxfilter(ah) |
2482 ATH9K_RX_FILTER_PHYERR);
2483 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
2484 ahp->ah_curani->ofdmTrigHigh =
2485 ah->ah_config.ofdm_trig_high;
2486 ahp->ah_curani->ofdmTrigLow =
2487 ah->ah_config.ofdm_trig_low;
2488 ahp->ah_curani->cckTrigHigh =
2489 ah->ah_config.cck_trig_high;
2490 ahp->ah_curani->cckTrigLow =
2491 ah->ah_config.cck_trig_low;
2492 }
2493 ath9k_ani_restart(ah);
2494 return;
2495 }
2496
2497 if (aniState->noiseImmunityLevel != 0)
2498 ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
2499 aniState->noiseImmunityLevel);
2500 if (aniState->spurImmunityLevel != 0)
2501 ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
2502 aniState->spurImmunityLevel);
2503 if (aniState->ofdmWeakSigDetectOff)
2504 ath9k_hw_ani_control(ah,
2505 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
2506 !aniState->ofdmWeakSigDetectOff);
2507 if (aniState->cckWeakSigThreshold)
2508 ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
2509 aniState->cckWeakSigThreshold);
2510 if (aniState->firstepLevel != 0)
2511 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
2512 aniState->firstepLevel);
2513 if (ahp->ah_hasHwPhyCounters) {
2514 ath9k_hw_setrxfilter(ah,
2515 ath9k_hw_getrxfilter(ah) &
2516 ~ATH9K_RX_FILTER_PHYERR);
2517 ath9k_ani_restart(ah);
2518 REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
2519 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
2520
2521 } else {
2522 ath9k_ani_restart(ah);
2523 ath9k_hw_setrxfilter(ah,
2524 ath9k_hw_getrxfilter(ah) |
2525 ATH9K_RX_FILTER_PHYERR);
2526 }
2527}
2528
2529/*
2530 * Process a MIB interrupt. We may potentially be invoked because
2531 * any of the MIB counters overflow/trigger so don't assume we're
2532 * here because a PHY error counter triggered.
2533 */
2534void ath9k_hw_procmibevent(struct ath_hal *ah,
2535 const struct ath9k_node_stats *stats)
2536{
2537 struct ath_hal_5416 *ahp = AH5416(ah);
2538 u32 phyCnt1, phyCnt2;
2539
2540 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Processing Mib Intr\n");
2541 /* Reset these counters regardless */
2542 REG_WRITE(ah, AR_FILT_OFDM, 0);
2543 REG_WRITE(ah, AR_FILT_CCK, 0);
2544 if (!(REG_READ(ah, AR_SLP_MIB_CTRL) & AR_SLP_MIB_PENDING))
2545 REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR);
2546
2547 /* Clear the mib counters and save them in the stats */
2548 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
2549 ahp->ah_stats.ast_nodestats = *stats;
2550
2551 if (!DO_ANI(ah))
2552 return;
2553
2554 /* NB: these are not reset-on-read */
2555 phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
2556 phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
2557 if (((phyCnt1 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK) ||
2558 ((phyCnt2 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK)) {
2559 struct ar5416AniState *aniState = ahp->ah_curani;
2560 u32 ofdmPhyErrCnt, cckPhyErrCnt;
2561
2562 /* NB: only use ast_ani_*errs with AH_PRIVATE_DIAG */
2563 ofdmPhyErrCnt = phyCnt1 - aniState->ofdmPhyErrBase;
2564 ahp->ah_stats.ast_ani_ofdmerrs +=
2565 ofdmPhyErrCnt - aniState->ofdmPhyErrCount;
2566 aniState->ofdmPhyErrCount = ofdmPhyErrCnt;
2567
2568 cckPhyErrCnt = phyCnt2 - aniState->cckPhyErrBase;
2569 ahp->ah_stats.ast_ani_cckerrs +=
2570 cckPhyErrCnt - aniState->cckPhyErrCount;
2571 aniState->cckPhyErrCount = cckPhyErrCnt;
2572
2573 /*
2574 * NB: figure out which counter triggered. If both
2575 * trigger we'll only deal with one as the processing
2576 * clobbers the error counter so the trigger threshold
2577 * check will never be true.
2578 */
2579 if (aniState->ofdmPhyErrCount > aniState->ofdmTrigHigh)
2580 ath9k_hw_ani_ofdm_err_trigger(ah);
2581 if (aniState->cckPhyErrCount > aniState->cckTrigHigh)
2582 ath9k_hw_ani_cck_err_trigger(ah);
2583 /* NB: always restart to insure the h/w counters are reset */
2584 ath9k_ani_restart(ah);
2585 }
2586}
2587
2588static void ath9k_hw_ani_lower_immunity(struct ath_hal *ah)
2589{
2590 struct ath_hal_5416 *ahp = AH5416(ah);
2591 struct ar5416AniState *aniState;
2592 int32_t rssi;
2593
2594 aniState = ahp->ah_curani;
2595
2596 if (ah->ah_opmode == ATH9K_M_HOSTAP) {
2597 if (aniState->firstepLevel > 0) {
2598 if (ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
2599 aniState->firstepLevel - 1)) {
2600 return;
2601 }
2602 }
2603 } else {
2604 rssi = BEACON_RSSI(ahp);
2605 if (rssi > aniState->rssiThrHigh) {
2606 /* XXX: Handle me */
2607 } else if (rssi > aniState->rssiThrLow) {
2608 if (aniState->ofdmWeakSigDetectOff) {
2609 if (ath9k_hw_ani_control(ah,
2610 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
2611 true) ==
2612 true) {
2613 return;
2614 }
2615 }
2616 if (aniState->firstepLevel > 0) {
2617 if (ath9k_hw_ani_control
2618 (ah, ATH9K_ANI_FIRSTEP_LEVEL,
2619 aniState->firstepLevel - 1) ==
2620 true) {
2621 return;
2622 }
2623 }
2624 } else {
2625 if (aniState->firstepLevel > 0) {
2626 if (ath9k_hw_ani_control
2627 (ah, ATH9K_ANI_FIRSTEP_LEVEL,
2628 aniState->firstepLevel - 1) ==
2629 true) {
2630 return;
2631 }
2632 }
2633 }
2634 }
2635
2636 if (aniState->spurImmunityLevel > 0) {
2637 if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
2638 aniState->spurImmunityLevel - 1)) {
2639 return;
2640 }
2641 }
2642
2643 if (aniState->noiseImmunityLevel > 0) {
2644 ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
2645 aniState->noiseImmunityLevel - 1);
2646 return;
2647 }
2648}
2649
2650static int32_t ath9k_hw_ani_get_listen_time(struct ath_hal *ah)
2651{
2652 struct ath_hal_5416 *ahp = AH5416(ah);
2653 struct ar5416AniState *aniState;
2654 u32 txFrameCount, rxFrameCount, cycleCount;
2655 int32_t listenTime;
2656
2657 txFrameCount = REG_READ(ah, AR_TFCNT);
2658 rxFrameCount = REG_READ(ah, AR_RFCNT);
2659 cycleCount = REG_READ(ah, AR_CCCNT);
2660
2661 aniState = ahp->ah_curani;
2662 if (aniState->cycleCount == 0 || aniState->cycleCount > cycleCount) {
2663
2664 listenTime = 0;
2665 ahp->ah_stats.ast_ani_lzero++;
2666 } else {
2667 int32_t ccdelta = cycleCount - aniState->cycleCount;
2668 int32_t rfdelta = rxFrameCount - aniState->rxFrameCount;
2669 int32_t tfdelta = txFrameCount - aniState->txFrameCount;
2670 listenTime = (ccdelta - rfdelta - tfdelta) / 44000;
2671 }
2672 aniState->cycleCount = cycleCount;
2673 aniState->txFrameCount = txFrameCount;
2674 aniState->rxFrameCount = rxFrameCount;
2675
2676 return listenTime;
2677}
2678
2679void ath9k_hw_ani_monitor(struct ath_hal *ah,
2680 const struct ath9k_node_stats *stats,
2681 struct ath9k_channel *chan)
2682{
2683 struct ath_hal_5416 *ahp = AH5416(ah);
2684 struct ar5416AniState *aniState;
2685 int32_t listenTime;
2686
2687 aniState = ahp->ah_curani;
2688 ahp->ah_stats.ast_nodestats = *stats;
2689
2690 listenTime = ath9k_hw_ani_get_listen_time(ah);
2691 if (listenTime < 0) {
2692 ahp->ah_stats.ast_ani_lneg++;
2693 ath9k_ani_restart(ah);
2694 return;
2695 }
2696
2697 aniState->listenTime += listenTime;
2698
2699 if (ahp->ah_hasHwPhyCounters) {
2700 u32 phyCnt1, phyCnt2;
2701 u32 ofdmPhyErrCnt, cckPhyErrCnt;
2702
2703 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
2704
2705 phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
2706 phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
2707
2708 if (phyCnt1 < aniState->ofdmPhyErrBase ||
2709 phyCnt2 < aniState->cckPhyErrBase) {
2710 if (phyCnt1 < aniState->ofdmPhyErrBase) {
2711 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2712 "%s: phyCnt1 0x%x, resetting "
2713 "counter value to 0x%x\n",
2714 __func__, phyCnt1,
2715 aniState->ofdmPhyErrBase);
2716 REG_WRITE(ah, AR_PHY_ERR_1,
2717 aniState->ofdmPhyErrBase);
2718 REG_WRITE(ah, AR_PHY_ERR_MASK_1,
2719 AR_PHY_ERR_OFDM_TIMING);
2720 }
2721 if (phyCnt2 < aniState->cckPhyErrBase) {
2722 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
2723 "%s: phyCnt2 0x%x, resetting "
2724 "counter value to 0x%x\n",
2725 __func__, phyCnt2,
2726 aniState->cckPhyErrBase);
2727 REG_WRITE(ah, AR_PHY_ERR_2,
2728 aniState->cckPhyErrBase);
2729 REG_WRITE(ah, AR_PHY_ERR_MASK_2,
2730 AR_PHY_ERR_CCK_TIMING);
2731 }
2732 return;
2733 }
2734
2735 ofdmPhyErrCnt = phyCnt1 - aniState->ofdmPhyErrBase;
2736 ahp->ah_stats.ast_ani_ofdmerrs +=
2737 ofdmPhyErrCnt - aniState->ofdmPhyErrCount;
2738 aniState->ofdmPhyErrCount = ofdmPhyErrCnt;
2739
2740 cckPhyErrCnt = phyCnt2 - aniState->cckPhyErrBase;
2741 ahp->ah_stats.ast_ani_cckerrs +=
2742 cckPhyErrCnt - aniState->cckPhyErrCount;
2743 aniState->cckPhyErrCount = cckPhyErrCnt;
2744 }
2745
2746 if (!DO_ANI(ah))
2747 return;
2748
2749 if (aniState->listenTime > 5 * ahp->ah_aniPeriod) {
2750 if (aniState->ofdmPhyErrCount <= aniState->listenTime *
2751 aniState->ofdmTrigLow / 1000 &&
2752 aniState->cckPhyErrCount <= aniState->listenTime *
2753 aniState->cckTrigLow / 1000)
2754 ath9k_hw_ani_lower_immunity(ah);
2755 ath9k_ani_restart(ah);
2756 } else if (aniState->listenTime > ahp->ah_aniPeriod) {
2757 if (aniState->ofdmPhyErrCount > aniState->listenTime *
2758 aniState->ofdmTrigHigh / 1000) {
2759 ath9k_hw_ani_ofdm_err_trigger(ah);
2760 ath9k_ani_restart(ah);
2761 } else if (aniState->cckPhyErrCount >
2762 aniState->listenTime * aniState->cckTrigHigh /
2763 1000) {
2764 ath9k_hw_ani_cck_err_trigger(ah);
2765 ath9k_ani_restart(ah);
2766 }
2767 }
2768}
2769
2770#ifndef ATH_NF_PER_CHAN
2771static void ath9k_init_nfcal_hist_buffer(struct ath_hal *ah)
2772{
2773 int i, j;
2774
2775 for (i = 0; i < NUM_NF_READINGS; i++) {
2776 ah->nfCalHist[i].currIndex = 0;
2777 ah->nfCalHist[i].privNF = AR_PHY_CCA_MAX_GOOD_VALUE;
2778 ah->nfCalHist[i].invalidNFcount =
2779 AR_PHY_CCA_FILTERWINDOW_LENGTH;
2780 for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) {
2781 ah->nfCalHist[i].nfCalBuffer[j] =
2782 AR_PHY_CCA_MAX_GOOD_VALUE;
2783 }
2784 }
2785 return;
2786}
2787#endif
2788
2789static void ath9k_hw_gpio_cfg_output_mux(struct ath_hal *ah,
2790 u32 gpio, u32 type)
2791{
2792 int addr;
2793 u32 gpio_shift, tmp;
2794
2795 if (gpio > 11)
2796 addr = AR_GPIO_OUTPUT_MUX3;
2797 else if (gpio > 5)
2798 addr = AR_GPIO_OUTPUT_MUX2;
2799 else
2800 addr = AR_GPIO_OUTPUT_MUX1;
2801
2802 gpio_shift = (gpio % 6) * 5;
2803
2804 if (AR_SREV_9280_20_OR_LATER(ah)
2805 || (addr != AR_GPIO_OUTPUT_MUX1)) {
2806 REG_RMW(ah, addr, (type << gpio_shift),
2807 (0x1f << gpio_shift));
2808 } else {
2809 tmp = REG_READ(ah, addr);
2810 tmp = ((tmp & 0x1F0) << 1) | (tmp & ~0x1F0);
2811 tmp &= ~(0x1f << gpio_shift);
2812 tmp |= (type << gpio_shift);
2813 REG_WRITE(ah, addr, tmp);
2814 }
2815}
2816
2817void ath9k_hw_cfg_output(struct ath_hal *ah, u32 gpio,
2818 u32 ah_signal_type)
2819{
2820 u32 gpio_shift;
2821
2822 ath9k_hw_gpio_cfg_output_mux(ah, gpio, ah_signal_type);
2823
2824 gpio_shift = 2 * gpio;
2825
2826 REG_RMW(ah,
2827 AR_GPIO_OE_OUT,
2828 (AR_GPIO_OE_OUT_DRV_ALL << gpio_shift),
2829 (AR_GPIO_OE_OUT_DRV << gpio_shift));
2830}
2831
2832void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 val)
2833{
2834 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio),
2835 AR_GPIO_BIT(gpio));
2836}
2837
2838/*
2839 * Configure GPIO Input lines
2840 */
2841void ath9k_hw_cfg_gpio_input(struct ath_hal *ah, u32 gpio)
2842{
2843 u32 gpio_shift;
2844
2845 ASSERT(gpio < ah->ah_caps.num_gpio_pins);
2846
2847 gpio_shift = gpio << 1;
2848
2849 REG_RMW(ah,
2850 AR_GPIO_OE_OUT,
2851 (AR_GPIO_OE_OUT_DRV_NO << gpio_shift),
2852 (AR_GPIO_OE_OUT_DRV << gpio_shift));
2853}
2854
2855#ifdef CONFIG_RFKILL
2856static void ath9k_enable_rfkill(struct ath_hal *ah)
2857{
2858 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
2859 AR_GPIO_INPUT_EN_VAL_RFSILENT_BB);
2860
2861 REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2,
2862 AR_GPIO_INPUT_MUX2_RFSILENT);
2863
2864 ath9k_hw_cfg_gpio_input(ah, ah->ah_rfkill_gpio);
2865 REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB);
2866}
2867#endif
2868
2869u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio)
2870{
2871 if (gpio >= ah->ah_caps.num_gpio_pins)
2872 return 0xffffffff;
2873
2874 if (AR_SREV_9280_10_OR_LATER(ah)) {
2875 return (MS
2876 (REG_READ(ah, AR_GPIO_IN_OUT),
2877 AR928X_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) != 0;
2878 } else {
2879 return (MS(REG_READ(ah, AR_GPIO_IN_OUT), AR_GPIO_IN_VAL) &
2880 AR_GPIO_BIT(gpio)) != 0;
2881 }
2882}
2883
2884static int ath9k_hw_post_attach(struct ath_hal *ah) 559static int ath9k_hw_post_attach(struct ath_hal *ah)
2885{ 560{
2886 int ecode; 561 int ecode;
2887 562
2888 if (!ath9k_hw_chip_test(ah)) { 563 if (!ath9k_hw_chip_test(ah)) {
2889 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, 564 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
2890 "%s: hardware self-test failed\n", __func__); 565 "%s: hardware self-test failed\n", __func__);
2891 return -ENODEV; 566 return -ENODEV;
2892 } 567 }
2893 568
@@ -2906,357 +581,12 @@ static int ath9k_hw_post_attach(struct ath_hal *ah)
2906 ath9k_hw_ani_setup(ah); 581 ath9k_hw_ani_setup(ah);
2907 ath9k_hw_ani_attach(ah); 582 ath9k_hw_ani_attach(ah);
2908 } 583 }
2909 return 0;
2910}
2911
2912static u32 ath9k_hw_ini_fixup(struct ath_hal *ah,
2913 struct ar5416_eeprom *pEepData,
2914 u32 reg, u32 value)
2915{
2916 struct base_eep_header *pBase = &(pEepData->baseEepHeader);
2917 584
2918 switch (ah->ah_devid) { 585 return 0;
2919 case AR9280_DEVID_PCI:
2920 if (reg == 0x7894) {
2921 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
2922 "ini VAL: %x EEPROM: %x\n", value,
2923 (pBase->version & 0xff));
2924
2925 if ((pBase->version & 0xff) > 0x0a) {
2926 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
2927 "PWDCLKIND: %d\n",
2928 pBase->pwdclkind);
2929 value &= ~AR_AN_TOP2_PWDCLKIND;
2930 value |= AR_AN_TOP2_PWDCLKIND & (pBase->
2931 pwdclkind << AR_AN_TOP2_PWDCLKIND_S);
2932 } else {
2933 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
2934 "PWDCLKIND Earlier Rev\n");
2935 }
2936
2937 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
2938 "final ini VAL: %x\n", value);
2939 }
2940 break;
2941 }
2942 return value;
2943}
2944
2945static bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
2946{
2947 struct ath_hal_5416 *ahp = AH5416(ah);
2948 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
2949 u16 capField = 0, eeval;
2950
2951 eeval = ath9k_hw_get_eeprom(ahp, EEP_REG_0);
2952
2953 ah->ah_currentRD = eeval;
2954
2955 eeval = ath9k_hw_get_eeprom(ahp, EEP_REG_1);
2956 ah->ah_currentRDExt = eeval;
2957
2958 capField = ath9k_hw_get_eeprom(ahp, EEP_OP_CAP);
2959
2960 if (ah->ah_opmode != ATH9K_M_HOSTAP &&
2961 ah->ah_subvendorid == AR_SUBVENDOR_ID_NEW_A) {
2962 if (ah->ah_currentRD == 0x64 || ah->ah_currentRD == 0x65)
2963 ah->ah_currentRD += 5;
2964 else if (ah->ah_currentRD == 0x41)
2965 ah->ah_currentRD = 0x43;
2966 DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
2967 "%s: regdomain mapped to 0x%x\n", __func__,
2968 ah->ah_currentRD);
2969 }
2970
2971 eeval = ath9k_hw_get_eeprom(ahp, EEP_OP_MODE);
2972 bitmap_zero(pCap->wireless_modes, ATH9K_MODE_MAX);
2973
2974 if (eeval & AR5416_OPFLAGS_11A) {
2975 set_bit(ATH9K_MODE_11A, pCap->wireless_modes);
2976 if (ah->ah_config.ht_enable) {
2977 if (!(eeval & AR5416_OPFLAGS_N_5G_HT20))
2978 set_bit(ATH9K_MODE_11NA_HT20,
2979 pCap->wireless_modes);
2980 if (!(eeval & AR5416_OPFLAGS_N_5G_HT40)) {
2981 set_bit(ATH9K_MODE_11NA_HT40PLUS,
2982 pCap->wireless_modes);
2983 set_bit(ATH9K_MODE_11NA_HT40MINUS,
2984 pCap->wireless_modes);
2985 }
2986 }
2987 }
2988
2989 if (eeval & AR5416_OPFLAGS_11G) {
2990 set_bit(ATH9K_MODE_11B, pCap->wireless_modes);
2991 set_bit(ATH9K_MODE_11G, pCap->wireless_modes);
2992 if (ah->ah_config.ht_enable) {
2993 if (!(eeval & AR5416_OPFLAGS_N_2G_HT20))
2994 set_bit(ATH9K_MODE_11NG_HT20,
2995 pCap->wireless_modes);
2996 if (!(eeval & AR5416_OPFLAGS_N_2G_HT40)) {
2997 set_bit(ATH9K_MODE_11NG_HT40PLUS,
2998 pCap->wireless_modes);
2999 set_bit(ATH9K_MODE_11NG_HT40MINUS,
3000 pCap->wireless_modes);
3001 }
3002 }
3003 }
3004
3005 pCap->tx_chainmask = ath9k_hw_get_eeprom(ahp, EEP_TX_MASK);
3006 if ((ah->ah_isPciExpress)
3007 || (eeval & AR5416_OPFLAGS_11A)) {
3008 pCap->rx_chainmask =
3009 ath9k_hw_get_eeprom(ahp, EEP_RX_MASK);
3010 } else {
3011 pCap->rx_chainmask =
3012 (ath9k_hw_gpio_get(ah, 0)) ? 0x5 : 0x7;
3013 }
3014
3015 if (!(AR_SREV_9280(ah) && (ah->ah_macRev == 0)))
3016 ahp->ah_miscMode |= AR_PCU_MIC_NEW_LOC_ENA;
3017
3018 pCap->low_2ghz_chan = 2312;
3019 pCap->high_2ghz_chan = 2732;
3020
3021 pCap->low_5ghz_chan = 4920;
3022 pCap->high_5ghz_chan = 6100;
3023
3024 pCap->hw_caps &= ~ATH9K_HW_CAP_CIPHER_CKIP;
3025 pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_TKIP;
3026 pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_AESCCM;
3027
3028 pCap->hw_caps &= ~ATH9K_HW_CAP_MIC_CKIP;
3029 pCap->hw_caps |= ATH9K_HW_CAP_MIC_TKIP;
3030 pCap->hw_caps |= ATH9K_HW_CAP_MIC_AESCCM;
3031
3032 pCap->hw_caps |= ATH9K_HW_CAP_CHAN_SPREAD;
3033
3034 if (ah->ah_config.ht_enable)
3035 pCap->hw_caps |= ATH9K_HW_CAP_HT;
3036 else
3037 pCap->hw_caps &= ~ATH9K_HW_CAP_HT;
3038
3039 pCap->hw_caps |= ATH9K_HW_CAP_GTT;
3040 pCap->hw_caps |= ATH9K_HW_CAP_VEOL;
3041 pCap->hw_caps |= ATH9K_HW_CAP_BSSIDMASK;
3042 pCap->hw_caps &= ~ATH9K_HW_CAP_MCAST_KEYSEARCH;
3043
3044 if (capField & AR_EEPROM_EEPCAP_MAXQCU)
3045 pCap->total_queues =
3046 MS(capField, AR_EEPROM_EEPCAP_MAXQCU);
3047 else
3048 pCap->total_queues = ATH9K_NUM_TX_QUEUES;
3049
3050 if (capField & AR_EEPROM_EEPCAP_KC_ENTRIES)
3051 pCap->keycache_size =
3052 1 << MS(capField, AR_EEPROM_EEPCAP_KC_ENTRIES);
3053 else
3054 pCap->keycache_size = AR_KEYTABLE_SIZE;
3055
3056 pCap->hw_caps |= ATH9K_HW_CAP_FASTCC;
3057 pCap->num_mr_retries = 4;
3058 pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD;
3059
3060 if (AR_SREV_9280_10_OR_LATER(ah))
3061 pCap->num_gpio_pins = AR928X_NUM_GPIO;
3062 else
3063 pCap->num_gpio_pins = AR_NUM_GPIO;
3064
3065 if (AR_SREV_9280_10_OR_LATER(ah)) {
3066 pCap->hw_caps |= ATH9K_HW_CAP_WOW;
3067 pCap->hw_caps |= ATH9K_HW_CAP_WOW_MATCHPATTERN_EXACT;
3068 } else {
3069 pCap->hw_caps &= ~ATH9K_HW_CAP_WOW;
3070 pCap->hw_caps &= ~ATH9K_HW_CAP_WOW_MATCHPATTERN_EXACT;
3071 }
3072
3073 if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) {
3074 pCap->hw_caps |= ATH9K_HW_CAP_CST;
3075 pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX;
3076 } else {
3077 pCap->rts_aggr_limit = (8 * 1024);
3078 }
3079
3080 pCap->hw_caps |= ATH9K_HW_CAP_ENHANCEDPM;
3081
3082#ifdef CONFIG_RFKILL
3083 ah->ah_rfsilent = ath9k_hw_get_eeprom(ahp, EEP_RF_SILENT);
3084 if (ah->ah_rfsilent & EEP_RFSILENT_ENABLED) {
3085 ah->ah_rfkill_gpio =
3086 MS(ah->ah_rfsilent, EEP_RFSILENT_GPIO_SEL);
3087 ah->ah_rfkill_polarity =
3088 MS(ah->ah_rfsilent, EEP_RFSILENT_POLARITY);
3089
3090 pCap->hw_caps |= ATH9K_HW_CAP_RFSILENT;
3091 }
3092#endif
3093
3094 if ((ah->ah_macVersion == AR_SREV_VERSION_5416_PCI) ||
3095 (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE) ||
3096 (ah->ah_macVersion == AR_SREV_VERSION_9160) ||
3097 (ah->ah_macVersion == AR_SREV_VERSION_9100) ||
3098 (ah->ah_macVersion == AR_SREV_VERSION_9280))
3099 pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
3100 else
3101 pCap->hw_caps |= ATH9K_HW_CAP_AUTOSLEEP;
3102
3103 if (AR_SREV_9280(ah))
3104 pCap->hw_caps &= ~ATH9K_HW_CAP_4KB_SPLITTRANS;
3105 else
3106 pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS;
3107
3108 if (ah->ah_currentRDExt & (1 << REG_EXT_JAPAN_MIDBAND)) {
3109 pCap->reg_cap =
3110 AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
3111 AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN |
3112 AR_EEPROM_EEREGCAP_EN_KK_U2 |
3113 AR_EEPROM_EEREGCAP_EN_KK_MIDBAND;
3114 } else {
3115 pCap->reg_cap =
3116 AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
3117 AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN;
3118 }
3119
3120 pCap->reg_cap |= AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND;
3121
3122 pCap->num_antcfg_5ghz =
3123 ath9k_hw_get_num_ant_config(ahp, IEEE80211_BAND_5GHZ);
3124 pCap->num_antcfg_2ghz =
3125 ath9k_hw_get_num_ant_config(ahp, IEEE80211_BAND_2GHZ);
3126
3127 return true;
3128}
3129
3130static void ar5416DisablePciePhy(struct ath_hal *ah)
3131{
3132 if (!AR_SREV_9100(ah))
3133 return;
3134
3135 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
3136 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
3137 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029);
3138 REG_WRITE(ah, AR_PCIE_SERDES, 0x57160824);
3139 REG_WRITE(ah, AR_PCIE_SERDES, 0x25980579);
3140 REG_WRITE(ah, AR_PCIE_SERDES, 0x00000000);
3141 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
3142 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
3143 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007);
3144
3145 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
3146}
3147
3148static void ath9k_set_power_sleep(struct ath_hal *ah, int setChip)
3149{
3150 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
3151 if (setChip) {
3152 REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE,
3153 AR_RTC_FORCE_WAKE_EN);
3154 if (!AR_SREV_9100(ah))
3155 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
3156
3157 REG_CLR_BIT(ah, (u16) (AR_RTC_RESET),
3158 AR_RTC_RESET_EN);
3159 }
3160}
3161
3162static void ath9k_set_power_network_sleep(struct ath_hal *ah, int setChip)
3163{
3164 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
3165 if (setChip) {
3166 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
3167
3168 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
3169 REG_WRITE(ah, AR_RTC_FORCE_WAKE,
3170 AR_RTC_FORCE_WAKE_ON_INT);
3171 } else {
3172 REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE,
3173 AR_RTC_FORCE_WAKE_EN);
3174 }
3175 }
3176}
3177
3178static bool ath9k_hw_set_power_awake(struct ath_hal *ah,
3179 int setChip)
3180{
3181 u32 val;
3182 int i;
3183
3184 if (setChip) {
3185 if ((REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M) ==
3186 AR_RTC_STATUS_SHUTDOWN) {
3187 if (ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)
3188 != true) {
3189 return false;
3190 }
3191 }
3192 if (AR_SREV_9100(ah))
3193 REG_SET_BIT(ah, AR_RTC_RESET,
3194 AR_RTC_RESET_EN);
3195
3196 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
3197 AR_RTC_FORCE_WAKE_EN);
3198 udelay(50);
3199
3200 for (i = POWER_UP_TIME / 50; i > 0; i--) {
3201 val = REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M;
3202 if (val == AR_RTC_STATUS_ON)
3203 break;
3204 udelay(50);
3205 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
3206 AR_RTC_FORCE_WAKE_EN);
3207 }
3208 if (i == 0) {
3209 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
3210 "%s: Failed to wakeup in %uus\n",
3211 __func__, POWER_UP_TIME / 20);
3212 return false;
3213 }
3214 }
3215
3216 REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
3217 return true;
3218}
3219
3220bool ath9k_hw_setpower(struct ath_hal *ah,
3221 enum ath9k_power_mode mode)
3222{
3223 struct ath_hal_5416 *ahp = AH5416(ah);
3224 static const char *modes[] = {
3225 "AWAKE",
3226 "FULL-SLEEP",
3227 "NETWORK SLEEP",
3228 "UNDEFINED"
3229 };
3230 int status = true, setChip = true;
3231
3232 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, "%s: %s -> %s (%s)\n", __func__,
3233 modes[ahp->ah_powerMode], modes[mode],
3234 setChip ? "set chip " : "");
3235
3236 switch (mode) {
3237 case ATH9K_PM_AWAKE:
3238 status = ath9k_hw_set_power_awake(ah, setChip);
3239 break;
3240 case ATH9K_PM_FULL_SLEEP:
3241 ath9k_set_power_sleep(ah, setChip);
3242 ahp->ah_chipFullSleep = true;
3243 break;
3244 case ATH9K_PM_NETWORK_SLEEP:
3245 ath9k_set_power_network_sleep(ah, setChip);
3246 break;
3247 default:
3248 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
3249 "%s: unknown power mode %u\n", __func__, mode);
3250 return false;
3251 }
3252 ahp->ah_powerMode = mode;
3253 return status;
3254} 586}
3255 587
3256static struct ath_hal *ath9k_hw_do_attach(u16 devid, 588static struct ath_hal *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
3257 struct ath_softc *sc, 589 void __iomem *mem, int *status)
3258 void __iomem *mem,
3259 int *status)
3260{ 590{
3261 struct ath_hal_5416 *ahp; 591 struct ath_hal_5416 *ahp;
3262 struct ath_hal *ah; 592 struct ath_hal *ah;
@@ -3300,6 +630,7 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3300 SER_REG_MODE_OFF; 630 SER_REG_MODE_OFF;
3301 } 631 }
3302 } 632 }
633
3303 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 634 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
3304 "%s: serialize_regmode is %d\n", 635 "%s: serialize_regmode is %d\n",
3305 __func__, ah->ah_config.serialize_regmode); 636 __func__, ah->ah_config.serialize_regmode);
@@ -3309,9 +640,9 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3309 (ah->ah_macVersion != AR_SREV_VERSION_9160) && 640 (ah->ah_macVersion != AR_SREV_VERSION_9160) &&
3310 (!AR_SREV_9100(ah)) && (!AR_SREV_9280(ah))) { 641 (!AR_SREV_9100(ah)) && (!AR_SREV_9280(ah))) {
3311 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 642 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
3312 "%s: Mac Chip Rev 0x%02x.%x is not supported by " 643 "%s: Mac Chip Rev 0x%02x.%x is not supported by "
3313 "this driver\n", __func__, 644 "this driver\n", __func__,
3314 ah->ah_macVersion, ah->ah_macRev); 645 ah->ah_macVersion, ah->ah_macRev);
3315 ecode = -EOPNOTSUPP; 646 ecode = -EOPNOTSUPP;
3316 goto bad; 647 goto bad;
3317 } 648 }
@@ -3341,8 +672,7 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3341 ahp->ah_adcDcCalInitData.calData = 672 ahp->ah_adcDcCalInitData.calData =
3342 &adc_init_dc_cal; 673 &adc_init_dc_cal;
3343 } 674 }
3344 ahp->ah_suppCals = 675 ahp->ah_suppCals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL;
3345 ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL;
3346 } 676 }
3347 677
3348 if (AR_SREV_9160(ah)) { 678 if (AR_SREV_9160(ah)) {
@@ -3352,14 +682,13 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3352 } else { 682 } else {
3353 ahp->ah_ani_function = ATH9K_ANI_ALL; 683 ahp->ah_ani_function = ATH9K_ANI_ALL;
3354 if (AR_SREV_9280_10_OR_LATER(ah)) { 684 if (AR_SREV_9280_10_OR_LATER(ah)) {
3355 ahp->ah_ani_function &= 685 ahp->ah_ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;
3356 ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;
3357 } 686 }
3358 } 687 }
3359 688
3360 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 689 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
3361 "%s: This Mac Chip Rev 0x%02x.%x is \n", __func__, 690 "%s: This Mac Chip Rev 0x%02x.%x is \n", __func__,
3362 ah->ah_macVersion, ah->ah_macRev); 691 ah->ah_macVersion, ah->ah_macRev);
3363 692
3364 if (AR_SREV_9280_20_OR_LATER(ah)) { 693 if (AR_SREV_9280_20_OR_LATER(ah)) {
3365 INIT_INI_ARRAY(&ahp->ah_iniModes, ar9280Modes_9280_2, 694 INIT_INI_ARRAY(&ahp->ah_iniModes, ar9280Modes_9280_2,
@@ -3369,21 +698,16 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3369 698
3370 if (ah->ah_config.pcie_clock_req) { 699 if (ah->ah_config.pcie_clock_req) {
3371 INIT_INI_ARRAY(&ahp->ah_iniPcieSerdes, 700 INIT_INI_ARRAY(&ahp->ah_iniPcieSerdes,
3372 ar9280PciePhy_clkreq_off_L1_9280, 701 ar9280PciePhy_clkreq_off_L1_9280,
3373 ARRAY_SIZE 702 ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280),2);
3374 (ar9280PciePhy_clkreq_off_L1_9280),
3375 2);
3376 } else { 703 } else {
3377 INIT_INI_ARRAY(&ahp->ah_iniPcieSerdes, 704 INIT_INI_ARRAY(&ahp->ah_iniPcieSerdes,
3378 ar9280PciePhy_clkreq_always_on_L1_9280, 705 ar9280PciePhy_clkreq_always_on_L1_9280,
3379 ARRAY_SIZE 706 ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2);
3380 (ar9280PciePhy_clkreq_always_on_L1_9280),
3381 2);
3382 } 707 }
3383 INIT_INI_ARRAY(&ahp->ah_iniModesAdditional, 708 INIT_INI_ARRAY(&ahp->ah_iniModesAdditional,
3384 ar9280Modes_fast_clock_9280_2, 709 ar9280Modes_fast_clock_9280_2,
3385 ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 710 ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3);
3386 3);
3387 } else if (AR_SREV_9280_10_OR_LATER(ah)) { 711 } else if (AR_SREV_9280_10_OR_LATER(ah)) {
3388 INIT_INI_ARRAY(&ahp->ah_iniModes, ar9280Modes_9280, 712 INIT_INI_ARRAY(&ahp->ah_iniModes, ar9280Modes_9280,
3389 ARRAY_SIZE(ar9280Modes_9280), 6); 713 ARRAY_SIZE(ar9280Modes_9280), 6);
@@ -3469,7 +793,7 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3469 if (ah->ah_isPciExpress) 793 if (ah->ah_isPciExpress)
3470 ath9k_hw_configpcipowersave(ah, 0); 794 ath9k_hw_configpcipowersave(ah, 0);
3471 else 795 else
3472 ar5416DisablePciePhy(ah); 796 ath9k_hw_disablepcie(ah);
3473 797
3474 ecode = ath9k_hw_post_attach(ah); 798 ecode = ath9k_hw_post_attach(ah);
3475 if (ecode != 0) 799 if (ecode != 0)
@@ -3490,10 +814,9 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3490 } 814 }
3491 } 815 }
3492#endif 816#endif
3493
3494 if (!ath9k_hw_fill_cap_info(ah)) { 817 if (!ath9k_hw_fill_cap_info(ah)) {
3495 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 818 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
3496 "%s:failed ath9k_hw_fill_cap_info\n", __func__); 819 "%s:failed ath9k_hw_fill_cap_info\n", __func__);
3497 ecode = -EINVAL; 820 ecode = -EINVAL;
3498 goto bad; 821 goto bad;
3499 } 822 }
@@ -3501,8 +824,8 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3501 ecode = ath9k_hw_init_macaddr(ah); 824 ecode = ath9k_hw_init_macaddr(ah);
3502 if (ecode != 0) { 825 if (ecode != 0) {
3503 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 826 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
3504 "%s: failed initializing mac address\n", 827 "%s: failed initializing mac address\n",
3505 __func__); 828 __func__);
3506 goto bad; 829 goto bad;
3507 } 830 }
3508 831
@@ -3511,1106 +834,553 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid,
3511 else 834 else
3512 ah->ah_txTrigLevel = (AR_FTRIG_512B >> AR_FTRIG_S); 835 ah->ah_txTrigLevel = (AR_FTRIG_512B >> AR_FTRIG_S);
3513 836
3514#ifndef ATH_NF_PER_CHAN
3515
3516 ath9k_init_nfcal_hist_buffer(ah); 837 ath9k_init_nfcal_hist_buffer(ah);
3517#endif
3518 838
3519 return ah; 839 return ah;
3520
3521bad: 840bad:
3522 if (ahp) 841 if (ahp)
3523 ath9k_hw_detach((struct ath_hal *) ahp); 842 ath9k_hw_detach((struct ath_hal *) ahp);
3524 if (status) 843 if (status)
3525 *status = ecode; 844 *status = ecode;
845
3526 return NULL; 846 return NULL;
3527} 847}
3528 848
3529void ath9k_hw_detach(struct ath_hal *ah) 849static void ath9k_hw_init_bb(struct ath_hal *ah,
850 struct ath9k_channel *chan)
3530{ 851{
3531 if (!AR_SREV_9100(ah)) 852 u32 synthDelay;
3532 ath9k_hw_ani_detach(ah);
3533 ath9k_hw_rfdetach(ah);
3534 853
3535 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP); 854 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
3536 kfree(ah); 855 if (IS_CHAN_CCK(chan))
856 synthDelay = (4 * synthDelay) / 22;
857 else
858 synthDelay /= 10;
859
860 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
861
862 udelay(synthDelay + BASE_ACTIVATE_DELAY);
3537} 863}
3538 864
3539bool ath9k_get_channel_edges(struct ath_hal *ah, 865static void ath9k_hw_init_qos(struct ath_hal *ah)
3540 u16 flags, u16 *low,
3541 u16 *high)
3542{ 866{
3543 struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 867 REG_WRITE(ah, AR_MIC_QOS_CONTROL, 0x100aa);
868 REG_WRITE(ah, AR_MIC_QOS_SELECT, 0x3210);
3544 869
3545 if (flags & CHANNEL_5GHZ) { 870 REG_WRITE(ah, AR_QOS_NO_ACK,
3546 *low = pCap->low_5ghz_chan; 871 SM(2, AR_QOS_NO_ACK_TWO_BIT) |
3547 *high = pCap->high_5ghz_chan; 872 SM(5, AR_QOS_NO_ACK_BIT_OFF) |
3548 return true; 873 SM(0, AR_QOS_NO_ACK_BYTE_OFF));
3549 }
3550 if ((flags & CHANNEL_2GHZ)) {
3551 *low = pCap->low_2ghz_chan;
3552 *high = pCap->high_2ghz_chan;
3553 874
3554 return true; 875 REG_WRITE(ah, AR_TXOP_X, AR_TXOP_X_VAL);
3555 } 876 REG_WRITE(ah, AR_TXOP_0_3, 0xFFFFFFFF);
3556 return false; 877 REG_WRITE(ah, AR_TXOP_4_7, 0xFFFFFFFF);
878 REG_WRITE(ah, AR_TXOP_8_11, 0xFFFFFFFF);
879 REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF);
3557} 880}
3558 881
3559static inline bool ath9k_hw_fill_vpd_table(u8 pwrMin, 882static void ath9k_hw_init_pll(struct ath_hal *ah,
3560 u8 pwrMax, 883 struct ath9k_channel *chan)
3561 u8 *pPwrList,
3562 u8 *pVpdList,
3563 u16
3564 numIntercepts,
3565 u8 *pRetVpdList)
3566{ 884{
3567 u16 i, k; 885 u32 pll;
3568 u8 currPwr = pwrMin;
3569 u16 idxL = 0, idxR = 0;
3570
3571 for (i = 0; i <= (pwrMax - pwrMin) / 2; i++) {
3572 ath9k_hw_get_lower_upper_index(currPwr, pPwrList,
3573 numIntercepts, &(idxL),
3574 &(idxR));
3575 if (idxR < 1)
3576 idxR = 1;
3577 if (idxL == numIntercepts - 1)
3578 idxL = (u16) (numIntercepts - 2);
3579 if (pPwrList[idxL] == pPwrList[idxR])
3580 k = pVpdList[idxL];
3581 else
3582 k = (u16) (((currPwr -
3583 pPwrList[idxL]) *
3584 pVpdList[idxR] +
3585 (pPwrList[idxR] -
3586 currPwr) * pVpdList[idxL]) /
3587 (pPwrList[idxR] -
3588 pPwrList[idxL]));
3589 pRetVpdList[i] = (u8) k;
3590 currPwr += 2;
3591 }
3592 886
3593 return true; 887 if (AR_SREV_9100(ah)) {
3594} 888 if (chan && IS_CHAN_5GHZ(chan))
889 pll = 0x1450;
890 else
891 pll = 0x1458;
892 } else {
893 if (AR_SREV_9280_10_OR_LATER(ah)) {
894 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
3595 895
3596static void 896 if (chan && IS_CHAN_HALF_RATE(chan))
3597ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hal *ah, 897 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
3598 struct ath9k_channel *chan, 898 else if (chan && IS_CHAN_QUARTER_RATE(chan))
3599 struct cal_data_per_freq *pRawDataSet, 899 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
3600 u8 *bChans,
3601 u16 availPiers,
3602 u16 tPdGainOverlap,
3603 int16_t *pMinCalPower,
3604 u16 *pPdGainBoundaries,
3605 u8 *pPDADCValues,
3606 u16 numXpdGains)
3607{
3608 int i, j, k;
3609 int16_t ss;
3610 u16 idxL = 0, idxR = 0, numPiers;
3611 static u8 vpdTableL[AR5416_NUM_PD_GAINS]
3612 [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
3613 static u8 vpdTableR[AR5416_NUM_PD_GAINS]
3614 [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
3615 static u8 vpdTableI[AR5416_NUM_PD_GAINS]
3616 [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
3617
3618 u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
3619 u8 minPwrT4[AR5416_NUM_PD_GAINS];
3620 u8 maxPwrT4[AR5416_NUM_PD_GAINS];
3621 int16_t vpdStep;
3622 int16_t tmpVal;
3623 u16 sizeCurrVpdTable, maxIndex, tgtIndex;
3624 bool match;
3625 int16_t minDelta = 0;
3626 struct chan_centers centers;
3627 900
3628 ath9k_hw_get_channel_centers(ah, chan, &centers); 901 if (chan && IS_CHAN_5GHZ(chan)) {
902 pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
3629 903
3630 for (numPiers = 0; numPiers < availPiers; numPiers++) {
3631 if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
3632 break;
3633 }
3634 904
3635 match = ath9k_hw_get_lower_upper_index((u8) 905 if (AR_SREV_9280_20(ah)) {
3636 FREQ2FBIN(centers. 906 if (((chan->channel % 20) == 0)
3637 synth_center, 907 || ((chan->channel % 10) == 0))
3638 IS_CHAN_2GHZ 908 pll = 0x2850;
3639 (chan)), bChans, 909 else
3640 numPiers, &idxL, &idxR); 910 pll = 0x142c;
3641 911 }
3642 if (match) { 912 } else {
3643 for (i = 0; i < numXpdGains; i++) { 913 pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
3644 minPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][0];
3645 maxPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][4];
3646 ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
3647 pRawDataSet[idxL].
3648 pwrPdg[i],
3649 pRawDataSet[idxL].
3650 vpdPdg[i],
3651 AR5416_PD_GAIN_ICEPTS,
3652 vpdTableI[i]);
3653 }
3654 } else {
3655 for (i = 0; i < numXpdGains; i++) {
3656 pVpdL = pRawDataSet[idxL].vpdPdg[i];
3657 pPwrL = pRawDataSet[idxL].pwrPdg[i];
3658 pVpdR = pRawDataSet[idxR].vpdPdg[i];
3659 pPwrR = pRawDataSet[idxR].pwrPdg[i];
3660
3661 minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
3662
3663 maxPwrT4[i] =
3664 min(pPwrL[AR5416_PD_GAIN_ICEPTS - 1],
3665 pPwrR[AR5416_PD_GAIN_ICEPTS - 1]);
3666
3667
3668 ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
3669 pPwrL, pVpdL,
3670 AR5416_PD_GAIN_ICEPTS,
3671 vpdTableL[i]);
3672 ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
3673 pPwrR, pVpdR,
3674 AR5416_PD_GAIN_ICEPTS,
3675 vpdTableR[i]);
3676
3677 for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
3678 vpdTableI[i][j] =
3679 (u8) (ath9k_hw_interpolate
3680 ((u16)
3681 FREQ2FBIN(centers.
3682 synth_center,
3683 IS_CHAN_2GHZ
3684 (chan)),
3685 bChans[idxL],
3686 bChans[idxR], vpdTableL[i]
3687 [j], vpdTableR[i]
3688 [j]));
3689 } 914 }
3690 }
3691 }
3692 915
3693 *pMinCalPower = (int16_t) (minPwrT4[0] / 2); 916 } else if (AR_SREV_9160_10_OR_LATER(ah)) {
3694
3695 k = 0;
3696 for (i = 0; i < numXpdGains; i++) {
3697 if (i == (numXpdGains - 1))
3698 pPdGainBoundaries[i] =
3699 (u16) (maxPwrT4[i] / 2);
3700 else
3701 pPdGainBoundaries[i] =
3702 (u16) ((maxPwrT4[i] +
3703 minPwrT4[i + 1]) / 4);
3704 917
3705 pPdGainBoundaries[i] = 918 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
3706 min((u16) AR5416_MAX_RATE_POWER,
3707 pPdGainBoundaries[i]);
3708 919
3709 if ((i == 0) && !AR_SREV_5416_V20_OR_LATER(ah)) { 920 if (chan && IS_CHAN_HALF_RATE(chan))
3710 minDelta = pPdGainBoundaries[0] - 23; 921 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
3711 pPdGainBoundaries[0] = 23; 922 else if (chan && IS_CHAN_QUARTER_RATE(chan))
3712 } else { 923 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
3713 minDelta = 0;
3714 }
3715 924
3716 if (i == 0) { 925 if (chan && IS_CHAN_5GHZ(chan))
3717 if (AR_SREV_9280_10_OR_LATER(ah)) 926 pll |= SM(0x50, AR_RTC_9160_PLL_DIV);
3718 ss = (int16_t) (0 - (minPwrT4[i] / 2));
3719 else 927 else
3720 ss = 0; 928 pll |= SM(0x58, AR_RTC_9160_PLL_DIV);
3721 } else { 929 } else {
3722 ss = (int16_t) ((pPdGainBoundaries[i - 1] - 930 pll = AR_RTC_PLL_REFDIV_5 | AR_RTC_PLL_DIV2;
3723 (minPwrT4[i] / 2)) -
3724 tPdGainOverlap + 1 + minDelta);
3725 }
3726 vpdStep = (int16_t) (vpdTableI[i][1] - vpdTableI[i][0]);
3727 vpdStep = (int16_t) ((vpdStep < 1) ? 1 : vpdStep);
3728
3729 while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
3730 tmpVal = (int16_t) (vpdTableI[i][0] + ss * vpdStep);
3731 pPDADCValues[k++] =
3732 (u8) ((tmpVal < 0) ? 0 : tmpVal);
3733 ss++;
3734 }
3735
3736 sizeCurrVpdTable =
3737 (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
3738 tgtIndex = (u8) (pPdGainBoundaries[i] + tPdGainOverlap -
3739 (minPwrT4[i] / 2));
3740 maxIndex = (tgtIndex <
3741 sizeCurrVpdTable) ? tgtIndex : sizeCurrVpdTable;
3742 931
3743 while ((ss < maxIndex) 932 if (chan && IS_CHAN_HALF_RATE(chan))
3744 && (k < (AR5416_NUM_PDADC_VALUES - 1))) { 933 pll |= SM(0x1, AR_RTC_PLL_CLKSEL);
3745 pPDADCValues[k++] = vpdTableI[i][ss++]; 934 else if (chan && IS_CHAN_QUARTER_RATE(chan))
3746 } 935 pll |= SM(0x2, AR_RTC_PLL_CLKSEL);
3747 936
3748 vpdStep = (int16_t) (vpdTableI[i][sizeCurrVpdTable - 1] - 937 if (chan && IS_CHAN_5GHZ(chan))
3749 vpdTableI[i][sizeCurrVpdTable - 2]); 938 pll |= SM(0xa, AR_RTC_PLL_DIV);
3750 vpdStep = (int16_t) ((vpdStep < 1) ? 1 : vpdStep); 939 else
3751 940 pll |= SM(0xb, AR_RTC_PLL_DIV);
3752 if (tgtIndex > maxIndex) {
3753 while ((ss <= tgtIndex)
3754 && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
3755 tmpVal = (int16_t) ((vpdTableI[i]
3756 [sizeCurrVpdTable -
3757 1] + (ss - maxIndex +
3758 1) * vpdStep));
3759 pPDADCValues[k++] = (u8) ((tmpVal >
3760 255) ? 255 : tmpVal);
3761 ss++;
3762 }
3763 } 941 }
3764 } 942 }
943 REG_WRITE(ah, (u16) (AR_RTC_PLL_CONTROL), pll);
3765 944
3766 while (i < AR5416_PD_GAINS_IN_MASK) { 945 udelay(RTC_PLL_SETTLE_DELAY);
3767 pPdGainBoundaries[i] = pPdGainBoundaries[i - 1];
3768 i++;
3769 }
3770 946
3771 while (k < AR5416_NUM_PDADC_VALUES) { 947 REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK);
3772 pPDADCValues[k] = pPDADCValues[k - 1];
3773 k++;
3774 }
3775 return;
3776} 948}
3777 949
3778static bool 950static void ath9k_hw_init_chain_masks(struct ath_hal *ah)
3779ath9k_hw_set_power_cal_table(struct ath_hal *ah,
3780 struct ar5416_eeprom *pEepData,
3781 struct ath9k_channel *chan,
3782 int16_t *pTxPowerIndexOffset)
3783{ 951{
3784 struct cal_data_per_freq *pRawDataset;
3785 u8 *pCalBChans = NULL;
3786 u16 pdGainOverlap_t2;
3787 static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
3788 u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
3789 u16 numPiers, i, j;
3790 int16_t tMinCalPower;
3791 u16 numXpdGain, xpdMask;
3792 u16 xpdGainValues[AR5416_NUM_PD_GAINS] = { 0, 0, 0, 0 };
3793 u32 reg32, regOffset, regChainOffset;
3794 int16_t modalIdx;
3795 struct ath_hal_5416 *ahp = AH5416(ah); 952 struct ath_hal_5416 *ahp = AH5416(ah);
953 int rx_chainmask, tx_chainmask;
3796 954
3797 modalIdx = IS_CHAN_2GHZ(chan) ? 1 : 0; 955 rx_chainmask = ahp->ah_rxchainmask;
3798 xpdMask = pEepData->modalHeader[modalIdx].xpdGain; 956 tx_chainmask = ahp->ah_txchainmask;
3799
3800 if ((pEepData->baseEepHeader.
3801 version & AR5416_EEP_VER_MINOR_MASK) >=
3802 AR5416_EEP_MINOR_VER_2) {
3803 pdGainOverlap_t2 =
3804 pEepData->modalHeader[modalIdx].pdGainOverlap;
3805 } else {
3806 pdGainOverlap_t2 =
3807 (u16) (MS
3808 (REG_READ(ah, AR_PHY_TPCRG5),
3809 AR_PHY_TPCRG5_PD_GAIN_OVERLAP));
3810 }
3811
3812 if (IS_CHAN_2GHZ(chan)) {
3813 pCalBChans = pEepData->calFreqPier2G;
3814 numPiers = AR5416_NUM_2G_CAL_PIERS;
3815 } else {
3816 pCalBChans = pEepData->calFreqPier5G;
3817 numPiers = AR5416_NUM_5G_CAL_PIERS;
3818 }
3819
3820 numXpdGain = 0;
3821 957
3822 for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) { 958 switch (rx_chainmask) {
3823 if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) { 959 case 0x5:
3824 if (numXpdGain >= AR5416_NUM_PD_GAINS) 960 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
3825 break; 961 AR_PHY_SWAP_ALT_CHAIN);
3826 xpdGainValues[numXpdGain] = 962 case 0x3:
3827 (u16) (AR5416_PD_GAINS_IN_MASK - i); 963 if (((ah)->ah_macVersion <= AR_SREV_VERSION_9160)) {
3828 numXpdGain++; 964 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, 0x7);
965 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, 0x7);
966 break;
3829 } 967 }
968 case 0x1:
969 case 0x2:
970 if (!AR_SREV_9280(ah))
971 break;
972 case 0x7:
973 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx_chainmask);
974 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx_chainmask);
975 break;
976 default:
977 break;
3830 } 978 }
3831 979
3832 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_NUM_PD_GAIN, 980 REG_WRITE(ah, AR_SELFGEN_MASK, tx_chainmask);
3833 (numXpdGain - 1) & 0x3); 981 if (tx_chainmask == 0x5) {
3834 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_1, 982 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
3835 xpdGainValues[0]); 983 AR_PHY_SWAP_ALT_CHAIN);
3836 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_2,
3837 xpdGainValues[1]);
3838 REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_3,
3839 xpdGainValues[2]);
3840
3841 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
3842 if (AR_SREV_5416_V20_OR_LATER(ah) &&
3843 (ahp->ah_rxchainmask == 5 || ahp->ah_txchainmask == 5)
3844 && (i != 0)) {
3845 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
3846 } else
3847 regChainOffset = i * 0x1000;
3848 if (pEepData->baseEepHeader.txMask & (1 << i)) {
3849 if (IS_CHAN_2GHZ(chan))
3850 pRawDataset = pEepData->calPierData2G[i];
3851 else
3852 pRawDataset = pEepData->calPierData5G[i];
3853
3854 ath9k_hw_get_gain_boundaries_pdadcs(ah, chan,
3855 pRawDataset,
3856 pCalBChans,
3857 numPiers,
3858 pdGainOverlap_t2,
3859 &tMinCalPower,
3860 gainBoundaries,
3861 pdadcValues,
3862 numXpdGain);
3863
3864 if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) {
3865
3866 REG_WRITE(ah,
3867 AR_PHY_TPCRG5 + regChainOffset,
3868 SM(pdGainOverlap_t2,
3869 AR_PHY_TPCRG5_PD_GAIN_OVERLAP)
3870 | SM(gainBoundaries[0],
3871 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_1)
3872 | SM(gainBoundaries[1],
3873 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_2)
3874 | SM(gainBoundaries[2],
3875 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_3)
3876 | SM(gainBoundaries[3],
3877 AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4));
3878 }
3879
3880 regOffset =
3881 AR_PHY_BASE + (672 << 2) + regChainOffset;
3882 for (j = 0; j < 32; j++) {
3883 reg32 =
3884 ((pdadcValues[4 * j + 0] & 0xFF) << 0)
3885 | ((pdadcValues[4 * j + 1] & 0xFF) <<
3886 8) | ((pdadcValues[4 * j + 2] &
3887 0xFF) << 16) |
3888 ((pdadcValues[4 * j + 3] & 0xFF) <<
3889 24);
3890 REG_WRITE(ah, regOffset, reg32);
3891
3892 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
3893 "PDADC (%d,%4x): %4.4x %8.8x\n",
3894 i, regChainOffset, regOffset,
3895 reg32);
3896 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
3897 "PDADC: Chain %d | PDADC %3d Value %3d | "
3898 "PDADC %3d Value %3d | PDADC %3d Value %3d | "
3899 "PDADC %3d Value %3d |\n",
3900 i, 4 * j, pdadcValues[4 * j],
3901 4 * j + 1, pdadcValues[4 * j + 1],
3902 4 * j + 2, pdadcValues[4 * j + 2],
3903 4 * j + 3,
3904 pdadcValues[4 * j + 3]);
3905
3906 regOffset += 4;
3907 }
3908 }
3909 } 984 }
3910 *pTxPowerIndexOffset = 0; 985 if (AR_SREV_9100(ah))
3911 986 REG_WRITE(ah, AR_PHY_ANALOG_SWAP,
3912 return true; 987 REG_READ(ah, AR_PHY_ANALOG_SWAP) | 0x00000001);
3913} 988}
3914 989
3915void ath9k_hw_configpcipowersave(struct ath_hal *ah, int restore) 990static void ath9k_hw_init_interrupt_masks(struct ath_hal *ah, enum ath9k_opmode opmode)
3916{ 991{
3917 struct ath_hal_5416 *ahp = AH5416(ah); 992 struct ath_hal_5416 *ahp = AH5416(ah);
3918 u8 i;
3919
3920 if (ah->ah_isPciExpress != true)
3921 return;
3922 993
3923 if (ah->ah_config.pcie_powersave_enable == 2) 994 ahp->ah_maskReg = AR_IMR_TXERR |
3924 return; 995 AR_IMR_TXURN |
3925 996 AR_IMR_RXERR |
3926 if (restore) 997 AR_IMR_RXORN |
3927 return; 998 AR_IMR_BCNMISC;
3928
3929 if (AR_SREV_9280_20_OR_LATER(ah)) {
3930 for (i = 0; i < ahp->ah_iniPcieSerdes.ia_rows; i++) {
3931 REG_WRITE(ah, INI_RA(&ahp->ah_iniPcieSerdes, i, 0),
3932 INI_RA(&ahp->ah_iniPcieSerdes, i, 1));
3933 }
3934 udelay(1000);
3935 } else if (AR_SREV_9280(ah)
3936 && (ah->ah_macRev == AR_SREV_REVISION_9280_10)) {
3937 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00);
3938 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
3939 999
3940 REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019); 1000 if (ahp->ah_intrMitigation)
3941 REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820); 1001 ahp->ah_maskReg |= AR_IMR_RXINTM | AR_IMR_RXMINTR;
3942 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560); 1002 else
1003 ahp->ah_maskReg |= AR_IMR_RXOK;
3943 1004
3944 if (ah->ah_config.pcie_clock_req) 1005 ahp->ah_maskReg |= AR_IMR_TXOK;
3945 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc);
3946 else
3947 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd);
3948 1006
3949 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); 1007 if (opmode == ATH9K_M_HOSTAP)
3950 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554); 1008 ahp->ah_maskReg |= AR_IMR_MIB;
3951 REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007);
3952 1009
3953 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); 1010 REG_WRITE(ah, AR_IMR, ahp->ah_maskReg);
1011 REG_WRITE(ah, AR_IMR_S2, REG_READ(ah, AR_IMR_S2) | AR_IMR_S2_GTT);
3954 1012
3955 udelay(1000); 1013 if (!AR_SREV_9100(ah)) {
3956 } else { 1014 REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF);
3957 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); 1015 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, AR_INTR_SYNC_DEFAULT);
3958 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); 1016 REG_WRITE(ah, AR_INTR_SYNC_MASK, 0);
3959 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039);
3960 REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824);
3961 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579);
3962 REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff);
3963 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
3964 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
3965 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007);
3966 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
3967 } 1017 }
1018}
3968 1019
3969 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); 1020static bool ath9k_hw_set_ack_timeout(struct ath_hal *ah, u32 us)
1021{
1022 struct ath_hal_5416 *ahp = AH5416(ah);
3970 1023
3971 if (ah->ah_config.pcie_waen) { 1024 if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) {
3972 REG_WRITE(ah, AR_WA, ah->ah_config.pcie_waen); 1025 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: bad ack timeout %u\n",
1026 __func__, us);
1027 ahp->ah_acktimeout = (u32) -1;
1028 return false;
3973 } else { 1029 } else {
3974 if (AR_SREV_9280(ah)) 1030 REG_RMW_FIELD(ah, AR_TIME_OUT,
3975 REG_WRITE(ah, AR_WA, 0x0040073f); 1031 AR_TIME_OUT_ACK, ath9k_hw_mac_to_clks(ah, us));
3976 else 1032 ahp->ah_acktimeout = us;
3977 REG_WRITE(ah, AR_WA, 0x0000073f); 1033 return true;
3978 } 1034 }
3979} 1035}
3980 1036
3981static void 1037static bool ath9k_hw_set_cts_timeout(struct ath_hal *ah, u32 us)
3982ath9k_hw_get_legacy_target_powers(struct ath_hal *ah,
3983 struct ath9k_channel *chan,
3984 struct cal_target_power_leg *powInfo,
3985 u16 numChannels,
3986 struct cal_target_power_leg *pNewPower,
3987 u16 numRates,
3988 bool isExtTarget)
3989{ 1038{
3990 u16 clo, chi; 1039 struct ath_hal_5416 *ahp = AH5416(ah);
3991 int i;
3992 int matchIndex = -1, lowIndex = -1;
3993 u16 freq;
3994 struct chan_centers centers;
3995
3996 ath9k_hw_get_channel_centers(ah, chan, &centers);
3997 freq = (isExtTarget) ? centers.ext_center : centers.ctl_center;
3998 1040
3999 if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel, 1041 if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) {
4000 IS_CHAN_2GHZ(chan))) { 1042 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: bad cts timeout %u\n",
4001 matchIndex = 0; 1043 __func__, us);
1044 ahp->ah_ctstimeout = (u32) -1;
1045 return false;
4002 } else { 1046 } else {
4003 for (i = 0; (i < numChannels) 1047 REG_RMW_FIELD(ah, AR_TIME_OUT,
4004 && (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) { 1048 AR_TIME_OUT_CTS, ath9k_hw_mac_to_clks(ah, us));
4005 if (freq == 1049 ahp->ah_ctstimeout = us;
4006 ath9k_hw_fbin2freq(powInfo[i].bChannel, 1050 return true;
4007 IS_CHAN_2GHZ(chan))) {
4008 matchIndex = i;
4009 break;
4010 } else if ((freq <
4011 ath9k_hw_fbin2freq(powInfo[i].bChannel,
4012 IS_CHAN_2GHZ(chan)))
4013 && (freq >
4014 ath9k_hw_fbin2freq(powInfo[i - 1].
4015 bChannel,
4016 IS_CHAN_2GHZ
4017 (chan)))) {
4018 lowIndex = i - 1;
4019 break;
4020 }
4021 }
4022 if ((matchIndex == -1) && (lowIndex == -1))
4023 matchIndex = i - 1;
4024 } 1051 }
1052}
4025 1053
4026 if (matchIndex != -1) { 1054static bool ath9k_hw_set_global_txtimeout(struct ath_hal *ah, u32 tu)
4027 *pNewPower = powInfo[matchIndex]; 1055{
1056 struct ath_hal_5416 *ahp = AH5416(ah);
1057
1058 if (tu > 0xFFFF) {
1059 DPRINTF(ah->ah_sc, ATH_DBG_XMIT,
1060 "%s: bad global tx timeout %u\n", __func__, tu);
1061 ahp->ah_globaltxtimeout = (u32) -1;
1062 return false;
4028 } else { 1063 } else {
4029 clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel, 1064 REG_RMW_FIELD(ah, AR_GTXTO, AR_GTXTO_TIMEOUT_LIMIT, tu);
4030 IS_CHAN_2GHZ(chan)); 1065 ahp->ah_globaltxtimeout = tu;
4031 chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel, 1066 return true;
4032 IS_CHAN_2GHZ(chan));
4033
4034 for (i = 0; i < numRates; i++) {
4035 pNewPower->tPow2x[i] =
4036 (u8) ath9k_hw_interpolate(freq, clo, chi,
4037 powInfo
4038 [lowIndex].
4039 tPow2x[i],
4040 powInfo
4041 [lowIndex +
4042 1].tPow2x[i]);
4043 }
4044 } 1067 }
4045} 1068}
4046 1069
4047static void 1070static void ath9k_hw_init_user_settings(struct ath_hal *ah)
4048ath9k_hw_get_target_powers(struct ath_hal *ah,
4049 struct ath9k_channel *chan,
4050 struct cal_target_power_ht *powInfo,
4051 u16 numChannels,
4052 struct cal_target_power_ht *pNewPower,
4053 u16 numRates,
4054 bool isHt40Target)
4055{ 1071{
4056 u16 clo, chi; 1072 struct ath_hal_5416 *ahp = AH5416(ah);
4057 int i;
4058 int matchIndex = -1, lowIndex = -1;
4059 u16 freq;
4060 struct chan_centers centers;
4061 1073
4062 ath9k_hw_get_channel_centers(ah, chan, &centers); 1074 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "--AP %s ahp->ah_miscMode 0x%x\n",
4063 freq = isHt40Target ? centers.synth_center : centers.ctl_center; 1075 __func__, ahp->ah_miscMode);
4064 1076
4065 if (freq <= 1077 if (ahp->ah_miscMode != 0)
4066 ath9k_hw_fbin2freq(powInfo[0].bChannel, IS_CHAN_2GHZ(chan))) { 1078 REG_WRITE(ah, AR_PCU_MISC,
4067 matchIndex = 0; 1079 REG_READ(ah, AR_PCU_MISC) | ahp->ah_miscMode);
4068 } else { 1080 if (ahp->ah_slottime != (u32) -1)
4069 for (i = 0; (i < numChannels) 1081 ath9k_hw_setslottime(ah, ahp->ah_slottime);
4070 && (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) { 1082 if (ahp->ah_acktimeout != (u32) -1)
4071 if (freq == 1083 ath9k_hw_set_ack_timeout(ah, ahp->ah_acktimeout);
4072 ath9k_hw_fbin2freq(powInfo[i].bChannel, 1084 if (ahp->ah_ctstimeout != (u32) -1)
4073 IS_CHAN_2GHZ(chan))) { 1085 ath9k_hw_set_cts_timeout(ah, ahp->ah_ctstimeout);
4074 matchIndex = i; 1086 if (ahp->ah_globaltxtimeout != (u32) -1)
4075 break; 1087 ath9k_hw_set_global_txtimeout(ah, ahp->ah_globaltxtimeout);
4076 } else 1088}
4077 if ((freq <
4078 ath9k_hw_fbin2freq(powInfo[i].bChannel,
4079 IS_CHAN_2GHZ(chan)))
4080 && (freq >
4081 ath9k_hw_fbin2freq(powInfo[i - 1].
4082 bChannel,
4083 IS_CHAN_2GHZ
4084 (chan)))) {
4085 lowIndex = i - 1;
4086 break;
4087 }
4088 }
4089 if ((matchIndex == -1) && (lowIndex == -1))
4090 matchIndex = i - 1;
4091 }
4092 1089
4093 if (matchIndex != -1) { 1090const char *ath9k_hw_probe(u16 vendorid, u16 devid)
4094 *pNewPower = powInfo[matchIndex]; 1091{
4095 } else { 1092 return vendorid == ATHEROS_VENDOR_ID ?
4096 clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel, 1093 ath9k_hw_devname(devid) : NULL;
4097 IS_CHAN_2GHZ(chan));
4098 chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
4099 IS_CHAN_2GHZ(chan));
4100
4101 for (i = 0; i < numRates; i++) {
4102 pNewPower->tPow2x[i] =
4103 (u8) ath9k_hw_interpolate(freq, clo, chi,
4104 powInfo
4105 [lowIndex].
4106 tPow2x[i],
4107 powInfo
4108 [lowIndex +
4109 1].tPow2x[i]);
4110 }
4111 }
4112} 1094}
4113 1095
4114static u16 1096void ath9k_hw_detach(struct ath_hal *ah)
4115ath9k_hw_get_max_edge_power(u16 freq,
4116 struct cal_ctl_edges *pRdEdgesPower,
4117 bool is2GHz)
4118{ 1097{
4119 u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER; 1098 if (!AR_SREV_9100(ah))
4120 int i; 1099 ath9k_hw_ani_detach(ah);
4121 1100
4122 for (i = 0; (i < AR5416_NUM_BAND_EDGES) 1101 ath9k_hw_rfdetach(ah);
4123 && (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) { 1102 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
4124 if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, 1103 kfree(ah);
4125 is2GHz)) {
4126 twiceMaxEdgePower = pRdEdgesPower[i].tPower;
4127 break;
4128 } else if ((i > 0)
4129 && (freq <
4130 ath9k_hw_fbin2freq(pRdEdgesPower[i].
4131 bChannel, is2GHz))) {
4132 if (ath9k_hw_fbin2freq
4133 (pRdEdgesPower[i - 1].bChannel, is2GHz) < freq
4134 && pRdEdgesPower[i - 1].flag) {
4135 twiceMaxEdgePower =
4136 pRdEdgesPower[i - 1].tPower;
4137 }
4138 break;
4139 }
4140 }
4141 return twiceMaxEdgePower;
4142} 1104}
4143 1105
4144static bool 1106struct ath_hal *ath9k_hw_attach(u16 devid, struct ath_softc *sc,
4145ath9k_hw_set_power_per_rate_table(struct ath_hal *ah, 1107 void __iomem *mem, int *error)
4146 struct ar5416_eeprom *pEepData,
4147 struct ath9k_channel *chan,
4148 int16_t *ratesArray,
4149 u16 cfgCtl,
4150 u8 AntennaReduction,
4151 u8 twiceMaxRegulatoryPower,
4152 u8 powerLimit)
4153{ 1108{
4154 u8 twiceMaxEdgePower = AR5416_MAX_RATE_POWER; 1109 struct ath_hal *ah = NULL;
4155 static const u16 tpScaleReductionTable[5] =
4156 { 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
4157 1110
4158 int i; 1111 switch (devid) {
4159 int8_t twiceLargestAntenna; 1112 case AR5416_DEVID_PCI:
4160 struct cal_ctl_data *rep; 1113 case AR5416_DEVID_PCIE:
4161 struct cal_target_power_leg targetPowerOfdm, targetPowerCck = { 1114 case AR9160_DEVID_PCI:
4162 0, { 0, 0, 0, 0} 1115 case AR9280_DEVID_PCI:
4163 }; 1116 case AR9280_DEVID_PCIE:
4164 struct cal_target_power_leg targetPowerOfdmExt = { 1117 ah = ath9k_hw_do_attach(devid, sc, mem, error);
4165 0, { 0, 0, 0, 0} }, targetPowerCckExt = { 1118 break;
4166 0, { 0, 0, 0, 0 } 1119 default:
4167 }; 1120 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
4168 struct cal_target_power_ht targetPowerHt20, targetPowerHt40 = { 1121 "devid=0x%x not supported.\n", devid);
4169 0, {0, 0, 0, 0} 1122 ah = NULL;
4170 }; 1123 *error = -ENXIO;
4171 u8 scaledPower = 0, minCtlPower, maxRegAllowedPower; 1124 break;
4172 u16 ctlModesFor11a[] = 1125 }
4173 { CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40 };
4174 u16 ctlModesFor11g[] =
4175 { CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT, CTL_11G_EXT,
4176 CTL_2GHT40
4177 };
4178 u16 numCtlModes, *pCtlMode, ctlMode, freq;
4179 struct chan_centers centers;
4180 int tx_chainmask;
4181 u8 twiceMinEdgePower;
4182 struct ath_hal_5416 *ahp = AH5416(ah);
4183 1126
4184 tx_chainmask = ahp->ah_txchainmask; 1127 return ah;
1128}
4185 1129
4186 ath9k_hw_get_channel_centers(ah, chan, &centers); 1130/*******/
1131/* INI */
1132/*******/
1133
1134static void ath9k_hw_override_ini(struct ath_hal *ah,
1135 struct ath9k_channel *chan)
1136{
1137 if (!AR_SREV_5416_V20_OR_LATER(ah) ||
1138 AR_SREV_9280_10_OR_LATER(ah))
1139 return;
4187 1140
4188 twiceLargestAntenna = max( 1141 REG_WRITE(ah, 0x9800 + (651 << 2), 0x11);
4189 pEepData->modalHeader 1142}
4190 [IS_CHAN_2GHZ(chan)].antennaGainCh[0],
4191 pEepData->modalHeader
4192 [IS_CHAN_2GHZ(chan)].antennaGainCh[1]);
4193 1143
4194 twiceLargestAntenna = max((u8) twiceLargestAntenna, 1144static u32 ath9k_hw_ini_fixup(struct ath_hal *ah,
4195 pEepData->modalHeader 1145 struct ar5416_eeprom *pEepData,
4196 [IS_CHAN_2GHZ(chan)].antennaGainCh[2]); 1146 u32 reg, u32 value)
1147{
1148 struct base_eep_header *pBase = &(pEepData->baseEepHeader);
4197 1149
4198 twiceLargestAntenna = 1150 switch (ah->ah_devid) {
4199 (int8_t) min(AntennaReduction - twiceLargestAntenna, 0); 1151 case AR9280_DEVID_PCI:
1152 if (reg == 0x7894) {
1153 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
1154 "ini VAL: %x EEPROM: %x\n", value,
1155 (pBase->version & 0xff));
4200 1156
4201 maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna; 1157 if ((pBase->version & 0xff) > 0x0a) {
1158 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
1159 "PWDCLKIND: %d\n",
1160 pBase->pwdclkind);
1161 value &= ~AR_AN_TOP2_PWDCLKIND;
1162 value |= AR_AN_TOP2_PWDCLKIND &
1163 (pBase->pwdclkind << AR_AN_TOP2_PWDCLKIND_S);
1164 } else {
1165 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
1166 "PWDCLKIND Earlier Rev\n");
1167 }
4202 1168
4203 if (ah->ah_tpScale != ATH9K_TP_SCALE_MAX) { 1169 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
4204 maxRegAllowedPower -= 1170 "final ini VAL: %x\n", value);
4205 (tpScaleReductionTable[(ah->ah_tpScale)] * 2); 1171 }
1172 break;
4206 } 1173 }
4207 1174
4208 scaledPower = min(powerLimit, maxRegAllowedPower); 1175 return value;
1176}
4209 1177
4210 switch (ar5416_get_ntxchains(tx_chainmask)) { 1178static int ath9k_hw_process_ini(struct ath_hal *ah,
4211 case 1: 1179 struct ath9k_channel *chan,
1180 enum ath9k_ht_macmode macmode)
1181{
1182 int i, regWrites = 0;
1183 struct ath_hal_5416 *ahp = AH5416(ah);
1184 u32 modesIndex, freqIndex;
1185 int status;
1186
1187 switch (chan->chanmode) {
1188 case CHANNEL_A:
1189 case CHANNEL_A_HT20:
1190 modesIndex = 1;
1191 freqIndex = 1;
4212 break; 1192 break;
4213 case 2: 1193 case CHANNEL_A_HT40PLUS:
4214 scaledPower -= 1194 case CHANNEL_A_HT40MINUS:
4215 pEepData->modalHeader[IS_CHAN_2GHZ(chan)]. 1195 modesIndex = 2;
4216 pwrDecreaseFor2Chain; 1196 freqIndex = 1;
4217 break; 1197 break;
4218 case 3: 1198 case CHANNEL_G:
4219 scaledPower -= 1199 case CHANNEL_G_HT20:
4220 pEepData->modalHeader[IS_CHAN_2GHZ(chan)]. 1200 case CHANNEL_B:
4221 pwrDecreaseFor3Chain; 1201 modesIndex = 4;
1202 freqIndex = 2;
4222 break; 1203 break;
1204 case CHANNEL_G_HT40PLUS:
1205 case CHANNEL_G_HT40MINUS:
1206 modesIndex = 3;
1207 freqIndex = 2;
1208 break;
1209
1210 default:
1211 return -EINVAL;
4223 } 1212 }
4224 1213
4225 scaledPower = max(0, (int32_t) scaledPower); 1214 REG_WRITE(ah, AR_PHY(0), 0x00000007);
4226
4227 if (IS_CHAN_2GHZ(chan)) {
4228 numCtlModes =
4229 ARRAY_SIZE(ctlModesFor11g) -
4230 SUB_NUM_CTL_MODES_AT_2G_40;
4231 pCtlMode = ctlModesFor11g;
4232
4233 ath9k_hw_get_legacy_target_powers(ah, chan,
4234 pEepData->
4235 calTargetPowerCck,
4236 AR5416_NUM_2G_CCK_TARGET_POWERS,
4237 &targetPowerCck, 4,
4238 false);
4239 ath9k_hw_get_legacy_target_powers(ah, chan,
4240 pEepData->
4241 calTargetPower2G,
4242 AR5416_NUM_2G_20_TARGET_POWERS,
4243 &targetPowerOfdm, 4,
4244 false);
4245 ath9k_hw_get_target_powers(ah, chan,
4246 pEepData->calTargetPower2GHT20,
4247 AR5416_NUM_2G_20_TARGET_POWERS,
4248 &targetPowerHt20, 8, false);
4249 1215
4250 if (IS_CHAN_HT40(chan)) { 1216 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO);
4251 numCtlModes = ARRAY_SIZE(ctlModesFor11g); 1217
4252 ath9k_hw_get_target_powers(ah, chan, 1218 ath9k_hw_set_addac(ah, chan);
4253 pEepData-> 1219
4254 calTargetPower2GHT40, 1220 if (AR_SREV_5416_V22_OR_LATER(ah)) {
4255 AR5416_NUM_2G_40_TARGET_POWERS, 1221 REG_WRITE_ARRAY(&ahp->ah_iniAddac, 1, regWrites);
4256 &targetPowerHt40, 8,
4257 true);
4258 ath9k_hw_get_legacy_target_powers(ah, chan,
4259 pEepData->
4260 calTargetPowerCck,
4261 AR5416_NUM_2G_CCK_TARGET_POWERS,
4262 &targetPowerCckExt,
4263 4, true);
4264 ath9k_hw_get_legacy_target_powers(ah, chan,
4265 pEepData->
4266 calTargetPower2G,
4267 AR5416_NUM_2G_20_TARGET_POWERS,
4268 &targetPowerOfdmExt,
4269 4, true);
4270 }
4271 } else { 1222 } else {
1223 struct ar5416IniArray temp;
1224 u32 addacSize =
1225 sizeof(u32) * ahp->ah_iniAddac.ia_rows *
1226 ahp->ah_iniAddac.ia_columns;
4272 1227
4273 numCtlModes = 1228 memcpy(ahp->ah_addac5416_21,
4274 ARRAY_SIZE(ctlModesFor11a) - 1229 ahp->ah_iniAddac.ia_array, addacSize);
4275 SUB_NUM_CTL_MODES_AT_5G_40;
4276 pCtlMode = ctlModesFor11a;
4277
4278 ath9k_hw_get_legacy_target_powers(ah, chan,
4279 pEepData->
4280 calTargetPower5G,
4281 AR5416_NUM_5G_20_TARGET_POWERS,
4282 &targetPowerOfdm, 4,
4283 false);
4284 ath9k_hw_get_target_powers(ah, chan,
4285 pEepData->calTargetPower5GHT20,
4286 AR5416_NUM_5G_20_TARGET_POWERS,
4287 &targetPowerHt20, 8, false);
4288 1230
4289 if (IS_CHAN_HT40(chan)) { 1231 (ahp->ah_addac5416_21)[31 * ahp->ah_iniAddac.ia_columns + 1] = 0;
4290 numCtlModes = ARRAY_SIZE(ctlModesFor11a);
4291 ath9k_hw_get_target_powers(ah, chan,
4292 pEepData->
4293 calTargetPower5GHT40,
4294 AR5416_NUM_5G_40_TARGET_POWERS,
4295 &targetPowerHt40, 8,
4296 true);
4297 ath9k_hw_get_legacy_target_powers(ah, chan,
4298 pEepData->
4299 calTargetPower5G,
4300 AR5416_NUM_5G_20_TARGET_POWERS,
4301 &targetPowerOfdmExt,
4302 4, true);
4303 }
4304 }
4305 1232
4306 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) { 1233 temp.ia_array = ahp->ah_addac5416_21;
4307 bool isHt40CtlMode = 1234 temp.ia_columns = ahp->ah_iniAddac.ia_columns;
4308 (pCtlMode[ctlMode] == CTL_5GHT40) 1235 temp.ia_rows = ahp->ah_iniAddac.ia_rows;
4309 || (pCtlMode[ctlMode] == CTL_2GHT40); 1236 REG_WRITE_ARRAY(&temp, 1, regWrites);
4310 if (isHt40CtlMode) 1237 }
4311 freq = centers.synth_center;
4312 else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
4313 freq = centers.ext_center;
4314 else
4315 freq = centers.ctl_center;
4316 1238
4317 if (ar5416_get_eep_ver(ahp) == 14 1239 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC);
4318 && ar5416_get_eep_rev(ahp) <= 2)
4319 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
4320 1240
4321 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, 1241 for (i = 0; i < ahp->ah_iniModes.ia_rows; i++) {
4322 "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, " 1242 u32 reg = INI_RA(&ahp->ah_iniModes, i, 0);
4323 "EXT_ADDITIVE %d\n", 1243 u32 val = INI_RA(&ahp->ah_iniModes, i, modesIndex);
4324 ctlMode, numCtlModes, isHt40CtlMode,
4325 (pCtlMode[ctlMode] & EXT_ADDITIVE));
4326 1244
4327 for (i = 0; (i < AR5416_NUM_CTLS) && pEepData->ctlIndex[i]; 1245#ifdef CONFIG_SLOW_ANT_DIV
4328 i++) { 1246 if (ah->ah_devid == AR9280_DEVID_PCI)
4329 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, 1247 val = ath9k_hw_ini_fixup(ah, &ahp->ah_eeprom, reg, val);
4330 " LOOP-Ctlidx %d: cfgCtl 0x%2.2x " 1248#endif
4331 "pCtlMode 0x%2.2x ctlIndex 0x%2.2x "
4332 "chan %d\n",
4333 i, cfgCtl, pCtlMode[ctlMode],
4334 pEepData->ctlIndex[i], chan->channel);
4335
4336 if ((((cfgCtl & ~CTL_MODE_M) |
4337 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
4338 pEepData->ctlIndex[i])
4339 ||
4340 (((cfgCtl & ~CTL_MODE_M) |
4341 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
4342 ((pEepData->
4343 ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))) {
4344 rep = &(pEepData->ctlData[i]);
4345
4346 twiceMinEdgePower =
4347 ath9k_hw_get_max_edge_power(freq,
4348 rep->
4349 ctlEdges
4350 [ar5416_get_ntxchains
4351 (tx_chainmask)
4352 - 1],
4353 IS_CHAN_2GHZ
4354 (chan));
4355
4356 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
4357 " MATCH-EE_IDX %d: ch %d is2 %d "
4358 "2xMinEdge %d chainmask %d chains %d\n",
4359 i, freq, IS_CHAN_2GHZ(chan),
4360 twiceMinEdgePower, tx_chainmask,
4361 ar5416_get_ntxchains
4362 (tx_chainmask));
4363 if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL) {
4364 twiceMaxEdgePower =
4365 min(twiceMaxEdgePower,
4366 twiceMinEdgePower);
4367 } else {
4368 twiceMaxEdgePower =
4369 twiceMinEdgePower;
4370 break;
4371 }
4372 }
4373 }
4374 1249
4375 minCtlPower = min(twiceMaxEdgePower, scaledPower); 1250 REG_WRITE(ah, reg, val);
4376 1251
4377 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, 1252 if (reg >= 0x7800 && reg < 0x78a0
4378 " SEL-Min ctlMode %d pCtlMode %d " 1253 && ah->ah_config.analog_shiftreg) {
4379 "2xMaxEdge %d sP %d minCtlPwr %d\n", 1254 udelay(100);
4380 ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
4381 scaledPower, minCtlPower);
4382
4383 switch (pCtlMode[ctlMode]) {
4384 case CTL_11B:
4385 for (i = 0; i < ARRAY_SIZE(targetPowerCck.tPow2x);
4386 i++) {
4387 targetPowerCck.tPow2x[i] =
4388 min(targetPowerCck.tPow2x[i],
4389 minCtlPower);
4390 }
4391 break;
4392 case CTL_11A:
4393 case CTL_11G:
4394 for (i = 0; i < ARRAY_SIZE(targetPowerOfdm.tPow2x);
4395 i++) {
4396 targetPowerOfdm.tPow2x[i] =
4397 min(targetPowerOfdm.tPow2x[i],
4398 minCtlPower);
4399 }
4400 break;
4401 case CTL_5GHT20:
4402 case CTL_2GHT20:
4403 for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x);
4404 i++) {
4405 targetPowerHt20.tPow2x[i] =
4406 min(targetPowerHt20.tPow2x[i],
4407 minCtlPower);
4408 }
4409 break;
4410 case CTL_11B_EXT:
4411 targetPowerCckExt.tPow2x[0] =
4412 min(targetPowerCckExt.tPow2x[0], minCtlPower);
4413 break;
4414 case CTL_11A_EXT:
4415 case CTL_11G_EXT:
4416 targetPowerOfdmExt.tPow2x[0] =
4417 min(targetPowerOfdmExt.tPow2x[0], minCtlPower);
4418 break;
4419 case CTL_5GHT40:
4420 case CTL_2GHT40:
4421 for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x);
4422 i++) {
4423 targetPowerHt40.tPow2x[i] =
4424 min(targetPowerHt40.tPow2x[i],
4425 minCtlPower);
4426 }
4427 break;
4428 default:
4429 break;
4430 } 1255 }
4431 }
4432 1256
4433 ratesArray[rate6mb] = ratesArray[rate9mb] = ratesArray[rate12mb] = 1257 DO_DELAY(regWrites);
4434 ratesArray[rate18mb] = ratesArray[rate24mb] =
4435 targetPowerOfdm.tPow2x[0];
4436 ratesArray[rate36mb] = targetPowerOfdm.tPow2x[1];
4437 ratesArray[rate48mb] = targetPowerOfdm.tPow2x[2];
4438 ratesArray[rate54mb] = targetPowerOfdm.tPow2x[3];
4439 ratesArray[rateXr] = targetPowerOfdm.tPow2x[0];
4440
4441 for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x); i++)
4442 ratesArray[rateHt20_0 + i] = targetPowerHt20.tPow2x[i];
4443
4444 if (IS_CHAN_2GHZ(chan)) {
4445 ratesArray[rate1l] = targetPowerCck.tPow2x[0];
4446 ratesArray[rate2s] = ratesArray[rate2l] =
4447 targetPowerCck.tPow2x[1];
4448 ratesArray[rate5_5s] = ratesArray[rate5_5l] =
4449 targetPowerCck.tPow2x[2];
4450 ;
4451 ratesArray[rate11s] = ratesArray[rate11l] =
4452 targetPowerCck.tPow2x[3];
4453 ;
4454 } 1258 }
4455 if (IS_CHAN_HT40(chan)) { 1259
4456 for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) { 1260 for (i = 0; i < ahp->ah_iniCommon.ia_rows; i++) {
4457 ratesArray[rateHt40_0 + i] = 1261 u32 reg = INI_RA(&ahp->ah_iniCommon, i, 0);
4458 targetPowerHt40.tPow2x[i]; 1262 u32 val = INI_RA(&ahp->ah_iniCommon, i, 1);
4459 } 1263
4460 ratesArray[rateDupOfdm] = targetPowerHt40.tPow2x[0]; 1264 REG_WRITE(ah, reg, val);
4461 ratesArray[rateDupCck] = targetPowerHt40.tPow2x[0]; 1265
4462 ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0]; 1266 if (reg >= 0x7800 && reg < 0x78a0
4463 if (IS_CHAN_2GHZ(chan)) { 1267 && ah->ah_config.analog_shiftreg) {
4464 ratesArray[rateExtCck] = 1268 udelay(100);
4465 targetPowerCckExt.tPow2x[0];
4466 } 1269 }
4467 }
4468 return true;
4469}
4470 1270
4471static int 1271 DO_DELAY(regWrites);
4472ath9k_hw_set_txpower(struct ath_hal *ah, 1272 }
4473 struct ar5416_eeprom *pEepData,
4474 struct ath9k_channel *chan,
4475 u16 cfgCtl,
4476 u8 twiceAntennaReduction,
4477 u8 twiceMaxRegulatoryPower,
4478 u8 powerLimit)
4479{
4480 struct modal_eep_header *pModal =
4481 &(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]);
4482 int16_t ratesArray[Ar5416RateSize];
4483 int16_t txPowerIndexOffset = 0;
4484 u8 ht40PowerIncForPdadc = 2;
4485 int i;
4486 1273
4487 memset(ratesArray, 0, sizeof(ratesArray)); 1274 ath9k_hw_write_regs(ah, modesIndex, freqIndex, regWrites);
4488 1275
4489 if ((pEepData->baseEepHeader. 1276 if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) {
4490 version & AR5416_EEP_VER_MINOR_MASK) >= 1277 REG_WRITE_ARRAY(&ahp->ah_iniModesAdditional, modesIndex,
4491 AR5416_EEP_MINOR_VER_2) { 1278 regWrites);
4492 ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
4493 } 1279 }
4494 1280
4495 if (!ath9k_hw_set_power_per_rate_table(ah, pEepData, chan, 1281 ath9k_hw_override_ini(ah, chan);
4496 &ratesArray[0], cfgCtl, 1282 ath9k_hw_set_regs(ah, chan, macmode);
4497 twiceAntennaReduction, 1283 ath9k_hw_init_chain_masks(ah);
4498 twiceMaxRegulatoryPower, 1284
4499 powerLimit)) { 1285 status = ath9k_hw_set_txpower(ah, chan,
4500 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 1286 ath9k_regd_get_ctl(ah, chan),
4501 "ath9k_hw_set_txpower: unable to set " 1287 ath9k_regd_get_antenna_allowed(ah,
4502 "tx power per rate table\n"); 1288 chan),
1289 chan->maxRegTxPower * 2,
1290 min((u32) MAX_RATE_POWER,
1291 (u32) ah->ah_powerLimit));
1292 if (status != 0) {
1293 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
1294 "%s: error init'ing transmit power\n", __func__);
4503 return -EIO; 1295 return -EIO;
4504 } 1296 }
4505 1297
4506 if (!ath9k_hw_set_power_cal_table 1298 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
4507 (ah, pEepData, chan, &txPowerIndexOffset)) { 1299 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
4508 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 1300 "%s: ar5416SetRfRegs failed\n", __func__);
4509 "ath9k_hw_set_txpower: unable to set power table\n");
4510 return -EIO; 1301 return -EIO;
4511 } 1302 }
4512 1303
4513 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) { 1304 return 0;
4514 ratesArray[i] = 1305}
4515 (int16_t) (txPowerIndexOffset + ratesArray[i]);
4516 if (ratesArray[i] > AR5416_MAX_RATE_POWER)
4517 ratesArray[i] = AR5416_MAX_RATE_POWER;
4518 }
4519 1306
4520 if (AR_SREV_9280_10_OR_LATER(ah)) { 1307/****************************************/
4521 for (i = 0; i < Ar5416RateSize; i++) 1308/* Reset and Channel Switching Routines */
4522 ratesArray[i] -= AR5416_PWR_TABLE_OFFSET * 2; 1309/****************************************/
4523 }
4524 1310
4525 REG_WRITE(ah, AR_PHY_POWER_TX_RATE1, 1311static void ath9k_hw_set_rfmode(struct ath_hal *ah, struct ath9k_channel *chan)
4526 ATH9K_POW_SM(ratesArray[rate18mb], 24) 1312{
4527 | ATH9K_POW_SM(ratesArray[rate12mb], 16) 1313 u32 rfMode = 0;
4528 | ATH9K_POW_SM(ratesArray[rate9mb], 8)
4529 | ATH9K_POW_SM(ratesArray[rate6mb], 0)
4530 );
4531 REG_WRITE(ah, AR_PHY_POWER_TX_RATE2,
4532 ATH9K_POW_SM(ratesArray[rate54mb], 24)
4533 | ATH9K_POW_SM(ratesArray[rate48mb], 16)
4534 | ATH9K_POW_SM(ratesArray[rate36mb], 8)
4535 | ATH9K_POW_SM(ratesArray[rate24mb], 0)
4536 );
4537
4538 if (IS_CHAN_2GHZ(chan)) {
4539 REG_WRITE(ah, AR_PHY_POWER_TX_RATE3,
4540 ATH9K_POW_SM(ratesArray[rate2s], 24)
4541 | ATH9K_POW_SM(ratesArray[rate2l], 16)
4542 | ATH9K_POW_SM(ratesArray[rateXr], 8)
4543 | ATH9K_POW_SM(ratesArray[rate1l], 0)
4544 );
4545 REG_WRITE(ah, AR_PHY_POWER_TX_RATE4,
4546 ATH9K_POW_SM(ratesArray[rate11s], 24)
4547 | ATH9K_POW_SM(ratesArray[rate11l], 16)
4548 | ATH9K_POW_SM(ratesArray[rate5_5s], 8)
4549 | ATH9K_POW_SM(ratesArray[rate5_5l], 0)
4550 );
4551 }
4552 1314
4553 REG_WRITE(ah, AR_PHY_POWER_TX_RATE5, 1315 if (chan == NULL)
4554 ATH9K_POW_SM(ratesArray[rateHt20_3], 24) 1316 return;
4555 | ATH9K_POW_SM(ratesArray[rateHt20_2], 16)
4556 | ATH9K_POW_SM(ratesArray[rateHt20_1], 8)
4557 | ATH9K_POW_SM(ratesArray[rateHt20_0], 0)
4558 );
4559 REG_WRITE(ah, AR_PHY_POWER_TX_RATE6,
4560 ATH9K_POW_SM(ratesArray[rateHt20_7], 24)
4561 | ATH9K_POW_SM(ratesArray[rateHt20_6], 16)
4562 | ATH9K_POW_SM(ratesArray[rateHt20_5], 8)
4563 | ATH9K_POW_SM(ratesArray[rateHt20_4], 0)
4564 );
4565 1317
4566 if (IS_CHAN_HT40(chan)) { 1318 rfMode |= (IS_CHAN_B(chan) || IS_CHAN_G(chan))
4567 REG_WRITE(ah, AR_PHY_POWER_TX_RATE7, 1319 ? AR_PHY_MODE_DYNAMIC : AR_PHY_MODE_OFDM;
4568 ATH9K_POW_SM(ratesArray[rateHt40_3] +
4569 ht40PowerIncForPdadc, 24)
4570 | ATH9K_POW_SM(ratesArray[rateHt40_2] +
4571 ht40PowerIncForPdadc, 16)
4572 | ATH9K_POW_SM(ratesArray[rateHt40_1] +
4573 ht40PowerIncForPdadc, 8)
4574 | ATH9K_POW_SM(ratesArray[rateHt40_0] +
4575 ht40PowerIncForPdadc, 0)
4576 );
4577 REG_WRITE(ah, AR_PHY_POWER_TX_RATE8,
4578 ATH9K_POW_SM(ratesArray[rateHt40_7] +
4579 ht40PowerIncForPdadc, 24)
4580 | ATH9K_POW_SM(ratesArray[rateHt40_6] +
4581 ht40PowerIncForPdadc, 16)
4582 | ATH9K_POW_SM(ratesArray[rateHt40_5] +
4583 ht40PowerIncForPdadc, 8)
4584 | ATH9K_POW_SM(ratesArray[rateHt40_4] +
4585 ht40PowerIncForPdadc, 0)
4586 );
4587
4588 REG_WRITE(ah, AR_PHY_POWER_TX_RATE9,
4589 ATH9K_POW_SM(ratesArray[rateExtOfdm], 24)
4590 | ATH9K_POW_SM(ratesArray[rateExtCck], 16)
4591 | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
4592 | ATH9K_POW_SM(ratesArray[rateDupCck], 0)
4593 );
4594 }
4595 1320
4596 REG_WRITE(ah, AR_PHY_POWER_TX_SUB, 1321 if (!AR_SREV_9280_10_OR_LATER(ah))
4597 ATH9K_POW_SM(pModal->pwrDecreaseFor3Chain, 6) 1322 rfMode |= (IS_CHAN_5GHZ(chan)) ?
4598 | ATH9K_POW_SM(pModal->pwrDecreaseFor2Chain, 0) 1323 AR_PHY_MODE_RF5GHZ : AR_PHY_MODE_RF2GHZ;
4599 );
4600 1324
4601 i = rate6mb; 1325 if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan))
4602 if (IS_CHAN_HT40(chan)) 1326 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
4603 i = rateHt40_0;
4604 else if (IS_CHAN_HT20(chan))
4605 i = rateHt20_0;
4606 1327
4607 if (AR_SREV_9280_10_OR_LATER(ah)) 1328 REG_WRITE(ah, AR_PHY_MODE, rfMode);
4608 ah->ah_maxPowerLevel = 1329}
4609 ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
4610 else
4611 ah->ah_maxPowerLevel = ratesArray[i];
4612 1330
4613 return 0; 1331static void ath9k_hw_mark_phy_inactive(struct ath_hal *ah)
1332{
1333 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
1334}
1335
1336static inline void ath9k_hw_set_dma(struct ath_hal *ah)
1337{
1338 u32 regval;
1339
1340 regval = REG_READ(ah, AR_AHB_MODE);
1341 REG_WRITE(ah, AR_AHB_MODE, regval | AR_AHB_PREFETCH_RD_EN);
1342
1343 regval = REG_READ(ah, AR_TXCFG) & ~AR_TXCFG_DMASZ_MASK;
1344 REG_WRITE(ah, AR_TXCFG, regval | AR_TXCFG_DMASZ_128B);
1345
1346 REG_RMW_FIELD(ah, AR_TXCFG, AR_FTRIG, ah->ah_txTrigLevel);
1347
1348 regval = REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_DMASZ_MASK;
1349 REG_WRITE(ah, AR_RXCFG, regval | AR_RXCFG_DMASZ_128B);
1350
1351 REG_WRITE(ah, AR_RXFIFO_CFG, 0x200);
1352
1353 if (AR_SREV_9285(ah)) {
1354 REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
1355 AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE);
1356 } else {
1357 REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
1358 AR_PCU_TXBUF_CTRL_USABLE_SIZE);
1359 }
1360}
1361
1362static void ath9k_hw_set_operating_mode(struct ath_hal *ah, int opmode)
1363{
1364 u32 val;
1365
1366 val = REG_READ(ah, AR_STA_ID1);
1367 val &= ~(AR_STA_ID1_STA_AP | AR_STA_ID1_ADHOC);
1368 switch (opmode) {
1369 case ATH9K_M_HOSTAP:
1370 REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_STA_AP
1371 | AR_STA_ID1_KSRCH_MODE);
1372 REG_CLR_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
1373 break;
1374 case ATH9K_M_IBSS:
1375 REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_ADHOC
1376 | AR_STA_ID1_KSRCH_MODE);
1377 REG_SET_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
1378 break;
1379 case ATH9K_M_STA:
1380 case ATH9K_M_MONITOR:
1381 REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_KSRCH_MODE);
1382 break;
1383 }
4614} 1384}
4615 1385
4616static inline void ath9k_hw_get_delta_slope_vals(struct ath_hal *ah, 1386static inline void ath9k_hw_get_delta_slope_vals(struct ath_hal *ah,
@@ -4632,9 +1402,8 @@ static inline void ath9k_hw_get_delta_slope_vals(struct ath_hal *ah,
4632 *coef_exponent = coef_exp - 16; 1402 *coef_exponent = coef_exp - 16;
4633} 1403}
4634 1404
4635static void 1405static void ath9k_hw_set_delta_slope(struct ath_hal *ah,
4636ath9k_hw_set_delta_slope(struct ath_hal *ah, 1406 struct ath9k_channel *chan)
4637 struct ath9k_channel *chan)
4638{ 1407{
4639 u32 coef_scaled, ds_coef_exp, ds_coef_man; 1408 u32 coef_scaled, ds_coef_exp, ds_coef_man;
4640 u32 clockMhzScaled = 0x64000000; 1409 u32 clockMhzScaled = 0x64000000;
@@ -4667,8 +1436,242 @@ ath9k_hw_set_delta_slope(struct ath_hal *ah,
4667 AR_PHY_HALFGI_DSC_EXP, ds_coef_exp); 1436 AR_PHY_HALFGI_DSC_EXP, ds_coef_exp);
4668} 1437}
4669 1438
4670static void ath9k_hw_9280_spur_mitigate(struct ath_hal *ah, 1439static bool ath9k_hw_set_reset(struct ath_hal *ah, int type)
4671 struct ath9k_channel *chan) 1440{
1441 u32 rst_flags;
1442 u32 tmpReg;
1443
1444 REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN |
1445 AR_RTC_FORCE_WAKE_ON_INT);
1446
1447 if (AR_SREV_9100(ah)) {
1448 rst_flags = AR_RTC_RC_MAC_WARM | AR_RTC_RC_MAC_COLD |
1449 AR_RTC_RC_COLD_RESET | AR_RTC_RC_WARM_RESET;
1450 } else {
1451 tmpReg = REG_READ(ah, AR_INTR_SYNC_CAUSE);
1452 if (tmpReg &
1453 (AR_INTR_SYNC_LOCAL_TIMEOUT |
1454 AR_INTR_SYNC_RADM_CPL_TIMEOUT)) {
1455 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
1456 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
1457 } else {
1458 REG_WRITE(ah, AR_RC, AR_RC_AHB);
1459 }
1460
1461 rst_flags = AR_RTC_RC_MAC_WARM;
1462 if (type == ATH9K_RESET_COLD)
1463 rst_flags |= AR_RTC_RC_MAC_COLD;
1464 }
1465
1466 REG_WRITE(ah, (u16) (AR_RTC_RC), rst_flags);
1467 udelay(50);
1468
1469 REG_WRITE(ah, (u16) (AR_RTC_RC), 0);
1470 if (!ath9k_hw_wait(ah, (u16) (AR_RTC_RC), AR_RTC_RC_M, 0)) {
1471 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
1472 "%s: RTC stuck in MAC reset\n",
1473 __func__);
1474 return false;
1475 }
1476
1477 if (!AR_SREV_9100(ah))
1478 REG_WRITE(ah, AR_RC, 0);
1479
1480 ath9k_hw_init_pll(ah, NULL);
1481
1482 if (AR_SREV_9100(ah))
1483 udelay(50);
1484
1485 return true;
1486}
1487
1488static bool ath9k_hw_set_reset_power_on(struct ath_hal *ah)
1489{
1490 REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN |
1491 AR_RTC_FORCE_WAKE_ON_INT);
1492
1493 REG_WRITE(ah, (u16) (AR_RTC_RESET), 0);
1494 REG_WRITE(ah, (u16) (AR_RTC_RESET), 1);
1495
1496 if (!ath9k_hw_wait(ah,
1497 AR_RTC_STATUS,
1498 AR_RTC_STATUS_M,
1499 AR_RTC_STATUS_ON)) {
1500 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: RTC not waking up\n",
1501 __func__);
1502 return false;
1503 }
1504
1505 ath9k_hw_read_revisions(ah);
1506
1507 return ath9k_hw_set_reset(ah, ATH9K_RESET_WARM);
1508}
1509
1510static bool ath9k_hw_set_reset_reg(struct ath_hal *ah, u32 type)
1511{
1512 REG_WRITE(ah, AR_RTC_FORCE_WAKE,
1513 AR_RTC_FORCE_WAKE_EN | AR_RTC_FORCE_WAKE_ON_INT);
1514
1515 switch (type) {
1516 case ATH9K_RESET_POWER_ON:
1517 return ath9k_hw_set_reset_power_on(ah);
1518 break;
1519 case ATH9K_RESET_WARM:
1520 case ATH9K_RESET_COLD:
1521 return ath9k_hw_set_reset(ah, type);
1522 break;
1523 default:
1524 return false;
1525 }
1526}
1527
1528static void ath9k_hw_set_regs(struct ath_hal *ah, struct ath9k_channel *chan,
1529 enum ath9k_ht_macmode macmode)
1530{
1531 u32 phymode;
1532 struct ath_hal_5416 *ahp = AH5416(ah);
1533
1534 phymode = AR_PHY_FC_HT_EN | AR_PHY_FC_SHORT_GI_40
1535 | AR_PHY_FC_SINGLE_HT_LTF1 | AR_PHY_FC_WALSH;
1536
1537 if (IS_CHAN_HT40(chan)) {
1538 phymode |= AR_PHY_FC_DYN2040_EN;
1539
1540 if ((chan->chanmode == CHANNEL_A_HT40PLUS) ||
1541 (chan->chanmode == CHANNEL_G_HT40PLUS))
1542 phymode |= AR_PHY_FC_DYN2040_PRI_CH;
1543
1544 if (ahp->ah_extprotspacing == ATH9K_HT_EXTPROTSPACING_25)
1545 phymode |= AR_PHY_FC_DYN2040_EXT_CH;
1546 }
1547 REG_WRITE(ah, AR_PHY_TURBO, phymode);
1548
1549 ath9k_hw_set11nmac2040(ah, macmode);
1550
1551 REG_WRITE(ah, AR_GTXTO, 25 << AR_GTXTO_TIMEOUT_LIMIT_S);
1552 REG_WRITE(ah, AR_CST, 0xF << AR_CST_TIMEOUT_LIMIT_S);
1553}
1554
1555static bool ath9k_hw_chip_reset(struct ath_hal *ah,
1556 struct ath9k_channel *chan)
1557{
1558 struct ath_hal_5416 *ahp = AH5416(ah);
1559
1560 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
1561 return false;
1562
1563 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1564 return false;
1565
1566 ahp->ah_chipFullSleep = false;
1567
1568 ath9k_hw_init_pll(ah, chan);
1569
1570 ath9k_hw_set_rfmode(ah, chan);
1571
1572 return true;
1573}
1574
1575static struct ath9k_channel *ath9k_hw_check_chan(struct ath_hal *ah,
1576 struct ath9k_channel *chan)
1577{
1578 if (!(IS_CHAN_2GHZ(chan) ^ IS_CHAN_5GHZ(chan))) {
1579 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1580 "%s: invalid channel %u/0x%x; not marked as "
1581 "2GHz or 5GHz\n", __func__, chan->channel,
1582 chan->channelFlags);
1583 return NULL;
1584 }
1585
1586 if (!IS_CHAN_OFDM(chan) &&
1587 !IS_CHAN_CCK(chan) &&
1588 !IS_CHAN_HT20(chan) &&
1589 !IS_CHAN_HT40(chan)) {
1590 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1591 "%s: invalid channel %u/0x%x; not marked as "
1592 "OFDM or CCK or HT20 or HT40PLUS or HT40MINUS\n",
1593 __func__, chan->channel, chan->channelFlags);
1594 return NULL;
1595 }
1596
1597 return ath9k_regd_check_channel(ah, chan);
1598}
1599
1600static bool ath9k_hw_channel_change(struct ath_hal *ah,
1601 struct ath9k_channel *chan,
1602 enum ath9k_ht_macmode macmode)
1603{
1604 u32 synthDelay, qnum;
1605
1606 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
1607 if (ath9k_hw_numtxpending(ah, qnum)) {
1608 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
1609 "%s: Transmit frames pending on queue %d\n",
1610 __func__, qnum);
1611 return false;
1612 }
1613 }
1614
1615 REG_WRITE(ah, AR_PHY_RFBUS_REQ, AR_PHY_RFBUS_REQ_EN);
1616 if (!ath9k_hw_wait(ah, AR_PHY_RFBUS_GRANT, AR_PHY_RFBUS_GRANT_EN,
1617 AR_PHY_RFBUS_GRANT_EN)) {
1618 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
1619 "%s: Could not kill baseband RX\n", __func__);
1620 return false;
1621 }
1622
1623 ath9k_hw_set_regs(ah, chan, macmode);
1624
1625 if (AR_SREV_9280_10_OR_LATER(ah)) {
1626 if (!(ath9k_hw_ar9280_set_channel(ah, chan))) {
1627 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1628 "%s: failed to set channel\n", __func__);
1629 return false;
1630 }
1631 } else {
1632 if (!(ath9k_hw_set_channel(ah, chan))) {
1633 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
1634 "%s: failed to set channel\n", __func__);
1635 return false;
1636 }
1637 }
1638
1639 if (ath9k_hw_set_txpower(ah, chan,
1640 ath9k_regd_get_ctl(ah, chan),
1641 ath9k_regd_get_antenna_allowed(ah, chan),
1642 chan->maxRegTxPower * 2,
1643 min((u32) MAX_RATE_POWER,
1644 (u32) ah->ah_powerLimit)) != 0) {
1645 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
1646 "%s: error init'ing transmit power\n", __func__);
1647 return false;
1648 }
1649
1650 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
1651 if (IS_CHAN_CCK(chan))
1652 synthDelay = (4 * synthDelay) / 22;
1653 else
1654 synthDelay /= 10;
1655
1656 udelay(synthDelay + BASE_ACTIVATE_DELAY);
1657
1658 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
1659
1660 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
1661 ath9k_hw_set_delta_slope(ah, chan);
1662
1663 if (AR_SREV_9280_10_OR_LATER(ah))
1664 ath9k_hw_9280_spur_mitigate(ah, chan);
1665 else
1666 ath9k_hw_spur_mitigate(ah, chan);
1667
1668 if (!chan->oneTimeCalsDone)
1669 chan->oneTimeCalsDone = true;
1670
1671 return true;
1672}
1673
1674static void ath9k_hw_9280_spur_mitigate(struct ath_hal *ah, struct ath9k_channel *chan)
4672{ 1675{
4673 int bb_spur = AR_NO_SPUR; 1676 int bb_spur = AR_NO_SPUR;
4674 int freq; 1677 int freq;
@@ -4918,8 +1921,7 @@ static void ath9k_hw_9280_spur_mitigate(struct ath_hal *ah,
4918 REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask); 1921 REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask);
4919} 1922}
4920 1923
4921static void ath9k_hw_spur_mitigate(struct ath_hal *ah, 1924static void ath9k_hw_spur_mitigate(struct ath_hal *ah, struct ath9k_channel *chan)
4922 struct ath9k_channel *chan)
4923{ 1925{
4924 int bb_spur = AR_NO_SPUR; 1926 int bb_spur = AR_NO_SPUR;
4925 int bin, cur_bin; 1927 int bin, cur_bin;
@@ -5120,752 +2122,11 @@ static void ath9k_hw_spur_mitigate(struct ath_hal *ah,
5120 REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask); 2122 REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask);
5121} 2123}
5122 2124
5123static void ath9k_hw_init_chain_masks(struct ath_hal *ah) 2125bool ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
5124{
5125 struct ath_hal_5416 *ahp = AH5416(ah);
5126 int rx_chainmask, tx_chainmask;
5127
5128 rx_chainmask = ahp->ah_rxchainmask;
5129 tx_chainmask = ahp->ah_txchainmask;
5130
5131 switch (rx_chainmask) {
5132 case 0x5:
5133 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
5134 AR_PHY_SWAP_ALT_CHAIN);
5135 case 0x3:
5136 if (((ah)->ah_macVersion <= AR_SREV_VERSION_9160)) {
5137 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, 0x7);
5138 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, 0x7);
5139 break;
5140 }
5141 case 0x1:
5142 case 0x2:
5143 if (!AR_SREV_9280(ah))
5144 break;
5145 case 0x7:
5146 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx_chainmask);
5147 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx_chainmask);
5148 break;
5149 default:
5150 break;
5151 }
5152
5153 REG_WRITE(ah, AR_SELFGEN_MASK, tx_chainmask);
5154 if (tx_chainmask == 0x5) {
5155 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
5156 AR_PHY_SWAP_ALT_CHAIN);
5157 }
5158 if (AR_SREV_9100(ah))
5159 REG_WRITE(ah, AR_PHY_ANALOG_SWAP,
5160 REG_READ(ah, AR_PHY_ANALOG_SWAP) | 0x00000001);
5161}
5162
5163static void ath9k_hw_set_addac(struct ath_hal *ah,
5164 struct ath9k_channel *chan)
5165{
5166 struct modal_eep_header *pModal;
5167 struct ath_hal_5416 *ahp = AH5416(ah);
5168 struct ar5416_eeprom *eep = &ahp->ah_eeprom;
5169 u8 biaslevel;
5170
5171 if (ah->ah_macVersion != AR_SREV_VERSION_9160)
5172 return;
5173
5174 if (ar5416_get_eep_rev(ahp) < AR5416_EEP_MINOR_VER_7)
5175 return;
5176
5177 pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
5178
5179 if (pModal->xpaBiasLvl != 0xff) {
5180 biaslevel = pModal->xpaBiasLvl;
5181 } else {
5182
5183 u16 resetFreqBin, freqBin, freqCount = 0;
5184 struct chan_centers centers;
5185
5186 ath9k_hw_get_channel_centers(ah, chan, &centers);
5187
5188 resetFreqBin =
5189 FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan));
5190 freqBin = pModal->xpaBiasLvlFreq[0] & 0xff;
5191 biaslevel = (u8) (pModal->xpaBiasLvlFreq[0] >> 14);
5192
5193 freqCount++;
5194
5195 while (freqCount < 3) {
5196 if (pModal->xpaBiasLvlFreq[freqCount] == 0x0)
5197 break;
5198
5199 freqBin = pModal->xpaBiasLvlFreq[freqCount] & 0xff;
5200 if (resetFreqBin >= freqBin) {
5201 biaslevel =
5202 (u8) (pModal->
5203 xpaBiasLvlFreq[freqCount]
5204 >> 14);
5205 } else {
5206 break;
5207 }
5208 freqCount++;
5209 }
5210 }
5211
5212 if (IS_CHAN_2GHZ(chan)) {
5213 INI_RA(&ahp->ah_iniAddac, 7, 1) =
5214 (INI_RA(&ahp->ah_iniAddac, 7, 1) & (~0x18)) | biaslevel
5215 << 3;
5216 } else {
5217 INI_RA(&ahp->ah_iniAddac, 6, 1) =
5218 (INI_RA(&ahp->ah_iniAddac, 6, 1) & (~0xc0)) | biaslevel
5219 << 6;
5220 }
5221}
5222
5223static u32 ath9k_hw_mac_usec(struct ath_hal *ah, u32 clks)
5224{
5225 if (ah->ah_curchan != NULL)
5226 return clks /
5227 CLOCK_RATE[ath9k_hw_chan2wmode(ah, ah->ah_curchan)];
5228 else
5229 return clks / CLOCK_RATE[ATH9K_MODE_11B];
5230}
5231
5232static u32 ath9k_hw_mac_to_usec(struct ath_hal *ah, u32 clks)
5233{
5234 struct ath9k_channel *chan = ah->ah_curchan;
5235
5236 if (chan && IS_CHAN_HT40(chan))
5237 return ath9k_hw_mac_usec(ah, clks) / 2;
5238 else
5239 return ath9k_hw_mac_usec(ah, clks);
5240}
5241
5242static u32 ath9k_hw_mac_clks(struct ath_hal *ah, u32 usecs)
5243{
5244 if (ah->ah_curchan != NULL)
5245 return usecs * CLOCK_RATE[ath9k_hw_chan2wmode(ah,
5246 ah->ah_curchan)];
5247 else
5248 return usecs * CLOCK_RATE[ATH9K_MODE_11B];
5249}
5250
5251static u32 ath9k_hw_mac_to_clks(struct ath_hal *ah, u32 usecs)
5252{
5253 struct ath9k_channel *chan = ah->ah_curchan;
5254
5255 if (chan && IS_CHAN_HT40(chan))
5256 return ath9k_hw_mac_clks(ah, usecs) * 2;
5257 else
5258 return ath9k_hw_mac_clks(ah, usecs);
5259}
5260
5261static bool ath9k_hw_set_ack_timeout(struct ath_hal *ah, u32 us)
5262{
5263 struct ath_hal_5416 *ahp = AH5416(ah);
5264
5265 if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) {
5266 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: bad ack timeout %u\n",
5267 __func__, us);
5268 ahp->ah_acktimeout = (u32) -1;
5269 return false;
5270 } else {
5271 REG_RMW_FIELD(ah, AR_TIME_OUT,
5272 AR_TIME_OUT_ACK, ath9k_hw_mac_to_clks(ah, us));
5273 ahp->ah_acktimeout = us;
5274 return true;
5275 }
5276}
5277
5278static bool ath9k_hw_set_cts_timeout(struct ath_hal *ah, u32 us)
5279{
5280 struct ath_hal_5416 *ahp = AH5416(ah);
5281
5282 if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) {
5283 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: bad cts timeout %u\n",
5284 __func__, us);
5285 ahp->ah_ctstimeout = (u32) -1;
5286 return false;
5287 } else {
5288 REG_RMW_FIELD(ah, AR_TIME_OUT,
5289 AR_TIME_OUT_CTS, ath9k_hw_mac_to_clks(ah, us));
5290 ahp->ah_ctstimeout = us;
5291 return true;
5292 }
5293}
5294static bool ath9k_hw_set_global_txtimeout(struct ath_hal *ah,
5295 u32 tu)
5296{
5297 struct ath_hal_5416 *ahp = AH5416(ah);
5298
5299 if (tu > 0xFFFF) {
5300 DPRINTF(ah->ah_sc, ATH_DBG_XMIT,
5301 "%s: bad global tx timeout %u\n", __func__, tu);
5302 ahp->ah_globaltxtimeout = (u32) -1;
5303 return false;
5304 } else {
5305 REG_RMW_FIELD(ah, AR_GTXTO, AR_GTXTO_TIMEOUT_LIMIT, tu);
5306 ahp->ah_globaltxtimeout = tu;
5307 return true;
5308 }
5309}
5310
5311bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us)
5312{
5313 struct ath_hal_5416 *ahp = AH5416(ah);
5314
5315 if (us < ATH9K_SLOT_TIME_9 || us > ath9k_hw_mac_to_usec(ah, 0xffff)) {
5316 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: bad slot time %u\n",
5317 __func__, us);
5318 ahp->ah_slottime = (u32) -1;
5319 return false;
5320 } else {
5321 REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath9k_hw_mac_to_clks(ah, us));
5322 ahp->ah_slottime = us;
5323 return true;
5324 }
5325}
5326
5327static void ath9k_hw_init_user_settings(struct ath_hal *ah)
5328{
5329 struct ath_hal_5416 *ahp = AH5416(ah);
5330
5331 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "--AP %s ahp->ah_miscMode 0x%x\n",
5332 __func__, ahp->ah_miscMode);
5333 if (ahp->ah_miscMode != 0)
5334 REG_WRITE(ah, AR_PCU_MISC,
5335 REG_READ(ah, AR_PCU_MISC) | ahp->ah_miscMode);
5336 if (ahp->ah_slottime != (u32) -1)
5337 ath9k_hw_setslottime(ah, ahp->ah_slottime);
5338 if (ahp->ah_acktimeout != (u32) -1)
5339 ath9k_hw_set_ack_timeout(ah, ahp->ah_acktimeout);
5340 if (ahp->ah_ctstimeout != (u32) -1)
5341 ath9k_hw_set_cts_timeout(ah, ahp->ah_ctstimeout);
5342 if (ahp->ah_globaltxtimeout != (u32) -1)
5343 ath9k_hw_set_global_txtimeout(ah, ahp->ah_globaltxtimeout);
5344}
5345
5346static int
5347ath9k_hw_process_ini(struct ath_hal *ah,
5348 struct ath9k_channel *chan,
5349 enum ath9k_ht_macmode macmode)
5350{
5351 int i, regWrites = 0;
5352 struct ath_hal_5416 *ahp = AH5416(ah);
5353 u32 modesIndex, freqIndex;
5354 int status;
5355
5356 switch (chan->chanmode) {
5357 case CHANNEL_A:
5358 case CHANNEL_A_HT20:
5359 modesIndex = 1;
5360 freqIndex = 1;
5361 break;
5362 case CHANNEL_A_HT40PLUS:
5363 case CHANNEL_A_HT40MINUS:
5364 modesIndex = 2;
5365 freqIndex = 1;
5366 break;
5367 case CHANNEL_G:
5368 case CHANNEL_G_HT20:
5369 case CHANNEL_B:
5370 modesIndex = 4;
5371 freqIndex = 2;
5372 break;
5373 case CHANNEL_G_HT40PLUS:
5374 case CHANNEL_G_HT40MINUS:
5375 modesIndex = 3;
5376 freqIndex = 2;
5377 break;
5378
5379 default:
5380 return -EINVAL;
5381 }
5382
5383 REG_WRITE(ah, AR_PHY(0), 0x00000007);
5384
5385 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO);
5386
5387 ath9k_hw_set_addac(ah, chan);
5388
5389 if (AR_SREV_5416_V22_OR_LATER(ah)) {
5390 REG_WRITE_ARRAY(&ahp->ah_iniAddac, 1, regWrites);
5391 } else {
5392 struct ar5416IniArray temp;
5393 u32 addacSize =
5394 sizeof(u32) * ahp->ah_iniAddac.ia_rows *
5395 ahp->ah_iniAddac.ia_columns;
5396
5397 memcpy(ahp->ah_addac5416_21,
5398 ahp->ah_iniAddac.ia_array, addacSize);
5399
5400 (ahp->ah_addac5416_21)[31 *
5401 ahp->ah_iniAddac.ia_columns + 1] = 0;
5402
5403 temp.ia_array = ahp->ah_addac5416_21;
5404 temp.ia_columns = ahp->ah_iniAddac.ia_columns;
5405 temp.ia_rows = ahp->ah_iniAddac.ia_rows;
5406 REG_WRITE_ARRAY(&temp, 1, regWrites);
5407 }
5408 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC);
5409
5410 for (i = 0; i < ahp->ah_iniModes.ia_rows; i++) {
5411 u32 reg = INI_RA(&ahp->ah_iniModes, i, 0);
5412 u32 val = INI_RA(&ahp->ah_iniModes, i, modesIndex);
5413
5414#ifdef CONFIG_SLOW_ANT_DIV
5415 if (ah->ah_devid == AR9280_DEVID_PCI)
5416 val = ath9k_hw_ini_fixup(ah, &ahp->ah_eeprom, reg,
5417 val);
5418#endif
5419
5420 REG_WRITE(ah, reg, val);
5421
5422 if (reg >= 0x7800 && reg < 0x78a0
5423 && ah->ah_config.analog_shiftreg) {
5424 udelay(100);
5425 }
5426
5427 DO_DELAY(regWrites);
5428 }
5429
5430 for (i = 0; i < ahp->ah_iniCommon.ia_rows; i++) {
5431 u32 reg = INI_RA(&ahp->ah_iniCommon, i, 0);
5432 u32 val = INI_RA(&ahp->ah_iniCommon, i, 1);
5433
5434 REG_WRITE(ah, reg, val);
5435
5436 if (reg >= 0x7800 && reg < 0x78a0
5437 && ah->ah_config.analog_shiftreg) {
5438 udelay(100);
5439 }
5440
5441 DO_DELAY(regWrites);
5442 }
5443
5444 ath9k_hw_write_regs(ah, modesIndex, freqIndex, regWrites);
5445
5446 if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) {
5447 REG_WRITE_ARRAY(&ahp->ah_iniModesAdditional, modesIndex,
5448 regWrites);
5449 }
5450
5451 ath9k_hw_override_ini(ah, chan);
5452 ath9k_hw_set_regs(ah, chan, macmode);
5453 ath9k_hw_init_chain_masks(ah);
5454
5455 status = ath9k_hw_set_txpower(ah, &ahp->ah_eeprom, chan,
5456 ath9k_regd_get_ctl(ah, chan),
5457 ath9k_regd_get_antenna_allowed(ah,
5458 chan),
5459 chan->maxRegTxPower * 2,
5460 min((u32) MAX_RATE_POWER,
5461 (u32) ah->ah_powerLimit));
5462 if (status != 0) {
5463 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
5464 "%s: error init'ing transmit power\n", __func__);
5465 return -EIO;
5466 }
5467
5468 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
5469 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
5470 "%s: ar5416SetRfRegs failed\n", __func__);
5471 return -EIO;
5472 }
5473
5474 return 0;
5475}
5476
5477static void ath9k_hw_setup_calibration(struct ath_hal *ah,
5478 struct hal_cal_list *currCal)
5479{
5480 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(0),
5481 AR_PHY_TIMING_CTRL4_IQCAL_LOG_COUNT_MAX,
5482 currCal->calData->calCountMax);
5483
5484 switch (currCal->calData->calType) {
5485 case IQ_MISMATCH_CAL:
5486 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_IQ);
5487 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5488 "%s: starting IQ Mismatch Calibration\n",
5489 __func__);
5490 break;
5491 case ADC_GAIN_CAL:
5492 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_GAIN);
5493 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5494 "%s: starting ADC Gain Calibration\n", __func__);
5495 break;
5496 case ADC_DC_CAL:
5497 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_DC_PER);
5498 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5499 "%s: starting ADC DC Calibration\n", __func__);
5500 break;
5501 case ADC_DC_INIT_CAL:
5502 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_DC_INIT);
5503 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5504 "%s: starting Init ADC DC Calibration\n",
5505 __func__);
5506 break;
5507 }
5508
5509 REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0),
5510 AR_PHY_TIMING_CTRL4_DO_CAL);
5511}
5512
5513static void ath9k_hw_reset_calibration(struct ath_hal *ah,
5514 struct hal_cal_list *currCal)
5515{
5516 struct ath_hal_5416 *ahp = AH5416(ah);
5517 int i;
5518
5519 ath9k_hw_setup_calibration(ah, currCal);
5520
5521 currCal->calState = CAL_RUNNING;
5522
5523 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
5524 ahp->ah_Meas0.sign[i] = 0;
5525 ahp->ah_Meas1.sign[i] = 0;
5526 ahp->ah_Meas2.sign[i] = 0;
5527 ahp->ah_Meas3.sign[i] = 0;
5528 }
5529
5530 ahp->ah_CalSamples = 0;
5531}
5532
5533static void
5534ath9k_hw_per_calibration(struct ath_hal *ah,
5535 struct ath9k_channel *ichan,
5536 u8 rxchainmask,
5537 struct hal_cal_list *currCal,
5538 bool *isCalDone)
5539{
5540 struct ath_hal_5416 *ahp = AH5416(ah);
5541
5542 *isCalDone = false;
5543
5544 if (currCal->calState == CAL_RUNNING) {
5545 if (!(REG_READ(ah,
5546 AR_PHY_TIMING_CTRL4(0)) &
5547 AR_PHY_TIMING_CTRL4_DO_CAL)) {
5548
5549 currCal->calData->calCollect(ah);
5550
5551 ahp->ah_CalSamples++;
5552
5553 if (ahp->ah_CalSamples >=
5554 currCal->calData->calNumSamples) {
5555 int i, numChains = 0;
5556 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
5557 if (rxchainmask & (1 << i))
5558 numChains++;
5559 }
5560
5561 currCal->calData->calPostProc(ah,
5562 numChains);
5563
5564 ichan->CalValid |=
5565 currCal->calData->calType;
5566 currCal->calState = CAL_DONE;
5567 *isCalDone = true;
5568 } else {
5569 ath9k_hw_setup_calibration(ah, currCal);
5570 }
5571 }
5572 } else if (!(ichan->CalValid & currCal->calData->calType)) {
5573 ath9k_hw_reset_calibration(ah, currCal);
5574 }
5575}
5576
5577static inline bool ath9k_hw_run_init_cals(struct ath_hal *ah,
5578 int init_cal_count)
5579{
5580 struct ath_hal_5416 *ahp = AH5416(ah);
5581 struct ath9k_channel ichan;
5582 bool isCalDone;
5583 struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
5584 const struct hal_percal_data *calData = currCal->calData;
5585 int i;
5586
5587 if (currCal == NULL)
5588 return false;
5589
5590 ichan.CalValid = 0;
5591
5592 for (i = 0; i < init_cal_count; i++) {
5593 ath9k_hw_reset_calibration(ah, currCal);
5594
5595 if (!ath9k_hw_wait(ah, AR_PHY_TIMING_CTRL4(0),
5596 AR_PHY_TIMING_CTRL4_DO_CAL, 0)) {
5597 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5598 "%s: Cal %d failed to complete in 100ms.\n",
5599 __func__, calData->calType);
5600
5601 ahp->ah_cal_list = ahp->ah_cal_list_last =
5602 ahp->ah_cal_list_curr = NULL;
5603 return false;
5604 }
5605
5606 ath9k_hw_per_calibration(ah, &ichan, ahp->ah_rxchainmask,
5607 currCal, &isCalDone);
5608 if (!isCalDone) {
5609 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5610 "%s: Not able to run Init Cal %d.\n",
5611 __func__, calData->calType);
5612 }
5613 if (currCal->calNext) {
5614 currCal = currCal->calNext;
5615 calData = currCal->calData;
5616 }
5617 }
5618
5619 ahp->ah_cal_list = ahp->ah_cal_list_last = ahp->ah_cal_list_curr = NULL;
5620 return true;
5621}
5622
5623static bool
5624ath9k_hw_channel_change(struct ath_hal *ah,
5625 struct ath9k_channel *chan,
5626 enum ath9k_ht_macmode macmode)
5627{
5628 u32 synthDelay, qnum;
5629 struct ath_hal_5416 *ahp = AH5416(ah);
5630
5631 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
5632 if (ath9k_hw_numtxpending(ah, qnum)) {
5633 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
5634 "%s: Transmit frames pending on queue %d\n",
5635 __func__, qnum);
5636 return false;
5637 }
5638 }
5639
5640 REG_WRITE(ah, AR_PHY_RFBUS_REQ, AR_PHY_RFBUS_REQ_EN);
5641 if (!ath9k_hw_wait(ah, AR_PHY_RFBUS_GRANT, AR_PHY_RFBUS_GRANT_EN,
5642 AR_PHY_RFBUS_GRANT_EN)) {
5643 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
5644 "%s: Could not kill baseband RX\n", __func__);
5645 return false;
5646 }
5647
5648 ath9k_hw_set_regs(ah, chan, macmode);
5649
5650 if (AR_SREV_9280_10_OR_LATER(ah)) {
5651 if (!(ath9k_hw_ar9280_set_channel(ah, chan))) {
5652 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
5653 "%s: failed to set channel\n", __func__);
5654 return false;
5655 }
5656 } else {
5657 if (!(ath9k_hw_set_channel(ah, chan))) {
5658 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
5659 "%s: failed to set channel\n", __func__);
5660 return false;
5661 }
5662 }
5663
5664 if (ath9k_hw_set_txpower(ah, &ahp->ah_eeprom, chan,
5665 ath9k_regd_get_ctl(ah, chan),
5666 ath9k_regd_get_antenna_allowed(ah, chan),
5667 chan->maxRegTxPower * 2,
5668 min((u32) MAX_RATE_POWER,
5669 (u32) ah->ah_powerLimit)) != 0) {
5670 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
5671 "%s: error init'ing transmit power\n", __func__);
5672 return false;
5673 }
5674
5675 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
5676 if (IS_CHAN_CCK(chan))
5677 synthDelay = (4 * synthDelay) / 22;
5678 else
5679 synthDelay /= 10;
5680
5681 udelay(synthDelay + BASE_ACTIVATE_DELAY);
5682
5683 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
5684
5685 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
5686 ath9k_hw_set_delta_slope(ah, chan);
5687
5688 if (AR_SREV_9280_10_OR_LATER(ah))
5689 ath9k_hw_9280_spur_mitigate(ah, chan);
5690 else
5691 ath9k_hw_spur_mitigate(ah, chan);
5692
5693 if (!chan->oneTimeCalsDone)
5694 chan->oneTimeCalsDone = true;
5695
5696 return true;
5697}
5698
5699static bool ath9k_hw_chip_reset(struct ath_hal *ah,
5700 struct ath9k_channel *chan)
5701{
5702 struct ath_hal_5416 *ahp = AH5416(ah);
5703
5704 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
5705 return false;
5706
5707 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
5708 return false;
5709
5710 ahp->ah_chipFullSleep = false;
5711
5712 ath9k_hw_init_pll(ah, chan);
5713
5714 ath9k_hw_set_rfmode(ah, chan);
5715
5716 return true;
5717}
5718
5719static inline void ath9k_hw_set_dma(struct ath_hal *ah)
5720{
5721 u32 regval;
5722
5723 regval = REG_READ(ah, AR_AHB_MODE);
5724 REG_WRITE(ah, AR_AHB_MODE, regval | AR_AHB_PREFETCH_RD_EN);
5725
5726 regval = REG_READ(ah, AR_TXCFG) & ~AR_TXCFG_DMASZ_MASK;
5727 REG_WRITE(ah, AR_TXCFG, regval | AR_TXCFG_DMASZ_128B);
5728
5729 REG_RMW_FIELD(ah, AR_TXCFG, AR_FTRIG, ah->ah_txTrigLevel);
5730
5731 regval = REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_DMASZ_MASK;
5732 REG_WRITE(ah, AR_RXCFG, regval | AR_RXCFG_DMASZ_128B);
5733
5734 REG_WRITE(ah, AR_RXFIFO_CFG, 0x200);
5735
5736 if (AR_SREV_9285(ah)) {
5737 REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
5738 AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE);
5739 } else {
5740 REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
5741 AR_PCU_TXBUF_CTRL_USABLE_SIZE);
5742 }
5743}
5744
5745bool ath9k_hw_stopdmarecv(struct ath_hal *ah)
5746{
5747 REG_WRITE(ah, AR_CR, AR_CR_RXD);
5748 if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0)) {
5749 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
5750 "%s: dma failed to stop in 10ms\n"
5751 "AR_CR=0x%08x\nAR_DIAG_SW=0x%08x\n",
5752 __func__,
5753 REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW));
5754 return false;
5755 } else {
5756 return true;
5757 }
5758}
5759
5760void ath9k_hw_startpcureceive(struct ath_hal *ah)
5761{
5762 REG_CLR_BIT(ah, AR_DIAG_SW,
5763 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
5764
5765 ath9k_enable_mib_counters(ah);
5766
5767 ath9k_ani_reset(ah);
5768}
5769
5770void ath9k_hw_stoppcurecv(struct ath_hal *ah)
5771{
5772 REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
5773
5774 ath9k_hw_disable_mib_counters(ah);
5775}
5776
5777static bool ath9k_hw_iscal_supported(struct ath_hal *ah,
5778 struct ath9k_channel *chan,
5779 enum hal_cal_types calType)
5780{
5781 struct ath_hal_5416 *ahp = AH5416(ah);
5782 bool retval = false;
5783
5784 switch (calType & ahp->ah_suppCals) {
5785 case IQ_MISMATCH_CAL:
5786 if (!IS_CHAN_B(chan))
5787 retval = true;
5788 break;
5789 case ADC_GAIN_CAL:
5790 case ADC_DC_CAL:
5791 if (!IS_CHAN_B(chan)
5792 && !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
5793 retval = true;
5794 break;
5795 }
5796
5797 return retval;
5798}
5799
5800static bool ath9k_hw_init_cal(struct ath_hal *ah,
5801 struct ath9k_channel *chan)
5802{
5803 struct ath_hal_5416 *ahp = AH5416(ah);
5804 struct ath9k_channel *ichan =
5805 ath9k_regd_check_channel(ah, chan);
5806
5807 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
5808 REG_READ(ah, AR_PHY_AGC_CONTROL) |
5809 AR_PHY_AGC_CONTROL_CAL);
5810
5811 if (!ath9k_hw_wait
5812 (ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 0)) {
5813 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5814 "%s: offset calibration failed to complete in 1ms; "
5815 "noisy environment?\n", __func__);
5816 return false;
5817 }
5818
5819 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
5820 REG_READ(ah, AR_PHY_AGC_CONTROL) |
5821 AR_PHY_AGC_CONTROL_NF);
5822
5823 ahp->ah_cal_list = ahp->ah_cal_list_last = ahp->ah_cal_list_curr =
5824 NULL;
5825
5826 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
5827 if (ath9k_hw_iscal_supported(ah, chan, ADC_GAIN_CAL)) {
5828 INIT_CAL(&ahp->ah_adcGainCalData);
5829 INSERT_CAL(ahp, &ahp->ah_adcGainCalData);
5830 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5831 "%s: enabling ADC Gain Calibration.\n",
5832 __func__);
5833 }
5834 if (ath9k_hw_iscal_supported(ah, chan, ADC_DC_CAL)) {
5835 INIT_CAL(&ahp->ah_adcDcCalData);
5836 INSERT_CAL(ahp, &ahp->ah_adcDcCalData);
5837 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5838 "%s: enabling ADC DC Calibration.\n",
5839 __func__);
5840 }
5841 if (ath9k_hw_iscal_supported(ah, chan, IQ_MISMATCH_CAL)) {
5842 INIT_CAL(&ahp->ah_iqCalData);
5843 INSERT_CAL(ahp, &ahp->ah_iqCalData);
5844 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
5845 "%s: enabling IQ Calibration.\n",
5846 __func__);
5847 }
5848
5849 ahp->ah_cal_list_curr = ahp->ah_cal_list;
5850
5851 if (ahp->ah_cal_list_curr)
5852 ath9k_hw_reset_calibration(ah,
5853 ahp->ah_cal_list_curr);
5854 }
5855
5856 ichan->CalValid = 0;
5857
5858 return true;
5859}
5860
5861
5862bool ath9k_hw_reset(struct ath_hal *ah,
5863 struct ath9k_channel *chan,
5864 enum ath9k_ht_macmode macmode, 2126 enum ath9k_ht_macmode macmode,
5865 u8 txchainmask, u8 rxchainmask, 2127 u8 txchainmask, u8 rxchainmask,
5866 enum ath9k_ht_extprotspacing extprotspacing, 2128 enum ath9k_ht_extprotspacing extprotspacing,
5867 bool bChannelChange, 2129 bool bChannelChange, int *status)
5868 int *status)
5869{ 2130{
5870 u32 saveLedState; 2131 u32 saveLedState;
5871 struct ath_hal_5416 *ahp = AH5416(ah); 2132 struct ath_hal_5416 *ahp = AH5416(ah);
@@ -5886,8 +2147,8 @@ bool ath9k_hw_reset(struct ath_hal *ah,
5886 2147
5887 if (ath9k_hw_check_chan(ah, chan) == NULL) { 2148 if (ath9k_hw_check_chan(ah, chan) == NULL) {
5888 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, 2149 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
5889 "%s: invalid channel %u/0x%x; no mapping\n", 2150 "%s: invalid channel %u/0x%x; no mapping\n",
5890 __func__, chan->channel, chan->channelFlags); 2151 __func__, chan->channel, chan->channelFlags);
5891 ecode = -EINVAL; 2152 ecode = -EINVAL;
5892 goto bad; 2153 goto bad;
5893 } 2154 }
@@ -5965,7 +2226,7 @@ bool ath9k_hw_reset(struct ath_hal *ah,
5965 2226
5966 if (!ath9k_hw_eeprom_set_board_values(ah, chan)) { 2227 if (!ath9k_hw_eeprom_set_board_values(ah, chan)) {
5967 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 2228 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
5968 "%s: error setting board options\n", __func__); 2229 "%s: error setting board options\n", __func__);
5969 ecode = -EIO; 2230 ecode = -EIO;
5970 goto bad; 2231 goto bad;
5971 } 2232 }
@@ -6055,15 +2316,15 @@ bool ath9k_hw_reset(struct ath_hal *ah,
6055 mask = REG_READ(ah, AR_CFG); 2316 mask = REG_READ(ah, AR_CFG);
6056 if (mask & (AR_CFG_SWRB | AR_CFG_SWTB | AR_CFG_SWRG)) { 2317 if (mask & (AR_CFG_SWRB | AR_CFG_SWTB | AR_CFG_SWRG)) {
6057 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 2318 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
6058 "%s CFG Byte Swap Set 0x%x\n", __func__, 2319 "%s CFG Byte Swap Set 0x%x\n", __func__,
6059 mask); 2320 mask);
6060 } else { 2321 } else {
6061 mask = 2322 mask =
6062 INIT_CONFIG_STATUS | AR_CFG_SWRB | AR_CFG_SWTB; 2323 INIT_CONFIG_STATUS | AR_CFG_SWRB | AR_CFG_SWTB;
6063 REG_WRITE(ah, AR_CFG, mask); 2324 REG_WRITE(ah, AR_CFG, mask);
6064 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 2325 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
6065 "%s Setting CFG 0x%x\n", __func__, 2326 "%s Setting CFG 0x%x\n", __func__,
6066 REG_READ(ah, AR_CFG)); 2327 REG_READ(ah, AR_CFG));
6067 } 2328 }
6068 } else { 2329 } else {
6069#ifdef __BIG_ENDIAN 2330#ifdef __BIG_ENDIAN
@@ -6078,692 +2339,403 @@ bad:
6078 return false; 2339 return false;
6079} 2340}
6080 2341
6081bool ath9k_hw_phy_disable(struct ath_hal *ah) 2342/************************/
6082{ 2343/* Key Cache Management */
6083 return ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM); 2344/************************/
6084}
6085
6086bool ath9k_hw_disable(struct ath_hal *ah)
6087{
6088 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
6089 return false;
6090
6091 return ath9k_hw_set_reset_reg(ah, ATH9K_RESET_COLD);
6092}
6093 2345
6094bool 2346bool ath9k_hw_keyreset(struct ath_hal *ah, u16 entry)
6095ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
6096 u8 rxchainmask, bool longcal,
6097 bool *isCalDone)
6098{ 2347{
6099 struct ath_hal_5416 *ahp = AH5416(ah); 2348 u32 keyType;
6100 struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
6101 struct ath9k_channel *ichan =
6102 ath9k_regd_check_channel(ah, chan);
6103
6104 *isCalDone = true;
6105 2349
6106 if (ichan == NULL) { 2350 if (entry >= ah->ah_caps.keycache_size) {
6107 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, 2351 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
6108 "%s: invalid channel %u/0x%x; no mapping\n", 2352 "%s: entry %u out of range\n", __func__, entry);
6109 __func__, chan->channel, chan->channelFlags);
6110 return false; 2353 return false;
6111 } 2354 }
6112 2355
6113 if (currCal && 2356 keyType = REG_READ(ah, AR_KEYTABLE_TYPE(entry));
6114 (currCal->calState == CAL_RUNNING ||
6115 currCal->calState == CAL_WAITING)) {
6116 ath9k_hw_per_calibration(ah, ichan, rxchainmask, currCal,
6117 isCalDone);
6118 if (*isCalDone) {
6119 ahp->ah_cal_list_curr = currCal = currCal->calNext;
6120
6121 if (currCal->calState == CAL_WAITING) {
6122 *isCalDone = false;
6123 ath9k_hw_reset_calibration(ah, currCal);
6124 }
6125 }
6126 }
6127 2357
6128 if (longcal) { 2358 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0);
6129 ath9k_hw_getnf(ah, ichan); 2359 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0);
6130 ath9k_hw_loadnf(ah, ah->ah_curchan); 2360 REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0);
6131 ath9k_hw_start_nfcal(ah); 2361 REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0);
2362 REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0);
2363 REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR);
2364 REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0);
2365 REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0);
6132 2366
6133 if ((ichan->channelFlags & CHANNEL_CW_INT) != 0) { 2367 if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) {
2368 u16 micentry = entry + 64;
2369
2370 REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0);
2371 REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
2372 REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0);
2373 REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
6134 2374
6135 chan->channelFlags |= CHANNEL_CW_INT;
6136 ichan->channelFlags &= ~CHANNEL_CW_INT;
6137 }
6138 } 2375 }
6139 2376
2377 if (ah->ah_curchan == NULL)
2378 return true;
2379
6140 return true; 2380 return true;
6141} 2381}
6142 2382
6143static void ath9k_hw_iqcal_collect(struct ath_hal *ah) 2383bool ath9k_hw_keysetmac(struct ath_hal *ah, u16 entry, const u8 *mac)
6144{ 2384{
6145 struct ath_hal_5416 *ahp = AH5416(ah); 2385 u32 macHi, macLo;
6146 int i;
6147 2386
6148 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 2387 if (entry >= ah->ah_caps.keycache_size) {
6149 ahp->ah_totalPowerMeasI[i] += 2388 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
6150 REG_READ(ah, AR_PHY_CAL_MEAS_0(i)); 2389 "%s: entry %u out of range\n", __func__, entry);
6151 ahp->ah_totalPowerMeasQ[i] += 2390 return false;
6152 REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
6153 ahp->ah_totalIqCorrMeas[i] +=
6154 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
6155 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6156 "%d: Chn %d pmi=0x%08x;pmq=0x%08x;iqcm=0x%08x;\n",
6157 ahp->ah_CalSamples, i, ahp->ah_totalPowerMeasI[i],
6158 ahp->ah_totalPowerMeasQ[i],
6159 ahp->ah_totalIqCorrMeas[i]);
6160 } 2391 }
6161}
6162 2392
6163static void ath9k_hw_adc_gaincal_collect(struct ath_hal *ah) 2393 if (mac != NULL) {
6164{ 2394 macHi = (mac[5] << 8) | mac[4];
6165 struct ath_hal_5416 *ahp = AH5416(ah); 2395 macLo = (mac[3] << 24) |
6166 int i; 2396 (mac[2] << 16) |
6167 2397 (mac[1] << 8) |
6168 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 2398 mac[0];
6169 ahp->ah_totalAdcIOddPhase[i] += 2399 macLo >>= 1;
6170 REG_READ(ah, AR_PHY_CAL_MEAS_0(i)); 2400 macLo |= (macHi & 1) << 31;
6171 ahp->ah_totalAdcIEvenPhase[i] += 2401 macHi >>= 1;
6172 REG_READ(ah, AR_PHY_CAL_MEAS_1(i)); 2402 } else {
6173 ahp->ah_totalAdcQOddPhase[i] += 2403 macLo = macHi = 0;
6174 REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
6175 ahp->ah_totalAdcQEvenPhase[i] +=
6176 REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
6177
6178 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6179 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
6180 "oddq=0x%08x; evenq=0x%08x;\n",
6181 ahp->ah_CalSamples, i,
6182 ahp->ah_totalAdcIOddPhase[i],
6183 ahp->ah_totalAdcIEvenPhase[i],
6184 ahp->ah_totalAdcQOddPhase[i],
6185 ahp->ah_totalAdcQEvenPhase[i]);
6186 } 2404 }
2405 REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), macLo);
2406 REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), macHi | AR_KEYTABLE_VALID);
2407
2408 return true;
6187} 2409}
6188 2410
6189static void ath9k_hw_adc_dccal_collect(struct ath_hal *ah) 2411bool ath9k_hw_set_keycache_entry(struct ath_hal *ah, u16 entry,
2412 const struct ath9k_keyval *k,
2413 const u8 *mac, int xorKey)
6190{ 2414{
2415 const struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
2416 u32 key0, key1, key2, key3, key4;
2417 u32 keyType;
2418 u32 xorMask = xorKey ?
2419 (ATH9K_KEY_XOR << 24 | ATH9K_KEY_XOR << 16 | ATH9K_KEY_XOR << 8
2420 | ATH9K_KEY_XOR) : 0;
6191 struct ath_hal_5416 *ahp = AH5416(ah); 2421 struct ath_hal_5416 *ahp = AH5416(ah);
6192 int i;
6193 2422
6194 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 2423 if (entry >= pCap->keycache_size) {
6195 ahp->ah_totalAdcDcOffsetIOddPhase[i] += 2424 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
6196 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_0(i)); 2425 "%s: entry %u out of range\n", __func__, entry);
6197 ahp->ah_totalAdcDcOffsetIEvenPhase[i] += 2426 return false;
6198 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
6199 ahp->ah_totalAdcDcOffsetQOddPhase[i] +=
6200 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
6201 ahp->ah_totalAdcDcOffsetQEvenPhase[i] +=
6202 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
6203
6204 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6205 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
6206 "oddq=0x%08x; evenq=0x%08x;\n",
6207 ahp->ah_CalSamples, i,
6208 ahp->ah_totalAdcDcOffsetIOddPhase[i],
6209 ahp->ah_totalAdcDcOffsetIEvenPhase[i],
6210 ahp->ah_totalAdcDcOffsetQOddPhase[i],
6211 ahp->ah_totalAdcDcOffsetQEvenPhase[i]);
6212 } 2427 }
6213}
6214 2428
6215static void ath9k_hw_iqcalibrate(struct ath_hal *ah, u8 numChains) 2429 switch (k->kv_type) {
6216{ 2430 case ATH9K_CIPHER_AES_OCB:
6217 struct ath_hal_5416 *ahp = AH5416(ah); 2431 keyType = AR_KEYTABLE_TYPE_AES;
6218 u32 powerMeasQ, powerMeasI, iqCorrMeas; 2432 break;
6219 u32 qCoffDenom, iCoffDenom; 2433 case ATH9K_CIPHER_AES_CCM:
6220 int32_t qCoff, iCoff; 2434 if (!(pCap->hw_caps & ATH9K_HW_CAP_CIPHER_AESCCM)) {
6221 int iqCorrNeg, i; 2435 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
2436 "%s: AES-CCM not supported by "
2437 "mac rev 0x%x\n", __func__,
2438 ah->ah_macRev);
2439 return false;
2440 }
2441 keyType = AR_KEYTABLE_TYPE_CCM;
2442 break;
2443 case ATH9K_CIPHER_TKIP:
2444 keyType = AR_KEYTABLE_TYPE_TKIP;
2445 if (ATH9K_IS_MIC_ENABLED(ah)
2446 && entry + 64 >= pCap->keycache_size) {
2447 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
2448 "%s: entry %u inappropriate for TKIP\n",
2449 __func__, entry);
2450 return false;
2451 }
2452 break;
2453 case ATH9K_CIPHER_WEP:
2454 if (k->kv_len < LEN_WEP40) {
2455 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
2456 "%s: WEP key length %u too small\n",
2457 __func__, k->kv_len);
2458 return false;
2459 }
2460 if (k->kv_len <= LEN_WEP40)
2461 keyType = AR_KEYTABLE_TYPE_40;
2462 else if (k->kv_len <= LEN_WEP104)
2463 keyType = AR_KEYTABLE_TYPE_104;
2464 else
2465 keyType = AR_KEYTABLE_TYPE_128;
2466 break;
2467 case ATH9K_CIPHER_CLR:
2468 keyType = AR_KEYTABLE_TYPE_CLR;
2469 break;
2470 default:
2471 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
2472 "%s: cipher %u not supported\n", __func__,
2473 k->kv_type);
2474 return false;
2475 }
6222 2476
6223 for (i = 0; i < numChains; i++) { 2477 key0 = get_unaligned_le32(k->kv_val + 0) ^ xorMask;
6224 powerMeasI = ahp->ah_totalPowerMeasI[i]; 2478 key1 = (get_unaligned_le16(k->kv_val + 4) ^ xorMask) & 0xffff;
6225 powerMeasQ = ahp->ah_totalPowerMeasQ[i]; 2479 key2 = get_unaligned_le32(k->kv_val + 6) ^ xorMask;
6226 iqCorrMeas = ahp->ah_totalIqCorrMeas[i]; 2480 key3 = (get_unaligned_le16(k->kv_val + 10) ^ xorMask) & 0xffff;
2481 key4 = get_unaligned_le32(k->kv_val + 12) ^ xorMask;
2482 if (k->kv_len <= LEN_WEP104)
2483 key4 &= 0xff;
6227 2484
6228 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 2485 if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) {
6229 "Starting IQ Cal and Correction for Chain %d\n", 2486 u16 micentry = entry + 64;
6230 i);
6231 2487
6232 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 2488 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), ~key0);
6233 "Orignal: Chn %diq_corr_meas = 0x%08x\n", 2489 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), ~key1);
6234 i, ahp->ah_totalIqCorrMeas[i]); 2490 REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);
2491 REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
2492 REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
2493 REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
2494 (void) ath9k_hw_keysetmac(ah, entry, mac);
6235 2495
6236 iqCorrNeg = 0; 2496 if (ahp->ah_miscMode & AR_PCU_MIC_NEW_LOC_ENA) {
2497 u32 mic0, mic1, mic2, mic3, mic4;
6237 2498
2499 mic0 = get_unaligned_le32(k->kv_mic + 0);
2500 mic2 = get_unaligned_le32(k->kv_mic + 4);
2501 mic1 = get_unaligned_le16(k->kv_txmic + 2) & 0xffff;
2502 mic3 = get_unaligned_le16(k->kv_txmic + 0) & 0xffff;
2503 mic4 = get_unaligned_le32(k->kv_txmic + 4);
2504 REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
2505 REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), mic1);
2506 REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
2507 REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), mic3);
2508 REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), mic4);
2509 REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
2510 AR_KEYTABLE_TYPE_CLR);
6238 2511
6239 if (iqCorrMeas > 0x80000000) { 2512 } else {
6240 iqCorrMeas = (0xffffffff - iqCorrMeas) + 1; 2513 u32 mic0, mic2;
6241 iqCorrNeg = 1;
6242 }
6243 2514
6244 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 2515 mic0 = get_unaligned_le32(k->kv_mic + 0);
6245 "Chn %d pwr_meas_i = 0x%08x\n", i, powerMeasI); 2516 mic2 = get_unaligned_le32(k->kv_mic + 4);
6246 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 2517 REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
6247 "Chn %d pwr_meas_q = 0x%08x\n", i, powerMeasQ); 2518 REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
6248 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, "iqCorrNeg is 0x%08x\n", 2519 REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
6249 iqCorrNeg); 2520 REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
6250 2521 REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);
6251 iCoffDenom = (powerMeasI / 2 + powerMeasQ / 2) / 128; 2522 REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
6252 qCoffDenom = powerMeasQ / 64; 2523 AR_KEYTABLE_TYPE_CLR);
6253
6254 if (powerMeasQ != 0) {
6255
6256 iCoff = iqCorrMeas / iCoffDenom;
6257 qCoff = powerMeasI / qCoffDenom - 64;
6258 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6259 "Chn %d iCoff = 0x%08x\n", i, iCoff);
6260 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6261 "Chn %d qCoff = 0x%08x\n", i, qCoff);
6262
6263
6264 iCoff = iCoff & 0x3f;
6265 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6266 "New: Chn %d iCoff = 0x%08x\n", i, iCoff);
6267 if (iqCorrNeg == 0x0)
6268 iCoff = 0x40 - iCoff;
6269
6270 if (qCoff > 15)
6271 qCoff = 15;
6272 else if (qCoff <= -16)
6273 qCoff = 16;
6274
6275 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6276 "Chn %d : iCoff = 0x%x qCoff = 0x%x\n",
6277 i, iCoff, qCoff);
6278
6279 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(i),
6280 AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF,
6281 iCoff);
6282 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(i),
6283 AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF,
6284 qCoff);
6285 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6286 "IQ Cal and Correction done for Chain %d\n",
6287 i);
6288 } 2524 }
6289 } 2525 REG_WRITE(ah, AR_KEYTABLE_MAC0(micentry), 0);
6290 2526 REG_WRITE(ah, AR_KEYTABLE_MAC1(micentry), 0);
6291 REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0), 2527 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
6292 AR_PHY_TIMING_CTRL4_IQCORR_ENABLE); 2528 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
6293} 2529 } else {
2530 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
2531 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
2532 REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);
2533 REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
2534 REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
2535 REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
6294 2536
6295static void 2537 (void) ath9k_hw_keysetmac(ah, entry, mac);
6296ath9k_hw_adc_gaincal_calibrate(struct ath_hal *ah, u8 numChains)
6297{
6298 struct ath_hal_5416 *ahp = AH5416(ah);
6299 u32 iOddMeasOffset, iEvenMeasOffset, qOddMeasOffset,
6300 qEvenMeasOffset;
6301 u32 qGainMismatch, iGainMismatch, val, i;
6302
6303 for (i = 0; i < numChains; i++) {
6304 iOddMeasOffset = ahp->ah_totalAdcIOddPhase[i];
6305 iEvenMeasOffset = ahp->ah_totalAdcIEvenPhase[i];
6306 qOddMeasOffset = ahp->ah_totalAdcQOddPhase[i];
6307 qEvenMeasOffset = ahp->ah_totalAdcQEvenPhase[i];
6308
6309 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6310 "Starting ADC Gain Cal for Chain %d\n", i);
6311
6312 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6313 "Chn %d pwr_meas_odd_i = 0x%08x\n", i,
6314 iOddMeasOffset);
6315 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6316 "Chn %d pwr_meas_even_i = 0x%08x\n", i,
6317 iEvenMeasOffset);
6318 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6319 "Chn %d pwr_meas_odd_q = 0x%08x\n", i,
6320 qOddMeasOffset);
6321 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6322 "Chn %d pwr_meas_even_q = 0x%08x\n", i,
6323 qEvenMeasOffset);
6324
6325 if (iOddMeasOffset != 0 && qEvenMeasOffset != 0) {
6326 iGainMismatch =
6327 ((iEvenMeasOffset * 32) /
6328 iOddMeasOffset) & 0x3f;
6329 qGainMismatch =
6330 ((qOddMeasOffset * 32) /
6331 qEvenMeasOffset) & 0x3f;
6332
6333 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6334 "Chn %d gain_mismatch_i = 0x%08x\n", i,
6335 iGainMismatch);
6336 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6337 "Chn %d gain_mismatch_q = 0x%08x\n", i,
6338 qGainMismatch);
6339
6340 val = REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i));
6341 val &= 0xfffff000;
6342 val |= (qGainMismatch) | (iGainMismatch << 6);
6343 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i), val);
6344
6345 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6346 "ADC Gain Cal done for Chain %d\n", i);
6347 }
6348 } 2538 }
6349 2539
6350 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0), 2540 if (ah->ah_curchan == NULL)
6351 REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0)) | 2541 return true;
6352 AR_PHY_NEW_ADC_GAIN_CORR_ENABLE); 2542
2543 return true;
6353} 2544}
6354 2545
6355static void 2546bool ath9k_hw_keyisvalid(struct ath_hal *ah, u16 entry)
6356ath9k_hw_adc_dccal_calibrate(struct ath_hal *ah, u8 numChains)
6357{ 2547{
6358 struct ath_hal_5416 *ahp = AH5416(ah); 2548 if (entry < ah->ah_caps.keycache_size) {
6359 u32 iOddMeasOffset, iEvenMeasOffset, val, i; 2549 u32 val = REG_READ(ah, AR_KEYTABLE_MAC1(entry));
6360 int32_t qOddMeasOffset, qEvenMeasOffset, qDcMismatch, iDcMismatch; 2550 if (val & AR_KEYTABLE_VALID)
6361 const struct hal_percal_data *calData = 2551 return true;
6362 ahp->ah_cal_list_curr->calData;
6363 u32 numSamples =
6364 (1 << (calData->calCountMax + 5)) * calData->calNumSamples;
6365
6366 for (i = 0; i < numChains; i++) {
6367 iOddMeasOffset = ahp->ah_totalAdcDcOffsetIOddPhase[i];
6368 iEvenMeasOffset = ahp->ah_totalAdcDcOffsetIEvenPhase[i];
6369 qOddMeasOffset = ahp->ah_totalAdcDcOffsetQOddPhase[i];
6370 qEvenMeasOffset = ahp->ah_totalAdcDcOffsetQEvenPhase[i];
6371
6372 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6373 "Starting ADC DC Offset Cal for Chain %d\n", i);
6374
6375 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6376 "Chn %d pwr_meas_odd_i = %d\n", i,
6377 iOddMeasOffset);
6378 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6379 "Chn %d pwr_meas_even_i = %d\n", i,
6380 iEvenMeasOffset);
6381 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6382 "Chn %d pwr_meas_odd_q = %d\n", i,
6383 qOddMeasOffset);
6384 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6385 "Chn %d pwr_meas_even_q = %d\n", i,
6386 qEvenMeasOffset);
6387
6388 iDcMismatch = (((iEvenMeasOffset - iOddMeasOffset) * 2) /
6389 numSamples) & 0x1ff;
6390 qDcMismatch = (((qOddMeasOffset - qEvenMeasOffset) * 2) /
6391 numSamples) & 0x1ff;
6392
6393 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6394 "Chn %d dc_offset_mismatch_i = 0x%08x\n", i,
6395 iDcMismatch);
6396 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6397 "Chn %d dc_offset_mismatch_q = 0x%08x\n", i,
6398 qDcMismatch);
6399
6400 val = REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i));
6401 val &= 0xc0000fff;
6402 val |= (qDcMismatch << 12) | (iDcMismatch << 21);
6403 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i), val);
6404
6405 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6406 "ADC DC Offset Cal done for Chain %d\n", i);
6407 } 2552 }
6408 2553 return false;
6409 REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0),
6410 REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0)) |
6411 AR_PHY_NEW_ADC_DC_OFFSET_CORR_ENABLE);
6412} 2554}
6413 2555
6414bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit) 2556/******************************/
6415{ 2557/* Power Management (Chipset) */
6416 struct ath_hal_5416 *ahp = AH5416(ah); 2558/******************************/
6417 struct ath9k_channel *chan = ah->ah_curchan;
6418 2559
6419 ah->ah_powerLimit = min(limit, (u32) MAX_RATE_POWER); 2560static void ath9k_set_power_sleep(struct ath_hal *ah, int setChip)
6420
6421 if (ath9k_hw_set_txpower(ah, &ahp->ah_eeprom, chan,
6422 ath9k_regd_get_ctl(ah, chan),
6423 ath9k_regd_get_antenna_allowed(ah,
6424 chan),
6425 chan->maxRegTxPower * 2,
6426 min((u32) MAX_RATE_POWER,
6427 (u32) ah->ah_powerLimit)) != 0)
6428 return false;
6429
6430 return true;
6431}
6432
6433void
6434ath9k_hw_get_channel_centers(struct ath_hal *ah,
6435 struct ath9k_channel *chan,
6436 struct chan_centers *centers)
6437{ 2561{
6438 int8_t extoff; 2562 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
6439 struct ath_hal_5416 *ahp = AH5416(ah); 2563 if (setChip) {
6440 2564 REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE,
6441 if (!IS_CHAN_HT40(chan)) { 2565 AR_RTC_FORCE_WAKE_EN);
6442 centers->ctl_center = centers->ext_center = 2566 if (!AR_SREV_9100(ah))
6443 centers->synth_center = chan->channel; 2567 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
6444 return;
6445 }
6446 2568
6447 if ((chan->chanmode == CHANNEL_A_HT40PLUS) || 2569 REG_CLR_BIT(ah, (u16) (AR_RTC_RESET),
6448 (chan->chanmode == CHANNEL_G_HT40PLUS)) { 2570 AR_RTC_RESET_EN);
6449 centers->synth_center =
6450 chan->channel + HT40_CHANNEL_CENTER_SHIFT;
6451 extoff = 1;
6452 } else {
6453 centers->synth_center =
6454 chan->channel - HT40_CHANNEL_CENTER_SHIFT;
6455 extoff = -1;
6456 } 2571 }
6457
6458 centers->ctl_center = centers->synth_center - (extoff *
6459 HT40_CHANNEL_CENTER_SHIFT);
6460 centers->ext_center = centers->synth_center + (extoff *
6461 ((ahp->
6462 ah_extprotspacing
6463 ==
6464 ATH9K_HT_EXTPROTSPACING_20)
6465 ?
6466 HT40_CHANNEL_CENTER_SHIFT
6467 : 15));
6468
6469} 2572}
6470 2573
6471void 2574static void ath9k_set_power_network_sleep(struct ath_hal *ah, int setChip)
6472ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan,
6473 bool *isCalDone)
6474{ 2575{
6475 struct ath_hal_5416 *ahp = AH5416(ah); 2576 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
6476 struct ath9k_channel *ichan = 2577 if (setChip) {
6477 ath9k_regd_check_channel(ah, chan); 2578 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
6478 struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
6479
6480 *isCalDone = true;
6481
6482 if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah))
6483 return;
6484
6485 if (currCal == NULL)
6486 return;
6487
6488 if (ichan == NULL) {
6489 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6490 "%s: invalid channel %u/0x%x; no mapping\n",
6491 __func__, chan->channel, chan->channelFlags);
6492 return;
6493 }
6494
6495 2579
6496 if (currCal->calState != CAL_DONE) { 2580 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
6497 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 2581 REG_WRITE(ah, AR_RTC_FORCE_WAKE,
6498 "%s: Calibration state incorrect, %d\n", 2582 AR_RTC_FORCE_WAKE_ON_INT);
6499 __func__, currCal->calState); 2583 } else {
6500 return; 2584 REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE,
2585 AR_RTC_FORCE_WAKE_EN);
2586 }
6501 } 2587 }
6502
6503
6504 if (!ath9k_hw_iscal_supported(ah, chan, currCal->calData->calType))
6505 return;
6506
6507 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
6508 "%s: Resetting Cal %d state for channel %u/0x%x\n",
6509 __func__, currCal->calData->calType, chan->channel,
6510 chan->channelFlags);
6511
6512 ichan->CalValid &= ~currCal->calData->calType;
6513 currCal->calState = CAL_WAITING;
6514
6515 *isCalDone = false;
6516} 2588}
6517 2589
6518void ath9k_hw_getmac(struct ath_hal *ah, u8 *mac) 2590static bool ath9k_hw_set_power_awake(struct ath_hal *ah,
2591 int setChip)
6519{ 2592{
6520 struct ath_hal_5416 *ahp = AH5416(ah); 2593 u32 val;
2594 int i;
6521 2595
6522 memcpy(mac, ahp->ah_macaddr, ETH_ALEN); 2596 if (setChip) {
6523} 2597 if ((REG_READ(ah, AR_RTC_STATUS) &
2598 AR_RTC_STATUS_M) == AR_RTC_STATUS_SHUTDOWN) {
2599 if (ath9k_hw_set_reset_reg(ah,
2600 ATH9K_RESET_POWER_ON) != true) {
2601 return false;
2602 }
2603 }
2604 if (AR_SREV_9100(ah))
2605 REG_SET_BIT(ah, AR_RTC_RESET,
2606 AR_RTC_RESET_EN);
6524 2607
6525bool ath9k_hw_setmac(struct ath_hal *ah, const u8 *mac) 2608 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
6526{ 2609 AR_RTC_FORCE_WAKE_EN);
6527 struct ath_hal_5416 *ahp = AH5416(ah); 2610 udelay(50);
6528 2611
6529 memcpy(ahp->ah_macaddr, mac, ETH_ALEN); 2612 for (i = POWER_UP_TIME / 50; i > 0; i--) {
6530 return true; 2613 val = REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M;
6531} 2614 if (val == AR_RTC_STATUS_ON)
2615 break;
2616 udelay(50);
2617 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
2618 AR_RTC_FORCE_WAKE_EN);
2619 }
2620 if (i == 0) {
2621 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
2622 "%s: Failed to wakeup in %uus\n",
2623 __func__, POWER_UP_TIME / 20);
2624 return false;
2625 }
2626 }
6532 2627
6533void ath9k_hw_getbssidmask(struct ath_hal *ah, u8 *mask) 2628 REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
6534{
6535 struct ath_hal_5416 *ahp = AH5416(ah);
6536 2629
6537 memcpy(mask, ahp->ah_bssidmask, ETH_ALEN); 2630 return true;
6538} 2631}
6539 2632
6540bool 2633bool ath9k_hw_setpower(struct ath_hal *ah,
6541ath9k_hw_setbssidmask(struct ath_hal *ah, const u8 *mask) 2634 enum ath9k_power_mode mode)
6542{ 2635{
6543 struct ath_hal_5416 *ahp = AH5416(ah); 2636 struct ath_hal_5416 *ahp = AH5416(ah);
2637 static const char *modes[] = {
2638 "AWAKE",
2639 "FULL-SLEEP",
2640 "NETWORK SLEEP",
2641 "UNDEFINED"
2642 };
2643 int status = true, setChip = true;
6544 2644
6545 memcpy(ahp->ah_bssidmask, mask, ETH_ALEN); 2645 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, "%s: %s -> %s (%s)\n", __func__,
2646 modes[ahp->ah_powerMode], modes[mode],
2647 setChip ? "set chip " : "");
6546 2648
6547 REG_WRITE(ah, AR_BSSMSKL, get_unaligned_le32(ahp->ah_bssidmask)); 2649 switch (mode) {
6548 REG_WRITE(ah, AR_BSSMSKU, get_unaligned_le16(ahp->ah_bssidmask + 4)); 2650 case ATH9K_PM_AWAKE:
2651 status = ath9k_hw_set_power_awake(ah, setChip);
2652 break;
2653 case ATH9K_PM_FULL_SLEEP:
2654 ath9k_set_power_sleep(ah, setChip);
2655 ahp->ah_chipFullSleep = true;
2656 break;
2657 case ATH9K_PM_NETWORK_SLEEP:
2658 ath9k_set_power_network_sleep(ah, setChip);
2659 break;
2660 default:
2661 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
2662 "%s: unknown power mode %u\n", __func__, mode);
2663 return false;
2664 }
2665 ahp->ah_powerMode = mode;
6549 2666
6550 return true; 2667 return status;
6551} 2668}
6552 2669
6553void 2670void ath9k_hw_configpcipowersave(struct ath_hal *ah, int restore)
6554ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid,
6555 u16 assocId)
6556{ 2671{
6557 struct ath_hal_5416 *ahp = AH5416(ah); 2672 struct ath_hal_5416 *ahp = AH5416(ah);
2673 u8 i;
6558 2674
6559 memcpy(ahp->ah_bssid, bssid, ETH_ALEN); 2675 if (ah->ah_isPciExpress != true)
6560 ahp->ah_assocId = assocId; 2676 return;
6561
6562 REG_WRITE(ah, AR_BSS_ID0, get_unaligned_le32(ahp->ah_bssid));
6563 REG_WRITE(ah, AR_BSS_ID1, get_unaligned_le16(ahp->ah_bssid + 4) |
6564 ((assocId & 0x3fff) << AR_BSS_ID1_AID_S));
6565}
6566
6567u64 ath9k_hw_gettsf64(struct ath_hal *ah)
6568{
6569 u64 tsf;
6570 2677
6571 tsf = REG_READ(ah, AR_TSF_U32); 2678 if (ah->ah_config.pcie_powersave_enable == 2)
6572 tsf = (tsf << 32) | REG_READ(ah, AR_TSF_L32); 2679 return;
6573 return tsf;
6574}
6575 2680
6576void ath9k_hw_reset_tsf(struct ath_hal *ah) 2681 if (restore)
6577{ 2682 return;
6578 int count;
6579 2683
6580 count = 0; 2684 if (AR_SREV_9280_20_OR_LATER(ah)) {
6581 while (REG_READ(ah, AR_SLP32_MODE) & AR_SLP32_TSF_WRITE_STATUS) { 2685 for (i = 0; i < ahp->ah_iniPcieSerdes.ia_rows; i++) {
6582 count++; 2686 REG_WRITE(ah, INI_RA(&ahp->ah_iniPcieSerdes, i, 0),
6583 if (count > 10) { 2687 INI_RA(&ahp->ah_iniPcieSerdes, i, 1));
6584 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
6585 "%s: AR_SLP32_TSF_WRITE_STATUS limit exceeded\n",
6586 __func__);
6587 break;
6588 } 2688 }
6589 udelay(10); 2689 udelay(1000);
6590 } 2690 } else if (AR_SREV_9280(ah) &&
6591 REG_WRITE(ah, AR_RESET_TSF, AR_RESET_TSF_ONCE); 2691 (ah->ah_macRev == AR_SREV_REVISION_9280_10)) {
6592} 2692 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00);
6593 2693 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
6594u32 ath9k_hw_getdefantenna(struct ath_hal *ah)
6595{
6596 return REG_READ(ah, AR_DEF_ANTENNA) & 0x7;
6597}
6598 2694
6599void ath9k_hw_setantenna(struct ath_hal *ah, u32 antenna) 2695 REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019);
6600{ 2696 REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820);
6601 REG_WRITE(ah, AR_DEF_ANTENNA, (antenna & 0x7)); 2697 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560);
6602}
6603 2698
6604bool 2699 if (ah->ah_config.pcie_clock_req)
6605ath9k_hw_setantennaswitch(struct ath_hal *ah, 2700 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc);
6606 enum ath9k_ant_setting settings, 2701 else
6607 struct ath9k_channel *chan, 2702 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd);
6608 u8 *tx_chainmask,
6609 u8 *rx_chainmask,
6610 u8 *antenna_cfgd)
6611{
6612 struct ath_hal_5416 *ahp = AH5416(ah);
6613 static u8 tx_chainmask_cfg, rx_chainmask_cfg;
6614 2703
6615 if (AR_SREV_9280(ah)) { 2704 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
6616 if (!tx_chainmask_cfg) { 2705 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
2706 REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007);
6617 2707
6618 tx_chainmask_cfg = *tx_chainmask; 2708 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
6619 rx_chainmask_cfg = *rx_chainmask;
6620 }
6621 2709
6622 switch (settings) { 2710 udelay(1000);
6623 case ATH9K_ANT_FIXED_A:
6624 *tx_chainmask = ATH9K_ANTENNA0_CHAINMASK;
6625 *rx_chainmask = ATH9K_ANTENNA0_CHAINMASK;
6626 *antenna_cfgd = true;
6627 break;
6628 case ATH9K_ANT_FIXED_B:
6629 if (ah->ah_caps.tx_chainmask >
6630 ATH9K_ANTENNA1_CHAINMASK) {
6631 *tx_chainmask = ATH9K_ANTENNA1_CHAINMASK;
6632 }
6633 *rx_chainmask = ATH9K_ANTENNA1_CHAINMASK;
6634 *antenna_cfgd = true;
6635 break;
6636 case ATH9K_ANT_VARIABLE:
6637 *tx_chainmask = tx_chainmask_cfg;
6638 *rx_chainmask = rx_chainmask_cfg;
6639 *antenna_cfgd = true;
6640 break;
6641 default:
6642 break;
6643 }
6644 } else { 2711 } else {
6645 ahp->ah_diversityControl = settings; 2712 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
2713 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
2714 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039);
2715 REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824);
2716 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579);
2717 REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff);
2718 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
2719 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
2720 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007);
2721 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
6646 } 2722 }
6647 2723
6648 return true; 2724 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
6649}
6650
6651void ath9k_hw_setopmode(struct ath_hal *ah)
6652{
6653 ath9k_hw_set_operating_mode(ah, ah->ah_opmode);
6654}
6655
6656bool
6657ath9k_hw_getcapability(struct ath_hal *ah, enum ath9k_capability_type type,
6658 u32 capability, u32 *result)
6659{
6660 struct ath_hal_5416 *ahp = AH5416(ah);
6661 const struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
6662 2725
6663 switch (type) { 2726 if (ah->ah_config.pcie_waen) {
6664 case ATH9K_CAP_CIPHER: 2727 REG_WRITE(ah, AR_WA, ah->ah_config.pcie_waen);
6665 switch (capability) { 2728 } else {
6666 case ATH9K_CIPHER_AES_CCM: 2729 if (AR_SREV_9280(ah))
6667 case ATH9K_CIPHER_AES_OCB: 2730 REG_WRITE(ah, AR_WA, 0x0040073f);
6668 case ATH9K_CIPHER_TKIP: 2731 else
6669 case ATH9K_CIPHER_WEP: 2732 REG_WRITE(ah, AR_WA, 0x0000073f);
6670 case ATH9K_CIPHER_MIC:
6671 case ATH9K_CIPHER_CLR:
6672 return true;
6673 default:
6674 return false;
6675 }
6676 case ATH9K_CAP_TKIP_MIC:
6677 switch (capability) {
6678 case 0:
6679 return true;
6680 case 1:
6681 return (ahp->ah_staId1Defaults &
6682 AR_STA_ID1_CRPT_MIC_ENABLE) ? true :
6683 false;
6684 }
6685 case ATH9K_CAP_TKIP_SPLIT:
6686 return (ahp->ah_miscMode & AR_PCU_MIC_NEW_LOC_ENA) ?
6687 false : true;
6688 case ATH9K_CAP_WME_TKIPMIC:
6689 return 0;
6690 case ATH9K_CAP_PHYCOUNTERS:
6691 return ahp->ah_hasHwPhyCounters ? 0 : -ENXIO;
6692 case ATH9K_CAP_DIVERSITY:
6693 return (REG_READ(ah, AR_PHY_CCK_DETECT) &
6694 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV) ?
6695 true : false;
6696 case ATH9K_CAP_PHYDIAG:
6697 return true;
6698 case ATH9K_CAP_MCAST_KEYSRCH:
6699 switch (capability) {
6700 case 0:
6701 return true;
6702 case 1:
6703 if (REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_ADHOC) {
6704 return false;
6705 } else {
6706 return (ahp->ah_staId1Defaults &
6707 AR_STA_ID1_MCAST_KSRCH) ? true :
6708 false;
6709 }
6710 }
6711 return false;
6712 case ATH9K_CAP_TSF_ADJUST:
6713 return (ahp->ah_miscMode & AR_PCU_TX_ADD_TSF) ?
6714 true : false;
6715 case ATH9K_CAP_RFSILENT:
6716 if (capability == 3)
6717 return false;
6718 case ATH9K_CAP_ANT_CFG_2GHZ:
6719 *result = pCap->num_antcfg_2ghz;
6720 return true;
6721 case ATH9K_CAP_ANT_CFG_5GHZ:
6722 *result = pCap->num_antcfg_5ghz;
6723 return true;
6724 case ATH9K_CAP_TXPOW:
6725 switch (capability) {
6726 case 0:
6727 return 0;
6728 case 1:
6729 *result = ah->ah_powerLimit;
6730 return 0;
6731 case 2:
6732 *result = ah->ah_maxPowerLevel;
6733 return 0;
6734 case 3:
6735 *result = ah->ah_tpScale;
6736 return 0;
6737 }
6738 return false;
6739 default:
6740 return false;
6741 } 2733 }
6742} 2734}
6743 2735
6744int 2736/**********************/
6745ath9k_hw_select_antconfig(struct ath_hal *ah, u32 cfg) 2737/* Interrupt Handling */
6746{ 2738/**********************/
6747 struct ath_hal_5416 *ahp = AH5416(ah);
6748 struct ath9k_channel *chan = ah->ah_curchan;
6749 const struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
6750 u16 ant_config;
6751 u32 halNumAntConfig;
6752
6753 halNumAntConfig =
6754 IS_CHAN_2GHZ(chan) ? pCap->num_antcfg_2ghz : pCap->
6755 num_antcfg_5ghz;
6756
6757 if (cfg < halNumAntConfig) {
6758 if (!ath9k_hw_get_eeprom_antenna_cfg(ahp, chan,
6759 cfg, &ant_config)) {
6760 REG_WRITE(ah, AR_PHY_SWITCH_COM, ant_config);
6761 return 0;
6762 }
6763 }
6764
6765 return -EINVAL;
6766}
6767 2739
6768bool ath9k_hw_intrpend(struct ath_hal *ah) 2740bool ath9k_hw_intrpend(struct ath_hal *ah)
6769{ 2741{
@@ -6791,6 +2763,7 @@ bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked)
6791 struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 2763 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
6792 u32 sync_cause = 0; 2764 u32 sync_cause = 0;
6793 bool fatal_int = false; 2765 bool fatal_int = false;
2766 struct ath_hal_5416 *ahp = AH5416(ah);
6794 2767
6795 if (!AR_SREV_9100(ah)) { 2768 if (!AR_SREV_9100(ah)) {
6796 if (REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) { 2769 if (REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) {
@@ -6800,9 +2773,8 @@ bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked)
6800 } 2773 }
6801 } 2774 }
6802 2775
6803 sync_cause = 2776 sync_cause = REG_READ(ah, AR_INTR_SYNC_CAUSE) &
6804 REG_READ(ah, 2777 AR_INTR_SYNC_DEFAULT;
6805 AR_INTR_SYNC_CAUSE) & AR_INTR_SYNC_DEFAULT;
6806 2778
6807 *masked = 0; 2779 *masked = 0;
6808 2780
@@ -6814,8 +2786,6 @@ bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked)
6814 } 2786 }
6815 2787
6816 if (isr) { 2788 if (isr) {
6817 struct ath_hal_5416 *ahp = AH5416(ah);
6818
6819 if (isr & AR_ISR_BCNMISC) { 2789 if (isr & AR_ISR_BCNMISC) {
6820 u32 isr2; 2790 u32 isr2;
6821 isr2 = REG_READ(ah, AR_ISR_S2); 2791 isr2 = REG_READ(ah, AR_ISR_S2);
@@ -6842,7 +2812,6 @@ bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked)
6842 *masked = isr & ATH9K_INT_COMMON; 2812 *masked = isr & ATH9K_INT_COMMON;
6843 2813
6844 if (ahp->ah_intrMitigation) { 2814 if (ahp->ah_intrMitigation) {
6845
6846 if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM)) 2815 if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM))
6847 *masked |= ATH9K_INT_RX; 2816 *masked |= ATH9K_INT_RX;
6848 } 2817 }
@@ -6867,8 +2836,8 @@ bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked)
6867 2836
6868 if (isr & AR_ISR_RXORN) { 2837 if (isr & AR_ISR_RXORN) {
6869 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT, 2838 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT,
6870 "%s: receive FIFO overrun interrupt\n", 2839 "%s: receive FIFO overrun interrupt\n",
6871 __func__); 2840 __func__);
6872 } 2841 }
6873 2842
6874 if (!AR_SREV_9100(ah)) { 2843 if (!AR_SREV_9100(ah)) {
@@ -6881,8 +2850,10 @@ bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked)
6881 2850
6882 *masked |= mask2; 2851 *masked |= mask2;
6883 } 2852 }
2853
6884 if (AR_SREV_9100(ah)) 2854 if (AR_SREV_9100(ah))
6885 return true; 2855 return true;
2856
6886 if (sync_cause) { 2857 if (sync_cause) {
6887 fatal_int = 2858 fatal_int =
6888 (sync_cause & 2859 (sync_cause &
@@ -6892,32 +2863,33 @@ bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked)
6892 if (fatal_int) { 2863 if (fatal_int) {
6893 if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) { 2864 if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) {
6894 DPRINTF(ah->ah_sc, ATH_DBG_ANY, 2865 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
6895 "%s: received PCI FATAL interrupt\n", 2866 "%s: received PCI FATAL interrupt\n",
6896 __func__); 2867 __func__);
6897 } 2868 }
6898 if (sync_cause & AR_INTR_SYNC_HOST1_PERR) { 2869 if (sync_cause & AR_INTR_SYNC_HOST1_PERR) {
6899 DPRINTF(ah->ah_sc, ATH_DBG_ANY, 2870 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
6900 "%s: received PCI PERR interrupt\n", 2871 "%s: received PCI PERR interrupt\n",
6901 __func__); 2872 __func__);
6902 } 2873 }
6903 } 2874 }
6904 if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) { 2875 if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) {
6905 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT, 2876 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT,
6906 "%s: AR_INTR_SYNC_RADM_CPL_TIMEOUT\n", 2877 "%s: AR_INTR_SYNC_RADM_CPL_TIMEOUT\n",
6907 __func__); 2878 __func__);
6908 REG_WRITE(ah, AR_RC, AR_RC_HOSTIF); 2879 REG_WRITE(ah, AR_RC, AR_RC_HOSTIF);
6909 REG_WRITE(ah, AR_RC, 0); 2880 REG_WRITE(ah, AR_RC, 0);
6910 *masked |= ATH9K_INT_FATAL; 2881 *masked |= ATH9K_INT_FATAL;
6911 } 2882 }
6912 if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) { 2883 if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) {
6913 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT, 2884 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT,
6914 "%s: AR_INTR_SYNC_LOCAL_TIMEOUT\n", 2885 "%s: AR_INTR_SYNC_LOCAL_TIMEOUT\n",
6915 __func__); 2886 __func__);
6916 } 2887 }
6917 2888
6918 REG_WRITE(ah, AR_INTR_SYNC_CAUSE_CLR, sync_cause); 2889 REG_WRITE(ah, AR_INTR_SYNC_CAUSE_CLR, sync_cause);
6919 (void) REG_READ(ah, AR_INTR_SYNC_CAUSE_CLR); 2890 (void) REG_READ(ah, AR_INTR_SYNC_CAUSE_CLR);
6920 } 2891 }
2892
6921 return true; 2893 return true;
6922} 2894}
6923 2895
@@ -7035,9 +3007,11 @@ enum ath9k_int ath9k_hw_set_interrupts(struct ath_hal *ah, enum ath9k_int ints)
7035 return omask; 3007 return omask;
7036} 3008}
7037 3009
7038void 3010/*******************/
7039ath9k_hw_beaconinit(struct ath_hal *ah, 3011/* Beacon Handling */
7040 u32 next_beacon, u32 beacon_period) 3012/*******************/
3013
3014void ath9k_hw_beaconinit(struct ath_hal *ah, u32 next_beacon, u32 beacon_period)
7041{ 3015{
7042 struct ath_hal_5416 *ahp = AH5416(ah); 3016 struct ath_hal_5416 *ahp = AH5416(ah);
7043 int flags = 0; 3017 int flags = 0;
@@ -7089,9 +3063,8 @@ ath9k_hw_beaconinit(struct ath_hal *ah,
7089 REG_SET_BIT(ah, AR_TIMER_MODE, flags); 3063 REG_SET_BIT(ah, AR_TIMER_MODE, flags);
7090} 3064}
7091 3065
7092void 3066void ath9k_hw_set_sta_beacon_timers(struct ath_hal *ah,
7093ath9k_hw_set_sta_beacon_timers(struct ath_hal *ah, 3067 const struct ath9k_beacon_state *bs)
7094 const struct ath9k_beacon_state *bs)
7095{ 3068{
7096 u32 nextTbtt, beaconintval, dtimperiod, beacontimeout; 3069 u32 nextTbtt, beaconintval, dtimperiod, beacontimeout;
7097 struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 3070 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
@@ -7154,1424 +3127,869 @@ ath9k_hw_set_sta_beacon_timers(struct ath_hal *ah,
7154 3127
7155} 3128}
7156 3129
7157bool ath9k_hw_keyisvalid(struct ath_hal *ah, u16 entry) 3130/***************/
7158{ 3131/* Rate tables */
7159 if (entry < ah->ah_caps.keycache_size) { 3132/***************/
7160 u32 val = REG_READ(ah, AR_KEYTABLE_MAC1(entry));
7161 if (val & AR_KEYTABLE_VALID)
7162 return true;
7163 }
7164 return false;
7165}
7166 3133
7167bool ath9k_hw_keyreset(struct ath_hal *ah, u16 entry) 3134static struct ath9k_rate_table ar5416_11a_table = {
7168{ 3135 8,
7169 u32 keyType; 3136 {0},
7170 3137 {
7171 if (entry >= ah->ah_caps.keycache_size) { 3138 {true, PHY_OFDM, 6000, 0x0b, 0x00, (0x80 | 12), 0},
7172 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE, 3139 {true, PHY_OFDM, 9000, 0x0f, 0x00, 18, 0},
7173 "%s: entry %u out of range\n", __func__, entry); 3140 {true, PHY_OFDM, 12000, 0x0a, 0x00, (0x80 | 24), 2},
7174 return false; 3141 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 2},
7175 } 3142 {true, PHY_OFDM, 24000, 0x09, 0x00, (0x80 | 48), 4},
7176 keyType = REG_READ(ah, AR_KEYTABLE_TYPE(entry)); 3143 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 4},
3144 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 4},
3145 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 4}
3146 },
3147};
7177 3148
7178 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0); 3149static struct ath9k_rate_table ar5416_11b_table = {
7179 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0); 3150 4,
7180 REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0); 3151 {0},
7181 REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0); 3152 {
7182 REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0); 3153 {true, PHY_CCK, 1000, 0x1b, 0x00, (0x80 | 2), 0},
7183 REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR); 3154 {true, PHY_CCK, 2000, 0x1a, 0x04, (0x80 | 4), 1},
7184 REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0); 3155 {true, PHY_CCK, 5500, 0x19, 0x04, (0x80 | 11), 1},
7185 REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0); 3156 {true, PHY_CCK, 11000, 0x18, 0x04, (0x80 | 22), 1}
3157 },
3158};
7186 3159
7187 if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) { 3160static struct ath9k_rate_table ar5416_11g_table = {
7188 u16 micentry = entry + 64; 3161 12,
3162 {0},
3163 {
3164 {true, PHY_CCK, 1000, 0x1b, 0x00, (0x80 | 2), 0},
3165 {true, PHY_CCK, 2000, 0x1a, 0x04, (0x80 | 4), 1},
3166 {true, PHY_CCK, 5500, 0x19, 0x04, (0x80 | 11), 2},
3167 {true, PHY_CCK, 11000, 0x18, 0x04, (0x80 | 22), 3},
7189 3168
7190 REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0); 3169 {false, PHY_OFDM, 6000, 0x0b, 0x00, 12, 4},
7191 REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0); 3170 {false, PHY_OFDM, 9000, 0x0f, 0x00, 18, 4},
7192 REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0); 3171 {true, PHY_OFDM, 12000, 0x0a, 0x00, 24, 6},
7193 REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0); 3172 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 6},
3173 {true, PHY_OFDM, 24000, 0x09, 0x00, 48, 8},
3174 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 8},
3175 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 8},
3176 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 8}
3177 },
3178};
7194 3179
7195 } 3180static struct ath9k_rate_table ar5416_11ng_table = {
3181 28,
3182 {0},
3183 {
3184 {true, PHY_CCK, 1000, 0x1b, 0x00, (0x80 | 2), 0},
3185 {true, PHY_CCK, 2000, 0x1a, 0x04, (0x80 | 4), 1},
3186 {true, PHY_CCK, 5500, 0x19, 0x04, (0x80 | 11), 2},
3187 {true, PHY_CCK, 11000, 0x18, 0x04, (0x80 | 22), 3},
7196 3188
7197 if (ah->ah_curchan == NULL) 3189 {false, PHY_OFDM, 6000, 0x0b, 0x00, 12, 4},
7198 return true; 3190 {false, PHY_OFDM, 9000, 0x0f, 0x00, 18, 4},
3191 {true, PHY_OFDM, 12000, 0x0a, 0x00, 24, 6},
3192 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 6},
3193 {true, PHY_OFDM, 24000, 0x09, 0x00, 48, 8},
3194 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 8},
3195 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 8},
3196 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 8},
3197 {true, PHY_HT, 6500, 0x80, 0x00, 0, 4},
3198 {true, PHY_HT, 13000, 0x81, 0x00, 1, 6},
3199 {true, PHY_HT, 19500, 0x82, 0x00, 2, 6},
3200 {true, PHY_HT, 26000, 0x83, 0x00, 3, 8},
3201 {true, PHY_HT, 39000, 0x84, 0x00, 4, 8},
3202 {true, PHY_HT, 52000, 0x85, 0x00, 5, 8},
3203 {true, PHY_HT, 58500, 0x86, 0x00, 6, 8},
3204 {true, PHY_HT, 65000, 0x87, 0x00, 7, 8},
3205 {true, PHY_HT, 13000, 0x88, 0x00, 8, 4},
3206 {true, PHY_HT, 26000, 0x89, 0x00, 9, 6},
3207 {true, PHY_HT, 39000, 0x8a, 0x00, 10, 6},
3208 {true, PHY_HT, 52000, 0x8b, 0x00, 11, 8},
3209 {true, PHY_HT, 78000, 0x8c, 0x00, 12, 8},
3210 {true, PHY_HT, 104000, 0x8d, 0x00, 13, 8},
3211 {true, PHY_HT, 117000, 0x8e, 0x00, 14, 8},
3212 {true, PHY_HT, 130000, 0x8f, 0x00, 15, 8},
3213 },
3214};
7199 3215
7200 return true; 3216static struct ath9k_rate_table ar5416_11na_table = {
7201} 3217 24,
3218 {0},
3219 {
3220 {true, PHY_OFDM, 6000, 0x0b, 0x00, (0x80 | 12), 0},
3221 {true, PHY_OFDM, 9000, 0x0f, 0x00, 18, 0},
3222 {true, PHY_OFDM, 12000, 0x0a, 0x00, (0x80 | 24), 2},
3223 {true, PHY_OFDM, 18000, 0x0e, 0x00, 36, 2},
3224 {true, PHY_OFDM, 24000, 0x09, 0x00, (0x80 | 48), 4},
3225 {true, PHY_OFDM, 36000, 0x0d, 0x00, 72, 4},
3226 {true, PHY_OFDM, 48000, 0x08, 0x00, 96, 4},
3227 {true, PHY_OFDM, 54000, 0x0c, 0x00, 108, 4},
3228 {true, PHY_HT, 6500, 0x80, 0x00, 0, 0},
3229 {true, PHY_HT, 13000, 0x81, 0x00, 1, 2},
3230 {true, PHY_HT, 19500, 0x82, 0x00, 2, 2},
3231 {true, PHY_HT, 26000, 0x83, 0x00, 3, 4},
3232 {true, PHY_HT, 39000, 0x84, 0x00, 4, 4},
3233 {true, PHY_HT, 52000, 0x85, 0x00, 5, 4},
3234 {true, PHY_HT, 58500, 0x86, 0x00, 6, 4},
3235 {true, PHY_HT, 65000, 0x87, 0x00, 7, 4},
3236 {true, PHY_HT, 13000, 0x88, 0x00, 8, 0},
3237 {true, PHY_HT, 26000, 0x89, 0x00, 9, 2},
3238 {true, PHY_HT, 39000, 0x8a, 0x00, 10, 2},
3239 {true, PHY_HT, 52000, 0x8b, 0x00, 11, 4},
3240 {true, PHY_HT, 78000, 0x8c, 0x00, 12, 4},
3241 {true, PHY_HT, 104000, 0x8d, 0x00, 13, 4},
3242 {true, PHY_HT, 117000, 0x8e, 0x00, 14, 4},
3243 {true, PHY_HT, 130000, 0x8f, 0x00, 15, 4},
3244 },
3245};
7202 3246
7203bool 3247static void ath9k_hw_setup_rate_table(struct ath_hal *ah,
7204ath9k_hw_keysetmac(struct ath_hal *ah, u16 entry, 3248 struct ath9k_rate_table *rt)
7205 const u8 *mac)
7206{ 3249{
7207 u32 macHi, macLo; 3250 int i;
7208 3251
7209 if (entry >= ah->ah_caps.keycache_size) { 3252 if (rt->rateCodeToIndex[0] != 0)
7210 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE, 3253 return;
7211 "%s: entry %u out of range\n", __func__, entry);
7212 return false;
7213 }
7214 3254
7215 if (mac != NULL) { 3255 for (i = 0; i < 256; i++)
7216 macHi = (mac[5] << 8) | mac[4]; 3256 rt->rateCodeToIndex[i] = (u8) -1;
7217 macLo = (mac[3] << 24) | (mac[2] << 16)
7218 | (mac[1] << 8) | mac[0];
7219 macLo >>= 1;
7220 macLo |= (macHi & 1) << 31;
7221 macHi >>= 1;
7222 } else {
7223 macLo = macHi = 0;
7224 }
7225 REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), macLo);
7226 REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), macHi | AR_KEYTABLE_VALID);
7227 3257
7228 return true; 3258 for (i = 0; i < rt->rateCount; i++) {
3259 u8 code = rt->info[i].rateCode;
3260 u8 cix = rt->info[i].controlRate;
3261
3262 rt->rateCodeToIndex[code] = i;
3263 rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i;
3264
3265 rt->info[i].lpAckDuration =
3266 ath9k_hw_computetxtime(ah, rt,
3267 WLAN_CTRL_FRAME_SIZE,
3268 cix,
3269 false);
3270 rt->info[i].spAckDuration =
3271 ath9k_hw_computetxtime(ah, rt,
3272 WLAN_CTRL_FRAME_SIZE,
3273 cix,
3274 true);
3275 }
7229} 3276}
7230 3277
7231bool 3278const struct ath9k_rate_table *ath9k_hw_getratetable(struct ath_hal *ah,
7232ath9k_hw_set_keycache_entry(struct ath_hal *ah, u16 entry, 3279 u32 mode)
7233 const struct ath9k_keyval *k,
7234 const u8 *mac, int xorKey)
7235{ 3280{
7236 const struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 3281 struct ath9k_rate_table *rt;
7237 u32 key0, key1, key2, key3, key4;
7238 u32 keyType;
7239 u32 xorMask = xorKey ?
7240 (ATH9K_KEY_XOR << 24 | ATH9K_KEY_XOR << 16 | ATH9K_KEY_XOR << 8
7241 | ATH9K_KEY_XOR) : 0;
7242 struct ath_hal_5416 *ahp = AH5416(ah);
7243 3282
7244 if (entry >= pCap->keycache_size) { 3283 switch (mode) {
7245 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE, 3284 case ATH9K_MODE_11A:
7246 "%s: entry %u out of range\n", __func__, entry); 3285 rt = &ar5416_11a_table;
7247 return false;
7248 }
7249 switch (k->kv_type) {
7250 case ATH9K_CIPHER_AES_OCB:
7251 keyType = AR_KEYTABLE_TYPE_AES;
7252 break; 3286 break;
7253 case ATH9K_CIPHER_AES_CCM: 3287 case ATH9K_MODE_11B:
7254 if (!(pCap->hw_caps & ATH9K_HW_CAP_CIPHER_AESCCM)) { 3288 rt = &ar5416_11b_table;
7255 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
7256 "%s: AES-CCM not supported by "
7257 "mac rev 0x%x\n", __func__,
7258 ah->ah_macRev);
7259 return false;
7260 }
7261 keyType = AR_KEYTABLE_TYPE_CCM;
7262 break; 3289 break;
7263 case ATH9K_CIPHER_TKIP: 3290 case ATH9K_MODE_11G:
7264 keyType = AR_KEYTABLE_TYPE_TKIP; 3291 rt = &ar5416_11g_table;
7265 if (ATH9K_IS_MIC_ENABLED(ah)
7266 && entry + 64 >= pCap->keycache_size) {
7267 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
7268 "%s: entry %u inappropriate for TKIP\n",
7269 __func__, entry);
7270 return false;
7271 }
7272 break; 3292 break;
7273 case ATH9K_CIPHER_WEP: 3293 case ATH9K_MODE_11NG_HT20:
7274 if (k->kv_len < LEN_WEP40) { 3294 case ATH9K_MODE_11NG_HT40PLUS:
7275 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE, 3295 case ATH9K_MODE_11NG_HT40MINUS:
7276 "%s: WEP key length %u too small\n", 3296 rt = &ar5416_11ng_table;
7277 __func__, k->kv_len);
7278 return false;
7279 }
7280 if (k->kv_len <= LEN_WEP40)
7281 keyType = AR_KEYTABLE_TYPE_40;
7282 else if (k->kv_len <= LEN_WEP104)
7283 keyType = AR_KEYTABLE_TYPE_104;
7284 else
7285 keyType = AR_KEYTABLE_TYPE_128;
7286 break; 3297 break;
7287 case ATH9K_CIPHER_CLR: 3298 case ATH9K_MODE_11NA_HT20:
7288 keyType = AR_KEYTABLE_TYPE_CLR; 3299 case ATH9K_MODE_11NA_HT40PLUS:
3300 case ATH9K_MODE_11NA_HT40MINUS:
3301 rt = &ar5416_11na_table;
7289 break; 3302 break;
7290 default: 3303 default:
7291 DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE, 3304 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, "%s: invalid mode 0x%x\n",
7292 "%s: cipher %u not supported\n", __func__, 3305 __func__, mode);
7293 k->kv_type); 3306 return NULL;
7294 return false;
7295 } 3307 }
7296 3308
7297 key0 = get_unaligned_le32(k->kv_val + 0) ^ xorMask; 3309 ath9k_hw_setup_rate_table(ah, rt);
7298 key1 = (get_unaligned_le16(k->kv_val + 4) ^ xorMask) & 0xffff;
7299 key2 = get_unaligned_le32(k->kv_val + 6) ^ xorMask;
7300 key3 = (get_unaligned_le16(k->kv_val + 10) ^ xorMask) & 0xffff;
7301 key4 = get_unaligned_le32(k->kv_val + 12) ^ xorMask;
7302 if (k->kv_len <= LEN_WEP104)
7303 key4 &= 0xff;
7304 3310
7305 if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) { 3311 return rt;
7306 u16 micentry = entry + 64; 3312}
7307 3313
7308 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), ~key0); 3314/*******************/
7309 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), ~key1); 3315/* HW Capabilities */
7310 REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2); 3316/*******************/
7311 REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
7312 REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
7313 REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
7314 (void) ath9k_hw_keysetmac(ah, entry, mac);
7315 3317
7316 if (ahp->ah_miscMode & AR_PCU_MIC_NEW_LOC_ENA) { 3318bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
7317 u32 mic0, mic1, mic2, mic3, mic4; 3319{
3320 struct ath_hal_5416 *ahp = AH5416(ah);
3321 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
3322 u16 capField = 0, eeval;
7318 3323
7319 mic0 = get_unaligned_le32(k->kv_mic + 0); 3324 eeval = ath9k_hw_get_eeprom(ah, EEP_REG_0);
7320 mic2 = get_unaligned_le32(k->kv_mic + 4);
7321 mic1 = get_unaligned_le16(k->kv_txmic + 2) & 0xffff;
7322 mic3 = get_unaligned_le16(k->kv_txmic + 0) & 0xffff;
7323 mic4 = get_unaligned_le32(k->kv_txmic + 4);
7324 REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
7325 REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), mic1);
7326 REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
7327 REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), mic3);
7328 REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), mic4);
7329 REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
7330 AR_KEYTABLE_TYPE_CLR);
7331 3325
7332 } else { 3326 ah->ah_currentRD = eeval;
7333 u32 mic0, mic2;
7334 3327
7335 mic0 = get_unaligned_le32(k->kv_mic + 0); 3328 eeval = ath9k_hw_get_eeprom(ah, EEP_REG_1);
7336 mic2 = get_unaligned_le32(k->kv_mic + 4); 3329 ah->ah_currentRDExt = eeval;
7337 REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
7338 REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
7339 REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
7340 REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
7341 REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);
7342 REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
7343 AR_KEYTABLE_TYPE_CLR);
7344 }
7345 REG_WRITE(ah, AR_KEYTABLE_MAC0(micentry), 0);
7346 REG_WRITE(ah, AR_KEYTABLE_MAC1(micentry), 0);
7347 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
7348 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
7349 } else {
7350 REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
7351 REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
7352 REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);
7353 REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
7354 REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
7355 REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
7356 3330
7357 (void) ath9k_hw_keysetmac(ah, entry, mac); 3331 capField = ath9k_hw_get_eeprom(ah, EEP_OP_CAP);
7358 }
7359 3332
7360 if (ah->ah_curchan == NULL) 3333 if (ah->ah_opmode != ATH9K_M_HOSTAP &&
7361 return true; 3334 ah->ah_subvendorid == AR_SUBVENDOR_ID_NEW_A) {
3335 if (ah->ah_currentRD == 0x64 || ah->ah_currentRD == 0x65)
3336 ah->ah_currentRD += 5;
3337 else if (ah->ah_currentRD == 0x41)
3338 ah->ah_currentRD = 0x43;
3339 DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
3340 "%s: regdomain mapped to 0x%x\n", __func__,
3341 ah->ah_currentRD);
3342 }
7362 3343
7363 return true; 3344 eeval = ath9k_hw_get_eeprom(ah, EEP_OP_MODE);
7364} 3345 bitmap_zero(pCap->wireless_modes, ATH9K_MODE_MAX);
7365 3346
7366bool 3347 if (eeval & AR5416_OPFLAGS_11A) {
7367ath9k_hw_updatetxtriglevel(struct ath_hal *ah, bool bIncTrigLevel) 3348 set_bit(ATH9K_MODE_11A, pCap->wireless_modes);
7368{ 3349 if (ah->ah_config.ht_enable) {
7369 struct ath_hal_5416 *ahp = AH5416(ah); 3350 if (!(eeval & AR5416_OPFLAGS_N_5G_HT20))
7370 u32 txcfg, curLevel, newLevel; 3351 set_bit(ATH9K_MODE_11NA_HT20,
7371 enum ath9k_int omask; 3352 pCap->wireless_modes);
3353 if (!(eeval & AR5416_OPFLAGS_N_5G_HT40)) {
3354 set_bit(ATH9K_MODE_11NA_HT40PLUS,
3355 pCap->wireless_modes);
3356 set_bit(ATH9K_MODE_11NA_HT40MINUS,
3357 pCap->wireless_modes);
3358 }
3359 }
3360 }
7372 3361
7373 if (ah->ah_txTrigLevel >= MAX_TX_FIFO_THRESHOLD) 3362 if (eeval & AR5416_OPFLAGS_11G) {
7374 return false; 3363 set_bit(ATH9K_MODE_11B, pCap->wireless_modes);
3364 set_bit(ATH9K_MODE_11G, pCap->wireless_modes);
3365 if (ah->ah_config.ht_enable) {
3366 if (!(eeval & AR5416_OPFLAGS_N_2G_HT20))
3367 set_bit(ATH9K_MODE_11NG_HT20,
3368 pCap->wireless_modes);
3369 if (!(eeval & AR5416_OPFLAGS_N_2G_HT40)) {
3370 set_bit(ATH9K_MODE_11NG_HT40PLUS,
3371 pCap->wireless_modes);
3372 set_bit(ATH9K_MODE_11NG_HT40MINUS,
3373 pCap->wireless_modes);
3374 }
3375 }
3376 }
7375 3377
7376 omask = ath9k_hw_set_interrupts(ah, 3378 pCap->tx_chainmask = ath9k_hw_get_eeprom(ah, EEP_TX_MASK);
7377 ahp->ah_maskReg & ~ATH9K_INT_GLOBAL); 3379 if ((ah->ah_isPciExpress)
3380 || (eeval & AR5416_OPFLAGS_11A)) {
3381 pCap->rx_chainmask =
3382 ath9k_hw_get_eeprom(ah, EEP_RX_MASK);
3383 } else {
3384 pCap->rx_chainmask =
3385 (ath9k_hw_gpio_get(ah, 0)) ? 0x5 : 0x7;
3386 }
7378 3387
7379 txcfg = REG_READ(ah, AR_TXCFG); 3388 if (!(AR_SREV_9280(ah) && (ah->ah_macRev == 0)))
7380 curLevel = MS(txcfg, AR_FTRIG); 3389 ahp->ah_miscMode |= AR_PCU_MIC_NEW_LOC_ENA;
7381 newLevel = curLevel;
7382 if (bIncTrigLevel) {
7383 if (curLevel < MAX_TX_FIFO_THRESHOLD)
7384 newLevel++;
7385 } else if (curLevel > MIN_TX_FIFO_THRESHOLD)
7386 newLevel--;
7387 if (newLevel != curLevel)
7388 REG_WRITE(ah, AR_TXCFG,
7389 (txcfg & ~AR_FTRIG) | SM(newLevel, AR_FTRIG));
7390 3390
7391 ath9k_hw_set_interrupts(ah, omask); 3391 pCap->low_2ghz_chan = 2312;
3392 pCap->high_2ghz_chan = 2732;
7392 3393
7393 ah->ah_txTrigLevel = newLevel; 3394 pCap->low_5ghz_chan = 4920;
3395 pCap->high_5ghz_chan = 6100;
7394 3396
7395 return newLevel != curLevel; 3397 pCap->hw_caps &= ~ATH9K_HW_CAP_CIPHER_CKIP;
7396} 3398 pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_TKIP;
3399 pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_AESCCM;
7397 3400
7398bool ath9k_hw_set_txq_props(struct ath_hal *ah, int q, 3401 pCap->hw_caps &= ~ATH9K_HW_CAP_MIC_CKIP;
7399 const struct ath9k_tx_queue_info *qinfo) 3402 pCap->hw_caps |= ATH9K_HW_CAP_MIC_TKIP;
7400{ 3403 pCap->hw_caps |= ATH9K_HW_CAP_MIC_AESCCM;
7401 u32 cw;
7402 struct ath_hal_5416 *ahp = AH5416(ah);
7403 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
7404 struct ath9k_tx_queue_info *qi;
7405 3404
7406 if (q >= pCap->total_queues) { 3405 pCap->hw_caps |= ATH9K_HW_CAP_CHAN_SPREAD;
7407 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n",
7408 __func__, q);
7409 return false;
7410 }
7411 3406
7412 qi = &ahp->ah_txq[q]; 3407 if (ah->ah_config.ht_enable)
7413 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { 3408 pCap->hw_caps |= ATH9K_HW_CAP_HT;
7414 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue\n", 3409 else
7415 __func__); 3410 pCap->hw_caps &= ~ATH9K_HW_CAP_HT;
7416 return false;
7417 }
7418 3411
7419 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: queue %p\n", __func__, qi); 3412 pCap->hw_caps |= ATH9K_HW_CAP_GTT;
3413 pCap->hw_caps |= ATH9K_HW_CAP_VEOL;
3414 pCap->hw_caps |= ATH9K_HW_CAP_BSSIDMASK;
3415 pCap->hw_caps &= ~ATH9K_HW_CAP_MCAST_KEYSEARCH;
7420 3416
7421 qi->tqi_ver = qinfo->tqi_ver; 3417 if (capField & AR_EEPROM_EEPCAP_MAXQCU)
7422 qi->tqi_subtype = qinfo->tqi_subtype; 3418 pCap->total_queues =
7423 qi->tqi_qflags = qinfo->tqi_qflags; 3419 MS(capField, AR_EEPROM_EEPCAP_MAXQCU);
7424 qi->tqi_priority = qinfo->tqi_priority;
7425 if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT)
7426 qi->tqi_aifs = min(qinfo->tqi_aifs, 255U);
7427 else
7428 qi->tqi_aifs = INIT_AIFS;
7429 if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) {
7430 cw = min(qinfo->tqi_cwmin, 1024U);
7431 qi->tqi_cwmin = 1;
7432 while (qi->tqi_cwmin < cw)
7433 qi->tqi_cwmin = (qi->tqi_cwmin << 1) | 1;
7434 } else
7435 qi->tqi_cwmin = qinfo->tqi_cwmin;
7436 if (qinfo->tqi_cwmax != ATH9K_TXQ_USEDEFAULT) {
7437 cw = min(qinfo->tqi_cwmax, 1024U);
7438 qi->tqi_cwmax = 1;
7439 while (qi->tqi_cwmax < cw)
7440 qi->tqi_cwmax = (qi->tqi_cwmax << 1) | 1;
7441 } else
7442 qi->tqi_cwmax = INIT_CWMAX;
7443
7444 if (qinfo->tqi_shretry != 0)
7445 qi->tqi_shretry = min((u32) qinfo->tqi_shretry, 15U);
7446 else 3420 else
7447 qi->tqi_shretry = INIT_SH_RETRY; 3421 pCap->total_queues = ATH9K_NUM_TX_QUEUES;
7448 if (qinfo->tqi_lgretry != 0) 3422
7449 qi->tqi_lgretry = min((u32) qinfo->tqi_lgretry, 15U); 3423 if (capField & AR_EEPROM_EEPCAP_KC_ENTRIES)
3424 pCap->keycache_size =
3425 1 << MS(capField, AR_EEPROM_EEPCAP_KC_ENTRIES);
7450 else 3426 else
7451 qi->tqi_lgretry = INIT_LG_RETRY; 3427 pCap->keycache_size = AR_KEYTABLE_SIZE;
7452 qi->tqi_cbrPeriod = qinfo->tqi_cbrPeriod;
7453 qi->tqi_cbrOverflowLimit = qinfo->tqi_cbrOverflowLimit;
7454 qi->tqi_burstTime = qinfo->tqi_burstTime;
7455 qi->tqi_readyTime = qinfo->tqi_readyTime;
7456
7457 switch (qinfo->tqi_subtype) {
7458 case ATH9K_WME_UPSD:
7459 if (qi->tqi_type == ATH9K_TX_QUEUE_DATA)
7460 qi->tqi_intFlags = ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS;
7461 break;
7462 default:
7463 break;
7464 }
7465 return true;
7466}
7467 3428
7468bool ath9k_hw_get_txq_props(struct ath_hal *ah, int q, 3429 pCap->hw_caps |= ATH9K_HW_CAP_FASTCC;
7469 struct ath9k_tx_queue_info *qinfo) 3430 pCap->num_mr_retries = 4;
7470{ 3431 pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD;
7471 struct ath_hal_5416 *ahp = AH5416(ah);
7472 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
7473 struct ath9k_tx_queue_info *qi;
7474 3432
7475 if (q >= pCap->total_queues) { 3433 if (AR_SREV_9280_10_OR_LATER(ah))
7476 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n", 3434 pCap->num_gpio_pins = AR928X_NUM_GPIO;
7477 __func__, q); 3435 else
7478 return false; 3436 pCap->num_gpio_pins = AR_NUM_GPIO;
7479 }
7480 3437
7481 qi = &ahp->ah_txq[q]; 3438 if (AR_SREV_9280_10_OR_LATER(ah)) {
7482 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { 3439 pCap->hw_caps |= ATH9K_HW_CAP_WOW;
7483 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue\n", 3440 pCap->hw_caps |= ATH9K_HW_CAP_WOW_MATCHPATTERN_EXACT;
7484 __func__); 3441 } else {
7485 return false; 3442 pCap->hw_caps &= ~ATH9K_HW_CAP_WOW;
3443 pCap->hw_caps &= ~ATH9K_HW_CAP_WOW_MATCHPATTERN_EXACT;
7486 } 3444 }
7487 3445
7488 qinfo->tqi_qflags = qi->tqi_qflags; 3446 if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) {
7489 qinfo->tqi_ver = qi->tqi_ver; 3447 pCap->hw_caps |= ATH9K_HW_CAP_CST;
7490 qinfo->tqi_subtype = qi->tqi_subtype; 3448 pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX;
7491 qinfo->tqi_qflags = qi->tqi_qflags; 3449 } else {
7492 qinfo->tqi_priority = qi->tqi_priority; 3450 pCap->rts_aggr_limit = (8 * 1024);
7493 qinfo->tqi_aifs = qi->tqi_aifs; 3451 }
7494 qinfo->tqi_cwmin = qi->tqi_cwmin;
7495 qinfo->tqi_cwmax = qi->tqi_cwmax;
7496 qinfo->tqi_shretry = qi->tqi_shretry;
7497 qinfo->tqi_lgretry = qi->tqi_lgretry;
7498 qinfo->tqi_cbrPeriod = qi->tqi_cbrPeriod;
7499 qinfo->tqi_cbrOverflowLimit = qi->tqi_cbrOverflowLimit;
7500 qinfo->tqi_burstTime = qi->tqi_burstTime;
7501 qinfo->tqi_readyTime = qi->tqi_readyTime;
7502 3452
7503 return true; 3453 pCap->hw_caps |= ATH9K_HW_CAP_ENHANCEDPM;
7504}
7505 3454
7506int 3455#ifdef CONFIG_RFKILL
7507ath9k_hw_setuptxqueue(struct ath_hal *ah, enum ath9k_tx_queue type, 3456 ah->ah_rfsilent = ath9k_hw_get_eeprom(ah, EEP_RF_SILENT);
7508 const struct ath9k_tx_queue_info *qinfo) 3457 if (ah->ah_rfsilent & EEP_RFSILENT_ENABLED) {
7509{ 3458 ah->ah_rfkill_gpio =
7510 struct ath_hal_5416 *ahp = AH5416(ah); 3459 MS(ah->ah_rfsilent, EEP_RFSILENT_GPIO_SEL);
7511 struct ath9k_tx_queue_info *qi; 3460 ah->ah_rfkill_polarity =
7512 struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 3461 MS(ah->ah_rfsilent, EEP_RFSILENT_POLARITY);
7513 int q;
7514 3462
7515 switch (type) { 3463 pCap->hw_caps |= ATH9K_HW_CAP_RFSILENT;
7516 case ATH9K_TX_QUEUE_BEACON:
7517 q = pCap->total_queues - 1;
7518 break;
7519 case ATH9K_TX_QUEUE_CAB:
7520 q = pCap->total_queues - 2;
7521 break;
7522 case ATH9K_TX_QUEUE_PSPOLL:
7523 q = 1;
7524 break;
7525 case ATH9K_TX_QUEUE_UAPSD:
7526 q = pCap->total_queues - 3;
7527 break;
7528 case ATH9K_TX_QUEUE_DATA:
7529 for (q = 0; q < pCap->total_queues; q++)
7530 if (ahp->ah_txq[q].tqi_type ==
7531 ATH9K_TX_QUEUE_INACTIVE)
7532 break;
7533 if (q == pCap->total_queues) {
7534 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
7535 "%s: no available tx queue\n", __func__);
7536 return -1;
7537 }
7538 break;
7539 default:
7540 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: bad tx queue type %u\n",
7541 __func__, type);
7542 return -1;
7543 } 3464 }
3465#endif
7544 3466
7545 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: queue %u\n", __func__, q); 3467 if ((ah->ah_macVersion == AR_SREV_VERSION_5416_PCI) ||
3468 (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE) ||
3469 (ah->ah_macVersion == AR_SREV_VERSION_9160) ||
3470 (ah->ah_macVersion == AR_SREV_VERSION_9100) ||
3471 (ah->ah_macVersion == AR_SREV_VERSION_9280))
3472 pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
3473 else
3474 pCap->hw_caps |= ATH9K_HW_CAP_AUTOSLEEP;
7546 3475
7547 qi = &ahp->ah_txq[q]; 3476 if (AR_SREV_9280(ah))
7548 if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) { 3477 pCap->hw_caps &= ~ATH9K_HW_CAP_4KB_SPLITTRANS;
7549 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, 3478 else
7550 "%s: tx queue %u already active\n", __func__, q); 3479 pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS;
7551 return -1; 3480
7552 } 3481 if (ah->ah_currentRDExt & (1 << REG_EXT_JAPAN_MIDBAND)) {
7553 memset(qi, 0, sizeof(struct ath9k_tx_queue_info)); 3482 pCap->reg_cap =
7554 qi->tqi_type = type; 3483 AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
7555 if (qinfo == NULL) { 3484 AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN |
7556 qi->tqi_qflags = 3485 AR_EEPROM_EEREGCAP_EN_KK_U2 |
7557 TXQ_FLAG_TXOKINT_ENABLE 3486 AR_EEPROM_EEREGCAP_EN_KK_MIDBAND;
7558 | TXQ_FLAG_TXERRINT_ENABLE
7559 | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE;
7560 qi->tqi_aifs = INIT_AIFS;
7561 qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
7562 qi->tqi_cwmax = INIT_CWMAX;
7563 qi->tqi_shretry = INIT_SH_RETRY;
7564 qi->tqi_lgretry = INIT_LG_RETRY;
7565 qi->tqi_physCompBuf = 0;
7566 } else { 3487 } else {
7567 qi->tqi_physCompBuf = qinfo->tqi_physCompBuf; 3488 pCap->reg_cap =
7568 (void) ath9k_hw_set_txq_props(ah, q, qinfo); 3489 AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
3490 AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN;
7569 } 3491 }
7570 3492
7571 return q; 3493 pCap->reg_cap |= AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND;
7572}
7573 3494
7574static void 3495 pCap->num_antcfg_5ghz =
7575ath9k_hw_set_txq_interrupts(struct ath_hal *ah, 3496 ath9k_hw_get_num_ant_config(ah, IEEE80211_BAND_5GHZ);
7576 struct ath9k_tx_queue_info *qi) 3497 pCap->num_antcfg_2ghz =
7577{ 3498 ath9k_hw_get_num_ant_config(ah, IEEE80211_BAND_2GHZ);
7578 struct ath_hal_5416 *ahp = AH5416(ah);
7579 3499
7580 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT, 3500 return true;
7581 "%s: tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n",
7582 __func__, ahp->ah_txOkInterruptMask,
7583 ahp->ah_txErrInterruptMask, ahp->ah_txDescInterruptMask,
7584 ahp->ah_txEolInterruptMask, ahp->ah_txUrnInterruptMask);
7585
7586 REG_WRITE(ah, AR_IMR_S0,
7587 SM(ahp->ah_txOkInterruptMask, AR_IMR_S0_QCU_TXOK)
7588 | SM(ahp->ah_txDescInterruptMask, AR_IMR_S0_QCU_TXDESC));
7589 REG_WRITE(ah, AR_IMR_S1,
7590 SM(ahp->ah_txErrInterruptMask, AR_IMR_S1_QCU_TXERR)
7591 | SM(ahp->ah_txEolInterruptMask, AR_IMR_S1_QCU_TXEOL));
7592 REG_RMW_FIELD(ah, AR_IMR_S2,
7593 AR_IMR_S2_QCU_TXURN, ahp->ah_txUrnInterruptMask);
7594} 3501}
7595 3502
7596bool ath9k_hw_releasetxqueue(struct ath_hal *ah, u32 q) 3503bool ath9k_hw_getcapability(struct ath_hal *ah, enum ath9k_capability_type type,
3504 u32 capability, u32 *result)
7597{ 3505{
7598 struct ath_hal_5416 *ahp = AH5416(ah); 3506 struct ath_hal_5416 *ahp = AH5416(ah);
7599 struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 3507 const struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
7600 struct ath9k_tx_queue_info *qi;
7601 3508
7602 if (q >= pCap->total_queues) { 3509 switch (type) {
7603 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n", 3510 case ATH9K_CAP_CIPHER:
7604 __func__, q); 3511 switch (capability) {
3512 case ATH9K_CIPHER_AES_CCM:
3513 case ATH9K_CIPHER_AES_OCB:
3514 case ATH9K_CIPHER_TKIP:
3515 case ATH9K_CIPHER_WEP:
3516 case ATH9K_CIPHER_MIC:
3517 case ATH9K_CIPHER_CLR:
3518 return true;
3519 default:
3520 return false;
3521 }
3522 case ATH9K_CAP_TKIP_MIC:
3523 switch (capability) {
3524 case 0:
3525 return true;
3526 case 1:
3527 return (ahp->ah_staId1Defaults &
3528 AR_STA_ID1_CRPT_MIC_ENABLE) ? true :
3529 false;
3530 }
3531 case ATH9K_CAP_TKIP_SPLIT:
3532 return (ahp->ah_miscMode & AR_PCU_MIC_NEW_LOC_ENA) ?
3533 false : true;
3534 case ATH9K_CAP_WME_TKIPMIC:
3535 return 0;
3536 case ATH9K_CAP_PHYCOUNTERS:
3537 return ahp->ah_hasHwPhyCounters ? 0 : -ENXIO;
3538 case ATH9K_CAP_DIVERSITY:
3539 return (REG_READ(ah, AR_PHY_CCK_DETECT) &
3540 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV) ?
3541 true : false;
3542 case ATH9K_CAP_PHYDIAG:
3543 return true;
3544 case ATH9K_CAP_MCAST_KEYSRCH:
3545 switch (capability) {
3546 case 0:
3547 return true;
3548 case 1:
3549 if (REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_ADHOC) {
3550 return false;
3551 } else {
3552 return (ahp->ah_staId1Defaults &
3553 AR_STA_ID1_MCAST_KSRCH) ? true :
3554 false;
3555 }
3556 }
7605 return false; 3557 return false;
7606 } 3558 case ATH9K_CAP_TSF_ADJUST:
7607 qi = &ahp->ah_txq[q]; 3559 return (ahp->ah_miscMode & AR_PCU_TX_ADD_TSF) ?
7608 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { 3560 true : false;
7609 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue %u\n", 3561 case ATH9K_CAP_RFSILENT:
7610 __func__, q); 3562 if (capability == 3)
3563 return false;
3564 case ATH9K_CAP_ANT_CFG_2GHZ:
3565 *result = pCap->num_antcfg_2ghz;
3566 return true;
3567 case ATH9K_CAP_ANT_CFG_5GHZ:
3568 *result = pCap->num_antcfg_5ghz;
3569 return true;
3570 case ATH9K_CAP_TXPOW:
3571 switch (capability) {
3572 case 0:
3573 return 0;
3574 case 1:
3575 *result = ah->ah_powerLimit;
3576 return 0;
3577 case 2:
3578 *result = ah->ah_maxPowerLevel;
3579 return 0;
3580 case 3:
3581 *result = ah->ah_tpScale;
3582 return 0;
3583 }
3584 return false;
3585 default:
7611 return false; 3586 return false;
7612 } 3587 }
7613
7614 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: release queue %u\n",
7615 __func__, q);
7616
7617 qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE;
7618 ahp->ah_txOkInterruptMask &= ~(1 << q);
7619 ahp->ah_txErrInterruptMask &= ~(1 << q);
7620 ahp->ah_txDescInterruptMask &= ~(1 << q);
7621 ahp->ah_txEolInterruptMask &= ~(1 << q);
7622 ahp->ah_txUrnInterruptMask &= ~(1 << q);
7623 ath9k_hw_set_txq_interrupts(ah, qi);
7624
7625 return true;
7626} 3588}
7627 3589
7628bool ath9k_hw_resettxqueue(struct ath_hal *ah, u32 q) 3590bool ath9k_hw_setcapability(struct ath_hal *ah, enum ath9k_capability_type type,
3591 u32 capability, u32 setting, int *status)
7629{ 3592{
7630 struct ath_hal_5416 *ahp = AH5416(ah); 3593 struct ath_hal_5416 *ahp = AH5416(ah);
7631 struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 3594 u32 v;
7632 struct ath9k_channel *chan = ah->ah_curchan;
7633 struct ath9k_tx_queue_info *qi;
7634 u32 cwMin, chanCwMin, value;
7635 3595
7636 if (q >= pCap->total_queues) { 3596 switch (type) {
7637 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n", 3597 case ATH9K_CAP_TKIP_MIC:
7638 __func__, q); 3598 if (setting)
7639 return false; 3599 ahp->ah_staId1Defaults |=
7640 } 3600 AR_STA_ID1_CRPT_MIC_ENABLE;
7641 qi = &ahp->ah_txq[q]; 3601 else
7642 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { 3602 ahp->ah_staId1Defaults &=
7643 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue %u\n", 3603 ~AR_STA_ID1_CRPT_MIC_ENABLE;
7644 __func__, q);
7645 return true; 3604 return true;
7646 } 3605 case ATH9K_CAP_DIVERSITY:
7647 3606 v = REG_READ(ah, AR_PHY_CCK_DETECT);
7648 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: reset queue %u\n", __func__, q); 3607 if (setting)
7649 3608 v |= AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
7650 if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
7651 if (chan && IS_CHAN_B(chan))
7652 chanCwMin = INIT_CWMIN_11B;
7653 else 3609 else
7654 chanCwMin = INIT_CWMIN; 3610 v &= ~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
7655 3611 REG_WRITE(ah, AR_PHY_CCK_DETECT, v);
7656 for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1); 3612 return true;
7657 } else 3613 case ATH9K_CAP_MCAST_KEYSRCH:
7658 cwMin = qi->tqi_cwmin; 3614 if (setting)
7659 3615 ahp->ah_staId1Defaults |= AR_STA_ID1_MCAST_KSRCH;
7660 REG_WRITE(ah, AR_DLCL_IFS(q), SM(cwMin, AR_D_LCL_IFS_CWMIN) 3616 else
7661 | SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX) 3617 ahp->ah_staId1Defaults &= ~AR_STA_ID1_MCAST_KSRCH;
7662 | SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS)); 3618 return true;
7663 3619 case ATH9K_CAP_TSF_ADJUST:
7664 REG_WRITE(ah, AR_DRETRY_LIMIT(q), 3620 if (setting)
7665 SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH) 3621 ahp->ah_miscMode |= AR_PCU_TX_ADD_TSF;
7666 | SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG) 3622 else
7667 | SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH)); 3623 ahp->ah_miscMode &= ~AR_PCU_TX_ADD_TSF;
7668 3624 return true;
7669 REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
7670 REG_WRITE(ah, AR_DMISC(q),
7671 AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2);
7672
7673 if (qi->tqi_cbrPeriod) {
7674 REG_WRITE(ah, AR_QCBRCFG(q),
7675 SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL)
7676 | SM(qi->tqi_cbrOverflowLimit,
7677 AR_Q_CBRCFG_OVF_THRESH));
7678 REG_WRITE(ah, AR_QMISC(q),
7679 REG_READ(ah,
7680 AR_QMISC(q)) | AR_Q_MISC_FSP_CBR | (qi->
7681 tqi_cbrOverflowLimit
7682 ?
7683 AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN
7684 :
7685 0));
7686 }
7687 if (qi->tqi_readyTime && (qi->tqi_type != ATH9K_TX_QUEUE_CAB)) {
7688 REG_WRITE(ah, AR_QRDYTIMECFG(q),
7689 SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) |
7690 AR_Q_RDYTIMECFG_EN);
7691 }
7692
7693 REG_WRITE(ah, AR_DCHNTIME(q),
7694 SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
7695 (qi->tqi_burstTime ? AR_D_CHNTIME_EN : 0));
7696
7697 if (qi->tqi_burstTime
7698 && (qi->tqi_qflags & TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)) {
7699 REG_WRITE(ah, AR_QMISC(q),
7700 REG_READ(ah,
7701 AR_QMISC(q)) |
7702 AR_Q_MISC_RDYTIME_EXP_POLICY);
7703
7704 }
7705
7706 if (qi->tqi_qflags & TXQ_FLAG_BACKOFF_DISABLE) {
7707 REG_WRITE(ah, AR_DMISC(q),
7708 REG_READ(ah, AR_DMISC(q)) |
7709 AR_D_MISC_POST_FR_BKOFF_DIS);
7710 }
7711 if (qi->tqi_qflags & TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE) {
7712 REG_WRITE(ah, AR_DMISC(q),
7713 REG_READ(ah, AR_DMISC(q)) |
7714 AR_D_MISC_FRAG_BKOFF_EN);
7715 }
7716 switch (qi->tqi_type) {
7717 case ATH9K_TX_QUEUE_BEACON:
7718 REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
7719 | AR_Q_MISC_FSP_DBA_GATED
7720 | AR_Q_MISC_BEACON_USE
7721 | AR_Q_MISC_CBR_INCR_DIS1);
7722
7723 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
7724 | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
7725 AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
7726 | AR_D_MISC_BEACON_USE
7727 | AR_D_MISC_POST_FR_BKOFF_DIS);
7728 break;
7729 case ATH9K_TX_QUEUE_CAB:
7730 REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
7731 | AR_Q_MISC_FSP_DBA_GATED
7732 | AR_Q_MISC_CBR_INCR_DIS1
7733 | AR_Q_MISC_CBR_INCR_DIS0);
7734 value = (qi->tqi_readyTime
7735 - (ah->ah_config.sw_beacon_response_time -
7736 ah->ah_config.dma_beacon_response_time)
7737 -
7738 ah->ah_config.additional_swba_backoff) *
7739 1024;
7740 REG_WRITE(ah, AR_QRDYTIMECFG(q),
7741 value | AR_Q_RDYTIMECFG_EN);
7742 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
7743 | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
7744 AR_D_MISC_ARB_LOCKOUT_CNTRL_S));
7745 break;
7746 case ATH9K_TX_QUEUE_PSPOLL:
7747 REG_WRITE(ah, AR_QMISC(q),
7748 REG_READ(ah,
7749 AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1);
7750 break;
7751 case ATH9K_TX_QUEUE_UAPSD:
7752 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
7753 | AR_D_MISC_POST_FR_BKOFF_DIS);
7754 break;
7755 default: 3625 default:
7756 break; 3626 return false;
7757 }
7758
7759 if (qi->tqi_intFlags & ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS) {
7760 REG_WRITE(ah, AR_DMISC(q),
7761 REG_READ(ah, AR_DMISC(q)) |
7762 SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
7763 AR_D_MISC_ARB_LOCKOUT_CNTRL) |
7764 AR_D_MISC_POST_FR_BKOFF_DIS);
7765 } 3627 }
7766
7767 if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE)
7768 ahp->ah_txOkInterruptMask |= 1 << q;
7769 else
7770 ahp->ah_txOkInterruptMask &= ~(1 << q);
7771 if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE)
7772 ahp->ah_txErrInterruptMask |= 1 << q;
7773 else
7774 ahp->ah_txErrInterruptMask &= ~(1 << q);
7775 if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE)
7776 ahp->ah_txDescInterruptMask |= 1 << q;
7777 else
7778 ahp->ah_txDescInterruptMask &= ~(1 << q);
7779 if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE)
7780 ahp->ah_txEolInterruptMask |= 1 << q;
7781 else
7782 ahp->ah_txEolInterruptMask &= ~(1 << q);
7783 if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE)
7784 ahp->ah_txUrnInterruptMask |= 1 << q;
7785 else
7786 ahp->ah_txUrnInterruptMask &= ~(1 << q);
7787 ath9k_hw_set_txq_interrupts(ah, qi);
7788
7789 return true;
7790} 3628}
7791 3629
7792void ath9k_hw_gettxintrtxqs(struct ath_hal *ah, u32 *txqs) 3630/****************************/
7793{ 3631/* GPIO / RFKILL / Antennae */
7794 struct ath_hal_5416 *ahp = AH5416(ah); 3632/****************************/
7795 *txqs &= ahp->ah_intrTxqs;
7796 ahp->ah_intrTxqs &= ~(*txqs);
7797}
7798 3633
7799bool 3634static void ath9k_hw_gpio_cfg_output_mux(struct ath_hal *ah,
7800ath9k_hw_filltxdesc(struct ath_hal *ah, struct ath_desc *ds, 3635 u32 gpio, u32 type)
7801 u32 segLen, bool firstSeg,
7802 bool lastSeg, const struct ath_desc *ds0)
7803{
7804 struct ar5416_desc *ads = AR5416DESC(ds);
7805
7806 if (firstSeg) {
7807 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_TxMore);
7808 } else if (lastSeg) {
7809 ads->ds_ctl0 = 0;
7810 ads->ds_ctl1 = segLen;
7811 ads->ds_ctl2 = AR5416DESC_CONST(ds0)->ds_ctl2;
7812 ads->ds_ctl3 = AR5416DESC_CONST(ds0)->ds_ctl3;
7813 } else {
7814 ads->ds_ctl0 = 0;
7815 ads->ds_ctl1 = segLen | AR_TxMore;
7816 ads->ds_ctl2 = 0;
7817 ads->ds_ctl3 = 0;
7818 }
7819 ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
7820 ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
7821 ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
7822 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
7823 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
7824 return true;
7825}
7826
7827void ath9k_hw_cleartxdesc(struct ath_hal *ah, struct ath_desc *ds)
7828{ 3636{
7829 struct ar5416_desc *ads = AR5416DESC(ds); 3637 int addr;
3638 u32 gpio_shift, tmp;
7830 3639
7831 ads->ds_txstatus0 = ads->ds_txstatus1 = 0; 3640 if (gpio > 11)
7832 ads->ds_txstatus2 = ads->ds_txstatus3 = 0; 3641 addr = AR_GPIO_OUTPUT_MUX3;
7833 ads->ds_txstatus4 = ads->ds_txstatus5 = 0; 3642 else if (gpio > 5)
7834 ads->ds_txstatus6 = ads->ds_txstatus7 = 0; 3643 addr = AR_GPIO_OUTPUT_MUX2;
7835 ads->ds_txstatus8 = ads->ds_txstatus9 = 0; 3644 else
7836} 3645 addr = AR_GPIO_OUTPUT_MUX1;
7837 3646
7838int 3647 gpio_shift = (gpio % 6) * 5;
7839ath9k_hw_txprocdesc(struct ath_hal *ah, struct ath_desc *ds)
7840{
7841 struct ar5416_desc *ads = AR5416DESC(ds);
7842
7843 if ((ads->ds_txstatus9 & AR_TxDone) == 0)
7844 return -EINPROGRESS;
7845
7846 ds->ds_txstat.ts_seqnum = MS(ads->ds_txstatus9, AR_SeqNum);
7847 ds->ds_txstat.ts_tstamp = ads->AR_SendTimestamp;
7848 ds->ds_txstat.ts_status = 0;
7849 ds->ds_txstat.ts_flags = 0;
7850
7851 if (ads->ds_txstatus1 & AR_ExcessiveRetries)
7852 ds->ds_txstat.ts_status |= ATH9K_TXERR_XRETRY;
7853 if (ads->ds_txstatus1 & AR_Filtered)
7854 ds->ds_txstat.ts_status |= ATH9K_TXERR_FILT;
7855 if (ads->ds_txstatus1 & AR_FIFOUnderrun)
7856 ds->ds_txstat.ts_status |= ATH9K_TXERR_FIFO;
7857 if (ads->ds_txstatus9 & AR_TxOpExceeded)
7858 ds->ds_txstat.ts_status |= ATH9K_TXERR_XTXOP;
7859 if (ads->ds_txstatus1 & AR_TxTimerExpired)
7860 ds->ds_txstat.ts_status |= ATH9K_TXERR_TIMER_EXPIRED;
7861
7862 if (ads->ds_txstatus1 & AR_DescCfgErr)
7863 ds->ds_txstat.ts_flags |= ATH9K_TX_DESC_CFG_ERR;
7864 if (ads->ds_txstatus1 & AR_TxDataUnderrun) {
7865 ds->ds_txstat.ts_flags |= ATH9K_TX_DATA_UNDERRUN;
7866 ath9k_hw_updatetxtriglevel(ah, true);
7867 }
7868 if (ads->ds_txstatus1 & AR_TxDelimUnderrun) {
7869 ds->ds_txstat.ts_flags |= ATH9K_TX_DELIM_UNDERRUN;
7870 ath9k_hw_updatetxtriglevel(ah, true);
7871 }
7872 if (ads->ds_txstatus0 & AR_TxBaStatus) {
7873 ds->ds_txstat.ts_flags |= ATH9K_TX_BA;
7874 ds->ds_txstat.ba_low = ads->AR_BaBitmapLow;
7875 ds->ds_txstat.ba_high = ads->AR_BaBitmapHigh;
7876 }
7877 3648
7878 ds->ds_txstat.ts_rateindex = MS(ads->ds_txstatus9, AR_FinalTxIdx); 3649 if (AR_SREV_9280_20_OR_LATER(ah)
7879 switch (ds->ds_txstat.ts_rateindex) { 3650 || (addr != AR_GPIO_OUTPUT_MUX1)) {
7880 case 0: 3651 REG_RMW(ah, addr, (type << gpio_shift),
7881 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate0); 3652 (0x1f << gpio_shift));
7882 break; 3653 } else {
7883 case 1: 3654 tmp = REG_READ(ah, addr);
7884 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate1); 3655 tmp = ((tmp & 0x1F0) << 1) | (tmp & ~0x1F0);
7885 break; 3656 tmp &= ~(0x1f << gpio_shift);
7886 case 2: 3657 tmp |= (type << gpio_shift);
7887 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate2); 3658 REG_WRITE(ah, addr, tmp);
7888 break;
7889 case 3:
7890 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate3);
7891 break;
7892 } 3659 }
7893
7894 ds->ds_txstat.ts_rssi = MS(ads->ds_txstatus5, AR_TxRSSICombined);
7895 ds->ds_txstat.ts_rssi_ctl0 = MS(ads->ds_txstatus0, AR_TxRSSIAnt00);
7896 ds->ds_txstat.ts_rssi_ctl1 = MS(ads->ds_txstatus0, AR_TxRSSIAnt01);
7897 ds->ds_txstat.ts_rssi_ctl2 = MS(ads->ds_txstatus0, AR_TxRSSIAnt02);
7898 ds->ds_txstat.ts_rssi_ext0 = MS(ads->ds_txstatus5, AR_TxRSSIAnt10);
7899 ds->ds_txstat.ts_rssi_ext1 = MS(ads->ds_txstatus5, AR_TxRSSIAnt11);
7900 ds->ds_txstat.ts_rssi_ext2 = MS(ads->ds_txstatus5, AR_TxRSSIAnt12);
7901 ds->ds_txstat.evm0 = ads->AR_TxEVM0;
7902 ds->ds_txstat.evm1 = ads->AR_TxEVM1;
7903 ds->ds_txstat.evm2 = ads->AR_TxEVM2;
7904 ds->ds_txstat.ts_shortretry = MS(ads->ds_txstatus1, AR_RTSFailCnt);
7905 ds->ds_txstat.ts_longretry = MS(ads->ds_txstatus1, AR_DataFailCnt);
7906 ds->ds_txstat.ts_virtcol = MS(ads->ds_txstatus1, AR_VirtRetryCnt);
7907 ds->ds_txstat.ts_antenna = 1;
7908
7909 return 0;
7910} 3660}
7911 3661
7912void 3662void ath9k_hw_cfg_gpio_input(struct ath_hal *ah, u32 gpio)
7913ath9k_hw_set11n_txdesc(struct ath_hal *ah, struct ath_desc *ds,
7914 u32 pktLen, enum ath9k_pkt_type type, u32 txPower,
7915 u32 keyIx, enum ath9k_key_type keyType, u32 flags)
7916{ 3663{
7917 struct ar5416_desc *ads = AR5416DESC(ds); 3664 u32 gpio_shift;
7918 struct ath_hal_5416 *ahp = AH5416(ah);
7919
7920 txPower += ahp->ah_txPowerIndexOffset;
7921 if (txPower > 63)
7922 txPower = 63;
7923
7924 ads->ds_ctl0 = (pktLen & AR_FrameLen)
7925 | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
7926 | SM(txPower, AR_XmitPower)
7927 | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
7928 | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
7929 | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
7930 | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
7931
7932 ads->ds_ctl1 =
7933 (keyIx != ATH9K_TXKEYIX_INVALID ? SM(keyIx, AR_DestIdx) : 0)
7934 | SM(type, AR_FrameType)
7935 | (flags & ATH9K_TXDESC_NOACK ? AR_NoAck : 0)
7936 | (flags & ATH9K_TXDESC_EXT_ONLY ? AR_ExtOnly : 0)
7937 | (flags & ATH9K_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0);
7938 3665
7939 ads->ds_ctl6 = SM(keyType, AR_EncrType); 3666 ASSERT(gpio < ah->ah_caps.num_gpio_pins);
7940 3667
7941 if (AR_SREV_9285(ah)) { 3668 gpio_shift = gpio << 1;
7942 3669
7943 ads->ds_ctl8 = 0; 3670 REG_RMW(ah,
7944 ads->ds_ctl9 = 0; 3671 AR_GPIO_OE_OUT,
7945 ads->ds_ctl10 = 0; 3672 (AR_GPIO_OE_OUT_DRV_NO << gpio_shift),
7946 ads->ds_ctl11 = 0; 3673 (AR_GPIO_OE_OUT_DRV << gpio_shift));
7947 }
7948} 3674}
7949 3675
7950void 3676u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio)
7951ath9k_hw_set11n_ratescenario(struct ath_hal *ah, struct ath_desc *ds,
7952 struct ath_desc *lastds,
7953 u32 durUpdateEn, u32 rtsctsRate,
7954 u32 rtsctsDuration,
7955 struct ath9k_11n_rate_series series[],
7956 u32 nseries, u32 flags)
7957{ 3677{
7958 struct ar5416_desc *ads = AR5416DESC(ds); 3678 if (gpio >= ah->ah_caps.num_gpio_pins)
7959 struct ar5416_desc *last_ads = AR5416DESC(lastds); 3679 return 0xffffffff;
7960 u32 ds_ctl0;
7961
7962 (void) nseries;
7963 (void) rtsctsDuration;
7964
7965 if (flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)) {
7966 ds_ctl0 = ads->ds_ctl0;
7967
7968 if (flags & ATH9K_TXDESC_RTSENA) {
7969 ds_ctl0 &= ~AR_CTSEnable;
7970 ds_ctl0 |= AR_RTSEnable;
7971 } else {
7972 ds_ctl0 &= ~AR_RTSEnable;
7973 ds_ctl0 |= AR_CTSEnable;
7974 }
7975 3680
7976 ads->ds_ctl0 = ds_ctl0; 3681 if (AR_SREV_9280_10_OR_LATER(ah)) {
3682 return (MS
3683 (REG_READ(ah, AR_GPIO_IN_OUT),
3684 AR928X_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) != 0;
7977 } else { 3685 } else {
7978 ads->ds_ctl0 = 3686 return (MS(REG_READ(ah, AR_GPIO_IN_OUT), AR_GPIO_IN_VAL) &
7979 (ads->ds_ctl0 & ~(AR_RTSEnable | AR_CTSEnable)); 3687 AR_GPIO_BIT(gpio)) != 0;
7980 } 3688 }
7981
7982 ads->ds_ctl2 = set11nTries(series, 0)
7983 | set11nTries(series, 1)
7984 | set11nTries(series, 2)
7985 | set11nTries(series, 3)
7986 | (durUpdateEn ? AR_DurUpdateEna : 0)
7987 | SM(0, AR_BurstDur);
7988
7989 ads->ds_ctl3 = set11nRate(series, 0)
7990 | set11nRate(series, 1)
7991 | set11nRate(series, 2)
7992 | set11nRate(series, 3);
7993
7994 ads->ds_ctl4 = set11nPktDurRTSCTS(series, 0)
7995 | set11nPktDurRTSCTS(series, 1);
7996
7997 ads->ds_ctl5 = set11nPktDurRTSCTS(series, 2)
7998 | set11nPktDurRTSCTS(series, 3);
7999
8000 ads->ds_ctl7 = set11nRateFlags(series, 0)
8001 | set11nRateFlags(series, 1)
8002 | set11nRateFlags(series, 2)
8003 | set11nRateFlags(series, 3)
8004 | SM(rtsctsRate, AR_RTSCTSRate);
8005 last_ads->ds_ctl2 = ads->ds_ctl2;
8006 last_ads->ds_ctl3 = ads->ds_ctl3;
8007} 3689}
8008 3690
8009void 3691void ath9k_hw_cfg_output(struct ath_hal *ah, u32 gpio,
8010ath9k_hw_set11n_aggr_first(struct ath_hal *ah, struct ath_desc *ds, 3692 u32 ah_signal_type)
8011 u32 aggrLen)
8012{ 3693{
8013 struct ar5416_desc *ads = AR5416DESC(ds); 3694 u32 gpio_shift;
8014
8015 ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
8016
8017 ads->ds_ctl6 &= ~AR_AggrLen;
8018 ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen);
8019}
8020 3695
8021void 3696 ath9k_hw_gpio_cfg_output_mux(ah, gpio, ah_signal_type);
8022ath9k_hw_set11n_aggr_middle(struct ath_hal *ah, struct ath_desc *ds,
8023 u32 numDelims)
8024{
8025 struct ar5416_desc *ads = AR5416DESC(ds);
8026 unsigned int ctl6;
8027 3697
8028 ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr); 3698 gpio_shift = 2 * gpio;
8029 3699
8030 ctl6 = ads->ds_ctl6; 3700 REG_RMW(ah,
8031 ctl6 &= ~AR_PadDelim; 3701 AR_GPIO_OE_OUT,
8032 ctl6 |= SM(numDelims, AR_PadDelim); 3702 (AR_GPIO_OE_OUT_DRV_ALL << gpio_shift),
8033 ads->ds_ctl6 = ctl6; 3703 (AR_GPIO_OE_OUT_DRV << gpio_shift));
8034} 3704}
8035 3705
8036void ath9k_hw_set11n_aggr_last(struct ath_hal *ah, struct ath_desc *ds) 3706void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 val)
8037{ 3707{
8038 struct ar5416_desc *ads = AR5416DESC(ds); 3708 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio),
8039 3709 AR_GPIO_BIT(gpio));
8040 ads->ds_ctl1 |= AR_IsAggr;
8041 ads->ds_ctl1 &= ~AR_MoreAggr;
8042 ads->ds_ctl6 &= ~AR_PadDelim;
8043} 3710}
8044 3711
8045void ath9k_hw_clr11n_aggr(struct ath_hal *ah, struct ath_desc *ds) 3712#ifdef CONFIG_RFKILL
3713void ath9k_enable_rfkill(struct ath_hal *ah)
8046{ 3714{
8047 struct ar5416_desc *ads = AR5416DESC(ds); 3715 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
3716 AR_GPIO_INPUT_EN_VAL_RFSILENT_BB);
8048 3717
8049 ads->ds_ctl1 &= (~AR_IsAggr & ~AR_MoreAggr); 3718 REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2,
3719 AR_GPIO_INPUT_MUX2_RFSILENT);
3720
3721 ath9k_hw_cfg_gpio_input(ah, ah->ah_rfkill_gpio);
3722 REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB);
8050} 3723}
3724#endif
8051 3725
8052void 3726int ath9k_hw_select_antconfig(struct ath_hal *ah, u32 cfg)
8053ath9k_hw_set11n_burstduration(struct ath_hal *ah, struct ath_desc *ds,
8054 u32 burstDuration)
8055{ 3727{
8056 struct ar5416_desc *ads = AR5416DESC(ds); 3728 struct ath9k_channel *chan = ah->ah_curchan;
3729 const struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
3730 u16 ant_config;
3731 u32 halNumAntConfig;
8057 3732
8058 ads->ds_ctl2 &= ~AR_BurstDur; 3733 halNumAntConfig = IS_CHAN_2GHZ(chan) ?
8059 ads->ds_ctl2 |= SM(burstDuration, AR_BurstDur); 3734 pCap->num_antcfg_2ghz : pCap->num_antcfg_5ghz;
8060}
8061 3735
8062void 3736 if (cfg < halNumAntConfig) {
8063ath9k_hw_set11n_virtualmorefrag(struct ath_hal *ah, struct ath_desc *ds, 3737 if (!ath9k_hw_get_eeprom_antenna_cfg(ah, chan,
8064 u32 vmf) 3738 cfg, &ant_config)) {
8065{ 3739 REG_WRITE(ah, AR_PHY_SWITCH_COM, ant_config);
8066 struct ar5416_desc *ads = AR5416DESC(ds); 3740 return 0;
3741 }
3742 }
8067 3743
8068 if (vmf) 3744 return -EINVAL;
8069 ads->ds_ctl0 |= AR_VirtMoreFrag;
8070 else
8071 ads->ds_ctl0 &= ~AR_VirtMoreFrag;
8072} 3745}
8073 3746
8074void ath9k_hw_putrxbuf(struct ath_hal *ah, u32 rxdp) 3747u32 ath9k_hw_getdefantenna(struct ath_hal *ah)
8075{ 3748{
8076 REG_WRITE(ah, AR_RXDP, rxdp); 3749 return REG_READ(ah, AR_DEF_ANTENNA) & 0x7;
8077} 3750}
8078 3751
8079void ath9k_hw_rxena(struct ath_hal *ah) 3752void ath9k_hw_setantenna(struct ath_hal *ah, u32 antenna)
8080{ 3753{
8081 REG_WRITE(ah, AR_CR, AR_CR_RXE); 3754 REG_WRITE(ah, AR_DEF_ANTENNA, (antenna & 0x7));
8082} 3755}
8083 3756
8084bool ath9k_hw_setrxabort(struct ath_hal *ah, bool set) 3757bool ath9k_hw_setantennaswitch(struct ath_hal *ah,
3758 enum ath9k_ant_setting settings,
3759 struct ath9k_channel *chan,
3760 u8 *tx_chainmask,
3761 u8 *rx_chainmask,
3762 u8 *antenna_cfgd)
8085{ 3763{
8086 if (set) { 3764 struct ath_hal_5416 *ahp = AH5416(ah);
8087 3765 static u8 tx_chainmask_cfg, rx_chainmask_cfg;
8088 REG_SET_BIT(ah, AR_DIAG_SW,
8089 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
8090
8091 if (!ath9k_hw_wait
8092 (ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE, 0)) {
8093 u32 reg;
8094 3766
8095 REG_CLR_BIT(ah, AR_DIAG_SW, 3767 if (AR_SREV_9280(ah)) {
8096 (AR_DIAG_RX_DIS | 3768 if (!tx_chainmask_cfg) {
8097 AR_DIAG_RX_ABORT));
8098 3769
8099 reg = REG_READ(ah, AR_OBS_BUS_1); 3770 tx_chainmask_cfg = *tx_chainmask;
8100 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, 3771 rx_chainmask_cfg = *rx_chainmask;
8101 "%s: rx failed to go idle in 10 ms RXSM=0x%x\n", 3772 }
8102 __func__, reg);
8103 3773
8104 return false; 3774 switch (settings) {
3775 case ATH9K_ANT_FIXED_A:
3776 *tx_chainmask = ATH9K_ANTENNA0_CHAINMASK;
3777 *rx_chainmask = ATH9K_ANTENNA0_CHAINMASK;
3778 *antenna_cfgd = true;
3779 break;
3780 case ATH9K_ANT_FIXED_B:
3781 if (ah->ah_caps.tx_chainmask >
3782 ATH9K_ANTENNA1_CHAINMASK) {
3783 *tx_chainmask = ATH9K_ANTENNA1_CHAINMASK;
3784 }
3785 *rx_chainmask = ATH9K_ANTENNA1_CHAINMASK;
3786 *antenna_cfgd = true;
3787 break;
3788 case ATH9K_ANT_VARIABLE:
3789 *tx_chainmask = tx_chainmask_cfg;
3790 *rx_chainmask = rx_chainmask_cfg;
3791 *antenna_cfgd = true;
3792 break;
3793 default:
3794 break;
8105 } 3795 }
8106 } else { 3796 } else {
8107 REG_CLR_BIT(ah, AR_DIAG_SW, 3797 ahp->ah_diversityControl = settings;
8108 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
8109 } 3798 }
8110 3799
8111 return true; 3800 return true;
8112} 3801}
8113 3802
8114void 3803/*********************/
8115ath9k_hw_setmcastfilter(struct ath_hal *ah, u32 filter0, 3804/* General Operation */
8116 u32 filter1) 3805/*********************/
8117{
8118 REG_WRITE(ah, AR_MCAST_FIL0, filter0);
8119 REG_WRITE(ah, AR_MCAST_FIL1, filter1);
8120}
8121 3806
8122bool 3807u32 ath9k_hw_getrxfilter(struct ath_hal *ah)
8123ath9k_hw_setuprxdesc(struct ath_hal *ah, struct ath_desc *ds,
8124 u32 size, u32 flags)
8125{ 3808{
8126 struct ar5416_desc *ads = AR5416DESC(ds); 3809 u32 bits = REG_READ(ah, AR_RX_FILTER);
8127 struct ath9k_hw_capabilities *pCap = &ah->ah_caps; 3810 u32 phybits = REG_READ(ah, AR_PHY_ERR);
8128 3811
8129 ads->ds_ctl1 = size & AR_BufLen; 3812 if (phybits & AR_PHY_ERR_RADAR)
8130 if (flags & ATH9K_RXDESC_INTREQ) 3813 bits |= ATH9K_RX_FILTER_PHYRADAR;
8131 ads->ds_ctl1 |= AR_RxIntrReq; 3814 if (phybits & (AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING))
3815 bits |= ATH9K_RX_FILTER_PHYERR;
8132 3816
8133 ads->ds_rxstatus8 &= ~AR_RxDone; 3817 return bits;
8134 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
8135 memset(&(ads->u), 0, sizeof(ads->u));
8136 return true;
8137} 3818}
8138 3819
8139int 3820void ath9k_hw_setrxfilter(struct ath_hal *ah, u32 bits)
8140ath9k_hw_rxprocdesc(struct ath_hal *ah, struct ath_desc *ds,
8141 u32 pa, struct ath_desc *nds, u64 tsf)
8142{ 3821{
8143 struct ar5416_desc ads; 3822 u32 phybits;
8144 struct ar5416_desc *adsp = AR5416DESC(ds);
8145
8146 if ((adsp->ds_rxstatus8 & AR_RxDone) == 0)
8147 return -EINPROGRESS;
8148
8149 ads.u.rx = adsp->u.rx;
8150
8151 ds->ds_rxstat.rs_status = 0;
8152 ds->ds_rxstat.rs_flags = 0;
8153 3823
8154 ds->ds_rxstat.rs_datalen = ads.ds_rxstatus1 & AR_DataLen; 3824 REG_WRITE(ah, AR_RX_FILTER, (bits & 0xffff) | AR_RX_COMPR_BAR);
8155 ds->ds_rxstat.rs_tstamp = ads.AR_RcvTimestamp; 3825 phybits = 0;
3826 if (bits & ATH9K_RX_FILTER_PHYRADAR)
3827 phybits |= AR_PHY_ERR_RADAR;
3828 if (bits & ATH9K_RX_FILTER_PHYERR)
3829 phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
3830 REG_WRITE(ah, AR_PHY_ERR, phybits);
8156 3831
8157 ds->ds_rxstat.rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined); 3832 if (phybits)
8158 ds->ds_rxstat.rs_rssi_ctl0 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt00); 3833 REG_WRITE(ah, AR_RXCFG,
8159 ds->ds_rxstat.rs_rssi_ctl1 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt01); 3834 REG_READ(ah, AR_RXCFG) | AR_RXCFG_ZLFDMA);
8160 ds->ds_rxstat.rs_rssi_ctl2 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt02);
8161 ds->ds_rxstat.rs_rssi_ext0 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt10);
8162 ds->ds_rxstat.rs_rssi_ext1 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt11);
8163 ds->ds_rxstat.rs_rssi_ext2 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt12);
8164 if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
8165 ds->ds_rxstat.rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
8166 else 3835 else
8167 ds->ds_rxstat.rs_keyix = ATH9K_RXKEYIX_INVALID; 3836 REG_WRITE(ah, AR_RXCFG,
8168 3837 REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_ZLFDMA);
8169 ds->ds_rxstat.rs_rate = RXSTATUS_RATE(ah, (&ads));
8170 ds->ds_rxstat.rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
8171
8172 ds->ds_rxstat.rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
8173 ds->ds_rxstat.rs_moreaggr =
8174 (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
8175 ds->ds_rxstat.rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
8176 ds->ds_rxstat.rs_flags =
8177 (ads.ds_rxstatus3 & AR_GI) ? ATH9K_RX_GI : 0;
8178 ds->ds_rxstat.rs_flags |=
8179 (ads.ds_rxstatus3 & AR_2040) ? ATH9K_RX_2040 : 0;
8180
8181 if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
8182 ds->ds_rxstat.rs_flags |= ATH9K_RX_DELIM_CRC_PRE;
8183 if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
8184 ds->ds_rxstat.rs_flags |= ATH9K_RX_DELIM_CRC_POST;
8185 if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
8186 ds->ds_rxstat.rs_flags |= ATH9K_RX_DECRYPT_BUSY;
8187
8188 if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
8189
8190 if (ads.ds_rxstatus8 & AR_CRCErr)
8191 ds->ds_rxstat.rs_status |= ATH9K_RXERR_CRC;
8192 else if (ads.ds_rxstatus8 & AR_PHYErr) {
8193 u32 phyerr;
8194
8195 ds->ds_rxstat.rs_status |= ATH9K_RXERR_PHY;
8196 phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
8197 ds->ds_rxstat.rs_phyerr = phyerr;
8198 } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
8199 ds->ds_rxstat.rs_status |= ATH9K_RXERR_DECRYPT;
8200 else if (ads.ds_rxstatus8 & AR_MichaelErr)
8201 ds->ds_rxstat.rs_status |= ATH9K_RXERR_MIC;
8202 }
8203
8204 return 0;
8205} 3838}
8206 3839
8207static void ath9k_hw_setup_rate_table(struct ath_hal *ah, 3840bool ath9k_hw_phy_disable(struct ath_hal *ah)
8208 struct ath9k_rate_table *rt)
8209{ 3841{
8210 int i; 3842 return ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM);
8211
8212 if (rt->rateCodeToIndex[0] != 0)
8213 return;
8214 for (i = 0; i < 256; i++)
8215 rt->rateCodeToIndex[i] = (u8) -1;
8216 for (i = 0; i < rt->rateCount; i++) {
8217 u8 code = rt->info[i].rateCode;
8218 u8 cix = rt->info[i].controlRate;
8219
8220 rt->rateCodeToIndex[code] = i;
8221 rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i;
8222
8223 rt->info[i].lpAckDuration =
8224 ath9k_hw_computetxtime(ah, rt,
8225 WLAN_CTRL_FRAME_SIZE,
8226 cix,
8227 false);
8228 rt->info[i].spAckDuration =
8229 ath9k_hw_computetxtime(ah, rt,
8230 WLAN_CTRL_FRAME_SIZE,
8231 cix,
8232 true);
8233 }
8234} 3843}
8235 3844
8236const struct ath9k_rate_table *ath9k_hw_getratetable(struct ath_hal *ah, 3845bool ath9k_hw_disable(struct ath_hal *ah)
8237 u32 mode)
8238{ 3846{
8239 struct ath9k_rate_table *rt; 3847 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
8240 switch (mode) { 3848 return false;
8241 case ATH9K_MODE_11A:
8242 rt = &ar5416_11a_table;
8243 break;
8244 case ATH9K_MODE_11B:
8245 rt = &ar5416_11b_table;
8246 break;
8247 case ATH9K_MODE_11G:
8248 rt = &ar5416_11g_table;
8249 break;
8250 case ATH9K_MODE_11NG_HT20:
8251 case ATH9K_MODE_11NG_HT40PLUS:
8252 case ATH9K_MODE_11NG_HT40MINUS:
8253 rt = &ar5416_11ng_table;
8254 break;
8255 case ATH9K_MODE_11NA_HT20:
8256 case ATH9K_MODE_11NA_HT40PLUS:
8257 case ATH9K_MODE_11NA_HT40MINUS:
8258 rt = &ar5416_11na_table;
8259 break;
8260 default:
8261 DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, "%s: invalid mode 0x%x\n",
8262 __func__, mode);
8263 return NULL;
8264 }
8265 ath9k_hw_setup_rate_table(ah, rt);
8266 return rt;
8267}
8268 3849
8269static const char *ath9k_hw_devname(u16 devid) 3850 return ath9k_hw_set_reset_reg(ah, ATH9K_RESET_COLD);
8270{
8271 switch (devid) {
8272 case AR5416_DEVID_PCI:
8273 case AR5416_DEVID_PCIE:
8274 return "Atheros 5416";
8275 case AR9160_DEVID_PCI:
8276 return "Atheros 9160";
8277 case AR9280_DEVID_PCI:
8278 case AR9280_DEVID_PCIE:
8279 return "Atheros 9280";
8280 }
8281 return NULL;
8282} 3851}
8283 3852
8284const char *ath9k_hw_probe(u16 vendorid, u16 devid) 3853bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit)
8285{ 3854{
8286 return vendorid == ATHEROS_VENDOR_ID ? 3855 struct ath9k_channel *chan = ah->ah_curchan;
8287 ath9k_hw_devname(devid) : NULL;
8288}
8289 3856
8290struct ath_hal *ath9k_hw_attach(u16 devid, 3857 ah->ah_powerLimit = min(limit, (u32) MAX_RATE_POWER);
8291 struct ath_softc *sc,
8292 void __iomem *mem,
8293 int *error)
8294{
8295 struct ath_hal *ah = NULL;
8296 3858
8297 switch (devid) { 3859 if (ath9k_hw_set_txpower(ah, chan,
8298 case AR5416_DEVID_PCI: 3860 ath9k_regd_get_ctl(ah, chan),
8299 case AR5416_DEVID_PCIE: 3861 ath9k_regd_get_antenna_allowed(ah, chan),
8300 case AR9160_DEVID_PCI: 3862 chan->maxRegTxPower * 2,
8301 case AR9280_DEVID_PCI: 3863 min((u32) MAX_RATE_POWER,
8302 case AR9280_DEVID_PCIE: 3864 (u32) ah->ah_powerLimit)) != 0)
8303 ah = ath9k_hw_do_attach(devid, sc, mem, error); 3865 return false;
8304 break;
8305 default:
8306 DPRINTF(ah->ah_sc, ATH_DBG_ANY,
8307 "devid=0x%x not supported.\n", devid);
8308 ah = NULL;
8309 *error = -ENXIO;
8310 break;
8311 }
8312 3866
8313 return ah; 3867 return true;
8314} 3868}
8315 3869
8316u16 3870void ath9k_hw_getmac(struct ath_hal *ah, u8 *mac)
8317ath9k_hw_computetxtime(struct ath_hal *ah,
8318 const struct ath9k_rate_table *rates,
8319 u32 frameLen, u16 rateix,
8320 bool shortPreamble)
8321{ 3871{
8322 u32 bitsPerSymbol, numBits, numSymbols, phyTime, txTime; 3872 struct ath_hal_5416 *ahp = AH5416(ah);
8323 u32 kbps;
8324
8325 kbps = rates->info[rateix].rateKbps;
8326
8327 if (kbps == 0)
8328 return 0;
8329 switch (rates->info[rateix].phy) {
8330
8331 case PHY_CCK:
8332 phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
8333 if (shortPreamble && rates->info[rateix].shortPreamble)
8334 phyTime >>= 1;
8335 numBits = frameLen << 3;
8336 txTime = CCK_SIFS_TIME + phyTime
8337 + ((numBits * 1000) / kbps);
8338 break;
8339 case PHY_OFDM:
8340 if (ah->ah_curchan && IS_CHAN_QUARTER_RATE(ah->ah_curchan)) {
8341 bitsPerSymbol =
8342 (kbps * OFDM_SYMBOL_TIME_QUARTER) / 1000;
8343
8344 numBits = OFDM_PLCP_BITS + (frameLen << 3);
8345 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
8346 txTime = OFDM_SIFS_TIME_QUARTER
8347 + OFDM_PREAMBLE_TIME_QUARTER
8348 + (numSymbols * OFDM_SYMBOL_TIME_QUARTER);
8349 } else if (ah->ah_curchan &&
8350 IS_CHAN_HALF_RATE(ah->ah_curchan)) {
8351 bitsPerSymbol =
8352 (kbps * OFDM_SYMBOL_TIME_HALF) / 1000;
8353
8354 numBits = OFDM_PLCP_BITS + (frameLen << 3);
8355 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
8356 txTime = OFDM_SIFS_TIME_HALF +
8357 OFDM_PREAMBLE_TIME_HALF
8358 + (numSymbols * OFDM_SYMBOL_TIME_HALF);
8359 } else {
8360 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME) / 1000;
8361
8362 numBits = OFDM_PLCP_BITS + (frameLen << 3);
8363 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
8364 txTime = OFDM_SIFS_TIME + OFDM_PREAMBLE_TIME
8365 + (numSymbols * OFDM_SYMBOL_TIME);
8366 }
8367 break;
8368 3873
8369 default: 3874 memcpy(mac, ahp->ah_macaddr, ETH_ALEN);
8370 DPRINTF(ah->ah_sc, ATH_DBG_PHY_IO,
8371 "%s: unknown phy %u (rate ix %u)\n", __func__,
8372 rates->info[rateix].phy, rateix);
8373 txTime = 0;
8374 break;
8375 }
8376 return txTime;
8377} 3875}
8378 3876
8379u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags) 3877bool ath9k_hw_setmac(struct ath_hal *ah, const u8 *mac)
8380{ 3878{
8381 if (flags & CHANNEL_2GHZ) { 3879 struct ath_hal_5416 *ahp = AH5416(ah);
8382 if (freq == 2484)
8383 return 14;
8384 if (freq < 2484)
8385 return (freq - 2407) / 5;
8386 else
8387 return 15 + ((freq - 2512) / 20);
8388 } else if (flags & CHANNEL_5GHZ) {
8389 if (ath9k_regd_is_public_safety_sku(ah) &&
8390 IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) {
8391 return ((freq * 10) +
8392 (((freq % 5) == 2) ? 5 : 0) - 49400) / 5;
8393 } else if ((flags & CHANNEL_A) && (freq <= 5000)) {
8394 return (freq - 4000) / 5;
8395 } else {
8396 return (freq - 5000) / 5;
8397 }
8398 } else {
8399 if (freq == 2484)
8400 return 14;
8401 if (freq < 2484)
8402 return (freq - 2407) / 5;
8403 if (freq < 5000) {
8404 if (ath9k_regd_is_public_safety_sku(ah)
8405 && IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) {
8406 return ((freq * 10) +
8407 (((freq % 5) ==
8408 2) ? 5 : 0) - 49400) / 5;
8409 } else if (freq > 4900) {
8410 return (freq - 4000) / 5;
8411 } else {
8412 return 15 + ((freq - 2512) / 20);
8413 }
8414 }
8415 return (freq - 5000) / 5;
8416 }
8417}
8418 3880
8419/* We can tune this as we go by monitoring really low values */ 3881 memcpy(ahp->ah_macaddr, mac, ETH_ALEN);
8420#define ATH9K_NF_TOO_LOW -60
8421 3882
8422/* AR5416 may return very high value (like -31 dBm), in those cases the nf
8423 * is incorrect and we should use the static NF value. Later we can try to
8424 * find out why they are reporting these values */
8425static bool ath9k_hw_nf_in_range(struct ath_hal *ah, s16 nf)
8426{
8427 if (nf > ATH9K_NF_TOO_LOW) {
8428 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
8429 "%s: noise floor value detected (%d) is "
8430 "lower than what we think is a "
8431 "reasonable value (%d)\n",
8432 __func__, nf, ATH9K_NF_TOO_LOW);
8433 return false;
8434 }
8435 return true; 3883 return true;
8436} 3884}
8437 3885
8438s16 3886void ath9k_hw_setopmode(struct ath_hal *ah)
8439ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan)
8440{ 3887{
8441 struct ath9k_channel *ichan; 3888 ath9k_hw_set_operating_mode(ah, ah->ah_opmode);
8442 s16 nf;
8443
8444 ichan = ath9k_regd_check_channel(ah, chan);
8445 if (ichan == NULL) {
8446 DPRINTF(ah->ah_sc, ATH_DBG_NF_CAL,
8447 "%s: invalid channel %u/0x%x; no mapping\n",
8448 __func__, chan->channel, chan->channelFlags);
8449 return ATH_DEFAULT_NOISE_FLOOR;
8450 }
8451 if (ichan->rawNoiseFloor == 0) {
8452 enum wireless_mode mode = ath9k_hw_chan2wmode(ah, chan);
8453 nf = NOISE_FLOOR[mode];
8454 } else
8455 nf = ichan->rawNoiseFloor;
8456
8457 if (!ath9k_hw_nf_in_range(ah, nf))
8458 nf = ATH_DEFAULT_NOISE_FLOOR;
8459
8460 return nf;
8461} 3889}
8462 3890
8463bool ath9k_hw_set_tsfadjust(struct ath_hal *ah, u32 setting) 3891void ath9k_hw_setmcastfilter(struct ath_hal *ah, u32 filter0, u32 filter1)
8464{ 3892{
8465 struct ath_hal_5416 *ahp = AH5416(ah); 3893 REG_WRITE(ah, AR_MCAST_FIL0, filter0);
8466 3894 REG_WRITE(ah, AR_MCAST_FIL1, filter1);
8467 if (setting)
8468 ahp->ah_miscMode |= AR_PCU_TX_ADD_TSF;
8469 else
8470 ahp->ah_miscMode &= ~AR_PCU_TX_ADD_TSF;
8471 return true;
8472} 3895}
8473 3896
8474bool ath9k_hw_phycounters(struct ath_hal *ah) 3897void ath9k_hw_getbssidmask(struct ath_hal *ah, u8 *mask)
8475{ 3898{
8476 struct ath_hal_5416 *ahp = AH5416(ah); 3899 struct ath_hal_5416 *ahp = AH5416(ah);
8477 3900
8478 return ahp->ah_hasHwPhyCounters ? true : false; 3901 memcpy(mask, ahp->ah_bssidmask, ETH_ALEN);
8479} 3902}
8480 3903
8481u32 ath9k_hw_gettxbuf(struct ath_hal *ah, u32 q) 3904bool ath9k_hw_setbssidmask(struct ath_hal *ah, const u8 *mask)
8482{ 3905{
8483 return REG_READ(ah, AR_QTXDP(q)); 3906 struct ath_hal_5416 *ahp = AH5416(ah);
8484}
8485 3907
8486bool ath9k_hw_puttxbuf(struct ath_hal *ah, u32 q, 3908 memcpy(ahp->ah_bssidmask, mask, ETH_ALEN);
8487 u32 txdp) 3909
8488{ 3910 REG_WRITE(ah, AR_BSSMSKL, get_unaligned_le32(ahp->ah_bssidmask));
8489 REG_WRITE(ah, AR_QTXDP(q), txdp); 3911 REG_WRITE(ah, AR_BSSMSKU, get_unaligned_le16(ahp->ah_bssidmask + 4));
8490 3912
8491 return true; 3913 return true;
8492} 3914}
8493 3915
8494bool ath9k_hw_txstart(struct ath_hal *ah, u32 q) 3916void ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid, u16 assocId)
8495{ 3917{
8496 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: queue %u\n", __func__, q); 3918 struct ath_hal_5416 *ahp = AH5416(ah);
8497 3919
8498 REG_WRITE(ah, AR_Q_TXE, 1 << q); 3920 memcpy(ahp->ah_bssid, bssid, ETH_ALEN);
3921 ahp->ah_assocId = assocId;
8499 3922
8500 return true; 3923 REG_WRITE(ah, AR_BSS_ID0, get_unaligned_le32(ahp->ah_bssid));
3924 REG_WRITE(ah, AR_BSS_ID1, get_unaligned_le16(ahp->ah_bssid + 4) |
3925 ((assocId & 0x3fff) << AR_BSS_ID1_AID_S));
8501} 3926}
8502 3927
8503u32 ath9k_hw_numtxpending(struct ath_hal *ah, u32 q) 3928u64 ath9k_hw_gettsf64(struct ath_hal *ah)
8504{ 3929{
8505 u32 npend; 3930 u64 tsf;
8506 3931
8507 npend = REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT; 3932 tsf = REG_READ(ah, AR_TSF_U32);
8508 if (npend == 0) { 3933 tsf = (tsf << 32) | REG_READ(ah, AR_TSF_L32);
8509 3934
8510 if (REG_READ(ah, AR_Q_TXE) & (1 << q)) 3935 return tsf;
8511 npend = 1;
8512 }
8513 return npend;
8514} 3936}
8515 3937
8516bool ath9k_hw_stoptxdma(struct ath_hal *ah, u32 q) 3938void ath9k_hw_reset_tsf(struct ath_hal *ah)
8517{ 3939{
8518 u32 wait; 3940 int count;
8519
8520 REG_WRITE(ah, AR_Q_TXD, 1 << q);
8521 3941
8522 for (wait = 1000; wait != 0; wait--) { 3942 count = 0;
8523 if (ath9k_hw_numtxpending(ah, q) == 0) 3943 while (REG_READ(ah, AR_SLP32_MODE) & AR_SLP32_TSF_WRITE_STATUS) {
3944 count++;
3945 if (count > 10) {
3946 DPRINTF(ah->ah_sc, ATH_DBG_RESET,
3947 "%s: AR_SLP32_TSF_WRITE_STATUS limit exceeded\n",
3948 __func__);
8524 break; 3949 break;
8525 udelay(100); 3950 }
3951 udelay(10);
8526 } 3952 }
3953 REG_WRITE(ah, AR_RESET_TSF, AR_RESET_TSF_ONCE);
3954}
8527 3955
8528 if (ath9k_hw_numtxpending(ah, q)) { 3956bool ath9k_hw_set_tsfadjust(struct ath_hal *ah, u32 setting)
8529 u32 tsfLow, j; 3957{
8530 3958 struct ath_hal_5416 *ahp = AH5416(ah);
8531 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
8532 "%s: Num of pending TX Frames %d on Q %d\n",
8533 __func__, ath9k_hw_numtxpending(ah, q), q);
8534
8535 for (j = 0; j < 2; j++) {
8536 tsfLow = REG_READ(ah, AR_TSF_L32);
8537 REG_WRITE(ah, AR_QUIET2,
8538 SM(10, AR_QUIET2_QUIET_DUR));
8539 REG_WRITE(ah, AR_QUIET_PERIOD, 100);
8540 REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10);
8541 REG_SET_BIT(ah, AR_TIMER_MODE,
8542 AR_QUIET_TIMER_EN);
8543 3959
8544 if ((REG_READ(ah, AR_TSF_L32) >> 10) == 3960 if (setting)
8545 (tsfLow >> 10)) { 3961 ahp->ah_miscMode |= AR_PCU_TX_ADD_TSF;
8546 break; 3962 else
8547 } 3963 ahp->ah_miscMode &= ~AR_PCU_TX_ADD_TSF;
8548 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
8549 "%s: TSF have moved while trying to set "
8550 "quiet time TSF: 0x%08x\n",
8551 __func__, tsfLow);
8552 }
8553 3964
8554 REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH); 3965 return true;
3966}
8555 3967
8556 udelay(200); 3968bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us)
8557 REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN); 3969{
3970 struct ath_hal_5416 *ahp = AH5416(ah);
8558 3971
8559 wait = 1000; 3972 if (us < ATH9K_SLOT_TIME_9 || us > ath9k_hw_mac_to_usec(ah, 0xffff)) {
3973 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s: bad slot time %u\n",
3974 __func__, us);
3975 ahp->ah_slottime = (u32) -1;
3976 return false;
3977 } else {
3978 REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath9k_hw_mac_to_clks(ah, us));
3979 ahp->ah_slottime = us;
3980 return true;
3981 }
3982}
8560 3983
8561 while (ath9k_hw_numtxpending(ah, q)) { 3984void ath9k_hw_set11nmac2040(struct ath_hal *ah, enum ath9k_ht_macmode mode)
8562 if ((--wait) == 0) { 3985{
8563 DPRINTF(ah->ah_sc, ATH_DBG_XMIT, 3986 u32 macmode;
8564 "%s: Failed to stop Tx DMA in 100 "
8565 "msec after killing last frame\n",
8566 __func__);
8567 break;
8568 }
8569 udelay(100);
8570 }
8571 3987
8572 REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH); 3988 if (mode == ATH9K_HT_MACMODE_2040 &&
8573 } 3989 !ah->ah_config.cwm_ignore_extcca)
3990 macmode = AR_2040_JOINED_RX_CLEAR;
3991 else
3992 macmode = 0;
8574 3993
8575 REG_WRITE(ah, AR_Q_TXD, 0); 3994 REG_WRITE(ah, AR_2040_MODE, macmode);
8576 return wait != 0;
8577} 3995}
diff --git a/drivers/net/wireless/ath9k/hw.h b/drivers/net/wireless/ath9k/hw.h
index 2113818ee934..6a29f2d43c21 100644
--- a/drivers/net/wireless/ath9k/hw.h
+++ b/drivers/net/wireless/ath9k/hw.h
@@ -923,7 +923,7 @@ struct ath_hal_5416 {
923#define OFDM_PLCP_BITS_QUARTER 22 923#define OFDM_PLCP_BITS_QUARTER 22
924#define OFDM_SYMBOL_TIME_QUARTER 16 924#define OFDM_SYMBOL_TIME_QUARTER 16
925 925
926u32 ath9k_hw_get_eeprom(struct ath_hal_5416 *ahp, 926u32 ath9k_hw_get_eeprom(struct ath_hal *ah,
927 enum eeprom_param param); 927 enum eeprom_param param);
928 928
929#endif 929#endif
diff --git a/drivers/net/wireless/ath9k/mac.c b/drivers/net/wireless/ath9k/mac.c
new file mode 100644
index 000000000000..c344a81e738a
--- /dev/null
+++ b/drivers/net/wireless/ath9k/mac.c
@@ -0,0 +1,1031 @@
1/*
2 * Copyright (c) 2008 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "core.h"
18#include "hw.h"
19#include "reg.h"
20#include "phy.h"
21
22static void ath9k_hw_set_txq_interrupts(struct ath_hal *ah,
23 struct ath9k_tx_queue_info *qi)
24{
25 struct ath_hal_5416 *ahp = AH5416(ah);
26
27 DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT,
28 "%s: tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n",
29 __func__, ahp->ah_txOkInterruptMask,
30 ahp->ah_txErrInterruptMask, ahp->ah_txDescInterruptMask,
31 ahp->ah_txEolInterruptMask, ahp->ah_txUrnInterruptMask);
32
33 REG_WRITE(ah, AR_IMR_S0,
34 SM(ahp->ah_txOkInterruptMask, AR_IMR_S0_QCU_TXOK)
35 | SM(ahp->ah_txDescInterruptMask, AR_IMR_S0_QCU_TXDESC));
36 REG_WRITE(ah, AR_IMR_S1,
37 SM(ahp->ah_txErrInterruptMask, AR_IMR_S1_QCU_TXERR)
38 | SM(ahp->ah_txEolInterruptMask, AR_IMR_S1_QCU_TXEOL));
39 REG_RMW_FIELD(ah, AR_IMR_S2,
40 AR_IMR_S2_QCU_TXURN, ahp->ah_txUrnInterruptMask);
41}
42
43void ath9k_hw_dmaRegDump(struct ath_hal *ah)
44{
45 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
46 int qcuOffset = 0, dcuOffset = 0;
47 u32 *qcuBase = &val[0], *dcuBase = &val[4];
48 int i;
49
50 REG_WRITE(ah, AR_MACMISC,
51 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
52 (AR_MACMISC_MISC_OBS_BUS_1 <<
53 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
54
55 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "Raw DMA Debug values:\n");
56
57 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
58 if (i % 4 == 0)
59 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "\n");
60
61 val[i] = REG_READ(ah, AR_DMADBG_0 + (i * sizeof(u32)));
62 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "%d: %08x ", i, val[i]);
63 }
64
65 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "\n\n");
66 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
67 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
68
69 for (i = 0; i < ATH9K_NUM_QUEUES;
70 i++, qcuOffset += 4, dcuOffset += 5) {
71 if (i == 8) {
72 qcuOffset = 0;
73 qcuBase++;
74 }
75
76 if (i == 6) {
77 dcuOffset = 0;
78 dcuBase++;
79 }
80
81 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
82 "%2d %2x %1x %2x %2x\n",
83 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
84 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
85 val[2] & (0x7 << (i * 3)) >> (i * 3),
86 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
87 }
88
89 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "\n");
90 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
91 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
92 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
93 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
94 "qcu_complete state: %2x dcu_complete state: %2x\n",
95 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
96 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
97 "dcu_arb state: %2x dcu_fp state: %2x\n",
98 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
99 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
100 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
101 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
102 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
103 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
104 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
105 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
106 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
107 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
108
109 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, "pcu observe 0x%x \n",
110 REG_READ(ah, AR_OBS_BUS_1));
111 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
112 "AR_CR 0x%x \n", REG_READ(ah, AR_CR));
113}
114
115u32 ath9k_hw_gettxbuf(struct ath_hal *ah, u32 q)
116{
117 return REG_READ(ah, AR_QTXDP(q));
118}
119
120bool ath9k_hw_puttxbuf(struct ath_hal *ah, u32 q, u32 txdp)
121{
122 REG_WRITE(ah, AR_QTXDP(q), txdp);
123
124 return true;
125}
126
127bool ath9k_hw_txstart(struct ath_hal *ah, u32 q)
128{
129 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: queue %u\n", __func__, q);
130
131 REG_WRITE(ah, AR_Q_TXE, 1 << q);
132
133 return true;
134}
135
136u32 ath9k_hw_numtxpending(struct ath_hal *ah, u32 q)
137{
138 u32 npend;
139
140 npend = REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT;
141 if (npend == 0) {
142
143 if (REG_READ(ah, AR_Q_TXE) & (1 << q))
144 npend = 1;
145 }
146
147 return npend;
148}
149
150bool ath9k_hw_updatetxtriglevel(struct ath_hal *ah, bool bIncTrigLevel)
151{
152 struct ath_hal_5416 *ahp = AH5416(ah);
153 u32 txcfg, curLevel, newLevel;
154 enum ath9k_int omask;
155
156 if (ah->ah_txTrigLevel >= MAX_TX_FIFO_THRESHOLD)
157 return false;
158
159 omask = ath9k_hw_set_interrupts(ah, ahp->ah_maskReg & ~ATH9K_INT_GLOBAL);
160
161 txcfg = REG_READ(ah, AR_TXCFG);
162 curLevel = MS(txcfg, AR_FTRIG);
163 newLevel = curLevel;
164 if (bIncTrigLevel) {
165 if (curLevel < MAX_TX_FIFO_THRESHOLD)
166 newLevel++;
167 } else if (curLevel > MIN_TX_FIFO_THRESHOLD)
168 newLevel--;
169 if (newLevel != curLevel)
170 REG_WRITE(ah, AR_TXCFG,
171 (txcfg & ~AR_FTRIG) | SM(newLevel, AR_FTRIG));
172
173 ath9k_hw_set_interrupts(ah, omask);
174
175 ah->ah_txTrigLevel = newLevel;
176
177 return newLevel != curLevel;
178}
179
180bool ath9k_hw_stoptxdma(struct ath_hal *ah, u32 q)
181{
182 u32 tsfLow, j, wait;
183
184 REG_WRITE(ah, AR_Q_TXD, 1 << q);
185
186 for (wait = 1000; wait != 0; wait--) {
187 if (ath9k_hw_numtxpending(ah, q) == 0)
188 break;
189 udelay(100);
190 }
191
192 if (ath9k_hw_numtxpending(ah, q)) {
193 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
194 "%s: Num of pending TX Frames %d on Q %d\n",
195 __func__, ath9k_hw_numtxpending(ah, q), q);
196
197 for (j = 0; j < 2; j++) {
198 tsfLow = REG_READ(ah, AR_TSF_L32);
199 REG_WRITE(ah, AR_QUIET2,
200 SM(10, AR_QUIET2_QUIET_DUR));
201 REG_WRITE(ah, AR_QUIET_PERIOD, 100);
202 REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10);
203 REG_SET_BIT(ah, AR_TIMER_MODE,
204 AR_QUIET_TIMER_EN);
205
206 if ((REG_READ(ah, AR_TSF_L32) >> 10) == (tsfLow >> 10))
207 break;
208
209 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
210 "%s: TSF have moved while trying to set "
211 "quiet time TSF: 0x%08x\n",
212 __func__, tsfLow);
213 }
214
215 REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
216
217 udelay(200);
218 REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN);
219
220 wait = 1000;
221
222 while (ath9k_hw_numtxpending(ah, q)) {
223 if ((--wait) == 0) {
224 DPRINTF(ah->ah_sc, ATH_DBG_XMIT,
225 "%s: Failed to stop Tx DMA in 100 "
226 "msec after killing last frame\n",
227 __func__);
228 break;
229 }
230 udelay(100);
231 }
232
233 REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
234 }
235
236 REG_WRITE(ah, AR_Q_TXD, 0);
237
238 return wait != 0;
239}
240
241bool ath9k_hw_filltxdesc(struct ath_hal *ah, struct ath_desc *ds,
242 u32 segLen, bool firstSeg,
243 bool lastSeg, const struct ath_desc *ds0)
244{
245 struct ar5416_desc *ads = AR5416DESC(ds);
246
247 if (firstSeg) {
248 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_TxMore);
249 } else if (lastSeg) {
250 ads->ds_ctl0 = 0;
251 ads->ds_ctl1 = segLen;
252 ads->ds_ctl2 = AR5416DESC_CONST(ds0)->ds_ctl2;
253 ads->ds_ctl3 = AR5416DESC_CONST(ds0)->ds_ctl3;
254 } else {
255 ads->ds_ctl0 = 0;
256 ads->ds_ctl1 = segLen | AR_TxMore;
257 ads->ds_ctl2 = 0;
258 ads->ds_ctl3 = 0;
259 }
260 ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
261 ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
262 ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
263 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
264 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
265
266 return true;
267}
268
269void ath9k_hw_cleartxdesc(struct ath_hal *ah, struct ath_desc *ds)
270{
271 struct ar5416_desc *ads = AR5416DESC(ds);
272
273 ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
274 ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
275 ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
276 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
277 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
278}
279
280int ath9k_hw_txprocdesc(struct ath_hal *ah, struct ath_desc *ds)
281{
282 struct ar5416_desc *ads = AR5416DESC(ds);
283
284 if ((ads->ds_txstatus9 & AR_TxDone) == 0)
285 return -EINPROGRESS;
286
287 ds->ds_txstat.ts_seqnum = MS(ads->ds_txstatus9, AR_SeqNum);
288 ds->ds_txstat.ts_tstamp = ads->AR_SendTimestamp;
289 ds->ds_txstat.ts_status = 0;
290 ds->ds_txstat.ts_flags = 0;
291
292 if (ads->ds_txstatus1 & AR_ExcessiveRetries)
293 ds->ds_txstat.ts_status |= ATH9K_TXERR_XRETRY;
294 if (ads->ds_txstatus1 & AR_Filtered)
295 ds->ds_txstat.ts_status |= ATH9K_TXERR_FILT;
296 if (ads->ds_txstatus1 & AR_FIFOUnderrun)
297 ds->ds_txstat.ts_status |= ATH9K_TXERR_FIFO;
298 if (ads->ds_txstatus9 & AR_TxOpExceeded)
299 ds->ds_txstat.ts_status |= ATH9K_TXERR_XTXOP;
300 if (ads->ds_txstatus1 & AR_TxTimerExpired)
301 ds->ds_txstat.ts_status |= ATH9K_TXERR_TIMER_EXPIRED;
302
303 if (ads->ds_txstatus1 & AR_DescCfgErr)
304 ds->ds_txstat.ts_flags |= ATH9K_TX_DESC_CFG_ERR;
305 if (ads->ds_txstatus1 & AR_TxDataUnderrun) {
306 ds->ds_txstat.ts_flags |= ATH9K_TX_DATA_UNDERRUN;
307 ath9k_hw_updatetxtriglevel(ah, true);
308 }
309 if (ads->ds_txstatus1 & AR_TxDelimUnderrun) {
310 ds->ds_txstat.ts_flags |= ATH9K_TX_DELIM_UNDERRUN;
311 ath9k_hw_updatetxtriglevel(ah, true);
312 }
313 if (ads->ds_txstatus0 & AR_TxBaStatus) {
314 ds->ds_txstat.ts_flags |= ATH9K_TX_BA;
315 ds->ds_txstat.ba_low = ads->AR_BaBitmapLow;
316 ds->ds_txstat.ba_high = ads->AR_BaBitmapHigh;
317 }
318
319 ds->ds_txstat.ts_rateindex = MS(ads->ds_txstatus9, AR_FinalTxIdx);
320 switch (ds->ds_txstat.ts_rateindex) {
321 case 0:
322 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate0);
323 break;
324 case 1:
325 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate1);
326 break;
327 case 2:
328 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate2);
329 break;
330 case 3:
331 ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate3);
332 break;
333 }
334
335 ds->ds_txstat.ts_rssi = MS(ads->ds_txstatus5, AR_TxRSSICombined);
336 ds->ds_txstat.ts_rssi_ctl0 = MS(ads->ds_txstatus0, AR_TxRSSIAnt00);
337 ds->ds_txstat.ts_rssi_ctl1 = MS(ads->ds_txstatus0, AR_TxRSSIAnt01);
338 ds->ds_txstat.ts_rssi_ctl2 = MS(ads->ds_txstatus0, AR_TxRSSIAnt02);
339 ds->ds_txstat.ts_rssi_ext0 = MS(ads->ds_txstatus5, AR_TxRSSIAnt10);
340 ds->ds_txstat.ts_rssi_ext1 = MS(ads->ds_txstatus5, AR_TxRSSIAnt11);
341 ds->ds_txstat.ts_rssi_ext2 = MS(ads->ds_txstatus5, AR_TxRSSIAnt12);
342 ds->ds_txstat.evm0 = ads->AR_TxEVM0;
343 ds->ds_txstat.evm1 = ads->AR_TxEVM1;
344 ds->ds_txstat.evm2 = ads->AR_TxEVM2;
345 ds->ds_txstat.ts_shortretry = MS(ads->ds_txstatus1, AR_RTSFailCnt);
346 ds->ds_txstat.ts_longretry = MS(ads->ds_txstatus1, AR_DataFailCnt);
347 ds->ds_txstat.ts_virtcol = MS(ads->ds_txstatus1, AR_VirtRetryCnt);
348 ds->ds_txstat.ts_antenna = 1;
349
350 return 0;
351}
352
353void ath9k_hw_set11n_txdesc(struct ath_hal *ah, struct ath_desc *ds,
354 u32 pktLen, enum ath9k_pkt_type type, u32 txPower,
355 u32 keyIx, enum ath9k_key_type keyType, u32 flags)
356{
357 struct ar5416_desc *ads = AR5416DESC(ds);
358 struct ath_hal_5416 *ahp = AH5416(ah);
359
360 txPower += ahp->ah_txPowerIndexOffset;
361 if (txPower > 63)
362 txPower = 63;
363
364 ads->ds_ctl0 = (pktLen & AR_FrameLen)
365 | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
366 | SM(txPower, AR_XmitPower)
367 | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
368 | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
369 | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
370 | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
371
372 ads->ds_ctl1 =
373 (keyIx != ATH9K_TXKEYIX_INVALID ? SM(keyIx, AR_DestIdx) : 0)
374 | SM(type, AR_FrameType)
375 | (flags & ATH9K_TXDESC_NOACK ? AR_NoAck : 0)
376 | (flags & ATH9K_TXDESC_EXT_ONLY ? AR_ExtOnly : 0)
377 | (flags & ATH9K_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0);
378
379 ads->ds_ctl6 = SM(keyType, AR_EncrType);
380
381 if (AR_SREV_9285(ah)) {
382 ads->ds_ctl8 = 0;
383 ads->ds_ctl9 = 0;
384 ads->ds_ctl10 = 0;
385 ads->ds_ctl11 = 0;
386 }
387}
388
389void ath9k_hw_set11n_ratescenario(struct ath_hal *ah, struct ath_desc *ds,
390 struct ath_desc *lastds,
391 u32 durUpdateEn, u32 rtsctsRate,
392 u32 rtsctsDuration,
393 struct ath9k_11n_rate_series series[],
394 u32 nseries, u32 flags)
395{
396 struct ar5416_desc *ads = AR5416DESC(ds);
397 struct ar5416_desc *last_ads = AR5416DESC(lastds);
398 u32 ds_ctl0;
399
400 (void) nseries;
401 (void) rtsctsDuration;
402
403 if (flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)) {
404 ds_ctl0 = ads->ds_ctl0;
405
406 if (flags & ATH9K_TXDESC_RTSENA) {
407 ds_ctl0 &= ~AR_CTSEnable;
408 ds_ctl0 |= AR_RTSEnable;
409 } else {
410 ds_ctl0 &= ~AR_RTSEnable;
411 ds_ctl0 |= AR_CTSEnable;
412 }
413
414 ads->ds_ctl0 = ds_ctl0;
415 } else {
416 ads->ds_ctl0 =
417 (ads->ds_ctl0 & ~(AR_RTSEnable | AR_CTSEnable));
418 }
419
420 ads->ds_ctl2 = set11nTries(series, 0)
421 | set11nTries(series, 1)
422 | set11nTries(series, 2)
423 | set11nTries(series, 3)
424 | (durUpdateEn ? AR_DurUpdateEna : 0)
425 | SM(0, AR_BurstDur);
426
427 ads->ds_ctl3 = set11nRate(series, 0)
428 | set11nRate(series, 1)
429 | set11nRate(series, 2)
430 | set11nRate(series, 3);
431
432 ads->ds_ctl4 = set11nPktDurRTSCTS(series, 0)
433 | set11nPktDurRTSCTS(series, 1);
434
435 ads->ds_ctl5 = set11nPktDurRTSCTS(series, 2)
436 | set11nPktDurRTSCTS(series, 3);
437
438 ads->ds_ctl7 = set11nRateFlags(series, 0)
439 | set11nRateFlags(series, 1)
440 | set11nRateFlags(series, 2)
441 | set11nRateFlags(series, 3)
442 | SM(rtsctsRate, AR_RTSCTSRate);
443 last_ads->ds_ctl2 = ads->ds_ctl2;
444 last_ads->ds_ctl3 = ads->ds_ctl3;
445}
446
447void ath9k_hw_set11n_aggr_first(struct ath_hal *ah, struct ath_desc *ds,
448 u32 aggrLen)
449{
450 struct ar5416_desc *ads = AR5416DESC(ds);
451
452 ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
453 ads->ds_ctl6 &= ~AR_AggrLen;
454 ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen);
455}
456
457void ath9k_hw_set11n_aggr_middle(struct ath_hal *ah, struct ath_desc *ds,
458 u32 numDelims)
459{
460 struct ar5416_desc *ads = AR5416DESC(ds);
461 unsigned int ctl6;
462
463 ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
464
465 ctl6 = ads->ds_ctl6;
466 ctl6 &= ~AR_PadDelim;
467 ctl6 |= SM(numDelims, AR_PadDelim);
468 ads->ds_ctl6 = ctl6;
469}
470
471void ath9k_hw_set11n_aggr_last(struct ath_hal *ah, struct ath_desc *ds)
472{
473 struct ar5416_desc *ads = AR5416DESC(ds);
474
475 ads->ds_ctl1 |= AR_IsAggr;
476 ads->ds_ctl1 &= ~AR_MoreAggr;
477 ads->ds_ctl6 &= ~AR_PadDelim;
478}
479
480void ath9k_hw_clr11n_aggr(struct ath_hal *ah, struct ath_desc *ds)
481{
482 struct ar5416_desc *ads = AR5416DESC(ds);
483
484 ads->ds_ctl1 &= (~AR_IsAggr & ~AR_MoreAggr);
485}
486
487void ath9k_hw_set11n_burstduration(struct ath_hal *ah, struct ath_desc *ds,
488 u32 burstDuration)
489{
490 struct ar5416_desc *ads = AR5416DESC(ds);
491
492 ads->ds_ctl2 &= ~AR_BurstDur;
493 ads->ds_ctl2 |= SM(burstDuration, AR_BurstDur);
494}
495
496void ath9k_hw_set11n_virtualmorefrag(struct ath_hal *ah, struct ath_desc *ds,
497 u32 vmf)
498{
499 struct ar5416_desc *ads = AR5416DESC(ds);
500
501 if (vmf)
502 ads->ds_ctl0 |= AR_VirtMoreFrag;
503 else
504 ads->ds_ctl0 &= ~AR_VirtMoreFrag;
505}
506
507void ath9k_hw_gettxintrtxqs(struct ath_hal *ah, u32 *txqs)
508{
509 struct ath_hal_5416 *ahp = AH5416(ah);
510
511 *txqs &= ahp->ah_intrTxqs;
512 ahp->ah_intrTxqs &= ~(*txqs);
513}
514
515bool ath9k_hw_set_txq_props(struct ath_hal *ah, int q,
516 const struct ath9k_tx_queue_info *qinfo)
517{
518 u32 cw;
519 struct ath_hal_5416 *ahp = AH5416(ah);
520 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
521 struct ath9k_tx_queue_info *qi;
522
523 if (q >= pCap->total_queues) {
524 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n",
525 __func__, q);
526 return false;
527 }
528
529 qi = &ahp->ah_txq[q];
530 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
531 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue\n",
532 __func__);
533 return false;
534 }
535
536 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: queue %p\n", __func__, qi);
537
538 qi->tqi_ver = qinfo->tqi_ver;
539 qi->tqi_subtype = qinfo->tqi_subtype;
540 qi->tqi_qflags = qinfo->tqi_qflags;
541 qi->tqi_priority = qinfo->tqi_priority;
542 if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT)
543 qi->tqi_aifs = min(qinfo->tqi_aifs, 255U);
544 else
545 qi->tqi_aifs = INIT_AIFS;
546 if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) {
547 cw = min(qinfo->tqi_cwmin, 1024U);
548 qi->tqi_cwmin = 1;
549 while (qi->tqi_cwmin < cw)
550 qi->tqi_cwmin = (qi->tqi_cwmin << 1) | 1;
551 } else
552 qi->tqi_cwmin = qinfo->tqi_cwmin;
553 if (qinfo->tqi_cwmax != ATH9K_TXQ_USEDEFAULT) {
554 cw = min(qinfo->tqi_cwmax, 1024U);
555 qi->tqi_cwmax = 1;
556 while (qi->tqi_cwmax < cw)
557 qi->tqi_cwmax = (qi->tqi_cwmax << 1) | 1;
558 } else
559 qi->tqi_cwmax = INIT_CWMAX;
560
561 if (qinfo->tqi_shretry != 0)
562 qi->tqi_shretry = min((u32) qinfo->tqi_shretry, 15U);
563 else
564 qi->tqi_shretry = INIT_SH_RETRY;
565 if (qinfo->tqi_lgretry != 0)
566 qi->tqi_lgretry = min((u32) qinfo->tqi_lgretry, 15U);
567 else
568 qi->tqi_lgretry = INIT_LG_RETRY;
569 qi->tqi_cbrPeriod = qinfo->tqi_cbrPeriod;
570 qi->tqi_cbrOverflowLimit = qinfo->tqi_cbrOverflowLimit;
571 qi->tqi_burstTime = qinfo->tqi_burstTime;
572 qi->tqi_readyTime = qinfo->tqi_readyTime;
573
574 switch (qinfo->tqi_subtype) {
575 case ATH9K_WME_UPSD:
576 if (qi->tqi_type == ATH9K_TX_QUEUE_DATA)
577 qi->tqi_intFlags = ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS;
578 break;
579 default:
580 break;
581 }
582
583 return true;
584}
585
586bool ath9k_hw_get_txq_props(struct ath_hal *ah, int q,
587 struct ath9k_tx_queue_info *qinfo)
588{
589 struct ath_hal_5416 *ahp = AH5416(ah);
590 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
591 struct ath9k_tx_queue_info *qi;
592
593 if (q >= pCap->total_queues) {
594 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n",
595 __func__, q);
596 return false;
597 }
598
599 qi = &ahp->ah_txq[q];
600 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
601 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue\n",
602 __func__);
603 return false;
604 }
605
606 qinfo->tqi_qflags = qi->tqi_qflags;
607 qinfo->tqi_ver = qi->tqi_ver;
608 qinfo->tqi_subtype = qi->tqi_subtype;
609 qinfo->tqi_qflags = qi->tqi_qflags;
610 qinfo->tqi_priority = qi->tqi_priority;
611 qinfo->tqi_aifs = qi->tqi_aifs;
612 qinfo->tqi_cwmin = qi->tqi_cwmin;
613 qinfo->tqi_cwmax = qi->tqi_cwmax;
614 qinfo->tqi_shretry = qi->tqi_shretry;
615 qinfo->tqi_lgretry = qi->tqi_lgretry;
616 qinfo->tqi_cbrPeriod = qi->tqi_cbrPeriod;
617 qinfo->tqi_cbrOverflowLimit = qi->tqi_cbrOverflowLimit;
618 qinfo->tqi_burstTime = qi->tqi_burstTime;
619 qinfo->tqi_readyTime = qi->tqi_readyTime;
620
621 return true;
622}
623
624int ath9k_hw_setuptxqueue(struct ath_hal *ah, enum ath9k_tx_queue type,
625 const struct ath9k_tx_queue_info *qinfo)
626{
627 struct ath_hal_5416 *ahp = AH5416(ah);
628 struct ath9k_tx_queue_info *qi;
629 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
630 int q;
631
632 switch (type) {
633 case ATH9K_TX_QUEUE_BEACON:
634 q = pCap->total_queues - 1;
635 break;
636 case ATH9K_TX_QUEUE_CAB:
637 q = pCap->total_queues - 2;
638 break;
639 case ATH9K_TX_QUEUE_PSPOLL:
640 q = 1;
641 break;
642 case ATH9K_TX_QUEUE_UAPSD:
643 q = pCap->total_queues - 3;
644 break;
645 case ATH9K_TX_QUEUE_DATA:
646 for (q = 0; q < pCap->total_queues; q++)
647 if (ahp->ah_txq[q].tqi_type ==
648 ATH9K_TX_QUEUE_INACTIVE)
649 break;
650 if (q == pCap->total_queues) {
651 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
652 "%s: no available tx queue\n", __func__);
653 return -1;
654 }
655 break;
656 default:
657 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: bad tx queue type %u\n",
658 __func__, type);
659 return -1;
660 }
661
662 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: queue %u\n", __func__, q);
663
664 qi = &ahp->ah_txq[q];
665 if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) {
666 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
667 "%s: tx queue %u already active\n", __func__, q);
668 return -1;
669 }
670 memset(qi, 0, sizeof(struct ath9k_tx_queue_info));
671 qi->tqi_type = type;
672 if (qinfo == NULL) {
673 qi->tqi_qflags =
674 TXQ_FLAG_TXOKINT_ENABLE
675 | TXQ_FLAG_TXERRINT_ENABLE
676 | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE;
677 qi->tqi_aifs = INIT_AIFS;
678 qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
679 qi->tqi_cwmax = INIT_CWMAX;
680 qi->tqi_shretry = INIT_SH_RETRY;
681 qi->tqi_lgretry = INIT_LG_RETRY;
682 qi->tqi_physCompBuf = 0;
683 } else {
684 qi->tqi_physCompBuf = qinfo->tqi_physCompBuf;
685 (void) ath9k_hw_set_txq_props(ah, q, qinfo);
686 }
687
688 return q;
689}
690
691bool ath9k_hw_releasetxqueue(struct ath_hal *ah, u32 q)
692{
693 struct ath_hal_5416 *ahp = AH5416(ah);
694 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
695 struct ath9k_tx_queue_info *qi;
696
697 if (q >= pCap->total_queues) {
698 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n",
699 __func__, q);
700 return false;
701 }
702 qi = &ahp->ah_txq[q];
703 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
704 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue %u\n",
705 __func__, q);
706 return false;
707 }
708
709 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: release queue %u\n",
710 __func__, q);
711
712 qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE;
713 ahp->ah_txOkInterruptMask &= ~(1 << q);
714 ahp->ah_txErrInterruptMask &= ~(1 << q);
715 ahp->ah_txDescInterruptMask &= ~(1 << q);
716 ahp->ah_txEolInterruptMask &= ~(1 << q);
717 ahp->ah_txUrnInterruptMask &= ~(1 << q);
718 ath9k_hw_set_txq_interrupts(ah, qi);
719
720 return true;
721}
722
723bool ath9k_hw_resettxqueue(struct ath_hal *ah, u32 q)
724{
725 struct ath_hal_5416 *ahp = AH5416(ah);
726 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
727 struct ath9k_channel *chan = ah->ah_curchan;
728 struct ath9k_tx_queue_info *qi;
729 u32 cwMin, chanCwMin, value;
730
731 if (q >= pCap->total_queues) {
732 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: invalid queue num %u\n",
733 __func__, q);
734 return false;
735 }
736
737 qi = &ahp->ah_txq[q];
738 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
739 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: inactive queue %u\n",
740 __func__, q);
741 return true;
742 }
743
744 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "%s: reset queue %u\n", __func__, q);
745
746 if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
747 if (chan && IS_CHAN_B(chan))
748 chanCwMin = INIT_CWMIN_11B;
749 else
750 chanCwMin = INIT_CWMIN;
751
752 for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1);
753 } else
754 cwMin = qi->tqi_cwmin;
755
756 REG_WRITE(ah, AR_DLCL_IFS(q),
757 SM(cwMin, AR_D_LCL_IFS_CWMIN) |
758 SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX) |
759 SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
760
761 REG_WRITE(ah, AR_DRETRY_LIMIT(q),
762 SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH) |
763 SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG) |
764 SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH));
765
766 REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
767 REG_WRITE(ah, AR_DMISC(q),
768 AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2);
769
770 if (qi->tqi_cbrPeriod) {
771 REG_WRITE(ah, AR_QCBRCFG(q),
772 SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL) |
773 SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_OVF_THRESH));
774 REG_WRITE(ah, AR_QMISC(q),
775 REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_FSP_CBR |
776 (qi->tqi_cbrOverflowLimit ?
777 AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0));
778 }
779 if (qi->tqi_readyTime && (qi->tqi_type != ATH9K_TX_QUEUE_CAB)) {
780 REG_WRITE(ah, AR_QRDYTIMECFG(q),
781 SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) |
782 AR_Q_RDYTIMECFG_EN);
783 }
784
785 REG_WRITE(ah, AR_DCHNTIME(q),
786 SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
787 (qi->tqi_burstTime ? AR_D_CHNTIME_EN : 0));
788
789 if (qi->tqi_burstTime
790 && (qi->tqi_qflags & TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)) {
791 REG_WRITE(ah, AR_QMISC(q),
792 REG_READ(ah, AR_QMISC(q)) |
793 AR_Q_MISC_RDYTIME_EXP_POLICY);
794
795 }
796
797 if (qi->tqi_qflags & TXQ_FLAG_BACKOFF_DISABLE) {
798 REG_WRITE(ah, AR_DMISC(q),
799 REG_READ(ah, AR_DMISC(q)) |
800 AR_D_MISC_POST_FR_BKOFF_DIS);
801 }
802 if (qi->tqi_qflags & TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE) {
803 REG_WRITE(ah, AR_DMISC(q),
804 REG_READ(ah, AR_DMISC(q)) |
805 AR_D_MISC_FRAG_BKOFF_EN);
806 }
807 switch (qi->tqi_type) {
808 case ATH9K_TX_QUEUE_BEACON:
809 REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
810 | AR_Q_MISC_FSP_DBA_GATED
811 | AR_Q_MISC_BEACON_USE
812 | AR_Q_MISC_CBR_INCR_DIS1);
813
814 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
815 | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
816 AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
817 | AR_D_MISC_BEACON_USE
818 | AR_D_MISC_POST_FR_BKOFF_DIS);
819 break;
820 case ATH9K_TX_QUEUE_CAB:
821 REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
822 | AR_Q_MISC_FSP_DBA_GATED
823 | AR_Q_MISC_CBR_INCR_DIS1
824 | AR_Q_MISC_CBR_INCR_DIS0);
825 value = (qi->tqi_readyTime -
826 (ah->ah_config.sw_beacon_response_time -
827 ah->ah_config.dma_beacon_response_time) -
828 ah->ah_config.additional_swba_backoff) * 1024;
829 REG_WRITE(ah, AR_QRDYTIMECFG(q),
830 value | AR_Q_RDYTIMECFG_EN);
831 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
832 | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
833 AR_D_MISC_ARB_LOCKOUT_CNTRL_S));
834 break;
835 case ATH9K_TX_QUEUE_PSPOLL:
836 REG_WRITE(ah, AR_QMISC(q),
837 REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1);
838 break;
839 case ATH9K_TX_QUEUE_UAPSD:
840 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) |
841 AR_D_MISC_POST_FR_BKOFF_DIS);
842 break;
843 default:
844 break;
845 }
846
847 if (qi->tqi_intFlags & ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS) {
848 REG_WRITE(ah, AR_DMISC(q),
849 REG_READ(ah, AR_DMISC(q)) |
850 SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
851 AR_D_MISC_ARB_LOCKOUT_CNTRL) |
852 AR_D_MISC_POST_FR_BKOFF_DIS);
853 }
854
855 if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE)
856 ahp->ah_txOkInterruptMask |= 1 << q;
857 else
858 ahp->ah_txOkInterruptMask &= ~(1 << q);
859 if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE)
860 ahp->ah_txErrInterruptMask |= 1 << q;
861 else
862 ahp->ah_txErrInterruptMask &= ~(1 << q);
863 if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE)
864 ahp->ah_txDescInterruptMask |= 1 << q;
865 else
866 ahp->ah_txDescInterruptMask &= ~(1 << q);
867 if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE)
868 ahp->ah_txEolInterruptMask |= 1 << q;
869 else
870 ahp->ah_txEolInterruptMask &= ~(1 << q);
871 if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE)
872 ahp->ah_txUrnInterruptMask |= 1 << q;
873 else
874 ahp->ah_txUrnInterruptMask &= ~(1 << q);
875 ath9k_hw_set_txq_interrupts(ah, qi);
876
877 return true;
878}
879
880int ath9k_hw_rxprocdesc(struct ath_hal *ah, struct ath_desc *ds,
881 u32 pa, struct ath_desc *nds, u64 tsf)
882{
883 struct ar5416_desc ads;
884 struct ar5416_desc *adsp = AR5416DESC(ds);
885 u32 phyerr;
886
887 if ((adsp->ds_rxstatus8 & AR_RxDone) == 0)
888 return -EINPROGRESS;
889
890 ads.u.rx = adsp->u.rx;
891
892 ds->ds_rxstat.rs_status = 0;
893 ds->ds_rxstat.rs_flags = 0;
894
895 ds->ds_rxstat.rs_datalen = ads.ds_rxstatus1 & AR_DataLen;
896 ds->ds_rxstat.rs_tstamp = ads.AR_RcvTimestamp;
897
898 ds->ds_rxstat.rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
899 ds->ds_rxstat.rs_rssi_ctl0 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt00);
900 ds->ds_rxstat.rs_rssi_ctl1 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt01);
901 ds->ds_rxstat.rs_rssi_ctl2 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt02);
902 ds->ds_rxstat.rs_rssi_ext0 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt10);
903 ds->ds_rxstat.rs_rssi_ext1 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt11);
904 ds->ds_rxstat.rs_rssi_ext2 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt12);
905 if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
906 ds->ds_rxstat.rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
907 else
908 ds->ds_rxstat.rs_keyix = ATH9K_RXKEYIX_INVALID;
909
910 ds->ds_rxstat.rs_rate = RXSTATUS_RATE(ah, (&ads));
911 ds->ds_rxstat.rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
912
913 ds->ds_rxstat.rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
914 ds->ds_rxstat.rs_moreaggr =
915 (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
916 ds->ds_rxstat.rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
917 ds->ds_rxstat.rs_flags =
918 (ads.ds_rxstatus3 & AR_GI) ? ATH9K_RX_GI : 0;
919 ds->ds_rxstat.rs_flags |=
920 (ads.ds_rxstatus3 & AR_2040) ? ATH9K_RX_2040 : 0;
921
922 if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
923 ds->ds_rxstat.rs_flags |= ATH9K_RX_DELIM_CRC_PRE;
924 if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
925 ds->ds_rxstat.rs_flags |= ATH9K_RX_DELIM_CRC_POST;
926 if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
927 ds->ds_rxstat.rs_flags |= ATH9K_RX_DECRYPT_BUSY;
928
929 if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
930 if (ads.ds_rxstatus8 & AR_CRCErr)
931 ds->ds_rxstat.rs_status |= ATH9K_RXERR_CRC;
932 else if (ads.ds_rxstatus8 & AR_PHYErr) {
933 ds->ds_rxstat.rs_status |= ATH9K_RXERR_PHY;
934 phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
935 ds->ds_rxstat.rs_phyerr = phyerr;
936 } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
937 ds->ds_rxstat.rs_status |= ATH9K_RXERR_DECRYPT;
938 else if (ads.ds_rxstatus8 & AR_MichaelErr)
939 ds->ds_rxstat.rs_status |= ATH9K_RXERR_MIC;
940 }
941
942 return 0;
943}
944
945bool ath9k_hw_setuprxdesc(struct ath_hal *ah, struct ath_desc *ds,
946 u32 size, u32 flags)
947{
948 struct ar5416_desc *ads = AR5416DESC(ds);
949 struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
950
951 ads->ds_ctl1 = size & AR_BufLen;
952 if (flags & ATH9K_RXDESC_INTREQ)
953 ads->ds_ctl1 |= AR_RxIntrReq;
954
955 ads->ds_rxstatus8 &= ~AR_RxDone;
956 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
957 memset(&(ads->u), 0, sizeof(ads->u));
958
959 return true;
960}
961
962bool ath9k_hw_setrxabort(struct ath_hal *ah, bool set)
963{
964 u32 reg;
965
966 if (set) {
967 REG_SET_BIT(ah, AR_DIAG_SW,
968 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
969
970 if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE, 0)) {
971 REG_CLR_BIT(ah, AR_DIAG_SW,
972 (AR_DIAG_RX_DIS |
973 AR_DIAG_RX_ABORT));
974
975 reg = REG_READ(ah, AR_OBS_BUS_1);
976 DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
977 "%s: rx failed to go idle in 10 ms RXSM=0x%x\n",
978 __func__, reg);
979
980 return false;
981 }
982 } else {
983 REG_CLR_BIT(ah, AR_DIAG_SW,
984 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
985 }
986
987 return true;
988}
989
990void ath9k_hw_putrxbuf(struct ath_hal *ah, u32 rxdp)
991{
992 REG_WRITE(ah, AR_RXDP, rxdp);
993}
994
995void ath9k_hw_rxena(struct ath_hal *ah)
996{
997 REG_WRITE(ah, AR_CR, AR_CR_RXE);
998}
999
1000void ath9k_hw_startpcureceive(struct ath_hal *ah)
1001{
1002 REG_CLR_BIT(ah, AR_DIAG_SW,
1003 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
1004
1005 ath9k_enable_mib_counters(ah);
1006
1007 ath9k_ani_reset(ah);
1008}
1009
1010void ath9k_hw_stoppcurecv(struct ath_hal *ah)
1011{
1012 REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
1013
1014 ath9k_hw_disable_mib_counters(ah);
1015}
1016
1017bool ath9k_hw_stopdmarecv(struct ath_hal *ah)
1018{
1019 REG_WRITE(ah, AR_CR, AR_CR_RXD);
1020
1021 if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0)) {
1022 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
1023 "%s: dma failed to stop in 10ms\n"
1024 "AR_CR=0x%08x\nAR_DIAG_SW=0x%08x\n",
1025 __func__,
1026 REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW));
1027 return false;
1028 } else {
1029 return true;
1030 }
1031}
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index f05f584ab7bc..f830fe1e4adc 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -21,8 +21,6 @@
21 21
22#define ATH_PCI_VERSION "0.1" 22#define ATH_PCI_VERSION "0.1"
23 23
24#define IEEE80211_HTCAP_MAXRXAMPDU_FACTOR 13
25
26static char *dev_info = "ath9k"; 24static char *dev_info = "ath9k";
27 25
28MODULE_AUTHOR("Atheros Communications"); 26MODULE_AUTHOR("Atheros Communications");
@@ -39,6 +37,8 @@ static struct pci_device_id ath_pci_id_table[] __devinitdata = {
39 { 0 } 37 { 0 }
40}; 38};
41 39
40static void ath_detach(struct ath_softc *sc);
41
42static int ath_get_channel(struct ath_softc *sc, 42static int ath_get_channel(struct ath_softc *sc,
43 struct ieee80211_channel *chan) 43 struct ieee80211_channel *chan)
44{ 44{
@@ -61,24 +61,24 @@ static u32 ath_get_extchanmode(struct ath_softc *sc,
61 61
62 switch (chan->band) { 62 switch (chan->band) {
63 case IEEE80211_BAND_2GHZ: 63 case IEEE80211_BAND_2GHZ:
64 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_NONE) && 64 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE) &&
65 (tx_chan_width == ATH9K_HT_MACMODE_20)) 65 (tx_chan_width == ATH9K_HT_MACMODE_20))
66 chanmode = CHANNEL_G_HT20; 66 chanmode = CHANNEL_G_HT20;
67 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_ABOVE) && 67 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) &&
68 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 68 (tx_chan_width == ATH9K_HT_MACMODE_2040))
69 chanmode = CHANNEL_G_HT40PLUS; 69 chanmode = CHANNEL_G_HT40PLUS;
70 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_BELOW) && 70 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) &&
71 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 71 (tx_chan_width == ATH9K_HT_MACMODE_2040))
72 chanmode = CHANNEL_G_HT40MINUS; 72 chanmode = CHANNEL_G_HT40MINUS;
73 break; 73 break;
74 case IEEE80211_BAND_5GHZ: 74 case IEEE80211_BAND_5GHZ:
75 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_NONE) && 75 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE) &&
76 (tx_chan_width == ATH9K_HT_MACMODE_20)) 76 (tx_chan_width == ATH9K_HT_MACMODE_20))
77 chanmode = CHANNEL_A_HT20; 77 chanmode = CHANNEL_A_HT20;
78 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_ABOVE) && 78 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) &&
79 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 79 (tx_chan_width == ATH9K_HT_MACMODE_2040))
80 chanmode = CHANNEL_A_HT40PLUS; 80 chanmode = CHANNEL_A_HT40PLUS;
81 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_BELOW) && 81 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) &&
82 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 82 (tx_chan_width == ATH9K_HT_MACMODE_2040))
83 chanmode = CHANNEL_A_HT40MINUS; 83 chanmode = CHANNEL_A_HT40MINUS;
84 break; 84 break;
@@ -164,7 +164,7 @@ static int ath_key_config(struct ath_softc *sc,
164 if (!sc->sc_vaps[0]) 164 if (!sc->sc_vaps[0])
165 return -EIO; 165 return -EIO;
166 166
167 vif = sc->sc_vaps[0]->av_if_data; 167 vif = sc->sc_vaps[0];
168 opmode = vif->type; 168 opmode = vif->type;
169 169
170 /* 170 /*
@@ -215,24 +215,24 @@ static void ath_key_delete(struct ath_softc *sc, struct ieee80211_key_conf *key)
215 ath_key_reset(sc, key->keyidx, freeslot); 215 ath_key_reset(sc, key->keyidx, freeslot);
216} 216}
217 217
218static void setup_ht_cap(struct ieee80211_ht_info *ht_info) 218static void setup_ht_cap(struct ieee80211_sta_ht_cap *ht_info)
219{ 219{
220#define ATH9K_HT_CAP_MAXRXAMPDU_65536 0x3 /* 2 ^ 16 */ 220#define ATH9K_HT_CAP_MAXRXAMPDU_65536 0x3 /* 2 ^ 16 */
221#define ATH9K_HT_CAP_MPDUDENSITY_8 0x6 /* 8 usec */ 221#define ATH9K_HT_CAP_MPDUDENSITY_8 0x6 /* 8 usec */
222 222
223 ht_info->ht_supported = 1; 223 ht_info->ht_supported = true;
224 ht_info->cap = (u16)IEEE80211_HT_CAP_SUP_WIDTH 224 ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
225 |(u16)IEEE80211_HT_CAP_SM_PS 225 IEEE80211_HT_CAP_SM_PS |
226 |(u16)IEEE80211_HT_CAP_SGI_40 226 IEEE80211_HT_CAP_SGI_40 |
227 |(u16)IEEE80211_HT_CAP_DSSSCCK40; 227 IEEE80211_HT_CAP_DSSSCCK40;
228 228
229 ht_info->ampdu_factor = ATH9K_HT_CAP_MAXRXAMPDU_65536; 229 ht_info->ampdu_factor = ATH9K_HT_CAP_MAXRXAMPDU_65536;
230 ht_info->ampdu_density = ATH9K_HT_CAP_MPDUDENSITY_8; 230 ht_info->ampdu_density = ATH9K_HT_CAP_MPDUDENSITY_8;
231 /* setup supported mcs set */ 231 /* set up supported mcs set */
232 memset(ht_info->supp_mcs_set, 0, 16); 232 memset(&ht_info->mcs, 0, sizeof(ht_info->mcs));
233 ht_info->supp_mcs_set[0] = 0xff; 233 ht_info->mcs.rx_mask[0] = 0xff;
234 ht_info->supp_mcs_set[1] = 0xff; 234 ht_info->mcs.rx_mask[1] = 0xff;
235 ht_info->supp_mcs_set[12] = IEEE80211_HT_CAP_MCS_TX_DEFINED; 235 ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
236} 236}
237 237
238static int ath_rate2idx(struct ath_softc *sc, int rate) 238static int ath_rate2idx(struct ath_softc *sc, int rate)
@@ -279,8 +279,15 @@ static void ath9k_rx_prepare(struct ath_softc *sc,
279 rx_status->rate_idx = ath_rate2idx(sc, (status->rateKbps / 100)); 279 rx_status->rate_idx = ath_rate2idx(sc, (status->rateKbps / 100));
280 rx_status->antenna = status->antenna; 280 rx_status->antenna = status->antenna;
281 281
282 /* XXX Fix me, 64 cannot be the max rssi value, rigure it out */ 282 /* at 45 you will be able to use MCS 15 reliably. A more elaborate
283 rx_status->qual = status->rssi * 100 / 64; 283 * scheme can be used here but it requires tables of SNR/throughput for
284 * each possible mode used. */
285 rx_status->qual = status->rssi * 100 / 45;
286
287 /* rssi can be more than 45 though, anything above that
288 * should be considered at 100% */
289 if (rx_status->qual > 100)
290 rx_status->qual = 100;
284 291
285 if (status->flags & ATH_RX_MIC_ERROR) 292 if (status->flags & ATH_RX_MIC_ERROR)
286 rx_status->flag |= RX_FLAG_MMIC_ERROR; 293 rx_status->flag |= RX_FLAG_MMIC_ERROR;
@@ -290,92 +297,37 @@ static void ath9k_rx_prepare(struct ath_softc *sc,
290 rx_status->flag |= RX_FLAG_TSFT; 297 rx_status->flag |= RX_FLAG_TSFT;
291} 298}
292 299
293static u8 parse_mpdudensity(u8 mpdudensity)
294{
295 /*
296 * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
297 * 0 for no restriction
298 * 1 for 1/4 us
299 * 2 for 1/2 us
300 * 3 for 1 us
301 * 4 for 2 us
302 * 5 for 4 us
303 * 6 for 8 us
304 * 7 for 16 us
305 */
306 switch (mpdudensity) {
307 case 0:
308 return 0;
309 case 1:
310 case 2:
311 case 3:
312 /* Our lower layer calculations limit our precision to
313 1 microsecond */
314 return 1;
315 case 4:
316 return 2;
317 case 5:
318 return 4;
319 case 6:
320 return 8;
321 case 7:
322 return 16;
323 default:
324 return 0;
325 }
326}
327
328static void ath9k_ht_conf(struct ath_softc *sc, 300static void ath9k_ht_conf(struct ath_softc *sc,
329 struct ieee80211_bss_conf *bss_conf) 301 struct ieee80211_bss_conf *bss_conf)
330{ 302{
331#define IEEE80211_HT_CAP_40MHZ_INTOLERANT BIT(14)
332 struct ath_ht_info *ht_info = &sc->sc_ht_info; 303 struct ath_ht_info *ht_info = &sc->sc_ht_info;
333 304
334 if (bss_conf->assoc_ht) { 305 if (sc->hw->conf.ht.enabled) {
335 ht_info->ext_chan_offset = 306 ht_info->ext_chan_offset = bss_conf->ht.secondary_channel_offset;
336 bss_conf->ht_bss_conf->bss_cap &
337 IEEE80211_HT_IE_CHA_SEC_OFFSET;
338 307
339 if (!(bss_conf->ht_conf->cap & 308 if (bss_conf->ht.width_40_ok)
340 IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
341 (bss_conf->ht_bss_conf->bss_cap &
342 IEEE80211_HT_IE_CHA_WIDTH))
343 ht_info->tx_chan_width = ATH9K_HT_MACMODE_2040; 309 ht_info->tx_chan_width = ATH9K_HT_MACMODE_2040;
344 else 310 else
345 ht_info->tx_chan_width = ATH9K_HT_MACMODE_20; 311 ht_info->tx_chan_width = ATH9K_HT_MACMODE_20;
346 312
347 ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width); 313 ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width);
348 ht_info->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
349 bss_conf->ht_conf->ampdu_factor);
350 ht_info->mpdudensity =
351 parse_mpdudensity(bss_conf->ht_conf->ampdu_density);
352
353 } 314 }
354
355#undef IEEE80211_HT_CAP_40MHZ_INTOLERANT
356} 315}
357 316
358static void ath9k_bss_assoc_info(struct ath_softc *sc, 317static void ath9k_bss_assoc_info(struct ath_softc *sc,
318 struct ieee80211_vif *vif,
359 struct ieee80211_bss_conf *bss_conf) 319 struct ieee80211_bss_conf *bss_conf)
360{ 320{
361 struct ieee80211_hw *hw = sc->hw; 321 struct ieee80211_hw *hw = sc->hw;
362 struct ieee80211_channel *curchan = hw->conf.channel; 322 struct ieee80211_channel *curchan = hw->conf.channel;
363 struct ath_vap *avp; 323 struct ath_vap *avp = (void *)vif->drv_priv;
364 int pos; 324 int pos;
365 DECLARE_MAC_BUF(mac);
366 325
367 if (bss_conf->assoc) { 326 if (bss_conf->assoc) {
368 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Bss Info ASSOC %d\n", 327 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Bss Info ASSOC %d\n",
369 __func__, 328 __func__,
370 bss_conf->aid); 329 bss_conf->aid);
371 330
372 avp = sc->sc_vaps[0];
373 if (avp == NULL) {
374 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
375 __func__);
376 return;
377 }
378
379 /* New association, store aid */ 331 /* New association, store aid */
380 if (avp->av_opmode == ATH9K_M_STA) { 332 if (avp->av_opmode == ATH9K_M_STA) {
381 sc->sc_curaid = bss_conf->aid; 333 sc->sc_curaid = bss_conf->aid;
@@ -394,12 +346,12 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
394 sc->sc_halstats.ns_avgtxrate = ATH_RATE_DUMMY_MARKER; 346 sc->sc_halstats.ns_avgtxrate = ATH_RATE_DUMMY_MARKER;
395 347
396 /* Update chainmask */ 348 /* Update chainmask */
397 ath_update_chainmask(sc, bss_conf->assoc_ht); 349 ath_update_chainmask(sc, hw->conf.ht.enabled);
398 350
399 DPRINTF(sc, ATH_DBG_CONFIG, 351 DPRINTF(sc, ATH_DBG_CONFIG,
400 "%s: bssid %s aid 0x%x\n", 352 "%s: bssid %pM aid 0x%x\n",
401 __func__, 353 __func__,
402 print_mac(mac, sc->sc_curbssid), sc->sc_curaid); 354 sc->sc_curbssid, sc->sc_curaid);
403 355
404 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n", 356 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n",
405 __func__, 357 __func__,
@@ -412,7 +364,7 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
412 return; 364 return;
413 } 365 }
414 366
415 if (hw->conf.ht_conf.ht_supported) 367 if (hw->conf.ht.enabled)
416 sc->sc_ah->ah_channels[pos].chanmode = 368 sc->sc_ah->ah_channels[pos].chanmode =
417 ath_get_extchanmode(sc, curchan); 369 ath_get_extchanmode(sc, curchan);
418 else 370 else
@@ -456,7 +408,7 @@ void ath_get_beaconconfig(struct ath_softc *sc,
456} 408}
457 409
458void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, 410void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
459 struct ath_xmit_status *tx_status, struct ath_node *an) 411 struct ath_xmit_status *tx_status)
460{ 412{
461 struct ieee80211_hw *hw = sc->hw; 413 struct ieee80211_hw *hw = sc->hw;
462 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 414 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
@@ -464,12 +416,13 @@ void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
464 DPRINTF(sc, ATH_DBG_XMIT, 416 DPRINTF(sc, ATH_DBG_XMIT,
465 "%s: TX complete: skb: %p\n", __func__, skb); 417 "%s: TX complete: skb: %p\n", __func__, skb);
466 418
419 ieee80211_tx_info_clear_status(tx_info);
467 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK || 420 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
468 tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) { 421 tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
469 /* free driver's private data area of tx_info */ 422 /* free driver's private data area of tx_info, XXX: HACK! */
470 if (tx_info->driver_data[0] != NULL) 423 if (tx_info->control.vif != NULL)
471 kfree(tx_info->driver_data[0]); 424 kfree(tx_info->control.vif);
472 tx_info->driver_data[0] = NULL; 425 tx_info->control.vif = NULL;
473 } 426 }
474 427
475 if (tx_status->flags & ATH_TX_BAR) { 428 if (tx_status->flags & ATH_TX_BAR) {
@@ -477,21 +430,14 @@ void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
477 tx_status->flags &= ~ATH_TX_BAR; 430 tx_status->flags &= ~ATH_TX_BAR;
478 } 431 }
479 432
480 if (tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY)) { 433 if (!(tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY))) {
481 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
482 /* Frame was not ACKed, but an ACK was expected */
483 tx_info->status.excessive_retries = 1;
484 }
485 } else {
486 /* Frame was ACKed */ 434 /* Frame was ACKed */
487 tx_info->flags |= IEEE80211_TX_STAT_ACK; 435 tx_info->flags |= IEEE80211_TX_STAT_ACK;
488 } 436 }
489 437
490 tx_info->status.retry_count = tx_status->retries; 438 tx_info->status.rates[0].count = tx_status->retries + 1;
491 439
492 ieee80211_tx_status(hw, skb); 440 ieee80211_tx_status(hw, skb);
493 if (an)
494 ath_node_put(sc, an, ATH9K_BH_STATUS_CHANGE);
495} 441}
496 442
497int _ath_rx_indicate(struct ath_softc *sc, 443int _ath_rx_indicate(struct ath_softc *sc,
@@ -500,12 +446,10 @@ int _ath_rx_indicate(struct ath_softc *sc,
500 u16 keyix) 446 u16 keyix)
501{ 447{
502 struct ieee80211_hw *hw = sc->hw; 448 struct ieee80211_hw *hw = sc->hw;
503 struct ath_node *an = NULL;
504 struct ieee80211_rx_status rx_status; 449 struct ieee80211_rx_status rx_status;
505 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 450 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
506 int hdrlen = ieee80211_get_hdrlen_from_skb(skb); 451 int hdrlen = ieee80211_get_hdrlen_from_skb(skb);
507 int padsize; 452 int padsize;
508 enum ATH_RX_TYPE st;
509 453
510 /* see if any padding is done by the hw and remove it */ 454 /* see if any padding is done by the hw and remove it */
511 if (hdrlen & 3) { 455 if (hdrlen & 3) {
@@ -529,34 +473,6 @@ int _ath_rx_indicate(struct ath_softc *sc,
529 rx_status.flag |= RX_FLAG_DECRYPTED; 473 rx_status.flag |= RX_FLAG_DECRYPTED;
530 } 474 }
531 475
532 spin_lock_bh(&sc->node_lock);
533 an = ath_node_find(sc, hdr->addr2);
534 spin_unlock_bh(&sc->node_lock);
535
536 if (an) {
537 ath_rx_input(sc, an,
538 hw->conf.ht_conf.ht_supported,
539 skb, status, &st);
540 }
541 if (!an || (st != ATH_RX_CONSUMED))
542 __ieee80211_rx(hw, skb, &rx_status);
543
544 return 0;
545}
546
547int ath_rx_subframe(struct ath_node *an,
548 struct sk_buff *skb,
549 struct ath_recv_status *status)
550{
551 struct ath_softc *sc = an->an_sc;
552 struct ieee80211_hw *hw = sc->hw;
553 struct ieee80211_rx_status rx_status;
554
555 /* Prepare rx status */
556 ath9k_rx_prepare(sc, skb, status, &rx_status);
557 if (!(status->flags & ATH_RX_DECRYPT_ERROR))
558 rx_status.flag |= RX_FLAG_DECRYPTED;
559
560 __ieee80211_rx(hw, skb, &rx_status); 476 __ieee80211_rx(hw, skb, &rx_status);
561 477
562 return 0; 478 return 0;
@@ -678,6 +594,7 @@ fail:
678} 594}
679 595
680#ifdef CONFIG_RFKILL 596#ifdef CONFIG_RFKILL
597
681/*******************/ 598/*******************/
682/* Rfkill */ 599/* Rfkill */
683/*******************/ 600/*******************/
@@ -878,43 +795,72 @@ static void ath_deinit_rfkill(struct ath_softc *sc)
878 sc->rf_kill.rfkill = NULL; 795 sc->rf_kill.rfkill = NULL;
879 } 796 }
880} 797}
798
799static int ath_start_rfkill_poll(struct ath_softc *sc)
800{
801 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
802 queue_delayed_work(sc->hw->workqueue,
803 &sc->rf_kill.rfkill_poll, 0);
804
805 if (!(sc->sc_flags & SC_OP_RFKILL_REGISTERED)) {
806 if (rfkill_register(sc->rf_kill.rfkill)) {
807 DPRINTF(sc, ATH_DBG_FATAL,
808 "Unable to register rfkill\n");
809 rfkill_free(sc->rf_kill.rfkill);
810
811 /* Deinitialize the device */
812 if (sc->pdev->irq)
813 free_irq(sc->pdev->irq, sc);
814 ath_detach(sc);
815 pci_iounmap(sc->pdev, sc->mem);
816 pci_release_region(sc->pdev, 0);
817 pci_disable_device(sc->pdev);
818 ieee80211_free_hw(sc->hw);
819 return -EIO;
820 } else {
821 sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
822 }
823 }
824
825 return 0;
826}
881#endif /* CONFIG_RFKILL */ 827#endif /* CONFIG_RFKILL */
882 828
883static int ath_detach(struct ath_softc *sc) 829static void ath_detach(struct ath_softc *sc)
884{ 830{
885 struct ieee80211_hw *hw = sc->hw; 831 struct ieee80211_hw *hw = sc->hw;
832 int i = 0;
886 833
887 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach ATH hw\n", __func__); 834 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach ATH hw\n", __func__);
888 835
889 /* Deinit LED control */ 836 ieee80211_unregister_hw(hw);
837
890 ath_deinit_leds(sc); 838 ath_deinit_leds(sc);
891 839
892#ifdef CONFIG_RFKILL 840#ifdef CONFIG_RFKILL
893 /* deinit rfkill */
894 ath_deinit_rfkill(sc); 841 ath_deinit_rfkill(sc);
895#endif 842#endif
896
897 /* Unregister hw */
898
899 ieee80211_unregister_hw(hw);
900
901 /* unregister Rate control */
902 ath_rate_control_unregister(); 843 ath_rate_control_unregister();
903 844 ath_rate_detach(sc->sc_rc);
904 /* tx/rx cleanup */
905 845
906 ath_rx_cleanup(sc); 846 ath_rx_cleanup(sc);
907 ath_tx_cleanup(sc); 847 ath_tx_cleanup(sc);
908 848
909 /* Deinit */ 849 tasklet_kill(&sc->intr_tq);
850 tasklet_kill(&sc->bcon_tasklet);
910 851
911 ath_deinit(sc); 852 if (!(sc->sc_flags & SC_OP_INVALID))
853 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
912 854
913 return 0; 855 /* cleanup tx queues */
856 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
857 if (ATH_TXQ_SETUP(sc, i))
858 ath_tx_cleanupq(sc, &sc->sc_txq[i]);
859
860 ath9k_hw_detach(sc->sc_ah);
914} 861}
915 862
916static int ath_attach(u16 devid, 863static int ath_attach(u16 devid, struct ath_softc *sc)
917 struct ath_softc *sc)
918{ 864{
919 struct ieee80211_hw *hw = sc->hw; 865 struct ieee80211_hw *hw = sc->hw;
920 int error = 0; 866 int error = 0;
@@ -925,50 +871,23 @@ static int ath_attach(u16 devid,
925 if (error != 0) 871 if (error != 0)
926 return error; 872 return error;
927 873
928 /* Init nodes */
929
930 INIT_LIST_HEAD(&sc->node_list);
931 spin_lock_init(&sc->node_lock);
932
933 /* get mac address from hardware and set in mac80211 */ 874 /* get mac address from hardware and set in mac80211 */
934 875
935 SET_IEEE80211_PERM_ADDR(hw, sc->sc_myaddr); 876 SET_IEEE80211_PERM_ADDR(hw, sc->sc_myaddr);
936 877
937 /* setup channels and rates */ 878 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
938 879 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
939 sc->sbands[IEEE80211_BAND_2GHZ].channels = 880 IEEE80211_HW_SIGNAL_DBM |
940 sc->channels[IEEE80211_BAND_2GHZ]; 881 IEEE80211_HW_AMPDU_AGGREGATION;
941 sc->sbands[IEEE80211_BAND_2GHZ].bitrates =
942 sc->rates[IEEE80211_BAND_2GHZ];
943 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
944
945 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
946 /* Setup HT capabilities for 2.4Ghz*/
947 setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_info);
948
949 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
950 &sc->sbands[IEEE80211_BAND_2GHZ];
951
952 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->ah_caps.wireless_modes)) {
953 sc->sbands[IEEE80211_BAND_5GHZ].channels =
954 sc->channels[IEEE80211_BAND_5GHZ];
955 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
956 sc->rates[IEEE80211_BAND_5GHZ];
957 sc->sbands[IEEE80211_BAND_5GHZ].band =
958 IEEE80211_BAND_5GHZ;
959
960 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
961 /* Setup HT capabilities for 5Ghz*/
962 setup_ht_cap(&sc->sbands[IEEE80211_BAND_5GHZ].ht_info);
963
964 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
965 &sc->sbands[IEEE80211_BAND_5GHZ];
966 }
967 882
968 /* FIXME: Have to figure out proper hw init values later */ 883 hw->wiphy->interface_modes =
884 BIT(NL80211_IFTYPE_AP) |
885 BIT(NL80211_IFTYPE_STATION) |
886 BIT(NL80211_IFTYPE_ADHOC);
969 887
970 hw->queues = 4; 888 hw->queues = 4;
971 hw->ampdu_queues = 1; 889 hw->sta_data_size = sizeof(struct ath_node);
890 hw->vif_data_size = sizeof(struct ath_vap);
972 891
973 /* Register rate control */ 892 /* Register rate control */
974 hw->rate_control_algorithm = "ath9k_rate_control"; 893 hw->rate_control_algorithm = "ath9k_rate_control";
@@ -981,6 +900,17 @@ static int ath_attach(u16 devid,
981 goto bad; 900 goto bad;
982 } 901 }
983 902
903 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) {
904 setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
905 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->ah_caps.wireless_modes))
906 setup_ht_cap(&sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
907 }
908
909 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &sc->sbands[IEEE80211_BAND_2GHZ];
910 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->ah_caps.wireless_modes))
911 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
912 &sc->sbands[IEEE80211_BAND_5GHZ];
913
984 error = ieee80211_register_hw(hw); 914 error = ieee80211_register_hw(hw);
985 if (error != 0) { 915 if (error != 0) {
986 ath_rate_control_unregister(); 916 ath_rate_control_unregister();
@@ -1026,62 +956,44 @@ static int ath9k_start(struct ieee80211_hw *hw)
1026 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Starting driver with " 956 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Starting driver with "
1027 "initial channel: %d MHz\n", __func__, curchan->center_freq); 957 "initial channel: %d MHz\n", __func__, curchan->center_freq);
1028 958
959 memset(&sc->sc_ht_info, 0, sizeof(struct ath_ht_info));
960
1029 /* setup initial channel */ 961 /* setup initial channel */
1030 962
1031 pos = ath_get_channel(sc, curchan); 963 pos = ath_get_channel(sc, curchan);
1032 if (pos == -1) { 964 if (pos == -1) {
1033 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid channel\n", __func__); 965 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid channel\n", __func__);
1034 return -EINVAL; 966 error = -EINVAL;
967 goto exit;
1035 } 968 }
1036 969
1037 sc->sc_ah->ah_channels[pos].chanmode = 970 sc->sc_ah->ah_channels[pos].chanmode =
1038 (curchan->band == IEEE80211_BAND_2GHZ) ? CHANNEL_G : CHANNEL_A; 971 (curchan->band == IEEE80211_BAND_2GHZ) ? CHANNEL_G : CHANNEL_A;
1039 972
1040 /* open ath_dev */
1041 error = ath_open(sc, &sc->sc_ah->ah_channels[pos]); 973 error = ath_open(sc, &sc->sc_ah->ah_channels[pos]);
1042 if (error) { 974 if (error) {
1043 DPRINTF(sc, ATH_DBG_FATAL, 975 DPRINTF(sc, ATH_DBG_FATAL,
1044 "%s: Unable to complete ath_open\n", __func__); 976 "%s: Unable to complete ath_open\n", __func__);
1045 return error; 977 goto exit;
1046 } 978 }
1047 979
1048#ifdef CONFIG_RFKILL 980#ifdef CONFIG_RFKILL
1049 /* Start rfkill polling */ 981 error = ath_start_rfkill_poll(sc);
1050 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1051 queue_delayed_work(sc->hw->workqueue,
1052 &sc->rf_kill.rfkill_poll, 0);
1053
1054 if (!(sc->sc_flags & SC_OP_RFKILL_REGISTERED)) {
1055 if (rfkill_register(sc->rf_kill.rfkill)) {
1056 DPRINTF(sc, ATH_DBG_FATAL,
1057 "Unable to register rfkill\n");
1058 rfkill_free(sc->rf_kill.rfkill);
1059
1060 /* Deinitialize the device */
1061 if (sc->pdev->irq)
1062 free_irq(sc->pdev->irq, sc);
1063 ath_detach(sc);
1064 pci_iounmap(sc->pdev, sc->mem);
1065 pci_release_region(sc->pdev, 0);
1066 pci_disable_device(sc->pdev);
1067 ieee80211_free_hw(hw);
1068 return -EIO;
1069 } else {
1070 sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
1071 }
1072 }
1073#endif 982#endif
1074 983
1075 ieee80211_wake_queues(hw); 984exit:
1076 return 0; 985 return error;
1077} 986}
1078 987
1079static int ath9k_tx(struct ieee80211_hw *hw, 988static int ath9k_tx(struct ieee80211_hw *hw,
1080 struct sk_buff *skb) 989 struct sk_buff *skb)
1081{ 990{
991 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1082 struct ath_softc *sc = hw->priv; 992 struct ath_softc *sc = hw->priv;
993 struct ath_tx_control txctl;
1083 int hdrlen, padsize; 994 int hdrlen, padsize;
1084 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 995
996 memset(&txctl, 0, sizeof(struct ath_tx_control));
1085 997
1086 /* 998 /*
1087 * As a temporary workaround, assign seq# here; this will likely need 999 * As a temporary workaround, assign seq# here; this will likely need
@@ -1106,45 +1018,47 @@ static int ath9k_tx(struct ieee80211_hw *hw,
1106 memmove(skb->data, skb->data + padsize, hdrlen); 1018 memmove(skb->data, skb->data + padsize, hdrlen);
1107 } 1019 }
1108 1020
1021 /* Check if a tx queue is available */
1022
1023 txctl.txq = ath_test_get_txq(sc, skb);
1024 if (!txctl.txq)
1025 goto exit;
1026
1109 DPRINTF(sc, ATH_DBG_XMIT, "%s: transmitting packet, skb: %p\n", 1027 DPRINTF(sc, ATH_DBG_XMIT, "%s: transmitting packet, skb: %p\n",
1110 __func__, 1028 __func__,
1111 skb); 1029 skb);
1112 1030
1113 if (ath_tx_start(sc, skb) != 0) { 1031 if (ath_tx_start(sc, skb, &txctl) != 0) {
1114 DPRINTF(sc, ATH_DBG_XMIT, "%s: TX failed\n", __func__); 1032 DPRINTF(sc, ATH_DBG_XMIT, "%s: TX failed\n", __func__);
1115 dev_kfree_skb_any(skb); 1033 goto exit;
1116 /* FIXME: Check for proper return value from ATH_DEV */
1117 return 0;
1118 } 1034 }
1119 1035
1120 return 0; 1036 return 0;
1037exit:
1038 dev_kfree_skb_any(skb);
1039 return 0;
1121} 1040}
1122 1041
1123static void ath9k_stop(struct ieee80211_hw *hw) 1042static void ath9k_stop(struct ieee80211_hw *hw)
1124{ 1043{
1125 struct ath_softc *sc = hw->priv; 1044 struct ath_softc *sc = hw->priv;
1126 int error;
1127 1045
1128 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Driver halt\n", __func__); 1046 if (sc->sc_flags & SC_OP_INVALID) {
1129 1047 DPRINTF(sc, ATH_DBG_ANY, "%s: Device not present\n", __func__);
1130 error = ath_suspend(sc); 1048 return;
1131 if (error) 1049 }
1132 DPRINTF(sc, ATH_DBG_CONFIG,
1133 "%s: Device is no longer present\n", __func__);
1134 1050
1135 ieee80211_stop_queues(hw); 1051 ath_stop(sc);
1136 1052
1137#ifdef CONFIG_RFKILL 1053 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Driver halt\n", __func__);
1138 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1139 cancel_delayed_work_sync(&sc->rf_kill.rfkill_poll);
1140#endif
1141} 1054}
1142 1055
1143static int ath9k_add_interface(struct ieee80211_hw *hw, 1056static int ath9k_add_interface(struct ieee80211_hw *hw,
1144 struct ieee80211_if_init_conf *conf) 1057 struct ieee80211_if_init_conf *conf)
1145{ 1058{
1146 struct ath_softc *sc = hw->priv; 1059 struct ath_softc *sc = hw->priv;
1147 int error, ic_opmode = 0; 1060 struct ath_vap *avp = (void *)conf->vif->drv_priv;
1061 int ic_opmode = 0;
1148 1062
1149 /* Support only vap for now */ 1063 /* Support only vap for now */
1150 1064
@@ -1172,13 +1086,22 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
1172 __func__, 1086 __func__,
1173 ic_opmode); 1087 ic_opmode);
1174 1088
1175 error = ath_vap_attach(sc, 0, conf->vif, ic_opmode); 1089 /* Set the VAP opmode */
1176 if (error) { 1090 avp->av_opmode = ic_opmode;
1177 DPRINTF(sc, ATH_DBG_FATAL, 1091 avp->av_bslot = -1;
1178 "%s: Unable to attach vap, error: %d\n", 1092
1179 __func__, error); 1093 if (ic_opmode == ATH9K_M_HOSTAP)
1180 return error; 1094 ath9k_hw_set_tsfadjust(sc->sc_ah, 1);
1181 } 1095
1096 sc->sc_vaps[0] = conf->vif;
1097 sc->sc_nvaps++;
1098
1099 /* Set the device opmode */
1100 sc->sc_ah->ah_opmode = ic_opmode;
1101
1102 /* default VAP configuration */
1103 avp->av_config.av_fixed_rateset = IEEE80211_FIXED_RATE_NONE;
1104 avp->av_config.av_fixed_retryset = 0x03030303;
1182 1105
1183 if (conf->type == NL80211_IFTYPE_AP) { 1106 if (conf->type == NL80211_IFTYPE_AP) {
1184 /* TODO: is this a suitable place to start ANI for AP mode? */ 1107 /* TODO: is this a suitable place to start ANI for AP mode? */
@@ -1194,27 +1117,16 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1194 struct ieee80211_if_init_conf *conf) 1117 struct ieee80211_if_init_conf *conf)
1195{ 1118{
1196 struct ath_softc *sc = hw->priv; 1119 struct ath_softc *sc = hw->priv;
1197 struct ath_vap *avp; 1120 struct ath_vap *avp = (void *)conf->vif->drv_priv;
1198 int error;
1199 1121
1200 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach VAP\n", __func__); 1122 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach VAP\n", __func__);
1201 1123
1202 avp = sc->sc_vaps[0];
1203 if (avp == NULL) {
1204 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
1205 __func__);
1206 return;
1207 }
1208
1209#ifdef CONFIG_SLOW_ANT_DIV 1124#ifdef CONFIG_SLOW_ANT_DIV
1210 ath_slow_ant_div_stop(&sc->sc_antdiv); 1125 ath_slow_ant_div_stop(&sc->sc_antdiv);
1211#endif 1126#endif
1212 /* Stop ANI */ 1127 /* Stop ANI */
1213 del_timer_sync(&sc->sc_ani.timer); 1128 del_timer_sync(&sc->sc_ani.timer);
1214 1129
1215 /* Update ratectrl */
1216 ath_rate_newstate(sc, avp);
1217
1218 /* Reclaim beacon resources */ 1130 /* Reclaim beacon resources */
1219 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP || 1131 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP ||
1220 sc->sc_ah->ah_opmode == ATH9K_M_IBSS) { 1132 sc->sc_ah->ah_opmode == ATH9K_M_IBSS) {
@@ -1222,29 +1134,26 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1222 ath_beacon_return(sc, avp); 1134 ath_beacon_return(sc, avp);
1223 } 1135 }
1224 1136
1225 /* Set interrupt mask */
1226 sc->sc_imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS);
1227 ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_imask & ~ATH9K_INT_GLOBAL);
1228 sc->sc_flags &= ~SC_OP_BEACONS; 1137 sc->sc_flags &= ~SC_OP_BEACONS;
1229 1138
1230 error = ath_vap_detach(sc, 0); 1139 sc->sc_vaps[0] = NULL;
1231 if (error) 1140 sc->sc_nvaps--;
1232 DPRINTF(sc, ATH_DBG_FATAL,
1233 "%s: Unable to detach vap, error: %d\n",
1234 __func__, error);
1235} 1141}
1236 1142
1237static int ath9k_config(struct ieee80211_hw *hw, 1143static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1238 struct ieee80211_conf *conf)
1239{ 1144{
1240 struct ath_softc *sc = hw->priv; 1145 struct ath_softc *sc = hw->priv;
1241 struct ieee80211_channel *curchan = hw->conf.channel; 1146 struct ieee80211_channel *curchan = hw->conf.channel;
1147 struct ieee80211_conf *conf = &hw->conf;
1242 int pos; 1148 int pos;
1243 1149
1244 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n", 1150 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n",
1245 __func__, 1151 __func__,
1246 curchan->center_freq); 1152 curchan->center_freq);
1247 1153
1154 /* Update chainmask */
1155 ath_update_chainmask(sc, conf->ht.enabled);
1156
1248 pos = ath_get_channel(sc, curchan); 1157 pos = ath_get_channel(sc, curchan);
1249 if (pos == -1) { 1158 if (pos == -1) {
1250 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid channel\n", __func__); 1159 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid channel\n", __func__);
@@ -1255,11 +1164,12 @@ static int ath9k_config(struct ieee80211_hw *hw,
1255 (curchan->band == IEEE80211_BAND_2GHZ) ? 1164 (curchan->band == IEEE80211_BAND_2GHZ) ?
1256 CHANNEL_G : CHANNEL_A; 1165 CHANNEL_G : CHANNEL_A;
1257 1166
1258 if (sc->sc_curaid && hw->conf.ht_conf.ht_supported) 1167 if (sc->sc_curaid && hw->conf.ht.enabled)
1259 sc->sc_ah->ah_channels[pos].chanmode = 1168 sc->sc_ah->ah_channels[pos].chanmode =
1260 ath_get_extchanmode(sc, curchan); 1169 ath_get_extchanmode(sc, curchan);
1261 1170
1262 sc->sc_config.txpowlimit = 2 * conf->power_level; 1171 if (changed & IEEE80211_CONF_CHANGE_POWER)
1172 sc->sc_config.txpowlimit = 2 * conf->power_level;
1263 1173
1264 /* set h/w channel */ 1174 /* set h/w channel */
1265 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0) 1175 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0)
@@ -1275,17 +1185,9 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
1275{ 1185{
1276 struct ath_softc *sc = hw->priv; 1186 struct ath_softc *sc = hw->priv;
1277 struct ath_hal *ah = sc->sc_ah; 1187 struct ath_hal *ah = sc->sc_ah;
1278 struct ath_vap *avp; 1188 struct ath_vap *avp = (void *)vif->drv_priv;
1279 u32 rfilt = 0; 1189 u32 rfilt = 0;
1280 int error, i; 1190 int error, i;
1281 DECLARE_MAC_BUF(mac);
1282
1283 avp = sc->sc_vaps[0];
1284 if (avp == NULL) {
1285 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
1286 __func__);
1287 return -EINVAL;
1288 }
1289 1191
1290 /* TODO: Need to decide which hw opmode to use for multi-interface 1192 /* TODO: Need to decide which hw opmode to use for multi-interface
1291 * cases */ 1193 * cases */
@@ -1315,27 +1217,10 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
1315 /* Set aggregation protection mode parameters */ 1217 /* Set aggregation protection mode parameters */
1316 sc->sc_config.ath_aggr_prot = 0; 1218 sc->sc_config.ath_aggr_prot = 0;
1317 1219
1318 /*
1319 * Reset our TSF so that its value is lower than the
1320 * beacon that we are trying to catch.
1321 * Only then hw will update its TSF register with the
1322 * new beacon. Reset the TSF before setting the BSSID
1323 * to avoid allowing in any frames that would update
1324 * our TSF only to have us clear it
1325 * immediately thereafter.
1326 */
1327 ath9k_hw_reset_tsf(sc->sc_ah);
1328
1329 /* Disable BMISS interrupt when we're not associated */
1330 ath9k_hw_set_interrupts(sc->sc_ah,
1331 sc->sc_imask &
1332 ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS));
1333 sc->sc_imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS);
1334
1335 DPRINTF(sc, ATH_DBG_CONFIG, 1220 DPRINTF(sc, ATH_DBG_CONFIG,
1336 "%s: RX filter 0x%x bssid %s aid 0x%x\n", 1221 "%s: RX filter 0x%x bssid %pM aid 0x%x\n",
1337 __func__, rfilt, 1222 __func__, rfilt,
1338 print_mac(mac, sc->sc_curbssid), sc->sc_curaid); 1223 sc->sc_curbssid, sc->sc_curaid);
1339 1224
1340 /* need to reconfigure the beacon */ 1225 /* need to reconfigure the beacon */
1341 sc->sc_flags &= ~SC_OP_BEACONS ; 1226 sc->sc_flags &= ~SC_OP_BEACONS ;
@@ -1367,7 +1252,7 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
1367 } 1252 }
1368 1253
1369 /* Check for WLAN_CAPABILITY_PRIVACY ? */ 1254 /* Check for WLAN_CAPABILITY_PRIVACY ? */
1370 if ((avp->av_opmode != NL80211_IFTYPE_STATION)) { 1255 if ((avp->av_opmode != ATH9K_M_STA)) {
1371 for (i = 0; i < IEEE80211_WEP_NKID; i++) 1256 for (i = 0; i < IEEE80211_WEP_NKID; i++)
1372 if (ath9k_hw_keyisvalid(sc->sc_ah, (u16)i)) 1257 if (ath9k_hw_keyisvalid(sc->sc_ah, (u16)i))
1373 ath9k_hw_keysetmac(sc->sc_ah, 1258 ath9k_hw_keysetmac(sc->sc_ah,
@@ -1422,37 +1307,13 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
1422 struct ieee80211_sta *sta) 1307 struct ieee80211_sta *sta)
1423{ 1308{
1424 struct ath_softc *sc = hw->priv; 1309 struct ath_softc *sc = hw->priv;
1425 struct ath_node *an;
1426 unsigned long flags;
1427 DECLARE_MAC_BUF(mac);
1428
1429 spin_lock_irqsave(&sc->node_lock, flags);
1430 an = ath_node_find(sc, sta->addr);
1431 spin_unlock_irqrestore(&sc->node_lock, flags);
1432 1310
1433 switch (cmd) { 1311 switch (cmd) {
1434 case STA_NOTIFY_ADD: 1312 case STA_NOTIFY_ADD:
1435 spin_lock_irqsave(&sc->node_lock, flags); 1313 ath_node_attach(sc, sta);
1436 if (!an) {
1437 ath_node_attach(sc, sta->addr, 0);
1438 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach a node: %s\n",
1439 __func__, print_mac(mac, sta->addr));
1440 } else {
1441 ath_node_get(sc, sta->addr);
1442 }
1443 spin_unlock_irqrestore(&sc->node_lock, flags);
1444 break; 1314 break;
1445 case STA_NOTIFY_REMOVE: 1315 case STA_NOTIFY_REMOVE:
1446 if (!an) 1316 ath_node_detach(sc, sta);
1447 DPRINTF(sc, ATH_DBG_FATAL,
1448 "%s: Removal of a non-existent node\n",
1449 __func__);
1450 else {
1451 ath_node_put(sc, an, ATH9K_BH_STATUS_INTACT);
1452 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Put a node: %s\n",
1453 __func__,
1454 print_mac(mac, sta->addr));
1455 }
1456 break; 1317 break;
1457 default: 1318 default:
1458 break; 1319 break;
@@ -1558,9 +1419,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1558 } 1419 }
1559 1420
1560 if (changed & BSS_CHANGED_HT) { 1421 if (changed & BSS_CHANGED_HT) {
1561 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed HT %d\n", 1422 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed HT\n",
1562 __func__, 1423 __func__);
1563 bss_conf->assoc_ht);
1564 ath9k_ht_conf(sc, bss_conf); 1424 ath9k_ht_conf(sc, bss_conf);
1565 } 1425 }
1566 1426
@@ -1568,7 +1428,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1568 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed ASSOC %d\n", 1428 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed ASSOC %d\n",
1569 __func__, 1429 __func__,
1570 bss_conf->assoc); 1430 bss_conf->assoc);
1571 ath9k_bss_assoc_info(sc, bss_conf); 1431 ath9k_bss_assoc_info(sc, vif, bss_conf);
1572 } 1432 }
1573} 1433}
1574 1434
@@ -1601,21 +1461,13 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
1601 1461
1602 switch (action) { 1462 switch (action) {
1603 case IEEE80211_AMPDU_RX_START: 1463 case IEEE80211_AMPDU_RX_START:
1604 ret = ath_rx_aggr_start(sc, sta->addr, tid, ssn); 1464 if (!(sc->sc_flags & SC_OP_RXAGGR))
1605 if (ret < 0) 1465 ret = -ENOTSUPP;
1606 DPRINTF(sc, ATH_DBG_FATAL,
1607 "%s: Unable to start RX aggregation\n",
1608 __func__);
1609 break; 1466 break;
1610 case IEEE80211_AMPDU_RX_STOP: 1467 case IEEE80211_AMPDU_RX_STOP:
1611 ret = ath_rx_aggr_stop(sc, sta->addr, tid);
1612 if (ret < 0)
1613 DPRINTF(sc, ATH_DBG_FATAL,
1614 "%s: Unable to stop RX aggregation\n",
1615 __func__);
1616 break; 1468 break;
1617 case IEEE80211_AMPDU_TX_START: 1469 case IEEE80211_AMPDU_TX_START:
1618 ret = ath_tx_aggr_start(sc, sta->addr, tid, ssn); 1470 ret = ath_tx_aggr_start(sc, sta, tid, ssn);
1619 if (ret < 0) 1471 if (ret < 0)
1620 DPRINTF(sc, ATH_DBG_FATAL, 1472 DPRINTF(sc, ATH_DBG_FATAL,
1621 "%s: Unable to start TX aggregation\n", 1473 "%s: Unable to start TX aggregation\n",
@@ -1624,7 +1476,7 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
1624 ieee80211_start_tx_ba_cb_irqsafe(hw, sta->addr, tid); 1476 ieee80211_start_tx_ba_cb_irqsafe(hw, sta->addr, tid);
1625 break; 1477 break;
1626 case IEEE80211_AMPDU_TX_STOP: 1478 case IEEE80211_AMPDU_TX_STOP:
1627 ret = ath_tx_aggr_stop(sc, sta->addr, tid); 1479 ret = ath_tx_aggr_stop(sc, sta, tid);
1628 if (ret < 0) 1480 if (ret < 0)
1629 DPRINTF(sc, ATH_DBG_FATAL, 1481 DPRINTF(sc, ATH_DBG_FATAL,
1630 "%s: Unable to stop TX aggregation\n", 1482 "%s: Unable to stop TX aggregation\n",
@@ -1632,6 +1484,9 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
1632 1484
1633 ieee80211_stop_tx_ba_cb_irqsafe(hw, sta->addr, tid); 1485 ieee80211_stop_tx_ba_cb_irqsafe(hw, sta->addr, tid);
1634 break; 1486 break;
1487 case IEEE80211_AMPDU_TX_RESUME:
1488 ath_tx_aggr_resume(sc, sta, tid);
1489 break;
1635 default: 1490 default:
1636 DPRINTF(sc, ATH_DBG_FATAL, 1491 DPRINTF(sc, ATH_DBG_FATAL,
1637 "%s: Unknown AMPDU action\n", __func__); 1492 "%s: Unknown AMPDU action\n", __func__);
@@ -1654,21 +1509,12 @@ static struct ieee80211_ops ath9k_ops = {
1654 .config = ath9k_config, 1509 .config = ath9k_config,
1655 .config_interface = ath9k_config_interface, 1510 .config_interface = ath9k_config_interface,
1656 .configure_filter = ath9k_configure_filter, 1511 .configure_filter = ath9k_configure_filter,
1657 .get_stats = NULL,
1658 .sta_notify = ath9k_sta_notify, 1512 .sta_notify = ath9k_sta_notify,
1659 .conf_tx = ath9k_conf_tx, 1513 .conf_tx = ath9k_conf_tx,
1660 .get_tx_stats = NULL,
1661 .bss_info_changed = ath9k_bss_info_changed, 1514 .bss_info_changed = ath9k_bss_info_changed,
1662 .set_tim = NULL,
1663 .set_key = ath9k_set_key, 1515 .set_key = ath9k_set_key,
1664 .hw_scan = NULL,
1665 .get_tkip_seq = NULL,
1666 .set_rts_threshold = NULL,
1667 .set_frag_threshold = NULL,
1668 .set_retry_limit = NULL,
1669 .get_tsf = ath9k_get_tsf, 1516 .get_tsf = ath9k_get_tsf,
1670 .reset_tsf = ath9k_reset_tsf, 1517 .reset_tsf = ath9k_reset_tsf,
1671 .tx_last_beacon = NULL,
1672 .ampdu_action = ath9k_ampdu_action, 1518 .ampdu_action = ath9k_ampdu_action,
1673 .set_frag_threshold = ath9k_no_fragmentation, 1519 .set_frag_threshold = ath9k_no_fragmentation,
1674}; 1520};
@@ -1746,16 +1592,6 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1746 goto bad2; 1592 goto bad2;
1747 } 1593 }
1748 1594
1749 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
1750 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1751 IEEE80211_HW_SIGNAL_DBM |
1752 IEEE80211_HW_NOISE_DBM;
1753
1754 hw->wiphy->interface_modes =
1755 BIT(NL80211_IFTYPE_AP) |
1756 BIT(NL80211_IFTYPE_STATION) |
1757 BIT(NL80211_IFTYPE_ADHOC);
1758
1759 SET_IEEE80211_DEV(hw, &pdev->dev); 1595 SET_IEEE80211_DEV(hw, &pdev->dev);
1760 pci_set_drvdata(pdev, hw); 1596 pci_set_drvdata(pdev, hw);
1761 1597
@@ -1803,17 +1639,10 @@ static void ath_pci_remove(struct pci_dev *pdev)
1803{ 1639{
1804 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 1640 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1805 struct ath_softc *sc = hw->priv; 1641 struct ath_softc *sc = hw->priv;
1806 enum ath9k_int status;
1807 1642
1808 if (pdev->irq) {
1809 ath9k_hw_set_interrupts(sc->sc_ah, 0);
1810 /* clear the ISR */
1811 ath9k_hw_getisr(sc->sc_ah, &status);
1812 sc->sc_flags |= SC_OP_INVALID;
1813 free_irq(pdev->irq, sc);
1814 }
1815 ath_detach(sc); 1643 ath_detach(sc);
1816 1644 if (pdev->irq)
1645 free_irq(pdev->irq, sc);
1817 pci_iounmap(pdev, sc->mem); 1646 pci_iounmap(pdev, sc->mem);
1818 pci_release_region(pdev, 0); 1647 pci_release_region(pdev, 0);
1819 pci_disable_device(pdev); 1648 pci_disable_device(pdev);
diff --git a/drivers/net/wireless/ath9k/phy.c b/drivers/net/wireless/ath9k/phy.c
index eb9121fdfd38..4f1c8bf8342b 100644
--- a/drivers/net/wireless/ath9k/phy.c
+++ b/drivers/net/wireless/ath9k/phy.c
@@ -215,7 +215,7 @@ ath9k_hw_set_rf_regs(struct ath_hal *ah, struct ath9k_channel *chan,
215 if (AR_SREV_9280_10_OR_LATER(ah)) 215 if (AR_SREV_9280_10_OR_LATER(ah))
216 return true; 216 return true;
217 217
218 eepMinorRev = ath9k_hw_get_eeprom(ahp, EEP_MINOR_REV); 218 eepMinorRev = ath9k_hw_get_eeprom(ah, EEP_MINOR_REV);
219 219
220 RF_BANK_SETUP(ahp->ah_analogBank0Data, &ahp->ah_iniBank0, 1); 220 RF_BANK_SETUP(ahp->ah_analogBank0Data, &ahp->ah_iniBank0, 1);
221 221
@@ -235,15 +235,15 @@ ath9k_hw_set_rf_regs(struct ath_hal *ah, struct ath9k_channel *chan,
235 235
236 if (eepMinorRev >= 2) { 236 if (eepMinorRev >= 2) {
237 if (IS_CHAN_2GHZ(chan)) { 237 if (IS_CHAN_2GHZ(chan)) {
238 ob2GHz = ath9k_hw_get_eeprom(ahp, EEP_OB_2); 238 ob2GHz = ath9k_hw_get_eeprom(ah, EEP_OB_2);
239 db2GHz = ath9k_hw_get_eeprom(ahp, EEP_DB_2); 239 db2GHz = ath9k_hw_get_eeprom(ah, EEP_DB_2);
240 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data, 240 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data,
241 ob2GHz, 3, 197, 0); 241 ob2GHz, 3, 197, 0);
242 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data, 242 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data,
243 db2GHz, 3, 194, 0); 243 db2GHz, 3, 194, 0);
244 } else { 244 } else {
245 ob5GHz = ath9k_hw_get_eeprom(ahp, EEP_OB_5); 245 ob5GHz = ath9k_hw_get_eeprom(ah, EEP_OB_5);
246 db5GHz = ath9k_hw_get_eeprom(ahp, EEP_DB_5); 246 db5GHz = ath9k_hw_get_eeprom(ah, EEP_DB_5);
247 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data, 247 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data,
248 ob5GHz, 3, 203, 0); 248 ob5GHz, 3, 203, 0);
249 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data, 249 ath9k_phy_modify_rx_buffer(ahp->ah_analogBank6Data,
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index cca2fc5b0765..aa6bfd717c20 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -816,7 +816,7 @@ void ath_rate_detach(struct ath_rate_softc *asc)
816} 816}
817 817
818u8 ath_rate_findrateix(struct ath_softc *sc, 818u8 ath_rate_findrateix(struct ath_softc *sc,
819 u8 dot11rate) 819 u8 dot11rate)
820{ 820{
821 const struct ath_rate_table *ratetable; 821 const struct ath_rate_table *ratetable;
822 struct ath_rate_softc *rsc = sc->sc_rc; 822 struct ath_rate_softc *rsc = sc->sc_rc;
@@ -1838,7 +1838,7 @@ void ath_rc_node_update(struct ieee80211_hw *hw, struct ath_rate_node *rc_priv)
1838 struct ath_softc *sc = hw->priv; 1838 struct ath_softc *sc = hw->priv;
1839 u32 capflag = 0; 1839 u32 capflag = 0;
1840 1840
1841 if (hw->conf.ht_conf.ht_supported) { 1841 if (hw->conf.ht.enabled) {
1842 capflag |= ATH_RC_HT_FLAG | ATH_RC_DS_FLAG; 1842 capflag |= ATH_RC_HT_FLAG | ATH_RC_DS_FLAG;
1843 if (sc->sc_ht_info.tx_chan_width == ATH9K_HT_MACMODE_2040) 1843 if (sc->sc_ht_info.tx_chan_width == ATH9K_HT_MACMODE_2040)
1844 capflag |= ATH_RC_CW40_FLAG; 1844 capflag |= ATH_RC_CW40_FLAG;
@@ -1864,73 +1864,26 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1864 1864
1865 hdr = (struct ieee80211_hdr *)skb->data; 1865 hdr = (struct ieee80211_hdr *)skb->data;
1866 fc = hdr->frame_control; 1866 fc = hdr->frame_control;
1867 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 1867 /* XXX: UGLY HACK!! */
1868 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1868 1869
1869 spin_lock_bh(&sc->node_lock); 1870 an = (struct ath_node *)sta->drv_priv;
1870 an = ath_node_find(sc, hdr->addr1);
1871 spin_unlock_bh(&sc->node_lock);
1872 1871
1873 if (!an || !priv_sta || !ieee80211_is_data(fc)) { 1872 if (tx_info_priv == NULL)
1874 if (tx_info->driver_data[0] != NULL) {
1875 kfree(tx_info->driver_data[0]);
1876 tx_info->driver_data[0] = NULL;
1877 }
1878 return; 1873 return;
1879 }
1880 if (tx_info->driver_data[0] != NULL) {
1881 ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv);
1882 kfree(tx_info->driver_data[0]);
1883 tx_info->driver_data[0] = NULL;
1884 }
1885}
1886
1887static void ath_tx_aggr_resp(struct ath_softc *sc,
1888 struct ieee80211_supported_band *sband,
1889 struct ieee80211_sta *sta,
1890 struct ath_node *an,
1891 u8 tidno)
1892{
1893 struct ath_atx_tid *txtid;
1894 u16 buffersize = 0;
1895 int state;
1896 struct sta_info *si;
1897 1874
1898 if (!(sc->sc_flags & SC_OP_TXAGGR)) 1875 if (an && priv_sta && ieee80211_is_data(fc))
1899 return; 1876 ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv);
1900
1901 txtid = ATH_AN_2_TID(an, tidno);
1902 if (!txtid->paused)
1903 return;
1904 1877
1905 /* 1878 kfree(tx_info_priv);
1906 * XXX: This is entirely busted, we aren't supposed to 1879 tx_info->control.vif = NULL;
1907 * access the sta from here because it's internal
1908 * to mac80211, and looking at the state without
1909 * locking is wrong too.
1910 */
1911 si = container_of(sta, struct sta_info, sta);
1912 buffersize = IEEE80211_MIN_AMPDU_BUF <<
1913 sband->ht_info.ampdu_factor; /* FIXME */
1914 state = si->ampdu_mlme.tid_state_tx[tidno];
1915
1916 if (state & HT_ADDBA_RECEIVED_MSK) {
1917 txtid->addba_exchangecomplete = 1;
1918 txtid->addba_exchangeinprogress = 0;
1919 txtid->baw_size = buffersize;
1920
1921 DPRINTF(sc, ATH_DBG_AGGR,
1922 "%s: Resuming tid, buffersize: %d\n",
1923 __func__,
1924 buffersize);
1925
1926 ath_tx_resume_tid(sc, txtid);
1927 }
1928} 1880}
1929 1881
1930static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband, 1882static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
1931 struct ieee80211_sta *sta, void *priv_sta, 1883 struct ieee80211_tx_rate_control *txrc)
1932 struct sk_buff *skb, struct rate_selection *sel)
1933{ 1884{
1885 struct ieee80211_supported_band *sband = txrc->sband;
1886 struct sk_buff *skb = txrc->skb;
1934 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1887 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1935 struct ath_softc *sc = priv; 1888 struct ath_softc *sc = priv;
1936 struct ieee80211_hw *hw = sc->hw; 1889 struct ieee80211_hw *hw = sc->hw;
@@ -1938,25 +1891,24 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
1938 struct ath_rate_node *ath_rc_priv = priv_sta; 1891 struct ath_rate_node *ath_rc_priv = priv_sta;
1939 struct ath_node *an; 1892 struct ath_node *an;
1940 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1893 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1941 int is_probe = FALSE, chk, ret; 1894 int is_probe = FALSE;
1942 s8 lowest_idx; 1895 s8 lowest_idx;
1943 __le16 fc = hdr->frame_control; 1896 __le16 fc = hdr->frame_control;
1944 u8 *qc, tid; 1897 u8 *qc, tid;
1945 DECLARE_MAC_BUF(mac);
1946 1898
1947 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 1899 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
1948 1900
1949 /* allocate driver private area of tx_info */ 1901 /* allocate driver private area of tx_info, XXX: UGLY HACK! */
1950 tx_info->driver_data[0] = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC); 1902 tx_info->control.vif = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
1951 ASSERT(tx_info->driver_data[0] != NULL); 1903 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1952 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 1904 ASSERT(tx_info_priv != NULL);
1953 1905
1954 lowest_idx = rate_lowest_index(sband, sta); 1906 lowest_idx = rate_lowest_index(sband, sta);
1955 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10; 1907 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10;
1956 /* lowest rate for management and multicast/broadcast frames */ 1908 /* lowest rate for management and multicast/broadcast frames */
1957 if (!ieee80211_is_data(fc) || 1909 if (!ieee80211_is_data(fc) ||
1958 is_multicast_ether_addr(hdr->addr1) || !sta) { 1910 is_multicast_ether_addr(hdr->addr1) || !sta) {
1959 sel->rate_idx = lowest_idx; 1911 tx_info->control.rates[0].idx = lowest_idx;
1960 return; 1912 return;
1961 } 1913 }
1962 1914
@@ -1967,8 +1919,10 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
1967 tx_info_priv->rcs, 1919 tx_info_priv->rcs,
1968 &is_probe, 1920 &is_probe,
1969 false); 1921 false);
1922#if 0
1970 if (is_probe) 1923 if (is_probe)
1971 sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate; 1924 sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate;
1925#endif
1972 1926
1973 /* Ratecontrol sometimes returns invalid rate index */ 1927 /* Ratecontrol sometimes returns invalid rate index */
1974 if (tx_info_priv->rcs[0].rix != 0xff) 1928 if (tx_info_priv->rcs[0].rix != 0xff)
@@ -1976,43 +1930,18 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
1976 else 1930 else
1977 tx_info_priv->rcs[0].rix = ath_rc_priv->prev_data_rix; 1931 tx_info_priv->rcs[0].rix = ath_rc_priv->prev_data_rix;
1978 1932
1979 sel->rate_idx = tx_info_priv->rcs[0].rix; 1933 tx_info->control.rates[0].idx = tx_info_priv->rcs[0].rix;
1980 1934
1981 /* Check if aggregation has to be enabled for this tid */ 1935 /* Check if aggregation has to be enabled for this tid */
1982 1936
1983 if (hw->conf.ht_conf.ht_supported) { 1937 if (hw->conf.ht.enabled) {
1984 if (ieee80211_is_data_qos(fc)) { 1938 if (ieee80211_is_data_qos(fc)) {
1985 qc = ieee80211_get_qos_ctl(hdr); 1939 qc = ieee80211_get_qos_ctl(hdr);
1986 tid = qc[0] & 0xf; 1940 tid = qc[0] & 0xf;
1941 an = (struct ath_node *)sta->drv_priv;
1987 1942
1988 spin_lock_bh(&sc->node_lock); 1943 if(ath_tx_aggr_check(sc, an, tid))
1989 an = ath_node_find(sc, hdr->addr1); 1944 ieee80211_start_tx_ba_session(hw, hdr->addr1, tid);
1990 spin_unlock_bh(&sc->node_lock);
1991
1992 if (!an) {
1993 DPRINTF(sc, ATH_DBG_AGGR,
1994 "%s: Node not found to "
1995 "init/chk TX aggr\n", __func__);
1996 return;
1997 }
1998
1999 chk = ath_tx_aggr_check(sc, an, tid);
2000 if (chk == AGGR_REQUIRED) {
2001 ret = ieee80211_start_tx_ba_session(hw,
2002 hdr->addr1, tid);
2003 if (ret)
2004 DPRINTF(sc, ATH_DBG_AGGR,
2005 "%s: Unable to start tx "
2006 "aggr for: %s\n",
2007 __func__,
2008 print_mac(mac, hdr->addr1));
2009 else
2010 DPRINTF(sc, ATH_DBG_AGGR,
2011 "%s: Started tx aggr for: %s\n",
2012 __func__,
2013 print_mac(mac, hdr->addr1));
2014 } else if (chk == AGGR_EXCHANGE_PROGRESS)
2015 ath_tx_aggr_resp(sc, sband, sta, an, tid);
2016 } 1945 }
2017 } 1946 }
2018} 1947}
@@ -2027,9 +1956,9 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
2027 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 1956 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
2028 1957
2029 ath_setup_rates(sc, sband, sta, ath_rc_priv); 1958 ath_setup_rates(sc, sband, sta, ath_rc_priv);
2030 if (sc->hw->conf.flags & IEEE80211_CONF_SUPPORT_HT_MODE) { 1959 if (sta->ht_cap.ht_supported) {
2031 for (i = 0; i < MCS_SET_SIZE; i++) { 1960 for (i = 0; i < 77; i++) {
2032 if (sc->hw->conf.ht_conf.supp_mcs_set[i/8] & (1<<(i%8))) 1961 if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
2033 ath_rc_priv->neg_ht_rates.rs_rates[j++] = i; 1962 ath_rc_priv->neg_ht_rates.rs_rates[j++] = i;
2034 if (j == ATH_RATE_MAX) 1963 if (j == ATH_RATE_MAX)
2035 break; 1964 break;
@@ -2039,11 +1968,6 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
2039 ath_rc_node_update(sc->hw, priv_sta); 1968 ath_rc_node_update(sc->hw, priv_sta);
2040} 1969}
2041 1970
2042static void ath_rate_clear(void *priv)
2043{
2044 return;
2045}
2046
2047static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) 1971static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
2048{ 1972{
2049 struct ath_softc *sc = hw->priv; 1973 struct ath_softc *sc = hw->priv;
@@ -2059,12 +1983,18 @@ static void ath_rate_free(void *priv)
2059 1983
2060static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) 1984static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
2061{ 1985{
1986 struct ieee80211_vif *vif;
2062 struct ath_softc *sc = priv; 1987 struct ath_softc *sc = priv;
2063 struct ath_vap *avp = sc->sc_vaps[0]; 1988 struct ath_vap *avp;
2064 struct ath_rate_node *rate_priv; 1989 struct ath_rate_node *rate_priv;
2065 1990
2066 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 1991 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
2067 1992
1993 vif = sc->sc_vaps[0];
1994 ASSERT(vif);
1995
1996 avp = (void *)vif->drv_priv;
1997
2068 rate_priv = ath_rate_node_alloc(avp, sc->sc_rc, gfp); 1998 rate_priv = ath_rate_node_alloc(avp, sc->sc_rc, gfp);
2069 if (!rate_priv) { 1999 if (!rate_priv) {
2070 DPRINTF(sc, ATH_DBG_FATAL, 2000 DPRINTF(sc, ATH_DBG_FATAL,
@@ -2093,7 +2023,6 @@ static struct rate_control_ops ath_rate_ops = {
2093 .tx_status = ath_tx_status, 2023 .tx_status = ath_tx_status,
2094 .get_rate = ath_get_rate, 2024 .get_rate = ath_get_rate,
2095 .rate_init = ath_rate_init, 2025 .rate_init = ath_rate_init,
2096 .clear = ath_rate_clear,
2097 .alloc = ath_rate_alloc, 2026 .alloc = ath_rate_alloc,
2098 .free = ath_rate_free, 2027 .free = ath_rate_free,
2099 .alloc_sta = ath_rate_alloc_sta, 2028 .alloc_sta = ath_rate_alloc_sta,
diff --git a/drivers/net/wireless/ath9k/rc.h b/drivers/net/wireless/ath9k/rc.h
index b95b41508b98..6671097fad72 100644
--- a/drivers/net/wireless/ath9k/rc.h
+++ b/drivers/net/wireless/ath9k/rc.h
@@ -59,7 +59,6 @@ struct ath_softc;
59#define FALSE 0 59#define FALSE 0
60 60
61#define ATH_RATE_MAX 30 61#define ATH_RATE_MAX 30
62#define MCS_SET_SIZE 128
63 62
64enum ieee80211_fixed_rate_mode { 63enum ieee80211_fixed_rate_mode {
65 IEEE80211_FIXED_RATE_NONE = 0, 64 IEEE80211_FIXED_RATE_NONE = 0,
diff --git a/drivers/net/wireless/ath9k/recv.c b/drivers/net/wireless/ath9k/recv.c
index 4983402af559..2ecb0a010ce2 100644
--- a/drivers/net/wireless/ath9k/recv.c
+++ b/drivers/net/wireless/ath9k/recv.c
@@ -64,328 +64,6 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
64 ath9k_hw_rxena(ah); 64 ath9k_hw_rxena(ah);
65} 65}
66 66
67/* Process received BAR frame */
68
69static int ath_bar_rx(struct ath_softc *sc,
70 struct ath_node *an,
71 struct sk_buff *skb)
72{
73 struct ieee80211_bar *bar;
74 struct ath_arx_tid *rxtid;
75 struct sk_buff *tskb;
76 struct ath_recv_status *rx_status;
77 int tidno, index, cindex;
78 u16 seqno;
79
80 /* look at BAR contents */
81
82 bar = (struct ieee80211_bar *)skb->data;
83 tidno = (le16_to_cpu(bar->control) & IEEE80211_BAR_CTL_TID_M)
84 >> IEEE80211_BAR_CTL_TID_S;
85 seqno = le16_to_cpu(bar->start_seq_num) >> IEEE80211_SEQ_SEQ_SHIFT;
86
87 /* process BAR - indicate all pending RX frames till the BAR seqno */
88
89 rxtid = &an->an_aggr.rx.tid[tidno];
90
91 spin_lock_bh(&rxtid->tidlock);
92
93 /* get relative index */
94
95 index = ATH_BA_INDEX(rxtid->seq_next, seqno);
96
97 /* drop BAR if old sequence (index is too large) */
98
99 if ((index > rxtid->baw_size) &&
100 (index > (IEEE80211_SEQ_MAX - (rxtid->baw_size << 2))))
101 /* discard frame, ieee layer may not treat frame as a dup */
102 goto unlock_and_free;
103
104 /* complete receive processing for all pending frames upto BAR seqno */
105
106 cindex = (rxtid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
107 while ((rxtid->baw_head != rxtid->baw_tail) &&
108 (rxtid->baw_head != cindex)) {
109 tskb = rxtid->rxbuf[rxtid->baw_head].rx_wbuf;
110 rx_status = &rxtid->rxbuf[rxtid->baw_head].rx_status;
111 rxtid->rxbuf[rxtid->baw_head].rx_wbuf = NULL;
112
113 if (tskb != NULL)
114 ath_rx_subframe(an, tskb, rx_status);
115
116 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
117 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
118 }
119
120 /* ... and indicate rest of the frames in-order */
121
122 while (rxtid->baw_head != rxtid->baw_tail &&
123 rxtid->rxbuf[rxtid->baw_head].rx_wbuf != NULL) {
124 tskb = rxtid->rxbuf[rxtid->baw_head].rx_wbuf;
125 rx_status = &rxtid->rxbuf[rxtid->baw_head].rx_status;
126 rxtid->rxbuf[rxtid->baw_head].rx_wbuf = NULL;
127
128 ath_rx_subframe(an, tskb, rx_status);
129
130 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
131 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
132 }
133
134unlock_and_free:
135 spin_unlock_bh(&rxtid->tidlock);
136 /* free bar itself */
137 dev_kfree_skb(skb);
138 return IEEE80211_FTYPE_CTL;
139}
140
141/* Function to handle a subframe of aggregation when HT is enabled */
142
143static int ath_ampdu_input(struct ath_softc *sc,
144 struct ath_node *an,
145 struct sk_buff *skb,
146 struct ath_recv_status *rx_status)
147{
148 struct ieee80211_hdr *hdr;
149 struct ath_arx_tid *rxtid;
150 struct ath_rxbuf *rxbuf;
151 u8 type, subtype;
152 u16 rxseq;
153 int tid = 0, index, cindex, rxdiff;
154 __le16 fc;
155 u8 *qc;
156
157 hdr = (struct ieee80211_hdr *)skb->data;
158 fc = hdr->frame_control;
159
160 /* collect stats of frames with non-zero version */
161
162 if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_VERS) != 0) {
163 dev_kfree_skb(skb);
164 return -1;
165 }
166
167 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
168 subtype = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE;
169
170 if (ieee80211_is_back_req(fc))
171 return ath_bar_rx(sc, an, skb);
172
173 /* special aggregate processing only for qos unicast data frames */
174
175 if (!ieee80211_is_data(fc) ||
176 !ieee80211_is_data_qos(fc) ||
177 is_multicast_ether_addr(hdr->addr1))
178 return ath_rx_subframe(an, skb, rx_status);
179
180 /* lookup rx tid state */
181
182 if (ieee80211_is_data_qos(fc)) {
183 qc = ieee80211_get_qos_ctl(hdr);
184 tid = qc[0] & 0xf;
185 }
186
187 if (sc->sc_ah->ah_opmode == ATH9K_M_STA) {
188 /* Drop the frame not belonging to me. */
189 if (memcmp(hdr->addr1, sc->sc_myaddr, ETH_ALEN)) {
190 dev_kfree_skb(skb);
191 return -1;
192 }
193 }
194
195 rxtid = &an->an_aggr.rx.tid[tid];
196
197 spin_lock(&rxtid->tidlock);
198
199 rxdiff = (rxtid->baw_tail - rxtid->baw_head) &
200 (ATH_TID_MAX_BUFS - 1);
201
202 /*
203 * If the ADDBA exchange has not been completed by the source,
204 * process via legacy path (i.e. no reordering buffer is needed)
205 */
206 if (!rxtid->addba_exchangecomplete) {
207 spin_unlock(&rxtid->tidlock);
208 return ath_rx_subframe(an, skb, rx_status);
209 }
210
211 /* extract sequence number from recvd frame */
212
213 rxseq = le16_to_cpu(hdr->seq_ctrl) >> IEEE80211_SEQ_SEQ_SHIFT;
214
215 if (rxtid->seq_reset) {
216 rxtid->seq_reset = 0;
217 rxtid->seq_next = rxseq;
218 }
219
220 index = ATH_BA_INDEX(rxtid->seq_next, rxseq);
221
222 /* drop frame if old sequence (index is too large) */
223
224 if (index > (IEEE80211_SEQ_MAX - (rxtid->baw_size << 2))) {
225 /* discard frame, ieee layer may not treat frame as a dup */
226 spin_unlock(&rxtid->tidlock);
227 dev_kfree_skb(skb);
228 return IEEE80211_FTYPE_DATA;
229 }
230
231 /* sequence number is beyond block-ack window */
232
233 if (index >= rxtid->baw_size) {
234
235 /* complete receive processing for all pending frames */
236
237 while (index >= rxtid->baw_size) {
238
239 rxbuf = rxtid->rxbuf + rxtid->baw_head;
240
241 if (rxbuf->rx_wbuf != NULL) {
242 ath_rx_subframe(an, rxbuf->rx_wbuf,
243 &rxbuf->rx_status);
244 rxbuf->rx_wbuf = NULL;
245 }
246
247 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
248 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
249
250 index--;
251 }
252 }
253
254 /* add buffer to the recv ba window */
255
256 cindex = (rxtid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
257 rxbuf = rxtid->rxbuf + cindex;
258
259 if (rxbuf->rx_wbuf != NULL) {
260 spin_unlock(&rxtid->tidlock);
261 /* duplicate frame */
262 dev_kfree_skb(skb);
263 return IEEE80211_FTYPE_DATA;
264 }
265
266 rxbuf->rx_wbuf = skb;
267 rxbuf->rx_time = get_timestamp();
268 rxbuf->rx_status = *rx_status;
269
270 /* advance tail if sequence received is newer
271 * than any received so far */
272
273 if (index >= rxdiff) {
274 rxtid->baw_tail = cindex;
275 INCR(rxtid->baw_tail, ATH_TID_MAX_BUFS);
276 }
277
278 /* indicate all in-order received frames */
279
280 while (rxtid->baw_head != rxtid->baw_tail) {
281 rxbuf = rxtid->rxbuf + rxtid->baw_head;
282 if (!rxbuf->rx_wbuf)
283 break;
284
285 ath_rx_subframe(an, rxbuf->rx_wbuf, &rxbuf->rx_status);
286 rxbuf->rx_wbuf = NULL;
287
288 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
289 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
290 }
291
292 /*
293 * start a timer to flush all received frames if there are pending
294 * receive frames
295 */
296 if (rxtid->baw_head != rxtid->baw_tail)
297 mod_timer(&rxtid->timer, ATH_RX_TIMEOUT);
298 else
299 del_timer_sync(&rxtid->timer);
300
301 spin_unlock(&rxtid->tidlock);
302 return IEEE80211_FTYPE_DATA;
303}
304
305/* Timer to flush all received sub-frames */
306
307static void ath_rx_timer(unsigned long data)
308{
309 struct ath_arx_tid *rxtid = (struct ath_arx_tid *)data;
310 struct ath_node *an = rxtid->an;
311 struct ath_rxbuf *rxbuf;
312 int nosched;
313
314 spin_lock_bh(&rxtid->tidlock);
315 while (rxtid->baw_head != rxtid->baw_tail) {
316 rxbuf = rxtid->rxbuf + rxtid->baw_head;
317 if (!rxbuf->rx_wbuf) {
318 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
319 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
320 continue;
321 }
322
323 /*
324 * Stop if the next one is a very recent frame.
325 *
326 * Call get_timestamp in every iteration to protect against the
327 * case in which a new frame is received while we are executing
328 * this function. Using a timestamp obtained before entering
329 * the loop could lead to a very large time interval
330 * (a negative value typecast to unsigned), breaking the
331 * function's logic.
332 */
333 if ((get_timestamp() - rxbuf->rx_time) <
334 (ATH_RX_TIMEOUT * HZ / 1000))
335 break;
336
337 ath_rx_subframe(an, rxbuf->rx_wbuf,
338 &rxbuf->rx_status);
339 rxbuf->rx_wbuf = NULL;
340
341 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
342 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
343 }
344
345 /*
346 * start a timer to flush all received frames if there are pending
347 * receive frames
348 */
349 if (rxtid->baw_head != rxtid->baw_tail)
350 nosched = 0;
351 else
352 nosched = 1; /* no need to re-arm the timer again */
353
354 spin_unlock_bh(&rxtid->tidlock);
355}
356
357/* Free all pending sub-frames in the re-ordering buffer */
358
359static void ath_rx_flush_tid(struct ath_softc *sc,
360 struct ath_arx_tid *rxtid, int drop)
361{
362 struct ath_rxbuf *rxbuf;
363 unsigned long flag;
364
365 spin_lock_irqsave(&rxtid->tidlock, flag);
366 while (rxtid->baw_head != rxtid->baw_tail) {
367 rxbuf = rxtid->rxbuf + rxtid->baw_head;
368 if (!rxbuf->rx_wbuf) {
369 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
370 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
371 continue;
372 }
373
374 if (drop)
375 dev_kfree_skb(rxbuf->rx_wbuf);
376 else
377 ath_rx_subframe(rxtid->an,
378 rxbuf->rx_wbuf,
379 &rxbuf->rx_status);
380
381 rxbuf->rx_wbuf = NULL;
382
383 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
384 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
385 }
386 spin_unlock_irqrestore(&rxtid->tidlock, flag);
387}
388
389static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc, 67static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc,
390 u32 len) 68 u32 len)
391{ 69{
@@ -716,24 +394,6 @@ void ath_flushrecv(struct ath_softc *sc)
716 spin_unlock_bh(&sc->sc_rxflushlock); 394 spin_unlock_bh(&sc->sc_rxflushlock);
717} 395}
718 396
719/* Process an individual frame */
720
721int ath_rx_input(struct ath_softc *sc,
722 struct ath_node *an,
723 int is_ampdu,
724 struct sk_buff *skb,
725 struct ath_recv_status *rx_status,
726 enum ATH_RX_TYPE *status)
727{
728 if (is_ampdu && (sc->sc_flags & SC_OP_RXAGGR)) {
729 *status = ATH_RX_CONSUMED;
730 return ath_ampdu_input(sc, an, skb, rx_status);
731 } else {
732 *status = ATH_RX_NON_CONSUMED;
733 return -1;
734 }
735}
736
737/* Process receive queue, as well as LED, etc. */ 397/* Process receive queue, as well as LED, etc. */
738 398
739int ath_rx_tasklet(struct ath_softc *sc, int flush) 399int ath_rx_tasklet(struct ath_softc *sc, int flush)
@@ -1092,200 +752,3 @@ rx_next:
1092 return 0; 752 return 0;
1093#undef PA2DESC 753#undef PA2DESC
1094} 754}
1095
1096/* Process ADDBA request in per-TID data structure */
1097
1098int ath_rx_aggr_start(struct ath_softc *sc,
1099 const u8 *addr,
1100 u16 tid,
1101 u16 *ssn)
1102{
1103 struct ath_arx_tid *rxtid;
1104 struct ath_node *an;
1105 struct ieee80211_hw *hw = sc->hw;
1106 struct ieee80211_supported_band *sband;
1107 u16 buffersize = 0;
1108
1109 spin_lock_bh(&sc->node_lock);
1110 an = ath_node_find(sc, (u8 *) addr);
1111 spin_unlock_bh(&sc->node_lock);
1112
1113 if (!an) {
1114 DPRINTF(sc, ATH_DBG_AGGR,
1115 "%s: Node not found to initialize RX aggregation\n",
1116 __func__);
1117 return -1;
1118 }
1119
1120 sband = hw->wiphy->bands[hw->conf.channel->band];
1121 buffersize = IEEE80211_MIN_AMPDU_BUF <<
1122 sband->ht_info.ampdu_factor; /* FIXME */
1123
1124 rxtid = &an->an_aggr.rx.tid[tid];
1125
1126 spin_lock_bh(&rxtid->tidlock);
1127 if (sc->sc_flags & SC_OP_RXAGGR) {
1128 /* Allow aggregation reception
1129 * Adjust rx BA window size. Peer might indicate a
1130 * zero buffer size for a _dont_care_ condition.
1131 */
1132 if (buffersize)
1133 rxtid->baw_size = min(buffersize, rxtid->baw_size);
1134
1135 /* set rx sequence number */
1136 rxtid->seq_next = *ssn;
1137
1138 /* Allocate the receive buffers for this TID */
1139 DPRINTF(sc, ATH_DBG_AGGR,
1140 "%s: Allcating rxbuffer for TID %d\n", __func__, tid);
1141
1142 if (rxtid->rxbuf == NULL) {
1143 /*
1144 * If the rxbuff is not NULL at this point, we *probably*
1145 * already allocated the buffer on a previous ADDBA,
1146 * and this is a subsequent ADDBA that got through.
1147 * Don't allocate, but use the value in the pointer,
1148 * we zero it out when we de-allocate.
1149 */
1150 rxtid->rxbuf = kmalloc(ATH_TID_MAX_BUFS *
1151 sizeof(struct ath_rxbuf), GFP_ATOMIC);
1152 }
1153 if (rxtid->rxbuf == NULL) {
1154 DPRINTF(sc, ATH_DBG_AGGR,
1155 "%s: Unable to allocate RX buffer, "
1156 "refusing ADDBA\n", __func__);
1157 } else {
1158 /* Ensure the memory is zeroed out (all internal
1159 * pointers are null) */
1160 memset(rxtid->rxbuf, 0, ATH_TID_MAX_BUFS *
1161 sizeof(struct ath_rxbuf));
1162 DPRINTF(sc, ATH_DBG_AGGR,
1163 "%s: Allocated @%p\n", __func__, rxtid->rxbuf);
1164
1165 /* Allow aggregation reception */
1166 rxtid->addba_exchangecomplete = 1;
1167 }
1168 }
1169 spin_unlock_bh(&rxtid->tidlock);
1170
1171 return 0;
1172}
1173
1174/* Process DELBA */
1175
1176int ath_rx_aggr_stop(struct ath_softc *sc,
1177 const u8 *addr,
1178 u16 tid)
1179{
1180 struct ath_node *an;
1181
1182 spin_lock_bh(&sc->node_lock);
1183 an = ath_node_find(sc, (u8 *) addr);
1184 spin_unlock_bh(&sc->node_lock);
1185
1186 if (!an) {
1187 DPRINTF(sc, ATH_DBG_AGGR,
1188 "%s: RX aggr stop for non-existent node\n", __func__);
1189 return -1;
1190 }
1191
1192 ath_rx_aggr_teardown(sc, an, tid);
1193 return 0;
1194}
1195
1196/* Rx aggregation tear down */
1197
1198void ath_rx_aggr_teardown(struct ath_softc *sc,
1199 struct ath_node *an, u8 tid)
1200{
1201 struct ath_arx_tid *rxtid = &an->an_aggr.rx.tid[tid];
1202
1203 if (!rxtid->addba_exchangecomplete)
1204 return;
1205
1206 del_timer_sync(&rxtid->timer);
1207 ath_rx_flush_tid(sc, rxtid, 0);
1208 rxtid->addba_exchangecomplete = 0;
1209
1210 /* De-allocate the receive buffer array allocated when addba started */
1211
1212 if (rxtid->rxbuf) {
1213 DPRINTF(sc, ATH_DBG_AGGR,
1214 "%s: Deallocating TID %d rxbuff @%p\n",
1215 __func__, tid, rxtid->rxbuf);
1216 kfree(rxtid->rxbuf);
1217
1218 /* Set pointer to null to avoid reuse*/
1219 rxtid->rxbuf = NULL;
1220 }
1221}
1222
1223/* Initialize per-node receive state */
1224
1225void ath_rx_node_init(struct ath_softc *sc, struct ath_node *an)
1226{
1227 if (sc->sc_flags & SC_OP_RXAGGR) {
1228 struct ath_arx_tid *rxtid;
1229 int tidno;
1230
1231 /* Init per tid rx state */
1232 for (tidno = 0, rxtid = &an->an_aggr.rx.tid[tidno];
1233 tidno < WME_NUM_TID;
1234 tidno++, rxtid++) {
1235 rxtid->an = an;
1236 rxtid->seq_reset = 1;
1237 rxtid->seq_next = 0;
1238 rxtid->baw_size = WME_MAX_BA;
1239 rxtid->baw_head = rxtid->baw_tail = 0;
1240
1241 /*
1242 * Ensure the buffer pointer is null at this point
1243 * (needs to be allocated when addba is received)
1244 */
1245
1246 rxtid->rxbuf = NULL;
1247 setup_timer(&rxtid->timer, ath_rx_timer,
1248 (unsigned long)rxtid);
1249 spin_lock_init(&rxtid->tidlock);
1250
1251 /* ADDBA state */
1252 rxtid->addba_exchangecomplete = 0;
1253 }
1254 }
1255}
1256
1257void ath_rx_node_cleanup(struct ath_softc *sc, struct ath_node *an)
1258{
1259 if (sc->sc_flags & SC_OP_RXAGGR) {
1260 struct ath_arx_tid *rxtid;
1261 int tidno, i;
1262
1263 /* Init per tid rx state */
1264 for (tidno = 0, rxtid = &an->an_aggr.rx.tid[tidno];
1265 tidno < WME_NUM_TID;
1266 tidno++, rxtid++) {
1267
1268 if (!rxtid->addba_exchangecomplete)
1269 continue;
1270
1271 /* must cancel timer first */
1272 del_timer_sync(&rxtid->timer);
1273
1274 /* drop any pending sub-frames */
1275 ath_rx_flush_tid(sc, rxtid, 1);
1276
1277 for (i = 0; i < ATH_TID_MAX_BUFS; i++)
1278 ASSERT(rxtid->rxbuf[i].rx_wbuf == NULL);
1279
1280 rxtid->addba_exchangecomplete = 0;
1281 }
1282 }
1283
1284}
1285
1286/* Cleanup per-node receive state */
1287
1288void ath_rx_node_free(struct ath_softc *sc, struct ath_node *an)
1289{
1290 ath_rx_node_cleanup(sc, an);
1291}
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index 3a4757942b3f..8937728b0301 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -65,11 +65,12 @@ static u32 bits_per_symbol[][2] = {
65 * NB: must be called with txq lock held 65 * NB: must be called with txq lock held
66 */ 66 */
67 67
68static void ath_tx_txqaddbuf(struct ath_softc *sc, 68static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
69 struct ath_txq *txq, struct list_head *head) 69 struct list_head *head)
70{ 70{
71 struct ath_hal *ah = sc->sc_ah; 71 struct ath_hal *ah = sc->sc_ah;
72 struct ath_buf *bf; 72 struct ath_buf *bf;
73
73 /* 74 /*
74 * Insert the frame on the outbound list and 75 * Insert the frame on the outbound list and
75 * pass it on to the hardware. 76 * pass it on to the hardware.
@@ -124,27 +125,29 @@ static int ath_tx_findindex(const struct ath9k_rate_table *rt, int rate)
124 125
125/* Check if it's okay to send out aggregates */ 126/* Check if it's okay to send out aggregates */
126 127
127static int ath_aggr_query(struct ath_softc *sc, 128static int ath_aggr_query(struct ath_softc *sc, struct ath_node *an, u8 tidno)
128 struct ath_node *an, u8 tidno)
129{ 129{
130 struct ath_atx_tid *tid; 130 struct ath_atx_tid *tid;
131 tid = ATH_AN_2_TID(an, tidno); 131 tid = ATH_AN_2_TID(an, tidno);
132 132
133 if (tid->addba_exchangecomplete || tid->addba_exchangeinprogress) 133 if (tid->state & AGGR_ADDBA_COMPLETE ||
134 tid->state & AGGR_ADDBA_PROGRESS)
134 return 1; 135 return 1;
135 else 136 else
136 return 0; 137 return 0;
137} 138}
138 139
139static enum ath9k_pkt_type get_hal_packet_type(struct ieee80211_hdr *hdr) 140/* Calculate Atheros packet type from IEEE80211 packet header */
141
142static enum ath9k_pkt_type get_hw_packet_type(struct sk_buff *skb)
140{ 143{
144 struct ieee80211_hdr *hdr;
141 enum ath9k_pkt_type htype; 145 enum ath9k_pkt_type htype;
142 __le16 fc; 146 __le16 fc;
143 147
148 hdr = (struct ieee80211_hdr *)skb->data;
144 fc = hdr->frame_control; 149 fc = hdr->frame_control;
145 150
146 /* Calculate Atheros packet type from IEEE80211 packet header */
147
148 if (ieee80211_is_beacon(fc)) 151 if (ieee80211_is_beacon(fc))
149 htype = ATH9K_PKT_TYPE_BEACON; 152 htype = ATH9K_PKT_TYPE_BEACON;
150 else if (ieee80211_is_probe_resp(fc)) 153 else if (ieee80211_is_probe_resp(fc))
@@ -159,232 +162,176 @@ static enum ath9k_pkt_type get_hal_packet_type(struct ieee80211_hdr *hdr)
159 return htype; 162 return htype;
160} 163}
161 164
162static void fill_min_rates(struct sk_buff *skb, struct ath_tx_control *txctl) 165static bool check_min_rate(struct sk_buff *skb)
163{ 166{
164 struct ieee80211_hdr *hdr; 167 struct ieee80211_hdr *hdr;
165 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 168 bool use_minrate = false;
166 struct ath_tx_info_priv *tx_info_priv;
167 __le16 fc; 169 __le16 fc;
168 170
169 hdr = (struct ieee80211_hdr *)skb->data; 171 hdr = (struct ieee80211_hdr *)skb->data;
170 fc = hdr->frame_control; 172 fc = hdr->frame_control;
171 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
172 173
173 if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc)) { 174 if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc)) {
174 txctl->use_minrate = 1; 175 use_minrate = true;
175 txctl->min_rate = tx_info_priv->min_rate;
176 } else if (ieee80211_is_data(fc)) { 176 } else if (ieee80211_is_data(fc)) {
177 if (ieee80211_is_nullfunc(fc) || 177 if (ieee80211_is_nullfunc(fc) ||
178 /* Port Access Entity (IEEE 802.1X) */ 178 /* Port Access Entity (IEEE 802.1X) */
179 (skb->protocol == cpu_to_be16(0x888E))) { 179 (skb->protocol == cpu_to_be16(ETH_P_PAE))) {
180 txctl->use_minrate = 1; 180 use_minrate = true;
181 txctl->min_rate = tx_info_priv->min_rate;
182 } 181 }
183 if (is_multicast_ether_addr(hdr->addr1))
184 txctl->mcast_rate = tx_info_priv->min_rate;
185 } 182 }
186 183
184 return use_minrate;
187} 185}
188 186
189/* This function will setup additional txctl information, mostly rate stuff */ 187static int get_hw_crypto_keytype(struct sk_buff *skb)
190/* FIXME: seqno, ps */
191static int ath_tx_prepare(struct ath_softc *sc,
192 struct sk_buff *skb,
193 struct ath_tx_control *txctl)
194{ 188{
195 struct ieee80211_hw *hw = sc->hw;
196 struct ieee80211_hdr *hdr;
197 struct ath_rc_series *rcs;
198 struct ath_txq *txq = NULL;
199 const struct ath9k_rate_table *rt;
200 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 189 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
201 struct ath_tx_info_priv *tx_info_priv;
202 int hdrlen;
203 u8 rix, antenna;
204 __le16 fc;
205 u8 *qc;
206
207 txctl->dev = sc;
208 hdr = (struct ieee80211_hdr *)skb->data;
209 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
210 fc = hdr->frame_control;
211
212 rt = sc->sc_currates;
213 BUG_ON(!rt);
214
215 /* Fill misc fields */
216
217 spin_lock_bh(&sc->node_lock);
218 txctl->an = ath_node_get(sc, hdr->addr1);
219 /* create a temp node, if the node is not there already */
220 if (!txctl->an)
221 txctl->an = ath_node_attach(sc, hdr->addr1, 0);
222 spin_unlock_bh(&sc->node_lock);
223
224 if (ieee80211_is_data_qos(fc)) {
225 qc = ieee80211_get_qos_ctl(hdr);
226 txctl->tidno = qc[0] & 0xf;
227 }
228
229 txctl->if_id = 0;
230 txctl->frmlen = skb->len + FCS_LEN - (hdrlen & 3);
231 txctl->txpower = MAX_RATE_POWER; /* FIXME */
232
233 /* Fill Key related fields */
234
235 txctl->keytype = ATH9K_KEY_TYPE_CLEAR;
236 txctl->keyix = ATH9K_TXKEYIX_INVALID;
237 190
238 if (tx_info->control.hw_key) { 191 if (tx_info->control.hw_key) {
239 txctl->keyix = tx_info->control.hw_key->hw_key_idx;
240 txctl->frmlen += tx_info->control.hw_key->icv_len;
241
242 if (tx_info->control.hw_key->alg == ALG_WEP) 192 if (tx_info->control.hw_key->alg == ALG_WEP)
243 txctl->keytype = ATH9K_KEY_TYPE_WEP; 193 return ATH9K_KEY_TYPE_WEP;
244 else if (tx_info->control.hw_key->alg == ALG_TKIP) 194 else if (tx_info->control.hw_key->alg == ALG_TKIP)
245 txctl->keytype = ATH9K_KEY_TYPE_TKIP; 195 return ATH9K_KEY_TYPE_TKIP;
246 else if (tx_info->control.hw_key->alg == ALG_CCMP) 196 else if (tx_info->control.hw_key->alg == ALG_CCMP)
247 txctl->keytype = ATH9K_KEY_TYPE_AES; 197 return ATH9K_KEY_TYPE_AES;
248 } 198 }
249 199
250 /* Fill packet type */ 200 return ATH9K_KEY_TYPE_CLEAR;
201}
251 202
252 txctl->atype = get_hal_packet_type(hdr); 203static void setup_rate_retries(struct ath_softc *sc, struct sk_buff *skb)
204{
205 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
206 struct ath_tx_info_priv *tx_info_priv;
207 struct ath_rc_series *rcs;
208 struct ieee80211_hdr *hdr;
209 const struct ath9k_rate_table *rt;
210 bool use_minrate;
211 __le16 fc;
212 u8 rix;
253 213
254 /* Fill qnum */ 214 rt = sc->sc_currates;
215 BUG_ON(!rt);
255 216
256 if (unlikely(txctl->flags & ATH9K_TXDESC_CAB)) { 217 hdr = (struct ieee80211_hdr *)skb->data;
257 txctl->qnum = 0; 218 fc = hdr->frame_control;
258 txq = sc->sc_cabq; 219 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif; /* HACK */
259 } else { 220 rcs = tx_info_priv->rcs;
260 txctl->qnum = ath_get_hal_qnum(skb_get_queue_mapping(skb), sc);
261 txq = &sc->sc_txq[txctl->qnum];
262 }
263 spin_lock_bh(&txq->axq_lock);
264 221
265 /* Try to avoid running out of descriptors */ 222 /* Check if min rates have to be used */
266 if (txq->axq_depth >= (ATH_TXBUF - 20) && 223 use_minrate = check_min_rate(skb);
267 !(txctl->flags & ATH9K_TXDESC_CAB)) {
268 DPRINTF(sc, ATH_DBG_FATAL,
269 "%s: TX queue: %d is full, depth: %d\n",
270 __func__,
271 txctl->qnum,
272 txq->axq_depth);
273 ieee80211_stop_queue(hw, skb_get_queue_mapping(skb));
274 txq->stopped = 1;
275 spin_unlock_bh(&txq->axq_lock);
276 return -1;
277 }
278 224
279 spin_unlock_bh(&txq->axq_lock); 225 if (ieee80211_is_data(fc) && !use_minrate) {
226 if (is_multicast_ether_addr(hdr->addr1)) {
227 rcs[0].rix =
228 ath_tx_findindex(rt, tx_info_priv->min_rate);
229 /* mcast packets are not re-tried */
230 rcs[0].tries = 1;
231 }
232 } else {
233 /* for management and control frames,
234 or for NULL and EAPOL frames */
235 if (use_minrate)
236 rcs[0].rix = ath_rate_findrateix(sc, tx_info_priv->min_rate);
237 else
238 rcs[0].rix = 0;
239 rcs[0].tries = ATH_MGT_TXMAXTRY;
240 }
280 241
281 /* Fill rate */ 242 rix = rcs[0].rix;
282 243
283 fill_min_rates(skb, txctl); 244 if (ieee80211_has_morefrags(fc) ||
245 (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG)) {
246 rcs[1].tries = rcs[2].tries = rcs[3].tries = 0;
247 rcs[1].rix = rcs[2].rix = rcs[3].rix = 0;
248 /* reset tries but keep rate index */
249 rcs[0].tries = ATH_TXMAXTRY;
250 }
251}
284 252
285 /* Fill flags */ 253/* Called only when tx aggregation is enabled and HT is supported */
286 254
287 txctl->flags |= ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */ 255static void assign_aggr_tid_seqno(struct sk_buff *skb,
256 struct ath_buf *bf)
257{
258 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
259 struct ieee80211_hdr *hdr;
260 struct ath_node *an;
261 struct ath_atx_tid *tid;
262 __le16 fc;
263 u8 *qc;
288 264
289 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) 265 if (!tx_info->control.sta)
290 txctl->flags |= ATH9K_TXDESC_NOACK; 266 return;
291 if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
292 txctl->flags |= ATH9K_TXDESC_RTSENA;
293 267
294 /* 268 an = (struct ath_node *)tx_info->control.sta->drv_priv;
295 * Setup for rate calculations. 269 hdr = (struct ieee80211_hdr *)skb->data;
296 */ 270 fc = hdr->frame_control;
297 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
298 rcs = tx_info_priv->rcs;
299 271
300 if (ieee80211_is_data(fc) && !txctl->use_minrate) { 272 /* Get tidno */
301 273
302 /* Enable HT only for DATA frames and not for EAPOL */ 274 if (ieee80211_is_data_qos(fc)) {
303 txctl->ht = (hw->conf.ht_conf.ht_supported && 275 qc = ieee80211_get_qos_ctl(hdr);
304 (tx_info->flags & IEEE80211_TX_CTL_AMPDU)); 276 bf->bf_tidno = qc[0] & 0xf;
277 }
305 278
306 if (is_multicast_ether_addr(hdr->addr1)) { 279 /* Get seqno */
307 rcs[0].rix = (u8)
308 ath_tx_findindex(rt, txctl->mcast_rate);
309 280
310 /* 281 if (ieee80211_is_data(fc) && !check_min_rate(skb)) {
311 * mcast packets are not re-tried.
312 */
313 rcs[0].tries = 1;
314 }
315 /* For HT capable stations, we save tidno for later use. 282 /* For HT capable stations, we save tidno for later use.
316 * We also override seqno set by upper layer with the one 283 * We also override seqno set by upper layer with the one
317 * in tx aggregation state. 284 * in tx aggregation state.
318 * 285 *
319 * First, the fragmentation stat is determined.
320 * If fragmentation is on, the sequence number is 286 * If fragmentation is on, the sequence number is
321 * not overridden, since it has been 287 * not overridden, since it has been
322 * incremented by the fragmentation routine. 288 * incremented by the fragmentation routine.
289 *
290 * FIXME: check if the fragmentation threshold exceeds
291 * IEEE80211 max.
323 */ 292 */
324 if (likely(!(txctl->flags & ATH9K_TXDESC_FRAG_IS_ON)) && 293 tid = ATH_AN_2_TID(an, bf->bf_tidno);
325 txctl->ht && (sc->sc_flags & SC_OP_TXAGGR)) { 294 hdr->seq_ctrl = cpu_to_le16(tid->seq_next <<
326 struct ath_atx_tid *tid; 295 IEEE80211_SEQ_SEQ_SHIFT);
296 bf->bf_seqno = tid->seq_next;
297 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
298 }
299}
327 300
328 tid = ATH_AN_2_TID(txctl->an, txctl->tidno); 301static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb,
302 struct ath_txq *txq)
303{
304 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
305 int flags = 0;
329 306
330 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << 307 flags |= ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */
331 IEEE80211_SEQ_SEQ_SHIFT); 308 flags |= ATH9K_TXDESC_INTREQ;
332 txctl->seqno = tid->seq_next;
333 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
334 }
335 } else {
336 /* for management and control frames,
337 * or for NULL and EAPOL frames */
338 if (txctl->min_rate)
339 rcs[0].rix = ath_rate_findrateix(sc, txctl->min_rate);
340 else
341 rcs[0].rix = 0;
342 rcs[0].tries = ATH_MGT_TXMAXTRY;
343 }
344 rix = rcs[0].rix;
345 309
346 if (ieee80211_has_morefrags(fc) || 310 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
347 (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG)) { 311 flags |= ATH9K_TXDESC_NOACK;
348 /* 312 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
349 ** Force hardware to use computed duration for next 313 flags |= ATH9K_TXDESC_RTSENA;
350 ** fragment by disabling multi-rate retry, which
351 ** updates duration based on the multi-rate
352 ** duration table.
353 */
354 rcs[1].tries = rcs[2].tries = rcs[3].tries = 0;
355 rcs[1].rix = rcs[2].rix = rcs[3].rix = 0;
356 /* reset tries but keep rate index */
357 rcs[0].tries = ATH_TXMAXTRY;
358 }
359 314
360 /* 315 return flags;
361 * Determine if a tx interrupt should be generated for 316}
362 * this descriptor. We take a tx interrupt to reap 317
363 * descriptors when the h/w hits an EOL condition or 318static struct ath_buf *ath_tx_get_buffer(struct ath_softc *sc)
364 * when the descriptor is specifically marked to generate 319{
365 * an interrupt. We periodically mark descriptors in this 320 struct ath_buf *bf = NULL;
366 * way to insure timely replenishing of the supply needed 321
367 * for sending frames. Defering interrupts reduces system 322 spin_lock_bh(&sc->sc_txbuflock);
368 * load and potentially allows more concurrent work to be
369 * done but if done to aggressively can cause senders to
370 * backup.
371 *
372 * NB: use >= to deal with sc_txintrperiod changing
373 * dynamically through sysctl.
374 */
375 spin_lock_bh(&txq->axq_lock);
376 if ((++txq->axq_intrcnt >= sc->sc_txintrperiod)) {
377 txctl->flags |= ATH9K_TXDESC_INTREQ;
378 txq->axq_intrcnt = 0;
379 }
380 spin_unlock_bh(&txq->axq_lock);
381 323
382 if (is_multicast_ether_addr(hdr->addr1)) { 324 if (unlikely(list_empty(&sc->sc_txbuf))) {
383 antenna = sc->sc_mcastantenna + 1; 325 spin_unlock_bh(&sc->sc_txbuflock);
384 sc->sc_mcastantenna = (sc->sc_mcastantenna + 1) & 0x1; 326 return NULL;
385 } 327 }
386 328
387 return 0; 329 bf = list_first_entry(&sc->sc_txbuf, struct ath_buf, list);
330 list_del(&bf->list);
331
332 spin_unlock_bh(&sc->sc_txbuflock);
333
334 return bf;
388} 335}
389 336
390/* To complete a chain of buffers associated a frame */ 337/* To complete a chain of buffers associated a frame */
@@ -414,13 +361,14 @@ static void ath_tx_complete_buf(struct ath_softc *sc,
414 if (bf_isxretried(bf)) 361 if (bf_isxretried(bf))
415 tx_status.flags |= ATH_TX_XRETRY; 362 tx_status.flags |= ATH_TX_XRETRY;
416 } 363 }
364
417 /* Unmap this frame */ 365 /* Unmap this frame */
418 pci_unmap_single(sc->pdev, 366 pci_unmap_single(sc->pdev,
419 bf->bf_dmacontext, 367 bf->bf_dmacontext,
420 skb->len, 368 skb->len,
421 PCI_DMA_TODEVICE); 369 PCI_DMA_TODEVICE);
422 /* complete this frame */ 370 /* complete this frame */
423 ath_tx_complete(sc, skb, &tx_status, bf->bf_node); 371 ath_tx_complete(sc, skb, &tx_status);
424 372
425 /* 373 /*
426 * Return the list of ath_buf of this mpdu to free queue 374 * Return the list of ath_buf of this mpdu to free queue
@@ -505,11 +453,9 @@ unlock:
505 453
506/* Compute the number of bad frames */ 454/* Compute the number of bad frames */
507 455
508static int ath_tx_num_badfrms(struct ath_softc *sc, 456static int ath_tx_num_badfrms(struct ath_softc *sc, struct ath_buf *bf,
509 struct ath_buf *bf, int txok) 457 int txok)
510{ 458{
511 struct ath_node *an = bf->bf_node;
512 int isnodegone = (an->an_flags & ATH_NODE_CLEAN);
513 struct ath_buf *bf_last = bf->bf_lastbf; 459 struct ath_buf *bf_last = bf->bf_lastbf;
514 struct ath_desc *ds = bf_last->bf_desc; 460 struct ath_desc *ds = bf_last->bf_desc;
515 u16 seq_st = 0; 461 u16 seq_st = 0;
@@ -518,7 +464,7 @@ static int ath_tx_num_badfrms(struct ath_softc *sc,
518 int nbad = 0; 464 int nbad = 0;
519 int isaggr = 0; 465 int isaggr = 0;
520 466
521 if (isnodegone || ds->ds_txstat.ts_flags == ATH9K_TX_SW_ABORTED) 467 if (ds->ds_txstat.ts_flags == ATH9K_TX_SW_ABORTED)
522 return 0; 468 return 0;
523 469
524 isaggr = bf_isaggr(bf); 470 isaggr = bf_isaggr(bf);
@@ -553,8 +499,8 @@ static void ath_tx_set_retry(struct ath_softc *sc, struct ath_buf *bf)
553 499
554/* Update block ack window */ 500/* Update block ack window */
555 501
556static void ath_tx_update_baw(struct ath_softc *sc, 502static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
557 struct ath_atx_tid *tid, int seqno) 503 int seqno)
558{ 504{
559 int index, cindex; 505 int index, cindex;
560 506
@@ -578,12 +524,8 @@ static void ath_tx_update_baw(struct ath_softc *sc,
578 * half_gi - to use 4us v/s 3.6 us for symbol time 524 * half_gi - to use 4us v/s 3.6 us for symbol time
579 */ 525 */
580 526
581static u32 ath_pkt_duration(struct ath_softc *sc, 527static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
582 u8 rix, 528 int width, int half_gi, bool shortPreamble)
583 struct ath_buf *bf,
584 int width,
585 int half_gi,
586 bool shortPreamble)
587{ 529{
588 const struct ath9k_rate_table *rt = sc->sc_currates; 530 const struct ath9k_rate_table *rt = sc->sc_currates;
589 u32 nbits, nsymbits, duration, nsymbols; 531 u32 nbits, nsymbits, duration, nsymbols;
@@ -597,11 +539,8 @@ static u32 ath_pkt_duration(struct ath_softc *sc,
597 * for legacy rates, use old function to compute packet duration 539 * for legacy rates, use old function to compute packet duration
598 */ 540 */
599 if (!IS_HT_RATE(rc)) 541 if (!IS_HT_RATE(rc))
600 return ath9k_hw_computetxtime(sc->sc_ah, 542 return ath9k_hw_computetxtime(sc->sc_ah, rt, pktlen, rix,
601 rt, 543 shortPreamble);
602 pktlen,
603 rix,
604 shortPreamble);
605 /* 544 /*
606 * find number of symbols: PLCP + data 545 * find number of symbols: PLCP + data
607 */ 546 */
@@ -619,6 +558,7 @@ static u32 ath_pkt_duration(struct ath_softc *sc,
619 */ 558 */
620 streams = HT_RC_2_STREAMS(rc); 559 streams = HT_RC_2_STREAMS(rc);
621 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams); 560 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
561
622 return duration; 562 return duration;
623} 563}
624 564
@@ -631,11 +571,18 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
631 struct ath_desc *ds = bf->bf_desc; 571 struct ath_desc *ds = bf->bf_desc;
632 struct ath_desc *lastds = bf->bf_lastbf->bf_desc; 572 struct ath_desc *lastds = bf->bf_lastbf->bf_desc;
633 struct ath9k_11n_rate_series series[4]; 573 struct ath9k_11n_rate_series series[4];
634 int i, flags, rtsctsena = 0, dynamic_mimops = 0; 574 int i, flags, rtsctsena = 0;
635 u32 ctsduration = 0; 575 u32 ctsduration = 0;
636 u8 rix = 0, cix, ctsrate = 0; 576 u8 rix = 0, cix, ctsrate = 0;
637 u32 aggr_limit_with_rts = ah->ah_caps.rts_aggr_limit; 577 struct ath_node *an = NULL;
638 struct ath_node *an = (struct ath_node *) bf->bf_node; 578 struct sk_buff *skb;
579 struct ieee80211_tx_info *tx_info;
580
581 skb = (struct sk_buff *)bf->bf_mpdu;
582 tx_info = IEEE80211_SKB_CB(skb);
583
584 if (tx_info->control.sta)
585 an = (struct ath_node *)tx_info->control.sta->drv_priv;
639 586
640 /* 587 /*
641 * get the cix for the lowest valid rix. 588 * get the cix for the lowest valid rix.
@@ -674,24 +621,11 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
674 * use RTS. 621 * use RTS.
675 */ 622 */
676 if ((ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) && bf_isdata(bf)) { 623 if ((ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) && bf_isdata(bf)) {
677 BUG_ON(!an);
678 /* 624 /*
679 * 802.11g protection not needed, use our default behavior 625 * 802.11g protection not needed, use our default behavior
680 */ 626 */
681 if (!rtsctsena) 627 if (!rtsctsena)
682 flags = ATH9K_TXDESC_RTSENA; 628 flags = ATH9K_TXDESC_RTSENA;
683 /*
684 * For dynamic MIMO PS, RTS needs to precede the first aggregate
685 * and the second aggregate should have any protection at all.
686 */
687 if (an->an_smmode == ATH_SM_PWRSAV_DYNAMIC) {
688 if (!bf_isaggrburst(bf)) {
689 flags = ATH9K_TXDESC_RTSENA;
690 dynamic_mimops = 1;
691 } else {
692 flags = 0;
693 }
694 }
695 } 629 }
696 630
697 /* 631 /*
@@ -707,7 +641,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
707 /* 641 /*
708 * For AR5416 - RTS cannot be followed by a frame larger than 8K. 642 * For AR5416 - RTS cannot be followed by a frame larger than 8K.
709 */ 643 */
710 if (bf_isaggr(bf) && (bf->bf_al > aggr_limit_with_rts)) { 644 if (bf_isaggr(bf) && (bf->bf_al > ah->ah_caps.rts_aggr_limit)) {
711 /* 645 /*
712 * Ensure that in the case of SM Dynamic power save 646 * Ensure that in the case of SM Dynamic power save
713 * while we are bursting the second aggregate the 647 * while we are bursting the second aggregate the
@@ -720,8 +654,8 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
720 * CTS transmit rate is derived from the transmit rate 654 * CTS transmit rate is derived from the transmit rate
721 * by looking in the h/w rate table. We must also factor 655 * by looking in the h/w rate table. We must also factor
722 * in whether or not a short preamble is to be used. 656 * in whether or not a short preamble is to be used.
657 * NB: cix is set above where RTS/CTS is enabled
723 */ 658 */
724 /* NB: cix is set above where RTS/CTS is enabled */
725 BUG_ON(cix == 0xff); 659 BUG_ON(cix == 0xff);
726 ctsrate = rt->info[cix].rateCode | 660 ctsrate = rt->info[cix].rateCode |
727 (bf_isshpreamble(bf) ? rt->info[cix].shortPreamble : 0); 661 (bf_isshpreamble(bf) ? rt->info[cix].shortPreamble : 0);
@@ -750,39 +684,18 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
750 ((bf->bf_rcs[i].flags & ATH_RC_SGI_FLAG) ? 684 ((bf->bf_rcs[i].flags & ATH_RC_SGI_FLAG) ?
751 ATH9K_RATESERIES_HALFGI : 0); 685 ATH9K_RATESERIES_HALFGI : 0);
752 686
753 series[i].PktDuration = ath_pkt_duration( 687 series[i].PktDuration = ath_pkt_duration(sc, rix, bf,
754 sc, rix, bf, 688 (bf->bf_rcs[i].flags & ATH_RC_CW40_FLAG) != 0,
755 (bf->bf_rcs[i].flags & ATH_RC_CW40_FLAG) != 0, 689 (bf->bf_rcs[i].flags & ATH_RC_SGI_FLAG),
756 (bf->bf_rcs[i].flags & ATH_RC_SGI_FLAG), 690 bf_isshpreamble(bf));
757 bf_isshpreamble(bf));
758 691
759 if ((an->an_smmode == ATH_SM_PWRSAV_STATIC) && 692 if (bf_isht(bf) && an)
760 (bf->bf_rcs[i].flags & ATH_RC_DS_FLAG) == 0) { 693 series[i].ChSel = ath_chainmask_sel_logic(sc, an);
761 /* 694 else
762 * When sending to an HT node that has enabled static
763 * SM/MIMO power save, send at single stream rates but
764 * use maximum allowed transmit chains per user,
765 * hardware, regulatory, or country limits for
766 * better range.
767 */
768 series[i].ChSel = sc->sc_tx_chainmask; 695 series[i].ChSel = sc->sc_tx_chainmask;
769 } else {
770 if (bf_isht(bf))
771 series[i].ChSel =
772 ath_chainmask_sel_logic(sc, an);
773 else
774 series[i].ChSel = sc->sc_tx_chainmask;
775 }
776 696
777 if (rtsctsena) 697 if (rtsctsena)
778 series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; 698 series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
779
780 /*
781 * Set RTS for all rates if node is in dynamic powersave
782 * mode and we are using dual stream rates.
783 */
784 if (dynamic_mimops && (bf->bf_rcs[i].flags & ATH_RC_DS_FLAG))
785 series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
786 } 699 }
787 700
788 /* 701 /*
@@ -828,6 +741,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
828 ctsrate, 741 ctsrate,
829 ctsduration, 742 ctsduration,
830 series, 4, flags); 743 series, 4, flags);
744
831 if (sc->sc_config.ath_aggr_prot && flags) 745 if (sc->sc_config.ath_aggr_prot && flags)
832 ath9k_hw_set11n_burstduration(ah, ds, 8192); 746 ath9k_hw_set11n_burstduration(ah, ds, 8192);
833} 747}
@@ -854,7 +768,9 @@ static int ath_tx_send_normal(struct ath_softc *sc,
854 768
855 skb = (struct sk_buff *)bf->bf_mpdu; 769 skb = (struct sk_buff *)bf->bf_mpdu;
856 tx_info = IEEE80211_SKB_CB(skb); 770 tx_info = IEEE80211_SKB_CB(skb);
857 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 771
772 /* XXX: HACK! */
773 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
858 memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0])); 774 memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
859 775
860 /* update starting sequence number for subsequent ADDBA request */ 776 /* update starting sequence number for subsequent ADDBA request */
@@ -906,8 +822,10 @@ static void ath_tx_complete_aggr_rifs(struct ath_softc *sc,
906 struct list_head *bf_q, 822 struct list_head *bf_q,
907 int txok) 823 int txok)
908{ 824{
909 struct ath_node *an = bf->bf_node; 825 struct ath_node *an = NULL;
910 struct ath_atx_tid *tid = ATH_AN_2_TID(an, bf->bf_tidno); 826 struct sk_buff *skb;
827 struct ieee80211_tx_info *tx_info;
828 struct ath_atx_tid *tid = NULL;
911 struct ath_buf *bf_last = bf->bf_lastbf; 829 struct ath_buf *bf_last = bf->bf_lastbf;
912 struct ath_desc *ds = bf_last->bf_desc; 830 struct ath_desc *ds = bf_last->bf_desc;
913 struct ath_buf *bf_next, *bf_lastq = NULL; 831 struct ath_buf *bf_next, *bf_lastq = NULL;
@@ -915,7 +833,14 @@ static void ath_tx_complete_aggr_rifs(struct ath_softc *sc,
915 u16 seq_st = 0; 833 u16 seq_st = 0;
916 u32 ba[WME_BA_BMP_SIZE >> 5]; 834 u32 ba[WME_BA_BMP_SIZE >> 5];
917 int isaggr, txfail, txpending, sendbar = 0, needreset = 0; 835 int isaggr, txfail, txpending, sendbar = 0, needreset = 0;
918 int isnodegone = (an->an_flags & ATH_NODE_CLEAN); 836
837 skb = (struct sk_buff *)bf->bf_mpdu;
838 tx_info = IEEE80211_SKB_CB(skb);
839
840 if (tx_info->control.sta) {
841 an = (struct ath_node *)tx_info->control.sta->drv_priv;
842 tid = ATH_AN_2_TID(an, bf->bf_tidno);
843 }
919 844
920 isaggr = bf_isaggr(bf); 845 isaggr = bf_isaggr(bf);
921 if (isaggr) { 846 if (isaggr) {
@@ -961,7 +886,7 @@ static void ath_tx_complete_aggr_rifs(struct ath_softc *sc,
961 /* transmit completion */ 886 /* transmit completion */
962 } else { 887 } else {
963 888
964 if (!tid->cleanup_inprogress && !isnodegone && 889 if (!(tid->state & AGGR_CLEANUP) &&
965 ds->ds_txstat.ts_flags != ATH9K_TX_SW_ABORTED) { 890 ds->ds_txstat.ts_flags != ATH9K_TX_SW_ABORTED) {
966 if (bf->bf_retries < ATH_MAX_SW_RETRIES) { 891 if (bf->bf_retries < ATH_MAX_SW_RETRIES) {
967 ath_tx_set_retry(sc, bf); 892 ath_tx_set_retry(sc, bf);
@@ -1049,7 +974,6 @@ static void ath_tx_complete_aggr_rifs(struct ath_softc *sc,
1049 974
1050 /* copy descriptor content */ 975 /* copy descriptor content */
1051 tbf->bf_mpdu = bf_last->bf_mpdu; 976 tbf->bf_mpdu = bf_last->bf_mpdu;
1052 tbf->bf_node = bf_last->bf_node;
1053 tbf->bf_buf_addr = bf_last->bf_buf_addr; 977 tbf->bf_buf_addr = bf_last->bf_buf_addr;
1054 *(tbf->bf_desc) = *(bf_last->bf_desc); 978 *(tbf->bf_desc) = *(bf_last->bf_desc);
1055 979
@@ -1090,25 +1014,16 @@ static void ath_tx_complete_aggr_rifs(struct ath_softc *sc,
1090 bf = bf_next; 1014 bf = bf_next;
1091 } 1015 }
1092 1016
1093 /* 1017 if (tid->state & AGGR_CLEANUP) {
1094 * node is already gone. no more assocication
1095 * with the node. the node might have been freed
1096 * any node acces can result in panic.note tid
1097 * is part of the node.
1098 */
1099 if (isnodegone)
1100 return;
1101
1102 if (tid->cleanup_inprogress) {
1103 /* check to see if we're done with cleaning the h/w queue */ 1018 /* check to see if we're done with cleaning the h/w queue */
1104 spin_lock_bh(&txq->axq_lock); 1019 spin_lock_bh(&txq->axq_lock);
1105 1020
1106 if (tid->baw_head == tid->baw_tail) { 1021 if (tid->baw_head == tid->baw_tail) {
1107 tid->addba_exchangecomplete = 0; 1022 tid->state &= ~AGGR_ADDBA_COMPLETE;
1108 tid->addba_exchangeattempts = 0; 1023 tid->addba_exchangeattempts = 0;
1109 spin_unlock_bh(&txq->axq_lock); 1024 spin_unlock_bh(&txq->axq_lock);
1110 1025
1111 tid->cleanup_inprogress = false; 1026 tid->state &= ~AGGR_CLEANUP;
1112 1027
1113 /* send buffered frames as singles */ 1028 /* send buffered frames as singles */
1114 ath_tx_flush_tid(sc, tid); 1029 ath_tx_flush_tid(sc, tid);
@@ -1158,7 +1073,6 @@ static int ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
1158 nacked = 0; 1073 nacked = 0;
1159 for (;;) { 1074 for (;;) {
1160 spin_lock_bh(&txq->axq_lock); 1075 spin_lock_bh(&txq->axq_lock);
1161 txq->axq_intrcnt = 0; /* reset periodic desc intr count */
1162 if (list_empty(&txq->axq_q)) { 1076 if (list_empty(&txq->axq_q)) {
1163 txq->axq_link = NULL; 1077 txq->axq_link = NULL;
1164 txq->axq_linkbuf = NULL; 1078 txq->axq_linkbuf = NULL;
@@ -1248,8 +1162,9 @@ static int ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
1248 } 1162 }
1249 skb = bf->bf_mpdu; 1163 skb = bf->bf_mpdu;
1250 tx_info = IEEE80211_SKB_CB(skb); 1164 tx_info = IEEE80211_SKB_CB(skb);
1251 tx_info_priv = (struct ath_tx_info_priv *) 1165
1252 tx_info->driver_data[0]; 1166 /* XXX: HACK! */
1167 tx_info_priv = (struct ath_tx_info_priv *) tx_info->control.vif;
1253 if (ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) 1168 if (ds->ds_txstat.ts_status & ATH9K_TXERR_FILT)
1254 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 1169 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
1255 if ((ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) == 0 && 1170 if ((ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) == 0 &&
@@ -1317,26 +1232,21 @@ static void ath_tx_stopdma(struct ath_softc *sc, struct ath_txq *txq)
1317static void ath_drain_txdataq(struct ath_softc *sc, bool retry_tx) 1232static void ath_drain_txdataq(struct ath_softc *sc, bool retry_tx)
1318{ 1233{
1319 struct ath_hal *ah = sc->sc_ah; 1234 struct ath_hal *ah = sc->sc_ah;
1320 int i; 1235 int i, status, npend = 0;
1321 int npend = 0;
1322 1236
1323 /* XXX return value */
1324 if (!(sc->sc_flags & SC_OP_INVALID)) { 1237 if (!(sc->sc_flags & SC_OP_INVALID)) {
1325 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { 1238 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1326 if (ATH_TXQ_SETUP(sc, i)) { 1239 if (ATH_TXQ_SETUP(sc, i)) {
1327 ath_tx_stopdma(sc, &sc->sc_txq[i]); 1240 ath_tx_stopdma(sc, &sc->sc_txq[i]);
1328
1329 /* The TxDMA may not really be stopped. 1241 /* The TxDMA may not really be stopped.
1330 * Double check the hal tx pending count */ 1242 * Double check the hal tx pending count */
1331 npend += ath9k_hw_numtxpending(ah, 1243 npend += ath9k_hw_numtxpending(ah,
1332 sc->sc_txq[i].axq_qnum); 1244 sc->sc_txq[i].axq_qnum);
1333 } 1245 }
1334 } 1246 }
1335 } 1247 }
1336 1248
1337 if (npend) { 1249 if (npend) {
1338 int status;
1339
1340 /* TxDMA not stopped, reset the hal */ 1250 /* TxDMA not stopped, reset the hal */
1341 DPRINTF(sc, ATH_DBG_XMIT, 1251 DPRINTF(sc, ATH_DBG_XMIT,
1342 "%s: Unable to stop TxDMA. Reset HAL!\n", __func__); 1252 "%s: Unable to stop TxDMA. Reset HAL!\n", __func__);
@@ -1392,7 +1302,6 @@ static void ath_tx_addto_baw(struct ath_softc *sc,
1392 */ 1302 */
1393 1303
1394static int ath_tx_send_ampdu(struct ath_softc *sc, 1304static int ath_tx_send_ampdu(struct ath_softc *sc,
1395 struct ath_txq *txq,
1396 struct ath_atx_tid *tid, 1305 struct ath_atx_tid *tid,
1397 struct list_head *bf_head, 1306 struct list_head *bf_head,
1398 struct ath_tx_control *txctl) 1307 struct ath_tx_control *txctl)
@@ -1406,8 +1315,6 @@ static int ath_tx_send_ampdu(struct ath_softc *sc,
1406 1315
1407 bf = list_first_entry(bf_head, struct ath_buf, list); 1316 bf = list_first_entry(bf_head, struct ath_buf, list);
1408 bf->bf_state.bf_type |= BUF_AMPDU; 1317 bf->bf_state.bf_type |= BUF_AMPDU;
1409 bf->bf_seqno = txctl->seqno; /* save seqno and tidno in buffer */
1410 bf->bf_tidno = txctl->tidno;
1411 1318
1412 /* 1319 /*
1413 * Do not queue to h/w when any of the following conditions is true: 1320 * Do not queue to h/w when any of the following conditions is true:
@@ -1418,19 +1325,20 @@ static int ath_tx_send_ampdu(struct ath_softc *sc,
1418 */ 1325 */
1419 if (!list_empty(&tid->buf_q) || tid->paused || 1326 if (!list_empty(&tid->buf_q) || tid->paused ||
1420 !BAW_WITHIN(tid->seq_start, tid->baw_size, bf->bf_seqno) || 1327 !BAW_WITHIN(tid->seq_start, tid->baw_size, bf->bf_seqno) ||
1421 txq->axq_depth >= ATH_AGGR_MIN_QDEPTH) { 1328 txctl->txq->axq_depth >= ATH_AGGR_MIN_QDEPTH) {
1422 /* 1329 /*
1423 * Add this frame to software queue for scheduling later 1330 * Add this frame to software queue for scheduling later
1424 * for aggregation. 1331 * for aggregation.
1425 */ 1332 */
1426 list_splice_tail_init(bf_head, &tid->buf_q); 1333 list_splice_tail_init(bf_head, &tid->buf_q);
1427 ath_tx_queue_tid(txq, tid); 1334 ath_tx_queue_tid(txctl->txq, tid);
1428 return 0; 1335 return 0;
1429 } 1336 }
1430 1337
1431 skb = (struct sk_buff *)bf->bf_mpdu; 1338 skb = (struct sk_buff *)bf->bf_mpdu;
1432 tx_info = IEEE80211_SKB_CB(skb); 1339 tx_info = IEEE80211_SKB_CB(skb);
1433 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 1340 /* XXX: HACK! */
1341 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1434 memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0])); 1342 memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
1435 1343
1436 /* Add sub-frame to BAW */ 1344 /* Add sub-frame to BAW */
@@ -1440,7 +1348,8 @@ static int ath_tx_send_ampdu(struct ath_softc *sc,
1440 bf->bf_nframes = 1; 1348 bf->bf_nframes = 1;
1441 bf->bf_lastbf = bf->bf_lastfrm; /* one single frame */ 1349 bf->bf_lastbf = bf->bf_lastfrm; /* one single frame */
1442 ath_buf_set_rate(sc, bf); 1350 ath_buf_set_rate(sc, bf);
1443 ath_tx_txqaddbuf(sc, txq, bf_head); 1351 ath_tx_txqaddbuf(sc, txctl->txq, bf_head);
1352
1444 return 0; 1353 return 0;
1445} 1354}
1446 1355
@@ -1450,7 +1359,8 @@ static int ath_tx_send_ampdu(struct ath_softc *sc,
1450 */ 1359 */
1451 1360
1452static u32 ath_lookup_rate(struct ath_softc *sc, 1361static u32 ath_lookup_rate(struct ath_softc *sc,
1453 struct ath_buf *bf) 1362 struct ath_buf *bf,
1363 struct ath_atx_tid *tid)
1454{ 1364{
1455 const struct ath9k_rate_table *rt = sc->sc_currates; 1365 const struct ath9k_rate_table *rt = sc->sc_currates;
1456 struct sk_buff *skb; 1366 struct sk_buff *skb;
@@ -1460,11 +1370,10 @@ static u32 ath_lookup_rate(struct ath_softc *sc,
1460 u16 aggr_limit, legacy = 0, maxampdu; 1370 u16 aggr_limit, legacy = 0, maxampdu;
1461 int i; 1371 int i;
1462 1372
1463
1464 skb = (struct sk_buff *)bf->bf_mpdu; 1373 skb = (struct sk_buff *)bf->bf_mpdu;
1465 tx_info = IEEE80211_SKB_CB(skb); 1374 tx_info = IEEE80211_SKB_CB(skb);
1466 tx_info_priv = (struct ath_tx_info_priv *) 1375 tx_info_priv = (struct ath_tx_info_priv *)
1467 tx_info->driver_data[0]; 1376 tx_info->control.vif; /* XXX: HACK! */
1468 memcpy(bf->bf_rcs, 1377 memcpy(bf->bf_rcs,
1469 tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0])); 1378 tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
1470 1379
@@ -1504,7 +1413,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc,
1504 * The IE, however can hold upto 65536, which shows up here 1413 * The IE, however can hold upto 65536, which shows up here
1505 * as zero. Ignore 65536 since we are constrained by hw. 1414 * as zero. Ignore 65536 since we are constrained by hw.
1506 */ 1415 */
1507 maxampdu = sc->sc_ht_info.maxampdu; 1416 maxampdu = tid->an->maxampdu;
1508 if (maxampdu) 1417 if (maxampdu)
1509 aggr_limit = min(aggr_limit, maxampdu); 1418 aggr_limit = min(aggr_limit, maxampdu);
1510 1419
@@ -1518,6 +1427,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc,
1518 */ 1427 */
1519 1428
1520static int ath_compute_num_delims(struct ath_softc *sc, 1429static int ath_compute_num_delims(struct ath_softc *sc,
1430 struct ath_atx_tid *tid,
1521 struct ath_buf *bf, 1431 struct ath_buf *bf,
1522 u16 frmlen) 1432 u16 frmlen)
1523{ 1433{
@@ -1545,7 +1455,7 @@ static int ath_compute_num_delims(struct ath_softc *sc,
1545 * required minimum length for subframe. Take into account 1455 * required minimum length for subframe. Take into account
1546 * whether high rate is 20 or 40Mhz and half or full GI. 1456 * whether high rate is 20 or 40Mhz and half or full GI.
1547 */ 1457 */
1548 mpdudensity = sc->sc_ht_info.mpdudensity; 1458 mpdudensity = tid->an->mpdudensity;
1549 1459
1550 /* 1460 /*
1551 * If there is no mpdu density restriction, no further calculation 1461 * If there is no mpdu density restriction, no further calculation
@@ -1619,7 +1529,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
1619 } 1529 }
1620 1530
1621 if (!rl) { 1531 if (!rl) {
1622 aggr_limit = ath_lookup_rate(sc, bf); 1532 aggr_limit = ath_lookup_rate(sc, bf, tid);
1623 rl = 1; 1533 rl = 1;
1624 /* 1534 /*
1625 * Is rate dual stream 1535 * Is rate dual stream
@@ -1657,7 +1567,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
1657 * Get the delimiters needed to meet the MPDU 1567 * Get the delimiters needed to meet the MPDU
1658 * density for this node. 1568 * density for this node.
1659 */ 1569 */
1660 ndelim = ath_compute_num_delims(sc, bf_first, bf->bf_frmlen); 1570 ndelim = ath_compute_num_delims(sc, tid, bf_first, bf->bf_frmlen);
1661 1571
1662 bpad = PADBYTES(al_delta) + (ndelim << 2); 1572 bpad = PADBYTES(al_delta) + (ndelim << 2);
1663 1573
@@ -1799,8 +1709,8 @@ static void ath_tx_sched_aggr(struct ath_softc *sc,
1799 1709
1800static void ath_tid_drain(struct ath_softc *sc, 1710static void ath_tid_drain(struct ath_softc *sc,
1801 struct ath_txq *txq, 1711 struct ath_txq *txq,
1802 struct ath_atx_tid *tid, 1712 struct ath_atx_tid *tid)
1803 bool bh_flag) 1713
1804{ 1714{
1805 struct ath_buf *bf; 1715 struct ath_buf *bf;
1806 struct list_head bf_head; 1716 struct list_head bf_head;
@@ -1821,18 +1731,12 @@ static void ath_tid_drain(struct ath_softc *sc,
1821 * do not indicate packets while holding txq spinlock. 1731 * do not indicate packets while holding txq spinlock.
1822 * unlock is intentional here 1732 * unlock is intentional here
1823 */ 1733 */
1824 if (likely(bh_flag)) 1734 spin_unlock(&txq->axq_lock);
1825 spin_unlock_bh(&txq->axq_lock);
1826 else
1827 spin_unlock(&txq->axq_lock);
1828 1735
1829 /* complete this sub-frame */ 1736 /* complete this sub-frame */
1830 ath_tx_complete_buf(sc, bf, &bf_head, 0, 0); 1737 ath_tx_complete_buf(sc, bf, &bf_head, 0, 0);
1831 1738
1832 if (likely(bh_flag)) 1739 spin_lock(&txq->axq_lock);
1833 spin_lock_bh(&txq->axq_lock);
1834 else
1835 spin_lock(&txq->axq_lock);
1836 } 1740 }
1837 1741
1838 /* 1742 /*
@@ -1851,8 +1755,7 @@ static void ath_tid_drain(struct ath_softc *sc,
1851 */ 1755 */
1852 1756
1853static void ath_txq_drain_pending_buffers(struct ath_softc *sc, 1757static void ath_txq_drain_pending_buffers(struct ath_softc *sc,
1854 struct ath_txq *txq, 1758 struct ath_txq *txq)
1855 bool bh_flag)
1856{ 1759{
1857 struct ath_atx_ac *ac, *ac_tmp; 1760 struct ath_atx_ac *ac, *ac_tmp;
1858 struct ath_atx_tid *tid, *tid_tmp; 1761 struct ath_atx_tid *tid, *tid_tmp;
@@ -1863,51 +1766,32 @@ static void ath_txq_drain_pending_buffers(struct ath_softc *sc,
1863 list_for_each_entry_safe(tid, tid_tmp, &ac->tid_q, list) { 1766 list_for_each_entry_safe(tid, tid_tmp, &ac->tid_q, list) {
1864 list_del(&tid->list); 1767 list_del(&tid->list);
1865 tid->sched = false; 1768 tid->sched = false;
1866 ath_tid_drain(sc, txq, tid, bh_flag); 1769 ath_tid_drain(sc, txq, tid);
1867 } 1770 }
1868 } 1771 }
1869} 1772}
1870 1773
1871static int ath_tx_start_dma(struct ath_softc *sc, 1774static void ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
1872 struct sk_buff *skb, 1775 struct sk_buff *skb, struct scatterlist *sg,
1873 struct scatterlist *sg, 1776 struct ath_tx_control *txctl)
1874 u32 n_sg,
1875 struct ath_tx_control *txctl)
1876{ 1777{
1877 struct ath_node *an = txctl->an; 1778 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1878 struct ath_buf *bf = NULL; 1779 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1879 struct list_head bf_head;
1880 struct ath_desc *ds;
1881 struct ath_hal *ah = sc->sc_ah;
1882 struct ath_txq *txq;
1883 struct ath_tx_info_priv *tx_info_priv; 1780 struct ath_tx_info_priv *tx_info_priv;
1884 struct ath_rc_series *rcs; 1781 struct ath_rc_series *rcs;
1885 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1782 int hdrlen;
1886 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1783 __le16 fc;
1887 __le16 fc = hdr->frame_control;
1888
1889 if (unlikely(txctl->flags & ATH9K_TXDESC_CAB))
1890 txq = sc->sc_cabq;
1891 else
1892 txq = &sc->sc_txq[txctl->qnum];
1893 1784
1894 /* For each sglist entry, allocate an ath_buf for DMA */ 1785 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1895 INIT_LIST_HEAD(&bf_head); 1786 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
1896 spin_lock_bh(&sc->sc_txbuflock); 1787 fc = hdr->frame_control;
1897 if (unlikely(list_empty(&sc->sc_txbuf))) { 1788 rcs = tx_info_priv->rcs;
1898 spin_unlock_bh(&sc->sc_txbuflock);
1899 return -ENOMEM;
1900 }
1901 1789
1902 bf = list_first_entry(&sc->sc_txbuf, struct ath_buf, list); 1790 ATH_TXBUF_RESET(bf);
1903 list_del(&bf->list);
1904 spin_unlock_bh(&sc->sc_txbuflock);
1905 1791
1906 list_add_tail(&bf->list, &bf_head); 1792 /* Frame type */
1907 1793
1908 /* set up this buffer */ 1794 bf->bf_frmlen = skb->len + FCS_LEN - (hdrlen & 3);
1909 ATH_TXBUF_RESET(bf);
1910 bf->bf_frmlen = txctl->frmlen;
1911 1795
1912 ieee80211_is_data(fc) ? 1796 ieee80211_is_data(fc) ?
1913 (bf->bf_state.bf_type |= BUF_DATA) : 1797 (bf->bf_state.bf_type |= BUF_DATA) :
@@ -1921,120 +1805,142 @@ static int ath_tx_start_dma(struct ath_softc *sc,
1921 (sc->sc_flags & SC_OP_PREAMBLE_SHORT) ? 1805 (sc->sc_flags & SC_OP_PREAMBLE_SHORT) ?
1922 (bf->bf_state.bf_type |= BUF_SHORT_PREAMBLE) : 1806 (bf->bf_state.bf_type |= BUF_SHORT_PREAMBLE) :
1923 (bf->bf_state.bf_type &= ~BUF_SHORT_PREAMBLE); 1807 (bf->bf_state.bf_type &= ~BUF_SHORT_PREAMBLE);
1808 (sc->hw->conf.ht.enabled &&
1809 (tx_info->flags & IEEE80211_TX_CTL_AMPDU)) ?
1810 (bf->bf_state.bf_type |= BUF_HT) :
1811 (bf->bf_state.bf_type &= ~BUF_HT);
1812
1813 bf->bf_flags = setup_tx_flags(sc, skb, txctl->txq);
1814
1815 /* Crypto */
1816
1817 bf->bf_keytype = get_hw_crypto_keytype(skb);
1818
1819 if (bf->bf_keytype != ATH9K_KEY_TYPE_CLEAR) {
1820 bf->bf_frmlen += tx_info->control.hw_key->icv_len;
1821 bf->bf_keyix = tx_info->control.hw_key->hw_key_idx;
1822 } else {
1823 bf->bf_keyix = ATH9K_TXKEYIX_INVALID;
1824 }
1825
1826 /* Rate series */
1827
1828 setup_rate_retries(sc, skb);
1924 1829
1925 bf->bf_flags = txctl->flags;
1926 bf->bf_keytype = txctl->keytype;
1927 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1928 rcs = tx_info_priv->rcs;
1929 bf->bf_rcs[0] = rcs[0]; 1830 bf->bf_rcs[0] = rcs[0];
1930 bf->bf_rcs[1] = rcs[1]; 1831 bf->bf_rcs[1] = rcs[1];
1931 bf->bf_rcs[2] = rcs[2]; 1832 bf->bf_rcs[2] = rcs[2];
1932 bf->bf_rcs[3] = rcs[3]; 1833 bf->bf_rcs[3] = rcs[3];
1933 bf->bf_node = an; 1834
1835 /* Assign seqno, tidno */
1836
1837 if (bf_isht(bf) && (sc->sc_flags & SC_OP_TXAGGR))
1838 assign_aggr_tid_seqno(skb, bf);
1839
1840 /* DMA setup */
1841
1934 bf->bf_mpdu = skb; 1842 bf->bf_mpdu = skb;
1935 bf->bf_buf_addr = sg_dma_address(sg); 1843 bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data,
1844 skb->len, PCI_DMA_TODEVICE);
1845 bf->bf_buf_addr = bf->bf_dmacontext;
1846}
1847
1848/* FIXME: tx power */
1849static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
1850 struct scatterlist *sg, u32 n_sg,
1851 struct ath_tx_control *txctl)
1852{
1853 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
1854 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1855 struct ath_node *an = NULL;
1856 struct list_head bf_head;
1857 struct ath_desc *ds;
1858 struct ath_atx_tid *tid;
1859 struct ath_hal *ah = sc->sc_ah;
1860 int frm_type;
1861
1862 frm_type = get_hw_packet_type(skb);
1863
1864 INIT_LIST_HEAD(&bf_head);
1865 list_add_tail(&bf->list, &bf_head);
1936 1866
1937 /* setup descriptor */ 1867 /* setup descriptor */
1868
1938 ds = bf->bf_desc; 1869 ds = bf->bf_desc;
1939 ds->ds_link = 0; 1870 ds->ds_link = 0;
1940 ds->ds_data = bf->bf_buf_addr; 1871 ds->ds_data = bf->bf_buf_addr;
1941 1872
1942 /* 1873 /* Formulate first tx descriptor with tx controls */
1943 * Save the DMA context in the first ath_buf
1944 */
1945 bf->bf_dmacontext = txctl->dmacontext;
1946 1874
1947 /* 1875 ath9k_hw_set11n_txdesc(ah, ds, bf->bf_frmlen, frm_type, MAX_RATE_POWER,
1948 * Formulate first tx descriptor with tx controls. 1876 bf->bf_keyix, bf->bf_keytype, bf->bf_flags);
1949 */ 1877
1950 ath9k_hw_set11n_txdesc(ah, 1878 ath9k_hw_filltxdesc(ah, ds,
1951 ds, 1879 sg_dma_len(sg), /* segment length */
1952 bf->bf_frmlen, /* frame length */ 1880 true, /* first segment */
1953 txctl->atype, /* Atheros packet type */ 1881 (n_sg == 1) ? true : false, /* last segment */
1954 min(txctl->txpower, (u16)60), /* txpower */ 1882 ds); /* first descriptor */
1955 txctl->keyix, /* key cache index */
1956 txctl->keytype, /* key type */
1957 txctl->flags); /* flags */
1958 ath9k_hw_filltxdesc(ah,
1959 ds,
1960 sg_dma_len(sg), /* segment length */
1961 true, /* first segment */
1962 (n_sg == 1) ? true : false, /* last segment */
1963 ds); /* first descriptor */
1964 1883
1965 bf->bf_lastfrm = bf; 1884 bf->bf_lastfrm = bf;
1966 (txctl->ht) ?
1967 (bf->bf_state.bf_type |= BUF_HT) :
1968 (bf->bf_state.bf_type &= ~BUF_HT);
1969 1885
1970 spin_lock_bh(&txq->axq_lock); 1886 spin_lock_bh(&txctl->txq->axq_lock);
1887
1888 if (bf_isht(bf) && (sc->sc_flags & SC_OP_TXAGGR) &&
1889 tx_info->control.sta) {
1890 an = (struct ath_node *)tx_info->control.sta->drv_priv;
1891 tid = ATH_AN_2_TID(an, bf->bf_tidno);
1971 1892
1972 if (txctl->ht && (sc->sc_flags & SC_OP_TXAGGR)) { 1893 if (ath_aggr_query(sc, an, bf->bf_tidno)) {
1973 struct ath_atx_tid *tid = ATH_AN_2_TID(an, txctl->tidno);
1974 if (ath_aggr_query(sc, an, txctl->tidno)) {
1975 /* 1894 /*
1976 * Try aggregation if it's a unicast data frame 1895 * Try aggregation if it's a unicast data frame
1977 * and the destination is HT capable. 1896 * and the destination is HT capable.
1978 */ 1897 */
1979 ath_tx_send_ampdu(sc, txq, tid, &bf_head, txctl); 1898 ath_tx_send_ampdu(sc, tid, &bf_head, txctl);
1980 } else { 1899 } else {
1981 /* 1900 /*
1982 * Send this frame as regular when ADDBA exchange 1901 * Send this frame as regular when ADDBA
1983 * is neither complete nor pending. 1902 * exchange is neither complete nor pending.
1984 */ 1903 */
1985 ath_tx_send_normal(sc, txq, tid, &bf_head); 1904 ath_tx_send_normal(sc, txctl->txq,
1905 tid, &bf_head);
1986 } 1906 }
1987 } else { 1907 } else {
1988 bf->bf_lastbf = bf; 1908 bf->bf_lastbf = bf;
1989 bf->bf_nframes = 1; 1909 bf->bf_nframes = 1;
1990 ath_buf_set_rate(sc, bf);
1991
1992 if (ieee80211_is_back_req(fc)) {
1993 /* This is required for resuming tid
1994 * during BAR completion */
1995 bf->bf_tidno = txctl->tidno;
1996 }
1997 1910
1998 ath_tx_txqaddbuf(sc, txq, &bf_head); 1911 ath_buf_set_rate(sc, bf);
1912 ath_tx_txqaddbuf(sc, txctl->txq, &bf_head);
1999 } 1913 }
2000 spin_unlock_bh(&txq->axq_lock); 1914
2001 return 0; 1915 spin_unlock_bh(&txctl->txq->axq_lock);
2002} 1916}
2003 1917
2004static void xmit_map_sg(struct ath_softc *sc, 1918int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb,
2005 struct sk_buff *skb, 1919 struct ath_tx_control *txctl)
2006 struct ath_tx_control *txctl)
2007{ 1920{
2008 struct ath_xmit_status tx_status; 1921 struct ath_buf *bf;
2009 struct ath_atx_tid *tid;
2010 struct scatterlist sg; 1922 struct scatterlist sg;
2011 1923
2012 txctl->dmacontext = pci_map_single(sc->pdev, skb->data, 1924 /* Check if a tx buffer is available */
2013 skb->len, PCI_DMA_TODEVICE); 1925
1926 bf = ath_tx_get_buffer(sc);
1927 if (!bf) {
1928 DPRINTF(sc, ATH_DBG_XMIT, "%s: TX buffers are full\n",
1929 __func__);
1930 return -1;
1931 }
1932
1933 ath_tx_setup_buffer(sc, bf, skb, &sg, txctl);
1934
1935 /* Setup S/G */
2014 1936
2015 /* setup S/G list */
2016 memset(&sg, 0, sizeof(struct scatterlist)); 1937 memset(&sg, 0, sizeof(struct scatterlist));
2017 sg_dma_address(&sg) = txctl->dmacontext; 1938 sg_dma_address(&sg) = bf->bf_dmacontext;
2018 sg_dma_len(&sg) = skb->len; 1939 sg_dma_len(&sg) = skb->len;
2019 1940
2020 if (ath_tx_start_dma(sc, skb, &sg, 1, txctl) != 0) { 1941 ath_tx_start_dma(sc, bf, &sg, 1, txctl);
2021 /*
2022 * We have to do drop frame here.
2023 */
2024 pci_unmap_single(sc->pdev, txctl->dmacontext,
2025 skb->len, PCI_DMA_TODEVICE);
2026
2027 tx_status.retries = 0;
2028 tx_status.flags = ATH_TX_ERROR;
2029 1942
2030 if (txctl->ht && (sc->sc_flags & SC_OP_TXAGGR)) { 1943 return 0;
2031 /* Reclaim the seqno. */
2032 tid = ATH_AN_2_TID((struct ath_node *)
2033 txctl->an, txctl->tidno);
2034 DECR(tid->seq_next, IEEE80211_SEQ_MAX);
2035 }
2036 ath_tx_complete(sc, skb, &tx_status, txctl->an);
2037 }
2038} 1944}
2039 1945
2040/* Initialize TX queue and h/w */ 1946/* Initialize TX queue and h/w */
@@ -2151,7 +2057,6 @@ struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype)
2151 txq->axq_depth = 0; 2057 txq->axq_depth = 0;
2152 txq->axq_aggr_depth = 0; 2058 txq->axq_aggr_depth = 0;
2153 txq->axq_totalqueued = 0; 2059 txq->axq_totalqueued = 0;
2154 txq->axq_intrcnt = 0;
2155 txq->axq_linkbuf = NULL; 2060 txq->axq_linkbuf = NULL;
2156 sc->sc_txqsetup |= 1<<qnum; 2061 sc->sc_txqsetup |= 1<<qnum;
2157 } 2062 }
@@ -2221,6 +2126,34 @@ int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype)
2221 return qnum; 2126 return qnum;
2222} 2127}
2223 2128
2129/* Get a transmit queue, if available */
2130
2131struct ath_txq *ath_test_get_txq(struct ath_softc *sc, struct sk_buff *skb)
2132{
2133 struct ath_txq *txq = NULL;
2134 int qnum;
2135
2136 qnum = ath_get_hal_qnum(skb_get_queue_mapping(skb), sc);
2137 txq = &sc->sc_txq[qnum];
2138
2139 spin_lock_bh(&txq->axq_lock);
2140
2141 /* Try to avoid running out of descriptors */
2142 if (txq->axq_depth >= (ATH_TXBUF - 20)) {
2143 DPRINTF(sc, ATH_DBG_FATAL,
2144 "%s: TX queue: %d is full, depth: %d\n",
2145 __func__, qnum, txq->axq_depth);
2146 ieee80211_stop_queue(sc->hw, skb_get_queue_mapping(skb));
2147 txq->stopped = 1;
2148 spin_unlock_bh(&txq->axq_lock);
2149 return NULL;
2150 }
2151
2152 spin_unlock_bh(&txq->axq_lock);
2153
2154 return txq;
2155}
2156
2224/* Update parameters for a transmit queue */ 2157/* Update parameters for a transmit queue */
2225 2158
2226int ath_txq_update(struct ath_softc *sc, int qnum, 2159int ath_txq_update(struct ath_softc *sc, int qnum,
@@ -2284,27 +2217,6 @@ int ath_cabq_update(struct ath_softc *sc)
2284 return 0; 2217 return 0;
2285} 2218}
2286 2219
2287int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb)
2288{
2289 struct ath_tx_control txctl;
2290 int error = 0;
2291
2292 memset(&txctl, 0, sizeof(struct ath_tx_control));
2293 error = ath_tx_prepare(sc, skb, &txctl);
2294 if (error == 0)
2295 /*
2296 * Start DMA mapping.
2297 * ath_tx_start_dma() will be called either synchronously
2298 * or asynchrounsly once DMA is complete.
2299 */
2300 xmit_map_sg(sc, skb, &txctl);
2301 else
2302 ath_node_put(sc, txctl.an, ATH9K_BH_STATUS_CHANGE);
2303
2304 /* failed packets will be dropped by the caller */
2305 return error;
2306}
2307
2308/* Deferred processing of transmit interrupt */ 2220/* Deferred processing of transmit interrupt */
2309 2221
2310void ath_tx_tasklet(struct ath_softc *sc) 2222void ath_tx_tasklet(struct ath_softc *sc)
@@ -2378,8 +2290,7 @@ void ath_tx_draintxq(struct ath_softc *sc,
2378 if (sc->sc_flags & SC_OP_TXAGGR) { 2290 if (sc->sc_flags & SC_OP_TXAGGR) {
2379 if (!retry_tx) { 2291 if (!retry_tx) {
2380 spin_lock_bh(&txq->axq_lock); 2292 spin_lock_bh(&txq->axq_lock);
2381 ath_txq_drain_pending_buffers(sc, txq, 2293 ath_txq_drain_pending_buffers(sc, txq);
2382 ATH9K_BH_STATUS_CHANGE);
2383 spin_unlock_bh(&txq->axq_lock); 2294 spin_unlock_bh(&txq->axq_lock);
2384 } 2295 }
2385 } 2296 }
@@ -2410,64 +2321,39 @@ u32 ath_txq_aggr_depth(struct ath_softc *sc, int qnum)
2410 return sc->sc_txq[qnum].axq_aggr_depth; 2321 return sc->sc_txq[qnum].axq_aggr_depth;
2411} 2322}
2412 2323
2413/* Check if an ADDBA is required. A valid node must be passed. */ 2324bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an, u8 tidno)
2414enum ATH_AGGR_CHECK ath_tx_aggr_check(struct ath_softc *sc,
2415 struct ath_node *an,
2416 u8 tidno)
2417{ 2325{
2418 struct ath_atx_tid *txtid; 2326 struct ath_atx_tid *txtid;
2419 DECLARE_MAC_BUF(mac);
2420 2327
2421 if (!(sc->sc_flags & SC_OP_TXAGGR)) 2328 if (!(sc->sc_flags & SC_OP_TXAGGR))
2422 return AGGR_NOT_REQUIRED; 2329 return false;
2423 2330
2424 /* ADDBA exchange must be completed before sending aggregates */
2425 txtid = ATH_AN_2_TID(an, tidno); 2331 txtid = ATH_AN_2_TID(an, tidno);
2426 2332
2427 if (txtid->addba_exchangecomplete) 2333 if (!(txtid->state & AGGR_ADDBA_COMPLETE)) {
2428 return AGGR_EXCHANGE_DONE; 2334 if (!(txtid->state & AGGR_ADDBA_PROGRESS) &&
2429
2430 if (txtid->cleanup_inprogress)
2431 return AGGR_CLEANUP_PROGRESS;
2432
2433 if (txtid->addba_exchangeinprogress)
2434 return AGGR_EXCHANGE_PROGRESS;
2435
2436 if (!txtid->addba_exchangecomplete) {
2437 if (!txtid->addba_exchangeinprogress &&
2438 (txtid->addba_exchangeattempts < ADDBA_EXCHANGE_ATTEMPTS)) { 2335 (txtid->addba_exchangeattempts < ADDBA_EXCHANGE_ATTEMPTS)) {
2439 txtid->addba_exchangeattempts++; 2336 txtid->addba_exchangeattempts++;
2440 return AGGR_REQUIRED; 2337 return true;
2441 } 2338 }
2442 } 2339 }
2443 2340
2444 return AGGR_NOT_REQUIRED; 2341 return false;
2445} 2342}
2446 2343
2447/* Start TX aggregation */ 2344/* Start TX aggregation */
2448 2345
2449int ath_tx_aggr_start(struct ath_softc *sc, 2346int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
2450 const u8 *addr, 2347 u16 tid, u16 *ssn)
2451 u16 tid,
2452 u16 *ssn)
2453{ 2348{
2454 struct ath_atx_tid *txtid; 2349 struct ath_atx_tid *txtid;
2455 struct ath_node *an; 2350 struct ath_node *an;
2456 2351
2457 spin_lock_bh(&sc->node_lock); 2352 an = (struct ath_node *)sta->drv_priv;
2458 an = ath_node_find(sc, (u8 *) addr);
2459 spin_unlock_bh(&sc->node_lock);
2460
2461 if (!an) {
2462 DPRINTF(sc, ATH_DBG_AGGR,
2463 "%s: Node not found to initialize "
2464 "TX aggregation\n", __func__);
2465 return -1;
2466 }
2467 2353
2468 if (sc->sc_flags & SC_OP_TXAGGR) { 2354 if (sc->sc_flags & SC_OP_TXAGGR) {
2469 txtid = ATH_AN_2_TID(an, tid); 2355 txtid = ATH_AN_2_TID(an, tid);
2470 txtid->addba_exchangeinprogress = 1; 2356 txtid->state |= AGGR_ADDBA_PROGRESS;
2471 ath_tx_pause_tid(sc, txtid); 2357 ath_tx_pause_tid(sc, txtid);
2472 } 2358 }
2473 2359
@@ -2476,24 +2362,31 @@ int ath_tx_aggr_start(struct ath_softc *sc,
2476 2362
2477/* Stop tx aggregation */ 2363/* Stop tx aggregation */
2478 2364
2479int ath_tx_aggr_stop(struct ath_softc *sc, 2365int ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
2480 const u8 *addr,
2481 u16 tid)
2482{ 2366{
2367 struct ath_node *an = (struct ath_node *)sta->drv_priv;
2368
2369 ath_tx_aggr_teardown(sc, an, tid);
2370 return 0;
2371}
2372
2373/* Resume tx aggregation */
2374
2375void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
2376{
2377 struct ath_atx_tid *txtid;
2483 struct ath_node *an; 2378 struct ath_node *an;
2484 2379
2485 spin_lock_bh(&sc->node_lock); 2380 an = (struct ath_node *)sta->drv_priv;
2486 an = ath_node_find(sc, (u8 *) addr);
2487 spin_unlock_bh(&sc->node_lock);
2488 2381
2489 if (!an) { 2382 if (sc->sc_flags & SC_OP_TXAGGR) {
2490 DPRINTF(sc, ATH_DBG_AGGR, 2383 txtid = ATH_AN_2_TID(an, tid);
2491 "%s: TX aggr stop for non-existent node\n", __func__); 2384 txtid->baw_size =
2492 return -1; 2385 IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
2386 txtid->state |= AGGR_ADDBA_COMPLETE;
2387 txtid->state &= ~AGGR_ADDBA_PROGRESS;
2388 ath_tx_resume_tid(sc, txtid);
2493 } 2389 }
2494
2495 ath_tx_aggr_teardown(sc, an, tid);
2496 return 0;
2497} 2390}
2498 2391
2499/* 2392/*
@@ -2503,8 +2396,7 @@ int ath_tx_aggr_stop(struct ath_softc *sc,
2503 * - Discard all retry frames from the s/w queue. 2396 * - Discard all retry frames from the s/w queue.
2504 */ 2397 */
2505 2398
2506void ath_tx_aggr_teardown(struct ath_softc *sc, 2399void ath_tx_aggr_teardown(struct ath_softc *sc, struct ath_node *an, u8 tid)
2507 struct ath_node *an, u8 tid)
2508{ 2400{
2509 struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid); 2401 struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid);
2510 struct ath_txq *txq = &sc->sc_txq[txtid->ac->qnum]; 2402 struct ath_txq *txq = &sc->sc_txq[txtid->ac->qnum];
@@ -2514,10 +2406,10 @@ void ath_tx_aggr_teardown(struct ath_softc *sc,
2514 2406
2515 DPRINTF(sc, ATH_DBG_AGGR, "%s: teardown TX aggregation\n", __func__); 2407 DPRINTF(sc, ATH_DBG_AGGR, "%s: teardown TX aggregation\n", __func__);
2516 2408
2517 if (txtid->cleanup_inprogress) /* cleanup is in progress */ 2409 if (txtid->state & AGGR_CLEANUP) /* cleanup is in progress */
2518 return; 2410 return;
2519 2411
2520 if (!txtid->addba_exchangecomplete) { 2412 if (!(txtid->state & AGGR_ADDBA_COMPLETE)) {
2521 txtid->addba_exchangeattempts = 0; 2413 txtid->addba_exchangeattempts = 0;
2522 return; 2414 return;
2523 } 2415 }
@@ -2547,9 +2439,9 @@ void ath_tx_aggr_teardown(struct ath_softc *sc,
2547 2439
2548 if (txtid->baw_head != txtid->baw_tail) { 2440 if (txtid->baw_head != txtid->baw_tail) {
2549 spin_unlock_bh(&txq->axq_lock); 2441 spin_unlock_bh(&txq->axq_lock);
2550 txtid->cleanup_inprogress = true; 2442 txtid->state |= AGGR_CLEANUP;
2551 } else { 2443 } else {
2552 txtid->addba_exchangecomplete = 0; 2444 txtid->state &= ~AGGR_ADDBA_COMPLETE;
2553 txtid->addba_exchangeattempts = 0; 2445 txtid->addba_exchangeattempts = 0;
2554 spin_unlock_bh(&txq->axq_lock); 2446 spin_unlock_bh(&txq->axq_lock);
2555 ath_tx_flush_tid(sc, txtid); 2447 ath_tx_flush_tid(sc, txtid);
@@ -2591,10 +2483,8 @@ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
2591 if (tid->paused) /* check next tid to keep h/w busy */ 2483 if (tid->paused) /* check next tid to keep h/w busy */
2592 continue; 2484 continue;
2593 2485
2594 if (!(tid->an->an_smmode == ATH_SM_PWRSAV_DYNAMIC) || 2486 if ((txq->axq_depth % 2) == 0)
2595 ((txq->axq_depth % 2) == 0)) {
2596 ath_tx_sched_aggr(sc, txq, tid); 2487 ath_tx_sched_aggr(sc, txq, tid);
2597 }
2598 2488
2599 /* 2489 /*
2600 * add tid to round-robin queue if more frames 2490 * add tid to round-robin queue if more frames
@@ -2625,72 +2515,67 @@ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
2625 2515
2626void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an) 2516void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
2627{ 2517{
2628 if (sc->sc_flags & SC_OP_TXAGGR) { 2518 struct ath_atx_tid *tid;
2629 struct ath_atx_tid *tid; 2519 struct ath_atx_ac *ac;
2630 struct ath_atx_ac *ac; 2520 int tidno, acno;
2631 int tidno, acno;
2632
2633 sc->sc_ht_info.maxampdu = ATH_AMPDU_LIMIT_DEFAULT;
2634 2521
2635 /* 2522 /*
2636 * Init per tid tx state 2523 * Init per tid tx state
2637 */ 2524 */
2638 for (tidno = 0, tid = &an->an_aggr.tx.tid[tidno]; 2525 for (tidno = 0, tid = &an->an_aggr.tx.tid[tidno];
2639 tidno < WME_NUM_TID; 2526 tidno < WME_NUM_TID;
2640 tidno++, tid++) { 2527 tidno++, tid++) {
2641 tid->an = an; 2528 tid->an = an;
2642 tid->tidno = tidno; 2529 tid->tidno = tidno;
2643 tid->seq_start = tid->seq_next = 0; 2530 tid->seq_start = tid->seq_next = 0;
2644 tid->baw_size = WME_MAX_BA; 2531 tid->baw_size = WME_MAX_BA;
2645 tid->baw_head = tid->baw_tail = 0; 2532 tid->baw_head = tid->baw_tail = 0;
2646 tid->sched = false; 2533 tid->sched = false;
2647 tid->paused = false; 2534 tid->paused = false;
2648 tid->cleanup_inprogress = false; 2535 tid->state &= ~AGGR_CLEANUP;
2649 INIT_LIST_HEAD(&tid->buf_q); 2536 INIT_LIST_HEAD(&tid->buf_q);
2650 2537
2651 acno = TID_TO_WME_AC(tidno); 2538 acno = TID_TO_WME_AC(tidno);
2652 tid->ac = &an->an_aggr.tx.ac[acno]; 2539 tid->ac = &an->an_aggr.tx.ac[acno];
2653 2540
2654 /* ADDBA state */ 2541 /* ADDBA state */
2655 tid->addba_exchangecomplete = 0; 2542 tid->state &= ~AGGR_ADDBA_COMPLETE;
2656 tid->addba_exchangeinprogress = 0; 2543 tid->state &= ~AGGR_ADDBA_PROGRESS;
2657 tid->addba_exchangeattempts = 0; 2544 tid->addba_exchangeattempts = 0;
2658 } 2545 }
2659 2546
2660 /* 2547 /*
2661 * Init per ac tx state 2548 * Init per ac tx state
2662 */ 2549 */
2663 for (acno = 0, ac = &an->an_aggr.tx.ac[acno]; 2550 for (acno = 0, ac = &an->an_aggr.tx.ac[acno];
2664 acno < WME_NUM_AC; acno++, ac++) { 2551 acno < WME_NUM_AC; acno++, ac++) {
2665 ac->sched = false; 2552 ac->sched = false;
2666 INIT_LIST_HEAD(&ac->tid_q); 2553 INIT_LIST_HEAD(&ac->tid_q);
2667 2554
2668 switch (acno) { 2555 switch (acno) {
2669 case WME_AC_BE: 2556 case WME_AC_BE:
2670 ac->qnum = ath_tx_get_qnum(sc, 2557 ac->qnum = ath_tx_get_qnum(sc,
2671 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE); 2558 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE);
2672 break; 2559 break;
2673 case WME_AC_BK: 2560 case WME_AC_BK:
2674 ac->qnum = ath_tx_get_qnum(sc, 2561 ac->qnum = ath_tx_get_qnum(sc,
2675 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BK); 2562 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BK);
2676 break; 2563 break;
2677 case WME_AC_VI: 2564 case WME_AC_VI:
2678 ac->qnum = ath_tx_get_qnum(sc, 2565 ac->qnum = ath_tx_get_qnum(sc,
2679 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_VI); 2566 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_VI);
2680 break; 2567 break;
2681 case WME_AC_VO: 2568 case WME_AC_VO:
2682 ac->qnum = ath_tx_get_qnum(sc, 2569 ac->qnum = ath_tx_get_qnum(sc,
2683 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_VO); 2570 ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_VO);
2684 break; 2571 break;
2685 }
2686 } 2572 }
2687 } 2573 }
2688} 2574}
2689 2575
2690/* Cleanupthe pending buffers for the node. */ 2576/* Cleanupthe pending buffers for the node. */
2691 2577
2692void ath_tx_node_cleanup(struct ath_softc *sc, 2578void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an)
2693 struct ath_node *an, bool bh_flag)
2694{ 2579{
2695 int i; 2580 int i;
2696 struct ath_atx_ac *ac, *ac_tmp; 2581 struct ath_atx_ac *ac, *ac_tmp;
@@ -2700,10 +2585,7 @@ void ath_tx_node_cleanup(struct ath_softc *sc,
2700 if (ATH_TXQ_SETUP(sc, i)) { 2585 if (ATH_TXQ_SETUP(sc, i)) {
2701 txq = &sc->sc_txq[i]; 2586 txq = &sc->sc_txq[i];
2702 2587
2703 if (likely(bh_flag)) 2588 spin_lock(&txq->axq_lock);
2704 spin_lock_bh(&txq->axq_lock);
2705 else
2706 spin_lock(&txq->axq_lock);
2707 2589
2708 list_for_each_entry_safe(ac, 2590 list_for_each_entry_safe(ac,
2709 ac_tmp, &txq->axq_acq, list) { 2591 ac_tmp, &txq->axq_acq, list) {
@@ -2718,36 +2600,14 @@ void ath_tx_node_cleanup(struct ath_softc *sc,
2718 tid_tmp, &ac->tid_q, list) { 2600 tid_tmp, &ac->tid_q, list) {
2719 list_del(&tid->list); 2601 list_del(&tid->list);
2720 tid->sched = false; 2602 tid->sched = false;
2721 ath_tid_drain(sc, txq, tid, bh_flag); 2603 ath_tid_drain(sc, txq, tid);
2722 tid->addba_exchangecomplete = 0; 2604 tid->state &= ~AGGR_ADDBA_COMPLETE;
2723 tid->addba_exchangeattempts = 0; 2605 tid->addba_exchangeattempts = 0;
2724 tid->cleanup_inprogress = false; 2606 tid->state &= ~AGGR_CLEANUP;
2725 } 2607 }
2726 } 2608 }
2727 2609
2728 if (likely(bh_flag)) 2610 spin_unlock(&txq->axq_lock);
2729 spin_unlock_bh(&txq->axq_lock);
2730 else
2731 spin_unlock(&txq->axq_lock);
2732 }
2733 }
2734}
2735
2736/* Cleanup per node transmit state */
2737
2738void ath_tx_node_free(struct ath_softc *sc, struct ath_node *an)
2739{
2740 if (sc->sc_flags & SC_OP_TXAGGR) {
2741 struct ath_atx_tid *tid;
2742 int tidno, i;
2743
2744 /* Init per tid rx state */
2745 for (tidno = 0, tid = &an->an_aggr.tx.tid[tidno];
2746 tidno < WME_NUM_TID;
2747 tidno++, tid++) {
2748
2749 for (i = 0; i < ATH_TID_MAX_BUFS; i++)
2750 ASSERT(tid->tx_buf[i] == NULL);
2751 } 2611 }
2752 } 2612 }
2753} 2613}
@@ -2758,6 +2618,8 @@ void ath_tx_cabq(struct ath_softc *sc, struct sk_buff *skb)
2758 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 2618 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2759 struct ath_tx_control txctl; 2619 struct ath_tx_control txctl;
2760 2620
2621 memset(&txctl, 0, sizeof(struct ath_tx_control));
2622
2761 /* 2623 /*
2762 * As a temporary workaround, assign seq# here; this will likely need 2624 * As a temporary workaround, assign seq# here; this will likely need
2763 * to be cleaned up to work better with Beacon transmission and virtual 2625 * to be cleaned up to work better with Beacon transmission and virtual
@@ -2785,23 +2647,18 @@ void ath_tx_cabq(struct ath_softc *sc, struct sk_buff *skb)
2785 memmove(skb->data, skb->data + padsize, hdrlen); 2647 memmove(skb->data, skb->data + padsize, hdrlen);
2786 } 2648 }
2787 2649
2650 txctl.txq = sc->sc_cabq;
2651
2788 DPRINTF(sc, ATH_DBG_XMIT, "%s: transmitting CABQ packet, skb: %p\n", 2652 DPRINTF(sc, ATH_DBG_XMIT, "%s: transmitting CABQ packet, skb: %p\n",
2789 __func__, 2653 __func__,
2790 skb); 2654 skb);
2791 2655
2792 memset(&txctl, 0, sizeof(struct ath_tx_control)); 2656 if (ath_tx_start(sc, skb, &txctl) != 0) {
2793 txctl.flags = ATH9K_TXDESC_CAB; 2657 DPRINTF(sc, ATH_DBG_XMIT, "%s: TX failed\n", __func__);
2794 if (ath_tx_prepare(sc, skb, &txctl) == 0) { 2658 goto exit;
2795 /*
2796 * Start DMA mapping.
2797 * ath_tx_start_dma() will be called either synchronously
2798 * or asynchrounsly once DMA is complete.
2799 */
2800 xmit_map_sg(sc, skb, &txctl);
2801 } else {
2802 ath_node_put(sc, txctl.an, ATH9K_BH_STATUS_CHANGE);
2803 DPRINTF(sc, ATH_DBG_XMIT, "%s: TX CABQ failed\n", __func__);
2804 dev_kfree_skb_any(skb);
2805 } 2659 }
2806}
2807 2660
2661 return;
2662exit:
2663 dev_kfree_skb_any(skb);
2664}
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index ecb02bdaab5b..3962b553fbf1 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -67,7 +67,7 @@
67#include <linux/moduleparam.h> 67#include <linux/moduleparam.h>
68#include <linux/firmware.h> 68#include <linux/firmware.h>
69#include <linux/jiffies.h> 69#include <linux/jiffies.h>
70#include <net/ieee80211.h> 70#include <linux/ieee80211.h>
71#include "atmel.h" 71#include "atmel.h"
72 72
73#define DRIVER_MAJOR 0 73#define DRIVER_MAJOR 0
@@ -569,7 +569,7 @@ static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data);
569static void atmel_command_irq(struct atmel_private *priv); 569static void atmel_command_irq(struct atmel_private *priv);
570static int atmel_validate_channel(struct atmel_private *priv, int channel); 570static int atmel_validate_channel(struct atmel_private *priv, int channel);
571static void atmel_management_frame(struct atmel_private *priv, 571static void atmel_management_frame(struct atmel_private *priv,
572 struct ieee80211_hdr_4addr *header, 572 struct ieee80211_hdr *header,
573 u16 frame_len, u8 rssi); 573 u16 frame_len, u8 rssi);
574static void atmel_management_timer(u_long a); 574static void atmel_management_timer(u_long a);
575static void atmel_send_command(struct atmel_private *priv, int command, 575static void atmel_send_command(struct atmel_private *priv, int command,
@@ -577,7 +577,7 @@ static void atmel_send_command(struct atmel_private *priv, int command,
577static int atmel_send_command_wait(struct atmel_private *priv, int command, 577static int atmel_send_command_wait(struct atmel_private *priv, int command,
578 void *cmd, int cmd_size); 578 void *cmd, int cmd_size);
579static void atmel_transmit_management_frame(struct atmel_private *priv, 579static void atmel_transmit_management_frame(struct atmel_private *priv,
580 struct ieee80211_hdr_4addr *header, 580 struct ieee80211_hdr *header,
581 u8 *body, int body_len); 581 u8 *body, int body_len);
582 582
583static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index); 583static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
@@ -785,7 +785,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
785{ 785{
786 static const u8 SNAP_RFC1024[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; 786 static const u8 SNAP_RFC1024[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
787 struct atmel_private *priv = netdev_priv(dev); 787 struct atmel_private *priv = netdev_priv(dev);
788 struct ieee80211_hdr_4addr header; 788 struct ieee80211_hdr header;
789 unsigned long flags; 789 unsigned long flags;
790 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; 790 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
791 791
@@ -823,7 +823,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
823 823
824 frame_ctl = IEEE80211_FTYPE_DATA; 824 frame_ctl = IEEE80211_FTYPE_DATA;
825 header.duration_id = 0; 825 header.duration_id = 0;
826 header.seq_ctl = 0; 826 header.seq_ctrl = 0;
827 if (priv->wep_is_on) 827 if (priv->wep_is_on)
828 frame_ctl |= IEEE80211_FCTL_PROTECTED; 828 frame_ctl |= IEEE80211_FCTL_PROTECTED;
829 if (priv->operating_mode == IW_MODE_ADHOC) { 829 if (priv->operating_mode == IW_MODE_ADHOC) {
@@ -840,7 +840,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
840 if (priv->use_wpa) 840 if (priv->use_wpa)
841 memcpy(&header.addr4, SNAP_RFC1024, 6); 841 memcpy(&header.addr4, SNAP_RFC1024, 6);
842 842
843 header.frame_ctl = cpu_to_le16(frame_ctl); 843 header.frame_control = cpu_to_le16(frame_ctl);
844 /* Copy the wireless header into the card */ 844 /* Copy the wireless header into the card */
845 atmel_copy_to_card(dev, buff, (unsigned char *)&header, DATA_FRAME_WS_HEADER_SIZE); 845 atmel_copy_to_card(dev, buff, (unsigned char *)&header, DATA_FRAME_WS_HEADER_SIZE);
846 /* Copy the packet sans its 802.3 header addresses which have been replaced */ 846 /* Copy the packet sans its 802.3 header addresses which have been replaced */
@@ -860,7 +860,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
860} 860}
861 861
862static void atmel_transmit_management_frame(struct atmel_private *priv, 862static void atmel_transmit_management_frame(struct atmel_private *priv,
863 struct ieee80211_hdr_4addr *header, 863 struct ieee80211_hdr *header,
864 u8 *body, int body_len) 864 u8 *body, int body_len)
865{ 865{
866 u16 buff; 866 u16 buff;
@@ -876,7 +876,7 @@ static void atmel_transmit_management_frame(struct atmel_private *priv,
876} 876}
877 877
878static void fast_rx_path(struct atmel_private *priv, 878static void fast_rx_path(struct atmel_private *priv,
879 struct ieee80211_hdr_4addr *header, 879 struct ieee80211_hdr *header,
880 u16 msdu_size, u16 rx_packet_loc, u32 crc) 880 u16 msdu_size, u16 rx_packet_loc, u32 crc)
881{ 881{
882 /* fast path: unfragmented packet copy directly into skbuf */ 882 /* fast path: unfragmented packet copy directly into skbuf */
@@ -914,12 +914,11 @@ static void fast_rx_path(struct atmel_private *priv,
914 } 914 }
915 915
916 memcpy(skbp, header->addr1, 6); /* destination address */ 916 memcpy(skbp, header->addr1, 6); /* destination address */
917 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 917 if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
918 memcpy(&skbp[6], header->addr3, 6); 918 memcpy(&skbp[6], header->addr3, 6);
919 else 919 else
920 memcpy(&skbp[6], header->addr2, 6); /* source address */ 920 memcpy(&skbp[6], header->addr2, 6); /* source address */
921 921
922 priv->dev->last_rx = jiffies;
923 skb->protocol = eth_type_trans(skb, priv->dev); 922 skb->protocol = eth_type_trans(skb, priv->dev);
924 skb->ip_summed = CHECKSUM_NONE; 923 skb->ip_summed = CHECKSUM_NONE;
925 netif_rx(skb); 924 netif_rx(skb);
@@ -950,7 +949,7 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
950} 949}
951 950
952static void frag_rx_path(struct atmel_private *priv, 951static void frag_rx_path(struct atmel_private *priv,
953 struct ieee80211_hdr_4addr *header, 952 struct ieee80211_hdr *header,
954 u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, 953 u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no,
955 u8 frag_no, int more_frags) 954 u8 frag_no, int more_frags)
956{ 955{
@@ -958,7 +957,7 @@ static void frag_rx_path(struct atmel_private *priv,
958 u8 source[6]; 957 u8 source[6];
959 struct sk_buff *skb; 958 struct sk_buff *skb;
960 959
961 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 960 if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
962 memcpy(source, header->addr3, 6); 961 memcpy(source, header->addr3, 6);
963 else 962 else
964 memcpy(source, header->addr2, 6); 963 memcpy(source, header->addr2, 6);
@@ -1026,7 +1025,6 @@ static void frag_rx_path(struct atmel_private *priv,
1026 memcpy(skb_put(skb, priv->frag_len + 12), 1025 memcpy(skb_put(skb, priv->frag_len + 12),
1027 priv->rx_buf, 1026 priv->rx_buf,
1028 priv->frag_len + 12); 1027 priv->frag_len + 12);
1029 priv->dev->last_rx = jiffies;
1030 skb->protocol = eth_type_trans(skb, priv->dev); 1028 skb->protocol = eth_type_trans(skb, priv->dev);
1031 skb->ip_summed = CHECKSUM_NONE; 1029 skb->ip_summed = CHECKSUM_NONE;
1032 netif_rx(skb); 1030 netif_rx(skb);
@@ -1041,7 +1039,7 @@ static void frag_rx_path(struct atmel_private *priv,
1041static void rx_done_irq(struct atmel_private *priv) 1039static void rx_done_irq(struct atmel_private *priv)
1042{ 1040{
1043 int i; 1041 int i;
1044 struct ieee80211_hdr_4addr header; 1042 struct ieee80211_hdr header;
1045 1043
1046 for (i = 0; 1044 for (i = 0;
1047 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID && 1045 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID &&
@@ -1068,10 +1066,10 @@ static void rx_done_irq(struct atmel_private *priv)
1068 goto next; 1066 goto next;
1069 } 1067 }
1070 1068
1071 /* Get header as far as end of seq_ctl */ 1069 /* Get header as far as end of seq_ctrl */
1072 atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24); 1070 atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24);
1073 frame_ctl = le16_to_cpu(header.frame_ctl); 1071 frame_ctl = le16_to_cpu(header.frame_control);
1074 seq_control = le16_to_cpu(header.seq_ctl); 1072 seq_control = le16_to_cpu(header.seq_ctrl);
1075 1073
1076 /* probe for CRC use here if needed once five packets have 1074 /* probe for CRC use here if needed once five packets have
1077 arrived with the same crc status, we assume we know what's 1075 arrived with the same crc status, we assume we know what's
@@ -1479,7 +1477,6 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
1479 struct net_device *dev; 1477 struct net_device *dev;
1480 struct atmel_private *priv; 1478 struct atmel_private *priv;
1481 int rc; 1479 int rc;
1482 DECLARE_MAC_BUF(mac);
1483 1480
1484 /* Create the network device object. */ 1481 /* Create the network device object. */
1485 dev = alloc_etherdev(sizeof(*priv)); 1482 dev = alloc_etherdev(sizeof(*priv));
@@ -1591,8 +1588,8 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
1591 if (!ent) 1588 if (!ent)
1592 printk(KERN_WARNING "atmel: unable to create /proc entry.\n"); 1589 printk(KERN_WARNING "atmel: unable to create /proc entry.\n");
1593 1590
1594 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %s\n", 1591 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %pM\n",
1595 dev->name, DRIVER_MAJOR, DRIVER_MINOR, print_mac(mac, dev->dev_addr)); 1592 dev->name, DRIVER_MAJOR, DRIVER_MINOR, dev->dev_addr);
1596 1593
1597 return dev; 1594 return dev;
1598 1595
@@ -1822,7 +1819,7 @@ static int atmel_set_encodeext(struct net_device *dev,
1822 /* Determine and validate the key index */ 1819 /* Determine and validate the key index */
1823 idx = encoding->flags & IW_ENCODE_INDEX; 1820 idx = encoding->flags & IW_ENCODE_INDEX;
1824 if (idx) { 1821 if (idx) {
1825 if (idx < 1 || idx > WEP_KEYS) 1822 if (idx < 1 || idx > 4)
1826 return -EINVAL; 1823 return -EINVAL;
1827 idx--; 1824 idx--;
1828 } else 1825 } else
@@ -1885,7 +1882,7 @@ static int atmel_get_encodeext(struct net_device *dev,
1885 1882
1886 idx = encoding->flags & IW_ENCODE_INDEX; 1883 idx = encoding->flags & IW_ENCODE_INDEX;
1887 if (idx) { 1884 if (idx) {
1888 if (idx < 1 || idx > WEP_KEYS) 1885 if (idx < 1 || idx > 4)
1889 return -EINVAL; 1886 return -EINVAL;
1890 idx--; 1887 idx--;
1891 } else 1888 } else
@@ -2800,7 +2797,7 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability,
2800 u8 channel) 2797 u8 channel)
2801{ 2798{
2802 int rejoin = 0; 2799 int rejoin = 0;
2803 int new = capability & MFIE_TYPE_POWER_CONSTRAINT ? 2800 int new = capability & WLAN_CAPABILITY_SHORT_PREAMBLE ?
2804 SHORT_PREAMBLE : LONG_PREAMBLE; 2801 SHORT_PREAMBLE : LONG_PREAMBLE;
2805 2802
2806 if (priv->preamble != new) { 2803 if (priv->preamble != new) {
@@ -2829,19 +2826,19 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability,
2829static void send_authentication_request(struct atmel_private *priv, u16 system, 2826static void send_authentication_request(struct atmel_private *priv, u16 system,
2830 u8 *challenge, int challenge_len) 2827 u8 *challenge, int challenge_len)
2831{ 2828{
2832 struct ieee80211_hdr_4addr header; 2829 struct ieee80211_hdr header;
2833 struct auth_body auth; 2830 struct auth_body auth;
2834 2831
2835 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); 2832 header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
2836 header.duration_id = cpu_to_le16(0x8000); 2833 header.duration_id = cpu_to_le16(0x8000);
2837 header.seq_ctl = 0; 2834 header.seq_ctrl = 0;
2838 memcpy(header.addr1, priv->CurrentBSSID, 6); 2835 memcpy(header.addr1, priv->CurrentBSSID, 6);
2839 memcpy(header.addr2, priv->dev->dev_addr, 6); 2836 memcpy(header.addr2, priv->dev->dev_addr, 6);
2840 memcpy(header.addr3, priv->CurrentBSSID, 6); 2837 memcpy(header.addr3, priv->CurrentBSSID, 6);
2841 2838
2842 if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1) 2839 if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1)
2843 /* no WEP for authentication frames with TrSeqNo 1 */ 2840 /* no WEP for authentication frames with TrSeqNo 1 */
2844 header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); 2841 header.frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
2845 2842
2846 auth.alg = cpu_to_le16(system); 2843 auth.alg = cpu_to_le16(system);
2847 2844
@@ -2864,7 +2861,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2864{ 2861{
2865 u8 *ssid_el_p; 2862 u8 *ssid_el_p;
2866 int bodysize; 2863 int bodysize;
2867 struct ieee80211_hdr_4addr header; 2864 struct ieee80211_hdr header;
2868 struct ass_req_format { 2865 struct ass_req_format {
2869 __le16 capability; 2866 __le16 capability;
2870 __le16 listen_interval; 2867 __le16 listen_interval;
@@ -2877,10 +2874,10 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2877 u8 rates[4]; 2874 u8 rates[4];
2878 } body; 2875 } body;
2879 2876
2880 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | 2877 header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2881 (is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ)); 2878 (is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ));
2882 header.duration_id = cpu_to_le16(0x8000); 2879 header.duration_id = cpu_to_le16(0x8000);
2883 header.seq_ctl = 0; 2880 header.seq_ctrl = 0;
2884 2881
2885 memcpy(header.addr1, priv->CurrentBSSID, 6); 2882 memcpy(header.addr1, priv->CurrentBSSID, 6);
2886 memcpy(header.addr2, priv->dev->dev_addr, 6); 2883 memcpy(header.addr2, priv->dev->dev_addr, 6);
@@ -2890,7 +2887,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2890 if (priv->wep_is_on) 2887 if (priv->wep_is_on)
2891 body.capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); 2888 body.capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
2892 if (priv->preamble == SHORT_PREAMBLE) 2889 if (priv->preamble == SHORT_PREAMBLE)
2893 body.capability |= cpu_to_le16(MFIE_TYPE_POWER_CONSTRAINT); 2890 body.capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
2894 2891
2895 body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period); 2892 body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period);
2896 2893
@@ -2904,10 +2901,10 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2904 bodysize = 12 + priv->SSID_size; 2901 bodysize = 12 + priv->SSID_size;
2905 } 2902 }
2906 2903
2907 ssid_el_p[0] = MFIE_TYPE_SSID; 2904 ssid_el_p[0] = WLAN_EID_SSID;
2908 ssid_el_p[1] = priv->SSID_size; 2905 ssid_el_p[1] = priv->SSID_size;
2909 memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size); 2906 memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size);
2910 ssid_el_p[2 + priv->SSID_size] = MFIE_TYPE_RATES; 2907 ssid_el_p[2 + priv->SSID_size] = WLAN_EID_SUPP_RATES;
2911 ssid_el_p[3 + priv->SSID_size] = 4; /* len of suported rates */ 2908 ssid_el_p[3 + priv->SSID_size] = 4; /* len of suported rates */
2912 memcpy(ssid_el_p + 4 + priv->SSID_size, atmel_basic_rates, 4); 2909 memcpy(ssid_el_p + 4 + priv->SSID_size, atmel_basic_rates, 4);
2913 2910
@@ -2915,9 +2912,9 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2915} 2912}
2916 2913
2917static int is_frame_from_current_bss(struct atmel_private *priv, 2914static int is_frame_from_current_bss(struct atmel_private *priv,
2918 struct ieee80211_hdr_4addr *header) 2915 struct ieee80211_hdr *header)
2919{ 2916{
2920 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 2917 if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
2921 return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0; 2918 return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0;
2922 else 2919 else
2923 return memcmp(header->addr2, priv->CurrentBSSID, 6) == 0; 2920 return memcmp(header->addr2, priv->CurrentBSSID, 6) == 0;
@@ -2965,7 +2962,7 @@ static int retrieve_bss(struct atmel_private *priv)
2965} 2962}
2966 2963
2967static void store_bss_info(struct atmel_private *priv, 2964static void store_bss_info(struct atmel_private *priv,
2968 struct ieee80211_hdr_4addr *header, u16 capability, 2965 struct ieee80211_hdr *header, u16 capability,
2969 u16 beacon_period, u8 channel, u8 rssi, u8 ssid_len, 2966 u16 beacon_period, u8 channel, u8 rssi, u8 ssid_len,
2970 u8 *ssid, int is_beacon) 2967 u8 *ssid, int is_beacon)
2971{ 2968{
@@ -3004,7 +3001,7 @@ static void store_bss_info(struct atmel_private *priv,
3004 else if (capability & WLAN_CAPABILITY_ESS) 3001 else if (capability & WLAN_CAPABILITY_ESS)
3005 priv->BSSinfo[index].BSStype =IW_MODE_INFRA; 3002 priv->BSSinfo[index].BSStype =IW_MODE_INFRA;
3006 3003
3007 priv->BSSinfo[index].preamble = capability & MFIE_TYPE_POWER_CONSTRAINT ? 3004 priv->BSSinfo[index].preamble = capability & WLAN_CAPABILITY_SHORT_PREAMBLE ?
3008 SHORT_PREAMBLE : LONG_PREAMBLE; 3005 SHORT_PREAMBLE : LONG_PREAMBLE;
3009} 3006}
3010 3007
@@ -3040,7 +3037,7 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
3040 } 3037 }
3041 } else if (system == WLAN_AUTH_SHARED_KEY) { 3038 } else if (system == WLAN_AUTH_SHARED_KEY) {
3042 if (trans_seq_no == 0x0002 && 3039 if (trans_seq_no == 0x0002 &&
3043 auth->el_id == MFIE_TYPE_CHALLENGE) { 3040 auth->el_id == WLAN_EID_CHALLENGE) {
3044 send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len); 3041 send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len);
3045 return; 3042 return;
3046 } else if (trans_seq_no == 0x0004) { 3043 } else if (trans_seq_no == 0x0004) {
@@ -3291,12 +3288,12 @@ static void atmel_smooth_qual(struct atmel_private *priv)
3291 3288
3292/* deals with incoming managment frames. */ 3289/* deals with incoming managment frames. */
3293static void atmel_management_frame(struct atmel_private *priv, 3290static void atmel_management_frame(struct atmel_private *priv,
3294 struct ieee80211_hdr_4addr *header, 3291 struct ieee80211_hdr *header,
3295 u16 frame_len, u8 rssi) 3292 u16 frame_len, u8 rssi)
3296{ 3293{
3297 u16 subtype; 3294 u16 subtype;
3298 3295
3299 subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE; 3296 subtype = le16_to_cpu(header->frame_control) & IEEE80211_FCTL_STYPE;
3300 switch (subtype) { 3297 switch (subtype) {
3301 case IEEE80211_STYPE_BEACON: 3298 case IEEE80211_STYPE_BEACON:
3302 case IEEE80211_STYPE_PROBE_RESP: 3299 case IEEE80211_STYPE_PROBE_RESP:
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 427b8203e3f9..a53c378e7484 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -718,7 +718,6 @@ struct b43_wldev {
718 718
719 bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */ 719 bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */
720 bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */ 720 bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */
721 bool short_slot; /* TRUE, if short slot timing is enabled. */
722 bool radio_hw_enable; /* saved state of radio hardware enabled state */ 721 bool radio_hw_enable; /* saved state of radio hardware enabled state */
723 bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */ 722 bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */
724 723
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 098f886976f6..6d65a02b7052 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -1387,13 +1387,11 @@ void b43_dma_handle_txstatus(struct b43_wldev *dev,
1387 1387
1388 info = IEEE80211_SKB_CB(meta->skb); 1388 info = IEEE80211_SKB_CB(meta->skb);
1389 1389
1390 memset(&info->status, 0, sizeof(info->status));
1391
1392 /* 1390 /*
1393 * Call back to inform the ieee80211 subsystem about 1391 * Call back to inform the ieee80211 subsystem about
1394 * the status of the transmission. 1392 * the status of the transmission.
1395 */ 1393 */
1396 frame_succeed = b43_fill_txstatus_report(info, status); 1394 frame_succeed = b43_fill_txstatus_report(dev, info, status);
1397#ifdef CONFIG_B43_DEBUG 1395#ifdef CONFIG_B43_DEBUG
1398 if (frame_succeed) 1396 if (frame_succeed)
1399 ring->nr_succeed_tx_packets++; 1397 ring->nr_succeed_tx_packets++;
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 14c44df584d0..ba7a5ab7fe1d 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -703,13 +703,11 @@ static void b43_set_slot_time(struct b43_wldev *dev, u16 slot_time)
703static void b43_short_slot_timing_enable(struct b43_wldev *dev) 703static void b43_short_slot_timing_enable(struct b43_wldev *dev)
704{ 704{
705 b43_set_slot_time(dev, 9); 705 b43_set_slot_time(dev, 9);
706 dev->short_slot = 1;
707} 706}
708 707
709static void b43_short_slot_timing_disable(struct b43_wldev *dev) 708static void b43_short_slot_timing_disable(struct b43_wldev *dev)
710{ 709{
711 b43_set_slot_time(dev, 20); 710 b43_set_slot_time(dev, 20);
712 dev->short_slot = 0;
713} 711}
714 712
715/* Enable a Generic IRQ. "mask" is the mask of which IRQs to enable. 713/* Enable a Generic IRQ. "mask" is the mask of which IRQs to enable.
@@ -1339,25 +1337,6 @@ u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
1339 return antenna_nr; 1337 return antenna_nr;
1340} 1338}
1341 1339
1342static int b43_antenna_from_ieee80211(struct b43_wldev *dev, u8 antenna)
1343{
1344 antenna = b43_ieee80211_antenna_sanitize(dev, antenna);
1345 switch (antenna) {
1346 case 0: /* default/diversity */
1347 return B43_ANTENNA_DEFAULT;
1348 case 1: /* Antenna 0 */
1349 return B43_ANTENNA0;
1350 case 2: /* Antenna 1 */
1351 return B43_ANTENNA1;
1352 case 3: /* Antenna 2 */
1353 return B43_ANTENNA2;
1354 case 4: /* Antenna 3 */
1355 return B43_ANTENNA3;
1356 default:
1357 return B43_ANTENNA_DEFAULT;
1358 }
1359}
1360
1361/* Convert a b43 antenna number value to the PHY TX control value. */ 1340/* Convert a b43 antenna number value to the PHY TX control value. */
1362static u16 b43_antenna_to_phyctl(int antenna) 1341static u16 b43_antenna_to_phyctl(int antenna)
1363{ 1342{
@@ -1399,7 +1378,7 @@ static void b43_write_beacon_template(struct b43_wldev *dev,
1399 len, ram_offset, shm_size_offset, rate); 1378 len, ram_offset, shm_size_offset, rate);
1400 1379
1401 /* Write the PHY TX control parameters. */ 1380 /* Write the PHY TX control parameters. */
1402 antenna = b43_antenna_from_ieee80211(dev, info->antenna_sel_tx); 1381 antenna = B43_ANTENNA_DEFAULT;
1403 antenna = b43_antenna_to_phyctl(antenna); 1382 antenna = b43_antenna_to_phyctl(antenna);
1404 ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL); 1383 ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL);
1405 /* We can't send beacons with short preamble. Would get PHY errors. */ 1384 /* We can't send beacons with short preamble. Would get PHY errors. */
@@ -1693,25 +1672,6 @@ static void b43_update_templates(struct b43_wl *wl)
1693 queue_work(wl->hw->workqueue, &wl->beacon_update_trigger); 1672 queue_work(wl->hw->workqueue, &wl->beacon_update_trigger);
1694} 1673}
1695 1674
1696static void b43_set_ssid(struct b43_wldev *dev, const u8 * ssid, u8 ssid_len)
1697{
1698 u32 tmp;
1699 u16 i, len;
1700
1701 len = min((u16) ssid_len, (u16) 0x100);
1702 for (i = 0; i < len; i += sizeof(u32)) {
1703 tmp = (u32) (ssid[i + 0]);
1704 if (i + 1 < len)
1705 tmp |= (u32) (ssid[i + 1]) << 8;
1706 if (i + 2 < len)
1707 tmp |= (u32) (ssid[i + 2]) << 16;
1708 if (i + 3 < len)
1709 tmp |= (u32) (ssid[i + 3]) << 24;
1710 b43_shm_write32(dev, B43_SHM_SHARED, 0x380 + i, tmp);
1711 }
1712 b43_shm_write16(dev, B43_SHM_SHARED, 0x48, len);
1713}
1714
1715static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int) 1675static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int)
1716{ 1676{
1717 b43_time_lock(dev); 1677 b43_time_lock(dev);
@@ -3339,11 +3299,28 @@ init_failure:
3339 return err; 3299 return err;
3340} 3300}
3341 3301
3342static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 3302/* Write the short and long frame retry limit values. */
3303static void b43_set_retry_limits(struct b43_wldev *dev,
3304 unsigned int short_retry,
3305 unsigned int long_retry)
3306{
3307 /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
3308 * the chip-internal counter. */
3309 short_retry = min(short_retry, (unsigned int)0xF);
3310 long_retry = min(long_retry, (unsigned int)0xF);
3311
3312 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_SRLIMIT,
3313 short_retry);
3314 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_LRLIMIT,
3315 long_retry);
3316}
3317
3318static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
3343{ 3319{
3344 struct b43_wl *wl = hw_to_b43_wl(hw); 3320 struct b43_wl *wl = hw_to_b43_wl(hw);
3345 struct b43_wldev *dev; 3321 struct b43_wldev *dev;
3346 struct b43_phy *phy; 3322 struct b43_phy *phy;
3323 struct ieee80211_conf *conf = &hw->conf;
3347 unsigned long flags; 3324 unsigned long flags;
3348 int antenna; 3325 int antenna;
3349 int err = 0; 3326 int err = 0;
@@ -3358,6 +3335,13 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
3358 dev = wl->current_dev; 3335 dev = wl->current_dev;
3359 phy = &dev->phy; 3336 phy = &dev->phy;
3360 3337
3338 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
3339 b43_set_retry_limits(dev, conf->short_frame_max_tx_count,
3340 conf->long_frame_max_tx_count);
3341 changed &= ~IEEE80211_CONF_CHANGE_RETRY_LIMITS;
3342 if (!changed)
3343 goto out_unlock_mutex;
3344
3361 /* Disable IRQs while reconfiguring the device. 3345 /* Disable IRQs while reconfiguring the device.
3362 * This makes it possible to drop the spinlock throughout 3346 * This makes it possible to drop the spinlock throughout
3363 * the reconfiguration process. */ 3347 * the reconfiguration process. */
@@ -3375,16 +3359,6 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
3375 if (conf->channel->hw_value != phy->channel) 3359 if (conf->channel->hw_value != phy->channel)
3376 b43_switch_channel(dev, conf->channel->hw_value); 3360 b43_switch_channel(dev, conf->channel->hw_value);
3377 3361
3378 /* Enable/Disable ShortSlot timing. */
3379 if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) !=
3380 dev->short_slot) {
3381 B43_WARN_ON(phy->type != B43_PHYTYPE_G);
3382 if (conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)
3383 b43_short_slot_timing_enable(dev);
3384 else
3385 b43_short_slot_timing_disable(dev);
3386 }
3387
3388 dev->wl->radiotap_enabled = !!(conf->flags & IEEE80211_CONF_RADIOTAP); 3362 dev->wl->radiotap_enabled = !!(conf->flags & IEEE80211_CONF_RADIOTAP);
3389 3363
3390 /* Adjust the desired TX power level. */ 3364 /* Adjust the desired TX power level. */
@@ -3399,9 +3373,9 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
3399 } 3373 }
3400 3374
3401 /* Antennas for RX and management frame TX. */ 3375 /* Antennas for RX and management frame TX. */
3402 antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_tx); 3376 antenna = B43_ANTENNA_DEFAULT;
3403 b43_mgmtframe_txantenna(dev, antenna); 3377 b43_mgmtframe_txantenna(dev, antenna);
3404 antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_rx); 3378 antenna = B43_ANTENNA_DEFAULT;
3405 if (phy->ops->set_rx_antenna) 3379 if (phy->ops->set_rx_antenna)
3406 phy->ops->set_rx_antenna(dev, antenna); 3380 phy->ops->set_rx_antenna(dev, antenna);
3407 3381
@@ -3435,6 +3409,104 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
3435 return err; 3409 return err;
3436} 3410}
3437 3411
3412static void b43_update_basic_rates(struct b43_wldev *dev, u64 brates)
3413{
3414 struct ieee80211_supported_band *sband =
3415 dev->wl->hw->wiphy->bands[b43_current_band(dev->wl)];
3416 struct ieee80211_rate *rate;
3417 int i;
3418 u16 basic, direct, offset, basic_offset, rateptr;
3419
3420 for (i = 0; i < sband->n_bitrates; i++) {
3421 rate = &sband->bitrates[i];
3422
3423 if (b43_is_cck_rate(rate->hw_value)) {
3424 direct = B43_SHM_SH_CCKDIRECT;
3425 basic = B43_SHM_SH_CCKBASIC;
3426 offset = b43_plcp_get_ratecode_cck(rate->hw_value);
3427 offset &= 0xF;
3428 } else {
3429 direct = B43_SHM_SH_OFDMDIRECT;
3430 basic = B43_SHM_SH_OFDMBASIC;
3431 offset = b43_plcp_get_ratecode_ofdm(rate->hw_value);
3432 offset &= 0xF;
3433 }
3434
3435 rate = ieee80211_get_response_rate(sband, brates, rate->bitrate);
3436
3437 if (b43_is_cck_rate(rate->hw_value)) {
3438 basic_offset = b43_plcp_get_ratecode_cck(rate->hw_value);
3439 basic_offset &= 0xF;
3440 } else {
3441 basic_offset = b43_plcp_get_ratecode_ofdm(rate->hw_value);
3442 basic_offset &= 0xF;
3443 }
3444
3445 /*
3446 * Get the pointer that we need to point to
3447 * from the direct map
3448 */
3449 rateptr = b43_shm_read16(dev, B43_SHM_SHARED,
3450 direct + 2 * basic_offset);
3451 /* and write it to the basic map */
3452 b43_shm_write16(dev, B43_SHM_SHARED, basic + 2 * offset,
3453 rateptr);
3454 }
3455}
3456
3457static void b43_op_bss_info_changed(struct ieee80211_hw *hw,
3458 struct ieee80211_vif *vif,
3459 struct ieee80211_bss_conf *conf,
3460 u32 changed)
3461{
3462 struct b43_wl *wl = hw_to_b43_wl(hw);
3463 struct b43_wldev *dev;
3464 struct b43_phy *phy;
3465 unsigned long flags;
3466 u32 savedirqs;
3467
3468 mutex_lock(&wl->mutex);
3469
3470 dev = wl->current_dev;
3471 phy = &dev->phy;
3472
3473 /* Disable IRQs while reconfiguring the device.
3474 * This makes it possible to drop the spinlock throughout
3475 * the reconfiguration process. */
3476 spin_lock_irqsave(&wl->irq_lock, flags);
3477 if (b43_status(dev) < B43_STAT_STARTED) {
3478 spin_unlock_irqrestore(&wl->irq_lock, flags);
3479 goto out_unlock_mutex;
3480 }
3481 savedirqs = b43_interrupt_disable(dev, B43_IRQ_ALL);
3482 spin_unlock_irqrestore(&wl->irq_lock, flags);
3483 b43_synchronize_irq(dev);
3484
3485 b43_mac_suspend(dev);
3486
3487 if (changed & BSS_CHANGED_BASIC_RATES)
3488 b43_update_basic_rates(dev, conf->basic_rates);
3489
3490 if (changed & BSS_CHANGED_ERP_SLOT) {
3491 if (conf->use_short_slot)
3492 b43_short_slot_timing_enable(dev);
3493 else
3494 b43_short_slot_timing_disable(dev);
3495 }
3496
3497 b43_mac_enable(dev);
3498
3499 spin_lock_irqsave(&wl->irq_lock, flags);
3500 b43_interrupt_enable(dev, savedirqs);
3501 /* XXX: why? */
3502 mmiowb();
3503 spin_unlock_irqrestore(&wl->irq_lock, flags);
3504 out_unlock_mutex:
3505 mutex_unlock(&wl->mutex);
3506
3507 return;
3508}
3509
3438static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 3510static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3439 const u8 *local_addr, const u8 *addr, 3511 const u8 *local_addr, const u8 *addr,
3440 struct ieee80211_key_conf *key) 3512 struct ieee80211_key_conf *key)
@@ -3445,7 +3517,6 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3445 u8 algorithm; 3517 u8 algorithm;
3446 u8 index; 3518 u8 index;
3447 int err; 3519 int err;
3448 DECLARE_MAC_BUF(mac);
3449 3520
3450 if (modparam_nohwcrypt) 3521 if (modparam_nohwcrypt)
3451 return -ENOSPC; /* User disabled HW-crypto */ 3522 return -ENOSPC; /* User disabled HW-crypto */
@@ -3533,9 +3604,9 @@ out_unlock:
3533 mutex_unlock(&wl->mutex); 3604 mutex_unlock(&wl->mutex);
3534 if (!err) { 3605 if (!err) {
3535 b43dbg(wl, "%s hardware based encryption for keyidx: %d, " 3606 b43dbg(wl, "%s hardware based encryption for keyidx: %d, "
3536 "mac: %s\n", 3607 "mac: %pM\n",
3537 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, 3608 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
3538 print_mac(mac, addr)); 3609 addr);
3539 } 3610 }
3540 return err; 3611 return err;
3541} 3612}
@@ -3598,8 +3669,6 @@ static int b43_op_config_interface(struct ieee80211_hw *hw,
3598 if (b43_is_mode(wl, NL80211_IFTYPE_AP) || 3669 if (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
3599 b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT)) { 3670 b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT)) {
3600 B43_WARN_ON(vif->type != wl->if_type); 3671 B43_WARN_ON(vif->type != wl->if_type);
3601 if (conf->changed & IEEE80211_IFCC_SSID)
3602 b43_set_ssid(dev, conf->ssid, conf->ssid_len);
3603 if (conf->changed & IEEE80211_IFCC_BEACON) 3672 if (conf->changed & IEEE80211_IFCC_BEACON)
3604 b43_update_templates(wl); 3673 b43_update_templates(wl);
3605 } else if (b43_is_mode(wl, NL80211_IFTYPE_ADHOC)) { 3674 } else if (b43_is_mode(wl, NL80211_IFTYPE_ADHOC)) {
@@ -3878,22 +3947,6 @@ static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev)
3878#endif /* CONFIG_SSB_DRIVER_PCICORE */ 3947#endif /* CONFIG_SSB_DRIVER_PCICORE */
3879} 3948}
3880 3949
3881/* Write the short and long frame retry limit values. */
3882static void b43_set_retry_limits(struct b43_wldev *dev,
3883 unsigned int short_retry,
3884 unsigned int long_retry)
3885{
3886 /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
3887 * the chip-internal counter. */
3888 short_retry = min(short_retry, (unsigned int)0xF);
3889 long_retry = min(long_retry, (unsigned int)0xF);
3890
3891 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_SRLIMIT,
3892 short_retry);
3893 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_LRLIMIT,
3894 long_retry);
3895}
3896
3897static void b43_set_synth_pu_delay(struct b43_wldev *dev, bool idle) 3950static void b43_set_synth_pu_delay(struct b43_wldev *dev, bool idle)
3898{ 3951{
3899 u16 pu_delay; 3952 u16 pu_delay;
@@ -4214,26 +4267,6 @@ static void b43_op_stop(struct ieee80211_hw *hw)
4214 cancel_work_sync(&(wl->txpower_adjust_work)); 4267 cancel_work_sync(&(wl->txpower_adjust_work));
4215} 4268}
4216 4269
4217static int b43_op_set_retry_limit(struct ieee80211_hw *hw,
4218 u32 short_retry_limit, u32 long_retry_limit)
4219{
4220 struct b43_wl *wl = hw_to_b43_wl(hw);
4221 struct b43_wldev *dev;
4222 int err = 0;
4223
4224 mutex_lock(&wl->mutex);
4225 dev = wl->current_dev;
4226 if (unlikely(!dev || (b43_status(dev) < B43_STAT_INITIALIZED))) {
4227 err = -ENODEV;
4228 goto out_unlock;
4229 }
4230 b43_set_retry_limits(dev, short_retry_limit, long_retry_limit);
4231out_unlock:
4232 mutex_unlock(&wl->mutex);
4233
4234 return err;
4235}
4236
4237static int b43_op_beacon_set_tim(struct ieee80211_hw *hw, 4270static int b43_op_beacon_set_tim(struct ieee80211_hw *hw,
4238 struct ieee80211_sta *sta, bool set) 4271 struct ieee80211_sta *sta, bool set)
4239{ 4272{
@@ -4263,6 +4296,7 @@ static const struct ieee80211_ops b43_hw_ops = {
4263 .add_interface = b43_op_add_interface, 4296 .add_interface = b43_op_add_interface,
4264 .remove_interface = b43_op_remove_interface, 4297 .remove_interface = b43_op_remove_interface,
4265 .config = b43_op_config, 4298 .config = b43_op_config,
4299 .bss_info_changed = b43_op_bss_info_changed,
4266 .config_interface = b43_op_config_interface, 4300 .config_interface = b43_op_config_interface,
4267 .configure_filter = b43_op_configure_filter, 4301 .configure_filter = b43_op_configure_filter,
4268 .set_key = b43_op_set_key, 4302 .set_key = b43_op_set_key,
@@ -4270,7 +4304,6 @@ static const struct ieee80211_ops b43_hw_ops = {
4270 .get_tx_stats = b43_op_get_tx_stats, 4304 .get_tx_stats = b43_op_get_tx_stats,
4271 .start = b43_op_start, 4305 .start = b43_op_start,
4272 .stop = b43_op_stop, 4306 .stop = b43_op_stop,
4273 .set_retry_limit = b43_op_set_retry_limit,
4274 .set_tim = b43_op_beacon_set_tim, 4307 .set_tim = b43_op_beacon_set_tim,
4275 .sta_notify = b43_op_sta_notify, 4308 .sta_notify = b43_op_sta_notify,
4276}; 4309};
@@ -4588,7 +4621,7 @@ static int b43_wireless_init(struct ssb_device *dev)
4588 BIT(NL80211_IFTYPE_ADHOC); 4621 BIT(NL80211_IFTYPE_ADHOC);
4589 4622
4590 hw->queues = b43_modparam_qos ? 4 : 1; 4623 hw->queues = b43_modparam_qos ? 4 : 1;
4591 hw->max_altrates = 1; 4624 hw->max_rates = 2;
4592 SET_IEEE80211_DEV(hw, dev->dev); 4625 SET_IEEE80211_DEV(hw, dev->dev);
4593 if (is_valid_ether_addr(sprom->et1mac)) 4626 if (is_valid_ether_addr(sprom->et1mac))
4594 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac); 4627 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c
index 401591267592..1036bef8c4cc 100644
--- a/drivers/net/wireless/b43/pio.c
+++ b/drivers/net/wireless/b43/pio.c
@@ -587,9 +587,8 @@ void b43_pio_handle_txstatus(struct b43_wldev *dev,
587 spin_lock(&q->lock); /* IRQs are already disabled. */ 587 spin_lock(&q->lock); /* IRQs are already disabled. */
588 588
589 info = IEEE80211_SKB_CB(pack->skb); 589 info = IEEE80211_SKB_CB(pack->skb);
590 memset(&info->status, 0, sizeof(info->status));
591 590
592 b43_fill_txstatus_report(info, status); 591 b43_fill_txstatus_report(dev, info, status);
593 592
594 total_len = pack->skb->len + b43_txhdr_size(dev); 593 total_len = pack->skb->len + b43_txhdr_size(dev);
595 total_len = roundup(total_len, 4); 594 total_len = roundup(total_len, 4);
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index 2fabcf8f0474..adba89b816d4 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -185,7 +185,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
185 u8 *_txhdr, 185 u8 *_txhdr,
186 const unsigned char *fragment_data, 186 const unsigned char *fragment_data,
187 unsigned int fragment_len, 187 unsigned int fragment_len,
188 const struct ieee80211_tx_info *info, 188 struct ieee80211_tx_info *info,
189 u16 cookie) 189 u16 cookie)
190{ 190{
191 struct b43_txhdr *txhdr = (struct b43_txhdr *)_txhdr; 191 struct b43_txhdr *txhdr = (struct b43_txhdr *)_txhdr;
@@ -202,6 +202,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
202 u16 phy_ctl = 0; 202 u16 phy_ctl = 0;
203 u8 extra_ft = 0; 203 u8 extra_ft = 0;
204 struct ieee80211_rate *txrate; 204 struct ieee80211_rate *txrate;
205 struct ieee80211_tx_rate *rates;
205 206
206 memset(txhdr, 0, sizeof(*txhdr)); 207 memset(txhdr, 0, sizeof(*txhdr));
207 208
@@ -291,7 +292,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
291 phy_ctl |= B43_TXH_PHY_ENC_OFDM; 292 phy_ctl |= B43_TXH_PHY_ENC_OFDM;
292 else 293 else
293 phy_ctl |= B43_TXH_PHY_ENC_CCK; 294 phy_ctl |= B43_TXH_PHY_ENC_CCK;
294 if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE) 295 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
295 phy_ctl |= B43_TXH_PHY_SHORTPRMBL; 296 phy_ctl |= B43_TXH_PHY_SHORTPRMBL;
296 297
297 switch (b43_ieee80211_antenna_sanitize(dev, info->antenna_sel_tx)) { 298 switch (b43_ieee80211_antenna_sanitize(dev, info->antenna_sel_tx)) {
@@ -314,6 +315,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
314 B43_WARN_ON(1); 315 B43_WARN_ON(1);
315 } 316 }
316 317
318 rates = info->control.rates;
317 /* MAC control */ 319 /* MAC control */
318 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) 320 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
319 mac_ctl |= B43_TXH_MAC_ACK; 321 mac_ctl |= B43_TXH_MAC_ACK;
@@ -324,12 +326,22 @@ int b43_generate_txhdr(struct b43_wldev *dev,
324 mac_ctl |= B43_TXH_MAC_STMSDU; 326 mac_ctl |= B43_TXH_MAC_STMSDU;
325 if (phy->type == B43_PHYTYPE_A) 327 if (phy->type == B43_PHYTYPE_A)
326 mac_ctl |= B43_TXH_MAC_5GHZ; 328 mac_ctl |= B43_TXH_MAC_5GHZ;
327 if (info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT) 329
330 /* Overwrite rates[0].count to make the retry calculation
331 * in the tx status easier. need the actual retry limit to
332 * detect whether the fallback rate was used.
333 */
334 if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
335 (rates[0].count <= dev->wl->hw->conf.long_frame_max_tx_count)) {
336 rates[0].count = dev->wl->hw->conf.long_frame_max_tx_count;
328 mac_ctl |= B43_TXH_MAC_LONGFRAME; 337 mac_ctl |= B43_TXH_MAC_LONGFRAME;
338 } else {
339 rates[0].count = dev->wl->hw->conf.short_frame_max_tx_count;
340 }
329 341
330 /* Generate the RTS or CTS-to-self frame */ 342 /* Generate the RTS or CTS-to-self frame */
331 if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) || 343 if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
332 (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) { 344 (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) {
333 unsigned int len; 345 unsigned int len;
334 struct ieee80211_hdr *hdr; 346 struct ieee80211_hdr *hdr;
335 int rts_rate, rts_rate_fb; 347 int rts_rate, rts_rate_fb;
@@ -344,7 +356,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
344 rts_rate_fb = b43_calc_fallback_rate(rts_rate); 356 rts_rate_fb = b43_calc_fallback_rate(rts_rate);
345 rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); 357 rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb);
346 358
347 if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { 359 if (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
348 struct ieee80211_cts *cts; 360 struct ieee80211_cts *cts;
349 361
350 if (b43_is_old_txhdr_format(dev)) { 362 if (b43_is_old_txhdr_format(dev)) {
@@ -687,10 +699,18 @@ void b43_handle_txstatus(struct b43_wldev *dev,
687/* Fill out the mac80211 TXstatus report based on the b43-specific 699/* Fill out the mac80211 TXstatus report based on the b43-specific
688 * txstatus report data. This returns a boolean whether the frame was 700 * txstatus report data. This returns a boolean whether the frame was
689 * successfully transmitted. */ 701 * successfully transmitted. */
690bool b43_fill_txstatus_report(struct ieee80211_tx_info *report, 702bool b43_fill_txstatus_report(struct b43_wldev *dev,
703 struct ieee80211_tx_info *report,
691 const struct b43_txstatus *status) 704 const struct b43_txstatus *status)
692{ 705{
693 bool frame_success = 1; 706 bool frame_success = 1;
707 int retry_limit;
708
709 /* preserve the confiured retry limit before clearing the status
710 * The xmit function has overwritten the rc's value with the actual
711 * retry limit done by the hardware */
712 retry_limit = report->status.rates[0].count;
713 ieee80211_tx_info_clear_status(report);
694 714
695 if (status->acked) { 715 if (status->acked) {
696 /* The frame was ACKed. */ 716 /* The frame was ACKed. */
@@ -700,14 +720,32 @@ bool b43_fill_txstatus_report(struct ieee80211_tx_info *report,
700 if (!(report->flags & IEEE80211_TX_CTL_NO_ACK)) { 720 if (!(report->flags & IEEE80211_TX_CTL_NO_ACK)) {
701 /* ...but we expected an ACK. */ 721 /* ...but we expected an ACK. */
702 frame_success = 0; 722 frame_success = 0;
703 report->status.excessive_retries = 1;
704 } 723 }
705 } 724 }
706 if (status->frame_count == 0) { 725 if (status->frame_count == 0) {
707 /* The frame was not transmitted at all. */ 726 /* The frame was not transmitted at all. */
708 report->status.retry_count = 0; 727 report->status.rates[0].count = 0;
709 } else 728 } else if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) {
710 report->status.retry_count = status->frame_count - 1; 729 /*
730 * If the short retries (RTS, not data frame) have exceeded
731 * the limit, the hw will not have tried the selected rate,
732 * but will have used the fallback rate instead.
733 * Don't let the rate control count attempts for the selected
734 * rate in this case, otherwise the statistics will be off.
735 */
736 report->status.rates[0].count = 0;
737 report->status.rates[1].count = status->frame_count;
738 } else {
739 if (status->frame_count > retry_limit) {
740 report->status.rates[0].count = retry_limit;
741 report->status.rates[1].count = status->frame_count -
742 retry_limit;
743
744 } else {
745 report->status.rates[0].count = status->frame_count;
746 report->status.rates[1].idx = -1;
747 }
748 }
711 749
712 return frame_success; 750 return frame_success;
713} 751}
diff --git a/drivers/net/wireless/b43/xmit.h b/drivers/net/wireless/b43/xmit.h
index 0215faf47541..4fb2a190f7a7 100644
--- a/drivers/net/wireless/b43/xmit.h
+++ b/drivers/net/wireless/b43/xmit.h
@@ -178,7 +178,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
178 u8 * txhdr, 178 u8 * txhdr,
179 const unsigned char *fragment_data, 179 const unsigned char *fragment_data,
180 unsigned int fragment_len, 180 unsigned int fragment_len,
181 const struct ieee80211_tx_info *txctl, u16 cookie); 181 struct ieee80211_tx_info *txctl, u16 cookie);
182 182
183/* Transmit Status */ 183/* Transmit Status */
184struct b43_txstatus { 184struct b43_txstatus {
@@ -294,7 +294,8 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr);
294 294
295void b43_handle_txstatus(struct b43_wldev *dev, 295void b43_handle_txstatus(struct b43_wldev *dev,
296 const struct b43_txstatus *status); 296 const struct b43_txstatus *status);
297bool b43_fill_txstatus_report(struct ieee80211_tx_info *report, 297bool b43_fill_txstatus_report(struct b43_wldev *dev,
298 struct ieee80211_tx_info *report,
298 const struct b43_txstatus *status); 299 const struct b43_txstatus *status);
299 300
300void b43_tx_suspend(struct b43_wldev *dev); 301void b43_tx_suspend(struct b43_wldev *dev);
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index fb6819e40f38..3649fc367098 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -919,7 +919,7 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev,
919 if (!ring->txhdr_cache) 919 if (!ring->txhdr_cache)
920 goto err_kfree_meta; 920 goto err_kfree_meta;
921 921
922 dma_test = ssb_dma_map_single(dev->dev, 922 dma_test = ssb_dma_map_single(dev->dev,
923 ring->txhdr_cache, 923 ring->txhdr_cache,
924 sizeof(struct b43legacy_txhdr_fw3), 924 sizeof(struct b43legacy_txhdr_fw3),
925 DMA_TO_DEVICE); 925 DMA_TO_DEVICE);
@@ -1411,6 +1411,7 @@ void b43legacy_dma_handle_txstatus(struct b43legacy_wldev *dev,
1411 struct b43legacy_dmaring *ring; 1411 struct b43legacy_dmaring *ring;
1412 struct b43legacy_dmadesc_generic *desc; 1412 struct b43legacy_dmadesc_generic *desc;
1413 struct b43legacy_dmadesc_meta *meta; 1413 struct b43legacy_dmadesc_meta *meta;
1414 int retry_limit;
1414 int slot; 1415 int slot;
1415 1416
1416 ring = parse_cookie(dev, status->cookie, &slot); 1417 ring = parse_cookie(dev, status->cookie, &slot);
@@ -1437,25 +1438,42 @@ void b43legacy_dma_handle_txstatus(struct b43legacy_wldev *dev,
1437 struct ieee80211_tx_info *info; 1438 struct ieee80211_tx_info *info;
1438 BUG_ON(!meta->skb); 1439 BUG_ON(!meta->skb);
1439 info = IEEE80211_SKB_CB(meta->skb); 1440 info = IEEE80211_SKB_CB(meta->skb);
1440 /* Call back to inform the ieee80211 subsystem about the
1441 * status of the transmission.
1442 * Some fields of txstat are already filled in dma_tx().
1443 */
1444 1441
1445 memset(&info->status, 0, sizeof(info->status)); 1442 /* preserve the confiured retry limit before clearing the status
1443 * The xmit function has overwritten the rc's value with the actual
1444 * retry limit done by the hardware */
1445 retry_limit = info->status.rates[0].count;
1446 ieee80211_tx_info_clear_status(info);
1446 1447
1447 if (status->acked) { 1448 if (status->acked)
1448 info->flags |= IEEE80211_TX_STAT_ACK; 1449 info->flags |= IEEE80211_TX_STAT_ACK;
1450
1451 if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) {
1452 /*
1453 * If the short retries (RTS, not data frame) have exceeded
1454 * the limit, the hw will not have tried the selected rate,
1455 * but will have used the fallback rate instead.
1456 * Don't let the rate control count attempts for the selected
1457 * rate in this case, otherwise the statistics will be off.
1458 */
1459 info->status.rates[0].count = 0;
1460 info->status.rates[1].count = status->frame_count;
1449 } else { 1461 } else {
1450 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) 1462 if (status->frame_count > retry_limit) {
1451 info->status.excessive_retries = 1; 1463 info->status.rates[0].count = retry_limit;
1464 info->status.rates[1].count = status->frame_count -
1465 retry_limit;
1466
1467 } else {
1468 info->status.rates[0].count = status->frame_count;
1469 info->status.rates[1].idx = -1;
1470 }
1452 } 1471 }
1453 if (status->frame_count == 0) { 1472
1454 /* The frame was not transmitted at all. */ 1473 /* Call back to inform the ieee80211 subsystem about the
1455 info->status.retry_count = 0; 1474 * status of the transmission.
1456 } else 1475 * Some fields of txstat are already filled in dma_tx().
1457 info->status.retry_count = status->frame_count 1476 */
1458 - 1;
1459 ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb); 1477 ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb);
1460 /* skb is freed by ieee80211_tx_status_irqsafe() */ 1478 /* skb is freed by ieee80211_tx_status_irqsafe() */
1461 meta->skb = NULL; 1479 meta->skb = NULL;
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index c66d57560e7c..6c8eb4d2519a 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -1160,29 +1160,6 @@ static void b43legacy_update_templates(struct b43legacy_wl *wl)
1160 wl->beacon1_uploaded = 0; 1160 wl->beacon1_uploaded = 0;
1161} 1161}
1162 1162
1163static void b43legacy_set_ssid(struct b43legacy_wldev *dev,
1164 const u8 *ssid, u8 ssid_len)
1165{
1166 u32 tmp;
1167 u16 i;
1168 u16 len;
1169
1170 len = min((u16)ssid_len, (u16)0x100);
1171 for (i = 0; i < len; i += sizeof(u32)) {
1172 tmp = (u32)(ssid[i + 0]);
1173 if (i + 1 < len)
1174 tmp |= (u32)(ssid[i + 1]) << 8;
1175 if (i + 2 < len)
1176 tmp |= (u32)(ssid[i + 2]) << 16;
1177 if (i + 3 < len)
1178 tmp |= (u32)(ssid[i + 3]) << 24;
1179 b43legacy_shm_write32(dev, B43legacy_SHM_SHARED,
1180 0x380 + i, tmp);
1181 }
1182 b43legacy_shm_write16(dev, B43legacy_SHM_SHARED,
1183 0x48, len);
1184}
1185
1186static void b43legacy_set_beacon_int(struct b43legacy_wldev *dev, 1163static void b43legacy_set_beacon_int(struct b43legacy_wldev *dev,
1187 u16 beacon_int) 1164 u16 beacon_int)
1188{ 1165{
@@ -2556,26 +2533,27 @@ init_failure:
2556 return err; 2533 return err;
2557} 2534}
2558 2535
2559static int b43legacy_antenna_from_ieee80211(u8 antenna) 2536/* Write the short and long frame retry limit values. */
2537static void b43legacy_set_retry_limits(struct b43legacy_wldev *dev,
2538 unsigned int short_retry,
2539 unsigned int long_retry)
2560{ 2540{
2561 switch (antenna) { 2541 /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
2562 case 0: /* default/diversity */ 2542 * the chip-internal counter. */
2563 return B43legacy_ANTENNA_DEFAULT; 2543 short_retry = min(short_retry, (unsigned int)0xF);
2564 case 1: /* Antenna 0 */ 2544 long_retry = min(long_retry, (unsigned int)0xF);
2565 return B43legacy_ANTENNA0; 2545
2566 case 2: /* Antenna 1 */ 2546 b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0006, short_retry);
2567 return B43legacy_ANTENNA1; 2547 b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0007, long_retry);
2568 default:
2569 return B43legacy_ANTENNA_DEFAULT;
2570 }
2571} 2548}
2572 2549
2573static int b43legacy_op_dev_config(struct ieee80211_hw *hw, 2550static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
2574 struct ieee80211_conf *conf) 2551 u32 changed)
2575{ 2552{
2576 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); 2553 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2577 struct b43legacy_wldev *dev; 2554 struct b43legacy_wldev *dev;
2578 struct b43legacy_phy *phy; 2555 struct b43legacy_phy *phy;
2556 struct ieee80211_conf *conf = &hw->conf;
2579 unsigned long flags; 2557 unsigned long flags;
2580 unsigned int new_phymode = 0xFFFF; 2558 unsigned int new_phymode = 0xFFFF;
2581 int antenna_tx; 2559 int antenna_tx;
@@ -2583,13 +2561,21 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
2583 int err = 0; 2561 int err = 0;
2584 u32 savedirqs; 2562 u32 savedirqs;
2585 2563
2586 antenna_tx = b43legacy_antenna_from_ieee80211(conf->antenna_sel_tx); 2564 antenna_tx = B43legacy_ANTENNA_DEFAULT;
2587 antenna_rx = b43legacy_antenna_from_ieee80211(conf->antenna_sel_rx); 2565 antenna_rx = B43legacy_ANTENNA_DEFAULT;
2588 2566
2589 mutex_lock(&wl->mutex); 2567 mutex_lock(&wl->mutex);
2590 dev = wl->current_dev; 2568 dev = wl->current_dev;
2591 phy = &dev->phy; 2569 phy = &dev->phy;
2592 2570
2571 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
2572 b43legacy_set_retry_limits(dev,
2573 conf->short_frame_max_tx_count,
2574 conf->long_frame_max_tx_count);
2575 changed &= ~IEEE80211_CONF_CHANGE_RETRY_LIMITS;
2576 if (!changed)
2577 goto out_unlock_mutex;
2578
2593 /* Switch the PHY mode (if necessary). */ 2579 /* Switch the PHY mode (if necessary). */
2594 switch (conf->channel->band) { 2580 switch (conf->channel->band) {
2595 case IEEE80211_BAND_2GHZ: 2581 case IEEE80211_BAND_2GHZ:
@@ -2735,7 +2721,6 @@ static int b43legacy_op_config_interface(struct ieee80211_hw *hw,
2735 if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) { 2721 if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) {
2736 if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP)) { 2722 if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP)) {
2737 B43legacy_WARN_ON(vif->type != NL80211_IFTYPE_AP); 2723 B43legacy_WARN_ON(vif->type != NL80211_IFTYPE_AP);
2738 b43legacy_set_ssid(dev, conf->ssid, conf->ssid_len);
2739 if (conf->changed & IEEE80211_IFCC_BEACON) 2724 if (conf->changed & IEEE80211_IFCC_BEACON)
2740 b43legacy_update_templates(wl); 2725 b43legacy_update_templates(wl);
2741 } else if (b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC)) { 2726 } else if (b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC)) {
@@ -3002,20 +2987,6 @@ static void b43legacy_imcfglo_timeouts_workaround(struct b43legacy_wldev *dev)
3002#endif /* CONFIG_SSB_DRIVER_PCICORE */ 2987#endif /* CONFIG_SSB_DRIVER_PCICORE */
3003} 2988}
3004 2989
3005/* Write the short and long frame retry limit values. */
3006static void b43legacy_set_retry_limits(struct b43legacy_wldev *dev,
3007 unsigned int short_retry,
3008 unsigned int long_retry)
3009{
3010 /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
3011 * the chip-internal counter. */
3012 short_retry = min(short_retry, (unsigned int)0xF);
3013 long_retry = min(long_retry, (unsigned int)0xF);
3014
3015 b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0006, short_retry);
3016 b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0007, long_retry);
3017}
3018
3019static void b43legacy_set_synth_pu_delay(struct b43legacy_wldev *dev, 2990static void b43legacy_set_synth_pu_delay(struct b43legacy_wldev *dev,
3020 bool idle) { 2991 bool idle) {
3021 u16 pu_delay = 1050; 2992 u16 pu_delay = 1050;
@@ -3380,28 +3351,6 @@ static void b43legacy_op_stop(struct ieee80211_hw *hw)
3380 mutex_unlock(&wl->mutex); 3351 mutex_unlock(&wl->mutex);
3381} 3352}
3382 3353
3383static int b43legacy_op_set_retry_limit(struct ieee80211_hw *hw,
3384 u32 short_retry_limit,
3385 u32 long_retry_limit)
3386{
3387 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3388 struct b43legacy_wldev *dev;
3389 int err = 0;
3390
3391 mutex_lock(&wl->mutex);
3392 dev = wl->current_dev;
3393 if (unlikely(!dev ||
3394 (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED))) {
3395 err = -ENODEV;
3396 goto out_unlock;
3397 }
3398 b43legacy_set_retry_limits(dev, short_retry_limit, long_retry_limit);
3399out_unlock:
3400 mutex_unlock(&wl->mutex);
3401
3402 return err;
3403}
3404
3405static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw, 3354static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw,
3406 struct ieee80211_sta *sta, bool set) 3355 struct ieee80211_sta *sta, bool set)
3407{ 3356{
@@ -3427,7 +3376,6 @@ static const struct ieee80211_ops b43legacy_hw_ops = {
3427 .get_tx_stats = b43legacy_op_get_tx_stats, 3376 .get_tx_stats = b43legacy_op_get_tx_stats,
3428 .start = b43legacy_op_start, 3377 .start = b43legacy_op_start,
3429 .stop = b43legacy_op_stop, 3378 .stop = b43legacy_op_stop,
3430 .set_retry_limit = b43legacy_op_set_retry_limit,
3431 .set_tim = b43legacy_op_beacon_set_tim, 3379 .set_tim = b43legacy_op_beacon_set_tim,
3432}; 3380};
3433 3381
@@ -3710,7 +3658,7 @@ static int b43legacy_wireless_init(struct ssb_device *dev)
3710 BIT(NL80211_IFTYPE_WDS) | 3658 BIT(NL80211_IFTYPE_WDS) |
3711 BIT(NL80211_IFTYPE_ADHOC); 3659 BIT(NL80211_IFTYPE_ADHOC);
3712 hw->queues = 1; /* FIXME: hardware has more queues */ 3660 hw->queues = 1; /* FIXME: hardware has more queues */
3713 hw->max_altrates = 1; 3661 hw->max_rates = 2;
3714 SET_IEEE80211_DEV(hw, dev->dev); 3662 SET_IEEE80211_DEV(hw, dev->dev);
3715 if (is_valid_ether_addr(sprom->et1mac)) 3663 if (is_valid_ether_addr(sprom->et1mac))
3716 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac); 3664 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
diff --git a/drivers/net/wireless/b43legacy/pio.c b/drivers/net/wireless/b43legacy/pio.c
index a86c7647fa2d..746d5361bba0 100644
--- a/drivers/net/wireless/b43legacy/pio.c
+++ b/drivers/net/wireless/b43legacy/pio.c
@@ -491,6 +491,7 @@ void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
491 struct b43legacy_pioqueue *queue; 491 struct b43legacy_pioqueue *queue;
492 struct b43legacy_pio_txpacket *packet; 492 struct b43legacy_pio_txpacket *packet;
493 struct ieee80211_tx_info *info; 493 struct ieee80211_tx_info *info;
494 int retry_limit;
494 495
495 queue = parse_cookie(dev, status->cookie, &packet); 496 queue = parse_cookie(dev, status->cookie, &packet);
496 B43legacy_WARN_ON(!queue); 497 B43legacy_WARN_ON(!queue);
@@ -503,11 +504,37 @@ void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
503 sizeof(struct b43legacy_txhdr_fw3)); 504 sizeof(struct b43legacy_txhdr_fw3));
504 505
505 info = IEEE80211_SKB_CB(packet->skb); 506 info = IEEE80211_SKB_CB(packet->skb);
506 memset(&info->status, 0, sizeof(info->status)); 507
508 /* preserve the confiured retry limit before clearing the status
509 * The xmit function has overwritten the rc's value with the actual
510 * retry limit done by the hardware */
511 retry_limit = info->status.rates[0].count;
512 ieee80211_tx_info_clear_status(info);
507 513
508 if (status->acked) 514 if (status->acked)
509 info->flags |= IEEE80211_TX_STAT_ACK; 515 info->flags |= IEEE80211_TX_STAT_ACK;
510 info->status.retry_count = status->frame_count - 1; 516
517 if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) {
518 /*
519 * If the short retries (RTS, not data frame) have exceeded
520 * the limit, the hw will not have tried the selected rate,
521 * but will have used the fallback rate instead.
522 * Don't let the rate control count attempts for the selected
523 * rate in this case, otherwise the statistics will be off.
524 */
525 info->status.rates[0].count = 0;
526 info->status.rates[1].count = status->frame_count;
527 } else {
528 if (status->frame_count > retry_limit) {
529 info->status.rates[0].count = retry_limit;
530 info->status.rates[1].count = status->frame_count -
531 retry_limit;
532
533 } else {
534 info->status.rates[0].count = status->frame_count;
535 info->status.rates[1].idx = -1;
536 }
537 }
511 ieee80211_tx_status_irqsafe(dev->wl->hw, packet->skb); 538 ieee80211_tx_status_irqsafe(dev->wl->hw, packet->skb);
512 packet->skb = NULL; 539 packet->skb = NULL;
513 540
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c
index 65e833781608..12fca99f7578 100644
--- a/drivers/net/wireless/b43legacy/xmit.c
+++ b/drivers/net/wireless/b43legacy/xmit.c
@@ -188,7 +188,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
188 struct b43legacy_txhdr_fw3 *txhdr, 188 struct b43legacy_txhdr_fw3 *txhdr,
189 const unsigned char *fragment_data, 189 const unsigned char *fragment_data,
190 unsigned int fragment_len, 190 unsigned int fragment_len,
191 const struct ieee80211_tx_info *info, 191 struct ieee80211_tx_info *info,
192 u16 cookie) 192 u16 cookie)
193{ 193{
194 const struct ieee80211_hdr *wlhdr; 194 const struct ieee80211_hdr *wlhdr;
@@ -201,6 +201,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
201 u32 mac_ctl = 0; 201 u32 mac_ctl = 0;
202 u16 phy_ctl = 0; 202 u16 phy_ctl = 0;
203 struct ieee80211_rate *tx_rate; 203 struct ieee80211_rate *tx_rate;
204 struct ieee80211_tx_rate *rates;
204 205
205 wlhdr = (const struct ieee80211_hdr *)fragment_data; 206 wlhdr = (const struct ieee80211_hdr *)fragment_data;
206 207
@@ -274,7 +275,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
274 /* PHY TX Control word */ 275 /* PHY TX Control word */
275 if (rate_ofdm) 276 if (rate_ofdm)
276 phy_ctl |= B43legacy_TX4_PHY_OFDM; 277 phy_ctl |= B43legacy_TX4_PHY_OFDM;
277 if (dev->short_preamble) 278 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
278 phy_ctl |= B43legacy_TX4_PHY_SHORTPRMBL; 279 phy_ctl |= B43legacy_TX4_PHY_SHORTPRMBL;
279 switch (info->antenna_sel_tx) { 280 switch (info->antenna_sel_tx) {
280 case 0: 281 case 0:
@@ -291,6 +292,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
291 } 292 }
292 293
293 /* MAC control */ 294 /* MAC control */
295 rates = info->control.rates;
294 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) 296 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
295 mac_ctl |= B43legacy_TX4_MAC_ACK; 297 mac_ctl |= B43legacy_TX4_MAC_ACK;
296 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) 298 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
@@ -299,12 +301,22 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
299 mac_ctl |= B43legacy_TX4_MAC_STMSDU; 301 mac_ctl |= B43legacy_TX4_MAC_STMSDU;
300 if (rate_fb_ofdm) 302 if (rate_fb_ofdm)
301 mac_ctl |= B43legacy_TX4_MAC_FALLBACKOFDM; 303 mac_ctl |= B43legacy_TX4_MAC_FALLBACKOFDM;
302 if (info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT) 304
305 /* Overwrite rates[0].count to make the retry calculation
306 * in the tx status easier. need the actual retry limit to
307 * detect whether the fallback rate was used.
308 */
309 if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
310 (rates[0].count <= dev->wl->hw->conf.long_frame_max_tx_count)) {
311 rates[0].count = dev->wl->hw->conf.long_frame_max_tx_count;
303 mac_ctl |= B43legacy_TX4_MAC_LONGFRAME; 312 mac_ctl |= B43legacy_TX4_MAC_LONGFRAME;
313 } else {
314 rates[0].count = dev->wl->hw->conf.short_frame_max_tx_count;
315 }
304 316
305 /* Generate the RTS or CTS-to-self frame */ 317 /* Generate the RTS or CTS-to-self frame */
306 if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) || 318 if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
307 (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) { 319 (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) {
308 unsigned int len; 320 unsigned int len;
309 struct ieee80211_hdr *hdr; 321 struct ieee80211_hdr *hdr;
310 int rts_rate; 322 int rts_rate;
@@ -319,7 +331,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
319 if (rts_rate_fb_ofdm) 331 if (rts_rate_fb_ofdm)
320 mac_ctl |= B43legacy_TX4_MAC_CTSFALLBACKOFDM; 332 mac_ctl |= B43legacy_TX4_MAC_CTSFALLBACKOFDM;
321 333
322 if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { 334 if (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
323 ieee80211_ctstoself_get(dev->wl->hw, 335 ieee80211_ctstoself_get(dev->wl->hw,
324 info->control.vif, 336 info->control.vif,
325 fragment_data, 337 fragment_data,
@@ -362,7 +374,7 @@ int b43legacy_generate_txhdr(struct b43legacy_wldev *dev,
362 u8 *txhdr, 374 u8 *txhdr,
363 const unsigned char *fragment_data, 375 const unsigned char *fragment_data,
364 unsigned int fragment_len, 376 unsigned int fragment_len,
365 const struct ieee80211_tx_info *info, 377 struct ieee80211_tx_info *info,
366 u16 cookie) 378 u16 cookie)
367{ 379{
368 return generate_txhdr_fw3(dev, (struct b43legacy_txhdr_fw3 *)txhdr, 380 return generate_txhdr_fw3(dev, (struct b43legacy_txhdr_fw3 *)txhdr,
diff --git a/drivers/net/wireless/b43legacy/xmit.h b/drivers/net/wireless/b43legacy/xmit.h
index e56777e0feab..62e09d02788f 100644
--- a/drivers/net/wireless/b43legacy/xmit.h
+++ b/drivers/net/wireless/b43legacy/xmit.h
@@ -80,7 +80,7 @@ int b43legacy_generate_txhdr(struct b43legacy_wldev *dev,
80 u8 *txhdr, 80 u8 *txhdr,
81 const unsigned char *fragment_data, 81 const unsigned char *fragment_data,
82 unsigned int fragment_len, 82 unsigned int fragment_len,
83 const struct ieee80211_tx_info *info, 83 struct ieee80211_tx_info *info,
84 u16 cookie); 84 u16 cookie);
85 85
86 86
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index f106bc1585a4..5f64461aa54e 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -19,7 +19,6 @@ void hostap_dump_rx_80211(const char *name, struct sk_buff *skb,
19{ 19{
20 struct ieee80211_hdr_4addr *hdr; 20 struct ieee80211_hdr_4addr *hdr;
21 u16 fc; 21 u16 fc;
22 DECLARE_MAC_BUF(mac);
23 22
24 hdr = (struct ieee80211_hdr_4addr *) skb->data; 23 hdr = (struct ieee80211_hdr_4addr *) skb->data;
25 24
@@ -45,11 +44,11 @@ void hostap_dump_rx_80211(const char *name, struct sk_buff *skb,
45 printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id), 44 printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
46 le16_to_cpu(hdr->seq_ctl)); 45 le16_to_cpu(hdr->seq_ctl));
47 46
48 printk(KERN_DEBUG " A1=%s", print_mac(mac, hdr->addr1)); 47 printk(KERN_DEBUG " A1=%pM", hdr->addr1);
49 printk(" A2=%s", print_mac(mac, hdr->addr2)); 48 printk(" A2=%pM", hdr->addr2);
50 printk(" A3=%s", print_mac(mac, hdr->addr3)); 49 printk(" A3=%pM", hdr->addr3);
51 if (skb->len >= 30) 50 if (skb->len >= 30)
52 printk(" A4=%s", print_mac(mac, hdr->addr4)); 51 printk(" A4=%pM", hdr->addr4);
53 printk("\n"); 52 printk("\n");
54} 53}
55 54
@@ -68,7 +67,6 @@ int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb,
68 67
69 iface = netdev_priv(dev); 68 iface = netdev_priv(dev);
70 local = iface->local; 69 local = iface->local;
71 dev->last_rx = jiffies;
72 70
73 if (dev->type == ARPHRD_IEEE80211_PRISM) { 71 if (dev->type == ARPHRD_IEEE80211_PRISM) {
74 if (local->monitor_type == PRISM2_MONITOR_PRISM) { 72 if (local->monitor_type == PRISM2_MONITOR_PRISM) {
@@ -557,7 +555,6 @@ static int
557hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr_4addr *hdr, 555hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr_4addr *hdr,
558 u16 fc, struct net_device **wds) 556 u16 fc, struct net_device **wds)
559{ 557{
560 DECLARE_MAC_BUF(mac);
561 /* FIX: is this really supposed to accept WDS frames only in Master 558 /* FIX: is this really supposed to accept WDS frames only in Master
562 * mode? What about Repeater or Managed with WDS frames? */ 559 * mode? What about Repeater or Managed with WDS frames? */
563 if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) != 560 if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) !=
@@ -573,10 +570,10 @@ hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr_4addr *hdr,
573 hdr->addr1[4] != 0xff || hdr->addr1[5] != 0xff)) { 570 hdr->addr1[4] != 0xff || hdr->addr1[5] != 0xff)) {
574 /* RA (or BSSID) is not ours - drop */ 571 /* RA (or BSSID) is not ours - drop */
575 PDEBUG(DEBUG_EXTRA2, "%s: received WDS frame with " 572 PDEBUG(DEBUG_EXTRA2, "%s: received WDS frame with "
576 "not own or broadcast %s=%s\n", 573 "not own or broadcast %s=%pM\n",
577 local->dev->name, 574 local->dev->name,
578 fc & IEEE80211_FCTL_FROMDS ? "RA" : "BSSID", 575 fc & IEEE80211_FCTL_FROMDS ? "RA" : "BSSID",
579 print_mac(mac, hdr->addr1)); 576 hdr->addr1);
580 return -1; 577 return -1;
581 } 578 }
582 579
@@ -589,8 +586,8 @@ hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr_4addr *hdr,
589 /* require that WDS link has been registered with TA or the 586 /* require that WDS link has been registered with TA or the
590 * frame is from current AP when using 'AP client mode' */ 587 * frame is from current AP when using 'AP client mode' */
591 PDEBUG(DEBUG_EXTRA, "%s: received WDS[4 addr] frame " 588 PDEBUG(DEBUG_EXTRA, "%s: received WDS[4 addr] frame "
592 "from unknown TA=%s\n", 589 "from unknown TA=%pM\n",
593 local->dev->name, print_mac(mac, hdr->addr2)); 590 local->dev->name, hdr->addr2);
594 if (local->ap && local->ap->autom_ap_wds) 591 if (local->ap && local->ap->autom_ap_wds)
595 hostap_wds_link_oper(local, hdr->addr2, WDS_ADD); 592 hostap_wds_link_oper(local, hdr->addr2, WDS_ADD);
596 return -1; 593 return -1;
@@ -667,10 +664,8 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
667 strcmp(crypt->ops->name, "TKIP") == 0) { 664 strcmp(crypt->ops->name, "TKIP") == 0) {
668 if (net_ratelimit()) { 665 if (net_ratelimit()) {
669 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " 666 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
670 "received packet from " MAC_FMT "\n", 667 "received packet from %pM\n",
671 local->dev->name, 668 local->dev->name, hdr->addr2);
672 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
673 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
674 } 669 }
675 return -1; 670 return -1;
676 } 671 }
@@ -679,12 +674,8 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
679 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); 674 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
680 atomic_dec(&crypt->refcnt); 675 atomic_dec(&crypt->refcnt);
681 if (res < 0) { 676 if (res < 0) {
682 printk(KERN_DEBUG "%s: decryption failed (SA=" MAC_FMT 677 printk(KERN_DEBUG "%s: decryption failed (SA=%pM) res=%d\n",
683 ") res=%d\n", 678 local->dev->name, hdr->addr2, res);
684 local->dev->name,
685 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
686 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
687 res);
688 local->comm_tallies.rx_discards_wep_undecryptable++; 679 local->comm_tallies.rx_discards_wep_undecryptable++;
689 return -1; 680 return -1;
690 } 681 }
@@ -700,7 +691,6 @@ hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb,
700{ 691{
701 struct ieee80211_hdr_4addr *hdr; 692 struct ieee80211_hdr_4addr *hdr;
702 int res, hdrlen; 693 int res, hdrlen;
703 DECLARE_MAC_BUF(mac);
704 694
705 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) 695 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
706 return 0; 696 return 0;
@@ -713,8 +703,8 @@ hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb,
713 atomic_dec(&crypt->refcnt); 703 atomic_dec(&crypt->refcnt);
714 if (res < 0) { 704 if (res < 0) {
715 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" 705 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
716 " (SA=%s keyidx=%d)\n", 706 " (SA=%pM keyidx=%d)\n",
717 local->dev->name, print_mac(mac, hdr->addr2), keyidx); 707 local->dev->name, hdr->addr2, keyidx);
718 return -1; 708 return -1;
719 } 709 }
720 710
@@ -822,10 +812,8 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
822 * frames silently instead of filling system log with 812 * frames silently instead of filling system log with
823 * these reports. */ 813 * these reports. */
824 printk(KERN_DEBUG "%s: WEP decryption failed (not set)" 814 printk(KERN_DEBUG "%s: WEP decryption failed (not set)"
825 " (SA=" MAC_FMT ")\n", 815 " (SA=%pM)\n",
826 local->dev->name, 816 local->dev->name, hdr->addr2);
827 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
828 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
829#endif 817#endif
830 local->comm_tallies.rx_discards_wep_undecryptable++; 818 local->comm_tallies.rx_discards_wep_undecryptable++;
831 goto rx_dropped; 819 goto rx_dropped;
@@ -839,9 +827,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
839 (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0) 827 (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
840 { 828 {
841 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth " 829 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
842 "from " MAC_FMT "\n", dev->name, 830 "from %pM\n", dev->name, hdr->addr2);
843 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
844 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
845 /* TODO: could inform hostapd about this so that it 831 /* TODO: could inform hostapd about this so that it
846 * could send auth failure report */ 832 * could send auth failure report */
847 goto rx_dropped; 833 goto rx_dropped;
@@ -896,8 +882,6 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
896 from_assoc_ap = 1; 882 from_assoc_ap = 1;
897 } 883 }
898 884
899 dev->last_rx = jiffies;
900
901 if ((local->iw_mode == IW_MODE_MASTER || 885 if ((local->iw_mode == IW_MODE_MASTER ||
902 local->iw_mode == IW_MODE_REPEAT) && 886 local->iw_mode == IW_MODE_REPEAT) &&
903 !from_assoc_ap) { 887 !from_assoc_ap) {
@@ -1009,10 +993,8 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
1009 "unencrypted EAPOL frame\n", local->dev->name); 993 "unencrypted EAPOL frame\n", local->dev->name);
1010 } else { 994 } else {
1011 printk(KERN_DEBUG "%s: encryption configured, but RX " 995 printk(KERN_DEBUG "%s: encryption configured, but RX "
1012 "frame not encrypted (SA=" MAC_FMT ")\n", 996 "frame not encrypted (SA=%pM)\n",
1013 local->dev->name, 997 local->dev->name, hdr->addr2);
1014 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1015 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
1016 goto rx_dropped; 998 goto rx_dropped;
1017 } 999 }
1018 } 1000 }
@@ -1021,10 +1003,8 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
1021 !hostap_is_eapol_frame(local, skb)) { 1003 !hostap_is_eapol_frame(local, skb)) {
1022 if (net_ratelimit()) { 1004 if (net_ratelimit()) {
1023 printk(KERN_DEBUG "%s: dropped unencrypted RX data " 1005 printk(KERN_DEBUG "%s: dropped unencrypted RX data "
1024 "frame from " MAC_FMT " (drop_unencrypted=1)\n", 1006 "frame from %pM (drop_unencrypted=1)\n",
1025 dev->name, 1007 dev->name, hdr->addr2);
1026 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1027 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
1028 } 1008 }
1029 goto rx_dropped; 1009 goto rx_dropped;
1030 } 1010 }
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index 921c984416f8..075247188e64 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -17,7 +17,6 @@ void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
17{ 17{
18 struct ieee80211_hdr_4addr *hdr; 18 struct ieee80211_hdr_4addr *hdr;
19 u16 fc; 19 u16 fc;
20 DECLARE_MAC_BUF(mac);
21 20
22 hdr = (struct ieee80211_hdr_4addr *) skb->data; 21 hdr = (struct ieee80211_hdr_4addr *) skb->data;
23 22
@@ -41,11 +40,11 @@ void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
41 printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id), 40 printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
42 le16_to_cpu(hdr->seq_ctl)); 41 le16_to_cpu(hdr->seq_ctl));
43 42
44 printk(KERN_DEBUG " A1=%s", print_mac(mac, hdr->addr1)); 43 printk(KERN_DEBUG " A1=%pM", hdr->addr1);
45 printk(" A2=%s", print_mac(mac, hdr->addr2)); 44 printk(" A2=%pM", hdr->addr2);
46 printk(" A3=%s", print_mac(mac, hdr->addr3)); 45 printk(" A3=%pM", hdr->addr3);
47 if (skb->len >= 30) 46 if (skb->len >= 30)
48 printk(" A4=%s", print_mac(mac, hdr->addr4)); 47 printk(" A4=%pM", hdr->addr4);
49 printk("\n"); 48 printk("\n");
50} 49}
51 50
@@ -328,10 +327,8 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
328 hdr = (struct ieee80211_hdr_4addr *) skb->data; 327 hdr = (struct ieee80211_hdr_4addr *) skb->data;
329 if (net_ratelimit()) { 328 if (net_ratelimit()) {
330 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " 329 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
331 "TX packet to " MAC_FMT "\n", 330 "TX packet to %pM\n",
332 local->dev->name, 331 local->dev->name, hdr->addr1);
333 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
334 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
335 } 332 }
336 kfree_skb(skb); 333 kfree_skb(skb);
337 return NULL; 334 return NULL;
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index af3d4ef2a80b..dec3dbe1bf8f 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -94,7 +94,6 @@ static void ap_sta_hash_add(struct ap_data *ap, struct sta_info *sta)
94static void ap_sta_hash_del(struct ap_data *ap, struct sta_info *sta) 94static void ap_sta_hash_del(struct ap_data *ap, struct sta_info *sta)
95{ 95{
96 struct sta_info *s; 96 struct sta_info *s;
97 DECLARE_MAC_BUF(mac);
98 97
99 s = ap->sta_hash[STA_HASH(sta->addr)]; 98 s = ap->sta_hash[STA_HASH(sta->addr)];
100 if (s == NULL) return; 99 if (s == NULL) return;
@@ -109,20 +108,18 @@ static void ap_sta_hash_del(struct ap_data *ap, struct sta_info *sta)
109 if (s->hnext != NULL) 108 if (s->hnext != NULL)
110 s->hnext = s->hnext->hnext; 109 s->hnext = s->hnext->hnext;
111 else 110 else
112 printk("AP: could not remove STA %s" 111 printk("AP: could not remove STA %pM from hash table\n",
113 " from hash table\n", 112 sta->addr);
114 print_mac(mac, sta->addr));
115} 113}
116 114
117static void ap_free_sta(struct ap_data *ap, struct sta_info *sta) 115static void ap_free_sta(struct ap_data *ap, struct sta_info *sta)
118{ 116{
119 DECLARE_MAC_BUF(mac);
120 if (sta->ap && sta->local) 117 if (sta->ap && sta->local)
121 hostap_event_expired_sta(sta->local->dev, sta); 118 hostap_event_expired_sta(sta->local->dev, sta);
122 119
123 if (ap->proc != NULL) { 120 if (ap->proc != NULL) {
124 char name[20]; 121 char name[20];
125 sprintf(name, "%s", print_mac(mac, sta->addr)); 122 sprintf(name, "%pM", sta->addr);
126 remove_proc_entry(name, ap->proc); 123 remove_proc_entry(name, ap->proc);
127 } 124 }
128 125
@@ -185,7 +182,6 @@ static void ap_handle_timer(unsigned long data)
185 struct ap_data *ap; 182 struct ap_data *ap;
186 unsigned long next_time = 0; 183 unsigned long next_time = 0;
187 int was_assoc; 184 int was_assoc;
188 DECLARE_MAC_BUF(mac);
189 185
190 if (sta == NULL || sta->local == NULL || sta->local->ap == NULL) { 186 if (sta == NULL || sta->local == NULL || sta->local->ap == NULL) {
191 PDEBUG(DEBUG_AP, "ap_handle_timer() called with NULL data\n"); 187 PDEBUG(DEBUG_AP, "ap_handle_timer() called with NULL data\n");
@@ -242,8 +238,8 @@ static void ap_handle_timer(unsigned long data)
242 if (sta->ap) { 238 if (sta->ap) {
243 if (ap->autom_ap_wds) { 239 if (ap->autom_ap_wds) {
244 PDEBUG(DEBUG_AP, "%s: removing automatic WDS " 240 PDEBUG(DEBUG_AP, "%s: removing automatic WDS "
245 "connection to AP %s\n", 241 "connection to AP %pM\n",
246 local->dev->name, print_mac(mac, sta->addr)); 242 local->dev->name, sta->addr);
247 hostap_wds_link_oper(local, sta->addr, WDS_DEL); 243 hostap_wds_link_oper(local, sta->addr, WDS_DEL);
248 } 244 }
249 } else if (sta->timeout_next == STA_NULLFUNC) { 245 } else if (sta->timeout_next == STA_NULLFUNC) {
@@ -259,11 +255,11 @@ static void ap_handle_timer(unsigned long data)
259 } else { 255 } else {
260 int deauth = sta->timeout_next == STA_DEAUTH; 256 int deauth = sta->timeout_next == STA_DEAUTH;
261 __le16 resp; 257 __le16 resp;
262 PDEBUG(DEBUG_AP, "%s: sending %s info to STA %s" 258 PDEBUG(DEBUG_AP, "%s: sending %s info to STA %pM"
263 "(last=%lu, jiffies=%lu)\n", 259 "(last=%lu, jiffies=%lu)\n",
264 local->dev->name, 260 local->dev->name,
265 deauth ? "deauthentication" : "disassociation", 261 deauth ? "deauthentication" : "disassociation",
266 print_mac(mac, sta->addr), sta->last_rx, jiffies); 262 sta->addr, sta->last_rx, jiffies);
267 263
268 resp = cpu_to_le16(deauth ? WLAN_REASON_PREV_AUTH_NOT_VALID : 264 resp = cpu_to_le16(deauth ? WLAN_REASON_PREV_AUTH_NOT_VALID :
269 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); 265 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
@@ -275,10 +271,10 @@ static void ap_handle_timer(unsigned long data)
275 271
276 if (sta->timeout_next == STA_DEAUTH) { 272 if (sta->timeout_next == STA_DEAUTH) {
277 if (sta->flags & WLAN_STA_PERM) { 273 if (sta->flags & WLAN_STA_PERM) {
278 PDEBUG(DEBUG_AP, "%s: STA %s" 274 PDEBUG(DEBUG_AP, "%s: STA %pM"
279 " would have been removed, " 275 " would have been removed, "
280 "but it has 'perm' flag\n", 276 "but it has 'perm' flag\n",
281 local->dev->name, print_mac(mac, sta->addr)); 277 local->dev->name, sta->addr);
282 } else 278 } else
283 ap_free_sta(ap, sta); 279 ap_free_sta(ap, sta);
284 return; 280 return;
@@ -332,7 +328,6 @@ static int ap_control_proc_read(char *page, char **start, off_t off,
332 struct ap_data *ap = (struct ap_data *) data; 328 struct ap_data *ap = (struct ap_data *) data;
333 char *policy_txt; 329 char *policy_txt;
334 struct mac_entry *entry; 330 struct mac_entry *entry;
335 DECLARE_MAC_BUF(mac);
336 331
337 if (off != 0) { 332 if (off != 0) {
338 *eof = 1; 333 *eof = 1;
@@ -363,7 +358,7 @@ static int ap_control_proc_read(char *page, char **start, off_t off,
363 break; 358 break;
364 } 359 }
365 360
366 p += sprintf(p, "%s\n", print_mac(mac, entry->addr)); 361 p += sprintf(p, "%pM\n", entry->addr);
367 } 362 }
368 spin_unlock_bh(&ap->mac_restrictions.lock); 363 spin_unlock_bh(&ap->mac_restrictions.lock);
369 364
@@ -520,7 +515,6 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off,
520 struct ap_data *ap = (struct ap_data *) data; 515 struct ap_data *ap = (struct ap_data *) data;
521 struct sta_info *sta; 516 struct sta_info *sta;
522 int i; 517 int i;
523 DECLARE_MAC_BUF(mac);
524 518
525 if (off > PROC_LIMIT) { 519 if (off > PROC_LIMIT) {
526 *eof = 1; 520 *eof = 1;
@@ -533,8 +527,8 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off,
533 if (!sta->ap) 527 if (!sta->ap)
534 continue; 528 continue;
535 529
536 p += sprintf(p, "%s %d %d %d %d '", 530 p += sprintf(p, "%pM %d %d %d %d '",
537 print_mac(mac, sta->addr), 531 sta->addr,
538 sta->u.ap.channel, sta->last_rx_signal, 532 sta->u.ap.channel, sta->last_rx_signal,
539 sta->last_rx_silence, sta->last_rx_rate); 533 sta->last_rx_silence, sta->last_rx_rate);
540 for (i = 0; i < sta->u.ap.ssid_len; i++) 534 for (i = 0; i < sta->u.ap.ssid_len; i++)
@@ -683,11 +677,9 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
683 if (sta) 677 if (sta)
684 atomic_dec(&sta->users); 678 atomic_dec(&sta->users);
685 if (txt) { 679 if (txt) {
686 PDEBUG(DEBUG_AP, "%s: " MAC_FMT " auth_cb - alg=%d " 680 PDEBUG(DEBUG_AP, "%s: %pM auth_cb - alg=%d "
687 "trans#=%d status=%d - %s\n", 681 "trans#=%d status=%d - %s\n",
688 dev->name, 682 dev->name, hdr->addr1,
689 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
690 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
691 auth_alg, auth_transaction, status, txt); 683 auth_alg, auth_transaction, status, txt);
692 } 684 }
693 dev_kfree_skb(skb); 685 dev_kfree_skb(skb);
@@ -754,11 +746,8 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
754 if (sta) 746 if (sta)
755 atomic_dec(&sta->users); 747 atomic_dec(&sta->users);
756 if (txt) { 748 if (txt) {
757 PDEBUG(DEBUG_AP, "%s: " MAC_FMT " assoc_cb - %s\n", 749 PDEBUG(DEBUG_AP, "%s: %pM assoc_cb - %s\n",
758 dev->name, 750 dev->name, hdr->addr1, txt);
759 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
760 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
761 txt);
762 } 751 }
763 dev_kfree_skb(skb); 752 dev_kfree_skb(skb);
764} 753}
@@ -781,11 +770,9 @@ static void hostap_ap_tx_cb_poll(struct sk_buff *skb, int ok, void *data)
781 sta->flags &= ~WLAN_STA_PENDING_POLL; 770 sta->flags &= ~WLAN_STA_PENDING_POLL;
782 spin_unlock(&ap->sta_table_lock); 771 spin_unlock(&ap->sta_table_lock);
783 } else { 772 } else {
784 PDEBUG(DEBUG_AP, "%s: STA " MAC_FMT 773 PDEBUG(DEBUG_AP,
785 " did not ACK activity poll frame\n", 774 "%s: STA %pM did not ACK activity poll frame\n",
786 ap->local->dev->name, 775 ap->local->dev->name, hdr->addr1);
787 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
788 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
789 } 776 }
790 777
791 fail: 778 fail:
@@ -1002,7 +989,6 @@ static int prism2_sta_proc_read(char *page, char **start, off_t off,
1002 char *p = page; 989 char *p = page;
1003 struct sta_info *sta = (struct sta_info *) data; 990 struct sta_info *sta = (struct sta_info *) data;
1004 int i; 991 int i;
1005 DECLARE_MAC_BUF(mac);
1006 992
1007 /* FIX: possible race condition.. the STA data could have just expired, 993 /* FIX: possible race condition.. the STA data could have just expired,
1008 * but proc entry was still here so that the read could have started; 994 * but proc entry was still here so that the read could have started;
@@ -1013,11 +999,11 @@ static int prism2_sta_proc_read(char *page, char **start, off_t off,
1013 return 0; 999 return 0;
1014 } 1000 }
1015 1001
1016 p += sprintf(p, "%s=%s\nusers=%d\naid=%d\n" 1002 p += sprintf(p, "%s=%pM\nusers=%d\naid=%d\n"
1017 "flags=0x%04x%s%s%s%s%s%s%s\n" 1003 "flags=0x%04x%s%s%s%s%s%s%s\n"
1018 "capability=0x%02x\nlisten_interval=%d\nsupported_rates=", 1004 "capability=0x%02x\nlisten_interval=%d\nsupported_rates=",
1019 sta->ap ? "AP" : "STA", 1005 sta->ap ? "AP" : "STA",
1020 print_mac(mac, sta->addr), atomic_read(&sta->users), sta->aid, 1006 sta->addr, atomic_read(&sta->users), sta->aid,
1021 sta->flags, 1007 sta->flags,
1022 sta->flags & WLAN_STA_AUTH ? " AUTH" : "", 1008 sta->flags & WLAN_STA_AUTH ? " AUTH" : "",
1023 sta->flags & WLAN_STA_ASSOC ? " ASSOC" : "", 1009 sta->flags & WLAN_STA_ASSOC ? " ASSOC" : "",
@@ -1078,7 +1064,6 @@ static void handle_add_proc_queue(struct work_struct *work)
1078 struct sta_info *sta; 1064 struct sta_info *sta;
1079 char name[20]; 1065 char name[20];
1080 struct add_sta_proc_data *entry, *prev; 1066 struct add_sta_proc_data *entry, *prev;
1081 DECLARE_MAC_BUF(mac);
1082 1067
1083 entry = ap->add_sta_proc_entries; 1068 entry = ap->add_sta_proc_entries;
1084 ap->add_sta_proc_entries = NULL; 1069 ap->add_sta_proc_entries = NULL;
@@ -1091,7 +1076,7 @@ static void handle_add_proc_queue(struct work_struct *work)
1091 spin_unlock_bh(&ap->sta_table_lock); 1076 spin_unlock_bh(&ap->sta_table_lock);
1092 1077
1093 if (sta) { 1078 if (sta) {
1094 sprintf(name, "%s", print_mac(mac, sta->addr)); 1079 sprintf(name, "%pM", sta->addr);
1095 sta->proc = create_proc_read_entry( 1080 sta->proc = create_proc_read_entry(
1096 name, 0, ap->proc, 1081 name, 0, ap->proc,
1097 prism2_sta_proc_read, sta); 1082 prism2_sta_proc_read, sta);
@@ -1318,9 +1303,7 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1318 1303
1319 if (len < 6) { 1304 if (len < 6) {
1320 PDEBUG(DEBUG_AP, "%s: handle_authen - too short payload " 1305 PDEBUG(DEBUG_AP, "%s: handle_authen - too short payload "
1321 "(len=%d) from " MAC_FMT "\n", dev->name, len, 1306 "(len=%d) from %pM\n", dev->name, len, hdr->addr2);
1322 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1323 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
1324 return; 1307 return;
1325 } 1308 }
1326 1309
@@ -1385,10 +1368,8 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1385 if (time_after(jiffies, sta->u.ap.last_beacon + 1368 if (time_after(jiffies, sta->u.ap.last_beacon +
1386 (10 * sta->listen_interval * HZ) / 1024)) { 1369 (10 * sta->listen_interval * HZ) / 1024)) {
1387 PDEBUG(DEBUG_AP, "%s: no beacons received for a while," 1370 PDEBUG(DEBUG_AP, "%s: no beacons received for a while,"
1388 " assuming AP " MAC_FMT " is now STA\n", 1371 " assuming AP %pM is now STA\n",
1389 dev->name, 1372 dev->name, sta->addr);
1390 sta->addr[0], sta->addr[1], sta->addr[2],
1391 sta->addr[3], sta->addr[4], sta->addr[5]);
1392 sta->ap = 0; 1373 sta->ap = 0;
1393 sta->flags = 0; 1374 sta->flags = 0;
1394 sta->u.sta.challenge = NULL; 1375 sta->u.sta.challenge = NULL;
@@ -1503,11 +1484,9 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1503 } 1484 }
1504 1485
1505 if (resp) { 1486 if (resp) {
1506 PDEBUG(DEBUG_AP, "%s: " MAC_FMT " auth (alg=%d " 1487 PDEBUG(DEBUG_AP, "%s: %pM auth (alg=%d "
1507 "trans#=%d stat=%d len=%d fc=%04x) ==> %d (%s)\n", 1488 "trans#=%d stat=%d len=%d fc=%04x) ==> %d (%s)\n",
1508 dev->name, 1489 dev->name, hdr->addr2,
1509 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1510 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1511 auth_alg, auth_transaction, status_code, len, 1490 auth_alg, auth_transaction, status_code, len,
1512 fc, resp, txt); 1491 fc, resp, txt);
1513 } 1492 }
@@ -1533,10 +1512,8 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
1533 1512
1534 if (len < (reassoc ? 10 : 4)) { 1513 if (len < (reassoc ? 10 : 4)) {
1535 PDEBUG(DEBUG_AP, "%s: handle_assoc - too short payload " 1514 PDEBUG(DEBUG_AP, "%s: handle_assoc - too short payload "
1536 "(len=%d, reassoc=%d) from " MAC_FMT "\n", 1515 "(len=%d, reassoc=%d) from %pM\n",
1537 dev->name, len, reassoc, 1516 dev->name, len, reassoc, hdr->addr2);
1538 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1539 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
1540 return; 1517 return;
1541 } 1518 }
1542 1519
@@ -1613,12 +1590,9 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
1613 } 1590 }
1614 1591
1615 if (left > 0) { 1592 if (left > 0) {
1616 PDEBUG(DEBUG_AP, "%s: assoc from " MAC_FMT 1593 PDEBUG(DEBUG_AP, "%s: assoc from %pM"
1617 " with extra data (%d bytes) [", 1594 " with extra data (%d bytes) [",
1618 dev->name, 1595 dev->name, hdr->addr2, left);
1619 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1620 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1621 left);
1622 while (left > 0) { 1596 while (left > 0) {
1623 PDEBUG2(DEBUG_AP, "<%02x>", *u); 1597 PDEBUG2(DEBUG_AP, "<%02x>", *u);
1624 u++; left--; 1598 u++; left--;
@@ -1717,14 +1691,12 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
1717 } 1691 }
1718 1692
1719#if 0 1693#if 0
1720 PDEBUG(DEBUG_AP, "%s: " MAC_FMT" %sassoc (len=%d " 1694 PDEBUG(DEBUG_AP, "%s: %pM %sassoc (len=%d "
1721 "prev_ap=" MAC_FMT") => %d(%d) (%s)\n", 1695 "prev_ap=%pM) => %d(%d) (%s)\n",
1722 dev->name, 1696 dev->name,
1723 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2], 1697 hdr->addr2,
1724 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1725 reassoc ? "re" : "", len, 1698 reassoc ? "re" : "", len,
1726 prev_ap[0], prev_ap[1], prev_ap[2], 1699 prev_ap,
1727 prev_ap[3], prev_ap[4], prev_ap[5],
1728 resp, send_deauth, txt); 1700 resp, send_deauth, txt);
1729#endif 1701#endif
1730} 1702}
@@ -1741,7 +1713,6 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
1741 u16 reason_code; 1713 u16 reason_code;
1742 __le16 *pos; 1714 __le16 *pos;
1743 struct sta_info *sta = NULL; 1715 struct sta_info *sta = NULL;
1744 DECLARE_MAC_BUF(mac);
1745 1716
1746 len = skb->len - IEEE80211_MGMT_HDR_LEN; 1717 len = skb->len - IEEE80211_MGMT_HDR_LEN;
1747 1718
@@ -1753,10 +1724,8 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
1753 pos = (__le16 *) body; 1724 pos = (__le16 *) body;
1754 reason_code = le16_to_cpu(*pos); 1725 reason_code = le16_to_cpu(*pos);
1755 1726
1756 PDEBUG(DEBUG_AP, "%s: deauthentication: " MAC_FMT " len=%d, " 1727 PDEBUG(DEBUG_AP, "%s: deauthentication: %pM len=%d, "
1757 "reason_code=%d\n", dev->name, 1728 "reason_code=%d\n", dev->name, hdr->addr2,
1758 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1759 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1760 len, reason_code); 1729 len, reason_code);
1761 1730
1762 spin_lock_bh(&local->ap->sta_table_lock); 1731 spin_lock_bh(&local->ap->sta_table_lock);
@@ -1768,11 +1737,9 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
1768 } 1737 }
1769 spin_unlock_bh(&local->ap->sta_table_lock); 1738 spin_unlock_bh(&local->ap->sta_table_lock);
1770 if (sta == NULL) { 1739 if (sta == NULL) {
1771 printk("%s: deauthentication from " MAC_FMT ", " 1740 printk("%s: deauthentication from %pM, "
1772 "reason_code=%d, but STA not authenticated\n", dev->name, 1741 "reason_code=%d, but STA not authenticated\n", dev->name,
1773 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2], 1742 hdr->addr2, reason_code);
1774 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1775 reason_code);
1776 } 1743 }
1777} 1744}
1778 1745
@@ -1799,10 +1766,8 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
1799 pos = (__le16 *) body; 1766 pos = (__le16 *) body;
1800 reason_code = le16_to_cpu(*pos); 1767 reason_code = le16_to_cpu(*pos);
1801 1768
1802 PDEBUG(DEBUG_AP, "%s: disassociation: " MAC_FMT " len=%d, " 1769 PDEBUG(DEBUG_AP, "%s: disassociation: %pM len=%d, "
1803 "reason_code=%d\n", dev->name, 1770 "reason_code=%d\n", dev->name, hdr->addr2,
1804 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1805 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1806 len, reason_code); 1771 len, reason_code);
1807 1772
1808 spin_lock_bh(&local->ap->sta_table_lock); 1773 spin_lock_bh(&local->ap->sta_table_lock);
@@ -1814,12 +1779,9 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
1814 } 1779 }
1815 spin_unlock_bh(&local->ap->sta_table_lock); 1780 spin_unlock_bh(&local->ap->sta_table_lock);
1816 if (sta == NULL) { 1781 if (sta == NULL) {
1817 printk("%s: disassociation from " MAC_FMT ", " 1782 printk("%s: disassociation from %pM, "
1818 "reason_code=%d, but STA not authenticated\n", 1783 "reason_code=%d, but STA not authenticated\n",
1819 dev->name, 1784 dev->name, hdr->addr2, reason_code);
1820 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1821 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1822 reason_code);
1823 } 1785 }
1824} 1786}
1825 1787
@@ -1909,19 +1871,14 @@ static void handle_pspoll(local_info_t *local,
1909 u16 aid; 1871 u16 aid;
1910 struct sk_buff *skb; 1872 struct sk_buff *skb;
1911 1873
1912 PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=" MAC_FMT 1874 PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=%pM, TA=%pM PWRMGT=%d\n",
1913 ", TA=" MAC_FMT " PWRMGT=%d\n", 1875 hdr->addr1, hdr->addr2,
1914 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
1915 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
1916 hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
1917 hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
1918 !!(le16_to_cpu(hdr->frame_ctl) & IEEE80211_FCTL_PM)); 1876 !!(le16_to_cpu(hdr->frame_ctl) & IEEE80211_FCTL_PM));
1919 1877
1920 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 1878 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
1921 PDEBUG(DEBUG_AP, "handle_pspoll - addr1(BSSID)=" MAC_FMT 1879 PDEBUG(DEBUG_AP,
1922 " not own MAC\n", 1880 "handle_pspoll - addr1(BSSID)=%pM not own MAC\n",
1923 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2], 1881 hdr->addr1);
1924 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
1925 return; 1882 return;
1926 } 1883 }
1927 1884
@@ -2007,11 +1964,10 @@ static void handle_wds_oper_queue(struct work_struct *work)
2007 1964
2008 while (entry) { 1965 while (entry) {
2009 PDEBUG(DEBUG_AP, "%s: %s automatic WDS connection " 1966 PDEBUG(DEBUG_AP, "%s: %s automatic WDS connection "
2010 "to AP " MAC_FMT "\n", 1967 "to AP %pM\n",
2011 local->dev->name, 1968 local->dev->name,
2012 entry->type == WDS_ADD ? "adding" : "removing", 1969 entry->type == WDS_ADD ? "adding" : "removing",
2013 entry->addr[0], entry->addr[1], entry->addr[2], 1970 entry->addr);
2014 entry->addr[3], entry->addr[4], entry->addr[5]);
2015 if (entry->type == WDS_ADD) 1971 if (entry->type == WDS_ADD)
2016 prism2_wds_add(local, entry->addr, 0); 1972 prism2_wds_add(local, entry->addr, 0);
2017 else if (entry->type == WDS_DEL) 1973 else if (entry->type == WDS_DEL)
@@ -2215,10 +2171,8 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2215 } 2171 }
2216 2172
2217 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 2173 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
2218 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(BSSID)=" 2174 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(BSSID)=%pM"
2219 MAC_FMT " not own MAC\n", 2175 " not own MAC\n", hdr->addr1);
2220 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2221 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
2222 goto done; 2176 goto done;
2223 } 2177 }
2224 2178
@@ -2254,18 +2208,14 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2254 } 2208 }
2255 2209
2256 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 2210 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
2257 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(DA)=" MAC_FMT 2211 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(DA)=%pM"
2258 " not own MAC\n", 2212 " not own MAC\n", hdr->addr1);
2259 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2260 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
2261 goto done; 2213 goto done;
2262 } 2214 }
2263 2215
2264 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) { 2216 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) {
2265 PDEBUG(DEBUG_AP, "handle_ap_item - addr3(BSSID)=" MAC_FMT 2217 PDEBUG(DEBUG_AP, "handle_ap_item - addr3(BSSID)=%pM"
2266 " not own MAC\n", 2218 " not own MAC\n", hdr->addr3);
2267 hdr->addr3[0], hdr->addr3[1], hdr->addr3[2],
2268 hdr->addr3[3], hdr->addr3[4], hdr->addr3[5]);
2269 goto done; 2219 goto done;
2270 } 2220 }
2271 2221
@@ -2366,10 +2316,9 @@ static void schedule_packet_send(local_info_t *local, struct sta_info *sta)
2366 memcpy(hdr->addr2, sta->addr, ETH_ALEN); 2316 memcpy(hdr->addr2, sta->addr, ETH_ALEN);
2367 hdr->duration_id = cpu_to_le16(sta->aid | BIT(15) | BIT(14)); 2317 hdr->duration_id = cpu_to_le16(sta->aid | BIT(15) | BIT(14));
2368 2318
2369 PDEBUG(DEBUG_PS2, "%s: Scheduling buffered packet delivery for STA " 2319 PDEBUG(DEBUG_PS2,
2370 MAC_FMT "\n", local->dev->name, 2320 "%s: Scheduling buffered packet delivery for STA %pM\n",
2371 sta->addr[0], sta->addr[1], sta->addr[2], 2321 local->dev->name, sta->addr);
2372 sta->addr[3], sta->addr[4], sta->addr[5]);
2373 2322
2374 skb->dev = local->dev; 2323 skb->dev = local->dev;
2375 2324
@@ -2723,12 +2672,8 @@ static int ap_update_sta_tx_rate(struct sta_info *sta, struct net_device *dev)
2723 case 3: sta->tx_rate = 110; break; 2672 case 3: sta->tx_rate = 110; break;
2724 default: sta->tx_rate = 0; break; 2673 default: sta->tx_rate = 0; break;
2725 } 2674 }
2726 PDEBUG(DEBUG_AP, "%s: STA " MAC_FMT 2675 PDEBUG(DEBUG_AP, "%s: STA %pM TX rate raised to %d\n",
2727 " TX rate raised to %d\n", 2676 dev->name, sta->addr, sta->tx_rate);
2728 dev->name,
2729 sta->addr[0], sta->addr[1], sta->addr[2],
2730 sta->addr[3], sta->addr[4], sta->addr[5],
2731 sta->tx_rate);
2732 } 2677 }
2733 sta->tx_since_last_failure = 0; 2678 sta->tx_since_last_failure = 0;
2734 } 2679 }
@@ -2781,9 +2726,7 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2781 * print out any errors here. */ 2726 * print out any errors here. */
2782 if (net_ratelimit()) { 2727 if (net_ratelimit()) {
2783 printk(KERN_DEBUG "AP: drop packet to non-associated " 2728 printk(KERN_DEBUG "AP: drop packet to non-associated "
2784 "STA " MAC_FMT "\n", 2729 "STA %pM\n", hdr->addr1);
2785 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2786 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
2787 } 2730 }
2788#endif 2731#endif
2789 local->ap->tx_drop_nonassoc++; 2732 local->ap->tx_drop_nonassoc++;
@@ -2821,11 +2764,9 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2821 } 2764 }
2822 2765
2823 if (skb_queue_len(&sta->tx_buf) >= STA_MAX_TX_BUFFER) { 2766 if (skb_queue_len(&sta->tx_buf) >= STA_MAX_TX_BUFFER) {
2824 PDEBUG(DEBUG_PS, "%s: No more space in STA (" MAC_FMT 2767 PDEBUG(DEBUG_PS, "%s: No more space in STA (%pM)'s"
2825 ")'s PS mode buffer\n", 2768 "PS mode buffer\n",
2826 local->dev->name, 2769 local->dev->name, sta->addr);
2827 sta->addr[0], sta->addr[1], sta->addr[2],
2828 sta->addr[3], sta->addr[4], sta->addr[5]);
2829 /* Make sure that TIM is set for the station (it might not be 2770 /* Make sure that TIM is set for the station (it might not be
2830 * after AP wlan hw reset). */ 2771 * after AP wlan hw reset). */
2831 /* FIX: should fix hw reset to restore bits based on STA 2772 /* FIX: should fix hw reset to restore bits based on STA
@@ -2897,12 +2838,9 @@ void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
2897 sta = ap_get_sta(local->ap, hdr->addr1); 2838 sta = ap_get_sta(local->ap, hdr->addr1);
2898 if (!sta) { 2839 if (!sta) {
2899 spin_unlock(&local->ap->sta_table_lock); 2840 spin_unlock(&local->ap->sta_table_lock);
2900 PDEBUG(DEBUG_AP, "%s: Could not find STA " MAC_FMT 2841 PDEBUG(DEBUG_AP, "%s: Could not find STA %pM"
2901 " for this TX error (@%lu)\n", 2842 " for this TX error (@%lu)\n",
2902 local->dev->name, 2843 local->dev->name, hdr->addr1, jiffies);
2903 hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
2904 hdr->addr1[3], hdr->addr1[4], hdr->addr1[5],
2905 jiffies);
2906 return; 2844 return;
2907 } 2845 }
2908 2846
@@ -2929,12 +2867,9 @@ void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
2929 case 3: sta->tx_rate = 110; break; 2867 case 3: sta->tx_rate = 110; break;
2930 default: sta->tx_rate = 0; break; 2868 default: sta->tx_rate = 0; break;
2931 } 2869 }
2932 PDEBUG(DEBUG_AP, "%s: STA " MAC_FMT 2870 PDEBUG(DEBUG_AP,
2933 " TX rate lowered to %d\n", 2871 "%s: STA %pM TX rate lowered to %d\n",
2934 local->dev->name, 2872 local->dev->name, sta->addr, sta->tx_rate);
2935 sta->addr[0], sta->addr[1], sta->addr[2],
2936 sta->addr[3], sta->addr[4], sta->addr[5],
2937 sta->tx_rate);
2938 } 2873 }
2939 sta->tx_consecutive_exc = 0; 2874 sta->tx_consecutive_exc = 0;
2940 } 2875 }
@@ -2945,17 +2880,16 @@ void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
2945static void hostap_update_sta_ps2(local_info_t *local, struct sta_info *sta, 2880static void hostap_update_sta_ps2(local_info_t *local, struct sta_info *sta,
2946 int pwrmgt, int type, int stype) 2881 int pwrmgt, int type, int stype)
2947{ 2882{
2948 DECLARE_MAC_BUF(mac);
2949 if (pwrmgt && !(sta->flags & WLAN_STA_PS)) { 2883 if (pwrmgt && !(sta->flags & WLAN_STA_PS)) {
2950 sta->flags |= WLAN_STA_PS; 2884 sta->flags |= WLAN_STA_PS;
2951 PDEBUG(DEBUG_PS2, "STA %s changed to use PS " 2885 PDEBUG(DEBUG_PS2, "STA %pM changed to use PS "
2952 "mode (type=0x%02X, stype=0x%02X)\n", 2886 "mode (type=0x%02X, stype=0x%02X)\n",
2953 print_mac(mac, sta->addr), type >> 2, stype >> 4); 2887 sta->addr, type >> 2, stype >> 4);
2954 } else if (!pwrmgt && (sta->flags & WLAN_STA_PS)) { 2888 } else if (!pwrmgt && (sta->flags & WLAN_STA_PS)) {
2955 sta->flags &= ~WLAN_STA_PS; 2889 sta->flags &= ~WLAN_STA_PS;
2956 PDEBUG(DEBUG_PS2, "STA %s changed to not use " 2890 PDEBUG(DEBUG_PS2, "STA %pM changed to not use "
2957 "PS mode (type=0x%02X, stype=0x%02X)\n", 2891 "PS mode (type=0x%02X, stype=0x%02X)\n",
2958 print_mac(mac, sta->addr), type >> 2, stype >> 4); 2892 sta->addr, type >> 2, stype >> 4);
2959 if (type != IEEE80211_FTYPE_CTL || 2893 if (type != IEEE80211_FTYPE_CTL ||
2960 stype != IEEE80211_STYPE_PSPOLL) 2894 stype != IEEE80211_STYPE_PSPOLL)
2961 schedule_packet_send(local, sta); 2895 schedule_packet_send(local, sta);
@@ -3029,13 +2963,9 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3029#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 2963#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3030 } else { 2964 } else {
3031 printk(KERN_DEBUG "%s: dropped received packet" 2965 printk(KERN_DEBUG "%s: dropped received packet"
3032 " from non-associated STA " 2966 " from non-associated STA %pM"
3033 MAC_FMT
3034 " (type=0x%02x, subtype=0x%02x)\n", 2967 " (type=0x%02x, subtype=0x%02x)\n",
3035 dev->name, 2968 dev->name, hdr->addr2,
3036 hdr->addr2[0], hdr->addr2[1],
3037 hdr->addr2[2], hdr->addr2[3],
3038 hdr->addr2[4], hdr->addr2[5],
3039 type >> 2, stype >> 4); 2969 type >> 2, stype >> 4);
3040 hostap_rx(dev, skb, rx_stats); 2970 hostap_rx(dev, skb, rx_stats);
3041#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 2971#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
@@ -3068,13 +2998,9 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3068 * after being unavailable for some time. Speed up 2998 * after being unavailable for some time. Speed up
3069 * re-association by informing the station about it not 2999 * re-association by informing the station about it not
3070 * being associated. */ 3000 * being associated. */
3071 printk(KERN_DEBUG "%s: rejected received nullfunc " 3001 printk(KERN_DEBUG "%s: rejected received nullfunc frame"
3072 "frame without ToDS from not associated STA " 3002 " without ToDS from not associated STA %pM\n",
3073 MAC_FMT "\n", 3003 dev->name, hdr->addr2);
3074 dev->name,
3075 hdr->addr2[0], hdr->addr2[1],
3076 hdr->addr2[2], hdr->addr2[3],
3077 hdr->addr2[4], hdr->addr2[5]);
3078 hostap_rx(dev, skb, rx_stats); 3004 hostap_rx(dev, skb, rx_stats);
3079#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 3005#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3080 } 3006 }
@@ -3090,13 +3016,10 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3090 * broadcast frame from an IBSS network. Drop it silently. 3016 * broadcast frame from an IBSS network. Drop it silently.
3091 * If BSSID is own, report the dropping of this frame. */ 3017 * If BSSID is own, report the dropping of this frame. */
3092 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) { 3018 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
3093 printk(KERN_DEBUG "%s: dropped received packet from " 3019 printk(KERN_DEBUG "%s: dropped received packet from %pM"
3094 MAC_FMT " with no ToDS flag " 3020 " with no ToDS flag "
3095 "(type=0x%02x, subtype=0x%02x)\n", dev->name, 3021 "(type=0x%02x, subtype=0x%02x)\n", dev->name,
3096 hdr->addr2[0], hdr->addr2[1], 3022 hdr->addr2, type >> 2, stype >> 4);
3097 hdr->addr2[2], hdr->addr2[3],
3098 hdr->addr2[4], hdr->addr2[5],
3099 type >> 2, stype >> 4);
3100 hostap_dump_rx_80211(dev->name, skb, rx_stats); 3023 hostap_dump_rx_80211(dev->name, skb, rx_stats);
3101 } 3024 }
3102 ret = AP_RX_DROP; 3025 ret = AP_RX_DROP;
diff --git a/drivers/net/wireless/hostap/hostap_common.h b/drivers/net/wireless/hostap/hostap_common.h
index b470c743c2d1..90b64b092007 100644
--- a/drivers/net/wireless/hostap/hostap_common.h
+++ b/drivers/net/wireless/hostap/hostap_common.h
@@ -6,19 +6,6 @@
6 6
7/* IEEE 802.11 defines */ 7/* IEEE 802.11 defines */
8 8
9/* Information Element IDs */
10#define WLAN_EID_SSID 0
11#define WLAN_EID_SUPP_RATES 1
12#define WLAN_EID_FH_PARAMS 2
13#define WLAN_EID_DS_PARAMS 3
14#define WLAN_EID_CF_PARAMS 4
15#define WLAN_EID_TIM 5
16#define WLAN_EID_IBSS_PARAMS 6
17#define WLAN_EID_CHALLENGE 16
18#define WLAN_EID_RSN 48
19#define WLAN_EID_GENERIC 221
20
21
22/* HFA384X Configuration RIDs */ 9/* HFA384X Configuration RIDs */
23#define HFA384X_RID_CNFPORTTYPE 0xFC00 10#define HFA384X_RID_CNFPORTTYPE 0xFC00
24#define HFA384X_RID_CNFOWNMACADDR 0xFC01 11#define HFA384X_RID_CNFOWNMACADDR 0xFC01
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 3153fe9d7ce0..fd7f7ceeac46 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -2335,10 +2335,6 @@ static void prism2_txexc(local_info_t *local)
2335 int show_dump, res; 2335 int show_dump, res;
2336 char *payload = NULL; 2336 char *payload = NULL;
2337 struct hfa384x_tx_frame txdesc; 2337 struct hfa384x_tx_frame txdesc;
2338 DECLARE_MAC_BUF(mac);
2339 DECLARE_MAC_BUF(mac2);
2340 DECLARE_MAC_BUF(mac3);
2341 DECLARE_MAC_BUF(mac4);
2342 2338
2343 show_dump = local->frame_dump & PRISM2_DUMP_TXEXC_HDR; 2339 show_dump = local->frame_dump & PRISM2_DUMP_TXEXC_HDR;
2344 local->stats.tx_errors++; 2340 local->stats.tx_errors++;
@@ -2404,9 +2400,9 @@ static void prism2_txexc(local_info_t *local)
2404 WLAN_FC_GET_STYPE(fc) >> 4, 2400 WLAN_FC_GET_STYPE(fc) >> 4,
2405 fc & IEEE80211_FCTL_TODS ? " ToDS" : "", 2401 fc & IEEE80211_FCTL_TODS ? " ToDS" : "",
2406 fc & IEEE80211_FCTL_FROMDS ? " FromDS" : ""); 2402 fc & IEEE80211_FCTL_FROMDS ? " FromDS" : "");
2407 PDEBUG(DEBUG_EXTRA, " A1=%s A2=%s A3=%s A4=%s\n", 2403 PDEBUG(DEBUG_EXTRA, " A1=%pM A2=%pM A3=%pM A4=%pM\n",
2408 print_mac(mac, txdesc.addr1), print_mac(mac2, txdesc.addr2), 2404 txdesc.addr1, txdesc.addr2,
2409 print_mac(mac3, txdesc.addr3), print_mac(mac4, txdesc.addr4)); 2405 txdesc.addr3, txdesc.addr4);
2410} 2406}
2411 2407
2412 2408
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c
index 7cd3fb79230e..99b4cf41edf2 100644
--- a/drivers/net/wireless/hostap/hostap_info.c
+++ b/drivers/net/wireless/hostap/hostap_info.c
@@ -166,7 +166,6 @@ static void prism2_host_roaming(local_info_t *local)
166 struct hfa384x_hostscan_result *selected, *entry; 166 struct hfa384x_hostscan_result *selected, *entry;
167 int i; 167 int i;
168 unsigned long flags; 168 unsigned long flags;
169 DECLARE_MAC_BUF(mac);
170 169
171 if (local->last_join_time && 170 if (local->last_join_time &&
172 time_before(jiffies, local->last_join_time + 10 * HZ)) { 171 time_before(jiffies, local->last_join_time + 10 * HZ)) {
@@ -199,9 +198,8 @@ static void prism2_host_roaming(local_info_t *local)
199 local->preferred_ap[2] || local->preferred_ap[3] || 198 local->preferred_ap[2] || local->preferred_ap[3] ||
200 local->preferred_ap[4] || local->preferred_ap[5]) { 199 local->preferred_ap[4] || local->preferred_ap[5]) {
201 /* Try to find preferred AP */ 200 /* Try to find preferred AP */
202 PDEBUG(DEBUG_EXTRA, "%s: Preferred AP BSSID " 201 PDEBUG(DEBUG_EXTRA, "%s: Preferred AP BSSID %pM\n",
203 "%s\n", 202 dev->name, local->preferred_ap);
204 dev->name, print_mac(mac, local->preferred_ap));
205 for (i = 0; i < local->last_scan_results_count; i++) { 203 for (i = 0; i < local->last_scan_results_count; i++) {
206 entry = &local->last_scan_results[i]; 204 entry = &local->last_scan_results[i];
207 if (memcmp(local->preferred_ap, entry->bssid, 6) == 0) 205 if (memcmp(local->preferred_ap, entry->bssid, 6) == 0)
@@ -218,9 +216,9 @@ static void prism2_host_roaming(local_info_t *local)
218 req.channel = selected->chid; 216 req.channel = selected->chid;
219 spin_unlock_irqrestore(&local->lock, flags); 217 spin_unlock_irqrestore(&local->lock, flags);
220 218
221 PDEBUG(DEBUG_EXTRA, "%s: JoinRequest: BSSID=%s" 219 PDEBUG(DEBUG_EXTRA, "%s: JoinRequest: BSSID=%pM"
222 " channel=%d\n", 220 " channel=%d\n",
223 dev->name, print_mac(mac, req.bssid), le16_to_cpu(req.channel)); 221 dev->name, req.bssid, le16_to_cpu(req.channel));
224 if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req, 222 if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
225 sizeof(req))) { 223 sizeof(req))) {
226 printk(KERN_DEBUG "%s: JoinRequest failed\n", dev->name); 224 printk(KERN_DEBUG "%s: JoinRequest failed\n", dev->name);
@@ -413,7 +411,6 @@ static void handle_info_queue_linkstatus(local_info_t *local)
413 int val = local->prev_link_status; 411 int val = local->prev_link_status;
414 int connected; 412 int connected;
415 union iwreq_data wrqu; 413 union iwreq_data wrqu;
416 DECLARE_MAC_BUF(mac);
417 414
418 connected = 415 connected =
419 val == HFA384X_LINKSTATUS_CONNECTED || 416 val == HFA384X_LINKSTATUS_CONNECTED ||
@@ -425,10 +422,9 @@ static void handle_info_queue_linkstatus(local_info_t *local)
425 printk(KERN_DEBUG "%s: could not read CURRENTBSSID after " 422 printk(KERN_DEBUG "%s: could not read CURRENTBSSID after "
426 "LinkStatus event\n", local->dev->name); 423 "LinkStatus event\n", local->dev->name);
427 } else { 424 } else {
428 PDEBUG(DEBUG_EXTRA, "%s: LinkStatus: BSSID=" 425 PDEBUG(DEBUG_EXTRA, "%s: LinkStatus: BSSID=%pM\n",
429 "%s\n",
430 local->dev->name, 426 local->dev->name,
431 print_mac(mac, (unsigned char *) local->bssid)); 427 (unsigned char *) local->bssid);
432 if (local->wds_type & HOSTAP_WDS_AP_CLIENT) 428 if (local->wds_type & HOSTAP_WDS_AP_CLIENT)
433 hostap_add_sta(local->ap, local->bssid); 429 hostap_add_sta(local->ap, local->bssid);
434 } 430 }
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 3f8b1d7036e5..2318c5df7a08 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -664,7 +664,6 @@ static int hostap_join_ap(struct net_device *dev)
664 unsigned long flags; 664 unsigned long flags;
665 int i; 665 int i;
666 struct hfa384x_hostscan_result *entry; 666 struct hfa384x_hostscan_result *entry;
667 DECLARE_MAC_BUF(mac);
668 667
669 iface = netdev_priv(dev); 668 iface = netdev_priv(dev);
670 local = iface->local; 669 local = iface->local;
@@ -686,14 +685,13 @@ static int hostap_join_ap(struct net_device *dev)
686 685
687 if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req, 686 if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
688 sizeof(req))) { 687 sizeof(req))) {
689 printk(KERN_DEBUG "%s: JoinRequest %s" 688 printk(KERN_DEBUG "%s: JoinRequest %pM failed\n",
690 " failed\n", 689 dev->name, local->preferred_ap);
691 dev->name, print_mac(mac, local->preferred_ap));
692 return -1; 690 return -1;
693 } 691 }
694 692
695 printk(KERN_DEBUG "%s: Trying to join BSSID %s\n", 693 printk(KERN_DEBUG "%s: Trying to join BSSID %pM\n",
696 dev->name, print_mac(mac, local->preferred_ap)); 694 dev->name, local->preferred_ap);
697 695
698 return 0; 696 return 0;
699} 697}
@@ -3701,10 +3699,8 @@ static int prism2_ioctl_set_assoc_ap_addr(local_info_t *local,
3701 struct prism2_hostapd_param *param, 3699 struct prism2_hostapd_param *param,
3702 int param_len) 3700 int param_len)
3703{ 3701{
3704 DECLARE_MAC_BUF(mac); 3702 printk(KERN_DEBUG "%ssta: associated as client with AP %pM\n",
3705 printk(KERN_DEBUG "%ssta: associated as client with AP " 3703 local->dev->name, param->sta_addr);
3706 "%s\n",
3707 local->dev->name, print_mac(mac, param->sta_addr));
3708 memcpy(local->assoc_ap_addr, param->sta_addr, ETH_ALEN); 3704 memcpy(local->assoc_ap_addr, param->sta_addr, ETH_ALEN);
3709 return 0; 3705 return 0;
3710} 3706}
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 756ab56c1f40..4c36eb2fafd1 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -530,10 +530,6 @@ int hostap_set_auth_algs(local_info_t *local)
530void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx) 530void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
531{ 531{
532 u16 status, fc; 532 u16 status, fc;
533 DECLARE_MAC_BUF(mac);
534 DECLARE_MAC_BUF(mac2);
535 DECLARE_MAC_BUF(mac3);
536 DECLARE_MAC_BUF(mac4);
537 533
538 status = __le16_to_cpu(rx->status); 534 status = __le16_to_cpu(rx->status);
539 535
@@ -552,12 +548,11 @@ void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
552 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", 548 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
553 fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); 549 fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
554 550
555 printk(KERN_DEBUG " A1=%s A2=%s A3=%s A4=%s\n", 551 printk(KERN_DEBUG " A1=%pM A2=%pM A3=%pM A4=%pM\n",
556 print_mac(mac, rx->addr1), print_mac(mac2, rx->addr2), 552 rx->addr1, rx->addr2, rx->addr3, rx->addr4);
557 print_mac(mac3, rx->addr3), print_mac(mac4, rx->addr4));
558 553
559 printk(KERN_DEBUG " dst=%s src=%s len=%d\n", 554 printk(KERN_DEBUG " dst=%pM src=%pM len=%d\n",
560 print_mac(mac, rx->dst_addr), print_mac(mac2, rx->src_addr), 555 rx->dst_addr, rx->src_addr,
561 __be16_to_cpu(rx->len)); 556 __be16_to_cpu(rx->len));
562} 557}
563 558
@@ -565,10 +560,6 @@ void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
565void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx) 560void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
566{ 561{
567 u16 fc; 562 u16 fc;
568 DECLARE_MAC_BUF(mac);
569 DECLARE_MAC_BUF(mac2);
570 DECLARE_MAC_BUF(mac3);
571 DECLARE_MAC_BUF(mac4);
572 563
573 printk(KERN_DEBUG "%s: TX status=0x%04x retry_count=%d tx_rate=%d " 564 printk(KERN_DEBUG "%s: TX status=0x%04x retry_count=%d tx_rate=%d "
574 "tx_control=0x%04x; jiffies=%ld\n", 565 "tx_control=0x%04x; jiffies=%ld\n",
@@ -584,12 +575,11 @@ void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
584 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", 575 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
585 fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); 576 fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
586 577
587 printk(KERN_DEBUG " A1=%s A2=%s A3=%s A4=%s\n", 578 printk(KERN_DEBUG " A1=%pM A2=%pM A3=%pM A4=%pM\n",
588 print_mac(mac, tx->addr1), print_mac(mac2, tx->addr2), 579 tx->addr1, tx->addr2, tx->addr3, tx->addr4);
589 print_mac(mac3, tx->addr3), print_mac(mac4, tx->addr4));
590 580
591 printk(KERN_DEBUG " dst=%s src=%s len=%d\n", 581 printk(KERN_DEBUG " dst=%pM src=%pM len=%d\n",
592 print_mac(mac, tx->dst_addr), print_mac(mac2, tx->src_addr), 582 tx->dst_addr, tx->src_addr,
593 __be16_to_cpu(tx->len)); 583 __be16_to_cpu(tx->len));
594} 584}
595 585
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 3a874fc621d3..8fdd41f4b4f2 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -312,7 +312,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
312 goto err_out_disable; 312 goto err_out_disable;
313 } 313 }
314 314
315 mem = ioremap(phymem, pci_resource_len(pdev, 0)); 315 mem = pci_ioremap_bar(pdev, 0);
316 if (mem == NULL) { 316 if (mem == NULL) {
317 printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ; 317 printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ;
318 goto fail; 318 goto fail;
diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c
index b03536008ad9..ae7d3caf3dae 100644
--- a/drivers/net/wireless/hostap/hostap_proc.c
+++ b/drivers/net/wireless/hostap/hostap_proc.c
@@ -106,7 +106,6 @@ static int prism2_wds_proc_read(char *page, char **start, off_t off,
106 local_info_t *local = (local_info_t *) data; 106 local_info_t *local = (local_info_t *) data;
107 struct list_head *ptr; 107 struct list_head *ptr;
108 struct hostap_interface *iface; 108 struct hostap_interface *iface;
109 DECLARE_MAC_BUF(mac);
110 109
111 if (off > PROC_LIMIT) { 110 if (off > PROC_LIMIT) {
112 *eof = 1; 111 *eof = 1;
@@ -118,9 +117,9 @@ static int prism2_wds_proc_read(char *page, char **start, off_t off,
118 iface = list_entry(ptr, struct hostap_interface, list); 117 iface = list_entry(ptr, struct hostap_interface, list);
119 if (iface->type != HOSTAP_INTERFACE_WDS) 118 if (iface->type != HOSTAP_INTERFACE_WDS)
120 continue; 119 continue;
121 p += sprintf(p, "%s\t%s\n", 120 p += sprintf(p, "%s\t%pM\n",
122 iface->dev->name, 121 iface->dev->name,
123 print_mac(mac, iface->u.wds.remote_addr)); 122 iface->u.wds.remote_addr);
124 if ((p - page) > PROC_LIMIT) { 123 if ((p - page) > PROC_LIMIT) {
125 printk(KERN_DEBUG "%s: wds proc did not fit\n", 124 printk(KERN_DEBUG "%s: wds proc did not fit\n",
126 local->dev->name); 125 local->dev->name);
@@ -148,7 +147,6 @@ static int prism2_bss_list_proc_read(char *page, char **start, off_t off,
148 struct list_head *ptr; 147 struct list_head *ptr;
149 struct hostap_bss_info *bss; 148 struct hostap_bss_info *bss;
150 int i; 149 int i;
151 DECLARE_MAC_BUF(mac);
152 150
153 if (off > PROC_LIMIT) { 151 if (off > PROC_LIMIT) {
154 *eof = 1; 152 *eof = 1;
@@ -160,8 +158,8 @@ static int prism2_bss_list_proc_read(char *page, char **start, off_t off,
160 spin_lock_bh(&local->lock); 158 spin_lock_bh(&local->lock);
161 list_for_each(ptr, &local->bss_list) { 159 list_for_each(ptr, &local->bss_list) {
162 bss = list_entry(ptr, struct hostap_bss_info, list); 160 bss = list_entry(ptr, struct hostap_bss_info, list);
163 p += sprintf(p, "%s\t%lu\t%u\t0x%x\t", 161 p += sprintf(p, "%pM\t%lu\t%u\t0x%x\t",
164 print_mac(mac, bss->bssid), bss->last_update, 162 bss->bssid, bss->last_update,
165 bss->count, bss->capab_info); 163 bss->count, bss->capab_info);
166 for (i = 0; i < bss->ssid_len; i++) { 164 for (i = 0; i < bss->ssid_len; i++) {
167 p += sprintf(p, "%c", 165 p += sprintf(p, "%c",
@@ -314,7 +312,6 @@ static int prism2_scan_results_proc_read(char *page, char **start, off_t off,
314 int entry, i, len, total = 0; 312 int entry, i, len, total = 0;
315 struct hfa384x_hostscan_result *scanres; 313 struct hfa384x_hostscan_result *scanres;
316 u8 *pos; 314 u8 *pos;
317 DECLARE_MAC_BUF(mac);
318 315
319 p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates " 316 p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates "
320 "SSID\n"); 317 "SSID\n");
@@ -332,14 +329,14 @@ static int prism2_scan_results_proc_read(char *page, char **start, off_t off,
332 if ((p - page) > (PAGE_SIZE - 200)) 329 if ((p - page) > (PAGE_SIZE - 200))
333 break; 330 break;
334 331
335 p += sprintf(p, "%d %d %d %d 0x%02x %d %s %d ", 332 p += sprintf(p, "%d %d %d %d 0x%02x %d %pM %d ",
336 le16_to_cpu(scanres->chid), 333 le16_to_cpu(scanres->chid),
337 (s16) le16_to_cpu(scanres->anl), 334 (s16) le16_to_cpu(scanres->anl),
338 (s16) le16_to_cpu(scanres->sl), 335 (s16) le16_to_cpu(scanres->sl),
339 le16_to_cpu(scanres->beacon_interval), 336 le16_to_cpu(scanres->beacon_interval),
340 le16_to_cpu(scanres->capability), 337 le16_to_cpu(scanres->capability),
341 le16_to_cpu(scanres->rate), 338 le16_to_cpu(scanres->rate),
342 print_mac(mac, scanres->bssid), 339 scanres->bssid,
343 le16_to_cpu(scanres->atim)); 340 le16_to_cpu(scanres->atim));
344 341
345 pos = scanres->sup_rates; 342 pos = scanres->sup_rates;
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
index a68f97c39359..d2c7a56b8b59 100644
--- a/drivers/net/wireless/hostap/hostap_wlan.h
+++ b/drivers/net/wireless/hostap/hostap_wlan.h
@@ -822,7 +822,7 @@ struct local_info {
822 int last_scan_results_count; 822 int last_scan_results_count;
823 enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type; 823 enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type;
824 struct work_struct info_queue; 824 struct work_struct info_queue;
825 long pending_info; /* bit field of pending info_queue items */ 825 unsigned long pending_info; /* bit field of pending info_queue items */
826#define PRISM2_INFO_PENDING_LINKSTATUS 0 826#define PRISM2_INFO_PENDING_LINKSTATUS 0
827#define PRISM2_INFO_PENDING_SCANRESULTS 1 827#define PRISM2_INFO_PENDING_SCANRESULTS 1
828 int prev_link_status; /* previous received LinkStatus info */ 828 int prev_link_status; /* previous received LinkStatus info */
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index bca74811bc7f..062c9f280304 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -163,6 +163,8 @@ that only one external action is invoked at a time.
163#include <linux/ctype.h> 163#include <linux/ctype.h>
164#include <linux/pm_qos_params.h> 164#include <linux/pm_qos_params.h>
165 165
166#include <net/lib80211.h>
167
166#include "ipw2100.h" 168#include "ipw2100.h"
167 169
168#define IPW2100_VERSION "git-1.2.2" 170#define IPW2100_VERSION "git-1.2.2"
@@ -185,7 +187,7 @@ MODULE_LICENSE("GPL");
185static int debug = 0; 187static int debug = 0;
186static int mode = 0; 188static int mode = 0;
187static int channel = 0; 189static int channel = 0;
188static int associate = 1; 190static int associate = 0;
189static int disable = 0; 191static int disable = 0;
190#ifdef CONFIG_PM 192#ifdef CONFIG_PM
191static struct ipw2100_fw ipw2100_firmware; 193static struct ipw2100_fw ipw2100_firmware;
@@ -201,7 +203,7 @@ module_param(disable, int, 0444);
201MODULE_PARM_DESC(debug, "debug level"); 203MODULE_PARM_DESC(debug, "debug level");
202MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS,2=Monitor)"); 204MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS,2=Monitor)");
203MODULE_PARM_DESC(channel, "channel"); 205MODULE_PARM_DESC(channel, "channel");
204MODULE_PARM_DESC(associate, "auto associate when scanning (default on)"); 206MODULE_PARM_DESC(associate, "auto associate when scanning (default off)");
205MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])"); 207MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
206 208
207static u32 ipw2100_debug_level = IPW_DL_NONE; 209static u32 ipw2100_debug_level = IPW_DL_NONE;
@@ -1914,7 +1916,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1914 u32 chan; 1916 u32 chan;
1915 char *txratename; 1917 char *txratename;
1916 u8 bssid[ETH_ALEN]; 1918 u8 bssid[ETH_ALEN];
1917 DECLARE_MAC_BUF(mac); 1919 DECLARE_SSID_BUF(ssid);
1918 1920
1919 /* 1921 /*
1920 * TBD: BSSID is usually 00:00:00:00:00:00 here and not 1922 * TBD: BSSID is usually 00:00:00:00:00:00 here and not
@@ -1975,10 +1977,9 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1975 break; 1977 break;
1976 } 1978 }
1977 1979
1978 IPW_DEBUG_INFO("%s: Associated with '%s' at %s, channel %d (BSSID=" 1980 IPW_DEBUG_INFO("%s: Associated with '%s' at %s, channel %d (BSSID=%pM)\n",
1979 "%s)\n", 1981 priv->net_dev->name, print_ssid(ssid, essid, essid_len),
1980 priv->net_dev->name, escape_essid(essid, essid_len), 1982 txratename, chan, bssid);
1981 txratename, chan, print_mac(mac, bssid));
1982 1983
1983 /* now we copy read ssid into dev */ 1984 /* now we copy read ssid into dev */
1984 if (!(priv->config & CFG_STATIC_ESSID)) { 1985 if (!(priv->config & CFG_STATIC_ESSID)) {
@@ -2004,8 +2005,9 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
2004 .host_command_length = ssid_len 2005 .host_command_length = ssid_len
2005 }; 2006 };
2006 int err; 2007 int err;
2008 DECLARE_SSID_BUF(ssid);
2007 2009
2008 IPW_DEBUG_HC("SSID: '%s'\n", escape_essid(essid, ssid_len)); 2010 IPW_DEBUG_HC("SSID: '%s'\n", print_ssid(ssid, essid, ssid_len));
2009 2011
2010 if (ssid_len) 2012 if (ssid_len)
2011 memcpy(cmd.host_command_parameters, essid, ssid_len); 2013 memcpy(cmd.host_command_parameters, essid, ssid_len);
@@ -2046,12 +2048,12 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
2046 2048
2047static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status) 2049static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
2048{ 2050{
2049 DECLARE_MAC_BUF(mac); 2051 DECLARE_SSID_BUF(ssid);
2050 2052
2051 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, 2053 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
2052 "disassociated: '%s' %s \n", 2054 "disassociated: '%s' %pM \n",
2053 escape_essid(priv->essid, priv->essid_len), 2055 print_ssid(ssid, priv->essid, priv->essid_len),
2054 print_mac(mac, priv->bssid)); 2056 priv->bssid);
2055 2057
2056 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); 2058 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
2057 2059
@@ -4058,7 +4060,6 @@ static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
4058 char *out = buf; 4060 char *out = buf;
4059 int length; 4061 int length;
4060 int ret; 4062 int ret;
4061 DECLARE_MAC_BUF(mac);
4062 4063
4063 if (priv->status & STATUS_RF_KILL_MASK) 4064 if (priv->status & STATUS_RF_KILL_MASK)
4064 return 0; 4065 return 0;
@@ -4086,7 +4087,7 @@ static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
4086 __LINE__); 4087 __LINE__);
4087 4088
4088 out += sprintf(out, "ESSID: %s\n", essid); 4089 out += sprintf(out, "ESSID: %s\n", essid);
4089 out += sprintf(out, "BSSID: %s\n", print_mac(mac, bssid)); 4090 out += sprintf(out, "BSSID: %pM\n", bssid);
4090 out += sprintf(out, "Channel: %d\n", chan); 4091 out += sprintf(out, "Channel: %d\n", chan);
4091 4092
4092 return out - buf; 4093 return out - buf;
@@ -4662,7 +4663,6 @@ static int ipw2100_read_mac_address(struct ipw2100_priv *priv)
4662{ 4663{
4663 u32 length = ETH_ALEN; 4664 u32 length = ETH_ALEN;
4664 u8 addr[ETH_ALEN]; 4665 u8 addr[ETH_ALEN];
4665 DECLARE_MAC_BUF(mac);
4666 4666
4667 int err; 4667 int err;
4668 4668
@@ -4673,8 +4673,7 @@ static int ipw2100_read_mac_address(struct ipw2100_priv *priv)
4673 } 4673 }
4674 4674
4675 memcpy(priv->net_dev->dev_addr, addr, ETH_ALEN); 4675 memcpy(priv->net_dev->dev_addr, addr, ETH_ALEN);
4676 IPW_DEBUG_INFO("card MAC is %s\n", 4676 IPW_DEBUG_INFO("card MAC is %pM\n", priv->net_dev->dev_addr);
4677 print_mac(mac, priv->net_dev->dev_addr));
4678 4677
4679 return 0; 4678 return 0;
4680} 4679}
@@ -5053,10 +5052,8 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 * bssid,
5053 int err; 5052 int err;
5054 5053
5055#ifdef CONFIG_IPW2100_DEBUG 5054#ifdef CONFIG_IPW2100_DEBUG
5056 DECLARE_MAC_BUF(mac);
5057 if (bssid != NULL) 5055 if (bssid != NULL)
5058 IPW_DEBUG_HC("MANDATORY_BSSID: %s\n", 5056 IPW_DEBUG_HC("MANDATORY_BSSID: %pM\n", bssid);
5059 print_mac(mac, bssid));
5060 else 5057 else
5061 IPW_DEBUG_HC("MANDATORY_BSSID: <clear>\n"); 5058 IPW_DEBUG_HC("MANDATORY_BSSID: <clear>\n");
5062#endif 5059#endif
@@ -6905,7 +6902,6 @@ static int ipw2100_wx_set_wap(struct net_device *dev,
6905 static const unsigned char off[] = { 6902 static const unsigned char off[] = {
6906 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 6903 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6907 }; 6904 };
6908 DECLARE_MAC_BUF(mac);
6909 6905
6910 // sanity checks 6906 // sanity checks
6911 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) 6907 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER)
@@ -6931,8 +6927,7 @@ static int ipw2100_wx_set_wap(struct net_device *dev,
6931 6927
6932 err = ipw2100_set_mandatory_bssid(priv, wrqu->ap_addr.sa_data, 0); 6928 err = ipw2100_set_mandatory_bssid(priv, wrqu->ap_addr.sa_data, 0);
6933 6929
6934 IPW_DEBUG_WX("SET BSSID -> %s\n", 6930 IPW_DEBUG_WX("SET BSSID -> %pM\n", wrqu->ap_addr.sa_data);
6935 print_mac(mac, wrqu->ap_addr.sa_data));
6936 6931
6937 done: 6932 done:
6938 mutex_unlock(&priv->action_mutex); 6933 mutex_unlock(&priv->action_mutex);
@@ -6948,7 +6943,6 @@ static int ipw2100_wx_get_wap(struct net_device *dev,
6948 */ 6943 */
6949 6944
6950 struct ipw2100_priv *priv = ieee80211_priv(dev); 6945 struct ipw2100_priv *priv = ieee80211_priv(dev);
6951 DECLARE_MAC_BUF(mac);
6952 6946
6953 /* If we are associated, trying to associate, or have a statically 6947 /* If we are associated, trying to associate, or have a statically
6954 * configured BSSID then return that; otherwise return ANY */ 6948 * configured BSSID then return that; otherwise return ANY */
@@ -6958,8 +6952,7 @@ static int ipw2100_wx_get_wap(struct net_device *dev,
6958 } else 6952 } else
6959 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); 6953 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
6960 6954
6961 IPW_DEBUG_WX("Getting WAP BSSID: %s\n", 6955 IPW_DEBUG_WX("Getting WAP BSSID: %pM\n", wrqu->ap_addr.sa_data);
6962 print_mac(mac, wrqu->ap_addr.sa_data));
6963 return 0; 6956 return 0;
6964} 6957}
6965 6958
@@ -6971,6 +6964,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
6971 char *essid = ""; /* ANY */ 6964 char *essid = ""; /* ANY */
6972 int length = 0; 6965 int length = 0;
6973 int err = 0; 6966 int err = 0;
6967 DECLARE_SSID_BUF(ssid);
6974 6968
6975 mutex_lock(&priv->action_mutex); 6969 mutex_lock(&priv->action_mutex);
6976 if (!(priv->status & STATUS_INITIALIZED)) { 6970 if (!(priv->status & STATUS_INITIALIZED)) {
@@ -7000,8 +6994,8 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
7000 goto done; 6994 goto done;
7001 } 6995 }
7002 6996
7003 IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(essid, length), 6997 IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n",
7004 length); 6998 print_ssid(ssid, essid, length), length);
7005 6999
7006 priv->essid_len = length; 7000 priv->essid_len = length;
7007 memcpy(priv->essid, essid, priv->essid_len); 7001 memcpy(priv->essid, essid, priv->essid_len);
@@ -7022,12 +7016,13 @@ static int ipw2100_wx_get_essid(struct net_device *dev,
7022 */ 7016 */
7023 7017
7024 struct ipw2100_priv *priv = ieee80211_priv(dev); 7018 struct ipw2100_priv *priv = ieee80211_priv(dev);
7019 DECLARE_SSID_BUF(ssid);
7025 7020
7026 /* If we are associated, trying to associate, or have a statically 7021 /* If we are associated, trying to associate, or have a statically
7027 * configured ESSID then return that; otherwise return ANY */ 7022 * configured ESSID then return that; otherwise return ANY */
7028 if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) { 7023 if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) {
7029 IPW_DEBUG_WX("Getting essid: '%s'\n", 7024 IPW_DEBUG_WX("Getting essid: '%s'\n",
7030 escape_essid(priv->essid, priv->essid_len)); 7025 print_ssid(ssid, priv->essid, priv->essid_len));
7031 memcpy(extra, priv->essid, priv->essid_len); 7026 memcpy(extra, priv->essid, priv->essid_len);
7032 wrqu->essid.length = priv->essid_len; 7027 wrqu->essid.length = priv->essid_len;
7033 wrqu->essid.flags = 1; /* active */ 7028 wrqu->essid.flags = 1; /* active */
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index dcce3542d5a7..051ae92d8b65 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -87,7 +87,7 @@ static int channel = 0;
87static int mode = 0; 87static int mode = 0;
88 88
89static u32 ipw_debug_level; 89static u32 ipw_debug_level;
90static int associate = 1; 90static int associate;
91static int auto_create = 1; 91static int auto_create = 1;
92static int led = 0; 92static int led = 0;
93static int disable = 0; 93static int disable = 0;
@@ -2265,8 +2265,8 @@ static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac)
2265 return -1; 2265 return -1;
2266 } 2266 }
2267 2267
2268 IPW_DEBUG_INFO("%s: Setting MAC to %s\n", 2268 IPW_DEBUG_INFO("%s: Setting MAC to %pM\n",
2269 priv->net_dev->name, print_mac(mac, mac)); 2269 priv->net_dev->name, mac);
2270 2270
2271 return ipw_send_cmd_pdu(priv, IPW_CMD_ADAPTER_ADDRESS, ETH_ALEN, mac); 2271 return ipw_send_cmd_pdu(priv, IPW_CMD_ADAPTER_ADDRESS, ETH_ALEN, mac);
2272} 2272}
@@ -3812,7 +3812,6 @@ static u8 ipw_add_station(struct ipw_priv *priv, u8 * bssid)
3812{ 3812{
3813 struct ipw_station_entry entry; 3813 struct ipw_station_entry entry;
3814 int i; 3814 int i;
3815 DECLARE_MAC_BUF(mac);
3816 3815
3817 for (i = 0; i < priv->num_stations; i++) { 3816 for (i = 0; i < priv->num_stations; i++) {
3818 if (!memcmp(priv->stations[i], bssid, ETH_ALEN)) { 3817 if (!memcmp(priv->stations[i], bssid, ETH_ALEN)) {
@@ -3829,7 +3828,7 @@ static u8 ipw_add_station(struct ipw_priv *priv, u8 * bssid)
3829 if (i == MAX_STATIONS) 3828 if (i == MAX_STATIONS)
3830 return IPW_INVALID_STATION; 3829 return IPW_INVALID_STATION;
3831 3830
3832 IPW_DEBUG_SCAN("Adding AdHoc station: %s\n", print_mac(mac, bssid)); 3831 IPW_DEBUG_SCAN("Adding AdHoc station: %pM\n", bssid);
3833 3832
3834 entry.reserved = 0; 3833 entry.reserved = 0;
3835 entry.support_mode = 0; 3834 entry.support_mode = 0;
@@ -3856,7 +3855,6 @@ static u8 ipw_find_station(struct ipw_priv *priv, u8 * bssid)
3856static void ipw_send_disassociate(struct ipw_priv *priv, int quiet) 3855static void ipw_send_disassociate(struct ipw_priv *priv, int quiet)
3857{ 3856{
3858 int err; 3857 int err;
3859 DECLARE_MAC_BUF(mac);
3860 3858
3861 if (priv->status & STATUS_ASSOCIATING) { 3859 if (priv->status & STATUS_ASSOCIATING) {
3862 IPW_DEBUG_ASSOC("Disassociating while associating.\n"); 3860 IPW_DEBUG_ASSOC("Disassociating while associating.\n");
@@ -3869,9 +3867,9 @@ static void ipw_send_disassociate(struct ipw_priv *priv, int quiet)
3869 return; 3867 return;
3870 } 3868 }
3871 3869
3872 IPW_DEBUG_ASSOC("Disassocation attempt from %s " 3870 IPW_DEBUG_ASSOC("Disassocation attempt from %pM "
3873 "on channel %d.\n", 3871 "on channel %d.\n",
3874 print_mac(mac, priv->assoc_request.bssid), 3872 priv->assoc_request.bssid,
3875 priv->assoc_request.channel); 3873 priv->assoc_request.channel);
3876 3874
3877 priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED); 3875 priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED);
@@ -4397,7 +4395,7 @@ static void handle_scan_event(struct ipw_priv *priv)
4397static void ipw_rx_notification(struct ipw_priv *priv, 4395static void ipw_rx_notification(struct ipw_priv *priv,
4398 struct ipw_rx_notification *notif) 4396 struct ipw_rx_notification *notif)
4399{ 4397{
4400 DECLARE_MAC_BUF(mac); 4398 DECLARE_SSID_BUF(ssid);
4401 u16 size = le16_to_cpu(notif->size); 4399 u16 size = le16_to_cpu(notif->size);
4402 notif->size = le16_to_cpu(notif->size); 4400 notif->size = le16_to_cpu(notif->size);
4403 4401
@@ -4411,11 +4409,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4411 case CMAS_ASSOCIATED:{ 4409 case CMAS_ASSOCIATED:{
4412 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | 4410 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
4413 IPW_DL_ASSOC, 4411 IPW_DL_ASSOC,
4414 "associated: '%s' %s" 4412 "associated: '%s' %pM \n",
4415 " \n", 4413 print_ssid(ssid, priv->essid,
4416 escape_essid(priv->essid, 4414 priv->essid_len),
4417 priv->essid_len), 4415 priv->bssid);
4418 print_mac(mac, priv->bssid));
4419 4416
4420 switch (priv->ieee->iw_mode) { 4417 switch (priv->ieee->iw_mode) {
4421 case IW_MODE_INFRA: 4418 case IW_MODE_INFRA:
@@ -4449,7 +4446,7 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4449 4446
4450#ifdef CONFIG_IPW2200_QOS 4447#ifdef CONFIG_IPW2200_QOS
4451#define IPW_GET_PACKET_STYPE(x) WLAN_FC_GET_STYPE( \ 4448#define IPW_GET_PACKET_STYPE(x) WLAN_FC_GET_STYPE( \
4452 le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_ctl)) 4449 le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_control))
4453 if ((priv->status & STATUS_AUTH) && 4450 if ((priv->status & STATUS_AUTH) &&
4454 (IPW_GET_PACKET_STYPE(&notif->u.raw) 4451 (IPW_GET_PACKET_STYPE(&notif->u.raw)
4455 == IEEE80211_STYPE_ASSOC_RESP)) { 4452 == IEEE80211_STYPE_ASSOC_RESP)) {
@@ -4492,13 +4489,14 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4492 IPW_DL_STATE | 4489 IPW_DL_STATE |
4493 IPW_DL_ASSOC, 4490 IPW_DL_ASSOC,
4494 "deauthenticated: '%s' " 4491 "deauthenticated: '%s' "
4495 "%s" 4492 "%pM"
4496 ": (0x%04X) - %s \n", 4493 ": (0x%04X) - %s \n",
4497 escape_essid(priv-> 4494 print_ssid(ssid,
4498 essid, 4495 priv->
4499 priv-> 4496 essid,
4500 essid_len), 4497 priv->
4501 print_mac(mac, priv->bssid), 4498 essid_len),
4499 priv->bssid,
4502 le16_to_cpu(auth->status), 4500 le16_to_cpu(auth->status),
4503 ipw_get_status_code 4501 ipw_get_status_code
4504 (le16_to_cpu 4502 (le16_to_cpu
@@ -4515,11 +4513,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4515 4513
4516 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | 4514 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
4517 IPW_DL_ASSOC, 4515 IPW_DL_ASSOC,
4518 "authenticated: '%s' %s" 4516 "authenticated: '%s' %pM\n",
4519 "\n", 4517 print_ssid(ssid, priv->essid,
4520 escape_essid(priv->essid, 4518 priv->essid_len),
4521 priv->essid_len), 4519 priv->bssid);
4522 print_mac(mac, priv->bssid));
4523 break; 4520 break;
4524 } 4521 }
4525 4522
@@ -4544,11 +4541,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4544 4541
4545 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | 4542 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
4546 IPW_DL_ASSOC, 4543 IPW_DL_ASSOC,
4547 "disassociated: '%s' %s" 4544 "disassociated: '%s' %pM \n",
4548 " \n", 4545 print_ssid(ssid, priv->essid,
4549 escape_essid(priv->essid, 4546 priv->essid_len),
4550 priv->essid_len), 4547 priv->bssid);
4551 print_mac(mac, priv->bssid));
4552 4548
4553 priv->status &= 4549 priv->status &=
4554 ~(STATUS_DISASSOCIATING | 4550 ~(STATUS_DISASSOCIATING |
@@ -4583,10 +4579,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4583 switch (auth->state) { 4579 switch (auth->state) {
4584 case CMAS_AUTHENTICATED: 4580 case CMAS_AUTHENTICATED:
4585 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, 4581 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
4586 "authenticated: '%s' %s \n", 4582 "authenticated: '%s' %pM \n",
4587 escape_essid(priv->essid, 4583 print_ssid(ssid, priv->essid,
4588 priv->essid_len), 4584 priv->essid_len),
4589 print_mac(mac, priv->bssid)); 4585 priv->bssid);
4590 priv->status |= STATUS_AUTH; 4586 priv->status |= STATUS_AUTH;
4591 break; 4587 break;
4592 4588
@@ -4602,10 +4598,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4602 } 4598 }
4603 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | 4599 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
4604 IPW_DL_ASSOC, 4600 IPW_DL_ASSOC,
4605 "deauthenticated: '%s' %s\n", 4601 "deauthenticated: '%s' %pM\n",
4606 escape_essid(priv->essid, 4602 print_ssid(ssid, priv->essid,
4607 priv->essid_len), 4603 priv->essid_len),
4608 print_mac(mac, priv->bssid)); 4604 priv->bssid);
4609 4605
4610 priv->status &= ~(STATUS_ASSOCIATING | 4606 priv->status &= ~(STATUS_ASSOCIATING |
4611 STATUS_AUTH | 4607 STATUS_AUTH |
@@ -5429,27 +5425,17 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5429 int roaming) 5425 int roaming)
5430{ 5426{
5431 struct ipw_supported_rates rates; 5427 struct ipw_supported_rates rates;
5432 DECLARE_MAC_BUF(mac); 5428 DECLARE_SSID_BUF(ssid);
5433 DECLARE_MAC_BUF(mac2);
5434 5429
5435 /* Verify that this network's capability is compatible with the 5430 /* Verify that this network's capability is compatible with the
5436 * current mode (AdHoc or Infrastructure) */ 5431 * current mode (AdHoc or Infrastructure) */
5437 if ((priv->ieee->iw_mode == IW_MODE_ADHOC && 5432 if ((priv->ieee->iw_mode == IW_MODE_ADHOC &&
5438 !(network->capability & WLAN_CAPABILITY_IBSS))) { 5433 !(network->capability & WLAN_CAPABILITY_IBSS))) {
5439 IPW_DEBUG_MERGE("Network '%s (%s)' excluded due to " 5434 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded due to "
5440 "capability mismatch.\n", 5435 "capability mismatch.\n",
5441 escape_essid(network->ssid, network->ssid_len), 5436 print_ssid(ssid, network->ssid,
5442 print_mac(mac, network->bssid)); 5437 network->ssid_len),
5443 return 0; 5438 network->bssid);
5444 }
5445
5446 /* If we do not have an ESSID for this AP, we can not associate with
5447 * it */
5448 if (network->flags & NETWORK_EMPTY_ESSID) {
5449 IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
5450 "because of hidden ESSID.\n",
5451 escape_essid(network->ssid, network->ssid_len),
5452 print_mac(mac, network->bssid));
5453 return 0; 5439 return 0;
5454 } 5440 }
5455 5441
@@ -5459,11 +5445,11 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5459 if ((network->ssid_len != match->network->ssid_len) || 5445 if ((network->ssid_len != match->network->ssid_len) ||
5460 memcmp(network->ssid, match->network->ssid, 5446 memcmp(network->ssid, match->network->ssid,
5461 network->ssid_len)) { 5447 network->ssid_len)) {
5462 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5448 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5463 "because of non-network ESSID.\n", 5449 "because of non-network ESSID.\n",
5464 escape_essid(network->ssid, 5450 print_ssid(ssid, network->ssid,
5465 network->ssid_len), 5451 network->ssid_len),
5466 print_mac(mac, network->bssid)); 5452 network->bssid);
5467 return 0; 5453 return 0;
5468 } 5454 }
5469 } else { 5455 } else {
@@ -5476,13 +5462,14 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5476 char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 5462 char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
5477 5463
5478 strncpy(escaped, 5464 strncpy(escaped,
5479 escape_essid(network->ssid, network->ssid_len), 5465 print_ssid(ssid, network->ssid,
5466 network->ssid_len),
5480 sizeof(escaped)); 5467 sizeof(escaped));
5481 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5468 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5482 "because of ESSID mismatch: '%s'.\n", 5469 "because of ESSID mismatch: '%s'.\n",
5483 escaped, print_mac(mac, network->bssid), 5470 escaped, network->bssid,
5484 escape_essid(priv->essid, 5471 print_ssid(ssid, priv->essid,
5485 priv->essid_len)); 5472 priv->essid_len));
5486 return 0; 5473 return 0;
5487 } 5474 }
5488 } 5475 }
@@ -5493,24 +5480,25 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5493 if (network->time_stamp[0] < match->network->time_stamp[0]) { 5480 if (network->time_stamp[0] < match->network->time_stamp[0]) {
5494 IPW_DEBUG_MERGE("Network '%s excluded because newer than " 5481 IPW_DEBUG_MERGE("Network '%s excluded because newer than "
5495 "current network.\n", 5482 "current network.\n",
5496 escape_essid(match->network->ssid, 5483 print_ssid(ssid, match->network->ssid,
5497 match->network->ssid_len)); 5484 match->network->ssid_len));
5498 return 0; 5485 return 0;
5499 } else if (network->time_stamp[1] < match->network->time_stamp[1]) { 5486 } else if (network->time_stamp[1] < match->network->time_stamp[1]) {
5500 IPW_DEBUG_MERGE("Network '%s excluded because newer than " 5487 IPW_DEBUG_MERGE("Network '%s excluded because newer than "
5501 "current network.\n", 5488 "current network.\n",
5502 escape_essid(match->network->ssid, 5489 print_ssid(ssid, match->network->ssid,
5503 match->network->ssid_len)); 5490 match->network->ssid_len));
5504 return 0; 5491 return 0;
5505 } 5492 }
5506 5493
5507 /* Now go through and see if the requested network is valid... */ 5494 /* Now go through and see if the requested network is valid... */
5508 if (priv->ieee->scan_age != 0 && 5495 if (priv->ieee->scan_age != 0 &&
5509 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) { 5496 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
5510 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5497 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5511 "because of age: %ums.\n", 5498 "because of age: %ums.\n",
5512 escape_essid(network->ssid, network->ssid_len), 5499 print_ssid(ssid, network->ssid,
5513 print_mac(mac, network->bssid), 5500 network->ssid_len),
5501 network->bssid,
5514 jiffies_to_msecs(jiffies - 5502 jiffies_to_msecs(jiffies -
5515 network->last_scanned)); 5503 network->last_scanned));
5516 return 0; 5504 return 0;
@@ -5518,10 +5506,11 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5518 5506
5519 if ((priv->config & CFG_STATIC_CHANNEL) && 5507 if ((priv->config & CFG_STATIC_CHANNEL) &&
5520 (network->channel != priv->channel)) { 5508 (network->channel != priv->channel)) {
5521 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5509 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5522 "because of channel mismatch: %d != %d.\n", 5510 "because of channel mismatch: %d != %d.\n",
5523 escape_essid(network->ssid, network->ssid_len), 5511 print_ssid(ssid, network->ssid,
5524 print_mac(mac, network->bssid), 5512 network->ssid_len),
5513 network->bssid,
5525 network->channel, priv->channel); 5514 network->channel, priv->channel);
5526 return 0; 5515 return 0;
5527 } 5516 }
@@ -5529,10 +5518,11 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5529 /* Verify privacy compatability */ 5518 /* Verify privacy compatability */
5530 if (((priv->capability & CAP_PRIVACY_ON) ? 1 : 0) != 5519 if (((priv->capability & CAP_PRIVACY_ON) ? 1 : 0) !=
5531 ((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) { 5520 ((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) {
5532 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5521 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5533 "because of privacy mismatch: %s != %s.\n", 5522 "because of privacy mismatch: %s != %s.\n",
5534 escape_essid(network->ssid, network->ssid_len), 5523 print_ssid(ssid, network->ssid,
5535 print_mac(mac, network->bssid), 5524 network->ssid_len),
5525 network->bssid,
5536 priv-> 5526 priv->
5537 capability & CAP_PRIVACY_ON ? "on" : "off", 5527 capability & CAP_PRIVACY_ON ? "on" : "off",
5538 network-> 5528 network->
@@ -5542,41 +5532,44 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5542 } 5532 }
5543 5533
5544 if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) { 5534 if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
5545 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5535 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5546 "because of the same BSSID match: %s" 5536 "because of the same BSSID match: %pM"
5547 ".\n", escape_essid(network->ssid, 5537 ".\n", print_ssid(ssid, network->ssid,
5548 network->ssid_len), 5538 network->ssid_len),
5549 print_mac(mac, network->bssid), 5539 network->bssid,
5550 print_mac(mac2, priv->bssid)); 5540 priv->bssid);
5551 return 0; 5541 return 0;
5552 } 5542 }
5553 5543
5554 /* Filter out any incompatible freq / mode combinations */ 5544 /* Filter out any incompatible freq / mode combinations */
5555 if (!ieee80211_is_valid_mode(priv->ieee, network->mode)) { 5545 if (!ieee80211_is_valid_mode(priv->ieee, network->mode)) {
5556 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5546 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5557 "because of invalid frequency/mode " 5547 "because of invalid frequency/mode "
5558 "combination.\n", 5548 "combination.\n",
5559 escape_essid(network->ssid, network->ssid_len), 5549 print_ssid(ssid, network->ssid,
5560 print_mac(mac, network->bssid)); 5550 network->ssid_len),
5551 network->bssid);
5561 return 0; 5552 return 0;
5562 } 5553 }
5563 5554
5564 /* Ensure that the rates supported by the driver are compatible with 5555 /* Ensure that the rates supported by the driver are compatible with
5565 * this AP, including verification of basic rates (mandatory) */ 5556 * this AP, including verification of basic rates (mandatory) */
5566 if (!ipw_compatible_rates(priv, network, &rates)) { 5557 if (!ipw_compatible_rates(priv, network, &rates)) {
5567 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5558 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5568 "because configured rate mask excludes " 5559 "because configured rate mask excludes "
5569 "AP mandatory rate.\n", 5560 "AP mandatory rate.\n",
5570 escape_essid(network->ssid, network->ssid_len), 5561 print_ssid(ssid, network->ssid,
5571 print_mac(mac, network->bssid)); 5562 network->ssid_len),
5563 network->bssid);
5572 return 0; 5564 return 0;
5573 } 5565 }
5574 5566
5575 if (rates.num_rates == 0) { 5567 if (rates.num_rates == 0) {
5576 IPW_DEBUG_MERGE("Network '%s (%s)' excluded " 5568 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5577 "because of no compatible rates.\n", 5569 "because of no compatible rates.\n",
5578 escape_essid(network->ssid, network->ssid_len), 5570 print_ssid(ssid, network->ssid,
5579 print_mac(mac, network->bssid)); 5571 network->ssid_len),
5572 network->bssid);
5580 return 0; 5573 return 0;
5581 } 5574 }
5582 5575
@@ -5587,15 +5580,16 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5587 /* Set up 'new' AP to this network */ 5580 /* Set up 'new' AP to this network */
5588 ipw_copy_rates(&match->rates, &rates); 5581 ipw_copy_rates(&match->rates, &rates);
5589 match->network = network; 5582 match->network = network;
5590 IPW_DEBUG_MERGE("Network '%s (%s)' is a viable match.\n", 5583 IPW_DEBUG_MERGE("Network '%s (%pM)' is a viable match.\n",
5591 escape_essid(network->ssid, network->ssid_len), 5584 print_ssid(ssid, network->ssid, network->ssid_len),
5592 print_mac(mac, network->bssid)); 5585 network->bssid);
5593 5586
5594 return 1; 5587 return 1;
5595} 5588}
5596 5589
5597static void ipw_merge_adhoc_network(struct work_struct *work) 5590static void ipw_merge_adhoc_network(struct work_struct *work)
5598{ 5591{
5592 DECLARE_SSID_BUF(ssid);
5599 struct ipw_priv *priv = 5593 struct ipw_priv *priv =
5600 container_of(work, struct ipw_priv, merge_networks); 5594 container_of(work, struct ipw_priv, merge_networks);
5601 struct ieee80211_network *network = NULL; 5595 struct ieee80211_network *network = NULL;
@@ -5626,8 +5620,8 @@ static void ipw_merge_adhoc_network(struct work_struct *work)
5626 mutex_lock(&priv->mutex); 5620 mutex_lock(&priv->mutex);
5627 if ((priv->ieee->iw_mode == IW_MODE_ADHOC)) { 5621 if ((priv->ieee->iw_mode == IW_MODE_ADHOC)) {
5628 IPW_DEBUG_MERGE("remove network %s\n", 5622 IPW_DEBUG_MERGE("remove network %s\n",
5629 escape_essid(priv->essid, 5623 print_ssid(ssid, priv->essid,
5630 priv->essid_len)); 5624 priv->essid_len));
5631 ipw_remove_current_network(priv); 5625 ipw_remove_current_network(priv);
5632 } 5626 }
5633 5627
@@ -5643,7 +5637,7 @@ static int ipw_best_network(struct ipw_priv *priv,
5643 struct ieee80211_network *network, int roaming) 5637 struct ieee80211_network *network, int roaming)
5644{ 5638{
5645 struct ipw_supported_rates rates; 5639 struct ipw_supported_rates rates;
5646 DECLARE_MAC_BUF(mac); 5640 DECLARE_SSID_BUF(ssid);
5647 5641
5648 /* Verify that this network's capability is compatible with the 5642 /* Verify that this network's capability is compatible with the
5649 * current mode (AdHoc or Infrastructure) */ 5643 * current mode (AdHoc or Infrastructure) */
@@ -5651,20 +5645,11 @@ static int ipw_best_network(struct ipw_priv *priv,
5651 !(network->capability & WLAN_CAPABILITY_ESS)) || 5645 !(network->capability & WLAN_CAPABILITY_ESS)) ||
5652 (priv->ieee->iw_mode == IW_MODE_ADHOC && 5646 (priv->ieee->iw_mode == IW_MODE_ADHOC &&
5653 !(network->capability & WLAN_CAPABILITY_IBSS))) { 5647 !(network->capability & WLAN_CAPABILITY_IBSS))) {
5654 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded due to " 5648 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded due to "
5655 "capability mismatch.\n", 5649 "capability mismatch.\n",
5656 escape_essid(network->ssid, network->ssid_len), 5650 print_ssid(ssid, network->ssid,
5657 print_mac(mac, network->bssid)); 5651 network->ssid_len),
5658 return 0; 5652 network->bssid);
5659 }
5660
5661 /* If we do not have an ESSID for this AP, we can not associate with
5662 * it */
5663 if (network->flags & NETWORK_EMPTY_ESSID) {
5664 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
5665 "because of hidden ESSID.\n",
5666 escape_essid(network->ssid, network->ssid_len),
5667 print_mac(mac, network->bssid));
5668 return 0; 5653 return 0;
5669 } 5654 }
5670 5655
@@ -5674,11 +5659,11 @@ static int ipw_best_network(struct ipw_priv *priv,
5674 if ((network->ssid_len != match->network->ssid_len) || 5659 if ((network->ssid_len != match->network->ssid_len) ||
5675 memcmp(network->ssid, match->network->ssid, 5660 memcmp(network->ssid, match->network->ssid,
5676 network->ssid_len)) { 5661 network->ssid_len)) {
5677 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5662 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5678 "because of non-network ESSID.\n", 5663 "because of non-network ESSID.\n",
5679 escape_essid(network->ssid, 5664 print_ssid(ssid, network->ssid,
5680 network->ssid_len), 5665 network->ssid_len),
5681 print_mac(mac, network->bssid)); 5666 network->bssid);
5682 return 0; 5667 return 0;
5683 } 5668 }
5684 } else { 5669 } else {
@@ -5690,13 +5675,14 @@ static int ipw_best_network(struct ipw_priv *priv,
5690 min(network->ssid_len, priv->essid_len)))) { 5675 min(network->ssid_len, priv->essid_len)))) {
5691 char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 5676 char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
5692 strncpy(escaped, 5677 strncpy(escaped,
5693 escape_essid(network->ssid, network->ssid_len), 5678 print_ssid(ssid, network->ssid,
5679 network->ssid_len),
5694 sizeof(escaped)); 5680 sizeof(escaped));
5695 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5681 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5696 "because of ESSID mismatch: '%s'.\n", 5682 "because of ESSID mismatch: '%s'.\n",
5697 escaped, print_mac(mac, network->bssid), 5683 escaped, network->bssid,
5698 escape_essid(priv->essid, 5684 print_ssid(ssid, priv->essid,
5699 priv->essid_len)); 5685 priv->essid_len));
5700 return 0; 5686 return 0;
5701 } 5687 }
5702 } 5688 }
@@ -5706,14 +5692,14 @@ static int ipw_best_network(struct ipw_priv *priv,
5706 if (match->network && match->network->stats.rssi > network->stats.rssi) { 5692 if (match->network && match->network->stats.rssi > network->stats.rssi) {
5707 char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 5693 char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
5708 strncpy(escaped, 5694 strncpy(escaped,
5709 escape_essid(network->ssid, network->ssid_len), 5695 print_ssid(ssid, network->ssid, network->ssid_len),
5710 sizeof(escaped)); 5696 sizeof(escaped));
5711 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded because " 5697 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded because "
5712 "'%s (%s)' has a stronger signal.\n", 5698 "'%s (%pM)' has a stronger signal.\n",
5713 escaped, print_mac(mac, network->bssid), 5699 escaped, network->bssid,
5714 escape_essid(match->network->ssid, 5700 print_ssid(ssid, match->network->ssid,
5715 match->network->ssid_len), 5701 match->network->ssid_len),
5716 print_mac(mac, match->network->bssid)); 5702 match->network->bssid);
5717 return 0; 5703 return 0;
5718 } 5704 }
5719 5705
@@ -5721,11 +5707,12 @@ static int ipw_best_network(struct ipw_priv *priv,
5721 * last 3 seconds, do not try and associate again... */ 5707 * last 3 seconds, do not try and associate again... */
5722 if (network->last_associate && 5708 if (network->last_associate &&
5723 time_after(network->last_associate + (HZ * 3UL), jiffies)) { 5709 time_after(network->last_associate + (HZ * 3UL), jiffies)) {
5724 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5710 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5725 "because of storming (%ums since last " 5711 "because of storming (%ums since last "
5726 "assoc attempt).\n", 5712 "assoc attempt).\n",
5727 escape_essid(network->ssid, network->ssid_len), 5713 print_ssid(ssid, network->ssid,
5728 print_mac(mac, network->bssid), 5714 network->ssid_len),
5715 network->bssid,
5729 jiffies_to_msecs(jiffies - 5716 jiffies_to_msecs(jiffies -
5730 network->last_associate)); 5717 network->last_associate));
5731 return 0; 5718 return 0;
@@ -5734,10 +5721,11 @@ static int ipw_best_network(struct ipw_priv *priv,
5734 /* Now go through and see if the requested network is valid... */ 5721 /* Now go through and see if the requested network is valid... */
5735 if (priv->ieee->scan_age != 0 && 5722 if (priv->ieee->scan_age != 0 &&
5736 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) { 5723 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
5737 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5724 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5738 "because of age: %ums.\n", 5725 "because of age: %ums.\n",
5739 escape_essid(network->ssid, network->ssid_len), 5726 print_ssid(ssid, network->ssid,
5740 print_mac(mac, network->bssid), 5727 network->ssid_len),
5728 network->bssid,
5741 jiffies_to_msecs(jiffies - 5729 jiffies_to_msecs(jiffies -
5742 network->last_scanned)); 5730 network->last_scanned));
5743 return 0; 5731 return 0;
@@ -5745,10 +5733,11 @@ static int ipw_best_network(struct ipw_priv *priv,
5745 5733
5746 if ((priv->config & CFG_STATIC_CHANNEL) && 5734 if ((priv->config & CFG_STATIC_CHANNEL) &&
5747 (network->channel != priv->channel)) { 5735 (network->channel != priv->channel)) {
5748 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5736 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5749 "because of channel mismatch: %d != %d.\n", 5737 "because of channel mismatch: %d != %d.\n",
5750 escape_essid(network->ssid, network->ssid_len), 5738 print_ssid(ssid, network->ssid,
5751 print_mac(mac, network->bssid), 5739 network->ssid_len),
5740 network->bssid,
5752 network->channel, priv->channel); 5741 network->channel, priv->channel);
5753 return 0; 5742 return 0;
5754 } 5743 }
@@ -5756,10 +5745,11 @@ static int ipw_best_network(struct ipw_priv *priv,
5756 /* Verify privacy compatability */ 5745 /* Verify privacy compatability */
5757 if (((priv->capability & CAP_PRIVACY_ON) ? 1 : 0) != 5746 if (((priv->capability & CAP_PRIVACY_ON) ? 1 : 0) !=
5758 ((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) { 5747 ((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) {
5759 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5748 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5760 "because of privacy mismatch: %s != %s.\n", 5749 "because of privacy mismatch: %s != %s.\n",
5761 escape_essid(network->ssid, network->ssid_len), 5750 print_ssid(ssid, network->ssid,
5762 print_mac(mac, network->bssid), 5751 network->ssid_len),
5752 network->bssid,
5763 priv->capability & CAP_PRIVACY_ON ? "on" : 5753 priv->capability & CAP_PRIVACY_ON ? "on" :
5764 "off", 5754 "off",
5765 network->capability & 5755 network->capability &
@@ -5769,48 +5759,53 @@ static int ipw_best_network(struct ipw_priv *priv,
5769 5759
5770 if ((priv->config & CFG_STATIC_BSSID) && 5760 if ((priv->config & CFG_STATIC_BSSID) &&
5771 memcmp(network->bssid, priv->bssid, ETH_ALEN)) { 5761 memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
5772 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5762 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5773 "because of BSSID mismatch: %s.\n", 5763 "because of BSSID mismatch: %pM.\n",
5774 escape_essid(network->ssid, network->ssid_len), 5764 print_ssid(ssid, network->ssid,
5775 print_mac(mac, network->bssid), print_mac(mac, priv->bssid)); 5765 network->ssid_len),
5766 network->bssid, priv->bssid);
5776 return 0; 5767 return 0;
5777 } 5768 }
5778 5769
5779 /* Filter out any incompatible freq / mode combinations */ 5770 /* Filter out any incompatible freq / mode combinations */
5780 if (!ieee80211_is_valid_mode(priv->ieee, network->mode)) { 5771 if (!ieee80211_is_valid_mode(priv->ieee, network->mode)) {
5781 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5772 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5782 "because of invalid frequency/mode " 5773 "because of invalid frequency/mode "
5783 "combination.\n", 5774 "combination.\n",
5784 escape_essid(network->ssid, network->ssid_len), 5775 print_ssid(ssid, network->ssid,
5785 print_mac(mac, network->bssid)); 5776 network->ssid_len),
5777 network->bssid);
5786 return 0; 5778 return 0;
5787 } 5779 }
5788 5780
5789 /* Filter out invalid channel in current GEO */ 5781 /* Filter out invalid channel in current GEO */
5790 if (!ieee80211_is_valid_channel(priv->ieee, network->channel)) { 5782 if (!ieee80211_is_valid_channel(priv->ieee, network->channel)) {
5791 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5783 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5792 "because of invalid channel in current GEO\n", 5784 "because of invalid channel in current GEO\n",
5793 escape_essid(network->ssid, network->ssid_len), 5785 print_ssid(ssid, network->ssid,
5794 print_mac(mac, network->bssid)); 5786 network->ssid_len),
5787 network->bssid);
5795 return 0; 5788 return 0;
5796 } 5789 }
5797 5790
5798 /* Ensure that the rates supported by the driver are compatible with 5791 /* Ensure that the rates supported by the driver are compatible with
5799 * this AP, including verification of basic rates (mandatory) */ 5792 * this AP, including verification of basic rates (mandatory) */
5800 if (!ipw_compatible_rates(priv, network, &rates)) { 5793 if (!ipw_compatible_rates(priv, network, &rates)) {
5801 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5794 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5802 "because configured rate mask excludes " 5795 "because configured rate mask excludes "
5803 "AP mandatory rate.\n", 5796 "AP mandatory rate.\n",
5804 escape_essid(network->ssid, network->ssid_len), 5797 print_ssid(ssid, network->ssid,
5805 print_mac(mac, network->bssid)); 5798 network->ssid_len),
5799 network->bssid);
5806 return 0; 5800 return 0;
5807 } 5801 }
5808 5802
5809 if (rates.num_rates == 0) { 5803 if (rates.num_rates == 0) {
5810 IPW_DEBUG_ASSOC("Network '%s (%s)' excluded " 5804 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5811 "because of no compatible rates.\n", 5805 "because of no compatible rates.\n",
5812 escape_essid(network->ssid, network->ssid_len), 5806 print_ssid(ssid, network->ssid,
5813 print_mac(mac, network->bssid)); 5807 network->ssid_len),
5808 network->bssid);
5814 return 0; 5809 return 0;
5815 } 5810 }
5816 5811
@@ -5822,9 +5817,9 @@ static int ipw_best_network(struct ipw_priv *priv,
5822 ipw_copy_rates(&match->rates, &rates); 5817 ipw_copy_rates(&match->rates, &rates);
5823 match->network = network; 5818 match->network = network;
5824 5819
5825 IPW_DEBUG_ASSOC("Network '%s (%s)' is a viable match.\n", 5820 IPW_DEBUG_ASSOC("Network '%s (%pM)' is a viable match.\n",
5826 escape_essid(network->ssid, network->ssid_len), 5821 print_ssid(ssid, network->ssid, network->ssid_len),
5827 print_mac(mac, network->bssid)); 5822 network->bssid);
5828 5823
5829 return 1; 5824 return 1;
5830} 5825}
@@ -6066,7 +6061,7 @@ static void ipw_bg_adhoc_check(struct work_struct *work)
6066 6061
6067static void ipw_debug_config(struct ipw_priv *priv) 6062static void ipw_debug_config(struct ipw_priv *priv)
6068{ 6063{
6069 DECLARE_MAC_BUF(mac); 6064 DECLARE_SSID_BUF(ssid);
6070 IPW_DEBUG_INFO("Scan completed, no valid APs matched " 6065 IPW_DEBUG_INFO("Scan completed, no valid APs matched "
6071 "[CFG 0x%08X]\n", priv->config); 6066 "[CFG 0x%08X]\n", priv->config);
6072 if (priv->config & CFG_STATIC_CHANNEL) 6067 if (priv->config & CFG_STATIC_CHANNEL)
@@ -6075,12 +6070,11 @@ static void ipw_debug_config(struct ipw_priv *priv)
6075 IPW_DEBUG_INFO("Channel unlocked.\n"); 6070 IPW_DEBUG_INFO("Channel unlocked.\n");
6076 if (priv->config & CFG_STATIC_ESSID) 6071 if (priv->config & CFG_STATIC_ESSID)
6077 IPW_DEBUG_INFO("ESSID locked to '%s'\n", 6072 IPW_DEBUG_INFO("ESSID locked to '%s'\n",
6078 escape_essid(priv->essid, priv->essid_len)); 6073 print_ssid(ssid, priv->essid, priv->essid_len));
6079 else 6074 else
6080 IPW_DEBUG_INFO("ESSID unlocked.\n"); 6075 IPW_DEBUG_INFO("ESSID unlocked.\n");
6081 if (priv->config & CFG_STATIC_BSSID) 6076 if (priv->config & CFG_STATIC_BSSID)
6082 IPW_DEBUG_INFO("BSSID locked to %s\n", 6077 IPW_DEBUG_INFO("BSSID locked to %pM\n", priv->bssid);
6083 print_mac(mac, priv->bssid));
6084 else 6078 else
6085 IPW_DEBUG_INFO("BSSID unlocked.\n"); 6079 IPW_DEBUG_INFO("BSSID unlocked.\n");
6086 if (priv->capability & CAP_PRIVACY_ON) 6080 if (priv->capability & CAP_PRIVACY_ON)
@@ -6892,8 +6886,7 @@ static int ipw_qos_handle_probe_response(struct ipw_priv *priv,
6892 if ((priv->status & STATUS_ASSOCIATED) && 6886 if ((priv->status & STATUS_ASSOCIATED) &&
6893 (priv->ieee->iw_mode == IW_MODE_ADHOC) && (active_network == 0)) { 6887 (priv->ieee->iw_mode == IW_MODE_ADHOC) && (active_network == 0)) {
6894 if (memcmp(network->bssid, priv->bssid, ETH_ALEN)) 6888 if (memcmp(network->bssid, priv->bssid, ETH_ALEN))
6895 if ((network->capability & WLAN_CAPABILITY_IBSS) && 6889 if (network->capability & WLAN_CAPABILITY_IBSS)
6896 !(network->flags & NETWORK_EMPTY_ESSID))
6897 if ((network->ssid_len == 6890 if ((network->ssid_len ==
6898 priv->assoc_network->ssid_len) && 6891 priv->assoc_network->ssid_len) &&
6899 !memcmp(network->ssid, 6892 !memcmp(network->ssid,
@@ -7295,7 +7288,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
7295 struct ipw_supported_rates *rates, int roaming) 7288 struct ipw_supported_rates *rates, int roaming)
7296{ 7289{
7297 int err; 7290 int err;
7298 DECLARE_MAC_BUF(mac); 7291 DECLARE_SSID_BUF(ssid);
7299 7292
7300 if (priv->config & CFG_FIXED_RATE) 7293 if (priv->config & CFG_FIXED_RATE)
7301 ipw_set_fixed_rate(priv, network->mode); 7294 ipw_set_fixed_rate(priv, network->mode);
@@ -7364,7 +7357,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
7364 IPW_DEBUG_ASSOC("%sssocation attempt: '%s', channel %d, " 7357 IPW_DEBUG_ASSOC("%sssocation attempt: '%s', channel %d, "
7365 "802.11%c [%d], %s[:%s], enc=%s%s%s%c%c\n", 7358 "802.11%c [%d], %s[:%s], enc=%s%s%s%c%c\n",
7366 roaming ? "Rea" : "A", 7359 roaming ? "Rea" : "A",
7367 escape_essid(priv->essid, priv->essid_len), 7360 print_ssid(ssid, priv->essid, priv->essid_len),
7368 network->channel, 7361 network->channel,
7369 ipw_modes[priv->assoc_request.ieee_mode], 7362 ipw_modes[priv->assoc_request.ieee_mode],
7370 rates->num_rates, 7363 rates->num_rates,
@@ -7463,9 +7456,9 @@ static int ipw_associate_network(struct ipw_priv *priv,
7463 return err; 7456 return err;
7464 } 7457 }
7465 7458
7466 IPW_DEBUG(IPW_DL_STATE, "associating: '%s' %s \n", 7459 IPW_DEBUG(IPW_DL_STATE, "associating: '%s' %pM \n",
7467 escape_essid(priv->essid, priv->essid_len), 7460 print_ssid(ssid, priv->essid, priv->essid_len),
7468 print_mac(mac, priv->bssid)); 7461 priv->bssid);
7469 7462
7470 return 0; 7463 return 0;
7471} 7464}
@@ -7555,6 +7548,7 @@ static int ipw_associate(void *data)
7555 struct ipw_supported_rates *rates; 7548 struct ipw_supported_rates *rates;
7556 struct list_head *element; 7549 struct list_head *element;
7557 unsigned long flags; 7550 unsigned long flags;
7551 DECLARE_SSID_BUF(ssid);
7558 7552
7559 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { 7553 if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
7560 IPW_DEBUG_ASSOC("Not attempting association (monitor mode)\n"); 7554 IPW_DEBUG_ASSOC("Not attempting association (monitor mode)\n");
@@ -7604,7 +7598,6 @@ static int ipw_associate(void *data)
7604 if (list_empty(&priv->ieee->network_free_list)) { 7598 if (list_empty(&priv->ieee->network_free_list)) {
7605 struct ieee80211_network *oldest = NULL; 7599 struct ieee80211_network *oldest = NULL;
7606 struct ieee80211_network *target; 7600 struct ieee80211_network *target;
7607 DECLARE_MAC_BUF(mac);
7608 7601
7609 list_for_each_entry(target, &priv->ieee->network_list, list) { 7602 list_for_each_entry(target, &priv->ieee->network_list, list) {
7610 if ((oldest == NULL) || 7603 if ((oldest == NULL) ||
@@ -7615,11 +7608,11 @@ static int ipw_associate(void *data)
7615 /* If there are no more slots, expire the oldest */ 7608 /* If there are no more slots, expire the oldest */
7616 list_del(&oldest->list); 7609 list_del(&oldest->list);
7617 target = oldest; 7610 target = oldest;
7618 IPW_DEBUG_ASSOC("Expired '%s' (%s) from " 7611 IPW_DEBUG_ASSOC("Expired '%s' (%pM) from "
7619 "network list.\n", 7612 "network list.\n",
7620 escape_essid(target->ssid, 7613 print_ssid(ssid, target->ssid,
7621 target->ssid_len), 7614 target->ssid_len),
7622 print_mac(mac, target->bssid)); 7615 target->bssid);
7623 list_add_tail(&target->list, 7616 list_add_tail(&target->list,
7624 &priv->ieee->network_free_list); 7617 &priv->ieee->network_free_list);
7625 } 7618 }
@@ -7672,12 +7665,12 @@ static void ipw_rebuild_decrypted_skb(struct ipw_priv *priv,
7672 u16 fc; 7665 u16 fc;
7673 7666
7674 hdr = (struct ieee80211_hdr *)skb->data; 7667 hdr = (struct ieee80211_hdr *)skb->data;
7675 fc = le16_to_cpu(hdr->frame_ctl); 7668 fc = le16_to_cpu(hdr->frame_control);
7676 if (!(fc & IEEE80211_FCTL_PROTECTED)) 7669 if (!(fc & IEEE80211_FCTL_PROTECTED))
7677 return; 7670 return;
7678 7671
7679 fc &= ~IEEE80211_FCTL_PROTECTED; 7672 fc &= ~IEEE80211_FCTL_PROTECTED;
7680 hdr->frame_ctl = cpu_to_le16(fc); 7673 hdr->frame_control = cpu_to_le16(fc);
7681 switch (priv->ieee->sec.level) { 7674 switch (priv->ieee->sec.level) {
7682 case SEC_LEVEL_3: 7675 case SEC_LEVEL_3:
7683 /* Remove CCMP HDR */ 7676 /* Remove CCMP HDR */
@@ -7989,17 +7982,17 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
7989 } 7982 }
7990 7983
7991 hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE; 7984 hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE;
7992 if (ieee80211_is_management(le16_to_cpu(hdr->frame_ctl))) { 7985 if (ieee80211_is_management(le16_to_cpu(hdr->frame_control))) {
7993 if (filter & IPW_PROM_NO_MGMT) 7986 if (filter & IPW_PROM_NO_MGMT)
7994 return; 7987 return;
7995 if (filter & IPW_PROM_MGMT_HEADER_ONLY) 7988 if (filter & IPW_PROM_MGMT_HEADER_ONLY)
7996 hdr_only = 1; 7989 hdr_only = 1;
7997 } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_ctl))) { 7990 } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_control))) {
7998 if (filter & IPW_PROM_NO_CTL) 7991 if (filter & IPW_PROM_NO_CTL)
7999 return; 7992 return;
8000 if (filter & IPW_PROM_CTL_HEADER_ONLY) 7993 if (filter & IPW_PROM_CTL_HEADER_ONLY)
8001 hdr_only = 1; 7994 hdr_only = 1;
8002 } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_ctl))) { 7995 } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_control))) {
8003 if (filter & IPW_PROM_NO_DATA) 7996 if (filter & IPW_PROM_NO_DATA)
8004 return; 7997 return;
8005 if (filter & IPW_PROM_DATA_HEADER_ONLY) 7998 if (filter & IPW_PROM_DATA_HEADER_ONLY)
@@ -8017,7 +8010,7 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
8017 ipw_rt = (void *)skb->data; 8010 ipw_rt = (void *)skb->data;
8018 8011
8019 if (hdr_only) 8012 if (hdr_only)
8020 len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 8013 len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));
8021 8014
8022 memcpy(ipw_rt->payload, hdr, len); 8015 memcpy(ipw_rt->payload, hdr, len);
8023 8016
@@ -8237,7 +8230,7 @@ static int is_duplicate_packet(struct ipw_priv *priv,
8237 /* Comment this line now since we observed the card receives 8230 /* Comment this line now since we observed the card receives
8238 * duplicate packets but the FCTL_RETRY bit is not set in the 8231 * duplicate packets but the FCTL_RETRY bit is not set in the
8239 * IBSS mode with fragmentation enabled. 8232 * IBSS mode with fragmentation enabled.
8240 BUG_ON(!(le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_RETRY)); */ 8233 BUG_ON(!(le16_to_cpu(header->frame_control) & IEEE80211_FCTL_RETRY)); */
8241 return 1; 8234 return 1;
8242} 8235}
8243 8236
@@ -8301,9 +8294,6 @@ static void ipw_rx(struct ipw_priv *priv)
8301 u32 r, w, i; 8294 u32 r, w, i;
8302 u8 network_packet; 8295 u8 network_packet;
8303 u8 fill_rx = 0; 8296 u8 fill_rx = 0;
8304 DECLARE_MAC_BUF(mac);
8305 DECLARE_MAC_BUF(mac2);
8306 DECLARE_MAC_BUF(mac3);
8307 8297
8308 r = ipw_read32(priv, IPW_RX_READ_INDEX); 8298 r = ipw_read32(priv, IPW_RX_READ_INDEX);
8309 w = ipw_read32(priv, IPW_RX_WRITE_INDEX); 8299 w = ipw_read32(priv, IPW_RX_WRITE_INDEX);
@@ -8433,18 +8423,12 @@ static void ipw_rx(struct ipw_priv *priv)
8433 header))) 8423 header)))
8434 { 8424 {
8435 IPW_DEBUG_DROP("Dropping: " 8425 IPW_DEBUG_DROP("Dropping: "
8436 "%s, " 8426 "%pM, "
8437 "%s, " 8427 "%pM, "
8438 "%s\n", 8428 "%pM\n",
8439 print_mac(mac, 8429 header->addr1,
8440 header-> 8430 header->addr2,
8441 addr1), 8431 header->addr3);
8442 print_mac(mac2,
8443 header->
8444 addr2),
8445 print_mac(mac3,
8446 header->
8447 addr3));
8448 break; 8432 break;
8449 } 8433 }
8450 8434
@@ -8983,7 +8967,6 @@ static int ipw_wx_set_wap(struct net_device *dev,
8983 union iwreq_data *wrqu, char *extra) 8967 union iwreq_data *wrqu, char *extra)
8984{ 8968{
8985 struct ipw_priv *priv = ieee80211_priv(dev); 8969 struct ipw_priv *priv = ieee80211_priv(dev);
8986 DECLARE_MAC_BUF(mac);
8987 8970
8988 static const unsigned char any[] = { 8971 static const unsigned char any[] = {
8989 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 8972 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
@@ -9014,8 +8997,8 @@ static int ipw_wx_set_wap(struct net_device *dev,
9014 return 0; 8997 return 0;
9015 } 8998 }
9016 8999
9017 IPW_DEBUG_WX("Setting mandatory BSSID to %s\n", 9000 IPW_DEBUG_WX("Setting mandatory BSSID to %pM\n",
9018 print_mac(mac, wrqu->ap_addr.sa_data)); 9001 wrqu->ap_addr.sa_data);
9019 9002
9020 memcpy(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN); 9003 memcpy(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN);
9021 9004
@@ -9033,7 +9016,6 @@ static int ipw_wx_get_wap(struct net_device *dev,
9033 union iwreq_data *wrqu, char *extra) 9016 union iwreq_data *wrqu, char *extra)
9034{ 9017{
9035 struct ipw_priv *priv = ieee80211_priv(dev); 9018 struct ipw_priv *priv = ieee80211_priv(dev);
9036 DECLARE_MAC_BUF(mac);
9037 9019
9038 /* If we are associated, trying to associate, or have a statically 9020 /* If we are associated, trying to associate, or have a statically
9039 * configured BSSID then return that; otherwise return ANY */ 9021 * configured BSSID then return that; otherwise return ANY */
@@ -9045,8 +9027,8 @@ static int ipw_wx_get_wap(struct net_device *dev,
9045 } else 9027 } else
9046 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); 9028 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
9047 9029
9048 IPW_DEBUG_WX("Getting WAP BSSID: %s\n", 9030 IPW_DEBUG_WX("Getting WAP BSSID: %pM\n",
9049 print_mac(mac, wrqu->ap_addr.sa_data)); 9031 wrqu->ap_addr.sa_data);
9050 mutex_unlock(&priv->mutex); 9032 mutex_unlock(&priv->mutex);
9051 return 0; 9033 return 0;
9052} 9034}
@@ -9057,6 +9039,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
9057{ 9039{
9058 struct ipw_priv *priv = ieee80211_priv(dev); 9040 struct ipw_priv *priv = ieee80211_priv(dev);
9059 int length; 9041 int length;
9042 DECLARE_SSID_BUF(ssid);
9060 9043
9061 mutex_lock(&priv->mutex); 9044 mutex_lock(&priv->mutex);
9062 9045
@@ -9081,8 +9064,8 @@ static int ipw_wx_set_essid(struct net_device *dev,
9081 return 0; 9064 return 0;
9082 } 9065 }
9083 9066
9084 IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(extra, length), 9067 IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n",
9085 length); 9068 print_ssid(ssid, extra, length), length);
9086 9069
9087 priv->essid_len = length; 9070 priv->essid_len = length;
9088 memcpy(priv->essid, extra, priv->essid_len); 9071 memcpy(priv->essid, extra, priv->essid_len);
@@ -9101,6 +9084,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
9101 union iwreq_data *wrqu, char *extra) 9084 union iwreq_data *wrqu, char *extra)
9102{ 9085{
9103 struct ipw_priv *priv = ieee80211_priv(dev); 9086 struct ipw_priv *priv = ieee80211_priv(dev);
9087 DECLARE_SSID_BUF(ssid);
9104 9088
9105 /* If we are associated, trying to associate, or have a statically 9089 /* If we are associated, trying to associate, or have a statically
9106 * configured ESSID then return that; otherwise return ANY */ 9090 * configured ESSID then return that; otherwise return ANY */
@@ -9108,7 +9092,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
9108 if (priv->config & CFG_STATIC_ESSID || 9092 if (priv->config & CFG_STATIC_ESSID ||
9109 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { 9093 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
9110 IPW_DEBUG_WX("Getting essid: '%s'\n", 9094 IPW_DEBUG_WX("Getting essid: '%s'\n",
9111 escape_essid(priv->essid, priv->essid_len)); 9095 print_ssid(ssid, priv->essid, priv->essid_len));
9112 memcpy(extra, priv->essid, priv->essid_len); 9096 memcpy(extra, priv->essid, priv->essid_len);
9113 wrqu->essid.length = priv->essid_len; 9097 wrqu->essid.length = priv->essid_len;
9114 wrqu->essid.flags = 1; /* active */ 9098 wrqu->essid.flags = 1; /* active */
@@ -10199,10 +10183,8 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
10199 id = ipw_add_station(priv, hdr->addr1); 10183 id = ipw_add_station(priv, hdr->addr1);
10200 if (id == IPW_INVALID_STATION) { 10184 if (id == IPW_INVALID_STATION) {
10201 IPW_WARNING("Attempt to send data to " 10185 IPW_WARNING("Attempt to send data to "
10202 "invalid cell: " MAC_FMT "\n", 10186 "invalid cell: %pM\n",
10203 hdr->addr1[0], hdr->addr1[1], 10187 hdr->addr1);
10204 hdr->addr1[2], hdr->addr1[3],
10205 hdr->addr1[4], hdr->addr1[5]);
10206 goto drop; 10188 goto drop;
10207 } 10189 }
10208 } 10190 }
@@ -10399,17 +10381,17 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10399 10381
10400 /* Filtering of fragment chains is done agains the first fragment */ 10382 /* Filtering of fragment chains is done agains the first fragment */
10401 hdr = (void *)txb->fragments[0]->data; 10383 hdr = (void *)txb->fragments[0]->data;
10402 if (ieee80211_is_management(le16_to_cpu(hdr->frame_ctl))) { 10384 if (ieee80211_is_management(le16_to_cpu(hdr->frame_control))) {
10403 if (filter & IPW_PROM_NO_MGMT) 10385 if (filter & IPW_PROM_NO_MGMT)
10404 return; 10386 return;
10405 if (filter & IPW_PROM_MGMT_HEADER_ONLY) 10387 if (filter & IPW_PROM_MGMT_HEADER_ONLY)
10406 hdr_only = 1; 10388 hdr_only = 1;
10407 } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_ctl))) { 10389 } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_control))) {
10408 if (filter & IPW_PROM_NO_CTL) 10390 if (filter & IPW_PROM_NO_CTL)
10409 return; 10391 return;
10410 if (filter & IPW_PROM_CTL_HEADER_ONLY) 10392 if (filter & IPW_PROM_CTL_HEADER_ONLY)
10411 hdr_only = 1; 10393 hdr_only = 1;
10412 } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_ctl))) { 10394 } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_control))) {
10413 if (filter & IPW_PROM_NO_DATA) 10395 if (filter & IPW_PROM_NO_DATA)
10414 return; 10396 return;
10415 if (filter & IPW_PROM_DATA_HEADER_ONLY) 10397 if (filter & IPW_PROM_DATA_HEADER_ONLY)
@@ -10424,7 +10406,7 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10424 10406
10425 if (hdr_only) { 10407 if (hdr_only) {
10426 hdr = (void *)src->data; 10408 hdr = (void *)src->data;
10427 len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 10409 len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));
10428 } else 10410 } else
10429 len = src->len; 10411 len = src->len;
10430 10412
@@ -10505,15 +10487,14 @@ static int ipw_net_set_mac_address(struct net_device *dev, void *p)
10505{ 10487{
10506 struct ipw_priv *priv = ieee80211_priv(dev); 10488 struct ipw_priv *priv = ieee80211_priv(dev);
10507 struct sockaddr *addr = p; 10489 struct sockaddr *addr = p;
10508 DECLARE_MAC_BUF(mac);
10509 10490
10510 if (!is_valid_ether_addr(addr->sa_data)) 10491 if (!is_valid_ether_addr(addr->sa_data))
10511 return -EADDRNOTAVAIL; 10492 return -EADDRNOTAVAIL;
10512 mutex_lock(&priv->mutex); 10493 mutex_lock(&priv->mutex);
10513 priv->config |= CFG_CUSTOM_MAC; 10494 priv->config |= CFG_CUSTOM_MAC;
10514 memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); 10495 memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN);
10515 printk(KERN_INFO "%s: Setting MAC to %s\n", 10496 printk(KERN_INFO "%s: Setting MAC to %pM\n",
10516 priv->net_dev->name, print_mac(mac, priv->mac_addr)); 10497 priv->net_dev->name, priv->mac_addr);
10517 queue_work(priv->workqueue, &priv->adapter_restart); 10498 queue_work(priv->workqueue, &priv->adapter_restart);
10518 mutex_unlock(&priv->mutex); 10499 mutex_unlock(&priv->mutex);
10519 return 0; 10500 return 0;
@@ -11648,7 +11629,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev,
11648 length = pci_resource_len(pdev, 0); 11629 length = pci_resource_len(pdev, 0);
11649 priv->hw_len = length; 11630 priv->hw_len = length;
11650 11631
11651 base = ioremap_nocache(pci_resource_start(pdev, 0), length); 11632 base = pci_ioremap_bar(pdev, 0);
11652 if (!base) { 11633 if (!base) {
11653 err = -ENODEV; 11634 err = -ENODEV;
11654 goto out_pci_release_regions; 11635 goto out_pci_release_regions;
@@ -11940,7 +11921,7 @@ module_param(disable, int, 0444);
11940MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])"); 11921MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
11941 11922
11942module_param(associate, int, 0444); 11923module_param(associate, int, 0444);
11943MODULE_PARM_DESC(associate, "auto associate when scanning (default on)"); 11924MODULE_PARM_DESC(associate, "auto associate when scanning (default off)");
11944 11925
11945module_param(auto_create, int, 0444); 11926module_param(auto_create, int, 0444);
11946MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)"); 11927MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)");
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index 0bad1ec3e7e0..0a84d52147bd 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -48,6 +48,7 @@
48#include <linux/jiffies.h> 48#include <linux/jiffies.h>
49#include <asm/io.h> 49#include <asm/io.h>
50 50
51#include <net/lib80211.h>
51#include <net/ieee80211.h> 52#include <net/ieee80211.h>
52#include <net/ieee80211_radiotap.h> 53#include <net/ieee80211_radiotap.h>
53 54
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index b0ac0ce3fb9f..47bee0ee0a7c 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -4,6 +4,7 @@ config IWLWIFI
4config IWLCORE 4config IWLCORE
5 tristate "Intel Wireless Wifi Core" 5 tristate "Intel Wireless Wifi Core"
6 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL 6 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
7 select LIB80211
7 select IWLWIFI 8 select IWLWIFI
8 select MAC80211_LEDS if IWLWIFI_LEDS 9 select MAC80211_LEDS if IWLWIFI_LEDS
9 select LEDS_CLASS if IWLWIFI_LEDS 10 select LEDS_CLASS if IWLWIFI_LEDS
@@ -105,6 +106,7 @@ config IWL3945
105 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" 106 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection"
106 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL 107 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
107 select FW_LOADER 108 select FW_LOADER
109 select LIB80211
108 select IWLWIFI 110 select IWLWIFI
109 select MAC80211_LEDS if IWL3945_LEDS 111 select MAC80211_LEDS if IWL3945_LEDS
110 select LEDS_CLASS if IWL3945_LEDS 112 select LEDS_CLASS if IWL3945_LEDS
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
index 817ece773643..8772d9d7d6e7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
@@ -121,7 +121,7 @@ enum {
121 REPLY_TX_PWR_TABLE_CMD = 0x97, 121 REPLY_TX_PWR_TABLE_CMD = 0x97,
122 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */ 122 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
123 123
124 /* Bluetooth device coexistance config command */ 124 /* Bluetooth device coexistence config command */
125 REPLY_BT_CONFIG = 0x9b, 125 REPLY_BT_CONFIG = 0x9b,
126 126
127 /* Statistics */ 127 /* Statistics */
@@ -158,7 +158,7 @@ struct iwl3945_cmd_header {
158 u8 cmd; /* Command ID: REPLY_RXON, etc. */ 158 u8 cmd; /* Command ID: REPLY_RXON, etc. */
159 u8 flags; /* IWL_CMD_* */ 159 u8 flags; /* IWL_CMD_* */
160 /* 160 /*
161 * The driver sets up the sequence number to values of its chosing. 161 * The driver sets up the sequence number to values of its choosing.
162 * uCode does not use this value, but passes it back to the driver 162 * uCode does not use this value, but passes it back to the driver
163 * when sending the response to each driver-originated command, so 163 * when sending the response to each driver-originated command, so
164 * the driver can match the response to the command. Since the values 164 * the driver can match the response to the command. Since the values
@@ -991,7 +991,7 @@ struct iwl3945_rate_scaling_cmd {
991 * 991 *
992 * 3945 and 4965 support hardware handshake with Bluetooth device on 992 * 3945 and 4965 support hardware handshake with Bluetooth device on
993 * same platform. Bluetooth device alerts wireless device when it will Tx; 993 * same platform. Bluetooth device alerts wireless device when it will Tx;
994 * wireless device can delay or kill its own Tx to accomodate. 994 * wireless device can delay or kill its own Tx to accommodate.
995 */ 995 */
996struct iwl3945_bt_cmd { 996struct iwl3945_bt_cmd {
997 u8 flags; 997 u8 flags;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-io.h b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
index b3fe48de3ae7..1daa3f05a775 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
@@ -53,7 +53,7 @@
53 * _iwl3945_read32.) 53 * _iwl3945_read32.)
54 * 54 *
55 * These declarations are *extremely* useful in quickly isolating code deltas 55 * These declarations are *extremely* useful in quickly isolating code deltas
56 * which result in misconfiguring of the hardware I/O. In combination with 56 * which result in misconfiguration of the hardware I/O. In combination with
57 * git-bisect and the IO debug level you can quickly determine the specific 57 * git-bisect and the IO debug level you can quickly determine the specific
58 * commit which breaks the IO sequence to the hardware. 58 * commit which breaks the IO sequence to the hardware.
59 * 59 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 6fc5e7361f26..bfeef701b1fd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -355,12 +355,6 @@ static void rs_free(void *priv)
355 return; 355 return;
356} 356}
357 357
358static void rs_clear(void *priv)
359{
360 return;
361}
362
363
364static void *rs_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) 358static void *rs_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
365{ 359{
366 struct iwl3945_rs_sta *rs_sta; 360 struct iwl3945_rs_sta *rs_sta;
@@ -422,34 +416,6 @@ static void rs_free_sta(void *priv, struct ieee80211_sta *sta,
422} 416}
423 417
424 418
425/*
426 * get ieee prev rate from rate scale table.
427 * for A and B mode we need to overright prev
428 * value
429 */
430static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate)
431{
432 int next_rate = iwl3945_get_prev_ieee_rate(rate);
433
434 switch (priv->band) {
435 case IEEE80211_BAND_5GHZ:
436 if (rate == IWL_RATE_12M_INDEX)
437 next_rate = IWL_RATE_9M_INDEX;
438 else if (rate == IWL_RATE_6M_INDEX)
439 next_rate = IWL_RATE_6M_INDEX;
440 break;
441/* XXX cannot be invoked in current mac80211 so not a regression
442 case MODE_IEEE80211B:
443 if (rate == IWL_RATE_11M_INDEX_TABLE)
444 next_rate = IWL_RATE_5M_INDEX_TABLE;
445 break;
446 */
447 default:
448 break;
449 }
450
451 return next_rate;
452}
453/** 419/**
454 * rs_tx_status - Update rate control values based on Tx results 420 * rs_tx_status - Update rate control values based on Tx results
455 * 421 *
@@ -460,17 +426,21 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
460 struct ieee80211_sta *sta, void *priv_sta, 426 struct ieee80211_sta *sta, void *priv_sta,
461 struct sk_buff *skb) 427 struct sk_buff *skb)
462{ 428{
463 u8 retries, current_count; 429 u8 retries = 0, current_count;
464 int scale_rate_index, first_index, last_index; 430 int scale_rate_index, first_index, last_index;
465 unsigned long flags; 431 unsigned long flags;
466 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; 432 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate;
467 struct iwl3945_rs_sta *rs_sta = priv_sta; 433 struct iwl3945_rs_sta *rs_sta = priv_sta;
468 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 434 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
435 int i;
469 436
470 IWL_DEBUG_RATE("enter\n"); 437 IWL_DEBUG_RATE("enter\n");
471 438
472 retries = info->status.retry_count; 439 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
473 first_index = sband->bitrates[info->tx_rate_idx].hw_value; 440 retries += info->status.rates[i].count;
441 retries--;
442
443 first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
474 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { 444 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) {
475 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); 445 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index);
476 return; 446 return;
@@ -502,7 +472,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
502 last_index = scale_rate_index; 472 last_index = scale_rate_index;
503 } else { 473 } else {
504 current_count = priv->retry_rate; 474 current_count = priv->retry_rate;
505 last_index = rs_adjust_next_rate(priv, 475 last_index = iwl3945_rs_next_rate(priv,
506 scale_rate_index); 476 scale_rate_index);
507 } 477 }
508 478
@@ -518,7 +488,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
518 488
519 if (retries) 489 if (retries)
520 scale_rate_index = 490 scale_rate_index =
521 rs_adjust_next_rate(priv, scale_rate_index); 491 iwl3945_rs_next_rate(priv, scale_rate_index);
522 } 492 }
523 493
524 494
@@ -630,10 +600,11 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
630 * rate table and must reference the driver allocated rate table 600 * rate table and must reference the driver allocated rate table
631 * 601 *
632 */ 602 */
633static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband, 603static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
634 struct ieee80211_sta *sta, void *priv_sta, 604 void *priv_sta, struct ieee80211_tx_rate_control *txrc)
635 struct sk_buff *skb, struct rate_selection *sel)
636{ 605{
606 struct ieee80211_supported_band *sband = txrc->sband;
607 struct sk_buff *skb = txrc->skb;
637 u8 low = IWL_RATE_INVALID; 608 u8 low = IWL_RATE_INVALID;
638 u8 high = IWL_RATE_INVALID; 609 u8 high = IWL_RATE_INVALID;
639 u16 high_low; 610 u16 high_low;
@@ -649,7 +620,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
649 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 620 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
650 u16 fc, rate_mask; 621 u16 fc, rate_mask;
651 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r; 622 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r;
652 DECLARE_MAC_BUF(mac); 623 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
653 624
654 IWL_DEBUG_RATE("enter\n"); 625 IWL_DEBUG_RATE("enter\n");
655 626
@@ -660,7 +631,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
660 is_multicast_ether_addr(hdr->addr1) || 631 is_multicast_ether_addr(hdr->addr1) ||
661 !sta || !priv_sta) { 632 !sta || !priv_sta) {
662 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 633 IWL_DEBUG_RATE("leave: No STA priv data to update!\n");
663 sel->rate_idx = rate_lowest_index(sband, sta); 634 info->control.rates[0].idx = rate_lowest_index(sband, sta);
664 return; 635 return;
665 } 636 }
666 637
@@ -675,8 +646,8 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
675 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1); 646 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
676 647
677 if (sta_id == IWL_INVALID_STATION) { 648 if (sta_id == IWL_INVALID_STATION) {
678 IWL_DEBUG_RATE("LQ: ADD station %s\n", 649 IWL_DEBUG_RATE("LQ: ADD station %pm\n",
679 print_mac(mac, hdr->addr1)); 650 hdr->addr1);
680 sta_id = iwl3945_add_station(priv, 651 sta_id = iwl3945_add_station(priv,
681 hdr->addr1, 0, CMD_ASYNC); 652 hdr->addr1, 0, CMD_ASYNC);
682 } 653 }
@@ -793,9 +764,10 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
793 764
794 rs_sta->last_txrate_idx = index; 765 rs_sta->last_txrate_idx = index;
795 if (sband->band == IEEE80211_BAND_5GHZ) 766 if (sband->band == IEEE80211_BAND_5GHZ)
796 sel->rate_idx = rs_sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; 767 info->control.rates[0].idx = rs_sta->last_txrate_idx -
768 IWL_FIRST_OFDM_RATE;
797 else 769 else
798 sel->rate_idx = rs_sta->last_txrate_idx; 770 info->control.rates[0].idx = rs_sta->last_txrate_idx;
799 771
800 IWL_DEBUG_RATE("leave: %d\n", index); 772 IWL_DEBUG_RATE("leave: %d\n", index);
801} 773}
@@ -806,7 +778,6 @@ static struct rate_control_ops rs_ops = {
806 .tx_status = rs_tx_status, 778 .tx_status = rs_tx_status,
807 .get_rate = rs_get_rate, 779 .get_rate = rs_get_rate,
808 .rate_init = rs_rate_init, 780 .rate_init = rs_rate_init,
809 .clear = rs_clear,
810 .alloc = rs_alloc, 781 .alloc = rs_alloc,
811 .free = rs_free, 782 .free = rs_free,
812 .alloc_sta = rs_alloc_sta, 783 .alloc_sta = rs_alloc_sta,
@@ -827,13 +798,12 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
827 rcu_read_lock(); 798 rcu_read_lock();
828 799
829 sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr); 800 sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr);
830 psta = (void *) sta->drv_priv; 801 if (!sta) {
831 if (!sta || !psta) {
832 IWL_DEBUG_RATE("leave - no private rate data!\n");
833 rcu_read_unlock(); 802 rcu_read_unlock();
834 return; 803 return;
835 } 804 }
836 805
806 psta = (void *) sta->drv_priv;
837 rs_sta = psta->rs_sta; 807 rs_sta = psta->rs_sta;
838 808
839 spin_lock_irqsave(&rs_sta->lock, flags); 809 spin_lock_irqsave(&rs_sta->lock, flags);
@@ -857,7 +827,6 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
857 break; 827 break;
858 } 828 }
859 829
860 rcu_read_unlock();
861 spin_unlock_irqrestore(&rs_sta->lock, flags); 830 spin_unlock_irqrestore(&rs_sta->lock, flags);
862 831
863 rssi = priv->last_rx_rssi; 832 rssi = priv->last_rx_rssi;
@@ -871,6 +840,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
871 IWL_DEBUG_RATE("leave: rssi %d assign rate index: " 840 IWL_DEBUG_RATE("leave: rssi %d assign rate index: "
872 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, 841 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate,
873 iwl3945_rates[rs_sta->start_rate].plcp); 842 iwl3945_rates[rs_sta->start_rate].plcp);
843 rcu_read_unlock();
874} 844}
875 845
876int iwl3945_rate_control_register(void) 846int iwl3945_rate_control_register(void)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 7ca5627cc078..af77ea70d737 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -200,7 +200,7 @@ static int iwl3945_hwrate_to_plcp_idx(u8 plcp)
200 * priv->eeprom is used to determine if antenna AUX/MAIN are reversed 200 * priv->eeprom is used to determine if antenna AUX/MAIN are reversed
201 * priv->antenna specifies the antenna diversity mode: 201 * priv->antenna specifies the antenna diversity mode:
202 * 202 *
203 * IWL_ANTENNA_DIVERISTY - NIC selects best antenna by itself 203 * IWL_ANTENNA_DIVERSITY - NIC selects best antenna by itself
204 * IWL_ANTENNA_MAIN - Force MAIN antenna 204 * IWL_ANTENNA_MAIN - Force MAIN antenna
205 * IWL_ANTENNA_AUX - Force AUX antenna 205 * IWL_ANTENNA_AUX - Force AUX antenna
206 */ 206 */
@@ -261,6 +261,35 @@ static inline const char *iwl3945_get_tx_fail_reason(u32 status)
261} 261}
262#endif 262#endif
263 263
264/*
265 * get ieee prev rate from rate scale table.
266 * for A and B mode we need to overright prev
267 * value
268 */
269int iwl3945_rs_next_rate(struct iwl3945_priv *priv, int rate)
270{
271 int next_rate = iwl3945_get_prev_ieee_rate(rate);
272
273 switch (priv->band) {
274 case IEEE80211_BAND_5GHZ:
275 if (rate == IWL_RATE_12M_INDEX)
276 next_rate = IWL_RATE_9M_INDEX;
277 else if (rate == IWL_RATE_6M_INDEX)
278 next_rate = IWL_RATE_6M_INDEX;
279 break;
280/* XXX cannot be invoked in current mac80211 so not a regression
281 case MODE_IEEE80211B:
282 if (rate == IWL_RATE_11M_INDEX_TABLE)
283 next_rate = IWL_RATE_5M_INDEX_TABLE;
284 break;
285 */
286 default:
287 break;
288 }
289
290 return next_rate;
291}
292
264 293
265/** 294/**
266 * iwl3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd 295 * iwl3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd
@@ -308,6 +337,7 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
308 struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 337 struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
309 u32 status = le32_to_cpu(tx_resp->status); 338 u32 status = le32_to_cpu(tx_resp->status);
310 int rate_idx; 339 int rate_idx;
340 int fail, i;
311 341
312 if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) { 342 if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) {
313 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " 343 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
@@ -318,9 +348,36 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
318 } 348 }
319 349
320 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); 350 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
321 memset(&info->status, 0, sizeof(info->status)); 351 ieee80211_tx_info_clear_status(info);
352
353 /* Fill the MRR chain with some info about on-chip retransmissions */
354 rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate);
355 if (info->band == IEEE80211_BAND_5GHZ)
356 rate_idx -= IWL_FIRST_OFDM_RATE;
357
358 fail = tx_resp->failure_frame;
359 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
360 int next = iwl3945_rs_next_rate(priv, rate_idx);
361
362 info->status.rates[i].idx = rate_idx;
363
364 /*
365 * Put remaining into the last count as best approximation
366 * of saying exactly what the hardware would have done...
367 */
368 if ((rate_idx == next) || (i == IEEE80211_TX_MAX_RATES - 1)) {
369 info->status.rates[i].count = fail;
370 break;
371 }
372
373 info->status.rates[i].count = priv->retry_rate;
374 fail -= priv->retry_rate;
375 rate_idx = next;
376 if (fail <= 0)
377 break;
378 }
379 info->status.rates[i].count++; /* add final attempt */
322 380
323 info->status.retry_count = tx_resp->failure_frame;
324 /* tx_status->rts_retry_count = tx_resp->failure_rts; */ 381 /* tx_status->rts_retry_count = tx_resp->failure_rts; */
325 info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? 382 info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ?
326 IEEE80211_TX_STAT_ACK : 0; 383 IEEE80211_TX_STAT_ACK : 0;
@@ -329,10 +386,6 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
329 txq_id, iwl3945_get_tx_fail_reason(status), status, 386 txq_id, iwl3945_get_tx_fail_reason(status), status,
330 tx_resp->rate, tx_resp->failure_frame); 387 tx_resp->rate, tx_resp->failure_frame);
331 388
332 rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate);
333 if (info->band == IEEE80211_BAND_5GHZ)
334 rate_idx -= IWL_FIRST_OFDM_RATE;
335 info->tx_rate_idx = rate_idx;
336 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 389 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
337 iwl3945_tx_queue_reclaim(priv, txq_id, index); 390 iwl3945_tx_queue_reclaim(priv, txq_id, index);
338 391
@@ -759,7 +812,6 @@ u8 iwl3945_hw_find_station(struct iwl3945_priv *priv, const u8 *addr)
759 int i; 812 int i;
760 int ret = IWL_INVALID_STATION; 813 int ret = IWL_INVALID_STATION;
761 unsigned long flags; 814 unsigned long flags;
762 DECLARE_MAC_BUF(mac);
763 815
764 spin_lock_irqsave(&priv->sta_lock, flags); 816 spin_lock_irqsave(&priv->sta_lock, flags);
765 for (i = IWL_STA_ID; i < priv->hw_setting.max_stations; i++) 817 for (i = IWL_STA_ID; i < priv->hw_setting.max_stations; i++)
@@ -770,8 +822,8 @@ u8 iwl3945_hw_find_station(struct iwl3945_priv *priv, const u8 *addr)
770 goto out; 822 goto out;
771 } 823 }
772 824
773 IWL_DEBUG_INFO("can not find STA %s (total %d)\n", 825 IWL_DEBUG_INFO("can not find STA %pM (total %d)\n",
774 print_mac(mac, addr), priv->num_stations); 826 addr, priv->num_stations);
775 out: 827 out:
776 spin_unlock_irqrestore(&priv->sta_lock, flags); 828 spin_unlock_irqrestore(&priv->sta_lock, flags);
777 return ret; 829 return ret;
@@ -1830,7 +1882,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl3945_priv *priv)
1830 ref_temp = (s16)priv->eeprom.groups[ch_info->group_index]. 1882 ref_temp = (s16)priv->eeprom.groups[ch_info->group_index].
1831 temperature; 1883 temperature;
1832 1884
1833 /* get power index adjustment based on curr and factory 1885 /* get power index adjustment based on current and factory
1834 * temps */ 1886 * temps */
1835 delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature, 1887 delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature,
1836 ref_temp); 1888 ref_temp);
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index bdd32475b99c..7187925bd0d5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -828,8 +828,6 @@ struct iwl3945_priv {
828 unsigned long last_statistics_time; 828 unsigned long last_statistics_time;
829 829
830 /* context information */ 830 /* context information */
831 u8 essid[IW_ESSID_MAX_SIZE];
832 u8 essid_len;
833 u16 rates_mask; 831 u16 rates_mask;
834 832
835 u32 power_mode; 833 u32 power_mode;
@@ -954,6 +952,8 @@ static inline int is_channel_ibss(const struct iwl3945_channel_info *ch)
954extern const struct iwl3945_channel_info *iwl3945_get_channel_info( 952extern const struct iwl3945_channel_info *iwl3945_get_channel_info(
955 const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel); 953 const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel);
956 954
955extern int iwl3945_rs_next_rate(struct iwl3945_priv *priv, int rate);
956
957/* Requires full declaration of iwl3945_priv before including */ 957/* Requires full declaration of iwl3945_priv before including */
958#include "iwl-3945-io.h" 958#include "iwl-3945-io.h"
959 959
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
index f4793a609443..9da7c7bea752 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
@@ -71,7 +71,7 @@
71 71
72#include "iwl-fh.h" 72#include "iwl-fh.h"
73 73
74/* EERPROM */ 74/* EEPROM */
75#define IWL4965_EEPROM_IMG_SIZE 1024 75#define IWL4965_EEPROM_IMG_SIZE 1024
76 76
77/* 77/*
@@ -111,7 +111,6 @@
111#define PCI_CFG_CMD_REG_INT_DIS_MSK 0x04 111#define PCI_CFG_CMD_REG_INT_DIS_MSK 0x04
112#define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) 112#define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
113 113
114#define TFD_QUEUE_SIZE_MAX (256)
115 114
116#define IWL_NUM_SCAN_RATES (2) 115#define IWL_NUM_SCAN_RATES (2)
117 116
@@ -287,13 +286,13 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr)
287 * that target txpower. 286 * that target txpower.
288 * 287 *
289 * 288 *
290 * 3) Determine (EEPROM) calibration subband for the target channel, by 289 * 3) Determine (EEPROM) calibration sub band for the target channel, by
291 * comparing against first and last channels in each subband 290 * comparing against first and last channels in each sub band
292 * (see struct iwl4965_eeprom_calib_subband_info). 291 * (see struct iwl4965_eeprom_calib_subband_info).
293 * 292 *
294 * 293 *
295 * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, 294 * 4) Linearly interpolate (EEPROM) factory calibration measurement sets,
296 * referencing the 2 factory-measured (sample) channels within the subband. 295 * referencing the 2 factory-measured (sample) channels within the sub band.
297 * 296 *
298 * Interpolation is based on difference between target channel's frequency 297 * Interpolation is based on difference between target channel's frequency
299 * and the sample channels' frequencies. Since channel numbers are based 298 * and the sample channels' frequencies. Since channel numbers are based
@@ -301,7 +300,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr)
301 * to interpolating based on channel number differences. 300 * to interpolating based on channel number differences.
302 * 301 *
303 * Note that the sample channels may or may not be the channels at the 302 * Note that the sample channels may or may not be the channels at the
304 * edges of the subband. The target channel may be "outside" of the 303 * edges of the sub band. The target channel may be "outside" of the
305 * span of the sampled channels. 304 * span of the sampled channels.
306 * 305 *
307 * Driver may choose the pair (for 2 Tx chains) of measurements (see 306 * Driver may choose the pair (for 2 Tx chains) of measurements (see
@@ -345,7 +344,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr)
345 * "4965 temperature calculation". 344 * "4965 temperature calculation".
346 * 345 *
347 * If current temperature is higher than factory temperature, driver must 346 * If current temperature is higher than factory temperature, driver must
348 * increase gain (lower gain table index), and vice versa. 347 * increase gain (lower gain table index), and vice verse.
349 * 348 *
350 * Temperature affects gain differently for different channels: 349 * Temperature affects gain differently for different channels:
351 * 350 *
@@ -815,125 +814,72 @@ enum {
815 * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array 814 * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array
816 * in DRAM containing 256 Transmit Frame Descriptors (TFDs). 815 * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
817 */ 816 */
818#define IWL49_MAX_WIN_SIZE 64
819#define IWL49_QUEUE_SIZE 256
820#define IWL49_NUM_FIFOS 7 817#define IWL49_NUM_FIFOS 7
821#define IWL49_CMD_FIFO_NUM 4 818#define IWL49_CMD_FIFO_NUM 4
822#define IWL49_NUM_QUEUES 16 819#define IWL49_NUM_QUEUES 16
823#define IWL49_NUM_AMPDU_QUEUES 8 820#define IWL49_NUM_AMPDU_QUEUES 8
824 821
822#define IWL_TX_DMA_MASK (DMA_BIT_MASK(36) & ~0x3)
823#define IWL_NUM_OF_TBS 20
824
825static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr)
826{
827 return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF;
828}
825/** 829/**
826 * struct iwl_tfd_frame_data 830 * struct iwl_tfd_tb transmit buffer descriptor within transmit frame descriptor
827 *
828 * Describes up to 2 buffers containing (contiguous) portions of a Tx frame.
829 * Each buffer must be on dword boundary.
830 * Up to 10 iwl_tfd_frame_data structures, describing up to 20 buffers,
831 * may be filled within a TFD (iwl_tfd_frame).
832 *
833 * Bit fields in tb1_addr:
834 * 31- 0: Tx buffer 1 address bits [31:0]
835 * 831 *
836 * Bit fields in val1: 832 * This structure contains dma address and length of transmission address
837 * 31-16: Tx buffer 2 address bits [15:0]
838 * 15- 4: Tx buffer 1 length (bytes)
839 * 3- 0: Tx buffer 1 address bits [32:32]
840 * 833 *
841 * Bit fields in val2: 834 * @lo: low [31:0] portion of the dma address of TX buffer
842 * 31-20: Tx buffer 2 length (bytes) 835 * every even is unaligned on 16 bit boundary
843 * 19- 0: Tx buffer 2 address bits [35:16] 836 * @hi_n_len 0-3 [35:32] portion of dma
837 * 4-16 length of the tx buffer
844 */ 838 */
845struct iwl_tfd_frame_data { 839struct iwl_tfd_tb {
846 __le32 tb1_addr; 840 __le32 lo;
847 841 __le16 hi_n_len;
848 __le32 val1; 842} __attribute__((packed));
849 /* __le32 ptb1_32_35:4; */
850#define IWL_tb1_addr_hi_POS 0
851#define IWL_tb1_addr_hi_LEN 4
852#define IWL_tb1_addr_hi_SYM val1
853 /* __le32 tb_len1:12; */
854#define IWL_tb1_len_POS 4
855#define IWL_tb1_len_LEN 12
856#define IWL_tb1_len_SYM val1
857 /* __le32 ptb2_0_15:16; */
858#define IWL_tb2_addr_lo16_POS 16
859#define IWL_tb2_addr_lo16_LEN 16
860#define IWL_tb2_addr_lo16_SYM val1
861
862 __le32 val2;
863 /* __le32 ptb2_16_35:20; */
864#define IWL_tb2_addr_hi20_POS 0
865#define IWL_tb2_addr_hi20_LEN 20
866#define IWL_tb2_addr_hi20_SYM val2
867 /* __le32 tb_len2:12; */
868#define IWL_tb2_len_POS 20
869#define IWL_tb2_len_LEN 12
870#define IWL_tb2_len_SYM val2
871} __attribute__ ((packed));
872
873 843
874/** 844/**
875 * struct iwl_tfd_frame 845 * struct iwl_tfd
876 * 846 *
877 * Transmit Frame Descriptor (TFD) 847 * Transmit Frame Descriptor (TFD)
878 * 848 *
879 * 4965 supports up to 16 Tx queues resident in host DRAM. 849 * @ __reserved1[3] reserved
850 * @ num_tbs 0-5 number of active tbs
851 * 6-7 padding (not used)
852 * @ tbs[20] transmit frame buffer descriptors
853 * @ __pad padding
854 *
880 * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. 855 * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
881 * Both driver and device share these circular buffers, each of which must be 856 * Both driver and device share these circular buffers, each of which must be
882 * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes for 4965. 857 * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes
883 * 858 *
884 * Driver must indicate the physical address of the base of each 859 * Driver must indicate the physical address of the base of each
885 * circular buffer via the 4965's FH_MEM_CBBC_QUEUE registers. 860 * circular buffer via the FH_MEM_CBBC_QUEUE registers.
886 * 861 *
887 * Each TFD contains pointer/size information for up to 20 data buffers 862 * Each TFD contains pointer/size information for up to 20 data buffers
888 * in host DRAM. These buffers collectively contain the (one) frame described 863 * in host DRAM. These buffers collectively contain the (one) frame described
889 * by the TFD. Each buffer must be a single contiguous block of memory within 864 * by the TFD. Each buffer must be a single contiguous block of memory within
890 * itself, but buffers may be scattered in host DRAM. Each buffer has max size 865 * itself, but buffers may be scattered in host DRAM. Each buffer has max size
891 * of (4K - 4). The 4965 concatenates all of a TFD's buffers into a single 866 * of (4K - 4). The concatenates all of a TFD's buffers into a single
892 * Tx frame, up to 8 KBytes in size. 867 * Tx frame, up to 8 KBytes in size.
893 * 868 *
894 * Bit fields in the control dword (val0):
895 * 31-30: # dwords (0-3) of padding required at end of frame for 16-byte bound
896 * 29: reserved
897 * 28-24: # Transmit Buffer Descriptors in TFD
898 * 23- 0: reserved
899 *
900 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. 869 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
901 */
902struct iwl_tfd_frame {
903 __le32 val0;
904 /* __le32 rsvd1:24; */
905 /* __le32 num_tbs:5; */
906#define IWL_num_tbs_POS 24
907#define IWL_num_tbs_LEN 5
908#define IWL_num_tbs_SYM val0
909 /* __le32 rsvd2:1; */
910 /* __le32 padding:2; */
911 struct iwl_tfd_frame_data pa[10];
912 __le32 reserved;
913} __attribute__ ((packed));
914
915
916/**
917 * struct iwl4965_queue_byte_cnt_entry
918 * 870 *
919 * Byte Count Table Entry 871 * Bit fields in the control dword (val0):
920 *
921 * Bit fields:
922 * 15-12: reserved
923 * 11- 0: total to-be-transmitted byte count of frame (does not include command)
924 */ 872 */
925struct iwl4965_queue_byte_cnt_entry { 873struct iwl_tfd {
926 __le16 val; 874 u8 __reserved1[3];
927 /* __le16 byte_cnt:12; */ 875 u8 num_tbs;
928#define IWL_byte_cnt_POS 0 876 struct iwl_tfd_tb tbs[IWL_NUM_OF_TBS];
929#define IWL_byte_cnt_LEN 12 877 __le32 __pad;
930#define IWL_byte_cnt_SYM val
931 /* __le16 rsvd:4; */
932} __attribute__ ((packed)); 878} __attribute__ ((packed));
933 879
934 880
935/** 881/**
936 * struct iwl4965_sched_queue_byte_cnt_tbl 882 * struct iwl4965_schedq_bc_tbl
937 * 883 *
938 * Byte Count table 884 * Byte Count table
939 * 885 *
@@ -947,15 +893,12 @@ struct iwl4965_queue_byte_cnt_entry {
947 * count table for the chosen Tx queue. If the TFD index is 0-63, the driver 893 * count table for the chosen Tx queue. If the TFD index is 0-63, the driver
948 * must duplicate the byte count entry in corresponding index 256-319. 894 * must duplicate the byte count entry in corresponding index 256-319.
949 * 895 *
950 * "dont_care" padding puts each byte count table on a 1024-byte boundary; 896 * padding puts each byte count table on a 1024-byte boundary;
951 * 4965 assumes tables are separated by 1024 bytes. 897 * 4965 assumes tables are separated by 1024 bytes.
952 */ 898 */
953struct iwl4965_sched_queue_byte_cnt_tbl { 899struct iwl4965_schedq_bc_tbl {
954 struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL49_QUEUE_SIZE + 900 __le16 tfd_offset[TFD_QUEUE_BC_SIZE];
955 IWL49_MAX_WIN_SIZE]; 901 u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)];
956 u8 dont_care[1024 -
957 (IWL49_QUEUE_SIZE + IWL49_MAX_WIN_SIZE) *
958 sizeof(__le16)];
959} __attribute__ ((packed)); 902} __attribute__ ((packed));
960 903
961 904
@@ -983,8 +926,7 @@ struct iwl4965_sched_queue_byte_cnt_tbl {
983 * 31- 0: Not used 926 * 31- 0: Not used
984 */ 927 */
985struct iwl4965_shared { 928struct iwl4965_shared {
986 struct iwl4965_sched_queue_byte_cnt_tbl 929 struct iwl4965_schedq_bc_tbl queues_bc_tbls[IWL49_NUM_QUEUES];
987 queues_byte_cnt_tbls[IWL49_NUM_QUEUES];
988 __le32 rb_closed; 930 __le32 rb_closed;
989 931
990 /* __le32 rb_closed_stts_rb_num:12; */ 932 /* __le32 rb_closed_stts_rb_num:12; */
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 9838de5f4369..157cad4e9da0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -246,7 +246,7 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv)
246 iwl_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, 246 iwl_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG,
247 priv->ucode_data.len); 247 priv->ucode_data.len);
248 248
249 /* Inst bytecount must be last to set up, bit 31 signals uCode 249 /* Inst byte count must be last to set up, bit 31 signals uCode
250 * that all new ptr/size info is in place */ 250 * that all new ptr/size info is in place */
251 iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, 251 iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG,
252 priv->ucode_code.len | BSM_DRAM_INST_LOAD); 252 priv->ucode_code.len | BSM_DRAM_INST_LOAD);
@@ -318,31 +318,13 @@ static int is_fat_channel(__le32 rxon_flags)
318/* 318/*
319 * EEPROM handlers 319 * EEPROM handlers
320 */ 320 */
321 321static u16 iwl4965_eeprom_calib_version(struct iwl_priv *priv)
322static int iwl4965_eeprom_check_version(struct iwl_priv *priv)
323{ 322{
324 u16 eeprom_ver; 323 return iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET);
325 u16 calib_ver;
326
327 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
328
329 calib_ver = iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET);
330
331 if (eeprom_ver < EEPROM_4965_EEPROM_VERSION ||
332 calib_ver < EEPROM_4965_TX_POWER_VERSION)
333 goto err;
334
335 return 0;
336err:
337 IWL_ERROR("Unsuported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
338 eeprom_ver, EEPROM_4965_EEPROM_VERSION,
339 calib_ver, EEPROM_4965_TX_POWER_VERSION);
340 return -EINVAL;
341
342} 324}
343 325
344/* 326/*
345 * Activate/Deactivat Tx DMA/FIFO channels according tx fifos mask 327 * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
346 * must be called under priv->lock and mac access 328 * must be called under priv->lock and mac access
347 */ 329 */
348static void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask) 330static void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask)
@@ -414,7 +396,7 @@ static void iwl4965_nic_config(struct iwl_priv *priv)
414 396
415 /* L1 is enabled by BIOS */ 397 /* L1 is enabled by BIOS */
416 if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) 398 if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN)
417 /* diable L0S disabled L1A enabled */ 399 /* disable L0S disabled L1A enabled */
418 iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 400 iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
419 else 401 else
420 /* L0S enabled L1A disabled */ 402 /* L0S enabled L1A disabled */
@@ -537,10 +519,10 @@ static void iwl4965_chain_noise_reset(struct iwl_priv *priv)
537 struct iwl_chain_noise_data *data = &(priv->chain_noise_data); 519 struct iwl_chain_noise_data *data = &(priv->chain_noise_data);
538 520
539 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) { 521 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) {
540 struct iwl4965_calibration_cmd cmd; 522 struct iwl_calib_diff_gain_cmd cmd;
541 523
542 memset(&cmd, 0, sizeof(cmd)); 524 memset(&cmd, 0, sizeof(cmd));
543 cmd.opCode = PHY_CALIBRATE_DIFF_GAIN_CMD; 525 cmd.opCode = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD;
544 cmd.diff_gain_a = 0; 526 cmd.diff_gain_a = 0;
545 cmd.diff_gain_b = 0; 527 cmd.diff_gain_b = 0;
546 cmd.diff_gain_c = 0; 528 cmd.diff_gain_c = 0;
@@ -587,11 +569,11 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
587 569
588 /* Differential gain gets sent to uCode only once */ 570 /* Differential gain gets sent to uCode only once */
589 if (!data->radio_write) { 571 if (!data->radio_write) {
590 struct iwl4965_calibration_cmd cmd; 572 struct iwl_calib_diff_gain_cmd cmd;
591 data->radio_write = 1; 573 data->radio_write = 1;
592 574
593 memset(&cmd, 0, sizeof(cmd)); 575 memset(&cmd, 0, sizeof(cmd));
594 cmd.opCode = PHY_CALIBRATE_DIFF_GAIN_CMD; 576 cmd.opCode = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD;
595 cmd.diff_gain_a = data->delta_gain_code[0]; 577 cmd.diff_gain_a = data->delta_gain_code[0];
596 cmd.diff_gain_b = data->delta_gain_code[1]; 578 cmd.diff_gain_b = data->delta_gain_code[1];
597 cmd.diff_gain_c = data->delta_gain_code[2]; 579 cmd.diff_gain_c = data->delta_gain_code[2];
@@ -619,10 +601,10 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
619static void iwl4965_rts_tx_cmd_flag(struct ieee80211_tx_info *info, 601static void iwl4965_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
620 __le32 *tx_flags) 602 __le32 *tx_flags)
621{ 603{
622 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 604 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
623 *tx_flags |= TX_CMD_FLG_RTS_MSK; 605 *tx_flags |= TX_CMD_FLG_RTS_MSK;
624 *tx_flags &= ~TX_CMD_FLG_CTS_MSK; 606 *tx_flags &= ~TX_CMD_FLG_CTS_MSK;
625 } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { 607 } else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
626 *tx_flags &= ~TX_CMD_FLG_RTS_MSK; 608 *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
627 *tx_flags |= TX_CMD_FLG_CTS_MSK; 609 *tx_flags |= TX_CMD_FLG_CTS_MSK;
628 } 610 }
@@ -643,7 +625,7 @@ static void iwl4965_bg_txpower_work(struct work_struct *work)
643 625
644 mutex_lock(&priv->mutex); 626 mutex_lock(&priv->mutex);
645 627
646 /* Regardless of if we are assocaited, we must reconfigure the 628 /* Regardless of if we are associated, we must reconfigure the
647 * TX power since frames can be sent on non-radar channels while 629 * TX power since frames can be sent on non-radar channels while
648 * not associated */ 630 * not associated */
649 iwl4965_send_tx_power(priv); 631 iwl4965_send_tx_power(priv);
@@ -734,7 +716,7 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
734 /* Tel 4965 where to find Tx byte count tables */ 716 /* Tel 4965 where to find Tx byte count tables */
735 iwl_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, 717 iwl_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR,
736 (priv->shared_phys + 718 (priv->shared_phys +
737 offsetof(struct iwl4965_shared, queues_byte_cnt_tbls)) >> 10); 719 offsetof(struct iwl4965_shared, queues_bc_tbls)) >> 10);
738 720
739 /* Disable chain mode for all queues */ 721 /* Disable chain mode for all queues */
740 iwl_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); 722 iwl_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0);
@@ -822,7 +804,6 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
822 } 804 }
823 805
824 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; 806 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
825 priv->hw_params.first_ampdu_q = IWL49_FIRST_AMPDU_QUEUE;
826 priv->hw_params.max_stations = IWL4965_STATION_COUNT; 807 priv->hw_params.max_stations = IWL4965_STATION_COUNT;
827 priv->hw_params.bcast_sta_id = IWL4965_BROADCAST_ID; 808 priv->hw_params.bcast_sta_id = IWL4965_BROADCAST_ID;
828 priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; 809 priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE;
@@ -1687,21 +1668,22 @@ static void iwl4965_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
1687 struct iwl_tx_queue *txq, 1668 struct iwl_tx_queue *txq,
1688 u16 byte_cnt) 1669 u16 byte_cnt)
1689{ 1670{
1690 int len;
1691 int txq_id = txq->q.id;
1692 struct iwl4965_shared *shared_data = priv->shared_virt; 1671 struct iwl4965_shared *shared_data = priv->shared_virt;
1672 int txq_id = txq->q.id;
1673 int write_ptr = txq->q.write_ptr;
1674 int len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
1675 __le16 bc_ent;
1693 1676
1694 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; 1677 WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
1695 1678
1679 bc_ent = cpu_to_le16(len & 0xFFF);
1696 /* Set up byte count within first 256 entries */ 1680 /* Set up byte count within first 256 entries */
1697 IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id]. 1681 shared_data->queues_bc_tbls[txq_id].tfd_offset[write_ptr] = bc_ent;
1698 tfd_offset[txq->q.write_ptr], byte_cnt, len);
1699 1682
1700 /* If within first 64 entries, duplicate at end */ 1683 /* If within first 64 entries, duplicate at end */
1701 if (txq->q.write_ptr < IWL49_MAX_WIN_SIZE) 1684 if (write_ptr < TFD_QUEUE_SIZE_BC_DUP)
1702 IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id]. 1685 shared_data->queues_bc_tbls[txq_id].
1703 tfd_offset[IWL49_QUEUE_SIZE + txq->q.write_ptr], 1686 tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
1704 byte_cnt, len);
1705} 1687}
1706 1688
1707/** 1689/**
@@ -2037,7 +2019,7 @@ static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp)
2037} 2019}
2038 2020
2039/** 2021/**
2040 * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue 2022 * iwl4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue
2041 */ 2023 */
2042static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, 2024static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2043 struct iwl_ht_agg *agg, 2025 struct iwl_ht_agg *agg,
@@ -2059,7 +2041,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2059 agg->rate_n_flags = rate_n_flags; 2041 agg->rate_n_flags = rate_n_flags;
2060 agg->bitmap = 0; 2042 agg->bitmap = 0;
2061 2043
2062 /* # frames attempted by Tx command */ 2044 /* num frames attempted by Tx command */
2063 if (agg->frame_count == 1) { 2045 if (agg->frame_count == 1) {
2064 /* Only one frame was attempted; no block-ack will arrive */ 2046 /* Only one frame was attempted; no block-ack will arrive */
2065 status = le16_to_cpu(frame_status[0].status); 2047 status = le16_to_cpu(frame_status[0].status);
@@ -2070,7 +2052,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2070 agg->frame_count, agg->start_idx, idx); 2052 agg->frame_count, agg->start_idx, idx);
2071 2053
2072 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); 2054 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
2073 info->status.retry_count = tx_resp->failure_frame; 2055 info->status.rates[0].count = tx_resp->failure_frame + 1;
2074 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 2056 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
2075 info->flags |= iwl_is_tx_success(status)? 2057 info->flags |= iwl_is_tx_success(status)?
2076 IEEE80211_TX_STAT_ACK : 0; 2058 IEEE80211_TX_STAT_ACK : 0;
@@ -2158,12 +2140,13 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2158 int txq_id = SEQ_TO_QUEUE(sequence); 2140 int txq_id = SEQ_TO_QUEUE(sequence);
2159 int index = SEQ_TO_INDEX(sequence); 2141 int index = SEQ_TO_INDEX(sequence);
2160 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 2142 struct iwl_tx_queue *txq = &priv->txq[txq_id];
2143 struct ieee80211_hdr *hdr;
2161 struct ieee80211_tx_info *info; 2144 struct ieee80211_tx_info *info;
2162 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 2145 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
2163 u32 status = le32_to_cpu(tx_resp->u.status); 2146 u32 status = le32_to_cpu(tx_resp->u.status);
2164 int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; 2147 int tid = MAX_TID_COUNT;
2165 __le16 fc; 2148 int sta_id;
2166 struct ieee80211_hdr *hdr; 2149 int freed;
2167 u8 *qc = NULL; 2150 u8 *qc = NULL;
2168 2151
2169 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) { 2152 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
@@ -2178,8 +2161,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2178 memset(&info->status, 0, sizeof(info->status)); 2161 memset(&info->status, 0, sizeof(info->status));
2179 2162
2180 hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); 2163 hdr = iwl_tx_queue_get_hdr(priv, txq_id, index);
2181 fc = hdr->frame_control; 2164 if (ieee80211_is_data_qos(hdr->frame_control)) {
2182 if (ieee80211_is_data_qos(fc)) {
2183 qc = ieee80211_get_qos_ctl(hdr); 2165 qc = ieee80211_get_qos_ctl(hdr);
2184 tid = qc[0] & 0xf; 2166 tid = qc[0] & 0xf;
2185 } 2167 }
@@ -2194,8 +2176,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2194 const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); 2176 const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp);
2195 struct iwl_ht_agg *agg = NULL; 2177 struct iwl_ht_agg *agg = NULL;
2196 2178
2197 if (!qc) 2179 WARN_ON(!qc);
2198 return;
2199 2180
2200 agg = &priv->stations[sta_id].tid[tid].agg; 2181 agg = &priv->stations[sta_id].tid[tid].agg;
2201 2182
@@ -2206,54 +2187,49 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2206 info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; 2187 info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
2207 2188
2208 if (txq->q.read_ptr != (scd_ssn & 0xff)) { 2189 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
2209 int freed, ampdu_q;
2210 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); 2190 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
2211 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " 2191 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
2212 "%d index %d\n", scd_ssn , index); 2192 "%d index %d\n", scd_ssn , index);
2213 freed = iwl_tx_queue_reclaim(priv, txq_id, index); 2193 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
2214 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 2194 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
2215 2195
2216 if (iwl_queue_space(&txq->q) > txq->q.low_mark && 2196 if (priv->mac80211_registered &&
2217 txq_id >= 0 && priv->mac80211_registered && 2197 (iwl_queue_space(&txq->q) > txq->q.low_mark) &&
2218 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { 2198 (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) {
2219 /* calculate mac80211 ampdu sw queue to wake */
2220 ampdu_q = txq_id - IWL49_FIRST_AMPDU_QUEUE +
2221 priv->hw->queues;
2222 if (agg->state == IWL_AGG_OFF) 2199 if (agg->state == IWL_AGG_OFF)
2223 ieee80211_wake_queue(priv->hw, txq_id); 2200 ieee80211_wake_queue(priv->hw, txq_id);
2224 else 2201 else
2225 ieee80211_wake_queue(priv->hw, ampdu_q); 2202 ieee80211_wake_queue(priv->hw,
2203 txq->swq_id);
2226 } 2204 }
2227 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
2228 } 2205 }
2229 } else { 2206 } else {
2230 info->status.retry_count = tx_resp->failure_frame; 2207 info->status.rates[0].count = tx_resp->failure_frame + 1;
2231 info->flags |= 2208 info->flags |= iwl_is_tx_success(status) ?
2232 iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 2209 IEEE80211_TX_STAT_ACK : 0;
2233 iwl_hwrate_to_tx_control(priv, 2210 iwl_hwrate_to_tx_control(priv,
2234 le32_to_cpu(tx_resp->rate_n_flags), 2211 le32_to_cpu(tx_resp->rate_n_flags),
2235 info); 2212 info);
2236 2213
2237 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags " 2214 IWL_DEBUG_TX_REPLY("TXQ %d status %s (0x%08x) "
2238 "0x%x retries %d\n", txq_id, 2215 "rate_n_flags 0x%x retries %d\n",
2239 iwl_get_tx_fail_reason(status), 2216 txq_id,
2240 status, le32_to_cpu(tx_resp->rate_n_flags), 2217 iwl_get_tx_fail_reason(status), status,
2241 tx_resp->failure_frame); 2218 le32_to_cpu(tx_resp->rate_n_flags),
2242 2219 tx_resp->failure_frame);
2243 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
2244 2220
2245 if (index != -1) { 2221 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
2246 int freed = iwl_tx_queue_reclaim(priv, txq_id, index); 2222 if (qc && likely(sta_id != IWL_INVALID_STATION))
2247 if (tid != MAX_TID_COUNT)
2248 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 2223 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
2249 if (iwl_queue_space(&txq->q) > txq->q.low_mark && 2224
2250 (txq_id >= 0) && priv->mac80211_registered) 2225 if (priv->mac80211_registered &&
2226 (iwl_queue_space(&txq->q) > txq->q.low_mark))
2251 ieee80211_wake_queue(priv->hw, txq_id); 2227 ieee80211_wake_queue(priv->hw, txq_id);
2252 if (tid != MAX_TID_COUNT)
2253 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
2254 }
2255 } 2228 }
2256 2229
2230 if (qc && likely(sta_id != IWL_INVALID_STATION))
2231 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
2232
2257 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 2233 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
2258 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); 2234 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n");
2259} 2235}
@@ -2347,7 +2323,7 @@ static struct iwl_lib_ops iwl4965_lib = {
2347 .reset = iwl4965_apm_reset, 2323 .reset = iwl4965_apm_reset,
2348 .stop = iwl4965_apm_stop, 2324 .stop = iwl4965_apm_stop,
2349 .config = iwl4965_nic_config, 2325 .config = iwl4965_nic_config,
2350 .set_pwr_src = iwl4965_set_pwr_src, 2326 .set_pwr_src = iwl_set_pwr_src,
2351 }, 2327 },
2352 .eeprom_ops = { 2328 .eeprom_ops = {
2353 .regulatory_bands = { 2329 .regulatory_bands = {
@@ -2362,11 +2338,11 @@ static struct iwl_lib_ops iwl4965_lib = {
2362 .verify_signature = iwlcore_eeprom_verify_signature, 2338 .verify_signature = iwlcore_eeprom_verify_signature,
2363 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, 2339 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
2364 .release_semaphore = iwlcore_eeprom_release_semaphore, 2340 .release_semaphore = iwlcore_eeprom_release_semaphore,
2365 .check_version = iwl4965_eeprom_check_version, 2341 .calib_version = iwl4965_eeprom_calib_version,
2366 .query_addr = iwlcore_eeprom_query_addr, 2342 .query_addr = iwlcore_eeprom_query_addr,
2367 }, 2343 },
2368 .send_tx_power = iwl4965_send_tx_power, 2344 .send_tx_power = iwl4965_send_tx_power,
2369 .update_chain_flags = iwl4965_update_chain_flags, 2345 .update_chain_flags = iwl_update_chain_flags,
2370 .temperature = iwl4965_temperature_calib, 2346 .temperature = iwl4965_temperature_calib,
2371}; 2347};
2372 2348
@@ -2381,6 +2357,8 @@ struct iwl_cfg iwl4965_agn_cfg = {
2381 .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode", 2357 .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode",
2382 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 2358 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
2383 .eeprom_size = IWL4965_EEPROM_IMG_SIZE, 2359 .eeprom_size = IWL4965_EEPROM_IMG_SIZE,
2360 .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
2361 .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION,
2384 .ops = &iwl4965_ops, 2362 .ops = &iwl4965_ops,
2385 .mod_params = &iwl4965_mod_params, 2363 .mod_params = &iwl4965_mod_params,
2386}; 2364};
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
index c479ee211c5c..12c74048a396 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
@@ -73,33 +73,34 @@
73#define IWL50_RTC_INST_SIZE (IWL50_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND) 73#define IWL50_RTC_INST_SIZE (IWL50_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
74#define IWL50_RTC_DATA_SIZE (IWL50_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND) 74#define IWL50_RTC_DATA_SIZE (IWL50_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
75 75
76/* EERPROM */ 76/* EEPROM */
77#define IWL_5000_EEPROM_IMG_SIZE 2048 77#define IWL_5000_EEPROM_IMG_SIZE 2048
78 78
79
80#define IWL50_MAX_WIN_SIZE 64
81#define IWL50_QUEUE_SIZE 256
82#define IWL50_CMD_FIFO_NUM 7 79#define IWL50_CMD_FIFO_NUM 7
83#define IWL50_NUM_QUEUES 20 80#define IWL50_NUM_QUEUES 20
84#define IWL50_NUM_AMPDU_QUEUES 10 81#define IWL50_NUM_AMPDU_QUEUES 10
85#define IWL50_FIRST_AMPDU_QUEUE 10 82#define IWL50_FIRST_AMPDU_QUEUE 10
86 83
87#define IWL_sta_id_POS 12
88#define IWL_sta_id_LEN 4
89#define IWL_sta_id_SYM val
90
91/* Fixed (non-configurable) rx data from phy */ 84/* Fixed (non-configurable) rx data from phy */
92 85
93/* Base physical address of iwl5000_shared is provided to SCD_DRAM_BASE_ADDR 86/**
94 * and &iwl5000_shared.val0 is provided to FH_RSCSR_CHNL0_STTS_WPTR_REG */ 87 * struct iwl5000_schedq_bc_tbl scheduler byte count table
95struct iwl5000_sched_queue_byte_cnt_tbl { 88 * base physical address of iwl5000_shared
96 struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL50_QUEUE_SIZE + 89 * is provided to SCD_DRAM_BASE_ADDR
97 IWL50_MAX_WIN_SIZE]; 90 * @tfd_offset 0-12 - tx command byte count
91 * 12-16 - station index
92 */
93struct iwl5000_schedq_bc_tbl {
94 __le16 tfd_offset[TFD_QUEUE_BC_SIZE];
98} __attribute__ ((packed)); 95} __attribute__ ((packed));
99 96
97/**
98 * struct iwl5000_shared
99 * @rb_closed
100 * address is provided to FH_RSCSR_CHNL0_STTS_WPTR_REG
101 */
100struct iwl5000_shared { 102struct iwl5000_shared {
101 struct iwl5000_sched_queue_byte_cnt_tbl 103 struct iwl5000_schedq_bc_tbl queues_bc_tbls[IWL50_NUM_QUEUES];
102 queues_byte_cnt_tbls[IWL50_NUM_QUEUES];
103 __le32 rb_closed; 104 __le32 rb_closed;
104 105
105 /* __le32 rb_closed_stts_rb_num:12; */ 106 /* __le32 rb_closed_stts_rb_num:12; */
@@ -129,13 +130,5 @@ struct iwl5000_shared {
129 __le32 padding2; 130 __le32 padding2;
130} __attribute__ ((packed)); 131} __attribute__ ((packed));
131 132
132/* calibrations defined for 5000 */
133/* defines the order in which results should be sent to the runtime uCode */
134enum iwl5000_calib {
135 IWL5000_CALIB_LO,
136 IWL5000_CALIB_TX_IQ,
137 IWL5000_CALIB_TX_IQ_PERD,
138};
139
140#endif /* __iwl_5000_hw_h__ */ 133#endif /* __iwl_5000_hw_h__ */
141 134
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 5155b8a760a7..31e62a838ad4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -46,6 +46,8 @@
46 46
47#define IWL5000_UCODE_API "-1" 47#define IWL5000_UCODE_API "-1"
48 48
49#define IWL5000_MODULE_FIRMWARE "iwlwifi-5000" IWL5000_UCODE_API ".ucode"
50
49static const u16 iwl5000_default_queue_to_tx_fifo[] = { 51static const u16 iwl5000_default_queue_to_tx_fifo[] = {
50 IWL_TX_FIFO_AC3, 52 IWL_TX_FIFO_AC3,
51 IWL_TX_FIFO_AC2, 53 IWL_TX_FIFO_AC2,
@@ -92,7 +94,7 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
92 iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, 94 iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
93 CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); 95 CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
94 96
95 /* Set FH wait treshold to maximum (HW error during stress W/A) */ 97 /* Set FH wait threshold to maximum (HW error during stress W/A) */
96 iwl_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); 98 iwl_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL);
97 99
98 /* enable HAP INTA to move device L1a -> L0s */ 100 /* enable HAP INTA to move device L1a -> L0s */
@@ -132,7 +134,7 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
132 return ret; 134 return ret;
133} 135}
134 136
135/* FIXME: this is indentical to 4965 */ 137/* FIXME: this is identical to 4965 */
136static void iwl5000_apm_stop(struct iwl_priv *priv) 138static void iwl5000_apm_stop(struct iwl_priv *priv)
137{ 139{
138 unsigned long flags; 140 unsigned long flags;
@@ -217,7 +219,7 @@ static void iwl5000_nic_config(struct iwl_priv *priv)
217 219
218 /* L1 is enabled by BIOS */ 220 /* L1 is enabled by BIOS */
219 if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) 221 if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN)
220 /* diable L0S disabled L1A enabled */ 222 /* disable L0S disabled L1A enabled */
221 iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 223 iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
222 else 224 else
223 /* L0S enabled L1A disabled */ 225 /* L0S enabled L1A disabled */
@@ -291,30 +293,17 @@ static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address)
291 return (address & ADDRESS_MSK) + (offset << 1); 293 return (address & ADDRESS_MSK) + (offset << 1);
292} 294}
293 295
294static int iwl5000_eeprom_check_version(struct iwl_priv *priv) 296static u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv)
295{ 297{
296 u16 eeprom_ver;
297 struct iwl_eeprom_calib_hdr { 298 struct iwl_eeprom_calib_hdr {
298 u8 version; 299 u8 version;
299 u8 pa_type; 300 u8 pa_type;
300 u16 voltage; 301 u16 voltage;
301 } *hdr; 302 } *hdr;
302 303
303 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
304
305 hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, 304 hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv,
306 EEPROM_5000_CALIB_ALL); 305 EEPROM_5000_CALIB_ALL);
307 306 return hdr->version;
308 if (eeprom_ver < EEPROM_5000_EEPROM_VERSION ||
309 hdr->version < EEPROM_5000_TX_POWER_VERSION)
310 goto err;
311
312 return 0;
313err:
314 IWL_ERROR("Unsuported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
315 eeprom_ver, EEPROM_5000_EEPROM_VERSION,
316 hdr->version, EEPROM_5000_TX_POWER_VERSION);
317 return -EINVAL;
318 307
319} 308}
320 309
@@ -348,10 +337,10 @@ static void iwl5000_gain_computation(struct iwl_priv *priv,
348 data->delta_gain_code[1], data->delta_gain_code[2]); 337 data->delta_gain_code[1], data->delta_gain_code[2]);
349 338
350 if (!data->radio_write) { 339 if (!data->radio_write) {
351 struct iwl5000_calibration_chain_noise_gain_cmd cmd; 340 struct iwl_calib_chain_noise_gain_cmd cmd;
352 memset(&cmd, 0, sizeof(cmd)); 341 memset(&cmd, 0, sizeof(cmd));
353 342
354 cmd.op_code = IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD; 343 cmd.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD;
355 cmd.delta_gain_1 = data->delta_gain_code[1]; 344 cmd.delta_gain_1 = data->delta_gain_code[1];
356 cmd.delta_gain_2 = data->delta_gain_code[2]; 345 cmd.delta_gain_2 = data->delta_gain_code[2];
357 iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD, 346 iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD,
@@ -375,10 +364,10 @@ static void iwl5000_chain_noise_reset(struct iwl_priv *priv)
375 struct iwl_chain_noise_data *data = &priv->chain_noise_data; 364 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
376 365
377 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) { 366 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) {
378 struct iwl5000_calibration_chain_noise_reset_cmd cmd; 367 struct iwl_calib_chain_noise_reset_cmd cmd;
379 368
380 memset(&cmd, 0, sizeof(cmd)); 369 memset(&cmd, 0, sizeof(cmd));
381 cmd.op_code = IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD; 370 cmd.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD;
382 if (iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, 371 if (iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
383 sizeof(cmd), &cmd)) 372 sizeof(cmd), &cmd))
384 IWL_ERROR("Could not send REPLY_PHY_CALIBRATION_CMD\n"); 373 IWL_ERROR("Could not send REPLY_PHY_CALIBRATION_CMD\n");
@@ -390,8 +379,8 @@ static void iwl5000_chain_noise_reset(struct iwl_priv *priv)
390static void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info, 379static void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
391 __le32 *tx_flags) 380 __le32 *tx_flags)
392{ 381{
393 if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) || 382 if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
394 (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) 383 (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
395 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK; 384 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
396 else 385 else
397 *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK; 386 *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK;
@@ -429,28 +418,27 @@ static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
429/* 418/*
430 * Calibration 419 * Calibration
431 */ 420 */
432static int iwl5000_send_Xtal_calib(struct iwl_priv *priv) 421static int iwl5000_set_Xtal_calib(struct iwl_priv *priv)
433{ 422{
423 u8 data[sizeof(struct iwl_calib_hdr) +
424 sizeof(struct iwl_cal_xtal_freq)];
425 struct iwl_calib_cmd *cmd = (struct iwl_calib_cmd *)data;
426 struct iwl_cal_xtal_freq *xtal = (struct iwl_cal_xtal_freq *)cmd->data;
434 u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL); 427 u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
435 428
436 struct iwl5000_calibration cal_cmd = { 429 cmd->hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
437 .op_code = IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD, 430 xtal->cap_pin1 = (u8)xtal_calib[0];
438 .data = { 431 xtal->cap_pin2 = (u8)xtal_calib[1];
439 (u8)xtal_calib[0], 432 return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL],
440 (u8)xtal_calib[1], 433 data, sizeof(data));
441 }
442 };
443
444 return iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
445 sizeof(cal_cmd), &cal_cmd);
446} 434}
447 435
448static int iwl5000_send_calib_cfg(struct iwl_priv *priv) 436static int iwl5000_send_calib_cfg(struct iwl_priv *priv)
449{ 437{
450 struct iwl5000_calib_cfg_cmd calib_cfg_cmd; 438 struct iwl_calib_cfg_cmd calib_cfg_cmd;
451 struct iwl_host_cmd cmd = { 439 struct iwl_host_cmd cmd = {
452 .id = CALIBRATION_CFG_CMD, 440 .id = CALIBRATION_CFG_CMD,
453 .len = sizeof(struct iwl5000_calib_cfg_cmd), 441 .len = sizeof(struct iwl_calib_cfg_cmd),
454 .data = &calib_cfg_cmd, 442 .data = &calib_cfg_cmd,
455 }; 443 };
456 444
@@ -467,7 +455,7 @@ static void iwl5000_rx_calib_result(struct iwl_priv *priv,
467 struct iwl_rx_mem_buffer *rxb) 455 struct iwl_rx_mem_buffer *rxb)
468{ 456{
469 struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 457 struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
470 struct iwl5000_calib_hdr *hdr = (struct iwl5000_calib_hdr *)pkt->u.raw; 458 struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw;
471 int len = le32_to_cpu(pkt->len) & FH_RSCSR_FRAME_SIZE_MSK; 459 int len = le32_to_cpu(pkt->len) & FH_RSCSR_FRAME_SIZE_MSK;
472 int index; 460 int index;
473 461
@@ -478,14 +466,14 @@ static void iwl5000_rx_calib_result(struct iwl_priv *priv,
478 * uCode. iwl_send_calib_results sends them in a row according to their 466 * uCode. iwl_send_calib_results sends them in a row according to their
479 * index. We sort them here */ 467 * index. We sort them here */
480 switch (hdr->op_code) { 468 switch (hdr->op_code) {
481 case IWL5000_PHY_CALIBRATE_LO_CMD: 469 case IWL_PHY_CALIBRATE_LO_CMD:
482 index = IWL5000_CALIB_LO; 470 index = IWL_CALIB_LO;
483 break; 471 break;
484 case IWL5000_PHY_CALIBRATE_TX_IQ_CMD: 472 case IWL_PHY_CALIBRATE_TX_IQ_CMD:
485 index = IWL5000_CALIB_TX_IQ; 473 index = IWL_CALIB_TX_IQ;
486 break; 474 break;
487 case IWL5000_PHY_CALIBRATE_TX_IQ_PERD_CMD: 475 case IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD:
488 index = IWL5000_CALIB_TX_IQ_PERD; 476 index = IWL_CALIB_TX_IQ_PERD;
489 break; 477 break;
490 default: 478 default:
491 IWL_ERROR("Unknown calibration notification %d\n", 479 IWL_ERROR("Unknown calibration notification %d\n",
@@ -535,7 +523,7 @@ static int iwl5000_load_section(struct iwl_priv *priv,
535 523
536 iwl_write_direct32(priv, 524 iwl_write_direct32(priv,
537 FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), 525 FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL),
538 (iwl_get_dma_hi_address(phy_addr) 526 (iwl_get_dma_hi_addr(phy_addr)
539 << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); 527 << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt);
540 528
541 iwl_write_direct32(priv, 529 iwl_write_direct32(priv,
@@ -547,7 +535,7 @@ static int iwl5000_load_section(struct iwl_priv *priv,
547 iwl_write_direct32(priv, 535 iwl_write_direct32(priv,
548 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), 536 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
549 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | 537 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
550 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL | 538 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
551 FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); 539 FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
552 540
553 iwl_release_nic_access(priv); 541 iwl_release_nic_access(priv);
@@ -561,14 +549,13 @@ static int iwl5000_load_given_ucode(struct iwl_priv *priv,
561{ 549{
562 int ret = 0; 550 int ret = 0;
563 551
564 ret = iwl5000_load_section( 552 ret = iwl5000_load_section(priv, inst_image, RTC_INST_LOWER_BOUND);
565 priv, inst_image, RTC_INST_LOWER_BOUND);
566 if (ret) 553 if (ret)
567 return ret; 554 return ret;
568 555
569 IWL_DEBUG_INFO("INST uCode section being loaded...\n"); 556 IWL_DEBUG_INFO("INST uCode section being loaded...\n");
570 ret = wait_event_interruptible_timeout(priv->wait_command_queue, 557 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
571 priv->ucode_write_complete, 5 * HZ); 558 priv->ucode_write_complete, 5 * HZ);
572 if (ret == -ERESTARTSYS) { 559 if (ret == -ERESTARTSYS) {
573 IWL_ERROR("Could not load the INST uCode section due " 560 IWL_ERROR("Could not load the INST uCode section due "
574 "to interrupt\n"); 561 "to interrupt\n");
@@ -682,7 +669,7 @@ static void iwl5000_tx_queue_set_status(struct iwl_priv *priv,
682 int tx_fifo_id, int scd_retry) 669 int tx_fifo_id, int scd_retry)
683{ 670{
684 int txq_id = txq->q.id; 671 int txq_id = txq->q.id;
685 int active = test_bit(txq_id, &priv->txq_ctx_active_msk)?1:0; 672 int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
686 673
687 iwl_write_prph(priv, IWL50_SCD_QUEUE_STATUS_BITS(txq_id), 674 iwl_write_prph(priv, IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
688 (active << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE) | 675 (active << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
@@ -735,7 +722,7 @@ static int iwl5000_alive_notify(struct iwl_priv *priv)
735 722
736 iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR, 723 iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
737 (priv->shared_phys + 724 (priv->shared_phys +
738 offsetof(struct iwl5000_shared, queues_byte_cnt_tbls)) >> 10); 725 offsetof(struct iwl5000_shared, queues_bc_tbls)) >> 10);
739 iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, 726 iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL,
740 IWL50_SCD_QUEUECHAIN_SEL_ALL( 727 IWL50_SCD_QUEUECHAIN_SEL_ALL(
741 priv->hw_params.max_txq_num)); 728 priv->hw_params.max_txq_num));
@@ -765,6 +752,7 @@ static int iwl5000_alive_notify(struct iwl_priv *priv)
765 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7)); 752 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
766 753
767 iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); 754 iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
755
768 /* map qos queues to fifos one-to-one */ 756 /* map qos queues to fifos one-to-one */
769 for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) { 757 for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
770 int ac = iwl5000_default_queue_to_tx_fifo[i]; 758 int ac = iwl5000_default_queue_to_tx_fifo[i];
@@ -784,10 +772,8 @@ static int iwl5000_alive_notify(struct iwl_priv *priv)
784 772
785 iwl5000_send_wimax_coex(priv); 773 iwl5000_send_wimax_coex(priv);
786 774
787 iwl5000_send_Xtal_calib(priv); 775 iwl5000_set_Xtal_calib(priv);
788 776 iwl_send_calib_results(priv);
789 if (priv->ucode_type == UCODE_RT)
790 iwl_send_calib_results(priv);
791 777
792 return 0; 778 return 0;
793} 779}
@@ -802,7 +788,6 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
802 } 788 }
803 789
804 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; 790 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
805 priv->hw_params.first_ampdu_q = IWL50_FIRST_AMPDU_QUEUE;
806 priv->hw_params.max_stations = IWL5000_STATION_COUNT; 791 priv->hw_params.max_stations = IWL5000_STATION_COUNT;
807 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID; 792 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
808 priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE; 793 priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE;
@@ -814,10 +799,14 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
814 799
815 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 800 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
816 case CSR_HW_REV_TYPE_5100: 801 case CSR_HW_REV_TYPE_5100:
802 priv->hw_params.tx_chains_num = 1;
803 priv->hw_params.rx_chains_num = 2;
804 priv->hw_params.valid_tx_ant = ANT_B;
805 priv->hw_params.valid_rx_ant = ANT_AB;
806 break;
817 case CSR_HW_REV_TYPE_5150: 807 case CSR_HW_REV_TYPE_5150:
818 priv->hw_params.tx_chains_num = 1; 808 priv->hw_params.tx_chains_num = 1;
819 priv->hw_params.rx_chains_num = 2; 809 priv->hw_params.rx_chains_num = 2;
820 /* FIXME: move to ANT_A, ANT_B, ANT_C enum */
821 priv->hw_params.valid_tx_ant = ANT_A; 810 priv->hw_params.valid_tx_ant = ANT_A;
822 priv->hw_params.valid_rx_ant = ANT_AB; 811 priv->hw_params.valid_rx_ant = ANT_AB;
823 break; 812 break;
@@ -844,6 +833,23 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
844 break; 833 break;
845 } 834 }
846 835
836 /* Set initial calibration set */
837 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
838 case CSR_HW_REV_TYPE_5100:
839 case CSR_HW_REV_TYPE_5300:
840 case CSR_HW_REV_TYPE_5350:
841 priv->hw_params.calib_init_cfg =
842 BIT(IWL_CALIB_XTAL) |
843 BIT(IWL_CALIB_LO) |
844 BIT(IWL_CALIB_TX_IQ) |
845 BIT(IWL_CALIB_TX_IQ_PERD);
846 break;
847 case CSR_HW_REV_TYPE_5150:
848 priv->hw_params.calib_init_cfg = 0;
849 break;
850 }
851
852
847 return 0; 853 return 0;
848} 854}
849 855
@@ -885,15 +891,17 @@ static void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
885 u16 byte_cnt) 891 u16 byte_cnt)
886{ 892{
887 struct iwl5000_shared *shared_data = priv->shared_virt; 893 struct iwl5000_shared *shared_data = priv->shared_virt;
894 int write_ptr = txq->q.write_ptr;
888 int txq_id = txq->q.id; 895 int txq_id = txq->q.id;
889 u8 sec_ctl = 0; 896 u8 sec_ctl = 0;
890 u8 sta = 0; 897 u8 sta_id = 0;
891 int len; 898 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
899 __le16 bc_ent;
892 900
893 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; 901 WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
894 902
895 if (txq_id != IWL_CMD_QUEUE_NUM) { 903 if (txq_id != IWL_CMD_QUEUE_NUM) {
896 sta = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id; 904 sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id;
897 sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl; 905 sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl;
898 906
899 switch (sec_ctl & TX_CMD_SEC_MSK) { 907 switch (sec_ctl & TX_CMD_SEC_MSK) {
@@ -909,40 +917,36 @@ static void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
909 } 917 }
910 } 918 }
911 919
912 IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id]. 920 bc_ent = cpu_to_le16((len & 0xFFF) | (sta_id << 12));
913 tfd_offset[txq->q.write_ptr], byte_cnt, len);
914 921
915 IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id]. 922 shared_data->queues_bc_tbls[txq_id].tfd_offset[write_ptr] = bc_ent;
916 tfd_offset[txq->q.write_ptr], sta_id, sta);
917 923
918 if (txq->q.write_ptr < IWL50_MAX_WIN_SIZE) { 924 if (txq->q.write_ptr < TFD_QUEUE_SIZE_BC_DUP)
919 IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id]. 925 shared_data->queues_bc_tbls[txq_id].
920 tfd_offset[IWL50_QUEUE_SIZE + txq->q.write_ptr], 926 tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
921 byte_cnt, len);
922 IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
923 tfd_offset[IWL50_QUEUE_SIZE + txq->q.write_ptr],
924 sta_id, sta);
925 }
926} 927}
927 928
928static void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv, 929static void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
929 struct iwl_tx_queue *txq) 930 struct iwl_tx_queue *txq)
930{ 931{
931 int txq_id = txq->q.id;
932 struct iwl5000_shared *shared_data = priv->shared_virt; 932 struct iwl5000_shared *shared_data = priv->shared_virt;
933 u8 sta = 0; 933 int txq_id = txq->q.id;
934 int read_ptr = txq->q.read_ptr;
935 u8 sta_id = 0;
936 __le16 bc_ent;
937
938 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
934 939
935 if (txq_id != IWL_CMD_QUEUE_NUM) 940 if (txq_id != IWL_CMD_QUEUE_NUM)
936 sta = txq->cmd[txq->q.read_ptr]->cmd.tx.sta_id; 941 sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id;
937 942
938 shared_data->queues_byte_cnt_tbls[txq_id].tfd_offset[txq->q.read_ptr]. 943 bc_ent = cpu_to_le16(1 | (sta_id << 12));
939 val = cpu_to_le16(1 | (sta << 12)); 944 shared_data->queues_bc_tbls[txq_id].
945 tfd_offset[read_ptr] = bc_ent;
940 946
941 if (txq->q.write_ptr < IWL50_MAX_WIN_SIZE) { 947 if (txq->q.write_ptr < TFD_QUEUE_SIZE_BC_DUP)
942 shared_data->queues_byte_cnt_tbls[txq_id]. 948 shared_data->queues_bc_tbls[txq_id].
943 tfd_offset[IWL50_QUEUE_SIZE + txq->q.read_ptr]. 949 tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = bc_ent;
944 val = cpu_to_le16(1 | (sta << 12));
945 }
946} 950}
947 951
948static int iwl5000_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid, 952static int iwl5000_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
@@ -1089,7 +1093,7 @@ static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
1089 1093
1090 1094
1091/* 1095/*
1092 * Activate/Deactivat Tx DMA/FIFO channels according tx fifos mask 1096 * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
1093 * must be called under priv->lock and mac access 1097 * must be called under priv->lock and mac access
1094 */ 1098 */
1095static void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask) 1099static void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask)
@@ -1136,10 +1140,10 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1136 agg->frame_count, agg->start_idx, idx); 1140 agg->frame_count, agg->start_idx, idx);
1137 1141
1138 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); 1142 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
1139 info->status.retry_count = tx_resp->failure_frame; 1143 info->status.rates[0].count = tx_resp->failure_frame + 1;
1140 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 1144 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
1141 info->flags |= iwl_is_tx_success(status)? 1145 info->flags |= iwl_is_tx_success(status)?
1142 IEEE80211_TX_STAT_ACK : 0; 1146 IEEE80211_TX_STAT_ACK : 0;
1143 iwl_hwrate_to_tx_control(priv, rate_n_flags, info); 1147 iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
1144 1148
1145 /* FIXME: code repetition end */ 1149 /* FIXME: code repetition end */
@@ -1225,9 +1229,9 @@ static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
1225 struct ieee80211_tx_info *info; 1229 struct ieee80211_tx_info *info;
1226 struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 1230 struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
1227 u32 status = le16_to_cpu(tx_resp->status.status); 1231 u32 status = le16_to_cpu(tx_resp->status.status);
1228 int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; 1232 int tid;
1229 struct ieee80211_hdr *hdr; 1233 int sta_id;
1230 u8 *qc = NULL; 1234 int freed;
1231 1235
1232 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) { 1236 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
1233 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " 1237 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
@@ -1240,25 +1244,13 @@ static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
1240 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); 1244 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
1241 memset(&info->status, 0, sizeof(info->status)); 1245 memset(&info->status, 0, sizeof(info->status));
1242 1246
1243 hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); 1247 tid = (tx_resp->ra_tid & IWL50_TX_RES_TID_MSK) >> IWL50_TX_RES_TID_POS;
1244 if (ieee80211_is_data_qos(hdr->frame_control)) { 1248 sta_id = (tx_resp->ra_tid & IWL50_TX_RES_RA_MSK) >> IWL50_TX_RES_RA_POS;
1245 qc = ieee80211_get_qos_ctl(hdr);
1246 tid = qc[0] & 0xf;
1247 }
1248
1249 sta_id = iwl_get_ra_sta_id(priv, hdr);
1250 if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) {
1251 IWL_ERROR("Station not known\n");
1252 return;
1253 }
1254 1249
1255 if (txq->sched_retry) { 1250 if (txq->sched_retry) {
1256 const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp); 1251 const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp);
1257 struct iwl_ht_agg *agg = NULL; 1252 struct iwl_ht_agg *agg = NULL;
1258 1253
1259 if (!qc)
1260 return;
1261
1262 agg = &priv->stations[sta_id].tid[tid].agg; 1254 agg = &priv->stations[sta_id].tid[tid].agg;
1263 1255
1264 iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); 1256 iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
@@ -1268,58 +1260,58 @@ static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
1268 info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; 1260 info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
1269 1261
1270 if (txq->q.read_ptr != (scd_ssn & 0xff)) { 1262 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
1271 int freed, ampdu_q;
1272 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); 1263 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
1273 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " 1264 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim "
1274 "%d index %d\n", scd_ssn , index); 1265 "scd_ssn=%d idx=%d txq=%d swq=%d\n",
1266 scd_ssn , index, txq_id, txq->swq_id);
1267
1275 freed = iwl_tx_queue_reclaim(priv, txq_id, index); 1268 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
1276 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 1269 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
1277 1270
1278 if (iwl_queue_space(&txq->q) > txq->q.low_mark && 1271 if (priv->mac80211_registered &&
1279 txq_id >= 0 && priv->mac80211_registered && 1272 (iwl_queue_space(&txq->q) > txq->q.low_mark) &&
1280 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { 1273 (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) {
1281 /* calculate mac80211 ampdu sw queue to wake */
1282 ampdu_q = txq_id - IWL50_FIRST_AMPDU_QUEUE +
1283 priv->hw->queues;
1284 if (agg->state == IWL_AGG_OFF) 1274 if (agg->state == IWL_AGG_OFF)
1285 ieee80211_wake_queue(priv->hw, txq_id); 1275 ieee80211_wake_queue(priv->hw, txq_id);
1286 else 1276 else
1287 ieee80211_wake_queue(priv->hw, ampdu_q); 1277 ieee80211_wake_queue(priv->hw,
1278 txq->swq_id);
1288 } 1279 }
1289 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
1290 } 1280 }
1291 } else { 1281 } else {
1292 info->status.retry_count = tx_resp->failure_frame; 1282 BUG_ON(txq_id != txq->swq_id);
1293 info->flags = 1283
1294 iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 1284 info->status.rates[0].count = tx_resp->failure_frame + 1;
1285 info->flags |= iwl_is_tx_success(status) ?
1286 IEEE80211_TX_STAT_ACK : 0;
1295 iwl_hwrate_to_tx_control(priv, 1287 iwl_hwrate_to_tx_control(priv,
1296 le32_to_cpu(tx_resp->rate_n_flags), 1288 le32_to_cpu(tx_resp->rate_n_flags),
1297 info); 1289 info);
1298 1290
1299 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags " 1291 IWL_DEBUG_TX_REPLY("TXQ %d status %s (0x%08x) rate_n_flags "
1300 "0x%x retries %d\n", txq_id, 1292 "0x%x retries %d\n",
1301 iwl_get_tx_fail_reason(status), 1293 txq_id,
1302 status, le32_to_cpu(tx_resp->rate_n_flags), 1294 iwl_get_tx_fail_reason(status), status,
1303 tx_resp->failure_frame); 1295 le32_to_cpu(tx_resp->rate_n_flags),
1296 tx_resp->failure_frame);
1304 1297
1305 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 1298 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
1306 if (index != -1) { 1299 if (ieee80211_is_data_qos(tx_resp->frame_ctrl))
1307 int freed = iwl_tx_queue_reclaim(priv, txq_id, index);
1308 if (tid != MAX_TID_COUNT)
1309 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 1300 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
1310 if (iwl_queue_space(&txq->q) > txq->q.low_mark && 1301
1311 (txq_id >= 0) && priv->mac80211_registered) 1302 if (priv->mac80211_registered &&
1303 (iwl_queue_space(&txq->q) > txq->q.low_mark))
1312 ieee80211_wake_queue(priv->hw, txq_id); 1304 ieee80211_wake_queue(priv->hw, txq_id);
1313 if (tid != MAX_TID_COUNT)
1314 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
1315 }
1316 } 1305 }
1317 1306
1307 if (ieee80211_is_data_qos(tx_resp->frame_ctrl))
1308 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
1309
1318 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 1310 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
1319 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); 1311 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n");
1320} 1312}
1321 1313
1322/* Currently 5000 is the supperset of everything */ 1314/* Currently 5000 is the superset of everything */
1323static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len) 1315static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len)
1324{ 1316{
1325 return len; 1317 return len;
@@ -1482,13 +1474,13 @@ static struct iwl_lib_ops iwl5000_lib = {
1482 .alive_notify = iwl5000_alive_notify, 1474 .alive_notify = iwl5000_alive_notify,
1483 .send_tx_power = iwl5000_send_tx_power, 1475 .send_tx_power = iwl5000_send_tx_power,
1484 .temperature = iwl5000_temperature, 1476 .temperature = iwl5000_temperature,
1485 .update_chain_flags = iwl4965_update_chain_flags, 1477 .update_chain_flags = iwl_update_chain_flags,
1486 .apm_ops = { 1478 .apm_ops = {
1487 .init = iwl5000_apm_init, 1479 .init = iwl5000_apm_init,
1488 .reset = iwl5000_apm_reset, 1480 .reset = iwl5000_apm_reset,
1489 .stop = iwl5000_apm_stop, 1481 .stop = iwl5000_apm_stop,
1490 .config = iwl5000_nic_config, 1482 .config = iwl5000_nic_config,
1491 .set_pwr_src = iwl4965_set_pwr_src, 1483 .set_pwr_src = iwl_set_pwr_src,
1492 }, 1484 },
1493 .eeprom_ops = { 1485 .eeprom_ops = {
1494 .regulatory_bands = { 1486 .regulatory_bands = {
@@ -1503,7 +1495,7 @@ static struct iwl_lib_ops iwl5000_lib = {
1503 .verify_signature = iwlcore_eeprom_verify_signature, 1495 .verify_signature = iwlcore_eeprom_verify_signature,
1504 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, 1496 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
1505 .release_semaphore = iwlcore_eeprom_release_semaphore, 1497 .release_semaphore = iwlcore_eeprom_release_semaphore,
1506 .check_version = iwl5000_eeprom_check_version, 1498 .calib_version = iwl5000_eeprom_calib_version,
1507 .query_addr = iwl5000_eeprom_query_addr, 1499 .query_addr = iwl5000_eeprom_query_addr,
1508 }, 1500 },
1509}; 1501};
@@ -1526,50 +1518,60 @@ static struct iwl_mod_params iwl50_mod_params = {
1526 1518
1527struct iwl_cfg iwl5300_agn_cfg = { 1519struct iwl_cfg iwl5300_agn_cfg = {
1528 .name = "5300AGN", 1520 .name = "5300AGN",
1529 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode", 1521 .fw_name = IWL5000_MODULE_FIRMWARE,
1530 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 1522 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
1531 .ops = &iwl5000_ops, 1523 .ops = &iwl5000_ops,
1532 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1524 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1525 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1526 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1533 .mod_params = &iwl50_mod_params, 1527 .mod_params = &iwl50_mod_params,
1534}; 1528};
1535 1529
1536struct iwl_cfg iwl5100_bg_cfg = { 1530struct iwl_cfg iwl5100_bg_cfg = {
1537 .name = "5100BG", 1531 .name = "5100BG",
1538 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode", 1532 .fw_name = IWL5000_MODULE_FIRMWARE,
1539 .sku = IWL_SKU_G, 1533 .sku = IWL_SKU_G,
1540 .ops = &iwl5000_ops, 1534 .ops = &iwl5000_ops,
1541 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1535 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1536 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1537 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1542 .mod_params = &iwl50_mod_params, 1538 .mod_params = &iwl50_mod_params,
1543}; 1539};
1544 1540
1545struct iwl_cfg iwl5100_abg_cfg = { 1541struct iwl_cfg iwl5100_abg_cfg = {
1546 .name = "5100ABG", 1542 .name = "5100ABG",
1547 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode", 1543 .fw_name = IWL5000_MODULE_FIRMWARE,
1548 .sku = IWL_SKU_A|IWL_SKU_G, 1544 .sku = IWL_SKU_A|IWL_SKU_G,
1549 .ops = &iwl5000_ops, 1545 .ops = &iwl5000_ops,
1550 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1546 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1547 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1548 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1551 .mod_params = &iwl50_mod_params, 1549 .mod_params = &iwl50_mod_params,
1552}; 1550};
1553 1551
1554struct iwl_cfg iwl5100_agn_cfg = { 1552struct iwl_cfg iwl5100_agn_cfg = {
1555 .name = "5100AGN", 1553 .name = "5100AGN",
1556 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode", 1554 .fw_name = IWL5000_MODULE_FIRMWARE,
1557 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 1555 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
1558 .ops = &iwl5000_ops, 1556 .ops = &iwl5000_ops,
1559 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1557 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1558 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1559 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1560 .mod_params = &iwl50_mod_params, 1560 .mod_params = &iwl50_mod_params,
1561}; 1561};
1562 1562
1563struct iwl_cfg iwl5350_agn_cfg = { 1563struct iwl_cfg iwl5350_agn_cfg = {
1564 .name = "5350AGN", 1564 .name = "5350AGN",
1565 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode", 1565 .fw_name = IWL5000_MODULE_FIRMWARE,
1566 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 1566 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
1567 .ops = &iwl5000_ops, 1567 .ops = &iwl5000_ops,
1568 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1568 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1569 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1570 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
1569 .mod_params = &iwl50_mod_params, 1571 .mod_params = &iwl50_mod_params,
1570}; 1572};
1571 1573
1572MODULE_FIRMWARE("iwlwifi-5000" IWL5000_UCODE_API ".ucode"); 1574MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
1573 1575
1574module_param_named(disable50, iwl50_mod_params.disable, int, 0444); 1576module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
1575MODULE_PARM_DESC(disable50, 1577MODULE_PARM_DESC(disable50,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index e2a58e477036..0332805cc630 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -188,7 +188,7 @@ static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta,
188 * 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits 188 * 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits
189 * "G" is the only table that supports CCK (the first 4 rates). 189 * "G" is the only table that supports CCK (the first 4 rates).
190 */ 190 */
191/*FIXME:RS:need to spearate tables for MIMO2/MIMO3*/ 191/*FIXME:RS:need to separate tables for MIMO2/MIMO3*/
192static s32 expected_tpt_A[IWL_RATE_COUNT] = { 192static s32 expected_tpt_A[IWL_RATE_COUNT] = {
193 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186, 186 193 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186, 186
194}; 194};
@@ -357,11 +357,9 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
357 struct iwl_lq_sta *lq_data, u8 tid, 357 struct iwl_lq_sta *lq_data, u8 tid,
358 struct ieee80211_sta *sta) 358 struct ieee80211_sta *sta)
359{ 359{
360 DECLARE_MAC_BUF(mac);
361
362 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { 360 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) {
363 IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n", 361 IWL_DEBUG_HT("Starting Tx agg: STA: %pM tid: %d\n",
364 print_mac(mac, sta->addr), tid); 362 sta->addr, tid);
365 ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid); 363 ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid);
366 } 364 }
367} 365}
@@ -800,7 +798,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
800 !(info->flags & IEEE80211_TX_STAT_AMPDU)) 798 !(info->flags & IEEE80211_TX_STAT_AMPDU))
801 return; 799 return;
802 800
803 retries = info->status.retry_count; 801 retries = info->status.rates[0].count - 1;
804 802
805 if (retries > 15) 803 if (retries > 15)
806 retries = 15; 804 retries = 15;
@@ -832,20 +830,15 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
832 if (priv->band == IEEE80211_BAND_5GHZ) 830 if (priv->band == IEEE80211_BAND_5GHZ)
833 rs_index -= IWL_FIRST_OFDM_RATE; 831 rs_index -= IWL_FIRST_OFDM_RATE;
834 832
835 if ((info->tx_rate_idx < 0) || 833 if ((info->status.rates[0].idx < 0) ||
836 (tbl_type.is_SGI ^ 834 (tbl_type.is_SGI != !!(info->status.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)) ||
837 !!(info->flags & IEEE80211_TX_CTL_SHORT_GI)) || 835 (tbl_type.is_fat != !!(info->status.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)) ||
838 (tbl_type.is_fat ^ 836 (tbl_type.is_dup != !!(info->status.rates[0].flags & IEEE80211_TX_RC_DUP_DATA)) ||
839 !!(info->flags & IEEE80211_TX_CTL_40_MHZ_WIDTH)) || 837 (tbl_type.ant_type != info->antenna_sel_tx) ||
840 (tbl_type.is_dup ^ 838 (!!(tx_rate & RATE_MCS_HT_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_MCS)) ||
841 !!(info->flags & IEEE80211_TX_CTL_DUP_DATA)) || 839 (!!(tx_rate & RATE_MCS_GF_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)) ||
842 (tbl_type.ant_type ^ info->antenna_sel_tx) ||
843 (!!(tx_rate & RATE_MCS_HT_MSK) ^
844 !!(info->flags & IEEE80211_TX_CTL_OFDM_HT)) ||
845 (!!(tx_rate & RATE_MCS_GF_MSK) ^
846 !!(info->flags & IEEE80211_TX_CTL_GREEN_FIELD)) ||
847 (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate != 840 (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate !=
848 hw->wiphy->bands[info->band]->bitrates[info->tx_rate_idx].bitrate)) { 841 hw->wiphy->bands[info->band]->bitrates[info->status.rates[0].idx].bitrate)) {
849 IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate); 842 IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate);
850 goto out; 843 goto out;
851 } 844 }
@@ -1135,11 +1128,10 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1135 s32 rate; 1128 s32 rate;
1136 s8 is_green = lq_sta->is_green; 1129 s8 is_green = lq_sta->is_green;
1137 1130
1138 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || 1131 if (!conf->ht.enabled || !sta->ht_cap.ht_supported)
1139 !sta->ht_info.ht_supported)
1140 return -1; 1132 return -1;
1141 1133
1142 if (((sta->ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2) 1134 if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2)
1143 == WLAN_HT_CAP_SM_PS_STATIC) 1135 == WLAN_HT_CAP_SM_PS_STATIC)
1144 return -1; 1136 return -1;
1145 1137
@@ -1203,8 +1195,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1203 u8 is_green = lq_sta->is_green; 1195 u8 is_green = lq_sta->is_green;
1204 s32 rate; 1196 s32 rate;
1205 1197
1206 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || 1198 if (!conf->ht.enabled || !sta->ht_cap.ht_supported)
1207 !sta->ht_info.ht_supported)
1208 return -1; 1199 return -1;
1209 1200
1210 IWL_DEBUG_RATE("LQ: try to switch to SISO\n"); 1201 IWL_DEBUG_RATE("LQ: try to switch to SISO\n");
@@ -2003,9 +1994,8 @@ lq_update:
2003 * stay with best antenna legacy modulation for a while 1994 * stay with best antenna legacy modulation for a while
2004 * before next round of mode comparisons. */ 1995 * before next round of mode comparisons. */
2005 tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); 1996 tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]);
2006 if (is_legacy(tbl1->lq_type) && 1997 if (is_legacy(tbl1->lq_type) && !conf->ht.enabled &&
2007 (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE)) && 1998 lq_sta->action_counter >= 1) {
2008 (lq_sta->action_counter >= 1)) {
2009 lq_sta->action_counter = 0; 1999 lq_sta->action_counter = 0;
2010 IWL_DEBUG_RATE("LQ: STAY in legacy table\n"); 2000 IWL_DEBUG_RATE("LQ: STAY in legacy table\n");
2011 rs_set_stay_in_table(priv, 1, lq_sta); 2001 rs_set_stay_in_table(priv, 1, lq_sta);
@@ -2081,15 +2071,13 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2081 if ((i < 0) || (i >= IWL_RATE_COUNT)) 2071 if ((i < 0) || (i >= IWL_RATE_COUNT))
2082 i = 0; 2072 i = 0;
2083 2073
2084 /* FIXME:RS: This is also wrong in 4965 */
2085 rate = iwl_rates[i].plcp; 2074 rate = iwl_rates[i].plcp;
2086 rate |= RATE_MCS_ANT_B_MSK; 2075 tbl->ant_type = first_antenna(valid_tx_ant);
2087 rate &= ~RATE_MCS_ANT_A_MSK; 2076 rate |= tbl->ant_type << RATE_MCS_ANT_POS;
2088 2077
2089 if (i >= IWL_FIRST_CCK_RATE && i <= IWL_LAST_CCK_RATE) 2078 if (i >= IWL_FIRST_CCK_RATE && i <= IWL_LAST_CCK_RATE)
2090 rate |= RATE_MCS_CCK_MSK; 2079 rate |= RATE_MCS_CCK_MSK;
2091 2080
2092 tbl->ant_type = ANT_B;
2093 rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); 2081 rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx);
2094 if (!rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) 2082 if (!rs_is_valid_ant(valid_tx_ant, tbl->ant_type))
2095 rs_toggle_antenna(valid_tx_ant, &rate, tbl); 2083 rs_toggle_antenna(valid_tx_ant, &rate, tbl);
@@ -2103,15 +2091,17 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2103 return; 2091 return;
2104} 2092}
2105 2093
2106static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband, 2094static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2107 struct ieee80211_sta *sta, void *priv_sta, 2095 struct ieee80211_tx_rate_control *txrc)
2108 struct sk_buff *skb, struct rate_selection *sel)
2109{ 2096{
2110 2097
2111 int i; 2098 int i;
2099 struct sk_buff *skb = txrc->skb;
2100 struct ieee80211_supported_band *sband = txrc->sband;
2112 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 2101 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
2113 struct ieee80211_conf *conf = &priv->hw->conf; 2102 struct ieee80211_conf *conf = &priv->hw->conf;
2114 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 2103 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2104 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2115 __le16 fc; 2105 __le16 fc;
2116 struct iwl_lq_sta *lq_sta; 2106 struct iwl_lq_sta *lq_sta;
2117 2107
@@ -2122,7 +2112,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
2122 fc = hdr->frame_control; 2112 fc = hdr->frame_control;
2123 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || 2113 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) ||
2124 !sta || !priv_sta) { 2114 !sta || !priv_sta) {
2125 sel->rate_idx = rate_lowest_index(sband, sta); 2115 info->control.rates[0].idx = rate_lowest_index(sband, sta);
2126 return; 2116 return;
2127 } 2117 }
2128 2118
@@ -2132,11 +2122,10 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
2132 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && 2122 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
2133 !lq_sta->ibss_sta_added) { 2123 !lq_sta->ibss_sta_added) {
2134 u8 sta_id = iwl_find_station(priv, hdr->addr1); 2124 u8 sta_id = iwl_find_station(priv, hdr->addr1);
2135 DECLARE_MAC_BUF(mac);
2136 2125
2137 if (sta_id == IWL_INVALID_STATION) { 2126 if (sta_id == IWL_INVALID_STATION) {
2138 IWL_DEBUG_RATE("LQ: ADD station %s\n", 2127 IWL_DEBUG_RATE("LQ: ADD station %pM\n",
2139 print_mac(mac, hdr->addr1)); 2128 hdr->addr1);
2140 sta_id = iwl_add_station_flags(priv, hdr->addr1, 2129 sta_id = iwl_add_station_flags(priv, hdr->addr1,
2141 0, CMD_ASYNC, NULL); 2130 0, CMD_ASYNC, NULL);
2142 } 2131 }
@@ -2149,13 +2138,13 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
2149 } 2138 }
2150 2139
2151 if ((i < 0) || (i > IWL_RATE_COUNT)) { 2140 if ((i < 0) || (i > IWL_RATE_COUNT)) {
2152 sel->rate_idx = rate_lowest_index(sband, sta); 2141 info->control.rates[0].idx = rate_lowest_index(sband, sta);
2153 return; 2142 return;
2154 } 2143 }
2155 2144
2156 if (sband->band == IEEE80211_BAND_5GHZ) 2145 if (sband->band == IEEE80211_BAND_5GHZ)
2157 i -= IWL_FIRST_OFDM_RATE; 2146 i -= IWL_FIRST_OFDM_RATE;
2158 sel->rate_idx = i; 2147 info->control.rates[0].idx = i;
2159} 2148}
2160 2149
2161static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, 2150static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
@@ -2205,15 +2194,12 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2205 lq_sta->ibss_sta_added = 0; 2194 lq_sta->ibss_sta_added = 0;
2206 if (priv->iw_mode == NL80211_IFTYPE_AP) { 2195 if (priv->iw_mode == NL80211_IFTYPE_AP) {
2207 u8 sta_id = iwl_find_station(priv, sta->addr); 2196 u8 sta_id = iwl_find_station(priv, sta->addr);
2208 DECLARE_MAC_BUF(mac);
2209 2197
2210 /* for IBSS the call are from tasklet */ 2198 /* for IBSS the call are from tasklet */
2211 IWL_DEBUG_RATE("LQ: ADD station %s\n", 2199 IWL_DEBUG_RATE("LQ: ADD station %pM\n", sta->addr);
2212 print_mac(mac, sta->addr));
2213 2200
2214 if (sta_id == IWL_INVALID_STATION) { 2201 if (sta_id == IWL_INVALID_STATION) {
2215 IWL_DEBUG_RATE("LQ: ADD station %s\n", 2202 IWL_DEBUG_RATE("LQ: ADD station %pM\n", sta->addr);
2216 print_mac(mac, sta->addr));
2217 sta_id = iwl_add_station_flags(priv, sta->addr, 2203 sta_id = iwl_add_station_flags(priv, sta->addr,
2218 0, CMD_ASYNC, NULL); 2204 0, CMD_ASYNC, NULL);
2219 } 2205 }
@@ -2244,19 +2230,19 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2244 * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), 2230 * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3),
2245 * supp_rates[] does not; shift to convert format, force 9 MBits off. 2231 * supp_rates[] does not; shift to convert format, force 9 MBits off.
2246 */ 2232 */
2247 lq_sta->active_siso_rate = conf->ht_conf.supp_mcs_set[0] << 1; 2233 lq_sta->active_siso_rate = sta->ht_cap.mcs.rx_mask[0] << 1;
2248 lq_sta->active_siso_rate |= conf->ht_conf.supp_mcs_set[0] & 0x1; 2234 lq_sta->active_siso_rate |= sta->ht_cap.mcs.rx_mask[0] & 0x1;
2249 lq_sta->active_siso_rate &= ~((u16)0x2); 2235 lq_sta->active_siso_rate &= ~((u16)0x2);
2250 lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE; 2236 lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE;
2251 2237
2252 /* Same here */ 2238 /* Same here */
2253 lq_sta->active_mimo2_rate = conf->ht_conf.supp_mcs_set[1] << 1; 2239 lq_sta->active_mimo2_rate = sta->ht_cap.mcs.rx_mask[1] << 1;
2254 lq_sta->active_mimo2_rate |= conf->ht_conf.supp_mcs_set[1] & 0x1; 2240 lq_sta->active_mimo2_rate |= sta->ht_cap.mcs.rx_mask[1] & 0x1;
2255 lq_sta->active_mimo2_rate &= ~((u16)0x2); 2241 lq_sta->active_mimo2_rate &= ~((u16)0x2);
2256 lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE; 2242 lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE;
2257 2243
2258 lq_sta->active_mimo3_rate = conf->ht_conf.supp_mcs_set[2] << 1; 2244 lq_sta->active_mimo3_rate = sta->ht_cap.mcs.rx_mask[2] << 1;
2259 lq_sta->active_mimo3_rate |= conf->ht_conf.supp_mcs_set[2] & 0x1; 2245 lq_sta->active_mimo3_rate |= sta->ht_cap.mcs.rx_mask[2] & 0x1;
2260 lq_sta->active_mimo3_rate &= ~((u16)0x2); 2246 lq_sta->active_mimo3_rate &= ~((u16)0x2);
2261 lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE; 2247 lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE;
2262 2248
@@ -2265,7 +2251,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2265 lq_sta->active_mimo2_rate, 2251 lq_sta->active_mimo2_rate,
2266 lq_sta->active_mimo3_rate); 2252 lq_sta->active_mimo3_rate);
2267 2253
2268 /* These values will be overriden later */ 2254 /* These values will be overridden later */
2269 lq_sta->lq.general_params.single_stream_ant_msk = ANT_A; 2255 lq_sta->lq.general_params.single_stream_ant_msk = ANT_A;
2270 lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; 2256 lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB;
2271 2257
@@ -2405,19 +2391,6 @@ static void rs_free(void *priv_rate)
2405 return; 2391 return;
2406} 2392}
2407 2393
2408static void rs_clear(void *priv_rate)
2409{
2410#ifdef CONFIG_IWLWIFI_DEBUG
2411 struct iwl_priv *priv = (struct iwl_priv *) priv_rate;
2412
2413 IWL_DEBUG_RATE("enter\n");
2414
2415 /* TODO - add rate scale state reset */
2416
2417 IWL_DEBUG_RATE("leave\n");
2418#endif /* CONFIG_IWLWIFI_DEBUG */
2419}
2420
2421static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta, 2394static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
2422 void *priv_sta) 2395 void *priv_sta)
2423{ 2396{
@@ -2605,7 +2578,6 @@ static struct rate_control_ops rs_ops = {
2605 .tx_status = rs_tx_status, 2578 .tx_status = rs_tx_status,
2606 .get_rate = rs_get_rate, 2579 .get_rate = rs_get_rate,
2607 .rate_init = rs_rate_init, 2580 .rate_init = rs_rate_init,
2608 .clear = rs_clear,
2609 .alloc = rs_alloc, 2581 .alloc = rs_alloc,
2610 .free = rs_free, 2582 .free = rs_free,
2611 .alloc_sta = rs_alloc_sta, 2583 .alloc_sta = rs_alloc_sta,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index d148d73635eb..adcbf538ed54 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -229,7 +229,7 @@ enum {
229#define IWL_MIMO2_SWITCH_SISO_C 4 229#define IWL_MIMO2_SWITCH_SISO_C 4
230#define IWL_MIMO2_SWITCH_GI 5 230#define IWL_MIMO2_SWITCH_GI 5
231 231
232/*FIXME:RS:add posible acctions for MIMO3*/ 232/*FIXME:RS:add possible actions for MIMO3*/
233 233
234#define IWL_ACTION_LIMIT 3 /* # possible actions */ 234#define IWL_ACTION_LIMIT 3 /* # possible actions */
235 235
@@ -284,7 +284,17 @@ static inline u8 num_of_ant(u8 mask)
284 !!((mask) & ANT_C); 284 !!((mask) & ANT_C);
285} 285}
286 286
287static inline u8 iwl4965_get_prev_ieee_rate(u8 rate_index) 287static inline u8 first_antenna(u8 mask)
288{
289 if (mask & ANT_A)
290 return ANT_A;
291 if (mask & ANT_B)
292 return ANT_B;
293 return ANT_C;
294}
295
296
297static inline u8 iwl_get_prev_ieee_rate(u8 rate_index)
288{ 298{
289 u8 rate = iwl_rates[rate_index].prev_ieee; 299 u8 rate = iwl_rates[rate_index].prev_ieee;
290 300
@@ -294,11 +304,11 @@ static inline u8 iwl4965_get_prev_ieee_rate(u8 rate_index)
294} 304}
295 305
296/** 306/**
297 * iwl4965_rate_control_register - Register the rate control algorithm callbacks 307 * iwl_rate_control_register - Register the rate control algorithm callbacks
298 * 308 *
299 * Since the rate control algorithm is hardware specific, there is no need 309 * Since the rate control algorithm is hardware specific, there is no need
300 * or reason to place it as a stand alone module. The driver can call 310 * or reason to place it as a stand alone module. The driver can call
301 * iwl4965_rate_control_register in order to register the rate control callbacks 311 * iwl_rate_control_register in order to register the rate control callbacks
302 * with the mac80211 subsystem. This should be performed prior to calling 312 * with the mac80211 subsystem. This should be performed prior to calling
303 * ieee80211_register_hw 313 * ieee80211_register_hw
304 * 314 *
@@ -306,7 +316,7 @@ static inline u8 iwl4965_get_prev_ieee_rate(u8 rate_index)
306extern int iwlagn_rate_control_register(void); 316extern int iwlagn_rate_control_register(void);
307 317
308/** 318/**
309 * iwl4965_rate_control_unregister - Unregister the rate control callbacks 319 * iwl_rate_control_unregister - Unregister the rate control callbacks
310 * 320 *
311 * This should be called after calling ieee80211_unregister_hw, but before 321 * This should be called after calling ieee80211_unregister_hw, but before
312 * the driver is unloaded. 322 * the driver is unloaded.
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 8d690a0eb1a9..8264d3742d08 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -96,7 +96,7 @@ MODULE_ALIAS("iwl4965");
96 96
97 97
98 98
99static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) 99static void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
100{ 100{
101 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 101 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
102 102
@@ -108,13 +108,13 @@ static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
108} 108}
109 109
110/** 110/**
111 * iwl4965_check_rxon_cmd - validate RXON structure is valid 111 * iwl_check_rxon_cmd - validate RXON structure is valid
112 * 112 *
113 * NOTE: This is really only useful during development and can eventually 113 * NOTE: This is really only useful during development and can eventually
114 * be #ifdef'd out once the driver is stable and folks aren't actively 114 * be #ifdef'd out once the driver is stable and folks aren't actively
115 * making changes 115 * making changes
116 */ 116 */
117static int iwl4965_check_rxon_cmd(struct iwl_rxon_cmd *rxon) 117static int iwl_check_rxon_cmd(struct iwl_rxon_cmd *rxon)
118{ 118{
119 int error = 0; 119 int error = 0;
120 int counter = 1; 120 int counter = 1;
@@ -174,7 +174,7 @@ static int iwl4965_check_rxon_cmd(struct iwl_rxon_cmd *rxon)
174 le16_to_cpu(rxon->channel)); 174 le16_to_cpu(rxon->channel));
175 175
176 if (error) { 176 if (error) {
177 IWL_ERROR("Not a valid iwl4965_rxon_assoc_cmd field values\n"); 177 IWL_ERROR("Not a valid iwl_rxon_assoc_cmd field values\n");
178 return -1; 178 return -1;
179 } 179 }
180 return 0; 180 return 0;
@@ -228,18 +228,17 @@ static int iwl_full_rxon_required(struct iwl_priv *priv)
228} 228}
229 229
230/** 230/**
231 * iwl4965_commit_rxon - commit staging_rxon to hardware 231 * iwl_commit_rxon - commit staging_rxon to hardware
232 * 232 *
233 * The RXON command in staging_rxon is committed to the hardware and 233 * The RXON command in staging_rxon is committed to the hardware and
234 * the active_rxon structure is updated with the new data. This 234 * the active_rxon structure is updated with the new data. This
235 * function correctly transitions out of the RXON_ASSOC_MSK state if 235 * function correctly transitions out of the RXON_ASSOC_MSK state if
236 * a HW tune is required based on the RXON structure changes. 236 * a HW tune is required based on the RXON structure changes.
237 */ 237 */
238static int iwl4965_commit_rxon(struct iwl_priv *priv) 238static int iwl_commit_rxon(struct iwl_priv *priv)
239{ 239{
240 /* cast away the const for active_rxon in this function */ 240 /* cast away the const for active_rxon in this function */
241 struct iwl_rxon_cmd *active_rxon = (void *)&priv->active_rxon; 241 struct iwl_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
242 DECLARE_MAC_BUF(mac);
243 int ret; 242 int ret;
244 bool new_assoc = 243 bool new_assoc =
245 !!(priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK); 244 !!(priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK);
@@ -253,14 +252,14 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
253 * 5000, but will not damage 4965 */ 252 * 5000, but will not damage 4965 */
254 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN; 253 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN;
255 254
256 ret = iwl4965_check_rxon_cmd(&priv->staging_rxon); 255 ret = iwl_check_rxon_cmd(&priv->staging_rxon);
257 if (ret) { 256 if (ret) {
258 IWL_ERROR("Invalid RXON configuration. Not committing.\n"); 257 IWL_ERROR("Invalid RXON configuration. Not committing.\n");
259 return -EINVAL; 258 return -EINVAL;
260 } 259 }
261 260
262 /* If we don't need to send a full RXON, we can use 261 /* If we don't need to send a full RXON, we can use
263 * iwl4965_rxon_assoc_cmd which is used to reconfigure filter 262 * iwl_rxon_assoc_cmd which is used to reconfigure filter
264 * and other flags for the current radio configuration. */ 263 * and other flags for the current radio configuration. */
265 if (!iwl_full_rxon_required(priv)) { 264 if (!iwl_full_rxon_required(priv)) {
266 ret = iwl_send_rxon_assoc(priv); 265 ret = iwl_send_rxon_assoc(priv);
@@ -300,12 +299,12 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
300 IWL_DEBUG_INFO("Sending RXON\n" 299 IWL_DEBUG_INFO("Sending RXON\n"
301 "* with%s RXON_FILTER_ASSOC_MSK\n" 300 "* with%s RXON_FILTER_ASSOC_MSK\n"
302 "* channel = %d\n" 301 "* channel = %d\n"
303 "* bssid = %s\n", 302 "* bssid = %pM\n",
304 (new_assoc ? "" : "out"), 303 (new_assoc ? "" : "out"),
305 le16_to_cpu(priv->staging_rxon.channel), 304 le16_to_cpu(priv->staging_rxon.channel),
306 print_mac(mac, priv->staging_rxon.bssid_addr)); 305 priv->staging_rxon.bssid_addr);
307 306
308 iwl4965_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto); 307 iwl_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto);
309 308
310 /* Apply the new configuration 309 /* Apply the new configuration
311 * RXON unassoc clears the station table in uCode, send it before 310 * RXON unassoc clears the station table in uCode, send it before
@@ -375,14 +374,14 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
375 return 0; 374 return 0;
376} 375}
377 376
378void iwl4965_update_chain_flags(struct iwl_priv *priv) 377void iwl_update_chain_flags(struct iwl_priv *priv)
379{ 378{
380 379
381 iwl_set_rxon_chain(priv); 380 iwl_set_rxon_chain(priv);
382 iwl4965_commit_rxon(priv); 381 iwl_commit_rxon(priv);
383} 382}
384 383
385static int iwl4965_send_bt_config(struct iwl_priv *priv) 384static int iwl_send_bt_config(struct iwl_priv *priv)
386{ 385{
387 struct iwl4965_bt_cmd bt_cmd = { 386 struct iwl4965_bt_cmd bt_cmd = {
388 .flags = 3, 387 .flags = 3,
@@ -460,7 +459,7 @@ static unsigned int iwl_fill_beacon_frame(struct iwl_priv *priv,
460 return priv->ibss_beacon->len; 459 return priv->ibss_beacon->len;
461} 460}
462 461
463static u8 iwl4965_rate_get_lowest_plcp(struct iwl_priv *priv) 462static u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv)
464{ 463{
465 int i; 464 int i;
466 int rate_mask; 465 int rate_mask;
@@ -485,7 +484,7 @@ static u8 iwl4965_rate_get_lowest_plcp(struct iwl_priv *priv)
485 return IWL_RATE_6M_PLCP; 484 return IWL_RATE_6M_PLCP;
486} 485}
487 486
488static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, 487static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
489 struct iwl_frame *frame, u8 rate) 488 struct iwl_frame *frame, u8 rate)
490{ 489{
491 struct iwl_tx_beacon_cmd *tx_beacon_cmd; 490 struct iwl_tx_beacon_cmd *tx_beacon_cmd;
@@ -517,7 +516,7 @@ static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
517 516
518 return sizeof(*tx_beacon_cmd) + frame_size; 517 return sizeof(*tx_beacon_cmd) + frame_size;
519} 518}
520static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) 519static int iwl_send_beacon_cmd(struct iwl_priv *priv)
521{ 520{
522 struct iwl_frame *frame; 521 struct iwl_frame *frame;
523 unsigned int frame_size; 522 unsigned int frame_size;
@@ -532,9 +531,9 @@ static int iwl4965_send_beacon_cmd(struct iwl_priv *priv)
532 return -ENOMEM; 531 return -ENOMEM;
533 } 532 }
534 533
535 rate = iwl4965_rate_get_lowest_plcp(priv); 534 rate = iwl_rate_get_lowest_plcp(priv);
536 535
537 frame_size = iwl4965_hw_get_beacon_cmd(priv, frame, rate); 536 frame_size = iwl_hw_get_beacon_cmd(priv, frame, rate);
538 537
539 rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, 538 rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size,
540 &frame->u.cmd[0]); 539 &frame->u.cmd[0]);
@@ -550,20 +549,33 @@ static int iwl4965_send_beacon_cmd(struct iwl_priv *priv)
550 * 549 *
551 ******************************************************************************/ 550 ******************************************************************************/
552 551
553static void iwl4965_ht_conf(struct iwl_priv *priv, 552static void iwl_ht_conf(struct iwl_priv *priv,
554 struct ieee80211_bss_conf *bss_conf) 553 struct ieee80211_bss_conf *bss_conf)
555{ 554{
556 struct ieee80211_ht_info *ht_conf = bss_conf->ht_conf; 555 struct ieee80211_sta_ht_cap *ht_conf;
557 struct ieee80211_ht_bss_info *ht_bss_conf = bss_conf->ht_bss_conf;
558 struct iwl_ht_info *iwl_conf = &priv->current_ht_config; 556 struct iwl_ht_info *iwl_conf = &priv->current_ht_config;
557 struct ieee80211_sta *sta;
559 558
560 IWL_DEBUG_MAC80211("enter: \n"); 559 IWL_DEBUG_MAC80211("enter: \n");
561 560
562 iwl_conf->is_ht = bss_conf->assoc_ht;
563
564 if (!iwl_conf->is_ht) 561 if (!iwl_conf->is_ht)
565 return; 562 return;
566 563
564
565 /*
566 * It is totally wrong to base global information on something
567 * that is valid only when associated, alas, this driver works
568 * that way and I don't know how to fix it.
569 */
570
571 rcu_read_lock();
572 sta = ieee80211_find_sta(priv->hw, priv->bssid);
573 if (!sta) {
574 rcu_read_unlock();
575 return;
576 }
577 ht_conf = &sta->ht_cap;
578
567 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20) 579 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20)
568 iwl_conf->sgf |= HT_SHORT_GI_20MHZ; 580 iwl_conf->sgf |= HT_SHORT_GI_20MHZ;
569 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40) 581 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40)
@@ -574,29 +586,28 @@ static void iwl4965_ht_conf(struct iwl_priv *priv,
574 !!(ht_conf->cap & IEEE80211_HT_CAP_MAX_AMSDU); 586 !!(ht_conf->cap & IEEE80211_HT_CAP_MAX_AMSDU);
575 587
576 iwl_conf->supported_chan_width = 588 iwl_conf->supported_chan_width =
577 !!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH); 589 !!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
578 iwl_conf->extension_chan_offset = 590
579 ht_bss_conf->bss_cap & IEEE80211_HT_IE_CHA_SEC_OFFSET; 591 iwl_conf->extension_chan_offset = bss_conf->ht.secondary_channel_offset;
580 /* If no above or below channel supplied disable FAT channel */ 592 /* If no above or below channel supplied disable FAT channel */
581 if (iwl_conf->extension_chan_offset != IEEE80211_HT_IE_CHA_SEC_ABOVE && 593 if (iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_ABOVE &&
582 iwl_conf->extension_chan_offset != IEEE80211_HT_IE_CHA_SEC_BELOW) { 594 iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_BELOW) {
583 iwl_conf->extension_chan_offset = IEEE80211_HT_IE_CHA_SEC_NONE; 595 iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
584 iwl_conf->supported_chan_width = 0; 596 iwl_conf->supported_chan_width = 0;
585 } 597 }
586 598
587 iwl_conf->sm_ps = (u8)((ht_conf->cap & IEEE80211_HT_CAP_SM_PS) >> 2); 599 iwl_conf->sm_ps = (u8)((ht_conf->cap & IEEE80211_HT_CAP_SM_PS) >> 2);
588 600
589 memcpy(iwl_conf->supp_mcs_set, ht_conf->supp_mcs_set, 16); 601 memcpy(&iwl_conf->mcs, &ht_conf->mcs, 16);
590 602
591 iwl_conf->control_channel = ht_bss_conf->primary_channel; 603 iwl_conf->tx_chan_width = bss_conf->ht.width_40_ok;
592 iwl_conf->tx_chan_width =
593 !!(ht_bss_conf->bss_cap & IEEE80211_HT_IE_CHA_WIDTH);
594 iwl_conf->ht_protection = 604 iwl_conf->ht_protection =
595 ht_bss_conf->bss_op_mode & IEEE80211_HT_IE_HT_PROTECTION; 605 bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
596 iwl_conf->non_GF_STA_present = 606 iwl_conf->non_GF_STA_present =
597 !!(ht_bss_conf->bss_op_mode & IEEE80211_HT_IE_NON_GF_STA_PRSNT); 607 !!(bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
608
609 rcu_read_unlock();
598 610
599 IWL_DEBUG_MAC80211("control channel %d\n", iwl_conf->control_channel);
600 IWL_DEBUG_MAC80211("leave\n"); 611 IWL_DEBUG_MAC80211("leave\n");
601} 612}
602 613
@@ -637,23 +648,22 @@ static void iwl_activate_qos(struct iwl_priv *priv, u8 force)
637 648
638#define MAX_UCODE_BEACON_INTERVAL 4096 649#define MAX_UCODE_BEACON_INTERVAL 4096
639 650
640static __le16 iwl4965_adjust_beacon_interval(u16 beacon_val) 651static u16 iwl_adjust_beacon_interval(u16 beacon_val)
641{ 652{
642 u16 new_val = 0; 653 u16 new_val = 0;
643 u16 beacon_factor = 0; 654 u16 beacon_factor = 0;
644 655
645 beacon_factor = 656 beacon_factor = (beacon_val + MAX_UCODE_BEACON_INTERVAL)
646 (beacon_val + MAX_UCODE_BEACON_INTERVAL) 657 / MAX_UCODE_BEACON_INTERVAL;
647 / MAX_UCODE_BEACON_INTERVAL;
648 new_val = beacon_val / beacon_factor; 658 new_val = beacon_val / beacon_factor;
649 659
650 return cpu_to_le16(new_val); 660 return new_val;
651} 661}
652 662
653static void iwl4965_setup_rxon_timing(struct iwl_priv *priv) 663static void iwl_setup_rxon_timing(struct iwl_priv *priv)
654{ 664{
655 u64 interval_tm_unit; 665 u64 tsf;
656 u64 tsf, result; 666 s32 interval_tm, rem;
657 unsigned long flags; 667 unsigned long flags;
658 struct ieee80211_conf *conf = NULL; 668 struct ieee80211_conf *conf = NULL;
659 u16 beacon_int = 0; 669 u16 beacon_int = 0;
@@ -661,49 +671,32 @@ static void iwl4965_setup_rxon_timing(struct iwl_priv *priv)
661 conf = ieee80211_get_hw_conf(priv->hw); 671 conf = ieee80211_get_hw_conf(priv->hw);
662 672
663 spin_lock_irqsave(&priv->lock, flags); 673 spin_lock_irqsave(&priv->lock, flags);
664 priv->rxon_timing.timestamp.dw[1] = cpu_to_le32(priv->timestamp >> 32); 674 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
665 priv->rxon_timing.timestamp.dw[0] =
666 cpu_to_le32(priv->timestamp & 0xFFFFFFFF);
667
668 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval); 675 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval);
669 676
670 tsf = priv->timestamp;
671
672 beacon_int = priv->beacon_int;
673 spin_unlock_irqrestore(&priv->lock, flags);
674
675 if (priv->iw_mode == NL80211_IFTYPE_STATION) { 677 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
676 if (beacon_int == 0) { 678 beacon_int = iwl_adjust_beacon_interval(priv->beacon_int);
677 priv->rxon_timing.beacon_interval = cpu_to_le16(100);
678 priv->rxon_timing.beacon_init_val = cpu_to_le32(102400);
679 } else {
680 priv->rxon_timing.beacon_interval =
681 cpu_to_le16(beacon_int);
682 priv->rxon_timing.beacon_interval =
683 iwl4965_adjust_beacon_interval(
684 le16_to_cpu(priv->rxon_timing.beacon_interval));
685 }
686
687 priv->rxon_timing.atim_window = 0; 679 priv->rxon_timing.atim_window = 0;
688 } else { 680 } else {
689 priv->rxon_timing.beacon_interval = 681 beacon_int = iwl_adjust_beacon_interval(conf->beacon_int);
690 iwl4965_adjust_beacon_interval(conf->beacon_int); 682
691 /* TODO: we need to get atim_window from upper stack 683 /* TODO: we need to get atim_window from upper stack
692 * for now we set to 0 */ 684 * for now we set to 0 */
693 priv->rxon_timing.atim_window = 0; 685 priv->rxon_timing.atim_window = 0;
694 } 686 }
695 687
696 interval_tm_unit = 688 priv->rxon_timing.beacon_interval = cpu_to_le16(beacon_int);
697 (le16_to_cpu(priv->rxon_timing.beacon_interval) * 1024); 689
698 result = do_div(tsf, interval_tm_unit); 690 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */
699 priv->rxon_timing.beacon_init_val = 691 interval_tm = beacon_int * 1024;
700 cpu_to_le32((u32) ((u64) interval_tm_unit - result)); 692 rem = do_div(tsf, interval_tm);
693 priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
701 694
702 IWL_DEBUG_ASSOC 695 spin_unlock_irqrestore(&priv->lock, flags);
703 ("beacon interval %d beacon timer %d beacon tim %d\n", 696 IWL_DEBUG_ASSOC("beacon interval %d beacon timer %d beacon tim %d\n",
704 le16_to_cpu(priv->rxon_timing.beacon_interval), 697 le16_to_cpu(priv->rxon_timing.beacon_interval),
705 le32_to_cpu(priv->rxon_timing.beacon_init_val), 698 le32_to_cpu(priv->rxon_timing.beacon_init_val),
706 le16_to_cpu(priv->rxon_timing.atim_window)); 699 le16_to_cpu(priv->rxon_timing.atim_window));
707} 700}
708 701
709static void iwl_set_flags_for_band(struct iwl_priv *priv, 702static void iwl_set_flags_for_band(struct iwl_priv *priv,
@@ -715,7 +708,7 @@ static void iwl_set_flags_for_band(struct iwl_priv *priv,
715 | RXON_FLG_CCK_MSK); 708 | RXON_FLG_CCK_MSK);
716 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 709 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
717 } else { 710 } else {
718 /* Copied from iwl4965_post_associate() */ 711 /* Copied from iwl_post_associate() */
719 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 712 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
720 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 713 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
721 else 714 else
@@ -733,13 +726,13 @@ static void iwl_set_flags_for_band(struct iwl_priv *priv,
733/* 726/*
734 * initialize rxon structure with default values from eeprom 727 * initialize rxon structure with default values from eeprom
735 */ 728 */
736static void iwl4965_connection_init_rx_config(struct iwl_priv *priv) 729static void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
737{ 730{
738 const struct iwl_channel_info *ch_info; 731 const struct iwl_channel_info *ch_info;
739 732
740 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 733 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
741 734
742 switch (priv->iw_mode) { 735 switch (mode) {
743 case NL80211_IFTYPE_AP: 736 case NL80211_IFTYPE_AP:
744 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP; 737 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
745 break; 738 break;
@@ -762,7 +755,7 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
762 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK; 755 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
763 break; 756 break;
764 default: 757 default:
765 IWL_ERROR("Unsupported interface type %d\n", priv->iw_mode); 758 IWL_ERROR("Unsupported interface type %d\n", mode);
766 break; 759 break;
767 } 760 }
768 761
@@ -808,11 +801,9 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
808 iwl_set_rxon_chain(priv); 801 iwl_set_rxon_chain(priv);
809} 802}
810 803
811static int iwl4965_set_mode(struct iwl_priv *priv, int mode) 804static int iwl_set_mode(struct iwl_priv *priv, int mode)
812{ 805{
813 priv->iw_mode = mode; 806 iwl_connection_init_rx_config(priv, mode);
814
815 iwl4965_connection_init_rx_config(priv);
816 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 807 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
817 808
818 iwl_clear_stations_table(priv); 809 iwl_clear_stations_table(priv);
@@ -828,12 +819,12 @@ static int iwl4965_set_mode(struct iwl_priv *priv, int mode)
828 return -EAGAIN; 819 return -EAGAIN;
829 } 820 }
830 821
831 iwl4965_commit_rxon(priv); 822 iwl_commit_rxon(priv);
832 823
833 return 0; 824 return 0;
834} 825}
835 826
836static void iwl4965_set_rate(struct iwl_priv *priv) 827static void iwl_set_rate(struct iwl_priv *priv)
837{ 828{
838 const struct ieee80211_supported_band *hw = NULL; 829 const struct ieee80211_supported_band *hw = NULL;
839 struct ieee80211_rate *rate; 830 struct ieee80211_rate *rate;
@@ -895,7 +886,7 @@ static void iwl4965_set_rate(struct iwl_priv *priv)
895 * the lower 3 bytes is the time in usec within one beacon interval 886 * the lower 3 bytes is the time in usec within one beacon interval
896 */ 887 */
897 888
898static u32 iwl4965_usecs_to_beacons(u32 usec, u32 beacon_interval) 889static u32 iwl_usecs_to_beacons(u32 usec, u32 beacon_interval)
899{ 890{
900 u32 quot; 891 u32 quot;
901 u32 rem; 892 u32 rem;
@@ -914,7 +905,7 @@ static u32 iwl4965_usecs_to_beacons(u32 usec, u32 beacon_interval)
914 * the same as HW timer counter counting down 905 * the same as HW timer counter counting down
915 */ 906 */
916 907
917static __le32 iwl4965_add_beacon_time(u32 base, u32 addon, u32 beacon_interval) 908static __le32 iwl_add_beacon_time(u32 base, u32 addon, u32 beacon_interval)
918{ 909{
919 u32 base_low = base & BEACON_TIME_MASK_LOW; 910 u32 base_low = base & BEACON_TIME_MASK_LOW;
920 u32 addon_low = addon & BEACON_TIME_MASK_LOW; 911 u32 addon_low = addon & BEACON_TIME_MASK_LOW;
@@ -933,7 +924,7 @@ static __le32 iwl4965_add_beacon_time(u32 base, u32 addon, u32 beacon_interval)
933 return cpu_to_le32(res); 924 return cpu_to_le32(res);
934} 925}
935 926
936static int iwl4965_get_measurement(struct iwl_priv *priv, 927static int iwl_get_measurement(struct iwl_priv *priv,
937 struct ieee80211_measurement_params *params, 928 struct ieee80211_measurement_params *params,
938 u8 type) 929 u8 type)
939{ 930{
@@ -951,7 +942,7 @@ static int iwl4965_get_measurement(struct iwl_priv *priv,
951 942
952 if (iwl_is_associated(priv)) 943 if (iwl_is_associated(priv))
953 add_time = 944 add_time =
954 iwl4965_usecs_to_beacons( 945 iwl_usecs_to_beacons(
955 le64_to_cpu(params->start_time) - priv->last_tsf, 946 le64_to_cpu(params->start_time) - priv->last_tsf,
956 le16_to_cpu(priv->rxon_timing.beacon_interval)); 947 le16_to_cpu(priv->rxon_timing.beacon_interval));
957 948
@@ -966,7 +957,7 @@ static int iwl4965_get_measurement(struct iwl_priv *priv,
966 957
967 if (iwl_is_associated(priv)) 958 if (iwl_is_associated(priv))
968 spectrum.start_time = 959 spectrum.start_time =
969 iwl4965_add_beacon_time(priv->last_beacon_time, 960 iwl_add_beacon_time(priv->last_beacon_time,
970 add_time, 961 add_time,
971 le16_to_cpu(priv->rxon_timing.beacon_interval)); 962 le16_to_cpu(priv->rxon_timing.beacon_interval));
972 else 963 else
@@ -1054,7 +1045,7 @@ static void iwl_rx_reply_alive(struct iwl_priv *priv,
1054 IWL_WARNING("uCode did not respond OK.\n"); 1045 IWL_WARNING("uCode did not respond OK.\n");
1055} 1046}
1056 1047
1057static void iwl4965_rx_reply_error(struct iwl_priv *priv, 1048static void iwl_rx_reply_error(struct iwl_priv *priv,
1058 struct iwl_rx_mem_buffer *rxb) 1049 struct iwl_rx_mem_buffer *rxb)
1059{ 1050{
1060 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1051 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
@@ -1070,7 +1061,7 @@ static void iwl4965_rx_reply_error(struct iwl_priv *priv,
1070 1061
1071#define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x 1062#define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x
1072 1063
1073static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) 1064static void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1074{ 1065{
1075 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1066 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
1076 struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon; 1067 struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon;
@@ -1081,7 +1072,7 @@ static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1081 priv->staging_rxon.channel = csa->channel; 1072 priv->staging_rxon.channel = csa->channel;
1082} 1073}
1083 1074
1084static void iwl4965_rx_spectrum_measure_notif(struct iwl_priv *priv, 1075static void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv,
1085 struct iwl_rx_mem_buffer *rxb) 1076 struct iwl_rx_mem_buffer *rxb)
1086{ 1077{
1087#ifdef CONFIG_IWLAGN_SPECTRUM_MEASUREMENT 1078#ifdef CONFIG_IWLAGN_SPECTRUM_MEASUREMENT
@@ -1099,7 +1090,7 @@ static void iwl4965_rx_spectrum_measure_notif(struct iwl_priv *priv,
1099#endif 1090#endif
1100} 1091}
1101 1092
1102static void iwl4965_rx_pm_sleep_notif(struct iwl_priv *priv, 1093static void iwl_rx_pm_sleep_notif(struct iwl_priv *priv,
1103 struct iwl_rx_mem_buffer *rxb) 1094 struct iwl_rx_mem_buffer *rxb)
1104{ 1095{
1105#ifdef CONFIG_IWLWIFI_DEBUG 1096#ifdef CONFIG_IWLWIFI_DEBUG
@@ -1110,7 +1101,7 @@ static void iwl4965_rx_pm_sleep_notif(struct iwl_priv *priv,
1110#endif 1101#endif
1111} 1102}
1112 1103
1113static void iwl4965_rx_pm_debug_statistics_notif(struct iwl_priv *priv, 1104static void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
1114 struct iwl_rx_mem_buffer *rxb) 1105 struct iwl_rx_mem_buffer *rxb)
1115{ 1106{
1116 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1107 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
@@ -1120,7 +1111,7 @@ static void iwl4965_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
1120 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len)); 1111 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len));
1121} 1112}
1122 1113
1123static void iwl4965_bg_beacon_update(struct work_struct *work) 1114static void iwl_bg_beacon_update(struct work_struct *work)
1124{ 1115{
1125 struct iwl_priv *priv = 1116 struct iwl_priv *priv =
1126 container_of(work, struct iwl_priv, beacon_update); 1117 container_of(work, struct iwl_priv, beacon_update);
@@ -1142,11 +1133,11 @@ static void iwl4965_bg_beacon_update(struct work_struct *work)
1142 priv->ibss_beacon = beacon; 1133 priv->ibss_beacon = beacon;
1143 mutex_unlock(&priv->mutex); 1134 mutex_unlock(&priv->mutex);
1144 1135
1145 iwl4965_send_beacon_cmd(priv); 1136 iwl_send_beacon_cmd(priv);
1146} 1137}
1147 1138
1148/** 1139/**
1149 * iwl4965_bg_statistics_periodic - Timer callback to queue statistics 1140 * iwl_bg_statistics_periodic - Timer callback to queue statistics
1150 * 1141 *
1151 * This callback is provided in order to send a statistics request. 1142 * This callback is provided in order to send a statistics request.
1152 * 1143 *
@@ -1155,17 +1146,21 @@ static void iwl4965_bg_beacon_update(struct work_struct *work)
1155 * was received. We need to ensure we receive the statistics in order 1146 * was received. We need to ensure we receive the statistics in order
1156 * to update the temperature used for calibrating the TXPOWER. 1147 * to update the temperature used for calibrating the TXPOWER.
1157 */ 1148 */
1158static void iwl4965_bg_statistics_periodic(unsigned long data) 1149static void iwl_bg_statistics_periodic(unsigned long data)
1159{ 1150{
1160 struct iwl_priv *priv = (struct iwl_priv *)data; 1151 struct iwl_priv *priv = (struct iwl_priv *)data;
1161 1152
1162 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 1153 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1163 return; 1154 return;
1164 1155
1156 /* dont send host command if rf-kill is on */
1157 if (!iwl_is_ready_rf(priv))
1158 return;
1159
1165 iwl_send_statistics_request(priv, CMD_ASYNC); 1160 iwl_send_statistics_request(priv, CMD_ASYNC);
1166} 1161}
1167 1162
1168static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, 1163static void iwl_rx_beacon_notif(struct iwl_priv *priv,
1169 struct iwl_rx_mem_buffer *rxb) 1164 struct iwl_rx_mem_buffer *rxb)
1170{ 1165{
1171#ifdef CONFIG_IWLWIFI_DEBUG 1166#ifdef CONFIG_IWLWIFI_DEBUG
@@ -1189,7 +1184,7 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv,
1189 1184
1190/* Handle notification from uCode that card's power state is changing 1185/* Handle notification from uCode that card's power state is changing
1191 * due to software, hardware, or critical temperature RFKILL */ 1186 * due to software, hardware, or critical temperature RFKILL */
1192static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, 1187static void iwl_rx_card_state_notif(struct iwl_priv *priv,
1193 struct iwl_rx_mem_buffer *rxb) 1188 struct iwl_rx_mem_buffer *rxb)
1194{ 1189{
1195 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1190 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
@@ -1258,7 +1253,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
1258 wake_up_interruptible(&priv->wait_command_queue); 1253 wake_up_interruptible(&priv->wait_command_queue);
1259} 1254}
1260 1255
1261int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src) 1256int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src)
1262{ 1257{
1263 int ret; 1258 int ret;
1264 unsigned long flags; 1259 unsigned long flags;
@@ -1290,7 +1285,7 @@ err:
1290} 1285}
1291 1286
1292/** 1287/**
1293 * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks 1288 * iwl_setup_rx_handlers - Initialize Rx handler callbacks
1294 * 1289 *
1295 * Setup the RX handlers for each of the reply types sent from the uCode 1290 * Setup the RX handlers for each of the reply types sent from the uCode
1296 * to the host. 1291 * to the host.
@@ -1301,14 +1296,14 @@ err:
1301static void iwl_setup_rx_handlers(struct iwl_priv *priv) 1296static void iwl_setup_rx_handlers(struct iwl_priv *priv)
1302{ 1297{
1303 priv->rx_handlers[REPLY_ALIVE] = iwl_rx_reply_alive; 1298 priv->rx_handlers[REPLY_ALIVE] = iwl_rx_reply_alive;
1304 priv->rx_handlers[REPLY_ERROR] = iwl4965_rx_reply_error; 1299 priv->rx_handlers[REPLY_ERROR] = iwl_rx_reply_error;
1305 priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl4965_rx_csa; 1300 priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_rx_csa;
1306 priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = 1301 priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] =
1307 iwl4965_rx_spectrum_measure_notif; 1302 iwl_rx_spectrum_measure_notif;
1308 priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl4965_rx_pm_sleep_notif; 1303 priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl_rx_pm_sleep_notif;
1309 priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = 1304 priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] =
1310 iwl4965_rx_pm_debug_statistics_notif; 1305 iwl_rx_pm_debug_statistics_notif;
1311 priv->rx_handlers[BEACON_NOTIFICATION] = iwl4965_rx_beacon_notif; 1306 priv->rx_handlers[BEACON_NOTIFICATION] = iwl_rx_beacon_notif;
1312 1307
1313 /* 1308 /*
1314 * The same handler is used for both the REPLY to a discrete 1309 * The same handler is used for both the REPLY to a discrete
@@ -1321,7 +1316,7 @@ static void iwl_setup_rx_handlers(struct iwl_priv *priv)
1321 iwl_setup_rx_scan_handlers(priv); 1316 iwl_setup_rx_scan_handlers(priv);
1322 1317
1323 /* status change handler */ 1318 /* status change handler */
1324 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; 1319 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl_rx_card_state_notif;
1325 1320
1326 priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = 1321 priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] =
1327 iwl_rx_missed_beacon_notif; 1322 iwl_rx_missed_beacon_notif;
@@ -1398,13 +1393,14 @@ void iwl_rx_handle(struct iwl_priv *priv)
1398 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && 1393 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
1399 (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && 1394 (pkt->hdr.cmd != REPLY_RX_PHY_CMD) &&
1400 (pkt->hdr.cmd != REPLY_RX) && 1395 (pkt->hdr.cmd != REPLY_RX) &&
1396 (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) &&
1401 (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && 1397 (pkt->hdr.cmd != REPLY_COMPRESSED_BA) &&
1402 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && 1398 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
1403 (pkt->hdr.cmd != REPLY_TX); 1399 (pkt->hdr.cmd != REPLY_TX);
1404 1400
1405 /* Based on type of command response or notification, 1401 /* Based on type of command response or notification,
1406 * handle those that need handling via function in 1402 * handle those that need handling via function in
1407 * rx_handlers table. See iwl4965_setup_rx_handlers() */ 1403 * rx_handlers table. See iwl_setup_rx_handlers() */
1408 if (priv->rx_handlers[pkt->hdr.cmd]) { 1404 if (priv->rx_handlers[pkt->hdr.cmd]) {
1409 IWL_DEBUG(IWL_DL_RX, "r = %d, i = %d, %s, 0x%02x\n", r, 1405 IWL_DEBUG(IWL_DL_RX, "r = %d, i = %d, %s, 0x%02x\n", r,
1410 i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); 1406 i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
@@ -1461,10 +1457,9 @@ void iwl_rx_handle(struct iwl_priv *priv)
1461} 1457}
1462 1458
1463#ifdef CONFIG_IWLWIFI_DEBUG 1459#ifdef CONFIG_IWLWIFI_DEBUG
1464static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv) 1460static void iwl_print_rx_config_cmd(struct iwl_priv *priv)
1465{ 1461{
1466 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 1462 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
1467 DECLARE_MAC_BUF(mac);
1468 1463
1469 IWL_DEBUG_RADIO("RX CONFIG:\n"); 1464 IWL_DEBUG_RADIO("RX CONFIG:\n");
1470 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); 1465 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
@@ -1476,15 +1471,13 @@ static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv)
1476 IWL_DEBUG_RADIO("u8 ofdm_basic_rates: 0x%02x\n", 1471 IWL_DEBUG_RADIO("u8 ofdm_basic_rates: 0x%02x\n",
1477 rxon->ofdm_basic_rates); 1472 rxon->ofdm_basic_rates);
1478 IWL_DEBUG_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); 1473 IWL_DEBUG_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates);
1479 IWL_DEBUG_RADIO("u8[6] node_addr: %s\n", 1474 IWL_DEBUG_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr);
1480 print_mac(mac, rxon->node_addr)); 1475 IWL_DEBUG_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr);
1481 IWL_DEBUG_RADIO("u8[6] bssid_addr: %s\n",
1482 print_mac(mac, rxon->bssid_addr));
1483 IWL_DEBUG_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); 1476 IWL_DEBUG_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id));
1484} 1477}
1485#endif 1478#endif
1486 1479
1487static void iwl4965_enable_interrupts(struct iwl_priv *priv) 1480static void iwl_enable_interrupts(struct iwl_priv *priv)
1488{ 1481{
1489 IWL_DEBUG_ISR("Enabling interrupts\n"); 1482 IWL_DEBUG_ISR("Enabling interrupts\n");
1490 set_bit(STATUS_INT_ENABLED, &priv->status); 1483 set_bit(STATUS_INT_ENABLED, &priv->status);
@@ -1494,12 +1487,12 @@ static void iwl4965_enable_interrupts(struct iwl_priv *priv)
1494/* call this function to flush any scheduled tasklet */ 1487/* call this function to flush any scheduled tasklet */
1495static inline void iwl_synchronize_irq(struct iwl_priv *priv) 1488static inline void iwl_synchronize_irq(struct iwl_priv *priv)
1496{ 1489{
1497 /* wait to make sure we flush pedding tasklet*/ 1490 /* wait to make sure we flush pending tasklet*/
1498 synchronize_irq(priv->pci_dev->irq); 1491 synchronize_irq(priv->pci_dev->irq);
1499 tasklet_kill(&priv->irq_tasklet); 1492 tasklet_kill(&priv->irq_tasklet);
1500} 1493}
1501 1494
1502static inline void iwl4965_disable_interrupts(struct iwl_priv *priv) 1495static inline void iwl_disable_interrupts(struct iwl_priv *priv)
1503{ 1496{
1504 clear_bit(STATUS_INT_ENABLED, &priv->status); 1497 clear_bit(STATUS_INT_ENABLED, &priv->status);
1505 1498
@@ -1515,11 +1508,11 @@ static inline void iwl4965_disable_interrupts(struct iwl_priv *priv)
1515 1508
1516 1509
1517/** 1510/**
1518 * iwl4965_irq_handle_error - called for HW or SW error interrupt from card 1511 * iwl_irq_handle_error - called for HW or SW error interrupt from card
1519 */ 1512 */
1520static void iwl4965_irq_handle_error(struct iwl_priv *priv) 1513static void iwl_irq_handle_error(struct iwl_priv *priv)
1521{ 1514{
1522 /* Set the FW error flag -- cleared on iwl4965_down */ 1515 /* Set the FW error flag -- cleared on iwl_down */
1523 set_bit(STATUS_FW_ERROR, &priv->status); 1516 set_bit(STATUS_FW_ERROR, &priv->status);
1524 1517
1525 /* Cancel currently queued command. */ 1518 /* Cancel currently queued command. */
@@ -1529,7 +1522,7 @@ static void iwl4965_irq_handle_error(struct iwl_priv *priv)
1529 if (priv->debug_level & IWL_DL_FW_ERRORS) { 1522 if (priv->debug_level & IWL_DL_FW_ERRORS) {
1530 iwl_dump_nic_error_log(priv); 1523 iwl_dump_nic_error_log(priv);
1531 iwl_dump_nic_event_log(priv); 1524 iwl_dump_nic_event_log(priv);
1532 iwl4965_print_rx_config_cmd(priv); 1525 iwl_print_rx_config_cmd(priv);
1533 } 1526 }
1534#endif 1527#endif
1535 1528
@@ -1553,14 +1546,14 @@ static void iwl4965_irq_handle_error(struct iwl_priv *priv)
1553 } 1546 }
1554} 1547}
1555 1548
1556static void iwl4965_error_recovery(struct iwl_priv *priv) 1549static void iwl_error_recovery(struct iwl_priv *priv)
1557{ 1550{
1558 unsigned long flags; 1551 unsigned long flags;
1559 1552
1560 memcpy(&priv->staging_rxon, &priv->recovery_rxon, 1553 memcpy(&priv->staging_rxon, &priv->recovery_rxon,
1561 sizeof(priv->staging_rxon)); 1554 sizeof(priv->staging_rxon));
1562 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 1555 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
1563 iwl4965_commit_rxon(priv); 1556 iwl_commit_rxon(priv);
1564 1557
1565 iwl_rxon_add_station(priv, priv->bssid, 1); 1558 iwl_rxon_add_station(priv, priv->bssid, 1);
1566 1559
@@ -1570,7 +1563,7 @@ static void iwl4965_error_recovery(struct iwl_priv *priv)
1570 spin_unlock_irqrestore(&priv->lock, flags); 1563 spin_unlock_irqrestore(&priv->lock, flags);
1571} 1564}
1572 1565
1573static void iwl4965_irq_tasklet(struct iwl_priv *priv) 1566static void iwl_irq_tasklet(struct iwl_priv *priv)
1574{ 1567{
1575 u32 inta, handled = 0; 1568 u32 inta, handled = 0;
1576 u32 inta_fh; 1569 u32 inta_fh;
@@ -1616,9 +1609,9 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv)
1616 IWL_ERROR("Microcode HW error detected. Restarting.\n"); 1609 IWL_ERROR("Microcode HW error detected. Restarting.\n");
1617 1610
1618 /* Tell the device to stop sending interrupts */ 1611 /* Tell the device to stop sending interrupts */
1619 iwl4965_disable_interrupts(priv); 1612 iwl_disable_interrupts(priv);
1620 1613
1621 iwl4965_irq_handle_error(priv); 1614 iwl_irq_handle_error(priv);
1622 1615
1623 handled |= CSR_INT_BIT_HW_ERR; 1616 handled |= CSR_INT_BIT_HW_ERR;
1624 1617
@@ -1672,7 +1665,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv)
1672 if (inta & CSR_INT_BIT_SW_ERR) { 1665 if (inta & CSR_INT_BIT_SW_ERR) {
1673 IWL_ERROR("Microcode SW error detected. Restarting 0x%X.\n", 1666 IWL_ERROR("Microcode SW error detected. Restarting 0x%X.\n",
1674 inta); 1667 inta);
1675 iwl4965_irq_handle_error(priv); 1668 iwl_irq_handle_error(priv);
1676 handled |= CSR_INT_BIT_SW_ERR; 1669 handled |= CSR_INT_BIT_SW_ERR;
1677 } 1670 }
1678 1671
@@ -1718,7 +1711,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv)
1718 /* Re-enable all interrupts */ 1711 /* Re-enable all interrupts */
1719 /* only Re-enable if diabled by irq */ 1712 /* only Re-enable if diabled by irq */
1720 if (test_bit(STATUS_INT_ENABLED, &priv->status)) 1713 if (test_bit(STATUS_INT_ENABLED, &priv->status))
1721 iwl4965_enable_interrupts(priv); 1714 iwl_enable_interrupts(priv);
1722 1715
1723#ifdef CONFIG_IWLWIFI_DEBUG 1716#ifdef CONFIG_IWLWIFI_DEBUG
1724 if (priv->debug_level & (IWL_DL_ISR)) { 1717 if (priv->debug_level & (IWL_DL_ISR)) {
@@ -1732,7 +1725,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv)
1732 spin_unlock_irqrestore(&priv->lock, flags); 1725 spin_unlock_irqrestore(&priv->lock, flags);
1733} 1726}
1734 1727
1735static irqreturn_t iwl4965_isr(int irq, void *data) 1728static irqreturn_t iwl_isr(int irq, void *data)
1736{ 1729{
1737 struct iwl_priv *priv = data; 1730 struct iwl_priv *priv = data;
1738 u32 inta, inta_mask; 1731 u32 inta, inta_mask;
@@ -1773,7 +1766,7 @@ static irqreturn_t iwl4965_isr(int irq, void *data)
1773 1766
1774 inta &= ~CSR_INT_BIT_SCD; 1767 inta &= ~CSR_INT_BIT_SCD;
1775 1768
1776 /* iwl4965_irq_tasklet() will service interrupts and re-enable them */ 1769 /* iwl_irq_tasklet() will service interrupts and re-enable them */
1777 if (likely(inta || inta_fh)) 1770 if (likely(inta || inta_fh))
1778 tasklet_schedule(&priv->irq_tasklet); 1771 tasklet_schedule(&priv->irq_tasklet);
1779 1772
@@ -1785,7 +1778,7 @@ static irqreturn_t iwl4965_isr(int irq, void *data)
1785 /* re-enable interrupts here since we don't have anything to service. */ 1778 /* re-enable interrupts here since we don't have anything to service. */
1786 /* only Re-enable if diabled by irq */ 1779 /* only Re-enable if diabled by irq */
1787 if (test_bit(STATUS_INT_ENABLED, &priv->status)) 1780 if (test_bit(STATUS_INT_ENABLED, &priv->status))
1788 iwl4965_enable_interrupts(priv); 1781 iwl_enable_interrupts(priv);
1789 spin_unlock(&priv->lock); 1782 spin_unlock(&priv->lock);
1790 return IRQ_NONE; 1783 return IRQ_NONE;
1791} 1784}
@@ -1796,7 +1789,7 @@ static irqreturn_t iwl4965_isr(int irq, void *data)
1796 * 1789 *
1797 ******************************************************************************/ 1790 ******************************************************************************/
1798 1791
1799static void iwl4965_dealloc_ucode_pci(struct iwl_priv *priv) 1792static void iwl_dealloc_ucode_pci(struct iwl_priv *priv)
1800{ 1793{
1801 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_code); 1794 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_code);
1802 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data); 1795 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data);
@@ -1806,7 +1799,7 @@ static void iwl4965_dealloc_ucode_pci(struct iwl_priv *priv)
1806 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_boot); 1799 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_boot);
1807} 1800}
1808 1801
1809static void iwl4965_nic_start(struct iwl_priv *priv) 1802static void iwl_nic_start(struct iwl_priv *priv)
1810{ 1803{
1811 /* Remove all resets to allow NIC to operate */ 1804 /* Remove all resets to allow NIC to operate */
1812 iwl_write32(priv, CSR_RESET, 0); 1805 iwl_write32(priv, CSR_RESET, 0);
@@ -1814,11 +1807,11 @@ static void iwl4965_nic_start(struct iwl_priv *priv)
1814 1807
1815 1808
1816/** 1809/**
1817 * iwl4965_read_ucode - Read uCode images from disk file. 1810 * iwl_read_ucode - Read uCode images from disk file.
1818 * 1811 *
1819 * Copy into buffers for card to fetch via bus-mastering 1812 * Copy into buffers for card to fetch via bus-mastering
1820 */ 1813 */
1821static int iwl4965_read_ucode(struct iwl_priv *priv) 1814static int iwl_read_ucode(struct iwl_priv *priv)
1822{ 1815{
1823 struct iwl_ucode *ucode; 1816 struct iwl_ucode *ucode;
1824 int ret; 1817 int ret;
@@ -1962,7 +1955,7 @@ static int iwl4965_read_ucode(struct iwl_priv *priv)
1962 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); 1955 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);
1963 1956
1964 /* Runtime data (2nd block) 1957 /* Runtime data (2nd block)
1965 * NOTE: Copy into backup buffer will be done in iwl4965_up() */ 1958 * NOTE: Copy into backup buffer will be done in iwl_up() */
1966 src = &ucode->data[inst_size]; 1959 src = &ucode->data[inst_size];
1967 len = priv->ucode_data.len; 1960 len = priv->ucode_data.len;
1968 IWL_DEBUG_INFO("Copying (but not loading) uCode data len %Zd\n", len); 1961 IWL_DEBUG_INFO("Copying (but not loading) uCode data len %Zd\n", len);
@@ -2000,7 +1993,7 @@ static int iwl4965_read_ucode(struct iwl_priv *priv)
2000 err_pci_alloc: 1993 err_pci_alloc:
2001 IWL_ERROR("failed to allocate pci memory\n"); 1994 IWL_ERROR("failed to allocate pci memory\n");
2002 ret = -ENOMEM; 1995 ret = -ENOMEM;
2003 iwl4965_dealloc_ucode_pci(priv); 1996 iwl_dealloc_ucode_pci(priv);
2004 1997
2005 err_release: 1998 err_release:
2006 release_firmware(ucode_raw); 1999 release_firmware(ucode_raw);
@@ -2045,7 +2038,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2045 goto restart; 2038 goto restart;
2046 } 2039 }
2047 2040
2048 /* After the ALIVE response, we can send host commands to 4965 uCode */ 2041 /* After the ALIVE response, we can send host commands to the uCode */
2049 set_bit(STATUS_ALIVE, &priv->status); 2042 set_bit(STATUS_ALIVE, &priv->status);
2050 2043
2051 if (iwl_is_rfkill(priv)) 2044 if (iwl_is_rfkill(priv))
@@ -2065,17 +2058,17 @@ static void iwl_alive_start(struct iwl_priv *priv)
2065 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2058 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2066 } else { 2059 } else {
2067 /* Initialize our rx_config data */ 2060 /* Initialize our rx_config data */
2068 iwl4965_connection_init_rx_config(priv); 2061 iwl_connection_init_rx_config(priv, priv->iw_mode);
2069 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 2062 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
2070 } 2063 }
2071 2064
2072 /* Configure Bluetooth device coexistence support */ 2065 /* Configure Bluetooth device coexistence support */
2073 iwl4965_send_bt_config(priv); 2066 iwl_send_bt_config(priv);
2074 2067
2075 iwl_reset_run_time_calib(priv); 2068 iwl_reset_run_time_calib(priv);
2076 2069
2077 /* Configure the adapter for unassociated operation */ 2070 /* Configure the adapter for unassociated operation */
2078 iwl4965_commit_rxon(priv); 2071 iwl_commit_rxon(priv);
2079 2072
2080 /* At this point, the NIC is initialized and operational */ 2073 /* At this point, the NIC is initialized and operational */
2081 iwl_rf_kill_ct_config(priv); 2074 iwl_rf_kill_ct_config(priv);
@@ -2087,12 +2080,12 @@ static void iwl_alive_start(struct iwl_priv *priv)
2087 wake_up_interruptible(&priv->wait_command_queue); 2080 wake_up_interruptible(&priv->wait_command_queue);
2088 2081
2089 if (priv->error_recovering) 2082 if (priv->error_recovering)
2090 iwl4965_error_recovery(priv); 2083 iwl_error_recovery(priv);
2091 2084
2092 iwl_power_update_mode(priv, 1); 2085 iwl_power_update_mode(priv, 1);
2093 2086
2094 if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status)) 2087 if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status))
2095 iwl4965_set_mode(priv, priv->iw_mode); 2088 iwl_set_mode(priv, priv->iw_mode);
2096 2089
2097 return; 2090 return;
2098 2091
@@ -2102,7 +2095,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2102 2095
2103static void iwl_cancel_deferred_work(struct iwl_priv *priv); 2096static void iwl_cancel_deferred_work(struct iwl_priv *priv);
2104 2097
2105static void __iwl4965_down(struct iwl_priv *priv) 2098static void __iwl_down(struct iwl_priv *priv)
2106{ 2099{
2107 unsigned long flags; 2100 unsigned long flags;
2108 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); 2101 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status);
@@ -2129,14 +2122,14 @@ static void __iwl4965_down(struct iwl_priv *priv)
2129 2122
2130 /* tell the device to stop sending interrupts */ 2123 /* tell the device to stop sending interrupts */
2131 spin_lock_irqsave(&priv->lock, flags); 2124 spin_lock_irqsave(&priv->lock, flags);
2132 iwl4965_disable_interrupts(priv); 2125 iwl_disable_interrupts(priv);
2133 spin_unlock_irqrestore(&priv->lock, flags); 2126 spin_unlock_irqrestore(&priv->lock, flags);
2134 iwl_synchronize_irq(priv); 2127 iwl_synchronize_irq(priv);
2135 2128
2136 if (priv->mac80211_registered) 2129 if (priv->mac80211_registered)
2137 ieee80211_stop_queues(priv->hw); 2130 ieee80211_stop_queues(priv->hw);
2138 2131
2139 /* If we have not previously called iwl4965_init() then 2132 /* If we have not previously called iwl_init() then
2140 * clear all bits but the RF Kill and SUSPEND bits and return */ 2133 * clear all bits but the RF Kill and SUSPEND bits and return */
2141 if (!iwl_is_init(priv)) { 2134 if (!iwl_is_init(priv)) {
2142 priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << 2135 priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) <<
@@ -2203,10 +2196,10 @@ static void __iwl4965_down(struct iwl_priv *priv)
2203 iwl_clear_free_frames(priv); 2196 iwl_clear_free_frames(priv);
2204} 2197}
2205 2198
2206static void iwl4965_down(struct iwl_priv *priv) 2199static void iwl_down(struct iwl_priv *priv)
2207{ 2200{
2208 mutex_lock(&priv->mutex); 2201 mutex_lock(&priv->mutex);
2209 __iwl4965_down(priv); 2202 __iwl_down(priv);
2210 mutex_unlock(&priv->mutex); 2203 mutex_unlock(&priv->mutex);
2211 2204
2212 iwl_cancel_deferred_work(priv); 2205 iwl_cancel_deferred_work(priv);
@@ -2214,7 +2207,7 @@ static void iwl4965_down(struct iwl_priv *priv)
2214 2207
2215#define MAX_HW_RESTARTS 5 2208#define MAX_HW_RESTARTS 5
2216 2209
2217static int __iwl4965_up(struct iwl_priv *priv) 2210static int __iwl_up(struct iwl_priv *priv)
2218{ 2211{
2219 int i; 2212 int i;
2220 int ret; 2213 int ret;
@@ -2236,7 +2229,7 @@ static int __iwl4965_up(struct iwl_priv *priv)
2236 set_bit(STATUS_RF_KILL_HW, &priv->status); 2229 set_bit(STATUS_RF_KILL_HW, &priv->status);
2237 2230
2238 if (iwl_is_rfkill(priv)) { 2231 if (iwl_is_rfkill(priv)) {
2239 iwl4965_enable_interrupts(priv); 2232 iwl_enable_interrupts(priv);
2240 IWL_WARNING("Radio disabled by %s RF Kill switch\n", 2233 IWL_WARNING("Radio disabled by %s RF Kill switch\n",
2241 test_bit(STATUS_RF_KILL_HW, &priv->status) ? "HW" : "SW"); 2234 test_bit(STATUS_RF_KILL_HW, &priv->status) ? "HW" : "SW");
2242 return 0; 2235 return 0;
@@ -2263,7 +2256,7 @@ static int __iwl4965_up(struct iwl_priv *priv)
2263 2256
2264 /* clear (again), then enable host interrupts */ 2257 /* clear (again), then enable host interrupts */
2265 iwl_write32(priv, CSR_INT, 0xFFFFFFFF); 2258 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
2266 iwl4965_enable_interrupts(priv); 2259 iwl_enable_interrupts(priv);
2267 2260
2268 /* really make sure rfkill handshake bits are cleared */ 2261 /* really make sure rfkill handshake bits are cleared */
2269 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); 2262 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
@@ -2293,7 +2286,7 @@ static int __iwl4965_up(struct iwl_priv *priv)
2293 clear_bit(STATUS_FW_ERROR, &priv->status); 2286 clear_bit(STATUS_FW_ERROR, &priv->status);
2294 2287
2295 /* start card; "initialize" will load runtime ucode */ 2288 /* start card; "initialize" will load runtime ucode */
2296 iwl4965_nic_start(priv); 2289 iwl_nic_start(priv);
2297 2290
2298 IWL_DEBUG_INFO(DRV_NAME " is coming up\n"); 2291 IWL_DEBUG_INFO(DRV_NAME " is coming up\n");
2299 2292
@@ -2301,7 +2294,7 @@ static int __iwl4965_up(struct iwl_priv *priv)
2301 } 2294 }
2302 2295
2303 set_bit(STATUS_EXIT_PENDING, &priv->status); 2296 set_bit(STATUS_EXIT_PENDING, &priv->status);
2304 __iwl4965_down(priv); 2297 __iwl_down(priv);
2305 clear_bit(STATUS_EXIT_PENDING, &priv->status); 2298 clear_bit(STATUS_EXIT_PENDING, &priv->status);
2306 2299
2307 /* tried to restart and config the device for as long as our 2300 /* tried to restart and config the device for as long as our
@@ -2344,7 +2337,7 @@ static void iwl_bg_alive_start(struct work_struct *data)
2344 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC); 2337 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
2345} 2338}
2346 2339
2347static void iwl4965_bg_rf_kill(struct work_struct *work) 2340static void iwl_bg_rf_kill(struct work_struct *work)
2348{ 2341{
2349 struct iwl_priv *priv = container_of(work, struct iwl_priv, rf_kill); 2342 struct iwl_priv *priv = container_of(work, struct iwl_priv, rf_kill);
2350 2343
@@ -2378,7 +2371,7 @@ static void iwl4965_bg_rf_kill(struct work_struct *work)
2378 iwl_rfkill_set_hw_state(priv); 2371 iwl_rfkill_set_hw_state(priv);
2379} 2372}
2380 2373
2381static void iwl4965_bg_set_monitor(struct work_struct *work) 2374static void iwl_bg_set_monitor(struct work_struct *work)
2382{ 2375{
2383 struct iwl_priv *priv = container_of(work, 2376 struct iwl_priv *priv = container_of(work,
2384 struct iwl_priv, set_monitor); 2377 struct iwl_priv, set_monitor);
@@ -2388,16 +2381,16 @@ static void iwl4965_bg_set_monitor(struct work_struct *work)
2388 2381
2389 mutex_lock(&priv->mutex); 2382 mutex_lock(&priv->mutex);
2390 2383
2391 ret = iwl4965_set_mode(priv, NL80211_IFTYPE_MONITOR); 2384 ret = iwl_set_mode(priv, NL80211_IFTYPE_MONITOR);
2392
2393 if (ret) { 2385 if (ret) {
2394 if (ret == -EAGAIN) 2386 if (ret == -EAGAIN)
2395 IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n"); 2387 IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n");
2396 else 2388 else
2397 IWL_ERROR("iwl4965_set_mode() failed ret = %d\n", ret); 2389 IWL_ERROR("iwl_set_mode() failed ret = %d\n", ret);
2398 } 2390 }
2399 2391
2400 mutex_unlock(&priv->mutex); 2392 mutex_unlock(&priv->mutex);
2393 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
2401} 2394}
2402 2395
2403static void iwl_bg_run_time_calib_work(struct work_struct *work) 2396static void iwl_bg_run_time_calib_work(struct work_struct *work)
@@ -2423,7 +2416,7 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
2423 return; 2416 return;
2424} 2417}
2425 2418
2426static void iwl4965_bg_up(struct work_struct *data) 2419static void iwl_bg_up(struct work_struct *data)
2427{ 2420{
2428 struct iwl_priv *priv = container_of(data, struct iwl_priv, up); 2421 struct iwl_priv *priv = container_of(data, struct iwl_priv, up);
2429 2422
@@ -2431,23 +2424,23 @@ static void iwl4965_bg_up(struct work_struct *data)
2431 return; 2424 return;
2432 2425
2433 mutex_lock(&priv->mutex); 2426 mutex_lock(&priv->mutex);
2434 __iwl4965_up(priv); 2427 __iwl_up(priv);
2435 mutex_unlock(&priv->mutex); 2428 mutex_unlock(&priv->mutex);
2436 iwl_rfkill_set_hw_state(priv); 2429 iwl_rfkill_set_hw_state(priv);
2437} 2430}
2438 2431
2439static void iwl4965_bg_restart(struct work_struct *data) 2432static void iwl_bg_restart(struct work_struct *data)
2440{ 2433{
2441 struct iwl_priv *priv = container_of(data, struct iwl_priv, restart); 2434 struct iwl_priv *priv = container_of(data, struct iwl_priv, restart);
2442 2435
2443 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2436 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2444 return; 2437 return;
2445 2438
2446 iwl4965_down(priv); 2439 iwl_down(priv);
2447 queue_work(priv->workqueue, &priv->up); 2440 queue_work(priv->workqueue, &priv->up);
2448} 2441}
2449 2442
2450static void iwl4965_bg_rx_replenish(struct work_struct *data) 2443static void iwl_bg_rx_replenish(struct work_struct *data)
2451{ 2444{
2452 struct iwl_priv *priv = 2445 struct iwl_priv *priv =
2453 container_of(data, struct iwl_priv, rx_replenish); 2446 container_of(data, struct iwl_priv, rx_replenish);
@@ -2462,11 +2455,10 @@ static void iwl4965_bg_rx_replenish(struct work_struct *data)
2462 2455
2463#define IWL_DELAY_NEXT_SCAN (HZ*2) 2456#define IWL_DELAY_NEXT_SCAN (HZ*2)
2464 2457
2465static void iwl4965_post_associate(struct iwl_priv *priv) 2458static void iwl_post_associate(struct iwl_priv *priv)
2466{ 2459{
2467 struct ieee80211_conf *conf = NULL; 2460 struct ieee80211_conf *conf = NULL;
2468 int ret = 0; 2461 int ret = 0;
2469 DECLARE_MAC_BUF(mac);
2470 unsigned long flags; 2462 unsigned long flags;
2471 2463
2472 if (priv->iw_mode == NL80211_IFTYPE_AP) { 2464 if (priv->iw_mode == NL80211_IFTYPE_AP) {
@@ -2474,9 +2466,8 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2474 return; 2466 return;
2475 } 2467 }
2476 2468
2477 IWL_DEBUG_ASSOC("Associated as %d to: %s\n", 2469 IWL_DEBUG_ASSOC("Associated as %d to: %pM\n",
2478 priv->assoc_id, 2470 priv->assoc_id, priv->active_rxon.bssid_addr);
2479 print_mac(mac, priv->active_rxon.bssid_addr));
2480 2471
2481 2472
2482 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2473 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
@@ -2492,10 +2483,9 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2492 conf = ieee80211_get_hw_conf(priv->hw); 2483 conf = ieee80211_get_hw_conf(priv->hw);
2493 2484
2494 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2485 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2495 iwl4965_commit_rxon(priv); 2486 iwl_commit_rxon(priv);
2496 2487
2497 memset(&priv->rxon_timing, 0, sizeof(struct iwl4965_rxon_time_cmd)); 2488 iwl_setup_rxon_timing(priv);
2498 iwl4965_setup_rxon_timing(priv);
2499 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 2489 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
2500 sizeof(priv->rxon_timing), &priv->rxon_timing); 2490 sizeof(priv->rxon_timing), &priv->rxon_timing);
2501 if (ret) 2491 if (ret)
@@ -2528,7 +2518,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2528 2518
2529 } 2519 }
2530 2520
2531 iwl4965_commit_rxon(priv); 2521 iwl_commit_rxon(priv);
2532 2522
2533 switch (priv->iw_mode) { 2523 switch (priv->iw_mode) {
2534 case NL80211_IFTYPE_STATION: 2524 case NL80211_IFTYPE_STATION:
@@ -2540,7 +2530,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2540 priv->assoc_id = 1; 2530 priv->assoc_id = 1;
2541 2531
2542 iwl_rxon_add_station(priv, priv->bssid, 0); 2532 iwl_rxon_add_station(priv, priv->bssid, 0);
2543 iwl4965_send_beacon_cmd(priv); 2533 iwl_send_beacon_cmd(priv);
2544 2534
2545 break; 2535 break;
2546 2536
@@ -2577,7 +2567,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2577 2567
2578#define UCODE_READY_TIMEOUT (4 * HZ) 2568#define UCODE_READY_TIMEOUT (4 * HZ)
2579 2569
2580static int iwl4965_mac_start(struct ieee80211_hw *hw) 2570static int iwl_mac_start(struct ieee80211_hw *hw)
2581{ 2571{
2582 struct iwl_priv *priv = hw->priv; 2572 struct iwl_priv *priv = hw->priv;
2583 int ret; 2573 int ret;
@@ -2599,7 +2589,7 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw)
2599 pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); 2589 pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd);
2600 } 2590 }
2601 2591
2602 ret = request_irq(priv->pci_dev->irq, iwl4965_isr, IRQF_SHARED, 2592 ret = request_irq(priv->pci_dev->irq, iwl_isr, IRQF_SHARED,
2603 DRV_NAME, priv); 2593 DRV_NAME, priv);
2604 if (ret) { 2594 if (ret) {
2605 IWL_ERROR("Error allocating IRQ %d\n", priv->pci_dev->irq); 2595 IWL_ERROR("Error allocating IRQ %d\n", priv->pci_dev->irq);
@@ -2614,7 +2604,7 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw)
2614 * ucode filename and max sizes are card-specific. */ 2604 * ucode filename and max sizes are card-specific. */
2615 2605
2616 if (!priv->ucode_code.len) { 2606 if (!priv->ucode_code.len) {
2617 ret = iwl4965_read_ucode(priv); 2607 ret = iwl_read_ucode(priv);
2618 if (ret) { 2608 if (ret) {
2619 IWL_ERROR("Could not read microcode: %d\n", ret); 2609 IWL_ERROR("Could not read microcode: %d\n", ret);
2620 mutex_unlock(&priv->mutex); 2610 mutex_unlock(&priv->mutex);
@@ -2622,7 +2612,7 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw)
2622 } 2612 }
2623 } 2613 }
2624 2614
2625 ret = __iwl4965_up(priv); 2615 ret = __iwl_up(priv);
2626 2616
2627 mutex_unlock(&priv->mutex); 2617 mutex_unlock(&priv->mutex);
2628 2618
@@ -2668,7 +2658,7 @@ out_disable_msi:
2668 return ret; 2658 return ret;
2669} 2659}
2670 2660
2671static void iwl4965_mac_stop(struct ieee80211_hw *hw) 2661static void iwl_mac_stop(struct ieee80211_hw *hw)
2672{ 2662{
2673 struct iwl_priv *priv = hw->priv; 2663 struct iwl_priv *priv = hw->priv;
2674 2664
@@ -2690,7 +2680,7 @@ static void iwl4965_mac_stop(struct ieee80211_hw *hw)
2690 mutex_unlock(&priv->mutex); 2680 mutex_unlock(&priv->mutex);
2691 } 2681 }
2692 2682
2693 iwl4965_down(priv); 2683 iwl_down(priv);
2694 2684
2695 flush_workqueue(priv->workqueue); 2685 flush_workqueue(priv->workqueue);
2696 free_irq(priv->pci_dev->irq, priv); 2686 free_irq(priv->pci_dev->irq, priv);
@@ -2701,7 +2691,7 @@ static void iwl4965_mac_stop(struct ieee80211_hw *hw)
2701 IWL_DEBUG_MAC80211("leave\n"); 2691 IWL_DEBUG_MAC80211("leave\n");
2702} 2692}
2703 2693
2704static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 2694static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2705{ 2695{
2706 struct iwl_priv *priv = hw->priv; 2696 struct iwl_priv *priv = hw->priv;
2707 2697
@@ -2717,12 +2707,11 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2717 return 0; 2707 return 0;
2718} 2708}
2719 2709
2720static int iwl4965_mac_add_interface(struct ieee80211_hw *hw, 2710static int iwl_mac_add_interface(struct ieee80211_hw *hw,
2721 struct ieee80211_if_init_conf *conf) 2711 struct ieee80211_if_init_conf *conf)
2722{ 2712{
2723 struct iwl_priv *priv = hw->priv; 2713 struct iwl_priv *priv = hw->priv;
2724 unsigned long flags; 2714 unsigned long flags;
2725 DECLARE_MAC_BUF(mac);
2726 2715
2727 IWL_DEBUG_MAC80211("enter: type %d\n", conf->type); 2716 IWL_DEBUG_MAC80211("enter: type %d\n", conf->type);
2728 2717
@@ -2733,17 +2722,18 @@ static int iwl4965_mac_add_interface(struct ieee80211_hw *hw,
2733 2722
2734 spin_lock_irqsave(&priv->lock, flags); 2723 spin_lock_irqsave(&priv->lock, flags);
2735 priv->vif = conf->vif; 2724 priv->vif = conf->vif;
2725 priv->iw_mode = conf->type;
2736 2726
2737 spin_unlock_irqrestore(&priv->lock, flags); 2727 spin_unlock_irqrestore(&priv->lock, flags);
2738 2728
2739 mutex_lock(&priv->mutex); 2729 mutex_lock(&priv->mutex);
2740 2730
2741 if (conf->mac_addr) { 2731 if (conf->mac_addr) {
2742 IWL_DEBUG_MAC80211("Set %s\n", print_mac(mac, conf->mac_addr)); 2732 IWL_DEBUG_MAC80211("Set %pM\n", conf->mac_addr);
2743 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); 2733 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
2744 } 2734 }
2745 2735
2746 if (iwl4965_set_mode(priv, conf->type) == -EAGAIN) 2736 if (iwl_set_mode(priv, conf->type) == -EAGAIN)
2747 /* we are not ready, will run again when ready */ 2737 /* we are not ready, will run again when ready */
2748 set_bit(STATUS_MODE_PENDING, &priv->status); 2738 set_bit(STATUS_MODE_PENDING, &priv->status);
2749 2739
@@ -2754,16 +2744,17 @@ static int iwl4965_mac_add_interface(struct ieee80211_hw *hw,
2754} 2744}
2755 2745
2756/** 2746/**
2757 * iwl4965_mac_config - mac80211 config callback 2747 * iwl_mac_config - mac80211 config callback
2758 * 2748 *
2759 * We ignore conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME since it seems to 2749 * We ignore conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME since it seems to
2760 * be set inappropriately and the driver currently sets the hardware up to 2750 * be set inappropriately and the driver currently sets the hardware up to
2761 * use it whenever needed. 2751 * use it whenever needed.
2762 */ 2752 */
2763static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 2753static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2764{ 2754{
2765 struct iwl_priv *priv = hw->priv; 2755 struct iwl_priv *priv = hw->priv;
2766 const struct iwl_channel_info *ch_info; 2756 const struct iwl_channel_info *ch_info;
2757 struct ieee80211_conf *conf = &hw->conf;
2767 unsigned long flags; 2758 unsigned long flags;
2768 int ret = 0; 2759 int ret = 0;
2769 u16 channel; 2760 u16 channel;
@@ -2771,6 +2762,8 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
2771 mutex_lock(&priv->mutex); 2762 mutex_lock(&priv->mutex);
2772 IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); 2763 IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value);
2773 2764
2765 priv->current_ht_config.is_ht = conf->ht.enabled;
2766
2774 if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) { 2767 if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) {
2775 IWL_DEBUG_MAC80211("leave - RF-KILL - waiting for uCode\n"); 2768 IWL_DEBUG_MAC80211("leave - RF-KILL - waiting for uCode\n");
2776 goto out; 2769 goto out;
@@ -2828,13 +2821,13 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
2828 /* The list of supported rates and rate mask can be different 2821 /* The list of supported rates and rate mask can be different
2829 * for each band; since the band may have changed, reset 2822 * for each band; since the band may have changed, reset
2830 * the rate mask to what mac80211 lists */ 2823 * the rate mask to what mac80211 lists */
2831 iwl4965_set_rate(priv); 2824 iwl_set_rate(priv);
2832 2825
2833 spin_unlock_irqrestore(&priv->lock, flags); 2826 spin_unlock_irqrestore(&priv->lock, flags);
2834 2827
2835#ifdef IEEE80211_CONF_CHANNEL_SWITCH 2828#ifdef IEEE80211_CONF_CHANNEL_SWITCH
2836 if (conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) { 2829 if (conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) {
2837 iwl4965_hw_channel_switch(priv, conf->channel); 2830 iwl_hw_channel_switch(priv, conf->channel);
2838 goto out; 2831 goto out;
2839 } 2832 }
2840#endif 2833#endif
@@ -2862,11 +2855,11 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
2862 2855
2863 iwl_set_tx_power(priv, conf->power_level, false); 2856 iwl_set_tx_power(priv, conf->power_level, false);
2864 2857
2865 iwl4965_set_rate(priv); 2858 iwl_set_rate(priv);
2866 2859
2867 if (memcmp(&priv->active_rxon, 2860 if (memcmp(&priv->active_rxon,
2868 &priv->staging_rxon, sizeof(priv->staging_rxon))) 2861 &priv->staging_rxon, sizeof(priv->staging_rxon)))
2869 iwl4965_commit_rxon(priv); 2862 iwl_commit_rxon(priv);
2870 else 2863 else
2871 IWL_DEBUG_INFO("No re-sending same RXON configuration.\n"); 2864 IWL_DEBUG_INFO("No re-sending same RXON configuration.\n");
2872 2865
@@ -2877,7 +2870,7 @@ out:
2877 return ret; 2870 return ret;
2878} 2871}
2879 2872
2880static void iwl4965_config_ap(struct iwl_priv *priv) 2873static void iwl_config_ap(struct iwl_priv *priv)
2881{ 2874{
2882 int ret = 0; 2875 int ret = 0;
2883 unsigned long flags; 2876 unsigned long flags;
@@ -2886,15 +2879,14 @@ static void iwl4965_config_ap(struct iwl_priv *priv)
2886 return; 2879 return;
2887 2880
2888 /* The following should be done only at AP bring up */ 2881 /* The following should be done only at AP bring up */
2889 if (!(iwl_is_associated(priv))) { 2882 if (!iwl_is_associated(priv)) {
2890 2883
2891 /* RXON - unassoc (to set timing command) */ 2884 /* RXON - unassoc (to set timing command) */
2892 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2885 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2893 iwl4965_commit_rxon(priv); 2886 iwl_commit_rxon(priv);
2894 2887
2895 /* RXON Timing */ 2888 /* RXON Timing */
2896 memset(&priv->rxon_timing, 0, sizeof(struct iwl4965_rxon_time_cmd)); 2889 iwl_setup_rxon_timing(priv);
2897 iwl4965_setup_rxon_timing(priv);
2898 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 2890 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
2899 sizeof(priv->rxon_timing), &priv->rxon_timing); 2891 sizeof(priv->rxon_timing), &priv->rxon_timing);
2900 if (ret) 2892 if (ret)
@@ -2927,13 +2919,13 @@ static void iwl4965_config_ap(struct iwl_priv *priv)
2927 } 2919 }
2928 /* restore RXON assoc */ 2920 /* restore RXON assoc */
2929 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 2921 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
2930 iwl4965_commit_rxon(priv); 2922 iwl_commit_rxon(priv);
2931 spin_lock_irqsave(&priv->lock, flags); 2923 spin_lock_irqsave(&priv->lock, flags);
2932 iwl_activate_qos(priv, 1); 2924 iwl_activate_qos(priv, 1);
2933 spin_unlock_irqrestore(&priv->lock, flags); 2925 spin_unlock_irqrestore(&priv->lock, flags);
2934 iwl_rxon_add_station(priv, iwl_bcast_addr, 0); 2926 iwl_rxon_add_station(priv, iwl_bcast_addr, 0);
2935 } 2927 }
2936 iwl4965_send_beacon_cmd(priv); 2928 iwl_send_beacon_cmd(priv);
2937 2929
2938 /* FIXME - we need to add code here to detect a totally new 2930 /* FIXME - we need to add code here to detect a totally new
2939 * configuration, reset the AP, unassoc, rxon timing, assoc, 2931 * configuration, reset the AP, unassoc, rxon timing, assoc,
@@ -2941,15 +2933,13 @@ static void iwl4965_config_ap(struct iwl_priv *priv)
2941} 2933}
2942 2934
2943/* temporary */ 2935/* temporary */
2944static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb); 2936static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb);
2945 2937
2946static int iwl4965_mac_config_interface(struct ieee80211_hw *hw, 2938static int iwl_mac_config_interface(struct ieee80211_hw *hw,
2947 struct ieee80211_vif *vif, 2939 struct ieee80211_vif *vif,
2948 struct ieee80211_if_conf *conf) 2940 struct ieee80211_if_conf *conf)
2949{ 2941{
2950 struct iwl_priv *priv = hw->priv; 2942 struct iwl_priv *priv = hw->priv;
2951 DECLARE_MAC_BUF(mac);
2952 unsigned long flags;
2953 int rc; 2943 int rc;
2954 2944
2955 if (conf == NULL) 2945 if (conf == NULL)
@@ -2965,26 +2955,18 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
2965 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); 2955 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
2966 if (!beacon) 2956 if (!beacon)
2967 return -ENOMEM; 2957 return -ENOMEM;
2968 rc = iwl4965_mac_beacon_update(hw, beacon); 2958 rc = iwl_mac_beacon_update(hw, beacon);
2969 if (rc) 2959 if (rc)
2970 return rc; 2960 return rc;
2971 } 2961 }
2972 2962
2973 if ((priv->iw_mode == NL80211_IFTYPE_AP) &&
2974 (!conf->ssid_len)) {
2975 IWL_DEBUG_MAC80211
2976 ("Leaving in AP mode because HostAPD is not ready.\n");
2977 return 0;
2978 }
2979
2980 if (!iwl_is_alive(priv)) 2963 if (!iwl_is_alive(priv))
2981 return -EAGAIN; 2964 return -EAGAIN;
2982 2965
2983 mutex_lock(&priv->mutex); 2966 mutex_lock(&priv->mutex);
2984 2967
2985 if (conf->bssid) 2968 if (conf->bssid)
2986 IWL_DEBUG_MAC80211("bssid: %s\n", 2969 IWL_DEBUG_MAC80211("bssid: %pM\n", conf->bssid);
2987 print_mac(mac, conf->bssid));
2988 2970
2989/* 2971/*
2990 * very dubious code was here; the probe filtering flag is never set: 2972 * very dubious code was here; the probe filtering flag is never set:
@@ -2997,8 +2979,8 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
2997 if (!conf->bssid) { 2979 if (!conf->bssid) {
2998 conf->bssid = priv->mac_addr; 2980 conf->bssid = priv->mac_addr;
2999 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN); 2981 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
3000 IWL_DEBUG_MAC80211("bssid was set to: %s\n", 2982 IWL_DEBUG_MAC80211("bssid was set to: %pM\n",
3001 print_mac(mac, conf->bssid)); 2983 conf->bssid);
3002 } 2984 }
3003 if (priv->ibss_beacon) 2985 if (priv->ibss_beacon)
3004 dev_kfree_skb(priv->ibss_beacon); 2986 dev_kfree_skb(priv->ibss_beacon);
@@ -3029,9 +3011,9 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
3029 memcpy(priv->bssid, conf->bssid, ETH_ALEN); 3011 memcpy(priv->bssid, conf->bssid, ETH_ALEN);
3030 3012
3031 if (priv->iw_mode == NL80211_IFTYPE_AP) 3013 if (priv->iw_mode == NL80211_IFTYPE_AP)
3032 iwl4965_config_ap(priv); 3014 iwl_config_ap(priv);
3033 else { 3015 else {
3034 rc = iwl4965_commit_rxon(priv); 3016 rc = iwl_commit_rxon(priv);
3035 if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc) 3017 if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc)
3036 iwl_rxon_add_station( 3018 iwl_rxon_add_station(
3037 priv, priv->active_rxon.bssid_addr, 1); 3019 priv, priv->active_rxon.bssid_addr, 1);
@@ -3040,26 +3022,17 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
3040 } else { 3022 } else {
3041 iwl_scan_cancel_timeout(priv, 100); 3023 iwl_scan_cancel_timeout(priv, 100);
3042 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3024 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3043 iwl4965_commit_rxon(priv); 3025 iwl_commit_rxon(priv);
3044 } 3026 }
3045 3027
3046 done: 3028 done:
3047 spin_lock_irqsave(&priv->lock, flags);
3048 if (!conf->ssid_len)
3049 memset(priv->essid, 0, IW_ESSID_MAX_SIZE);
3050 else
3051 memcpy(priv->essid, conf->ssid, conf->ssid_len);
3052
3053 priv->essid_len = conf->ssid_len;
3054 spin_unlock_irqrestore(&priv->lock, flags);
3055
3056 IWL_DEBUG_MAC80211("leave\n"); 3029 IWL_DEBUG_MAC80211("leave\n");
3057 mutex_unlock(&priv->mutex); 3030 mutex_unlock(&priv->mutex);
3058 3031
3059 return 0; 3032 return 0;
3060} 3033}
3061 3034
3062static void iwl4965_configure_filter(struct ieee80211_hw *hw, 3035static void iwl_configure_filter(struct ieee80211_hw *hw,
3063 unsigned int changed_flags, 3036 unsigned int changed_flags,
3064 unsigned int *total_flags, 3037 unsigned int *total_flags,
3065 int mc_count, struct dev_addr_list *mc_list) 3038 int mc_count, struct dev_addr_list *mc_list)
@@ -3078,7 +3051,7 @@ static void iwl4965_configure_filter(struct ieee80211_hw *hw,
3078 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 3051 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
3079} 3052}
3080 3053
3081static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw, 3054static void iwl_mac_remove_interface(struct ieee80211_hw *hw,
3082 struct ieee80211_if_init_conf *conf) 3055 struct ieee80211_if_init_conf *conf)
3083{ 3056{
3084 struct iwl_priv *priv = hw->priv; 3057 struct iwl_priv *priv = hw->priv;
@@ -3090,13 +3063,11 @@ static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw,
3090 if (iwl_is_ready_rf(priv)) { 3063 if (iwl_is_ready_rf(priv)) {
3091 iwl_scan_cancel_timeout(priv, 100); 3064 iwl_scan_cancel_timeout(priv, 100);
3092 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3065 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3093 iwl4965_commit_rxon(priv); 3066 iwl_commit_rxon(priv);
3094 } 3067 }
3095 if (priv->vif == conf->vif) { 3068 if (priv->vif == conf->vif) {
3096 priv->vif = NULL; 3069 priv->vif = NULL;
3097 memset(priv->bssid, 0, ETH_ALEN); 3070 memset(priv->bssid, 0, ETH_ALEN);
3098 memset(priv->essid, 0, IW_ESSID_MAX_SIZE);
3099 priv->essid_len = 0;
3100 } 3071 }
3101 mutex_unlock(&priv->mutex); 3072 mutex_unlock(&priv->mutex);
3102 3073
@@ -3105,7 +3076,7 @@ static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw,
3105} 3076}
3106 3077
3107#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) 3078#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
3108static void iwl4965_bss_info_changed(struct ieee80211_hw *hw, 3079static void iwl_bss_info_changed(struct ieee80211_hw *hw,
3109 struct ieee80211_vif *vif, 3080 struct ieee80211_vif *vif,
3110 struct ieee80211_bss_conf *bss_conf, 3081 struct ieee80211_bss_conf *bss_conf,
3111 u32 changes) 3082 u32 changes)
@@ -3132,8 +3103,7 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
3132 } 3103 }
3133 3104
3134 if (changes & BSS_CHANGED_HT) { 3105 if (changes & BSS_CHANGED_HT) {
3135 IWL_DEBUG_MAC80211("HT %d\n", bss_conf->assoc_ht); 3106 iwl_ht_conf(priv, bss_conf);
3136 iwl4965_ht_conf(priv, bss_conf);
3137 iwl_set_rxon_chain(priv); 3107 iwl_set_rxon_chain(priv);
3138 } 3108 }
3139 3109
@@ -3156,7 +3126,7 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
3156 priv->next_scan_jiffies = jiffies + 3126 priv->next_scan_jiffies = jiffies +
3157 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC; 3127 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
3158 mutex_lock(&priv->mutex); 3128 mutex_lock(&priv->mutex);
3159 iwl4965_post_associate(priv); 3129 iwl_post_associate(priv);
3160 mutex_unlock(&priv->mutex); 3130 mutex_unlock(&priv->mutex);
3161 } else { 3131 } else {
3162 priv->assoc_id = 0; 3132 priv->assoc_id = 0;
@@ -3232,7 +3202,7 @@ out_unlock:
3232 return ret; 3202 return ret;
3233} 3203}
3234 3204
3235static void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, 3205static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
3236 struct ieee80211_key_conf *keyconf, const u8 *addr, 3206 struct ieee80211_key_conf *keyconf, const u8 *addr,
3237 u32 iv32, u16 *phase1key) 3207 u32 iv32, u16 *phase1key)
3238{ 3208{
@@ -3241,14 +3211,13 @@ static void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw,
3241 unsigned long flags; 3211 unsigned long flags;
3242 __le16 key_flags = 0; 3212 __le16 key_flags = 0;
3243 int i; 3213 int i;
3244 DECLARE_MAC_BUF(mac);
3245 3214
3246 IWL_DEBUG_MAC80211("enter\n"); 3215 IWL_DEBUG_MAC80211("enter\n");
3247 3216
3248 sta_id = iwl_find_station(priv, addr); 3217 sta_id = iwl_find_station(priv, addr);
3249 if (sta_id == IWL_INVALID_STATION) { 3218 if (sta_id == IWL_INVALID_STATION) {
3250 IWL_DEBUG_MAC80211("leave - %s not in station map.\n", 3219 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n",
3251 print_mac(mac, addr)); 3220 addr);
3252 return; 3221 return;
3253 } 3222 }
3254 3223
@@ -3284,12 +3253,11 @@ static void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw,
3284 IWL_DEBUG_MAC80211("leave\n"); 3253 IWL_DEBUG_MAC80211("leave\n");
3285} 3254}
3286 3255
3287static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 3256static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3288 const u8 *local_addr, const u8 *addr, 3257 const u8 *local_addr, const u8 *addr,
3289 struct ieee80211_key_conf *key) 3258 struct ieee80211_key_conf *key)
3290{ 3259{
3291 struct iwl_priv *priv = hw->priv; 3260 struct iwl_priv *priv = hw->priv;
3292 DECLARE_MAC_BUF(mac);
3293 int ret = 0; 3261 int ret = 0;
3294 u8 sta_id = IWL_INVALID_STATION; 3262 u8 sta_id = IWL_INVALID_STATION;
3295 u8 is_default_wep_key = 0; 3263 u8 is_default_wep_key = 0;
@@ -3307,8 +3275,8 @@ static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3307 3275
3308 sta_id = iwl_find_station(priv, addr); 3276 sta_id = iwl_find_station(priv, addr);
3309 if (sta_id == IWL_INVALID_STATION) { 3277 if (sta_id == IWL_INVALID_STATION) {
3310 IWL_DEBUG_MAC80211("leave - %s not in station map.\n", 3278 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n",
3311 print_mac(mac, addr)); 3279 addr);
3312 return -EINVAL; 3280 return -EINVAL;
3313 3281
3314 } 3282 }
@@ -3356,7 +3324,7 @@ static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3356 return ret; 3324 return ret;
3357} 3325}
3358 3326
3359static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, 3327static int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
3360 const struct ieee80211_tx_queue_params *params) 3328 const struct ieee80211_tx_queue_params *params)
3361{ 3329{
3362 struct iwl_priv *priv = hw->priv; 3330 struct iwl_priv *priv = hw->priv;
@@ -3404,15 +3372,14 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
3404 return 0; 3372 return 0;
3405} 3373}
3406 3374
3407static int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, 3375static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3408 enum ieee80211_ampdu_mlme_action action, 3376 enum ieee80211_ampdu_mlme_action action,
3409 struct ieee80211_sta *sta, u16 tid, u16 *ssn) 3377 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
3410{ 3378{
3411 struct iwl_priv *priv = hw->priv; 3379 struct iwl_priv *priv = hw->priv;
3412 DECLARE_MAC_BUF(mac);
3413 3380
3414 IWL_DEBUG_HT("A-MPDU action on addr %s tid %d\n", 3381 IWL_DEBUG_HT("A-MPDU action on addr %pM tid %d\n",
3415 print_mac(mac, sta->addr), tid); 3382 sta->addr, tid);
3416 3383
3417 if (!(priv->cfg->sku & IWL_SKU_N)) 3384 if (!(priv->cfg->sku & IWL_SKU_N))
3418 return -EACCES; 3385 return -EACCES;
@@ -3437,7 +3404,7 @@ static int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
3437 } 3404 }
3438 return 0; 3405 return 0;
3439} 3406}
3440static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, 3407static int iwl_mac_get_tx_stats(struct ieee80211_hw *hw,
3441 struct ieee80211_tx_queue_stats *stats) 3408 struct ieee80211_tx_queue_stats *stats)
3442{ 3409{
3443 struct iwl_priv *priv = hw->priv; 3410 struct iwl_priv *priv = hw->priv;
@@ -3472,7 +3439,7 @@ static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw,
3472 return 0; 3439 return 0;
3473} 3440}
3474 3441
3475static int iwl4965_mac_get_stats(struct ieee80211_hw *hw, 3442static int iwl_mac_get_stats(struct ieee80211_hw *hw,
3476 struct ieee80211_low_level_stats *stats) 3443 struct ieee80211_low_level_stats *stats)
3477{ 3444{
3478 struct iwl_priv *priv = hw->priv; 3445 struct iwl_priv *priv = hw->priv;
@@ -3484,7 +3451,7 @@ static int iwl4965_mac_get_stats(struct ieee80211_hw *hw,
3484 return 0; 3451 return 0;
3485} 3452}
3486 3453
3487static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw) 3454static void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
3488{ 3455{
3489 struct iwl_priv *priv = hw->priv; 3456 struct iwl_priv *priv = hw->priv;
3490 unsigned long flags; 3457 unsigned long flags;
@@ -3528,7 +3495,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
3528 if (priv->iw_mode != NL80211_IFTYPE_AP) { 3495 if (priv->iw_mode != NL80211_IFTYPE_AP) {
3529 iwl_scan_cancel_timeout(priv, 100); 3496 iwl_scan_cancel_timeout(priv, 100);
3530 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3497 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3531 iwl4965_commit_rxon(priv); 3498 iwl_commit_rxon(priv);
3532 } 3499 }
3533 3500
3534 iwl_power_update_mode(priv, 0); 3501 iwl_power_update_mode(priv, 0);
@@ -3551,14 +3518,14 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
3551 return; 3518 return;
3552 } 3519 }
3553 3520
3554 iwl4965_set_rate(priv); 3521 iwl_set_rate(priv);
3555 3522
3556 mutex_unlock(&priv->mutex); 3523 mutex_unlock(&priv->mutex);
3557 3524
3558 IWL_DEBUG_MAC80211("leave\n"); 3525 IWL_DEBUG_MAC80211("leave\n");
3559} 3526}
3560 3527
3561static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) 3528static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
3562{ 3529{
3563 struct iwl_priv *priv = hw->priv; 3530 struct iwl_priv *priv = hw->priv;
3564 unsigned long flags; 3531 unsigned long flags;
@@ -3595,7 +3562,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
3595 3562
3596 iwl_reset_qos(priv); 3563 iwl_reset_qos(priv);
3597 3564
3598 iwl4965_post_associate(priv); 3565 iwl_post_associate(priv);
3599 3566
3600 mutex_unlock(&priv->mutex); 3567 mutex_unlock(&priv->mutex);
3601 3568
@@ -3749,7 +3716,7 @@ static ssize_t store_flags(struct device *d,
3749 else { 3716 else {
3750 IWL_DEBUG_INFO("Commit rxon.flags = 0x%04X\n", flags); 3717 IWL_DEBUG_INFO("Commit rxon.flags = 0x%04X\n", flags);
3751 priv->staging_rxon.flags = cpu_to_le32(flags); 3718 priv->staging_rxon.flags = cpu_to_le32(flags);
3752 iwl4965_commit_rxon(priv); 3719 iwl_commit_rxon(priv);
3753 } 3720 }
3754 } 3721 }
3755 mutex_unlock(&priv->mutex); 3722 mutex_unlock(&priv->mutex);
@@ -3790,7 +3757,7 @@ static ssize_t store_filter_flags(struct device *d,
3790 "0x%04X\n", filter_flags); 3757 "0x%04X\n", filter_flags);
3791 priv->staging_rxon.filter_flags = 3758 priv->staging_rxon.filter_flags =
3792 cpu_to_le32(filter_flags); 3759 cpu_to_le32(filter_flags);
3793 iwl4965_commit_rxon(priv); 3760 iwl_commit_rxon(priv);
3794 } 3761 }
3795 } 3762 }
3796 mutex_unlock(&priv->mutex); 3763 mutex_unlock(&priv->mutex);
@@ -3865,7 +3832,7 @@ static ssize_t store_measurement(struct device *d,
3865 3832
3866 IWL_DEBUG_INFO("Invoking measurement of type %d on " 3833 IWL_DEBUG_INFO("Invoking measurement of type %d on "
3867 "channel %d (for '%s')\n", type, params.channel, buf); 3834 "channel %d (for '%s')\n", type, params.channel, buf);
3868 iwl4965_get_measurement(priv, &params, type); 3835 iwl_get_measurement(priv, &params, type);
3869 3836
3870 return count; 3837 return count;
3871} 3838}
@@ -4085,12 +4052,12 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
4085 4052
4086 init_waitqueue_head(&priv->wait_command_queue); 4053 init_waitqueue_head(&priv->wait_command_queue);
4087 4054
4088 INIT_WORK(&priv->up, iwl4965_bg_up); 4055 INIT_WORK(&priv->up, iwl_bg_up);
4089 INIT_WORK(&priv->restart, iwl4965_bg_restart); 4056 INIT_WORK(&priv->restart, iwl_bg_restart);
4090 INIT_WORK(&priv->rx_replenish, iwl4965_bg_rx_replenish); 4057 INIT_WORK(&priv->rx_replenish, iwl_bg_rx_replenish);
4091 INIT_WORK(&priv->rf_kill, iwl4965_bg_rf_kill); 4058 INIT_WORK(&priv->rf_kill, iwl_bg_rf_kill);
4092 INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); 4059 INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update);
4093 INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); 4060 INIT_WORK(&priv->set_monitor, iwl_bg_set_monitor);
4094 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); 4061 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work);
4095 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); 4062 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start);
4096 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); 4063 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start);
@@ -4103,10 +4070,10 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
4103 4070
4104 init_timer(&priv->statistics_periodic); 4071 init_timer(&priv->statistics_periodic);
4105 priv->statistics_periodic.data = (unsigned long)priv; 4072 priv->statistics_periodic.data = (unsigned long)priv;
4106 priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; 4073 priv->statistics_periodic.function = iwl_bg_statistics_periodic;
4107 4074
4108 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 4075 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
4109 iwl4965_irq_tasklet, (unsigned long)priv); 4076 iwl_irq_tasklet, (unsigned long)priv);
4110} 4077}
4111 4078
4112static void iwl_cancel_deferred_work(struct iwl_priv *priv) 4079static void iwl_cancel_deferred_work(struct iwl_priv *priv)
@@ -4122,7 +4089,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
4122 del_timer_sync(&priv->statistics_periodic); 4089 del_timer_sync(&priv->statistics_periodic);
4123} 4090}
4124 4091
4125static struct attribute *iwl4965_sysfs_entries[] = { 4092static struct attribute *iwl_sysfs_entries[] = {
4126 &dev_attr_channels.attr, 4093 &dev_attr_channels.attr,
4127 &dev_attr_flags.attr, 4094 &dev_attr_flags.attr,
4128 &dev_attr_filter_flags.attr, 4095 &dev_attr_filter_flags.attr,
@@ -4143,39 +4110,38 @@ static struct attribute *iwl4965_sysfs_entries[] = {
4143 NULL 4110 NULL
4144}; 4111};
4145 4112
4146static struct attribute_group iwl4965_attribute_group = { 4113static struct attribute_group iwl_attribute_group = {
4147 .name = NULL, /* put in device directory */ 4114 .name = NULL, /* put in device directory */
4148 .attrs = iwl4965_sysfs_entries, 4115 .attrs = iwl_sysfs_entries,
4149}; 4116};
4150 4117
4151static struct ieee80211_ops iwl4965_hw_ops = { 4118static struct ieee80211_ops iwl_hw_ops = {
4152 .tx = iwl4965_mac_tx, 4119 .tx = iwl_mac_tx,
4153 .start = iwl4965_mac_start, 4120 .start = iwl_mac_start,
4154 .stop = iwl4965_mac_stop, 4121 .stop = iwl_mac_stop,
4155 .add_interface = iwl4965_mac_add_interface, 4122 .add_interface = iwl_mac_add_interface,
4156 .remove_interface = iwl4965_mac_remove_interface, 4123 .remove_interface = iwl_mac_remove_interface,
4157 .config = iwl4965_mac_config, 4124 .config = iwl_mac_config,
4158 .config_interface = iwl4965_mac_config_interface, 4125 .config_interface = iwl_mac_config_interface,
4159 .configure_filter = iwl4965_configure_filter, 4126 .configure_filter = iwl_configure_filter,
4160 .set_key = iwl4965_mac_set_key, 4127 .set_key = iwl_mac_set_key,
4161 .update_tkip_key = iwl4965_mac_update_tkip_key, 4128 .update_tkip_key = iwl_mac_update_tkip_key,
4162 .get_stats = iwl4965_mac_get_stats, 4129 .get_stats = iwl_mac_get_stats,
4163 .get_tx_stats = iwl4965_mac_get_tx_stats, 4130 .get_tx_stats = iwl_mac_get_tx_stats,
4164 .conf_tx = iwl4965_mac_conf_tx, 4131 .conf_tx = iwl_mac_conf_tx,
4165 .reset_tsf = iwl4965_mac_reset_tsf, 4132 .reset_tsf = iwl_mac_reset_tsf,
4166 .bss_info_changed = iwl4965_bss_info_changed, 4133 .bss_info_changed = iwl_bss_info_changed,
4167 .ampdu_action = iwl4965_mac_ampdu_action, 4134 .ampdu_action = iwl_mac_ampdu_action,
4168 .hw_scan = iwl_mac_hw_scan 4135 .hw_scan = iwl_mac_hw_scan
4169}; 4136};
4170 4137
4171static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 4138static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4172{ 4139{
4173 int err = 0; 4140 int err = 0;
4174 struct iwl_priv *priv; 4141 struct iwl_priv *priv;
4175 struct ieee80211_hw *hw; 4142 struct ieee80211_hw *hw;
4176 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 4143 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
4177 unsigned long flags; 4144 unsigned long flags;
4178 DECLARE_MAC_BUF(mac);
4179 4145
4180 /************************ 4146 /************************
4181 * 1. Allocating HW data 4147 * 1. Allocating HW data
@@ -4187,10 +4153,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4187 if (cfg->mod_params->debug & IWL_DL_INFO) 4153 if (cfg->mod_params->debug & IWL_DL_INFO)
4188 dev_printk(KERN_DEBUG, &(pdev->dev), 4154 dev_printk(KERN_DEBUG, &(pdev->dev),
4189 "Disabling hw_scan\n"); 4155 "Disabling hw_scan\n");
4190 iwl4965_hw_ops.hw_scan = NULL; 4156 iwl_hw_ops.hw_scan = NULL;
4191 } 4157 }
4192 4158
4193 hw = iwl_alloc_all(cfg, &iwl4965_hw_ops); 4159 hw = iwl_alloc_all(cfg, &iwl_hw_ops);
4194 if (!hw) { 4160 if (!hw) {
4195 err = -ENOMEM; 4161 err = -ENOMEM;
4196 goto out; 4162 goto out;
@@ -4284,7 +4250,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4284 4250
4285 /* extract MAC Address */ 4251 /* extract MAC Address */
4286 iwl_eeprom_get_mac(priv, priv->mac_addr); 4252 iwl_eeprom_get_mac(priv, priv->mac_addr);
4287 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); 4253 IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr);
4288 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 4254 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
4289 4255
4290 /************************ 4256 /************************
@@ -4318,10 +4284,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4318 * 8. Setup services 4284 * 8. Setup services
4319 ********************/ 4285 ********************/
4320 spin_lock_irqsave(&priv->lock, flags); 4286 spin_lock_irqsave(&priv->lock, flags);
4321 iwl4965_disable_interrupts(priv); 4287 iwl_disable_interrupts(priv);
4322 spin_unlock_irqrestore(&priv->lock, flags); 4288 spin_unlock_irqrestore(&priv->lock, flags);
4323 4289
4324 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); 4290 err = sysfs_create_group(&pdev->dev.kobj, &iwl_attribute_group);
4325 if (err) { 4291 if (err) {
4326 IWL_ERROR("failed to create sysfs device attributes\n"); 4292 IWL_ERROR("failed to create sysfs device attributes\n");
4327 goto out_uninit_drv; 4293 goto out_uninit_drv;
@@ -4357,7 +4323,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4357 return 0; 4323 return 0;
4358 4324
4359 out_remove_sysfs: 4325 out_remove_sysfs:
4360 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); 4326 sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group);
4361 out_uninit_drv: 4327 out_uninit_drv:
4362 iwl_uninit_drv(priv); 4328 iwl_uninit_drv(priv);
4363 out_free_eeprom: 4329 out_free_eeprom:
@@ -4375,7 +4341,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4375 return err; 4341 return err;
4376} 4342}
4377 4343
4378static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) 4344static void __devexit iwl_pci_remove(struct pci_dev *pdev)
4379{ 4345{
4380 struct iwl_priv *priv = pci_get_drvdata(pdev); 4346 struct iwl_priv *priv = pci_get_drvdata(pdev);
4381 unsigned long flags; 4347 unsigned long flags;
@@ -4386,10 +4352,10 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
4386 IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n"); 4352 IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n");
4387 4353
4388 iwl_dbgfs_unregister(priv); 4354 iwl_dbgfs_unregister(priv);
4389 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); 4355 sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group);
4390 4356
4391 /* ieee80211_unregister_hw call wil cause iwl4965_mac_stop to 4357 /* ieee80211_unregister_hw call wil cause iwl_mac_stop to
4392 * to be called and iwl4965_down since we are removing the device 4358 * to be called and iwl_down since we are removing the device
4393 * we need to set STATUS_EXIT_PENDING bit. 4359 * we need to set STATUS_EXIT_PENDING bit.
4394 */ 4360 */
4395 set_bit(STATUS_EXIT_PENDING, &priv->status); 4361 set_bit(STATUS_EXIT_PENDING, &priv->status);
@@ -4397,20 +4363,20 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
4397 ieee80211_unregister_hw(priv->hw); 4363 ieee80211_unregister_hw(priv->hw);
4398 priv->mac80211_registered = 0; 4364 priv->mac80211_registered = 0;
4399 } else { 4365 } else {
4400 iwl4965_down(priv); 4366 iwl_down(priv);
4401 } 4367 }
4402 4368
4403 /* make sure we flush any pending irq or 4369 /* make sure we flush any pending irq or
4404 * tasklet for the driver 4370 * tasklet for the driver
4405 */ 4371 */
4406 spin_lock_irqsave(&priv->lock, flags); 4372 spin_lock_irqsave(&priv->lock, flags);
4407 iwl4965_disable_interrupts(priv); 4373 iwl_disable_interrupts(priv);
4408 spin_unlock_irqrestore(&priv->lock, flags); 4374 spin_unlock_irqrestore(&priv->lock, flags);
4409 4375
4410 iwl_synchronize_irq(priv); 4376 iwl_synchronize_irq(priv);
4411 4377
4412 iwl_rfkill_unregister(priv); 4378 iwl_rfkill_unregister(priv);
4413 iwl4965_dealloc_ucode_pci(priv); 4379 iwl_dealloc_ucode_pci(priv);
4414 4380
4415 if (priv->rxq.bd) 4381 if (priv->rxq.bd)
4416 iwl_rx_queue_free(priv, &priv->rxq); 4382 iwl_rx_queue_free(priv, &priv->rxq);
@@ -4423,7 +4389,7 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
4423 /*netif_stop_queue(dev); */ 4389 /*netif_stop_queue(dev); */
4424 flush_workqueue(priv->workqueue); 4390 flush_workqueue(priv->workqueue);
4425 4391
4426 /* ieee80211_unregister_hw calls iwl4965_mac_stop, which flushes 4392 /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes
4427 * priv->workqueue... so we can't take down the workqueue 4393 * priv->workqueue... so we can't take down the workqueue
4428 * until now... */ 4394 * until now... */
4429 destroy_workqueue(priv->workqueue); 4395 destroy_workqueue(priv->workqueue);
@@ -4444,13 +4410,13 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
4444 4410
4445#ifdef CONFIG_PM 4411#ifdef CONFIG_PM
4446 4412
4447static int iwl4965_pci_suspend(struct pci_dev *pdev, pm_message_t state) 4413static int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
4448{ 4414{
4449 struct iwl_priv *priv = pci_get_drvdata(pdev); 4415 struct iwl_priv *priv = pci_get_drvdata(pdev);
4450 4416
4451 if (priv->is_open) { 4417 if (priv->is_open) {
4452 set_bit(STATUS_IN_SUSPEND, &priv->status); 4418 set_bit(STATUS_IN_SUSPEND, &priv->status);
4453 iwl4965_mac_stop(priv->hw); 4419 iwl_mac_stop(priv->hw);
4454 priv->is_open = 1; 4420 priv->is_open = 1;
4455 } 4421 }
4456 4422
@@ -4459,14 +4425,14 @@ static int iwl4965_pci_suspend(struct pci_dev *pdev, pm_message_t state)
4459 return 0; 4425 return 0;
4460} 4426}
4461 4427
4462static int iwl4965_pci_resume(struct pci_dev *pdev) 4428static int iwl_pci_resume(struct pci_dev *pdev)
4463{ 4429{
4464 struct iwl_priv *priv = pci_get_drvdata(pdev); 4430 struct iwl_priv *priv = pci_get_drvdata(pdev);
4465 4431
4466 pci_set_power_state(pdev, PCI_D0); 4432 pci_set_power_state(pdev, PCI_D0);
4467 4433
4468 if (priv->is_open) 4434 if (priv->is_open)
4469 iwl4965_mac_start(priv->hw); 4435 iwl_mac_start(priv->hw);
4470 4436
4471 clear_bit(STATUS_IN_SUSPEND, &priv->status); 4437 clear_bit(STATUS_IN_SUSPEND, &priv->status);
4472 return 0; 4438 return 0;
@@ -4509,15 +4475,15 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
4509static struct pci_driver iwl_driver = { 4475static struct pci_driver iwl_driver = {
4510 .name = DRV_NAME, 4476 .name = DRV_NAME,
4511 .id_table = iwl_hw_card_ids, 4477 .id_table = iwl_hw_card_ids,
4512 .probe = iwl4965_pci_probe, 4478 .probe = iwl_pci_probe,
4513 .remove = __devexit_p(iwl4965_pci_remove), 4479 .remove = __devexit_p(iwl_pci_remove),
4514#ifdef CONFIG_PM 4480#ifdef CONFIG_PM
4515 .suspend = iwl4965_pci_suspend, 4481 .suspend = iwl_pci_suspend,
4516 .resume = iwl4965_pci_resume, 4482 .resume = iwl_pci_resume,
4517#endif 4483#endif
4518}; 4484};
4519 4485
4520static int __init iwl4965_init(void) 4486static int __init iwl_init(void)
4521{ 4487{
4522 4488
4523 int ret; 4489 int ret;
@@ -4543,11 +4509,11 @@ error_register:
4543 return ret; 4509 return ret;
4544} 4510}
4545 4511
4546static void __exit iwl4965_exit(void) 4512static void __exit iwl_exit(void)
4547{ 4513{
4548 pci_unregister_driver(&iwl_driver); 4514 pci_unregister_driver(&iwl_driver);
4549 iwlagn_rate_control_unregister(); 4515 iwlagn_rate_control_unregister();
4550} 4516}
4551 4517
4552module_exit(iwl4965_exit); 4518module_exit(iwl_exit);
4553module_init(iwl4965_init); 4519module_init(iwl_init);
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 72fbf47229db..25f4658f1a76 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -70,7 +70,7 @@
70 * INIT calibrations framework 70 * INIT calibrations framework
71 *****************************************************************************/ 71 *****************************************************************************/
72 72
73 int iwl_send_calib_results(struct iwl_priv *priv) 73int iwl_send_calib_results(struct iwl_priv *priv)
74{ 74{
75 int ret = 0; 75 int ret = 0;
76 int i = 0; 76 int i = 0;
@@ -80,14 +80,16 @@
80 .meta.flags = CMD_SIZE_HUGE, 80 .meta.flags = CMD_SIZE_HUGE,
81 }; 81 };
82 82
83 for (i = 0; i < IWL_CALIB_MAX; i++) 83 for (i = 0; i < IWL_CALIB_MAX; i++) {
84 if (priv->calib_results[i].buf) { 84 if ((BIT(i) & priv->hw_params.calib_init_cfg) &&
85 priv->calib_results[i].buf) {
85 hcmd.len = priv->calib_results[i].buf_len; 86 hcmd.len = priv->calib_results[i].buf_len;
86 hcmd.data = priv->calib_results[i].buf; 87 hcmd.data = priv->calib_results[i].buf;
87 ret = iwl_send_cmd_sync(priv, &hcmd); 88 ret = iwl_send_cmd_sync(priv, &hcmd);
88 if (ret) 89 if (ret)
89 goto err; 90 goto err;
90 } 91 }
92 }
91 93
92 return 0; 94 return 0;
93err: 95err:
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 8d04e966ad48..8aade00e165a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -66,8 +66,8 @@
66 * Please use iwl-dev.h for driver implementation definitions. 66 * Please use iwl-dev.h for driver implementation definitions.
67 */ 67 */
68 68
69#ifndef __iwl4965_commands_h__ 69#ifndef __iwl_commands_h__
70#define __iwl4965_commands_h__ 70#define __iwl_commands_h__
71 71
72enum { 72enum {
73 REPLY_ALIVE = 0x1, 73 REPLY_ALIVE = 0x1,
@@ -98,6 +98,11 @@ enum {
98 COEX_MEDIUM_NOTIFICATION = 0x5b, 98 COEX_MEDIUM_NOTIFICATION = 0x5b,
99 COEX_EVENT_CMD = 0x5c, 99 COEX_EVENT_CMD = 0x5c,
100 100
101 /* Calibration */
102 CALIBRATION_CFG_CMD = 0x65,
103 CALIBRATION_RES_NOTIFICATION = 0x66,
104 CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
105
101 /* 802.11h related */ 106 /* 802.11h related */
102 RADAR_NOTIFICATION = 0x70, /* not used */ 107 RADAR_NOTIFICATION = 0x70, /* not used */
103 REPLY_QUIET_CMD = 0x71, /* not used */ 108 REPLY_QUIET_CMD = 0x71, /* not used */
@@ -129,7 +134,7 @@ enum {
129 REPLY_TX_POWER_DBM_CMD = 0x98, 134 REPLY_TX_POWER_DBM_CMD = 0x98,
130 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */ 135 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
131 136
132 /* Bluetooth device coexistance config command */ 137 /* Bluetooth device coexistence config command */
133 REPLY_BT_CONFIG = 0x9b, 138 REPLY_BT_CONFIG = 0x9b,
134 139
135 /* Statistics */ 140 /* Statistics */
@@ -180,7 +185,7 @@ struct iwl_cmd_header {
180 u8 cmd; /* Command ID: REPLY_RXON, etc. */ 185 u8 cmd; /* Command ID: REPLY_RXON, etc. */
181 u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ 186 u8 flags; /* 0:5 reserved, 6 abort, 7 internal */
182 /* 187 /*
183 * The driver sets up the sequence number to values of its chosing. 188 * The driver sets up the sequence number to values of its choosing.
184 * uCode does not use this value, but passes it back to the driver 189 * uCode does not use this value, but passes it back to the driver
185 * when sending the response to each driver-originated command, so 190 * when sending the response to each driver-originated command, so
186 * the driver can match the response to the command. Since the values 191 * the driver can match the response to the command. Since the values
@@ -278,18 +283,20 @@ struct iwl_cmd_header {
278#define RATE_MCS_SGI_MSK 0x2000 283#define RATE_MCS_SGI_MSK 0x2000
279 284
280/** 285/**
281 * rate_n_flags Tx antenna masks (4965 has 2 transmitters): 286 * rate_n_flags Tx antenna masks
282 * bit14:15 01 B inactive, A active 287 * 4965 has 2 transmitters
283 * 10 B active, A inactive 288 * 5100 has 1 transmitter B
284 * 11 Both active 289 * 5150 has 1 transmitter A
290 * 5300 has 3 transmitters
291 * 5350 has 3 transmitters
292 * bit14:16
285 */ 293 */
286#define RATE_MCS_ANT_POS 14 294#define RATE_MCS_ANT_POS 14
287#define RATE_MCS_ANT_A_MSK 0x04000 295#define RATE_MCS_ANT_A_MSK 0x04000
288#define RATE_MCS_ANT_B_MSK 0x08000 296#define RATE_MCS_ANT_B_MSK 0x08000
289#define RATE_MCS_ANT_C_MSK 0x10000 297#define RATE_MCS_ANT_C_MSK 0x10000
290#define RATE_MCS_ANT_ABC_MSK 0x1C000 298#define RATE_MCS_ANT_ABC_MSK 0x1C000
291 299#define RATE_ANT_NUM 3
292#define RATE_MCS_ANT_INIT_IND 1
293 300
294#define POWER_TABLE_NUM_ENTRIES 33 301#define POWER_TABLE_NUM_ENTRIES 33
295#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32 302#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
@@ -340,7 +347,7 @@ struct iwl4965_tx_power_db {
340} __attribute__ ((packed)); 347} __attribute__ ((packed));
341 348
342/** 349/**
343 * Commad REPLY_TX_POWER_DBM_CMD = 0x98 350 * Command REPLY_TX_POWER_DBM_CMD = 0x98
344 * struct iwl5000_tx_power_dbm_cmd 351 * struct iwl5000_tx_power_dbm_cmd
345 */ 352 */
346#define IWL50_TX_POWER_AUTO 0x7f 353#define IWL50_TX_POWER_AUTO 0x7f
@@ -376,7 +383,7 @@ struct iwl5000_tx_power_dbm_cmd {
376 * calculating txpower settings: 383 * calculating txpower settings:
377 * 384 *
378 * 1) Power supply voltage indication. The voltage sensor outputs higher 385 * 1) Power supply voltage indication. The voltage sensor outputs higher
379 * values for lower voltage, and vice versa. 386 * values for lower voltage, and vice verse.
380 * 387 *
381 * 2) Temperature measurement parameters, for each of two channel widths 388 * 2) Temperature measurement parameters, for each of two channel widths
382 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing 389 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
@@ -477,11 +484,6 @@ struct iwl_alive_resp {
477} __attribute__ ((packed)); 484} __attribute__ ((packed));
478 485
479 486
480union tsf {
481 u8 byte[8];
482 __le16 word[4];
483 __le32 dw[2];
484};
485 487
486/* 488/*
487 * REPLY_ERROR = 0x2 (response only, not a command) 489 * REPLY_ERROR = 0x2 (response only, not a command)
@@ -492,7 +494,7 @@ struct iwl_error_resp {
492 u8 reserved1; 494 u8 reserved1;
493 __le16 bad_cmd_seq_num; 495 __le16 bad_cmd_seq_num;
494 __le32 error_info; 496 __le32 error_info;
495 union tsf timestamp; 497 __le64 timestamp;
496} __attribute__ ((packed)); 498} __attribute__ ((packed));
497 499
498/****************************************************************************** 500/******************************************************************************
@@ -620,7 +622,7 @@ struct iwl4965_rxon_cmd {
620 u8 ofdm_ht_dual_stream_basic_rates; 622 u8 ofdm_ht_dual_stream_basic_rates;
621} __attribute__ ((packed)); 623} __attribute__ ((packed));
622 624
623/* 5000 HW just extend this cmmand */ 625/* 5000 HW just extend this command */
624struct iwl_rxon_cmd { 626struct iwl_rxon_cmd {
625 u8 node_addr[6]; 627 u8 node_addr[6];
626 __le16 reserved1; 628 __le16 reserved1;
@@ -679,8 +681,8 @@ struct iwl4965_rxon_assoc_cmd {
679/* 681/*
680 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) 682 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
681 */ 683 */
682struct iwl4965_rxon_time_cmd { 684struct iwl_rxon_time_cmd {
683 union tsf timestamp; 685 __le64 timestamp;
684 __le16 beacon_interval; 686 __le16 beacon_interval;
685 __le16 atim_window; 687 __le16 atim_window;
686 __le32 beacon_init_val; 688 __le32 beacon_init_val;
@@ -1111,7 +1113,7 @@ struct iwl4965_rx_non_cfg_phy {
1111#define IWL50_OFDM_RSSI_C_BIT_POS 0 1113#define IWL50_OFDM_RSSI_C_BIT_POS 0
1112 1114
1113struct iwl5000_non_cfg_phy { 1115struct iwl5000_non_cfg_phy {
1114 __le32 non_cfg_phy[IWL50_RX_RES_PHY_CNT]; /* upto 8 phy entries */ 1116 __le32 non_cfg_phy[IWL50_RX_RES_PHY_CNT]; /* up to 8 phy entries */
1115} __attribute__ ((packed)); 1117} __attribute__ ((packed));
1116 1118
1117 1119
@@ -1167,7 +1169,7 @@ struct iwl4965_rx_mpdu_res_start {
1167 1169
1168/* REPLY_TX Tx flags field */ 1170/* REPLY_TX Tx flags field */
1169 1171
1170/* 1: Use RTS/CTS protocol or CTS-to-self if spec alows it 1172/* 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
1171 * before this frame. if CTS-to-self required check 1173 * before this frame. if CTS-to-self required check
1172 * RXON_FLG_SELF_CTS_EN status. */ 1174 * RXON_FLG_SELF_CTS_EN status. */
1173#define TX_CMD_FLG_RTS_CTS_MSK __constant_cpu_to_le32(1 << 0) 1175#define TX_CMD_FLG_RTS_CTS_MSK __constant_cpu_to_le32(1 << 0)
@@ -1411,21 +1413,21 @@ enum {
1411}; 1413};
1412 1414
1413enum { 1415enum {
1414 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ 1416 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
1415 TX_STATUS_DELAY_MSK = 0x00000040, 1417 TX_STATUS_DELAY_MSK = 0x00000040,
1416 TX_STATUS_ABORT_MSK = 0x00000080, 1418 TX_STATUS_ABORT_MSK = 0x00000080,
1417 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */ 1419 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
1418 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */ 1420 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
1419 TX_RESERVED = 0x00780000, /* bits 19:22 */ 1421 TX_RESERVED = 0x00780000, /* bits 19:22 */
1420 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */ 1422 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
1421 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ 1423 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
1422}; 1424};
1423 1425
1424static inline int iwl_is_tx_success(u32 status) 1426static inline bool iwl_is_tx_success(u32 status)
1425{ 1427{
1426 status &= TX_STATUS_MSK; 1428 status &= TX_STATUS_MSK;
1427 return (status == TX_STATUS_SUCCESS) 1429 return (status == TX_STATUS_SUCCESS) ||
1428 || (status == TX_STATUS_DIRECT_DONE); 1430 (status == TX_STATUS_DIRECT_DONE);
1429} 1431}
1430 1432
1431 1433
@@ -1450,10 +1452,9 @@ enum {
1450 AGG_TX_STATE_DELAY_TX_MSK = 0x400 1452 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1451}; 1453};
1452 1454
1453#define AGG_TX_STATE_LAST_SENT_MSK \ 1455#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1454(AGG_TX_STATE_LAST_SENT_TTL_MSK | \ 1456 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1455 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \ 1457 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1456 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1457 1458
1458/* # tx attempts for first frame in aggregation */ 1459/* # tx attempts for first frame in aggregation */
1459#define AGG_TX_STATE_TRY_CNT_POS 12 1460#define AGG_TX_STATE_TRY_CNT_POS 12
@@ -1526,6 +1527,28 @@ struct iwl4965_tx_resp {
1526 } u; 1527 } u;
1527} __attribute__ ((packed)); 1528} __attribute__ ((packed));
1528 1529
1530/*
1531 * definitions for initial rate index field
1532 * bits [3:0] initial rate index
1533 * bits [6:4] rate table color, used for the initial rate
1534 * bit-7 invalid rate indication
1535 * i.e. rate was not chosen from rate table
1536 * or rate table color was changed during frame retries
1537 * refer tlc rate info
1538 */
1539
1540#define IWL50_TX_RES_INIT_RATE_INDEX_POS 0
1541#define IWL50_TX_RES_INIT_RATE_INDEX_MSK 0x0f
1542#define IWL50_TX_RES_RATE_TABLE_COLOR_POS 4
1543#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK 0x70
1544#define IWL50_TX_RES_INV_RATE_INDEX_MSK 0x80
1545
1546/* refer to ra_tid */
1547#define IWL50_TX_RES_TID_POS 0
1548#define IWL50_TX_RES_TID_MSK 0x0f
1549#define IWL50_TX_RES_RA_POS 4
1550#define IWL50_TX_RES_RA_MSK 0xf0
1551
1529struct iwl5000_tx_resp { 1552struct iwl5000_tx_resp {
1530 u8 frame_count; /* 1 no aggregation, >1 aggregation */ 1553 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1531 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ 1554 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
@@ -1540,14 +1563,17 @@ struct iwl5000_tx_resp {
1540 * For agg: RTS + CTS + aggregation tx time + block-ack time. */ 1563 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1541 __le16 wireless_media_time; /* uSecs */ 1564 __le16 wireless_media_time; /* uSecs */
1542 1565
1543 __le16 reserved; 1566 u8 pa_status; /* RF power amplifier measurement (not used) */
1544 __le32 pa_power1; /* RF power amplifier measurement (not used) */ 1567 u8 pa_integ_res_a[3];
1545 __le32 pa_power2; 1568 u8 pa_integ_res_b[3];
1569 u8 pa_integ_res_C[3];
1546 1570
1547 __le32 tfd_info; 1571 __le32 tfd_info;
1548 __le16 seq_ctl; 1572 __le16 seq_ctl;
1549 __le16 byte_cnt; 1573 __le16 byte_cnt;
1550 __le32 tlc_info; 1574 u8 tlc_info;
1575 u8 ra_tid; /* tid (0:3), sta_id (4:7) */
1576 __le16 frame_ctrl;
1551 /* 1577 /*
1552 * For non-agg: frame status TX_STATUS_* 1578 * For non-agg: frame status TX_STATUS_*
1553 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status 1579 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
@@ -1742,7 +1768,7 @@ struct iwl_link_qual_agg_params {
1742 * match the modulation characteristics of the history set. 1768 * match the modulation characteristics of the history set.
1743 * 1769 *
1744 * When using block-ack (aggregation), all frames are transmitted at the same 1770 * When using block-ack (aggregation), all frames are transmitted at the same
1745 * rate, since there is no per-attempt acknowledgement from the destination 1771 * rate, since there is no per-attempt acknowledgment from the destination
1746 * station. The Tx response struct iwl_tx_resp indicates the Tx rate in 1772 * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
1747 * rate_n_flags field. After receiving a block-ack, the driver can update 1773 * rate_n_flags field. After receiving a block-ack, the driver can update
1748 * history for the entire block all at once. 1774 * history for the entire block all at once.
@@ -1881,7 +1907,7 @@ struct iwl_link_quality_cmd {
1881 * 1907 *
1882 * 3945 and 4965 support hardware handshake with Bluetooth device on 1908 * 3945 and 4965 support hardware handshake with Bluetooth device on
1883 * same platform. Bluetooth device alerts wireless device when it will Tx; 1909 * same platform. Bluetooth device alerts wireless device when it will Tx;
1884 * wireless device can delay or kill its own Tx to accomodate. 1910 * wireless device can delay or kill its own Tx to accommodate.
1885 */ 1911 */
1886struct iwl4965_bt_cmd { 1912struct iwl4965_bt_cmd {
1887 u8 flags; 1913 u8 flags;
@@ -2043,7 +2069,7 @@ struct iwl4965_spectrum_notification {
2043 * '11' Illegal set 2069 * '11' Illegal set
2044 * 2070 *
2045 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then 2071 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
2046 * ucode assume sleep over DTIM is allowed and we don't need to wakeup 2072 * ucode assume sleep over DTIM is allowed and we don't need to wake up
2047 * for every DTIM. 2073 * for every DTIM.
2048 */ 2074 */
2049#define IWL_POWER_VEC_SIZE 5 2075#define IWL_POWER_VEC_SIZE 5
@@ -2849,55 +2875,30 @@ struct iwl_sensitivity_cmd {
2849 * 1-0: amount of gain, units of 1.5 dB 2875 * 1-0: amount of gain, units of 1.5 dB
2850 */ 2876 */
2851 2877
2852/* "Differential Gain" opcode used in REPLY_PHY_CALIBRATION_CMD. */ 2878/* Phy calibration command for series */
2853#define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
2854
2855struct iwl4965_calibration_cmd {
2856 u8 opCode; /* PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
2857 u8 flags; /* not used */
2858 __le16 reserved;
2859 s8 diff_gain_a; /* see above */
2860 s8 diff_gain_b;
2861 s8 diff_gain_c;
2862 u8 reserved1;
2863} __attribute__ ((packed));
2864
2865/* Phy calibration command for 5000 series */
2866 2879
2867enum { 2880enum {
2868 IWL5000_PHY_CALIBRATE_DC_CMD = 8, 2881 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
2869 IWL5000_PHY_CALIBRATE_LO_CMD = 9, 2882 IWL_PHY_CALIBRATE_DC_CMD = 8,
2870 IWL5000_PHY_CALIBRATE_RX_BB_CMD = 10, 2883 IWL_PHY_CALIBRATE_LO_CMD = 9,
2871 IWL5000_PHY_CALIBRATE_TX_IQ_CMD = 11, 2884 IWL_PHY_CALIBRATE_RX_BB_CMD = 10,
2872 IWL5000_PHY_CALIBRATE_RX_IQ_CMD = 12, 2885 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
2873 IWL5000_PHY_CALIBRATION_NOISE_CMD = 13, 2886 IWL_PHY_CALIBRATE_RX_IQ_CMD = 12,
2874 IWL5000_PHY_CALIBRATE_AGC_TABLE_CMD = 14, 2887 IWL_PHY_CALIBRATION_NOISE_CMD = 13,
2875 IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15, 2888 IWL_PHY_CALIBRATE_AGC_TABLE_CMD = 14,
2876 IWL5000_PHY_CALIBRATE_BASE_BAND_CMD = 16, 2889 IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
2877 IWL5000_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17, 2890 IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
2878 IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD = 18, 2891 IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
2879 IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD = 19, 2892 IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD = 18,
2893 IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD = 19,
2880}; 2894};
2881 2895
2882enum {
2883 CALIBRATION_CFG_CMD = 0x65,
2884 CALIBRATION_RES_NOTIFICATION = 0x66,
2885 CALIBRATION_COMPLETE_NOTIFICATION = 0x67
2886};
2887 2896
2888struct iwl_cal_crystal_freq_cmd { 2897struct iwl_cal_xtal_freq {
2889 u8 cap_pin1; 2898 u8 cap_pin1;
2890 u8 cap_pin2; 2899 u8 cap_pin2;
2891} __attribute__ ((packed)); 2900} __attribute__ ((packed));
2892 2901
2893struct iwl5000_calibration {
2894 u8 op_code;
2895 u8 first_group;
2896 u8 num_groups;
2897 u8 all_data_valid;
2898 struct iwl_cal_crystal_freq_cmd data;
2899} __attribute__ ((packed));
2900
2901#define IWL_CALIB_INIT_CFG_ALL __constant_cpu_to_le32(0xffffffff) 2902#define IWL_CALIB_INIT_CFG_ALL __constant_cpu_to_le32(0xffffffff)
2902 2903
2903struct iwl_calib_cfg_elmnt_s { 2904struct iwl_calib_cfg_elmnt_s {
@@ -2914,27 +2915,44 @@ struct iwl_calib_cfg_status_s {
2914 __le32 flags; 2915 __le32 flags;
2915} __attribute__ ((packed)); 2916} __attribute__ ((packed));
2916 2917
2917struct iwl5000_calib_cfg_cmd { 2918struct iwl_calib_cfg_cmd {
2918 struct iwl_calib_cfg_status_s ucd_calib_cfg; 2919 struct iwl_calib_cfg_status_s ucd_calib_cfg;
2919 struct iwl_calib_cfg_status_s drv_calib_cfg; 2920 struct iwl_calib_cfg_status_s drv_calib_cfg;
2920 __le32 reserved1; 2921 __le32 reserved1;
2921} __attribute__ ((packed)); 2922} __attribute__ ((packed));
2922 2923
2923struct iwl5000_calib_hdr { 2924struct iwl_calib_hdr {
2924 u8 op_code; 2925 u8 op_code;
2925 u8 first_group; 2926 u8 first_group;
2926 u8 groups_num; 2927 u8 groups_num;
2927 u8 data_valid; 2928 u8 data_valid;
2928} __attribute__ ((packed)); 2929} __attribute__ ((packed));
2929 2930
2930struct iwl5000_calibration_chain_noise_reset_cmd { 2931struct iwl_calib_cmd {
2931 u8 op_code; /* IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */ 2932 struct iwl_calib_hdr hdr;
2933 u8 data[0];
2934} __attribute__ ((packed));
2935
2936/* "Differential Gain" opcode used in REPLY_PHY_CALIBRATION_CMD. */
2937
2938struct iwl_calib_diff_gain_cmd {
2939 u8 opCode; /* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
2940 u8 flags; /* not used */
2941 __le16 reserved;
2942 s8 diff_gain_a; /* see above */
2943 s8 diff_gain_b;
2944 s8 diff_gain_c;
2945 u8 reserved1;
2946} __attribute__ ((packed));
2947
2948struct iwl_calib_chain_noise_reset_cmd {
2949 u8 op_code; /* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
2932 u8 flags; /* not used */ 2950 u8 flags; /* not used */
2933 __le16 reserved; 2951 __le16 reserved;
2934} __attribute__ ((packed)); 2952} __attribute__ ((packed));
2935 2953
2936struct iwl5000_calibration_chain_noise_gain_cmd { 2954struct iwl_calib_chain_noise_gain_cmd {
2937 u8 op_code; /* IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */ 2955 u8 op_code; /* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
2938 u8 flags; /* not used */ 2956 u8 flags; /* not used */
2939 __le16 reserved; 2957 __le16 reserved;
2940 u8 delta_gain_1; 2958 u8 delta_gain_1;
@@ -2999,11 +3017,11 @@ struct iwl_wimax_coex_event_entry {
2999 3017
3000/* COEX flag masks */ 3018/* COEX flag masks */
3001 3019
3002/* Staion table is valid */ 3020/* Station table is valid */
3003#define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1) 3021#define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1)
3004/* UnMask wakeup src at unassociated sleep */ 3022/* UnMask wake up src at unassociated sleep */
3005#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4) 3023#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4)
3006/* UnMask wakeup src at associated sleep */ 3024/* UnMask wake up src at associated sleep */
3007#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8) 3025#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8)
3008/* Enable CoEx feature. */ 3026/* Enable CoEx feature. */
3009#define COEX_FLAGS_COEX_ENABLE_MSK (0x80) 3027#define COEX_FLAGS_COEX_ENABLE_MSK (0x80)
@@ -3039,7 +3057,6 @@ struct iwl_rx_packet {
3039 struct iwl_notif_statistics stats; 3057 struct iwl_notif_statistics stats;
3040 struct iwl_compressed_ba_resp compressed_ba; 3058 struct iwl_compressed_ba_resp compressed_ba;
3041 struct iwl4965_missed_beacon_notif missed_beacon; 3059 struct iwl4965_missed_beacon_notif missed_beacon;
3042 struct iwl5000_calibration calib;
3043 __le32 status; 3060 __le32 status;
3044 u8 raw[0]; 3061 u8 raw[0];
3045 } u; 3062 } u;
@@ -3047,4 +3064,4 @@ struct iwl_rx_packet {
3047 3064
3048#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame)) 3065#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame))
3049 3066
3050#endif /* __iwl4965_commands_h__ */ 3067#endif /* __iwl_commands_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 4c312c55f90c..8eb02031e797 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -88,26 +88,27 @@ EXPORT_SYMBOL(iwl_rates);
88 * translate ucode response to mac80211 tx status control values 88 * translate ucode response to mac80211 tx status control values
89 */ 89 */
90void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, 90void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
91 struct ieee80211_tx_info *control) 91 struct ieee80211_tx_info *info)
92{ 92{
93 int rate_index; 93 int rate_index;
94 struct ieee80211_tx_rate *r = &info->control.rates[0];
94 95
95 control->antenna_sel_tx = 96 info->antenna_sel_tx =
96 ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); 97 ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
97 if (rate_n_flags & RATE_MCS_HT_MSK) 98 if (rate_n_flags & RATE_MCS_HT_MSK)
98 control->flags |= IEEE80211_TX_CTL_OFDM_HT; 99 r->flags |= IEEE80211_TX_RC_MCS;
99 if (rate_n_flags & RATE_MCS_GF_MSK) 100 if (rate_n_flags & RATE_MCS_GF_MSK)
100 control->flags |= IEEE80211_TX_CTL_GREEN_FIELD; 101 r->flags |= IEEE80211_TX_RC_GREEN_FIELD;
101 if (rate_n_flags & RATE_MCS_FAT_MSK) 102 if (rate_n_flags & RATE_MCS_FAT_MSK)
102 control->flags |= IEEE80211_TX_CTL_40_MHZ_WIDTH; 103 r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
103 if (rate_n_flags & RATE_MCS_DUP_MSK) 104 if (rate_n_flags & RATE_MCS_DUP_MSK)
104 control->flags |= IEEE80211_TX_CTL_DUP_DATA; 105 r->flags |= IEEE80211_TX_RC_DUP_DATA;
105 if (rate_n_flags & RATE_MCS_SGI_MSK) 106 if (rate_n_flags & RATE_MCS_SGI_MSK)
106 control->flags |= IEEE80211_TX_CTL_SHORT_GI; 107 r->flags |= IEEE80211_TX_RC_SHORT_GI;
107 rate_index = iwl_hwrate_to_plcp_idx(rate_n_flags); 108 rate_index = iwl_hwrate_to_plcp_idx(rate_n_flags);
108 if (control->band == IEEE80211_BAND_5GHZ) 109 if (info->band == IEEE80211_BAND_5GHZ)
109 rate_index -= IWL_FIRST_OFDM_RATE; 110 rate_index -= IWL_FIRST_OFDM_RATE;
110 control->tx_rate_idx = rate_index; 111 r->idx = rate_index;
111} 112}
112EXPORT_SYMBOL(iwl_hwrate_to_tx_control); 113EXPORT_SYMBOL(iwl_hwrate_to_tx_control);
113 114
@@ -119,7 +120,9 @@ int iwl_hwrate_to_plcp_idx(u32 rate_n_flags)
119 if (rate_n_flags & RATE_MCS_HT_MSK) { 120 if (rate_n_flags & RATE_MCS_HT_MSK) {
120 idx = (rate_n_flags & 0xff); 121 idx = (rate_n_flags & 0xff);
121 122
122 if (idx >= IWL_RATE_MIMO2_6M_PLCP) 123 if (idx >= IWL_RATE_MIMO3_6M_PLCP)
124 idx = idx - IWL_RATE_MIMO3_6M_PLCP;
125 else if (idx >= IWL_RATE_MIMO2_6M_PLCP)
123 idx = idx - IWL_RATE_MIMO2_6M_PLCP; 126 idx = idx - IWL_RATE_MIMO2_6M_PLCP;
124 127
125 idx += IWL_FIRST_OFDM_RATE; 128 idx += IWL_FIRST_OFDM_RATE;
@@ -140,7 +143,17 @@ int iwl_hwrate_to_plcp_idx(u32 rate_n_flags)
140} 143}
141EXPORT_SYMBOL(iwl_hwrate_to_plcp_idx); 144EXPORT_SYMBOL(iwl_hwrate_to_plcp_idx);
142 145
143 146u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant)
147{
148 int i;
149 u8 ind = ant;
150 for (i = 0; i < RATE_ANT_NUM - 1; i++) {
151 ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0;
152 if (priv->hw_params.valid_tx_ant & BIT(ind))
153 return ind;
154 }
155 return ant;
156}
144 157
145const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 158const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
146EXPORT_SYMBOL(iwl_bcast_addr); 159EXPORT_SYMBOL(iwl_bcast_addr);
@@ -382,10 +395,10 @@ void iwl_reset_qos(struct iwl_priv *priv)
382} 395}
383EXPORT_SYMBOL(iwl_reset_qos); 396EXPORT_SYMBOL(iwl_reset_qos);
384 397
385#define MAX_BIT_RATE_40_MHZ 0x96 /* 150 Mbps */ 398#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
386#define MAX_BIT_RATE_20_MHZ 0x48 /* 72 Mbps */ 399#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
387static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, 400static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
388 struct ieee80211_ht_info *ht_info, 401 struct ieee80211_sta_ht_cap *ht_info,
389 enum ieee80211_band band) 402 enum ieee80211_band band)
390{ 403{
391 u16 max_bit_rate = 0; 404 u16 max_bit_rate = 0;
@@ -393,45 +406,46 @@ static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
393 u8 tx_chains_num = priv->hw_params.tx_chains_num; 406 u8 tx_chains_num = priv->hw_params.tx_chains_num;
394 407
395 ht_info->cap = 0; 408 ht_info->cap = 0;
396 memset(ht_info->supp_mcs_set, 0, 16); 409 memset(&ht_info->mcs, 0, sizeof(ht_info->mcs));
397 410
398 ht_info->ht_supported = 1; 411 ht_info->ht_supported = true;
399 412
400 ht_info->cap |= (u16)IEEE80211_HT_CAP_GRN_FLD; 413 ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD;
401 ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_20; 414 ht_info->cap |= IEEE80211_HT_CAP_SGI_20;
402 ht_info->cap |= (u16)(IEEE80211_HT_CAP_SM_PS & 415 ht_info->cap |= (IEEE80211_HT_CAP_SM_PS &
403 (WLAN_HT_CAP_SM_PS_DISABLED << 2)); 416 (WLAN_HT_CAP_SM_PS_DISABLED << 2));
404 417
405 max_bit_rate = MAX_BIT_RATE_20_MHZ; 418 max_bit_rate = MAX_BIT_RATE_20_MHZ;
406 if (priv->hw_params.fat_channel & BIT(band)) { 419 if (priv->hw_params.fat_channel & BIT(band)) {
407 ht_info->cap |= (u16)IEEE80211_HT_CAP_SUP_WIDTH; 420 ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
408 ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_40; 421 ht_info->cap |= IEEE80211_HT_CAP_SGI_40;
409 ht_info->supp_mcs_set[4] = 0x01; 422 ht_info->mcs.rx_mask[4] = 0x01;
410 max_bit_rate = MAX_BIT_RATE_40_MHZ; 423 max_bit_rate = MAX_BIT_RATE_40_MHZ;
411 } 424 }
412 425
413 if (priv->cfg->mod_params->amsdu_size_8K) 426 if (priv->cfg->mod_params->amsdu_size_8K)
414 ht_info->cap |= (u16)IEEE80211_HT_CAP_MAX_AMSDU; 427 ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU;
415 428
416 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; 429 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF;
417 ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; 430 ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF;
418 431
419 ht_info->supp_mcs_set[0] = 0xFF; 432 ht_info->mcs.rx_mask[0] = 0xFF;
420 if (rx_chains_num >= 2) 433 if (rx_chains_num >= 2)
421 ht_info->supp_mcs_set[1] = 0xFF; 434 ht_info->mcs.rx_mask[1] = 0xFF;
422 if (rx_chains_num >= 3) 435 if (rx_chains_num >= 3)
423 ht_info->supp_mcs_set[2] = 0xFF; 436 ht_info->mcs.rx_mask[2] = 0xFF;
424 437
425 /* Highest supported Rx data rate */ 438 /* Highest supported Rx data rate */
426 max_bit_rate *= rx_chains_num; 439 max_bit_rate *= rx_chains_num;
427 ht_info->supp_mcs_set[10] = (u8)(max_bit_rate & 0x00FF); 440 WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK);
428 ht_info->supp_mcs_set[11] = (u8)((max_bit_rate & 0xFF00) >> 8); 441 ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate);
429 442
430 /* Tx MCS capabilities */ 443 /* Tx MCS capabilities */
431 ht_info->supp_mcs_set[12] = IEEE80211_HT_CAP_MCS_TX_DEFINED; 444 ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
432 if (tx_chains_num != rx_chains_num) { 445 if (tx_chains_num != rx_chains_num) {
433 ht_info->supp_mcs_set[12] |= IEEE80211_HT_CAP_MCS_TX_RX_DIFF; 446 ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF;
434 ht_info->supp_mcs_set[12] |= ((tx_chains_num - 1) << 2); 447 ht_info->mcs.tx_params |= ((tx_chains_num - 1) <<
448 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
435 } 449 }
436} 450}
437 451
@@ -495,7 +509,7 @@ static int iwlcore_init_geos(struct iwl_priv *priv)
495 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE; 509 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE;
496 510
497 if (priv->cfg->sku & IWL_SKU_N) 511 if (priv->cfg->sku & IWL_SKU_N)
498 iwlcore_init_ht_hw_capab(priv, &sband->ht_info, 512 iwlcore_init_ht_hw_capab(priv, &sband->ht_cap,
499 IEEE80211_BAND_5GHZ); 513 IEEE80211_BAND_5GHZ);
500 514
501 sband = &priv->bands[IEEE80211_BAND_2GHZ]; 515 sband = &priv->bands[IEEE80211_BAND_2GHZ];
@@ -505,7 +519,7 @@ static int iwlcore_init_geos(struct iwl_priv *priv)
505 sband->n_bitrates = IWL_RATE_COUNT; 519 sband->n_bitrates = IWL_RATE_COUNT;
506 520
507 if (priv->cfg->sku & IWL_SKU_N) 521 if (priv->cfg->sku & IWL_SKU_N)
508 iwlcore_init_ht_hw_capab(priv, &sband->ht_info, 522 iwlcore_init_ht_hw_capab(priv, &sband->ht_cap,
509 IEEE80211_BAND_2GHZ); 523 IEEE80211_BAND_2GHZ);
510 524
511 priv->ieee_channels = channels; 525 priv->ieee_channels = channels;
@@ -595,8 +609,8 @@ static void iwlcore_free_geos(struct iwl_priv *priv)
595static bool is_single_rx_stream(struct iwl_priv *priv) 609static bool is_single_rx_stream(struct iwl_priv *priv)
596{ 610{
597 return !priv->current_ht_config.is_ht || 611 return !priv->current_ht_config.is_ht ||
598 ((priv->current_ht_config.supp_mcs_set[1] == 0) && 612 ((priv->current_ht_config.mcs.rx_mask[1] == 0) &&
599 (priv->current_ht_config.supp_mcs_set[2] == 0)); 613 (priv->current_ht_config.mcs.rx_mask[2] == 0));
600} 614}
601 615
602static u8 iwl_is_channel_extension(struct iwl_priv *priv, 616static u8 iwl_is_channel_extension(struct iwl_priv *priv,
@@ -609,10 +623,10 @@ static u8 iwl_is_channel_extension(struct iwl_priv *priv,
609 if (!is_channel_valid(ch_info)) 623 if (!is_channel_valid(ch_info))
610 return 0; 624 return 0;
611 625
612 if (extension_chan_offset == IEEE80211_HT_IE_CHA_SEC_ABOVE) 626 if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE)
613 return !(ch_info->fat_extension_channel & 627 return !(ch_info->fat_extension_channel &
614 IEEE80211_CHAN_NO_FAT_ABOVE); 628 IEEE80211_CHAN_NO_FAT_ABOVE);
615 else if (extension_chan_offset == IEEE80211_HT_IE_CHA_SEC_BELOW) 629 else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW)
616 return !(ch_info->fat_extension_channel & 630 return !(ch_info->fat_extension_channel &
617 IEEE80211_CHAN_NO_FAT_BELOW); 631 IEEE80211_CHAN_NO_FAT_BELOW);
618 632
@@ -620,24 +634,24 @@ static u8 iwl_is_channel_extension(struct iwl_priv *priv,
620} 634}
621 635
622u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv, 636u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv,
623 struct ieee80211_ht_info *sta_ht_inf) 637 struct ieee80211_sta_ht_cap *sta_ht_inf)
624{ 638{
625 struct iwl_ht_info *iwl_ht_conf = &priv->current_ht_config; 639 struct iwl_ht_info *iwl_ht_conf = &priv->current_ht_config;
626 640
627 if ((!iwl_ht_conf->is_ht) || 641 if ((!iwl_ht_conf->is_ht) ||
628 (iwl_ht_conf->supported_chan_width != IWL_CHANNEL_WIDTH_40MHZ) || 642 (iwl_ht_conf->supported_chan_width != IWL_CHANNEL_WIDTH_40MHZ) ||
629 (iwl_ht_conf->extension_chan_offset == IEEE80211_HT_IE_CHA_SEC_NONE)) 643 (iwl_ht_conf->extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE))
630 return 0; 644 return 0;
631 645
632 if (sta_ht_inf) { 646 if (sta_ht_inf) {
633 if ((!sta_ht_inf->ht_supported) || 647 if ((!sta_ht_inf->ht_supported) ||
634 (!(sta_ht_inf->cap & IEEE80211_HT_CAP_SUP_WIDTH))) 648 (!(sta_ht_inf->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)))
635 return 0; 649 return 0;
636 } 650 }
637 651
638 return iwl_is_channel_extension(priv, priv->band, 652 return iwl_is_channel_extension(priv, priv->band,
639 iwl_ht_conf->control_channel, 653 le16_to_cpu(priv->staging_rxon.channel),
640 iwl_ht_conf->extension_chan_offset); 654 iwl_ht_conf->extension_chan_offset);
641} 655}
642EXPORT_SYMBOL(iwl_is_fat_tx_allowed); 656EXPORT_SYMBOL(iwl_is_fat_tx_allowed);
643 657
@@ -662,22 +676,15 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
662 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK | 676 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK |
663 RXON_FLG_CHANNEL_MODE_PURE_40_MSK); 677 RXON_FLG_CHANNEL_MODE_PURE_40_MSK);
664 678
665 if (le16_to_cpu(rxon->channel) != ht_info->control_channel) {
666 IWL_DEBUG_ASSOC("control diff than current %d %d\n",
667 le16_to_cpu(rxon->channel),
668 ht_info->control_channel);
669 return;
670 }
671
672 /* Note: control channel is opposite of extension channel */ 679 /* Note: control channel is opposite of extension channel */
673 switch (ht_info->extension_chan_offset) { 680 switch (ht_info->extension_chan_offset) {
674 case IEEE80211_HT_IE_CHA_SEC_ABOVE: 681 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
675 rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); 682 rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
676 break; 683 break;
677 case IEEE80211_HT_IE_CHA_SEC_BELOW: 684 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
678 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; 685 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
679 break; 686 break;
680 case IEEE80211_HT_IE_CHA_SEC_NONE: 687 case IEEE80211_HT_PARAM_CHA_SEC_NONE:
681 default: 688 default:
682 rxon->flags &= ~RXON_FLG_CHANNEL_MODE_MIXED_MSK; 689 rxon->flags &= ~RXON_FLG_CHANNEL_MODE_MIXED_MSK;
683 break; 690 break;
@@ -691,14 +698,12 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
691 698
692 IWL_DEBUG_ASSOC("supported HT rate 0x%X 0x%X 0x%X " 699 IWL_DEBUG_ASSOC("supported HT rate 0x%X 0x%X 0x%X "
693 "rxon flags 0x%X operation mode :0x%X " 700 "rxon flags 0x%X operation mode :0x%X "
694 "extension channel offset 0x%x " 701 "extension channel offset 0x%x\n",
695 "control chan %d\n", 702 ht_info->mcs.rx_mask[0],
696 ht_info->supp_mcs_set[0], 703 ht_info->mcs.rx_mask[1],
697 ht_info->supp_mcs_set[1], 704 ht_info->mcs.rx_mask[2],
698 ht_info->supp_mcs_set[2],
699 le32_to_cpu(rxon->flags), ht_info->ht_protection, 705 le32_to_cpu(rxon->flags), ht_info->ht_protection,
700 ht_info->extension_chan_offset, 706 ht_info->extension_chan_offset);
701 ht_info->control_channel);
702 return; 707 return;
703} 708}
704EXPORT_SYMBOL(iwl_set_rxon_ht); 709EXPORT_SYMBOL(iwl_set_rxon_ht);
@@ -742,7 +747,7 @@ static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt)
742 break; 747 break;
743 case WLAN_HT_CAP_SM_PS_INVALID: 748 case WLAN_HT_CAP_SM_PS_INVALID:
744 default: 749 default:
745 IWL_ERROR("invalide mimo ps mode %d\n", 750 IWL_ERROR("invalid mimo ps mode %d\n",
746 priv->current_ht_config.sm_ps); 751 priv->current_ht_config.sm_ps);
747 WARN_ON(1); 752 WARN_ON(1);
748 idle_cnt = -1; 753 idle_cnt = -1;
@@ -868,7 +873,8 @@ int iwl_setup_mac(struct iwl_priv *priv)
868 873
869 /* Tell mac80211 our characteristics */ 874 /* Tell mac80211 our characteristics */
870 hw->flags = IEEE80211_HW_SIGNAL_DBM | 875 hw->flags = IEEE80211_HW_SIGNAL_DBM |
871 IEEE80211_HW_NOISE_DBM; 876 IEEE80211_HW_NOISE_DBM |
877 IEEE80211_HW_AMPDU_AGGREGATION;
872 hw->wiphy->interface_modes = 878 hw->wiphy->interface_modes =
873 BIT(NL80211_IFTYPE_AP) | 879 BIT(NL80211_IFTYPE_AP) |
874 BIT(NL80211_IFTYPE_STATION) | 880 BIT(NL80211_IFTYPE_STATION) |
@@ -945,7 +951,6 @@ int iwl_init_drv(struct iwl_priv *priv)
945 951
946 priv->iw_mode = NL80211_IFTYPE_STATION; 952 priv->iw_mode = NL80211_IFTYPE_STATION;
947 953
948 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
949 priv->current_ht_config.sm_ps = WLAN_HT_CAP_SM_PS_DISABLED; 954 priv->current_ht_config.sm_ps = WLAN_HT_CAP_SM_PS_DISABLED;
950 955
951 /* Choose which receivers/antennas to use */ 956 /* Choose which receivers/antennas to use */
@@ -1169,24 +1174,47 @@ int iwl_verify_ucode(struct iwl_priv *priv)
1169} 1174}
1170EXPORT_SYMBOL(iwl_verify_ucode); 1175EXPORT_SYMBOL(iwl_verify_ucode);
1171 1176
1177
1178static const char *desc_lookup_text[] = {
1179 "OK",
1180 "FAIL",
1181 "BAD_PARAM",
1182 "BAD_CHECKSUM",
1183 "NMI_INTERRUPT_WDG",
1184 "SYSASSERT",
1185 "FATAL_ERROR",
1186 "BAD_COMMAND",
1187 "HW_ERROR_TUNE_LOCK",
1188 "HW_ERROR_TEMPERATURE",
1189 "ILLEGAL_CHAN_FREQ",
1190 "VCC_NOT_STABLE",
1191 "FH_ERROR",
1192 "NMI_INTERRUPT_HOST",
1193 "NMI_INTERRUPT_ACTION_PT",
1194 "NMI_INTERRUPT_UNKNOWN",
1195 "UCODE_VERSION_MISMATCH",
1196 "HW_ERROR_ABS_LOCK",
1197 "HW_ERROR_CAL_LOCK_FAIL",
1198 "NMI_INTERRUPT_INST_ACTION_PT",
1199 "NMI_INTERRUPT_DATA_ACTION_PT",
1200 "NMI_TRM_HW_ER",
1201 "NMI_INTERRUPT_TRM",
1202 "NMI_INTERRUPT_BREAK_POINT"
1203 "DEBUG_0",
1204 "DEBUG_1",
1205 "DEBUG_2",
1206 "DEBUG_3",
1207 "UNKNOWN"
1208};
1209
1172static const char *desc_lookup(int i) 1210static const char *desc_lookup(int i)
1173{ 1211{
1174 switch (i) { 1212 int max = ARRAY_SIZE(desc_lookup_text) - 1;
1175 case 1: 1213
1176 return "FAIL"; 1214 if (i < 0 || i > max)
1177 case 2: 1215 i = max;
1178 return "BAD_PARAM";
1179 case 3:
1180 return "BAD_CHECKSUM";
1181 case 4:
1182 return "NMI_INTERRUPT";
1183 case 5:
1184 return "SYSASSERT";
1185 case 6:
1186 return "FATAL_ERROR";
1187 }
1188 1216
1189 return "UNKNOWN"; 1217 return desc_lookup_text[i];
1190} 1218}
1191 1219
1192#define ERROR_START_OFFSET (1 * sizeof(u32)) 1220#define ERROR_START_OFFSET (1 * sizeof(u32))
@@ -1232,9 +1260,9 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
1232 line = iwl_read_targ_mem(priv, base + 9 * sizeof(u32)); 1260 line = iwl_read_targ_mem(priv, base + 9 * sizeof(u32));
1233 time = iwl_read_targ_mem(priv, base + 11 * sizeof(u32)); 1261 time = iwl_read_targ_mem(priv, base + 11 * sizeof(u32));
1234 1262
1235 IWL_ERROR("Desc Time " 1263 IWL_ERROR("Desc Time "
1236 "data1 data2 line\n"); 1264 "data1 data2 line\n");
1237 IWL_ERROR("%-13s (#%d) %010u 0x%08X 0x%08X %u\n", 1265 IWL_ERROR("%-28s (#%02d) %010u 0x%08X 0x%08X %u\n",
1238 desc_lookup(desc), desc, time, data1, data2, line); 1266 desc_lookup(desc), desc, time, data1, data2, line);
1239 IWL_ERROR("blink1 blink2 ilink1 ilink2\n"); 1267 IWL_ERROR("blink1 blink2 ilink1 ilink2\n");
1240 IWL_ERROR("0x%05X 0x%05X 0x%05X 0x%05X\n", blink1, blink2, 1268 IWL_ERROR("0x%05X 0x%05X 0x%05X 0x%05X\n", blink1, blink2,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 288b6a800e03..10f07f6e1737 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -100,7 +100,7 @@ struct iwl_hcmd_utils_ops {
100}; 100};
101 101
102struct iwl_lib_ops { 102struct iwl_lib_ops {
103 /* set hw dependant perameters */ 103 /* set hw dependent parameters */
104 int (*set_hw_params)(struct iwl_priv *priv); 104 int (*set_hw_params)(struct iwl_priv *priv);
105 /* ucode shared memory */ 105 /* ucode shared memory */
106 int (*alloc_shared_mem)(struct iwl_priv *priv); 106 int (*alloc_shared_mem)(struct iwl_priv *priv);
@@ -173,6 +173,8 @@ struct iwl_cfg {
173 const char *fw_name; 173 const char *fw_name;
174 unsigned int sku; 174 unsigned int sku;
175 int eeprom_size; 175 int eeprom_size;
176 u16 eeprom_ver;
177 u16 eeprom_calib_ver;
176 const struct iwl_ops *ops; 178 const struct iwl_ops *ops;
177 const struct iwl_mod_params *mod_params; 179 const struct iwl_mod_params *mod_params;
178}; 180};
@@ -190,7 +192,7 @@ void iwl_set_rxon_chain(struct iwl_priv *priv);
190int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch); 192int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch);
191void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info); 193void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info);
192u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv, 194u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv,
193 struct ieee80211_ht_info *sta_ht_inf); 195 struct ieee80211_sta_ht_cap *sta_ht_inf);
194int iwl_hw_nic_init(struct iwl_priv *priv); 196int iwl_hw_nic_init(struct iwl_priv *priv);
195int iwl_setup_mac(struct iwl_priv *priv); 197int iwl_setup_mac(struct iwl_priv *priv);
196int iwl_set_hw_params(struct iwl_priv *priv); 198int iwl_set_hw_params(struct iwl_priv *priv);
@@ -237,7 +239,6 @@ int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
237int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn); 239int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn);
238int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid); 240int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid);
239int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id); 241int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id);
240
241/***************************************************** 242/*****************************************************
242 * TX power 243 * TX power
243 ****************************************************/ 244 ****************************************************/
@@ -259,6 +260,13 @@ void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
259 struct ieee80211_tx_info *info); 260 struct ieee80211_tx_info *info);
260int iwl_hwrate_to_plcp_idx(u32 rate_n_flags); 261int iwl_hwrate_to_plcp_idx(u32 rate_n_flags);
261 262
263u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx);
264
265static inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
266{
267 return BIT(ant_idx) << RATE_MCS_ANT_POS;
268}
269
262static inline u8 iwl_hw_get_rate(__le32 rate_n_flags) 270static inline u8 iwl_hw_get_rate(__le32 rate_n_flags)
263{ 271{
264 return le32_to_cpu(rate_n_flags) & 0xFF; 272 return le32_to_cpu(rate_n_flags) & 0xFF;
@@ -313,6 +321,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
313void iwl_dump_nic_error_log(struct iwl_priv *priv); 321void iwl_dump_nic_error_log(struct iwl_priv *priv);
314void iwl_dump_nic_event_log(struct iwl_priv *priv); 322void iwl_dump_nic_event_log(struct iwl_priv *priv);
315 323
324
316/*************** DRIVER STATUS FUNCTIONS *****/ 325/*************** DRIVER STATUS FUNCTIONS *****/
317 326
318#define STATUS_HCMD_ACTIVE 0 /* host command in progress */ 327#define STATUS_HCMD_ACTIVE 0 /* host command in progress */
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 662edf4f8d22..84f56a21770d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -60,6 +60,8 @@
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 * 61 *
62 *****************************************************************************/ 62 *****************************************************************************/
63#ifndef __iwl_csr_h__
64#define __iwl_csr_h__
63/*=== CSR (control and status registers) ===*/ 65/*=== CSR (control and status registers) ===*/
64#define CSR_BASE (0x000) 66#define CSR_BASE (0x000)
65 67
@@ -286,4 +288,4 @@
286#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004) 288#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004)
287 289
288 290
289 291#endif /* !__iwl_csr_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index e548d67f87fd..84b7772809e3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -101,13 +101,12 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv)
101 * 101 *
102 * To add your debug level to the list of levels seen when you perform 102 * To add your debug level to the list of levels seen when you perform
103 * 103 *
104 * % cat /proc/net/iwl/debug_level 104 * % cat /sys/class/net/wlanX/device/debug_level
105 * 105 *
106 * you simply need to add your entry to the iwl_debug_levels array. 106 * you simply need to add your entry to the iwl_debug_levels array.
107 * 107 *
108 * If you do not see debug_level in /proc/net/iwl then you do not have 108 * If you do not see debug_level in /sys/class/net/wlanX/device/debug_level
109 * CONFIG_IWLWIFI_DEBUG defined in your kernel configuration 109 * then you do not have CONFIG_IWLWIFI_DEBUG defined in your kernel config file
110 *
111 */ 110 */
112 111
113#define IWL_DL_INFO (1 << 0) 112#define IWL_DL_INFO (1 << 0)
@@ -183,6 +182,8 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv)
183#define IWL_DEBUG_STATS(f, a...) IWL_DEBUG(IWL_DL_STATS, f, ## a) 182#define IWL_DEBUG_STATS(f, a...) IWL_DEBUG(IWL_DL_STATS, f, ## a)
184#define IWL_DEBUG_STATS_LIMIT(f, a...) IWL_DEBUG_LIMIT(IWL_DL_STATS, f, ## a) 183#define IWL_DEBUG_STATS_LIMIT(f, a...) IWL_DEBUG_LIMIT(IWL_DL_STATS, f, ## a)
185#define IWL_DEBUG_TX_REPLY(f, a...) IWL_DEBUG(IWL_DL_TX_REPLY, f, ## a) 184#define IWL_DEBUG_TX_REPLY(f, a...) IWL_DEBUG(IWL_DL_TX_REPLY, f, ## a)
185#define IWL_DEBUG_TX_REPLY_LIMIT(f, a...) \
186 IWL_DEBUG_LIMIT(IWL_DL_TX_REPLY, f, ## a)
186#define IWL_DEBUG_QOS(f, a...) IWL_DEBUG(IWL_DL_QOS, f, ## a) 187#define IWL_DEBUG_QOS(f, a...) IWL_DEBUG(IWL_DL_QOS, f, ## a)
187#define IWL_DEBUG_RADIO(f, a...) IWL_DEBUG(IWL_DL_RADIO, f, ## a) 188#define IWL_DEBUG_RADIO(f, a...) IWL_DEBUG(IWL_DL_RADIO, f, ## a)
188#define IWL_DEBUG_POWER(f, a...) IWL_DEBUG(IWL_DL_POWER, f, ## a) 189#define IWL_DEBUG_POWER(f, a...) IWL_DEBUG(IWL_DL_POWER, f, ## a)
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 20db0eb636a8..c3df5aa8df91 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -58,7 +58,8 @@
58#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ 58#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
59 dbgfs->dbgfs_##parent##_files.file_##name = \ 59 dbgfs->dbgfs_##parent##_files.file_##name = \
60 debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr); \ 60 debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr); \
61 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name)) \ 61 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
62 || !dbgfs->dbgfs_##parent##_files.file_##name) \
62 goto err; \ 63 goto err; \
63} while (0) 64} while (0)
64 65
@@ -228,7 +229,6 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
228 ssize_t ret; 229 ssize_t ret;
229 /* Add 30 for initial string */ 230 /* Add 30 for initial string */
230 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); 231 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
231 DECLARE_MAC_BUF(mac);
232 232
233 buf = kmalloc(bufsz, GFP_KERNEL); 233 buf = kmalloc(bufsz, GFP_KERNEL);
234 if (!buf) 234 if (!buf)
@@ -242,7 +242,6 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
242 if (station->used) { 242 if (station->used) {
243 pos += scnprintf(buf + pos, bufsz - pos, 243 pos += scnprintf(buf + pos, bufsz - pos,
244 "station %d:\ngeneral data:\n", i+1); 244 "station %d:\ngeneral data:\n", i+1);
245 print_mac(mac, station->sta.sta.addr);
246 pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n", 245 pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
247 station->sta.sta.sta_id); 246 station->sta.sta.sta_id);
248 pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n", 247 pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c018121085e9..eb396f26730c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -112,11 +112,9 @@ struct iwl_queue {
112 * space less than this */ 112 * space less than this */
113} __attribute__ ((packed)); 113} __attribute__ ((packed));
114 114
115#define MAX_NUM_OF_TBS (20)
116
117/* One for each TFD */ 115/* One for each TFD */
118struct iwl_tx_info { 116struct iwl_tx_info {
119 struct sk_buff *skb[MAX_NUM_OF_TBS]; 117 struct sk_buff *skb[IWL_NUM_OF_TBS - 1];
120}; 118};
121 119
122/** 120/**
@@ -134,12 +132,13 @@ struct iwl_tx_info {
134 */ 132 */
135struct iwl_tx_queue { 133struct iwl_tx_queue {
136 struct iwl_queue q; 134 struct iwl_queue q;
137 struct iwl_tfd_frame *bd; 135 struct iwl_tfd *tfds;
138 struct iwl_cmd *cmd[TFD_TX_CMD_SLOTS]; 136 struct iwl_cmd *cmd[TFD_TX_CMD_SLOTS];
139 struct iwl_tx_info *txb; 137 struct iwl_tx_info *txb;
140 int need_update; 138 u8 need_update;
141 int sched_retry; 139 u8 sched_retry;
142 int active; 140 u8 active;
141 u8 swq_id;
143}; 142};
144 143
145#define IWL_NUM_SCAN_RATES (2) 144#define IWL_NUM_SCAN_RATES (2)
@@ -252,7 +251,8 @@ struct iwl_cmd_meta {
252 /* The CMD_SIZE_HUGE flag bit indicates that the command 251 /* The CMD_SIZE_HUGE flag bit indicates that the command
253 * structure is stored at the end of the shared queue memory. */ 252 * structure is stored at the end of the shared queue memory. */
254 u32 flags; 253 u32 flags;
255 254 DECLARE_PCI_UNMAP_ADDR(mapping)
255 DECLARE_PCI_UNMAP_LEN(len)
256} __attribute__ ((packed)); 256} __attribute__ ((packed));
257 257
258#define IWL_CMD_MAX_PAYLOAD 320 258#define IWL_CMD_MAX_PAYLOAD 320
@@ -268,24 +268,16 @@ struct iwl_cmd {
268 struct iwl_cmd_meta meta; /* driver data */ 268 struct iwl_cmd_meta meta; /* driver data */
269 struct iwl_cmd_header hdr; /* uCode API */ 269 struct iwl_cmd_header hdr; /* uCode API */
270 union { 270 union {
271 struct iwl_addsta_cmd addsta;
272 struct iwl_led_cmd led;
273 u32 flags; 271 u32 flags;
274 u8 val8; 272 u8 val8;
275 u16 val16; 273 u16 val16;
276 u32 val32; 274 u32 val32;
277 struct iwl4965_bt_cmd bt;
278 struct iwl4965_rxon_time_cmd rxon_time;
279 struct iwl_powertable_cmd powertable;
280 struct iwl_qosparam_cmd qosparam;
281 struct iwl_tx_cmd tx; 275 struct iwl_tx_cmd tx;
282 struct iwl4965_rxon_assoc_cmd rxon_assoc;
283 struct iwl_rem_sta_cmd rm_sta;
284 u8 *indirect;
285 u8 payload[IWL_CMD_MAX_PAYLOAD]; 276 u8 payload[IWL_CMD_MAX_PAYLOAD];
286 } __attribute__ ((packed)) cmd; 277 } __attribute__ ((packed)) cmd;
287} __attribute__ ((packed)); 278} __attribute__ ((packed));
288 279
280
289struct iwl_host_cmd { 281struct iwl_host_cmd {
290 u8 id; 282 u8 id;
291 u16 len; 283 u16 len;
@@ -412,9 +404,8 @@ struct iwl_ht_info {
412 u8 max_amsdu_size; 404 u8 max_amsdu_size;
413 u8 ampdu_factor; 405 u8 ampdu_factor;
414 u8 mpdu_density; 406 u8 mpdu_density;
415 u8 supp_mcs_set[16]; 407 struct ieee80211_mcs_info mcs;
416 /* BSS related data */ 408 /* BSS related data */
417 u8 control_channel;
418 u8 extension_chan_offset; 409 u8 extension_chan_offset;
419 u8 tx_chan_width; 410 u8 tx_chan_width;
420 u8 ht_protection; 411 u8 ht_protection;
@@ -527,8 +518,8 @@ struct iwl_sensitivity_ranges {
527 * @sw_crypto: 0 for hw, 1 for sw 518 * @sw_crypto: 0 for hw, 1 for sw
528 * @max_xxx_size: for ucode uses 519 * @max_xxx_size: for ucode uses
529 * @ct_kill_threshold: temperature threshold 520 * @ct_kill_threshold: temperature threshold
521 * @calib_init_cfg: setup initial calibrations for the hw
530 * @struct iwl_sensitivity_ranges: range of sensitivity values 522 * @struct iwl_sensitivity_ranges: range of sensitivity values
531 * @first_ampdu_q: first HW queue available for ampdu
532 */ 523 */
533struct iwl_hw_params { 524struct iwl_hw_params {
534 u16 max_txq_num; 525 u16 max_txq_num;
@@ -548,8 +539,8 @@ struct iwl_hw_params {
548 u32 max_data_size; 539 u32 max_data_size;
549 u32 max_bsm_size; 540 u32 max_bsm_size;
550 u32 ct_kill_threshold; /* value in hw-dependent units */ 541 u32 ct_kill_threshold; /* value in hw-dependent units */
542 u32 calib_init_cfg;
551 const struct iwl_sensitivity_ranges *sens; 543 const struct iwl_sensitivity_ranges *sens;
552 u8 first_ampdu_q;
553}; 544};
554 545
555#define HT_SHORT_GI_20MHZ (1 << 0) 546#define HT_SHORT_GI_20MHZ (1 << 0)
@@ -584,9 +575,9 @@ struct iwl_addsta_cmd;
584extern int iwl_send_add_sta(struct iwl_priv *priv, 575extern int iwl_send_add_sta(struct iwl_priv *priv,
585 struct iwl_addsta_cmd *sta, u8 flags); 576 struct iwl_addsta_cmd *sta, u8 flags);
586extern u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, 577extern u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr,
587 int is_ap, u8 flags, struct ieee80211_ht_info *ht_info); 578 int is_ap, u8 flags, struct ieee80211_sta_ht_cap *ht_info);
588extern void iwl4965_update_chain_flags(struct iwl_priv *priv); 579extern void iwl_update_chain_flags(struct iwl_priv *priv);
589extern int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src); 580extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
590extern const u8 iwl_bcast_addr[ETH_ALEN]; 581extern const u8 iwl_bcast_addr[ETH_ALEN];
591extern int iwl_rxq_stop(struct iwl_priv *priv); 582extern int iwl_rxq_stop(struct iwl_priv *priv);
592extern void iwl_txq_ctx_stop(struct iwl_priv *priv); 583extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
@@ -699,6 +690,20 @@ struct statistics_general_data {
699 u32 beacon_energy_c; 690 u32 beacon_energy_c;
700}; 691};
701 692
693
694/*
695 * enum iwl_calib
696 * defines the order in which results of initial calibrations
697 * should be sent to the runtime uCode
698 */
699enum iwl_calib {
700 IWL_CALIB_XTAL,
701 IWL_CALIB_LO,
702 IWL_CALIB_TX_IQ,
703 IWL_CALIB_TX_IQ_PERD,
704 IWL_CALIB_MAX
705};
706
702/* Opaque calibration results */ 707/* Opaque calibration results */
703struct iwl_calib_result { 708struct iwl_calib_result {
704 void *buf; 709 void *buf;
@@ -765,7 +770,6 @@ enum {
765 770
766 771
767#define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */ 772#define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */
768#define IWL_CALIB_MAX 3
769 773
770struct iwl_priv { 774struct iwl_priv {
771 775
@@ -817,12 +821,13 @@ struct iwl_priv {
817 unsigned long scan_start; 821 unsigned long scan_start;
818 unsigned long scan_pass_start; 822 unsigned long scan_pass_start;
819 unsigned long scan_start_tsf; 823 unsigned long scan_start_tsf;
824 struct iwl_scan_cmd *scan;
820 int scan_bands; 825 int scan_bands;
821 int one_direct_scan; 826 int one_direct_scan;
822 u8 direct_ssid_len; 827 u8 direct_ssid_len;
823 u8 direct_ssid[IW_ESSID_MAX_SIZE]; 828 u8 direct_ssid[IW_ESSID_MAX_SIZE];
824 struct iwl_scan_cmd *scan; 829 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
825 u32 scan_tx_ant[IEEE80211_NUM_BANDS]; 830 u8 mgmt_tx_ant;
826 831
827 /* spinlock */ 832 /* spinlock */
828 spinlock_t lock; /* protect general shared data */ 833 spinlock_t lock; /* protect general shared data */
@@ -849,7 +854,7 @@ struct iwl_priv {
849 u8 ucode_write_complete; /* the image write is complete */ 854 u8 ucode_write_complete; /* the image write is complete */
850 855
851 856
852 struct iwl4965_rxon_time_cmd rxon_timing; 857 struct iwl_rxon_time_cmd rxon_timing;
853 858
854 /* We declare this const so it can only be 859 /* We declare this const so it can only be
855 * changed via explicit cast within the 860 * changed via explicit cast within the
@@ -881,7 +886,6 @@ struct iwl_priv {
881 u16 active_rate_basic; 886 u16 active_rate_basic;
882 887
883 u8 assoc_station_added; 888 u8 assoc_station_added;
884 u8 use_ant_b_for_management_frame; /* Tx antenna selection */
885 u8 start_calib; 889 u8 start_calib;
886 struct iwl_sensitivity_data sensitivity_data; 890 struct iwl_sensitivity_data sensitivity_data;
887 struct iwl_chain_noise_data chain_noise_data; 891 struct iwl_chain_noise_data chain_noise_data;
@@ -907,7 +911,7 @@ struct iwl_priv {
907 911
908 unsigned long status; 912 unsigned long status;
909 913
910 int last_rx_rssi; /* From Rx packet statisitics */ 914 int last_rx_rssi; /* From Rx packet statistics */
911 int last_rx_noise; /* From beacon statistics */ 915 int last_rx_noise; /* From beacon statistics */
912 916
913 /* counts mgmt, ctl, and data packets */ 917 /* counts mgmt, ctl, and data packets */
@@ -922,8 +926,6 @@ struct iwl_priv {
922 unsigned long last_statistics_time; 926 unsigned long last_statistics_time;
923 927
924 /* context information */ 928 /* context information */
925 u8 essid[IW_ESSID_MAX_SIZE];
926 u8 essid_len;
927 u16 rates_mask; 929 u16 rates_mask;
928 930
929 u32 power_mode; 931 u32 power_mode;
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 37155755efc5..792a3c15f172 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -279,7 +279,23 @@ EXPORT_SYMBOL(iwl_eeprom_free);
279 279
280int iwl_eeprom_check_version(struct iwl_priv *priv) 280int iwl_eeprom_check_version(struct iwl_priv *priv)
281{ 281{
282 return priv->cfg->ops->lib->eeprom_ops.check_version(priv); 282 u16 eeprom_ver;
283 u16 calib_ver;
284
285 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
286 calib_ver = priv->cfg->ops->lib->eeprom_ops.calib_version(priv);
287
288 if (eeprom_ver < priv->cfg->eeprom_ver ||
289 calib_ver < priv->cfg->eeprom_calib_ver)
290 goto err;
291
292 return 0;
293err:
294 IWL_ERROR("Unsupported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
295 eeprom_ver, priv->cfg->eeprom_ver,
296 calib_ver, priv->cfg->eeprom_calib_ver);
297 return -EINVAL;
298
283} 299}
284EXPORT_SYMBOL(iwl_eeprom_check_version); 300EXPORT_SYMBOL(iwl_eeprom_check_version);
285 301
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index d3a2a5b4ac56..997f23c8db2e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -174,6 +174,9 @@ struct iwl_eeprom_channel {
174#define EEPROM_5000_REG_BAND_52_FAT_CHANNELS ((0x92)\ 174#define EEPROM_5000_REG_BAND_52_FAT_CHANNELS ((0x92)\
175 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */ 175 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */
176 176
177/* 5050 Specific */
178#define EEPROM_5050_TX_POWER_VERSION (4)
179#define EEPROM_5050_EEPROM_VERSION (0x21E)
177 180
178/* 2.4 GHz */ 181/* 2.4 GHz */
179extern const u8 iwl_eeprom_band_1[14]; 182extern const u8 iwl_eeprom_band_1[14];
@@ -371,7 +374,7 @@ struct iwl_eeprom_ops {
371 int (*verify_signature) (struct iwl_priv *priv); 374 int (*verify_signature) (struct iwl_priv *priv);
372 int (*acquire_semaphore) (struct iwl_priv *priv); 375 int (*acquire_semaphore) (struct iwl_priv *priv);
373 void (*release_semaphore) (struct iwl_priv *priv); 376 void (*release_semaphore) (struct iwl_priv *priv);
374 int (*check_version) (struct iwl_priv *priv); 377 u16 (*calib_version) (struct iwl_priv *priv);
375 const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset); 378 const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset);
376}; 379};
377 380
diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h
index a72efdf6d1dd..97e2cf41258d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fh.h
@@ -60,6 +60,8 @@
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 * 61 *
62 *****************************************************************************/ 62 *****************************************************************************/
63#ifndef __iwl_fh_h__
64#define __iwl_fh_h__
63 65
64/****************************/ 66/****************************/
65/* Flow Handler Definitions */ 67/* Flow Handler Definitions */
@@ -316,34 +318,40 @@
316#define FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60) 318#define FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60)
317 319
318/* Find Control/Status reg for given Tx DMA/FIFO channel */ 320/* Find Control/Status reg for given Tx DMA/FIFO channel */
319#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ 321#define FH49_TCSR_CHNL_NUM (7)
320 (FH_TCSR_LOWER_BOUND + 0x20 * _chnl) 322#define FH50_TCSR_CHNL_NUM (8)
321 323
322#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000) 324#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
323#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008) 325 (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl))
326#define FH_TCSR_CHNL_TX_CREDIT_REG(_chnl) \
327 (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
328#define FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \
329 (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
324 330
325#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) 331#define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
326#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) 332#define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001)
327#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
328 333
329#define FH_TCSR_CHNL_NUM (7) 334#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000)
335#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008)
330 336
331#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) 337#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
332#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) 338#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
333#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) 339#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
334 340
335#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) 341#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
336#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) 342#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
337#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) 343#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
338 344
339#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) 345#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
340#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) 346#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
341#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ 347#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
342 (FH_TCSR_LOWER_BOUND + 0x20 * _chnl) 348
343#define FH_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ 349#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
344 (FH_TCSR_LOWER_BOUND + 0x20 * _chnl + 0x4) 350#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
345#define FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ 351#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
346 (FH_TCSR_LOWER_BOUND + 0x20 * _chnl + 0x8) 352
353#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
354#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
347 355
348/** 356/**
349 * Tx Shared Status Registers (TSSR) 357 * Tx Shared Status Registers (TSSR)
@@ -360,7 +368,7 @@
360#define FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0) 368#define FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0)
361#define FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0) 369#define FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0)
362 370
363#define FH_TSSR_TX_STATUS_REG (FH_TSSR_LOWER_BOUND + 0x010) 371#define FH_TSSR_TX_STATUS_REG (FH_TSSR_LOWER_BOUND + 0x010)
364 372
365#define FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) ((1 << (_chnl)) << 24) 373#define FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) ((1 << (_chnl)) << 24)
366#define FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) ((1 << (_chnl)) << 16) 374#define FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) ((1 << (_chnl)) << 16)
@@ -391,3 +399,9 @@
391/* TCSR: tx_config register values */ 399/* TCSR: tx_config register values */
392#define FH_RSCSR_FRAME_SIZE_MSK (0x00003FFF) /* bits 0-13 */ 400#define FH_RSCSR_FRAME_SIZE_MSK (0x00003FFF) /* bits 0-13 */
393 401
402#define TFD_QUEUE_SIZE_MAX (256)
403#define TFD_QUEUE_SIZE_BC_DUP (64)
404#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
405
406
407#endif /* !__iwl_fh_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h
index 41eed6793328..4f0fa215d32e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
@@ -32,108 +32,6 @@
32 32
33#include <linux/ctype.h> 33#include <linux/ctype.h>
34 34
35/*
36 * The structures defined by the hardware/uCode interface
37 * have bit-wise operations. For each bit-field there is
38 * a data symbol in the structure, the start bit position
39 * and the length of the bit-field.
40 *
41 * iwl_get_bits and iwl_set_bits will return or set the
42 * appropriate bits on a 32-bit value.
43 *
44 * IWL_GET_BITS and IWL_SET_BITS use symbol expansion to
45 * expand out to the appropriate call to iwl_get_bits
46 * and iwl_set_bits without having to reference all of the
47 * numerical constants and defines provided in the hardware
48 * definition
49 */
50
51/**
52 * iwl_get_bits - Extract a hardware bit-field value
53 * @src: source hardware value (__le32)
54 * @pos: bit-position (0-based) of first bit of value
55 * @len: length of bit-field
56 *
57 * iwl_get_bits will return the bit-field in cpu endian ordering.
58 *
59 * NOTE: If used from IWL_GET_BITS then pos and len are compile-constants and
60 * will collapse to minimal code by the compiler.
61 */
62static inline u32 iwl_get_bits(__le32 src, u8 pos, u8 len)
63{
64 u32 tmp = le32_to_cpu(src);
65
66 tmp >>= pos;
67 tmp &= (1UL << len) - 1;
68 return tmp;
69}
70
71/**
72 * iwl_set_bits - Set a hardware bit-field value
73 * @dst: Address of __le32 hardware value
74 * @pos: bit-position (0-based) of first bit of value
75 * @len: length of bit-field
76 * @val: cpu endian value to encode into the bit-field
77 *
78 * iwl_set_bits will encode val into dst, masked to be len bits long at bit
79 * position pos.
80 *
81 * NOTE: If used IWL_SET_BITS pos and len will be compile-constants and
82 * will collapse to minimal code by the compiler.
83 */
84static inline void iwl_set_bits(__le32 *dst, u8 pos, u8 len, int val)
85{
86 u32 tmp = le32_to_cpu(*dst);
87
88 tmp &= ~(((1UL << len) - 1) << pos);
89 tmp |= (val & ((1UL << len) - 1)) << pos;
90 *dst = cpu_to_le32(tmp);
91}
92
93static inline void iwl_set_bits16(__le16 *dst, u8 pos, u8 len, int val)
94{
95 u16 tmp = le16_to_cpu(*dst);
96
97 tmp &= ~((1UL << (pos + len)) - (1UL << pos));
98 tmp |= (val & ((1UL << len) - 1)) << pos;
99 *dst = cpu_to_le16(tmp);
100}
101
102/*
103 * The bit-field definitions in iwl-xxxx-hw.h are in the form of:
104 *
105 * struct example {
106 * __le32 val1;
107 * #define IWL_name_POS 8
108 * #define IWL_name_LEN 4
109 * #define IWL_name_SYM val1
110 * };
111 *
112 * The IWL_SET_BITS and IWL_GET_BITS macros are provided to allow the driver
113 * to call:
114 *
115 * struct example bar;
116 * u32 val = IWL_GET_BITS(bar, name);
117 * val = val * 2;
118 * IWL_SET_BITS(bar, name, val);
119 *
120 * All cpu / host ordering, masking, and shifts are performed by the macros
121 * and iwl_{get,set}_bits.
122 *
123 */
124#define IWL_SET_BITS(s, sym, v) \
125 iwl_set_bits(&(s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
126 IWL_ ## sym ## _LEN, (v))
127
128#define IWL_SET_BITS16(s, sym, v) \
129 iwl_set_bits16(&(s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
130 IWL_ ## sym ## _LEN, (v))
131
132#define IWL_GET_BITS(s, sym) \
133 iwl_get_bits((s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
134 IWL_ ## sym ## _LEN)
135
136
137#define KELVIN_TO_CELSIUS(x) ((x)-273) 35#define KELVIN_TO_CELSIUS(x) ((x)-273)
138#define CELSIUS_TO_KELVIN(x) ((x)+273) 36#define CELSIUS_TO_KELVIN(x) ((x)+273)
139#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) 37#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
@@ -159,11 +57,6 @@ static inline unsigned long elapsed_jiffies(unsigned long start,
159 return end + (MAX_JIFFY_OFFSET - start) + 1; 57 return end + (MAX_JIFFY_OFFSET - start) + 1;
160} 58}
161 59
162static inline u8 iwl_get_dma_hi_address(dma_addr_t addr)
163{
164 return sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0;
165}
166
167/** 60/**
168 * iwl_queue_inc_wrap - increment queue index, wrap back to beginning 61 * iwl_queue_inc_wrap - increment queue index, wrap back to beginning
169 * @index -- current index 62 * @index -- current index
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index 9740fcc1805e..40e0050b7536 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -55,7 +55,7 @@
55 * _iwl_read32.) 55 * _iwl_read32.)
56 * 56 *
57 * These declarations are *extremely* useful in quickly isolating code deltas 57 * These declarations are *extremely* useful in quickly isolating code deltas
58 * which result in misconfiguring of the hardware I/O. In combination with 58 * which result in misconfiguration of the hardware I/O. In combination with
59 * git-bisect and the IO debug level you can quickly determine the specific 59 * git-bisect and the IO debug level you can quickly determine the specific
60 * commit which breaks the IO sequence to the hardware. 60 * commit which breaks the IO sequence to the hardware.
61 * 61 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 4eee1b163cd2..ffb428a7dd6d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -278,7 +278,7 @@ static int iwl_get_blink_rate(struct iwl_priv *priv)
278 /* FIXME: + priv->rx_stats[2].bytes; */ 278 /* FIXME: + priv->rx_stats[2].bytes; */
279 s64 tpt = current_tpt - priv->led_tpt; 279 s64 tpt = current_tpt - priv->led_tpt;
280 280
281 if (tpt < 0) /* wrapparound */ 281 if (tpt < 0) /* wraparound */
282 tpt = -tpt; 282 tpt = -tpt;
283 283
284 IWL_DEBUG_LED("tpt %lld current_tpt %llu\n", 284 IWL_DEBUG_LED("tpt %lld current_tpt %llu\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 60a03d2d2d0e..07a5f60e9229 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -80,7 +80,7 @@
80#define IWL_REDUCED_POWER_TEMPERATURE 95 80#define IWL_REDUCED_POWER_TEMPERATURE 95
81 81
82/* default power management (not Tx power) table values */ 82/* default power management (not Tx power) table values */
83/* for tim 0-10 */ 83/* for TIM 0-10 */
84static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = { 84static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
85 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 85 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
86 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, 86 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
@@ -91,7 +91,7 @@ static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
91}; 91};
92 92
93 93
94/* for tim = 3-10 */ 94/* for TIM = 3-10 */
95static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = { 95static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
96 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 96 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
97 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0}, 97 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
@@ -101,7 +101,7 @@ static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
101 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 7, 10, 10)}, 2} 101 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 7, 10, 10)}, 2}
102}; 102};
103 103
104/* for tim > 11 */ 104/* for TIM > 11 */
105static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = { 105static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = {
106 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 106 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
107 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0}, 107 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
@@ -183,7 +183,7 @@ static int iwl_power_init_handle(struct iwl_priv *priv)
183 return 0; 183 return 0;
184} 184}
185 185
186/* adjust power command according to dtim period and power level*/ 186/* adjust power command according to DTIM period and power level*/
187static int iwl_update_power_command(struct iwl_priv *priv, 187static int iwl_update_power_command(struct iwl_priv *priv,
188 struct iwl_powertable_cmd *cmd, 188 struct iwl_powertable_cmd *cmd,
189 u16 mode) 189 u16 mode)
@@ -325,7 +325,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
325EXPORT_SYMBOL(iwl_power_update_mode); 325EXPORT_SYMBOL(iwl_power_update_mode);
326 326
327/* Allow other iwl code to disable/enable power management active 327/* Allow other iwl code to disable/enable power management active
328 * this will be usefull for rate scale to disable PM during heavy 328 * this will be useful for rate scale to disable PM during heavy
329 * Tx/Rx activities 329 * Tx/Rx activities
330 */ 330 */
331int iwl_power_disable_management(struct iwl_priv *priv, u32 ms) 331int iwl_power_disable_management(struct iwl_priv *priv, u32 ms)
@@ -352,8 +352,8 @@ int iwl_power_disable_management(struct iwl_priv *priv, u32 ms)
352EXPORT_SYMBOL(iwl_power_disable_management); 352EXPORT_SYMBOL(iwl_power_disable_management);
353 353
354/* Allow other iwl code to disable/enable power management active 354/* Allow other iwl code to disable/enable power management active
355 * this will be usefull for rate scale to disable PM during hight 355 * this will be useful for rate scale to disable PM during high
356 * valume activities 356 * volume activities
357 */ 357 */
358int iwl_power_enable_management(struct iwl_priv *priv) 358int iwl_power_enable_management(struct iwl_priv *priv)
359{ 359{
@@ -391,7 +391,7 @@ int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode)
391} 391}
392EXPORT_SYMBOL(iwl_power_set_system_mode); 392EXPORT_SYMBOL(iwl_power_set_system_mode);
393 393
394/* initilize to default */ 394/* initialize to default */
395void iwl_power_initialize(struct iwl_priv *priv) 395void iwl_power_initialize(struct iwl_priv *priv)
396{ 396{
397 397
@@ -443,7 +443,7 @@ static void iwl_bg_set_power_save(struct work_struct *work)
443 443
444 mutex_lock(&priv->mutex); 444 mutex_lock(&priv->mutex);
445 445
446 /* on starting association we disable power managment 446 /* on starting association we disable power management
447 * until association, if association failed then this 447 * until association, if association failed then this
448 * timer will expire and enable PM again. 448 * timer will expire and enable PM again.
449 */ 449 */
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index ee5afd48d3af..b0ffb8919d3b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -158,9 +158,9 @@
158 * 158 *
159 * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction 159 * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction
160 * images in host DRAM. The last register loaded must be the instruction 160 * images in host DRAM. The last register loaded must be the instruction
161 * bytecount register ("1" in MSbit tells initialization uCode to load 161 * byte count register ("1" in MSbit tells initialization uCode to load
162 * the runtime uCode): 162 * the runtime uCode):
163 * BSM_DRAM_INST_BYTECOUNT_REG = bytecount | BSM_DRAM_INST_LOAD 163 * BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD
164 * 164 *
165 * 5) Wait for "alive" notification, then issue normal runtime commands. 165 * 5) Wait for "alive" notification, then issue normal runtime commands.
166 * 166 *
@@ -244,7 +244,7 @@
244/** 244/**
245 * Tx Scheduler 245 * Tx Scheduler
246 * 246 *
247 * The Tx Scheduler selects the next frame to be transmitted, chosing TFDs 247 * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs
248 * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in 248 * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in
249 * host DRAM. It steers each frame's Tx command (which contains the frame 249 * host DRAM. It steers each frame's Tx command (which contains the frame
250 * data) into one of up to 7 prioritized Tx DMA FIFO channels within the 250 * data) into one of up to 7 prioritized Tx DMA FIFO channels within the
diff --git a/drivers/net/wireless/iwlwifi/iwl-rfkill.c b/drivers/net/wireless/iwlwifi/iwl-rfkill.c
index 5d642298f04c..618841a53b90 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rfkill.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rfkill.c
@@ -64,7 +64,7 @@ static int iwl_rfkill_soft_rf_kill(void *data, enum rfkill_state state)
64 iwl_radio_kill_sw_disable_radio(priv); 64 iwl_radio_kill_sw_disable_radio(priv);
65 break; 65 break;
66 default: 66 default:
67 IWL_WARNING("we recieved unexpected RFKILL state %d\n", state); 67 IWL_WARNING("we received unexpected RFKILL state %d\n", state);
68 break; 68 break;
69 } 69 }
70out_unlock: 70out_unlock:
@@ -83,7 +83,7 @@ int iwl_rfkill_init(struct iwl_priv *priv)
83 IWL_DEBUG_RF_KILL("Initializing RFKILL.\n"); 83 IWL_DEBUG_RF_KILL("Initializing RFKILL.\n");
84 priv->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN); 84 priv->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
85 if (!priv->rfkill) { 85 if (!priv->rfkill) {
86 IWL_ERROR("Unable to allocate rfkill device.\n"); 86 IWL_ERROR("Unable to allocate RFKILL device.\n");
87 ret = -ENOMEM; 87 ret = -ENOMEM;
88 goto error; 88 goto error;
89 } 89 }
@@ -99,7 +99,7 @@ int iwl_rfkill_init(struct iwl_priv *priv)
99 99
100 ret = rfkill_register(priv->rfkill); 100 ret = rfkill_register(priv->rfkill);
101 if (ret) { 101 if (ret) {
102 IWL_ERROR("Unable to register rfkill: %d\n", ret); 102 IWL_ERROR("Unable to register RFKILL: %d\n", ret);
103 goto free_rfkill; 103 goto free_rfkill;
104 } 104 }
105 105
@@ -127,7 +127,7 @@ void iwl_rfkill_unregister(struct iwl_priv *priv)
127} 127}
128EXPORT_SYMBOL(iwl_rfkill_unregister); 128EXPORT_SYMBOL(iwl_rfkill_unregister);
129 129
130/* set rf-kill to the right state. */ 130/* set RFKILL to the right state. */
131void iwl_rfkill_set_hw_state(struct iwl_priv *priv) 131void iwl_rfkill_set_hw_state(struct iwl_priv *priv)
132{ 132{
133 if (!priv->rfkill) 133 if (!priv->rfkill)
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 7cde9d76ff5d..b86f9586acde 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -407,7 +407,7 @@ int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
407 (priv->shared_phys + priv->rb_closed_offset) >> 4); 407 (priv->shared_phys + priv->rb_closed_offset) >> 4);
408 408
409 /* Enable Rx DMA 409 /* Enable Rx DMA
410 * FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY is set becuase of HW bug in 410 * FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY is set because of HW bug in
411 * the credit mechanism in 5000 HW RX FIFO 411 * the credit mechanism in 5000 HW RX FIFO
412 * Direct rx interrupts to hosts 412 * Direct rx interrupts to hosts
413 * Rx buffer size 4 or 8k 413 * Rx buffer size 4 or 8k
@@ -1149,7 +1149,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1149 priv->last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; 1149 priv->last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
1150 1150
1151 /* Set "1" to report good data frames in groups of 100 */ 1151 /* Set "1" to report good data frames in groups of 100 */
1152 /* FIXME: need to optimze the call: */ 1152 /* FIXME: need to optimize the call: */
1153 iwl_dbg_report_frame(priv, pkt, header, 1); 1153 iwl_dbg_report_frame(priv, pkt, header, 1);
1154 1154
1155 IWL_DEBUG_STATS_LIMIT("Rssi %d, noise %d, qual %d, TSF %llu\n", 1155 IWL_DEBUG_STATS_LIMIT("Rssi %d, noise %d, qual %d, TSF %llu\n",
@@ -1160,12 +1160,12 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1160 * "antenna number" 1160 * "antenna number"
1161 * 1161 *
1162 * It seems that the antenna field in the phy flags value 1162 * It seems that the antenna field in the phy flags value
1163 * is actually a bitfield. This is undefined by radiotap, 1163 * is actually a bit field. This is undefined by radiotap,
1164 * it wants an actual antenna number but I always get "7" 1164 * it wants an actual antenna number but I always get "7"
1165 * for most legacy frames I receive indicating that the 1165 * for most legacy frames I receive indicating that the
1166 * same frame was received on all three RX chains. 1166 * same frame was received on all three RX chains.
1167 * 1167 *
1168 * I think this field should be removed in favour of a 1168 * I think this field should be removed in favor of a
1169 * new 802.11n radiotap field "RX chains" that is defined 1169 * new 802.11n radiotap field "RX chains" that is defined
1170 * as a bitmask. 1170 * as a bitmask.
1171 */ 1171 */
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index c89365e2ca58..c4b90301e9a1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -25,8 +25,10 @@
25 * Tomas Winkler <tomas.winkler@intel.com> 25 * Tomas Winkler <tomas.winkler@intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/ 27 *****************************************************************************/
28#include <net/mac80211.h> 28#include <linux/types.h>
29#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
30#include <net/lib80211.h>
31#include <net/mac80211.h>
30 32
31#include "iwl-eeprom.h" 33#include "iwl-eeprom.h"
32#include "iwl-dev.h" 34#include "iwl-dev.h"
@@ -64,54 +66,6 @@
64#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) 66#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
65 67
66 68
67static int scan_tx_ant[3] = {
68 RATE_MCS_ANT_A_MSK, RATE_MCS_ANT_B_MSK, RATE_MCS_ANT_C_MSK
69};
70
71
72
73static int iwl_is_empty_essid(const char *essid, int essid_len)
74{
75 /* Single white space is for Linksys APs */
76 if (essid_len == 1 && essid[0] == ' ')
77 return 1;
78
79 /* Otherwise, if the entire essid is 0, we assume it is hidden */
80 while (essid_len) {
81 essid_len--;
82 if (essid[essid_len] != '\0')
83 return 0;
84 }
85
86 return 1;
87}
88
89
90
91static const char *iwl_escape_essid(const char *essid, u8 essid_len)
92{
93 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
94 const char *s = essid;
95 char *d = escaped;
96
97 if (iwl_is_empty_essid(essid, essid_len)) {
98 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
99 return escaped;
100 }
101
102 essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
103 while (essid_len--) {
104 if (*s == '\0') {
105 *d++ = '\\';
106 *d++ = '0';
107 s++;
108 } else
109 *d++ = *s++;
110 }
111 *d = '\0';
112 return escaped;
113}
114
115/** 69/**
116 * iwl_scan_cancel - Cancel any currently executing HW scan 70 * iwl_scan_cancel - Cancel any currently executing HW scan
117 * 71 *
@@ -455,10 +409,11 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
455 409
456void iwl_init_scan_params(struct iwl_priv *priv) 410void iwl_init_scan_params(struct iwl_priv *priv)
457{ 411{
412 u8 ant_idx = fls(priv->hw_params.valid_tx_ant) - 1;
458 if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ]) 413 if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ])
459 priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = RATE_MCS_ANT_INIT_IND; 414 priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx;
460 if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ]) 415 if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ])
461 priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = RATE_MCS_ANT_INIT_IND; 416 priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx;
462} 417}
463 418
464int iwl_scan_initiate(struct iwl_priv *priv) 419int iwl_scan_initiate(struct iwl_priv *priv)
@@ -550,7 +505,7 @@ static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
550{ 505{
551 struct ieee80211_ht_cap *ht_cap; 506 struct ieee80211_ht_cap *ht_cap;
552 507
553 if (!sband || !sband->ht_info.ht_supported) 508 if (!sband || !sband->ht_cap.ht_supported)
554 return; 509 return;
555 510
556 if (*left < sizeof(struct ieee80211_ht_cap)) 511 if (*left < sizeof(struct ieee80211_ht_cap))
@@ -559,12 +514,12 @@ static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
559 *pos++ = sizeof(struct ieee80211_ht_cap); 514 *pos++ = sizeof(struct ieee80211_ht_cap);
560 ht_cap = (struct ieee80211_ht_cap *) pos; 515 ht_cap = (struct ieee80211_ht_cap *) pos;
561 516
562 ht_cap->cap_info = cpu_to_le16(sband->ht_info.cap); 517 ht_cap->cap_info = cpu_to_le16(sband->ht_cap.cap);
563 memcpy(ht_cap->supp_mcs_set, sband->ht_info.supp_mcs_set, 16); 518 memcpy(&ht_cap->mcs, &sband->ht_cap.mcs, 16);
564 ht_cap->ampdu_params_info = 519 ht_cap->ampdu_params_info =
565 (sband->ht_info.ampdu_factor & IEEE80211_HT_CAP_AMPDU_FACTOR) | 520 (sband->ht_cap.ampdu_factor & IEEE80211_HT_AMPDU_PARM_FACTOR) |
566 ((sband->ht_info.ampdu_density << 2) & 521 ((sband->ht_cap.ampdu_density << 2) &
567 IEEE80211_HT_CAP_AMPDU_DENSITY); 522 IEEE80211_HT_AMPDU_PARM_DENSITY);
568 *left -= sizeof(struct ieee80211_ht_cap); 523 *left -= sizeof(struct ieee80211_ht_cap);
569} 524}
570 525
@@ -670,23 +625,6 @@ static u16 iwl_fill_probe_req(struct iwl_priv *priv,
670 return (u16)len; 625 return (u16)len;
671} 626}
672 627
673static u32 iwl_scan_tx_ant(struct iwl_priv *priv, enum ieee80211_band band)
674{
675 int i, ind;
676
677 ind = priv->scan_tx_ant[band];
678 for (i = 0; i < priv->hw_params.tx_chains_num; i++) {
679 ind = (ind+1) >= priv->hw_params.tx_chains_num ? 0 : ind+1;
680 if (priv->hw_params.valid_tx_ant & (1 << ind)) {
681 priv->scan_tx_ant[band] = ind;
682 break;
683 }
684 }
685 IWL_DEBUG_SCAN("select TX ANT = %c\n", 'A' + ind);
686 return scan_tx_ant[ind];
687}
688
689
690static void iwl_bg_request_scan(struct work_struct *data) 628static void iwl_bg_request_scan(struct work_struct *data)
691{ 629{
692 struct iwl_priv *priv = 630 struct iwl_priv *priv =
@@ -699,11 +637,13 @@ static void iwl_bg_request_scan(struct work_struct *data)
699 struct iwl_scan_cmd *scan; 637 struct iwl_scan_cmd *scan;
700 struct ieee80211_conf *conf = NULL; 638 struct ieee80211_conf *conf = NULL;
701 int ret = 0; 639 int ret = 0;
702 u32 tx_ant; 640 u32 rate_flags = 0;
703 u16 cmd_len; 641 u16 cmd_len;
704 enum ieee80211_band band; 642 enum ieee80211_band band;
705 u8 n_probes = 2; 643 u8 n_probes = 2;
706 u8 rx_chain = priv->hw_params.valid_rx_ant; 644 u8 rx_chain = priv->hw_params.valid_rx_ant;
645 u8 rate;
646 DECLARE_SSID_BUF(ssid);
707 647
708 conf = ieee80211_get_hw_conf(priv->hw); 648 conf = ieee80211_get_hw_conf(priv->hw);
709 649
@@ -714,7 +654,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
714 goto done; 654 goto done;
715 } 655 }
716 656
717 /* Make sure the scan wasn't cancelled before this queued work 657 /* Make sure the scan wasn't canceled before this queued work
718 * was given the chance to run... */ 658 * was given the chance to run... */
719 if (!test_bit(STATUS_SCANNING, &priv->status)) 659 if (!test_bit(STATUS_SCANNING, &priv->status))
720 goto done; 660 goto done;
@@ -796,20 +736,13 @@ static void iwl_bg_request_scan(struct work_struct *data)
796 /* We should add the ability for user to lock to PASSIVE ONLY */ 736 /* We should add the ability for user to lock to PASSIVE ONLY */
797 if (priv->one_direct_scan) { 737 if (priv->one_direct_scan) {
798 IWL_DEBUG_SCAN("Start direct scan for '%s'\n", 738 IWL_DEBUG_SCAN("Start direct scan for '%s'\n",
799 iwl_escape_essid(priv->direct_ssid, 739 print_ssid(ssid, priv->direct_ssid,
800 priv->direct_ssid_len)); 740 priv->direct_ssid_len));
801 scan->direct_scan[0].id = WLAN_EID_SSID; 741 scan->direct_scan[0].id = WLAN_EID_SSID;
802 scan->direct_scan[0].len = priv->direct_ssid_len; 742 scan->direct_scan[0].len = priv->direct_ssid_len;
803 memcpy(scan->direct_scan[0].ssid, 743 memcpy(scan->direct_scan[0].ssid,
804 priv->direct_ssid, priv->direct_ssid_len); 744 priv->direct_ssid, priv->direct_ssid_len);
805 n_probes++; 745 n_probes++;
806 } else if (!iwl_is_associated(priv) && priv->essid_len) {
807 IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n",
808 iwl_escape_essid(priv->essid, priv->essid_len));
809 scan->direct_scan[0].id = WLAN_EID_SSID;
810 scan->direct_scan[0].len = priv->essid_len;
811 memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
812 n_probes++;
813 } else { 746 } else {
814 IWL_DEBUG_SCAN("Start indirect scan.\n"); 747 IWL_DEBUG_SCAN("Start indirect scan.\n");
815 } 748 }
@@ -822,23 +755,16 @@ static void iwl_bg_request_scan(struct work_struct *data)
822 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) { 755 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) {
823 band = IEEE80211_BAND_2GHZ; 756 band = IEEE80211_BAND_2GHZ;
824 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 757 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
825 tx_ant = iwl_scan_tx_ant(priv, band); 758 if (priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) {
826 if (priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) 759 rate = IWL_RATE_6M_PLCP;
827 scan->tx_cmd.rate_n_flags = 760 } else {
828 iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, 761 rate = IWL_RATE_1M_PLCP;
829 tx_ant); 762 rate_flags = RATE_MCS_CCK_MSK;
830 else 763 }
831 scan->tx_cmd.rate_n_flags =
832 iwl_hw_set_rate_n_flags(IWL_RATE_1M_PLCP,
833 tx_ant |
834 RATE_MCS_CCK_MSK);
835 scan->good_CRC_th = 0; 764 scan->good_CRC_th = 0;
836 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) { 765 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
837 band = IEEE80211_BAND_5GHZ; 766 band = IEEE80211_BAND_5GHZ;
838 tx_ant = iwl_scan_tx_ant(priv, band); 767 rate = IWL_RATE_6M_PLCP;
839 scan->tx_cmd.rate_n_flags =
840 iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP,
841 tx_ant);
842 scan->good_CRC_th = IWL_GOOD_CRC_TH; 768 scan->good_CRC_th = IWL_GOOD_CRC_TH;
843 769
844 /* Force use of chains B and C (0x6) for scan Rx for 4965 770 /* Force use of chains B and C (0x6) for scan Rx for 4965
@@ -851,6 +777,11 @@ static void iwl_bg_request_scan(struct work_struct *data)
851 goto done; 777 goto done;
852 } 778 }
853 779
780 priv->scan_tx_ant[band] =
781 iwl_toggle_tx_ant(priv, priv->scan_tx_ant[band]);
782 rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]);
783 scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
784
854 /* MIMO is not used here, but value is required */ 785 /* MIMO is not used here, but value is required */
855 scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK | 786 scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK |
856 cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) | 787 cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 61797f3f8d5c..0c5f1221b8f3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -45,7 +45,6 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
45 int start = 0; 45 int start = 0;
46 int ret = IWL_INVALID_STATION; 46 int ret = IWL_INVALID_STATION;
47 unsigned long flags; 47 unsigned long flags;
48 DECLARE_MAC_BUF(mac);
49 48
50 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) || 49 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
51 (priv->iw_mode == NL80211_IFTYPE_AP)) 50 (priv->iw_mode == NL80211_IFTYPE_AP))
@@ -63,8 +62,8 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
63 goto out; 62 goto out;
64 } 63 }
65 64
66 IWL_DEBUG_ASSOC_LIMIT("can not find STA %s total %d\n", 65 IWL_DEBUG_ASSOC_LIMIT("can not find STA %pM total %d\n",
67 print_mac(mac, addr), priv->num_stations); 66 addr, priv->num_stations);
68 67
69 out: 68 out:
70 spin_unlock_irqrestore(&priv->sta_lock, flags); 69 spin_unlock_irqrestore(&priv->sta_lock, flags);
@@ -86,7 +85,6 @@ EXPORT_SYMBOL(iwl_get_ra_sta_id);
86static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) 85static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
87{ 86{
88 unsigned long flags; 87 unsigned long flags;
89 DECLARE_MAC_BUF(mac);
90 88
91 spin_lock_irqsave(&priv->sta_lock, flags); 89 spin_lock_irqsave(&priv->sta_lock, flags);
92 90
@@ -94,8 +92,8 @@ static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
94 IWL_ERROR("ACTIVATE a non DRIVER active station %d\n", sta_id); 92 IWL_ERROR("ACTIVATE a non DRIVER active station %d\n", sta_id);
95 93
96 priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE; 94 priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE;
97 IWL_DEBUG_ASSOC("Added STA to Ucode: %s\n", 95 IWL_DEBUG_ASSOC("Added STA to Ucode: %pM\n",
98 print_mac(mac, priv->stations[sta_id].sta.sta.addr)); 96 priv->stations[sta_id].sta.sta.addr);
99 97
100 spin_unlock_irqrestore(&priv->sta_lock, flags); 98 spin_unlock_irqrestore(&priv->sta_lock, flags);
101} 99}
@@ -104,7 +102,9 @@ static int iwl_add_sta_callback(struct iwl_priv *priv,
104 struct iwl_cmd *cmd, struct sk_buff *skb) 102 struct iwl_cmd *cmd, struct sk_buff *skb)
105{ 103{
106 struct iwl_rx_packet *res = NULL; 104 struct iwl_rx_packet *res = NULL;
107 u8 sta_id = cmd->cmd.addsta.sta.sta_id; 105 struct iwl_addsta_cmd *addsta =
106 (struct iwl_addsta_cmd *)cmd->cmd.payload;
107 u8 sta_id = addsta->sta.sta_id;
108 108
109 if (!skb) { 109 if (!skb) {
110 IWL_ERROR("Error: Response NULL in REPLY_ADD_STA.\n"); 110 IWL_ERROR("Error: Response NULL in REPLY_ADD_STA.\n");
@@ -183,7 +183,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
183EXPORT_SYMBOL(iwl_send_add_sta); 183EXPORT_SYMBOL(iwl_send_add_sta);
184 184
185static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, 185static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
186 struct ieee80211_ht_info *sta_ht_inf) 186 struct ieee80211_sta_ht_cap *sta_ht_inf)
187{ 187{
188 __le32 sta_flags; 188 __le32 sta_flags;
189 u8 mimo_ps_mode; 189 u8 mimo_ps_mode;
@@ -231,13 +231,12 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
231 * iwl_add_station_flags - Add station to tables in driver and device 231 * iwl_add_station_flags - Add station to tables in driver and device
232 */ 232 */
233u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap, 233u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
234 u8 flags, struct ieee80211_ht_info *ht_info) 234 u8 flags, struct ieee80211_sta_ht_cap *ht_info)
235{ 235{
236 int i; 236 int i;
237 int sta_id = IWL_INVALID_STATION; 237 int sta_id = IWL_INVALID_STATION;
238 struct iwl_station_entry *station; 238 struct iwl_station_entry *station;
239 unsigned long flags_spin; 239 unsigned long flags_spin;
240 DECLARE_MAC_BUF(mac);
241 240
242 spin_lock_irqsave(&priv->sta_lock, flags_spin); 241 spin_lock_irqsave(&priv->sta_lock, flags_spin);
243 if (is_ap) 242 if (is_ap)
@@ -273,8 +272,8 @@ u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
273 272
274 station = &priv->stations[sta_id]; 273 station = &priv->stations[sta_id];
275 station->used = IWL_STA_DRIVER_ACTIVE; 274 station->used = IWL_STA_DRIVER_ACTIVE;
276 IWL_DEBUG_ASSOC("Add STA to driver ID %d: %s\n", 275 IWL_DEBUG_ASSOC("Add STA to driver ID %d: %pM\n",
277 sta_id, print_mac(mac, addr)); 276 sta_id, addr);
278 priv->num_stations++; 277 priv->num_stations++;
279 278
280 /* Set up the REPLY_ADD_STA command to send to device */ 279 /* Set up the REPLY_ADD_STA command to send to device */
@@ -301,14 +300,11 @@ EXPORT_SYMBOL(iwl_add_station_flags);
301static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const char *addr) 300static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const char *addr)
302{ 301{
303 unsigned long flags; 302 unsigned long flags;
304 DECLARE_MAC_BUF(mac);
305
306 u8 sta_id = iwl_find_station(priv, addr); 303 u8 sta_id = iwl_find_station(priv, addr);
307 304
308 BUG_ON(sta_id == IWL_INVALID_STATION); 305 BUG_ON(sta_id == IWL_INVALID_STATION);
309 306
310 IWL_DEBUG_ASSOC("Removed STA from Ucode: %s\n", 307 IWL_DEBUG_ASSOC("Removed STA from Ucode: %pM\n", addr);
311 print_mac(mac, addr));
312 308
313 spin_lock_irqsave(&priv->sta_lock, flags); 309 spin_lock_irqsave(&priv->sta_lock, flags);
314 310
@@ -326,7 +322,9 @@ static int iwl_remove_sta_callback(struct iwl_priv *priv,
326 struct iwl_cmd *cmd, struct sk_buff *skb) 322 struct iwl_cmd *cmd, struct sk_buff *skb)
327{ 323{
328 struct iwl_rx_packet *res = NULL; 324 struct iwl_rx_packet *res = NULL;
329 const char *addr = cmd->cmd.rm_sta.addr; 325 struct iwl_rem_sta_cmd *rm_sta =
326 (struct iwl_rem_sta_cmd *)cmd->cmd.payload;
327 const char *addr = rm_sta->addr;
330 328
331 if (!skb) { 329 if (!skb) {
332 IWL_ERROR("Error: Response NULL in REPLY_REMOVE_STA.\n"); 330 IWL_ERROR("Error: Response NULL in REPLY_REMOVE_STA.\n");
@@ -415,7 +413,6 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
415 int sta_id = IWL_INVALID_STATION; 413 int sta_id = IWL_INVALID_STATION;
416 int i, ret = -EINVAL; 414 int i, ret = -EINVAL;
417 unsigned long flags; 415 unsigned long flags;
418 DECLARE_MAC_BUF(mac);
419 416
420 spin_lock_irqsave(&priv->sta_lock, flags); 417 spin_lock_irqsave(&priv->sta_lock, flags);
421 418
@@ -435,18 +432,18 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
435 if (unlikely(sta_id == IWL_INVALID_STATION)) 432 if (unlikely(sta_id == IWL_INVALID_STATION))
436 goto out; 433 goto out;
437 434
438 IWL_DEBUG_ASSOC("Removing STA from driver:%d %s\n", 435 IWL_DEBUG_ASSOC("Removing STA from driver:%d %pM\n",
439 sta_id, print_mac(mac, addr)); 436 sta_id, addr);
440 437
441 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { 438 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
442 IWL_ERROR("Removing %s but non DRIVER active\n", 439 IWL_ERROR("Removing %pM but non DRIVER active\n",
443 print_mac(mac, addr)); 440 addr);
444 goto out; 441 goto out;
445 } 442 }
446 443
447 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { 444 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
448 IWL_ERROR("Removing %s but non UCODE active\n", 445 IWL_ERROR("Removing %pM but non UCODE active\n",
449 print_mac(mac, addr)); 446 addr);
450 goto out; 447 goto out;
451 } 448 }
452 449
@@ -696,7 +693,7 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
696 /* else, we are overriding an existing key => no need to allocated room 693 /* else, we are overriding an existing key => no need to allocated room
697 * in uCode. */ 694 * in uCode. */
698 695
699 /* This copy is acutally not needed: we get the key with each TX */ 696 /* This copy is actually not needed: we get the key with each TX */
700 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16); 697 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
701 698
702 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16); 699 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16);
@@ -791,7 +788,7 @@ static void iwl_dump_lq_cmd(struct iwl_priv *priv,
791{ 788{
792 int i; 789 int i;
793 IWL_DEBUG_RATE("lq station id 0x%x\n", lq->sta_id); 790 IWL_DEBUG_RATE("lq station id 0x%x\n", lq->sta_id);
794 IWL_DEBUG_RATE("lq dta 0x%X 0x%X\n", 791 IWL_DEBUG_RATE("lq ant 0x%X 0x%X\n",
795 lq->general_params.single_stream_ant_msk, 792 lq->general_params.single_stream_ant_msk,
796 lq->general_params.dual_stream_ant_msk); 793 lq->general_params.dual_stream_ant_msk);
797 794
@@ -852,7 +849,7 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, int is_ap)
852 struct iwl_link_quality_cmd link_cmd = { 849 struct iwl_link_quality_cmd link_cmd = {
853 .reserved1 = 0, 850 .reserved1 = 0,
854 }; 851 };
855 u16 rate_flags; 852 u32 rate_flags;
856 853
857 /* Set up the rate scaling to start at selected rate, fall back 854 /* Set up the rate scaling to start at selected rate, fall back
858 * all the way down to 1M in IEEE order, and then spin on 1M */ 855 * all the way down to 1M in IEEE order, and then spin on 1M */
@@ -868,15 +865,16 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, int is_ap)
868 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) 865 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
869 rate_flags |= RATE_MCS_CCK_MSK; 866 rate_flags |= RATE_MCS_CCK_MSK;
870 867
871 /* Use Tx antenna B only */ 868 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
872 rate_flags |= RATE_MCS_ANT_B_MSK; /*FIXME:RS*/ 869 RATE_MCS_ANT_POS;
873 870
874 link_cmd.rs_table[i].rate_n_flags = 871 link_cmd.rs_table[i].rate_n_flags =
875 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); 872 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
876 r = iwl4965_get_prev_ieee_rate(r); 873 r = iwl_get_prev_ieee_rate(r);
877 } 874 }
878 875
879 link_cmd.general_params.single_stream_ant_msk = 2; 876 link_cmd.general_params.single_stream_ant_msk =
877 first_antenna(priv->hw_params.valid_tx_ant);
880 link_cmd.general_params.dual_stream_ant_msk = 3; 878 link_cmd.general_params.dual_stream_ant_msk = 3;
881 link_cmd.agg_params.agg_dis_start_th = 3; 879 link_cmd.agg_params.agg_dis_start_th = 3;
882 link_cmd.agg_params.agg_time_limit = cpu_to_le16(4000); 880 link_cmd.agg_params.agg_time_limit = cpu_to_le16(4000);
@@ -892,24 +890,35 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, int is_ap)
892 * iwl_rxon_add_station - add station into station table. 890 * iwl_rxon_add_station - add station into station table.
893 * 891 *
894 * there is only one AP station with id= IWL_AP_ID 892 * there is only one AP station with id= IWL_AP_ID
895 * NOTE: mutex must be held before calling this fnction 893 * NOTE: mutex must be held before calling this function
896 */ 894 */
897int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap) 895int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
898{ 896{
897 struct ieee80211_sta *sta;
898 struct ieee80211_sta_ht_cap ht_config;
899 struct ieee80211_sta_ht_cap *cur_ht_config = NULL;
899 u8 sta_id; 900 u8 sta_id;
900 901
901 /* Add station to device's station table */ 902 /* Add station to device's station table */
902 struct ieee80211_conf *conf = &priv->hw->conf; 903
903 struct ieee80211_ht_info *cur_ht_config = &conf->ht_conf; 904 /*
904 905 * XXX: This check is definitely not correct, if we're an AP
905 if ((is_ap) && 906 * it'll always be false which is not what we want, but
906 (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) && 907 * it doesn't look like iwlagn is prepared to be an HT
907 (priv->iw_mode == NL80211_IFTYPE_STATION)) 908 * AP anyway.
908 sta_id = iwl_add_station_flags(priv, addr, is_ap, 909 */
909 0, cur_ht_config); 910 if (priv->current_ht_config.is_ht) {
910 else 911 rcu_read_lock();
911 sta_id = iwl_add_station_flags(priv, addr, is_ap, 912 sta = ieee80211_find_sta(priv->hw, addr);
912 0, NULL); 913 if (sta) {
914 memcpy(&ht_config, &sta->ht_cap, sizeof(ht_config));
915 cur_ht_config = &ht_config;
916 }
917 rcu_read_unlock();
918 }
919
920 sta_id = iwl_add_station_flags(priv, addr, is_ap,
921 0, cur_ht_config);
913 922
914 /* Set up default rate scaling table in device's station table */ 923 /* Set up default rate scaling table in device's station table */
915 iwl_sta_init_lq(priv, addr, is_ap); 924 iwl_sta_init_lq(priv, addr, is_ap);
@@ -927,7 +936,6 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
927{ 936{
928 int sta_id; 937 int sta_id;
929 u16 fc = le16_to_cpu(hdr->frame_control); 938 u16 fc = le16_to_cpu(hdr->frame_control);
930 DECLARE_MAC_BUF(mac);
931 939
932 /* If this frame is broadcast or management, use broadcast station id */ 940 /* If this frame is broadcast or management, use broadcast station id */
933 if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) || 941 if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) ||
@@ -962,9 +970,9 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
962 if (sta_id != IWL_INVALID_STATION) 970 if (sta_id != IWL_INVALID_STATION)
963 return sta_id; 971 return sta_id;
964 972
965 IWL_DEBUG_DROP("Station %s not in station map. " 973 IWL_DEBUG_DROP("Station %pM not in station map. "
966 "Defaulting to broadcast...\n", 974 "Defaulting to broadcast...\n",
967 print_mac(mac, hdr->addr1)); 975 hdr->addr1);
968 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); 976 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
969 return priv->hw_params.bcast_sta_id; 977 return priv->hw_params.bcast_sta_id;
970 978
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 907a53ebc6e4..7d8b4e2d5094 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -56,96 +56,112 @@ static const u16 default_tid_to_tx_fifo[] = {
56 IWL_TX_FIFO_AC3 56 IWL_TX_FIFO_AC3
57}; 57};
58 58
59static inline dma_addr_t iwl_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx)
60{
61 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
62
63 dma_addr_t addr = get_unaligned_le32(&tb->lo);
64 if (sizeof(dma_addr_t) > sizeof(u32))
65 addr |=
66 ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16;
67
68 return addr;
69}
70
71static inline u16 iwl_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx)
72{
73 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
74
75 return le16_to_cpu(tb->hi_n_len) >> 4;
76}
77
78static inline void iwl_tfd_set_tb(struct iwl_tfd *tfd, u8 idx,
79 dma_addr_t addr, u16 len)
80{
81 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
82 u16 hi_n_len = len << 4;
83
84 put_unaligned_le32(addr, &tb->lo);
85 if (sizeof(dma_addr_t) > sizeof(u32))
86 hi_n_len |= ((addr >> 16) >> 16) & 0xF;
87
88 tb->hi_n_len = cpu_to_le16(hi_n_len);
89
90 tfd->num_tbs = idx + 1;
91}
92
93static inline u8 iwl_tfd_get_num_tbs(struct iwl_tfd *tfd)
94{
95 return tfd->num_tbs & 0x1f;
96}
59 97
60/** 98/**
61 * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] 99 * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr]
100 * @priv - driver private data
101 * @txq - tx queue
62 * 102 *
63 * Does NOT advance any TFD circular buffer read/write indexes 103 * Does NOT advance any TFD circular buffer read/write indexes
64 * Does NOT free the TFD itself (which is within circular buffer) 104 * Does NOT free the TFD itself (which is within circular buffer)
65 */ 105 */
66static int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) 106static void iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
67{ 107{
68 struct iwl_tfd_frame *bd_tmp = (struct iwl_tfd_frame *)&txq->bd[0]; 108 struct iwl_tfd *tfd_tmp = (struct iwl_tfd *)&txq->tfds[0];
69 struct iwl_tfd_frame *bd = &bd_tmp[txq->q.read_ptr]; 109 struct iwl_tfd *tfd;
70 struct pci_dev *dev = priv->pci_dev; 110 struct pci_dev *dev = priv->pci_dev;
111 int index = txq->q.read_ptr;
71 int i; 112 int i;
72 int counter = 0; 113 int num_tbs;
73 int index, is_odd;
74 114
75 /* Host command buffers stay mapped in memory, nothing to clean */ 115 tfd = &tfd_tmp[index];
76 if (txq->q.id == IWL_CMD_QUEUE_NUM)
77 return 0;
78 116
79 /* Sanity check on number of chunks */ 117 /* Sanity check on number of chunks */
80 counter = IWL_GET_BITS(*bd, num_tbs); 118 num_tbs = iwl_tfd_get_num_tbs(tfd);
81 if (counter > MAX_NUM_OF_TBS) { 119
82 IWL_ERROR("Too many chunks: %i\n", counter); 120 if (num_tbs >= IWL_NUM_OF_TBS) {
121 IWL_ERROR("Too many chunks: %i\n", num_tbs);
83 /* @todo issue fatal error, it is quite serious situation */ 122 /* @todo issue fatal error, it is quite serious situation */
84 return 0; 123 return;
85 } 124 }
86 125
87 /* Unmap chunks, if any. 126 /* Unmap tx_cmd */
88 * TFD info for odd chunks is different format than for even chunks. */ 127 if (num_tbs)
89 for (i = 0; i < counter; i++) { 128 pci_unmap_single(dev,
90 index = i / 2; 129 pci_unmap_addr(&txq->cmd[index]->meta, mapping),
91 is_odd = i & 0x1; 130 pci_unmap_len(&txq->cmd[index]->meta, len),
92
93 if (is_odd)
94 pci_unmap_single(
95 dev,
96 IWL_GET_BITS(bd->pa[index], tb2_addr_lo16) |
97 (IWL_GET_BITS(bd->pa[index],
98 tb2_addr_hi20) << 16),
99 IWL_GET_BITS(bd->pa[index], tb2_len),
100 PCI_DMA_TODEVICE); 131 PCI_DMA_TODEVICE);
101 132
102 else if (i > 0) 133 /* Unmap chunks, if any. */
103 pci_unmap_single(dev, 134 for (i = 1; i < num_tbs; i++) {
104 le32_to_cpu(bd->pa[index].tb1_addr), 135 pci_unmap_single(dev, iwl_tfd_tb_get_addr(tfd, i),
105 IWL_GET_BITS(bd->pa[index], tb1_len), 136 iwl_tfd_tb_get_len(tfd, i), PCI_DMA_TODEVICE);
106 PCI_DMA_TODEVICE);
107
108 /* Free SKB, if any, for this chunk */
109 if (txq->txb[txq->q.read_ptr].skb[i]) {
110 struct sk_buff *skb = txq->txb[txq->q.read_ptr].skb[i];
111 137
112 dev_kfree_skb(skb); 138 if (txq->txb) {
113 txq->txb[txq->q.read_ptr].skb[i] = NULL; 139 dev_kfree_skb(txq->txb[txq->q.read_ptr].skb[i - 1]);
140 txq->txb[txq->q.read_ptr].skb[i - 1] = NULL;
114 } 141 }
115 } 142 }
116 return 0;
117} 143}
118 144
119static int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr, 145static int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
120 dma_addr_t addr, u16 len) 146 struct iwl_tfd *tfd,
147 dma_addr_t addr, u16 len)
121{ 148{
122 int index, is_odd; 149
123 struct iwl_tfd_frame *tfd = ptr; 150 u32 num_tbs = iwl_tfd_get_num_tbs(tfd);
124 u32 num_tbs = IWL_GET_BITS(*tfd, num_tbs);
125 151
126 /* Each TFD can point to a maximum 20 Tx buffers */ 152 /* Each TFD can point to a maximum 20 Tx buffers */
127 if (num_tbs >= MAX_NUM_OF_TBS) { 153 if (num_tbs >= IWL_NUM_OF_TBS) {
128 IWL_ERROR("Error can not send more than %d chunks\n", 154 IWL_ERROR("Error can not send more than %d chunks\n",
129 MAX_NUM_OF_TBS); 155 IWL_NUM_OF_TBS);
130 return -EINVAL; 156 return -EINVAL;
131 } 157 }
132 158
133 index = num_tbs / 2; 159 BUG_ON(addr & ~DMA_BIT_MASK(36));
134 is_odd = num_tbs & 0x1; 160 if (unlikely(addr & ~IWL_TX_DMA_MASK))
135 161 IWL_ERROR("Unaligned address = %llx\n",
136 if (!is_odd) { 162 (unsigned long long)addr);
137 tfd->pa[index].tb1_addr = cpu_to_le32(addr);
138 IWL_SET_BITS(tfd->pa[index], tb1_addr_hi,
139 iwl_get_dma_hi_address(addr));
140 IWL_SET_BITS(tfd->pa[index], tb1_len, len);
141 } else {
142 IWL_SET_BITS(tfd->pa[index], tb2_addr_lo16,
143 (u32) (addr & 0xffff));
144 IWL_SET_BITS(tfd->pa[index], tb2_addr_hi20, addr >> 16);
145 IWL_SET_BITS(tfd->pa[index], tb2_len, len);
146 }
147 163
148 IWL_SET_BITS(*tfd, num_tbs, num_tbs + 1); 164 iwl_tfd_set_tb(tfd, num_tbs, addr, len);
149 165
150 return 0; 166 return 0;
151} 167}
@@ -210,7 +226,7 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
210 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 226 struct iwl_tx_queue *txq = &priv->txq[txq_id];
211 struct iwl_queue *q = &txq->q; 227 struct iwl_queue *q = &txq->q;
212 struct pci_dev *dev = priv->pci_dev; 228 struct pci_dev *dev = priv->pci_dev;
213 int i, slots_num, len; 229 int i, len;
214 230
215 if (q->n_bd == 0) 231 if (q->n_bd == 0)
216 return; 232 return;
@@ -221,21 +237,15 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
221 iwl_hw_txq_free_tfd(priv, txq); 237 iwl_hw_txq_free_tfd(priv, txq);
222 238
223 len = sizeof(struct iwl_cmd) * q->n_window; 239 len = sizeof(struct iwl_cmd) * q->n_window;
224 if (q->id == IWL_CMD_QUEUE_NUM)
225 len += IWL_MAX_SCAN_SIZE;
226 240
227 /* De-alloc array of command/tx buffers */ 241 /* De-alloc array of command/tx buffers */
228 slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ? 242 for (i = 0; i < TFD_TX_CMD_SLOTS; i++)
229 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
230 for (i = 0; i < slots_num; i++)
231 kfree(txq->cmd[i]); 243 kfree(txq->cmd[i]);
232 if (txq_id == IWL_CMD_QUEUE_NUM)
233 kfree(txq->cmd[slots_num]);
234 244
235 /* De-alloc circular buffer of TFDs */ 245 /* De-alloc circular buffer of TFDs */
236 if (txq->q.n_bd) 246 if (txq->q.n_bd)
237 pci_free_consistent(dev, sizeof(struct iwl_tfd_frame) * 247 pci_free_consistent(dev, sizeof(struct iwl_tfd) *
238 txq->q.n_bd, txq->bd, txq->q.dma_addr); 248 txq->q.n_bd, txq->tfds, txq->q.dma_addr);
239 249
240 /* De-alloc array of per-TFD driver data */ 250 /* De-alloc array of per-TFD driver data */
241 kfree(txq->txb); 251 kfree(txq->txb);
@@ -245,6 +255,40 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
245 memset(txq, 0, sizeof(*txq)); 255 memset(txq, 0, sizeof(*txq));
246} 256}
247 257
258
259/**
260 * iwl_cmd_queue_free - Deallocate DMA queue.
261 * @txq: Transmit queue to deallocate.
262 *
263 * Empty queue by removing and destroying all BD's.
264 * Free all buffers.
265 * 0-fill, but do not free "txq" descriptor structure.
266 */
267static void iwl_cmd_queue_free(struct iwl_priv *priv)
268{
269 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
270 struct iwl_queue *q = &txq->q;
271 struct pci_dev *dev = priv->pci_dev;
272 int i, len;
273
274 if (q->n_bd == 0)
275 return;
276
277 len = sizeof(struct iwl_cmd) * q->n_window;
278 len += IWL_MAX_SCAN_SIZE;
279
280 /* De-alloc array of command/tx buffers */
281 for (i = 0; i <= TFD_CMD_SLOTS; i++)
282 kfree(txq->cmd[i]);
283
284 /* De-alloc circular buffer of TFDs */
285 if (txq->q.n_bd)
286 pci_free_consistent(dev, sizeof(struct iwl_tfd) *
287 txq->q.n_bd, txq->tfds, txq->q.dma_addr);
288
289 /* 0-fill queue descriptor structure */
290 memset(txq, 0, sizeof(*txq));
291}
248/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** 292/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
249 * DMA services 293 * DMA services
250 * 294 *
@@ -340,13 +384,13 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
340 384
341 /* Circular buffer of transmit frame descriptors (TFDs), 385 /* Circular buffer of transmit frame descriptors (TFDs),
342 * shared with device */ 386 * shared with device */
343 txq->bd = pci_alloc_consistent(dev, 387 txq->tfds = pci_alloc_consistent(dev,
344 sizeof(txq->bd[0]) * TFD_QUEUE_SIZE_MAX, 388 sizeof(txq->tfds[0]) * TFD_QUEUE_SIZE_MAX,
345 &txq->q.dma_addr); 389 &txq->q.dma_addr);
346 390
347 if (!txq->bd) { 391 if (!txq->tfds) {
348 IWL_ERROR("pci_alloc_consistent(%zd) failed\n", 392 IWL_ERROR("pci_alloc_consistent(%zd) failed\n",
349 sizeof(txq->bd[0]) * TFD_QUEUE_SIZE_MAX); 393 sizeof(txq->tfds[0]) * TFD_QUEUE_SIZE_MAX);
350 goto error; 394 goto error;
351 } 395 }
352 txq->q.id = id; 396 txq->q.id = id;
@@ -370,15 +414,15 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
370static int iwl_hw_tx_queue_init(struct iwl_priv *priv, 414static int iwl_hw_tx_queue_init(struct iwl_priv *priv,
371 struct iwl_tx_queue *txq) 415 struct iwl_tx_queue *txq)
372{ 416{
373 int rc; 417 int ret;
374 unsigned long flags; 418 unsigned long flags;
375 int txq_id = txq->q.id; 419 int txq_id = txq->q.id;
376 420
377 spin_lock_irqsave(&priv->lock, flags); 421 spin_lock_irqsave(&priv->lock, flags);
378 rc = iwl_grab_nic_access(priv); 422 ret = iwl_grab_nic_access(priv);
379 if (rc) { 423 if (ret) {
380 spin_unlock_irqrestore(&priv->lock, flags); 424 spin_unlock_irqrestore(&priv->lock, flags);
381 return rc; 425 return ret;
382 } 426 }
383 427
384 /* Circular buffer (TFD queue in DRAM) physical base address */ 428 /* Circular buffer (TFD queue in DRAM) physical base address */
@@ -386,10 +430,10 @@ static int iwl_hw_tx_queue_init(struct iwl_priv *priv,
386 txq->q.dma_addr >> 8); 430 txq->q.dma_addr >> 8);
387 431
388 /* Enable DMA channel, using same id as for TFD queue */ 432 /* Enable DMA channel, using same id as for TFD queue */
389 iwl_write_direct32( 433 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(txq_id),
390 priv, FH_TCSR_CHNL_TX_CONFIG_REG(txq_id), 434 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
391 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | 435 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
392 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL); 436
393 iwl_release_nic_access(priv); 437 iwl_release_nic_access(priv);
394 spin_unlock_irqrestore(&priv->lock, flags); 438 spin_unlock_irqrestore(&priv->lock, flags);
395 439
@@ -468,7 +512,10 @@ void iwl_hw_txq_ctx_free(struct iwl_priv *priv)
468 512
469 /* Tx queues */ 513 /* Tx queues */
470 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) 514 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
471 iwl_tx_queue_free(priv, txq_id); 515 if (txq_id == IWL_CMD_QUEUE_NUM)
516 iwl_cmd_queue_free(priv);
517 else
518 iwl_tx_queue_free(priv, txq_id);
472 519
473 /* Keep-warm buffer */ 520 /* Keep-warm buffer */
474 iwl_kw_free(priv); 521 iwl_kw_free(priv);
@@ -477,7 +524,7 @@ EXPORT_SYMBOL(iwl_hw_txq_ctx_free);
477 524
478/** 525/**
479 * iwl_txq_ctx_reset - Reset TX queue context 526 * iwl_txq_ctx_reset - Reset TX queue context
480 * Destroys all DMA structures and initialise them again 527 * Destroys all DMA structures and initialize them again
481 * 528 *
482 * @param priv 529 * @param priv
483 * @return error code 530 * @return error code
@@ -647,11 +694,11 @@ static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
647 __le16 fc, int sta_id, 694 __le16 fc, int sta_id,
648 int is_hcca) 695 int is_hcca)
649{ 696{
697 u32 rate_flags = 0;
698 int rate_idx;
650 u8 rts_retry_limit = 0; 699 u8 rts_retry_limit = 0;
651 u8 data_retry_limit = 0; 700 u8 data_retry_limit = 0;
652 u8 rate_plcp; 701 u8 rate_plcp;
653 u16 rate_flags = 0;
654 int rate_idx;
655 702
656 rate_idx = min(ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xffff, 703 rate_idx = min(ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xffff,
657 IWL_RATE_COUNT - 1); 704 IWL_RATE_COUNT - 1);
@@ -694,14 +741,8 @@ static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
694 break; 741 break;
695 } 742 }
696 743
697 /* Alternate between antenna A and B for successive frames */ 744 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant);
698 if (priv->use_ant_b_for_management_frame) { 745 rate_flags |= iwl_ant_idx_to_flags(priv->mgmt_tx_ant);
699 priv->use_ant_b_for_management_frame = 0;
700 rate_flags |= RATE_MCS_ANT_B_MSK;
701 } else {
702 priv->use_ant_b_for_management_frame = 1;
703 rate_flags |= RATE_MCS_ANT_A_MSK;
704 }
705 } 746 }
706 747
707 tx_cmd->rts_retry_limit = rts_retry_limit; 748 tx_cmd->rts_retry_limit = rts_retry_limit;
@@ -723,7 +764,7 @@ static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
723 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); 764 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
724 if (info->flags & IEEE80211_TX_CTL_AMPDU) 765 if (info->flags & IEEE80211_TX_CTL_AMPDU)
725 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; 766 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK;
726 IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n"); 767 IWL_DEBUG_TX("tx_cmd with AES hwcrypto\n");
727 break; 768 break;
728 769
729 case ALG_TKIP: 770 case ALG_TKIP:
@@ -767,7 +808,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
767{ 808{
768 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 809 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
769 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 810 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
770 struct iwl_tfd_frame *tfd; 811 struct iwl_tfd *tfd;
771 struct iwl_tx_queue *txq; 812 struct iwl_tx_queue *txq;
772 struct iwl_queue *q; 813 struct iwl_queue *q;
773 struct iwl_cmd *out_cmd; 814 struct iwl_cmd *out_cmd;
@@ -776,7 +817,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
776 dma_addr_t phys_addr; 817 dma_addr_t phys_addr;
777 dma_addr_t txcmd_phys; 818 dma_addr_t txcmd_phys;
778 dma_addr_t scratch_phys; 819 dma_addr_t scratch_phys;
779 u16 len, idx, len_org; 820 u16 len, len_org;
780 u16 seq_number = 0; 821 u16 seq_number = 0;
781 __le16 fc; 822 __le16 fc;
782 u8 hdr_len, unicast; 823 u8 hdr_len, unicast;
@@ -830,10 +871,8 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
830 /* Find (or create) index into station table for destination station */ 871 /* Find (or create) index into station table for destination station */
831 sta_id = iwl_get_sta_id(priv, hdr); 872 sta_id = iwl_get_sta_id(priv, hdr);
832 if (sta_id == IWL_INVALID_STATION) { 873 if (sta_id == IWL_INVALID_STATION) {
833 DECLARE_MAC_BUF(mac); 874 IWL_DEBUG_DROP("Dropping - INVALID STATION: %pM\n",
834 875 hdr->addr1);
835 IWL_DEBUG_DROP("Dropping - INVALID STATION: %s\n",
836 print_mac(mac, hdr->addr1));
837 goto drop; 876 goto drop;
838 } 877 }
839 878
@@ -856,23 +895,22 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
856 priv->stations[sta_id].tid[tid].tfds_in_queue++; 895 priv->stations[sta_id].tid[tid].tfds_in_queue++;
857 } 896 }
858 897
859 /* Descriptor for chosen Tx queue */
860 txq = &priv->txq[txq_id]; 898 txq = &priv->txq[txq_id];
861 q = &txq->q; 899 q = &txq->q;
900 txq->swq_id = swq_id;
862 901
863 spin_lock_irqsave(&priv->lock, flags); 902 spin_lock_irqsave(&priv->lock, flags);
864 903
865 /* Set up first empty TFD within this queue's circular TFD buffer */ 904 /* Set up first empty TFD within this queue's circular TFD buffer */
866 tfd = &txq->bd[q->write_ptr]; 905 tfd = &txq->tfds[q->write_ptr];
867 memset(tfd, 0, sizeof(*tfd)); 906 memset(tfd, 0, sizeof(*tfd));
868 idx = get_cmd_index(q, q->write_ptr, 0);
869 907
870 /* Set up driver data for this TFD */ 908 /* Set up driver data for this TFD */
871 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); 909 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
872 txq->txb[q->write_ptr].skb[0] = skb; 910 txq->txb[q->write_ptr].skb[0] = skb;
873 911
874 /* Set up first empty entry in queue's array of Tx/cmd buffers */ 912 /* Set up first empty entry in queue's array of Tx/cmd buffers */
875 out_cmd = txq->cmd[idx]; 913 out_cmd = txq->cmd[q->write_ptr];
876 tx_cmd = &out_cmd->cmd.tx; 914 tx_cmd = &out_cmd->cmd.tx;
877 memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); 915 memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr));
878 memset(tx_cmd, 0, sizeof(struct iwl_tx_cmd)); 916 memset(tx_cmd, 0, sizeof(struct iwl_tx_cmd));
@@ -912,12 +950,14 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
912 950
913 /* Physical address of this Tx command's header (not MAC header!), 951 /* Physical address of this Tx command's header (not MAC header!),
914 * within command buffer array. */ 952 * within command buffer array. */
915 txcmd_phys = pci_map_single(priv->pci_dev, out_cmd, 953 txcmd_phys = pci_map_single(priv->pci_dev,
916 sizeof(struct iwl_cmd), PCI_DMA_TODEVICE); 954 out_cmd, sizeof(struct iwl_cmd),
917 txcmd_phys += offsetof(struct iwl_cmd, hdr); 955 PCI_DMA_TODEVICE);
918 956 pci_unmap_addr_set(&out_cmd->meta, mapping, txcmd_phys);
957 pci_unmap_len_set(&out_cmd->meta, len, sizeof(struct iwl_cmd));
919 /* Add buffer containing Tx command and MAC(!) header to TFD's 958 /* Add buffer containing Tx command and MAC(!) header to TFD's
920 * first entry */ 959 * first entry */
960 txcmd_phys += offsetof(struct iwl_cmd, hdr);
921 iwl_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); 961 iwl_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len);
922 962
923 if (info->control.hw_key) 963 if (info->control.hw_key)
@@ -950,7 +990,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
950 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + 990 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
951 offsetof(struct iwl_tx_cmd, scratch); 991 offsetof(struct iwl_tx_cmd, scratch);
952 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); 992 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys);
953 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys); 993 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
954 994
955 if (!ieee80211_has_morefrags(hdr->frame_control)) { 995 if (!ieee80211_has_morefrags(hdr->frame_control)) {
956 txq->need_update = 1; 996 txq->need_update = 1;
@@ -983,7 +1023,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
983 iwl_txq_update_write_ptr(priv, txq); 1023 iwl_txq_update_write_ptr(priv, txq);
984 spin_unlock_irqrestore(&priv->lock, flags); 1024 spin_unlock_irqrestore(&priv->lock, flags);
985 } else { 1025 } else {
986 ieee80211_stop_queue(priv->hw, swq_id); 1026 ieee80211_stop_queue(priv->hw, txq->swq_id);
987 } 1027 }
988 } 1028 }
989 1029
@@ -1011,7 +1051,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1011{ 1051{
1012 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; 1052 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
1013 struct iwl_queue *q = &txq->q; 1053 struct iwl_queue *q = &txq->q;
1014 struct iwl_tfd_frame *tfd; 1054 struct iwl_tfd *tfd;
1015 struct iwl_cmd *out_cmd; 1055 struct iwl_cmd *out_cmd;
1016 dma_addr_t phys_addr; 1056 dma_addr_t phys_addr;
1017 unsigned long flags; 1057 unsigned long flags;
@@ -1040,7 +1080,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1040 1080
1041 spin_lock_irqsave(&priv->hcmd_lock, flags); 1081 spin_lock_irqsave(&priv->hcmd_lock, flags);
1042 1082
1043 tfd = &txq->bd[q->write_ptr]; 1083 tfd = &txq->tfds[q->write_ptr];
1044 memset(tfd, 0, sizeof(*tfd)); 1084 memset(tfd, 0, sizeof(*tfd));
1045 1085
1046 1086
@@ -1061,9 +1101,13 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1061 out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; 1101 out_cmd->hdr.sequence |= SEQ_HUGE_FRAME;
1062 len = (idx == TFD_CMD_SLOTS) ? 1102 len = (idx == TFD_CMD_SLOTS) ?
1063 IWL_MAX_SCAN_SIZE : sizeof(struct iwl_cmd); 1103 IWL_MAX_SCAN_SIZE : sizeof(struct iwl_cmd);
1064 phys_addr = pci_map_single(priv->pci_dev, out_cmd, len, 1104
1065 PCI_DMA_TODEVICE); 1105 phys_addr = pci_map_single(priv->pci_dev, out_cmd,
1106 len, PCI_DMA_TODEVICE);
1107 pci_unmap_addr_set(&out_cmd->meta, mapping, phys_addr);
1108 pci_unmap_len_set(&out_cmd->meta, len, len);
1066 phys_addr += offsetof(struct iwl_cmd, hdr); 1109 phys_addr += offsetof(struct iwl_cmd, hdr);
1110
1067 iwl_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size); 1111 iwl_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size);
1068 1112
1069#ifdef CONFIG_IWLWIFI_DEBUG 1113#ifdef CONFIG_IWLWIFI_DEBUG
@@ -1113,8 +1157,9 @@ int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
1113 return 0; 1157 return 0;
1114 } 1158 }
1115 1159
1116 for (index = iwl_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; 1160 for (index = iwl_queue_inc_wrap(index, q->n_bd);
1117 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 1161 q->read_ptr != index;
1162 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
1118 1163
1119 tx_info = &txq->txb[txq->q.read_ptr]; 1164 tx_info = &txq->txb[txq->q.read_ptr];
1120 ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb[0]); 1165 ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb[0]);
@@ -1138,44 +1183,34 @@ EXPORT_SYMBOL(iwl_tx_queue_reclaim);
1138 * need to be reclaimed. As result, some free space forms. If there is 1183 * need to be reclaimed. As result, some free space forms. If there is
1139 * enough free space (> low mark), wake the stack that feeds us. 1184 * enough free space (> low mark), wake the stack that feeds us.
1140 */ 1185 */
1141static void iwl_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) 1186static void iwl_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id,
1187 int idx, int cmd_idx)
1142{ 1188{
1143 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 1189 struct iwl_tx_queue *txq = &priv->txq[txq_id];
1144 struct iwl_queue *q = &txq->q; 1190 struct iwl_queue *q = &txq->q;
1145 struct iwl_tfd_frame *bd = &txq->bd[index];
1146 dma_addr_t dma_addr;
1147 int is_odd, buf_len;
1148 int nfreed = 0; 1191 int nfreed = 0;
1149 1192
1150 if ((index >= q->n_bd) || (iwl_queue_used(q, index) == 0)) { 1193 if ((idx >= q->n_bd) || (iwl_queue_used(q, idx) == 0)) {
1151 IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " 1194 IWL_ERROR("Read index for DMA queue txq id (%d), index %d, "
1152 "is out of range [0-%d] %d %d.\n", txq_id, 1195 "is out of range [0-%d] %d %d.\n", txq_id,
1153 index, q->n_bd, q->write_ptr, q->read_ptr); 1196 idx, q->n_bd, q->write_ptr, q->read_ptr);
1154 return; 1197 return;
1155 } 1198 }
1156 1199
1157 for (index = iwl_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; 1200 pci_unmap_single(priv->pci_dev,
1158 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 1201 pci_unmap_addr(&txq->cmd[cmd_idx]->meta, mapping),
1202 pci_unmap_len(&txq->cmd[cmd_idx]->meta, len),
1203 PCI_DMA_TODEVICE);
1204
1205 for (idx = iwl_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx;
1206 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
1159 1207
1160 if (nfreed > 1) { 1208 if (nfreed++ > 0) {
1161 IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, 1209 IWL_ERROR("HCMD skipped: index (%d) %d %d\n", idx,
1162 q->write_ptr, q->read_ptr); 1210 q->write_ptr, q->read_ptr);
1163 queue_work(priv->workqueue, &priv->restart); 1211 queue_work(priv->workqueue, &priv->restart);
1164 } 1212 }
1165 is_odd = (index/2) & 0x1;
1166 if (is_odd) {
1167 dma_addr = IWL_GET_BITS(bd->pa[index], tb2_addr_lo16) |
1168 (IWL_GET_BITS(bd->pa[index],
1169 tb2_addr_hi20) << 16);
1170 buf_len = IWL_GET_BITS(bd->pa[index], tb2_len);
1171 } else {
1172 dma_addr = le32_to_cpu(bd->pa[index].tb1_addr);
1173 buf_len = IWL_GET_BITS(bd->pa[index], tb1_len);
1174 }
1175 1213
1176 pci_unmap_single(priv->pci_dev, dma_addr, buf_len,
1177 PCI_DMA_TODEVICE);
1178 nfreed++;
1179 } 1214 }
1180} 1215}
1181 1216
@@ -1215,7 +1250,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1215 !cmd->meta.u.callback(priv, cmd, rxb->skb)) 1250 !cmd->meta.u.callback(priv, cmd, rxb->skb))
1216 rxb->skb = NULL; 1251 rxb->skb = NULL;
1217 1252
1218 iwl_hcmd_queue_reclaim(priv, txq_id, index); 1253 iwl_hcmd_queue_reclaim(priv, txq_id, index, cmd_index);
1219 1254
1220 if (!(cmd->meta.flags & CMD_ASYNC)) { 1255 if (!(cmd->meta.flags & CMD_ASYNC)) {
1221 clear_bit(STATUS_HCMD_ACTIVE, &priv->status); 1256 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
@@ -1248,15 +1283,14 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
1248 int ret; 1283 int ret;
1249 unsigned long flags; 1284 unsigned long flags;
1250 struct iwl_tid_data *tid_data; 1285 struct iwl_tid_data *tid_data;
1251 DECLARE_MAC_BUF(mac);
1252 1286
1253 if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) 1287 if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo)))
1254 tx_fifo = default_tid_to_tx_fifo[tid]; 1288 tx_fifo = default_tid_to_tx_fifo[tid];
1255 else 1289 else
1256 return -EINVAL; 1290 return -EINVAL;
1257 1291
1258 IWL_WARNING("%s on ra = %s tid = %d\n", 1292 IWL_WARNING("%s on ra = %pM tid = %d\n",
1259 __func__, print_mac(mac, ra), tid); 1293 __func__, ra, tid);
1260 1294
1261 sta_id = iwl_find_station(priv, ra); 1295 sta_id = iwl_find_station(priv, ra);
1262 if (sta_id == IWL_INVALID_STATION) 1296 if (sta_id == IWL_INVALID_STATION)
@@ -1301,7 +1335,6 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1301 struct iwl_tid_data *tid_data; 1335 struct iwl_tid_data *tid_data;
1302 int ret, write_ptr, read_ptr; 1336 int ret, write_ptr, read_ptr;
1303 unsigned long flags; 1337 unsigned long flags;
1304 DECLARE_MAC_BUF(mac);
1305 1338
1306 if (!ra) { 1339 if (!ra) {
1307 IWL_ERROR("ra = NULL\n"); 1340 IWL_ERROR("ra = NULL\n");
@@ -1362,8 +1395,8 @@ int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id)
1362 case IWL_EMPTYING_HW_QUEUE_DELBA: 1395 case IWL_EMPTYING_HW_QUEUE_DELBA:
1363 /* We are reclaiming the last packet of the */ 1396 /* We are reclaiming the last packet of the */
1364 /* aggregated HW queue */ 1397 /* aggregated HW queue */
1365 if (txq_id == tid_data->agg.txq_id && 1398 if ((txq_id == tid_data->agg.txq_id) &&
1366 q->read_ptr == q->write_ptr) { 1399 (q->read_ptr == q->write_ptr)) {
1367 u16 ssn = SEQ_TO_SN(tid_data->seq_number); 1400 u16 ssn = SEQ_TO_SN(tid_data->seq_number);
1368 int tx_fifo = default_tid_to_tx_fifo[tid]; 1401 int tx_fifo = default_tid_to_tx_fifo[tid];
1369 IWL_DEBUG_HT("HW queue empty: continue DELBA flow\n"); 1402 IWL_DEBUG_HT("HW queue empty: continue DELBA flow\n");
@@ -1414,7 +1447,7 @@ static int iwl_tx_status_reply_compressed_ba(struct iwl_priv *priv,
1414 IWL_DEBUG_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); 1447 IWL_DEBUG_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl);
1415 1448
1416 /* Calculate shift to align block-ack bits with our Tx window bits */ 1449 /* Calculate shift to align block-ack bits with our Tx window bits */
1417 sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl>>4); 1450 sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4);
1418 if (sh < 0) /* tbw something is wrong with indices */ 1451 if (sh < 0) /* tbw something is wrong with indices */
1419 sh += 0x100; 1452 sh += 0x100;
1420 1453
@@ -1464,10 +1497,11 @@ void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
1464{ 1497{
1465 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1498 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
1466 struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; 1499 struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba;
1467 int index;
1468 struct iwl_tx_queue *txq = NULL; 1500 struct iwl_tx_queue *txq = NULL;
1469 struct iwl_ht_agg *agg; 1501 struct iwl_ht_agg *agg;
1470 DECLARE_MAC_BUF(mac); 1502 int index;
1503 int sta_id;
1504 int tid;
1471 1505
1472 /* "flow" corresponds to Tx queue */ 1506 /* "flow" corresponds to Tx queue */
1473 u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); 1507 u16 scd_flow = le16_to_cpu(ba_resp->scd_flow);
@@ -1482,17 +1516,19 @@ void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
1482 } 1516 }
1483 1517
1484 txq = &priv->txq[scd_flow]; 1518 txq = &priv->txq[scd_flow];
1485 agg = &priv->stations[ba_resp->sta_id].tid[ba_resp->tid].agg; 1519 sta_id = ba_resp->sta_id;
1520 tid = ba_resp->tid;
1521 agg = &priv->stations[sta_id].tid[tid].agg;
1486 1522
1487 /* Find index just before block-ack window */ 1523 /* Find index just before block-ack window */
1488 index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); 1524 index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd);
1489 1525
1490 /* TODO: Need to get this copy more safely - now good for debug */ 1526 /* TODO: Need to get this copy more safely - now good for debug */
1491 1527
1492 IWL_DEBUG_TX_REPLY("REPLY_COMPRESSED_BA [%d]Received from %s, " 1528 IWL_DEBUG_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, "
1493 "sta_id = %d\n", 1529 "sta_id = %d\n",
1494 agg->wait_for_ba, 1530 agg->wait_for_ba,
1495 print_mac(mac, (u8 *) &ba_resp->sta_addr_lo32), 1531 (u8 *) &ba_resp->sta_addr_lo32,
1496 ba_resp->sta_id); 1532 ba_resp->sta_id);
1497 IWL_DEBUG_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = " 1533 IWL_DEBUG_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = "
1498 "%d, scd_ssn = %d\n", 1534 "%d, scd_ssn = %d\n",
@@ -1513,18 +1549,15 @@ void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
1513 * transmitted ... if not, it's too late anyway). */ 1549 * transmitted ... if not, it's too late anyway). */
1514 if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { 1550 if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) {
1515 /* calculate mac80211 ampdu sw queue to wake */ 1551 /* calculate mac80211 ampdu sw queue to wake */
1516 int ampdu_q =
1517 scd_flow - priv->hw_params.first_ampdu_q + priv->hw->queues;
1518 int freed = iwl_tx_queue_reclaim(priv, scd_flow, index); 1552 int freed = iwl_tx_queue_reclaim(priv, scd_flow, index);
1519 priv->stations[ba_resp->sta_id]. 1553 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
1520 tid[ba_resp->tid].tfds_in_queue -= freed; 1554
1521 if (iwl_queue_space(&txq->q) > txq->q.low_mark && 1555 if ((iwl_queue_space(&txq->q) > txq->q.low_mark) &&
1522 priv->mac80211_registered && 1556 priv->mac80211_registered &&
1523 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) 1557 (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA))
1524 ieee80211_wake_queue(priv->hw, ampdu_q); 1558 ieee80211_wake_queue(priv->hw, txq->swq_id);
1525 1559
1526 iwl_txq_check_empty(priv, ba_resp->sta_id, 1560 iwl_txq_check_empty(priv, sta_id, tid, scd_flow);
1527 ba_resp->tid, scd_flow);
1528 } 1561 }
1529} 1562}
1530EXPORT_SYMBOL(iwl_rx_reply_compressed_ba); 1563EXPORT_SYMBOL(iwl_rx_reply_compressed_ba);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 285b53e7e261..119185fb1e26 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -41,6 +41,7 @@
41#include <linux/if_arp.h> 41#include <linux/if_arp.h>
42 42
43#include <net/ieee80211_radiotap.h> 43#include <net/ieee80211_radiotap.h>
44#include <net/lib80211.h>
44#include <net/mac80211.h> 45#include <net/mac80211.h>
45 46
46#include <asm/div64.h> 47#include <asm/div64.h>
@@ -107,46 +108,6 @@ static const struct ieee80211_supported_band *iwl3945_get_band(
107 return priv->hw->wiphy->bands[band]; 108 return priv->hw->wiphy->bands[band];
108} 109}
109 110
110static int iwl3945_is_empty_essid(const char *essid, int essid_len)
111{
112 /* Single white space is for Linksys APs */
113 if (essid_len == 1 && essid[0] == ' ')
114 return 1;
115
116 /* Otherwise, if the entire essid is 0, we assume it is hidden */
117 while (essid_len) {
118 essid_len--;
119 if (essid[essid_len] != '\0')
120 return 0;
121 }
122
123 return 1;
124}
125
126static const char *iwl3945_escape_essid(const char *essid, u8 essid_len)
127{
128 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
129 const char *s = essid;
130 char *d = escaped;
131
132 if (iwl3945_is_empty_essid(essid, essid_len)) {
133 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
134 return escaped;
135 }
136
137 essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
138 while (essid_len--) {
139 if (*s == '\0') {
140 *d++ = '\\';
141 *d++ = '0';
142 s++;
143 } else
144 *d++ = *s++;
145 }
146 *d = '\0';
147 return escaped;
148}
149
150/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** 111/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
151 * DMA services 112 * DMA services
152 * 113 *
@@ -446,7 +407,6 @@ u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *addr, int is_ap, u8
446 int index = IWL_INVALID_STATION; 407 int index = IWL_INVALID_STATION;
447 struct iwl3945_station_entry *station; 408 struct iwl3945_station_entry *station;
448 unsigned long flags_spin; 409 unsigned long flags_spin;
449 DECLARE_MAC_BUF(mac);
450 u8 rate; 410 u8 rate;
451 411
452 spin_lock_irqsave(&priv->sta_lock, flags_spin); 412 spin_lock_irqsave(&priv->sta_lock, flags_spin);
@@ -480,7 +440,7 @@ u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *addr, int is_ap, u8
480 return index; 440 return index;
481 } 441 }
482 442
483 IWL_DEBUG_ASSOC("Add STA ID %d: %s\n", index, print_mac(mac, addr)); 443 IWL_DEBUG_ASSOC("Add STA ID %d: %pM\n", index, addr);
484 station = &priv->stations[index]; 444 station = &priv->stations[index];
485 station->used = 1; 445 station->used = 1;
486 priv->num_stations++; 446 priv->num_stations++;
@@ -1063,7 +1023,6 @@ static int iwl3945_commit_rxon(struct iwl3945_priv *priv)
1063 /* cast away the const for active_rxon in this function */ 1023 /* cast away the const for active_rxon in this function */
1064 struct iwl3945_rxon_cmd *active_rxon = (void *)&priv->active_rxon; 1024 struct iwl3945_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
1065 int rc = 0; 1025 int rc = 0;
1066 DECLARE_MAC_BUF(mac);
1067 1026
1068 if (!iwl3945_is_alive(priv)) 1027 if (!iwl3945_is_alive(priv))
1069 return -1; 1028 return -1;
@@ -1124,11 +1083,11 @@ static int iwl3945_commit_rxon(struct iwl3945_priv *priv)
1124 IWL_DEBUG_INFO("Sending RXON\n" 1083 IWL_DEBUG_INFO("Sending RXON\n"
1125 "* with%s RXON_FILTER_ASSOC_MSK\n" 1084 "* with%s RXON_FILTER_ASSOC_MSK\n"
1126 "* channel = %d\n" 1085 "* channel = %d\n"
1127 "* bssid = %s\n", 1086 "* bssid = %pM\n",
1128 ((priv->staging_rxon.filter_flags & 1087 ((priv->staging_rxon.filter_flags &
1129 RXON_FILTER_ASSOC_MSK) ? "" : "out"), 1088 RXON_FILTER_ASSOC_MSK) ? "" : "out"),
1130 le16_to_cpu(priv->staging_rxon.channel), 1089 le16_to_cpu(priv->staging_rxon.channel),
1131 print_mac(mac, priv->staging_rxon.bssid_addr)); 1090 priv->staging_rxon.bssid_addr);
1132 1091
1133 /* Apply the new configuration */ 1092 /* Apply the new configuration */
1134 rc = iwl3945_send_cmd_pdu(priv, REPLY_RXON, 1093 rc = iwl3945_send_cmd_pdu(priv, REPLY_RXON,
@@ -1634,7 +1593,7 @@ static u16 iwl3945_supported_rate_to_ie(u8 *ie, u16 supported_rate,
1634 */ 1593 */
1635static u16 iwl3945_fill_probe_req(struct iwl3945_priv *priv, 1594static u16 iwl3945_fill_probe_req(struct iwl3945_priv *priv,
1636 struct ieee80211_mgmt *frame, 1595 struct ieee80211_mgmt *frame,
1637 int left, int is_direct) 1596 int left)
1638{ 1597{
1639 int len = 0; 1598 int len = 0;
1640 u8 *pos = NULL; 1599 u8 *pos = NULL;
@@ -1664,20 +1623,6 @@ static u16 iwl3945_fill_probe_req(struct iwl3945_priv *priv,
1664 *pos++ = WLAN_EID_SSID; 1623 *pos++ = WLAN_EID_SSID;
1665 *pos++ = 0; 1624 *pos++ = 0;
1666 1625
1667 /* fill in our direct SSID IE... */
1668 if (is_direct) {
1669 /* ...next IE... */
1670 left -= 2 + priv->essid_len;
1671 if (left < 0)
1672 return 0;
1673 /* ... fill it in... */
1674 *pos++ = WLAN_EID_SSID;
1675 *pos++ = priv->essid_len;
1676 memcpy(pos, priv->essid, priv->essid_len);
1677 pos += priv->essid_len;
1678 len += 2 + priv->essid_len;
1679 }
1680
1681 /* fill in supported rate */ 1626 /* fill in supported rate */
1682 /* ...next IE... */ 1627 /* ...next IE... */
1683 left -= 2; 1628 left -= 2;
@@ -1846,7 +1791,7 @@ static void iwl3945_activate_qos(struct iwl3945_priv *priv, u8 force)
1846 spin_unlock_irqrestore(&priv->lock, flags); 1791 spin_unlock_irqrestore(&priv->lock, flags);
1847 1792
1848 if (force || iwl3945_is_associated(priv)) { 1793 if (force || iwl3945_is_associated(priv)) {
1849 IWL_DEBUG_QOS("send QoS cmd with Qos active %d \n", 1794 IWL_DEBUG_QOS("send QoS cmd with QoS active %d \n",
1850 priv->qos_data.qos_active); 1795 priv->qos_data.qos_active);
1851 1796
1852 iwl3945_send_qos_params_command(priv, 1797 iwl3945_send_qos_params_command(priv,
@@ -1870,7 +1815,7 @@ static void iwl3945_activate_qos(struct iwl3945_priv *priv, u8 force)
1870 1815
1871 1816
1872/* default power management (not Tx power) table values */ 1817/* default power management (not Tx power) table values */
1873/* for tim 0-10 */ 1818/* for TIM 0-10 */
1874static struct iwl3945_power_vec_entry range_0[IWL_POWER_AC] = { 1819static struct iwl3945_power_vec_entry range_0[IWL_POWER_AC] = {
1875 {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 1820 {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
1876 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0}, 1821 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
@@ -1880,7 +1825,7 @@ static struct iwl3945_power_vec_entry range_0[IWL_POWER_AC] = {
1880 {{SLP, SLP_TIMEOUT(25), SLP_TIMEOUT(25), SLP_VEC(4, 7, 10, 10, 10)}, 1} 1825 {{SLP, SLP_TIMEOUT(25), SLP_TIMEOUT(25), SLP_VEC(4, 7, 10, 10, 10)}, 1}
1881}; 1826};
1882 1827
1883/* for tim > 10 */ 1828/* for TIM > 10 */
1884static struct iwl3945_power_vec_entry range_1[IWL_POWER_AC] = { 1829static struct iwl3945_power_vec_entry range_1[IWL_POWER_AC] = {
1885 {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 1830 {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
1886 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500), 1831 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500),
@@ -2230,13 +2175,14 @@ static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv,
2230/* 2175/*
2231 * initialize rxon structure with default values from eeprom 2176 * initialize rxon structure with default values from eeprom
2232 */ 2177 */
2233static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv) 2178static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv,
2179 int mode)
2234{ 2180{
2235 const struct iwl3945_channel_info *ch_info; 2181 const struct iwl3945_channel_info *ch_info;
2236 2182
2237 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 2183 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
2238 2184
2239 switch (priv->iw_mode) { 2185 switch (mode) {
2240 case NL80211_IFTYPE_AP: 2186 case NL80211_IFTYPE_AP:
2241 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP; 2187 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
2242 break; 2188 break;
@@ -2259,7 +2205,7 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv)
2259 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK; 2205 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
2260 break; 2206 break;
2261 default: 2207 default:
2262 IWL_ERROR("Unsupported interface type %d\n", priv->iw_mode); 2208 IWL_ERROR("Unsupported interface type %d\n", mode);
2263 break; 2209 break;
2264 } 2210 }
2265 2211
@@ -2282,8 +2228,7 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv)
2282 * in some case A channels are all non IBSS 2228 * in some case A channels are all non IBSS
2283 * in this case force B/G channel 2229 * in this case force B/G channel
2284 */ 2230 */
2285 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && 2231 if ((mode == NL80211_IFTYPE_ADHOC) && !(is_channel_ibss(ch_info)))
2286 !(is_channel_ibss(ch_info)))
2287 ch_info = &priv->channel_info[0]; 2232 ch_info = &priv->channel_info[0];
2288 2233
2289 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); 2234 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
@@ -2316,14 +2261,12 @@ static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode)
2316 } 2261 }
2317 } 2262 }
2318 2263
2319 priv->iw_mode = mode; 2264 iwl3945_connection_init_rx_config(priv, mode);
2320
2321 iwl3945_connection_init_rx_config(priv);
2322 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 2265 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
2323 2266
2324 iwl3945_clear_stations_table(priv); 2267 iwl3945_clear_stations_table(priv);
2325 2268
2326 /* dont commit rxon if rf-kill is on*/ 2269 /* don't commit rxon if rf-kill is on*/
2327 if (!iwl3945_is_ready_rf(priv)) 2270 if (!iwl3945_is_ready_rf(priv))
2328 return -EAGAIN; 2271 return -EAGAIN;
2329 2272
@@ -2352,7 +2295,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
2352 case ALG_CCMP: 2295 case ALG_CCMP:
2353 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_CCM; 2296 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_CCM;
2354 memcpy(cmd->cmd.tx.key, keyinfo->key, keyinfo->keylen); 2297 memcpy(cmd->cmd.tx.key, keyinfo->key, keyinfo->keylen);
2355 IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n"); 2298 IWL_DEBUG_TX("tx_cmd with AES hwcrypto\n");
2356 break; 2299 break;
2357 2300
2358 case ALG_TKIP: 2301 case ALG_TKIP:
@@ -2397,6 +2340,7 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv,
2397{ 2340{
2398 __le16 fc = hdr->frame_control; 2341 __le16 fc = hdr->frame_control;
2399 __le32 tx_flags = cmd->cmd.tx.tx_flags; 2342 __le32 tx_flags = cmd->cmd.tx.tx_flags;
2343 u8 rc_flags = info->control.rates[0].flags;
2400 2344
2401 cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 2345 cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
2402 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { 2346 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
@@ -2423,10 +2367,10 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv,
2423 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 2367 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
2424 } 2368 }
2425 2369
2426 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 2370 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
2427 tx_flags |= TX_CMD_FLG_RTS_MSK; 2371 tx_flags |= TX_CMD_FLG_RTS_MSK;
2428 tx_flags &= ~TX_CMD_FLG_CTS_MSK; 2372 tx_flags &= ~TX_CMD_FLG_CTS_MSK;
2429 } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { 2373 } else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2430 tx_flags &= ~TX_CMD_FLG_RTS_MSK; 2374 tx_flags &= ~TX_CMD_FLG_RTS_MSK;
2431 tx_flags |= TX_CMD_FLG_CTS_MSK; 2375 tx_flags |= TX_CMD_FLG_CTS_MSK;
2432 } 2376 }
@@ -2482,8 +2426,6 @@ static int iwl3945_get_sta_id(struct iwl3945_priv *priv, struct ieee80211_hdr *h
2482 /* If this frame is going out to an IBSS network, find the station, 2426 /* If this frame is going out to an IBSS network, find the station,
2483 * or create a new station table entry */ 2427 * or create a new station table entry */
2484 case NL80211_IFTYPE_ADHOC: { 2428 case NL80211_IFTYPE_ADHOC: {
2485 DECLARE_MAC_BUF(mac);
2486
2487 /* Create new station table entry */ 2429 /* Create new station table entry */
2488 sta_id = iwl3945_hw_find_station(priv, hdr->addr1); 2430 sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
2489 if (sta_id != IWL_INVALID_STATION) 2431 if (sta_id != IWL_INVALID_STATION)
@@ -2494,9 +2436,9 @@ static int iwl3945_get_sta_id(struct iwl3945_priv *priv, struct ieee80211_hdr *h
2494 if (sta_id != IWL_INVALID_STATION) 2436 if (sta_id != IWL_INVALID_STATION)
2495 return sta_id; 2437 return sta_id;
2496 2438
2497 IWL_DEBUG_DROP("Station %s not in station map. " 2439 IWL_DEBUG_DROP("Station %pM not in station map. "
2498 "Defaulting to broadcast...\n", 2440 "Defaulting to broadcast...\n",
2499 print_mac(mac, hdr->addr1)); 2441 hdr->addr1);
2500 iwl3945_print_hex_dump(IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); 2442 iwl3945_print_hex_dump(IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
2501 return priv->hw_setting.bcast_sta_id; 2443 return priv->hw_setting.bcast_sta_id;
2502 } 2444 }
@@ -2579,10 +2521,8 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
2579 /* Find (or create) index into station table for destination station */ 2521 /* Find (or create) index into station table for destination station */
2580 sta_id = iwl3945_get_sta_id(priv, hdr); 2522 sta_id = iwl3945_get_sta_id(priv, hdr);
2581 if (sta_id == IWL_INVALID_STATION) { 2523 if (sta_id == IWL_INVALID_STATION) {
2582 DECLARE_MAC_BUF(mac); 2524 IWL_DEBUG_DROP("Dropping - INVALID STATION: %pM\n",
2583 2525 hdr->addr1);
2584 IWL_DEBUG_DROP("Dropping - INVALID STATION: %s\n",
2585 print_mac(mac, hdr->addr1));
2586 goto drop; 2526 goto drop;
2587 } 2527 }
2588 2528
@@ -4019,8 +3959,6 @@ static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv,
4019#ifdef CONFIG_IWL3945_DEBUG 3959#ifdef CONFIG_IWL3945_DEBUG
4020static void iwl3945_print_rx_config_cmd(struct iwl3945_rxon_cmd *rxon) 3960static void iwl3945_print_rx_config_cmd(struct iwl3945_rxon_cmd *rxon)
4021{ 3961{
4022 DECLARE_MAC_BUF(mac);
4023
4024 IWL_DEBUG_RADIO("RX CONFIG:\n"); 3962 IWL_DEBUG_RADIO("RX CONFIG:\n");
4025 iwl3945_print_hex_dump(IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); 3963 iwl3945_print_hex_dump(IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
4026 IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); 3964 IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel));
@@ -4031,10 +3969,8 @@ static void iwl3945_print_rx_config_cmd(struct iwl3945_rxon_cmd *rxon)
4031 IWL_DEBUG_RADIO("u8 ofdm_basic_rates: 0x%02x\n", 3969 IWL_DEBUG_RADIO("u8 ofdm_basic_rates: 0x%02x\n",
4032 rxon->ofdm_basic_rates); 3970 rxon->ofdm_basic_rates);
4033 IWL_DEBUG_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); 3971 IWL_DEBUG_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates);
4034 IWL_DEBUG_RADIO("u8[6] node_addr: %s\n", 3972 IWL_DEBUG_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr);
4035 print_mac(mac, rxon->node_addr)); 3973 IWL_DEBUG_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr);
4036 IWL_DEBUG_RADIO("u8[6] bssid_addr: %s\n",
4037 print_mac(mac, rxon->bssid_addr));
4038 IWL_DEBUG_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); 3974 IWL_DEBUG_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id));
4039} 3975}
4040#endif 3976#endif
@@ -4050,7 +3986,7 @@ static void iwl3945_enable_interrupts(struct iwl3945_priv *priv)
4050/* call this function to flush any scheduled tasklet */ 3986/* call this function to flush any scheduled tasklet */
4051static inline void iwl_synchronize_irq(struct iwl3945_priv *priv) 3987static inline void iwl_synchronize_irq(struct iwl3945_priv *priv)
4052{ 3988{
4053 /* wait to make sure we flush pedding tasklet*/ 3989 /* wait to make sure we flush pending tasklet*/
4054 synchronize_irq(priv->pci_dev->irq); 3990 synchronize_irq(priv->pci_dev->irq);
4055 tasklet_kill(&priv->irq_tasklet); 3991 tasklet_kill(&priv->irq_tasklet);
4056} 3992}
@@ -5607,7 +5543,7 @@ static int iwl3945_set_ucode_ptrs(struct iwl3945_priv *priv)
5607 iwl3945_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, 5543 iwl3945_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG,
5608 priv->ucode_data.len); 5544 priv->ucode_data.len);
5609 5545
5610 /* Inst bytecount must be last to set up, bit 31 signals uCode 5546 /* Inst byte count must be last to set up, bit 31 signals uCode
5611 * that all new ptr/size info is in place */ 5547 * that all new ptr/size info is in place */
5612 iwl3945_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, 5548 iwl3945_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG,
5613 priv->ucode_code.len | BSM_DRAM_INST_LOAD); 5549 priv->ucode_code.len | BSM_DRAM_INST_LOAD);
@@ -5699,7 +5635,7 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
5699 5635
5700 rc = iwl3945_grab_nic_access(priv); 5636 rc = iwl3945_grab_nic_access(priv);
5701 if (rc) { 5637 if (rc) {
5702 IWL_WARNING("Can not read rfkill status from adapter\n"); 5638 IWL_WARNING("Can not read RFKILL status from adapter\n");
5703 return; 5639 return;
5704 } 5640 }
5705 5641
@@ -5709,7 +5645,7 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
5709 5645
5710 if (rfkill & 0x1) { 5646 if (rfkill & 0x1) {
5711 clear_bit(STATUS_RF_KILL_HW, &priv->status); 5647 clear_bit(STATUS_RF_KILL_HW, &priv->status);
5712 /* if rfkill is not on, then wait for thermal 5648 /* if RFKILL is not on, then wait for thermal
5713 * sensor in adapter to kick in */ 5649 * sensor in adapter to kick in */
5714 while (iwl3945_hw_get_temperature(priv) == 0) { 5650 while (iwl3945_hw_get_temperature(priv) == 0) {
5715 thermal_spin++; 5651 thermal_spin++;
@@ -5747,7 +5683,7 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
5747 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 5683 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
5748 } else { 5684 } else {
5749 /* Initialize our rx_config data */ 5685 /* Initialize our rx_config data */
5750 iwl3945_connection_init_rx_config(priv); 5686 iwl3945_connection_init_rx_config(priv, priv->iw_mode);
5751 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 5687 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
5752 } 5688 }
5753 5689
@@ -5902,7 +5838,7 @@ static int __iwl3945_up(struct iwl3945_priv *priv)
5902 } 5838 }
5903 5839
5904 if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { 5840 if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) {
5905 IWL_ERROR("ucode not available for device bringup\n"); 5841 IWL_ERROR("ucode not available for device bring up\n");
5906 return -EIO; 5842 return -EIO;
5907 } 5843 }
5908 5844
@@ -6063,6 +5999,7 @@ static void iwl3945_bg_set_monitor(struct work_struct *work)
6063 IWL_ERROR("iwl3945_set_mode() failed\n"); 5999 IWL_ERROR("iwl3945_set_mode() failed\n");
6064 6000
6065 mutex_unlock(&priv->mutex); 6001 mutex_unlock(&priv->mutex);
6002 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
6066} 6003}
6067 6004
6068#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 6005#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ)
@@ -6102,6 +6039,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
6102 struct ieee80211_conf *conf = NULL; 6039 struct ieee80211_conf *conf = NULL;
6103 u8 n_probes = 2; 6040 u8 n_probes = 2;
6104 enum ieee80211_band band; 6041 enum ieee80211_band band;
6042 DECLARE_SSID_BUF(ssid);
6105 6043
6106 conf = ieee80211_get_hw_conf(priv->hw); 6044 conf = ieee80211_get_hw_conf(priv->hw);
6107 6045
@@ -6112,7 +6050,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
6112 goto done; 6050 goto done;
6113 } 6051 }
6114 6052
6115 /* Make sure the scan wasn't cancelled before this queued work 6053 /* Make sure the scan wasn't canceled before this queued work
6116 * was given the chance to run... */ 6054 * was given the chance to run... */
6117 if (!test_bit(STATUS_SCANNING, &priv->status)) 6055 if (!test_bit(STATUS_SCANNING, &priv->status))
6118 goto done; 6056 goto done;
@@ -6202,21 +6140,13 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
6202 if (priv->one_direct_scan) { 6140 if (priv->one_direct_scan) {
6203 IWL_DEBUG_SCAN 6141 IWL_DEBUG_SCAN
6204 ("Kicking off one direct scan for '%s'\n", 6142 ("Kicking off one direct scan for '%s'\n",
6205 iwl3945_escape_essid(priv->direct_ssid, 6143 print_ssid(ssid, priv->direct_ssid,
6206 priv->direct_ssid_len)); 6144 priv->direct_ssid_len));
6207 scan->direct_scan[0].id = WLAN_EID_SSID; 6145 scan->direct_scan[0].id = WLAN_EID_SSID;
6208 scan->direct_scan[0].len = priv->direct_ssid_len; 6146 scan->direct_scan[0].len = priv->direct_ssid_len;
6209 memcpy(scan->direct_scan[0].ssid, 6147 memcpy(scan->direct_scan[0].ssid,
6210 priv->direct_ssid, priv->direct_ssid_len); 6148 priv->direct_ssid, priv->direct_ssid_len);
6211 n_probes++; 6149 n_probes++;
6212 } else if (!iwl3945_is_associated(priv) && priv->essid_len) {
6213 IWL_DEBUG_SCAN
6214 ("Kicking off one direct scan for '%s' when not associated\n",
6215 iwl3945_escape_essid(priv->essid, priv->essid_len));
6216 scan->direct_scan[0].id = WLAN_EID_SSID;
6217 scan->direct_scan[0].len = priv->essid_len;
6218 memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
6219 n_probes++;
6220 } else 6150 } else
6221 IWL_DEBUG_SCAN("Kicking off one indirect scan.\n"); 6151 IWL_DEBUG_SCAN("Kicking off one indirect scan.\n");
6222 6152
@@ -6224,7 +6154,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
6224 * that based on the direct_mask added to each channel entry */ 6154 * that based on the direct_mask added to each channel entry */
6225 scan->tx_cmd.len = cpu_to_le16( 6155 scan->tx_cmd.len = cpu_to_le16(
6226 iwl3945_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, 6156 iwl3945_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data,
6227 IWL_MAX_SCAN_SIZE - sizeof(*scan), 0)); 6157 IWL_MAX_SCAN_SIZE - sizeof(*scan)));
6228 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 6158 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
6229 scan->tx_cmd.sta_id = priv->hw_setting.bcast_sta_id; 6159 scan->tx_cmd.sta_id = priv->hw_setting.bcast_sta_id;
6230 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 6160 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
@@ -6334,7 +6264,6 @@ static void iwl3945_post_associate(struct iwl3945_priv *priv)
6334{ 6264{
6335 int rc = 0; 6265 int rc = 0;
6336 struct ieee80211_conf *conf = NULL; 6266 struct ieee80211_conf *conf = NULL;
6337 DECLARE_MAC_BUF(mac);
6338 6267
6339 if (priv->iw_mode == NL80211_IFTYPE_AP) { 6268 if (priv->iw_mode == NL80211_IFTYPE_AP) {
6340 IWL_ERROR("%s Should not be called in AP mode\n", __func__); 6269 IWL_ERROR("%s Should not be called in AP mode\n", __func__);
@@ -6342,9 +6271,8 @@ static void iwl3945_post_associate(struct iwl3945_priv *priv)
6342 } 6271 }
6343 6272
6344 6273
6345 IWL_DEBUG_ASSOC("Associated as %d to: %s\n", 6274 IWL_DEBUG_ASSOC("Associated as %d to: %pM\n",
6346 priv->assoc_id, 6275 priv->assoc_id, priv->active_rxon.bssid_addr);
6347 print_mac(mac, priv->active_rxon.bssid_addr));
6348 6276
6349 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 6277 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
6350 return; 6278 return;
@@ -6440,7 +6368,7 @@ static void iwl3945_bg_abort_scan(struct work_struct *work)
6440 mutex_unlock(&priv->mutex); 6368 mutex_unlock(&priv->mutex);
6441} 6369}
6442 6370
6443static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 6371static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed);
6444 6372
6445static void iwl3945_bg_scan_completed(struct work_struct *work) 6373static void iwl3945_bg_scan_completed(struct work_struct *work)
6446{ 6374{
@@ -6453,7 +6381,7 @@ static void iwl3945_bg_scan_completed(struct work_struct *work)
6453 return; 6381 return;
6454 6382
6455 if (test_bit(STATUS_CONF_PENDING, &priv->status)) 6383 if (test_bit(STATUS_CONF_PENDING, &priv->status))
6456 iwl3945_mac_config(priv->hw, ieee80211_get_hw_conf(priv->hw)); 6384 iwl3945_mac_config(priv->hw, 0);
6457 6385
6458 ieee80211_scan_completed(priv->hw); 6386 ieee80211_scan_completed(priv->hw);
6459 6387
@@ -6605,7 +6533,6 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
6605{ 6533{
6606 struct iwl3945_priv *priv = hw->priv; 6534 struct iwl3945_priv *priv = hw->priv;
6607 unsigned long flags; 6535 unsigned long flags;
6608 DECLARE_MAC_BUF(mac);
6609 6536
6610 IWL_DEBUG_MAC80211("enter: type %d\n", conf->type); 6537 IWL_DEBUG_MAC80211("enter: type %d\n", conf->type);
6611 6538
@@ -6616,13 +6543,14 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
6616 6543
6617 spin_lock_irqsave(&priv->lock, flags); 6544 spin_lock_irqsave(&priv->lock, flags);
6618 priv->vif = conf->vif; 6545 priv->vif = conf->vif;
6546 priv->iw_mode = conf->type;
6619 6547
6620 spin_unlock_irqrestore(&priv->lock, flags); 6548 spin_unlock_irqrestore(&priv->lock, flags);
6621 6549
6622 mutex_lock(&priv->mutex); 6550 mutex_lock(&priv->mutex);
6623 6551
6624 if (conf->mac_addr) { 6552 if (conf->mac_addr) {
6625 IWL_DEBUG_MAC80211("Set: %s\n", print_mac(mac, conf->mac_addr)); 6553 IWL_DEBUG_MAC80211("Set: %pM\n", conf->mac_addr);
6626 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); 6554 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
6627 } 6555 }
6628 6556
@@ -6642,10 +6570,11 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
6642 * be set inappropriately and the driver currently sets the hardware up to 6570 * be set inappropriately and the driver currently sets the hardware up to
6643 * use it whenever needed. 6571 * use it whenever needed.
6644 */ 6572 */
6645static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 6573static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
6646{ 6574{
6647 struct iwl3945_priv *priv = hw->priv; 6575 struct iwl3945_priv *priv = hw->priv;
6648 const struct iwl3945_channel_info *ch_info; 6576 const struct iwl3945_channel_info *ch_info;
6577 struct ieee80211_conf *conf = &hw->conf;
6649 unsigned long flags; 6578 unsigned long flags;
6650 int ret = 0; 6579 int ret = 0;
6651 6580
@@ -6791,8 +6720,6 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6791 struct ieee80211_if_conf *conf) 6720 struct ieee80211_if_conf *conf)
6792{ 6721{
6793 struct iwl3945_priv *priv = hw->priv; 6722 struct iwl3945_priv *priv = hw->priv;
6794 DECLARE_MAC_BUF(mac);
6795 unsigned long flags;
6796 int rc; 6723 int rc;
6797 6724
6798 if (conf == NULL) 6725 if (conf == NULL)
@@ -6814,23 +6741,13 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6814 return rc; 6741 return rc;
6815 } 6742 }
6816 6743
6817 /* XXX: this MUST use conf->mac_addr */
6818
6819 if ((priv->iw_mode == NL80211_IFTYPE_AP) &&
6820 (!conf->ssid_len)) {
6821 IWL_DEBUG_MAC80211
6822 ("Leaving in AP mode because HostAPD is not ready.\n");
6823 return 0;
6824 }
6825
6826 if (!iwl3945_is_alive(priv)) 6744 if (!iwl3945_is_alive(priv))
6827 return -EAGAIN; 6745 return -EAGAIN;
6828 6746
6829 mutex_lock(&priv->mutex); 6747 mutex_lock(&priv->mutex);
6830 6748
6831 if (conf->bssid) 6749 if (conf->bssid)
6832 IWL_DEBUG_MAC80211("bssid: %s\n", 6750 IWL_DEBUG_MAC80211("bssid: %pM\n", conf->bssid);
6833 print_mac(mac, conf->bssid));
6834 6751
6835/* 6752/*
6836 * very dubious code was here; the probe filtering flag is never set: 6753 * very dubious code was here; the probe filtering flag is never set:
@@ -6843,8 +6760,8 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6843 if (!conf->bssid) { 6760 if (!conf->bssid) {
6844 conf->bssid = priv->mac_addr; 6761 conf->bssid = priv->mac_addr;
6845 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN); 6762 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
6846 IWL_DEBUG_MAC80211("bssid was set to: %s\n", 6763 IWL_DEBUG_MAC80211("bssid was set to: %pM\n",
6847 print_mac(mac, conf->bssid)); 6764 conf->bssid);
6848 } 6765 }
6849 if (priv->ibss_beacon) 6766 if (priv->ibss_beacon)
6850 dev_kfree_skb(priv->ibss_beacon); 6767 dev_kfree_skb(priv->ibss_beacon);
@@ -6890,15 +6807,6 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6890 } 6807 }
6891 6808
6892 done: 6809 done:
6893 spin_lock_irqsave(&priv->lock, flags);
6894 if (!conf->ssid_len)
6895 memset(priv->essid, 0, IW_ESSID_MAX_SIZE);
6896 else
6897 memcpy(priv->essid, conf->ssid, conf->ssid_len);
6898
6899 priv->essid_len = conf->ssid_len;
6900 spin_unlock_irqrestore(&priv->lock, flags);
6901
6902 IWL_DEBUG_MAC80211("leave\n"); 6810 IWL_DEBUG_MAC80211("leave\n");
6903 mutex_unlock(&priv->mutex); 6811 mutex_unlock(&priv->mutex);
6904 6812
@@ -6941,8 +6849,6 @@ static void iwl3945_mac_remove_interface(struct ieee80211_hw *hw,
6941 if (priv->vif == conf->vif) { 6849 if (priv->vif == conf->vif) {
6942 priv->vif = NULL; 6850 priv->vif = NULL;
6943 memset(priv->bssid, 0, ETH_ALEN); 6851 memset(priv->bssid, 0, ETH_ALEN);
6944 memset(priv->essid, 0, IW_ESSID_MAX_SIZE);
6945 priv->essid_len = 0;
6946 } 6852 }
6947 mutex_unlock(&priv->mutex); 6853 mutex_unlock(&priv->mutex);
6948 6854
@@ -7011,6 +6917,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
7011 int rc = 0; 6917 int rc = 0;
7012 unsigned long flags; 6918 unsigned long flags;
7013 struct iwl3945_priv *priv = hw->priv; 6919 struct iwl3945_priv *priv = hw->priv;
6920 DECLARE_SSID_BUF(ssid_buf);
7014 6921
7015 IWL_DEBUG_MAC80211("enter\n"); 6922 IWL_DEBUG_MAC80211("enter\n");
7016 6923
@@ -7044,7 +6951,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
7044 } 6951 }
7045 if (len) { 6952 if (len) {
7046 IWL_DEBUG_SCAN("direct scan for %s [%d]\n ", 6953 IWL_DEBUG_SCAN("direct scan for %s [%d]\n ",
7047 iwl3945_escape_essid(ssid, len), (int)len); 6954 print_ssid(ssid_buf, ssid, len), (int)len);
7048 6955
7049 priv->one_direct_scan = 1; 6956 priv->one_direct_scan = 1;
7050 priv->direct_ssid_len = (u8) 6957 priv->direct_ssid_len = (u8)
@@ -7085,10 +6992,8 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
7085 6992
7086 sta_id = iwl3945_hw_find_station(priv, addr); 6993 sta_id = iwl3945_hw_find_station(priv, addr);
7087 if (sta_id == IWL_INVALID_STATION) { 6994 if (sta_id == IWL_INVALID_STATION) {
7088 DECLARE_MAC_BUF(mac); 6995 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n",
7089 6996 addr);
7090 IWL_DEBUG_MAC80211("leave - %s not in station map.\n",
7091 print_mac(mac, addr));
7092 return -EINVAL; 6997 return -EINVAL;
7093 } 6998 }
7094 6999
@@ -7220,14 +7125,6 @@ static int iwl3945_mac_get_stats(struct ieee80211_hw *hw,
7220 return 0; 7125 return 0;
7221} 7126}
7222 7127
7223static u64 iwl3945_mac_get_tsf(struct ieee80211_hw *hw)
7224{
7225 IWL_DEBUG_MAC80211("enter\n");
7226 IWL_DEBUG_MAC80211("leave\n");
7227
7228 return 0;
7229}
7230
7231static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw) 7128static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
7232{ 7129{
7233 struct iwl3945_priv *priv = hw->priv; 7130 struct iwl3945_priv *priv = hw->priv;
@@ -7793,7 +7690,7 @@ static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log);
7793 7690
7794/***************************************************************************** 7691/*****************************************************************************
7795 * 7692 *
7796 * driver setup and teardown 7693 * driver setup and tear down
7797 * 7694 *
7798 *****************************************************************************/ 7695 *****************************************************************************/
7799 7696
@@ -7870,7 +7767,6 @@ static struct ieee80211_ops iwl3945_hw_ops = {
7870 .get_stats = iwl3945_mac_get_stats, 7767 .get_stats = iwl3945_mac_get_stats,
7871 .get_tx_stats = iwl3945_mac_get_tx_stats, 7768 .get_tx_stats = iwl3945_mac_get_tx_stats,
7872 .conf_tx = iwl3945_mac_conf_tx, 7769 .conf_tx = iwl3945_mac_conf_tx,
7873 .get_tsf = iwl3945_mac_get_tsf,
7874 .reset_tsf = iwl3945_mac_reset_tsf, 7770 .reset_tsf = iwl3945_mac_reset_tsf,
7875 .bss_info_changed = iwl3945_bss_info_changed, 7771 .bss_info_changed = iwl3945_bss_info_changed,
7876 .hw_scan = iwl3945_mac_hw_scan 7772 .hw_scan = iwl3945_mac_hw_scan
@@ -7883,7 +7779,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7883 struct ieee80211_hw *hw; 7779 struct ieee80211_hw *hw;
7884 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data); 7780 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data);
7885 unsigned long flags; 7781 unsigned long flags;
7886 DECLARE_MAC_BUF(mac);
7887 7782
7888 /* Disabling hardware scan means that mac80211 will perform scans 7783 /* Disabling hardware scan means that mac80211 will perform scans
7889 * "the hard way", rather than using device's scan. */ 7784 * "the hard way", rather than using device's scan. */
@@ -8058,7 +7953,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8058 } 7953 }
8059 /* MAC Address location in EEPROM same for 3945/4965 */ 7954 /* MAC Address location in EEPROM same for 3945/4965 */
8060 get_eeprom_mac(priv, priv->mac_addr); 7955 get_eeprom_mac(priv, priv->mac_addr);
8061 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); 7956 IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr);
8062 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 7957 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
8063 7958
8064 err = iwl3945_init_channel_map(priv); 7959 err = iwl3945_init_channel_map(priv);
@@ -8223,7 +8118,7 @@ static int iwl3945_rfkill_soft_rf_kill(void *data, enum rfkill_state state)
8223 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 8118 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
8224 return 0; 8119 return 0;
8225 8120
8226 IWL_DEBUG_RF_KILL("we recieved soft RFKILL set to state %d\n", state); 8121 IWL_DEBUG_RF_KILL("we received soft RFKILL set to state %d\n", state);
8227 mutex_lock(&priv->mutex); 8122 mutex_lock(&priv->mutex);
8228 8123
8229 switch (state) { 8124 switch (state) {
@@ -8238,7 +8133,7 @@ static int iwl3945_rfkill_soft_rf_kill(void *data, enum rfkill_state state)
8238 iwl3945_radio_kill_sw(priv, 1); 8133 iwl3945_radio_kill_sw(priv, 1);
8239 break; 8134 break;
8240 default: 8135 default:
8241 IWL_WARNING("we recieved unexpected RFKILL state %d\n", state); 8136 IWL_WARNING("we received unexpected RFKILL state %d\n", state);
8242 break; 8137 break;
8243 } 8138 }
8244out_unlock: 8139out_unlock:
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 92be60415d04..a0e440cd8967 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -1,6 +1,10 @@
1/* Copyright (C) 2006, Red Hat, Inc. */ 1/* Copyright (C) 2006, Red Hat, Inc. */
2 2
3#include <linux/types.h>
3#include <linux/etherdevice.h> 4#include <linux/etherdevice.h>
5#include <linux/ieee80211.h>
6#include <linux/if_arp.h>
7#include <net/lib80211.h>
4 8
5#include "assoc.h" 9#include "assoc.h"
6#include "decl.h" 10#include "decl.h"
@@ -151,18 +155,18 @@ static int lbs_adhoc_join(struct lbs_private *priv,
151 struct cmd_ds_802_11_ad_hoc_join cmd; 155 struct cmd_ds_802_11_ad_hoc_join cmd;
152 struct bss_descriptor *bss = &assoc_req->bss; 156 struct bss_descriptor *bss = &assoc_req->bss;
153 u8 preamble = RADIO_PREAMBLE_LONG; 157 u8 preamble = RADIO_PREAMBLE_LONG;
154 DECLARE_MAC_BUF(mac); 158 DECLARE_SSID_BUF(ssid);
155 u16 ratesize = 0; 159 u16 ratesize = 0;
156 int ret = 0; 160 int ret = 0;
157 161
158 lbs_deb_enter(LBS_DEB_ASSOC); 162 lbs_deb_enter(LBS_DEB_ASSOC);
159 163
160 lbs_deb_join("current SSID '%s', ssid length %u\n", 164 lbs_deb_join("current SSID '%s', ssid length %u\n",
161 escape_essid(priv->curbssparams.ssid, 165 print_ssid(ssid, priv->curbssparams.ssid,
162 priv->curbssparams.ssid_len), 166 priv->curbssparams.ssid_len),
163 priv->curbssparams.ssid_len); 167 priv->curbssparams.ssid_len);
164 lbs_deb_join("requested ssid '%s', ssid length %u\n", 168 lbs_deb_join("requested ssid '%s', ssid length %u\n",
165 escape_essid(bss->ssid, bss->ssid_len), 169 print_ssid(ssid, bss->ssid, bss->ssid_len),
166 bss->ssid_len); 170 bss->ssid_len);
167 171
168 /* check if the requested SSID is already joined */ 172 /* check if the requested SSID is already joined */
@@ -226,8 +230,8 @@ static int lbs_adhoc_join(struct lbs_private *priv,
226 bss->capability, CAPINFO_MASK); 230 bss->capability, CAPINFO_MASK);
227 231
228 /* information on BSSID descriptor passed to FW */ 232 /* information on BSSID descriptor passed to FW */
229 lbs_deb_join("ADHOC_J_CMD: BSSID = %s, SSID = '%s'\n", 233 lbs_deb_join("ADHOC_J_CMD: BSSID = %pM, SSID = '%s'\n",
230 print_mac(mac, cmd.bss.bssid), cmd.bss.ssid); 234 cmd.bss.bssid, cmd.bss.ssid);
231 235
232 /* Only v8 and below support setting these */ 236 /* Only v8 and below support setting these */
233 if (priv->fwrelease < 0x09000000) { 237 if (priv->fwrelease < 0x09000000) {
@@ -307,6 +311,7 @@ static int lbs_adhoc_start(struct lbs_private *priv,
307 size_t ratesize = 0; 311 size_t ratesize = 0;
308 u16 tmpcap = 0; 312 u16 tmpcap = 0;
309 int ret = 0; 313 int ret = 0;
314 DECLARE_SSID_BUF(ssid);
310 315
311 lbs_deb_enter(LBS_DEB_ASSOC); 316 lbs_deb_enter(LBS_DEB_ASSOC);
312 317
@@ -326,7 +331,7 @@ static int lbs_adhoc_start(struct lbs_private *priv,
326 memcpy(cmd.ssid, assoc_req->ssid, assoc_req->ssid_len); 331 memcpy(cmd.ssid, assoc_req->ssid, assoc_req->ssid_len);
327 332
328 lbs_deb_join("ADHOC_START: SSID '%s', ssid length %u\n", 333 lbs_deb_join("ADHOC_START: SSID '%s', ssid length %u\n",
329 escape_essid(assoc_req->ssid, assoc_req->ssid_len), 334 print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len),
330 assoc_req->ssid_len); 335 assoc_req->ssid_len);
331 336
332 cmd.bsstype = CMD_BSS_TYPE_IBSS; 337 cmd.bsstype = CMD_BSS_TYPE_IBSS;
@@ -338,12 +343,12 @@ static int lbs_adhoc_start(struct lbs_private *priv,
338 WARN_ON(!assoc_req->channel); 343 WARN_ON(!assoc_req->channel);
339 344
340 /* set Physical parameter set */ 345 /* set Physical parameter set */
341 cmd.phyparamset.dsparamset.elementid = MFIE_TYPE_DS_SET; 346 cmd.phyparamset.dsparamset.elementid = WLAN_EID_DS_PARAMS;
342 cmd.phyparamset.dsparamset.len = 1; 347 cmd.phyparamset.dsparamset.len = 1;
343 cmd.phyparamset.dsparamset.currentchan = assoc_req->channel; 348 cmd.phyparamset.dsparamset.currentchan = assoc_req->channel;
344 349
345 /* set IBSS parameter set */ 350 /* set IBSS parameter set */
346 cmd.ssparamset.ibssparamset.elementid = MFIE_TYPE_IBSS_SET; 351 cmd.ssparamset.ibssparamset.elementid = WLAN_EID_IBSS_PARAMS;
347 cmd.ssparamset.ibssparamset.len = 2; 352 cmd.ssparamset.ibssparamset.len = 2;
348 cmd.ssparamset.ibssparamset.atimwindow = 0; 353 cmd.ssparamset.ibssparamset.atimwindow = 0;
349 354
@@ -427,8 +432,8 @@ static inline int match_bss_no_security(struct lbs_802_11_security *secinfo,
427{ 432{
428 if (!secinfo->wep_enabled && !secinfo->WPAenabled 433 if (!secinfo->wep_enabled && !secinfo->WPAenabled
429 && !secinfo->WPA2enabled 434 && !secinfo->WPA2enabled
430 && match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC 435 && match_bss->wpa_ie[0] != WLAN_EID_GENERIC
431 && match_bss->rsn_ie[0] != MFIE_TYPE_RSN 436 && match_bss->rsn_ie[0] != WLAN_EID_RSN
432 && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY)) 437 && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY))
433 return 1; 438 return 1;
434 else 439 else
@@ -450,7 +455,7 @@ static inline int match_bss_wpa(struct lbs_802_11_security *secinfo,
450 struct bss_descriptor *match_bss) 455 struct bss_descriptor *match_bss)
451{ 456{
452 if (!secinfo->wep_enabled && secinfo->WPAenabled 457 if (!secinfo->wep_enabled && secinfo->WPAenabled
453 && (match_bss->wpa_ie[0] == MFIE_TYPE_GENERIC) 458 && (match_bss->wpa_ie[0] == WLAN_EID_GENERIC)
454 /* privacy bit may NOT be set in some APs like LinkSys WRT54G 459 /* privacy bit may NOT be set in some APs like LinkSys WRT54G
455 && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */ 460 && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */
456 ) 461 )
@@ -463,7 +468,7 @@ static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo,
463 struct bss_descriptor *match_bss) 468 struct bss_descriptor *match_bss)
464{ 469{
465 if (!secinfo->wep_enabled && secinfo->WPA2enabled && 470 if (!secinfo->wep_enabled && secinfo->WPA2enabled &&
466 (match_bss->rsn_ie[0] == MFIE_TYPE_RSN) 471 (match_bss->rsn_ie[0] == WLAN_EID_RSN)
467 /* privacy bit may NOT be set in some APs like LinkSys WRT54G 472 /* privacy bit may NOT be set in some APs like LinkSys WRT54G
468 (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */ 473 (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */
469 ) 474 )
@@ -477,8 +482,8 @@ static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo,
477{ 482{
478 if (!secinfo->wep_enabled && !secinfo->WPAenabled 483 if (!secinfo->wep_enabled && !secinfo->WPAenabled
479 && !secinfo->WPA2enabled 484 && !secinfo->WPA2enabled
480 && (match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC) 485 && (match_bss->wpa_ie[0] != WLAN_EID_GENERIC)
481 && (match_bss->rsn_ie[0] != MFIE_TYPE_RSN) 486 && (match_bss->rsn_ie[0] != WLAN_EID_RSN)
482 && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) 487 && (match_bss->capability & WLAN_CAPABILITY_PRIVACY))
483 return 1; 488 return 1;
484 else 489 else
@@ -694,6 +699,7 @@ static int assoc_helper_essid(struct lbs_private *priv,
694 int ret = 0; 699 int ret = 0;
695 struct bss_descriptor * bss; 700 struct bss_descriptor * bss;
696 int channel = -1; 701 int channel = -1;
702 DECLARE_SSID_BUF(ssid);
697 703
698 lbs_deb_enter(LBS_DEB_ASSOC); 704 lbs_deb_enter(LBS_DEB_ASSOC);
699 705
@@ -705,7 +711,7 @@ static int assoc_helper_essid(struct lbs_private *priv,
705 channel = assoc_req->channel; 711 channel = assoc_req->channel;
706 712
707 lbs_deb_assoc("SSID '%s' requested\n", 713 lbs_deb_assoc("SSID '%s' requested\n",
708 escape_essid(assoc_req->ssid, assoc_req->ssid_len)); 714 print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len));
709 if (assoc_req->mode == IW_MODE_INFRA) { 715 if (assoc_req->mode == IW_MODE_INFRA) {
710 lbs_send_specific_ssid_scan(priv, assoc_req->ssid, 716 lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
711 assoc_req->ssid_len); 717 assoc_req->ssid_len);
@@ -752,17 +758,15 @@ static int assoc_helper_bssid(struct lbs_private *priv,
752{ 758{
753 int ret = 0; 759 int ret = 0;
754 struct bss_descriptor * bss; 760 struct bss_descriptor * bss;
755 DECLARE_MAC_BUF(mac);
756 761
757 lbs_deb_enter_args(LBS_DEB_ASSOC, "BSSID %s", 762 lbs_deb_enter_args(LBS_DEB_ASSOC, "BSSID %pM", assoc_req->bssid);
758 print_mac(mac, assoc_req->bssid));
759 763
760 /* Search for index position in list for requested MAC */ 764 /* Search for index position in list for requested MAC */
761 bss = lbs_find_bssid_in_list(priv, assoc_req->bssid, 765 bss = lbs_find_bssid_in_list(priv, assoc_req->bssid,
762 assoc_req->mode); 766 assoc_req->mode);
763 if (bss == NULL) { 767 if (bss == NULL) {
764 lbs_deb_assoc("ASSOC: WAP: BSSID %s not found, " 768 lbs_deb_assoc("ASSOC: WAP: BSSID %pM not found, "
765 "cannot associate.\n", print_mac(mac, assoc_req->bssid)); 769 "cannot associate.\n", assoc_req->bssid);
766 goto out; 770 goto out;
767 } 771 }
768 772
@@ -1208,7 +1212,7 @@ void lbs_association_worker(struct work_struct *work)
1208 struct assoc_request * assoc_req = NULL; 1212 struct assoc_request * assoc_req = NULL;
1209 int ret = 0; 1213 int ret = 0;
1210 int find_any_ssid = 0; 1214 int find_any_ssid = 0;
1211 DECLARE_MAC_BUF(mac); 1215 DECLARE_SSID_BUF(ssid);
1212 1216
1213 lbs_deb_enter(LBS_DEB_ASSOC); 1217 lbs_deb_enter(LBS_DEB_ASSOC);
1214 1218
@@ -1228,13 +1232,13 @@ void lbs_association_worker(struct work_struct *work)
1228 " chann: %d\n" 1232 " chann: %d\n"
1229 " band: %d\n" 1233 " band: %d\n"
1230 " mode: %d\n" 1234 " mode: %d\n"
1231 " BSSID: %s\n" 1235 " BSSID: %pM\n"
1232 " secinfo: %s%s%s\n" 1236 " secinfo: %s%s%s\n"
1233 " auth_mode: %d\n", 1237 " auth_mode: %d\n",
1234 assoc_req->flags, 1238 assoc_req->flags,
1235 escape_essid(assoc_req->ssid, assoc_req->ssid_len), 1239 print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len),
1236 assoc_req->channel, assoc_req->band, assoc_req->mode, 1240 assoc_req->channel, assoc_req->band, assoc_req->mode,
1237 print_mac(mac, assoc_req->bssid), 1241 assoc_req->bssid,
1238 assoc_req->secinfo.WPAenabled ? " WPA" : "", 1242 assoc_req->secinfo.WPAenabled ? " WPA" : "",
1239 assoc_req->secinfo.WPA2enabled ? " WPA2" : "", 1243 assoc_req->secinfo.WPA2enabled ? " WPA2" : "",
1240 assoc_req->secinfo.wep_enabled ? " WEP" : "", 1244 assoc_req->secinfo.wep_enabled ? " WEP" : "",
@@ -1357,8 +1361,8 @@ void lbs_association_worker(struct work_struct *work)
1357 } 1361 }
1358 1362
1359 if (success) { 1363 if (success) {
1360 lbs_deb_assoc("associated to %s\n", 1364 lbs_deb_assoc("associated to %pM\n",
1361 print_mac(mac, priv->curbssparams.bssid)); 1365 priv->curbssparams.bssid);
1362 lbs_prepare_and_send_command(priv, 1366 lbs_prepare_and_send_command(priv,
1363 CMD_802_11_RSSI, 1367 CMD_802_11_RSSI,
1364 0, CMD_OPTION_WAITFORRSP, 0, NULL); 1368 0, CMD_OPTION_WAITFORRSP, 0, NULL);
@@ -1478,7 +1482,6 @@ int lbs_cmd_80211_authenticate(struct lbs_private *priv,
1478 struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth; 1482 struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth;
1479 int ret = -1; 1483 int ret = -1;
1480 u8 *bssid = pdata_buf; 1484 u8 *bssid = pdata_buf;
1481 DECLARE_MAC_BUF(mac);
1482 1485
1483 lbs_deb_enter(LBS_DEB_JOIN); 1486 lbs_deb_enter(LBS_DEB_JOIN);
1484 1487
@@ -1505,8 +1508,8 @@ int lbs_cmd_80211_authenticate(struct lbs_private *priv,
1505 1508
1506 memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); 1509 memcpy(pauthenticate->macaddr, bssid, ETH_ALEN);
1507 1510
1508 lbs_deb_join("AUTH_CMD: BSSID %s, auth 0x%x\n", 1511 lbs_deb_join("AUTH_CMD: BSSID %pM, auth 0x%x\n",
1509 print_mac(mac, bssid), pauthenticate->authtype); 1512 bssid, pauthenticate->authtype);
1510 ret = 0; 1513 ret = 0;
1511 1514
1512out: 1515out:
@@ -1770,7 +1773,7 @@ static int lbs_adhoc_post(struct lbs_private *priv, struct cmd_header *resp)
1770 struct cmd_ds_802_11_ad_hoc_result *adhoc_resp; 1773 struct cmd_ds_802_11_ad_hoc_result *adhoc_resp;
1771 union iwreq_data wrqu; 1774 union iwreq_data wrqu;
1772 struct bss_descriptor *bss; 1775 struct bss_descriptor *bss;
1773 DECLARE_MAC_BUF(mac); 1776 DECLARE_SSID_BUF(ssid);
1774 1777
1775 lbs_deb_enter(LBS_DEB_JOIN); 1778 lbs_deb_enter(LBS_DEB_JOIN);
1776 1779
@@ -1819,9 +1822,9 @@ static int lbs_adhoc_post(struct lbs_private *priv, struct cmd_header *resp)
1819 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 1822 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1820 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 1823 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
1821 1824
1822 lbs_deb_join("ADHOC_RESP: Joined/started '%s', BSSID %s, channel %d\n", 1825 lbs_deb_join("ADHOC_RESP: Joined/started '%s', BSSID %pM, channel %d\n",
1823 escape_essid(bss->ssid, bss->ssid_len), 1826 print_ssid(ssid, bss->ssid, bss->ssid_len),
1824 print_mac(mac, priv->curbssparams.bssid), 1827 priv->curbssparams.bssid,
1825 priv->curbssparams.channel); 1828 priv->curbssparams.channel);
1826 1829
1827done: 1830done:
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 8265c7d25edc..957fd5a10a8d 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include <net/iw_handler.h> 6#include <net/iw_handler.h>
7#include <net/ieee80211.h> 7#include <net/lib80211.h>
8#include <linux/kfifo.h> 8#include <linux/kfifo.h>
9#include "host.h" 9#include "host.h"
10#include "hostcmd.h" 10#include "hostcmd.h"
@@ -87,7 +87,6 @@ int lbs_update_hw_spec(struct lbs_private *priv)
87 struct cmd_ds_get_hw_spec cmd; 87 struct cmd_ds_get_hw_spec cmd;
88 int ret = -1; 88 int ret = -1;
89 u32 i; 89 u32 i;
90 DECLARE_MAC_BUF(mac);
91 90
92 lbs_deb_enter(LBS_DEB_CMD); 91 lbs_deb_enter(LBS_DEB_CMD);
93 92
@@ -110,8 +109,8 @@ int lbs_update_hw_spec(struct lbs_private *priv)
110 * CF card firmware 5.0.16p0: cap 0x00000303 109 * CF card firmware 5.0.16p0: cap 0x00000303
111 * USB dongle firmware 5.110.17p2: cap 0x00000303 110 * USB dongle firmware 5.110.17p2: cap 0x00000303
112 */ 111 */
113 lbs_pr_info("%s, fw %u.%u.%up%u, cap 0x%08x\n", 112 lbs_pr_info("%pM, fw %u.%u.%up%u, cap 0x%08x\n",
114 print_mac(mac, cmd.permanentaddr), 113 cmd.permanentaddr,
115 priv->fwrelease >> 24 & 0xff, 114 priv->fwrelease >> 24 & 0xff,
116 priv->fwrelease >> 16 & 0xff, 115 priv->fwrelease >> 16 & 0xff,
117 priv->fwrelease >> 8 & 0xff, 116 priv->fwrelease >> 8 & 0xff,
@@ -1063,6 +1062,7 @@ int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
1063{ 1062{
1064 struct cmd_ds_mesh_config cmd; 1063 struct cmd_ds_mesh_config cmd;
1065 struct mrvl_meshie *ie; 1064 struct mrvl_meshie *ie;
1065 DECLARE_SSID_BUF(ssid);
1066 1066
1067 memset(&cmd, 0, sizeof(cmd)); 1067 memset(&cmd, 0, sizeof(cmd));
1068 cmd.channel = cpu_to_le16(chan); 1068 cmd.channel = cpu_to_le16(chan);
@@ -1070,7 +1070,7 @@ int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
1070 1070
1071 switch (action) { 1071 switch (action) {
1072 case CMD_ACT_MESH_CONFIG_START: 1072 case CMD_ACT_MESH_CONFIG_START:
1073 ie->hdr.id = MFIE_TYPE_GENERIC; 1073 ie->id = WLAN_EID_GENERIC;
1074 ie->val.oui[0] = 0x00; 1074 ie->val.oui[0] = 0x00;
1075 ie->val.oui[1] = 0x50; 1075 ie->val.oui[1] = 0x50;
1076 ie->val.oui[2] = 0x43; 1076 ie->val.oui[2] = 0x43;
@@ -1082,7 +1082,7 @@ int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
1082 ie->val.mesh_capability = MARVELL_MESH_CAPABILITY; 1082 ie->val.mesh_capability = MARVELL_MESH_CAPABILITY;
1083 ie->val.mesh_id_len = priv->mesh_ssid_len; 1083 ie->val.mesh_id_len = priv->mesh_ssid_len;
1084 memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len); 1084 memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len);
1085 ie->hdr.len = sizeof(struct mrvl_meshie_val) - 1085 ie->len = sizeof(struct mrvl_meshie_val) -
1086 IW_ESSID_MAX_SIZE + priv->mesh_ssid_len; 1086 IW_ESSID_MAX_SIZE + priv->mesh_ssid_len;
1087 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val)); 1087 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val));
1088 break; 1088 break;
@@ -1093,7 +1093,7 @@ int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
1093 } 1093 }
1094 lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n", 1094 lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n",
1095 action, priv->mesh_tlv, chan, 1095 action, priv->mesh_tlv, chan,
1096 escape_essid(priv->mesh_ssid, priv->mesh_ssid_len)); 1096 print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len));
1097 1097
1098 return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv); 1098 return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
1099} 1099}
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 0aa0ce3b2c42..ec4efd7ff3c8 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -5,6 +5,7 @@
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <net/iw_handler.h> 7#include <net/iw_handler.h>
8#include <net/lib80211.h>
8 9
9#include "dev.h" 10#include "dev.h"
10#include "decl.h" 11#include "decl.h"
@@ -65,7 +66,7 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
65 int numscansdone = 0, res; 66 int numscansdone = 0, res;
66 unsigned long addr = get_zeroed_page(GFP_KERNEL); 67 unsigned long addr = get_zeroed_page(GFP_KERNEL);
67 char *buf = (char *)addr; 68 char *buf = (char *)addr;
68 DECLARE_MAC_BUF(mac); 69 DECLARE_SSID_BUF(ssid);
69 struct bss_descriptor * iter_bss; 70 struct bss_descriptor * iter_bss;
70 71
71 pos += snprintf(buf+pos, len-pos, 72 pos += snprintf(buf+pos, len-pos,
@@ -77,17 +78,17 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
77 u16 privacy = (iter_bss->capability & WLAN_CAPABILITY_PRIVACY); 78 u16 privacy = (iter_bss->capability & WLAN_CAPABILITY_PRIVACY);
78 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT); 79 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT);
79 80
80 pos += snprintf(buf+pos, len-pos, 81 pos += snprintf(buf+pos, len-pos, "%02u| %03d | %04d | %pM |",
81 "%02u| %03d | %04d | %s |",
82 numscansdone, iter_bss->channel, iter_bss->rssi, 82 numscansdone, iter_bss->channel, iter_bss->rssi,
83 print_mac(mac, iter_bss->bssid)); 83 iter_bss->bssid);
84 pos += snprintf(buf+pos, len-pos, " %04x-", iter_bss->capability); 84 pos += snprintf(buf+pos, len-pos, " %04x-", iter_bss->capability);
85 pos += snprintf(buf+pos, len-pos, "%c%c%c |", 85 pos += snprintf(buf+pos, len-pos, "%c%c%c |",
86 ibss ? 'A' : 'I', privacy ? 'P' : ' ', 86 ibss ? 'A' : 'I', privacy ? 'P' : ' ',
87 spectrum_mgmt ? 'S' : ' '); 87 spectrum_mgmt ? 'S' : ' ');
88 pos += snprintf(buf+pos, len-pos, " %04d |", SCAN_RSSI(iter_bss->rssi)); 88 pos += snprintf(buf+pos, len-pos, " %04d |", SCAN_RSSI(iter_bss->rssi));
89 pos += snprintf(buf+pos, len-pos, " %s\n", 89 pos += snprintf(buf+pos, len-pos, " %s\n",
90 escape_essid(iter_bss->ssid, iter_bss->ssid_len)); 90 print_ssid(ssid, iter_bss->ssid,
91 iter_bss->ssid_len));
91 92
92 numscansdone++; 93 numscansdone++;
93 } 94 }
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 1a8888cceadc..0b84bdca0726 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -74,8 +74,4 @@ void lbs_host_to_card_done(struct lbs_private *priv);
74 74
75int lbs_update_channel(struct lbs_private *priv); 75int lbs_update_channel(struct lbs_private *priv);
76 76
77#ifndef CONFIG_IEEE80211
78const char *escape_essid(const char *essid, u8 essid_len);
79#endif
80
81#endif 77#endif
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index 076a636e8f62..2d4666f26808 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -79,7 +79,7 @@ do { if ((lbs_debug & (grp)) == (grp)) \
79#define lbs_deb_tx(fmt, args...) LBS_DEB_LL(LBS_DEB_TX, " tx", fmt, ##args) 79#define lbs_deb_tx(fmt, args...) LBS_DEB_LL(LBS_DEB_TX, " tx", fmt, ##args)
80#define lbs_deb_fw(fmt, args...) LBS_DEB_LL(LBS_DEB_FW, " fw", fmt, ##args) 80#define lbs_deb_fw(fmt, args...) LBS_DEB_LL(LBS_DEB_FW, " fw", fmt, ##args)
81#define lbs_deb_usb(fmt, args...) LBS_DEB_LL(LBS_DEB_USB, " usb", fmt, ##args) 81#define lbs_deb_usb(fmt, args...) LBS_DEB_LL(LBS_DEB_USB, " usb", fmt, ##args)
82#define lbs_deb_usbd(dev, fmt, args...) LBS_DEB_LL(LBS_DEB_USB, " usbd", "%s:" fmt, (dev)->bus_id, ##args) 82#define lbs_deb_usbd(dev, fmt, args...) LBS_DEB_LL(LBS_DEB_USB, " usbd", "%s:" fmt, dev_name(dev), ##args)
83#define lbs_deb_cs(fmt, args...) LBS_DEB_LL(LBS_DEB_CS, " cs", fmt, ##args) 83#define lbs_deb_cs(fmt, args...) LBS_DEB_LL(LBS_DEB_CS, " cs", fmt, ##args)
84#define lbs_deb_thread(fmt, args...) LBS_DEB_LL(LBS_DEB_THREAD, " thread", fmt, ##args) 84#define lbs_deb_thread(fmt, args...) LBS_DEB_LL(LBS_DEB_THREAD, " thread", fmt, ##args)
85#define lbs_deb_sdio(fmt, args...) LBS_DEB_LL(LBS_DEB_SDIO, " sdio", fmt, ##args) 85#define lbs_deb_sdio(fmt, args...) LBS_DEB_LL(LBS_DEB_SDIO, " sdio", fmt, ##args)
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index f6f3753da303..dd682c4cfde8 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -10,7 +10,6 @@
10#include <linux/wireless.h> 10#include <linux/wireless.h>
11#include <linux/ethtool.h> 11#include <linux/ethtool.h>
12#include <linux/debugfs.h> 12#include <linux/debugfs.h>
13#include <net/ieee80211.h>
14 13
15#include "defs.h" 14#include "defs.h"
16#include "hostcmd.h" 15#include "hostcmd.h"
@@ -278,6 +277,12 @@ struct lbs_private {
278 struct enc_key wpa_mcast_key; 277 struct enc_key wpa_mcast_key;
279 struct enc_key wpa_unicast_key; 278 struct enc_key wpa_unicast_key;
280 279
280/*
281 * In theory, the IE is limited to the IE length, 255,
282 * but in practice 64 bytes are enough.
283 */
284#define MAX_WPA_IE_LEN 64
285
281 /** WPA Information Elements*/ 286 /** WPA Information Elements*/
282 u8 wpa_ie[MAX_WPA_IE_LEN]; 287 u8 wpa_ie[MAX_WPA_IE_LEN];
283 u8 wpa_ie_len; 288 u8 wpa_ie_len;
diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c
index 688d60de55cb..156f471217bb 100644
--- a/drivers/net/wireless/libertas/ethtool.c
+++ b/drivers/net/wireless/libertas/ethtool.c
@@ -23,7 +23,7 @@ static const char * mesh_stat_strings[]= {
23static void lbs_ethtool_get_drvinfo(struct net_device *dev, 23static void lbs_ethtool_get_drvinfo(struct net_device *dev,
24 struct ethtool_drvinfo *info) 24 struct ethtool_drvinfo *info)
25{ 25{
26 struct lbs_private *priv = (struct lbs_private *) dev->priv; 26 struct lbs_private *priv = netdev_priv(dev);
27 27
28 snprintf(info->fw_version, 32, "%u.%u.%u.p%u", 28 snprintf(info->fw_version, 32, "%u.%u.%u.p%u",
29 priv->fwrelease >> 24 & 0xff, 29 priv->fwrelease >> 24 & 0xff,
@@ -47,7 +47,7 @@ static int lbs_ethtool_get_eeprom_len(struct net_device *dev)
47static int lbs_ethtool_get_eeprom(struct net_device *dev, 47static int lbs_ethtool_get_eeprom(struct net_device *dev,
48 struct ethtool_eeprom *eeprom, u8 * bytes) 48 struct ethtool_eeprom *eeprom, u8 * bytes)
49{ 49{
50 struct lbs_private *priv = (struct lbs_private *) dev->priv; 50 struct lbs_private *priv = netdev_priv(dev);
51 struct cmd_ds_802_11_eeprom_access cmd; 51 struct cmd_ds_802_11_eeprom_access cmd;
52 int ret; 52 int ret;
53 53
@@ -76,7 +76,7 @@ out:
76static void lbs_ethtool_get_stats(struct net_device *dev, 76static void lbs_ethtool_get_stats(struct net_device *dev,
77 struct ethtool_stats *stats, uint64_t *data) 77 struct ethtool_stats *stats, uint64_t *data)
78{ 78{
79 struct lbs_private *priv = dev->priv; 79 struct lbs_private *priv = netdev_priv(dev);
80 struct cmd_ds_mesh_access mesh_access; 80 struct cmd_ds_mesh_access mesh_access;
81 int ret; 81 int ret;
82 82
@@ -113,7 +113,7 @@ static void lbs_ethtool_get_stats(struct net_device *dev,
113 113
114static int lbs_ethtool_get_sset_count(struct net_device *dev, int sset) 114static int lbs_ethtool_get_sset_count(struct net_device *dev, int sset)
115{ 115{
116 struct lbs_private *priv = dev->priv; 116 struct lbs_private *priv = netdev_priv(dev);
117 117
118 if (sset == ETH_SS_STATS && dev == priv->mesh_dev) 118 if (sset == ETH_SS_STATS && dev == priv->mesh_dev)
119 return MESH_STATS_NUM; 119 return MESH_STATS_NUM;
@@ -143,7 +143,7 @@ static void lbs_ethtool_get_strings(struct net_device *dev,
143static void lbs_ethtool_get_wol(struct net_device *dev, 143static void lbs_ethtool_get_wol(struct net_device *dev,
144 struct ethtool_wolinfo *wol) 144 struct ethtool_wolinfo *wol)
145{ 145{
146 struct lbs_private *priv = dev->priv; 146 struct lbs_private *priv = netdev_priv(dev);
147 147
148 if (priv->wol_criteria == 0xffffffff) { 148 if (priv->wol_criteria == 0xffffffff) {
149 /* Interface driver didn't configure wake */ 149 /* Interface driver didn't configure wake */
@@ -166,7 +166,7 @@ static void lbs_ethtool_get_wol(struct net_device *dev,
166static int lbs_ethtool_set_wol(struct net_device *dev, 166static int lbs_ethtool_set_wol(struct net_device *dev,
167 struct ethtool_wolinfo *wol) 167 struct ethtool_wolinfo *wol)
168{ 168{
169 struct lbs_private *priv = dev->priv; 169 struct lbs_private *priv = netdev_priv(dev);
170 uint32_t criteria = 0; 170 uint32_t criteria = 0;
171 171
172 if (priv->wol_criteria == 0xffffffff && wol->wolopts) 172 if (priv->wol_criteria == 0xffffffff && wol->wolopts)
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 73dc8c72402a..241af7fe44bb 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -12,9 +12,8 @@
12#include <linux/kthread.h> 12#include <linux/kthread.h>
13#include <linux/kfifo.h> 13#include <linux/kfifo.h>
14#include <linux/stddef.h> 14#include <linux/stddef.h>
15 15#include <linux/ieee80211.h>
16#include <net/iw_handler.h> 16#include <net/iw_handler.h>
17#include <net/ieee80211.h>
18 17
19#include "host.h" 18#include "host.h"
20#include "decl.h" 19#include "decl.h"
@@ -223,7 +222,7 @@ u8 lbs_data_rate_to_fw_index(u32 rate)
223static ssize_t lbs_anycast_get(struct device *dev, 222static ssize_t lbs_anycast_get(struct device *dev,
224 struct device_attribute *attr, char * buf) 223 struct device_attribute *attr, char * buf)
225{ 224{
226 struct lbs_private *priv = to_net_dev(dev)->priv; 225 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
227 struct cmd_ds_mesh_access mesh_access; 226 struct cmd_ds_mesh_access mesh_access;
228 int ret; 227 int ret;
229 228
@@ -242,7 +241,7 @@ static ssize_t lbs_anycast_get(struct device *dev,
242static ssize_t lbs_anycast_set(struct device *dev, 241static ssize_t lbs_anycast_set(struct device *dev,
243 struct device_attribute *attr, const char * buf, size_t count) 242 struct device_attribute *attr, const char * buf, size_t count)
244{ 243{
245 struct lbs_private *priv = to_net_dev(dev)->priv; 244 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
246 struct cmd_ds_mesh_access mesh_access; 245 struct cmd_ds_mesh_access mesh_access;
247 uint32_t datum; 246 uint32_t datum;
248 int ret; 247 int ret;
@@ -270,7 +269,7 @@ static void lbs_remove_mesh(struct lbs_private *priv);
270static ssize_t lbs_rtap_get(struct device *dev, 269static ssize_t lbs_rtap_get(struct device *dev,
271 struct device_attribute *attr, char * buf) 270 struct device_attribute *attr, char * buf)
272{ 271{
273 struct lbs_private *priv = to_net_dev(dev)->priv; 272 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
274 return snprintf(buf, 5, "0x%X\n", priv->monitormode); 273 return snprintf(buf, 5, "0x%X\n", priv->monitormode);
275} 274}
276 275
@@ -281,7 +280,7 @@ static ssize_t lbs_rtap_set(struct device *dev,
281 struct device_attribute *attr, const char * buf, size_t count) 280 struct device_attribute *attr, const char * buf, size_t count)
282{ 281{
283 int monitor_mode; 282 int monitor_mode;
284 struct lbs_private *priv = to_net_dev(dev)->priv; 283 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
285 284
286 sscanf(buf, "%x", &monitor_mode); 285 sscanf(buf, "%x", &monitor_mode);
287 if (monitor_mode) { 286 if (monitor_mode) {
@@ -332,7 +331,7 @@ static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, lbs_rtap_set );
332static ssize_t lbs_mesh_get(struct device *dev, 331static ssize_t lbs_mesh_get(struct device *dev,
333 struct device_attribute *attr, char * buf) 332 struct device_attribute *attr, char * buf)
334{ 333{
335 struct lbs_private *priv = to_net_dev(dev)->priv; 334 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
336 return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev); 335 return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
337} 336}
338 337
@@ -342,7 +341,7 @@ static ssize_t lbs_mesh_get(struct device *dev,
342static ssize_t lbs_mesh_set(struct device *dev, 341static ssize_t lbs_mesh_set(struct device *dev,
343 struct device_attribute *attr, const char * buf, size_t count) 342 struct device_attribute *attr, const char * buf, size_t count)
344{ 343{
345 struct lbs_private *priv = to_net_dev(dev)->priv; 344 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
346 int enable; 345 int enable;
347 int ret, action = CMD_ACT_MESH_CONFIG_STOP; 346 int ret, action = CMD_ACT_MESH_CONFIG_STOP;
348 347
@@ -393,7 +392,7 @@ static struct attribute_group lbs_mesh_attr_group = {
393 */ 392 */
394static int lbs_dev_open(struct net_device *dev) 393static int lbs_dev_open(struct net_device *dev)
395{ 394{
396 struct lbs_private *priv = (struct lbs_private *) dev->priv ; 395 struct lbs_private *priv = netdev_priv(dev) ;
397 int ret = 0; 396 int ret = 0;
398 397
399 lbs_deb_enter(LBS_DEB_NET); 398 lbs_deb_enter(LBS_DEB_NET);
@@ -435,7 +434,7 @@ static int lbs_dev_open(struct net_device *dev)
435 */ 434 */
436static int lbs_mesh_stop(struct net_device *dev) 435static int lbs_mesh_stop(struct net_device *dev)
437{ 436{
438 struct lbs_private *priv = (struct lbs_private *) (dev->priv); 437 struct lbs_private *priv = dev->ml_priv;
439 438
440 lbs_deb_enter(LBS_DEB_MESH); 439 lbs_deb_enter(LBS_DEB_MESH);
441 spin_lock_irq(&priv->driver_lock); 440 spin_lock_irq(&priv->driver_lock);
@@ -462,7 +461,7 @@ static int lbs_mesh_stop(struct net_device *dev)
462 */ 461 */
463static int lbs_eth_stop(struct net_device *dev) 462static int lbs_eth_stop(struct net_device *dev)
464{ 463{
465 struct lbs_private *priv = (struct lbs_private *) dev->priv; 464 struct lbs_private *priv = netdev_priv(dev);
466 465
467 lbs_deb_enter(LBS_DEB_NET); 466 lbs_deb_enter(LBS_DEB_NET);
468 467
@@ -479,7 +478,7 @@ static int lbs_eth_stop(struct net_device *dev)
479 478
480static void lbs_tx_timeout(struct net_device *dev) 479static void lbs_tx_timeout(struct net_device *dev)
481{ 480{
482 struct lbs_private *priv = (struct lbs_private *) dev->priv; 481 struct lbs_private *priv = netdev_priv(dev);
483 482
484 lbs_deb_enter(LBS_DEB_TX); 483 lbs_deb_enter(LBS_DEB_TX);
485 484
@@ -531,7 +530,7 @@ EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
531 */ 530 */
532static struct net_device_stats *lbs_get_stats(struct net_device *dev) 531static struct net_device_stats *lbs_get_stats(struct net_device *dev)
533{ 532{
534 struct lbs_private *priv = (struct lbs_private *) dev->priv; 533 struct lbs_private *priv = netdev_priv(dev);
535 534
536 lbs_deb_enter(LBS_DEB_NET); 535 lbs_deb_enter(LBS_DEB_NET);
537 return &priv->stats; 536 return &priv->stats;
@@ -540,7 +539,7 @@ static struct net_device_stats *lbs_get_stats(struct net_device *dev)
540static int lbs_set_mac_address(struct net_device *dev, void *addr) 539static int lbs_set_mac_address(struct net_device *dev, void *addr)
541{ 540{
542 int ret = 0; 541 int ret = 0;
543 struct lbs_private *priv = (struct lbs_private *) dev->priv; 542 struct lbs_private *priv = netdev_priv(dev);
544 struct sockaddr *phwaddr = addr; 543 struct sockaddr *phwaddr = addr;
545 struct cmd_ds_802_11_mac_address cmd; 544 struct cmd_ds_802_11_mac_address cmd;
546 545
@@ -588,7 +587,6 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
588{ 587{
589 int i = nr_addrs; 588 int i = nr_addrs;
590 struct dev_mc_list *mc_list; 589 struct dev_mc_list *mc_list;
591 DECLARE_MAC_BUF(mac);
592 590
593 if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST)) 591 if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST))
594 return nr_addrs; 592 return nr_addrs;
@@ -596,16 +594,16 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
596 netif_addr_lock_bh(dev); 594 netif_addr_lock_bh(dev);
597 for (mc_list = dev->mc_list; mc_list; mc_list = mc_list->next) { 595 for (mc_list = dev->mc_list; mc_list; mc_list = mc_list->next) {
598 if (mac_in_list(cmd->maclist, nr_addrs, mc_list->dmi_addr)) { 596 if (mac_in_list(cmd->maclist, nr_addrs, mc_list->dmi_addr)) {
599 lbs_deb_net("mcast address %s:%s skipped\n", dev->name, 597 lbs_deb_net("mcast address %s:%pM skipped\n", dev->name,
600 print_mac(mac, mc_list->dmi_addr)); 598 mc_list->dmi_addr);
601 continue; 599 continue;
602 } 600 }
603 601
604 if (i == MRVDRV_MAX_MULTICAST_LIST_SIZE) 602 if (i == MRVDRV_MAX_MULTICAST_LIST_SIZE)
605 break; 603 break;
606 memcpy(&cmd->maclist[6*i], mc_list->dmi_addr, ETH_ALEN); 604 memcpy(&cmd->maclist[6*i], mc_list->dmi_addr, ETH_ALEN);
607 lbs_deb_net("mcast address %s:%s added to filter\n", dev->name, 605 lbs_deb_net("mcast address %s:%pM added to filter\n", dev->name,
608 print_mac(mac, mc_list->dmi_addr)); 606 mc_list->dmi_addr);
609 i++; 607 i++;
610 } 608 }
611 netif_addr_unlock_bh(dev); 609 netif_addr_unlock_bh(dev);
@@ -674,7 +672,7 @@ static void lbs_set_mcast_worker(struct work_struct *work)
674 672
675static void lbs_set_multicast_list(struct net_device *dev) 673static void lbs_set_multicast_list(struct net_device *dev)
676{ 674{
677 struct lbs_private *priv = dev->priv; 675 struct lbs_private *priv = netdev_priv(dev);
678 676
679 schedule_work(&priv->mcast_work); 677 schedule_work(&priv->mcast_work);
680} 678}
@@ -690,7 +688,7 @@ static void lbs_set_multicast_list(struct net_device *dev)
690static int lbs_thread(void *data) 688static int lbs_thread(void *data)
691{ 689{
692 struct net_device *dev = data; 690 struct net_device *dev = data;
693 struct lbs_private *priv = dev->priv; 691 struct lbs_private *priv = netdev_priv(dev);
694 wait_queue_t wait; 692 wait_queue_t wait;
695 693
696 lbs_deb_enter(LBS_DEB_THREAD); 694 lbs_deb_enter(LBS_DEB_THREAD);
@@ -1125,7 +1123,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
1125 lbs_pr_err("init ethX device failed\n"); 1123 lbs_pr_err("init ethX device failed\n");
1126 goto done; 1124 goto done;
1127 } 1125 }
1128 priv = dev->priv; 1126 priv = netdev_priv(dev);
1129 1127
1130 if (lbs_init_adapter(priv)) { 1128 if (lbs_init_adapter(priv)) {
1131 lbs_pr_err("failed to initialize adapter structure.\n"); 1129 lbs_pr_err("failed to initialize adapter structure.\n");
@@ -1378,7 +1376,7 @@ static int lbs_add_mesh(struct lbs_private *priv)
1378 ret = -ENOMEM; 1376 ret = -ENOMEM;
1379 goto done; 1377 goto done;
1380 } 1378 }
1381 mesh_dev->priv = priv; 1379 mesh_dev->ml_priv = priv;
1382 priv->mesh_dev = mesh_dev; 1380 priv->mesh_dev = mesh_dev;
1383 1381
1384 mesh_dev->open = lbs_dev_open; 1382 mesh_dev->open = lbs_dev_open;
@@ -1591,7 +1589,7 @@ static int lbs_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1591 1589
1592static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev) 1590static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev)
1593{ 1591{
1594 struct lbs_private *priv = dev->priv; 1592 struct lbs_private *priv = dev->ml_priv;
1595 lbs_deb_enter(LBS_DEB_NET); 1593 lbs_deb_enter(LBS_DEB_NET);
1596 return &priv->stats; 1594 return &priv->stats;
1597} 1595}
@@ -1632,7 +1630,7 @@ static int lbs_add_rtap(struct lbs_private *priv)
1632 rtap_dev->stop = lbs_rtap_stop; 1630 rtap_dev->stop = lbs_rtap_stop;
1633 rtap_dev->get_stats = lbs_rtap_get_stats; 1631 rtap_dev->get_stats = lbs_rtap_get_stats;
1634 rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit; 1632 rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit;
1635 rtap_dev->priv = priv; 1633 rtap_dev->ml_priv = priv;
1636 SET_NETDEV_DEV(rtap_dev, priv->dev->dev.parent); 1634 SET_NETDEV_DEV(rtap_dev, priv->dev->dev.parent);
1637 1635
1638 ret = register_netdev(rtap_dev); 1636 ret = register_netdev(rtap_dev);
@@ -1647,33 +1645,6 @@ out:
1647 return ret; 1645 return ret;
1648} 1646}
1649 1647
1650#ifndef CONFIG_IEEE80211
1651const char *escape_essid(const char *essid, u8 essid_len)
1652{
1653 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
1654 const char *s = essid;
1655 char *d = escaped;
1656
1657 if (ieee80211_is_empty_essid(essid, essid_len)) {
1658 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
1659 return escaped;
1660 }
1661
1662 essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
1663 while (essid_len--) {
1664 if (*s == '\0') {
1665 *d++ = '\\';
1666 *d++ = '0';
1667 s++;
1668 } else {
1669 *d++ = *s++;
1670 }
1671 }
1672 *d = '\0';
1673 return escaped;
1674}
1675#endif
1676
1677module_init(lbs_init_module); 1648module_init(lbs_init_module);
1678module_exit(lbs_exit_module); 1649module_exit(lbs_exit_module);
1679 1650
diff --git a/drivers/net/wireless/libertas/persistcfg.c b/drivers/net/wireless/libertas/persistcfg.c
index 3309a9c3cfef..d42b7a5a1b3f 100644
--- a/drivers/net/wireless/libertas/persistcfg.c
+++ b/drivers/net/wireless/libertas/persistcfg.c
@@ -18,7 +18,7 @@
18static int mesh_get_default_parameters(struct device *dev, 18static int mesh_get_default_parameters(struct device *dev,
19 struct mrvl_mesh_defaults *defs) 19 struct mrvl_mesh_defaults *defs)
20{ 20{
21 struct lbs_private *priv = to_net_dev(dev)->priv; 21 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
22 struct cmd_ds_mesh_config cmd; 22 struct cmd_ds_mesh_config cmd;
23 int ret; 23 int ret;
24 24
@@ -57,7 +57,7 @@ static ssize_t bootflag_get(struct device *dev,
57static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr, 57static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
58 const char *buf, size_t count) 58 const char *buf, size_t count)
59{ 59{
60 struct lbs_private *priv = to_net_dev(dev)->priv; 60 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
61 struct cmd_ds_mesh_config cmd; 61 struct cmd_ds_mesh_config cmd;
62 uint32_t datum; 62 uint32_t datum;
63 int ret; 63 int ret;
@@ -100,7 +100,7 @@ static ssize_t boottime_get(struct device *dev,
100static ssize_t boottime_set(struct device *dev, 100static ssize_t boottime_set(struct device *dev,
101 struct device_attribute *attr, const char *buf, size_t count) 101 struct device_attribute *attr, const char *buf, size_t count)
102{ 102{
103 struct lbs_private *priv = to_net_dev(dev)->priv; 103 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
104 struct cmd_ds_mesh_config cmd; 104 struct cmd_ds_mesh_config cmd;
105 uint32_t datum; 105 uint32_t datum;
106 int ret; 106 int ret;
@@ -152,7 +152,7 @@ static ssize_t channel_get(struct device *dev,
152static ssize_t channel_set(struct device *dev, struct device_attribute *attr, 152static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
153 const char *buf, size_t count) 153 const char *buf, size_t count)
154{ 154{
155 struct lbs_private *priv = to_net_dev(dev)->priv; 155 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
156 struct cmd_ds_mesh_config cmd; 156 struct cmd_ds_mesh_config cmd;
157 uint32_t datum; 157 uint32_t datum;
158 int ret; 158 int ret;
@@ -210,7 +210,7 @@ static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr,
210 struct cmd_ds_mesh_config cmd; 210 struct cmd_ds_mesh_config cmd;
211 struct mrvl_mesh_defaults defs; 211 struct mrvl_mesh_defaults defs;
212 struct mrvl_meshie *ie; 212 struct mrvl_meshie *ie;
213 struct lbs_private *priv = to_net_dev(dev)->priv; 213 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
214 int len; 214 int len;
215 int ret; 215 int ret;
216 216
@@ -233,7 +233,7 @@ static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr,
233 /* SSID len */ 233 /* SSID len */
234 ie->val.mesh_id_len = len; 234 ie->val.mesh_id_len = len;
235 /* IE len */ 235 /* IE len */
236 ie->hdr.len = sizeof(struct mrvl_meshie_val) - IW_ESSID_MAX_SIZE + len; 236 ie->len = sizeof(struct mrvl_meshie_val) - IW_ESSID_MAX_SIZE + len;
237 237
238 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, 238 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
239 CMD_TYPE_MESH_SET_MESH_IE); 239 CMD_TYPE_MESH_SET_MESH_IE);
@@ -269,7 +269,7 @@ static ssize_t protocol_id_set(struct device *dev,
269 struct cmd_ds_mesh_config cmd; 269 struct cmd_ds_mesh_config cmd;
270 struct mrvl_mesh_defaults defs; 270 struct mrvl_mesh_defaults defs;
271 struct mrvl_meshie *ie; 271 struct mrvl_meshie *ie;
272 struct lbs_private *priv = to_net_dev(dev)->priv; 272 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
273 uint32_t datum; 273 uint32_t datum;
274 int ret; 274 int ret;
275 275
@@ -323,7 +323,7 @@ static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
323 struct cmd_ds_mesh_config cmd; 323 struct cmd_ds_mesh_config cmd;
324 struct mrvl_mesh_defaults defs; 324 struct mrvl_mesh_defaults defs;
325 struct mrvl_meshie *ie; 325 struct mrvl_meshie *ie;
326 struct lbs_private *priv = to_net_dev(dev)->priv; 326 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
327 uint32_t datum; 327 uint32_t datum;
328 int ret; 328 int ret;
329 329
@@ -377,7 +377,7 @@ static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
377 struct cmd_ds_mesh_config cmd; 377 struct cmd_ds_mesh_config cmd;
378 struct mrvl_mesh_defaults defs; 378 struct mrvl_mesh_defaults defs;
379 struct mrvl_meshie *ie; 379 struct mrvl_meshie *ie;
380 struct lbs_private *priv = to_net_dev(dev)->priv; 380 struct lbs_private *priv = netdev_priv(to_net_dev(dev));
381 uint32_t datum; 381 uint32_t datum;
382 int ret; 382 int ret;
383 383
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 22c4c6110521..57f6c12cda20 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -4,8 +4,11 @@
4 * IOCTL handlers as well as command preperation and response routines 4 * IOCTL handlers as well as command preperation and response routines
5 * for sending scan commands to the firmware. 5 * for sending scan commands to the firmware.
6 */ 6 */
7#include <linux/types.h>
7#include <linux/etherdevice.h> 8#include <linux/etherdevice.h>
9#include <linux/if_arp.h>
8#include <asm/unaligned.h> 10#include <asm/unaligned.h>
11#include <net/lib80211.h>
9 12
10#include "host.h" 13#include "host.h"
11#include "decl.h" 14#include "decl.h"
@@ -52,6 +55,8 @@
52//! Scan time specified in the channel TLV for each channel for active scans 55//! Scan time specified in the channel TLV for each channel for active scans
53#define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100 56#define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100
54 57
58#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
59
55static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy, 60static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
56 struct cmd_header *resp); 61 struct cmd_header *resp);
57 62
@@ -359,7 +364,7 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
359#ifdef CONFIG_LIBERTAS_DEBUG 364#ifdef CONFIG_LIBERTAS_DEBUG
360 struct bss_descriptor *iter; 365 struct bss_descriptor *iter;
361 int i = 0; 366 int i = 0;
362 DECLARE_MAC_BUF(mac); 367 DECLARE_SSID_BUF(ssid);
363#endif 368#endif
364 369
365 lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan); 370 lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan);
@@ -451,9 +456,9 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
451 mutex_lock(&priv->lock); 456 mutex_lock(&priv->lock);
452 lbs_deb_scan("scan table:\n"); 457 lbs_deb_scan("scan table:\n");
453 list_for_each_entry(iter, &priv->network_list, list) 458 list_for_each_entry(iter, &priv->network_list, list)
454 lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n", 459 lbs_deb_scan("%02d: BSSID %pM, RSSI %d, SSID '%s'\n",
455 i++, print_mac(mac, iter->bssid), iter->rssi, 460 i++, iter->bssid, iter->rssi,
456 escape_essid(iter->ssid, iter->ssid_len)); 461 print_ssid(ssid, iter->ssid, iter->ssid_len));
457 mutex_unlock(&priv->lock); 462 mutex_unlock(&priv->lock);
458#endif 463#endif
459 464
@@ -512,7 +517,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
512 struct ieeetypes_dsparamset *pDS; 517 struct ieeetypes_dsparamset *pDS;
513 struct ieeetypes_cfparamset *pCF; 518 struct ieeetypes_cfparamset *pCF;
514 struct ieeetypes_ibssparamset *pibss; 519 struct ieeetypes_ibssparamset *pibss;
515 DECLARE_MAC_BUF(mac); 520 DECLARE_SSID_BUF(ssid);
516 struct ieeetypes_countryinfoset *pcountryinfo; 521 struct ieeetypes_countryinfoset *pcountryinfo;
517 uint8_t *pos, *end, *p; 522 uint8_t *pos, *end, *p;
518 uint8_t n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0; 523 uint8_t n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0;
@@ -544,7 +549,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
544 *bytesleft -= beaconsize; 549 *bytesleft -= beaconsize;
545 550
546 memcpy(bss->bssid, pos, ETH_ALEN); 551 memcpy(bss->bssid, pos, ETH_ALEN);
547 lbs_deb_scan("process_bss: BSSID %s\n", print_mac(mac, bss->bssid)); 552 lbs_deb_scan("process_bss: BSSID %pM\n", bss->bssid);
548 pos += ETH_ALEN; 553 pos += ETH_ALEN;
549 554
550 if ((end - pos) < 12) { 555 if ((end - pos) < 12) {
@@ -588,38 +593,36 @@ static int lbs_process_bss(struct bss_descriptor *bss,
588 593
589 /* process variable IE */ 594 /* process variable IE */
590 while (pos <= end - 2) { 595 while (pos <= end - 2) {
591 struct ieee80211_info_element * elem = (void *)pos; 596 if (pos + pos[1] > end) {
592
593 if (pos + elem->len > end) {
594 lbs_deb_scan("process_bss: error in processing IE, " 597 lbs_deb_scan("process_bss: error in processing IE, "
595 "bytes left < IE length\n"); 598 "bytes left < IE length\n");
596 break; 599 break;
597 } 600 }
598 601
599 switch (elem->id) { 602 switch (pos[0]) {
600 case MFIE_TYPE_SSID: 603 case WLAN_EID_SSID:
601 bss->ssid_len = min_t(int, 32, elem->len); 604 bss->ssid_len = min_t(int, IEEE80211_MAX_SSID_LEN, pos[1]);
602 memcpy(bss->ssid, elem->data, bss->ssid_len); 605 memcpy(bss->ssid, pos + 2, bss->ssid_len);
603 lbs_deb_scan("got SSID IE: '%s', len %u\n", 606 lbs_deb_scan("got SSID IE: '%s', len %u\n",
604 escape_essid(bss->ssid, bss->ssid_len), 607 print_ssid(ssid, bss->ssid, bss->ssid_len),
605 bss->ssid_len); 608 bss->ssid_len);
606 break; 609 break;
607 610
608 case MFIE_TYPE_RATES: 611 case WLAN_EID_SUPP_RATES:
609 n_basic_rates = min_t(uint8_t, MAX_RATES, elem->len); 612 n_basic_rates = min_t(uint8_t, MAX_RATES, pos[1]);
610 memcpy(bss->rates, elem->data, n_basic_rates); 613 memcpy(bss->rates, pos + 2, n_basic_rates);
611 got_basic_rates = 1; 614 got_basic_rates = 1;
612 lbs_deb_scan("got RATES IE\n"); 615 lbs_deb_scan("got RATES IE\n");
613 break; 616 break;
614 617
615 case MFIE_TYPE_FH_SET: 618 case WLAN_EID_FH_PARAMS:
616 pFH = (struct ieeetypes_fhparamset *) pos; 619 pFH = (struct ieeetypes_fhparamset *) pos;
617 memmove(&bss->phyparamset.fhparamset, pFH, 620 memmove(&bss->phyparamset.fhparamset, pFH,
618 sizeof(struct ieeetypes_fhparamset)); 621 sizeof(struct ieeetypes_fhparamset));
619 lbs_deb_scan("got FH IE\n"); 622 lbs_deb_scan("got FH IE\n");
620 break; 623 break;
621 624
622 case MFIE_TYPE_DS_SET: 625 case WLAN_EID_DS_PARAMS:
623 pDS = (struct ieeetypes_dsparamset *) pos; 626 pDS = (struct ieeetypes_dsparamset *) pos;
624 bss->channel = pDS->currentchan; 627 bss->channel = pDS->currentchan;
625 memcpy(&bss->phyparamset.dsparamset, pDS, 628 memcpy(&bss->phyparamset.dsparamset, pDS,
@@ -627,14 +630,14 @@ static int lbs_process_bss(struct bss_descriptor *bss,
627 lbs_deb_scan("got DS IE, channel %d\n", bss->channel); 630 lbs_deb_scan("got DS IE, channel %d\n", bss->channel);
628 break; 631 break;
629 632
630 case MFIE_TYPE_CF_SET: 633 case WLAN_EID_CF_PARAMS:
631 pCF = (struct ieeetypes_cfparamset *) pos; 634 pCF = (struct ieeetypes_cfparamset *) pos;
632 memcpy(&bss->ssparamset.cfparamset, pCF, 635 memcpy(&bss->ssparamset.cfparamset, pCF,
633 sizeof(struct ieeetypes_cfparamset)); 636 sizeof(struct ieeetypes_cfparamset));
634 lbs_deb_scan("got CF IE\n"); 637 lbs_deb_scan("got CF IE\n");
635 break; 638 break;
636 639
637 case MFIE_TYPE_IBSS_SET: 640 case WLAN_EID_IBSS_PARAMS:
638 pibss = (struct ieeetypes_ibssparamset *) pos; 641 pibss = (struct ieeetypes_ibssparamset *) pos;
639 bss->atimwindow = le16_to_cpu(pibss->atimwindow); 642 bss->atimwindow = le16_to_cpu(pibss->atimwindow);
640 memmove(&bss->ssparamset.ibssparamset, pibss, 643 memmove(&bss->ssparamset.ibssparamset, pibss,
@@ -642,7 +645,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
642 lbs_deb_scan("got IBSS IE\n"); 645 lbs_deb_scan("got IBSS IE\n");
643 break; 646 break;
644 647
645 case MFIE_TYPE_COUNTRY: 648 case WLAN_EID_COUNTRY:
646 pcountryinfo = (struct ieeetypes_countryinfoset *) pos; 649 pcountryinfo = (struct ieeetypes_countryinfoset *) pos;
647 lbs_deb_scan("got COUNTRY IE\n"); 650 lbs_deb_scan("got COUNTRY IE\n");
648 if (pcountryinfo->len < sizeof(pcountryinfo->countrycode) 651 if (pcountryinfo->len < sizeof(pcountryinfo->countrycode)
@@ -659,7 +662,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
659 (int) (pcountryinfo->len + 2)); 662 (int) (pcountryinfo->len + 2));
660 break; 663 break;
661 664
662 case MFIE_TYPE_RATES_EX: 665 case WLAN_EID_EXT_SUPP_RATES:
663 /* only process extended supported rate if data rate is 666 /* only process extended supported rate if data rate is
664 * already found. Data rate IE should come before 667 * already found. Data rate IE should come before
665 * extended supported rate IE 668 * extended supported rate IE
@@ -670,50 +673,51 @@ static int lbs_process_bss(struct bss_descriptor *bss,
670 break; 673 break;
671 } 674 }
672 675
673 n_ex_rates = elem->len; 676 n_ex_rates = pos[1];
674 if (n_basic_rates + n_ex_rates > MAX_RATES) 677 if (n_basic_rates + n_ex_rates > MAX_RATES)
675 n_ex_rates = MAX_RATES - n_basic_rates; 678 n_ex_rates = MAX_RATES - n_basic_rates;
676 679
677 p = bss->rates + n_basic_rates; 680 p = bss->rates + n_basic_rates;
678 memcpy(p, elem->data, n_ex_rates); 681 memcpy(p, pos + 2, n_ex_rates);
679 break; 682 break;
680 683
681 case MFIE_TYPE_GENERIC: 684 case WLAN_EID_GENERIC:
682 if (elem->len >= 4 && 685 if (pos[1] >= 4 &&
683 elem->data[0] == 0x00 && elem->data[1] == 0x50 && 686 pos[2] == 0x00 && pos[3] == 0x50 &&
684 elem->data[2] == 0xf2 && elem->data[3] == 0x01) { 687 pos[4] == 0xf2 && pos[5] == 0x01) {
685 bss->wpa_ie_len = min(elem->len + 2, MAX_WPA_IE_LEN); 688 bss->wpa_ie_len = min(pos[1] + 2, MAX_WPA_IE_LEN);
686 memcpy(bss->wpa_ie, elem, bss->wpa_ie_len); 689 memcpy(bss->wpa_ie, pos, bss->wpa_ie_len);
687 lbs_deb_scan("got WPA IE\n"); 690 lbs_deb_scan("got WPA IE\n");
688 lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie, elem->len); 691 lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie,
689 } else if (elem->len >= MARVELL_MESH_IE_LENGTH && 692 bss->wpa_ie_len);
690 elem->data[0] == 0x00 && elem->data[1] == 0x50 && 693 } else if (pos[1] >= MARVELL_MESH_IE_LENGTH &&
691 elem->data[2] == 0x43 && elem->data[3] == 0x04) { 694 pos[2] == 0x00 && pos[3] == 0x50 &&
695 pos[4] == 0x43 && pos[4] == 0x04) {
692 lbs_deb_scan("got mesh IE\n"); 696 lbs_deb_scan("got mesh IE\n");
693 bss->mesh = 1; 697 bss->mesh = 1;
694 } else { 698 } else {
695 lbs_deb_scan("got generic IE: %02x:%02x:%02x:%02x, len %d\n", 699 lbs_deb_scan("got generic IE: %02x:%02x:%02x:%02x, len %d\n",
696 elem->data[0], elem->data[1], 700 pos[2], pos[3],
697 elem->data[2], elem->data[3], 701 pos[4], pos[5],
698 elem->len); 702 pos[1]);
699 } 703 }
700 break; 704 break;
701 705
702 case MFIE_TYPE_RSN: 706 case WLAN_EID_RSN:
703 lbs_deb_scan("got RSN IE\n"); 707 lbs_deb_scan("got RSN IE\n");
704 bss->rsn_ie_len = min(elem->len + 2, MAX_WPA_IE_LEN); 708 bss->rsn_ie_len = min(pos[1] + 2, MAX_WPA_IE_LEN);
705 memcpy(bss->rsn_ie, elem, bss->rsn_ie_len); 709 memcpy(bss->rsn_ie, pos, bss->rsn_ie_len);
706 lbs_deb_hex(LBS_DEB_SCAN, "process_bss: RSN_IE", 710 lbs_deb_hex(LBS_DEB_SCAN, "process_bss: RSN_IE",
707 bss->rsn_ie, elem->len); 711 bss->rsn_ie, bss->rsn_ie_len);
708 break; 712 break;
709 713
710 default: 714 default:
711 lbs_deb_scan("got IE 0x%04x, len %d\n", 715 lbs_deb_scan("got IE 0x%04x, len %d\n",
712 elem->id, elem->len); 716 pos[0], pos[1]);
713 break; 717 break;
714 } 718 }
715 719
716 pos += elem->len + 2; 720 pos += pos[1] + 2;
717 } 721 }
718 722
719 /* Timestamp */ 723 /* Timestamp */
@@ -741,10 +745,11 @@ done:
741int lbs_send_specific_ssid_scan(struct lbs_private *priv, uint8_t *ssid, 745int lbs_send_specific_ssid_scan(struct lbs_private *priv, uint8_t *ssid,
742 uint8_t ssid_len) 746 uint8_t ssid_len)
743{ 747{
748 DECLARE_SSID_BUF(ssid_buf);
744 int ret = 0; 749 int ret = 0;
745 750
746 lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s'\n", 751 lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s'\n",
747 escape_essid(ssid, ssid_len)); 752 print_ssid(ssid_buf, ssid, ssid_len));
748 753
749 if (!ssid_len) 754 if (!ssid_len)
750 goto out; 755 goto out;
@@ -939,7 +944,8 @@ out:
939int lbs_set_scan(struct net_device *dev, struct iw_request_info *info, 944int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
940 union iwreq_data *wrqu, char *extra) 945 union iwreq_data *wrqu, char *extra)
941{ 946{
942 struct lbs_private *priv = dev->priv; 947 DECLARE_SSID_BUF(ssid);
948 struct lbs_private *priv = netdev_priv(dev);
943 int ret = 0; 949 int ret = 0;
944 950
945 lbs_deb_enter(LBS_DEB_WEXT); 951 lbs_deb_enter(LBS_DEB_WEXT);
@@ -968,7 +974,7 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
968 priv->scan_ssid_len = req->essid_len; 974 priv->scan_ssid_len = req->essid_len;
969 memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); 975 memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len);
970 lbs_deb_wext("set_scan, essid '%s'\n", 976 lbs_deb_wext("set_scan, essid '%s'\n",
971 escape_essid(priv->scan_ssid, priv->scan_ssid_len)); 977 print_ssid(ssid, priv->scan_ssid, priv->scan_ssid_len));
972 } else { 978 } else {
973 priv->scan_ssid_len = 0; 979 priv->scan_ssid_len = 0;
974 } 980 }
@@ -1002,7 +1008,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
1002 struct iw_point *dwrq, char *extra) 1008 struct iw_point *dwrq, char *extra)
1003{ 1009{
1004#define SCAN_ITEM_SIZE 128 1010#define SCAN_ITEM_SIZE 128
1005 struct lbs_private *priv = dev->priv; 1011 struct lbs_private *priv = netdev_priv(dev);
1006 int err = 0; 1012 int err = 0;
1007 char *ev = extra; 1013 char *ev = extra;
1008 char *stop = ev + dwrq->length; 1014 char *stop = ev + dwrq->length;
@@ -1151,7 +1157,6 @@ static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
1151 struct bss_descriptor new; 1157 struct bss_descriptor new;
1152 struct bss_descriptor *found = NULL; 1158 struct bss_descriptor *found = NULL;
1153 struct bss_descriptor *oldest = NULL; 1159 struct bss_descriptor *oldest = NULL;
1154 DECLARE_MAC_BUF(mac);
1155 1160
1156 /* Process the data fields and IEs returned for this BSS */ 1161 /* Process the data fields and IEs returned for this BSS */
1157 memset(&new, 0, sizeof (struct bss_descriptor)); 1162 memset(&new, 0, sizeof (struct bss_descriptor));
@@ -1190,7 +1195,7 @@ static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
1190 continue; 1195 continue;
1191 } 1196 }
1192 1197
1193 lbs_deb_scan("SCAN_RESP: BSSID %s\n", print_mac(mac, new.bssid)); 1198 lbs_deb_scan("SCAN_RESP: BSSID %pM\n", new.bssid);
1194 1199
1195 /* Copy the locally created newbssentry to the scan table */ 1200 /* Copy the locally created newbssentry to the scan table */
1196 memcpy(found, &new, offsetof(struct bss_descriptor, list)); 1201 memcpy(found, &new, offsetof(struct bss_descriptor, list));
diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h
index 9e07b0464a8e..fab7d5d097fc 100644
--- a/drivers/net/wireless/libertas/scan.h
+++ b/drivers/net/wireless/libertas/scan.h
@@ -7,6 +7,10 @@
7#ifndef _LBS_SCAN_H 7#ifndef _LBS_SCAN_H
8#define _LBS_SCAN_H 8#define _LBS_SCAN_H
9 9
10#include <net/iw_handler.h>
11
12#define MAX_NETWORK_COUNT 128
13
10/** 14/**
11 * @brief Maximum number of channels that can be sent in a setuserscan ioctl 15 * @brief Maximum number of channels that can be sent in a setuserscan ioctl
12 */ 16 */
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c
index a4972fed2941..dac462641170 100644
--- a/drivers/net/wireless/libertas/tx.c
+++ b/drivers/net/wireless/libertas/tx.c
@@ -60,7 +60,7 @@ static u32 convert_radiotap_rate_to_mv(u8 rate)
60int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 60int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
61{ 61{
62 unsigned long flags; 62 unsigned long flags;
63 struct lbs_private *priv = dev->priv; 63 struct lbs_private *priv = netdev_priv(dev);
64 struct txpd *txpd; 64 struct txpd *txpd;
65 char *p802x_hdr; 65 char *p802x_hdr;
66 uint16_t pkt_len; 66 uint16_t pkt_len;
diff --git a/drivers/net/wireless/libertas/types.h b/drivers/net/wireless/libertas/types.h
index e0c2599da92f..fb7a2d1a2525 100644
--- a/drivers/net/wireless/libertas/types.h
+++ b/drivers/net/wireless/libertas/types.h
@@ -7,7 +7,6 @@
7#include <linux/if_ether.h> 7#include <linux/if_ether.h>
8#include <asm/byteorder.h> 8#include <asm/byteorder.h>
9#include <linux/wireless.h> 9#include <linux/wireless.h>
10#include <net/ieee80211.h>
11 10
12struct ieeetypes_cfparamset { 11struct ieeetypes_cfparamset {
13 u8 elementid; 12 u8 elementid;
@@ -258,7 +257,7 @@ struct mrvlietypes_ledbhv {
258 * Note that the len member of the ieee80211_info_element varies depending on 257 * Note that the len member of the ieee80211_info_element varies depending on
259 * the mesh_id_len */ 258 * the mesh_id_len */
260struct mrvl_meshie_val { 259struct mrvl_meshie_val {
261 uint8_t oui[P80211_OUI_LEN]; 260 uint8_t oui[3];
262 uint8_t type; 261 uint8_t type;
263 uint8_t subtype; 262 uint8_t subtype;
264 uint8_t version; 263 uint8_t version;
@@ -270,7 +269,7 @@ struct mrvl_meshie_val {
270} __attribute__ ((packed)); 269} __attribute__ ((packed));
271 270
272struct mrvl_meshie { 271struct mrvl_meshie {
273 struct ieee80211_info_element hdr; 272 u8 id, len;
274 struct mrvl_meshie_val val; 273 struct mrvl_meshie_val val;
275} __attribute__ ((packed)); 274} __attribute__ ((packed));
276 275
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 82c3e5a50ea6..c6102e08179e 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -8,7 +8,7 @@
8#include <linux/wireless.h> 8#include <linux/wireless.h>
9#include <linux/bitops.h> 9#include <linux/bitops.h>
10 10
11#include <net/ieee80211.h> 11#include <net/lib80211.h>
12#include <net/iw_handler.h> 12#include <net/iw_handler.h>
13 13
14#include "host.h" 14#include "host.h"
@@ -163,7 +163,7 @@ static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
163static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info, 163static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
164 struct iw_freq *fwrq, char *extra) 164 struct iw_freq *fwrq, char *extra)
165{ 165{
166 struct lbs_private *priv = dev->priv; 166 struct lbs_private *priv = netdev_priv(dev);
167 struct chan_freq_power *cfp; 167 struct chan_freq_power *cfp;
168 168
169 lbs_deb_enter(LBS_DEB_WEXT); 169 lbs_deb_enter(LBS_DEB_WEXT);
@@ -189,7 +189,7 @@ static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
189static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info, 189static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
190 struct sockaddr *awrq, char *extra) 190 struct sockaddr *awrq, char *extra)
191{ 191{
192 struct lbs_private *priv = dev->priv; 192 struct lbs_private *priv = netdev_priv(dev);
193 193
194 lbs_deb_enter(LBS_DEB_WEXT); 194 lbs_deb_enter(LBS_DEB_WEXT);
195 195
@@ -207,7 +207,7 @@ static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
207static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info, 207static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
208 struct iw_point *dwrq, char *extra) 208 struct iw_point *dwrq, char *extra)
209{ 209{
210 struct lbs_private *priv = dev->priv; 210 struct lbs_private *priv = netdev_priv(dev);
211 211
212 lbs_deb_enter(LBS_DEB_WEXT); 212 lbs_deb_enter(LBS_DEB_WEXT);
213 213
@@ -231,7 +231,7 @@ static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
231static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info, 231static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
232 struct iw_point *dwrq, char *extra) 232 struct iw_point *dwrq, char *extra)
233{ 233{
234 struct lbs_private *priv = dev->priv; 234 struct lbs_private *priv = netdev_priv(dev);
235 235
236 lbs_deb_enter(LBS_DEB_WEXT); 236 lbs_deb_enter(LBS_DEB_WEXT);
237 237
@@ -248,7 +248,7 @@ static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
248static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info, 248static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
249 struct iw_point *dwrq, char *extra) 249 struct iw_point *dwrq, char *extra)
250{ 250{
251 struct lbs_private *priv = dev->priv; 251 struct lbs_private *priv = netdev_priv(dev);
252 252
253 lbs_deb_enter(LBS_DEB_WEXT); 253 lbs_deb_enter(LBS_DEB_WEXT);
254 254
@@ -273,7 +273,7 @@ static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
273 struct iw_param *vwrq, char *extra) 273 struct iw_param *vwrq, char *extra)
274{ 274{
275 int ret = 0; 275 int ret = 0;
276 struct lbs_private *priv = dev->priv; 276 struct lbs_private *priv = netdev_priv(dev);
277 u32 val = vwrq->value; 277 u32 val = vwrq->value;
278 278
279 lbs_deb_enter(LBS_DEB_WEXT); 279 lbs_deb_enter(LBS_DEB_WEXT);
@@ -293,7 +293,7 @@ static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
293static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info, 293static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
294 struct iw_param *vwrq, char *extra) 294 struct iw_param *vwrq, char *extra)
295{ 295{
296 struct lbs_private *priv = dev->priv; 296 struct lbs_private *priv = netdev_priv(dev);
297 int ret = 0; 297 int ret = 0;
298 u16 val = 0; 298 u16 val = 0;
299 299
@@ -315,7 +315,7 @@ out:
315static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info, 315static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
316 struct iw_param *vwrq, char *extra) 316 struct iw_param *vwrq, char *extra)
317{ 317{
318 struct lbs_private *priv = dev->priv; 318 struct lbs_private *priv = netdev_priv(dev);
319 int ret = 0; 319 int ret = 0;
320 u32 val = vwrq->value; 320 u32 val = vwrq->value;
321 321
@@ -336,7 +336,7 @@ static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
336static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info, 336static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
337 struct iw_param *vwrq, char *extra) 337 struct iw_param *vwrq, char *extra)
338{ 338{
339 struct lbs_private *priv = dev->priv; 339 struct lbs_private *priv = netdev_priv(dev);
340 int ret = 0; 340 int ret = 0;
341 u16 val = 0; 341 u16 val = 0;
342 342
@@ -359,7 +359,7 @@ out:
359static int lbs_get_mode(struct net_device *dev, 359static int lbs_get_mode(struct net_device *dev,
360 struct iw_request_info *info, u32 * uwrq, char *extra) 360 struct iw_request_info *info, u32 * uwrq, char *extra)
361{ 361{
362 struct lbs_private *priv = dev->priv; 362 struct lbs_private *priv = netdev_priv(dev);
363 363
364 lbs_deb_enter(LBS_DEB_WEXT); 364 lbs_deb_enter(LBS_DEB_WEXT);
365 365
@@ -385,7 +385,7 @@ static int lbs_get_txpow(struct net_device *dev,
385 struct iw_request_info *info, 385 struct iw_request_info *info,
386 struct iw_param *vwrq, char *extra) 386 struct iw_param *vwrq, char *extra)
387{ 387{
388 struct lbs_private *priv = dev->priv; 388 struct lbs_private *priv = netdev_priv(dev);
389 s16 curlevel = 0; 389 s16 curlevel = 0;
390 int ret = 0; 390 int ret = 0;
391 391
@@ -418,7 +418,7 @@ out:
418static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info, 418static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
419 struct iw_param *vwrq, char *extra) 419 struct iw_param *vwrq, char *extra)
420{ 420{
421 struct lbs_private *priv = dev->priv; 421 struct lbs_private *priv = netdev_priv(dev);
422 int ret = 0; 422 int ret = 0;
423 u16 slimit = 0, llimit = 0; 423 u16 slimit = 0, llimit = 0;
424 424
@@ -466,7 +466,7 @@ out:
466static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info, 466static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
467 struct iw_param *vwrq, char *extra) 467 struct iw_param *vwrq, char *extra)
468{ 468{
469 struct lbs_private *priv = dev->priv; 469 struct lbs_private *priv = netdev_priv(dev);
470 int ret = 0; 470 int ret = 0;
471 u16 val = 0; 471 u16 val = 0;
472 472
@@ -542,7 +542,7 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
542 struct iw_point *dwrq, char *extra) 542 struct iw_point *dwrq, char *extra)
543{ 543{
544 int i, j; 544 int i, j;
545 struct lbs_private *priv = dev->priv; 545 struct lbs_private *priv = netdev_priv(dev);
546 struct iw_range *range = (struct iw_range *)extra; 546 struct iw_range *range = (struct iw_range *)extra;
547 struct chan_freq_power *cfp; 547 struct chan_freq_power *cfp;
548 u8 rates[MAX_RATES + 1]; 548 u8 rates[MAX_RATES + 1];
@@ -708,7 +708,7 @@ out:
708static int lbs_set_power(struct net_device *dev, struct iw_request_info *info, 708static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
709 struct iw_param *vwrq, char *extra) 709 struct iw_param *vwrq, char *extra)
710{ 710{
711 struct lbs_private *priv = dev->priv; 711 struct lbs_private *priv = netdev_priv(dev);
712 712
713 lbs_deb_enter(LBS_DEB_WEXT); 713 lbs_deb_enter(LBS_DEB_WEXT);
714 714
@@ -758,7 +758,7 @@ static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
758static int lbs_get_power(struct net_device *dev, struct iw_request_info *info, 758static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
759 struct iw_param *vwrq, char *extra) 759 struct iw_param *vwrq, char *extra)
760{ 760{
761 struct lbs_private *priv = dev->priv; 761 struct lbs_private *priv = netdev_priv(dev);
762 762
763 lbs_deb_enter(LBS_DEB_WEXT); 763 lbs_deb_enter(LBS_DEB_WEXT);
764 764
@@ -781,7 +781,7 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
781 EXCELLENT = 95, 781 EXCELLENT = 95,
782 PERFECT = 100 782 PERFECT = 100
783 }; 783 };
784 struct lbs_private *priv = dev->priv; 784 struct lbs_private *priv = netdev_priv(dev);
785 u32 rssi_qual; 785 u32 rssi_qual;
786 u32 tx_qual; 786 u32 tx_qual;
787 u32 quality = 0; 787 u32 quality = 0;
@@ -886,7 +886,7 @@ static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
886 struct iw_freq *fwrq, char *extra) 886 struct iw_freq *fwrq, char *extra)
887{ 887{
888 int ret = -EINVAL; 888 int ret = -EINVAL;
889 struct lbs_private *priv = dev->priv; 889 struct lbs_private *priv = netdev_priv(dev);
890 struct chan_freq_power *cfp; 890 struct chan_freq_power *cfp;
891 struct assoc_request * assoc_req; 891 struct assoc_request * assoc_req;
892 892
@@ -943,7 +943,7 @@ static int lbs_mesh_set_freq(struct net_device *dev,
943 struct iw_request_info *info, 943 struct iw_request_info *info,
944 struct iw_freq *fwrq, char *extra) 944 struct iw_freq *fwrq, char *extra)
945{ 945{
946 struct lbs_private *priv = dev->priv; 946 struct lbs_private *priv = netdev_priv(dev);
947 struct chan_freq_power *cfp; 947 struct chan_freq_power *cfp;
948 int ret = -EINVAL; 948 int ret = -EINVAL;
949 949
@@ -994,7 +994,7 @@ out:
994static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info, 994static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
995 struct iw_param *vwrq, char *extra) 995 struct iw_param *vwrq, char *extra)
996{ 996{
997 struct lbs_private *priv = dev->priv; 997 struct lbs_private *priv = netdev_priv(dev);
998 u8 new_rate = 0; 998 u8 new_rate = 0;
999 int ret = -EINVAL; 999 int ret = -EINVAL;
1000 u8 rates[MAX_RATES + 1]; 1000 u8 rates[MAX_RATES + 1];
@@ -1054,7 +1054,7 @@ out:
1054static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info, 1054static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
1055 struct iw_param *vwrq, char *extra) 1055 struct iw_param *vwrq, char *extra)
1056{ 1056{
1057 struct lbs_private *priv = dev->priv; 1057 struct lbs_private *priv = netdev_priv(dev);
1058 1058
1059 lbs_deb_enter(LBS_DEB_WEXT); 1059 lbs_deb_enter(LBS_DEB_WEXT);
1060 1060
@@ -1079,7 +1079,7 @@ static int lbs_set_mode(struct net_device *dev,
1079 struct iw_request_info *info, u32 * uwrq, char *extra) 1079 struct iw_request_info *info, u32 * uwrq, char *extra)
1080{ 1080{
1081 int ret = 0; 1081 int ret = 0;
1082 struct lbs_private *priv = dev->priv; 1082 struct lbs_private *priv = netdev_priv(dev);
1083 struct assoc_request * assoc_req; 1083 struct assoc_request * assoc_req;
1084 1084
1085 lbs_deb_enter(LBS_DEB_WEXT); 1085 lbs_deb_enter(LBS_DEB_WEXT);
@@ -1124,7 +1124,7 @@ static int lbs_get_encode(struct net_device *dev,
1124 struct iw_request_info *info, 1124 struct iw_request_info *info,
1125 struct iw_point *dwrq, u8 * extra) 1125 struct iw_point *dwrq, u8 * extra)
1126{ 1126{
1127 struct lbs_private *priv = dev->priv; 1127 struct lbs_private *priv = netdev_priv(dev);
1128 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 1128 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1129 1129
1130 lbs_deb_enter(LBS_DEB_WEXT); 1130 lbs_deb_enter(LBS_DEB_WEXT);
@@ -1319,7 +1319,7 @@ static int lbs_set_encode(struct net_device *dev,
1319 struct iw_point *dwrq, char *extra) 1319 struct iw_point *dwrq, char *extra)
1320{ 1320{
1321 int ret = 0; 1321 int ret = 0;
1322 struct lbs_private *priv = dev->priv; 1322 struct lbs_private *priv = netdev_priv(dev);
1323 struct assoc_request * assoc_req; 1323 struct assoc_request * assoc_req;
1324 u16 is_default = 0, index = 0, set_tx_key = 0; 1324 u16 is_default = 0, index = 0, set_tx_key = 0;
1325 1325
@@ -1395,7 +1395,7 @@ static int lbs_get_encodeext(struct net_device *dev,
1395 char *extra) 1395 char *extra)
1396{ 1396{
1397 int ret = -EINVAL; 1397 int ret = -EINVAL;
1398 struct lbs_private *priv = dev->priv; 1398 struct lbs_private *priv = netdev_priv(dev);
1399 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1399 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1400 int index, max_key_len; 1400 int index, max_key_len;
1401 1401
@@ -1501,7 +1501,7 @@ static int lbs_set_encodeext(struct net_device *dev,
1501 char *extra) 1501 char *extra)
1502{ 1502{
1503 int ret = 0; 1503 int ret = 0;
1504 struct lbs_private *priv = dev->priv; 1504 struct lbs_private *priv = netdev_priv(dev);
1505 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1505 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1506 int alg = ext->alg; 1506 int alg = ext->alg;
1507 struct assoc_request * assoc_req; 1507 struct assoc_request * assoc_req;
@@ -1639,7 +1639,7 @@ static int lbs_set_genie(struct net_device *dev,
1639 struct iw_point *dwrq, 1639 struct iw_point *dwrq,
1640 char *extra) 1640 char *extra)
1641{ 1641{
1642 struct lbs_private *priv = dev->priv; 1642 struct lbs_private *priv = netdev_priv(dev);
1643 int ret = 0; 1643 int ret = 0;
1644 struct assoc_request * assoc_req; 1644 struct assoc_request * assoc_req;
1645 1645
@@ -1685,7 +1685,7 @@ static int lbs_get_genie(struct net_device *dev,
1685 char *extra) 1685 char *extra)
1686{ 1686{
1687 int ret = 0; 1687 int ret = 0;
1688 struct lbs_private *priv = dev->priv; 1688 struct lbs_private *priv = netdev_priv(dev);
1689 1689
1690 lbs_deb_enter(LBS_DEB_WEXT); 1690 lbs_deb_enter(LBS_DEB_WEXT);
1691 1691
@@ -1713,7 +1713,7 @@ static int lbs_set_auth(struct net_device *dev,
1713 struct iw_param *dwrq, 1713 struct iw_param *dwrq,
1714 char *extra) 1714 char *extra)
1715{ 1715{
1716 struct lbs_private *priv = dev->priv; 1716 struct lbs_private *priv = netdev_priv(dev);
1717 struct assoc_request * assoc_req; 1717 struct assoc_request * assoc_req;
1718 int ret = 0; 1718 int ret = 0;
1719 int updated = 0; 1719 int updated = 0;
@@ -1816,7 +1816,7 @@ static int lbs_get_auth(struct net_device *dev,
1816 char *extra) 1816 char *extra)
1817{ 1817{
1818 int ret = 0; 1818 int ret = 0;
1819 struct lbs_private *priv = dev->priv; 1819 struct lbs_private *priv = netdev_priv(dev);
1820 1820
1821 lbs_deb_enter(LBS_DEB_WEXT); 1821 lbs_deb_enter(LBS_DEB_WEXT);
1822 1822
@@ -1857,7 +1857,7 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1857 struct iw_param *vwrq, char *extra) 1857 struct iw_param *vwrq, char *extra)
1858{ 1858{
1859 int ret = 0; 1859 int ret = 0;
1860 struct lbs_private *priv = dev->priv; 1860 struct lbs_private *priv = netdev_priv(dev);
1861 s16 dbm = (s16) vwrq->value; 1861 s16 dbm = (s16) vwrq->value;
1862 1862
1863 lbs_deb_enter(LBS_DEB_WEXT); 1863 lbs_deb_enter(LBS_DEB_WEXT);
@@ -1936,7 +1936,7 @@ out:
1936static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info, 1936static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
1937 struct iw_point *dwrq, char *extra) 1937 struct iw_point *dwrq, char *extra)
1938{ 1938{
1939 struct lbs_private *priv = dev->priv; 1939 struct lbs_private *priv = netdev_priv(dev);
1940 1940
1941 lbs_deb_enter(LBS_DEB_WEXT); 1941 lbs_deb_enter(LBS_DEB_WEXT);
1942 1942
@@ -1971,12 +1971,13 @@ static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
1971static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info, 1971static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
1972 struct iw_point *dwrq, char *extra) 1972 struct iw_point *dwrq, char *extra)
1973{ 1973{
1974 struct lbs_private *priv = dev->priv; 1974 struct lbs_private *priv = netdev_priv(dev);
1975 int ret = 0; 1975 int ret = 0;
1976 u8 ssid[IW_ESSID_MAX_SIZE]; 1976 u8 ssid[IW_ESSID_MAX_SIZE];
1977 u8 ssid_len = 0; 1977 u8 ssid_len = 0;
1978 struct assoc_request * assoc_req; 1978 struct assoc_request * assoc_req;
1979 int in_ssid_len = dwrq->length; 1979 int in_ssid_len = dwrq->length;
1980 DECLARE_SSID_BUF(ssid_buf);
1980 1981
1981 lbs_deb_enter(LBS_DEB_WEXT); 1982 lbs_deb_enter(LBS_DEB_WEXT);
1982 1983
@@ -2005,7 +2006,7 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
2005 lbs_deb_wext("requested any SSID\n"); 2006 lbs_deb_wext("requested any SSID\n");
2006 } else { 2007 } else {
2007 lbs_deb_wext("requested SSID '%s'\n", 2008 lbs_deb_wext("requested SSID '%s'\n",
2008 escape_essid(ssid, ssid_len)); 2009 print_ssid(ssid_buf, ssid, ssid_len));
2009 } 2010 }
2010 2011
2011out: 2012out:
@@ -2039,7 +2040,7 @@ static int lbs_mesh_get_essid(struct net_device *dev,
2039 struct iw_request_info *info, 2040 struct iw_request_info *info,
2040 struct iw_point *dwrq, char *extra) 2041 struct iw_point *dwrq, char *extra)
2041{ 2042{
2042 struct lbs_private *priv = dev->priv; 2043 struct lbs_private *priv = netdev_priv(dev);
2043 2044
2044 lbs_deb_enter(LBS_DEB_WEXT); 2045 lbs_deb_enter(LBS_DEB_WEXT);
2045 2046
@@ -2057,7 +2058,7 @@ static int lbs_mesh_set_essid(struct net_device *dev,
2057 struct iw_request_info *info, 2058 struct iw_request_info *info,
2058 struct iw_point *dwrq, char *extra) 2059 struct iw_point *dwrq, char *extra)
2059{ 2060{
2060 struct lbs_private *priv = dev->priv; 2061 struct lbs_private *priv = netdev_priv(dev);
2061 int ret = 0; 2062 int ret = 0;
2062 2063
2063 lbs_deb_enter(LBS_DEB_WEXT); 2064 lbs_deb_enter(LBS_DEB_WEXT);
@@ -2101,10 +2102,9 @@ static int lbs_mesh_set_essid(struct net_device *dev,
2101static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info, 2102static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
2102 struct sockaddr *awrq, char *extra) 2103 struct sockaddr *awrq, char *extra)
2103{ 2104{
2104 struct lbs_private *priv = dev->priv; 2105 struct lbs_private *priv = netdev_priv(dev);
2105 struct assoc_request * assoc_req; 2106 struct assoc_request * assoc_req;
2106 int ret = 0; 2107 int ret = 0;
2107 DECLARE_MAC_BUF(mac);
2108 2108
2109 lbs_deb_enter(LBS_DEB_WEXT); 2109 lbs_deb_enter(LBS_DEB_WEXT);
2110 2110
@@ -2114,7 +2114,7 @@ static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
2114 if (awrq->sa_family != ARPHRD_ETHER) 2114 if (awrq->sa_family != ARPHRD_ETHER)
2115 return -EINVAL; 2115 return -EINVAL;
2116 2116
2117 lbs_deb_wext("ASSOC: WAP: sa_data %s\n", print_mac(mac, awrq->sa_data)); 2117 lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
2118 2118
2119 mutex_lock(&priv->lock); 2119 mutex_lock(&priv->lock);
2120 2120
diff --git a/drivers/net/wireless/libertas_tf/cmd.c b/drivers/net/wireless/libertas_tf/cmd.c
index fdbcf8ba3e8a..3d3914c83b14 100644
--- a/drivers/net/wireless/libertas_tf/cmd.c
+++ b/drivers/net/wireless/libertas_tf/cmd.c
@@ -79,7 +79,6 @@ int lbtf_update_hw_spec(struct lbtf_private *priv)
79 struct cmd_ds_get_hw_spec cmd; 79 struct cmd_ds_get_hw_spec cmd;
80 int ret = -1; 80 int ret = -1;
81 u32 i; 81 u32 i;
82 DECLARE_MAC_BUF(mac);
83 82
84 memset(&cmd, 0, sizeof(cmd)); 83 memset(&cmd, 0, sizeof(cmd));
85 cmd.hdr.size = cpu_to_le16(sizeof(cmd)); 84 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
@@ -96,8 +95,8 @@ int lbtf_update_hw_spec(struct lbtf_private *priv)
96 priv->fwrelease = (priv->fwrelease << 8) | 95 priv->fwrelease = (priv->fwrelease << 8) |
97 (priv->fwrelease >> 24 & 0xff); 96 (priv->fwrelease >> 24 & 0xff);
98 97
99 printk(KERN_INFO "libertastf: %s, fw %u.%u.%up%u, cap 0x%08x\n", 98 printk(KERN_INFO "libertastf: %pM, fw %u.%u.%up%u, cap 0x%08x\n",
100 print_mac(mac, cmd.permanentaddr), 99 cmd.permanentaddr,
101 priv->fwrelease >> 24 & 0xff, 100 priv->fwrelease >> 24 & 0xff,
102 priv->fwrelease >> 16 & 0xff, 101 priv->fwrelease >> 16 & 0xff,
103 priv->fwrelease >> 8 & 0xff, 102 priv->fwrelease >> 8 & 0xff,
diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c
index 1cc03a8dd67a..59634c33b1f9 100644
--- a/drivers/net/wireless/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/libertas_tf/if_usb.c
@@ -331,7 +331,7 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
331 /* Fill the receive configuration URB and initialise the Rx call back */ 331 /* Fill the receive configuration URB and initialise the Rx call back */
332 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, 332 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev,
333 usb_rcvbulkpipe(cardp->udev, cardp->ep_in), 333 usb_rcvbulkpipe(cardp->udev, cardp->ep_in),
334 (void *) (skb->tail), 334 skb_tail_pointer(skb),
335 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp); 335 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp);
336 336
337 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET; 337 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index feff945ad856..d1fc305de5fe 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -354,9 +354,11 @@ static void lbtf_op_remove_interface(struct ieee80211_hw *hw,
354 priv->vif = NULL; 354 priv->vif = NULL;
355} 355}
356 356
357static int lbtf_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 357static int lbtf_op_config(struct ieee80211_hw *hw, u32 changed)
358{ 358{
359 struct lbtf_private *priv = hw->priv; 359 struct lbtf_private *priv = hw->priv;
360 struct ieee80211_conf *conf = &hw->conf;
361
360 if (conf->channel->center_freq != priv->cur_freq) { 362 if (conf->channel->center_freq != priv->cur_freq) {
361 priv->cur_freq = conf->channel->center_freq; 363 priv->cur_freq = conf->channel->center_freq;
362 lbtf_set_channel(priv, conf->channel->hw_value); 364 lbtf_set_channel(priv, conf->channel->hw_value);
@@ -590,14 +592,14 @@ EXPORT_SYMBOL_GPL(lbtf_remove_card);
590void lbtf_send_tx_feedback(struct lbtf_private *priv, u8 retrycnt, u8 fail) 592void lbtf_send_tx_feedback(struct lbtf_private *priv, u8 retrycnt, u8 fail)
591{ 593{
592 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb); 594 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb);
593 memset(&info->status, 0, sizeof(info->status)); 595
596 ieee80211_tx_info_clear_status(info);
594 /* 597 /*
595 * Commented out, otherwise we never go beyond 1Mbit/s using mac80211 598 * Commented out, otherwise we never go beyond 1Mbit/s using mac80211
596 * default pid rc algorithm. 599 * default pid rc algorithm.
597 * 600 *
598 * info->status.retry_count = MRVL_DEFAULT_RETRIES - retrycnt; 601 * info->status.retry_count = MRVL_DEFAULT_RETRIES - retrycnt;
599 */ 602 */
600 info->status.excessive_retries = fail ? 1 : 0;
601 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && !fail) 603 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && !fail)
602 info->flags |= IEEE80211_TX_STAT_ACK; 604 info->flags |= IEEE80211_TX_STAT_ACK;
603 skb_pull(priv->tx_skb, sizeof(struct txpd)); 605 skb_pull(priv->tx_skb, sizeof(struct txpd));
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 1a019e98dac3..b9230da925ee 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -21,6 +21,7 @@
21#include <linux/if_arp.h> 21#include <linux/if_arp.h>
22#include <linux/rtnetlink.h> 22#include <linux/rtnetlink.h>
23#include <linux/etherdevice.h> 23#include <linux/etherdevice.h>
24#include <linux/debugfs.h>
24 25
25MODULE_AUTHOR("Jouni Malinen"); 26MODULE_AUTHOR("Jouni Malinen");
26MODULE_DESCRIPTION("Software simulator of 802.11 radio(s) for mac80211"); 27MODULE_DESCRIPTION("Software simulator of 802.11 radio(s) for mac80211");
@@ -32,6 +33,9 @@ MODULE_PARM_DESC(radios, "Number of simulated radios");
32 33
33struct hwsim_vif_priv { 34struct hwsim_vif_priv {
34 u32 magic; 35 u32 magic;
36 u8 bssid[ETH_ALEN];
37 bool assoc;
38 u16 aid;
35}; 39};
36 40
37#define HWSIM_VIF_MAGIC 0x69537748 41#define HWSIM_VIF_MAGIC 0x69537748
@@ -63,13 +67,13 @@ struct hwsim_sta_priv {
63static inline void hwsim_check_sta_magic(struct ieee80211_sta *sta) 67static inline void hwsim_check_sta_magic(struct ieee80211_sta *sta)
64{ 68{
65 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; 69 struct hwsim_sta_priv *sp = (void *)sta->drv_priv;
66 WARN_ON(sp->magic != HWSIM_VIF_MAGIC); 70 WARN_ON(sp->magic != HWSIM_STA_MAGIC);
67} 71}
68 72
69static inline void hwsim_set_sta_magic(struct ieee80211_sta *sta) 73static inline void hwsim_set_sta_magic(struct ieee80211_sta *sta)
70{ 74{
71 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; 75 struct hwsim_sta_priv *sp = (void *)sta->drv_priv;
72 sp->magic = HWSIM_VIF_MAGIC; 76 sp->magic = HWSIM_STA_MAGIC;
73} 77}
74 78
75static inline void hwsim_clear_sta_magic(struct ieee80211_sta *sta) 79static inline void hwsim_clear_sta_magic(struct ieee80211_sta *sta)
@@ -132,6 +136,12 @@ struct mac80211_hwsim_data {
132 unsigned int rx_filter; 136 unsigned int rx_filter;
133 int started; 137 int started;
134 struct timer_list beacon_timer; 138 struct timer_list beacon_timer;
139 enum ps_mode {
140 PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL
141 } ps;
142 bool ps_poll_pending;
143 struct dentry *debugfs;
144 struct dentry *debugfs_ps;
135}; 145};
136 146
137 147
@@ -196,6 +206,34 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
196} 206}
197 207
198 208
209static bool hwsim_ps_rx_ok(struct mac80211_hwsim_data *data,
210 struct sk_buff *skb)
211{
212 switch (data->ps) {
213 case PS_DISABLED:
214 return true;
215 case PS_ENABLED:
216 return false;
217 case PS_AUTO_POLL:
218 /* TODO: accept (some) Beacons by default and other frames only
219 * if pending PS-Poll has been sent */
220 return true;
221 case PS_MANUAL_POLL:
222 /* Allow unicast frames to own address if there is a pending
223 * PS-Poll */
224 if (data->ps_poll_pending &&
225 memcmp(data->hw->wiphy->perm_addr, skb->data + 4,
226 ETH_ALEN) == 0) {
227 data->ps_poll_pending = false;
228 return true;
229 }
230 return false;
231 }
232
233 return true;
234}
235
236
199static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, 237static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
200 struct sk_buff *skb) 238 struct sk_buff *skb)
201{ 239{
@@ -209,9 +247,12 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
209 /* TODO: set mactime */ 247 /* TODO: set mactime */
210 rx_status.freq = data->channel->center_freq; 248 rx_status.freq = data->channel->center_freq;
211 rx_status.band = data->channel->band; 249 rx_status.band = data->channel->band;
212 rx_status.rate_idx = info->tx_rate_idx; 250 rx_status.rate_idx = info->control.rates[0].idx;
213 /* TODO: simulate signal strength (and optional packet drop) */ 251 /* TODO: simulate signal strength (and optional packet drop) */
214 252
253 if (data->ps != PS_DISABLED)
254 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
255
215 /* Copy skb to all enabled radios that are on the current frequency */ 256 /* Copy skb to all enabled radios that are on the current frequency */
216 spin_lock(&hwsim_radio_lock); 257 spin_lock(&hwsim_radio_lock);
217 list_for_each_entry(data2, &hwsim_radios, list) { 258 list_for_each_entry(data2, &hwsim_radios, list) {
@@ -221,6 +262,7 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
221 continue; 262 continue;
222 263
223 if (!data2->started || !data2->radio_enabled || 264 if (!data2->started || !data2->radio_enabled ||
265 !hwsim_ps_rx_ok(data2, skb) ||
224 data->channel->center_freq != data2->channel->center_freq) 266 data->channel->center_freq != data2->channel->center_freq)
225 continue; 267 continue;
226 268
@@ -269,13 +311,9 @@ static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
269 if (txi->control.sta) 311 if (txi->control.sta)
270 hwsim_check_sta_magic(txi->control.sta); 312 hwsim_check_sta_magic(txi->control.sta);
271 313
272 memset(&txi->status, 0, sizeof(txi->status)); 314 ieee80211_tx_info_clear_status(txi);
273 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { 315 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) && ack)
274 if (ack) 316 txi->flags |= IEEE80211_TX_STAT_ACK;
275 txi->flags |= IEEE80211_TX_STAT_ACK;
276 else
277 txi->status.excessive_retries = 1;
278 }
279 ieee80211_tx_status_irqsafe(hw, skb); 317 ieee80211_tx_status_irqsafe(hw, skb);
280 return NETDEV_TX_OK; 318 return NETDEV_TX_OK;
281} 319}
@@ -294,6 +332,7 @@ static void mac80211_hwsim_stop(struct ieee80211_hw *hw)
294{ 332{
295 struct mac80211_hwsim_data *data = hw->priv; 333 struct mac80211_hwsim_data *data = hw->priv;
296 data->started = 0; 334 data->started = 0;
335 del_timer(&data->beacon_timer);
297 printk(KERN_DEBUG "%s:%s\n", wiphy_name(hw->wiphy), __func__); 336 printk(KERN_DEBUG "%s:%s\n", wiphy_name(hw->wiphy), __func__);
298} 337}
299 338
@@ -301,10 +340,9 @@ static void mac80211_hwsim_stop(struct ieee80211_hw *hw)
301static int mac80211_hwsim_add_interface(struct ieee80211_hw *hw, 340static int mac80211_hwsim_add_interface(struct ieee80211_hw *hw,
302 struct ieee80211_if_init_conf *conf) 341 struct ieee80211_if_init_conf *conf)
303{ 342{
304 DECLARE_MAC_BUF(mac); 343 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%pM)\n",
305 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n",
306 wiphy_name(hw->wiphy), __func__, conf->type, 344 wiphy_name(hw->wiphy), __func__, conf->type,
307 print_mac(mac, conf->mac_addr)); 345 conf->mac_addr);
308 hwsim_set_magic(conf->vif); 346 hwsim_set_magic(conf->vif);
309 return 0; 347 return 0;
310} 348}
@@ -313,10 +351,9 @@ static int mac80211_hwsim_add_interface(struct ieee80211_hw *hw,
313static void mac80211_hwsim_remove_interface( 351static void mac80211_hwsim_remove_interface(
314 struct ieee80211_hw *hw, struct ieee80211_if_init_conf *conf) 352 struct ieee80211_hw *hw, struct ieee80211_if_init_conf *conf)
315{ 353{
316 DECLARE_MAC_BUF(mac); 354 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%pM)\n",
317 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n",
318 wiphy_name(hw->wiphy), __func__, conf->type, 355 wiphy_name(hw->wiphy), __func__, conf->type,
319 print_mac(mac, conf->mac_addr)); 356 conf->mac_addr);
320 hwsim_check_magic(conf->vif); 357 hwsim_check_magic(conf->vif);
321 hwsim_clear_magic(conf->vif); 358 hwsim_clear_magic(conf->vif);
322} 359}
@@ -361,10 +398,10 @@ static void mac80211_hwsim_beacon(unsigned long arg)
361} 398}
362 399
363 400
364static int mac80211_hwsim_config(struct ieee80211_hw *hw, 401static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
365 struct ieee80211_conf *conf)
366{ 402{
367 struct mac80211_hwsim_data *data = hw->priv; 403 struct mac80211_hwsim_data *data = hw->priv;
404 struct ieee80211_conf *conf = &hw->conf;
368 405
369 printk(KERN_DEBUG "%s:%s (freq=%d radio_enabled=%d beacon_int=%d)\n", 406 printk(KERN_DEBUG "%s:%s (freq=%d radio_enabled=%d beacon_int=%d)\n",
370 wiphy_name(hw->wiphy), __func__, 407 wiphy_name(hw->wiphy), __func__,
@@ -409,7 +446,16 @@ static int mac80211_hwsim_config_interface(struct ieee80211_hw *hw,
409 struct ieee80211_vif *vif, 446 struct ieee80211_vif *vif,
410 struct ieee80211_if_conf *conf) 447 struct ieee80211_if_conf *conf)
411{ 448{
449 struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
450
412 hwsim_check_magic(vif); 451 hwsim_check_magic(vif);
452 if (conf->changed & IEEE80211_IFCC_BSSID) {
453 DECLARE_MAC_BUF(mac);
454 printk(KERN_DEBUG "%s:%s: BSSID changed: %s\n",
455 wiphy_name(hw->wiphy), __func__,
456 print_mac(mac, conf->bssid));
457 memcpy(vp->bssid, conf->bssid, ETH_ALEN);
458 }
413 return 0; 459 return 0;
414} 460}
415 461
@@ -418,7 +464,48 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
418 struct ieee80211_bss_conf *info, 464 struct ieee80211_bss_conf *info,
419 u32 changed) 465 u32 changed)
420{ 466{
467 struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
468
421 hwsim_check_magic(vif); 469 hwsim_check_magic(vif);
470
471 printk(KERN_DEBUG "%s:%s(changed=0x%x)\n",
472 wiphy_name(hw->wiphy), __func__, changed);
473
474 if (changed & BSS_CHANGED_ASSOC) {
475 printk(KERN_DEBUG " %s: ASSOC: assoc=%d aid=%d\n",
476 wiphy_name(hw->wiphy), info->assoc, info->aid);
477 vp->assoc = info->assoc;
478 vp->aid = info->aid;
479 }
480
481 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
482 printk(KERN_DEBUG " %s: ERP_CTS_PROT: %d\n",
483 wiphy_name(hw->wiphy), info->use_cts_prot);
484 }
485
486 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
487 printk(KERN_DEBUG " %s: ERP_PREAMBLE: %d\n",
488 wiphy_name(hw->wiphy), info->use_short_preamble);
489 }
490
491 if (changed & BSS_CHANGED_ERP_SLOT) {
492 printk(KERN_DEBUG " %s: ERP_SLOT: %d\n",
493 wiphy_name(hw->wiphy), info->use_short_slot);
494 }
495
496 if (changed & BSS_CHANGED_HT) {
497 printk(KERN_DEBUG " %s: HT: sec_ch_offs=%d width_40_ok=%d "
498 "op_mode=%d\n",
499 wiphy_name(hw->wiphy),
500 info->ht.secondary_channel_offset,
501 info->ht.width_40_ok, info->ht.operation_mode);
502 }
503
504 if (changed & BSS_CHANGED_BASIC_RATES) {
505 printk(KERN_DEBUG " %s: BASIC_RATES: 0x%llx\n",
506 wiphy_name(hw->wiphy),
507 (unsigned long long) info->basic_rates);
508 }
422} 509}
423 510
424static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw, 511static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw,
@@ -445,6 +532,17 @@ static int mac80211_hwsim_set_tim(struct ieee80211_hw *hw,
445 return 0; 532 return 0;
446} 533}
447 534
535static int mac80211_hwsim_conf_tx(
536 struct ieee80211_hw *hw, u16 queue,
537 const struct ieee80211_tx_queue_params *params)
538{
539 printk(KERN_DEBUG "%s:%s (queue=%d txop=%d cw_min=%d cw_max=%d "
540 "aifs=%d)\n",
541 wiphy_name(hw->wiphy), __func__, queue,
542 params->txop, params->cw_min, params->cw_max, params->aifs);
543 return 0;
544}
545
448static const struct ieee80211_ops mac80211_hwsim_ops = 546static const struct ieee80211_ops mac80211_hwsim_ops =
449{ 547{
450 .tx = mac80211_hwsim_tx, 548 .tx = mac80211_hwsim_tx,
@@ -458,6 +556,7 @@ static const struct ieee80211_ops mac80211_hwsim_ops =
458 .bss_info_changed = mac80211_hwsim_bss_info_changed, 556 .bss_info_changed = mac80211_hwsim_bss_info_changed,
459 .sta_notify = mac80211_hwsim_sta_notify, 557 .sta_notify = mac80211_hwsim_sta_notify,
460 .set_tim = mac80211_hwsim_set_tim, 558 .set_tim = mac80211_hwsim_set_tim,
559 .conf_tx = mac80211_hwsim_conf_tx,
461}; 560};
462 561
463 562
@@ -474,6 +573,8 @@ static void mac80211_hwsim_free(void)
474 spin_unlock_bh(&hwsim_radio_lock); 573 spin_unlock_bh(&hwsim_radio_lock);
475 574
476 list_for_each_entry(data, &tmplist, list) { 575 list_for_each_entry(data, &tmplist, list) {
576 debugfs_remove(data->debugfs_ps);
577 debugfs_remove(data->debugfs);
477 ieee80211_unregister_hw(data->hw); 578 ieee80211_unregister_hw(data->hw);
478 device_unregister(data->dev); 579 device_unregister(data->dev);
479 ieee80211_free_hw(data->hw); 580 ieee80211_free_hw(data->hw);
@@ -499,13 +600,133 @@ static void hwsim_mon_setup(struct net_device *dev)
499} 600}
500 601
501 602
603static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif)
604{
605 struct mac80211_hwsim_data *data = dat;
606 struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
607 DECLARE_MAC_BUF(buf);
608 struct sk_buff *skb;
609 struct ieee80211_pspoll *pspoll;
610
611 if (!vp->assoc)
612 return;
613
614 printk(KERN_DEBUG "%s:%s: send PS-Poll to %s for aid %d\n",
615 wiphy_name(data->hw->wiphy), __func__,
616 print_mac(buf, vp->bssid), vp->aid);
617
618 skb = dev_alloc_skb(sizeof(*pspoll));
619 if (!skb)
620 return;
621 pspoll = (void *) skb_put(skb, sizeof(*pspoll));
622 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
623 IEEE80211_STYPE_PSPOLL |
624 IEEE80211_FCTL_PM);
625 pspoll->aid = cpu_to_le16(0xc000 | vp->aid);
626 memcpy(pspoll->bssid, vp->bssid, ETH_ALEN);
627 memcpy(pspoll->ta, mac, ETH_ALEN);
628 if (data->radio_enabled &&
629 !mac80211_hwsim_tx_frame(data->hw, skb))
630 printk(KERN_DEBUG "%s: PS-Poll frame not ack'ed\n", __func__);
631 dev_kfree_skb(skb);
632}
633
634
635static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac,
636 struct ieee80211_vif *vif, int ps)
637{
638 struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
639 DECLARE_MAC_BUF(buf);
640 struct sk_buff *skb;
641 struct ieee80211_hdr *hdr;
642
643 if (!vp->assoc)
644 return;
645
646 printk(KERN_DEBUG "%s:%s: send data::nullfunc to %s ps=%d\n",
647 wiphy_name(data->hw->wiphy), __func__,
648 print_mac(buf, vp->bssid), ps);
649
650 skb = dev_alloc_skb(sizeof(*hdr));
651 if (!skb)
652 return;
653 hdr = (void *) skb_put(skb, sizeof(*hdr) - ETH_ALEN);
654 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
655 IEEE80211_STYPE_NULLFUNC |
656 (ps ? IEEE80211_FCTL_PM : 0));
657 hdr->duration_id = cpu_to_le16(0);
658 memcpy(hdr->addr1, vp->bssid, ETH_ALEN);
659 memcpy(hdr->addr2, mac, ETH_ALEN);
660 memcpy(hdr->addr3, vp->bssid, ETH_ALEN);
661 if (data->radio_enabled &&
662 !mac80211_hwsim_tx_frame(data->hw, skb))
663 printk(KERN_DEBUG "%s: nullfunc frame not ack'ed\n", __func__);
664 dev_kfree_skb(skb);
665}
666
667
668static void hwsim_send_nullfunc_ps(void *dat, u8 *mac,
669 struct ieee80211_vif *vif)
670{
671 struct mac80211_hwsim_data *data = dat;
672 hwsim_send_nullfunc(data, mac, vif, 1);
673}
674
675
676static void hwsim_send_nullfunc_no_ps(void *dat, u8 *mac,
677 struct ieee80211_vif *vif)
678{
679 struct mac80211_hwsim_data *data = dat;
680 hwsim_send_nullfunc(data, mac, vif, 0);
681}
682
683
684static int hwsim_fops_ps_read(void *dat, u64 *val)
685{
686 struct mac80211_hwsim_data *data = dat;
687 *val = data->ps;
688 return 0;
689}
690
691static int hwsim_fops_ps_write(void *dat, u64 val)
692{
693 struct mac80211_hwsim_data *data = dat;
694 enum ps_mode old_ps;
695
696 if (val != PS_DISABLED && val != PS_ENABLED && val != PS_AUTO_POLL &&
697 val != PS_MANUAL_POLL)
698 return -EINVAL;
699
700 old_ps = data->ps;
701 data->ps = val;
702
703 if (val == PS_MANUAL_POLL) {
704 ieee80211_iterate_active_interfaces(data->hw,
705 hwsim_send_ps_poll, data);
706 data->ps_poll_pending = true;
707 } else if (old_ps == PS_DISABLED && val != PS_DISABLED) {
708 ieee80211_iterate_active_interfaces(data->hw,
709 hwsim_send_nullfunc_ps,
710 data);
711 } else if (old_ps != PS_DISABLED && val == PS_DISABLED) {
712 ieee80211_iterate_active_interfaces(data->hw,
713 hwsim_send_nullfunc_no_ps,
714 data);
715 }
716
717 return 0;
718}
719
720DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write,
721 "%llu\n");
722
723
502static int __init init_mac80211_hwsim(void) 724static int __init init_mac80211_hwsim(void)
503{ 725{
504 int i, err = 0; 726 int i, err = 0;
505 u8 addr[ETH_ALEN]; 727 u8 addr[ETH_ALEN];
506 struct mac80211_hwsim_data *data; 728 struct mac80211_hwsim_data *data;
507 struct ieee80211_hw *hw; 729 struct ieee80211_hw *hw;
508 DECLARE_MAC_BUF(mac);
509 730
510 if (radios < 1 || radios > 100) 731 if (radios < 1 || radios > 100)
511 return -EINVAL; 732 return -EINVAL;
@@ -566,19 +787,18 @@ static int __init init_mac80211_hwsim(void)
566 data->band.n_channels = ARRAY_SIZE(hwsim_channels); 787 data->band.n_channels = ARRAY_SIZE(hwsim_channels);
567 data->band.bitrates = data->rates; 788 data->band.bitrates = data->rates;
568 data->band.n_bitrates = ARRAY_SIZE(hwsim_rates); 789 data->band.n_bitrates = ARRAY_SIZE(hwsim_rates);
569 data->band.ht_info.ht_supported = 1; 790 data->band.ht_cap.ht_supported = true;
570 data->band.ht_info.cap = IEEE80211_HT_CAP_SUP_WIDTH | 791 data->band.ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
571 IEEE80211_HT_CAP_GRN_FLD | 792 IEEE80211_HT_CAP_GRN_FLD |
572 IEEE80211_HT_CAP_SGI_40 | 793 IEEE80211_HT_CAP_SGI_40 |
573 IEEE80211_HT_CAP_DSSSCCK40; 794 IEEE80211_HT_CAP_DSSSCCK40;
574 data->band.ht_info.ampdu_factor = 0x3; 795 data->band.ht_cap.ampdu_factor = 0x3;
575 data->band.ht_info.ampdu_density = 0x6; 796 data->band.ht_cap.ampdu_density = 0x6;
576 memset(data->band.ht_info.supp_mcs_set, 0, 797 memset(&data->band.ht_cap.mcs, 0,
577 sizeof(data->band.ht_info.supp_mcs_set)); 798 sizeof(data->band.ht_cap.mcs));
578 data->band.ht_info.supp_mcs_set[0] = 0xff; 799 data->band.ht_cap.mcs.rx_mask[0] = 0xff;
579 data->band.ht_info.supp_mcs_set[1] = 0xff; 800 data->band.ht_cap.mcs.rx_mask[1] = 0xff;
580 data->band.ht_info.supp_mcs_set[12] = 801 data->band.ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
581 IEEE80211_HT_CAP_MCS_TX_DEFINED;
582 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &data->band; 802 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &data->band;
583 803
584 err = ieee80211_register_hw(hw); 804 err = ieee80211_register_hw(hw);
@@ -588,9 +808,15 @@ static int __init init_mac80211_hwsim(void)
588 goto failed_hw; 808 goto failed_hw;
589 } 809 }
590 810
591 printk(KERN_DEBUG "%s: hwaddr %s registered\n", 811 printk(KERN_DEBUG "%s: hwaddr %pM registered\n",
592 wiphy_name(hw->wiphy), 812 wiphy_name(hw->wiphy),
593 print_mac(mac, hw->wiphy->perm_addr)); 813 hw->wiphy->perm_addr);
814
815 data->debugfs = debugfs_create_dir("hwsim",
816 hw->wiphy->debugfsdir);
817 data->debugfs_ps = debugfs_create_file("ps", 0666,
818 data->debugfs, data,
819 &hwsim_fops_ps);
594 820
595 setup_timer(&data->beacon_timer, mac80211_hwsim_beacon, 821 setup_timer(&data->beacon_timer, mac80211_hwsim_beacon,
596 (unsigned long) hw); 822 (unsigned long) hw);
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index a670f36b5f3f..24caec6caf1f 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -737,7 +737,6 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
737 win_req_t req; 737 win_req_t req;
738 memreq_t mem; 738 memreq_t mem;
739 u_char __iomem *ramBase = NULL; 739 u_char __iomem *ramBase = NULL;
740 DECLARE_MAC_BUF(mac);
741 740
742 DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link); 741 DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link);
743 742
@@ -808,12 +807,12 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
808 dev->dev_addr[i] = readb(ramBase + NETWAVE_EREG_PA + i); 807 dev->dev_addr[i] = readb(ramBase + NETWAVE_EREG_PA + i);
809 808
810 printk(KERN_INFO "%s: Netwave: port %#3lx, irq %d, mem %lx, " 809 printk(KERN_INFO "%s: Netwave: port %#3lx, irq %d, mem %lx, "
811 "id %c%c, hw_addr %s\n", 810 "id %c%c, hw_addr %pM\n",
812 dev->name, dev->base_addr, dev->irq, 811 dev->name, dev->base_addr, dev->irq,
813 (u_long) ramBase, 812 (u_long) ramBase,
814 (int) readb(ramBase+NETWAVE_EREG_NI), 813 (int) readb(ramBase+NETWAVE_EREG_NI),
815 (int) readb(ramBase+NETWAVE_EREG_NI+1), 814 (int) readb(ramBase+NETWAVE_EREG_NI+1),
816 print_mac(mac, dev->dev_addr)); 815 dev->dev_addr);
817 816
818 /* get revision words */ 817 /* get revision words */
819 printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", 818 printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n",
@@ -1308,7 +1307,6 @@ static int netwave_rx(struct net_device *dev)
1308 /* Queue packet for network layer */ 1307 /* Queue packet for network layer */
1309 netif_rx(skb); 1308 netif_rx(skb);
1310 1309
1311 dev->last_rx = jiffies;
1312 priv->stats.rx_packets++; 1310 priv->stats.rx_packets++;
1313 priv->stats.rx_bytes += rcvLen; 1311 priv->stats.rx_bytes += rcvLen;
1314 1312
diff --git a/drivers/net/wireless/orinoco/Makefile b/drivers/net/wireless/orinoco/Makefile
new file mode 100644
index 000000000000..791366e08c50
--- /dev/null
+++ b/drivers/net/wireless/orinoco/Makefile
@@ -0,0 +1,12 @@
1#
2# Makefile for the orinoco wireless device drivers.
3#
4
5obj-$(CONFIG_HERMES) += orinoco.o hermes.o hermes_dld.o
6obj-$(CONFIG_PCMCIA_HERMES) += orinoco_cs.o
7obj-$(CONFIG_APPLE_AIRPORT) += airport.o
8obj-$(CONFIG_PLX_HERMES) += orinoco_plx.o
9obj-$(CONFIG_PCI_HERMES) += orinoco_pci.o
10obj-$(CONFIG_TMD_HERMES) += orinoco_tmd.o
11obj-$(CONFIG_NORTEL_HERMES) += orinoco_nortel.o
12obj-$(CONFIG_PCMCIA_SPECTRUM) += spectrum_cs.o
diff --git a/drivers/net/wireless/airport.c b/drivers/net/wireless/orinoco/airport.c
index ce03a2e865fa..ce03a2e865fa 100644
--- a/drivers/net/wireless/airport.c
+++ b/drivers/net/wireless/orinoco/airport.c
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/orinoco/hermes.c
index bfa375369df3..bfa375369df3 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/orinoco/hermes.c
diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/orinoco/hermes.h
index 8b13c8fef3dc..8b13c8fef3dc 100644
--- a/drivers/net/wireless/hermes.h
+++ b/drivers/net/wireless/orinoco/hermes.h
diff --git a/drivers/net/wireless/hermes_dld.c b/drivers/net/wireless/orinoco/hermes_dld.c
index d8c626e61a3a..d8c626e61a3a 100644
--- a/drivers/net/wireless/hermes_dld.c
+++ b/drivers/net/wireless/orinoco/hermes_dld.c
diff --git a/drivers/net/wireless/hermes_dld.h b/drivers/net/wireless/orinoco/hermes_dld.h
index 6fcb26277999..6fcb26277999 100644
--- a/drivers/net/wireless/hermes_dld.h
+++ b/drivers/net/wireless/orinoco/hermes_dld.h
diff --git a/drivers/net/wireless/hermes_rid.h b/drivers/net/wireless/orinoco/hermes_rid.h
index 42eb67dea1df..42eb67dea1df 100644
--- a/drivers/net/wireless/hermes_rid.h
+++ b/drivers/net/wireless/orinoco/hermes_rid.h
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco/orinoco.c
index e0512e49d6d3..072be44b37de 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco/orinoco.c
@@ -86,8 +86,8 @@
86#include <linux/firmware.h> 86#include <linux/firmware.h>
87#include <linux/if_arp.h> 87#include <linux/if_arp.h>
88#include <linux/wireless.h> 88#include <linux/wireless.h>
89#include <linux/ieee80211.h>
89#include <net/iw_handler.h> 90#include <net/iw_handler.h>
90#include <net/ieee80211.h>
91 91
92#include <linux/scatterlist.h> 92#include <linux/scatterlist.h>
93#include <linux/crypto.h> 93#include <linux/crypto.h>
@@ -143,7 +143,7 @@ static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
143#define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2) 143#define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
144 144
145#define ORINOCO_MIN_MTU 256 145#define ORINOCO_MIN_MTU 256
146#define ORINOCO_MAX_MTU (IEEE80211_DATA_LEN - ENCAPS_OVERHEAD) 146#define ORINOCO_MAX_MTU (IEEE80211_MAX_DATA_LEN - ENCAPS_OVERHEAD)
147 147
148#define SYMBOL_MAX_VER_LEN (14) 148#define SYMBOL_MAX_VER_LEN (14)
149#define USER_BAP 0 149#define USER_BAP 0
@@ -392,7 +392,7 @@ static void orinoco_bss_data_init(struct orinoco_private *priv)
392} 392}
393 393
394static inline u8 *orinoco_get_ie(u8 *data, size_t len, 394static inline u8 *orinoco_get_ie(u8 *data, size_t len,
395 enum ieee80211_mfie eid) 395 enum ieee80211_eid eid)
396{ 396{
397 u8 *p = data; 397 u8 *p = data;
398 while ((p + 2) < (data + len)) { 398 while ((p + 2) < (data + len)) {
@@ -409,7 +409,7 @@ static inline u8 *orinoco_get_wpa_ie(u8 *data, size_t len)
409{ 409{
410 u8 *p = data; 410 u8 *p = data;
411 while ((p + 2 + WPA_SELECTOR_LEN) < (data + len)) { 411 while ((p + 2 + WPA_SELECTOR_LEN) < (data + len)) {
412 if ((p[0] == MFIE_TYPE_GENERIC) && 412 if ((p[0] == WLAN_EID_GENERIC) &&
413 (memcmp(&p[2], WPA_OUI_TYPE, WPA_SELECTOR_LEN) == 0)) 413 (memcmp(&p[2], WPA_OUI_TYPE, WPA_SELECTOR_LEN) == 0))
414 return p; 414 return p;
415 p += p[1] + 2; 415 p += p[1] + 2;
@@ -487,12 +487,17 @@ orinoco_dl_firmware(struct orinoco_private *priv,
487 if (err) 487 if (err)
488 goto free; 488 goto free;
489 489
490 err = request_firmware(&fw_entry, firmware, priv->dev); 490 if (priv->cached_fw)
491 if (err) { 491 fw_entry = priv->cached_fw;
492 printk(KERN_ERR "%s: Cannot find firmware %s\n", 492 else {
493 dev->name, firmware); 493 err = request_firmware(&fw_entry, firmware, priv->dev);
494 err = -ENOENT; 494 if (err) {
495 goto free; 495 printk(KERN_ERR "%s: Cannot find firmware %s\n",
496 dev->name, firmware);
497 err = -ENOENT;
498 goto free;
499 }
500 priv->cached_fw = fw_entry;
496 } 501 }
497 502
498 hdr = (const struct orinoco_fw_header *) fw_entry->data; 503 hdr = (const struct orinoco_fw_header *) fw_entry->data;
@@ -535,7 +540,11 @@ orinoco_dl_firmware(struct orinoco_private *priv,
535 dev->name, hermes_present(hw)); 540 dev->name, hermes_present(hw));
536 541
537abort: 542abort:
538 release_firmware(fw_entry); 543 /* In case of error, assume firmware was bogus and release it */
544 if (err) {
545 priv->cached_fw = NULL;
546 release_firmware(fw_entry);
547 }
539 548
540free: 549free:
541 kfree(pda); 550 kfree(pda);
@@ -830,7 +839,8 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
830 if ( (new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU) ) 839 if ( (new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU) )
831 return -EINVAL; 840 return -EINVAL;
832 841
833 if ( (new_mtu + ENCAPS_OVERHEAD + IEEE80211_HLEN) > 842 /* MTU + encapsulation + header length */
843 if ( (new_mtu + ENCAPS_OVERHEAD + sizeof(struct ieee80211_hdr)) >
834 (priv->nicbuf_size - ETH_HLEN) ) 844 (priv->nicbuf_size - ETH_HLEN) )
835 return -EINVAL; 845 return -EINVAL;
836 846
@@ -1245,7 +1255,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
1245 } 1255 }
1246 1256
1247 /* sanity check the length */ 1257 /* sanity check the length */
1248 if (datalen > IEEE80211_DATA_LEN + 12) { 1258 if (datalen > IEEE80211_MAX_DATA_LEN + 12) {
1249 printk(KERN_DEBUG "%s: oversized monitor frame, " 1259 printk(KERN_DEBUG "%s: oversized monitor frame, "
1250 "data length = %d\n", dev->name, datalen); 1260 "data length = %d\n", dev->name, datalen);
1251 stats->rx_length_errors++; 1261 stats->rx_length_errors++;
@@ -1280,7 +1290,6 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
1280 skb->pkt_type = PACKET_OTHERHOST; 1290 skb->pkt_type = PACKET_OTHERHOST;
1281 skb->protocol = __constant_htons(ETH_P_802_2); 1291 skb->protocol = __constant_htons(ETH_P_802_2);
1282 1292
1283 dev->last_rx = jiffies;
1284 stats->rx_packets++; 1293 stats->rx_packets++;
1285 stats->rx_bytes += skb->len; 1294 stats->rx_bytes += skb->len;
1286 1295
@@ -1374,7 +1383,7 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
1374 data. */ 1383 data. */
1375 goto out; 1384 goto out;
1376 } 1385 }
1377 if (length > IEEE80211_DATA_LEN) { 1386 if (length > IEEE80211_MAX_DATA_LEN) {
1378 printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n", 1387 printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n",
1379 dev->name, length); 1388 dev->name, length);
1380 stats->rx_length_errors++; 1389 stats->rx_length_errors++;
@@ -1477,12 +1486,11 @@ static void orinoco_rx(struct net_device *dev,
1477 MICHAEL_MIC_LEN)) { 1486 MICHAEL_MIC_LEN)) {
1478 union iwreq_data wrqu; 1487 union iwreq_data wrqu;
1479 struct iw_michaelmicfailure wxmic; 1488 struct iw_michaelmicfailure wxmic;
1480 DECLARE_MAC_BUF(mac);
1481 1489
1482 printk(KERN_WARNING "%s: " 1490 printk(KERN_WARNING "%s: "
1483 "Invalid Michael MIC in data frame from %s, " 1491 "Invalid Michael MIC in data frame from %pM, "
1484 "using key %i\n", 1492 "using key %i\n",
1485 dev->name, print_mac(mac, src), key_id); 1493 dev->name, src, key_id);
1486 1494
1487 /* TODO: update stats */ 1495 /* TODO: update stats */
1488 1496
@@ -1530,7 +1538,6 @@ static void orinoco_rx(struct net_device *dev,
1530 else 1538 else
1531 memcpy(hdr->h_source, desc->addr2, ETH_ALEN); 1539 memcpy(hdr->h_source, desc->addr2, ETH_ALEN);
1532 1540
1533 dev->last_rx = jiffies;
1534 skb->protocol = eth_type_trans(skb, dev); 1541 skb->protocol = eth_type_trans(skb, dev);
1535 skb->ip_summed = CHECKSUM_NONE; 1542 skb->ip_summed = CHECKSUM_NONE;
1536 if (fc & IEEE80211_FCTL_TODS) 1543 if (fc & IEEE80211_FCTL_TODS)
@@ -2301,6 +2308,11 @@ int orinoco_reinit_firmware(struct net_device *dev)
2301 int err; 2308 int err;
2302 2309
2303 err = hermes_init(hw); 2310 err = hermes_init(hw);
2311 if (priv->do_fw_download && !err) {
2312 err = orinoco_download(priv);
2313 if (err)
2314 priv->do_fw_download = 0;
2315 }
2304 if (!err) 2316 if (!err)
2305 err = orinoco_allocate_fid(dev); 2317 err = orinoco_allocate_fid(dev);
2306 2318
@@ -2926,12 +2938,6 @@ static void orinoco_reset(struct work_struct *work)
2926 } 2938 }
2927 } 2939 }
2928 2940
2929 if (priv->do_fw_download) {
2930 err = orinoco_download(priv);
2931 if (err)
2932 priv->do_fw_download = 0;
2933 }
2934
2935 err = orinoco_reinit_firmware(dev); 2941 err = orinoco_reinit_firmware(dev);
2936 if (err) { 2942 if (err) {
2937 printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n", 2943 printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n",
@@ -3277,11 +3283,10 @@ static int orinoco_init(struct net_device *dev)
3277 struct hermes_idstring nickbuf; 3283 struct hermes_idstring nickbuf;
3278 u16 reclen; 3284 u16 reclen;
3279 int len; 3285 int len;
3280 DECLARE_MAC_BUF(mac);
3281 3286
3282 /* No need to lock, the hw_unavailable flag is already set in 3287 /* No need to lock, the hw_unavailable flag is already set in
3283 * alloc_orinocodev() */ 3288 * alloc_orinocodev() */
3284 priv->nicbuf_size = IEEE80211_FRAME_LEN + ETH_HLEN; 3289 priv->nicbuf_size = IEEE80211_MAX_FRAME_LEN + ETH_HLEN;
3285 3290
3286 /* Initialize the firmware */ 3291 /* Initialize the firmware */
3287 err = hermes_init(hw); 3292 err = hermes_init(hw);
@@ -3348,8 +3353,8 @@ static int orinoco_init(struct net_device *dev)
3348 goto out; 3353 goto out;
3349 } 3354 }
3350 3355
3351 printk(KERN_DEBUG "%s: MAC address %s\n", 3356 printk(KERN_DEBUG "%s: MAC address %pM\n",
3352 dev->name, print_mac(mac, dev->dev_addr)); 3357 dev->name, dev->dev_addr);
3353 3358
3354 /* Get the station name */ 3359 /* Get the station name */
3355 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, 3360 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
@@ -3535,6 +3540,8 @@ struct net_device
3535 netif_carrier_off(dev); 3540 netif_carrier_off(dev);
3536 priv->last_linkstatus = 0xffff; 3541 priv->last_linkstatus = 0xffff;
3537 3542
3543 priv->cached_fw = NULL;
3544
3538 return dev; 3545 return dev;
3539} 3546}
3540 3547
@@ -3546,6 +3553,9 @@ void free_orinocodev(struct net_device *dev)
3546 * when we call tasklet_kill it will run one final time, 3553 * when we call tasklet_kill it will run one final time,
3547 * emptying the list */ 3554 * emptying the list */
3548 tasklet_kill(&priv->rx_tasklet); 3555 tasklet_kill(&priv->rx_tasklet);
3556 if (priv->cached_fw)
3557 release_firmware(priv->cached_fw);
3558 priv->cached_fw = NULL;
3549 priv->wpa_ie_len = 0; 3559 priv->wpa_ie_len = 0;
3550 kfree(priv->wpa_ie); 3560 kfree(priv->wpa_ie);
3551 orinoco_mic_free(priv); 3561 orinoco_mic_free(priv);
@@ -4672,7 +4682,7 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev,
4672 /* Determine and validate the key index */ 4682 /* Determine and validate the key index */
4673 idx = encoding->flags & IW_ENCODE_INDEX; 4683 idx = encoding->flags & IW_ENCODE_INDEX;
4674 if (idx) { 4684 if (idx) {
4675 if ((idx < 1) || (idx > WEP_KEYS)) 4685 if ((idx < 1) || (idx > 4))
4676 goto out; 4686 goto out;
4677 idx--; 4687 idx--;
4678 } else 4688 } else
@@ -4777,7 +4787,7 @@ static int orinoco_ioctl_get_encodeext(struct net_device *dev,
4777 4787
4778 idx = encoding->flags & IW_ENCODE_INDEX; 4788 idx = encoding->flags & IW_ENCODE_INDEX;
4779 if (idx) { 4789 if (idx) {
4780 if ((idx < 1) || (idx > WEP_KEYS)) 4790 if ((idx < 1) || (idx > 4))
4781 goto out; 4791 goto out;
4782 idx--; 4792 idx--;
4783 } else 4793 } else
@@ -4940,7 +4950,8 @@ static int orinoco_ioctl_set_genie(struct net_device *dev,
4940 unsigned long flags; 4950 unsigned long flags;
4941 int err = 0; 4951 int err = 0;
4942 4952
4943 if ((wrqu->data.length > MAX_WPA_IE_LEN) || 4953 /* cut off at IEEE80211_MAX_DATA_LEN */
4954 if ((wrqu->data.length > IEEE80211_MAX_DATA_LEN) ||
4944 (wrqu->data.length && (extra == NULL))) 4955 (wrqu->data.length && (extra == NULL)))
4945 return -EINVAL; 4956 return -EINVAL;
4946 4957
@@ -5623,7 +5634,7 @@ static inline char *orinoco_translate_ext_scan(struct net_device *dev,
5623 &iwe, IW_EV_UINT_LEN); 5634 &iwe, IW_EV_UINT_LEN);
5624 } 5635 }
5625 5636
5626 ie = orinoco_get_ie(bss->data, sizeof(bss->data), MFIE_TYPE_DS_SET); 5637 ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_DS_PARAMS);
5627 channel = ie ? ie[2] : 0; 5638 channel = ie ? ie[2] : 0;
5628 if ((channel >= 1) && (channel <= NUM_CHANNELS)) { 5639 if ((channel >= 1) && (channel <= NUM_CHANNELS)) {
5629 /* Add channel and frequency */ 5640 /* Add channel and frequency */
@@ -5673,7 +5684,7 @@ static inline char *orinoco_translate_ext_scan(struct net_device *dev,
5673 } 5684 }
5674 5685
5675 /* RSN IE */ 5686 /* RSN IE */
5676 ie = orinoco_get_ie(bss->data, sizeof(bss->data), MFIE_TYPE_RSN); 5687 ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_RSN);
5677 if (ie) { 5688 if (ie) {
5678 iwe.cmd = IWEVGENIE; 5689 iwe.cmd = IWEVGENIE;
5679 iwe.u.data.length = ie[1] + 2; 5690 iwe.u.data.length = ie[1] + 2;
@@ -5681,7 +5692,7 @@ static inline char *orinoco_translate_ext_scan(struct net_device *dev,
5681 &iwe, ie); 5692 &iwe, ie);
5682 } 5693 }
5683 5694
5684 ie = orinoco_get_ie(bss->data, sizeof(bss->data), MFIE_TYPE_RATES); 5695 ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_SUPP_RATES);
5685 if (ie) { 5696 if (ie) {
5686 char *p = current_ev + iwe_stream_lcp_len(info); 5697 char *p = current_ev + iwe_stream_lcp_len(info);
5687 int i; 5698 int i;
@@ -5976,7 +5987,7 @@ static void orinoco_get_drvinfo(struct net_device *dev,
5976 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); 5987 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
5977 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1); 5988 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1);
5978 if (dev->dev.parent) 5989 if (dev->dev.parent)
5979 strncpy(info->bus_info, dev->dev.parent->bus_id, 5990 strncpy(info->bus_info, dev_name(dev->dev.parent),
5980 sizeof(info->bus_info) - 1); 5991 sizeof(info->bus_info) - 1);
5981 else 5992 else
5982 snprintf(info->bus_info, sizeof(info->bus_info) - 1, 5993 snprintf(info->bus_info, sizeof(info->bus_info) - 1,
diff --git a/drivers/net/wireless/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index 981570bd3b9d..8c2953834923 100644
--- a/drivers/net/wireless/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -66,6 +66,8 @@ struct orinoco_rx_data {
66 struct list_head list; 66 struct list_head list;
67}; 67};
68 68
69struct firmware;
70
69struct orinoco_private { 71struct orinoco_private {
70 void *card; /* Pointer to card dependent structure */ 72 void *card; /* Pointer to card dependent structure */
71 struct device *dev; 73 struct device *dev;
@@ -164,6 +166,9 @@ struct orinoco_private {
164 unsigned int wpa_enabled:1; 166 unsigned int wpa_enabled:1;
165 unsigned int tkip_cm_active:1; 167 unsigned int tkip_cm_active:1;
166 unsigned int key_mgmt:3; 168 unsigned int key_mgmt:3;
169
170 /* Cached in memory firmware to use in ->resume */
171 const struct firmware *cached_fw;
167}; 172};
168 173
169#ifdef ORINOCO_DEBUG 174#ifdef ORINOCO_DEBUG
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index 6fcf2bda7cdf..bf6a51da3b29 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -308,7 +308,7 @@ orinoco_cs_config(struct pcmcia_device *link)
308 308
309 /* Finally, report what we've done */ 309 /* Finally, report what we've done */
310 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 310 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
311 "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, 311 "0x%04x-0x%04x\n", dev->name, dev_name(dev->dev.parent),
312 link->irq.AssignedIRQ, link->io.BasePort1, 312 link->irq.AssignedIRQ, link->io.BasePort1,
313 link->io.BasePort1 + link->io.NumPorts1 - 1); 313 link->io.BasePort1 + link->io.NumPorts1 - 1);
314 return 0; 314 return 0;
diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index 2fc86596302e..2fc86596302e 100644
--- a/drivers/net/wireless/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
diff --git a/drivers/net/wireless/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index 4ebd638a073e..4ebd638a073e 100644
--- a/drivers/net/wireless/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
diff --git a/drivers/net/wireless/orinoco_pci.h b/drivers/net/wireless/orinoco/orinoco_pci.h
index f4e5e06760c1..f4e5e06760c1 100644
--- a/drivers/net/wireless/orinoco_pci.h
+++ b/drivers/net/wireless/orinoco/orinoco_pci.h
diff --git a/drivers/net/wireless/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index ef761857bb38..ef761857bb38 100644
--- a/drivers/net/wireless/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
diff --git a/drivers/net/wireless/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index ede24ec309c0..ede24ec309c0 100644
--- a/drivers/net/wireless/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 852789ad34b3..0bae3dcf9d50 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -383,7 +383,7 @@ spectrum_cs_config(struct pcmcia_device *link)
383 383
384 /* Finally, report what we've done */ 384 /* Finally, report what we've done */
385 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 385 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
386 "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, 386 "0x%04x-0x%04x\n", dev->name, dev_name(dev->dev.parent),
387 link->irq.AssignedIRQ, link->io.BasePort1, 387 link->irq.AssignedIRQ, link->io.BasePort1,
388 link->io.BasePort1 + link->io.NumPorts1 - 1); 388 link->io.BasePort1 + link->io.NumPorts1 - 1);
389 389
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
index 1d0704fe146f..b585ff65e0e4 100644
--- a/drivers/net/wireless/p54/p54.h
+++ b/drivers/net/wireless/p54/p54.h
@@ -14,17 +14,17 @@
14 * published by the Free Software Foundation. 14 * published by the Free Software Foundation.
15 */ 15 */
16 16
17enum control_frame_types { 17enum p54_control_frame_types {
18 P54_CONTROL_TYPE_FILTER_SET = 0, 18 P54_CONTROL_TYPE_SETUP = 0,
19 P54_CONTROL_TYPE_CHANNEL_CHANGE, 19 P54_CONTROL_TYPE_SCAN,
20 P54_CONTROL_TYPE_FREQDONE, 20 P54_CONTROL_TYPE_TRAP,
21 P54_CONTROL_TYPE_DCFINIT, 21 P54_CONTROL_TYPE_DCFINIT,
22 P54_CONTROL_TYPE_ENCRYPTION, 22 P54_CONTROL_TYPE_RX_KEYCACHE,
23 P54_CONTROL_TYPE_TIM, 23 P54_CONTROL_TYPE_TIM,
24 P54_CONTROL_TYPE_POWERMGT, 24 P54_CONTROL_TYPE_PSM,
25 P54_CONTROL_TYPE_FREEQUEUE, 25 P54_CONTROL_TYPE_TXCANCEL,
26 P54_CONTROL_TYPE_TXDONE, 26 P54_CONTROL_TYPE_TXDONE,
27 P54_CONTROL_TYPE_PING, 27 P54_CONTROL_TYPE_BURST,
28 P54_CONTROL_TYPE_STAT_READBACK, 28 P54_CONTROL_TYPE_STAT_READBACK,
29 P54_CONTROL_TYPE_BBP, 29 P54_CONTROL_TYPE_BBP,
30 P54_CONTROL_TYPE_EEPROM_READBACK, 30 P54_CONTROL_TYPE_EEPROM_READBACK,
@@ -37,18 +37,30 @@ enum control_frame_types {
37 P54_CONTROL_TYPE_XBOW_SYNTH_CFG, 37 P54_CONTROL_TYPE_XBOW_SYNTH_CFG,
38 P54_CONTROL_TYPE_CCE_QUIET, 38 P54_CONTROL_TYPE_CCE_QUIET,
39 P54_CONTROL_TYPE_PSM_STA_UNLOCK, 39 P54_CONTROL_TYPE_PSM_STA_UNLOCK,
40 P54_CONTROL_TYPE_PCS,
41 P54_CONTROL_TYPE_BT_BALANCER = 28,
42 P54_CONTROL_TYPE_GROUP_ADDRESS_TABLE = 30,
43 P54_CONTROL_TYPE_ARPTABLE = 31,
44 P54_CONTROL_TYPE_BT_OPTIONS = 35
40}; 45};
41 46
42struct p54_control_hdr { 47struct p54_hdr {
43 __le16 magic1; 48 __le16 flags;
44 __le16 len; 49 __le16 len;
45 __le32 req_id; 50 __le32 req_id;
46 __le16 type; /* enum control_frame_types */ 51 __le16 type; /* enum p54_control_frame_types */
47 u8 retry1; 52 u8 rts_tries;
48 u8 retry2; 53 u8 tries;
49 u8 data[0]; 54 u8 data[0];
50} __attribute__ ((packed)); 55} __attribute__ ((packed));
51 56
57struct p54_edcf_queue_param {
58 __le16 aifs;
59 __le16 cwmin;
60 __le16 cwmax;
61 __le16 txop;
62} __attribute__ ((packed));
63
52#define EEPROM_READBACK_LEN 0x3fc 64#define EEPROM_READBACK_LEN 0x3fc
53 65
54#define ISL38XX_DEV_FIRMWARE_ADDR 0x20000 66#define ISL38XX_DEV_FIRMWARE_ADDR 0x20000
@@ -62,46 +74,48 @@ struct p54_common {
62 u32 rx_start; 74 u32 rx_start;
63 u32 rx_end; 75 u32 rx_end;
64 struct sk_buff_head tx_queue; 76 struct sk_buff_head tx_queue;
65 void (*tx)(struct ieee80211_hw *dev, struct p54_control_hdr *data, 77 void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb,
66 size_t len, int free_on_tx); 78 int free_on_tx);
67 int (*open)(struct ieee80211_hw *dev); 79 int (*open)(struct ieee80211_hw *dev);
68 void (*stop)(struct ieee80211_hw *dev); 80 void (*stop)(struct ieee80211_hw *dev);
69 int mode; 81 int mode;
70 u16 seqno;
71 u16 rx_mtu; 82 u16 rx_mtu;
72 u8 headroom; 83 u8 headroom;
73 u8 tailroom; 84 u8 tailroom;
74 struct mutex conf_mutex; 85 struct mutex conf_mutex;
75 u8 mac_addr[ETH_ALEN]; 86 u8 mac_addr[ETH_ALEN];
76 u8 bssid[ETH_ALEN]; 87 u8 bssid[ETH_ALEN];
77 __le16 filter_type; 88 u16 mac_mode;
78 struct pda_iq_autocal_entry *iq_autocal; 89 struct pda_iq_autocal_entry *iq_autocal;
79 unsigned int iq_autocal_len; 90 unsigned int iq_autocal_len;
80 struct pda_channel_output_limit *output_limit; 91 struct pda_channel_output_limit *output_limit;
81 unsigned int output_limit_len; 92 unsigned int output_limit_len;
82 struct pda_pa_curve_data *curve_data; 93 struct pda_pa_curve_data *curve_data;
83 unsigned int filter_flags; 94 unsigned int filter_flags;
95 bool use_short_slot;
84 u16 rxhw; 96 u16 rxhw;
85 u8 version; 97 u8 version;
86 u8 rx_antenna; 98 u8 rx_antenna;
87 unsigned int tx_hdr_len; 99 unsigned int tx_hdr_len;
88 void *cached_vdcf;
89 unsigned int fw_var; 100 unsigned int fw_var;
90 unsigned int fw_interface; 101 unsigned int fw_interface;
91 unsigned int output_power; 102 unsigned int output_power;
92 u32 tsf_low32; 103 u32 tsf_low32;
93 u32 tsf_high32; 104 u32 tsf_high32;
94 struct ieee80211_tx_queue_stats tx_stats[8]; 105 struct ieee80211_tx_queue_stats tx_stats[8];
106 struct p54_edcf_queue_param qos_params[8];
95 struct ieee80211_low_level_stats stats; 107 struct ieee80211_low_level_stats stats;
96 struct timer_list stats_timer; 108 struct timer_list stats_timer;
97 struct completion stats_comp; 109 struct completion stats_comp;
98 void *cached_stats; 110 struct sk_buff *cached_stats;
111 struct sk_buff *cached_beacon;
99 int noise; 112 int noise;
100 void *eeprom; 113 void *eeprom;
101 struct completion eeprom_comp; 114 struct completion eeprom_comp;
102}; 115};
103 116
104int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb); 117int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb);
118void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb);
105int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw); 119int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw);
106int p54_read_eeprom(struct ieee80211_hw *dev); 120int p54_read_eeprom(struct ieee80211_hw *dev);
107struct ieee80211_hw *p54_init_common(size_t priv_data_len); 121struct ieee80211_hw *p54_init_common(size_t priv_data_len);
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 827ca0384a4c..1796b8c6c5b8 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -1,12 +1,15 @@
1
2/* 1/*
3 * Common code for mac80211 Prism54 drivers 2 * Common code for mac80211 Prism54 drivers
4 * 3 *
5 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> 4 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
6 * Copyright (c) 2007, Christian Lamparter <chunkeey@web.de> 5 * Copyright (c) 2007, Christian Lamparter <chunkeey@web.de>
6 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
7 * 7 *
8 * Based on the islsm (softmac prism54) driver, which is: 8 * Based on:
9 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. 9 * - the islsm (softmac prism54) driver, which is:
10 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
11 * - stlc45xx driver
12 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
10 * 13 *
11 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 15 * it under the terms of the GNU General Public License version 2 as
@@ -183,7 +186,7 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
183 priv->headroom = desc->headroom; 186 priv->headroom = desc->headroom;
184 priv->tailroom = desc->tailroom; 187 priv->tailroom = desc->tailroom;
185 if (le32_to_cpu(bootrec->len) == 11) 188 if (le32_to_cpu(bootrec->len) == 11)
186 priv->rx_mtu = le16_to_cpu(bootrec->rx_mtu); 189 priv->rx_mtu = le16_to_cpu(desc->rx_mtu);
187 else 190 else
188 priv->rx_mtu = (size_t) 191 priv->rx_mtu = (size_t)
189 0x620 - priv->tx_hdr_len; 192 0x620 - priv->tx_hdr_len;
@@ -211,12 +214,17 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
211 printk(KERN_INFO "p54: FW rev %s - Softmac protocol %x.%x\n", 214 printk(KERN_INFO "p54: FW rev %s - Softmac protocol %x.%x\n",
212 fw_version, priv->fw_var >> 8, priv->fw_var & 0xff); 215 fw_version, priv->fw_var >> 8, priv->fw_var & 0xff);
213 216
217 if (priv->fw_var < 0x500)
218 printk(KERN_INFO "p54: you are using an obsolete firmware. "
219 "visit http://wireless.kernel.org/en/users/Drivers/p54 "
220 "and grab one for \"kernel >= 2.6.28\"!\n");
221
214 if (priv->fw_var >= 0x300) { 222 if (priv->fw_var >= 0x300) {
215 /* Firmware supports QoS, use it! */ 223 /* Firmware supports QoS, use it! */
216 priv->tx_stats[4].limit = 3; 224 priv->tx_stats[4].limit = 3; /* AC_VO */
217 priv->tx_stats[5].limit = 4; 225 priv->tx_stats[5].limit = 4; /* AC_VI */
218 priv->tx_stats[6].limit = 3; 226 priv->tx_stats[6].limit = 3; /* AC_BE */
219 priv->tx_stats[7].limit = 1; 227 priv->tx_stats[7].limit = 2; /* AC_BK */
220 dev->queues = 4; 228 dev->queues = 4;
221 } 229 }
222 230
@@ -320,7 +328,6 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
320 int err; 328 int err;
321 u8 *end = (u8 *)eeprom + len; 329 u8 *end = (u8 *)eeprom + len;
322 u16 synth = 0; 330 u16 synth = 0;
323 DECLARE_MAC_BUF(mac);
324 331
325 wrap = (struct eeprom_pda_wrap *) eeprom; 332 wrap = (struct eeprom_pda_wrap *) eeprom;
326 entry = (void *)wrap->data + le16_to_cpu(wrap->len); 333 entry = (void *)wrap->data + le16_to_cpu(wrap->len);
@@ -413,6 +420,30 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
413 /* make it overrun */ 420 /* make it overrun */
414 entry_len = len; 421 entry_len = len;
415 break; 422 break;
423 case PDR_MANUFACTURING_PART_NUMBER:
424 case PDR_PDA_VERSION:
425 case PDR_NIC_SERIAL_NUMBER:
426 case PDR_REGULATORY_DOMAIN_LIST:
427 case PDR_TEMPERATURE_TYPE:
428 case PDR_PRISM_PCI_IDENTIFIER:
429 case PDR_COUNTRY_INFORMATION:
430 case PDR_OEM_NAME:
431 case PDR_PRODUCT_NAME:
432 case PDR_UTF8_OEM_NAME:
433 case PDR_UTF8_PRODUCT_NAME:
434 case PDR_COUNTRY_LIST:
435 case PDR_DEFAULT_COUNTRY:
436 case PDR_ANTENNA_GAIN:
437 case PDR_PRISM_INDIGO_PA_CALIBRATION_DATA:
438 case PDR_RSSI_LINEAR_APPROXIMATION:
439 case PDR_RSSI_LINEAR_APPROXIMATION_DUAL_BAND:
440 case PDR_REGULATORY_POWER_LIMITS:
441 case PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED:
442 case PDR_RADIATED_TRANSMISSION_CORRECTION:
443 case PDR_PRISM_TX_IQ_CALIBRATION:
444 case PDR_BASEBAND_REGISTERS:
445 case PDR_PER_CHANNEL_BASEBAND_REGISTERS:
446 break;
416 default: 447 default:
417 printk(KERN_INFO "p54: unknown eeprom code : 0x%x\n", 448 printk(KERN_INFO "p54: unknown eeprom code : 0x%x\n",
418 le16_to_cpu(entry->code)); 449 le16_to_cpu(entry->code));
@@ -429,12 +460,12 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
429 goto err; 460 goto err;
430 } 461 }
431 462
432 priv->rxhw = synth & 0x07; 463 priv->rxhw = synth & PDR_SYNTH_FRONTEND_MASK;
433 if (priv->rxhw == 4) 464 if (priv->rxhw == 4)
434 p54_init_xbow_synth(dev); 465 p54_init_xbow_synth(dev);
435 if (!(synth & 0x40)) 466 if (!(synth & PDR_SYNTH_24_GHZ_DISABLED))
436 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz; 467 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz;
437 if (!(synth & 0x80)) 468 if (!(synth & PDR_SYNTH_5_GHZ_DISABLED))
438 dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz; 469 dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz;
439 470
440 if (!is_valid_ether_addr(dev->wiphy->perm_addr)) { 471 if (!is_valid_ether_addr(dev->wiphy->perm_addr)) {
@@ -446,9 +477,9 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
446 SET_IEEE80211_PERM_ADDR(dev, perm_addr); 477 SET_IEEE80211_PERM_ADDR(dev, perm_addr);
447 } 478 }
448 479
449 printk(KERN_INFO "%s: hwaddr %s, MAC:isl38%02x RF:%s\n", 480 printk(KERN_INFO "%s: hwaddr %pM, MAC:isl38%02x RF:%s\n",
450 wiphy_name(dev->wiphy), 481 wiphy_name(dev->wiphy),
451 print_mac(mac, dev->wiphy->perm_addr), 482 dev->wiphy->perm_addr,
452 priv->version, p54_rf_chips[priv->rxhw]); 483 priv->version, p54_rf_chips[priv->rxhw]);
453 484
454 return 0; 485 return 0;
@@ -482,13 +513,13 @@ static int p54_rssi_to_dbm(struct ieee80211_hw *dev, int rssi)
482static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb) 513static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
483{ 514{
484 struct p54_common *priv = dev->priv; 515 struct p54_common *priv = dev->priv;
485 struct p54_rx_hdr *hdr = (struct p54_rx_hdr *) skb->data; 516 struct p54_rx_data *hdr = (struct p54_rx_data *) skb->data;
486 struct ieee80211_rx_status rx_status = {0}; 517 struct ieee80211_rx_status rx_status = {0};
487 u16 freq = le16_to_cpu(hdr->freq); 518 u16 freq = le16_to_cpu(hdr->freq);
488 size_t header_len = sizeof(*hdr); 519 size_t header_len = sizeof(*hdr);
489 u32 tsf32; 520 u32 tsf32;
490 521
491 if (!(hdr->magic & cpu_to_le16(0x0001))) { 522 if (!(hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_IN_FCS_GOOD))) {
492 if (priv->filter_flags & FIF_FCSFAIL) 523 if (priv->filter_flags & FIF_FCSFAIL)
493 rx_status.flag |= RX_FLAG_FAILED_FCS_CRC; 524 rx_status.flag |= RX_FLAG_FAILED_FCS_CRC;
494 else 525 else
@@ -513,7 +544,7 @@ static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
513 544
514 rx_status.flag |= RX_FLAG_TSFT; 545 rx_status.flag |= RX_FLAG_TSFT;
515 546
516 if (hdr->magic & cpu_to_le16(0x4000)) 547 if (hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN))
517 header_len += hdr->align[0]; 548 header_len += hdr->align[0];
518 549
519 skb_pull(skb, header_len); 550 skb_pull(skb, header_len);
@@ -529,81 +560,155 @@ static void inline p54_wake_free_queues(struct ieee80211_hw *dev)
529 struct p54_common *priv = dev->priv; 560 struct p54_common *priv = dev->priv;
530 int i; 561 int i;
531 562
563 if (priv->mode == NL80211_IFTYPE_UNSPECIFIED)
564 return ;
565
532 for (i = 0; i < dev->queues; i++) 566 for (i = 0; i < dev->queues; i++)
533 if (priv->tx_stats[i + 4].len < priv->tx_stats[i + 4].limit) 567 if (priv->tx_stats[i + 4].len < priv->tx_stats[i + 4].limit)
534 ieee80211_wake_queue(dev, i); 568 ieee80211_wake_queue(dev, i);
535} 569}
536 570
571void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
572{
573 struct p54_common *priv = dev->priv;
574 struct ieee80211_tx_info *info;
575 struct memrecord *range;
576 unsigned long flags;
577 u32 freed = 0, last_addr = priv->rx_start;
578
579 if (!skb || !dev)
580 return;
581
582 spin_lock_irqsave(&priv->tx_queue.lock, flags);
583 info = IEEE80211_SKB_CB(skb);
584 range = (void *)info->rate_driver_data;
585 if (skb->prev != (struct sk_buff *)&priv->tx_queue) {
586 struct ieee80211_tx_info *ni;
587 struct memrecord *mr;
588
589 ni = IEEE80211_SKB_CB(skb->prev);
590 mr = (struct memrecord *)ni->rate_driver_data;
591 last_addr = mr->end_addr;
592 }
593 if (skb->next != (struct sk_buff *)&priv->tx_queue) {
594 struct ieee80211_tx_info *ni;
595 struct memrecord *mr;
596
597 ni = IEEE80211_SKB_CB(skb->next);
598 mr = (struct memrecord *)ni->rate_driver_data;
599 freed = mr->start_addr - last_addr;
600 } else
601 freed = priv->rx_end - last_addr;
602 __skb_unlink(skb, &priv->tx_queue);
603 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
604 kfree_skb(skb);
605
606 if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 +
607 IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
608 p54_wake_free_queues(dev);
609}
610EXPORT_SYMBOL_GPL(p54_free_skb);
611
537static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb) 612static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
538{ 613{
539 struct p54_common *priv = dev->priv; 614 struct p54_common *priv = dev->priv;
540 struct p54_control_hdr *hdr = (struct p54_control_hdr *) skb->data; 615 struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
541 struct p54_frame_sent_hdr *payload = (struct p54_frame_sent_hdr *) hdr->data; 616 struct p54_frame_sent *payload = (struct p54_frame_sent *) hdr->data;
542 struct sk_buff *entry = (struct sk_buff *) priv->tx_queue.next; 617 struct sk_buff *entry = (struct sk_buff *) priv->tx_queue.next;
543 u32 addr = le32_to_cpu(hdr->req_id) - priv->headroom; 618 u32 addr = le32_to_cpu(hdr->req_id) - priv->headroom;
544 struct memrecord *range = NULL; 619 struct memrecord *range = NULL;
545 u32 freed = 0; 620 u32 freed = 0;
546 u32 last_addr = priv->rx_start; 621 u32 last_addr = priv->rx_start;
547 unsigned long flags; 622 unsigned long flags;
623 int count, idx;
548 624
549 spin_lock_irqsave(&priv->tx_queue.lock, flags); 625 spin_lock_irqsave(&priv->tx_queue.lock, flags);
550 while (entry != (struct sk_buff *)&priv->tx_queue) { 626 while (entry != (struct sk_buff *)&priv->tx_queue) {
551 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); 627 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry);
552 range = (void *)info->driver_data; 628 struct p54_hdr *entry_hdr;
553 if (range->start_addr == addr) { 629 struct p54_tx_data *entry_data;
554 struct p54_control_hdr *entry_hdr; 630 int pad = 0;
555 struct p54_tx_control_allocdata *entry_data;
556 int pad = 0;
557
558 if (entry->next != (struct sk_buff *)&priv->tx_queue) {
559 struct ieee80211_tx_info *ni;
560 struct memrecord *mr;
561
562 ni = IEEE80211_SKB_CB(entry->next);
563 mr = (struct memrecord *)ni->driver_data;
564 freed = mr->start_addr - last_addr;
565 } else
566 freed = priv->rx_end - last_addr;
567 631
632 range = (void *)info->rate_driver_data;
633 if (range->start_addr != addr) {
568 last_addr = range->end_addr; 634 last_addr = range->end_addr;
569 __skb_unlink(entry, &priv->tx_queue); 635 entry = entry->next;
570 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 636 continue;
571 637 }
572 memset(&info->status, 0, sizeof(info->status)); 638
573 entry_hdr = (struct p54_control_hdr *) entry->data; 639 if (entry->next != (struct sk_buff *)&priv->tx_queue) {
574 entry_data = (struct p54_tx_control_allocdata *) entry_hdr->data; 640 struct ieee80211_tx_info *ni;
575 if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) != 0) 641 struct memrecord *mr;
576 pad = entry_data->align[0]; 642
577 643 ni = IEEE80211_SKB_CB(entry->next);
578 priv->tx_stats[entry_data->hw_queue].len--; 644 mr = (struct memrecord *)ni->rate_driver_data;
579 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { 645 freed = mr->start_addr - last_addr;
580 if (!(payload->status & 0x01))
581 info->flags |= IEEE80211_TX_STAT_ACK;
582 else
583 info->status.excessive_retries = 1;
584 }
585 info->status.retry_count = payload->retries - 1;
586 info->status.ack_signal = p54_rssi_to_dbm(dev,
587 le16_to_cpu(payload->ack_rssi));
588 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data));
589 ieee80211_tx_status_irqsafe(dev, entry);
590 goto out;
591 } else 646 } else
592 last_addr = range->end_addr; 647 freed = priv->rx_end - last_addr;
593 entry = entry->next; 648
649 last_addr = range->end_addr;
650 __skb_unlink(entry, &priv->tx_queue);
651 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
652
653 if (unlikely(entry == priv->cached_beacon)) {
654 kfree_skb(entry);
655 priv->cached_beacon = NULL;
656 goto out;
657 }
658
659 /*
660 * Clear manually, ieee80211_tx_info_clear_status would
661 * clear the counts too and we need them.
662 */
663 memset(&info->status.ampdu_ack_len, 0,
664 sizeof(struct ieee80211_tx_info) -
665 offsetof(struct ieee80211_tx_info, status.ampdu_ack_len));
666 BUILD_BUG_ON(offsetof(struct ieee80211_tx_info,
667 status.ampdu_ack_len) != 23);
668
669 entry_hdr = (struct p54_hdr *) entry->data;
670 entry_data = (struct p54_tx_data *) entry_hdr->data;
671 if (entry_hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN))
672 pad = entry_data->align[0];
673
674 /* walk through the rates array and adjust the counts */
675 count = payload->tries;
676 for (idx = 0; idx < 4; idx++) {
677 if (count >= info->status.rates[idx].count) {
678 count -= info->status.rates[idx].count;
679 } else if (count > 0) {
680 info->status.rates[idx].count = count;
681 count = 0;
682 } else {
683 info->status.rates[idx].idx = -1;
684 info->status.rates[idx].count = 0;
685 }
686 }
687
688 priv->tx_stats[entry_data->hw_queue].len--;
689 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) &&
690 (!payload->status))
691 info->flags |= IEEE80211_TX_STAT_ACK;
692 if (payload->status & P54_TX_PSM_CANCELLED)
693 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
694 info->status.ack_signal = p54_rssi_to_dbm(dev,
695 (int)payload->ack_rssi);
696 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data));
697 ieee80211_tx_status_irqsafe(dev, entry);
698 goto out;
594 } 699 }
595 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 700 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
596 701
597out: 702out:
598 if (freed >= IEEE80211_MAX_RTS_THRESHOLD + 0x170 + 703 if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 +
599 sizeof(struct p54_control_hdr)) 704 IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
600 p54_wake_free_queues(dev); 705 p54_wake_free_queues(dev);
601} 706}
602 707
603static void p54_rx_eeprom_readback(struct ieee80211_hw *dev, 708static void p54_rx_eeprom_readback(struct ieee80211_hw *dev,
604 struct sk_buff *skb) 709 struct sk_buff *skb)
605{ 710{
606 struct p54_control_hdr *hdr = (struct p54_control_hdr *) skb->data; 711 struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
607 struct p54_eeprom_lm86 *eeprom = (struct p54_eeprom_lm86 *) hdr->data; 712 struct p54_eeprom_lm86 *eeprom = (struct p54_eeprom_lm86 *) hdr->data;
608 struct p54_common *priv = dev->priv; 713 struct p54_common *priv = dev->priv;
609 714
@@ -618,7 +723,7 @@ static void p54_rx_eeprom_readback(struct ieee80211_hw *dev,
618static void p54_rx_stats(struct ieee80211_hw *dev, struct sk_buff *skb) 723static void p54_rx_stats(struct ieee80211_hw *dev, struct sk_buff *skb)
619{ 724{
620 struct p54_common *priv = dev->priv; 725 struct p54_common *priv = dev->priv;
621 struct p54_control_hdr *hdr = (struct p54_control_hdr *) skb->data; 726 struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
622 struct p54_statistics *stats = (struct p54_statistics *) hdr->data; 727 struct p54_statistics *stats = (struct p54_statistics *) hdr->data;
623 u32 tsf32 = le32_to_cpu(stats->tsf32); 728 u32 tsf32 = le32_to_cpu(stats->tsf32);
624 729
@@ -636,14 +741,46 @@ static void p54_rx_stats(struct ieee80211_hw *dev, struct sk_buff *skb)
636 mod_timer(&priv->stats_timer, jiffies + 5 * HZ); 741 mod_timer(&priv->stats_timer, jiffies + 5 * HZ);
637} 742}
638 743
744static void p54_rx_trap(struct ieee80211_hw *dev, struct sk_buff *skb)
745{
746 struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
747 struct p54_trap *trap = (struct p54_trap *) hdr->data;
748 u16 event = le16_to_cpu(trap->event);
749 u16 freq = le16_to_cpu(trap->frequency);
750
751 switch (event) {
752 case P54_TRAP_BEACON_TX:
753 break;
754 case P54_TRAP_RADAR:
755 printk(KERN_INFO "%s: radar (freq:%d MHz)\n",
756 wiphy_name(dev->wiphy), freq);
757 break;
758 case P54_TRAP_NO_BEACON:
759 break;
760 case P54_TRAP_SCAN:
761 break;
762 case P54_TRAP_TBTT:
763 break;
764 case P54_TRAP_TIMER:
765 break;
766 default:
767 printk(KERN_INFO "%s: received event:%x freq:%d\n",
768 wiphy_name(dev->wiphy), event, freq);
769 break;
770 }
771}
772
639static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb) 773static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb)
640{ 774{
641 struct p54_control_hdr *hdr = (struct p54_control_hdr *) skb->data; 775 struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
642 776
643 switch (le16_to_cpu(hdr->type)) { 777 switch (le16_to_cpu(hdr->type)) {
644 case P54_CONTROL_TYPE_TXDONE: 778 case P54_CONTROL_TYPE_TXDONE:
645 p54_rx_frame_sent(dev, skb); 779 p54_rx_frame_sent(dev, skb);
646 break; 780 break;
781 case P54_CONTROL_TYPE_TRAP:
782 p54_rx_trap(dev, skb);
783 break;
647 case P54_CONTROL_TYPE_BBP: 784 case P54_CONTROL_TYPE_BBP:
648 break; 785 break;
649 case P54_CONTROL_TYPE_STAT_READBACK: 786 case P54_CONTROL_TYPE_STAT_READBACK:
@@ -664,9 +801,9 @@ static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb)
664/* returns zero if skb can be reused */ 801/* returns zero if skb can be reused */
665int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb) 802int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
666{ 803{
667 u8 type = le16_to_cpu(*((__le16 *)skb->data)) >> 8; 804 u16 type = le16_to_cpu(*((__le16 *)skb->data));
668 805
669 if (type == 0x80) 806 if (type & P54_HDR_FLAG_CONTROL)
670 return p54_rx_control(dev, skb); 807 return p54_rx_control(dev, skb);
671 else 808 else
672 return p54_rx_data(dev, skb); 809 return p54_rx_data(dev, skb);
@@ -682,12 +819,14 @@ EXPORT_SYMBOL_GPL(p54_rx);
682 * marks allocated areas as reserved if necessary. p54_rx_frame_sent frees 819 * marks allocated areas as reserved if necessary. p54_rx_frame_sent frees
683 * allocated areas. 820 * allocated areas.
684 */ 821 */
685static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb, 822static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
686 struct p54_control_hdr *data, u32 len) 823 struct p54_hdr *data, u32 len)
687{ 824{
688 struct p54_common *priv = dev->priv; 825 struct p54_common *priv = dev->priv;
689 struct sk_buff *entry = priv->tx_queue.next; 826 struct sk_buff *entry = priv->tx_queue.next;
690 struct sk_buff *target_skb = NULL; 827 struct sk_buff *target_skb = NULL;
828 struct ieee80211_tx_info *info;
829 struct memrecord *range;
691 u32 last_addr = priv->rx_start; 830 u32 last_addr = priv->rx_start;
692 u32 largest_hole = 0; 831 u32 largest_hole = 0;
693 u32 target_addr = priv->rx_start; 832 u32 target_addr = priv->rx_start;
@@ -695,12 +834,15 @@ static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
695 unsigned int left; 834 unsigned int left;
696 len = (len + priv->headroom + priv->tailroom + 3) & ~0x3; 835 len = (len + priv->headroom + priv->tailroom + 3) & ~0x3;
697 836
837 if (!skb)
838 return -EINVAL;
839
698 spin_lock_irqsave(&priv->tx_queue.lock, flags); 840 spin_lock_irqsave(&priv->tx_queue.lock, flags);
699 left = skb_queue_len(&priv->tx_queue); 841 left = skb_queue_len(&priv->tx_queue);
700 while (left--) { 842 while (left--) {
701 u32 hole_size; 843 u32 hole_size;
702 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); 844 info = IEEE80211_SKB_CB(entry);
703 struct memrecord *range = (void *)info->driver_data; 845 range = (void *)info->rate_driver_data;
704 hole_size = range->start_addr - last_addr; 846 hole_size = range->start_addr - last_addr;
705 if (!target_skb && hole_size >= len) { 847 if (!target_skb && hole_size >= len) {
706 target_skb = entry->prev; 848 target_skb = entry->prev;
@@ -715,64 +857,89 @@ static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
715 target_skb = priv->tx_queue.prev; 857 target_skb = priv->tx_queue.prev;
716 largest_hole = max(largest_hole, priv->rx_end - last_addr - len); 858 largest_hole = max(largest_hole, priv->rx_end - last_addr - len);
717 if (!skb_queue_empty(&priv->tx_queue)) { 859 if (!skb_queue_empty(&priv->tx_queue)) {
718 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(target_skb); 860 info = IEEE80211_SKB_CB(target_skb);
719 struct memrecord *range = (void *)info->driver_data; 861 range = (void *)info->rate_driver_data;
720 target_addr = range->end_addr; 862 target_addr = range->end_addr;
721 } 863 }
722 } else 864 } else
723 largest_hole = max(largest_hole, priv->rx_end - last_addr); 865 largest_hole = max(largest_hole, priv->rx_end - last_addr);
724 866
725 if (skb) { 867 if (!target_skb) {
726 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 868 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
727 struct memrecord *range = (void *)info->driver_data; 869 ieee80211_stop_queues(dev);
728 range->start_addr = target_addr; 870 return -ENOMEM;
729 range->end_addr = target_addr + len;
730 __skb_queue_after(&priv->tx_queue, target_skb, skb);
731 if (largest_hole < priv->rx_mtu + priv->headroom +
732 priv->tailroom +
733 sizeof(struct p54_control_hdr))
734 ieee80211_stop_queues(dev);
735 } 871 }
872
873 info = IEEE80211_SKB_CB(skb);
874 range = (void *)info->rate_driver_data;
875 range->start_addr = target_addr;
876 range->end_addr = target_addr + len;
877 __skb_queue_after(&priv->tx_queue, target_skb, skb);
736 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 878 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
737 879
880 if (largest_hole < priv->headroom + sizeof(struct p54_hdr) +
881 48 + IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
882 ieee80211_stop_queues(dev);
883
738 data->req_id = cpu_to_le32(target_addr + priv->headroom); 884 data->req_id = cpu_to_le32(target_addr + priv->headroom);
885 return 0;
886}
887
888static struct sk_buff *p54_alloc_skb(struct ieee80211_hw *dev,
889 u16 hdr_flags, u16 len, u16 type, gfp_t memflags)
890{
891 struct p54_common *priv = dev->priv;
892 struct p54_hdr *hdr;
893 struct sk_buff *skb;
894
895 skb = __dev_alloc_skb(len + priv->tx_hdr_len, memflags);
896 if (!skb)
897 return NULL;
898 skb_reserve(skb, priv->tx_hdr_len);
899
900 hdr = (struct p54_hdr *) skb_put(skb, sizeof(*hdr));
901 hdr->flags = cpu_to_le16(hdr_flags);
902 hdr->len = cpu_to_le16(len - sizeof(*hdr));
903 hdr->type = cpu_to_le16(type);
904 hdr->tries = hdr->rts_tries = 0;
905
906 if (unlikely(p54_assign_address(dev, skb, hdr, len))) {
907 kfree_skb(skb);
908 return NULL;
909 }
910 return skb;
739} 911}
740 912
741int p54_read_eeprom(struct ieee80211_hw *dev) 913int p54_read_eeprom(struct ieee80211_hw *dev)
742{ 914{
743 struct p54_common *priv = dev->priv; 915 struct p54_common *priv = dev->priv;
744 struct p54_control_hdr *hdr = NULL; 916 struct p54_hdr *hdr = NULL;
745 struct p54_eeprom_lm86 *eeprom_hdr; 917 struct p54_eeprom_lm86 *eeprom_hdr;
918 struct sk_buff *skb;
746 size_t eeprom_size = 0x2020, offset = 0, blocksize; 919 size_t eeprom_size = 0x2020, offset = 0, blocksize;
747 int ret = -ENOMEM; 920 int ret = -ENOMEM;
748 void *eeprom = NULL; 921 void *eeprom = NULL;
749 922
750 hdr = (struct p54_control_hdr *)kzalloc(sizeof(*hdr) + 923 skb = p54_alloc_skb(dev, 0x8000, sizeof(*hdr) + sizeof(*eeprom_hdr) +
751 sizeof(*eeprom_hdr) + EEPROM_READBACK_LEN, GFP_KERNEL); 924 EEPROM_READBACK_LEN,
752 if (!hdr) 925 P54_CONTROL_TYPE_EEPROM_READBACK, GFP_KERNEL);
926 if (!skb)
753 goto free; 927 goto free;
754
755 priv->eeprom = kzalloc(EEPROM_READBACK_LEN, GFP_KERNEL); 928 priv->eeprom = kzalloc(EEPROM_READBACK_LEN, GFP_KERNEL);
756 if (!priv->eeprom) 929 if (!priv->eeprom)
757 goto free; 930 goto free;
758
759 eeprom = kzalloc(eeprom_size, GFP_KERNEL); 931 eeprom = kzalloc(eeprom_size, GFP_KERNEL);
760 if (!eeprom) 932 if (!eeprom)
761 goto free; 933 goto free;
762 934
763 hdr->magic1 = cpu_to_le16(0x8000); 935 eeprom_hdr = (struct p54_eeprom_lm86 *) skb_put(skb,
764 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_EEPROM_READBACK); 936 sizeof(*eeprom_hdr) + EEPROM_READBACK_LEN);
765 hdr->retry1 = hdr->retry2 = 0;
766 eeprom_hdr = (struct p54_eeprom_lm86 *) hdr->data;
767 937
768 while (eeprom_size) { 938 while (eeprom_size) {
769 blocksize = min(eeprom_size, (size_t)EEPROM_READBACK_LEN); 939 blocksize = min(eeprom_size, (size_t)EEPROM_READBACK_LEN);
770 hdr->len = cpu_to_le16(blocksize + sizeof(*eeprom_hdr));
771 eeprom_hdr->offset = cpu_to_le16(offset); 940 eeprom_hdr->offset = cpu_to_le16(offset);
772 eeprom_hdr->len = cpu_to_le16(blocksize); 941 eeprom_hdr->len = cpu_to_le16(blocksize);
773 p54_assign_address(dev, NULL, hdr, le16_to_cpu(hdr->len) + 942 priv->tx(dev, skb, 0);
774 sizeof(*hdr));
775 priv->tx(dev, hdr, le16_to_cpu(hdr->len) + sizeof(*hdr), 0);
776 943
777 if (!wait_for_completion_interruptible_timeout(&priv->eeprom_comp, HZ)) { 944 if (!wait_for_completion_interruptible_timeout(&priv->eeprom_comp, HZ)) {
778 printk(KERN_ERR "%s: device does not respond!\n", 945 printk(KERN_ERR "%s: device does not respond!\n",
@@ -790,165 +957,336 @@ int p54_read_eeprom(struct ieee80211_hw *dev)
790free: 957free:
791 kfree(priv->eeprom); 958 kfree(priv->eeprom);
792 priv->eeprom = NULL; 959 priv->eeprom = NULL;
793 kfree(hdr); 960 p54_free_skb(dev, skb);
794 kfree(eeprom); 961 kfree(eeprom);
795 962
796 return ret; 963 return ret;
797} 964}
798EXPORT_SYMBOL_GPL(p54_read_eeprom); 965EXPORT_SYMBOL_GPL(p54_read_eeprom);
799 966
967static int p54_set_tim(struct ieee80211_hw *dev, struct ieee80211_sta *sta,
968 bool set)
969{
970 struct p54_common *priv = dev->priv;
971 struct sk_buff *skb;
972 struct p54_tim *tim;
973
974 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET,
975 sizeof(struct p54_hdr) + sizeof(*tim),
976 P54_CONTROL_TYPE_TIM, GFP_KERNEL);
977 if (!skb)
978 return -ENOMEM;
979
980 tim = (struct p54_tim *) skb_put(skb, sizeof(*tim));
981 tim->count = 1;
982 tim->entry[0] = cpu_to_le16(set ? (sta->aid | 0x8000) : sta->aid);
983 priv->tx(dev, skb, 1);
984 return 0;
985}
986
987static int p54_sta_unlock(struct ieee80211_hw *dev, u8 *addr)
988{
989 struct p54_common *priv = dev->priv;
990 struct sk_buff *skb;
991 struct p54_sta_unlock *sta;
992
993 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET,
994 sizeof(struct p54_hdr) + sizeof(*sta),
995 P54_CONTROL_TYPE_PSM_STA_UNLOCK, GFP_ATOMIC);
996 if (!skb)
997 return -ENOMEM;
998
999 sta = (struct p54_sta_unlock *)skb_put(skb, sizeof(*sta));
1000 memcpy(sta->addr, addr, ETH_ALEN);
1001 priv->tx(dev, skb, 1);
1002 return 0;
1003}
1004
1005static int p54_tx_cancel(struct ieee80211_hw *dev, struct sk_buff *entry)
1006{
1007 struct p54_common *priv = dev->priv;
1008 struct sk_buff *skb;
1009 struct p54_hdr *hdr;
1010 struct p54_txcancel *cancel;
1011
1012 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET,
1013 sizeof(struct p54_hdr) + sizeof(*cancel),
1014 P54_CONTROL_TYPE_TXCANCEL, GFP_ATOMIC);
1015 if (!skb)
1016 return -ENOMEM;
1017
1018 hdr = (void *)entry->data;
1019 cancel = (struct p54_txcancel *)skb_put(skb, sizeof(*cancel));
1020 cancel->req_id = hdr->req_id;
1021 priv->tx(dev, skb, 1);
1022 return 0;
1023}
1024
1025static int p54_tx_fill(struct ieee80211_hw *dev, struct sk_buff *skb,
1026 struct ieee80211_tx_info *info, u8 *queue, size_t *extra_len,
1027 u16 *flags, u16 *aid)
1028{
1029 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1030 struct p54_common *priv = dev->priv;
1031 int ret = 0;
1032
1033 if (unlikely(ieee80211_is_mgmt(hdr->frame_control))) {
1034 if (ieee80211_is_beacon(hdr->frame_control)) {
1035 *aid = 0;
1036 *queue = 0;
1037 *extra_len = IEEE80211_MAX_TIM_LEN;
1038 *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP;
1039 return 0;
1040 } else if (ieee80211_is_probe_resp(hdr->frame_control)) {
1041 *aid = 0;
1042 *queue = 2;
1043 *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP |
1044 P54_HDR_FLAG_DATA_OUT_NOCANCEL;
1045 return 0;
1046 } else {
1047 *queue = 2;
1048 ret = 0;
1049 }
1050 } else {
1051 *queue += 4;
1052 ret = 1;
1053 }
1054
1055 switch (priv->mode) {
1056 case NL80211_IFTYPE_STATION:
1057 *aid = 1;
1058 break;
1059 case NL80211_IFTYPE_AP:
1060 case NL80211_IFTYPE_ADHOC:
1061 if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) {
1062 *aid = 0;
1063 *queue = 3;
1064 return 0;
1065 }
1066 if (info->control.sta)
1067 *aid = info->control.sta->aid;
1068 else
1069 *flags = P54_HDR_FLAG_DATA_OUT_NOCANCEL;
1070 }
1071 return ret;
1072}
1073
800static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb) 1074static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
801{ 1075{
802 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1076 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
803 struct ieee80211_tx_queue_stats *current_queue; 1077 struct ieee80211_tx_queue_stats *current_queue = NULL;
804 struct p54_common *priv = dev->priv; 1078 struct p54_common *priv = dev->priv;
805 struct p54_control_hdr *hdr; 1079 struct p54_hdr *hdr;
806 struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data; 1080 struct p54_tx_data *txhdr;
807 struct p54_tx_control_allocdata *txhdr; 1081 size_t padding, len, tim_len = 0;
808 size_t padding, len; 1082 int i, j, ridx;
809 u8 rate; 1083 u16 hdr_flags = 0, aid = 0;
1084 u8 rate, queue;
810 u8 cts_rate = 0x20; 1085 u8 cts_rate = 0x20;
811 1086 u8 rc_flags;
812 current_queue = &priv->tx_stats[skb_get_queue_mapping(skb) + 4]; 1087 u8 calculated_tries[4];
813 if (unlikely(current_queue->len > current_queue->limit)) 1088 u8 nrates = 0, nremaining = 8;
814 return NETDEV_TX_BUSY; 1089
815 current_queue->len++; 1090 queue = skb_get_queue_mapping(skb);
816 current_queue->count++; 1091
817 if (current_queue->len == current_queue->limit) 1092 if (p54_tx_fill(dev, skb, info, &queue, &tim_len, &hdr_flags, &aid)) {
818 ieee80211_stop_queue(dev, skb_get_queue_mapping(skb)); 1093 current_queue = &priv->tx_stats[queue];
1094 if (unlikely(current_queue->len > current_queue->limit))
1095 return NETDEV_TX_BUSY;
1096 current_queue->len++;
1097 current_queue->count++;
1098 if (current_queue->len == current_queue->limit)
1099 ieee80211_stop_queue(dev, skb_get_queue_mapping(skb));
1100 }
819 1101
820 padding = (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr))) & 3; 1102 padding = (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr))) & 3;
821 len = skb->len; 1103 len = skb->len;
822 1104
823 txhdr = (struct p54_tx_control_allocdata *) 1105 if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) {
824 skb_push(skb, sizeof(*txhdr) + padding); 1106 if (info->control.sta)
825 hdr = (struct p54_control_hdr *) skb_push(skb, sizeof(*hdr)); 1107 if (p54_sta_unlock(dev, info->control.sta->addr)) {
1108 if (current_queue) {
1109 current_queue->len--;
1110 current_queue->count--;
1111 }
1112 return NETDEV_TX_BUSY;
1113 }
1114 }
1115
1116 txhdr = (struct p54_tx_data *) skb_push(skb, sizeof(*txhdr) + padding);
1117 hdr = (struct p54_hdr *) skb_push(skb, sizeof(*hdr));
826 1118
827 if (padding) 1119 if (padding)
828 hdr->magic1 = cpu_to_le16(0x4010); 1120 hdr_flags |= P54_HDR_FLAG_DATA_ALIGN;
829 else
830 hdr->magic1 = cpu_to_le16(0x0010);
831 hdr->len = cpu_to_le16(len); 1121 hdr->len = cpu_to_le16(len);
832 hdr->type = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 0 : cpu_to_le16(1); 1122 hdr->type = cpu_to_le16(aid);
833 hdr->retry1 = hdr->retry2 = info->control.retry_limit; 1123 hdr->rts_tries = info->control.rates[0].count;
834 1124
835 /* TODO: add support for alternate retry TX rates */ 1125 /*
836 rate = ieee80211_get_tx_rate(dev, info)->hw_value; 1126 * we register the rates in perfect order, and
837 if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE) { 1127 * RTS/CTS won't happen on 5 GHz
838 rate |= 0x10; 1128 */
839 cts_rate |= 0x10; 1129 cts_rate = info->control.rts_cts_rate_idx;
1130
1131 memset(&txhdr->rateset, 0, sizeof(txhdr->rateset));
1132
1133 /* see how many rates got used */
1134 for (i = 0; i < 4; i++) {
1135 if (info->control.rates[i].idx < 0)
1136 break;
1137 nrates++;
1138 }
1139
1140 /* limit tries to 8/nrates per rate */
1141 for (i = 0; i < nrates; i++) {
1142 /*
1143 * The magic expression here is equivalent to 8/nrates for
1144 * all values that matter, but avoids division and jumps.
1145 * Note that nrates can only take the values 1 through 4.
1146 */
1147 calculated_tries[i] = min_t(int, ((15 >> nrates) | 1) + 1,
1148 info->control.rates[i].count);
1149 nremaining -= calculated_tries[i];
840 } 1150 }
841 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 1151
842 rate |= 0x40; 1152 /* if there are tries left, distribute from back to front */
843 cts_rate |= ieee80211_get_rts_cts_rate(dev, info)->hw_value; 1153 for (i = nrates - 1; nremaining > 0 && i >= 0; i--) {
844 } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { 1154 int tmp = info->control.rates[i].count - calculated_tries[i];
845 rate |= 0x20; 1155
846 cts_rate |= ieee80211_get_rts_cts_rate(dev, info)->hw_value; 1156 if (tmp <= 0)
1157 continue;
1158 /* RC requested more tries at this rate */
1159
1160 tmp = min_t(int, tmp, nremaining);
1161 calculated_tries[i] += tmp;
1162 nremaining -= tmp;
847 } 1163 }
848 memset(txhdr->rateset, rate, 8); 1164
1165 ridx = 0;
1166 for (i = 0; i < nrates && ridx < 8; i++) {
1167 /* we register the rates in perfect order */
1168 rate = info->control.rates[i].idx;
1169 if (info->band == IEEE80211_BAND_5GHZ)
1170 rate += 4;
1171
1172 /* store the count we actually calculated for TX status */
1173 info->control.rates[i].count = calculated_tries[i];
1174
1175 rc_flags = info->control.rates[i].flags;
1176 if (rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) {
1177 rate |= 0x10;
1178 cts_rate |= 0x10;
1179 }
1180 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
1181 rate |= 0x40;
1182 else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
1183 rate |= 0x20;
1184 for (j = 0; j < calculated_tries[i] && ridx < 8; j++) {
1185 txhdr->rateset[ridx] = rate;
1186 ridx++;
1187 }
1188 }
1189
1190 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
1191 hdr_flags |= P54_HDR_FLAG_DATA_OUT_SEQNR;
1192
1193 /* TODO: enable bursting */
1194 hdr->flags = cpu_to_le16(hdr_flags);
1195 hdr->tries = ridx;
1196 txhdr->crypt_offset = 0;
1197 txhdr->rts_rate_idx = 0;
849 txhdr->key_type = 0; 1198 txhdr->key_type = 0;
850 txhdr->key_len = 0; 1199 txhdr->key_len = 0;
851 txhdr->hw_queue = skb_get_queue_mapping(skb) + 4; 1200 txhdr->hw_queue = queue;
1201 txhdr->backlog = 32;
1202 memset(txhdr->durations, 0, sizeof(txhdr->durations));
852 txhdr->tx_antenna = (info->antenna_sel_tx == 0) ? 1203 txhdr->tx_antenna = (info->antenna_sel_tx == 0) ?
853 2 : info->antenna_sel_tx - 1; 1204 2 : info->antenna_sel_tx - 1;
854 txhdr->output_power = priv->output_power; 1205 txhdr->output_power = priv->output_power;
855 txhdr->cts_rate = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 1206 txhdr->cts_rate = cts_rate;
856 0 : cts_rate;
857 if (padding) 1207 if (padding)
858 txhdr->align[0] = padding; 1208 txhdr->align[0] = padding;
859 1209
860 /* FIXME: The sequence that follows is needed for this driver to
861 * work with mac80211 since "mac80211: fix TX sequence numbers".
862 * As with the temporary code in rt2x00, changes will be needed
863 * to get proper sequence numbers on beacons. In addition, this
864 * patch places the sequence number in the hardware state, which
865 * limits us to a single virtual state.
866 */
867 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
868 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
869 priv->seqno += 0x10;
870 ieee80211hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
871 ieee80211hdr->seq_ctrl |= cpu_to_le16(priv->seqno);
872 }
873 /* modifies skb->cb and with it info, so must be last! */ 1210 /* modifies skb->cb and with it info, so must be last! */
874 p54_assign_address(dev, skb, hdr, skb->len); 1211 if (unlikely(p54_assign_address(dev, skb, hdr, skb->len + tim_len))) {
875 1212 skb_pull(skb, sizeof(*hdr) + sizeof(*txhdr) + padding);
876 priv->tx(dev, hdr, skb->len, 0); 1213 if (current_queue) {
1214 current_queue->len--;
1215 current_queue->count--;
1216 }
1217 return NETDEV_TX_BUSY;
1218 }
1219 priv->tx(dev, skb, 0);
877 return 0; 1220 return 0;
878} 1221}
879 1222
880static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type, 1223static int p54_setup_mac(struct ieee80211_hw *dev, u16 mode, const u8 *bssid)
881 const u8 *bssid)
882{ 1224{
883 struct p54_common *priv = dev->priv; 1225 struct p54_common *priv = dev->priv;
884 struct p54_control_hdr *hdr; 1226 struct sk_buff *skb;
885 struct p54_tx_control_filter *filter; 1227 struct p54_setup_mac *setup;
886 size_t data_len;
887 1228
888 hdr = kzalloc(sizeof(*hdr) + sizeof(*filter) + 1229 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*setup) +
889 priv->tx_hdr_len, GFP_ATOMIC); 1230 sizeof(struct p54_hdr), P54_CONTROL_TYPE_SETUP,
890 if (!hdr) 1231 GFP_ATOMIC);
1232 if (!skb)
891 return -ENOMEM; 1233 return -ENOMEM;
892 1234
893 hdr = (void *)hdr + priv->tx_hdr_len; 1235 setup = (struct p54_setup_mac *) skb_put(skb, sizeof(*setup));
894 1236 priv->mac_mode = mode;
895 filter = (struct p54_tx_control_filter *) hdr->data; 1237 setup->mac_mode = cpu_to_le16(mode);
896 hdr->magic1 = cpu_to_le16(0x8001); 1238 memcpy(setup->mac_addr, priv->mac_addr, ETH_ALEN);
897 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_FILTER_SET);
898
899 priv->filter_type = filter->filter_type = cpu_to_le16(filter_type);
900 memcpy(filter->mac_addr, priv->mac_addr, ETH_ALEN);
901 if (!bssid) 1239 if (!bssid)
902 memset(filter->bssid, ~0, ETH_ALEN); 1240 memset(setup->bssid, ~0, ETH_ALEN);
903 else 1241 else
904 memcpy(filter->bssid, bssid, ETH_ALEN); 1242 memcpy(setup->bssid, bssid, ETH_ALEN);
905 1243 setup->rx_antenna = priv->rx_antenna;
906 filter->rx_antenna = priv->rx_antenna; 1244 setup->rx_align = 0;
907
908 if (priv->fw_var < 0x500) { 1245 if (priv->fw_var < 0x500) {
909 data_len = P54_TX_CONTROL_FILTER_V1_LEN; 1246 setup->v1.basic_rate_mask = cpu_to_le32(0x15f);
910 filter->v1.basic_rate_mask = cpu_to_le32(0x15F); 1247 memset(setup->v1.rts_rates, 0, 8);
911 filter->v1.rx_addr = cpu_to_le32(priv->rx_end); 1248 setup->v1.rx_addr = cpu_to_le32(priv->rx_end);
912 filter->v1.max_rx = cpu_to_le16(priv->rx_mtu); 1249 setup->v1.max_rx = cpu_to_le16(priv->rx_mtu);
913 filter->v1.rxhw = cpu_to_le16(priv->rxhw); 1250 setup->v1.rxhw = cpu_to_le16(priv->rxhw);
914 filter->v1.wakeup_timer = cpu_to_le16(500); 1251 setup->v1.wakeup_timer = cpu_to_le16(500);
1252 setup->v1.unalloc0 = cpu_to_le16(0);
915 } else { 1253 } else {
916 data_len = P54_TX_CONTROL_FILTER_V2_LEN; 1254 setup->v2.rx_addr = cpu_to_le32(priv->rx_end);
917 filter->v2.rx_addr = cpu_to_le32(priv->rx_end); 1255 setup->v2.max_rx = cpu_to_le16(priv->rx_mtu);
918 filter->v2.max_rx = cpu_to_le16(priv->rx_mtu); 1256 setup->v2.rxhw = cpu_to_le16(priv->rxhw);
919 filter->v2.rxhw = cpu_to_le16(priv->rxhw); 1257 setup->v2.timer = cpu_to_le16(1000);
920 filter->v2.timer = cpu_to_le16(1000); 1258 setup->v2.truncate = cpu_to_le16(48896);
1259 setup->v2.basic_rate_mask = cpu_to_le32(0x15f);
1260 setup->v2.sbss_offset = 0;
1261 setup->v2.mcast_window = 0;
1262 setup->v2.rx_rssi_threshold = 0;
1263 setup->v2.rx_ed_threshold = 0;
1264 setup->v2.ref_clock = cpu_to_le32(644245094);
1265 setup->v2.lpf_bandwidth = cpu_to_le16(65535);
1266 setup->v2.osc_start_delay = cpu_to_le16(65535);
921 } 1267 }
922 1268 priv->tx(dev, skb, 1);
923 hdr->len = cpu_to_le16(data_len);
924 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + data_len);
925 priv->tx(dev, hdr, sizeof(*hdr) + data_len, 1);
926 return 0; 1269 return 0;
927} 1270}
928 1271
929static int p54_set_freq(struct ieee80211_hw *dev, __le16 freq) 1272static int p54_set_freq(struct ieee80211_hw *dev, u16 frequency)
930{ 1273{
931 struct p54_common *priv = dev->priv; 1274 struct p54_common *priv = dev->priv;
932 struct p54_control_hdr *hdr; 1275 struct sk_buff *skb;
933 struct p54_tx_control_channel *chan; 1276 struct p54_scan *chan;
934 unsigned int i; 1277 unsigned int i;
935 size_t data_len;
936 void *entry; 1278 void *entry;
1279 __le16 freq = cpu_to_le16(frequency);
937 1280
938 hdr = kzalloc(sizeof(*hdr) + sizeof(*chan) + 1281 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*chan) +
939 priv->tx_hdr_len, GFP_KERNEL); 1282 sizeof(struct p54_hdr), P54_CONTROL_TYPE_SCAN,
940 if (!hdr) 1283 GFP_ATOMIC);
1284 if (!skb)
941 return -ENOMEM; 1285 return -ENOMEM;
942 1286
943 hdr = (void *)hdr + priv->tx_hdr_len; 1287 chan = (struct p54_scan *) skb_put(skb, sizeof(*chan));
944 1288 memset(chan->padding1, 0, sizeof(chan->padding1));
945 chan = (struct p54_tx_control_channel *) hdr->data; 1289 chan->mode = cpu_to_le16(P54_SCAN_EXIT);
946
947 hdr->magic1 = cpu_to_le16(0x8001);
948
949 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_CHANNEL_CHANGE);
950
951 chan->flags = cpu_to_le16(0x1);
952 chan->dwell = cpu_to_le16(0x0); 1290 chan->dwell = cpu_to_le16(0x0);
953 1291
954 for (i = 0; i < priv->iq_autocal_len; i++) { 1292 for (i = 0; i < priv->iq_autocal_len; i++) {
@@ -990,61 +1328,50 @@ static int p54_set_freq(struct ieee80211_hw *dev, __le16 freq)
990 } 1328 }
991 1329
992 entry += sizeof(__le16); 1330 entry += sizeof(__le16);
993 chan->pa_points_per_curve = 1331 chan->pa_points_per_curve = 8;
994 min(priv->curve_data->points_per_channel, (u8) 8); 1332 memset(chan->curve_data, 0, sizeof(*chan->curve_data));
995 1333 memcpy(chan->curve_data, entry,
996 memcpy(chan->curve_data, entry, sizeof(*chan->curve_data) * 1334 sizeof(struct p54_pa_curve_data_sample) *
997 chan->pa_points_per_curve); 1335 min((u8)8, priv->curve_data->points_per_channel));
998 break; 1336 break;
999 } 1337 }
1000 1338
1001 if (priv->fw_var < 0x500) { 1339 if (priv->fw_var < 0x500) {
1002 data_len = P54_TX_CONTROL_CHANNEL_V1_LEN;
1003 chan->v1.rssical_mul = cpu_to_le16(130); 1340 chan->v1.rssical_mul = cpu_to_le16(130);
1004 chan->v1.rssical_add = cpu_to_le16(0xfe70); 1341 chan->v1.rssical_add = cpu_to_le16(0xfe70);
1005 } else { 1342 } else {
1006 data_len = P54_TX_CONTROL_CHANNEL_V2_LEN;
1007 chan->v2.rssical_mul = cpu_to_le16(130); 1343 chan->v2.rssical_mul = cpu_to_le16(130);
1008 chan->v2.rssical_add = cpu_to_le16(0xfe70); 1344 chan->v2.rssical_add = cpu_to_le16(0xfe70);
1009 chan->v2.basic_rate_mask = cpu_to_le32(0x15f); 1345 chan->v2.basic_rate_mask = cpu_to_le32(0x15f);
1346 memset(chan->v2.rts_rates, 0, 8);
1010 } 1347 }
1011 1348 priv->tx(dev, skb, 1);
1012 hdr->len = cpu_to_le16(data_len);
1013 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + data_len);
1014 priv->tx(dev, hdr, sizeof(*hdr) + data_len, 1);
1015 return 0; 1349 return 0;
1016 1350
1017 err: 1351 err:
1018 printk(KERN_ERR "%s: frequency change failed\n", wiphy_name(dev->wiphy)); 1352 printk(KERN_ERR "%s: frequency change failed\n", wiphy_name(dev->wiphy));
1019 kfree(hdr); 1353 kfree_skb(skb);
1020 return -EINVAL; 1354 return -EINVAL;
1021} 1355}
1022 1356
1023static int p54_set_leds(struct ieee80211_hw *dev, int mode, int link, int act) 1357static int p54_set_leds(struct ieee80211_hw *dev, int mode, int link, int act)
1024{ 1358{
1025 struct p54_common *priv = dev->priv; 1359 struct p54_common *priv = dev->priv;
1026 struct p54_control_hdr *hdr; 1360 struct sk_buff *skb;
1027 struct p54_tx_control_led *led; 1361 struct p54_led *led;
1028 1362
1029 hdr = kzalloc(sizeof(*hdr) + sizeof(*led) + 1363 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*led) +
1030 priv->tx_hdr_len, GFP_KERNEL); 1364 sizeof(struct p54_hdr), P54_CONTROL_TYPE_LED,
1031 if (!hdr) 1365 GFP_ATOMIC);
1366 if (!skb)
1032 return -ENOMEM; 1367 return -ENOMEM;
1033 1368
1034 hdr = (void *)hdr + priv->tx_hdr_len; 1369 led = (struct p54_led *)skb_put(skb, sizeof(*led));
1035 hdr->magic1 = cpu_to_le16(0x8001);
1036 hdr->len = cpu_to_le16(sizeof(*led));
1037 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_LED);
1038 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*led));
1039
1040 led = (struct p54_tx_control_led *) hdr->data;
1041 led->mode = cpu_to_le16(mode); 1370 led->mode = cpu_to_le16(mode);
1042 led->led_permanent = cpu_to_le16(link); 1371 led->led_permanent = cpu_to_le16(link);
1043 led->led_temporary = cpu_to_le16(act); 1372 led->led_temporary = cpu_to_le16(act);
1044 led->duration = cpu_to_le16(1000); 1373 led->duration = cpu_to_le16(1000);
1045 1374 priv->tx(dev, skb, 1);
1046 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*led), 1);
1047
1048 return 0; 1375 return 0;
1049} 1376}
1050 1377
@@ -1056,88 +1383,152 @@ do { \
1056 queue.txop = cpu_to_le16(_txop); \ 1383 queue.txop = cpu_to_le16(_txop); \
1057} while(0) 1384} while(0)
1058 1385
1059static void p54_init_vdcf(struct ieee80211_hw *dev) 1386static int p54_set_edcf(struct ieee80211_hw *dev)
1060{ 1387{
1061 struct p54_common *priv = dev->priv; 1388 struct p54_common *priv = dev->priv;
1062 struct p54_control_hdr *hdr; 1389 struct sk_buff *skb;
1063 struct p54_tx_control_vdcf *vdcf; 1390 struct p54_edcf *edcf;
1064 1391
1065 /* all USB V1 adapters need a extra headroom */ 1392 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*edcf) +
1066 hdr = (void *)priv->cached_vdcf + priv->tx_hdr_len; 1393 sizeof(struct p54_hdr), P54_CONTROL_TYPE_DCFINIT,
1067 hdr->magic1 = cpu_to_le16(0x8001); 1394 GFP_ATOMIC);
1068 hdr->len = cpu_to_le16(sizeof(*vdcf)); 1395 if (!skb)
1069 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_DCFINIT); 1396 return -ENOMEM;
1070 hdr->req_id = cpu_to_le32(priv->rx_start); 1397
1071 1398 edcf = (struct p54_edcf *)skb_put(skb, sizeof(*edcf));
1072 vdcf = (struct p54_tx_control_vdcf *) hdr->data; 1399 if (priv->use_short_slot) {
1073 1400 edcf->slottime = 9;
1074 P54_SET_QUEUE(vdcf->queue[0], 0x0002, 0x0003, 0x0007, 47); 1401 edcf->sifs = 0x10;
1075 P54_SET_QUEUE(vdcf->queue[1], 0x0002, 0x0007, 0x000f, 94); 1402 edcf->eofpad = 0x00;
1076 P54_SET_QUEUE(vdcf->queue[2], 0x0003, 0x000f, 0x03ff, 0); 1403 } else {
1077 P54_SET_QUEUE(vdcf->queue[3], 0x0007, 0x000f, 0x03ff, 0); 1404 edcf->slottime = 20;
1405 edcf->sifs = 0x0a;
1406 edcf->eofpad = 0x06;
1407 }
1408 /* (see prism54/isl_oid.h for further details) */
1409 edcf->frameburst = cpu_to_le16(0);
1410 edcf->round_trip_delay = cpu_to_le16(0);
1411 edcf->flags = 0;
1412 memset(edcf->mapping, 0, sizeof(edcf->mapping));
1413 memcpy(edcf->queue, priv->qos_params, sizeof(edcf->queue));
1414 priv->tx(dev, skb, 1);
1415 return 0;
1078} 1416}
1079 1417
1080static void p54_set_vdcf(struct ieee80211_hw *dev) 1418static int p54_init_stats(struct ieee80211_hw *dev)
1081{ 1419{
1082 struct p54_common *priv = dev->priv; 1420 struct p54_common *priv = dev->priv;
1083 struct p54_control_hdr *hdr;
1084 struct p54_tx_control_vdcf *vdcf;
1085 1421
1086 hdr = (void *)priv->cached_vdcf + priv->tx_hdr_len; 1422 priv->cached_stats = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL,
1423 sizeof(struct p54_hdr) + sizeof(struct p54_statistics),
1424 P54_CONTROL_TYPE_STAT_READBACK, GFP_KERNEL);
1425 if (!priv->cached_stats)
1426 return -ENOMEM;
1427
1428 mod_timer(&priv->stats_timer, jiffies + HZ);
1429 return 0;
1430}
1087 1431
1088 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*vdcf)); 1432static int p54_beacon_tim(struct sk_buff *skb)
1433{
1434 /*
1435 * the good excuse for this mess is ... the firmware.
1436 * The dummy TIM MUST be at the end of the beacon frame,
1437 * because it'll be overwritten!
1438 */
1089 1439
1090 vdcf = (struct p54_tx_control_vdcf *) hdr->data; 1440 struct ieee80211_mgmt *mgmt = (void *)skb->data;
1441 u8 *pos, *end;
1091 1442
1092 if (dev->conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME) { 1443 if (skb->len <= sizeof(mgmt)) {
1093 vdcf->slottime = 9; 1444 printk(KERN_ERR "p54: beacon is too short!\n");
1094 vdcf->magic1 = 0x10; 1445 return -EINVAL;
1095 vdcf->magic2 = 0x00;
1096 } else {
1097 vdcf->slottime = 20;
1098 vdcf->magic1 = 0x0a;
1099 vdcf->magic2 = 0x06;
1100 } 1446 }
1101 1447
1102 /* (see prism54/isl_oid.h for further details) */ 1448 pos = (u8 *)mgmt->u.beacon.variable;
1103 vdcf->frameburst = cpu_to_le16(0); 1449 end = skb->data + skb->len;
1450 while (pos < end) {
1451 if (pos + 2 + pos[1] > end) {
1452 printk(KERN_ERR "p54: parsing beacon failed\n");
1453 return -EINVAL;
1454 }
1455
1456 if (pos[0] == WLAN_EID_TIM) {
1457 u8 dtim_len = pos[1];
1458 u8 dtim_period = pos[3];
1459 u8 *next = pos + 2 + dtim_len;
1460
1461 if (dtim_len < 3) {
1462 printk(KERN_ERR "p54: invalid dtim len!\n");
1463 return -EINVAL;
1464 }
1465 memmove(pos, next, end - next);
1104 1466
1105 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*vdcf), 0); 1467 if (dtim_len > 3)
1468 skb_trim(skb, skb->len - (dtim_len - 3));
1469
1470 pos = end - (dtim_len + 2);
1471
1472 /* add the dummy at the end */
1473 pos[0] = WLAN_EID_TIM;
1474 pos[1] = 3;
1475 pos[2] = 0;
1476 pos[3] = dtim_period;
1477 pos[4] = 0;
1478 return 0;
1479 }
1480 pos += 2 + pos[1];
1481 }
1482 return 0;
1106} 1483}
1107 1484
1108static int p54_start(struct ieee80211_hw *dev) 1485static int p54_beacon_update(struct ieee80211_hw *dev,
1486 struct ieee80211_vif *vif)
1109{ 1487{
1110 struct p54_common *priv = dev->priv; 1488 struct p54_common *priv = dev->priv;
1111 int err; 1489 struct sk_buff *beacon;
1112 1490 int ret;
1113 if (!priv->cached_vdcf) {
1114 priv->cached_vdcf = kzalloc(sizeof(struct p54_tx_control_vdcf)+
1115 priv->tx_hdr_len + sizeof(struct p54_control_hdr),
1116 GFP_KERNEL);
1117 1491
1118 if (!priv->cached_vdcf) 1492 if (priv->cached_beacon) {
1119 return -ENOMEM; 1493 p54_tx_cancel(dev, priv->cached_beacon);
1494 /* wait for the last beacon the be freed */
1495 msleep(10);
1120 } 1496 }
1121 1497
1122 if (!priv->cached_stats) { 1498 beacon = ieee80211_beacon_get(dev, vif);
1123 priv->cached_stats = kzalloc(sizeof(struct p54_statistics) + 1499 if (!beacon)
1124 priv->tx_hdr_len + sizeof(struct p54_control_hdr), 1500 return -ENOMEM;
1125 GFP_KERNEL); 1501 ret = p54_beacon_tim(beacon);
1502 if (ret)
1503 return ret;
1504 ret = p54_tx(dev, beacon);
1505 if (ret)
1506 return ret;
1507 priv->cached_beacon = beacon;
1508 priv->tsf_high32 = 0;
1509 priv->tsf_low32 = 0;
1126 1510
1127 if (!priv->cached_stats) { 1511 return 0;
1128 kfree(priv->cached_vdcf); 1512}
1129 priv->cached_vdcf = NULL;
1130 return -ENOMEM;
1131 }
1132 }
1133 1513
1514static int p54_start(struct ieee80211_hw *dev)
1515{
1516 struct p54_common *priv = dev->priv;
1517 int err;
1518
1519 mutex_lock(&priv->conf_mutex);
1134 err = priv->open(dev); 1520 err = priv->open(dev);
1135 if (!err) 1521 if (!err)
1136 priv->mode = NL80211_IFTYPE_MONITOR; 1522 priv->mode = NL80211_IFTYPE_MONITOR;
1523 P54_SET_QUEUE(priv->qos_params[0], 0x0002, 0x0003, 0x0007, 47);
1524 P54_SET_QUEUE(priv->qos_params[1], 0x0002, 0x0007, 0x000f, 94);
1525 P54_SET_QUEUE(priv->qos_params[2], 0x0003, 0x000f, 0x03ff, 0);
1526 P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0);
1527 err = p54_set_edcf(dev);
1528 if (!err)
1529 err = p54_init_stats(dev);
1137 1530
1138 p54_init_vdcf(dev); 1531 mutex_unlock(&priv->conf_mutex);
1139
1140 mod_timer(&priv->stats_timer, jiffies + HZ);
1141 return err; 1532 return err;
1142} 1533}
1143 1534
@@ -1146,12 +1537,22 @@ static void p54_stop(struct ieee80211_hw *dev)
1146 struct p54_common *priv = dev->priv; 1537 struct p54_common *priv = dev->priv;
1147 struct sk_buff *skb; 1538 struct sk_buff *skb;
1148 1539
1540 mutex_lock(&priv->conf_mutex);
1149 del_timer(&priv->stats_timer); 1541 del_timer(&priv->stats_timer);
1542 p54_free_skb(dev, priv->cached_stats);
1543 priv->cached_stats = NULL;
1544 if (priv->cached_beacon)
1545 p54_tx_cancel(dev, priv->cached_beacon);
1546
1150 while ((skb = skb_dequeue(&priv->tx_queue))) 1547 while ((skb = skb_dequeue(&priv->tx_queue)))
1151 kfree_skb(skb); 1548 kfree_skb(skb);
1549
1550 kfree(priv->cached_beacon);
1551 priv->cached_beacon = NULL;
1152 priv->stop(dev); 1552 priv->stop(dev);
1153 priv->tsf_high32 = priv->tsf_low32 = 0; 1553 priv->tsf_high32 = priv->tsf_low32 = 0;
1154 priv->mode = NL80211_IFTYPE_UNSPECIFIED; 1554 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
1555 mutex_unlock(&priv->conf_mutex);
1155} 1556}
1156 1557
1157static int p54_add_interface(struct ieee80211_hw *dev, 1558static int p54_add_interface(struct ieee80211_hw *dev,
@@ -1159,24 +1560,36 @@ static int p54_add_interface(struct ieee80211_hw *dev,
1159{ 1560{
1160 struct p54_common *priv = dev->priv; 1561 struct p54_common *priv = dev->priv;
1161 1562
1162 if (priv->mode != NL80211_IFTYPE_MONITOR) 1563 mutex_lock(&priv->conf_mutex);
1564 if (priv->mode != NL80211_IFTYPE_MONITOR) {
1565 mutex_unlock(&priv->conf_mutex);
1163 return -EOPNOTSUPP; 1566 return -EOPNOTSUPP;
1567 }
1164 1568
1165 switch (conf->type) { 1569 switch (conf->type) {
1166 case NL80211_IFTYPE_STATION: 1570 case NL80211_IFTYPE_STATION:
1571 case NL80211_IFTYPE_ADHOC:
1572 case NL80211_IFTYPE_AP:
1167 priv->mode = conf->type; 1573 priv->mode = conf->type;
1168 break; 1574 break;
1169 default: 1575 default:
1576 mutex_unlock(&priv->conf_mutex);
1170 return -EOPNOTSUPP; 1577 return -EOPNOTSUPP;
1171 } 1578 }
1172 1579
1173 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); 1580 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
1174 1581
1175 p54_set_filter(dev, 0, NULL); 1582 p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
1176 1583
1177 switch (conf->type) { 1584 switch (conf->type) {
1178 case NL80211_IFTYPE_STATION: 1585 case NL80211_IFTYPE_STATION:
1179 p54_set_filter(dev, 1, NULL); 1586 p54_setup_mac(dev, P54_FILTER_TYPE_STATION, NULL);
1587 break;
1588 case NL80211_IFTYPE_AP:
1589 p54_setup_mac(dev, P54_FILTER_TYPE_AP, priv->mac_addr);
1590 break;
1591 case NL80211_IFTYPE_ADHOC:
1592 p54_setup_mac(dev, P54_FILTER_TYPE_IBSS, NULL);
1180 break; 1593 break;
1181 default: 1594 default:
1182 BUG(); /* impossible */ 1595 BUG(); /* impossible */
@@ -1185,6 +1598,7 @@ static int p54_add_interface(struct ieee80211_hw *dev,
1185 1598
1186 p54_set_leds(dev, 1, 0, 0); 1599 p54_set_leds(dev, 1, 0, 0);
1187 1600
1601 mutex_unlock(&priv->conf_mutex);
1188 return 0; 1602 return 0;
1189} 1603}
1190 1604
@@ -1192,22 +1606,28 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
1192 struct ieee80211_if_init_conf *conf) 1606 struct ieee80211_if_init_conf *conf)
1193{ 1607{
1194 struct p54_common *priv = dev->priv; 1608 struct p54_common *priv = dev->priv;
1609
1610 mutex_lock(&priv->conf_mutex);
1611 if (priv->cached_beacon)
1612 p54_tx_cancel(dev, priv->cached_beacon);
1613 p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
1195 priv->mode = NL80211_IFTYPE_MONITOR; 1614 priv->mode = NL80211_IFTYPE_MONITOR;
1196 memset(priv->mac_addr, 0, ETH_ALEN); 1615 memset(priv->mac_addr, 0, ETH_ALEN);
1197 p54_set_filter(dev, 0, NULL); 1616 mutex_unlock(&priv->conf_mutex);
1198} 1617}
1199 1618
1200static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) 1619static int p54_config(struct ieee80211_hw *dev, u32 changed)
1201{ 1620{
1202 int ret; 1621 int ret;
1203 struct p54_common *priv = dev->priv; 1622 struct p54_common *priv = dev->priv;
1623 struct ieee80211_conf *conf = &dev->conf;
1204 1624
1205 mutex_lock(&priv->conf_mutex); 1625 mutex_lock(&priv->conf_mutex);
1206 priv->rx_antenna = (conf->antenna_sel_rx == 0) ? 1626 priv->rx_antenna = 2; /* automatic */
1207 2 : conf->antenna_sel_tx - 1;
1208 priv->output_power = conf->power_level << 2; 1627 priv->output_power = conf->power_level << 2;
1209 ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq)); 1628 ret = p54_set_freq(dev, conf->channel->center_freq);
1210 p54_set_vdcf(dev); 1629 if (!ret)
1630 ret = p54_set_edcf(dev);
1211 mutex_unlock(&priv->conf_mutex); 1631 mutex_unlock(&priv->conf_mutex);
1212 return ret; 1632 return ret;
1213} 1633}
@@ -1217,13 +1637,41 @@ static int p54_config_interface(struct ieee80211_hw *dev,
1217 struct ieee80211_if_conf *conf) 1637 struct ieee80211_if_conf *conf)
1218{ 1638{
1219 struct p54_common *priv = dev->priv; 1639 struct p54_common *priv = dev->priv;
1640 int ret = 0;
1220 1641
1221 mutex_lock(&priv->conf_mutex); 1642 mutex_lock(&priv->conf_mutex);
1222 p54_set_filter(dev, 0, conf->bssid); 1643 switch (priv->mode) {
1223 p54_set_leds(dev, 1, !is_multicast_ether_addr(conf->bssid), 0); 1644 case NL80211_IFTYPE_STATION:
1224 memcpy(priv->bssid, conf->bssid, ETH_ALEN); 1645 ret = p54_setup_mac(dev, P54_FILTER_TYPE_STATION, conf->bssid);
1646 if (ret)
1647 goto out;
1648 ret = p54_set_leds(dev, 1,
1649 !is_multicast_ether_addr(conf->bssid), 0);
1650 if (ret)
1651 goto out;
1652 memcpy(priv->bssid, conf->bssid, ETH_ALEN);
1653 break;
1654 case NL80211_IFTYPE_AP:
1655 case NL80211_IFTYPE_ADHOC:
1656 memcpy(priv->bssid, conf->bssid, ETH_ALEN);
1657 ret = p54_set_freq(dev, dev->conf.channel->center_freq);
1658 if (ret)
1659 goto out;
1660 ret = p54_setup_mac(dev, priv->mac_mode, priv->bssid);
1661 if (ret)
1662 goto out;
1663 if (conf->changed & IEEE80211_IFCC_BEACON) {
1664 ret = p54_beacon_update(dev, vif);
1665 if (ret)
1666 goto out;
1667 ret = p54_set_edcf(dev);
1668 if (ret)
1669 goto out;
1670 }
1671 }
1672out:
1225 mutex_unlock(&priv->conf_mutex); 1673 mutex_unlock(&priv->conf_mutex);
1226 return 0; 1674 return ret;
1227} 1675}
1228 1676
1229static void p54_configure_filter(struct ieee80211_hw *dev, 1677static void p54_configure_filter(struct ieee80211_hw *dev,
@@ -1241,20 +1689,16 @@ static void p54_configure_filter(struct ieee80211_hw *dev,
1241 1689
1242 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { 1690 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
1243 if (*total_flags & FIF_BCN_PRBRESP_PROMISC) 1691 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
1244 p54_set_filter(dev, le16_to_cpu(priv->filter_type), 1692 p54_setup_mac(dev, priv->mac_mode, NULL);
1245 NULL);
1246 else 1693 else
1247 p54_set_filter(dev, le16_to_cpu(priv->filter_type), 1694 p54_setup_mac(dev, priv->mac_mode, priv->bssid);
1248 priv->bssid);
1249 } 1695 }
1250 1696
1251 if (changed_flags & FIF_PROMISC_IN_BSS) { 1697 if (changed_flags & FIF_PROMISC_IN_BSS) {
1252 if (*total_flags & FIF_PROMISC_IN_BSS) 1698 if (*total_flags & FIF_PROMISC_IN_BSS)
1253 p54_set_filter(dev, le16_to_cpu(priv->filter_type) | 1699 p54_setup_mac(dev, priv->mac_mode | 0x8, NULL);
1254 0x8, NULL);
1255 else 1700 else
1256 p54_set_filter(dev, le16_to_cpu(priv->filter_type) & 1701 p54_setup_mac(dev, priv->mac_mode & ~0x8, priv->bssid);
1257 ~0x8, priv->bssid);
1258 } 1702 }
1259} 1703}
1260 1704
@@ -1262,46 +1706,39 @@ static int p54_conf_tx(struct ieee80211_hw *dev, u16 queue,
1262 const struct ieee80211_tx_queue_params *params) 1706 const struct ieee80211_tx_queue_params *params)
1263{ 1707{
1264 struct p54_common *priv = dev->priv; 1708 struct p54_common *priv = dev->priv;
1265 struct p54_tx_control_vdcf *vdcf; 1709 int ret;
1266
1267 vdcf = (struct p54_tx_control_vdcf *)(((struct p54_control_hdr *)
1268 ((void *)priv->cached_vdcf + priv->tx_hdr_len))->data);
1269 1710
1711 mutex_lock(&priv->conf_mutex);
1270 if ((params) && !(queue > 4)) { 1712 if ((params) && !(queue > 4)) {
1271 P54_SET_QUEUE(vdcf->queue[queue], params->aifs, 1713 P54_SET_QUEUE(priv->qos_params[queue], params->aifs,
1272 params->cw_min, params->cw_max, params->txop); 1714 params->cw_min, params->cw_max, params->txop);
1273 } else 1715 } else
1274 return -EINVAL; 1716 ret = -EINVAL;
1275 1717 if (!ret)
1276 p54_set_vdcf(dev); 1718 ret = p54_set_edcf(dev);
1277 1719 mutex_unlock(&priv->conf_mutex);
1278 return 0; 1720 return ret;
1279} 1721}
1280 1722
1281static int p54_init_xbow_synth(struct ieee80211_hw *dev) 1723static int p54_init_xbow_synth(struct ieee80211_hw *dev)
1282{ 1724{
1283 struct p54_common *priv = dev->priv; 1725 struct p54_common *priv = dev->priv;
1284 struct p54_control_hdr *hdr; 1726 struct sk_buff *skb;
1285 struct p54_tx_control_xbow_synth *xbow; 1727 struct p54_xbow_synth *xbow;
1286 1728
1287 hdr = kzalloc(sizeof(*hdr) + sizeof(*xbow) + 1729 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*xbow) +
1288 priv->tx_hdr_len, GFP_KERNEL); 1730 sizeof(struct p54_hdr),
1289 if (!hdr) 1731 P54_CONTROL_TYPE_XBOW_SYNTH_CFG,
1732 GFP_KERNEL);
1733 if (!skb)
1290 return -ENOMEM; 1734 return -ENOMEM;
1291 1735
1292 hdr = (void *)hdr + priv->tx_hdr_len; 1736 xbow = (struct p54_xbow_synth *)skb_put(skb, sizeof(*xbow));
1293 hdr->magic1 = cpu_to_le16(0x8001);
1294 hdr->len = cpu_to_le16(sizeof(*xbow));
1295 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_XBOW_SYNTH_CFG);
1296 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*xbow));
1297
1298 xbow = (struct p54_tx_control_xbow_synth *) hdr->data;
1299 xbow->magic1 = cpu_to_le16(0x1); 1737 xbow->magic1 = cpu_to_le16(0x1);
1300 xbow->magic2 = cpu_to_le16(0x2); 1738 xbow->magic2 = cpu_to_le16(0x2);
1301 xbow->freq = cpu_to_le16(5390); 1739 xbow->freq = cpu_to_le16(5390);
1302 1740 memset(xbow->padding, 0, sizeof(xbow->padding));
1303 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*xbow), 1); 1741 priv->tx(dev, skb, 1);
1304
1305 return 0; 1742 return 0;
1306} 1743}
1307 1744
@@ -1309,18 +1746,10 @@ static void p54_statistics_timer(unsigned long data)
1309{ 1746{
1310 struct ieee80211_hw *dev = (struct ieee80211_hw *) data; 1747 struct ieee80211_hw *dev = (struct ieee80211_hw *) data;
1311 struct p54_common *priv = dev->priv; 1748 struct p54_common *priv = dev->priv;
1312 struct p54_control_hdr *hdr;
1313 struct p54_statistics *stats;
1314 1749
1315 BUG_ON(!priv->cached_stats); 1750 BUG_ON(!priv->cached_stats);
1316 1751
1317 hdr = (void *)priv->cached_stats + priv->tx_hdr_len; 1752 priv->tx(dev, priv->cached_stats, 0);
1318 hdr->magic1 = cpu_to_le16(0x8000);
1319 hdr->len = cpu_to_le16(sizeof(*stats));
1320 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_STAT_READBACK);
1321 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*stats));
1322
1323 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*stats), 0);
1324} 1753}
1325 1754
1326static int p54_get_stats(struct ieee80211_hw *dev, 1755static int p54_get_stats(struct ieee80211_hw *dev,
@@ -1352,14 +1781,29 @@ static int p54_get_tx_stats(struct ieee80211_hw *dev,
1352 return 0; 1781 return 0;
1353} 1782}
1354 1783
1784static void p54_bss_info_changed(struct ieee80211_hw *dev,
1785 struct ieee80211_vif *vif,
1786 struct ieee80211_bss_conf *info,
1787 u32 changed)
1788{
1789 struct p54_common *priv = dev->priv;
1790
1791 if (changed & BSS_CHANGED_ERP_SLOT) {
1792 priv->use_short_slot = info->use_short_slot;
1793 p54_set_edcf(dev);
1794 }
1795}
1796
1355static const struct ieee80211_ops p54_ops = { 1797static const struct ieee80211_ops p54_ops = {
1356 .tx = p54_tx, 1798 .tx = p54_tx,
1357 .start = p54_start, 1799 .start = p54_start,
1358 .stop = p54_stop, 1800 .stop = p54_stop,
1359 .add_interface = p54_add_interface, 1801 .add_interface = p54_add_interface,
1360 .remove_interface = p54_remove_interface, 1802 .remove_interface = p54_remove_interface,
1803 .set_tim = p54_set_tim,
1361 .config = p54_config, 1804 .config = p54_config,
1362 .config_interface = p54_config_interface, 1805 .config_interface = p54_config_interface,
1806 .bss_info_changed = p54_bss_info_changed,
1363 .configure_filter = p54_configure_filter, 1807 .configure_filter = p54_configure_filter,
1364 .conf_tx = p54_conf_tx, 1808 .conf_tx = p54_conf_tx,
1365 .get_stats = p54_get_stats, 1809 .get_stats = p54_get_stats,
@@ -1378,24 +1822,34 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
1378 priv = dev->priv; 1822 priv = dev->priv;
1379 priv->mode = NL80211_IFTYPE_UNSPECIFIED; 1823 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
1380 skb_queue_head_init(&priv->tx_queue); 1824 skb_queue_head_init(&priv->tx_queue);
1381 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */ 1825 dev->flags = IEEE80211_HW_RX_INCLUDES_FCS |
1382 IEEE80211_HW_RX_INCLUDES_FCS |
1383 IEEE80211_HW_SIGNAL_DBM | 1826 IEEE80211_HW_SIGNAL_DBM |
1384 IEEE80211_HW_NOISE_DBM; 1827 IEEE80211_HW_NOISE_DBM;
1385 1828
1386 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 1829 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION |
1830 NL80211_IFTYPE_ADHOC |
1831 NL80211_IFTYPE_AP);
1387 1832
1388 dev->channel_change_time = 1000; /* TODO: find actual value */ 1833 dev->channel_change_time = 1000; /* TODO: find actual value */
1389 1834 priv->tx_stats[0].limit = 1; /* Beacon queue */
1390 priv->tx_stats[0].limit = 1; 1835 priv->tx_stats[1].limit = 1; /* Probe queue for HW scan */
1391 priv->tx_stats[1].limit = 1; 1836 priv->tx_stats[2].limit = 3; /* queue for MLMEs */
1392 priv->tx_stats[2].limit = 1; 1837 priv->tx_stats[3].limit = 3; /* Broadcast / MC queue */
1393 priv->tx_stats[3].limit = 1; 1838 priv->tx_stats[4].limit = 5; /* Data */
1394 priv->tx_stats[4].limit = 5;
1395 dev->queues = 1; 1839 dev->queues = 1;
1396 priv->noise = -94; 1840 priv->noise = -94;
1397 dev->extra_tx_headroom = sizeof(struct p54_control_hdr) + 4 + 1841 /*
1398 sizeof(struct p54_tx_control_allocdata); 1842 * We support at most 8 tries no matter which rate they're at,
1843 * we cannot support max_rates * max_rate_tries as we set it
1844 * here, but setting it correctly to 4/2 or so would limit us
1845 * artificially if the RC algorithm wants just two rates, so
1846 * let's say 4/7, we'll redistribute it at TX time, see the
1847 * comments there.
1848 */
1849 dev->max_rates = 4;
1850 dev->max_rate_tries = 7;
1851 dev->extra_tx_headroom = sizeof(struct p54_hdr) + 4 +
1852 sizeof(struct p54_tx_data);
1399 1853
1400 mutex_init(&priv->conf_mutex); 1854 mutex_init(&priv->conf_mutex);
1401 init_completion(&priv->eeprom_comp); 1855 init_completion(&priv->eeprom_comp);
@@ -1410,11 +1864,11 @@ EXPORT_SYMBOL_GPL(p54_init_common);
1410void p54_free_common(struct ieee80211_hw *dev) 1864void p54_free_common(struct ieee80211_hw *dev)
1411{ 1865{
1412 struct p54_common *priv = dev->priv; 1866 struct p54_common *priv = dev->priv;
1413 kfree(priv->cached_stats); 1867 del_timer(&priv->stats_timer);
1868 kfree_skb(priv->cached_stats);
1414 kfree(priv->iq_autocal); 1869 kfree(priv->iq_autocal);
1415 kfree(priv->output_limit); 1870 kfree(priv->output_limit);
1416 kfree(priv->curve_data); 1871 kfree(priv->curve_data);
1417 kfree(priv->cached_vdcf);
1418} 1872}
1419EXPORT_SYMBOL_GPL(p54_free_common); 1873EXPORT_SYMBOL_GPL(p54_free_common);
1420 1874
diff --git a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireless/p54/p54common.h
index 2fa994cfcfed..8c8793cb2d79 100644
--- a/drivers/net/wireless/p54/p54common.h
+++ b/drivers/net/wireless/p54/p54common.h
@@ -7,8 +7,12 @@
7 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> 7 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
8 * Copyright (c) 2007, Christian Lamparter <chunkeey@web.de> 8 * Copyright (c) 2007, Christian Lamparter <chunkeey@web.de>
9 * 9 *
10 * Based on the islsm (softmac prism54) driver, which is: 10 * Based on:
11 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. 11 * - the islsm (softmac prism54) driver, which is:
12 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
13 *
14 * - LMAC API interface header file for STLC4560 (lmac_longbow.h)
15 * Copyright (C) 2007 Conexant Systems, Inc.
12 * 16 *
13 * This program is free software; you can redistribute it and/or modify 17 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as 18 * it under the terms of the GNU General Public License version 2 as
@@ -19,9 +23,24 @@ struct bootrec {
19 __le32 code; 23 __le32 code;
20 __le32 len; 24 __le32 len;
21 u32 data[10]; 25 u32 data[10];
22 __le16 rx_mtu;
23} __attribute__((packed)); 26} __attribute__((packed));
24 27
28#define PDR_SYNTH_FRONTEND_MASK 0x0007
29#define PDR_SYNTH_IQ_CAL_MASK 0x0018
30#define PDR_SYNTH_IQ_CAL_PA_DETECTOR 0x0000
31#define PDR_SYNTH_IQ_CAL_DISABLED 0x0008
32#define PDR_SYNTH_IQ_CAL_ZIF 0x0010
33#define PDR_SYNTH_FAA_SWITCH_MASK 0x0020
34#define PDR_SYNTH_FAA_SWITCH_ENABLED 0x0001
35#define PDR_SYNTH_24_GHZ_MASK 0x0040
36#define PDR_SYNTH_24_GHZ_DISABLED 0x0040
37#define PDR_SYNTH_5_GHZ_MASK 0x0080
38#define PDR_SYNTH_5_GHZ_DISABLED 0x0080
39#define PDR_SYNTH_RX_DIV_MASK 0x0100
40#define PDR_SYNTH_RX_DIV_SUPPORTED 0x0100
41#define PDR_SYNTH_TX_DIV_MASK 0x0200
42#define PDR_SYNTH_TX_DIV_SUPPORTED 0x0200
43
25struct bootrec_exp_if { 44struct bootrec_exp_if {
26 __le16 role; 45 __le16 role;
27 __le16 if_id; 46 __le16 if_id;
@@ -30,6 +49,13 @@ struct bootrec_exp_if {
30 __le16 top_compat; 49 __le16 top_compat;
31} __attribute__((packed)); 50} __attribute__((packed));
32 51
52#define BR_DESC_PRIV_CAP_WEP BIT(0)
53#define BR_DESC_PRIV_CAP_TKIP BIT(1)
54#define BR_DESC_PRIV_CAP_MICHAEL BIT(2)
55#define BR_DESC_PRIV_CAP_CCX_CP BIT(3)
56#define BR_DESC_PRIV_CAP_CCX_MIC BIT(4)
57#define BR_DESC_PRIV_CAP_AESCCMP BIT(5)
58
33struct bootrec_desc { 59struct bootrec_desc {
34 __le16 modes; 60 __le16 modes;
35 __le16 flags; 61 __le16 flags;
@@ -37,8 +63,15 @@ struct bootrec_desc {
37 __le32 rx_end; 63 __le32 rx_end;
38 u8 headroom; 64 u8 headroom;
39 u8 tailroom; 65 u8 tailroom;
40 u8 unimportant[6]; 66 u8 tx_queues;
67 u8 tx_depth;
68 u8 privacy_caps;
69 u8 rx_keycache_size;
70 u8 time_size;
71 u8 padding;
41 u8 rates[16]; 72 u8 rates[16];
73 u8 padding2[4];
74 __le16 rx_mtu;
42} __attribute__((packed)); 75} __attribute__((packed));
43 76
44#define BR_CODE_MIN 0x80000000 77#define BR_CODE_MIN 0x80000000
@@ -51,6 +84,34 @@ struct bootrec_desc {
51#define BR_CODE_END_OF_BRA 0xFF0000FF 84#define BR_CODE_END_OF_BRA 0xFF0000FF
52#define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF 85#define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF
53 86
87#define P54_HDR_FLAG_CONTROL BIT(15)
88#define P54_HDR_FLAG_CONTROL_OPSET (BIT(15) + BIT(0))
89
90#define P54_HDR_FLAG_DATA_ALIGN BIT(14)
91#define P54_HDR_FLAG_DATA_OUT_PROMISC BIT(0)
92#define P54_HDR_FLAG_DATA_OUT_TIMESTAMP BIT(1)
93#define P54_HDR_FLAG_DATA_OUT_SEQNR BIT(2)
94#define P54_HDR_FLAG_DATA_OUT_BIT3 BIT(3)
95#define P54_HDR_FLAG_DATA_OUT_BURST BIT(4)
96#define P54_HDR_FLAG_DATA_OUT_NOCANCEL BIT(5)
97#define P54_HDR_FLAG_DATA_OUT_CLEARTIM BIT(6)
98#define P54_HDR_FLAG_DATA_OUT_HITCHHIKE BIT(7)
99#define P54_HDR_FLAG_DATA_OUT_COMPRESS BIT(8)
100#define P54_HDR_FLAG_DATA_OUT_CONCAT BIT(9)
101#define P54_HDR_FLAG_DATA_OUT_PCS_ACCEPT BIT(10)
102#define P54_HDR_FLAG_DATA_OUT_WAITEOSP BIT(11)
103
104#define P54_HDR_FLAG_DATA_IN_FCS_GOOD BIT(0)
105#define P54_HDR_FLAG_DATA_IN_MATCH_MAC BIT(1)
106#define P54_HDR_FLAG_DATA_IN_MCBC BIT(2)
107#define P54_HDR_FLAG_DATA_IN_BEACON BIT(3)
108#define P54_HDR_FLAG_DATA_IN_MATCH_BSS BIT(4)
109#define P54_HDR_FLAG_DATA_IN_BCAST_BSS BIT(5)
110#define P54_HDR_FLAG_DATA_IN_DATA BIT(6)
111#define P54_HDR_FLAG_DATA_IN_TRUNCATED BIT(7)
112#define P54_HDR_FLAG_DATA_IN_BIT8 BIT(8)
113#define P54_HDR_FLAG_DATA_IN_TRANSPARENT BIT(9)
114
54/* PDA defines are Copyright (C) 2005 Nokia Corporation (taken from islsm_pda.h) */ 115/* PDA defines are Copyright (C) 2005 Nokia Corporation (taken from islsm_pda.h) */
55 116
56struct pda_entry { 117struct pda_entry {
@@ -165,6 +226,19 @@ struct pda_pa_curve_data {
165#define PDR_BASEBAND_REGISTERS 0x8000 226#define PDR_BASEBAND_REGISTERS 0x8000
166#define PDR_PER_CHANNEL_BASEBAND_REGISTERS 0x8001 227#define PDR_PER_CHANNEL_BASEBAND_REGISTERS 0x8001
167 228
229/* PDR definitions for default country & country list */
230#define PDR_COUNTRY_CERT_CODE 0x80
231#define PDR_COUNTRY_CERT_CODE_REAL 0x00
232#define PDR_COUNTRY_CERT_CODE_PSEUDO 0x80
233#define PDR_COUNTRY_CERT_BAND 0x40
234#define PDR_COUNTRY_CERT_BAND_2GHZ 0x00
235#define PDR_COUNTRY_CERT_BAND_5GHZ 0x40
236#define PDR_COUNTRY_CERT_IODOOR 0x30
237#define PDR_COUNTRY_CERT_IODOOR_BOTH 0x00
238#define PDR_COUNTRY_CERT_IODOOR_INDOOR 0x20
239#define PDR_COUNTRY_CERT_IODOOR_OUTDOOR 0x30
240#define PDR_COUNTRY_CERT_INDEX 0x0F
241
168/* stored in skb->cb */ 242/* stored in skb->cb */
169struct memrecord { 243struct memrecord {
170 u32 start_addr; 244 u32 start_addr;
@@ -177,36 +251,91 @@ struct p54_eeprom_lm86 {
177 u8 data[0]; 251 u8 data[0];
178} __attribute__ ((packed)); 252} __attribute__ ((packed));
179 253
180struct p54_rx_hdr { 254enum p54_rx_decrypt_status {
181 __le16 magic; 255 P54_DECRYPT_NONE = 0,
256 P54_DECRYPT_OK,
257 P54_DECRYPT_NOKEY,
258 P54_DECRYPT_NOMICHAEL,
259 P54_DECRYPT_NOCKIPMIC,
260 P54_DECRYPT_FAIL_WEP,
261 P54_DECRYPT_FAIL_TKIP,
262 P54_DECRYPT_FAIL_MICAHEL,
263 P54_DECRYPT_FAIL_CKIPKP,
264 P54_DECRYPT_FAIL_CKIPMIC,
265 P54_DECRYPT_FAIL_AESCCMP
266};
267
268struct p54_rx_data {
269 __le16 flags;
182 __le16 len; 270 __le16 len;
183 __le16 freq; 271 __le16 freq;
184 u8 antenna; 272 u8 antenna;
185 u8 rate; 273 u8 rate;
186 u8 rssi; 274 u8 rssi;
187 u8 quality; 275 u8 quality;
188 u16 unknown2; 276 u8 decrypt_status;
277 u8 rssi_raw;
189 __le32 tsf32; 278 __le32 tsf32;
190 __le32 unalloc0; 279 __le32 unalloc0;
191 u8 align[0]; 280 u8 align[0];
192} __attribute__ ((packed)); 281} __attribute__ ((packed));
193 282
194struct p54_frame_sent_hdr { 283enum p54_trap_type {
284 P54_TRAP_SCAN = 0,
285 P54_TRAP_TIMER,
286 P54_TRAP_BEACON_TX,
287 P54_TRAP_FAA_RADIO_ON,
288 P54_TRAP_FAA_RADIO_OFF,
289 P54_TRAP_RADAR,
290 P54_TRAP_NO_BEACON,
291 P54_TRAP_TBTT,
292 P54_TRAP_SCO_ENTER,
293 P54_TRAP_SCO_EXIT
294};
295
296struct p54_trap {
297 __le16 event;
298 __le16 frequency;
299} __attribute__ ((packed));
300
301enum p54_frame_sent_status {
302 P54_TX_OK = 0,
303 P54_TX_FAILED,
304 P54_TX_PSM,
305 P54_TX_PSM_CANCELLED
306};
307
308struct p54_frame_sent {
195 u8 status; 309 u8 status;
196 u8 retries; 310 u8 tries;
197 __le16 ack_rssi; 311 u8 ack_rssi;
312 u8 quality;
198 __le16 seq; 313 __le16 seq;
199 u16 rate; 314 u8 antenna;
315 u8 padding;
200} __attribute__ ((packed)); 316} __attribute__ ((packed));
201 317
202struct p54_tx_control_allocdata { 318enum p54_tx_data_crypt {
319 P54_CRYPTO_NONE = 0,
320 P54_CRYPTO_WEP,
321 P54_CRYPTO_TKIP,
322 P54_CRYPTO_TKIPMICHAEL,
323 P54_CRYPTO_CCX_WEPMIC,
324 P54_CRYPTO_CCX_KPMIC,
325 P54_CRYPTO_CCX_KP,
326 P54_CRYPTO_AESCCMP
327};
328
329struct p54_tx_data {
203 u8 rateset[8]; 330 u8 rateset[8];
204 u8 unalloc0[2]; 331 u8 rts_rate_idx;
332 u8 crypt_offset;
205 u8 key_type; 333 u8 key_type;
206 u8 key_len; 334 u8 key_len;
207 u8 key[16]; 335 u8 key[16];
208 u8 hw_queue; 336 u8 hw_queue;
209 u8 unalloc1[9]; 337 u8 backlog;
338 __le16 durations[4];
210 u8 tx_antenna; 339 u8 tx_antenna;
211 u8 output_power; 340 u8 output_power;
212 u8 cts_rate; 341 u8 cts_rate;
@@ -214,8 +343,18 @@ struct p54_tx_control_allocdata {
214 u8 align[0]; 343 u8 align[0];
215} __attribute__ ((packed)); 344} __attribute__ ((packed));
216 345
217struct p54_tx_control_filter { 346#define P54_FILTER_TYPE_NONE 0
218 __le16 filter_type; 347#define P54_FILTER_TYPE_STATION BIT(0)
348#define P54_FILTER_TYPE_IBSS BIT(1)
349#define P54_FILTER_TYPE_AP BIT(2)
350#define P54_FILTER_TYPE_TRANSPARENT BIT(3)
351#define P54_FILTER_TYPE_PROMISCUOUS BIT(4)
352#define P54_FILTER_TYPE_HIBERNATE BIT(5)
353#define P54_FILTER_TYPE_NOACK BIT(6)
354#define P54_FILTER_TYPE_RX_DISABLED BIT(7)
355
356struct p54_setup_mac {
357 __le16 mac_mode;
219 u8 mac_addr[ETH_ALEN]; 358 u8 mac_addr[ETH_ALEN];
220 u8 bssid[ETH_ALEN]; 359 u8 bssid[ETH_ALEN];
221 u8 rx_antenna; 360 u8 rx_antenna;
@@ -235,17 +374,29 @@ struct p54_tx_control_filter {
235 __le16 max_rx; 374 __le16 max_rx;
236 __le16 rxhw; 375 __le16 rxhw;
237 __le16 timer; 376 __le16 timer;
238 __le16 unalloc0; 377 __le16 truncate;
239 __le32 unalloc1; 378 __le32 basic_rate_mask;
379 u8 sbss_offset;
380 u8 mcast_window;
381 u8 rx_rssi_threshold;
382 u8 rx_ed_threshold;
383 __le32 ref_clock;
384 __le16 lpf_bandwidth;
385 __le16 osc_start_delay;
240 } v2 __attribute__ ((packed)); 386 } v2 __attribute__ ((packed));
241 } __attribute__ ((packed)); 387 } __attribute__ ((packed));
242} __attribute__ ((packed)); 388} __attribute__ ((packed));
243 389
244#define P54_TX_CONTROL_FILTER_V1_LEN (sizeof(struct p54_tx_control_filter)) 390#define P54_SETUP_V1_LEN 40
245#define P54_TX_CONTROL_FILTER_V2_LEN (sizeof(struct p54_tx_control_filter)-8) 391#define P54_SETUP_V2_LEN (sizeof(struct p54_setup_mac))
246 392
247struct p54_tx_control_channel { 393#define P54_SCAN_EXIT BIT(0)
248 __le16 flags; 394#define P54_SCAN_TRAP BIT(1)
395#define P54_SCAN_ACTIVE BIT(2)
396#define P54_SCAN_FILTER BIT(3)
397
398struct p54_scan {
399 __le16 mode;
249 __le16 dwell; 400 __le16 dwell;
250 u8 padding1[20]; 401 u8 padding1[20];
251 struct pda_iq_autocal_entry iq_autocal; 402 struct pda_iq_autocal_entry iq_autocal;
@@ -268,38 +419,32 @@ struct p54_tx_control_channel {
268 419
269 struct { 420 struct {
270 __le32 basic_rate_mask; 421 __le32 basic_rate_mask;
271 u8 rts_rates[8]; 422 u8 rts_rates[8];
272 __le16 rssical_mul; 423 __le16 rssical_mul;
273 __le16 rssical_add; 424 __le16 rssical_add;
274 } v2 __attribute__ ((packed)); 425 } v2 __attribute__ ((packed));
275 } __attribute__ ((packed)); 426 } __attribute__ ((packed));
276} __attribute__ ((packed)); 427} __attribute__ ((packed));
277 428
278#define P54_TX_CONTROL_CHANNEL_V1_LEN (sizeof(struct p54_tx_control_channel)-12) 429#define P54_SCAN_V1_LEN (sizeof(struct p54_scan)-12)
279#define P54_TX_CONTROL_CHANNEL_V2_LEN (sizeof(struct p54_tx_control_channel)) 430#define P54_SCAN_V2_LEN (sizeof(struct p54_scan))
280 431
281struct p54_tx_control_led { 432struct p54_led {
282 __le16 mode; 433 __le16 mode;
283 __le16 led_temporary; 434 __le16 led_temporary;
284 __le16 led_permanent; 435 __le16 led_permanent;
285 __le16 duration; 436 __le16 duration;
286} __attribute__ ((packed)); 437} __attribute__ ((packed));
287 438
288struct p54_tx_vdcf_queues { 439struct p54_edcf {
289 __le16 aifs; 440 u8 flags;
290 __le16 cwmin;
291 __le16 cwmax;
292 __le16 txop;
293} __attribute__ ((packed));
294
295struct p54_tx_control_vdcf {
296 u8 padding;
297 u8 slottime; 441 u8 slottime;
298 u8 magic1; 442 u8 sifs;
299 u8 magic2; 443 u8 eofpad;
300 struct p54_tx_vdcf_queues queue[8]; 444 struct p54_edcf_queue_param queue[8];
301 u8 pad2[4]; 445 u8 mapping[4];
302 __le16 frameburst; 446 __le16 frameburst;
447 __le16 round_trip_delay;
303} __attribute__ ((packed)); 448} __attribute__ ((packed));
304 449
305struct p54_statistics { 450struct p54_statistics {
@@ -312,14 +457,103 @@ struct p54_statistics {
312 __le32 tsf32; 457 __le32 tsf32;
313 __le32 airtime; 458 __le32 airtime;
314 __le32 noise; 459 __le32 noise;
315 __le32 unkn[10]; /* CCE / CCA / RADAR */ 460 __le32 sample_noise[8];
461 __le32 sample_cca;
462 __le32 sample_tx;
316} __attribute__ ((packed)); 463} __attribute__ ((packed));
317 464
318struct p54_tx_control_xbow_synth { 465struct p54_xbow_synth {
319 __le16 magic1; 466 __le16 magic1;
320 __le16 magic2; 467 __le16 magic2;
321 __le16 freq; 468 __le16 freq;
322 u32 padding[5]; 469 u32 padding[5];
323} __attribute__ ((packed)); 470} __attribute__ ((packed));
324 471
472struct p54_timer {
473 __le32 interval;
474} __attribute__ ((packed));
475
476struct p54_keycache {
477 u8 entry;
478 u8 key_id;
479 u8 mac[ETH_ALEN];
480 u8 padding[2];
481 u8 key_type;
482 u8 key_len;
483 u8 key[24];
484} __attribute__ ((packed));
485
486struct p54_burst {
487 u8 flags;
488 u8 queue;
489 u8 backlog;
490 u8 pad;
491 __le16 durations[32];
492} __attribute__ ((packed));
493
494struct p54_psm_interval {
495 __le16 interval;
496 __le16 periods;
497} __attribute__ ((packed));
498
499#define P54_PSM BIT(0)
500#define P54_PSM_DTIM BIT(1)
501#define P54_PSM_MCBC BIT(2)
502#define P54_PSM_CHECKSUM BIT(3)
503#define P54_PSM_SKIP_MORE_DATA BIT(4)
504#define P54_PSM_BEACON_TIMEOUT BIT(5)
505#define P54_PSM_HFOSLEEP BIT(6)
506#define P54_PSM_AUTOSWITCH_SLEEP BIT(7)
507#define P54_PSM_LPIT BIT(8)
508#define P54_PSM_BF_UCAST_SKIP BIT(9)
509#define P54_PSM_BF_MCAST_SKIP BIT(10)
510
511struct p54_psm {
512 __le16 mode;
513 __le16 aid;
514 struct p54_psm_interval intervals[4];
515 u8 beacon_rssi_skip_max;
516 u8 rssi_delta_threshold;
517 u8 nr;
518 u8 exclude[1];
519} __attribute__ ((packed));
520
521#define MC_FILTER_ADDRESS_NUM 4
522
523struct p54_group_address_table {
524 __le16 filter_enable;
525 __le16 num_address;
526 u8 mac_list[MC_FILTER_ADDRESS_NUM][ETH_ALEN];
527} __attribute__ ((packed));
528
529struct p54_txcancel {
530 __le32 req_id;
531} __attribute__ ((packed));
532
533struct p54_sta_unlock {
534 u8 addr[ETH_ALEN];
535 u16 padding;
536} __attribute__ ((packed));
537
538#define P54_TIM_CLEAR BIT(15)
539struct p54_tim {
540 u8 count;
541 u8 padding[3];
542 __le16 entry[8];
543} __attribute__ ((packed));
544
545struct p54_cce_quiet {
546 __le32 period;
547} __attribute__ ((packed));
548
549struct p54_bt_balancer {
550 __le16 prio_thresh;
551 __le16 acl_thresh;
552} __attribute__ ((packed));
553
554struct p54_arp_table {
555 __le16 filter_enable;
556 u8 ipv4_addr[4];
557} __attribute__ ((packed));
558
325#endif /* P54COMMON_H */ 559#endif /* P54COMMON_H */
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index 88b3cad8b65e..c4a868ae6d6b 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -28,6 +28,7 @@ MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
28MODULE_DESCRIPTION("Prism54 PCI wireless driver"); 28MODULE_DESCRIPTION("Prism54 PCI wireless driver");
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30MODULE_ALIAS("prism54pci"); 30MODULE_ALIAS("prism54pci");
31MODULE_FIRMWARE("isl3886pci");
31 32
32static struct pci_device_id p54p_table[] __devinitdata = { 33static struct pci_device_id p54p_table[] __devinitdata = {
33 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ 34 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
@@ -72,11 +73,13 @@ static int p54p_upload_firmware(struct ieee80211_hw *dev)
72 P54P_WRITE(ctrl_stat, reg); 73 P54P_WRITE(ctrl_stat, reg);
73 wmb(); 74 wmb();
74 75
75 err = request_firmware(&fw_entry, "isl3886", &priv->pdev->dev); 76 err = request_firmware(&fw_entry, "isl3886pci", &priv->pdev->dev);
76 if (err) { 77 if (err) {
77 printk(KERN_ERR "%s (p54pci): cannot find firmware " 78 printk(KERN_ERR "%s (p54pci): cannot find firmware "
78 "(isl3886)\n", pci_name(priv->pdev)); 79 "(isl3886pci)\n", pci_name(priv->pdev));
79 return err; 80 err = request_firmware(&fw_entry, "isl3886", &priv->pdev->dev);
81 if (err)
82 return err;
80 } 83 }
81 84
82 err = p54_parse_firmware(dev, fw_entry); 85 err = p54_parse_firmware(dev, fw_entry);
@@ -235,7 +238,7 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index,
235 238
236 while (i != idx) { 239 while (i != idx) {
237 desc = &ring[i]; 240 desc = &ring[i];
238 kfree(tx_buf[i]); 241 p54_free_skb(dev, tx_buf[i]);
239 tx_buf[i] = NULL; 242 tx_buf[i] = NULL;
240 243
241 pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), 244 pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
@@ -306,8 +309,8 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
306 return reg ? IRQ_HANDLED : IRQ_NONE; 309 return reg ? IRQ_HANDLED : IRQ_NONE;
307} 310}
308 311
309static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data, 312static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
310 size_t len, int free_on_tx) 313 int free_on_tx)
311{ 314{
312 struct p54p_priv *priv = dev->priv; 315 struct p54p_priv *priv = dev->priv;
313 struct p54p_ring_control *ring_control = priv->ring_control; 316 struct p54p_ring_control *ring_control = priv->ring_control;
@@ -322,18 +325,19 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data,
322 idx = le32_to_cpu(ring_control->host_idx[1]); 325 idx = le32_to_cpu(ring_control->host_idx[1]);
323 i = idx % ARRAY_SIZE(ring_control->tx_data); 326 i = idx % ARRAY_SIZE(ring_control->tx_data);
324 327
325 mapping = pci_map_single(priv->pdev, data, len, PCI_DMA_TODEVICE); 328 mapping = pci_map_single(priv->pdev, skb->data, skb->len,
329 PCI_DMA_TODEVICE);
326 desc = &ring_control->tx_data[i]; 330 desc = &ring_control->tx_data[i];
327 desc->host_addr = cpu_to_le32(mapping); 331 desc->host_addr = cpu_to_le32(mapping);
328 desc->device_addr = data->req_id; 332 desc->device_addr = ((struct p54_hdr *)skb->data)->req_id;
329 desc->len = cpu_to_le16(len); 333 desc->len = cpu_to_le16(skb->len);
330 desc->flags = 0; 334 desc->flags = 0;
331 335
332 wmb(); 336 wmb();
333 ring_control->host_idx[1] = cpu_to_le32(idx + 1); 337 ring_control->host_idx[1] = cpu_to_le32(idx + 1);
334 338
335 if (free_on_tx) 339 if (free_on_tx)
336 priv->tx_buf_data[i] = data; 340 priv->tx_buf_data[i] = skb;
337 341
338 spin_unlock_irqrestore(&priv->lock, flags); 342 spin_unlock_irqrestore(&priv->lock, flags);
339 343
@@ -342,8 +346,10 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data,
342 346
343 /* FIXME: unlikely to happen because the device usually runs out of 347 /* FIXME: unlikely to happen because the device usually runs out of
344 memory before we fill the ring up, but we can make it impossible */ 348 memory before we fill the ring up, but we can make it impossible */
345 if (idx - device_idx > ARRAY_SIZE(ring_control->tx_data) - 2) 349 if (idx - device_idx > ARRAY_SIZE(ring_control->tx_data) - 2) {
350 p54_free_skb(dev, skb);
346 printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy)); 351 printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy));
352 }
347} 353}
348 354
349static void p54p_stop(struct ieee80211_hw *dev) 355static void p54p_stop(struct ieee80211_hw *dev)
@@ -393,7 +399,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
393 le16_to_cpu(desc->len), 399 le16_to_cpu(desc->len),
394 PCI_DMA_TODEVICE); 400 PCI_DMA_TODEVICE);
395 401
396 kfree(priv->tx_buf_data[i]); 402 p54_free_skb(dev, priv->tx_buf_data[i]);
397 priv->tx_buf_data[i] = NULL; 403 priv->tx_buf_data[i] = NULL;
398 } 404 }
399 405
@@ -405,7 +411,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
405 le16_to_cpu(desc->len), 411 le16_to_cpu(desc->len),
406 PCI_DMA_TODEVICE); 412 PCI_DMA_TODEVICE);
407 413
408 kfree(priv->tx_buf_mgmt[i]); 414 p54_free_skb(dev, priv->tx_buf_mgmt[i]);
409 priv->tx_buf_mgmt[i] = NULL; 415 priv->tx_buf_mgmt[i] = NULL;
410 } 416 }
411 417
@@ -481,7 +487,6 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
481 struct ieee80211_hw *dev; 487 struct ieee80211_hw *dev;
482 unsigned long mem_addr, mem_len; 488 unsigned long mem_addr, mem_len;
483 int err; 489 int err;
484 DECLARE_MAC_BUF(mac);
485 490
486 err = pci_enable_device(pdev); 491 err = pci_enable_device(pdev);
487 if (err) { 492 if (err) {
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index 75d749bccb0d..21ba526a45bf 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -28,6 +28,8 @@ MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
28MODULE_DESCRIPTION("Prism54 USB wireless driver"); 28MODULE_DESCRIPTION("Prism54 USB wireless driver");
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30MODULE_ALIAS("prism54usb"); 30MODULE_ALIAS("prism54usb");
31MODULE_FIRMWARE("isl3886usb");
32MODULE_FIRMWARE("isl3887usb");
31 33
32static struct usb_device_id p54u_table[] __devinitdata = { 34static struct usb_device_id p54u_table[] __devinitdata = {
33 /* Version 1 devices (pci chip + net2280) */ 35 /* Version 1 devices (pci chip + net2280) */
@@ -135,6 +137,16 @@ static void p54u_rx_cb(struct urb *urb)
135 usb_submit_urb(urb, GFP_ATOMIC); 137 usb_submit_urb(urb, GFP_ATOMIC);
136} 138}
137 139
140static void p54u_tx_reuse_skb_cb(struct urb *urb)
141{
142 struct sk_buff *skb = urb->context;
143 struct p54u_priv *priv = (struct p54u_priv *)((struct ieee80211_hw *)
144 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)))->priv;
145
146 skb_pull(skb, priv->common.tx_hdr_len);
147 usb_free_urb(urb);
148}
149
138static void p54u_tx_cb(struct urb *urb) 150static void p54u_tx_cb(struct urb *urb)
139{ 151{
140 usb_free_urb(urb); 152 usb_free_urb(urb);
@@ -146,6 +158,16 @@ static void p54u_tx_free_cb(struct urb *urb)
146 usb_free_urb(urb); 158 usb_free_urb(urb);
147} 159}
148 160
161static void p54u_tx_free_skb_cb(struct urb *urb)
162{
163 struct sk_buff *skb = urb->context;
164 struct ieee80211_hw *dev = (struct ieee80211_hw *)
165 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
166
167 p54_free_skb(dev, skb);
168 usb_free_urb(urb);
169}
170
149static int p54u_init_urbs(struct ieee80211_hw *dev) 171static int p54u_init_urbs(struct ieee80211_hw *dev)
150{ 172{
151 struct p54u_priv *priv = dev->priv; 173 struct p54u_priv *priv = dev->priv;
@@ -192,8 +214,8 @@ static void p54u_free_urbs(struct ieee80211_hw *dev)
192 } 214 }
193} 215}
194 216
195static void p54u_tx_3887(struct ieee80211_hw *dev, struct p54_control_hdr *data, 217static void p54u_tx_3887(struct ieee80211_hw *dev, struct sk_buff *skb,
196 size_t len, int free_on_tx) 218 int free_on_tx)
197{ 219{
198 struct p54u_priv *priv = dev->priv; 220 struct p54u_priv *priv = dev->priv;
199 struct urb *addr_urb, *data_urb; 221 struct urb *addr_urb, *data_urb;
@@ -209,11 +231,14 @@ static void p54u_tx_3887(struct ieee80211_hw *dev, struct p54_control_hdr *data,
209 } 231 }
210 232
211 usb_fill_bulk_urb(addr_urb, priv->udev, 233 usb_fill_bulk_urb(addr_urb, priv->udev,
212 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), &data->req_id, 234 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
213 sizeof(data->req_id), p54u_tx_cb, dev); 235 &((struct p54_hdr *)skb->data)->req_id, 4,
236 p54u_tx_cb, dev);
214 usb_fill_bulk_urb(data_urb, priv->udev, 237 usb_fill_bulk_urb(data_urb, priv->udev,
215 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), data, len, 238 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
216 free_on_tx ? p54u_tx_free_cb : p54u_tx_cb, dev); 239 skb->data, skb->len,
240 free_on_tx ? p54u_tx_free_skb_cb :
241 p54u_tx_reuse_skb_cb, skb);
217 242
218 usb_submit_urb(addr_urb, GFP_ATOMIC); 243 usb_submit_urb(addr_urb, GFP_ATOMIC);
219 usb_submit_urb(data_urb, GFP_ATOMIC); 244 usb_submit_urb(data_urb, GFP_ATOMIC);
@@ -232,31 +257,35 @@ static __le32 p54u_lm87_chksum(const u32 *data, size_t length)
232 return cpu_to_le32(chk); 257 return cpu_to_le32(chk);
233} 258}
234 259
235static void p54u_tx_lm87(struct ieee80211_hw *dev, 260static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb,
236 struct p54_control_hdr *data, 261 int free_on_tx)
237 size_t len, int free_on_tx)
238{ 262{
239 struct p54u_priv *priv = dev->priv; 263 struct p54u_priv *priv = dev->priv;
240 struct urb *data_urb; 264 struct urb *data_urb;
241 struct lm87_tx_hdr *hdr = (void *)data - sizeof(*hdr); 265 struct lm87_tx_hdr *hdr;
266 __le32 checksum;
267 __le32 addr = ((struct p54_hdr *)skb->data)->req_id;
242 268
243 data_urb = usb_alloc_urb(0, GFP_ATOMIC); 269 data_urb = usb_alloc_urb(0, GFP_ATOMIC);
244 if (!data_urb) 270 if (!data_urb)
245 return; 271 return;
246 272
247 hdr->chksum = p54u_lm87_chksum((u32 *)data, len); 273 checksum = p54u_lm87_chksum((u32 *)skb->data, skb->len);
248 hdr->device_addr = data->req_id; 274 hdr = (struct lm87_tx_hdr *)skb_push(skb, sizeof(*hdr));
275 hdr->chksum = checksum;
276 hdr->device_addr = addr;
249 277
250 usb_fill_bulk_urb(data_urb, priv->udev, 278 usb_fill_bulk_urb(data_urb, priv->udev,
251 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), hdr, 279 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
252 len + sizeof(*hdr), free_on_tx ? p54u_tx_free_cb : p54u_tx_cb, 280 skb->data, skb->len,
253 dev); 281 free_on_tx ? p54u_tx_free_skb_cb :
282 p54u_tx_reuse_skb_cb, skb);
254 283
255 usb_submit_urb(data_urb, GFP_ATOMIC); 284 usb_submit_urb(data_urb, GFP_ATOMIC);
256} 285}
257 286
258static void p54u_tx_net2280(struct ieee80211_hw *dev, struct p54_control_hdr *data, 287static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb,
259 size_t len, int free_on_tx) 288 int free_on_tx)
260{ 289{
261 struct p54u_priv *priv = dev->priv; 290 struct p54u_priv *priv = dev->priv;
262 struct urb *int_urb, *data_urb; 291 struct urb *int_urb, *data_urb;
@@ -284,11 +313,10 @@ static void p54u_tx_net2280(struct ieee80211_hw *dev, struct p54_control_hdr *da
284 reg->addr = cpu_to_le32(P54U_DEV_BASE); 313 reg->addr = cpu_to_le32(P54U_DEV_BASE);
285 reg->val = cpu_to_le32(ISL38XX_DEV_INT_DATA); 314 reg->val = cpu_to_le32(ISL38XX_DEV_INT_DATA);
286 315
287 len += sizeof(*data); 316 hdr = (void *)skb_push(skb, sizeof(*hdr));
288 hdr = (void *)data - sizeof(*hdr);
289 memset(hdr, 0, sizeof(*hdr)); 317 memset(hdr, 0, sizeof(*hdr));
290 hdr->device_addr = data->req_id; 318 hdr->device_addr = ((struct p54_hdr *)skb->data)->req_id;
291 hdr->len = cpu_to_le16(len); 319 hdr->len = cpu_to_le16(skb->len + sizeof(struct p54_hdr));
292 320
293 usb_fill_bulk_urb(int_urb, priv->udev, 321 usb_fill_bulk_urb(int_urb, priv->udev,
294 usb_sndbulkpipe(priv->udev, P54U_PIPE_DEV), reg, sizeof(*reg), 322 usb_sndbulkpipe(priv->udev, P54U_PIPE_DEV), reg, sizeof(*reg),
@@ -296,8 +324,10 @@ static void p54u_tx_net2280(struct ieee80211_hw *dev, struct p54_control_hdr *da
296 usb_submit_urb(int_urb, GFP_ATOMIC); 324 usb_submit_urb(int_urb, GFP_ATOMIC);
297 325
298 usb_fill_bulk_urb(data_urb, priv->udev, 326 usb_fill_bulk_urb(data_urb, priv->udev,
299 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), hdr, len + sizeof(*hdr), 327 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
300 free_on_tx ? p54u_tx_free_cb : p54u_tx_cb, dev); 328 skb->data, skb->len,
329 free_on_tx ? p54u_tx_free_skb_cb :
330 p54u_tx_reuse_skb_cb, skb);
301 usb_submit_urb(data_urb, GFP_ATOMIC); 331 usb_submit_urb(data_urb, GFP_ATOMIC);
302} 332}
303 333
@@ -387,10 +417,13 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
387 goto err_reset; 417 goto err_reset;
388 } 418 }
389 419
390 err = request_firmware(&fw_entry, "isl3887usb_bare", &priv->udev->dev); 420 err = request_firmware(&fw_entry, "isl3887usb", &priv->udev->dev);
391 if (err) { 421 if (err) {
392 printk(KERN_ERR "p54usb: cannot find firmware (isl3887usb_bare)!\n"); 422 printk(KERN_ERR "p54usb: cannot find firmware (isl3887usb)\n");
393 goto err_req_fw_failed; 423 err = request_firmware(&fw_entry, "isl3887usb_bare",
424 &priv->udev->dev);
425 if (err)
426 goto err_req_fw_failed;
394 } 427 }
395 428
396 err = p54_parse_firmware(dev, fw_entry); 429 err = p54_parse_firmware(dev, fw_entry);
@@ -525,11 +558,15 @@ static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
525 return -ENOMEM; 558 return -ENOMEM;
526 } 559 }
527 560
528 err = request_firmware(&fw_entry, "isl3890usb", &priv->udev->dev); 561 err = request_firmware(&fw_entry, "isl3886usb", &priv->udev->dev);
529 if (err) { 562 if (err) {
530 printk(KERN_ERR "p54usb: cannot find firmware (isl3890usb)!\n"); 563 printk(KERN_ERR "p54usb: cannot find firmware (isl3886usb)\n");
531 kfree(buf); 564 err = request_firmware(&fw_entry, "isl3890usb",
532 return err; 565 &priv->udev->dev);
566 if (err) {
567 kfree(buf);
568 return err;
569 }
533 } 570 }
534 571
535 err = p54_parse_firmware(dev, fw_entry); 572 err = p54_parse_firmware(dev, fw_entry);
@@ -786,7 +823,6 @@ static int __devinit p54u_probe(struct usb_interface *intf,
786 struct p54u_priv *priv; 823 struct p54u_priv *priv;
787 int err; 824 int err;
788 unsigned int i, recognized_pipes; 825 unsigned int i, recognized_pipes;
789 DECLARE_MAC_BUF(mac);
790 826
791 dev = p54_init_common(sizeof(*priv)); 827 dev = p54_init_common(sizeof(*priv));
792 if (!dev) { 828 if (!dev) {
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index 16e68f4b654a..57a150a22de5 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -2028,12 +2028,11 @@ static void
2028format_event(islpci_private *priv, char *dest, const char *str, 2028format_event(islpci_private *priv, char *dest, const char *str,
2029 const struct obj_mlme *mlme, u16 *length, int error) 2029 const struct obj_mlme *mlme, u16 *length, int error)
2030{ 2030{
2031 DECLARE_MAC_BUF(mac);
2032 int n = snprintf(dest, IW_CUSTOM_MAX, 2031 int n = snprintf(dest, IW_CUSTOM_MAX,
2033 "%s %s %s %s (%2.2X)", 2032 "%s %s %pM %s (%2.2X)",
2034 str, 2033 str,
2035 ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"), 2034 ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
2036 print_mac(mac, mlme->address), 2035 mlme->address,
2037 (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ") 2036 (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
2038 : ""), mlme->code); 2037 : ""), mlme->code);
2039 BUG_ON(n > IW_CUSTOM_MAX); 2038 BUG_ON(n > IW_CUSTOM_MAX);
@@ -2113,7 +2112,6 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
2113{ 2112{
2114 struct list_head *ptr; 2113 struct list_head *ptr;
2115 struct islpci_bss_wpa_ie *bss = NULL; 2114 struct islpci_bss_wpa_ie *bss = NULL;
2116 DECLARE_MAC_BUF(mac);
2117 2115
2118 if (wpa_ie_len > MAX_WPA_IE_LEN) 2116 if (wpa_ie_len > MAX_WPA_IE_LEN)
2119 wpa_ie_len = MAX_WPA_IE_LEN; 2117 wpa_ie_len = MAX_WPA_IE_LEN;
@@ -2154,7 +2152,7 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
2154 bss->last_update = jiffies; 2152 bss->last_update = jiffies;
2155 } else { 2153 } else {
2156 printk(KERN_DEBUG "Failed to add BSS WPA entry for " 2154 printk(KERN_DEBUG "Failed to add BSS WPA entry for "
2157 "%s\n", print_mac(mac, bssid)); 2155 "%pM\n", bssid);
2158 } 2156 }
2159 2157
2160 /* expire old entries from WPA list */ 2158 /* expire old entries from WPA list */
@@ -2219,7 +2217,6 @@ prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
2219{ 2217{
2220 struct ieee80211_beacon_phdr *hdr; 2218 struct ieee80211_beacon_phdr *hdr;
2221 u8 *pos, *end; 2219 u8 *pos, *end;
2222 DECLARE_MAC_BUF(mac);
2223 2220
2224 if (!priv->wpa) 2221 if (!priv->wpa)
2225 return; 2222 return;
@@ -2230,7 +2227,7 @@ prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
2230 while (pos < end) { 2227 while (pos < end) {
2231 if (pos + 2 + pos[1] > end) { 2228 if (pos + 2 + pos[1] > end) {
2232 printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed " 2229 printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
2233 "for %s\n", print_mac(mac, addr)); 2230 "for %pM\n", addr);
2234 return; 2231 return;
2235 } 2232 }
2236 if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 && 2233 if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
@@ -2269,7 +2266,6 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2269 size_t len = 0; /* u16, better? */ 2266 size_t len = 0; /* u16, better? */
2270 u8 *payload = NULL, *pos = NULL; 2267 u8 *payload = NULL, *pos = NULL;
2271 int ret; 2268 int ret;
2272 DECLARE_MAC_BUF(mac);
2273 2269
2274 /* I think all trapable objects are listed here. 2270 /* I think all trapable objects are listed here.
2275 * Some oids have a EX version. The difference is that they are emitted 2271 * Some oids have a EX version. The difference is that they are emitted
@@ -2358,8 +2354,8 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2358 break; 2354 break;
2359 2355
2360 memcpy(&confirm->address, mlmeex->address, ETH_ALEN); 2356 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2361 printk(KERN_DEBUG "Authenticate from: address:\t%s\n", 2357 printk(KERN_DEBUG "Authenticate from: address:\t%pM\n",
2362 print_mac(mac, mlmeex->address)); 2358 mlmeex->address);
2363 confirm->id = -1; /* or mlmeex->id ? */ 2359 confirm->id = -1; /* or mlmeex->id ? */
2364 confirm->state = 0; /* not used */ 2360 confirm->state = 0; /* not used */
2365 confirm->code = 0; 2361 confirm->code = 0;
@@ -2404,8 +2400,8 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2404 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie); 2400 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2405 2401
2406 if (!wpa_ie_len) { 2402 if (!wpa_ie_len) {
2407 printk(KERN_DEBUG "No WPA IE found from address:\t%s\n", 2403 printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
2408 print_mac(mac, mlmeex->address)); 2404 mlmeex->address);
2409 kfree(confirm); 2405 kfree(confirm);
2410 break; 2406 break;
2411 } 2407 }
@@ -2441,8 +2437,8 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2441 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie); 2437 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2442 2438
2443 if (!wpa_ie_len) { 2439 if (!wpa_ie_len) {
2444 printk(KERN_DEBUG "No WPA IE found from address:\t%s\n", 2440 printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
2445 print_mac(mac, mlmeex->address)); 2441 mlmeex->address);
2446 kfree(confirm); 2442 kfree(confirm);
2447 break; 2443 break;
2448 } 2444 }
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 1404a5717520..81b71f07f5ad 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -414,7 +414,6 @@ static int ray_config(struct pcmcia_device *link)
414 memreq_t mem; 414 memreq_t mem;
415 struct net_device *dev = (struct net_device *)link->priv; 415 struct net_device *dev = (struct net_device *)link->priv;
416 ray_dev_t *local = netdev_priv(dev); 416 ray_dev_t *local = netdev_priv(dev);
417 DECLARE_MAC_BUF(mac);
418 417
419 DEBUG(1, "ray_config(0x%p)\n", link); 418 DEBUG(1, "ray_config(0x%p)\n", link);
420 419
@@ -485,8 +484,8 @@ static int ray_config(struct pcmcia_device *link)
485 strcpy(local->node.dev_name, dev->name); 484 strcpy(local->node.dev_name, dev->name);
486 link->dev_node = &local->node; 485 link->dev_node = &local->node;
487 486
488 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %s\n", 487 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %pM\n",
489 dev->name, dev->irq, print_mac(mac, dev->dev_addr)); 488 dev->name, dev->irq, dev->dev_addr);
490 489
491 return 0; 490 return 0;
492 491
@@ -2285,7 +2284,6 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i
2285 2284
2286 skb->protocol = eth_type_trans(skb,dev); 2285 skb->protocol = eth_type_trans(skb,dev);
2287 netif_rx(skb); 2286 netif_rx(skb);
2288 dev->last_rx = jiffies;
2289 local->stats.rx_packets++; 2287 local->stats.rx_packets++;
2290 local->stats.rx_bytes += total_len; 2288 local->stats.rx_bytes += total_len;
2291 2289
@@ -2595,7 +2593,6 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
2595 UCHAR *p; 2593 UCHAR *p;
2596 struct freq_hop_element *pfh; 2594 struct freq_hop_element *pfh;
2597 UCHAR c[33]; 2595 UCHAR c[33];
2598 DECLARE_MAC_BUF(mac);
2599 2596
2600 link = this_device; 2597 link = this_device;
2601 if (!link) 2598 if (!link)
@@ -2623,8 +2620,7 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
2623 nettype[local->sparm.b5.a_network_type], c); 2620 nettype[local->sparm.b5.a_network_type], c);
2624 2621
2625 p = local->bss_id; 2622 p = local->bss_id;
2626 seq_printf(m, "BSSID = %s\n", 2623 seq_printf(m, "BSSID = %pM\n", p);
2627 print_mac(mac, p));
2628 2624
2629 seq_printf(m, "Country code = %d\n", 2625 seq_printf(m, "Country code = %d\n",
2630 local->sparm.b5.a_curr_country_code); 2626 local->sparm.b5.a_curr_country_code);
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 2b414899dfa0..607ce9f61b54 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -37,11 +37,11 @@
37#include <linux/usb.h> 37#include <linux/usb.h>
38#include <linux/usb/cdc.h> 38#include <linux/usb/cdc.h>
39#include <linux/wireless.h> 39#include <linux/wireless.h>
40#include <linux/ieee80211.h>
40#include <linux/if_arp.h> 41#include <linux/if_arp.h>
41#include <linux/ctype.h> 42#include <linux/ctype.h>
42#include <linux/spinlock.h> 43#include <linux/spinlock.h>
43#include <net/iw_handler.h> 44#include <net/iw_handler.h>
44#include <net/ieee80211.h>
45#include <linux/usb/usbnet.h> 45#include <linux/usb/usbnet.h>
46#include <linux/usb/rndis_host.h> 46#include <linux/usb/rndis_host.h>
47 47
@@ -1104,7 +1104,7 @@ static int rndis_iw_get_range(struct net_device *dev,
1104 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1104 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1105{ 1105{
1106 struct iw_range *range = (struct iw_range *)extra; 1106 struct iw_range *range = (struct iw_range *)extra;
1107 struct usbnet *usbdev = dev->priv; 1107 struct usbnet *usbdev = netdev_priv(dev);
1108 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1108 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1109 int len, ret, i, j, num, has_80211g_rates; 1109 int len, ret, i, j, num, has_80211g_rates;
1110 u8 rates[8]; 1110 u8 rates[8];
@@ -1210,7 +1210,7 @@ static int rndis_iw_get_range(struct net_device *dev,
1210static int rndis_iw_get_name(struct net_device *dev, 1210static int rndis_iw_get_name(struct net_device *dev,
1211 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1211 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1212{ 1212{
1213 struct usbnet *usbdev = dev->priv; 1213 struct usbnet *usbdev = netdev_priv(dev);
1214 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1214 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1215 1215
1216 strcpy(wrqu->name, priv->name); 1216 strcpy(wrqu->name, priv->name);
@@ -1223,7 +1223,7 @@ static int rndis_iw_set_essid(struct net_device *dev,
1223{ 1223{
1224 struct ndis_80211_ssid ssid; 1224 struct ndis_80211_ssid ssid;
1225 int length = wrqu->essid.length; 1225 int length = wrqu->essid.length;
1226 struct usbnet *usbdev = dev->priv; 1226 struct usbnet *usbdev = netdev_priv(dev);
1227 1227
1228 devdbg(usbdev, "SIOCSIWESSID: [flags:%d,len:%d] '%.32s'", 1228 devdbg(usbdev, "SIOCSIWESSID: [flags:%d,len:%d] '%.32s'",
1229 wrqu->essid.flags, wrqu->essid.length, essid); 1229 wrqu->essid.flags, wrqu->essid.length, essid);
@@ -1250,7 +1250,7 @@ static int rndis_iw_get_essid(struct net_device *dev,
1250 struct iw_request_info *info, union iwreq_data *wrqu, char *essid) 1250 struct iw_request_info *info, union iwreq_data *wrqu, char *essid)
1251{ 1251{
1252 struct ndis_80211_ssid ssid; 1252 struct ndis_80211_ssid ssid;
1253 struct usbnet *usbdev = dev->priv; 1253 struct usbnet *usbdev = netdev_priv(dev);
1254 int ret; 1254 int ret;
1255 1255
1256 ret = get_essid(usbdev, &ssid); 1256 ret = get_essid(usbdev, &ssid);
@@ -1273,15 +1273,14 @@ static int rndis_iw_get_essid(struct net_device *dev,
1273static int rndis_iw_get_bssid(struct net_device *dev, 1273static int rndis_iw_get_bssid(struct net_device *dev,
1274 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1274 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1275{ 1275{
1276 struct usbnet *usbdev = dev->priv; 1276 struct usbnet *usbdev = netdev_priv(dev);
1277 unsigned char bssid[ETH_ALEN]; 1277 unsigned char bssid[ETH_ALEN];
1278 int ret; 1278 int ret;
1279 DECLARE_MAC_BUF(mac);
1280 1279
1281 ret = get_bssid(usbdev, bssid); 1280 ret = get_bssid(usbdev, bssid);
1282 1281
1283 if (ret == 0) 1282 if (ret == 0)
1284 devdbg(usbdev, "SIOCGIWAP: %s", print_mac(mac, bssid)); 1283 devdbg(usbdev, "SIOCGIWAP: %pM", bssid);
1285 else 1284 else
1286 devdbg(usbdev, "SIOCGIWAP: <not associated>"); 1285 devdbg(usbdev, "SIOCGIWAP: <not associated>");
1287 1286
@@ -1295,12 +1294,11 @@ static int rndis_iw_get_bssid(struct net_device *dev,
1295static int rndis_iw_set_bssid(struct net_device *dev, 1294static int rndis_iw_set_bssid(struct net_device *dev,
1296 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1295 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1297{ 1296{
1298 struct usbnet *usbdev = dev->priv; 1297 struct usbnet *usbdev = netdev_priv(dev);
1299 u8 *bssid = (u8 *)wrqu->ap_addr.sa_data; 1298 u8 *bssid = (u8 *)wrqu->ap_addr.sa_data;
1300 DECLARE_MAC_BUF(mac);
1301 int ret; 1299 int ret;
1302 1300
1303 devdbg(usbdev, "SIOCSIWAP: %s", print_mac(mac, bssid)); 1301 devdbg(usbdev, "SIOCSIWAP: %pM", bssid);
1304 1302
1305 ret = rndis_set_oid(usbdev, OID_802_11_BSSID, bssid, ETH_ALEN); 1303 ret = rndis_set_oid(usbdev, OID_802_11_BSSID, bssid, ETH_ALEN);
1306 1304
@@ -1318,7 +1316,7 @@ static int rndis_iw_set_auth(struct net_device *dev,
1318 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1316 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1319{ 1317{
1320 struct iw_param *p = &wrqu->param; 1318 struct iw_param *p = &wrqu->param;
1321 struct usbnet *usbdev = dev->priv; 1319 struct usbnet *usbdev = netdev_priv(dev);
1322 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1320 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1323 int ret = -ENOTSUPP; 1321 int ret = -ENOTSUPP;
1324 1322
@@ -1399,7 +1397,7 @@ static int rndis_iw_get_auth(struct net_device *dev,
1399 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1397 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1400{ 1398{
1401 struct iw_param *p = &wrqu->param; 1399 struct iw_param *p = &wrqu->param;
1402 struct usbnet *usbdev = dev->priv; 1400 struct usbnet *usbdev = netdev_priv(dev);
1403 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1401 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1404 1402
1405 switch (p->flags & IW_AUTH_INDEX) { 1403 switch (p->flags & IW_AUTH_INDEX) {
@@ -1431,7 +1429,7 @@ static int rndis_iw_get_mode(struct net_device *dev,
1431 struct iw_request_info *info, 1429 struct iw_request_info *info,
1432 union iwreq_data *wrqu, char *extra) 1430 union iwreq_data *wrqu, char *extra)
1433{ 1431{
1434 struct usbnet *usbdev = dev->priv; 1432 struct usbnet *usbdev = netdev_priv(dev);
1435 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1433 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1436 1434
1437 switch (priv->infra_mode) { 1435 switch (priv->infra_mode) {
@@ -1454,7 +1452,7 @@ static int rndis_iw_get_mode(struct net_device *dev,
1454static int rndis_iw_set_mode(struct net_device *dev, 1452static int rndis_iw_set_mode(struct net_device *dev,
1455 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1453 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1456{ 1454{
1457 struct usbnet *usbdev = dev->priv; 1455 struct usbnet *usbdev = netdev_priv(dev);
1458 int mode; 1456 int mode;
1459 1457
1460 devdbg(usbdev, "SIOCSIWMODE: %08x", wrqu->mode); 1458 devdbg(usbdev, "SIOCSIWMODE: %08x", wrqu->mode);
@@ -1479,7 +1477,7 @@ static int rndis_iw_set_mode(struct net_device *dev,
1479static int rndis_iw_set_encode(struct net_device *dev, 1477static int rndis_iw_set_encode(struct net_device *dev,
1480 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1478 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1481{ 1479{
1482 struct usbnet *usbdev = dev->priv; 1480 struct usbnet *usbdev = netdev_priv(dev);
1483 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1481 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1484 int ret, index, key_len; 1482 int ret, index, key_len;
1485 u8 *key; 1483 u8 *key;
@@ -1542,7 +1540,7 @@ static int rndis_iw_set_encode_ext(struct net_device *dev,
1542 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1540 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1543{ 1541{
1544 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1542 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1545 struct usbnet *usbdev = dev->priv; 1543 struct usbnet *usbdev = netdev_priv(dev);
1546 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1544 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1547 struct ndis_80211_key ndis_key; 1545 struct ndis_80211_key ndis_key;
1548 int keyidx, ret; 1546 int keyidx, ret;
@@ -1627,7 +1625,7 @@ static int rndis_iw_set_encode_ext(struct net_device *dev,
1627static int rndis_iw_set_scan(struct net_device *dev, 1625static int rndis_iw_set_scan(struct net_device *dev,
1628 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1626 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1629{ 1627{
1630 struct usbnet *usbdev = dev->priv; 1628 struct usbnet *usbdev = netdev_priv(dev);
1631 union iwreq_data evt; 1629 union iwreq_data evt;
1632 int ret = -EINVAL; 1630 int ret = -EINVAL;
1633 __le32 tmp; 1631 __le32 tmp;
@@ -1652,19 +1650,18 @@ static char *rndis_translate_scan(struct net_device *dev,
1652 struct ndis_80211_bssid_ex *bssid) 1650 struct ndis_80211_bssid_ex *bssid)
1653{ 1651{
1654#ifdef DEBUG 1652#ifdef DEBUG
1655 struct usbnet *usbdev = dev->priv; 1653 struct usbnet *usbdev = netdev_priv(dev);
1656#endif 1654#endif
1657 struct ieee80211_info_element *ie; 1655 u8 *ie;
1658 char *current_val; 1656 char *current_val;
1659 int bssid_len, ie_len, i; 1657 int bssid_len, ie_len, i;
1660 u32 beacon, atim; 1658 u32 beacon, atim;
1661 struct iw_event iwe; 1659 struct iw_event iwe;
1662 unsigned char sbuf[32]; 1660 unsigned char sbuf[32];
1663 DECLARE_MAC_BUF(mac);
1664 1661
1665 bssid_len = le32_to_cpu(bssid->length); 1662 bssid_len = le32_to_cpu(bssid->length);
1666 1663
1667 devdbg(usbdev, "BSSID %s", print_mac(mac, bssid->mac)); 1664 devdbg(usbdev, "BSSID %pM", bssid->mac);
1668 iwe.cmd = SIOCGIWAP; 1665 iwe.cmd = SIOCGIWAP;
1669 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 1666 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1670 memcpy(iwe.u.ap_addr.sa_data, bssid->mac, ETH_ALEN); 1667 memcpy(iwe.u.ap_addr.sa_data, bssid->mac, ETH_ALEN);
@@ -1753,20 +1750,20 @@ static char *rndis_translate_scan(struct net_device *dev,
1753 ie_len = min(bssid_len - (int)sizeof(*bssid), 1750 ie_len = min(bssid_len - (int)sizeof(*bssid),
1754 (int)le32_to_cpu(bssid->ie_length)); 1751 (int)le32_to_cpu(bssid->ie_length));
1755 ie_len -= sizeof(struct ndis_80211_fixed_ies); 1752 ie_len -= sizeof(struct ndis_80211_fixed_ies);
1756 while (ie_len >= sizeof(*ie) && sizeof(*ie) + ie->len <= ie_len) { 1753 while (ie_len >= 2 && 2 + ie[1] <= ie_len) {
1757 if ((ie->id == MFIE_TYPE_GENERIC && ie->len >= 4 && 1754 if ((ie[0] == WLAN_EID_GENERIC && ie[1] >= 4 &&
1758 memcmp(ie->data, "\x00\x50\xf2\x01", 4) == 0) || 1755 memcmp(ie + 2, "\x00\x50\xf2\x01", 4) == 0) ||
1759 ie->id == MFIE_TYPE_RSN) { 1756 ie[0] == WLAN_EID_RSN) {
1760 devdbg(usbdev, "IE: WPA%d", 1757 devdbg(usbdev, "IE: WPA%d",
1761 (ie->id == MFIE_TYPE_RSN) ? 2 : 1); 1758 (ie[0] == WLAN_EID_RSN) ? 2 : 1);
1762 iwe.cmd = IWEVGENIE; 1759 iwe.cmd = IWEVGENIE;
1763 iwe.u.data.length = min(ie->len + 2, MAX_WPA_IE_LEN); 1760 /* arbitrary cut-off at 64 */
1764 cev = iwe_stream_add_point(info, cev, end_buf, &iwe, 1761 iwe.u.data.length = min(ie[1] + 2, 64);
1765 (u8 *)ie); 1762 cev = iwe_stream_add_point(info, cev, end_buf, &iwe, ie);
1766 } 1763 }
1767 1764
1768 ie_len -= sizeof(*ie) + ie->len; 1765 ie_len -= 2 + ie[1];
1769 ie = (struct ieee80211_info_element *)&ie->data[ie->len]; 1766 ie += 2 + ie[1];
1770 } 1767 }
1771 1768
1772 return cev; 1769 return cev;
@@ -1776,7 +1773,7 @@ static char *rndis_translate_scan(struct net_device *dev,
1776static int rndis_iw_get_scan(struct net_device *dev, 1773static int rndis_iw_get_scan(struct net_device *dev,
1777 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1774 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1778{ 1775{
1779 struct usbnet *usbdev = dev->priv; 1776 struct usbnet *usbdev = netdev_priv(dev);
1780 void *buf = NULL; 1777 void *buf = NULL;
1781 char *cev = extra; 1778 char *cev = extra;
1782 struct ndis_80211_bssid_list_ex *bssid_list; 1779 struct ndis_80211_bssid_list_ex *bssid_list;
@@ -1822,7 +1819,7 @@ out:
1822static int rndis_iw_set_genie(struct net_device *dev, 1819static int rndis_iw_set_genie(struct net_device *dev,
1823 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1820 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1824{ 1821{
1825 struct usbnet *usbdev = dev->priv; 1822 struct usbnet *usbdev = netdev_priv(dev);
1826 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1823 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1827 int ret = 0; 1824 int ret = 0;
1828 1825
@@ -1856,7 +1853,7 @@ static int rndis_iw_set_genie(struct net_device *dev,
1856static int rndis_iw_get_genie(struct net_device *dev, 1853static int rndis_iw_get_genie(struct net_device *dev,
1857 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1854 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1858{ 1855{
1859 struct usbnet *usbdev = dev->priv; 1856 struct usbnet *usbdev = netdev_priv(dev);
1860 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1857 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1861 1858
1862 devdbg(usbdev, "SIOCGIWGENIE"); 1859 devdbg(usbdev, "SIOCGIWGENIE");
@@ -1879,7 +1876,7 @@ static int rndis_iw_get_genie(struct net_device *dev,
1879static int rndis_iw_set_rts(struct net_device *dev, 1876static int rndis_iw_set_rts(struct net_device *dev,
1880 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1877 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1881{ 1878{
1882 struct usbnet *usbdev = dev->priv; 1879 struct usbnet *usbdev = netdev_priv(dev);
1883 __le32 tmp; 1880 __le32 tmp;
1884 devdbg(usbdev, "SIOCSIWRTS"); 1881 devdbg(usbdev, "SIOCSIWRTS");
1885 1882
@@ -1892,7 +1889,7 @@ static int rndis_iw_set_rts(struct net_device *dev,
1892static int rndis_iw_get_rts(struct net_device *dev, 1889static int rndis_iw_get_rts(struct net_device *dev,
1893 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1890 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1894{ 1891{
1895 struct usbnet *usbdev = dev->priv; 1892 struct usbnet *usbdev = netdev_priv(dev);
1896 __le32 tmp; 1893 __le32 tmp;
1897 int len, ret; 1894 int len, ret;
1898 1895
@@ -1913,7 +1910,7 @@ static int rndis_iw_get_rts(struct net_device *dev,
1913static int rndis_iw_set_frag(struct net_device *dev, 1910static int rndis_iw_set_frag(struct net_device *dev,
1914 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1911 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1915{ 1912{
1916 struct usbnet *usbdev = dev->priv; 1913 struct usbnet *usbdev = netdev_priv(dev);
1917 __le32 tmp; 1914 __le32 tmp;
1918 1915
1919 devdbg(usbdev, "SIOCSIWFRAG"); 1916 devdbg(usbdev, "SIOCSIWFRAG");
@@ -1927,7 +1924,7 @@ static int rndis_iw_set_frag(struct net_device *dev,
1927static int rndis_iw_get_frag(struct net_device *dev, 1924static int rndis_iw_get_frag(struct net_device *dev,
1928 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1925 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1929{ 1926{
1930 struct usbnet *usbdev = dev->priv; 1927 struct usbnet *usbdev = netdev_priv(dev);
1931 __le32 tmp; 1928 __le32 tmp;
1932 int len, ret; 1929 int len, ret;
1933 1930
@@ -1947,7 +1944,7 @@ static int rndis_iw_get_frag(struct net_device *dev,
1947static int rndis_iw_set_nick(struct net_device *dev, 1944static int rndis_iw_set_nick(struct net_device *dev,
1948 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1945 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1949{ 1946{
1950 struct usbnet *usbdev = dev->priv; 1947 struct usbnet *usbdev = netdev_priv(dev);
1951 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1948 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1952 1949
1953 devdbg(usbdev, "SIOCSIWNICK"); 1950 devdbg(usbdev, "SIOCSIWNICK");
@@ -1964,7 +1961,7 @@ static int rndis_iw_set_nick(struct net_device *dev,
1964static int rndis_iw_get_nick(struct net_device *dev, 1961static int rndis_iw_get_nick(struct net_device *dev,
1965 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1962 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1966{ 1963{
1967 struct usbnet *usbdev = dev->priv; 1964 struct usbnet *usbdev = netdev_priv(dev);
1968 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 1965 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
1969 1966
1970 wrqu->data.flags = 1; 1967 wrqu->data.flags = 1;
@@ -1980,7 +1977,7 @@ static int rndis_iw_get_nick(struct net_device *dev,
1980static int rndis_iw_set_freq(struct net_device *dev, 1977static int rndis_iw_set_freq(struct net_device *dev,
1981 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1978 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1982{ 1979{
1983 struct usbnet *usbdev = dev->priv; 1980 struct usbnet *usbdev = netdev_priv(dev);
1984 struct ndis_80211_conf config; 1981 struct ndis_80211_conf config;
1985 unsigned int dsconfig; 1982 unsigned int dsconfig;
1986 int len, ret; 1983 int len, ret;
@@ -2011,7 +2008,7 @@ static int rndis_iw_set_freq(struct net_device *dev,
2011static int rndis_iw_get_freq(struct net_device *dev, 2008static int rndis_iw_get_freq(struct net_device *dev,
2012 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2009 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2013{ 2010{
2014 struct usbnet *usbdev = dev->priv; 2011 struct usbnet *usbdev = netdev_priv(dev);
2015 struct ndis_80211_conf config; 2012 struct ndis_80211_conf config;
2016 int len, ret; 2013 int len, ret;
2017 2014
@@ -2028,7 +2025,7 @@ static int rndis_iw_get_freq(struct net_device *dev,
2028static int rndis_iw_get_txpower(struct net_device *dev, 2025static int rndis_iw_get_txpower(struct net_device *dev,
2029 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2026 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2030{ 2027{
2031 struct usbnet *usbdev = dev->priv; 2028 struct usbnet *usbdev = netdev_priv(dev);
2032 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2029 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
2033 __le32 tx_power; 2030 __le32 tx_power;
2034 int ret = 0, len; 2031 int ret = 0, len;
@@ -2062,7 +2059,7 @@ static int rndis_iw_get_txpower(struct net_device *dev,
2062static int rndis_iw_set_txpower(struct net_device *dev, 2059static int rndis_iw_set_txpower(struct net_device *dev,
2063 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2060 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2064{ 2061{
2065 struct usbnet *usbdev = dev->priv; 2062 struct usbnet *usbdev = netdev_priv(dev);
2066 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2063 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
2067 __le32 tx_power = 0; 2064 __le32 tx_power = 0;
2068 int ret = 0; 2065 int ret = 0;
@@ -2114,7 +2111,7 @@ static int rndis_iw_set_txpower(struct net_device *dev,
2114static int rndis_iw_get_rate(struct net_device *dev, 2111static int rndis_iw_get_rate(struct net_device *dev,
2115 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2112 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2116{ 2113{
2117 struct usbnet *usbdev = dev->priv; 2114 struct usbnet *usbdev = netdev_priv(dev);
2118 __le32 tmp; 2115 __le32 tmp;
2119 int ret, len; 2116 int ret, len;
2120 2117
@@ -2132,7 +2129,7 @@ static int rndis_iw_get_rate(struct net_device *dev,
2132static int rndis_iw_set_mlme(struct net_device *dev, 2129static int rndis_iw_set_mlme(struct net_device *dev,
2133 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2130 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2134{ 2131{
2135 struct usbnet *usbdev = dev->priv; 2132 struct usbnet *usbdev = netdev_priv(dev);
2136 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2133 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
2137 struct iw_mlme *mlme = (struct iw_mlme *)extra; 2134 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2138 unsigned char bssid[ETH_ALEN]; 2135 unsigned char bssid[ETH_ALEN];
@@ -2157,7 +2154,7 @@ static int rndis_iw_set_mlme(struct net_device *dev,
2157 2154
2158static struct iw_statistics *rndis_get_wireless_stats(struct net_device *dev) 2155static struct iw_statistics *rndis_get_wireless_stats(struct net_device *dev)
2159{ 2156{
2160 struct usbnet *usbdev = dev->priv; 2157 struct usbnet *usbdev = netdev_priv(dev);
2161 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2158 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
2162 unsigned long flags; 2159 unsigned long flags;
2163 2160
@@ -2287,7 +2284,7 @@ get_bssid:
2287 2284
2288static void rndis_wext_set_multicast_list(struct net_device *dev) 2285static void rndis_wext_set_multicast_list(struct net_device *dev)
2289{ 2286{
2290 struct usbnet *usbdev = dev->priv; 2287 struct usbnet *usbdev = netdev_priv(dev);
2291 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2288 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
2292 2289
2293 if (test_bit(WORK_SET_MULTICAST_LIST, &priv->work_pending)) 2290 if (test_bit(WORK_SET_MULTICAST_LIST, &priv->work_pending))
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 08cb9eec16a6..42bd38ac7a1d 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -188,43 +188,34 @@ static void rt2400pci_eepromregister_write(struct eeprom_93cx6 *eeprom)
188} 188}
189 189
190#ifdef CONFIG_RT2X00_LIB_DEBUGFS 190#ifdef CONFIG_RT2X00_LIB_DEBUGFS
191#define CSR_OFFSET(__word) ( CSR_REG_BASE + ((__word) * sizeof(u32)) )
192
193static void rt2400pci_read_csr(struct rt2x00_dev *rt2x00dev,
194 const unsigned int word, u32 *data)
195{
196 rt2x00pci_register_read(rt2x00dev, CSR_OFFSET(word), data);
197}
198
199static void rt2400pci_write_csr(struct rt2x00_dev *rt2x00dev,
200 const unsigned int word, u32 data)
201{
202 rt2x00pci_register_write(rt2x00dev, CSR_OFFSET(word), data);
203}
204
205static const struct rt2x00debug rt2400pci_rt2x00debug = { 191static const struct rt2x00debug rt2400pci_rt2x00debug = {
206 .owner = THIS_MODULE, 192 .owner = THIS_MODULE,
207 .csr = { 193 .csr = {
208 .read = rt2400pci_read_csr, 194 .read = rt2x00pci_register_read,
209 .write = rt2400pci_write_csr, 195 .write = rt2x00pci_register_write,
196 .flags = RT2X00DEBUGFS_OFFSET,
197 .word_base = CSR_REG_BASE,
210 .word_size = sizeof(u32), 198 .word_size = sizeof(u32),
211 .word_count = CSR_REG_SIZE / sizeof(u32), 199 .word_count = CSR_REG_SIZE / sizeof(u32),
212 }, 200 },
213 .eeprom = { 201 .eeprom = {
214 .read = rt2x00_eeprom_read, 202 .read = rt2x00_eeprom_read,
215 .write = rt2x00_eeprom_write, 203 .write = rt2x00_eeprom_write,
204 .word_base = EEPROM_BASE,
216 .word_size = sizeof(u16), 205 .word_size = sizeof(u16),
217 .word_count = EEPROM_SIZE / sizeof(u16), 206 .word_count = EEPROM_SIZE / sizeof(u16),
218 }, 207 },
219 .bbp = { 208 .bbp = {
220 .read = rt2400pci_bbp_read, 209 .read = rt2400pci_bbp_read,
221 .write = rt2400pci_bbp_write, 210 .write = rt2400pci_bbp_write,
211 .word_base = BBP_BASE,
222 .word_size = sizeof(u8), 212 .word_size = sizeof(u8),
223 .word_count = BBP_SIZE / sizeof(u8), 213 .word_count = BBP_SIZE / sizeof(u8),
224 }, 214 },
225 .rf = { 215 .rf = {
226 .read = rt2x00_rf_read, 216 .read = rt2x00_rf_read,
227 .write = rt2400pci_rf_write, 217 .write = rt2400pci_rf_write,
218 .word_base = RF_BASE,
228 .word_size = sizeof(u32), 219 .word_size = sizeof(u32),
229 .word_count = RF_SIZE / sizeof(u32), 220 .word_count = RF_SIZE / sizeof(u32),
230 }, 221 },
@@ -396,12 +387,74 @@ static void rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
396 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84); 387 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
397 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); 388 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
398 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); 389 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
390
391 rt2x00pci_register_write(rt2x00dev, ARCSR1, erp->basic_rates);
392
393 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
394 rt2x00_set_field32(&reg, CSR11_SLOT_TIME, erp->slot_time);
395 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
396
397 rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
398 rt2x00_set_field32(&reg, CSR18_SIFS, erp->sifs);
399 rt2x00_set_field32(&reg, CSR18_PIFS, erp->pifs);
400 rt2x00pci_register_write(rt2x00dev, CSR18, reg);
401
402 rt2x00pci_register_read(rt2x00dev, CSR19, &reg);
403 rt2x00_set_field32(&reg, CSR19_DIFS, erp->difs);
404 rt2x00_set_field32(&reg, CSR19_EIFS, erp->eifs);
405 rt2x00pci_register_write(rt2x00dev, CSR19, reg);
399} 406}
400 407
401static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev, 408static void rt2400pci_config_ant(struct rt2x00_dev *rt2x00dev,
402 const int basic_rate_mask) 409 struct antenna_setup *ant)
403{ 410{
404 rt2x00pci_register_write(rt2x00dev, ARCSR1, basic_rate_mask); 411 u8 r1;
412 u8 r4;
413
414 /*
415 * We should never come here because rt2x00lib is supposed
416 * to catch this and send us the correct antenna explicitely.
417 */
418 BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY ||
419 ant->tx == ANTENNA_SW_DIVERSITY);
420
421 rt2400pci_bbp_read(rt2x00dev, 4, &r4);
422 rt2400pci_bbp_read(rt2x00dev, 1, &r1);
423
424 /*
425 * Configure the TX antenna.
426 */
427 switch (ant->tx) {
428 case ANTENNA_HW_DIVERSITY:
429 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 1);
430 break;
431 case ANTENNA_A:
432 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 0);
433 break;
434 case ANTENNA_B:
435 default:
436 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 2);
437 break;
438 }
439
440 /*
441 * Configure the RX antenna.
442 */
443 switch (ant->rx) {
444 case ANTENNA_HW_DIVERSITY:
445 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
446 break;
447 case ANTENNA_A:
448 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 0);
449 break;
450 case ANTENNA_B:
451 default:
452 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
453 break;
454 }
455
456 rt2400pci_bbp_write(rt2x00dev, 4, r4);
457 rt2400pci_bbp_write(rt2x00dev, 1, r1);
405} 458}
406 459
407static void rt2400pci_config_channel(struct rt2x00_dev *rt2x00dev, 460static void rt2400pci_config_channel(struct rt2x00_dev *rt2x00dev,
@@ -460,56 +513,17 @@ static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower)
460 rt2400pci_bbp_write(rt2x00dev, 3, TXPOWER_TO_DEV(txpower)); 513 rt2400pci_bbp_write(rt2x00dev, 3, TXPOWER_TO_DEV(txpower));
461} 514}
462 515
463static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, 516static void rt2400pci_config_retry_limit(struct rt2x00_dev *rt2x00dev,
464 struct antenna_setup *ant) 517 struct rt2x00lib_conf *libconf)
465{ 518{
466 u8 r1; 519 u32 reg;
467 u8 r4;
468
469 /*
470 * We should never come here because rt2x00lib is supposed
471 * to catch this and send us the correct antenna explicitely.
472 */
473 BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY ||
474 ant->tx == ANTENNA_SW_DIVERSITY);
475
476 rt2400pci_bbp_read(rt2x00dev, 4, &r4);
477 rt2400pci_bbp_read(rt2x00dev, 1, &r1);
478
479 /*
480 * Configure the TX antenna.
481 */
482 switch (ant->tx) {
483 case ANTENNA_HW_DIVERSITY:
484 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 1);
485 break;
486 case ANTENNA_A:
487 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 0);
488 break;
489 case ANTENNA_B:
490 default:
491 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 2);
492 break;
493 }
494
495 /*
496 * Configure the RX antenna.
497 */
498 switch (ant->rx) {
499 case ANTENNA_HW_DIVERSITY:
500 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
501 break;
502 case ANTENNA_A:
503 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 0);
504 break;
505 case ANTENNA_B:
506 default:
507 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
508 break;
509 }
510 520
511 rt2400pci_bbp_write(rt2x00dev, 4, r4); 521 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
512 rt2400pci_bbp_write(rt2x00dev, 1, r1); 522 rt2x00_set_field32(&reg, CSR11_LONG_RETRY,
523 libconf->conf->long_frame_max_tx_count);
524 rt2x00_set_field32(&reg, CSR11_SHORT_RETRY,
525 libconf->conf->short_frame_max_tx_count);
526 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
513} 527}
514 528
515static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev, 529static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev,
@@ -517,20 +531,6 @@ static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev,
517{ 531{
518 u32 reg; 532 u32 reg;
519 533
520 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
521 rt2x00_set_field32(&reg, CSR11_SLOT_TIME, libconf->slot_time);
522 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
523
524 rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
525 rt2x00_set_field32(&reg, CSR18_SIFS, libconf->sifs);
526 rt2x00_set_field32(&reg, CSR18_PIFS, libconf->pifs);
527 rt2x00pci_register_write(rt2x00dev, CSR18, reg);
528
529 rt2x00pci_register_read(rt2x00dev, CSR19, &reg);
530 rt2x00_set_field32(&reg, CSR19_DIFS, libconf->difs);
531 rt2x00_set_field32(&reg, CSR19_EIFS, libconf->eifs);
532 rt2x00pci_register_write(rt2x00dev, CSR19, reg);
533
534 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg); 534 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
535 rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER); 535 rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
536 rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1); 536 rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
@@ -548,16 +548,14 @@ static void rt2400pci_config(struct rt2x00_dev *rt2x00dev,
548 struct rt2x00lib_conf *libconf, 548 struct rt2x00lib_conf *libconf,
549 const unsigned int flags) 549 const unsigned int flags)
550{ 550{
551 if (flags & CONFIG_UPDATE_PHYMODE) 551 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
552 rt2400pci_config_phymode(rt2x00dev, libconf->basic_rates);
553 if (flags & CONFIG_UPDATE_CHANNEL)
554 rt2400pci_config_channel(rt2x00dev, &libconf->rf); 552 rt2400pci_config_channel(rt2x00dev, &libconf->rf);
555 if (flags & CONFIG_UPDATE_TXPOWER) 553 if (flags & IEEE80211_CONF_CHANGE_POWER)
556 rt2400pci_config_txpower(rt2x00dev, 554 rt2400pci_config_txpower(rt2x00dev,
557 libconf->conf->power_level); 555 libconf->conf->power_level);
558 if (flags & CONFIG_UPDATE_ANTENNA) 556 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
559 rt2400pci_config_antenna(rt2x00dev, &libconf->ant); 557 rt2400pci_config_retry_limit(rt2x00dev, libconf);
560 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 558 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
561 rt2400pci_config_duration(rt2x00dev, libconf); 559 rt2400pci_config_duration(rt2x00dev, libconf);
562} 560}
563 561
@@ -1313,10 +1311,8 @@ static int rt2400pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1313 */ 1311 */
1314 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); 1312 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
1315 if (!is_valid_ether_addr(mac)) { 1313 if (!is_valid_ether_addr(mac)) {
1316 DECLARE_MAC_BUF(macbuf);
1317
1318 random_ether_addr(mac); 1314 random_ether_addr(mac);
1319 EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac)); 1315 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
1320 } 1316 }
1321 1317
1322 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); 1318 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
@@ -1504,20 +1500,6 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1504/* 1500/*
1505 * IEEE80211 stack callback functions. 1501 * IEEE80211 stack callback functions.
1506 */ 1502 */
1507static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw,
1508 u32 short_retry, u32 long_retry)
1509{
1510 struct rt2x00_dev *rt2x00dev = hw->priv;
1511 u32 reg;
1512
1513 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
1514 rt2x00_set_field32(&reg, CSR11_LONG_RETRY, long_retry);
1515 rt2x00_set_field32(&reg, CSR11_SHORT_RETRY, short_retry);
1516 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
1517
1518 return 0;
1519}
1520
1521static int rt2400pci_conf_tx(struct ieee80211_hw *hw, u16 queue, 1503static int rt2400pci_conf_tx(struct ieee80211_hw *hw, u16 queue,
1522 const struct ieee80211_tx_queue_params *params) 1504 const struct ieee80211_tx_queue_params *params)
1523{ 1505{
@@ -1576,7 +1558,6 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
1576 .config_interface = rt2x00mac_config_interface, 1558 .config_interface = rt2x00mac_config_interface,
1577 .configure_filter = rt2x00mac_configure_filter, 1559 .configure_filter = rt2x00mac_configure_filter,
1578 .get_stats = rt2x00mac_get_stats, 1560 .get_stats = rt2x00mac_get_stats,
1579 .set_retry_limit = rt2400pci_set_retry_limit,
1580 .bss_info_changed = rt2x00mac_bss_info_changed, 1561 .bss_info_changed = rt2x00mac_bss_info_changed,
1581 .conf_tx = rt2400pci_conf_tx, 1562 .conf_tx = rt2400pci_conf_tx,
1582 .get_tx_stats = rt2x00mac_get_tx_stats, 1563 .get_tx_stats = rt2x00mac_get_tx_stats,
@@ -1604,6 +1585,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1604 .config_filter = rt2400pci_config_filter, 1585 .config_filter = rt2400pci_config_filter,
1605 .config_intf = rt2400pci_config_intf, 1586 .config_intf = rt2400pci_config_intf,
1606 .config_erp = rt2400pci_config_erp, 1587 .config_erp = rt2400pci_config_erp,
1588 .config_ant = rt2400pci_config_ant,
1607 .config = rt2400pci_config, 1589 .config = rt2400pci_config,
1608}; 1590};
1609 1591
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.h b/drivers/net/wireless/rt2x00/rt2400pci.h
index bbff381ce396..9aefda4ab3c2 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.h
+++ b/drivers/net/wireless/rt2x00/rt2400pci.h
@@ -46,7 +46,9 @@
46#define CSR_REG_SIZE 0x014c 46#define CSR_REG_SIZE 0x014c
47#define EEPROM_BASE 0x0000 47#define EEPROM_BASE 0x0000
48#define EEPROM_SIZE 0x0100 48#define EEPROM_SIZE 0x0100
49#define BBP_BASE 0x0000
49#define BBP_SIZE 0x0020 50#define BBP_SIZE 0x0020
51#define RF_BASE 0x0000
50#define RF_SIZE 0x0010 52#define RF_SIZE 0x0010
51 53
52/* 54/*
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index ef42cc04a2d7..928452f30c25 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -188,43 +188,34 @@ static void rt2500pci_eepromregister_write(struct eeprom_93cx6 *eeprom)
188} 188}
189 189
190#ifdef CONFIG_RT2X00_LIB_DEBUGFS 190#ifdef CONFIG_RT2X00_LIB_DEBUGFS
191#define CSR_OFFSET(__word) ( CSR_REG_BASE + ((__word) * sizeof(u32)) )
192
193static void rt2500pci_read_csr(struct rt2x00_dev *rt2x00dev,
194 const unsigned int word, u32 *data)
195{
196 rt2x00pci_register_read(rt2x00dev, CSR_OFFSET(word), data);
197}
198
199static void rt2500pci_write_csr(struct rt2x00_dev *rt2x00dev,
200 const unsigned int word, u32 data)
201{
202 rt2x00pci_register_write(rt2x00dev, CSR_OFFSET(word), data);
203}
204
205static const struct rt2x00debug rt2500pci_rt2x00debug = { 191static const struct rt2x00debug rt2500pci_rt2x00debug = {
206 .owner = THIS_MODULE, 192 .owner = THIS_MODULE,
207 .csr = { 193 .csr = {
208 .read = rt2500pci_read_csr, 194 .read = rt2x00pci_register_read,
209 .write = rt2500pci_write_csr, 195 .write = rt2x00pci_register_write,
196 .flags = RT2X00DEBUGFS_OFFSET,
197 .word_base = CSR_REG_BASE,
210 .word_size = sizeof(u32), 198 .word_size = sizeof(u32),
211 .word_count = CSR_REG_SIZE / sizeof(u32), 199 .word_count = CSR_REG_SIZE / sizeof(u32),
212 }, 200 },
213 .eeprom = { 201 .eeprom = {
214 .read = rt2x00_eeprom_read, 202 .read = rt2x00_eeprom_read,
215 .write = rt2x00_eeprom_write, 203 .write = rt2x00_eeprom_write,
204 .word_base = EEPROM_BASE,
216 .word_size = sizeof(u16), 205 .word_size = sizeof(u16),
217 .word_count = EEPROM_SIZE / sizeof(u16), 206 .word_count = EEPROM_SIZE / sizeof(u16),
218 }, 207 },
219 .bbp = { 208 .bbp = {
220 .read = rt2500pci_bbp_read, 209 .read = rt2500pci_bbp_read,
221 .write = rt2500pci_bbp_write, 210 .write = rt2500pci_bbp_write,
211 .word_base = BBP_BASE,
222 .word_size = sizeof(u8), 212 .word_size = sizeof(u8),
223 .word_count = BBP_SIZE / sizeof(u8), 213 .word_count = BBP_SIZE / sizeof(u8),
224 }, 214 },
225 .rf = { 215 .rf = {
226 .read = rt2x00_rf_read, 216 .read = rt2x00_rf_read,
227 .write = rt2500pci_rf_write, 217 .write = rt2500pci_rf_write,
218 .word_base = RF_BASE,
228 .word_size = sizeof(u32), 219 .word_size = sizeof(u32),
229 .word_count = RF_SIZE / sizeof(u32), 220 .word_count = RF_SIZE / sizeof(u32),
230 }, 221 },
@@ -402,12 +393,94 @@ static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
402 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84); 393 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
403 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); 394 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
404 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); 395 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
396
397 rt2x00pci_register_write(rt2x00dev, ARCSR1, erp->basic_rates);
398
399 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
400 rt2x00_set_field32(&reg, CSR11_SLOT_TIME, erp->slot_time);
401 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
402
403 rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
404 rt2x00_set_field32(&reg, CSR18_SIFS, erp->sifs);
405 rt2x00_set_field32(&reg, CSR18_PIFS, erp->pifs);
406 rt2x00pci_register_write(rt2x00dev, CSR18, reg);
407
408 rt2x00pci_register_read(rt2x00dev, CSR19, &reg);
409 rt2x00_set_field32(&reg, CSR19_DIFS, erp->difs);
410 rt2x00_set_field32(&reg, CSR19_EIFS, erp->eifs);
411 rt2x00pci_register_write(rt2x00dev, CSR19, reg);
405} 412}
406 413
407static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev, 414static void rt2500pci_config_ant(struct rt2x00_dev *rt2x00dev,
408 const int basic_rate_mask) 415 struct antenna_setup *ant)
409{ 416{
410 rt2x00pci_register_write(rt2x00dev, ARCSR1, basic_rate_mask); 417 u32 reg;
418 u8 r14;
419 u8 r2;
420
421 /*
422 * We should never come here because rt2x00lib is supposed
423 * to catch this and send us the correct antenna explicitely.
424 */
425 BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY ||
426 ant->tx == ANTENNA_SW_DIVERSITY);
427
428 rt2x00pci_register_read(rt2x00dev, BBPCSR1, &reg);
429 rt2500pci_bbp_read(rt2x00dev, 14, &r14);
430 rt2500pci_bbp_read(rt2x00dev, 2, &r2);
431
432 /*
433 * Configure the TX antenna.
434 */
435 switch (ant->tx) {
436 case ANTENNA_A:
437 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 0);
438 rt2x00_set_field32(&reg, BBPCSR1_CCK, 0);
439 rt2x00_set_field32(&reg, BBPCSR1_OFDM, 0);
440 break;
441 case ANTENNA_B:
442 default:
443 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2);
444 rt2x00_set_field32(&reg, BBPCSR1_CCK, 2);
445 rt2x00_set_field32(&reg, BBPCSR1_OFDM, 2);
446 break;
447 }
448
449 /*
450 * Configure the RX antenna.
451 */
452 switch (ant->rx) {
453 case ANTENNA_A:
454 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 0);
455 break;
456 case ANTENNA_B:
457 default:
458 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2);
459 break;
460 }
461
462 /*
463 * RT2525E and RT5222 need to flip TX I/Q
464 */
465 if (rt2x00_rf(&rt2x00dev->chip, RF2525E) ||
466 rt2x00_rf(&rt2x00dev->chip, RF5222)) {
467 rt2x00_set_field8(&r2, BBP_R2_TX_IQ_FLIP, 1);
468 rt2x00_set_field32(&reg, BBPCSR1_CCK_FLIP, 1);
469 rt2x00_set_field32(&reg, BBPCSR1_OFDM_FLIP, 1);
470
471 /*
472 * RT2525E does not need RX I/Q Flip.
473 */
474 if (rt2x00_rf(&rt2x00dev->chip, RF2525E))
475 rt2x00_set_field8(&r14, BBP_R14_RX_IQ_FLIP, 0);
476 } else {
477 rt2x00_set_field32(&reg, BBPCSR1_CCK_FLIP, 0);
478 rt2x00_set_field32(&reg, BBPCSR1_OFDM_FLIP, 0);
479 }
480
481 rt2x00pci_register_write(rt2x00dev, BBPCSR1, reg);
482 rt2500pci_bbp_write(rt2x00dev, 14, r14);
483 rt2500pci_bbp_write(rt2x00dev, 2, r2);
411} 484}
412 485
413static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev, 486static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev,
@@ -489,76 +562,17 @@ static void rt2500pci_config_txpower(struct rt2x00_dev *rt2x00dev,
489 rt2500pci_rf_write(rt2x00dev, 3, rf3); 562 rt2500pci_rf_write(rt2x00dev, 3, rf3);
490} 563}
491 564
492static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev, 565static void rt2500pci_config_retry_limit(struct rt2x00_dev *rt2x00dev,
493 struct antenna_setup *ant) 566 struct rt2x00lib_conf *libconf)
494{ 567{
495 u32 reg; 568 u32 reg;
496 u8 r14;
497 u8 r2;
498 569
499 /* 570 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
500 * We should never come here because rt2x00lib is supposed 571 rt2x00_set_field32(&reg, CSR11_LONG_RETRY,
501 * to catch this and send us the correct antenna explicitely. 572 libconf->conf->long_frame_max_tx_count);
502 */ 573 rt2x00_set_field32(&reg, CSR11_SHORT_RETRY,
503 BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY || 574 libconf->conf->short_frame_max_tx_count);
504 ant->tx == ANTENNA_SW_DIVERSITY); 575 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
505
506 rt2x00pci_register_read(rt2x00dev, BBPCSR1, &reg);
507 rt2500pci_bbp_read(rt2x00dev, 14, &r14);
508 rt2500pci_bbp_read(rt2x00dev, 2, &r2);
509
510 /*
511 * Configure the TX antenna.
512 */
513 switch (ant->tx) {
514 case ANTENNA_A:
515 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 0);
516 rt2x00_set_field32(&reg, BBPCSR1_CCK, 0);
517 rt2x00_set_field32(&reg, BBPCSR1_OFDM, 0);
518 break;
519 case ANTENNA_B:
520 default:
521 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2);
522 rt2x00_set_field32(&reg, BBPCSR1_CCK, 2);
523 rt2x00_set_field32(&reg, BBPCSR1_OFDM, 2);
524 break;
525 }
526
527 /*
528 * Configure the RX antenna.
529 */
530 switch (ant->rx) {
531 case ANTENNA_A:
532 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 0);
533 break;
534 case ANTENNA_B:
535 default:
536 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2);
537 break;
538 }
539
540 /*
541 * RT2525E and RT5222 need to flip TX I/Q
542 */
543 if (rt2x00_rf(&rt2x00dev->chip, RF2525E) ||
544 rt2x00_rf(&rt2x00dev->chip, RF5222)) {
545 rt2x00_set_field8(&r2, BBP_R2_TX_IQ_FLIP, 1);
546 rt2x00_set_field32(&reg, BBPCSR1_CCK_FLIP, 1);
547 rt2x00_set_field32(&reg, BBPCSR1_OFDM_FLIP, 1);
548
549 /*
550 * RT2525E does not need RX I/Q Flip.
551 */
552 if (rt2x00_rf(&rt2x00dev->chip, RF2525E))
553 rt2x00_set_field8(&r14, BBP_R14_RX_IQ_FLIP, 0);
554 } else {
555 rt2x00_set_field32(&reg, BBPCSR1_CCK_FLIP, 0);
556 rt2x00_set_field32(&reg, BBPCSR1_OFDM_FLIP, 0);
557 }
558
559 rt2x00pci_register_write(rt2x00dev, BBPCSR1, reg);
560 rt2500pci_bbp_write(rt2x00dev, 14, r14);
561 rt2500pci_bbp_write(rt2x00dev, 2, r2);
562} 576}
563 577
564static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev, 578static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev,
@@ -566,20 +580,6 @@ static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev,
566{ 580{
567 u32 reg; 581 u32 reg;
568 582
569 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
570 rt2x00_set_field32(&reg, CSR11_SLOT_TIME, libconf->slot_time);
571 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
572
573 rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
574 rt2x00_set_field32(&reg, CSR18_SIFS, libconf->sifs);
575 rt2x00_set_field32(&reg, CSR18_PIFS, libconf->pifs);
576 rt2x00pci_register_write(rt2x00dev, CSR18, reg);
577
578 rt2x00pci_register_read(rt2x00dev, CSR19, &reg);
579 rt2x00_set_field32(&reg, CSR19_DIFS, libconf->difs);
580 rt2x00_set_field32(&reg, CSR19_EIFS, libconf->eifs);
581 rt2x00pci_register_write(rt2x00dev, CSR19, reg);
582
583 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg); 583 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
584 rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER); 584 rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
585 rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1); 585 rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
@@ -597,17 +597,16 @@ static void rt2500pci_config(struct rt2x00_dev *rt2x00dev,
597 struct rt2x00lib_conf *libconf, 597 struct rt2x00lib_conf *libconf,
598 const unsigned int flags) 598 const unsigned int flags)
599{ 599{
600 if (flags & CONFIG_UPDATE_PHYMODE) 600 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
601 rt2500pci_config_phymode(rt2x00dev, libconf->basic_rates);
602 if (flags & CONFIG_UPDATE_CHANNEL)
603 rt2500pci_config_channel(rt2x00dev, &libconf->rf, 601 rt2500pci_config_channel(rt2x00dev, &libconf->rf,
604 libconf->conf->power_level); 602 libconf->conf->power_level);
605 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 603 if ((flags & IEEE80211_CONF_CHANGE_POWER) &&
604 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
606 rt2500pci_config_txpower(rt2x00dev, 605 rt2500pci_config_txpower(rt2x00dev,
607 libconf->conf->power_level); 606 libconf->conf->power_level);
608 if (flags & CONFIG_UPDATE_ANTENNA) 607 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
609 rt2500pci_config_antenna(rt2x00dev, &libconf->ant); 608 rt2500pci_config_retry_limit(rt2x00dev, libconf);
610 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 609 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
611 rt2500pci_config_duration(rt2x00dev, libconf); 610 rt2500pci_config_duration(rt2x00dev, libconf);
612} 611}
613 612
@@ -1451,11 +1450,8 @@ static int rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1451 */ 1450 */
1452 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); 1451 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
1453 if (!is_valid_ether_addr(mac)) { 1452 if (!is_valid_ether_addr(mac)) {
1454 DECLARE_MAC_BUF(macbuf);
1455
1456 random_ether_addr(mac); 1453 random_ether_addr(mac);
1457 EEPROM(rt2x00dev, "MAC: %s\n", 1454 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
1458 print_mac(macbuf, mac));
1459 } 1455 }
1460 1456
1461 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); 1457 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
@@ -1830,20 +1826,6 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1830/* 1826/*
1831 * IEEE80211 stack callback functions. 1827 * IEEE80211 stack callback functions.
1832 */ 1828 */
1833static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw,
1834 u32 short_retry, u32 long_retry)
1835{
1836 struct rt2x00_dev *rt2x00dev = hw->priv;
1837 u32 reg;
1838
1839 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
1840 rt2x00_set_field32(&reg, CSR11_LONG_RETRY, long_retry);
1841 rt2x00_set_field32(&reg, CSR11_SHORT_RETRY, short_retry);
1842 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
1843
1844 return 0;
1845}
1846
1847static u64 rt2500pci_get_tsf(struct ieee80211_hw *hw) 1829static u64 rt2500pci_get_tsf(struct ieee80211_hw *hw)
1848{ 1830{
1849 struct rt2x00_dev *rt2x00dev = hw->priv; 1831 struct rt2x00_dev *rt2x00dev = hw->priv;
@@ -1877,7 +1859,6 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
1877 .config_interface = rt2x00mac_config_interface, 1859 .config_interface = rt2x00mac_config_interface,
1878 .configure_filter = rt2x00mac_configure_filter, 1860 .configure_filter = rt2x00mac_configure_filter,
1879 .get_stats = rt2x00mac_get_stats, 1861 .get_stats = rt2x00mac_get_stats,
1880 .set_retry_limit = rt2500pci_set_retry_limit,
1881 .bss_info_changed = rt2x00mac_bss_info_changed, 1862 .bss_info_changed = rt2x00mac_bss_info_changed,
1882 .conf_tx = rt2x00mac_conf_tx, 1863 .conf_tx = rt2x00mac_conf_tx,
1883 .get_tx_stats = rt2x00mac_get_tx_stats, 1864 .get_tx_stats = rt2x00mac_get_tx_stats,
@@ -1905,6 +1886,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1905 .config_filter = rt2500pci_config_filter, 1886 .config_filter = rt2500pci_config_filter,
1906 .config_intf = rt2500pci_config_intf, 1887 .config_intf = rt2500pci_config_intf,
1907 .config_erp = rt2500pci_config_erp, 1888 .config_erp = rt2500pci_config_erp,
1889 .config_ant = rt2500pci_config_ant,
1908 .config = rt2500pci_config, 1890 .config = rt2500pci_config,
1909}; 1891};
1910 1892
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.h b/drivers/net/wireless/rt2x00/rt2500pci.h
index 8c26bef6cf49..e135247f7f89 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.h
+++ b/drivers/net/wireless/rt2x00/rt2500pci.h
@@ -57,7 +57,9 @@
57#define CSR_REG_SIZE 0x0174 57#define CSR_REG_SIZE 0x0174
58#define EEPROM_BASE 0x0000 58#define EEPROM_BASE 0x0000
59#define EEPROM_SIZE 0x0200 59#define EEPROM_SIZE 0x0200
60#define BBP_BASE 0x0000
60#define BBP_SIZE 0x0040 61#define BBP_SIZE 0x0040
62#define RF_BASE 0x0000
61#define RF_SIZE 0x0014 63#define RF_SIZE 0x0014
62 64
63/* 65/*
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index d3bf7bba611a..639d5a2f84e2 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -245,43 +245,48 @@ rf_write:
245} 245}
246 246
247#ifdef CONFIG_RT2X00_LIB_DEBUGFS 247#ifdef CONFIG_RT2X00_LIB_DEBUGFS
248#define CSR_OFFSET(__word) ( CSR_REG_BASE + ((__word) * sizeof(u16)) ) 248static void _rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
249 249 const unsigned int offset,
250static void rt2500usb_read_csr(struct rt2x00_dev *rt2x00dev, 250 u32 *value)
251 const unsigned int word, u32 *data)
252{ 251{
253 rt2500usb_register_read(rt2x00dev, CSR_OFFSET(word), (u16 *) data); 252 rt2500usb_register_read(rt2x00dev, offset, (u16 *)value);
254} 253}
255 254
256static void rt2500usb_write_csr(struct rt2x00_dev *rt2x00dev, 255static void _rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
257 const unsigned int word, u32 data) 256 const unsigned int offset,
257 u32 value)
258{ 258{
259 rt2500usb_register_write(rt2x00dev, CSR_OFFSET(word), data); 259 rt2500usb_register_write(rt2x00dev, offset, value);
260} 260}
261 261
262static const struct rt2x00debug rt2500usb_rt2x00debug = { 262static const struct rt2x00debug rt2500usb_rt2x00debug = {
263 .owner = THIS_MODULE, 263 .owner = THIS_MODULE,
264 .csr = { 264 .csr = {
265 .read = rt2500usb_read_csr, 265 .read = _rt2500usb_register_read,
266 .write = rt2500usb_write_csr, 266 .write = _rt2500usb_register_write,
267 .flags = RT2X00DEBUGFS_OFFSET,
268 .word_base = CSR_REG_BASE,
267 .word_size = sizeof(u16), 269 .word_size = sizeof(u16),
268 .word_count = CSR_REG_SIZE / sizeof(u16), 270 .word_count = CSR_REG_SIZE / sizeof(u16),
269 }, 271 },
270 .eeprom = { 272 .eeprom = {
271 .read = rt2x00_eeprom_read, 273 .read = rt2x00_eeprom_read,
272 .write = rt2x00_eeprom_write, 274 .write = rt2x00_eeprom_write,
275 .word_base = EEPROM_BASE,
273 .word_size = sizeof(u16), 276 .word_size = sizeof(u16),
274 .word_count = EEPROM_SIZE / sizeof(u16), 277 .word_count = EEPROM_SIZE / sizeof(u16),
275 }, 278 },
276 .bbp = { 279 .bbp = {
277 .read = rt2500usb_bbp_read, 280 .read = rt2500usb_bbp_read,
278 .write = rt2500usb_bbp_write, 281 .write = rt2500usb_bbp_write,
282 .word_base = BBP_BASE,
279 .word_size = sizeof(u8), 283 .word_size = sizeof(u8),
280 .word_count = BBP_SIZE / sizeof(u8), 284 .word_count = BBP_SIZE / sizeof(u8),
281 }, 285 },
282 .rf = { 286 .rf = {
283 .read = rt2x00_rf_read, 287 .read = rt2x00_rf_read,
284 .write = rt2500usb_rf_write, 288 .write = rt2500usb_rf_write,
289 .word_base = RF_BASE,
285 .word_size = sizeof(u32), 290 .word_size = sizeof(u32),
286 .word_count = RF_SIZE / sizeof(u32), 291 .word_count = RF_SIZE / sizeof(u32),
287 }, 292 },
@@ -423,57 +428,16 @@ static void rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
423 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, 428 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
424 !!erp->short_preamble); 429 !!erp->short_preamble);
425 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg); 430 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
426}
427
428static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev,
429 const int basic_rate_mask)
430{
431 rt2500usb_register_write(rt2x00dev, TXRX_CSR11, basic_rate_mask);
432}
433 431
434static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev, 432 rt2500usb_register_write(rt2x00dev, TXRX_CSR11, erp->basic_rates);
435 struct rf_channel *rf, const int txpower)
436{
437 /*
438 * Set TXpower.
439 */
440 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
441 433
442 /* 434 rt2500usb_register_write(rt2x00dev, MAC_CSR10, erp->slot_time);
443 * For RT2525E we should first set the channel to half band higher. 435 rt2500usb_register_write(rt2x00dev, MAC_CSR11, erp->sifs);
444 */ 436 rt2500usb_register_write(rt2x00dev, MAC_CSR12, erp->eifs);
445 if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) {
446 static const u32 vals[] = {
447 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2,
448 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba,
449 0x000008ba, 0x000008be, 0x000008b7, 0x00000902,
450 0x00000902, 0x00000906
451 };
452
453 rt2500usb_rf_write(rt2x00dev, 2, vals[rf->channel - 1]);
454 if (rf->rf4)
455 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
456 }
457
458 rt2500usb_rf_write(rt2x00dev, 1, rf->rf1);
459 rt2500usb_rf_write(rt2x00dev, 2, rf->rf2);
460 rt2500usb_rf_write(rt2x00dev, 3, rf->rf3);
461 if (rf->rf4)
462 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
463}
464
465static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
466 const int txpower)
467{
468 u32 rf3;
469
470 rt2x00_rf_read(rt2x00dev, 3, &rf3);
471 rt2x00_set_field32(&rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
472 rt2500usb_rf_write(rt2x00dev, 3, rf3);
473} 437}
474 438
475static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev, 439static void rt2500usb_config_ant(struct rt2x00_dev *rt2x00dev,
476 struct antenna_setup *ant) 440 struct antenna_setup *ant)
477{ 441{
478 u8 r2; 442 u8 r2;
479 u8 r14; 443 u8 r14;
@@ -555,15 +519,52 @@ static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev,
555 rt2500usb_register_write(rt2x00dev, PHY_CSR6, csr6); 519 rt2500usb_register_write(rt2x00dev, PHY_CSR6, csr6);
556} 520}
557 521
522static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev,
523 struct rf_channel *rf, const int txpower)
524{
525 /*
526 * Set TXpower.
527 */
528 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
529
530 /*
531 * For RT2525E we should first set the channel to half band higher.
532 */
533 if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) {
534 static const u32 vals[] = {
535 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2,
536 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba,
537 0x000008ba, 0x000008be, 0x000008b7, 0x00000902,
538 0x00000902, 0x00000906
539 };
540
541 rt2500usb_rf_write(rt2x00dev, 2, vals[rf->channel - 1]);
542 if (rf->rf4)
543 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
544 }
545
546 rt2500usb_rf_write(rt2x00dev, 1, rf->rf1);
547 rt2500usb_rf_write(rt2x00dev, 2, rf->rf2);
548 rt2500usb_rf_write(rt2x00dev, 3, rf->rf3);
549 if (rf->rf4)
550 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
551}
552
553static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
554 const int txpower)
555{
556 u32 rf3;
557
558 rt2x00_rf_read(rt2x00dev, 3, &rf3);
559 rt2x00_set_field32(&rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
560 rt2500usb_rf_write(rt2x00dev, 3, rf3);
561}
562
558static void rt2500usb_config_duration(struct rt2x00_dev *rt2x00dev, 563static void rt2500usb_config_duration(struct rt2x00_dev *rt2x00dev,
559 struct rt2x00lib_conf *libconf) 564 struct rt2x00lib_conf *libconf)
560{ 565{
561 u16 reg; 566 u16 reg;
562 567
563 rt2500usb_register_write(rt2x00dev, MAC_CSR10, libconf->slot_time);
564 rt2500usb_register_write(rt2x00dev, MAC_CSR11, libconf->sifs);
565 rt2500usb_register_write(rt2x00dev, MAC_CSR12, libconf->eifs);
566
567 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg); 568 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg);
568 rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL, 569 rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL,
569 libconf->conf->beacon_int * 4); 570 libconf->conf->beacon_int * 4);
@@ -574,17 +575,14 @@ static void rt2500usb_config(struct rt2x00_dev *rt2x00dev,
574 struct rt2x00lib_conf *libconf, 575 struct rt2x00lib_conf *libconf,
575 const unsigned int flags) 576 const unsigned int flags)
576{ 577{
577 if (flags & CONFIG_UPDATE_PHYMODE) 578 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
578 rt2500usb_config_phymode(rt2x00dev, libconf->basic_rates);
579 if (flags & CONFIG_UPDATE_CHANNEL)
580 rt2500usb_config_channel(rt2x00dev, &libconf->rf, 579 rt2500usb_config_channel(rt2x00dev, &libconf->rf,
581 libconf->conf->power_level); 580 libconf->conf->power_level);
582 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 581 if ((flags & IEEE80211_CONF_CHANGE_POWER) &&
582 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
583 rt2500usb_config_txpower(rt2x00dev, 583 rt2500usb_config_txpower(rt2x00dev,
584 libconf->conf->power_level); 584 libconf->conf->power_level);
585 if (flags & CONFIG_UPDATE_ANTENNA) 585 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
586 rt2500usb_config_antenna(rt2x00dev, &libconf->ant);
587 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
588 rt2500usb_config_duration(rt2x00dev, libconf); 586 rt2500usb_config_duration(rt2x00dev, libconf);
589} 587}
590 588
@@ -1319,10 +1317,8 @@ static int rt2500usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1319 */ 1317 */
1320 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); 1318 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
1321 if (!is_valid_ether_addr(mac)) { 1319 if (!is_valid_ether_addr(mac)) {
1322 DECLARE_MAC_BUF(macbuf);
1323
1324 random_ether_addr(mac); 1320 random_ether_addr(mac);
1325 EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac)); 1321 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
1326 } 1322 }
1327 1323
1328 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); 1324 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
@@ -1796,6 +1792,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1796 .config_filter = rt2500usb_config_filter, 1792 .config_filter = rt2500usb_config_filter,
1797 .config_intf = rt2500usb_config_intf, 1793 .config_intf = rt2500usb_config_intf,
1798 .config_erp = rt2500usb_config_erp, 1794 .config_erp = rt2500usb_config_erp,
1795 .config_ant = rt2500usb_config_ant,
1799 .config = rt2500usb_config, 1796 .config = rt2500usb_config,
1800}; 1797};
1801 1798
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.h b/drivers/net/wireless/rt2x00/rt2500usb.h
index 89e5ed24e4f7..dbb5d689e23d 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.h
+++ b/drivers/net/wireless/rt2x00/rt2500usb.h
@@ -57,7 +57,9 @@
57#define CSR_REG_SIZE 0x0100 57#define CSR_REG_SIZE 0x0100
58#define EEPROM_BASE 0x0000 58#define EEPROM_BASE 0x0000
59#define EEPROM_SIZE 0x006a 59#define EEPROM_SIZE 0x006a
60#define BBP_BASE 0x0000
60#define BBP_SIZE 0x0060 61#define BBP_SIZE 0x0060
62#define RF_BASE 0x0000
61#define RF_SIZE 0x0014 63#define RF_SIZE 0x0014
62 64
63/* 65/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 1359a3768404..f85eedbbad68 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -44,7 +44,7 @@
44/* 44/*
45 * Module information. 45 * Module information.
46 */ 46 */
47#define DRV_VERSION "2.2.1" 47#define DRV_VERSION "2.2.2"
48#define DRV_PROJECT "http://rt2x00.serialmonkey.com" 48#define DRV_PROJECT "http://rt2x00.serialmonkey.com"
49 49
50/* 50/*
@@ -348,13 +348,6 @@ struct rt2x00_intf {
348 spinlock_t lock; 348 spinlock_t lock;
349 349
350 /* 350 /*
351 * BSS configuration. Copied from the structure
352 * passed to us through the bss_info_changed()
353 * callback funtion.
354 */
355 struct ieee80211_bss_conf conf;
356
357 /*
358 * MAC of the device. 351 * MAC of the device.
359 */ 352 */
360 u8 mac[ETH_ALEN]; 353 u8 mac[ETH_ALEN];
@@ -433,18 +426,6 @@ struct rt2x00lib_conf {
433 426
434 struct rf_channel rf; 427 struct rf_channel rf;
435 struct channel_info channel; 428 struct channel_info channel;
436
437 struct antenna_setup ant;
438
439 enum ieee80211_band band;
440
441 u32 basic_rates;
442 u32 slot_time;
443
444 short sifs;
445 short pifs;
446 short difs;
447 short eifs;
448}; 429};
449 430
450/* 431/*
@@ -456,6 +437,15 @@ struct rt2x00lib_erp {
456 437
457 int ack_timeout; 438 int ack_timeout;
458 int ack_consume_time; 439 int ack_consume_time;
440
441 u64 basic_rates;
442
443 int slot_time;
444
445 short sifs;
446 short pifs;
447 short difs;
448 short eifs;
459}; 449};
460 450
461/* 451/*
@@ -589,16 +579,11 @@ struct rt2x00lib_ops {
589 579
590 void (*config_erp) (struct rt2x00_dev *rt2x00dev, 580 void (*config_erp) (struct rt2x00_dev *rt2x00dev,
591 struct rt2x00lib_erp *erp); 581 struct rt2x00lib_erp *erp);
582 void (*config_ant) (struct rt2x00_dev *rt2x00dev,
583 struct antenna_setup *ant);
592 void (*config) (struct rt2x00_dev *rt2x00dev, 584 void (*config) (struct rt2x00_dev *rt2x00dev,
593 struct rt2x00lib_conf *libconf, 585 struct rt2x00lib_conf *libconf,
594 const unsigned int flags); 586 const unsigned int changed_flags);
595#define CONFIG_UPDATE_PHYMODE ( 1 << 1 )
596#define CONFIG_UPDATE_CHANNEL ( 1 << 2 )
597#define CONFIG_UPDATE_TXPOWER ( 1 << 3 )
598#define CONFIG_UPDATE_ANTENNA ( 1 << 4 )
599#define CONFIG_UPDATE_SLOT_TIME ( 1 << 5 )
600#define CONFIG_UPDATE_BEACON_INT ( 1 << 6 )
601#define CONFIG_UPDATE_ALL 0xffff
602}; 587};
603 588
604/* 589/*
@@ -997,7 +982,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
997 struct ieee80211_if_init_conf *conf); 982 struct ieee80211_if_init_conf *conf);
998void rt2x00mac_remove_interface(struct ieee80211_hw *hw, 983void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
999 struct ieee80211_if_init_conf *conf); 984 struct ieee80211_if_init_conf *conf);
1000int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 985int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed);
1001int rt2x00mac_config_interface(struct ieee80211_hw *hw, 986int rt2x00mac_config_interface(struct ieee80211_hw *hw,
1002 struct ieee80211_vif *vif, 987 struct ieee80211_vif *vif,
1003 struct ieee80211_if_conf *conf); 988 struct ieee80211_if_conf *conf);
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 4d5e87b015a0..3e4eee3ab7d2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -86,13 +86,14 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
86 erp.short_preamble = bss_conf->use_short_preamble; 86 erp.short_preamble = bss_conf->use_short_preamble;
87 erp.cts_protection = bss_conf->use_cts_prot; 87 erp.cts_protection = bss_conf->use_cts_prot;
88 88
89 erp.ack_timeout = PLCP + get_duration(ACK_SIZE, 10); 89 erp.slot_time = bss_conf->use_short_slot ? SHORT_SLOT_TIME : SLOT_TIME;
90 erp.ack_consume_time = SIFS + PLCP + get_duration(ACK_SIZE, 10); 90 erp.sifs = SIFS;
91 erp.pifs = bss_conf->use_short_slot ? SHORT_PIFS : PIFS;
92 erp.difs = bss_conf->use_short_slot ? SHORT_DIFS : DIFS;
93 erp.eifs = bss_conf->use_short_slot ? SHORT_EIFS : EIFS;
91 94
92 if (rt2x00dev->hw->conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME) 95 erp.ack_timeout = PLCP + erp.difs + get_duration(ACK_SIZE, 10);
93 erp.ack_timeout += SHORT_DIFS; 96 erp.ack_consume_time = SIFS + PLCP + get_duration(ACK_SIZE, 10);
94 else
95 erp.ack_timeout += DIFS;
96 97
97 if (bss_conf->use_short_preamble) { 98 if (bss_conf->use_short_preamble) {
98 erp.ack_timeout += SHORT_PREAMBLE; 99 erp.ack_timeout += SHORT_PREAMBLE;
@@ -102,16 +103,18 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
102 erp.ack_consume_time += PREAMBLE; 103 erp.ack_consume_time += PREAMBLE;
103 } 104 }
104 105
106 erp.basic_rates = bss_conf->basic_rates;
107
105 rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp); 108 rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp);
106} 109}
107 110
108void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, 111void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
109 enum antenna rx, enum antenna tx) 112 enum antenna rx, enum antenna tx)
110{ 113{
111 struct rt2x00lib_conf libconf; 114 struct antenna_setup ant;
112 115
113 libconf.ant.rx = rx; 116 ant.rx = rx;
114 libconf.ant.tx = tx; 117 ant.tx = tx;
115 118
116 if (rx == rt2x00dev->link.ant.active.rx && 119 if (rx == rt2x00dev->link.ant.active.rx &&
117 tx == rt2x00dev->link.ant.active.tx) 120 tx == rt2x00dev->link.ant.active.tx)
@@ -129,119 +132,28 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
129 * The latter is required since we need to recalibrate the 132 * The latter is required since we need to recalibrate the
130 * noise-sensitivity ratio for the new setup. 133 * noise-sensitivity ratio for the new setup.
131 */ 134 */
132 rt2x00dev->ops->lib->config(rt2x00dev, &libconf, CONFIG_UPDATE_ANTENNA); 135 rt2x00dev->ops->lib->config_ant(rt2x00dev, &ant);
136
133 rt2x00lib_reset_link_tuner(rt2x00dev); 137 rt2x00lib_reset_link_tuner(rt2x00dev);
134 rt2x00_reset_link_ant_rssi(&rt2x00dev->link); 138 rt2x00_reset_link_ant_rssi(&rt2x00dev->link);
135 139
136 rt2x00dev->link.ant.active.rx = libconf.ant.rx; 140 memcpy(&rt2x00dev->link.ant.active, &ant, sizeof(ant));
137 rt2x00dev->link.ant.active.tx = libconf.ant.tx;
138 141
139 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) 142 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
140 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK); 143 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK);
141} 144}
142 145
143static u32 rt2x00lib_get_basic_rates(struct ieee80211_supported_band *band)
144{
145 const struct rt2x00_rate *rate;
146 unsigned int i;
147 u32 mask = 0;
148
149 for (i = 0; i < band->n_bitrates; i++) {
150 rate = rt2x00_get_rate(band->bitrates[i].hw_value);
151 if (rate->flags & DEV_RATE_BASIC)
152 mask |= rate->ratemask;
153 }
154
155 return mask;
156}
157
158void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, 146void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
159 struct ieee80211_conf *conf, const int force_config) 147 struct ieee80211_conf *conf,
148 unsigned int ieee80211_flags)
160{ 149{
161 struct rt2x00lib_conf libconf; 150 struct rt2x00lib_conf libconf;
162 struct ieee80211_supported_band *band;
163 struct antenna_setup *default_ant = &rt2x00dev->default_ant;
164 struct antenna_setup *active_ant = &rt2x00dev->link.ant.active;
165 int flags = 0;
166 int short_slot_time;
167
168 /*
169 * In some situations we want to force all configurations
170 * to be reloaded (When resuming for instance).
171 */
172 if (force_config) {
173 flags = CONFIG_UPDATE_ALL;
174 goto config;
175 }
176
177 /*
178 * Check which configuration options have been
179 * updated and should be send to the device.
180 */
181 if (rt2x00dev->rx_status.band != conf->channel->band)
182 flags |= CONFIG_UPDATE_PHYMODE;
183 if (rt2x00dev->rx_status.freq != conf->channel->center_freq)
184 flags |= CONFIG_UPDATE_CHANNEL;
185 if (rt2x00dev->tx_power != conf->power_level)
186 flags |= CONFIG_UPDATE_TXPOWER;
187
188 /*
189 * Determining changes in the antenna setups request several checks:
190 * antenna_sel_{r,t}x = 0
191 * -> Does active_{r,t}x match default_{r,t}x
192 * -> Is default_{r,t}x SW_DIVERSITY
193 * antenna_sel_{r,t}x = 1/2
194 * -> Does active_{r,t}x match antenna_sel_{r,t}x
195 * The reason for not updating the antenna while SW diversity
196 * should be used is simple: Software diversity means that
197 * we should switch between the antenna's based on the
198 * quality. This means that the current antenna is good enough
199 * to work with untill the link tuner decides that an antenna
200 * switch should be performed.
201 */
202 if (!conf->antenna_sel_rx &&
203 default_ant->rx != ANTENNA_SW_DIVERSITY &&
204 default_ant->rx != active_ant->rx)
205 flags |= CONFIG_UPDATE_ANTENNA;
206 else if (conf->antenna_sel_rx &&
207 conf->antenna_sel_rx != active_ant->rx)
208 flags |= CONFIG_UPDATE_ANTENNA;
209 else if (active_ant->rx == ANTENNA_SW_DIVERSITY)
210 flags |= CONFIG_UPDATE_ANTENNA;
211
212 if (!conf->antenna_sel_tx &&
213 default_ant->tx != ANTENNA_SW_DIVERSITY &&
214 default_ant->tx != active_ant->tx)
215 flags |= CONFIG_UPDATE_ANTENNA;
216 else if (conf->antenna_sel_tx &&
217 conf->antenna_sel_tx != active_ant->tx)
218 flags |= CONFIG_UPDATE_ANTENNA;
219 else if (active_ant->tx == ANTENNA_SW_DIVERSITY)
220 flags |= CONFIG_UPDATE_ANTENNA;
221 151
222 /*
223 * The following configuration options are never
224 * stored anywhere and will always be updated.
225 */
226 flags |= CONFIG_UPDATE_SLOT_TIME;
227 flags |= CONFIG_UPDATE_BEACON_INT;
228
229 /*
230 * We have determined what options should be updated,
231 * now precalculate device configuration values depending
232 * on what configuration options need to be updated.
233 */
234config:
235 memset(&libconf, 0, sizeof(libconf)); 152 memset(&libconf, 0, sizeof(libconf));
236 153
237 if (flags & CONFIG_UPDATE_PHYMODE) { 154 libconf.conf = conf;
238 band = &rt2x00dev->bands[conf->channel->band];
239
240 libconf.band = conf->channel->band;
241 libconf.basic_rates = rt2x00lib_get_basic_rates(band);
242 }
243 155
244 if (flags & CONFIG_UPDATE_CHANNEL) { 156 if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL) {
245 memcpy(&libconf.rf, 157 memcpy(&libconf.rf,
246 &rt2x00dev->spec.channels[conf->channel->hw_value], 158 &rt2x00dev->spec.channels[conf->channel->hw_value],
247 sizeof(libconf.rf)); 159 sizeof(libconf.rf));
@@ -251,61 +163,21 @@ config:
251 sizeof(libconf.channel)); 163 sizeof(libconf.channel));
252 } 164 }
253 165
254 if (flags & CONFIG_UPDATE_ANTENNA) {
255 if (conf->antenna_sel_rx)
256 libconf.ant.rx = conf->antenna_sel_rx;
257 else if (default_ant->rx != ANTENNA_SW_DIVERSITY)
258 libconf.ant.rx = default_ant->rx;
259 else if (active_ant->rx == ANTENNA_SW_DIVERSITY)
260 libconf.ant.rx = ANTENNA_B;
261 else
262 libconf.ant.rx = active_ant->rx;
263
264 if (conf->antenna_sel_tx)
265 libconf.ant.tx = conf->antenna_sel_tx;
266 else if (default_ant->tx != ANTENNA_SW_DIVERSITY)
267 libconf.ant.tx = default_ant->tx;
268 else if (active_ant->tx == ANTENNA_SW_DIVERSITY)
269 libconf.ant.tx = ANTENNA_B;
270 else
271 libconf.ant.tx = active_ant->tx;
272 }
273
274 if (flags & CONFIG_UPDATE_SLOT_TIME) {
275 short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME;
276
277 libconf.slot_time =
278 short_slot_time ? SHORT_SLOT_TIME : SLOT_TIME;
279 libconf.sifs = SIFS;
280 libconf.pifs = short_slot_time ? SHORT_PIFS : PIFS;
281 libconf.difs = short_slot_time ? SHORT_DIFS : DIFS;
282 libconf.eifs = short_slot_time ? SHORT_EIFS : EIFS;
283 }
284
285 libconf.conf = conf;
286
287 /* 166 /*
288 * Start configuration. 167 * Start configuration.
289 */ 168 */
290 rt2x00dev->ops->lib->config(rt2x00dev, &libconf, flags); 169 rt2x00dev->ops->lib->config(rt2x00dev, &libconf, ieee80211_flags);
291 170
292 /* 171 /*
293 * Some configuration changes affect the link quality 172 * Some configuration changes affect the link quality
294 * which means we need to reset the link tuner. 173 * which means we need to reset the link tuner.
295 */ 174 */
296 if (flags & (CONFIG_UPDATE_CHANNEL | CONFIG_UPDATE_ANTENNA)) 175 if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL)
297 rt2x00lib_reset_link_tuner(rt2x00dev); 176 rt2x00lib_reset_link_tuner(rt2x00dev);
298 177
299 if (flags & CONFIG_UPDATE_PHYMODE) { 178 rt2x00dev->curr_band = conf->channel->band;
300 rt2x00dev->curr_band = conf->channel->band;
301 rt2x00dev->rx_status.band = conf->channel->band;
302 }
303
304 rt2x00dev->rx_status.freq = conf->channel->center_freq;
305 rt2x00dev->tx_power = conf->power_level; 179 rt2x00dev->tx_power = conf->power_level;
306 180
307 if (flags & CONFIG_UPDATE_ANTENNA) { 181 rt2x00dev->rx_status.band = conf->channel->band;
308 rt2x00dev->link.ant.active.rx = libconf.ant.rx; 182 rt2x00dev->rx_status.freq = conf->channel->center_freq;
309 rt2x00dev->link.ant.active.tx = libconf.ant.tx;
310 }
311} 183}
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index 5cf4c859e39d..54dd10060bf1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -285,7 +285,7 @@ exit:
285} 285}
286 286
287static unsigned int rt2x00debug_poll_queue_dump(struct file *file, 287static unsigned int rt2x00debug_poll_queue_dump(struct file *file,
288 poll_table *wait) 288 poll_table *wait)
289{ 289{
290 struct rt2x00debug_intf *intf = file->private_data; 290 struct rt2x00debug_intf *intf = file->private_data;
291 291
@@ -377,7 +377,7 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file,
377 if (*offset) 377 if (*offset)
378 return 0; 378 return 0;
379 379
380 data = kzalloc((1 + CIPHER_MAX)* MAX_LINE_LENGTH, GFP_KERNEL); 380 data = kzalloc((1 + CIPHER_MAX) * MAX_LINE_LENGTH, GFP_KERNEL);
381 if (!data) 381 if (!data)
382 return -ENOMEM; 382 return -ENOMEM;
383 383
@@ -424,16 +424,21 @@ static ssize_t rt2x00debug_read_##__name(struct file *file, \
424 const struct rt2x00debug *debug = intf->debug; \ 424 const struct rt2x00debug *debug = intf->debug; \
425 char line[16]; \ 425 char line[16]; \
426 size_t size; \ 426 size_t size; \
427 unsigned int index = intf->offset_##__name; \
427 __type value; \ 428 __type value; \
428 \ 429 \
429 if (*offset) \ 430 if (*offset) \
430 return 0; \ 431 return 0; \
431 \ 432 \
432 if (intf->offset_##__name >= debug->__name.word_count) \ 433 if (index >= debug->__name.word_count) \
433 return -EINVAL; \ 434 return -EINVAL; \
434 \ 435 \
435 debug->__name.read(intf->rt2x00dev, \ 436 if (debug->__name.flags & RT2X00DEBUGFS_OFFSET) \
436 intf->offset_##__name, &value); \ 437 index *= debug->__name.word_size; \
438 \
439 index += debug->__name.word_base; \
440 \
441 debug->__name.read(intf->rt2x00dev, index, &value); \
437 \ 442 \
438 size = sprintf(line, __format, value); \ 443 size = sprintf(line, __format, value); \
439 \ 444 \
@@ -454,12 +459,13 @@ static ssize_t rt2x00debug_write_##__name(struct file *file, \
454 const struct rt2x00debug *debug = intf->debug; \ 459 const struct rt2x00debug *debug = intf->debug; \
455 char line[16]; \ 460 char line[16]; \
456 size_t size; \ 461 size_t size; \
462 unsigned int index = intf->offset_##__name; \
457 __type value; \ 463 __type value; \
458 \ 464 \
459 if (*offset) \ 465 if (*offset) \
460 return 0; \ 466 return 0; \
461 \ 467 \
462 if (intf->offset_##__name >= debug->__name.word_count) \ 468 if (index >= debug->__name.word_count) \
463 return -EINVAL; \ 469 return -EINVAL; \
464 \ 470 \
465 if (copy_from_user(line, buf, length)) \ 471 if (copy_from_user(line, buf, length)) \
@@ -468,8 +474,12 @@ static ssize_t rt2x00debug_write_##__name(struct file *file, \
468 size = strlen(line); \ 474 size = strlen(line); \
469 value = simple_strtoul(line, NULL, 0); \ 475 value = simple_strtoul(line, NULL, 0); \
470 \ 476 \
471 debug->__name.write(intf->rt2x00dev, \ 477 if (debug->__name.flags & RT2X00DEBUGFS_OFFSET) \
472 intf->offset_##__name, value); \ 478 index *= debug->__name.word_size; \
479 \
480 index += debug->__name.word_base; \
481 \
482 debug->__name.write(intf->rt2x00dev, index, value); \
473 \ 483 \
474 *offset += size; \ 484 *offset += size; \
475 return size; \ 485 return size; \
@@ -587,29 +597,29 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
587 intf->driver_folder = 597 intf->driver_folder =
588 debugfs_create_dir(intf->rt2x00dev->ops->name, 598 debugfs_create_dir(intf->rt2x00dev->ops->name,
589 rt2x00dev->hw->wiphy->debugfsdir); 599 rt2x00dev->hw->wiphy->debugfsdir);
590 if (IS_ERR(intf->driver_folder)) 600 if (IS_ERR(intf->driver_folder) || !intf->driver_folder)
591 goto exit; 601 goto exit;
592 602
593 intf->driver_entry = 603 intf->driver_entry =
594 rt2x00debug_create_file_driver("driver", intf, &intf->driver_blob); 604 rt2x00debug_create_file_driver("driver", intf, &intf->driver_blob);
595 if (IS_ERR(intf->driver_entry)) 605 if (IS_ERR(intf->driver_entry) || !intf->driver_entry)
596 goto exit; 606 goto exit;
597 607
598 intf->chipset_entry = 608 intf->chipset_entry =
599 rt2x00debug_create_file_chipset("chipset", 609 rt2x00debug_create_file_chipset("chipset",
600 intf, &intf->chipset_blob); 610 intf, &intf->chipset_blob);
601 if (IS_ERR(intf->chipset_entry)) 611 if (IS_ERR(intf->chipset_entry) || !intf->chipset_entry)
602 goto exit; 612 goto exit;
603 613
604 intf->dev_flags = debugfs_create_file("dev_flags", S_IRUSR, 614 intf->dev_flags = debugfs_create_file("dev_flags", S_IRUSR,
605 intf->driver_folder, intf, 615 intf->driver_folder, intf,
606 &rt2x00debug_fop_dev_flags); 616 &rt2x00debug_fop_dev_flags);
607 if (IS_ERR(intf->dev_flags)) 617 if (IS_ERR(intf->dev_flags) || !intf->dev_flags)
608 goto exit; 618 goto exit;
609 619
610 intf->register_folder = 620 intf->register_folder =
611 debugfs_create_dir("register", intf->driver_folder); 621 debugfs_create_dir("register", intf->driver_folder);
612 if (IS_ERR(intf->register_folder)) 622 if (IS_ERR(intf->register_folder) || !intf->register_folder)
613 goto exit; 623 goto exit;
614 624
615#define RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(__intf, __name) \ 625#define RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(__intf, __name) \
@@ -619,7 +629,8 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
619 S_IRUSR | S_IWUSR, \ 629 S_IRUSR | S_IWUSR, \
620 (__intf)->register_folder, \ 630 (__intf)->register_folder, \
621 &(__intf)->offset_##__name); \ 631 &(__intf)->offset_##__name); \
622 if (IS_ERR((__intf)->__name##_off_entry)) \ 632 if (IS_ERR((__intf)->__name##_off_entry) \
633 || !(__intf)->__name##_off_entry) \
623 goto exit; \ 634 goto exit; \
624 \ 635 \
625 (__intf)->__name##_val_entry = \ 636 (__intf)->__name##_val_entry = \
@@ -627,7 +638,8 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
627 S_IRUSR | S_IWUSR, \ 638 S_IRUSR | S_IWUSR, \
628 (__intf)->register_folder, \ 639 (__intf)->register_folder, \
629 (__intf), &rt2x00debug_fop_##__name);\ 640 (__intf), &rt2x00debug_fop_##__name);\
630 if (IS_ERR((__intf)->__name##_val_entry)) \ 641 if (IS_ERR((__intf)->__name##_val_entry) \
642 || !(__intf)->__name##_val_entry) \
631 goto exit; \ 643 goto exit; \
632}) 644})
633 645
@@ -640,13 +652,14 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
640 652
641 intf->queue_folder = 653 intf->queue_folder =
642 debugfs_create_dir("queue", intf->driver_folder); 654 debugfs_create_dir("queue", intf->driver_folder);
643 if (IS_ERR(intf->queue_folder)) 655 if (IS_ERR(intf->queue_folder) || !intf->queue_folder)
644 goto exit; 656 goto exit;
645 657
646 intf->queue_frame_dump_entry = 658 intf->queue_frame_dump_entry =
647 debugfs_create_file("dump", S_IRUSR, intf->queue_folder, 659 debugfs_create_file("dump", S_IRUSR, intf->queue_folder,
648 intf, &rt2x00debug_fop_queue_dump); 660 intf, &rt2x00debug_fop_queue_dump);
649 if (IS_ERR(intf->queue_frame_dump_entry)) 661 if (IS_ERR(intf->queue_frame_dump_entry)
662 || !intf->queue_frame_dump_entry)
650 goto exit; 663 goto exit;
651 664
652 skb_queue_head_init(&intf->frame_dump_skbqueue); 665 skb_queue_head_init(&intf->frame_dump_skbqueue);
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.h b/drivers/net/wireless/rt2x00/rt2x00debug.h
index c4ce895aa1c7..a92104dfee9a 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.h
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.h
@@ -28,6 +28,16 @@
28 28
29struct rt2x00_dev; 29struct rt2x00_dev;
30 30
31/**
32 * enum rt2x00debugfs_entry_flags: Flags for debugfs registry entry
33 *
34 * @RT2X00DEBUGFS_OFFSET: rt2x00lib should pass the register offset
35 * as argument when using the callback function read()/write()
36 */
37enum rt2x00debugfs_entry_flags {
38 RT2X00DEBUGFS_OFFSET = (1 << 0),
39};
40
31#define RT2X00DEBUGFS_REGISTER_ENTRY(__name, __type) \ 41#define RT2X00DEBUGFS_REGISTER_ENTRY(__name, __type) \
32struct reg##__name { \ 42struct reg##__name { \
33 void (*read)(struct rt2x00_dev *rt2x00dev, \ 43 void (*read)(struct rt2x00_dev *rt2x00dev, \
@@ -35,6 +45,9 @@ struct reg##__name { \
35 void (*write)(struct rt2x00_dev *rt2x00dev, \ 45 void (*write)(struct rt2x00_dev *rt2x00dev, \
36 const unsigned int word, __type data); \ 46 const unsigned int word, __type data); \
37 \ 47 \
48 unsigned int flags; \
49 \
50 unsigned int word_base; \
38 unsigned int word_size; \ 51 unsigned int word_size; \
39 unsigned int word_count; \ 52 unsigned int word_count; \
40} __name 53} __name
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 86840e3585e8..477a944167c4 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -249,11 +249,9 @@ static void rt2x00lib_evaluate_antenna(struct rt2x00_dev *rt2x00dev)
249 rt2x00dev->link.ant.flags &= ~ANTENNA_RX_DIVERSITY; 249 rt2x00dev->link.ant.flags &= ~ANTENNA_RX_DIVERSITY;
250 rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY; 250 rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY;
251 251
252 if (rt2x00dev->hw->conf.antenna_sel_rx == 0 && 252 if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
253 rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
254 rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY; 253 rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY;
255 if (rt2x00dev->hw->conf.antenna_sel_tx == 0 && 254 if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
256 rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
257 rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY; 255 rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY;
258 256
259 if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) && 257 if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) &&
@@ -419,7 +417,7 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
419 */ 417 */
420 spin_lock(&intf->lock); 418 spin_lock(&intf->lock);
421 419
422 memcpy(&conf, &intf->conf, sizeof(conf)); 420 memcpy(&conf, &vif->bss_conf, sizeof(conf));
423 delayed_flags = intf->delayed_flags; 421 delayed_flags = intf->delayed_flags;
424 intf->delayed_flags = 0; 422 intf->delayed_flags = 0;
425 423
@@ -500,7 +498,9 @@ void rt2x00lib_txdone(struct queue_entry *entry,
500{ 498{
501 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 499 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
502 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); 500 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
501 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
503 enum data_queue_qid qid = skb_get_queue_mapping(entry->skb); 502 enum data_queue_qid qid = skb_get_queue_mapping(entry->skb);
503 u8 rate_idx, rate_flags;
504 504
505 /* 505 /*
506 * Unmap the skb. 506 * Unmap the skb.
@@ -530,14 +530,18 @@ void rt2x00lib_txdone(struct queue_entry *entry,
530 rt2x00dev->link.qual.tx_failed += 530 rt2x00dev->link.qual.tx_failed +=
531 test_bit(TXDONE_FAILURE, &txdesc->flags); 531 test_bit(TXDONE_FAILURE, &txdesc->flags);
532 532
533 rate_idx = skbdesc->tx_rate_idx;
534 rate_flags = skbdesc->tx_rate_flags;
535
533 /* 536 /*
534 * Initialize TX status 537 * Initialize TX status
535 */ 538 */
536 memset(&tx_info->status, 0, sizeof(tx_info->status)); 539 memset(&tx_info->status, 0, sizeof(tx_info->status));
537 tx_info->status.ack_signal = 0; 540 tx_info->status.ack_signal = 0;
538 tx_info->status.excessive_retries = 541 tx_info->status.rates[0].idx = rate_idx;
539 test_bit(TXDONE_EXCESSIVE_RETRY, &txdesc->flags); 542 tx_info->status.rates[0].flags = rate_flags;
540 tx_info->status.retry_count = txdesc->retry; 543 tx_info->status.rates[0].count = txdesc->retry + 1;
544 tx_info->status.rates[1].idx = -1; /* terminate */
541 545
542 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) { 546 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
543 if (test_bit(TXDONE_SUCCESS, &txdesc->flags)) 547 if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
@@ -546,7 +550,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
546 rt2x00dev->low_level_stats.dot11ACKFailureCount++; 550 rt2x00dev->low_level_stats.dot11ACKFailureCount++;
547 } 551 }
548 552
549 if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 553 if (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
550 if (test_bit(TXDONE_SUCCESS, &txdesc->flags)) 554 if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
551 rt2x00dev->low_level_stats.dot11RTSSuccessCount++; 555 rt2x00dev->low_level_stats.dot11RTSSuccessCount++;
552 else if (test_bit(TXDONE_FAILURE, &txdesc->flags)) 556 else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
@@ -1052,10 +1056,16 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1052 */ 1056 */
1053 rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf); 1057 rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf);
1054 1058
1055 rt2x00dev->hw->wiphy->interface_modes = 1059 /*
1056 BIT(NL80211_IFTYPE_AP) | 1060 * Determine which operating modes are supported, all modes
1057 BIT(NL80211_IFTYPE_STATION) | 1061 * which require beaconing, depend on the availability of
1058 BIT(NL80211_IFTYPE_ADHOC); 1062 * beacon entries.
1063 */
1064 rt2x00dev->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
1065 if (rt2x00dev->ops->bcn->entry_num > 0)
1066 rt2x00dev->hw->wiphy->interface_modes |=
1067 BIT(NL80211_IFTYPE_ADHOC) |
1068 BIT(NL80211_IFTYPE_AP);
1059 1069
1060 /* 1070 /*
1061 * Let the driver probe the device to detect the capabilities. 1071 * Let the driver probe the device to detect the capabilities.
@@ -1247,7 +1257,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1247 /* 1257 /*
1248 * Reconfigure device. 1258 * Reconfigure device.
1249 */ 1259 */
1250 retval = rt2x00mac_config(rt2x00dev->hw, &rt2x00dev->hw->conf); 1260 retval = rt2x00mac_config(rt2x00dev->hw, ~0);
1251 if (retval) 1261 if (retval)
1252 goto exit; 1262 goto exit;
1253 1263
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 797eb619aa0a..9f214f89ba6d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -96,7 +96,8 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
96void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, 96void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
97 enum antenna rx, enum antenna tx); 97 enum antenna rx, enum antenna tx);
98void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, 98void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
99 struct ieee80211_conf *conf, const int force_config); 99 struct ieee80211_conf *conf,
100 const unsigned int changed_flags);
100 101
101/** 102/**
102 * DOC: Queue handlers 103 * DOC: Queue handlers
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 2c6cc5c374ff..8fc2315c5963 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -39,7 +39,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
39 unsigned int data_length; 39 unsigned int data_length;
40 int retval = 0; 40 int retval = 0;
41 41
42 if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) 42 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
43 data_length = sizeof(struct ieee80211_cts); 43 data_length = sizeof(struct ieee80211_cts);
44 else 44 else
45 data_length = sizeof(struct ieee80211_rts); 45 data_length = sizeof(struct ieee80211_rts);
@@ -64,11 +64,11 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
64 */ 64 */
65 memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb)); 65 memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb));
66 rts_info = IEEE80211_SKB_CB(skb); 66 rts_info = IEEE80211_SKB_CB(skb);
67 rts_info->flags &= ~IEEE80211_TX_CTL_USE_RTS_CTS; 67 rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_RTS_CTS;
68 rts_info->flags &= ~IEEE80211_TX_CTL_USE_CTS_PROTECT; 68 rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_CTS_PROTECT;
69 rts_info->flags &= ~IEEE80211_TX_CTL_REQ_TX_STATUS; 69 rts_info->flags &= ~IEEE80211_TX_CTL_REQ_TX_STATUS;
70 70
71 if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) 71 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
72 rts_info->flags |= IEEE80211_TX_CTL_NO_ACK; 72 rts_info->flags |= IEEE80211_TX_CTL_NO_ACK;
73 else 73 else
74 rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK; 74 rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK;
@@ -84,7 +84,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
84 data_length += rt2x00crypto_tx_overhead(tx_info); 84 data_length += rt2x00crypto_tx_overhead(tx_info);
85#endif /* CONFIG_RT2X00_LIB_CRYPTO */ 85#endif /* CONFIG_RT2X00_LIB_CRYPTO */
86 86
87 if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) 87 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
88 ieee80211_ctstoself_get(rt2x00dev->hw, tx_info->control.vif, 88 ieee80211_ctstoself_get(rt2x00dev->hw, tx_info->control.vif,
89 frag_skb->data, data_length, tx_info, 89 frag_skb->data, data_length, tx_info,
90 (struct ieee80211_cts *)(skb->data)); 90 (struct ieee80211_cts *)(skb->data));
@@ -146,8 +146,8 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
146 * inside the hardware. 146 * inside the hardware.
147 */ 147 */
148 frame_control = le16_to_cpu(ieee80211hdr->frame_control); 148 frame_control = le16_to_cpu(ieee80211hdr->frame_control);
149 if ((tx_info->flags & (IEEE80211_TX_CTL_USE_RTS_CTS | 149 if ((tx_info->control.rates[0].flags & (IEEE80211_TX_RC_USE_RTS_CTS |
150 IEEE80211_TX_CTL_USE_CTS_PROTECT)) && 150 IEEE80211_TX_RC_USE_CTS_PROTECT)) &&
151 !rt2x00dev->ops->hw->set_rts_threshold) { 151 !rt2x00dev->ops->hw->set_rts_threshold) {
152 if (rt2x00queue_available(queue) <= 1) 152 if (rt2x00queue_available(queue) <= 1)
153 goto exit_fail; 153 goto exit_fail;
@@ -335,9 +335,10 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
335} 335}
336EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface); 336EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface);
337 337
338int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 338int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed)
339{ 339{
340 struct rt2x00_dev *rt2x00dev = hw->priv; 340 struct rt2x00_dev *rt2x00dev = hw->priv;
341 struct ieee80211_conf *conf = &hw->conf;
341 int radio_on; 342 int radio_on;
342 int status; 343 int status;
343 344
@@ -369,7 +370,7 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
369 * When we've just turned on the radio, we want to reprogram 370 * When we've just turned on the radio, we want to reprogram
370 * everything to ensure a consistent state 371 * everything to ensure a consistent state
371 */ 372 */
372 rt2x00lib_config(rt2x00dev, conf, !radio_on); 373 rt2x00lib_config(rt2x00dev, conf, changed);
373 374
374 /* Turn RX back on */ 375 /* Turn RX back on */
375 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 376 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
@@ -633,7 +634,6 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
633 } 634 }
634 635
635 spin_lock(&intf->lock); 636 spin_lock(&intf->lock);
636 memcpy(&intf->conf, bss_conf, sizeof(*bss_conf));
637 if (delayed) { 637 if (delayed) {
638 intf->delayed_flags |= delayed; 638 intf->delayed_flags |= delayed;
639 schedule_work(&rt2x00dev->intf_work); 639 schedule_work(&rt2x00dev->intf_work);
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index adf2876ed8ab..62449da577e5 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -222,8 +222,7 @@ static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev)
222{ 222{
223 struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev); 223 struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
224 224
225 rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0), 225 rt2x00dev->csr.base = pci_ioremap_bar(pci_dev, 0);
226 pci_resource_len(pci_dev, 0));
227 if (!rt2x00dev->csr.base) 226 if (!rt2x00dev->csr.base)
228 goto exit; 227 goto exit;
229 228
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.h b/drivers/net/wireless/rt2x00/rt2x00pci.h
index 80bf97c03e2d..a83f45f784f2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.h
@@ -58,7 +58,7 @@
58 * Register access. 58 * Register access.
59 */ 59 */
60static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev, 60static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev,
61 const unsigned long offset, 61 const unsigned int offset,
62 u32 *value) 62 u32 *value)
63{ 63{
64 *value = readl(rt2x00dev->csr.base + offset); 64 *value = readl(rt2x00dev->csr.base + offset);
@@ -66,14 +66,14 @@ static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev,
66 66
67static inline void 67static inline void
68rt2x00pci_register_multiread(struct rt2x00_dev *rt2x00dev, 68rt2x00pci_register_multiread(struct rt2x00_dev *rt2x00dev,
69 const unsigned long offset, 69 const unsigned int offset,
70 void *value, const u16 length) 70 void *value, const u16 length)
71{ 71{
72 memcpy_fromio(value, rt2x00dev->csr.base + offset, length); 72 memcpy_fromio(value, rt2x00dev->csr.base + offset, length);
73} 73}
74 74
75static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev, 75static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev,
76 const unsigned long offset, 76 const unsigned int offset,
77 u32 value) 77 u32 value)
78{ 78{
79 writel(value, rt2x00dev->csr.base + offset); 79 writel(value, rt2x00dev->csr.base + offset);
@@ -81,7 +81,7 @@ static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev,
81 81
82static inline void 82static inline void
83rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev, 83rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev,
84 const unsigned long offset, 84 const unsigned int offset,
85 const void *value, const u16 length) 85 const void *value, const u16 length)
86{ 86{
87 memcpy_toio(rt2x00dev->csr.base + offset, value, length); 87 memcpy_toio(rt2x00dev->csr.base + offset, value, length);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 451d410ecdae..e9f4261054bc 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -230,8 +230,15 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
230 /* 230 /*
231 * Determine retry information. 231 * Determine retry information.
232 */ 232 */
233 txdesc->retry_limit = tx_info->control.retry_limit; 233 txdesc->retry_limit = tx_info->control.rates[0].count - 1;
234 if (tx_info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT) 234 /*
235 * XXX: If at this point we knew whether the HW is going to use
236 * the RETRY_MODE bit or the retry_limit (currently all
237 * use the RETRY_MODE bit) we could do something like b43
238 * does, set the RETRY_MODE bit when the RC algorithm is
239 * requesting more than the long retry limit.
240 */
241 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
235 __set_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags); 242 __set_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags);
236 243
237 /* 244 /*
@@ -371,10 +378,12 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
371 378
372int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb) 379int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
373{ 380{
381 struct ieee80211_tx_info *tx_info;
374 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); 382 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
375 struct txentry_desc txdesc; 383 struct txentry_desc txdesc;
376 struct skb_frame_desc *skbdesc; 384 struct skb_frame_desc *skbdesc;
377 unsigned int iv_len = 0; 385 unsigned int iv_len = 0;
386 u8 rate_idx, rate_flags;
378 387
379 if (unlikely(rt2x00queue_full(queue))) 388 if (unlikely(rt2x00queue_full(queue)))
380 return -EINVAL; 389 return -EINVAL;
@@ -399,13 +408,18 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
399 iv_len = IEEE80211_SKB_CB(skb)->control.hw_key->iv_len; 408 iv_len = IEEE80211_SKB_CB(skb)->control.hw_key->iv_len;
400 409
401 /* 410 /*
402 * All information is retreived from the skb->cb array, 411 * All information is retrieved from the skb->cb array,
403 * now we should claim ownership of the driver part of that 412 * now we should claim ownership of the driver part of that
404 * array. 413 * array, preserving the bitrate index and flags.
405 */ 414 */
415 tx_info = IEEE80211_SKB_CB(skb);
416 rate_idx = tx_info->control.rates[0].idx;
417 rate_flags = tx_info->control.rates[0].flags;
406 skbdesc = get_skb_frame_desc(entry->skb); 418 skbdesc = get_skb_frame_desc(entry->skb);
407 memset(skbdesc, 0, sizeof(*skbdesc)); 419 memset(skbdesc, 0, sizeof(*skbdesc));
408 skbdesc->entry = entry; 420 skbdesc->entry = entry;
421 skbdesc->tx_rate_idx = rate_idx;
422 skbdesc->tx_rate_flags = rate_flags;
409 423
410 /* 424 /*
411 * When hardware encryption is supported, and this frame 425 * When hardware encryption is supported, and this frame
@@ -556,7 +570,7 @@ void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index)
556 queue->length++; 570 queue->length++;
557 } else if (index == Q_INDEX_DONE) { 571 } else if (index == Q_INDEX_DONE) {
558 queue->length--; 572 queue->length--;
559 queue->count ++; 573 queue->count++;
560 } 574 }
561 575
562 spin_unlock_irqrestore(&queue->lock, irqflags); 576 spin_unlock_irqrestore(&queue->lock, irqflags);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h
index 9dbf04f0f04c..4d3c7246f9ae 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.h
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
@@ -104,6 +104,8 @@ enum skb_frame_desc_flags {
104 * 104 *
105 * @flags: Frame flags, see &enum skb_frame_desc_flags. 105 * @flags: Frame flags, see &enum skb_frame_desc_flags.
106 * @desc_len: Length of the frame descriptor. 106 * @desc_len: Length of the frame descriptor.
107 * @tx_rate_idx: the index of the TX rate, used for TX status reporting
108 * @tx_rate_flags: the TX rate flags, used for TX status reporting
107 * @desc: Pointer to descriptor part of the frame. 109 * @desc: Pointer to descriptor part of the frame.
108 * Note that this pointer could point to something outside 110 * Note that this pointer could point to something outside
109 * of the scope of the skb->data pointer. 111 * of the scope of the skb->data pointer.
@@ -113,9 +115,12 @@ enum skb_frame_desc_flags {
113 * @entry: The entry to which this sk buffer belongs. 115 * @entry: The entry to which this sk buffer belongs.
114 */ 116 */
115struct skb_frame_desc { 117struct skb_frame_desc {
116 unsigned int flags; 118 u8 flags;
119
120 u8 desc_len;
121 u8 tx_rate_idx;
122 u8 tx_rate_flags;
117 123
118 unsigned int desc_len;
119 void *desc; 124 void *desc;
120 125
121 __le32 iv; 126 __le32 iv;
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index a461620b489f..3f272793412a 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -228,43 +228,34 @@ static void rt61pci_eepromregister_write(struct eeprom_93cx6 *eeprom)
228} 228}
229 229
230#ifdef CONFIG_RT2X00_LIB_DEBUGFS 230#ifdef CONFIG_RT2X00_LIB_DEBUGFS
231#define CSR_OFFSET(__word) ( CSR_REG_BASE + ((__word) * sizeof(u32)) )
232
233static void rt61pci_read_csr(struct rt2x00_dev *rt2x00dev,
234 const unsigned int word, u32 *data)
235{
236 rt2x00pci_register_read(rt2x00dev, CSR_OFFSET(word), data);
237}
238
239static void rt61pci_write_csr(struct rt2x00_dev *rt2x00dev,
240 const unsigned int word, u32 data)
241{
242 rt2x00pci_register_write(rt2x00dev, CSR_OFFSET(word), data);
243}
244
245static const struct rt2x00debug rt61pci_rt2x00debug = { 231static const struct rt2x00debug rt61pci_rt2x00debug = {
246 .owner = THIS_MODULE, 232 .owner = THIS_MODULE,
247 .csr = { 233 .csr = {
248 .read = rt61pci_read_csr, 234 .read = rt2x00pci_register_read,
249 .write = rt61pci_write_csr, 235 .write = rt2x00pci_register_write,
236 .flags = RT2X00DEBUGFS_OFFSET,
237 .word_base = CSR_REG_BASE,
250 .word_size = sizeof(u32), 238 .word_size = sizeof(u32),
251 .word_count = CSR_REG_SIZE / sizeof(u32), 239 .word_count = CSR_REG_SIZE / sizeof(u32),
252 }, 240 },
253 .eeprom = { 241 .eeprom = {
254 .read = rt2x00_eeprom_read, 242 .read = rt2x00_eeprom_read,
255 .write = rt2x00_eeprom_write, 243 .write = rt2x00_eeprom_write,
244 .word_base = EEPROM_BASE,
256 .word_size = sizeof(u16), 245 .word_size = sizeof(u16),
257 .word_count = EEPROM_SIZE / sizeof(u16), 246 .word_count = EEPROM_SIZE / sizeof(u16),
258 }, 247 },
259 .bbp = { 248 .bbp = {
260 .read = rt61pci_bbp_read, 249 .read = rt61pci_bbp_read,
261 .write = rt61pci_bbp_write, 250 .write = rt61pci_bbp_write,
251 .word_base = BBP_BASE,
262 .word_size = sizeof(u8), 252 .word_size = sizeof(u8),
263 .word_count = BBP_SIZE / sizeof(u8), 253 .word_count = BBP_SIZE / sizeof(u8),
264 }, 254 },
265 .rf = { 255 .rf = {
266 .read = rt2x00_rf_read, 256 .read = rt2x00_rf_read,
267 .write = rt61pci_rf_write, 257 .write = rt61pci_rf_write,
258 .word_base = RF_BASE,
268 .word_size = sizeof(u32), 259 .word_size = sizeof(u32),
269 .word_count = RF_SIZE / sizeof(u32), 260 .word_count = RF_SIZE / sizeof(u32),
270 }, 261 },
@@ -643,95 +634,18 @@ static void rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
643 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 634 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
644 !!erp->short_preamble); 635 !!erp->short_preamble);
645 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg); 636 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
646}
647
648
649static void rt61pci_config_lna_gain(struct rt2x00_dev *rt2x00dev,
650 struct rt2x00lib_conf *libconf)
651{
652 u16 eeprom;
653 short lna_gain = 0;
654
655 if (libconf->band == IEEE80211_BAND_2GHZ) {
656 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
657 lna_gain += 14;
658
659 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &eeprom);
660 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
661 } else {
662 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
663 lna_gain += 14;
664
665 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &eeprom);
666 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
667 }
668
669 rt2x00dev->lna_gain = lna_gain;
670}
671
672static void rt61pci_config_phymode(struct rt2x00_dev *rt2x00dev,
673 const int basic_rate_mask)
674{
675 rt2x00pci_register_write(rt2x00dev, TXRX_CSR5, basic_rate_mask);
676}
677
678static void rt61pci_config_channel(struct rt2x00_dev *rt2x00dev,
679 struct rf_channel *rf, const int txpower)
680{
681 u8 r3;
682 u8 r94;
683 u8 smart;
684
685 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
686 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
687
688 smart = !(rt2x00_rf(&rt2x00dev->chip, RF5225) ||
689 rt2x00_rf(&rt2x00dev->chip, RF2527));
690
691 rt61pci_bbp_read(rt2x00dev, 3, &r3);
692 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, smart);
693 rt61pci_bbp_write(rt2x00dev, 3, r3);
694
695 r94 = 6;
696 if (txpower > MAX_TXPOWER && txpower <= (MAX_TXPOWER + r94))
697 r94 += txpower - MAX_TXPOWER;
698 else if (txpower < MIN_TXPOWER && txpower >= (MIN_TXPOWER - r94))
699 r94 += txpower;
700 rt61pci_bbp_write(rt2x00dev, 94, r94);
701
702 rt61pci_rf_write(rt2x00dev, 1, rf->rf1);
703 rt61pci_rf_write(rt2x00dev, 2, rf->rf2);
704 rt61pci_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
705 rt61pci_rf_write(rt2x00dev, 4, rf->rf4);
706
707 udelay(200);
708
709 rt61pci_rf_write(rt2x00dev, 1, rf->rf1);
710 rt61pci_rf_write(rt2x00dev, 2, rf->rf2);
711 rt61pci_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
712 rt61pci_rf_write(rt2x00dev, 4, rf->rf4);
713
714 udelay(200);
715
716 rt61pci_rf_write(rt2x00dev, 1, rf->rf1);
717 rt61pci_rf_write(rt2x00dev, 2, rf->rf2);
718 rt61pci_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
719 rt61pci_rf_write(rt2x00dev, 4, rf->rf4);
720 637
721 msleep(1); 638 rt2x00pci_register_write(rt2x00dev, TXRX_CSR5, erp->basic_rates);
722}
723 639
724static void rt61pci_config_txpower(struct rt2x00_dev *rt2x00dev, 640 rt2x00pci_register_read(rt2x00dev, MAC_CSR9, &reg);
725 const int txpower) 641 rt2x00_set_field32(&reg, MAC_CSR9_SLOT_TIME, erp->slot_time);
726{ 642 rt2x00pci_register_write(rt2x00dev, MAC_CSR9, reg);
727 struct rf_channel rf;
728
729 rt2x00_rf_read(rt2x00dev, 1, &rf.rf1);
730 rt2x00_rf_read(rt2x00dev, 2, &rf.rf2);
731 rt2x00_rf_read(rt2x00dev, 3, &rf.rf3);
732 rt2x00_rf_read(rt2x00dev, 4, &rf.rf4);
733 643
734 rt61pci_config_channel(rt2x00dev, &rf, txpower); 644 rt2x00pci_register_read(rt2x00dev, MAC_CSR8, &reg);
645 rt2x00_set_field32(&reg, MAC_CSR8_SIFS, erp->sifs);
646 rt2x00_set_field32(&reg, MAC_CSR8_SIFS_AFTER_RX_OFDM, 3);
647 rt2x00_set_field32(&reg, MAC_CSR8_EIFS, erp->eifs);
648 rt2x00pci_register_write(rt2x00dev, MAC_CSR8, reg);
735} 649}
736 650
737static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev, 651static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
@@ -906,8 +820,8 @@ static const struct antenna_sel antenna_sel_bg[] = {
906 { 98, { 0x48, 0x48 } }, 820 { 98, { 0x48, 0x48 } },
907}; 821};
908 822
909static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev, 823static void rt61pci_config_ant(struct rt2x00_dev *rt2x00dev,
910 struct antenna_setup *ant) 824 struct antenna_setup *ant)
911{ 825{
912 const struct antenna_sel *sel; 826 const struct antenna_sel *sel;
913 unsigned int lna; 827 unsigned int lna;
@@ -954,20 +868,105 @@ static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev,
954 } 868 }
955} 869}
956 870
957static void rt61pci_config_duration(struct rt2x00_dev *rt2x00dev, 871static void rt61pci_config_lna_gain(struct rt2x00_dev *rt2x00dev,
872 struct rt2x00lib_conf *libconf)
873{
874 u16 eeprom;
875 short lna_gain = 0;
876
877 if (libconf->conf->channel->band == IEEE80211_BAND_2GHZ) {
878 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
879 lna_gain += 14;
880
881 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &eeprom);
882 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
883 } else {
884 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
885 lna_gain += 14;
886
887 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &eeprom);
888 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
889 }
890
891 rt2x00dev->lna_gain = lna_gain;
892}
893
894static void rt61pci_config_channel(struct rt2x00_dev *rt2x00dev,
895 struct rf_channel *rf, const int txpower)
896{
897 u8 r3;
898 u8 r94;
899 u8 smart;
900
901 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
902 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
903
904 smart = !(rt2x00_rf(&rt2x00dev->chip, RF5225) ||
905 rt2x00_rf(&rt2x00dev->chip, RF2527));
906
907 rt61pci_bbp_read(rt2x00dev, 3, &r3);
908 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, smart);
909 rt61pci_bbp_write(rt2x00dev, 3, r3);
910
911 r94 = 6;
912 if (txpower > MAX_TXPOWER && txpower <= (MAX_TXPOWER + r94))
913 r94 += txpower - MAX_TXPOWER;
914 else if (txpower < MIN_TXPOWER && txpower >= (MIN_TXPOWER - r94))
915 r94 += txpower;
916 rt61pci_bbp_write(rt2x00dev, 94, r94);
917
918 rt61pci_rf_write(rt2x00dev, 1, rf->rf1);
919 rt61pci_rf_write(rt2x00dev, 2, rf->rf2);
920 rt61pci_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
921 rt61pci_rf_write(rt2x00dev, 4, rf->rf4);
922
923 udelay(200);
924
925 rt61pci_rf_write(rt2x00dev, 1, rf->rf1);
926 rt61pci_rf_write(rt2x00dev, 2, rf->rf2);
927 rt61pci_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
928 rt61pci_rf_write(rt2x00dev, 4, rf->rf4);
929
930 udelay(200);
931
932 rt61pci_rf_write(rt2x00dev, 1, rf->rf1);
933 rt61pci_rf_write(rt2x00dev, 2, rf->rf2);
934 rt61pci_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
935 rt61pci_rf_write(rt2x00dev, 4, rf->rf4);
936
937 msleep(1);
938}
939
940static void rt61pci_config_txpower(struct rt2x00_dev *rt2x00dev,
941 const int txpower)
942{
943 struct rf_channel rf;
944
945 rt2x00_rf_read(rt2x00dev, 1, &rf.rf1);
946 rt2x00_rf_read(rt2x00dev, 2, &rf.rf2);
947 rt2x00_rf_read(rt2x00dev, 3, &rf.rf3);
948 rt2x00_rf_read(rt2x00dev, 4, &rf.rf4);
949
950 rt61pci_config_channel(rt2x00dev, &rf, txpower);
951}
952
953static void rt61pci_config_retry_limit(struct rt2x00_dev *rt2x00dev,
958 struct rt2x00lib_conf *libconf) 954 struct rt2x00lib_conf *libconf)
959{ 955{
960 u32 reg; 956 u32 reg;
961 957
962 rt2x00pci_register_read(rt2x00dev, MAC_CSR9, &reg); 958 rt2x00pci_register_read(rt2x00dev, TXRX_CSR4, &reg);
963 rt2x00_set_field32(&reg, MAC_CSR9_SLOT_TIME, libconf->slot_time); 959 rt2x00_set_field32(&reg, TXRX_CSR4_LONG_RETRY_LIMIT,
964 rt2x00pci_register_write(rt2x00dev, MAC_CSR9, reg); 960 libconf->conf->long_frame_max_tx_count);
961 rt2x00_set_field32(&reg, TXRX_CSR4_SHORT_RETRY_LIMIT,
962 libconf->conf->short_frame_max_tx_count);
963 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
964}
965 965
966 rt2x00pci_register_read(rt2x00dev, MAC_CSR8, &reg); 966static void rt61pci_config_duration(struct rt2x00_dev *rt2x00dev,
967 rt2x00_set_field32(&reg, MAC_CSR8_SIFS, libconf->sifs); 967 struct rt2x00lib_conf *libconf)
968 rt2x00_set_field32(&reg, MAC_CSR8_SIFS_AFTER_RX_OFDM, 3); 968{
969 rt2x00_set_field32(&reg, MAC_CSR8_EIFS, libconf->eifs); 969 u32 reg;
970 rt2x00pci_register_write(rt2x00dev, MAC_CSR8, reg);
971 970
972 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg); 971 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
973 rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER); 972 rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER);
@@ -990,16 +989,15 @@ static void rt61pci_config(struct rt2x00_dev *rt2x00dev,
990 /* Always recalculate LNA gain before changing configuration */ 989 /* Always recalculate LNA gain before changing configuration */
991 rt61pci_config_lna_gain(rt2x00dev, libconf); 990 rt61pci_config_lna_gain(rt2x00dev, libconf);
992 991
993 if (flags & CONFIG_UPDATE_PHYMODE) 992 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
994 rt61pci_config_phymode(rt2x00dev, libconf->basic_rates);
995 if (flags & CONFIG_UPDATE_CHANNEL)
996 rt61pci_config_channel(rt2x00dev, &libconf->rf, 993 rt61pci_config_channel(rt2x00dev, &libconf->rf,
997 libconf->conf->power_level); 994 libconf->conf->power_level);
998 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 995 if ((flags & IEEE80211_CONF_CHANGE_POWER) &&
996 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
999 rt61pci_config_txpower(rt2x00dev, libconf->conf->power_level); 997 rt61pci_config_txpower(rt2x00dev, libconf->conf->power_level);
1000 if (flags & CONFIG_UPDATE_ANTENNA) 998 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
1001 rt61pci_config_antenna(rt2x00dev, &libconf->ant); 999 rt61pci_config_retry_limit(rt2x00dev, libconf);
1002 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 1000 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
1003 rt61pci_config_duration(rt2x00dev, libconf); 1001 rt61pci_config_duration(rt2x00dev, libconf);
1004} 1002}
1005 1003
@@ -1934,7 +1932,7 @@ static int rt61pci_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1934} 1932}
1935 1933
1936static void rt61pci_fill_rxdone(struct queue_entry *entry, 1934static void rt61pci_fill_rxdone(struct queue_entry *entry,
1937 struct rxdone_entry_desc *rxdesc) 1935 struct rxdone_entry_desc *rxdesc)
1938{ 1936{
1939 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 1937 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1940 struct queue_entry_priv_pci *entry_priv = entry->priv_data; 1938 struct queue_entry_priv_pci *entry_priv = entry->priv_data;
@@ -2175,10 +2173,8 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
2175 */ 2173 */
2176 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); 2174 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
2177 if (!is_valid_ether_addr(mac)) { 2175 if (!is_valid_ether_addr(mac)) {
2178 DECLARE_MAC_BUF(macbuf);
2179
2180 random_ether_addr(mac); 2176 random_ether_addr(mac);
2181 EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac)); 2177 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
2182 } 2178 }
2183 2179
2184 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); 2180 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
@@ -2630,20 +2626,6 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
2630/* 2626/*
2631 * IEEE80211 stack callback functions. 2627 * IEEE80211 stack callback functions.
2632 */ 2628 */
2633static int rt61pci_set_retry_limit(struct ieee80211_hw *hw,
2634 u32 short_retry, u32 long_retry)
2635{
2636 struct rt2x00_dev *rt2x00dev = hw->priv;
2637 u32 reg;
2638
2639 rt2x00pci_register_read(rt2x00dev, TXRX_CSR4, &reg);
2640 rt2x00_set_field32(&reg, TXRX_CSR4_LONG_RETRY_LIMIT, long_retry);
2641 rt2x00_set_field32(&reg, TXRX_CSR4_SHORT_RETRY_LIMIT, short_retry);
2642 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
2643
2644 return 0;
2645}
2646
2647static int rt61pci_conf_tx(struct ieee80211_hw *hw, u16 queue_idx, 2629static int rt61pci_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
2648 const struct ieee80211_tx_queue_params *params) 2630 const struct ieee80211_tx_queue_params *params)
2649{ 2631{
@@ -2726,7 +2708,6 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = {
2726 .configure_filter = rt2x00mac_configure_filter, 2708 .configure_filter = rt2x00mac_configure_filter,
2727 .set_key = rt2x00mac_set_key, 2709 .set_key = rt2x00mac_set_key,
2728 .get_stats = rt2x00mac_get_stats, 2710 .get_stats = rt2x00mac_get_stats,
2729 .set_retry_limit = rt61pci_set_retry_limit,
2730 .bss_info_changed = rt2x00mac_bss_info_changed, 2711 .bss_info_changed = rt2x00mac_bss_info_changed,
2731 .conf_tx = rt61pci_conf_tx, 2712 .conf_tx = rt61pci_conf_tx,
2732 .get_tx_stats = rt2x00mac_get_tx_stats, 2713 .get_tx_stats = rt2x00mac_get_tx_stats,
@@ -2758,6 +2739,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2758 .config_filter = rt61pci_config_filter, 2739 .config_filter = rt61pci_config_filter,
2759 .config_intf = rt61pci_config_intf, 2740 .config_intf = rt61pci_config_intf,
2760 .config_erp = rt61pci_config_erp, 2741 .config_erp = rt61pci_config_erp,
2742 .config_ant = rt61pci_config_ant,
2761 .config = rt61pci_config, 2743 .config = rt61pci_config,
2762}; 2744};
2763 2745
diff --git a/drivers/net/wireless/rt2x00/rt61pci.h b/drivers/net/wireless/rt2x00/rt61pci.h
index 8ec1451308cc..65fe3332364a 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.h
+++ b/drivers/net/wireless/rt2x00/rt61pci.h
@@ -48,7 +48,9 @@
48#define CSR_REG_SIZE 0x04b0 48#define CSR_REG_SIZE 0x04b0
49#define EEPROM_BASE 0x0000 49#define EEPROM_BASE 0x0000
50#define EEPROM_SIZE 0x0100 50#define EEPROM_SIZE 0x0100
51#define BBP_BASE 0x0000
51#define BBP_SIZE 0x0080 52#define BBP_SIZE 0x0080
53#define RF_BASE 0x0000
52#define RF_SIZE 0x0014 54#define RF_SIZE 0x0014
53 55
54/* 56/*
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 934f8e03c5aa..767e3c98184c 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -249,43 +249,34 @@ rf_write:
249} 249}
250 250
251#ifdef CONFIG_RT2X00_LIB_DEBUGFS 251#ifdef CONFIG_RT2X00_LIB_DEBUGFS
252#define CSR_OFFSET(__word) ( CSR_REG_BASE + ((__word) * sizeof(u32)) )
253
254static void rt73usb_read_csr(struct rt2x00_dev *rt2x00dev,
255 const unsigned int word, u32 *data)
256{
257 rt73usb_register_read(rt2x00dev, CSR_OFFSET(word), data);
258}
259
260static void rt73usb_write_csr(struct rt2x00_dev *rt2x00dev,
261 const unsigned int word, u32 data)
262{
263 rt73usb_register_write(rt2x00dev, CSR_OFFSET(word), data);
264}
265
266static const struct rt2x00debug rt73usb_rt2x00debug = { 252static const struct rt2x00debug rt73usb_rt2x00debug = {
267 .owner = THIS_MODULE, 253 .owner = THIS_MODULE,
268 .csr = { 254 .csr = {
269 .read = rt73usb_read_csr, 255 .read = rt73usb_register_read,
270 .write = rt73usb_write_csr, 256 .write = rt73usb_register_write,
257 .flags = RT2X00DEBUGFS_OFFSET,
258 .word_base = CSR_REG_BASE,
271 .word_size = sizeof(u32), 259 .word_size = sizeof(u32),
272 .word_count = CSR_REG_SIZE / sizeof(u32), 260 .word_count = CSR_REG_SIZE / sizeof(u32),
273 }, 261 },
274 .eeprom = { 262 .eeprom = {
275 .read = rt2x00_eeprom_read, 263 .read = rt2x00_eeprom_read,
276 .write = rt2x00_eeprom_write, 264 .write = rt2x00_eeprom_write,
265 .word_base = EEPROM_BASE,
277 .word_size = sizeof(u16), 266 .word_size = sizeof(u16),
278 .word_count = EEPROM_SIZE / sizeof(u16), 267 .word_count = EEPROM_SIZE / sizeof(u16),
279 }, 268 },
280 .bbp = { 269 .bbp = {
281 .read = rt73usb_bbp_read, 270 .read = rt73usb_bbp_read,
282 .write = rt73usb_bbp_write, 271 .write = rt73usb_bbp_write,
272 .word_base = BBP_BASE,
283 .word_size = sizeof(u8), 273 .word_size = sizeof(u8),
284 .word_count = BBP_SIZE / sizeof(u8), 274 .word_count = BBP_SIZE / sizeof(u8),
285 }, 275 },
286 .rf = { 276 .rf = {
287 .read = rt2x00_rf_read, 277 .read = rt2x00_rf_read,
288 .write = rt73usb_rf_write, 278 .write = rt73usb_rf_write,
279 .word_base = RF_BASE,
289 .word_size = sizeof(u32), 280 .word_size = sizeof(u32),
290 .word_count = RF_SIZE / sizeof(u32), 281 .word_count = RF_SIZE / sizeof(u32),
291 }, 282 },
@@ -669,87 +660,18 @@ static void rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
669 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 660 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
670 !!erp->short_preamble); 661 !!erp->short_preamble);
671 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); 662 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg);
672}
673
674static void rt73usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
675 struct rt2x00lib_conf *libconf)
676{
677 u16 eeprom;
678 short lna_gain = 0;
679
680 if (libconf->band == IEEE80211_BAND_2GHZ) {
681 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
682 lna_gain += 14;
683
684 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &eeprom);
685 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
686 } else {
687 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &eeprom);
688 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
689 }
690
691 rt2x00dev->lna_gain = lna_gain;
692}
693
694static void rt73usb_config_phymode(struct rt2x00_dev *rt2x00dev,
695 const int basic_rate_mask)
696{
697 rt73usb_register_write(rt2x00dev, TXRX_CSR5, basic_rate_mask);
698}
699
700static void rt73usb_config_channel(struct rt2x00_dev *rt2x00dev,
701 struct rf_channel *rf, const int txpower)
702{
703 u8 r3;
704 u8 r94;
705 u8 smart;
706
707 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
708 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
709
710 smart = !(rt2x00_rf(&rt2x00dev->chip, RF5225) ||
711 rt2x00_rf(&rt2x00dev->chip, RF2527));
712
713 rt73usb_bbp_read(rt2x00dev, 3, &r3);
714 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, smart);
715 rt73usb_bbp_write(rt2x00dev, 3, r3);
716
717 r94 = 6;
718 if (txpower > MAX_TXPOWER && txpower <= (MAX_TXPOWER + r94))
719 r94 += txpower - MAX_TXPOWER;
720 else if (txpower < MIN_TXPOWER && txpower >= (MIN_TXPOWER - r94))
721 r94 += txpower;
722 rt73usb_bbp_write(rt2x00dev, 94, r94);
723
724 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
725 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
726 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
727 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
728
729 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
730 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
731 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
732 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
733
734 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
735 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
736 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
737 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
738 663
739 udelay(10); 664 rt73usb_register_write(rt2x00dev, TXRX_CSR5, erp->basic_rates);
740}
741
742static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev,
743 const int txpower)
744{
745 struct rf_channel rf;
746 665
747 rt2x00_rf_read(rt2x00dev, 1, &rf.rf1); 666 rt73usb_register_read(rt2x00dev, MAC_CSR9, &reg);
748 rt2x00_rf_read(rt2x00dev, 2, &rf.rf2); 667 rt2x00_set_field32(&reg, MAC_CSR9_SLOT_TIME, erp->slot_time);
749 rt2x00_rf_read(rt2x00dev, 3, &rf.rf3); 668 rt73usb_register_write(rt2x00dev, MAC_CSR9, reg);
750 rt2x00_rf_read(rt2x00dev, 4, &rf.rf4);
751 669
752 rt73usb_config_channel(rt2x00dev, &rf, txpower); 670 rt73usb_register_read(rt2x00dev, MAC_CSR8, &reg);
671 rt2x00_set_field32(&reg, MAC_CSR8_SIFS, erp->sifs);
672 rt2x00_set_field32(&reg, MAC_CSR8_SIFS_AFTER_RX_OFDM, 3);
673 rt2x00_set_field32(&reg, MAC_CSR8_EIFS, erp->eifs);
674 rt73usb_register_write(rt2x00dev, MAC_CSR8, reg);
753} 675}
754 676
755static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, 677static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
@@ -869,8 +791,8 @@ static const struct antenna_sel antenna_sel_bg[] = {
869 { 98, { 0x48, 0x48 } }, 791 { 98, { 0x48, 0x48 } },
870}; 792};
871 793
872static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev, 794static void rt73usb_config_ant(struct rt2x00_dev *rt2x00dev,
873 struct antenna_setup *ant) 795 struct antenna_setup *ant)
874{ 796{
875 const struct antenna_sel *sel; 797 const struct antenna_sel *sel;
876 unsigned int lna; 798 unsigned int lna;
@@ -912,20 +834,98 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
912 rt73usb_config_antenna_2x(rt2x00dev, ant); 834 rt73usb_config_antenna_2x(rt2x00dev, ant);
913} 835}
914 836
915static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev, 837static void rt73usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
916 struct rt2x00lib_conf *libconf) 838 struct rt2x00lib_conf *libconf)
917{ 839{
840 u16 eeprom;
841 short lna_gain = 0;
842
843 if (libconf->conf->channel->band == IEEE80211_BAND_2GHZ) {
844 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
845 lna_gain += 14;
846
847 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &eeprom);
848 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
849 } else {
850 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &eeprom);
851 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
852 }
853
854 rt2x00dev->lna_gain = lna_gain;
855}
856
857static void rt73usb_config_channel(struct rt2x00_dev *rt2x00dev,
858 struct rf_channel *rf, const int txpower)
859{
860 u8 r3;
861 u8 r94;
862 u8 smart;
863
864 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
865 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
866
867 smart = !(rt2x00_rf(&rt2x00dev->chip, RF5225) ||
868 rt2x00_rf(&rt2x00dev->chip, RF2527));
869
870 rt73usb_bbp_read(rt2x00dev, 3, &r3);
871 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, smart);
872 rt73usb_bbp_write(rt2x00dev, 3, r3);
873
874 r94 = 6;
875 if (txpower > MAX_TXPOWER && txpower <= (MAX_TXPOWER + r94))
876 r94 += txpower - MAX_TXPOWER;
877 else if (txpower < MIN_TXPOWER && txpower >= (MIN_TXPOWER - r94))
878 r94 += txpower;
879 rt73usb_bbp_write(rt2x00dev, 94, r94);
880
881 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
882 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
883 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
884 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
885
886 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
887 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
888 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
889 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
890
891 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
892 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
893 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
894 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
895
896 udelay(10);
897}
898
899static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev,
900 const int txpower)
901{
902 struct rf_channel rf;
903
904 rt2x00_rf_read(rt2x00dev, 1, &rf.rf1);
905 rt2x00_rf_read(rt2x00dev, 2, &rf.rf2);
906 rt2x00_rf_read(rt2x00dev, 3, &rf.rf3);
907 rt2x00_rf_read(rt2x00dev, 4, &rf.rf4);
908
909 rt73usb_config_channel(rt2x00dev, &rf, txpower);
910}
911
912static void rt73usb_config_retry_limit(struct rt2x00_dev *rt2x00dev,
913 struct rt2x00lib_conf *libconf)
914{
918 u32 reg; 915 u32 reg;
919 916
920 rt73usb_register_read(rt2x00dev, MAC_CSR9, &reg); 917 rt73usb_register_read(rt2x00dev, TXRX_CSR4, &reg);
921 rt2x00_set_field32(&reg, MAC_CSR9_SLOT_TIME, libconf->slot_time); 918 rt2x00_set_field32(&reg, TXRX_CSR4_LONG_RETRY_LIMIT,
922 rt73usb_register_write(rt2x00dev, MAC_CSR9, reg); 919 libconf->conf->long_frame_max_tx_count);
920 rt2x00_set_field32(&reg, TXRX_CSR4_SHORT_RETRY_LIMIT,
921 libconf->conf->short_frame_max_tx_count);
922 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg);
923}
923 924
924 rt73usb_register_read(rt2x00dev, MAC_CSR8, &reg); 925static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev,
925 rt2x00_set_field32(&reg, MAC_CSR8_SIFS, libconf->sifs); 926 struct rt2x00lib_conf *libconf)
926 rt2x00_set_field32(&reg, MAC_CSR8_SIFS_AFTER_RX_OFDM, 3); 927{
927 rt2x00_set_field32(&reg, MAC_CSR8_EIFS, libconf->eifs); 928 u32 reg;
928 rt73usb_register_write(rt2x00dev, MAC_CSR8, reg);
929 929
930 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg); 930 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
931 rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER); 931 rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER);
@@ -948,16 +948,15 @@ static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
948 /* Always recalculate LNA gain before changing configuration */ 948 /* Always recalculate LNA gain before changing configuration */
949 rt73usb_config_lna_gain(rt2x00dev, libconf); 949 rt73usb_config_lna_gain(rt2x00dev, libconf);
950 950
951 if (flags & CONFIG_UPDATE_PHYMODE) 951 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
952 rt73usb_config_phymode(rt2x00dev, libconf->basic_rates);
953 if (flags & CONFIG_UPDATE_CHANNEL)
954 rt73usb_config_channel(rt2x00dev, &libconf->rf, 952 rt73usb_config_channel(rt2x00dev, &libconf->rf,
955 libconf->conf->power_level); 953 libconf->conf->power_level);
956 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 954 if ((flags & IEEE80211_CONF_CHANGE_POWER) &&
955 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
957 rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level); 956 rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level);
958 if (flags & CONFIG_UPDATE_ANTENNA) 957 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
959 rt73usb_config_antenna(rt2x00dev, &libconf->ant); 958 rt73usb_config_retry_limit(rt2x00dev, libconf);
960 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 959 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
961 rt73usb_config_duration(rt2x00dev, libconf); 960 rt73usb_config_duration(rt2x00dev, libconf);
962} 961}
963 962
@@ -1685,7 +1684,7 @@ static int rt73usb_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1685} 1684}
1686 1685
1687static void rt73usb_fill_rxdone(struct queue_entry *entry, 1686static void rt73usb_fill_rxdone(struct queue_entry *entry,
1688 struct rxdone_entry_desc *rxdesc) 1687 struct rxdone_entry_desc *rxdesc)
1689{ 1688{
1690 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 1689 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1691 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 1690 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
@@ -1781,10 +1780,8 @@ static int rt73usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1781 */ 1780 */
1782 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); 1781 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
1783 if (!is_valid_ether_addr(mac)) { 1782 if (!is_valid_ether_addr(mac)) {
1784 DECLARE_MAC_BUF(macbuf);
1785
1786 random_ether_addr(mac); 1783 random_ether_addr(mac);
1787 EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac)); 1784 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
1788 } 1785 }
1789 1786
1790 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); 1787 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
@@ -2211,20 +2208,6 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
2211/* 2208/*
2212 * IEEE80211 stack callback functions. 2209 * IEEE80211 stack callback functions.
2213 */ 2210 */
2214static int rt73usb_set_retry_limit(struct ieee80211_hw *hw,
2215 u32 short_retry, u32 long_retry)
2216{
2217 struct rt2x00_dev *rt2x00dev = hw->priv;
2218 u32 reg;
2219
2220 rt73usb_register_read(rt2x00dev, TXRX_CSR4, &reg);
2221 rt2x00_set_field32(&reg, TXRX_CSR4_LONG_RETRY_LIMIT, long_retry);
2222 rt2x00_set_field32(&reg, TXRX_CSR4_SHORT_RETRY_LIMIT, short_retry);
2223 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg);
2224
2225 return 0;
2226}
2227
2228static int rt73usb_conf_tx(struct ieee80211_hw *hw, u16 queue_idx, 2211static int rt73usb_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
2229 const struct ieee80211_tx_queue_params *params) 2212 const struct ieee80211_tx_queue_params *params)
2230{ 2213{
@@ -2317,7 +2300,6 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
2317 .configure_filter = rt2x00mac_configure_filter, 2300 .configure_filter = rt2x00mac_configure_filter,
2318 .set_key = rt2x00mac_set_key, 2301 .set_key = rt2x00mac_set_key,
2319 .get_stats = rt2x00mac_get_stats, 2302 .get_stats = rt2x00mac_get_stats,
2320 .set_retry_limit = rt73usb_set_retry_limit,
2321 .bss_info_changed = rt2x00mac_bss_info_changed, 2303 .bss_info_changed = rt2x00mac_bss_info_changed,
2322 .conf_tx = rt73usb_conf_tx, 2304 .conf_tx = rt73usb_conf_tx,
2323 .get_tx_stats = rt2x00mac_get_tx_stats, 2305 .get_tx_stats = rt2x00mac_get_tx_stats,
@@ -2348,6 +2330,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2348 .config_filter = rt73usb_config_filter, 2330 .config_filter = rt73usb_config_filter,
2349 .config_intf = rt73usb_config_intf, 2331 .config_intf = rt73usb_config_intf,
2350 .config_erp = rt73usb_config_erp, 2332 .config_erp = rt73usb_config_erp,
2333 .config_ant = rt73usb_config_ant,
2351 .config = rt73usb_config, 2334 .config = rt73usb_config,
2352}; 2335};
2353 2336
diff --git a/drivers/net/wireless/rt2x00/rt73usb.h b/drivers/net/wireless/rt2x00/rt73usb.h
index 868386c457f6..46e1405eb0e2 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.h
+++ b/drivers/net/wireless/rt2x00/rt73usb.h
@@ -48,7 +48,9 @@
48#define CSR_REG_SIZE 0x04b0 48#define CSR_REG_SIZE 0x04b0
49#define EEPROM_BASE 0x0000 49#define EEPROM_BASE 0x0000
50#define EEPROM_SIZE 0x0100 50#define EEPROM_SIZE 0x0100
51#define BBP_BASE 0x0000
51#define BBP_SIZE 0x0080 52#define BBP_SIZE 0x0080
53#define RF_BASE 0x0000
52#define RF_SIZE 0x0014 54#define RF_SIZE 0x0014
53 55
54/* 56/*
diff --git a/drivers/net/wireless/rtl8180_dev.c b/drivers/net/wireless/rtl8180_dev.c
index df7e78ee8a88..6c226c024dd9 100644
--- a/drivers/net/wireless/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl8180_dev.c
@@ -182,15 +182,13 @@ static void rtl8180_handle_tx(struct ieee80211_hw *dev, unsigned int prio)
182 skb->len, PCI_DMA_TODEVICE); 182 skb->len, PCI_DMA_TODEVICE);
183 183
184 info = IEEE80211_SKB_CB(skb); 184 info = IEEE80211_SKB_CB(skb);
185 memset(&info->status, 0, sizeof(info->status)); 185 ieee80211_tx_info_clear_status(info);
186 186
187 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { 187 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) &&
188 if (flags & RTL818X_TX_DESC_FLAG_TX_OK) 188 (flags & RTL818X_TX_DESC_FLAG_TX_OK))
189 info->flags |= IEEE80211_TX_STAT_ACK; 189 info->flags |= IEEE80211_TX_STAT_ACK;
190 else 190
191 info->status.excessive_retries = 1; 191 info->status.rates[0].count = (flags & 0xFF) + 1;
192 }
193 info->status.retry_count = flags & 0xFF;
194 192
195 ieee80211_tx_status_irqsafe(dev, skb); 193 ieee80211_tx_status_irqsafe(dev, skb);
196 if (ring->entries - skb_queue_len(&ring->queue) == 2) 194 if (ring->entries - skb_queue_len(&ring->queue) == 2)
@@ -243,6 +241,7 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
243 unsigned int idx, prio; 241 unsigned int idx, prio;
244 dma_addr_t mapping; 242 dma_addr_t mapping;
245 u32 tx_flags; 243 u32 tx_flags;
244 u8 rc_flags;
246 u16 plcp_len = 0; 245 u16 plcp_len = 0;
247 __le16 rts_duration = 0; 246 __le16 rts_duration = 0;
248 247
@@ -261,15 +260,16 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
261 tx_flags |= RTL818X_TX_DESC_FLAG_DMA | 260 tx_flags |= RTL818X_TX_DESC_FLAG_DMA |
262 RTL818X_TX_DESC_FLAG_NO_ENC; 261 RTL818X_TX_DESC_FLAG_NO_ENC;
263 262
264 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 263 rc_flags = info->control.rates[0].flags;
264 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
265 tx_flags |= RTL818X_TX_DESC_FLAG_RTS; 265 tx_flags |= RTL818X_TX_DESC_FLAG_RTS;
266 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; 266 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
267 } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { 267 } else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
268 tx_flags |= RTL818X_TX_DESC_FLAG_CTS; 268 tx_flags |= RTL818X_TX_DESC_FLAG_CTS;
269 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; 269 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
270 } 270 }
271 271
272 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) 272 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
273 rts_duration = ieee80211_rts_duration(dev, priv->vif, skb->len, 273 rts_duration = ieee80211_rts_duration(dev, priv->vif, skb->len,
274 info); 274 info);
275 275
@@ -292,9 +292,9 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
292 entry->plcp_len = cpu_to_le16(plcp_len); 292 entry->plcp_len = cpu_to_le16(plcp_len);
293 entry->tx_buf = cpu_to_le32(mapping); 293 entry->tx_buf = cpu_to_le32(mapping);
294 entry->frame_len = cpu_to_le32(skb->len); 294 entry->frame_len = cpu_to_le32(skb->len);
295 entry->flags2 = info->control.retries[0].rate_idx >= 0 ? 295 entry->flags2 = info->control.rates[1].idx >= 0 ?
296 ieee80211_get_alt_retry_rate(dev, info, 0)->bitrate << 4 : 0; 296 ieee80211_get_alt_retry_rate(dev, info, 0)->bitrate << 4 : 0;
297 entry->retry_limit = info->control.retry_limit; 297 entry->retry_limit = info->control.rates[0].count;
298 entry->flags = cpu_to_le32(tx_flags); 298 entry->flags = cpu_to_le32(tx_flags);
299 __skb_queue_tail(&ring->queue, skb); 299 __skb_queue_tail(&ring->queue, skb);
300 if (ring->entries - skb_queue_len(&ring->queue) < 2) 300 if (ring->entries - skb_queue_len(&ring->queue) < 2)
@@ -692,9 +692,10 @@ static void rtl8180_remove_interface(struct ieee80211_hw *dev,
692 priv->vif = NULL; 692 priv->vif = NULL;
693} 693}
694 694
695static int rtl8180_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) 695static int rtl8180_config(struct ieee80211_hw *dev, u32 changed)
696{ 696{
697 struct rtl8180_priv *priv = dev->priv; 697 struct rtl8180_priv *priv = dev->priv;
698 struct ieee80211_conf *conf = &dev->conf;
698 699
699 priv->rf->set_chan(dev, conf); 700 priv->rf->set_chan(dev, conf);
700 701
@@ -806,7 +807,6 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
806 const char *chip_name, *rf_name = NULL; 807 const char *chip_name, *rf_name = NULL;
807 u32 reg; 808 u32 reg;
808 u16 eeprom_val; 809 u16 eeprom_val;
809 DECLARE_MAC_BUF(mac);
810 810
811 err = pci_enable_device(pdev); 811 err = pci_enable_device(pdev);
812 if (err) { 812 if (err) {
@@ -855,7 +855,7 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
855 priv = dev->priv; 855 priv = dev->priv;
856 priv->pdev = pdev; 856 priv->pdev = pdev;
857 857
858 dev->max_altrates = 1; 858 dev->max_rates = 2;
859 SET_IEEE80211_DEV(dev, &pdev->dev); 859 SET_IEEE80211_DEV(dev, &pdev->dev);
860 pci_set_drvdata(pdev, dev); 860 pci_set_drvdata(pdev, dev);
861 861
@@ -1002,8 +1002,8 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
1002 goto err_iounmap; 1002 goto err_iounmap;
1003 } 1003 }
1004 1004
1005 printk(KERN_INFO "%s: hwaddr %s, %s + %s\n", 1005 printk(KERN_INFO "%s: hwaddr %pM, %s + %s\n",
1006 wiphy_name(dev->wiphy), print_mac(mac, dev->wiphy->perm_addr), 1006 wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
1007 chip_name, priv->rf->name); 1007 chip_name, priv->rf->name);
1008 1008
1009 return 0; 1009 return 0;
diff --git a/drivers/net/wireless/rtl8187.h b/drivers/net/wireless/rtl8187.h
index e82bb4d289e8..33725d0978b3 100644
--- a/drivers/net/wireless/rtl8187.h
+++ b/drivers/net/wireless/rtl8187.h
@@ -100,7 +100,6 @@ struct rtl8187_priv {
100 struct usb_device *udev; 100 struct usb_device *udev;
101 u32 rx_conf; 101 u32 rx_conf;
102 u16 txpwr_base; 102 u16 txpwr_base;
103 u16 seqno;
104 u8 asic_rev; 103 u8 asic_rev;
105 u8 is_rtl8187b; 104 u8 is_rtl8187b;
106 enum { 105 enum {
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index 69eb0132593b..e1399d0b55d3 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -155,21 +155,19 @@ void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data)
155 rtl818x_iowrite8(priv, &priv->map->PHY[2], (data >> 16) & 0xFF); 155 rtl818x_iowrite8(priv, &priv->map->PHY[2], (data >> 16) & 0xFF);
156 rtl818x_iowrite8(priv, &priv->map->PHY[1], (data >> 8) & 0xFF); 156 rtl818x_iowrite8(priv, &priv->map->PHY[1], (data >> 8) & 0xFF);
157 rtl818x_iowrite8(priv, &priv->map->PHY[0], data & 0xFF); 157 rtl818x_iowrite8(priv, &priv->map->PHY[0], data & 0xFF);
158
159 msleep(1);
160} 158}
161 159
162static void rtl8187_tx_cb(struct urb *urb) 160static void rtl8187_tx_cb(struct urb *urb)
163{ 161{
164 struct sk_buff *skb = (struct sk_buff *)urb->context; 162 struct sk_buff *skb = (struct sk_buff *)urb->context;
165 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 163 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
166 struct ieee80211_hw *hw = info->driver_data[0]; 164 struct ieee80211_hw *hw = info->rate_driver_data[0];
167 struct rtl8187_priv *priv = hw->priv; 165 struct rtl8187_priv *priv = hw->priv;
168 166
169 usb_free_urb(info->driver_data[1]); 167 usb_free_urb(info->rate_driver_data[1]);
170 skb_pull(skb, priv->is_rtl8187b ? sizeof(struct rtl8187b_tx_hdr) : 168 skb_pull(skb, priv->is_rtl8187b ? sizeof(struct rtl8187b_tx_hdr) :
171 sizeof(struct rtl8187_tx_hdr)); 169 sizeof(struct rtl8187_tx_hdr));
172 memset(&info->status, 0, sizeof(info->status)); 170 ieee80211_tx_info_clear_status(info);
173 info->flags |= IEEE80211_TX_STAT_ACK; 171 info->flags |= IEEE80211_TX_STAT_ACK;
174 ieee80211_tx_status_irqsafe(hw, skb); 172 ieee80211_tx_status_irqsafe(hw, skb);
175} 173}
@@ -178,7 +176,6 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
178{ 176{
179 struct rtl8187_priv *priv = dev->priv; 177 struct rtl8187_priv *priv = dev->priv;
180 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 178 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
181 struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data;
182 unsigned int ep; 179 unsigned int ep;
183 void *buf; 180 void *buf;
184 struct urb *urb; 181 struct urb *urb;
@@ -198,12 +195,12 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
198 flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24; 195 flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24;
199 if (ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control)) 196 if (ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control))
200 flags |= RTL818X_TX_DESC_FLAG_MOREFRAG; 197 flags |= RTL818X_TX_DESC_FLAG_MOREFRAG;
201 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 198 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
202 flags |= RTL818X_TX_DESC_FLAG_RTS; 199 flags |= RTL818X_TX_DESC_FLAG_RTS;
203 flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; 200 flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
204 rts_dur = ieee80211_rts_duration(dev, priv->vif, 201 rts_dur = ieee80211_rts_duration(dev, priv->vif,
205 skb->len, info); 202 skb->len, info);
206 } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { 203 } else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
207 flags |= RTL818X_TX_DESC_FLAG_CTS; 204 flags |= RTL818X_TX_DESC_FLAG_CTS;
208 flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; 205 flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
209 } 206 }
@@ -214,7 +211,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
214 hdr->flags = cpu_to_le32(flags); 211 hdr->flags = cpu_to_le32(flags);
215 hdr->len = 0; 212 hdr->len = 0;
216 hdr->rts_duration = rts_dur; 213 hdr->rts_duration = rts_dur;
217 hdr->retry = cpu_to_le32(info->control.retry_limit << 8); 214 hdr->retry = cpu_to_le32((info->control.rates[0].count - 1) << 8);
218 buf = hdr; 215 buf = hdr;
219 216
220 ep = 2; 217 ep = 2;
@@ -232,7 +229,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
232 memset(hdr, 0, sizeof(*hdr)); 229 memset(hdr, 0, sizeof(*hdr));
233 hdr->flags = cpu_to_le32(flags); 230 hdr->flags = cpu_to_le32(flags);
234 hdr->rts_duration = rts_dur; 231 hdr->rts_duration = rts_dur;
235 hdr->retry = cpu_to_le32(info->control.retry_limit << 8); 232 hdr->retry = cpu_to_le32((info->control.rates[0].count - 1) << 8);
236 hdr->tx_duration = 233 hdr->tx_duration =
237 ieee80211_generic_frame_duration(dev, priv->vif, 234 ieee80211_generic_frame_duration(dev, priv->vif,
238 skb->len, txrate); 235 skb->len, txrate);
@@ -244,22 +241,8 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
244 ep = epmap[skb_get_queue_mapping(skb)]; 241 ep = epmap[skb_get_queue_mapping(skb)];
245 } 242 }
246 243
247 /* FIXME: The sequence that follows is needed for this driver to 244 info->rate_driver_data[0] = dev;
248 * work with mac80211 since "mac80211: fix TX sequence numbers". 245 info->rate_driver_data[1] = urb;
249 * As with the temporary code in rt2x00, changes will be needed
250 * to get proper sequence numbers on beacons. In addition, this
251 * patch places the sequence number in the hardware state, which
252 * limits us to a single virtual state.
253 */
254 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
255 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
256 priv->seqno += 0x10;
257 ieee80211hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
258 ieee80211hdr->seq_ctrl |= cpu_to_le16(priv->seqno);
259 }
260
261 info->driver_data[0] = dev;
262 info->driver_data[1] = urb;
263 246
264 usb_fill_bulk_urb(urb, priv->udev, usb_sndbulkpipe(priv->udev, ep), 247 usb_fill_bulk_urb(urb, priv->udev, usb_sndbulkpipe(priv->udev, ep),
265 buf, skb->len, rtl8187_tx_cb, skb); 248 buf, skb->len, rtl8187_tx_cb, skb);
@@ -687,7 +670,7 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
687 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, 0x0480); 670 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, 0x0480);
688 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0x2488); 671 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0x2488);
689 rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, 0x1FFF); 672 rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, 0x1FFF);
690 msleep(1100); 673 msleep(100);
691 674
692 priv->rf->init(dev); 675 priv->rf->init(dev);
693 676
@@ -876,9 +859,10 @@ static void rtl8187_remove_interface(struct ieee80211_hw *dev,
876 mutex_unlock(&priv->conf_mutex); 859 mutex_unlock(&priv->conf_mutex);
877} 860}
878 861
879static int rtl8187_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) 862static int rtl8187_config(struct ieee80211_hw *dev, u32 changed)
880{ 863{
881 struct rtl8187_priv *priv = dev->priv; 864 struct rtl8187_priv *priv = dev->priv;
865 struct ieee80211_conf *conf = &dev->conf;
882 u32 reg; 866 u32 reg;
883 867
884 mutex_lock(&priv->conf_mutex); 868 mutex_lock(&priv->conf_mutex);
@@ -889,27 +873,10 @@ static int rtl8187_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
889 */ 873 */
890 rtl818x_iowrite32(priv, &priv->map->TX_CONF, 874 rtl818x_iowrite32(priv, &priv->map->TX_CONF,
891 reg | RTL818X_TX_CONF_LOOPBACK_MAC); 875 reg | RTL818X_TX_CONF_LOOPBACK_MAC);
892 msleep(10);
893 priv->rf->set_chan(dev, conf); 876 priv->rf->set_chan(dev, conf);
894 msleep(10); 877 msleep(10);
895 rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg); 878 rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg);
896 879
897 if (!priv->is_rtl8187b) {
898 rtl818x_iowrite8(priv, &priv->map->SIFS, 0x22);
899
900 if (conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) {
901 rtl818x_iowrite8(priv, &priv->map->SLOT, 0x9);
902 rtl818x_iowrite8(priv, &priv->map->DIFS, 0x14);
903 rtl818x_iowrite8(priv, &priv->map->EIFS, 91 - 0x14);
904 rtl818x_iowrite8(priv, &priv->map->CW_VAL, 0x73);
905 } else {
906 rtl818x_iowrite8(priv, &priv->map->SLOT, 0x14);
907 rtl818x_iowrite8(priv, &priv->map->DIFS, 0x24);
908 rtl818x_iowrite8(priv, &priv->map->EIFS, 91 - 0x24);
909 rtl818x_iowrite8(priv, &priv->map->CW_VAL, 0xa5);
910 }
911 }
912
913 rtl818x_iowrite16(priv, &priv->map->ATIM_WND, 2); 880 rtl818x_iowrite16(priv, &priv->map->ATIM_WND, 2);
914 rtl818x_iowrite16(priv, &priv->map->ATIMTR_INTERVAL, 100); 881 rtl818x_iowrite16(priv, &priv->map->ATIMTR_INTERVAL, 100);
915 rtl818x_iowrite16(priv, &priv->map->BEACON_INTERVAL, 100); 882 rtl818x_iowrite16(priv, &priv->map->BEACON_INTERVAL, 100);
@@ -944,6 +911,72 @@ static int rtl8187_config_interface(struct ieee80211_hw *dev,
944 return 0; 911 return 0;
945} 912}
946 913
914static void rtl8187_conf_erp(struct rtl8187_priv *priv, bool use_short_slot,
915 bool use_short_preamble)
916{
917 if (priv->is_rtl8187b) {
918 u8 difs, eifs, slot_time;
919 u16 ack_timeout;
920
921 if (use_short_slot) {
922 slot_time = 0x9;
923 difs = 0x1c;
924 eifs = 0x53;
925 } else {
926 slot_time = 0x14;
927 difs = 0x32;
928 eifs = 0x5b;
929 }
930 rtl818x_iowrite8(priv, &priv->map->SIFS, 0xa);
931 rtl818x_iowrite8(priv, &priv->map->SLOT, slot_time);
932 rtl818x_iowrite8(priv, &priv->map->DIFS, difs);
933
934 /*
935 * BRSR+1 on 8187B is in fact EIFS register
936 * Value in units of 4 us
937 */
938 rtl818x_iowrite8(priv, (u8 *)&priv->map->BRSR + 1, eifs);
939
940 /*
941 * For 8187B, CARRIER_SENSE_COUNTER is in fact ack timeout
942 * register. In units of 4 us like eifs register
943 * ack_timeout = ack duration + plcp + difs + preamble
944 */
945 ack_timeout = 112 + 48 + difs;
946 if (use_short_preamble)
947 ack_timeout += 72;
948 else
949 ack_timeout += 144;
950 rtl818x_iowrite8(priv, &priv->map->CARRIER_SENSE_COUNTER,
951 DIV_ROUND_UP(ack_timeout, 4));
952 } else {
953 rtl818x_iowrite8(priv, &priv->map->SIFS, 0x22);
954 if (use_short_slot) {
955 rtl818x_iowrite8(priv, &priv->map->SLOT, 0x9);
956 rtl818x_iowrite8(priv, &priv->map->DIFS, 0x14);
957 rtl818x_iowrite8(priv, &priv->map->EIFS, 91 - 0x14);
958 rtl818x_iowrite8(priv, &priv->map->CW_VAL, 0x73);
959 } else {
960 rtl818x_iowrite8(priv, &priv->map->SLOT, 0x14);
961 rtl818x_iowrite8(priv, &priv->map->DIFS, 0x24);
962 rtl818x_iowrite8(priv, &priv->map->EIFS, 91 - 0x24);
963 rtl818x_iowrite8(priv, &priv->map->CW_VAL, 0xa5);
964 }
965 }
966}
967
968static void rtl8187_bss_info_changed(struct ieee80211_hw *dev,
969 struct ieee80211_vif *vif,
970 struct ieee80211_bss_conf *info,
971 u32 changed)
972{
973 struct rtl8187_priv *priv = dev->priv;
974
975 if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_ERP_PREAMBLE))
976 rtl8187_conf_erp(priv, info->use_short_slot,
977 info->use_short_preamble);
978}
979
947static void rtl8187_configure_filter(struct ieee80211_hw *dev, 980static void rtl8187_configure_filter(struct ieee80211_hw *dev,
948 unsigned int changed_flags, 981 unsigned int changed_flags,
949 unsigned int *total_flags, 982 unsigned int *total_flags,
@@ -984,6 +1017,7 @@ static const struct ieee80211_ops rtl8187_ops = {
984 .remove_interface = rtl8187_remove_interface, 1017 .remove_interface = rtl8187_remove_interface,
985 .config = rtl8187_config, 1018 .config = rtl8187_config,
986 .config_interface = rtl8187_config_interface, 1019 .config_interface = rtl8187_config_interface,
1020 .bss_info_changed = rtl8187_bss_info_changed,
987 .configure_filter = rtl8187_configure_filter, 1021 .configure_filter = rtl8187_configure_filter,
988}; 1022};
989 1023
@@ -1029,7 +1063,6 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1029 const char *chip_name; 1063 const char *chip_name;
1030 u16 txpwr, reg; 1064 u16 txpwr, reg;
1031 int err, i; 1065 int err, i;
1032 DECLARE_MAC_BUF(mac);
1033 1066
1034 dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops); 1067 dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops);
1035 if (!dev) { 1068 if (!dev) {
@@ -1190,6 +1223,10 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1190 dev->max_signal = 65; 1223 dev->max_signal = 65;
1191 } 1224 }
1192 1225
1226 /*
1227 * XXX: Once this driver supports anything that requires
1228 * beacons it must implement IEEE80211_TX_CTL_ASSIGN_SEQ.
1229 */
1193 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 1230 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
1194 1231
1195 if ((id->driver_info == DEVICE_RTL8187) && priv->is_rtl8187b) 1232 if ((id->driver_info == DEVICE_RTL8187) && priv->is_rtl8187b)
@@ -1212,8 +1249,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1212 } 1249 }
1213 mutex_init(&priv->conf_mutex); 1250 mutex_init(&priv->conf_mutex);
1214 1251
1215 printk(KERN_INFO "%s: hwaddr %s, %s V%d + %s\n", 1252 printk(KERN_INFO "%s: hwaddr %pM, %s V%d + %s\n",
1216 wiphy_name(dev->wiphy), print_mac(mac, dev->wiphy->perm_addr), 1253 wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
1217 chip_name, priv->asic_rev, priv->rf->name); 1254 chip_name, priv->asic_rev, priv->rf->name);
1218 1255
1219 return 0; 1256 return 0;
diff --git a/drivers/net/wireless/rtl8187_rtl8225.c b/drivers/net/wireless/rtl8187_rtl8225.c
index 1bae89903410..69030be62b36 100644
--- a/drivers/net/wireless/rtl8187_rtl8225.c
+++ b/drivers/net/wireless/rtl8187_rtl8225.c
@@ -64,7 +64,6 @@ static void rtl8225_write_bitbang(struct ieee80211_hw *dev, u8 addr, u16 data)
64 64
65 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80 | (1 << 2)); 65 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80 | (1 << 2));
66 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, reg84); 66 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, reg84);
67 msleep(2);
68} 67}
69 68
70static void rtl8225_write_8051(struct ieee80211_hw *dev, u8 addr, __le16 data) 69static void rtl8225_write_8051(struct ieee80211_hw *dev, u8 addr, __le16 data)
@@ -98,7 +97,6 @@ static void rtl8225_write_8051(struct ieee80211_hw *dev, u8 addr, __le16 data)
98 97
99 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80 | (1 << 2)); 98 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80 | (1 << 2));
100 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, reg84); 99 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, reg84);
101 msleep(2);
102} 100}
103 101
104static void rtl8225_write(struct ieee80211_hw *dev, u8 addr, u16 data) 102static void rtl8225_write(struct ieee80211_hw *dev, u8 addr, u16 data)
@@ -333,21 +331,21 @@ static void rtl8225_rf_init(struct ieee80211_hw *dev)
333 struct rtl8187_priv *priv = dev->priv; 331 struct rtl8187_priv *priv = dev->priv;
334 int i; 332 int i;
335 333
336 rtl8225_write(dev, 0x0, 0x067); msleep(1); 334 rtl8225_write(dev, 0x0, 0x067);
337 rtl8225_write(dev, 0x1, 0xFE0); msleep(1); 335 rtl8225_write(dev, 0x1, 0xFE0);
338 rtl8225_write(dev, 0x2, 0x44D); msleep(1); 336 rtl8225_write(dev, 0x2, 0x44D);
339 rtl8225_write(dev, 0x3, 0x441); msleep(1); 337 rtl8225_write(dev, 0x3, 0x441);
340 rtl8225_write(dev, 0x4, 0x486); msleep(1); 338 rtl8225_write(dev, 0x4, 0x486);
341 rtl8225_write(dev, 0x5, 0xBC0); msleep(1); 339 rtl8225_write(dev, 0x5, 0xBC0);
342 rtl8225_write(dev, 0x6, 0xAE6); msleep(1); 340 rtl8225_write(dev, 0x6, 0xAE6);
343 rtl8225_write(dev, 0x7, 0x82A); msleep(1); 341 rtl8225_write(dev, 0x7, 0x82A);
344 rtl8225_write(dev, 0x8, 0x01F); msleep(1); 342 rtl8225_write(dev, 0x8, 0x01F);
345 rtl8225_write(dev, 0x9, 0x334); msleep(1); 343 rtl8225_write(dev, 0x9, 0x334);
346 rtl8225_write(dev, 0xA, 0xFD4); msleep(1); 344 rtl8225_write(dev, 0xA, 0xFD4);
347 rtl8225_write(dev, 0xB, 0x391); msleep(1); 345 rtl8225_write(dev, 0xB, 0x391);
348 rtl8225_write(dev, 0xC, 0x050); msleep(1); 346 rtl8225_write(dev, 0xC, 0x050);
349 rtl8225_write(dev, 0xD, 0x6DB); msleep(1); 347 rtl8225_write(dev, 0xD, 0x6DB);
350 rtl8225_write(dev, 0xE, 0x029); msleep(1); 348 rtl8225_write(dev, 0xE, 0x029);
351 rtl8225_write(dev, 0xF, 0x914); msleep(100); 349 rtl8225_write(dev, 0xF, 0x914); msleep(100);
352 350
353 rtl8225_write(dev, 0x2, 0xC4D); msleep(200); 351 rtl8225_write(dev, 0x2, 0xC4D); msleep(200);
@@ -375,91 +373,89 @@ static void rtl8225_rf_init(struct ieee80211_hw *dev)
375 373
376 for (i = 0; i < ARRAY_SIZE(rtl8225_agc); i++) { 374 for (i = 0; i < ARRAY_SIZE(rtl8225_agc); i++) {
377 rtl8225_write_phy_ofdm(dev, 0xB, rtl8225_agc[i]); 375 rtl8225_write_phy_ofdm(dev, 0xB, rtl8225_agc[i]);
378 msleep(1);
379 rtl8225_write_phy_ofdm(dev, 0xA, 0x80 + i); 376 rtl8225_write_phy_ofdm(dev, 0xA, 0x80 + i);
380 msleep(1);
381 } 377 }
382 378
383 msleep(1); 379 msleep(1);
384 380
385 rtl8225_write_phy_ofdm(dev, 0x00, 0x01); msleep(1); 381 rtl8225_write_phy_ofdm(dev, 0x00, 0x01);
386 rtl8225_write_phy_ofdm(dev, 0x01, 0x02); msleep(1); 382 rtl8225_write_phy_ofdm(dev, 0x01, 0x02);
387 rtl8225_write_phy_ofdm(dev, 0x02, 0x42); msleep(1); 383 rtl8225_write_phy_ofdm(dev, 0x02, 0x42);
388 rtl8225_write_phy_ofdm(dev, 0x03, 0x00); msleep(1); 384 rtl8225_write_phy_ofdm(dev, 0x03, 0x00);
389 rtl8225_write_phy_ofdm(dev, 0x04, 0x00); msleep(1); 385 rtl8225_write_phy_ofdm(dev, 0x04, 0x00);
390 rtl8225_write_phy_ofdm(dev, 0x05, 0x00); msleep(1); 386 rtl8225_write_phy_ofdm(dev, 0x05, 0x00);
391 rtl8225_write_phy_ofdm(dev, 0x06, 0x40); msleep(1); 387 rtl8225_write_phy_ofdm(dev, 0x06, 0x40);
392 rtl8225_write_phy_ofdm(dev, 0x07, 0x00); msleep(1); 388 rtl8225_write_phy_ofdm(dev, 0x07, 0x00);
393 rtl8225_write_phy_ofdm(dev, 0x08, 0x40); msleep(1); 389 rtl8225_write_phy_ofdm(dev, 0x08, 0x40);
394 rtl8225_write_phy_ofdm(dev, 0x09, 0xfe); msleep(1); 390 rtl8225_write_phy_ofdm(dev, 0x09, 0xfe);
395 rtl8225_write_phy_ofdm(dev, 0x0a, 0x09); msleep(1); 391 rtl8225_write_phy_ofdm(dev, 0x0a, 0x09);
396 rtl8225_write_phy_ofdm(dev, 0x0b, 0x80); msleep(1); 392 rtl8225_write_phy_ofdm(dev, 0x0b, 0x80);
397 rtl8225_write_phy_ofdm(dev, 0x0c, 0x01); msleep(1); 393 rtl8225_write_phy_ofdm(dev, 0x0c, 0x01);
398 rtl8225_write_phy_ofdm(dev, 0x0e, 0xd3); msleep(1); 394 rtl8225_write_phy_ofdm(dev, 0x0e, 0xd3);
399 rtl8225_write_phy_ofdm(dev, 0x0f, 0x38); msleep(1); 395 rtl8225_write_phy_ofdm(dev, 0x0f, 0x38);
400 rtl8225_write_phy_ofdm(dev, 0x10, 0x84); msleep(1); 396 rtl8225_write_phy_ofdm(dev, 0x10, 0x84);
401 rtl8225_write_phy_ofdm(dev, 0x11, 0x06); msleep(1); 397 rtl8225_write_phy_ofdm(dev, 0x11, 0x06);
402 rtl8225_write_phy_ofdm(dev, 0x12, 0x20); msleep(1); 398 rtl8225_write_phy_ofdm(dev, 0x12, 0x20);
403 rtl8225_write_phy_ofdm(dev, 0x13, 0x20); msleep(1); 399 rtl8225_write_phy_ofdm(dev, 0x13, 0x20);
404 rtl8225_write_phy_ofdm(dev, 0x14, 0x00); msleep(1); 400 rtl8225_write_phy_ofdm(dev, 0x14, 0x00);
405 rtl8225_write_phy_ofdm(dev, 0x15, 0x40); msleep(1); 401 rtl8225_write_phy_ofdm(dev, 0x15, 0x40);
406 rtl8225_write_phy_ofdm(dev, 0x16, 0x00); msleep(1); 402 rtl8225_write_phy_ofdm(dev, 0x16, 0x00);
407 rtl8225_write_phy_ofdm(dev, 0x17, 0x40); msleep(1); 403 rtl8225_write_phy_ofdm(dev, 0x17, 0x40);
408 rtl8225_write_phy_ofdm(dev, 0x18, 0xef); msleep(1); 404 rtl8225_write_phy_ofdm(dev, 0x18, 0xef);
409 rtl8225_write_phy_ofdm(dev, 0x19, 0x19); msleep(1); 405 rtl8225_write_phy_ofdm(dev, 0x19, 0x19);
410 rtl8225_write_phy_ofdm(dev, 0x1a, 0x20); msleep(1); 406 rtl8225_write_phy_ofdm(dev, 0x1a, 0x20);
411 rtl8225_write_phy_ofdm(dev, 0x1b, 0x76); msleep(1); 407 rtl8225_write_phy_ofdm(dev, 0x1b, 0x76);
412 rtl8225_write_phy_ofdm(dev, 0x1c, 0x04); msleep(1); 408 rtl8225_write_phy_ofdm(dev, 0x1c, 0x04);
413 rtl8225_write_phy_ofdm(dev, 0x1e, 0x95); msleep(1); 409 rtl8225_write_phy_ofdm(dev, 0x1e, 0x95);
414 rtl8225_write_phy_ofdm(dev, 0x1f, 0x75); msleep(1); 410 rtl8225_write_phy_ofdm(dev, 0x1f, 0x75);
415 rtl8225_write_phy_ofdm(dev, 0x20, 0x1f); msleep(1); 411 rtl8225_write_phy_ofdm(dev, 0x20, 0x1f);
416 rtl8225_write_phy_ofdm(dev, 0x21, 0x27); msleep(1); 412 rtl8225_write_phy_ofdm(dev, 0x21, 0x27);
417 rtl8225_write_phy_ofdm(dev, 0x22, 0x16); msleep(1); 413 rtl8225_write_phy_ofdm(dev, 0x22, 0x16);
418 rtl8225_write_phy_ofdm(dev, 0x24, 0x46); msleep(1); 414 rtl8225_write_phy_ofdm(dev, 0x24, 0x46);
419 rtl8225_write_phy_ofdm(dev, 0x25, 0x20); msleep(1); 415 rtl8225_write_phy_ofdm(dev, 0x25, 0x20);
420 rtl8225_write_phy_ofdm(dev, 0x26, 0x90); msleep(1); 416 rtl8225_write_phy_ofdm(dev, 0x26, 0x90);
421 rtl8225_write_phy_ofdm(dev, 0x27, 0x88); msleep(1); 417 rtl8225_write_phy_ofdm(dev, 0x27, 0x88);
422 418
423 rtl8225_write_phy_ofdm(dev, 0x0d, rtl8225_gain[2 * 4]); 419 rtl8225_write_phy_ofdm(dev, 0x0d, rtl8225_gain[2 * 4]);
424 rtl8225_write_phy_ofdm(dev, 0x1b, rtl8225_gain[2 * 4 + 2]); 420 rtl8225_write_phy_ofdm(dev, 0x1b, rtl8225_gain[2 * 4 + 2]);
425 rtl8225_write_phy_ofdm(dev, 0x1d, rtl8225_gain[2 * 4 + 3]); 421 rtl8225_write_phy_ofdm(dev, 0x1d, rtl8225_gain[2 * 4 + 3]);
426 rtl8225_write_phy_ofdm(dev, 0x23, rtl8225_gain[2 * 4 + 1]); 422 rtl8225_write_phy_ofdm(dev, 0x23, rtl8225_gain[2 * 4 + 1]);
427 423
428 rtl8225_write_phy_cck(dev, 0x00, 0x98); msleep(1); 424 rtl8225_write_phy_cck(dev, 0x00, 0x98);
429 rtl8225_write_phy_cck(dev, 0x03, 0x20); msleep(1); 425 rtl8225_write_phy_cck(dev, 0x03, 0x20);
430 rtl8225_write_phy_cck(dev, 0x04, 0x7e); msleep(1); 426 rtl8225_write_phy_cck(dev, 0x04, 0x7e);
431 rtl8225_write_phy_cck(dev, 0x05, 0x12); msleep(1); 427 rtl8225_write_phy_cck(dev, 0x05, 0x12);
432 rtl8225_write_phy_cck(dev, 0x06, 0xfc); msleep(1); 428 rtl8225_write_phy_cck(dev, 0x06, 0xfc);
433 rtl8225_write_phy_cck(dev, 0x07, 0x78); msleep(1); 429 rtl8225_write_phy_cck(dev, 0x07, 0x78);
434 rtl8225_write_phy_cck(dev, 0x08, 0x2e); msleep(1); 430 rtl8225_write_phy_cck(dev, 0x08, 0x2e);
435 rtl8225_write_phy_cck(dev, 0x10, 0x9b); msleep(1); 431 rtl8225_write_phy_cck(dev, 0x10, 0x9b);
436 rtl8225_write_phy_cck(dev, 0x11, 0x88); msleep(1); 432 rtl8225_write_phy_cck(dev, 0x11, 0x88);
437 rtl8225_write_phy_cck(dev, 0x12, 0x47); msleep(1); 433 rtl8225_write_phy_cck(dev, 0x12, 0x47);
438 rtl8225_write_phy_cck(dev, 0x13, 0xd0); 434 rtl8225_write_phy_cck(dev, 0x13, 0xd0);
439 rtl8225_write_phy_cck(dev, 0x19, 0x00); 435 rtl8225_write_phy_cck(dev, 0x19, 0x00);
440 rtl8225_write_phy_cck(dev, 0x1a, 0xa0); 436 rtl8225_write_phy_cck(dev, 0x1a, 0xa0);
441 rtl8225_write_phy_cck(dev, 0x1b, 0x08); 437 rtl8225_write_phy_cck(dev, 0x1b, 0x08);
442 rtl8225_write_phy_cck(dev, 0x40, 0x86); 438 rtl8225_write_phy_cck(dev, 0x40, 0x86);
443 rtl8225_write_phy_cck(dev, 0x41, 0x8d); msleep(1); 439 rtl8225_write_phy_cck(dev, 0x41, 0x8d);
444 rtl8225_write_phy_cck(dev, 0x42, 0x15); msleep(1); 440 rtl8225_write_phy_cck(dev, 0x42, 0x15);
445 rtl8225_write_phy_cck(dev, 0x43, 0x18); msleep(1); 441 rtl8225_write_phy_cck(dev, 0x43, 0x18);
446 rtl8225_write_phy_cck(dev, 0x44, 0x1f); msleep(1); 442 rtl8225_write_phy_cck(dev, 0x44, 0x1f);
447 rtl8225_write_phy_cck(dev, 0x45, 0x1e); msleep(1); 443 rtl8225_write_phy_cck(dev, 0x45, 0x1e);
448 rtl8225_write_phy_cck(dev, 0x46, 0x1a); msleep(1); 444 rtl8225_write_phy_cck(dev, 0x46, 0x1a);
449 rtl8225_write_phy_cck(dev, 0x47, 0x15); msleep(1); 445 rtl8225_write_phy_cck(dev, 0x47, 0x15);
450 rtl8225_write_phy_cck(dev, 0x48, 0x10); msleep(1); 446 rtl8225_write_phy_cck(dev, 0x48, 0x10);
451 rtl8225_write_phy_cck(dev, 0x49, 0x0a); msleep(1); 447 rtl8225_write_phy_cck(dev, 0x49, 0x0a);
452 rtl8225_write_phy_cck(dev, 0x4a, 0x05); msleep(1); 448 rtl8225_write_phy_cck(dev, 0x4a, 0x05);
453 rtl8225_write_phy_cck(dev, 0x4b, 0x02); msleep(1); 449 rtl8225_write_phy_cck(dev, 0x4b, 0x02);
454 rtl8225_write_phy_cck(dev, 0x4c, 0x05); msleep(1); 450 rtl8225_write_phy_cck(dev, 0x4c, 0x05);
455 451
456 rtl818x_iowrite8(priv, &priv->map->TESTR, 0x0D); 452 rtl818x_iowrite8(priv, &priv->map->TESTR, 0x0D);
457 453
458 rtl8225_rf_set_tx_power(dev, 1); 454 rtl8225_rf_set_tx_power(dev, 1);
459 455
460 /* RX antenna default to A */ 456 /* RX antenna default to A */
461 rtl8225_write_phy_cck(dev, 0x10, 0x9b); msleep(1); /* B: 0xDB */ 457 rtl8225_write_phy_cck(dev, 0x10, 0x9b); /* B: 0xDB */
462 rtl8225_write_phy_ofdm(dev, 0x26, 0x90); msleep(1); /* B: 0x10 */ 458 rtl8225_write_phy_ofdm(dev, 0x26, 0x90); /* B: 0x10 */
463 459
464 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); /* B: 0x00 */ 460 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); /* B: 0x00 */
465 msleep(1); 461 msleep(1);
@@ -629,7 +625,7 @@ static void rtl8225z2_b_rf_set_tx_power(struct ieee80211_hw *dev, int channel)
629 rtl8225_write_phy_cck(dev, 0x44 + i, *tmp++); 625 rtl8225_write_phy_cck(dev, 0x44 + i, *tmp++);
630 626
631 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_CCK, 627 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_CCK,
632 rtl8225z2_tx_gain_cck_ofdm[cck_power]); 628 rtl8225z2_tx_gain_cck_ofdm[cck_power] << 1);
633 msleep(1); 629 msleep(1);
634 630
635 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_OFDM, 631 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_OFDM,
@@ -687,22 +683,23 @@ static void rtl8225z2_rf_init(struct ieee80211_hw *dev)
687 struct rtl8187_priv *priv = dev->priv; 683 struct rtl8187_priv *priv = dev->priv;
688 int i; 684 int i;
689 685
690 rtl8225_write(dev, 0x0, 0x2BF); msleep(1); 686 rtl8225_write(dev, 0x0, 0x2BF);
691 rtl8225_write(dev, 0x1, 0xEE0); msleep(1); 687 rtl8225_write(dev, 0x1, 0xEE0);
692 rtl8225_write(dev, 0x2, 0x44D); msleep(1); 688 rtl8225_write(dev, 0x2, 0x44D);
693 rtl8225_write(dev, 0x3, 0x441); msleep(1); 689 rtl8225_write(dev, 0x3, 0x441);
694 rtl8225_write(dev, 0x4, 0x8C3); msleep(1); 690 rtl8225_write(dev, 0x4, 0x8C3);
695 rtl8225_write(dev, 0x5, 0xC72); msleep(1); 691 rtl8225_write(dev, 0x5, 0xC72);
696 rtl8225_write(dev, 0x6, 0x0E6); msleep(1); 692 rtl8225_write(dev, 0x6, 0x0E6);
697 rtl8225_write(dev, 0x7, 0x82A); msleep(1); 693 rtl8225_write(dev, 0x7, 0x82A);
698 rtl8225_write(dev, 0x8, 0x03F); msleep(1); 694 rtl8225_write(dev, 0x8, 0x03F);
699 rtl8225_write(dev, 0x9, 0x335); msleep(1); 695 rtl8225_write(dev, 0x9, 0x335);
700 rtl8225_write(dev, 0xa, 0x9D4); msleep(1); 696 rtl8225_write(dev, 0xa, 0x9D4);
701 rtl8225_write(dev, 0xb, 0x7BB); msleep(1); 697 rtl8225_write(dev, 0xb, 0x7BB);
702 rtl8225_write(dev, 0xc, 0x850); msleep(1); 698 rtl8225_write(dev, 0xc, 0x850);
703 rtl8225_write(dev, 0xd, 0xCDF); msleep(1); 699 rtl8225_write(dev, 0xd, 0xCDF);
704 rtl8225_write(dev, 0xe, 0x02B); msleep(1); 700 rtl8225_write(dev, 0xe, 0x02B);
705 rtl8225_write(dev, 0xf, 0x114); msleep(100); 701 rtl8225_write(dev, 0xf, 0x114);
702 msleep(100);
706 703
707 rtl8225_write(dev, 0x0, 0x1B7); 704 rtl8225_write(dev, 0x0, 0x1B7);
708 705
@@ -736,94 +733,92 @@ static void rtl8225z2_rf_init(struct ieee80211_hw *dev)
736 733
737 for (i = 0; i < ARRAY_SIZE(rtl8225_agc); i++) { 734 for (i = 0; i < ARRAY_SIZE(rtl8225_agc); i++) {
738 rtl8225_write_phy_ofdm(dev, 0xB, rtl8225_agc[i]); 735 rtl8225_write_phy_ofdm(dev, 0xB, rtl8225_agc[i]);
739 msleep(1);
740 rtl8225_write_phy_ofdm(dev, 0xA, 0x80 + i); 736 rtl8225_write_phy_ofdm(dev, 0xA, 0x80 + i);
741 msleep(1);
742 } 737 }
743 738
744 msleep(1); 739 msleep(1);
745 740
746 rtl8225_write_phy_ofdm(dev, 0x00, 0x01); msleep(1); 741 rtl8225_write_phy_ofdm(dev, 0x00, 0x01);
747 rtl8225_write_phy_ofdm(dev, 0x01, 0x02); msleep(1); 742 rtl8225_write_phy_ofdm(dev, 0x01, 0x02);
748 rtl8225_write_phy_ofdm(dev, 0x02, 0x42); msleep(1); 743 rtl8225_write_phy_ofdm(dev, 0x02, 0x42);
749 rtl8225_write_phy_ofdm(dev, 0x03, 0x00); msleep(1); 744 rtl8225_write_phy_ofdm(dev, 0x03, 0x00);
750 rtl8225_write_phy_ofdm(dev, 0x04, 0x00); msleep(1); 745 rtl8225_write_phy_ofdm(dev, 0x04, 0x00);
751 rtl8225_write_phy_ofdm(dev, 0x05, 0x00); msleep(1); 746 rtl8225_write_phy_ofdm(dev, 0x05, 0x00);
752 rtl8225_write_phy_ofdm(dev, 0x06, 0x40); msleep(1); 747 rtl8225_write_phy_ofdm(dev, 0x06, 0x40);
753 rtl8225_write_phy_ofdm(dev, 0x07, 0x00); msleep(1); 748 rtl8225_write_phy_ofdm(dev, 0x07, 0x00);
754 rtl8225_write_phy_ofdm(dev, 0x08, 0x40); msleep(1); 749 rtl8225_write_phy_ofdm(dev, 0x08, 0x40);
755 rtl8225_write_phy_ofdm(dev, 0x09, 0xfe); msleep(1); 750 rtl8225_write_phy_ofdm(dev, 0x09, 0xfe);
756 rtl8225_write_phy_ofdm(dev, 0x0a, 0x08); msleep(1); 751 rtl8225_write_phy_ofdm(dev, 0x0a, 0x08);
757 rtl8225_write_phy_ofdm(dev, 0x0b, 0x80); msleep(1); 752 rtl8225_write_phy_ofdm(dev, 0x0b, 0x80);
758 rtl8225_write_phy_ofdm(dev, 0x0c, 0x01); msleep(1); 753 rtl8225_write_phy_ofdm(dev, 0x0c, 0x01);
759 rtl8225_write_phy_ofdm(dev, 0x0d, 0x43); 754 rtl8225_write_phy_ofdm(dev, 0x0d, 0x43);
760 rtl8225_write_phy_ofdm(dev, 0x0e, 0xd3); msleep(1); 755 rtl8225_write_phy_ofdm(dev, 0x0e, 0xd3);
761 rtl8225_write_phy_ofdm(dev, 0x0f, 0x38); msleep(1); 756 rtl8225_write_phy_ofdm(dev, 0x0f, 0x38);
762 rtl8225_write_phy_ofdm(dev, 0x10, 0x84); msleep(1); 757 rtl8225_write_phy_ofdm(dev, 0x10, 0x84);
763 rtl8225_write_phy_ofdm(dev, 0x11, 0x07); msleep(1); 758 rtl8225_write_phy_ofdm(dev, 0x11, 0x07);
764 rtl8225_write_phy_ofdm(dev, 0x12, 0x20); msleep(1); 759 rtl8225_write_phy_ofdm(dev, 0x12, 0x20);
765 rtl8225_write_phy_ofdm(dev, 0x13, 0x20); msleep(1); 760 rtl8225_write_phy_ofdm(dev, 0x13, 0x20);
766 rtl8225_write_phy_ofdm(dev, 0x14, 0x00); msleep(1); 761 rtl8225_write_phy_ofdm(dev, 0x14, 0x00);
767 rtl8225_write_phy_ofdm(dev, 0x15, 0x40); msleep(1); 762 rtl8225_write_phy_ofdm(dev, 0x15, 0x40);
768 rtl8225_write_phy_ofdm(dev, 0x16, 0x00); msleep(1); 763 rtl8225_write_phy_ofdm(dev, 0x16, 0x00);
769 rtl8225_write_phy_ofdm(dev, 0x17, 0x40); msleep(1); 764 rtl8225_write_phy_ofdm(dev, 0x17, 0x40);
770 rtl8225_write_phy_ofdm(dev, 0x18, 0xef); msleep(1); 765 rtl8225_write_phy_ofdm(dev, 0x18, 0xef);
771 rtl8225_write_phy_ofdm(dev, 0x19, 0x19); msleep(1); 766 rtl8225_write_phy_ofdm(dev, 0x19, 0x19);
772 rtl8225_write_phy_ofdm(dev, 0x1a, 0x20); msleep(1); 767 rtl8225_write_phy_ofdm(dev, 0x1a, 0x20);
773 rtl8225_write_phy_ofdm(dev, 0x1b, 0x15); msleep(1); 768 rtl8225_write_phy_ofdm(dev, 0x1b, 0x15);
774 rtl8225_write_phy_ofdm(dev, 0x1c, 0x04); msleep(1); 769 rtl8225_write_phy_ofdm(dev, 0x1c, 0x04);
775 rtl8225_write_phy_ofdm(dev, 0x1d, 0xc5); msleep(1); 770 rtl8225_write_phy_ofdm(dev, 0x1d, 0xc5);
776 rtl8225_write_phy_ofdm(dev, 0x1e, 0x95); msleep(1); 771 rtl8225_write_phy_ofdm(dev, 0x1e, 0x95);
777 rtl8225_write_phy_ofdm(dev, 0x1f, 0x75); msleep(1); 772 rtl8225_write_phy_ofdm(dev, 0x1f, 0x75);
778 rtl8225_write_phy_ofdm(dev, 0x20, 0x1f); msleep(1); 773 rtl8225_write_phy_ofdm(dev, 0x20, 0x1f);
779 rtl8225_write_phy_ofdm(dev, 0x21, 0x17); msleep(1); 774 rtl8225_write_phy_ofdm(dev, 0x21, 0x17);
780 rtl8225_write_phy_ofdm(dev, 0x22, 0x16); msleep(1); 775 rtl8225_write_phy_ofdm(dev, 0x22, 0x16);
781 rtl8225_write_phy_ofdm(dev, 0x23, 0x80); msleep(1); //FIXME: not needed? 776 rtl8225_write_phy_ofdm(dev, 0x23, 0x80);
782 rtl8225_write_phy_ofdm(dev, 0x24, 0x46); msleep(1); 777 rtl8225_write_phy_ofdm(dev, 0x24, 0x46);
783 rtl8225_write_phy_ofdm(dev, 0x25, 0x00); msleep(1); 778 rtl8225_write_phy_ofdm(dev, 0x25, 0x00);
784 rtl8225_write_phy_ofdm(dev, 0x26, 0x90); msleep(1); 779 rtl8225_write_phy_ofdm(dev, 0x26, 0x90);
785 rtl8225_write_phy_ofdm(dev, 0x27, 0x88); msleep(1); 780 rtl8225_write_phy_ofdm(dev, 0x27, 0x88);
786 781
787 rtl8225_write_phy_ofdm(dev, 0x0b, rtl8225z2_gain_bg[4 * 3]); 782 rtl8225_write_phy_ofdm(dev, 0x0b, rtl8225z2_gain_bg[4 * 3]);
788 rtl8225_write_phy_ofdm(dev, 0x1b, rtl8225z2_gain_bg[4 * 3 + 1]); 783 rtl8225_write_phy_ofdm(dev, 0x1b, rtl8225z2_gain_bg[4 * 3 + 1]);
789 rtl8225_write_phy_ofdm(dev, 0x1d, rtl8225z2_gain_bg[4 * 3 + 2]); 784 rtl8225_write_phy_ofdm(dev, 0x1d, rtl8225z2_gain_bg[4 * 3 + 2]);
790 rtl8225_write_phy_ofdm(dev, 0x21, 0x37); 785 rtl8225_write_phy_ofdm(dev, 0x21, 0x37);
791 786
792 rtl8225_write_phy_cck(dev, 0x00, 0x98); msleep(1); 787 rtl8225_write_phy_cck(dev, 0x00, 0x98);
793 rtl8225_write_phy_cck(dev, 0x03, 0x20); msleep(1); 788 rtl8225_write_phy_cck(dev, 0x03, 0x20);
794 rtl8225_write_phy_cck(dev, 0x04, 0x7e); msleep(1); 789 rtl8225_write_phy_cck(dev, 0x04, 0x7e);
795 rtl8225_write_phy_cck(dev, 0x05, 0x12); msleep(1); 790 rtl8225_write_phy_cck(dev, 0x05, 0x12);
796 rtl8225_write_phy_cck(dev, 0x06, 0xfc); msleep(1); 791 rtl8225_write_phy_cck(dev, 0x06, 0xfc);
797 rtl8225_write_phy_cck(dev, 0x07, 0x78); msleep(1); 792 rtl8225_write_phy_cck(dev, 0x07, 0x78);
798 rtl8225_write_phy_cck(dev, 0x08, 0x2e); msleep(1); 793 rtl8225_write_phy_cck(dev, 0x08, 0x2e);
799 rtl8225_write_phy_cck(dev, 0x10, 0x9b); msleep(1); 794 rtl8225_write_phy_cck(dev, 0x10, 0x9b);
800 rtl8225_write_phy_cck(dev, 0x11, 0x88); msleep(1); 795 rtl8225_write_phy_cck(dev, 0x11, 0x88);
801 rtl8225_write_phy_cck(dev, 0x12, 0x47); msleep(1); 796 rtl8225_write_phy_cck(dev, 0x12, 0x47);
802 rtl8225_write_phy_cck(dev, 0x13, 0xd0); 797 rtl8225_write_phy_cck(dev, 0x13, 0xd0);
803 rtl8225_write_phy_cck(dev, 0x19, 0x00); 798 rtl8225_write_phy_cck(dev, 0x19, 0x00);
804 rtl8225_write_phy_cck(dev, 0x1a, 0xa0); 799 rtl8225_write_phy_cck(dev, 0x1a, 0xa0);
805 rtl8225_write_phy_cck(dev, 0x1b, 0x08); 800 rtl8225_write_phy_cck(dev, 0x1b, 0x08);
806 rtl8225_write_phy_cck(dev, 0x40, 0x86); 801 rtl8225_write_phy_cck(dev, 0x40, 0x86);
807 rtl8225_write_phy_cck(dev, 0x41, 0x8d); msleep(1); 802 rtl8225_write_phy_cck(dev, 0x41, 0x8d);
808 rtl8225_write_phy_cck(dev, 0x42, 0x15); msleep(1); 803 rtl8225_write_phy_cck(dev, 0x42, 0x15);
809 rtl8225_write_phy_cck(dev, 0x43, 0x18); msleep(1); 804 rtl8225_write_phy_cck(dev, 0x43, 0x18);
810 rtl8225_write_phy_cck(dev, 0x44, 0x36); msleep(1); 805 rtl8225_write_phy_cck(dev, 0x44, 0x36);
811 rtl8225_write_phy_cck(dev, 0x45, 0x35); msleep(1); 806 rtl8225_write_phy_cck(dev, 0x45, 0x35);
812 rtl8225_write_phy_cck(dev, 0x46, 0x2e); msleep(1); 807 rtl8225_write_phy_cck(dev, 0x46, 0x2e);
813 rtl8225_write_phy_cck(dev, 0x47, 0x25); msleep(1); 808 rtl8225_write_phy_cck(dev, 0x47, 0x25);
814 rtl8225_write_phy_cck(dev, 0x48, 0x1c); msleep(1); 809 rtl8225_write_phy_cck(dev, 0x48, 0x1c);
815 rtl8225_write_phy_cck(dev, 0x49, 0x12); msleep(1); 810 rtl8225_write_phy_cck(dev, 0x49, 0x12);
816 rtl8225_write_phy_cck(dev, 0x4a, 0x09); msleep(1); 811 rtl8225_write_phy_cck(dev, 0x4a, 0x09);
817 rtl8225_write_phy_cck(dev, 0x4b, 0x04); msleep(1); 812 rtl8225_write_phy_cck(dev, 0x4b, 0x04);
818 rtl8225_write_phy_cck(dev, 0x4c, 0x05); msleep(1); 813 rtl8225_write_phy_cck(dev, 0x4c, 0x05);
819 814
820 rtl818x_iowrite8(priv, (u8 *)0xFF5B, 0x0D); msleep(1); 815 rtl818x_iowrite8(priv, (u8 *)0xFF5B, 0x0D); msleep(1);
821 816
822 rtl8225z2_rf_set_tx_power(dev, 1); 817 rtl8225z2_rf_set_tx_power(dev, 1);
823 818
824 /* RX antenna default to A */ 819 /* RX antenna default to A */
825 rtl8225_write_phy_cck(dev, 0x10, 0x9b); msleep(1); /* B: 0xDB */ 820 rtl8225_write_phy_cck(dev, 0x10, 0x9b); /* B: 0xDB */
826 rtl8225_write_phy_ofdm(dev, 0x26, 0x90); msleep(1); /* B: 0x10 */ 821 rtl8225_write_phy_ofdm(dev, 0x26, 0x90); /* B: 0x10 */
827 822
828 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); /* B: 0x00 */ 823 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); /* B: 0x00 */
829 msleep(1); 824 msleep(1);
@@ -835,40 +830,38 @@ static void rtl8225z2_b_rf_init(struct ieee80211_hw *dev)
835 struct rtl8187_priv *priv = dev->priv; 830 struct rtl8187_priv *priv = dev->priv;
836 int i; 831 int i;
837 832
838 rtl8225_write(dev, 0x0, 0x0B7); msleep(1); 833 rtl8225_write(dev, 0x0, 0x0B7);
839 rtl8225_write(dev, 0x1, 0xEE0); msleep(1); 834 rtl8225_write(dev, 0x1, 0xEE0);
840 rtl8225_write(dev, 0x2, 0x44D); msleep(1); 835 rtl8225_write(dev, 0x2, 0x44D);
841 rtl8225_write(dev, 0x3, 0x441); msleep(1); 836 rtl8225_write(dev, 0x3, 0x441);
842 rtl8225_write(dev, 0x4, 0x8C3); msleep(1); 837 rtl8225_write(dev, 0x4, 0x8C3);
843 rtl8225_write(dev, 0x5, 0xC72); msleep(1); 838 rtl8225_write(dev, 0x5, 0xC72);
844 rtl8225_write(dev, 0x6, 0x0E6); msleep(1); 839 rtl8225_write(dev, 0x6, 0x0E6);
845 rtl8225_write(dev, 0x7, 0x82A); msleep(1); 840 rtl8225_write(dev, 0x7, 0x82A);
846 rtl8225_write(dev, 0x8, 0x03F); msleep(1); 841 rtl8225_write(dev, 0x8, 0x03F);
847 rtl8225_write(dev, 0x9, 0x335); msleep(1); 842 rtl8225_write(dev, 0x9, 0x335);
848 rtl8225_write(dev, 0xa, 0x9D4); msleep(1); 843 rtl8225_write(dev, 0xa, 0x9D4);
849 rtl8225_write(dev, 0xb, 0x7BB); msleep(1); 844 rtl8225_write(dev, 0xb, 0x7BB);
850 rtl8225_write(dev, 0xc, 0x850); msleep(1); 845 rtl8225_write(dev, 0xc, 0x850);
851 rtl8225_write(dev, 0xd, 0xCDF); msleep(1); 846 rtl8225_write(dev, 0xd, 0xCDF);
852 rtl8225_write(dev, 0xe, 0x02B); msleep(1); 847 rtl8225_write(dev, 0xe, 0x02B);
853 rtl8225_write(dev, 0xf, 0x114); msleep(1); 848 rtl8225_write(dev, 0xf, 0x114);
854 849
855 rtl8225_write(dev, 0x0, 0x1B7); msleep(1); 850 rtl8225_write(dev, 0x0, 0x1B7);
856 851
857 for (i = 0; i < ARRAY_SIZE(rtl8225z2_rxgain); i++) { 852 for (i = 0; i < ARRAY_SIZE(rtl8225z2_rxgain); i++) {
858 rtl8225_write(dev, 0x1, i + 1); msleep(1); 853 rtl8225_write(dev, 0x1, i + 1);
859 rtl8225_write(dev, 0x2, rtl8225z2_rxgain[i]); msleep(1); 854 rtl8225_write(dev, 0x2, rtl8225z2_rxgain[i]);
860 } 855 }
861 856
862 rtl8225_write(dev, 0x3, 0x080); msleep(1); 857 rtl8225_write(dev, 0x3, 0x080);
863 rtl8225_write(dev, 0x5, 0x004); msleep(1); 858 rtl8225_write(dev, 0x5, 0x004);
864 rtl8225_write(dev, 0x0, 0x0B7); msleep(1); 859 rtl8225_write(dev, 0x0, 0x0B7);
865 msleep(3000);
866 860
867 rtl8225_write(dev, 0x2, 0xC4D); msleep(1); 861 rtl8225_write(dev, 0x2, 0xC4D);
868 msleep(2000);
869 862
870 rtl8225_write(dev, 0x2, 0x44D); msleep(1); 863 rtl8225_write(dev, 0x2, 0x44D);
871 rtl8225_write(dev, 0x0, 0x2BF); msleep(1); 864 rtl8225_write(dev, 0x0, 0x2BF);
872 865
873 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_CCK, 0x03); 866 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_CCK, 0x03);
874 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_OFDM, 0x07); 867 rtl818x_iowrite8(priv, &priv->map->TX_GAIN_OFDM, 0x07);
@@ -885,24 +878,16 @@ static void rtl8225z2_b_rf_init(struct ieee80211_hw *dev)
885 for (i = 0; i < ARRAY_SIZE(rtl8225z2_ofdm); i++) 878 for (i = 0; i < ARRAY_SIZE(rtl8225z2_ofdm); i++)
886 rtl8225_write_phy_ofdm(dev, i, rtl8225z2_ofdm[i]); 879 rtl8225_write_phy_ofdm(dev, i, rtl8225z2_ofdm[i]);
887 880
888 rtl818x_iowrite8(priv, &priv->map->SIFS, 0x22);
889 rtl818x_iowrite8(priv, &priv->map->SLOT, 9);
890 rtl818x_iowrite8(priv, (u8 *)0xFFF0, 28);
891 rtl818x_iowrite8(priv, (u8 *)0xFFF4, 28);
892 rtl818x_iowrite8(priv, (u8 *)0xFFF8, 28);
893 rtl818x_iowrite8(priv, (u8 *)0xFFFC, 28);
894 rtl818x_iowrite8(priv, (u8 *)0xFF2D, 0x5B);
895 rtl818x_iowrite8(priv, (u8 *)0xFF79, 0x5B);
896 rtl818x_iowrite32(priv, (__le32 *)0xFFF0, (7 << 12) | (3 << 8) | 28); 881 rtl818x_iowrite32(priv, (__le32 *)0xFFF0, (7 << 12) | (3 << 8) | 28);
897 rtl818x_iowrite32(priv, (__le32 *)0xFFF4, (7 << 12) | (3 << 8) | 28); 882 rtl818x_iowrite32(priv, (__le32 *)0xFFF4, (7 << 12) | (3 << 8) | 28);
898 rtl818x_iowrite32(priv, (__le32 *)0xFFF8, (7 << 12) | (3 << 8) | 28); 883 rtl818x_iowrite32(priv, (__le32 *)0xFFF8, (7 << 12) | (3 << 8) | 28);
899 rtl818x_iowrite32(priv, (__le32 *)0xFFFC, (7 << 12) | (3 << 8) | 28); 884 rtl818x_iowrite32(priv, (__le32 *)0xFFFC, (7 << 12) | (3 << 8) | 28);
900 rtl818x_iowrite8(priv, &priv->map->ACM_CONTROL, 0); 885 rtl818x_iowrite8(priv, &priv->map->ACM_CONTROL, 0);
901 886
902 rtl8225_write_phy_ofdm(dev, 0x97, 0x46); msleep(1); 887 rtl8225_write_phy_ofdm(dev, 0x97, 0x46);
903 rtl8225_write_phy_ofdm(dev, 0xa4, 0xb6); msleep(1); 888 rtl8225_write_phy_ofdm(dev, 0xa4, 0xb6);
904 rtl8225_write_phy_ofdm(dev, 0x85, 0xfc); msleep(1); 889 rtl8225_write_phy_ofdm(dev, 0x85, 0xfc);
905 rtl8225_write_phy_cck(dev, 0xc1, 0x88); msleep(1); 890 rtl8225_write_phy_cck(dev, 0xc1, 0x88);
906} 891}
907 892
908static void rtl8225_rf_stop(struct ieee80211_hw *dev) 893static void rtl8225_rf_stop(struct ieee80211_hw *dev)
@@ -910,7 +895,7 @@ static void rtl8225_rf_stop(struct ieee80211_hw *dev)
910 u8 reg; 895 u8 reg;
911 struct rtl8187_priv *priv = dev->priv; 896 struct rtl8187_priv *priv = dev->priv;
912 897
913 rtl8225_write(dev, 0x4, 0x1f); msleep(1); 898 rtl8225_write(dev, 0x4, 0x1f);
914 899
915 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); 900 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
916 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); 901 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 417e9e675fac..cf0d070ced13 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -1997,7 +1997,6 @@ static void deliver_packet(struct strip *strip_info, STRIP_Header * header,
1997#ifdef EXT_COUNTERS 1997#ifdef EXT_COUNTERS
1998 strip_info->rx_bytes += packetlen; 1998 strip_info->rx_bytes += packetlen;
1999#endif 1999#endif
2000 skb->dev->last_rx = jiffies;
2001 netif_rx(skb); 2000 netif_rx(skb);
2002 } 2001 }
2003} 2002}
@@ -2490,7 +2489,6 @@ static void strip_dev_setup(struct net_device *dev)
2490 */ 2489 */
2491 2490
2492 dev->trans_start = 0; 2491 dev->trans_start = 0;
2493 dev->last_rx = 0;
2494 dev->tx_queue_len = 30; /* Drop after 30 frames queued */ 2492 dev->tx_queue_len = 30; /* Drop after 30 frames queued */
2495 2493
2496 dev->flags = 0; 2494 dev->flags = 0;
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index e939a73ff794..832679396b6c 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -134,7 +134,7 @@ static inline void wv_16_on(unsigned long ioaddr, u16 hacr)
134 */ 134 */
135static inline void wv_ints_off(struct net_device * dev) 135static inline void wv_ints_off(struct net_device * dev)
136{ 136{
137 net_local *lp = (net_local *) dev->priv; 137 net_local *lp = netdev_priv(dev);
138 unsigned long ioaddr = dev->base_addr; 138 unsigned long ioaddr = dev->base_addr;
139 139
140 lp->hacr &= ~HACR_INTRON; 140 lp->hacr &= ~HACR_INTRON;
@@ -148,7 +148,7 @@ static inline void wv_ints_off(struct net_device * dev)
148 */ 148 */
149static inline void wv_ints_on(struct net_device * dev) 149static inline void wv_ints_on(struct net_device * dev)
150{ 150{
151 net_local *lp = (net_local *) dev->priv; 151 net_local *lp = netdev_priv(dev);
152 unsigned long ioaddr = dev->base_addr; 152 unsigned long ioaddr = dev->base_addr;
153 153
154 lp->hacr |= HACR_INTRON; 154 lp->hacr |= HACR_INTRON;
@@ -526,7 +526,7 @@ static inline void obram_write(unsigned long ioaddr, u16 o, u8 * b, int n)
526 */ 526 */
527static void wv_ack(struct net_device * dev) 527static void wv_ack(struct net_device * dev)
528{ 528{
529 net_local *lp = (net_local *) dev->priv; 529 net_local *lp = netdev_priv(dev);
530 unsigned long ioaddr = dev->base_addr; 530 unsigned long ioaddr = dev->base_addr;
531 u16 scb_cs; 531 u16 scb_cs;
532 int i; 532 int i;
@@ -568,7 +568,7 @@ static void wv_ack(struct net_device * dev)
568 */ 568 */
569static int wv_synchronous_cmd(struct net_device * dev, const char *str) 569static int wv_synchronous_cmd(struct net_device * dev, const char *str)
570{ 570{
571 net_local *lp = (net_local *) dev->priv; 571 net_local *lp = netdev_priv(dev);
572 unsigned long ioaddr = dev->base_addr; 572 unsigned long ioaddr = dev->base_addr;
573 u16 scb_cmd; 573 u16 scb_cmd;
574 ach_t cb; 574 ach_t cb;
@@ -824,7 +824,7 @@ if (lp->tx_n_in_use > 0)
824 */ 824 */
825static void wv_82586_reconfig(struct net_device * dev) 825static void wv_82586_reconfig(struct net_device * dev)
826{ 826{
827 net_local *lp = (net_local *) dev->priv; 827 net_local *lp = netdev_priv(dev);
828 unsigned long flags; 828 unsigned long flags;
829 829
830 /* Arm the flag, will be cleard in wv_82586_config() */ 830 /* Arm the flag, will be cleard in wv_82586_config() */
@@ -859,8 +859,6 @@ static void wv_82586_reconfig(struct net_device * dev)
859 */ 859 */
860static void wv_psa_show(psa_t * p) 860static void wv_psa_show(psa_t * p)
861{ 861{
862 DECLARE_MAC_BUF(mac);
863
864 printk(KERN_DEBUG "##### WaveLAN PSA contents: #####\n"); 862 printk(KERN_DEBUG "##### WaveLAN PSA contents: #####\n");
865 printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n", 863 printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n",
866 p->psa_io_base_addr_1, 864 p->psa_io_base_addr_1,
@@ -872,13 +870,10 @@ static void wv_psa_show(psa_t * p)
872 printk(KERN_DEBUG "psa_holi_params: 0x%02x, ", p->psa_holi_params); 870 printk(KERN_DEBUG "psa_holi_params: 0x%02x, ", p->psa_holi_params);
873 printk("psa_int_req_no: %d\n", p->psa_int_req_no); 871 printk("psa_int_req_no: %d\n", p->psa_int_req_no);
874#ifdef DEBUG_SHOW_UNUSED 872#ifdef DEBUG_SHOW_UNUSED
875 printk(KERN_DEBUG "psa_unused0[]: %s\n", 873 printk(KERN_DEBUG "psa_unused0[]: %pM\n", p->psa_unused0);
876 print_mac(mac, p->psa_unused0));
877#endif /* DEBUG_SHOW_UNUSED */ 874#endif /* DEBUG_SHOW_UNUSED */
878 printk(KERN_DEBUG "psa_univ_mac_addr[]: %s\n", 875 printk(KERN_DEBUG "psa_univ_mac_addr[]: %pM\n", p->psa_univ_mac_addr);
879 print_mac(mac, p->psa_univ_mac_addr)); 876 printk(KERN_DEBUG "psa_local_mac_addr[]: %pM\n", p->psa_local_mac_addr);
880 printk(KERN_DEBUG "psa_local_mac_addr[]: %s\n",
881 print_mac(mac, p->psa_local_mac_addr));
882 printk(KERN_DEBUG "psa_univ_local_sel: %d, ", 877 printk(KERN_DEBUG "psa_univ_local_sel: %d, ",
883 p->psa_univ_local_sel); 878 p->psa_univ_local_sel);
884 printk("psa_comp_number: %d, ", p->psa_comp_number); 879 printk("psa_comp_number: %d, ", p->psa_comp_number);
@@ -927,7 +922,7 @@ static void wv_psa_show(psa_t * p)
927static void wv_mmc_show(struct net_device * dev) 922static void wv_mmc_show(struct net_device * dev)
928{ 923{
929 unsigned long ioaddr = dev->base_addr; 924 unsigned long ioaddr = dev->base_addr;
930 net_local *lp = (net_local *) dev->priv; 925 net_local *lp = netdev_priv(dev);
931 mmr_t m; 926 mmr_t m;
932 927
933 /* Basic check */ 928 /* Basic check */
@@ -1107,8 +1102,6 @@ static void wv_scb_show(unsigned long ioaddr)
1107 */ 1102 */
1108static void wv_ru_show(struct net_device * dev) 1103static void wv_ru_show(struct net_device * dev)
1109{ 1104{
1110 /* net_local *lp = (net_local *) dev->priv; */
1111
1112 printk(KERN_DEBUG 1105 printk(KERN_DEBUG
1113 "##### WaveLAN i82586 receiver unit status: #####\n"); 1106 "##### WaveLAN i82586 receiver unit status: #####\n");
1114 printk(KERN_DEBUG "ru:"); 1107 printk(KERN_DEBUG "ru:");
@@ -1153,7 +1146,7 @@ static void wv_cu_show_one(struct net_device * dev, net_local * lp, int i, u16 p
1153 */ 1146 */
1154static void wv_cu_show(struct net_device * dev) 1147static void wv_cu_show(struct net_device * dev)
1155{ 1148{
1156 net_local *lp = (net_local *) dev->priv; 1149 net_local *lp = netdev_priv(dev);
1157 unsigned int i; 1150 unsigned int i;
1158 u16 p; 1151 u16 p;
1159 1152
@@ -1195,7 +1188,7 @@ static void wv_local_show(struct net_device * dev)
1195{ 1188{
1196 net_local *lp; 1189 net_local *lp;
1197 1190
1198 lp = (net_local *) dev->priv; 1191 lp = netdev_priv(dev);
1199 1192
1200 printk(KERN_DEBUG "local:"); 1193 printk(KERN_DEBUG "local:");
1201 printk(" tx_n_in_use=%d,", lp->tx_n_in_use); 1194 printk(" tx_n_in_use=%d,", lp->tx_n_in_use);
@@ -1220,14 +1213,13 @@ static inline void wv_packet_info(u8 * p, /* Packet to dump */
1220{ /* Name of the function */ 1213{ /* Name of the function */
1221 int i; 1214 int i;
1222 int maxi; 1215 int maxi;
1223 DECLARE_MAC_BUF(mac);
1224 1216
1225 printk(KERN_DEBUG 1217 printk(KERN_DEBUG
1226 "%s: %s(): dest %s, length %d\n", 1218 "%s: %s(): dest %pM, length %d\n",
1227 msg1, msg2, print_mac(mac, p), length); 1219 msg1, msg2, p, length);
1228 printk(KERN_DEBUG 1220 printk(KERN_DEBUG
1229 "%s: %s(): src %s, type 0x%02X%02X\n", 1221 "%s: %s(): src %pM, type 0x%02X%02X\n",
1230 msg1, msg2, print_mac(mac, &p[6]), p[12], p[13]); 1222 msg1, msg2, &p[6], p[12], p[13]);
1231 1223
1232#ifdef DEBUG_PACKET_DUMP 1224#ifdef DEBUG_PACKET_DUMP
1233 1225
@@ -1256,11 +1248,8 @@ static inline void wv_packet_info(u8 * p, /* Packet to dump */
1256static void wv_init_info(struct net_device * dev) 1248static void wv_init_info(struct net_device * dev)
1257{ 1249{
1258 short ioaddr = dev->base_addr; 1250 short ioaddr = dev->base_addr;
1259 net_local *lp = (net_local *) dev->priv; 1251 net_local *lp = netdev_priv(dev);
1260 psa_t psa; 1252 psa_t psa;
1261#ifdef DEBUG_BASIC_SHOW
1262 DECLARE_MAC_BUF(mac);
1263#endif
1264 1253
1265 /* Read the parameter storage area */ 1254 /* Read the parameter storage area */
1266 psa_read(ioaddr, lp->hacr, 0, (unsigned char *) &psa, sizeof(psa)); 1255 psa_read(ioaddr, lp->hacr, 0, (unsigned char *) &psa, sizeof(psa));
@@ -1277,8 +1266,8 @@ static void wv_init_info(struct net_device * dev)
1277 1266
1278#ifdef DEBUG_BASIC_SHOW 1267#ifdef DEBUG_BASIC_SHOW
1279 /* Now, let's go for the basic stuff. */ 1268 /* Now, let's go for the basic stuff. */
1280 printk(KERN_NOTICE "%s: WaveLAN at %#x, %s, IRQ %d", 1269 printk(KERN_NOTICE "%s: WaveLAN at %#x, %pM, IRQ %d",
1281 dev->name, ioaddr, print_mac(mac, dev->dev_addr), dev->irq); 1270 dev->name, ioaddr, dev->dev_addr, dev->irq);
1282 1271
1283 /* Print current network ID. */ 1272 /* Print current network ID. */
1284 if (psa.psa_nwid_select) 1273 if (psa.psa_nwid_select)
@@ -1369,7 +1358,7 @@ static en_stats *wavelan_get_stats(struct net_device * dev)
1369 printk(KERN_DEBUG "%s: <>wavelan_get_stats()\n", dev->name); 1358 printk(KERN_DEBUG "%s: <>wavelan_get_stats()\n", dev->name);
1370#endif 1359#endif
1371 1360
1372 return (&((net_local *) dev->priv)->stats); 1361 return &((net_local *)netdev_priv(dev))->stats;
1373} 1362}
1374 1363
1375/*------------------------------------------------------------------*/ 1364/*------------------------------------------------------------------*/
@@ -1382,7 +1371,7 @@ static en_stats *wavelan_get_stats(struct net_device * dev)
1382 */ 1371 */
1383static void wavelan_set_multicast_list(struct net_device * dev) 1372static void wavelan_set_multicast_list(struct net_device * dev)
1384{ 1373{
1385 net_local *lp = (net_local *) dev->priv; 1374 net_local *lp = netdev_priv(dev);
1386 1375
1387#ifdef DEBUG_IOCTL_TRACE 1376#ifdef DEBUG_IOCTL_TRACE
1388 printk(KERN_DEBUG "%s: ->wavelan_set_multicast_list()\n", 1377 printk(KERN_DEBUG "%s: ->wavelan_set_multicast_list()\n",
@@ -1716,7 +1705,7 @@ static inline void wl_spy_gather(struct net_device * dev,
1716 */ 1705 */
1717static inline void wl_his_gather(struct net_device * dev, u8 * stats) 1706static inline void wl_his_gather(struct net_device * dev, u8 * stats)
1718{ /* Statistics to gather */ 1707{ /* Statistics to gather */
1719 net_local *lp = (net_local *) dev->priv; 1708 net_local *lp = netdev_priv(dev);
1720 u8 level = stats[0] & MMR_SIGNAL_LVL; 1709 u8 level = stats[0] & MMR_SIGNAL_LVL;
1721 int i; 1710 int i;
1722 1711
@@ -1753,7 +1742,7 @@ static int wavelan_set_nwid(struct net_device *dev,
1753 char *extra) 1742 char *extra)
1754{ 1743{
1755 unsigned long ioaddr = dev->base_addr; 1744 unsigned long ioaddr = dev->base_addr;
1756 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 1745 net_local *lp = netdev_priv(dev); /* lp is not unused */
1757 psa_t psa; 1746 psa_t psa;
1758 mm_t m; 1747 mm_t m;
1759 unsigned long flags; 1748 unsigned long flags;
@@ -1812,7 +1801,7 @@ static int wavelan_get_nwid(struct net_device *dev,
1812 char *extra) 1801 char *extra)
1813{ 1802{
1814 unsigned long ioaddr = dev->base_addr; 1803 unsigned long ioaddr = dev->base_addr;
1815 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 1804 net_local *lp = netdev_priv(dev); /* lp is not unused */
1816 psa_t psa; 1805 psa_t psa;
1817 unsigned long flags; 1806 unsigned long flags;
1818 int ret = 0; 1807 int ret = 0;
@@ -1844,7 +1833,7 @@ static int wavelan_set_freq(struct net_device *dev,
1844 char *extra) 1833 char *extra)
1845{ 1834{
1846 unsigned long ioaddr = dev->base_addr; 1835 unsigned long ioaddr = dev->base_addr;
1847 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 1836 net_local *lp = netdev_priv(dev); /* lp is not unused */
1848 unsigned long flags; 1837 unsigned long flags;
1849 int ret; 1838 int ret;
1850 1839
@@ -1874,7 +1863,7 @@ static int wavelan_get_freq(struct net_device *dev,
1874 char *extra) 1863 char *extra)
1875{ 1864{
1876 unsigned long ioaddr = dev->base_addr; 1865 unsigned long ioaddr = dev->base_addr;
1877 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 1866 net_local *lp = netdev_priv(dev); /* lp is not unused */
1878 psa_t psa; 1867 psa_t psa;
1879 unsigned long flags; 1868 unsigned long flags;
1880 int ret = 0; 1869 int ret = 0;
@@ -1920,7 +1909,7 @@ static int wavelan_set_sens(struct net_device *dev,
1920 char *extra) 1909 char *extra)
1921{ 1910{
1922 unsigned long ioaddr = dev->base_addr; 1911 unsigned long ioaddr = dev->base_addr;
1923 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 1912 net_local *lp = netdev_priv(dev); /* lp is not unused */
1924 psa_t psa; 1913 psa_t psa;
1925 unsigned long flags; 1914 unsigned long flags;
1926 int ret = 0; 1915 int ret = 0;
@@ -1956,7 +1945,7 @@ static int wavelan_get_sens(struct net_device *dev,
1956 char *extra) 1945 char *extra)
1957{ 1946{
1958 unsigned long ioaddr = dev->base_addr; 1947 unsigned long ioaddr = dev->base_addr;
1959 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 1948 net_local *lp = netdev_priv(dev); /* lp is not unused */
1960 psa_t psa; 1949 psa_t psa;
1961 unsigned long flags; 1950 unsigned long flags;
1962 int ret = 0; 1951 int ret = 0;
@@ -1987,7 +1976,7 @@ static int wavelan_set_encode(struct net_device *dev,
1987 char *extra) 1976 char *extra)
1988{ 1977{
1989 unsigned long ioaddr = dev->base_addr; 1978 unsigned long ioaddr = dev->base_addr;
1990 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 1979 net_local *lp = netdev_priv(dev); /* lp is not unused */
1991 unsigned long flags; 1980 unsigned long flags;
1992 psa_t psa; 1981 psa_t psa;
1993 int ret = 0; 1982 int ret = 0;
@@ -2057,7 +2046,7 @@ static int wavelan_get_encode(struct net_device *dev,
2057 char *extra) 2046 char *extra)
2058{ 2047{
2059 unsigned long ioaddr = dev->base_addr; 2048 unsigned long ioaddr = dev->base_addr;
2060 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 2049 net_local *lp = netdev_priv(dev); /* lp is not unused */
2061 psa_t psa; 2050 psa_t psa;
2062 unsigned long flags; 2051 unsigned long flags;
2063 int ret = 0; 2052 int ret = 0;
@@ -2104,7 +2093,7 @@ static int wavelan_get_range(struct net_device *dev,
2104 char *extra) 2093 char *extra)
2105{ 2094{
2106 unsigned long ioaddr = dev->base_addr; 2095 unsigned long ioaddr = dev->base_addr;
2107 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 2096 net_local *lp = netdev_priv(dev); /* lp is not unused */
2108 struct iw_range *range = (struct iw_range *) extra; 2097 struct iw_range *range = (struct iw_range *) extra;
2109 unsigned long flags; 2098 unsigned long flags;
2110 int ret = 0; 2099 int ret = 0;
@@ -2179,7 +2168,7 @@ static int wavelan_set_qthr(struct net_device *dev,
2179 char *extra) 2168 char *extra)
2180{ 2169{
2181 unsigned long ioaddr = dev->base_addr; 2170 unsigned long ioaddr = dev->base_addr;
2182 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 2171 net_local *lp = netdev_priv(dev); /* lp is not unused */
2183 psa_t psa; 2172 psa_t psa;
2184 unsigned long flags; 2173 unsigned long flags;
2185 2174
@@ -2211,7 +2200,7 @@ static int wavelan_get_qthr(struct net_device *dev,
2211 char *extra) 2200 char *extra)
2212{ 2201{
2213 unsigned long ioaddr = dev->base_addr; 2202 unsigned long ioaddr = dev->base_addr;
2214 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 2203 net_local *lp = netdev_priv(dev); /* lp is not unused */
2215 psa_t psa; 2204 psa_t psa;
2216 unsigned long flags; 2205 unsigned long flags;
2217 2206
@@ -2239,7 +2228,7 @@ static int wavelan_set_histo(struct net_device *dev,
2239 union iwreq_data *wrqu, 2228 union iwreq_data *wrqu,
2240 char *extra) 2229 char *extra)
2241{ 2230{
2242 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 2231 net_local *lp = netdev_priv(dev); /* lp is not unused */
2243 2232
2244 /* Check the number of intervals. */ 2233 /* Check the number of intervals. */
2245 if (wrqu->data.length > 16) { 2234 if (wrqu->data.length > 16) {
@@ -2282,7 +2271,7 @@ static int wavelan_get_histo(struct net_device *dev,
2282 union iwreq_data *wrqu, 2271 union iwreq_data *wrqu,
2283 char *extra) 2272 char *extra)
2284{ 2273{
2285 net_local *lp = (net_local *) dev->priv; /* lp is not unused */ 2274 net_local *lp = netdev_priv(dev); /* lp is not unused */
2286 2275
2287 /* Set the number of intervals. */ 2276 /* Set the number of intervals. */
2288 wrqu->data.length = lp->his_number; 2277 wrqu->data.length = lp->his_number;
@@ -2386,7 +2375,7 @@ static const struct iw_handler_def wavelan_handler_def =
2386static iw_stats *wavelan_get_wireless_stats(struct net_device * dev) 2375static iw_stats *wavelan_get_wireless_stats(struct net_device * dev)
2387{ 2376{
2388 unsigned long ioaddr = dev->base_addr; 2377 unsigned long ioaddr = dev->base_addr;
2389 net_local *lp = (net_local *) dev->priv; 2378 net_local *lp = netdev_priv(dev);
2390 mmr_t m; 2379 mmr_t m;
2391 iw_stats *wstats; 2380 iw_stats *wstats;
2392 unsigned long flags; 2381 unsigned long flags;
@@ -2461,7 +2450,7 @@ static iw_stats *wavelan_get_wireless_stats(struct net_device * dev)
2461static void 2450static void
2462wv_packet_read(struct net_device * dev, u16 buf_off, int sksize) 2451wv_packet_read(struct net_device * dev, u16 buf_off, int sksize)
2463{ 2452{
2464 net_local *lp = (net_local *) dev->priv; 2453 net_local *lp = netdev_priv(dev);
2465 unsigned long ioaddr = dev->base_addr; 2454 unsigned long ioaddr = dev->base_addr;
2466 struct sk_buff *skb; 2455 struct sk_buff *skb;
2467 2456
@@ -2537,7 +2526,6 @@ wv_packet_read(struct net_device * dev, u16 buf_off, int sksize)
2537 netif_rx(skb); 2526 netif_rx(skb);
2538 2527
2539 /* Keep statistics up to date */ 2528 /* Keep statistics up to date */
2540 dev->last_rx = jiffies;
2541 lp->stats.rx_packets++; 2529 lp->stats.rx_packets++;
2542 lp->stats.rx_bytes += sksize; 2530 lp->stats.rx_bytes += sksize;
2543 2531
@@ -2556,7 +2544,7 @@ wv_packet_read(struct net_device * dev, u16 buf_off, int sksize)
2556static void wv_receive(struct net_device * dev) 2544static void wv_receive(struct net_device * dev)
2557{ 2545{
2558 unsigned long ioaddr = dev->base_addr; 2546 unsigned long ioaddr = dev->base_addr;
2559 net_local *lp = (net_local *) dev->priv; 2547 net_local *lp = netdev_priv(dev);
2560 fd_t fd; 2548 fd_t fd;
2561 rbd_t rbd; 2549 rbd_t rbd;
2562 int nreaped = 0; 2550 int nreaped = 0;
@@ -2738,7 +2726,7 @@ static void wv_receive(struct net_device * dev)
2738 */ 2726 */
2739static int wv_packet_write(struct net_device * dev, void *buf, short length) 2727static int wv_packet_write(struct net_device * dev, void *buf, short length)
2740{ 2728{
2741 net_local *lp = (net_local *) dev->priv; 2729 net_local *lp = netdev_priv(dev);
2742 unsigned long ioaddr = dev->base_addr; 2730 unsigned long ioaddr = dev->base_addr;
2743 unsigned short txblock; 2731 unsigned short txblock;
2744 unsigned short txpred; 2732 unsigned short txpred;
@@ -2869,7 +2857,7 @@ static int wv_packet_write(struct net_device * dev, void *buf, short length)
2869 */ 2857 */
2870static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev) 2858static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev)
2871{ 2859{
2872 net_local *lp = (net_local *) dev->priv; 2860 net_local *lp = netdev_priv(dev);
2873 unsigned long flags; 2861 unsigned long flags;
2874 char data[ETH_ZLEN]; 2862 char data[ETH_ZLEN];
2875 2863
@@ -2937,7 +2925,7 @@ static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev)
2937static int wv_mmc_init(struct net_device * dev) 2925static int wv_mmc_init(struct net_device * dev)
2938{ 2926{
2939 unsigned long ioaddr = dev->base_addr; 2927 unsigned long ioaddr = dev->base_addr;
2940 net_local *lp = (net_local *) dev->priv; 2928 net_local *lp = netdev_priv(dev);
2941 psa_t psa; 2929 psa_t psa;
2942 mmw_t m; 2930 mmw_t m;
2943 int configured; 2931 int configured;
@@ -3108,7 +3096,7 @@ static int wv_mmc_init(struct net_device * dev)
3108 */ 3096 */
3109static int wv_ru_start(struct net_device * dev) 3097static int wv_ru_start(struct net_device * dev)
3110{ 3098{
3111 net_local *lp = (net_local *) dev->priv; 3099 net_local *lp = netdev_priv(dev);
3112 unsigned long ioaddr = dev->base_addr; 3100 unsigned long ioaddr = dev->base_addr;
3113 u16 scb_cs; 3101 u16 scb_cs;
3114 fd_t fd; 3102 fd_t fd;
@@ -3200,7 +3188,7 @@ static int wv_ru_start(struct net_device * dev)
3200 */ 3188 */
3201static int wv_cu_start(struct net_device * dev) 3189static int wv_cu_start(struct net_device * dev)
3202{ 3190{
3203 net_local *lp = (net_local *) dev->priv; 3191 net_local *lp = netdev_priv(dev);
3204 unsigned long ioaddr = dev->base_addr; 3192 unsigned long ioaddr = dev->base_addr;
3205 int i; 3193 int i;
3206 u16 txblock; 3194 u16 txblock;
@@ -3301,7 +3289,7 @@ static int wv_cu_start(struct net_device * dev)
3301 */ 3289 */
3302static int wv_82586_start(struct net_device * dev) 3290static int wv_82586_start(struct net_device * dev)
3303{ 3291{
3304 net_local *lp = (net_local *) dev->priv; 3292 net_local *lp = netdev_priv(dev);
3305 unsigned long ioaddr = dev->base_addr; 3293 unsigned long ioaddr = dev->base_addr;
3306 scp_t scp; /* system configuration pointer */ 3294 scp_t scp; /* system configuration pointer */
3307 iscp_t iscp; /* intermediate scp */ 3295 iscp_t iscp; /* intermediate scp */
@@ -3433,7 +3421,7 @@ static int wv_82586_start(struct net_device * dev)
3433 */ 3421 */
3434static void wv_82586_config(struct net_device * dev) 3422static void wv_82586_config(struct net_device * dev)
3435{ 3423{
3436 net_local *lp = (net_local *) dev->priv; 3424 net_local *lp = netdev_priv(dev);
3437 unsigned long ioaddr = dev->base_addr; 3425 unsigned long ioaddr = dev->base_addr;
3438 unsigned short txblock; 3426 unsigned short txblock;
3439 unsigned short txpred; 3427 unsigned short txpred;
@@ -3565,15 +3553,11 @@ static void wv_82586_config(struct net_device * dev)
3565 WAVELAN_ADDR_SIZE >> 1); 3553 WAVELAN_ADDR_SIZE >> 1);
3566 3554
3567#ifdef DEBUG_CONFIG_INFO 3555#ifdef DEBUG_CONFIG_INFO
3568 {
3569 DECLARE_MAC_BUF(mac);
3570 printk(KERN_DEBUG 3556 printk(KERN_DEBUG
3571 "%s: wv_82586_config(): set %d multicast addresses:\n", 3557 "%s: wv_82586_config(): set %d multicast addresses:\n",
3572 dev->name, lp->mc_count); 3558 dev->name, lp->mc_count);
3573 for (dmi = dev->mc_list; dmi; dmi = dmi->next) 3559 for (dmi = dev->mc_list; dmi; dmi = dmi->next)
3574 printk(KERN_DEBUG " %s\n", 3560 printk(KERN_DEBUG " %pM\n", dmi->dmi_addr);
3575 print_mac(mac, dmi->dmi_addr));
3576 }
3577#endif 3561#endif
3578 } 3562 }
3579 3563
@@ -3613,7 +3597,7 @@ static void wv_82586_config(struct net_device * dev)
3613 */ 3597 */
3614static void wv_82586_stop(struct net_device * dev) 3598static void wv_82586_stop(struct net_device * dev)
3615{ 3599{
3616 net_local *lp = (net_local *) dev->priv; 3600 net_local *lp = netdev_priv(dev);
3617 unsigned long ioaddr = dev->base_addr; 3601 unsigned long ioaddr = dev->base_addr;
3618 u16 scb_cmd; 3602 u16 scb_cmd;
3619 3603
@@ -3650,7 +3634,7 @@ static void wv_82586_stop(struct net_device * dev)
3650 */ 3634 */
3651static int wv_hw_reset(struct net_device * dev) 3635static int wv_hw_reset(struct net_device * dev)
3652{ 3636{
3653 net_local *lp = (net_local *) dev->priv; 3637 net_local *lp = netdev_priv(dev);
3654 unsigned long ioaddr = dev->base_addr; 3638 unsigned long ioaddr = dev->base_addr;
3655 3639
3656#ifdef DEBUG_CONFIG_TRACE 3640#ifdef DEBUG_CONFIG_TRACE
@@ -3751,7 +3735,7 @@ static irqreturn_t wavelan_interrupt(int irq, void *dev_id)
3751 printk(KERN_DEBUG "%s: ->wavelan_interrupt()\n", dev->name); 3735 printk(KERN_DEBUG "%s: ->wavelan_interrupt()\n", dev->name);
3752#endif 3736#endif
3753 3737
3754 lp = (net_local *) dev->priv; 3738 lp = netdev_priv(dev);
3755 ioaddr = dev->base_addr; 3739 ioaddr = dev->base_addr;
3756 3740
3757#ifdef DEBUG_INTERRUPT_INFO 3741#ifdef DEBUG_INTERRUPT_INFO
@@ -3894,7 +3878,7 @@ static irqreturn_t wavelan_interrupt(int irq, void *dev_id)
3894 */ 3878 */
3895static void wavelan_watchdog(struct net_device * dev) 3879static void wavelan_watchdog(struct net_device * dev)
3896{ 3880{
3897 net_local * lp = (net_local *)dev->priv; 3881 net_local *lp = netdev_priv(dev);
3898 u_long ioaddr = dev->base_addr; 3882 u_long ioaddr = dev->base_addr;
3899 unsigned long flags; 3883 unsigned long flags;
3900 unsigned int nreaped; 3884 unsigned int nreaped;
@@ -3974,7 +3958,7 @@ static void wavelan_watchdog(struct net_device * dev)
3974 */ 3958 */
3975static int wavelan_open(struct net_device * dev) 3959static int wavelan_open(struct net_device * dev)
3976{ 3960{
3977 net_local * lp = (net_local *)dev->priv; 3961 net_local *lp = netdev_priv(dev);
3978 unsigned long flags; 3962 unsigned long flags;
3979 3963
3980#ifdef DEBUG_CALLBACK_TRACE 3964#ifdef DEBUG_CALLBACK_TRACE
@@ -4029,7 +4013,7 @@ static int wavelan_open(struct net_device * dev)
4029 */ 4013 */
4030static int wavelan_close(struct net_device * dev) 4014static int wavelan_close(struct net_device * dev)
4031{ 4015{
4032 net_local *lp = (net_local *) dev->priv; 4016 net_local *lp = netdev_priv(dev);
4033 unsigned long flags; 4017 unsigned long flags;
4034 4018
4035#ifdef DEBUG_CALLBACK_TRACE 4019#ifdef DEBUG_CALLBACK_TRACE
@@ -4128,8 +4112,8 @@ static int __init wavelan_config(struct net_device *dev, unsigned short ioaddr)
4128 dev->if_port = 0; 4112 dev->if_port = 0;
4129 4113
4130 /* Initialize device structures */ 4114 /* Initialize device structures */
4131 memset(dev->priv, 0, sizeof(net_local)); 4115 memset(netdev_priv(dev), 0, sizeof(net_local));
4132 lp = (net_local *) dev->priv; 4116 lp = netdev_priv(dev);
4133 4117
4134 /* Back link to the device structure. */ 4118 /* Back link to the device structure. */
4135 lp->dev = dev; 4119 lp->dev = dev;
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index e124b1d6267a..de717f8ffd61 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -1020,7 +1020,6 @@ wv_82593_reconfig(struct net_device * dev)
1020static void 1020static void
1021wv_psa_show(psa_t * p) 1021wv_psa_show(psa_t * p)
1022{ 1022{
1023 DECLARE_MAC_BUF(mac);
1024 printk(KERN_DEBUG "##### wavelan psa contents: #####\n"); 1023 printk(KERN_DEBUG "##### wavelan psa contents: #####\n");
1025 printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n", 1024 printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n",
1026 p->psa_io_base_addr_1, 1025 p->psa_io_base_addr_1,
@@ -1034,13 +1033,10 @@ wv_psa_show(psa_t * p)
1034 printk(KERN_DEBUG "psa_holi_params: 0x%02x, ", p->psa_holi_params); 1033 printk(KERN_DEBUG "psa_holi_params: 0x%02x, ", p->psa_holi_params);
1035 printk("psa_int_req_no: %d\n", p->psa_int_req_no); 1034 printk("psa_int_req_no: %d\n", p->psa_int_req_no);
1036#ifdef DEBUG_SHOW_UNUSED 1035#ifdef DEBUG_SHOW_UNUSED
1037 printk(KERN_DEBUG "psa_unused0[]: %s\n", 1036 printk(KERN_DEBUG "psa_unused0[]: %pM\n", p->psa_unused0);
1038 print_mac(mac, p->psa_unused0));
1039#endif /* DEBUG_SHOW_UNUSED */ 1037#endif /* DEBUG_SHOW_UNUSED */
1040 printk(KERN_DEBUG "psa_univ_mac_addr[]: %s\n", 1038 printk(KERN_DEBUG "psa_univ_mac_addr[]: %pM\n", p->psa_univ_mac_addr);
1041 print_mac(mac, p->psa_univ_mac_addr)); 1039 printk(KERN_DEBUG "psa_local_mac_addr[]: %pM\n", p->psa_local_mac_addr);
1042 printk(KERN_DEBUG "psa_local_mac_addr[]: %s\n",
1043 print_mac(mac, p->psa_local_mac_addr));
1044 printk(KERN_DEBUG "psa_univ_local_sel: %d, ", p->psa_univ_local_sel); 1040 printk(KERN_DEBUG "psa_univ_local_sel: %d, ", p->psa_univ_local_sel);
1045 printk("psa_comp_number: %d, ", p->psa_comp_number); 1041 printk("psa_comp_number: %d, ", p->psa_comp_number);
1046 printk("psa_thr_pre_set: 0x%02x\n", p->psa_thr_pre_set); 1042 printk("psa_thr_pre_set: 0x%02x\n", p->psa_thr_pre_set);
@@ -1238,12 +1234,11 @@ wv_packet_info(u_char * p, /* Packet to dump */
1238{ 1234{
1239 int i; 1235 int i;
1240 int maxi; 1236 int maxi;
1241 DECLARE_MAC_BUF(mac);
1242 1237
1243 printk(KERN_DEBUG "%s: %s(): dest %s, length %d\n", 1238 printk(KERN_DEBUG "%s: %s(): dest %pM, length %d\n",
1244 msg1, msg2, print_mac(mac, p), length); 1239 msg1, msg2, p, length);
1245 printk(KERN_DEBUG "%s: %s(): src %s, type 0x%02X%02X\n", 1240 printk(KERN_DEBUG "%s: %s(): src %pM, type 0x%02X%02X\n",
1246 msg1, msg2, print_mac(mac, &p[6]), p[12], p[13]); 1241 msg1, msg2, &p[6], p[12], p[13]);
1247 1242
1248#ifdef DEBUG_PACKET_DUMP 1243#ifdef DEBUG_PACKET_DUMP
1249 1244
@@ -1274,7 +1269,6 @@ wv_init_info(struct net_device * dev)
1274{ 1269{
1275 unsigned int base = dev->base_addr; 1270 unsigned int base = dev->base_addr;
1276 psa_t psa; 1271 psa_t psa;
1277 DECLARE_MAC_BUF(mac);
1278 1272
1279 /* Read the parameter storage area */ 1273 /* Read the parameter storage area */
1280 psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa)); 1274 psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa));
@@ -1291,10 +1285,8 @@ wv_init_info(struct net_device * dev)
1291 1285
1292#ifdef DEBUG_BASIC_SHOW 1286#ifdef DEBUG_BASIC_SHOW
1293 /* Now, let's go for the basic stuff */ 1287 /* Now, let's go for the basic stuff */
1294 printk(KERN_NOTICE "%s: WaveLAN: port %#x, irq %d, " 1288 printk(KERN_NOTICE "%s: WaveLAN: port %#x, irq %d, hw_addr %pM",
1295 "hw_addr %s", 1289 dev->name, base, dev->irq, dev->dev_addr);
1296 dev->name, base, dev->irq,
1297 print_mac(mac, dev->dev_addr));
1298 1290
1299 /* Print current network id */ 1291 /* Print current network id */
1300 if(psa.psa_nwid_select) 1292 if(psa.psa_nwid_select)
@@ -2243,13 +2235,7 @@ static int wavelan_set_wap(struct net_device *dev,
2243 char *extra) 2235 char *extra)
2244{ 2236{
2245#ifdef DEBUG_IOCTL_INFO 2237#ifdef DEBUG_IOCTL_INFO
2246 printk(KERN_DEBUG "Set AP to : %02X:%02X:%02X:%02X:%02X:%02X\n", 2238 printk(KERN_DEBUG "Set AP to : %pM\n", wrqu->ap_addr.sa_data);
2247 wrqu->ap_addr.sa_data[0],
2248 wrqu->ap_addr.sa_data[1],
2249 wrqu->ap_addr.sa_data[2],
2250 wrqu->ap_addr.sa_data[3],
2251 wrqu->ap_addr.sa_data[4],
2252 wrqu->ap_addr.sa_data[5]);
2253#endif /* DEBUG_IOCTL_INFO */ 2239#endif /* DEBUG_IOCTL_INFO */
2254 2240
2255 return -EOPNOTSUPP; 2241 return -EOPNOTSUPP;
@@ -2892,7 +2878,6 @@ wv_packet_read(struct net_device * dev,
2892 netif_rx(skb); 2878 netif_rx(skb);
2893 2879
2894 /* Keep stats up to date */ 2880 /* Keep stats up to date */
2895 dev->last_rx = jiffies;
2896 lp->stats.rx_packets++; 2881 lp->stats.rx_packets++;
2897 lp->stats.rx_bytes += sksize; 2882 lp->stats.rx_bytes += sksize;
2898 2883
@@ -3647,12 +3632,10 @@ wv_82593_config(struct net_device * dev)
3647 int addrs_len = WAVELAN_ADDR_SIZE * lp->mc_count; 3632 int addrs_len = WAVELAN_ADDR_SIZE * lp->mc_count;
3648 3633
3649#ifdef DEBUG_CONFIG_INFO 3634#ifdef DEBUG_CONFIG_INFO
3650 DECLARE_MAC_BUF(mac);
3651 printk(KERN_DEBUG "%s: wv_hw_config(): set %d multicast addresses:\n", 3635 printk(KERN_DEBUG "%s: wv_hw_config(): set %d multicast addresses:\n",
3652 dev->name, lp->mc_count); 3636 dev->name, lp->mc_count);
3653 for(dmi=dev->mc_list; dmi; dmi=dmi->next) 3637 for(dmi=dev->mc_list; dmi; dmi=dmi->next)
3654 printk(KERN_DEBUG " %s\n", 3638 printk(KERN_DEBUG " %pM\n", dmi->dmi_addr);
3655 print_mac(mac, dmi->dmi_addr));
3656#endif 3639#endif
3657 3640
3658 /* Initialize adapter's ethernet multicast addresses */ 3641 /* Initialize adapter's ethernet multicast addresses */
diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h
index 65ceb088f700..59bb3a55ab48 100644
--- a/drivers/net/wireless/wl3501.h
+++ b/drivers/net/wireless/wl3501.h
@@ -2,7 +2,7 @@
2#define __WL3501_H__ 2#define __WL3501_H__
3 3
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <net/ieee80211.h> 5#include <linux/ieee80211.h>
6 6
7/* define for WLA 2.0 */ 7/* define for WLA 2.0 */
8#define WL3501_BLKSZ 256 8#define WL3501_BLKSZ 256
@@ -548,7 +548,7 @@ struct wl3501_80211_tx_plcp_hdr {
548 548
549struct wl3501_80211_tx_hdr { 549struct wl3501_80211_tx_hdr {
550 struct wl3501_80211_tx_plcp_hdr pclp_hdr; 550 struct wl3501_80211_tx_plcp_hdr pclp_hdr;
551 struct ieee80211_hdr_4addr mac_hdr; 551 struct ieee80211_hdr mac_hdr;
552} __attribute__ ((packed)); 552} __attribute__ ((packed));
553 553
554/* 554/*
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 68789c6e1ce9..c99a1b6b948f 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -860,10 +860,9 @@ static int wl3501_esbq_confirm(struct wl3501_card *this)
860static void wl3501_online(struct net_device *dev) 860static void wl3501_online(struct net_device *dev)
861{ 861{
862 struct wl3501_card *this = netdev_priv(dev); 862 struct wl3501_card *this = netdev_priv(dev);
863 DECLARE_MAC_BUF(mac);
864 863
865 printk(KERN_INFO "%s: Wireless LAN online. BSSID: %s\n", 864 printk(KERN_INFO "%s: Wireless LAN online. BSSID: %pM\n",
866 dev->name, print_mac(mac, this->bssid)); 865 dev->name, this->bssid);
867 netif_wake_queue(dev); 866 netif_wake_queue(dev);
868} 867}
869 868
@@ -1014,7 +1013,6 @@ static inline void wl3501_md_ind_interrupt(struct net_device *dev,
1014 wl3501_receive(this, skb->data, pkt_len); 1013 wl3501_receive(this, skb->data, pkt_len);
1015 skb_put(skb, pkt_len); 1014 skb_put(skb, pkt_len);
1016 skb->protocol = eth_type_trans(skb, dev); 1015 skb->protocol = eth_type_trans(skb, dev);
1017 dev->last_rx = jiffies;
1018 this->stats.rx_packets++; 1016 this->stats.rx_packets++;
1019 this->stats.rx_bytes += skb->len; 1017 this->stats.rx_bytes += skb->len;
1020 netif_rx(skb); 1018 netif_rx(skb);
@@ -1965,7 +1963,6 @@ static int wl3501_config(struct pcmcia_device *link)
1965 struct net_device *dev = link->priv; 1963 struct net_device *dev = link->priv;
1966 int i = 0, j, last_fn, last_ret; 1964 int i = 0, j, last_fn, last_ret;
1967 struct wl3501_card *this; 1965 struct wl3501_card *this;
1968 DECLARE_MAC_BUF(mac);
1969 1966
1970 /* Try allocating IO ports. This tries a few fixed addresses. If you 1967 /* Try allocating IO ports. This tries a few fixed addresses. If you
1971 * want, you can also read the card's config table to pick addresses -- 1968 * want, you can also read the card's config table to pick addresses --
@@ -2024,9 +2021,9 @@ static int wl3501_config(struct pcmcia_device *link)
2024 2021
2025 /* print probe information */ 2022 /* print probe information */
2026 printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, " 2023 printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, "
2027 "MAC addr in flash ROM:%s\n", 2024 "MAC addr in flash ROM:%pM\n",
2028 dev->name, this->base_addr, (int)dev->irq, 2025 dev->name, this->base_addr, (int)dev->irq,
2029 print_mac(mac, dev->dev_addr)); 2026 dev->dev_addr);
2030 /* 2027 /*
2031 * Initialize card parameters - added by jss 2028 * Initialize card parameters - added by jss
2032 */ 2029 */
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index b16ec6e5f0e3..1134e2fb1890 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -17,11 +17,11 @@
17#include <linux/netdevice.h> 17#include <linux/netdevice.h>
18#include <linux/etherdevice.h> 18#include <linux/etherdevice.h>
19#include <linux/wireless.h> 19#include <linux/wireless.h>
20#include <linux/ieee80211.h>
20#include <net/iw_handler.h> 21#include <net/iw_handler.h>
21#include <linux/string.h> 22#include <linux/string.h>
22#include <linux/if_arp.h> 23#include <linux/if_arp.h>
23#include <linux/firmware.h> 24#include <linux/firmware.h>
24#include <net/ieee80211.h>
25#include "zd1201.h" 25#include "zd1201.h"
26 26
27static struct usb_device_id zd1201_table[] = { 27static struct usb_device_id zd1201_table[] = {
@@ -328,7 +328,6 @@ static void zd1201_usbrx(struct urb *urb)
328 memcpy(skb_put(skb, 2), &data[datalen-24], 2); 328 memcpy(skb_put(skb, 2), &data[datalen-24], 2);
329 memcpy(skb_put(skb, len), data, len); 329 memcpy(skb_put(skb, len), data, len);
330 skb->protocol = eth_type_trans(skb, zd->dev); 330 skb->protocol = eth_type_trans(skb, zd->dev);
331 skb->dev->last_rx = jiffies;
332 zd->stats.rx_packets++; 331 zd->stats.rx_packets++;
333 zd->stats.rx_bytes += skb->len; 332 zd->stats.rx_bytes += skb->len;
334 netif_rx(skb); 333 netif_rx(skb);
@@ -346,7 +345,7 @@ static void zd1201_usbrx(struct urb *urb)
346 frag = kmalloc(sizeof(*frag), GFP_ATOMIC); 345 frag = kmalloc(sizeof(*frag), GFP_ATOMIC);
347 if (!frag) 346 if (!frag)
348 goto resubmit; 347 goto resubmit;
349 skb = dev_alloc_skb(IEEE80211_DATA_LEN +14+2); 348 skb = dev_alloc_skb(IEEE80211_MAX_DATA_LEN +14+2);
350 if (!skb) { 349 if (!skb) {
351 kfree(frag); 350 kfree(frag);
352 goto resubmit; 351 goto resubmit;
@@ -385,7 +384,6 @@ static void zd1201_usbrx(struct urb *urb)
385 memcpy(skb_put(skb, len), data+8, len); 384 memcpy(skb_put(skb, len), data+8, len);
386 } 385 }
387 skb->protocol = eth_type_trans(skb, zd->dev); 386 skb->protocol = eth_type_trans(skb, zd->dev);
388 skb->dev->last_rx = jiffies;
389 zd->stats.rx_packets++; 387 zd->stats.rx_packets++;
390 zd->stats.rx_bytes += skb->len; 388 zd->stats.rx_bytes += skb->len;
391 netif_rx(skb); 389 netif_rx(skb);
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index e0ac58b8ff1f..f1519143f8a6 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -378,7 +378,6 @@ int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr)
378 [0] = { .addr = CR_MAC_ADDR_P1 }, 378 [0] = { .addr = CR_MAC_ADDR_P1 },
379 [1] = { .addr = CR_MAC_ADDR_P2 }, 379 [1] = { .addr = CR_MAC_ADDR_P2 },
380 }; 380 };
381 DECLARE_MAC_BUF(mac);
382 381
383 if (mac_addr) { 382 if (mac_addr) {
384 reqs[0].value = (mac_addr[3] << 24) 383 reqs[0].value = (mac_addr[3] << 24)
@@ -387,8 +386,7 @@ int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr)
387 | mac_addr[0]; 386 | mac_addr[0];
388 reqs[1].value = (mac_addr[5] << 8) 387 reqs[1].value = (mac_addr[5] << 8)
389 | mac_addr[4]; 388 | mac_addr[4];
390 dev_dbg_f(zd_chip_dev(chip), 389 dev_dbg_f(zd_chip_dev(chip), "mac addr %pM\n", mac_addr);
391 "mac addr %s\n", print_mac(mac, mac_addr));
392 } else { 390 } else {
393 dev_dbg_f(zd_chip_dev(chip), "set NULL mac\n"); 391 dev_dbg_f(zd_chip_dev(chip), "set NULL mac\n");
394 } 392 }
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index fe1867b25ff7..07513e48b8f2 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -171,7 +171,7 @@ int zd_mac_init_hw(struct ieee80211_hw *hw)
171 171
172 r = zd_reg2alpha2(mac->regdomain, alpha2); 172 r = zd_reg2alpha2(mac->regdomain, alpha2);
173 if (!r) 173 if (!r)
174 regulatory_hint(hw->wiphy, alpha2, NULL); 174 regulatory_hint(hw->wiphy, alpha2);
175 175
176 r = 0; 176 r = 0;
177disable_int: 177disable_int:
@@ -296,15 +296,14 @@ static void zd_op_stop(struct ieee80211_hw *hw)
296 * If no status information has been requested, the skb is freed. 296 * If no status information has been requested, the skb is freed.
297 */ 297 */
298static void tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, 298static void tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
299 u32 flags, int ackssi, bool success) 299 int ackssi, bool success)
300{ 300{
301 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 301 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
302 302
303 memset(&info->status, 0, sizeof(info->status)); 303 ieee80211_tx_info_clear_status(info);
304 304
305 if (!success) 305 if (success)
306 info->status.excessive_retries = 1; 306 info->flags |= IEEE80211_TX_STAT_ACK;
307 info->flags |= flags;
308 info->status.ack_signal = ackssi; 307 info->status.ack_signal = ackssi;
309 ieee80211_tx_status_irqsafe(hw, skb); 308 ieee80211_tx_status_irqsafe(hw, skb);
310} 309}
@@ -326,7 +325,7 @@ void zd_mac_tx_failed(struct ieee80211_hw *hw)
326 if (skb == NULL) 325 if (skb == NULL)
327 return; 326 return;
328 327
329 tx_status(hw, skb, 0, 0, 0); 328 tx_status(hw, skb, 0, 0);
330} 329}
331 330
332/** 331/**
@@ -342,12 +341,12 @@ void zd_mac_tx_failed(struct ieee80211_hw *hw)
342void zd_mac_tx_to_dev(struct sk_buff *skb, int error) 341void zd_mac_tx_to_dev(struct sk_buff *skb, int error)
343{ 342{
344 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 343 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
345 struct ieee80211_hw *hw = info->driver_data[0]; 344 struct ieee80211_hw *hw = info->rate_driver_data[0];
346 345
347 skb_pull(skb, sizeof(struct zd_ctrlset)); 346 skb_pull(skb, sizeof(struct zd_ctrlset));
348 if (unlikely(error || 347 if (unlikely(error ||
349 (info->flags & IEEE80211_TX_CTL_NO_ACK))) { 348 (info->flags & IEEE80211_TX_CTL_NO_ACK))) {
350 tx_status(hw, skb, 0, 0, !error); 349 tx_status(hw, skb, 0, !error);
351 } else { 350 } else {
352 struct sk_buff_head *q = 351 struct sk_buff_head *q =
353 &zd_hw_mac(hw)->ack_wait_queue; 352 &zd_hw_mac(hw)->ack_wait_queue;
@@ -406,7 +405,8 @@ static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length)
406} 405}
407 406
408static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, 407static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
409 struct ieee80211_hdr *header, u32 flags) 408 struct ieee80211_hdr *header,
409 struct ieee80211_tx_info *info)
410{ 410{
411 /* 411 /*
412 * CONTROL TODO: 412 * CONTROL TODO:
@@ -417,7 +417,7 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
417 cs->control = 0; 417 cs->control = 0;
418 418
419 /* First fragment */ 419 /* First fragment */
420 if (flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) 420 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
421 cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; 421 cs->control |= ZD_CS_NEED_RANDOM_BACKOFF;
422 422
423 /* Multicast */ 423 /* Multicast */
@@ -428,10 +428,10 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
428 if (ieee80211_is_pspoll(header->frame_control)) 428 if (ieee80211_is_pspoll(header->frame_control))
429 cs->control |= ZD_CS_PS_POLL_FRAME; 429 cs->control |= ZD_CS_PS_POLL_FRAME;
430 430
431 if (flags & IEEE80211_TX_CTL_USE_RTS_CTS) 431 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
432 cs->control |= ZD_CS_RTS; 432 cs->control |= ZD_CS_RTS;
433 433
434 if (flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) 434 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
435 cs->control |= ZD_CS_SELF_CTS; 435 cs->control |= ZD_CS_SELF_CTS;
436 436
437 /* FIXME: Management frame? */ 437 /* FIXME: Management frame? */
@@ -517,12 +517,12 @@ static int fill_ctrlset(struct zd_mac *mac,
517 txrate = ieee80211_get_tx_rate(mac->hw, info); 517 txrate = ieee80211_get_tx_rate(mac->hw, info);
518 518
519 cs->modulation = txrate->hw_value; 519 cs->modulation = txrate->hw_value;
520 if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE) 520 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
521 cs->modulation = txrate->hw_value_short; 521 cs->modulation = txrate->hw_value_short;
522 522
523 cs->tx_length = cpu_to_le16(frag_len); 523 cs->tx_length = cpu_to_le16(frag_len);
524 524
525 cs_set_control(mac, cs, hdr, info->flags); 525 cs_set_control(mac, cs, hdr, info);
526 526
527 packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; 527 packet_length = frag_len + sizeof(struct zd_ctrlset) + 10;
528 ZD_ASSERT(packet_length <= 0xffff); 528 ZD_ASSERT(packet_length <= 0xffff);
@@ -577,7 +577,7 @@ static int zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
577 if (r) 577 if (r)
578 return r; 578 return r;
579 579
580 info->driver_data[0] = hw; 580 info->rate_driver_data[0] = hw;
581 581
582 r = zd_usb_tx(&mac->chip.usb, skb); 582 r = zd_usb_tx(&mac->chip.usb, skb);
583 if (r) 583 if (r)
@@ -618,7 +618,7 @@ static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr,
618 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1))) 618 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1)))
619 { 619 {
620 __skb_unlink(skb, q); 620 __skb_unlink(skb, q);
621 tx_status(hw, skb, IEEE80211_TX_STAT_ACK, stats->signal, 1); 621 tx_status(hw, skb, stats->signal, 1);
622 goto out; 622 goto out;
623 } 623 }
624 } 624 }
@@ -743,9 +743,11 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw,
743 zd_write_mac_addr(&mac->chip, NULL); 743 zd_write_mac_addr(&mac->chip, NULL);
744} 744}
745 745
746static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 746static int zd_op_config(struct ieee80211_hw *hw, u32 changed)
747{ 747{
748 struct zd_mac *mac = zd_hw_mac(hw); 748 struct zd_mac *mac = zd_hw_mac(hw);
749 struct ieee80211_conf *conf = &hw->conf;
750
749 return zd_chip_set_channel(&mac->chip, conf->channel->hw_value); 751 return zd_chip_set_channel(&mac->chip, conf->channel->hw_value);
750} 752}
751 753
@@ -852,14 +854,12 @@ static void zd_op_configure_filter(struct ieee80211_hw *hw,
852 if (*new_flags & (FIF_PROMISC_IN_BSS | FIF_ALLMULTI)) { 854 if (*new_flags & (FIF_PROMISC_IN_BSS | FIF_ALLMULTI)) {
853 zd_mc_add_all(&hash); 855 zd_mc_add_all(&hash);
854 } else { 856 } else {
855 DECLARE_MAC_BUF(macbuf);
856
857 zd_mc_clear(&hash); 857 zd_mc_clear(&hash);
858 for (i = 0; i < mc_count; i++) { 858 for (i = 0; i < mc_count; i++) {
859 if (!mclist) 859 if (!mclist)
860 break; 860 break;
861 dev_dbg_f(zd_mac_dev(mac), "mc addr %s\n", 861 dev_dbg_f(zd_mac_dev(mac), "mc addr %pM\n",
862 print_mac(macbuf, mclist->dmi_addr)); 862 mclist->dmi_addr);
863 zd_mc_add_addr(&hash, mclist->dmi_addr); 863 zd_mc_add_addr(&hash, mclist->dmi_addr);
864 mclist = mclist->next; 864 mclist = mclist->next;
865 } 865 }
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index a3ccd8c1c716..04c139666965 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -909,7 +909,7 @@ free_urb:
909 * it might be freed by zd_mac_tx_to_dev or mac80211) 909 * it might be freed by zd_mac_tx_to_dev or mac80211)
910 */ 910 */
911 info = IEEE80211_SKB_CB(skb); 911 info = IEEE80211_SKB_CB(skb);
912 usb = &zd_hw_mac(info->driver_data[0])->chip.usb; 912 usb = &zd_hw_mac(info->rate_driver_data[0])->chip.usb;
913 zd_mac_tx_to_dev(skb, urb->status); 913 zd_mac_tx_to_dev(skb, urb->status);
914 free_tx_urb(usb, urb); 914 free_tx_urb(usb, urb);
915 tx_dec_submitted_urbs(usb); 915 tx_dec_submitted_urbs(usb);
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index c6948d8f53f6..4b21bcf4af99 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -841,7 +841,6 @@ static int handle_incoming_queue(struct net_device *dev,
841 841
842 /* Pass it up. */ 842 /* Pass it up. */
843 netif_receive_skb(skb); 843 netif_receive_skb(skb);
844 dev->last_rx = jiffies;
845 } 844 }
846 845
847 return packets_dropped; 846 return packets_dropped;
diff --git a/drivers/net/xtsonic.c b/drivers/net/xtsonic.c
index da42aa06a3ba..03a3f34e9039 100644
--- a/drivers/net/xtsonic.c
+++ b/drivers/net/xtsonic.c
@@ -239,8 +239,6 @@ int __init xtsonic_probe(struct platform_device *pdev)
239 struct resource *resmem, *resirq; 239 struct resource *resmem, *resirq;
240 int err = 0; 240 int err = 0;
241 241
242 DECLARE_MAC_BUF(mac);
243
244 if ((resmem = platform_get_resource(pdev, IORESOURCE_MEM, 0)) == NULL) 242 if ((resmem = platform_get_resource(pdev, IORESOURCE_MEM, 0)) == NULL)
245 return -ENODEV; 243 return -ENODEV;
246 244
@@ -263,8 +261,8 @@ int __init xtsonic_probe(struct platform_device *pdev)
263 if ((err = register_netdev(dev))) 261 if ((err = register_netdev(dev)))
264 goto out1; 262 goto out1;
265 263
266 printk("%s: SONIC ethernet @%08lx, MAC %s, IRQ %d\n", dev->name, 264 printk("%s: SONIC ethernet @%08lx, MAC %pM, IRQ %d\n", dev->name,
267 dev->base_addr, print_mac(mac, dev->dev_addr), dev->irq); 265 dev->base_addr, dev->dev_addr, dev->irq);
268 266
269 return 0; 267 return 0;
270 268
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index 57e1f495b9fc..d8dbc57f3e56 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -374,7 +374,6 @@ static int __devinit yellowfin_init_one(struct pci_dev *pdev,
374#else 374#else
375 int bar = 1; 375 int bar = 1;
376#endif 376#endif
377 DECLARE_MAC_BUF(mac);
378 377
379/* when built into the kernel, we only print version if device is found */ 378/* when built into the kernel, we only print version if device is found */
380#ifndef MODULE 379#ifndef MODULE
@@ -481,10 +480,10 @@ static int __devinit yellowfin_init_one(struct pci_dev *pdev,
481 if (i) 480 if (i)
482 goto err_out_unmap_status; 481 goto err_out_unmap_status;
483 482
484 printk(KERN_INFO "%s: %s type %8x at %p, %s, IRQ %d.\n", 483 printk(KERN_INFO "%s: %s type %8x at %p, %pM, IRQ %d.\n",
485 dev->name, pci_id_tbl[chip_idx].name, 484 dev->name, pci_id_tbl[chip_idx].name,
486 ioread32(ioaddr + ChipRev), ioaddr, 485 ioread32(ioaddr + ChipRev), ioaddr,
487 print_mac(mac, dev->dev_addr), irq); 486 dev->dev_addr, irq);
488 487
489 if (np->drv_flags & HasMII) { 488 if (np->drv_flags & HasMII) {
490 int phy, phy_idx = 0; 489 int phy, phy_idx = 0;
@@ -1100,11 +1099,9 @@ static int yellowfin_rx(struct net_device *dev)
1100 memcmp(le32_to_cpu(yp->rx_ring_dma + 1099 memcmp(le32_to_cpu(yp->rx_ring_dma +
1101 entry*sizeof(struct yellowfin_desc)), 1100 entry*sizeof(struct yellowfin_desc)),
1102 "\377\377\377\377\377\377", 6) != 0) { 1101 "\377\377\377\377\377\377", 6) != 0) {
1103 if (bogus_rx++ == 0) { 1102 if (bogus_rx++ == 0)
1104 DECLARE_MAC_BUF(mac); 1103 printk(KERN_WARNING "%s: Bad frame to %pM\n",
1105 printk(KERN_WARNING "%s: Bad frame to %s\n", 1104 dev->name, buf_addr);
1106 dev->name, print_mac(mac, buf_addr));
1107 }
1108#endif 1105#endif
1109 } else { 1106 } else {
1110 struct sk_buff *skb; 1107 struct sk_buff *skb;
@@ -1141,7 +1138,6 @@ static int yellowfin_rx(struct net_device *dev)
1141 } 1138 }
1142 skb->protocol = eth_type_trans(skb, dev); 1139 skb->protocol = eth_type_trans(skb, dev);
1143 netif_rx(skb); 1140 netif_rx(skb);
1144 dev->last_rx = jiffies;
1145 dev->stats.rx_packets++; 1141 dev->stats.rx_packets++;
1146 dev->stats.rx_bytes += pkt_len; 1142 dev->stats.rx_bytes += pkt_len;
1147 } 1143 }
diff --git a/drivers/net/znet.c b/drivers/net/znet.c
index a86c022d6a94..f0b15c9347d0 100644
--- a/drivers/net/znet.c
+++ b/drivers/net/znet.c
@@ -167,7 +167,7 @@ static void znet_tx_timeout (struct net_device *dev);
167/* Request needed resources */ 167/* Request needed resources */
168static int znet_request_resources (struct net_device *dev) 168static int znet_request_resources (struct net_device *dev)
169{ 169{
170 struct znet_private *znet = dev->priv; 170 struct znet_private *znet = netdev_priv(dev);
171 unsigned long flags; 171 unsigned long flags;
172 172
173 if (request_irq (dev->irq, &znet_interrupt, 0, "ZNet", dev)) 173 if (request_irq (dev->irq, &znet_interrupt, 0, "ZNet", dev))
@@ -201,7 +201,7 @@ static int znet_request_resources (struct net_device *dev)
201 201
202static void znet_release_resources (struct net_device *dev) 202static void znet_release_resources (struct net_device *dev)
203{ 203{
204 struct znet_private *znet = dev->priv; 204 struct znet_private *znet = netdev_priv(dev);
205 unsigned long flags; 205 unsigned long flags;
206 206
207 release_region (znet->sia_base, znet->sia_size); 207 release_region (znet->sia_base, znet->sia_size);
@@ -216,7 +216,7 @@ static void znet_release_resources (struct net_device *dev)
216/* Keep the magical SIA stuff in a single function... */ 216/* Keep the magical SIA stuff in a single function... */
217static void znet_transceiver_power (struct net_device *dev, int on) 217static void znet_transceiver_power (struct net_device *dev, int on)
218{ 218{
219 struct znet_private *znet = dev->priv; 219 struct znet_private *znet = netdev_priv(dev);
220 unsigned char v; 220 unsigned char v;
221 221
222 /* Turn on/off the 82501 SIA, using zenith-specific magic. */ 222 /* Turn on/off the 82501 SIA, using zenith-specific magic. */
@@ -235,7 +235,7 @@ static void znet_transceiver_power (struct net_device *dev, int on)
235 Also used from hardware_init. */ 235 Also used from hardware_init. */
236static void znet_set_multicast_list (struct net_device *dev) 236static void znet_set_multicast_list (struct net_device *dev)
237{ 237{
238 struct znet_private *znet = dev->priv; 238 struct znet_private *znet = netdev_priv(dev);
239 short ioaddr = dev->base_addr; 239 short ioaddr = dev->base_addr;
240 struct i82593_conf_block *cfblk = &znet->i593_init; 240 struct i82593_conf_block *cfblk = &znet->i593_init;
241 241
@@ -370,7 +370,6 @@ static int __init znet_probe (void)
370 struct net_device *dev; 370 struct net_device *dev;
371 char *p; 371 char *p;
372 int err = -ENOMEM; 372 int err = -ENOMEM;
373 DECLARE_MAC_BUF(mac);
374 373
375 /* This code scans the region 0xf0000 to 0xfffff for a "NETIDBLK". */ 374 /* This code scans the region 0xf0000 to 0xfffff for a "NETIDBLK". */
376 for(p = (char *)phys_to_virt(0xf0000); p < (char *)phys_to_virt(0x100000); p++) 375 for(p = (char *)phys_to_virt(0xf0000); p < (char *)phys_to_virt(0x100000); p++)
@@ -387,7 +386,7 @@ static int __init znet_probe (void)
387 if (!dev) 386 if (!dev)
388 return -ENOMEM; 387 return -ENOMEM;
389 388
390 znet = dev->priv; 389 znet = netdev_priv(dev);
391 390
392 netinfo = (struct netidblk *)p; 391 netinfo = (struct netidblk *)p;
393 dev->base_addr = netinfo->iobase1; 392 dev->base_addr = netinfo->iobase1;
@@ -397,9 +396,9 @@ static int __init znet_probe (void)
397 for (i = 0; i < 6; i++) 396 for (i = 0; i < 6; i++)
398 dev->dev_addr[i] = netinfo->netid[i]; 397 dev->dev_addr[i] = netinfo->netid[i];
399 398
400 printk(KERN_INFO "%s: ZNET at %#3lx, %s" 399 printk(KERN_INFO "%s: ZNET at %#3lx, %pM"
401 ", using IRQ %d DMA %d and %d.\n", 400 ", using IRQ %d DMA %d and %d.\n",
402 dev->name, dev->base_addr, print_mac(mac, dev->dev_addr), 401 dev->name, dev->base_addr, dev->dev_addr,
403 dev->irq, netinfo->dma1, netinfo->dma2); 402 dev->irq, netinfo->dma1, netinfo->dma2);
404 403
405 if (znet_debug > 1) { 404 if (znet_debug > 1) {
@@ -531,7 +530,7 @@ static void znet_tx_timeout (struct net_device *dev)
531static int znet_send_packet(struct sk_buff *skb, struct net_device *dev) 530static int znet_send_packet(struct sk_buff *skb, struct net_device *dev)
532{ 531{
533 int ioaddr = dev->base_addr; 532 int ioaddr = dev->base_addr;
534 struct znet_private *znet = dev->priv; 533 struct znet_private *znet = netdev_priv(dev);
535 unsigned long flags; 534 unsigned long flags;
536 short length = skb->len; 535 short length = skb->len;
537 536
@@ -601,7 +600,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev)
601static irqreturn_t znet_interrupt(int irq, void *dev_id) 600static irqreturn_t znet_interrupt(int irq, void *dev_id)
602{ 601{
603 struct net_device *dev = dev_id; 602 struct net_device *dev = dev_id;
604 struct znet_private *znet = dev->priv; 603 struct znet_private *znet = netdev_priv(dev);
605 int ioaddr; 604 int ioaddr;
606 int boguscnt = 20; 605 int boguscnt = 20;
607 int handled = 0; 606 int handled = 0;
@@ -679,7 +678,7 @@ static irqreturn_t znet_interrupt(int irq, void *dev_id)
679 678
680static void znet_rx(struct net_device *dev) 679static void znet_rx(struct net_device *dev)
681{ 680{
682 struct znet_private *znet = dev->priv; 681 struct znet_private *znet = netdev_priv(dev);
683 int ioaddr = dev->base_addr; 682 int ioaddr = dev->base_addr;
684 int boguscount = 1; 683 int boguscount = 1;
685 short next_frame_end_offset = 0; /* Offset of next frame start. */ 684 short next_frame_end_offset = 0; /* Offset of next frame start. */
@@ -786,7 +785,6 @@ static void znet_rx(struct net_device *dev)
786 } 785 }
787 skb->protocol=eth_type_trans(skb,dev); 786 skb->protocol=eth_type_trans(skb,dev);
788 netif_rx(skb); 787 netif_rx(skb);
789 dev->last_rx = jiffies;
790 dev->stats.rx_packets++; 788 dev->stats.rx_packets++;
791 dev->stats.rx_bytes += pkt_len; 789 dev->stats.rx_bytes += pkt_len;
792 } 790 }
@@ -829,7 +827,7 @@ static void show_dma(struct net_device *dev)
829{ 827{
830 short ioaddr = dev->base_addr; 828 short ioaddr = dev->base_addr;
831 unsigned char stat = inb (ioaddr); 829 unsigned char stat = inb (ioaddr);
832 struct znet_private *znet = dev->priv; 830 struct znet_private *znet = netdev_priv(dev);
833 unsigned long flags; 831 unsigned long flags;
834 short dma_port = ((znet->tx_dma&3)<<2) + IO_DMA2_BASE; 832 short dma_port = ((znet->tx_dma&3)<<2) + IO_DMA2_BASE;
835 unsigned addr = inb(dma_port); 833 unsigned addr = inb(dma_port);
@@ -852,7 +850,7 @@ static void hardware_init(struct net_device *dev)
852{ 850{
853 unsigned long flags; 851 unsigned long flags;
854 short ioaddr = dev->base_addr; 852 short ioaddr = dev->base_addr;
855 struct znet_private *znet = dev->priv; 853 struct znet_private *znet = netdev_priv(dev);
856 854
857 znet->rx_cur = znet->rx_start; 855 znet->rx_cur = znet->rx_start;
858 znet->tx_cur = znet->tx_start; 856 znet->tx_cur = znet->tx_start;
@@ -914,7 +912,7 @@ static void update_stop_hit(short ioaddr, unsigned short rx_stop_offset)
914static __exit void znet_cleanup (void) 912static __exit void znet_cleanup (void)
915{ 913{
916 if (znet_dev) { 914 if (znet_dev) {
917 struct znet_private *znet = znet_dev->priv; 915 struct znet_private *znet = netdev_priv(znet_dev);
918 916
919 unregister_netdev (znet_dev); 917 unregister_netdev (znet_dev);
920 kfree (znet->rx_start); 918 kfree (znet->rx_start);
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index 3926b2aa9cca..9c73df4a0d30 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -151,7 +151,6 @@ static int __devinit zorro8390_init(struct net_device *dev,
151 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 151 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
152 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 152 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
153 }; 153 };
154 DECLARE_MAC_BUF(mac);
155 154
156 /* Reset card. Who knows what dain-bramaged state it was left in. */ 155 /* Reset card. Who knows what dain-bramaged state it was left in. */
157 { 156 {
@@ -216,7 +215,7 @@ static int __devinit zorro8390_init(struct net_device *dev,
216 dev->dev_addr[i] = SA_prom[i]; 215 dev->dev_addr[i] = SA_prom[i];
217 216
218#ifdef DEBUG 217#ifdef DEBUG
219 printk("%s", print_mac(mac, dev->dev_addr)); 218 printk("%pM", dev->dev_addr);
220#endif 219#endif
221 220
222 ei_status.name = name; 221 ei_status.name = name;
@@ -244,8 +243,8 @@ static int __devinit zorro8390_init(struct net_device *dev,
244 return err; 243 return err;
245 } 244 }
246 245
247 printk(KERN_INFO "%s: %s at 0x%08lx, Ethernet Address %s\n", 246 printk(KERN_INFO "%s: %s at 0x%08lx, Ethernet Address %pM\n",
248 dev->name, name, board, print_mac(mac, dev->dev_addr)); 247 dev->name, name, board, dev->dev_addr);
249 248
250 return 0; 249 return 0;
251} 250}
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 1b1e80336d2c..8a8fad7a8bea 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -131,17 +131,13 @@ static int qeth_l2_send_setgroupmac_cb(struct qeth_card *card,
131 mac = &cmd->data.setdelmac.mac[0]; 131 mac = &cmd->data.setdelmac.mac[0];
132 /* MAC already registered, needed in couple/uncouple case */ 132 /* MAC already registered, needed in couple/uncouple case */
133 if (cmd->hdr.return_code == 0x2005) { 133 if (cmd->hdr.return_code == 0x2005) {
134 QETH_DBF_MESSAGE(2, "Group MAC %02x:%02x:%02x:%02x:%02x:%02x " 134 QETH_DBF_MESSAGE(2, "Group MAC %pM already existing on %s \n",
135 "already existing on %s \n", 135 mac, QETH_CARD_IFNAME(card));
136 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
137 QETH_CARD_IFNAME(card));
138 cmd->hdr.return_code = 0; 136 cmd->hdr.return_code = 0;
139 } 137 }
140 if (cmd->hdr.return_code) 138 if (cmd->hdr.return_code)
141 QETH_DBF_MESSAGE(2, "Could not set group MAC " 139 QETH_DBF_MESSAGE(2, "Could not set group MAC %pM on %s: %x\n",
142 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n", 140 mac, QETH_CARD_IFNAME(card), cmd->hdr.return_code);
143 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
144 QETH_CARD_IFNAME(card), cmd->hdr.return_code);
145 return 0; 141 return 0;
146} 142}
147 143
@@ -163,10 +159,8 @@ static int qeth_l2_send_delgroupmac_cb(struct qeth_card *card,
163 cmd = (struct qeth_ipa_cmd *) data; 159 cmd = (struct qeth_ipa_cmd *) data;
164 mac = &cmd->data.setdelmac.mac[0]; 160 mac = &cmd->data.setdelmac.mac[0];
165 if (cmd->hdr.return_code) 161 if (cmd->hdr.return_code)
166 QETH_DBF_MESSAGE(2, "Could not delete group MAC " 162 QETH_DBF_MESSAGE(2, "Could not delete group MAC %pM on %s: %x\n",
167 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n", 163 mac, QETH_CARD_IFNAME(card), cmd->hdr.return_code);
168 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
169 QETH_CARD_IFNAME(card), cmd->hdr.return_code);
170 return 0; 164 return 0;
171} 165}
172 166
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index ed6c54cae7b1..e11bce6ab63c 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -1601,14 +1601,14 @@ static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
1601 case AF_INET: 1601 case AF_INET:
1602 sin = (struct sockaddr_in *)addr; 1602 sin = (struct sockaddr_in *)addr;
1603 spin_lock_bh(&conn->session->lock); 1603 spin_lock_bh(&conn->session->lock);
1604 sprintf(buf, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr)); 1604 sprintf(buf, "%pI4", &sin->sin_addr.s_addr);
1605 *port = be16_to_cpu(sin->sin_port); 1605 *port = be16_to_cpu(sin->sin_port);
1606 spin_unlock_bh(&conn->session->lock); 1606 spin_unlock_bh(&conn->session->lock);
1607 break; 1607 break;
1608 case AF_INET6: 1608 case AF_INET6:
1609 sin6 = (struct sockaddr_in6 *)addr; 1609 sin6 = (struct sockaddr_in6 *)addr;
1610 spin_lock_bh(&conn->session->lock); 1610 spin_lock_bh(&conn->session->lock);
1611 sprintf(buf, NIP6_FMT, NIP6(sin6->sin6_addr)); 1611 sprintf(buf, "%pI6", &sin6->sin6_addr);
1612 *port = be16_to_cpu(sin6->sin6_port); 1612 *port = be16_to_cpu(sin6->sin6_port);
1613 spin_unlock_bh(&conn->session->lock); 1613 spin_unlock_bh(&conn->session->lock);
1614 break; 1614 break;
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index db7ea3bb4e83..eb3a414b189a 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -206,8 +206,7 @@ static int qla4xxx_conn_get_param(struct iscsi_cls_conn *conn,
206 break; 206 break;
207 case ISCSI_PARAM_CONN_ADDRESS: 207 case ISCSI_PARAM_CONN_ADDRESS:
208 /* TODO: what are the ipv6 bits */ 208 /* TODO: what are the ipv6 bits */
209 len = sprintf(buf, "%u.%u.%u.%u\n", 209 len = sprintf(buf, "%pI4\n", &ddb_entry->ip_addr);
210 NIPQUAD(ddb_entry->ip_addr));
211 break; 210 break;
212 default: 211 default:
213 return -ENOSYS; 212 return -ENOSYS;
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 9aea43a8c4ad..5ed4ae07bac1 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -286,9 +286,7 @@ static ssize_t cxacru_sysfs_show_mac_address(struct device *dev,
286 struct usbatm_data *usbatm_instance = usb_get_intfdata(intf); 286 struct usbatm_data *usbatm_instance = usb_get_intfdata(intf);
287 struct atm_dev *atm_dev = usbatm_instance->atm_dev; 287 struct atm_dev *atm_dev = usbatm_instance->atm_dev;
288 288
289 return snprintf(buf, PAGE_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x\n", 289 return snprintf(buf, PAGE_SIZE, "%pM\n", atm_dev->esi);
290 atm_dev->esi[0], atm_dev->esi[1], atm_dev->esi[2],
291 atm_dev->esi[3], atm_dev->esi[4], atm_dev->esi[5]);
292} 290}
293 291
294static ssize_t cxacru_sysfs_show_adsl_state(struct device *dev, 292static ssize_t cxacru_sysfs_show_adsl_state(struct device *dev,
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 06dd114910d4..fbea8563df1e 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -770,10 +770,7 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
770 return sprintf(page, "%s\n", instance->description); 770 return sprintf(page, "%s\n", instance->description);
771 771
772 if (!left--) 772 if (!left--)
773 return sprintf(page, "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", 773 return sprintf(page, "MAC: %pM\n", atm_dev->esi);
774 atm_dev->esi[0], atm_dev->esi[1],
775 atm_dev->esi[2], atm_dev->esi[3],
776 atm_dev->esi[4], atm_dev->esi[5]);
777 774
778 if (!left--) 775 if (!left--)
779 return sprintf(page, 776 return sprintf(page,
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 66948b72bb9b..00fa5239879d 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -787,10 +787,8 @@ int __init gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
787 dev_dbg(&g->dev, "register_netdev failed, %d\n", status); 787 dev_dbg(&g->dev, "register_netdev failed, %d\n", status);
788 free_netdev(net); 788 free_netdev(net);
789 } else { 789 } else {
790 DECLARE_MAC_BUF(tmp); 790 INFO(dev, "MAC %pM\n", net->dev_addr);
791 791 INFO(dev, "HOST MAC %pM\n", dev->host_mac);
792 INFO(dev, "MAC %s\n", print_mac(tmp, net->dev_addr));
793 INFO(dev, "HOST MAC %s\n", print_mac(tmp, dev->host_mac));
794 792
795 the_dev = dev; 793 the_dev = dev;
796 } 794 }
diff --git a/drivers/uwb/wlp/eda.c b/drivers/uwb/wlp/eda.c
index cdfe8dfc4340..10985fa233cc 100644
--- a/drivers/uwb/wlp/eda.c
+++ b/drivers/uwb/wlp/eda.c
@@ -313,12 +313,9 @@ int wlp_eda_for_virtual(struct wlp_eda *eda,
313 list_for_each_entry(itr, &eda->cache, list_node) { 313 list_for_each_entry(itr, &eda->cache, list_node) {
314 if (!memcmp(itr->virt_addr, virt_addr, 314 if (!memcmp(itr->virt_addr, virt_addr,
315 sizeof(itr->virt_addr))) { 315 sizeof(itr->virt_addr))) {
316 d_printf(6, dev, "EDA: looking for " 316 d_printf(6, dev, "EDA: looking for %pM hit %02x:%02x "
317 "%02x:%02x:%02x:%02x:%02x:%02x hit %02x:%02x "
318 "wss %p tag 0x%02x state %u\n", 317 "wss %p tag 0x%02x state %u\n",
319 virt_addr[0], virt_addr[1], 318 virt_addr,
320 virt_addr[2], virt_addr[3],
321 virt_addr[4], virt_addr[5],
322 itr->dev_addr.data[1], 319 itr->dev_addr.data[1],
323 itr->dev_addr.data[0], itr->wss, 320 itr->dev_addr.data[0], itr->wss,
324 itr->tag, itr->state); 321 itr->tag, itr->state);
@@ -327,24 +324,13 @@ int wlp_eda_for_virtual(struct wlp_eda *eda,
327 found = 1; 324 found = 1;
328 break; 325 break;
329 } else 326 } else
330 d_printf(6, dev, "EDA: looking for " 327 d_printf(6, dev, "EDA: looking for %pM against %pM miss\n",
331 "%02x:%02x:%02x:%02x:%02x:%02x " 328 virt_addr, itr->virt_addr);
332 "against "
333 "%02x:%02x:%02x:%02x:%02x:%02x miss\n",
334 virt_addr[0], virt_addr[1],
335 virt_addr[2], virt_addr[3],
336 virt_addr[4], virt_addr[5],
337 itr->virt_addr[0], itr->virt_addr[1],
338 itr->virt_addr[2], itr->virt_addr[3],
339 itr->virt_addr[4], itr->virt_addr[5]);
340 } 329 }
341 if (!found) { 330 if (!found) {
342 if (printk_ratelimit()) 331 if (printk_ratelimit())
343 dev_err(dev, "EDA: Eth addr %02x:%02x:%02x" 332 dev_err(dev, "EDA: Eth addr %pM not found.\n",
344 ":%02x:%02x:%02x not found.\n", 333 virt_addr);
345 virt_addr[0], virt_addr[1],
346 virt_addr[2], virt_addr[3],
347 virt_addr[4], virt_addr[5]);
348 result = -ENODEV; 334 result = -ENODEV;
349 } 335 }
350 spin_unlock_irqrestore(&eda->lock, flags); 336 spin_unlock_irqrestore(&eda->lock, flags);
@@ -380,19 +366,13 @@ ssize_t wlp_eda_show(struct wlp *wlp, char *buf)
380 "tag state virt_addr\n"); 366 "tag state virt_addr\n");
381 list_for_each_entry(entry, &eda->cache, list_node) { 367 list_for_each_entry(entry, &eda->cache, list_node) {
382 result += scnprintf(buf + result, PAGE_SIZE - result, 368 result += scnprintf(buf + result, PAGE_SIZE - result,
383 "%02x:%02x:%02x:%02x:%02x:%02x %02x:%02x " 369 "%pM %02x:%02x %p 0x%02x %s %pM\n",
384 "%p 0x%02x %s " 370 entry->eth_addr,
385 "%02x:%02x:%02x:%02x:%02x:%02x\n",
386 entry->eth_addr[0], entry->eth_addr[1],
387 entry->eth_addr[2], entry->eth_addr[3],
388 entry->eth_addr[4], entry->eth_addr[5],
389 entry->dev_addr.data[1], 371 entry->dev_addr.data[1],
390 entry->dev_addr.data[0], entry->wss, 372 entry->dev_addr.data[0], entry->wss,
391 entry->tag, 373 entry->tag,
392 wlp_wss_connect_state_str(entry->state), 374 wlp_wss_connect_state_str(entry->state),
393 entry->virt_addr[0], entry->virt_addr[1], 375 entry->virt_addr);
394 entry->virt_addr[2], entry->virt_addr[3],
395 entry->virt_addr[4], entry->virt_addr[5]);
396 if (result >= PAGE_SIZE) 376 if (result >= PAGE_SIZE)
397 break; 377 break;
398 } 378 }